1/* $Id:composer.js 2017-01-12 00:00:00 SocialEngineSolutions $*/ 2 3var activityDesignOne = false; 4(function() { // START NAMESPACE 5 6Composer = function(element, options){ 7 8 this.elements = {}; 9 10 this.plugins = {}; 11 12 this.options = { 13 lang : {}, 14 overText : true, 15 allowEmptyWithoutAttachment : false, 16 allowEmptyWithAttachment : true, 17 hideSubmitOnBlur : false, 18 submitElement : false, 19 useContentEditable : true 20 }; 21 22 this.initialize = function(element, options) { 23 this.options = scriptJquery.extend(this.options,options); 24 this.elements = new Hash(this.elements); 25 this.plugins = new Hash(this.plugins); 26 27 this.elements.textarea = scriptJquery("#"+element); 28 this.elements.textarea.data('Composer'); 29 30 this.attach(); 31 this.getTray(); 32 this.getMenu(); 33 34 this.pluginReady = false; 35 36 this.getForm().on('submit', function(e) { 37 var activatedPlugin = this.getActivePlugin(); 38 if(activatedPlugin) 39 var pluginName = activatedPlugin.getName(); 40 else 41 var pluginName = ''; 42 43 //feeling work 44 if(pluginName != 'buysell' && pluginName != 'quote' && pluginName != 'prayer' && pluginName != 'wishe' && pluginName != 'thought' && pluginName != 'text' && !scriptJquery('#image_id').val() && !scriptJquery('#reaction_id').val() && !scriptJquery('#tag_location').val() && !scriptJquery('#feeling_activity').val() && !scriptJquery('#feedbgid').val()){ 45 46 if(typeof musicfeedupload != 'undefined' && musicfeedupload) { 47 return; 48 } 49 if( this.pluginReady ) { 50 if( !this.options.allowEmptyWithAttachment && this.getContent() == '' ) { 51 e.preventDefault(); 52 scriptJquery('.activity_post_box').addClass('_blank'); 53 54 //scriptJquery('#activity-form').removeClass('feed_background_image'); 55 scriptJquery('.activity_post_box').css('background-image', 'none'); 56 return; 57 } 58 } else { 59 if( !this.options.allowEmptyWithoutAttachment && this.getContent() == '' ) { 60 e.preventDefault(); 61 scriptJquery('.activity_post_box').addClass('_blank'); 62 63 //scriptJquery('#activity-form').removeClass('feed_background_image'); 64 scriptJquery('.activity_post_box').css('background-image', 'none'); 65 return; 66 } 67 } 68 69 scriptJquery('.activity_post_box').removeClass('_blank'); 70 } 71 this.saveContent(); 72 }.bind(this)); 73 }; 74 this.updateComposer= function(e){ 75 scriptJquery("#activity_body").mentionsInput("update"); 76 }; 77 this.getMenu = function() { 78 if( !$type(this.elements.menu) ) { 79 80 try { 81 this.elements.menu = scriptJquery("#"+this.options.menuElement); 82 } catch(err){ console.log(err); } 83 if( !$type(this.elements.menu) ) { 84 this.elements.menu = scriptJquery.crtEle('div',{ 85 'id' : 'compose-menu', 86 'class' : 'compose-menu' 87 }).insertAfter(this.getForm()); 88 } 89 } 90 return this.elements.menu; 91 }; 92 93 this.getTray = function() { 94 if( !$type(this.elements.tray) ) { 95 try { 96 this.elements.tray = scriptJquery(this.options.trayElement); 97 } catch(err){ console.log(err); } 98 99 if( !$type(this.elements.tray) || !this.elements.tray.length ) { 100 this.elements.tray = scriptJquery.crtEle('div',{ 101 'id' : 'compose-tray', 102 'class' : 'compose-tray', 103 104 }).insertAfter('#composer-tray-container').hide(); 105 } 106 } 107 return this.elements.tray; 108 } 109 110 this.getInputArea = function() { 111 if( !$type(this.elements.inputarea) ) { 112 var form = this.elements.textarea.closest('form'); 113 this.elements.inputarea = scriptJquery.crtEle('div', { 114 'class':'fileupload-cnt', 115 }).css({ 116 'display' : 'none', 117 }).appendTo(form); 118 } 119 return this.elements.inputarea; 120 }; 121 122 this.getForm = function() { 123 return this.elements.textarea.closest('form'); 124 } 125 126 this.c= function(e){ 127 scriptJquery("#activity_body").mentionsInput("update"); 128 }; 129 130 // Editor 131 132 this.attach = function() { 133 134 // Modify textarea 135 this.elements.textarea.addClass('compose-textarea').css('display', 'none'); 136 137 // Create container 138 this.elements.container = scriptJquery.crtEle('div', { 139 'id' : 'compose-container', 140 'class' : 'compose-container', 141 142 }); 143 this.elements.textarea.wrap(this.elements.container); 144 145 146 // Create body 147 var supportsContentEditable = this._supportsContentEditable(); 148 149 if( supportsContentEditable ) { 150 this.elements.body = scriptJquery.crtEle('div', { 151 'class' : 'compose-content', 152 'styles' : { 153 'display' : 'block' 154 }, 155 'events' : { 156 'keypress' : function(event) { 157 if( event.key == 'a' && event.control ) { 158 // FF only 159 // if( Browser.Engine.gecko ) { 160 // fix_gecko_select_all_contenteditable_bug(this, event); 161 // } 162 } 163 } 164 } 165 }).insertBefore(this.elements.textarea); 166 } else { 167 this.elements.body = this.elements.textarea; 168 var parentThis = this; 169 scriptJquery(this.elements.body).bind('input', function(e) { 170 parentThis.checkPostLength(e); 171 }); 172 } 173 174 // Attach blur event 175 var self = this; 176 this.elements.body.on('blur', function(e) { 177 var curVal; 178 if( supportsContentEditable ) { 179 curVal = scriptJquery(this).html().replace(/\s/, '').replace(/<[^<>]+?>/ig, ''); 180 } else { 181 curVal = scriptJquery(this).html().replace(/\s/, '').replace(/<[^<>]+?>/ig, '') 182 } 183 if( '' == curVal ) { 184 if( supportsContentEditable ) { 185 scriptJquery(this).html('<br />'); 186 } else { 187 scriptJquery(this).html(''); 188 } 189 190 if( self.options.hideSubmitOnBlur ) { 191 (function() { 192 if( !self.hasActivePlugin() ) { 193 self.getMenu().css('display', 'none'); 194 } 195 }).delay(250); 196 } 197 } 198 }); 199 200 if( self.options.hideSubmitOnBlur ) { 201 this.getMenu().css('display', 'none'); 202 this.elements.body.addEvent('focus', function(e) { 203 self.getMenu().css('display', ''); 204 }); 205 } 206 207 if( supportsContentEditable ) { 208 this.elements.body.contentEditable = true; 209 this.elements.body.designMode = 'On'; 210 211 ['MouseUp', 'MouseDown', 'ContextMenu', 'Click', 'Dblclick', 'KeyPress', 'KeyUp', 'KeyDown','Paste'].each(function(eventName) { 212 var method = (this['editor' + eventName] || function(){}).bind(this); 213 this.elements.body.addEvent(eventName.toLowerCase(), method); 214 }.bind(this)); 215 216 this.setContent(this.elements.textarea.value); 217 218 this.selection = new Composer.Selection(this.elements.body); 219 } else { 220 this.elements.textarea.css('display', ''); 221 } 222 223 if( this.options.overText && supportsContentEditable ) { 224 new Composer.OverText(this.elements.body, $merge({ 225 textOverride : this._lang('Post Something...'), 226 poll : true, 227 isPlainText : !supportsContentEditable, 228 positionOptions: { 229 position: ( en4.orientation == 'rtl' ? 'upperRight' : 'upperLeft' ), 230 edge: ( en4.orientation == 'rtl' ? 'upperRight' : 'upperLeft' ), 231 offset: { 232 x: ( en4.orientation == 'rtl' ? -4 : 4 ), 233 y: 2 234 } 235 } 236 }, this.options.overTextOptions)); 237 } 238 239 if(typeof enabledShedulepost != "undefined" && enabledShedulepost){ 240 this.elements.schedule = scriptJquery.crtEle('span', { 241 'class' : 'composer_schedulepost_toggle activity_tooltip', 242 'href' : 'javascript:void(0);', 243 'id' : 'activity_shedulepost', 244 'title' : en4.core.language.translate("Schedule Post"), 245 }); 246 this.elements.schedule.appendTo(scriptJquery('#compose-menu')); 247 } 248 249 //this.fireEvent('attach', this); 250 251 252 isonCommentBox = false;
253 if(!scriptJquery('#activity_body').attr('id')) 254 scriptJquery('#activity_body').attr('id',new Date().getTime()); 255 256 var data = scriptJquery('#activity_body').val(); 257 //var data = composeInstance.getContent(); 258 259 if(!scriptJquery('#activity_body').val() || isOnEditField || scriptJquery('#hashtagtext').val()){ 260 if(!scriptJquery('#activity_body').val() ) 261 EditFieldValue = ''; 262 scriptJquery('#activity_body').mentionsInput({ 263 onDataRequest:function (mode, query, callback) { 264 scriptJquery.getJSON('activity/ajax/friends/query/'+query, function(responseData) { 265 responseData = _.filter(responseData, function(item) { return item.name.toLowerCase().indexOf(query.toLowerCase()) > -1 }); 266 callback.call('#activity_body', responseData); 267 }); 268 }, 269 //defaultValue: EditFieldValue, 270 onCaret: true 271 }); 272 } 273 274 if(data){ 275 getDataMentionEdit('#activity_body',data); 276 } 277 278 if(!scriptJquery('#activity_body').parent().hasClass('typehead')){ 279 scriptJquery('#activity_body').hashtags(); 280 } 281 setTimeout(function(){ scriptJquery('#activity_body').mentionsInput("update"); }, 1000); 282 283 try{ 284 AttachEventListerSE("click",".comment_emotion_container_inner .emoji_contents ul > li > a",this.updateComposer.bind(this)); 285 }catch(err){ 286 console.log(err); 287 } 288 }; 289 290 this.setCaretPos = function(pos) { 291 this.lastCaretPos = pos; 292 var index = 0, range = document.createRange(), body = this.elements.body[0]; 293 range.setStart(body, 0); 294 range.collapse(true); 295 var nodeArray = [body], node, isStart = false, stop = false; 296 297 while (!stop && (node = nodeArray.pop())) { 298 if (node.nodeType === 3) { 299 var nextIndex = index + node.length; 300 if (!isStart && pos >= index && pos <= nextIndex) { 301 range.setStart(node, pos - index); 302 isStart = true; 303 } else if (isStart && pos >= index && pos <= nextIndex) { 304 range.setEnd(node, pos - index); 305 stop = true; 306 } 307 index = nextIndex; 308 } else { 309 var i = node.childNodes.length; 310 while (i--) { 311 nodeArray.push(node.childNodes[i]); 312 } 313 } 314 } 315 var selection = window.getSelection(); 316 selection.removeAllRanges(); 317 selection.addRange(range); 318 319 } 320 this.checkPostLength = function(e) { 321 var content = this.getContent(); 322 content = content.replace(/ /g, ' '); 323 content = content.replace(/&/g, '&'); 324 content = content.replace(/</g, '<'); 325 content = content.replace(/>/g, '>'); 326 327 if(this.options.postLength && this.options.postLength < content.length){ 328 content = content.substr(0,this.options.postLength); 329 this.setContent(content); 330 this.setCaretPos(content.length); 331 } 332 if(this.options.postLength){ 333 scriptJquery(".compose-content-counter").css("display","inline-block"); 334 scriptJquery(".compose-content-counter").html(this.options.postLength-content.length); 335 return; 336 } 337 } 338 this.detach = function() { 339 this.saveContent(); 340 this.textarea.css('display', '').removeClass('compose-textarea').insertBefore(this.container); 341 this.container.dispose(); 342 //this.fireEvent('detach', this); 343 return this; 344 }; 345 346 this.focus = function(){ 347 // needs the delay to get focus working 348 (function(){ 349 this.elements.body.focus(); 350 //this.fireEvent('focus', this); 351 }).bind(this).delay(10); 352 return this; 353 }; 354 355 356 357 // Content 358 359 this.getContent = function(){ 360 return scriptJquery(this.elements.textarea).val(); 361 }; 362 363 this.setContent = function(newContent) { 364 //scriptJquery('#activity_body_emojis').val(newContent); 365 scriptJquery(this.elements.textarea).val(newContent); 366 this.checkPostLength(); 367 return this; 368 }; 369 370 371 this.saveContent = function(){ 372 if( this._supportsContentEditable() ) { 373 scriptJquery(this.elements.textarea).val( this.getContent()); 374 } 375 return this; 376 }; 377 378 this.cleanup = function(html) { 379 // @todo 380 return html 381 .replace(/<(br|p|div)[^<>]*?>/ig, "\r\n") 382 .replace(/<[^<>]+?>/ig, ' ') 383 .replace(/(\r\n?|\n){3,}/ig, "\n\n") 384 .trim(); 385 }; 386 387 388 389 // Plugins 390 391 this.addPlugin = function(plugin) { 392 var key = plugin.getName(); 393 this.plugins.set(key, plugin); 394 plugin.setComposer(this); 395 return this; 396 }; 397 398 this.addPlugins = function(plugins) { 399 plugins.each(function(plugin) { 400 this.addPlugin(plugin); 401 }.bind(this)); 402 }; 403 404 this.getPlugin = function(name) { 405 return this.plugins.get(name); 406 }; 407 408 this.activate = function(name) { 409 this.deactivate(); 410 this.getMenu().css(); 411 this.plugins.get(name).activate(); 412 }; 413 414 this.deactivate = function() { 415
416 Object.entries(this.plugins).forEach(function([key,plugin]) { 417 plugin.deactivate(); 418 scriptJquery('#compose-'+plugin.getName()+'-activator').parent().removeClass('active'); 419 }); 420 scriptJquery('#fancyalbumuploadfileids').val(''); 421 scriptJquery('#reaction_id').val(''); 422 scriptJquery('.fileupload-cnt').html(''); 423 this.getTray().empty(); 424 }; 425 426 this.signalPluginReady = function(state) { 427 this.pluginReady = state; 428 }; 429 this.getActivePlugin = function() { 430 431 var activeplugin = false; 432 Object.entries(this.plugins).forEach(function([key,plugin]) { 433 if(plugin.active) 434 activeplugin = plugin; 435 }); 436 return activeplugin; 437 }; 438 this.hasActivePlugin = function() { 439 var active = false; 440 Object.entries(this.plugins).forEach(function([key,plugin]) { 441 active = active || plugin.active; 442 }); 443 return active; 444 }; 445 446 447 448 // Key events 449 450 this.editorMouseUp = function(e){ 451 //this.fireEvent('editorMouseUp', e); 452 }; 453 454 this.editorMouseDown = function(e){ 455 //this.fireEvent('editorMouseDown', e); 456 }; 457 458 this.editorContextMenu = function(e){ 459 //this.fireEvent('editorContextMenu', e); 460 }; 461 462 this.editorClick = function(e){ 463 // make images selectable and draggable in Safari 464 // if (Browser.Engine.webkit){ 465 // var el = e.target; 466 // if (el.get('tag') == 'img'){ 467 // this.selection.selectNode(el); 468 // } 469 // } 470 471 //this.fireEvent('editorClick', e); 472 }; 473 474 this.editorDoubleClick = function(e){ 475 //this.fireEvent('editorDoubleClick', e); 476 }; 477 478 this.editorKeyPress = function(e){ 479 this.keyListener(e); 480 //this.fireEvent('editorKeyPress', e); 481 }; 482 483 this.editorKeyUp = function(e){ 484 //this.fireEvent('editorKeyUp', e); 485 setTimeout(function () { 486 linkDetection(); 487 }, 0); 488 var str = this.getContent(); 489 //scriptJquery(this).parent().parent().find(".highlighter").css("width",$(this).css("width")); 490 str = str.replace(/\n/g, '<br>'); 491 if(!str.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?#([a-zA-Z0-9]+)/g) && !str.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?@([a-zA-Z0-9]+)/g) && !str.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?#([\u0600-\u06FF]+)/g) && !str.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?@([\u0600-\u06FF]+)/g)) { 492 if(!str.match(/#(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))#/g)) { //arabic support 493 str = str.replace(/#(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))/g,'<span class="hashtag">#$1</span>'); 494 }else{ 495 str = str.replace(/#(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))#(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))/g,'<span class="hashtag">#$1</span>'); 496 } 497 if(!str.match(/@(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))@/g)) { 498 //str = str.replace(/@(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))/g,'<span class="hashtag">@$1</span>'); 499 }else{ 500 //str = str.replace(/@(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))@(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))/g,'<span class="hashtag">@$1</span>'); 501 } 502 } 503 this.setContent(str); 504 505 } 506 this.editorPaste = function(e) { 507 //this.fireEvent('editorPaste', e); 508 setTimeout(function () { 509 linkDetection(); 510 }, 0); 511 }; 512 this.editorKeyDown = function(e){ 513 //this.fireEvent('editorKeyDown', e); 514 }; 515 516 this.keyListener = function(e){ 517 518 }; 519 this._lang = function() { 520 try { 521 if( arguments.length < 1 ) { 522 return ''; 523 } 524 525 var string = arguments[0]; 526 if( $type(this.options.lang) && $type(this.options.lang[string]) ) { 527 string = this.options.lang[string]; 528 } 529 530 if( arguments.length <= 1 ) { 531 return string; 532 } 533 534 var args = new Array(); 535 for( var i = 1, l = arguments.length; i < l; i++ ) { 536 args.push(arguments[i]); 537 } 538 539 return string.vsprintf(args); 540 } catch( e ) { 541 alert(e); 542 } 543 }, 544 545 this._supportsContentEditable = function() { 546 return false; 547 } 548 this.initialize(element,options); 549}; 550 551Composer.Selection = function(win){ 552 this.initialize = function(win){ 553 this.win = win; 554 } 555
556 this.getSelection = function(){ 557 //this.win.focus(); 558 return window.getSelection(); 559 } 560 561 this.getRange = function(){ 562 var s = this.getSelection(); 563 564 if (!s) return null; 565 566 try { 567 return s.rangeCount > 0 ? s.getRangeAt(0) : (s.createRange ? s.createRange() : null); 568 } catch(e) { 569 // IE bug when used in frameset 570 return document.body.createTextRange(); 571 } 572 } 573 574 this.setRange = function(range){ 575 if (range.select){ 576 try{ 577 (function(){ 578 range.select(); 579 }); 580 } catch(err){ console.log(err); } 581 } else { 582 var s = this.getSelection(); 583 if (s.addRange){ 584 s.removeAllRanges(); 585 s.addRange(range); 586 } 587 } 588 } 589 this.selectNode = function(node, collapse){ 590 var r = this.getRange(); 591 var s = this.getSelection(); 592 if (r.moveToElementText){ 593 try{ 594 (function(){ 595 r.moveToElementText(node); 596 r.select(); 597 }); 598 } catch(err){ console.log(err); } 599 } else if (s.addRange){ 600 collapse ? r.selectNodeContents(node) : r.selectNode(node); 601 s.removeAllRanges(); 602 s.addRange(r); 603 } else { 604 s.setBaseAndExtent(node, 0, node, 1); 605 } 606 607 return node; 608 } 609 610 this.isCollapsed = function(){ 611 var r = this.getRange(); 612 if (r.item) return false;
613 return r.boundingWidth == 0 || this.getSelection().isCollapsed; 614 } 615 616 this.collapse = function(toStart){ 617 var r = this.getRange(); 618 var s = this.getSelection(); 619 if (r.select){ 620 r.collapse(toStart); 621 r.select(); 622 } else { 623 toStart ? s.collapseToStart() : s.collapseToEnd(); 624 } 625 } 626 this.getContent = function(){ 627 var r = this.getRange(); 628 var body = scriptJquery.crtEle('body',{}); 629 if (this.isCollapsed()) return ''; 630 if (r.cloneContents){ 631 body.appendChild(r.cloneContents()); 632 } else if ($defined(r.item) || $defined(r.htmlText)){ 633 body.html(r.item ? r.item(0).outerHTML : r.htmlText); 634 } else { 635 body.html(r.toString()); 636 } 637 var content = body.html(); 638 return content; 639 } 640 this.getText = function(){ 641 var r = this.getRange(); 642 var s = this.getSelection(); 643 return this.isCollapsed() ? '' : r.text || s.toString(); 644 } 645 this.getNode = function(){ 646 var r = this.getRange(); 647 if (!Browser.Engine.trident){ 648 var el = null; 649 if (r){ 650 el = r.commonAncestorContainer; 651 // Handle selection a image or other control like element such as anchors 652 if (!r.collapsed) 653 if (r.startContainer == r.endContainer) 654 if (r.startOffset - r.endOffset < 2) 655 if (r.startContainer.hasChildNodes()) 656 el = r.startContainer.childNodes[r.startOffset]; 657 658 while ($type(el) != 'element') el = el.parentNode; 659 } 660 return scriptJquery(el); 661 } 662 return scriptJquery(r.item ? r.item(0) : r.parent()); 663 } 664 this.insertContent = function(content){ 665 var r = this.getRange(); 666 if (r.insertNode){ 667 r.deleteContents(); 668 r.insertNode(r.createContextualFragment(content)); 669 } else { 670 // Handle text and control range 671 (r.pasteHTML) ? r.pasteHTML(content) : r.item(0).outerHTML = content; 672 } 673 } 674 this.initialize(win); 675}; 676 677 678class ComposerOverText extends OverText{ 679 //Extends : OverText, 680 constructor(element, options){ 681 super(element, options); 682 } 683 test() { 684 if( !$type(this.options.isPlainText) || !this.options.isPlainText) { 685 return !this.element.html().replace(/\s+/, '').replace(/<br.*?>/, ''); 686 } else { 687 return this.parent(); 688 } 689 } 690 hide(suppressFocus, force){ 691 if (this.text && (this.text.is(":visible") && (!this.element.prop('disabled') || force))){ 692 this.text.hide(); 693 //this.fireEvent('textHide', [this.text, this.element]); 694 try { 695 this.element.trigger('focus'); 696 this.element.focus(); 697 } catch(e){} //IE barfs if you call focus on hidden elements 698 699 this.pollingPaused = true; 700 } 701 return this; 702 } 703} 704 705Composer.Plugin = {}; 706 707Composer.Plugin.Interface = function(options){ 708 709this.name = 'interface'; 710 this.active = false; 711 this.composer = false; 712 this.options = { 713 loadingImage : en4.core.staticBaseUrl + 'application/modules/Core/externals/images/loading.gif' 714 }; 715 this.elements = {}; 716 this.persistentElements = ['activator', 'loadingImage','aActivator','sactivator']; 717 this.params = {}; 718 this.initialize = function(options) { 719 this.params = new Hash(); 720 this.elements = new Hash(); 721 this.reset(); 722 this.options = scriptJquery.extend(this.options,options); 723 } 724 this.getName = function() { 725 return this.name; 726 } 727 this.setComposer = function(composer) { 728 this.composer = composer; 729 this.attach(); 730 return this; 731 } 732 this.getComposer = function() { 733 if( !this.composer ) throw "No composer defined"; 734 return this.composer; 735 } 736 this.attach = function() { 737 this.reset(); 738 } 739 this.detach = function() { 740 this.reset(); 741 if( this.elements.activator ) { 742 this.elements.activator.remove(); 743 this.elements.erase('menu'); 744 } 745 } 746 this.reset = function() { 747 Object.entries(this.elements).forEach(function([key,element]) { 748 if(!this.persistentElements.includes(key)) { 749 if(scriptJquery(element).length) 750 scriptJquery(element).remove(); 751 this.elements.erase(key); 752 } 753 }.bind(this)); 754 this.params = new Hash(); 755 this.elements = new Hash(); 756 } 757 758 this.activate = function() { 759 if( this.active ) return; 760 761 scriptJquery("#feedbg_main_continer").hide();
762 //Feed Background image work 763 if(document.getElementById('feedbgid') && document.getElementById('feedbgid').value != 0) { 764 scriptJquery('#feedbgid_isphoto').val(0); 765 scriptJquery('#feedbgid').val(0); 766 scriptJquery('.activity_post_box').css('background-image', 'none'); 767 scriptJquery('#activity-form').removeClass('feed_background_image'); 768 scriptJquery('#feedbg_main_continer').css('display','none'); 769 scriptJquery('#hideshowfeedbgcont').css('display','none'); 770 } 771 //Feed Background image work 772 773 this.getComposer().getTray().empty(); 774 scriptJquery('#fancyalbumuploadfileids').val(''); 775 scriptJquery('#reaction_id').val(''); 776 scriptJquery('.fileupload-cnt').html(''); 777 Object.entries(composeInstance.plugins).forEach(function([key,plugin]) { 778 plugin.active = false; 779 scriptJquery('#compose-'+plugin.getName()+'-activator').parent().removeClass('active'); 780 }); 781 scriptJquery('#compose-'+this.getName()+'-activator').parent().addClass('active'); 782 this.active = true; 783 this.reset(); 784 this.getComposer().getTray().css('display', ''); 785 786 this.getComposer().getMenu().css('border', 'none'); 787 788 this.getComposer().getMenu().find('.compose-activator').each(function(e) { 789 scriptJquery(this).css('display', 'none'); 790 }); 791 792 switch($type(this.options.loadingImage)) { 793 case 'object': 794 break; 795 case 'string': 796 this.elements.loadingImage = scriptJquery.crtEle('img', { 797 'id' : 'compose-' + this.getName() + '-loading-image', 798 'class' : 'compose-loading-image', 799 'src' : this.options.loadingImage 800 }); 801 break; 802 default: 803 this.elements.loadingImage = scriptJquery.crtEle('img', { 804 'id' : 'compose-' + this.getName() + '-loading-image', 805 'class' : 'compose-loading-image', 806 'src' : 'application/modules/Core/externals/images/loading.gif', 807 }); 808 break; 809 } 810 811 } 812 813 this.deactivate = function() { 814 if( !this.active ) return; 815 this.active = false; 816 817 this.reset(); 818 this.getComposer().getTray().css('display', 'none'); 819 this.getComposer().getMenu().css('display', ''); 820 var submitButtonEl = scriptJquery(this.getComposer().options.submitElement); 821 if( submitButtonEl.length) { 822 submitButtonEl.css('display', ''); 823 } 824 this.getComposer().getMenu().find('.compose-activator').each(function(e) { 825 scriptJquery(this).css('display', ''); 826 }); 827 828 this.getComposer().getMenu().attr('style', ''); 829 this.getComposer().signalPluginReady(false); 830 scriptJquery('#fancyalbumuploadfileids').val(''); 831 scriptJquery('#reaction_id').val(''); 832 scriptJquery('.fileupload-cnt').html(''); 833 834 //Feed Background Image Work 835 if(document.getElementById('feedbgid')) { 836 document.getElementById('hideshowfeedbgcont').style.display = 'block'; 837 scriptJquery('#feedbg_main_continer').css('display','block'); 838 } 839 // scriptJquery('#compose-menu').next().html(''); 840 } 841 842 this.ready = function() { 843 this.getComposer().signalPluginReady(true); 844 this.getComposer().getMenu().css('display', ''); 845 846 var submitEl = document.getElementById(this.getComposer().options.submitElement); 847 if( submitEl ) { 848 submitEl.style.display = ""; 849 } 850 }, 851 852 853 // Utility 854 855 this.makeActivator = function() { 856 if( !this.elements.activator ) { 857 var moreTab = false; 858 var spanInsertBefore = 'activity_post_media_options_before'; 859 if(activityDesign == 1) { 860 if(!activityDesignOne){ 861 var content = ''; 862 if(scriptJquery('#feedbg_main_continer').length > 0) { 863 content = scriptJquery('#feedbg_main_continer')[0].outerHTML; 864 scriptJquery('#feedbg_main_continer').remove(); 865 scriptJquery(content).insertAfter(scriptJquery("#activity_post_box_status")); 866 } 867 let newcontent = scriptJquery("#activity-menu")[0].outerHTML; 868 scriptJquery("#activity-menu").remove(); 869 scriptJquery(newcontent).insertBefore(scriptJquery("#composer-tray-container")); 870 871 } 872 activityDesignOne = true; 873 this.elements.activator = scriptJquery.crtEle('span', { 874 'class': 'activity_post_tool_i tool_i_'+this.getName(), 875 }); 876 877 scriptJquery('#activity-menu').append(this.elements.activator); 878 this.elements.aActivator = scriptJquery.crtEle('a', { 879 'id' : 'compose-' + this.getName() + '-activator', 880 'class' : 'activity_tooltip', 881 'data-bs-toggle' : 'tooltip', 882 'href' : 'javascript:;', 883 'title' : this._lang(this.options.title), 884 }).appendTo(this.elements.activator).click((e) => { 885 this.activate(this); 886 }); 887 888 if (this.getName() == 'buysell'){ 889 scriptJquery('<i><svg viewBox="0 0 24 24">
889<path d="M23,19H21V17a1,1,0,0,0-2,0v2H17a1,1,0,0,0,0,2h2v2a1,1,0,0,0,2,0V21h2a1,1,0,0,0,0-2Z"/><path d="M21,6H18A6,6,0,0,0,6,6H3A3,3,0,0,0,0,9V19a5.006,5.006,0,0,0,5,5h9a1,1,0,0,0,0-2H5a3,3,0,0,1-3-3V9A1,1,0,0,1,3,8H6v2a1,1,0,0,0,2,0V8h8v2a1,1,0,0,0,2,0V8h3a1,1,0,0,1,1,1v5a1,1,0,0,0,2,0V9A3,3,0,0,0,21,6ZM8,6a4,4,0,0,1,8,0Z"/></svg></i>').appendTo(this.elements.aActivator); 890 }else if (this.getName() == 'intopenaiImage'){ 891 scriptJquery('<i><svg viewBox="0 0 24 24"><path d="m12,21c0,.553-.448,1-1,1h-6c-2.757,0-5-2.243-5-5V5C0,2.243,2.243,0,5,0h12c2.757,0,5,2.243,5,5v6c0,.553-.448,1-1,1s-1-.447-1-1v-6c0-1.654-1.346-3-3-3H5c-1.654,0-3,1.346-3,3v6.959l2.808-2.808c1.532-1.533,4.025-1.533,5.558,0l5.341,5.341c.391.391.391,1.023,0,1.414-.195.195-.451.293-.707.293s-.512-.098-.707-.293l-5.341-5.341c-.752-.751-1.976-.752-2.73,0l-4.222,4.222v2.213c0,1.654,1.346,3,3,3h6c.552,0,1,.447,1,1ZM15,3.5c1.654,0,3,1.346,3,3s-1.346,3-3,3-3-1.346-3-3,1.346-3,3-3Zm0,2c-.551,0-1,.448-1,1s.449,1,1,1,1-.448,1-1-.449-1-1-1Zm8,12.5h-3v-3c0-.553-.448-1-1-1s-1,.447-1,1v3h-3c-.552,0-1,.447-1,1s.448,1,1,1h3v3c0,.553.448,1,1,1s1-.447,1-1v-3h3c.552,0,1-.447,1-1s-.448-1-1-1Z"></svg></i>').appendTo(this.elements.aActivator); 892 } else if (this.getName() == 'intopenaiDescription'){ 893 scriptJquery('<i><svg viewBox="0 0 24 24" width="512" height="512"><path d="M19,2H5C2.24,2,0,4.24,0,7v10c0,2.76,2.24,5,5,5h14c2.76,0,5-2.24,5-5V7c0-2.76-2.24-5-5-5ZM5,4h14c1.65,0,3,1.35,3,3H2c0-1.65,1.35-3,3-3Zm14,16H5c-1.65,0-3-1.35-3-3V9H22v8c0,1.65-1.35,3-3,3ZM10,12c0,.55-.45,1-1,1h-1v4c0,.55-.45,1-1,1s-1-.45-1-1v-4h-1c-.55,0-1-.45-1-1s.45-1,1-1h4c.55,0,1,.45,1,1Zm10,0c0,.55-.45,1-1,1h-6c-.55,0-1-.45-1-1s.45-1,1-1h6c.55,0,1,.45,1,1Zm0,4c0,.55-.45,1-1,1h-6c-.55,0-1-.45-1-1s.45-1,1-1h6c.55,0,1,.45,1,1Z"/></svg></i>').appendTo(this.elements.aActivator); 894 895 } 896 897 if(!scriptJquery("#activity_post_box_status").find("#composer-close-design1").length){ 898 var closeComposer = scriptJquery.crtEle('a', { 899 'id' : 'composer-close-design1', 900 'class' : 'activity_tooltip font_color', 901 'data-bs-toggle' : 'tooltip', 902 'href' : 'javascript:;', 903 'style' : 'display:none;', 904 'title' : this._lang("close"), 905 }); 906 scriptJquery("#activity_post_box_status").append(closeComposer); 907 908 scriptJquery(closeComposer).click((e) => { 909 this.closeOption(this) 910 });; 911 } 912 scriptJquery('#activity-menu').find('.executed').removeClass('executed'); 913 }else if(activityDesign == 2){ 914 915 if(scriptJquery("body").attr("id") != "global_page_messages-messages-compose" && scriptJquery("body").attr("id") != "global_page_messages-messages-view") 916 //scriptJquery(".activity_post_media_options").hide(); 917 918 var displayCI = 'block'; 919 if(counterLoopComposerItem == 4) { 920 var html = scriptJquery('<span class="activity_post_media_options_icon tool_i_more" style="display:flex;"><a href="javascript:void(0);" title="More" class="activity_tooltip"><i></i></a></span>').insertBefore(scriptJquery('#activity_post_media_options_before')); 921 } 922 if(counterLoopComposerItem > 3) 923 displayCI = 'none'; 924 counterLoopComposerItem++; 925 926 this.elements.activator = scriptJquery.crtEle('span', { 927 'html' : '', 928 'style': 'display:'+displayCI, 929 'class': 'activity_post_media_options_icon tool_i_'+this.getName(), 930 }); 931 932 //Album Work 933 try { 934 this.elements.aActivator = scriptJquery.crtEle('a', { 935 'id' : 'compose-' + this.getName() + '-activator', 936 'class' : 'activity_tooltip', 937 'href' : 'javascript:;', 938 'title' : this._lang(this.options.title), 939 }).appendTo(this.elements.activator).click((e) => { 940 this.activate(this); 941 }); 942 } catch(err){ 943 console.log(err); 944 945 } 946 if (this.getName() == 'buysell'){ 947 scriptJquery('<i><svg viewBox="0 0 24 24">
947<path d="M23,19H21V17a1,1,0,0,0-2,0v2H17a1,1,0,0,0,0,2h2v2a1,1,0,0,0,2,0V21h2a1,1,0,0,0,0-2Z"/><path d="M21,6H18A6,6,0,0,0,6,6H3A3,3,0,0,0,0,9V19a5.006,5.006,0,0,0,5,5h9a1,1,0,0,0,0-2H5a3,3,0,0,1-3-3V9A1,1,0,0,1,3,8H6v2a1,1,0,0,0,2,0V8h8v2a1,1,0,0,0,2,0V8h3a1,1,0,0,1,1,1v5a1,1,0,0,0,2,0V9A3,3,0,0,0,21,6ZM8,6a4,4,0,0,1,8,0Z"/></svg></i>').appendTo(this.elements.aActivator); 948 } else if (this.getName() == 'intopenaiImage'){ 949 scriptJquery('<i><svg viewBox="0 0 24 24"><path d="m12,21c0,.553-.448,1-1,1h-6c-2.757,0-5-2.243-5-5V5C0,2.243,2.243,0,5,0h12c2.757,0,5,2.243,5,5v6c0,.553-.448,1-1,1s-1-.447-1-1v-6c0-1.654-1.346-3-3-3H5c-1.654,0-3,1.346-3,3v6.959l2.808-2.808c1.532-1.533,4.025-1.533,5.558,0l5.341,5.341c.391.391.391,1.023,0,1.414-.195.195-.451.293-.707.293s-.512-.098-.707-.293l-5.341-5.341c-.752-.751-1.976-.752-2.73,0l-4.222,4.222v2.213c0,1.654,1.346,3,3,3h6c.552,0,1,.447,1,1ZM15,3.5c1.654,0,3,1.346,3,3s-1.346,3-3,3-3-1.346-3-3,1.346-3,3-3Zm0,2c-.551,0-1,.448-1,1s.449,1,1,1,1-.448,1-1-.449-1-1-1Zm8,12.5h-3v-3c0-.553-.448-1-1-1s-1,.447-1,1v3h-3c-.552,0-1,.447-1,1s.448,1,1,1h3v3c0,.553.448,1,1,1s1-.447,1-1v-3h3c.552,0,1-.447,1-1s-.448-1-1-1Z"></svg></i>').appendTo(this.elements.aActivator); 950 } else if (this.getName() == 'intopenaiDescription'){ 951 scriptJquery('<i><svg viewBox="0 0 24 24" width="512" height="512"><path d="M19,2H5C2.24,2,0,4.24,0,7v10c0,2.76,2.24,5,5,5h14c2.76,0,5-2.24,5-5V7c0-2.76-2.24-5-5-5ZM5,4h14c1.65,0,3,1.35,3,3H2c0-1.65,1.35-3,3-3Zm14,16H5c-1.65,0-3-1.35-3-3V9H22v8c0,1.65-1.35,3-3,3ZM10,12c0,.55-.45,1-1,1h-1v4c0,.55-.45,1-1,1s-1-.45-1-1v-4h-1c-.55,0-1-.45-1-1s.45-1,1-1h4c.55,0,1,.45,1,1Zm10,0c0,.55-.45,1-1,1h-6c-.55,0-1-.45-1-1s.45-1,1-1h6c.55,0,1,.45,1,1Zm0,4c0,.55-.45,1-1,1h-6c-.55,0-1-.45-1-1s.45-1,1-1h6c.55,0,1,.45,1,1Z"/></svg></i>').appendTo(this.elements.aActivator); 952 953 } 954 955 956 957 this.elements.sactivator = scriptJquery.crtEle('span', {}).html(this._lang(this.options.title)).appendTo(this.elements.aActivator); 958 959 this.elements.activator.insertBefore(scriptJquery('#activity_post_media_options_before')); 960 } 961 } 962 }; 963 964 this.makeMenu = function() { 965 if( !this.elements.menu ) { 966 var tray = this.getComposer().getTray(); 967 968 this.elements.menu = scriptJquery.crtEle('div', { 969 'id' : 'compose-' + this.getName() + '-menu', 970 'class' : 'compose-menu' 971 }).appendTo(tray); 972 973 this.elements.menuTitle = scriptJquery.crtEle('span', { 974 'class' : 'compose-menu-head', 975 }).html(this._lang(this.options.title)).appendTo(this.elements.menu); 976 977 this.elements.menuClose = scriptJquery.crtEle('a', { 978 'class' : 'compose-menu-close fas fa-times', 979 'href' : 'javascript:void(0);', 980 'title' : this._lang('cancel'), 981 }).appendTo(this.elements.menuTitle).click(function(e) { 982 //e.stop(); 983 this.getComposer().deactivate(); 984 scriptJquery('#compose-tray').hide(); 985 }.bind(this)); 986 987 this.elements.menuTitle.append(''); 988 989 } 990 } 991 this.closeOption = function(){ 992 if(scriptJquery("#feedbg_main_continer").length){ 993 feedbgimage('defaultimage'); 994 } 995 scriptJquery("#feedbg_main_continer").hide(); 996 scriptJquery("#composer-close-design1").hide(); 997 } 998 this.makeBody = function() { 999 if( !this.elements.body ) { 1000 var tray = this.getComposer().getTray(); 1001 this.elements.body = scriptJquery.crtEle('div', { 1002 'id' : 'compose-' + this.getName() + '-body', 1003 'class' : 'compose-body' 1004 }).appendTo(tray); 1005 } 1006 } 1007 1008 this.makeLoading = function(action) { 1009 if( !this.elements.loading ) { 1010 if( action == 'empty' ) { 1011 this.elements.body.empty(); 1012 } else if( action == 'hide' ) { 1013 this.elements.body.getChildren().each(function(element){ element.css('display', 'none')}); 1014 } else if( action == 'invisible' ) { 1015 this.elements.body.getChildren().each(function(element){ element.css('height', '0px').css('visibility', 'hidden')}); 1016 } 1017 1018 this.elements.loading = scriptJquery.crtEle('div', { 1019 'id' : 'compose-' + this.getName() + '-loading', 1020 'class' : 'compose-loading' 1021 }).appendTo(this.elements.body); 1022 var image = this.elements.loadingImage || (scriptJquery.crtEle('img', { 1023 'id' : 'compose-' + this.getName() + '-loading-image', 1024 'class' : 'compose-loading-image' 1025 })); 1026 image.appendTo(this.elements.loading); 1027 } 1028 } 1029 1030 this.makeError = function(message, action) { 1031 if( !$type(action) ) action = 'empty'; 1032 message = message || 'An error has occurred'; 1033 message = this._lang(message); 1034 this.elements.error = scriptJquery.crtEle('div', { 1035 'id' : 'compose-' + this.getName() + '-error', 1036 'class' : 'compose-error', 1037 'html' : message 1038 }).html(message).appendTo(this.elements.body); 1039 } 1040 this.makeFormInputs = function(data) { 1041 1042 this.ready(); 1043 this.getComposer().getInputArea().empty(); 1044 var name = this.getName(); 1045 if(name == 'link') 1046 name = 'activitylink'; 1047 data.type = name;
1048 Object.entries(data).forEach(function([key,value]) { 1049 this.setFormInputValue(key, value); 1050 }.bind(this)); 1051 1052 } 1053 1054 this.setFormInputValue = function(key, value) { 1055 var elName = 'attachmentForm' + key.replace(/\b[a-z]/g, function(match){ 1056 return match.toUpperCase(); 1057 }); 1058 if( !this.elements.has(elName) ) { 1059 this.elements.set(elName,scriptJquery.crtEle('input', { 1060 'type' : 'hidden', 1061 'name' : 'attachment[' + key + ']', 1062 'value' : value || '' 1063 }).appendTo(this.getComposer().getInputArea())); 1064 } 1065 this.elements.get(elName).val(value); 1066 } 1067 this._lang = function() { 1068 try { 1069 if( arguments.length < 1 ) { 1070 return ''; 1071 } 1072 var string = arguments[0]; 1073 if( $type(this.options.lang) && $type(this.options.lang[string]) ) { 1074 string = this.options.lang[string]; 1075 } 1076 if( arguments.length <= 1 ) { 1077 return string; 1078 } 1079 var args = new Array(); 1080 for( var i = 1, l = arguments.length; i < l; i++ ) { 1081 args.push(arguments[i]); 1082 } 1083 return string.vsprintf(args); 1084 } catch( e ) { 1085 alert(e); 1086 } 1087 } 1088 this.initialize(options); 1089}; 1090})(); 1091 1092 1093AttachEventListerSE('click',function(e) { 1094 var container = scriptJquery('.activity_post_container'); 1095 var smoothbox = scriptJquery('.ajaxsmoothbox_main'); 1096 var smoothboxIcon = scriptJquery('.ajaxsmoothbox_overlay'); 1097 var smoothboxSE = scriptJquery('#TB_window'); 1098 var smoothboxSEOverlay = scriptJquery('#TB_overlay'); 1099 var notclose = scriptJquery('.notclose'); 1100 if(scriptJquery(e.target).hasClass('notclose') || scriptJquery(e.target).closest('.ui-autocomplete').length > 0 || scriptJquery(e.target).hasClass("compose-form-submit") || scriptJquery(e.target).parent().hasClass('tag') || smoothbox.has(e.target).length || smoothbox.is(e.target) || smoothboxIcon.has(e.target).length || smoothboxIcon.is(e.target) || notclose.has(e.target).length || notclose.is(e.target) || scriptJquery(e.target).hasClass('ajaxsmoothbox_close_btn') || scriptJquery(e.target).hasClass('ajaxsmoothbox_main') || smoothboxSE.has(e.target).length || smoothboxSE.is(e.target) || smoothboxSEOverlay.has(e.target).length || smoothboxSEOverlay.is(e.target) || scriptJquery(e.target).attr('id') == 'TB_overlay' || scriptJquery(e.target).hasClass('close') || scriptJquery('.pac-container').has(e.target).length || scriptJquery('.pac-container').is(e.target) || scriptJquery(e.target).attr('id') == 'TB_window' || scriptJquery(e.target).prop("tagName") == 'BODY'){ 1101 return; 1102 } 1103 1104 if(scriptJquery(e.target).attr('id') == 'discard_post' || scriptJquery(e.target).attr('id') == 'goto_post'){ 1105 return; 1106 } 1107 1108 //Feed Background Image Work 1109 if(scriptJquery(e.target).hasClass('fa fa-angle-right') || scriptJquery(e.target).hasClass('fa fa-angle-left')){ 1110 return; 1111 } 1112 if(scriptJquery("#composer-close-design1").is(e.target)){ 1113 return; 1114 } 1115 if ((!container.is(e.target) 1116 && container.has(e.target).length === 0) || scriptJquery(e.target).hasClass('activity_post_box_close_a')) 1117 { 1118 if(scriptJquery('.activity_composer_active').length && !scriptJquery(e.target).hasClass('compose-menu-close')){ 1119 if(scriptJquery(".modal.show").length == 0) 1120 checkComposerAdv(); 1121 } 1122 } else { 1123 if(activityDesign != 2){ 1124 scriptJquery("#composer-close-design1").show(); 1125 scriptJquery('#feedbg_main_continer').show(); 1126 return; 1127 } 1128 scriptJquery('.activity_post_container_wrapper').addClass('activity_composer_active'); 1129 scriptJquery(".activity_post_box_close").show(); 1130 scriptJquery('.activity_post_media_options').addClass('activity_post_media_options_active'); 1131 1132 scriptJquery(".activity_post_media_options span:gt(3)").show(); 1133 scriptJquery(".activity_post_media_options").children().eq(3).hide(); 1134 1135 // Feed bg work 1136 var activatedPlugin = composeInstance.getActivePlugin(); 1137 1138 var textlengthBody = scriptJquery('#activity_body').val().length; 1139 1140 if(document.getElementById('feedbg_main_continer') && !activatedPlugin && textlengthBody <= 120) 1141 scriptJquery('#feedbg_main_continer').css('display','block'); 1142 1143 if(scriptJquery('#activitylng').val()) { 1144 scriptJquery('#feedbg_main_continer').css('display','none'); 1145 }
1146 if(activityBodyHeight){ 1147 scriptJquery('#activity_body').height(activityBodyHeight); 1148 } 1149 scriptJquery('.activity_post_media_options').show(); 1150 scriptJquery('#compose-menu').show(); 1151 } 1152}); 1153 1154 1155var activityBodyHeight = 0; 1156function hideStatusBoxSecond() { 1157 scriptJquery('.activity_post_container_wrapper').removeClass('activity_composer_active'); 1158 scriptJquery('.activity_post_media_options').removeClass('activity_post_media_options_active'); 1159 1160 scriptJquery(".activity_post_media_options span:gt(4)").hide(); 1161 scriptJquery(".activity_post_media_options").children().eq(3).show(); 1162 scriptJquery(".activity_post_media_options").children().eq(2).find("span").show(); 1163 1164 scriptJquery(".activity_post_box_close").hide(); 1165 scriptJquery('.activity_shedulepost_overlay').hide(); 1166 scriptJquery('html').removeClass('overflow-hidden') 1167 scriptJquery('body').removeClass('overflow-hidden'); 1168 //scriptJquery('.activity_post_media_options').hide(); 1169 1170 //Feed Background Image Work 1171 if(document.getElementById('feedbgid').value) { 1172 if(document.getElementById('feedbg_main_continer')) 1173 document.getElementById('feedbg_main_continer').style.display = 'none'; 1174 scriptJquery('.activity_post_box').css('background-image', 'none'); 1175 scriptJquery('#activity-form').removeClass('feed_background_image'); 1176 } else { 1177 //Feed Background Image Work 1178 document.getElementById('hideshowfeedbgcont').style.display = 'block'; 1179 scriptJquery('#feedbg_content').css('display','inline-block'); 1180 scriptJquery('#feedbg_main_continer').css('display','none'); 1181 scriptJquery('.activity_post_box').css('background-image', 'none'); 1182 scriptJquery('#activity-form').removeClass('feed_background_image'); 1183 } 1184 scriptJquery('.activity_post_box').removeClass('_blank'); 1185} 1186 1187 1188function getConfirmation() { 1189 if(!scriptJquery('#activity_body').val()) 1190 return; 1191 var retVal = confirm("Are you sure to discard this post ?"); 1192 if( retVal == true ) { 1193 resetComposerBoxStatus(); 1194 Object.entries(composeInstance.plugins).forEach(function([key,plugin]) { 1195 plugin.deactivate(); 1196 scriptJquery('#compose-menu').hide(); 1197 scriptJquery('#compose-'+plugin.getName()+'-activator').parent().removeClass('active'); 1198 }); 1199 } 1200} 1201 1202AttachEventListerSE('paste','#activity_body',function(){ 1203 setTimeout(function () { 1204 linkDetection(); 1205 }, 20); 1206}); 1207 1208AttachEventListerSE('keyup','#activity_body',function(e) { 1209 if(e.keyCode != '32') 1210 return; 1211 setTimeout(function () { 1212 linkDetection(); 1213 }, 20); 1214}); 1215function updateEditVal(that,data){ 1216 EditFieldValue = data; 1217 scriptJquery(that).mentionsInput("update"); 1218} 1219var mentiondataarray = []; 1220AttachEventListerSE('keyup','#activity_body',function(){ 1221 var data = scriptJquery(this).val(); 1222 EditFieldValue = data; 1223 //scriptJquery(this).mentionsInput("update"); 1224}); 1225function getDataMentionEdit (that,data){ 1226 if (scriptJquery(that).attr('data-mentions-input') === 'true') { 1227 updateEditVal(that, data); 1228 } 1229} 1230var isOnEditField = isonCommentBox = false; 1231AttachEventListerSE('focus','#activity_body',function(){ 1232 isonCommentBox = false; 1233 if(!scriptJquery(this).attr('id')) 1234 scriptJquery(this).attr('id',new Date().getTime()); 1235 var data = scriptJquery(this).val(); 1236 if(!scriptJquery(this).val() || isOnEditField){ 1237 if(!scriptJquery(this).val() ) 1238 EditFieldValue = ''; 1239 1240 //if(userTagsEnable) { 1241 scriptJquery(this).mentionsInput({ 1242 onDataRequest:function (mode, query, callback) { 1243 scriptJquery.getJSON('activity/ajax/friends/query/'+query, function(responseData) { 1244 responseData = _.filter(responseData, function(item) { return item.name.toLowerCase().indexOf(query.toLowerCase()) > -1 }); 1245 callback.call(this, responseData); 1246 }); 1247 }, 1248 //defaultValue: EditFieldValue, 1249 onCaret: true 1250 }); 1251 //} 1252 } 1253 1254 if(data){ 1255 getDataMentionEdit(this,data); 1256 } 1257 if(!scriptJquery(this).parent().hasClass('typehead')){ 1258 scriptJquery(this).hashtags(); 1259 scriptJquery(this).focus(); 1260 } 1261 1262 autosize(scriptJquery(this)); 1263 1264}); 1265function getUrlVars() 1266{ 1267 var vars = [], hash; 1268 var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); 1269 for(var i = 0; i < hashes.length; i++) 1270 { 1271 hash = hashes[i].split('='); 1272 vars.push(hash[0]); 1273 vars[hash[0]] = hash[1]; 1274 } 1275 return vars; 1276} 1277AttachEventListerSE('keydown','#activity_body',function(){ 1278 if(scriptJquery(this).val() != '') 1279 scriptJquery('.activity_post_box').removeClass('_blank'); 1280 1281}); 1282 1283function checkComposerAdv(){ 1284 hideStatusBoxSecond(); 1285 return; 1286} 1287function linkDetection(){ 1288 var html = scriptJquery('#activity_body').val(); 1289 //var html = composeInstance.getContent(); 1290 if(!html || !scriptJquery('#compose-link-activator').length || scriptJquery('#compose-tray').html()) 1291 return false;
1292 var mystrings = []; 1293 var valid = false; 1294 var url = ''; 1295 valid = this.checkUrl(html); 1296 if(!valid) 1297 return; 1298 var pluginlink = composeInstance.getPlugin('link'); 1299 pluginlink.activate(); 1300 //check for youtube video url 1301 var matches = valid.match(/watch\?v=([a-zA-Z0-9\-_]+)/); 1302 if (matches) 1303 { 1304 if(valid.indexOf('?') < 0) 1305 valid = valid+'?youtubevideo=1'; 1306 else 1307 valid = valid+'&youtubevideo=1'; 1308 }else if(parseVimeo(valid)){ 1309 if(valid.indexOf('?') < 0) 1310 valid = valid+'?vimeovideo=1'; 1311 else 1312 valid = valid+'&vimeovideo=1'; 1313 }else if(valid.indexOf('https://soundcloud.com') >= 0){ 1314 if(valid.indexOf('?') < 0) 1315 valid = valid+'?soundcloud=1'; 1316 else 1317 valid = valid+'&soundcloud=1'; 1318 } 1319 scriptJquery(pluginlink.elements.formInput).val(valid); 1320 pluginlink.doAttach(); 1321 pluginlink.active = true; 1322 scriptJquery('#compose-link-form-submit').trigger('click'); 1323} 1324function parseVimeo(str) { 1325 // embed & link: http://vimeo.com/86164897 1326 var re = /\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/i; 1327 var matches = re.exec(str); 1328 return matches && matches[1]; 1329} 1330function checkUrl(str){ 1331 var geturl = /(((https?:\/\/)|(www\.))[^\s]+)/g; 1332 if(str.match(geturl)){ 1333 var length = str.match(geturl).length 1334 var urls = str.match(geturl) 1335 1336 if(length) 1337 return urls[0]; 1338 } 1339 return ''; 1340} 1341 1342/* $Id:composer_buysell.js 2017-01-12 00:00:00 SocialEngineSolutions $*/ 1343 1344Composer.Plugin.Buysell = function(options){ 1345 1346 this.__proto__ = new Composer.Plugin.Interface(options); 1347 1348 this.name = 'buysell' 1349 1350 this.options = { 1351 title : en4.core.language.translate("Sell Something"), 1352 lang : {}, 1353 // Options for the link preview request 1354 requestOptions : {}, 1355 debug : false 1356 } 1357 1358 this.initialize = function(options) { 1359 this.params = new Hash(this.params); 1360 this.__proto__.initialize.call(this,scriptJquery.extend(options,this.__proto__.options)); 1361 } 1362 1363 this.attach = function() { 1364 this.__proto__.attach.call(this); 1365 this.makeActivator(); 1366 return this; 1367 } 1368 1369 this.detach = function() { 1370 this.__proto__.detach.call(this); 1371 if( this.interval ) $clear(this.interval); 1372 return this; 1373 } 1374 1375 this.activate = function() { 1376 if( this.active ) return; 1377 this.__proto__.activate.call(this); 1378 1379 this.makeMenu(); 1380 this.makeBody(); 1381 1382 var title = '<div class="activity_sell_composer"><div class="activity_sell_composer_title"><input type="text" id="buysell-title" placeholder="'+ en4.core.language.translate("What are you selling?")+'" name="buysell-title"><span id="buysell-title-count" class="font_color_light">100</span></div>'; 1383 var wheretobuy = '<div class="activity_sell_composer_title"><input type="text" id="buy-url" placeholder="'+ en4.core.language.translate("Where to Buy (URL Optional)")+'" name="buy-url"></div>'; 1384 var currencyId = 'buysell-currency'; 1385 var price = '<div class="activity_sell_composer_price"><span class="activity_sell_composer_price_currency font_color_light">'+this.__proto__.options.currency+'</span><span class="activity_sell_composer_price_input"><input type="text" id="buysell-price" placeholder="'+ en4.core.language.translate("Add price")+'" name="buysell-price"><input type="hidden" id="'+currencyId+'" name="buysell-currency" value="'+this.__proto__.options.currencySymbol+'"></span></div>'; 1386 if(isEnablegLocation) { 1387 var location = '<div class="activity_sell_composer_location"><i class="font_color_light fas fa-map-marker-alt"></i><span id="locValuesbuysell-element"></span><span id="buyselllocal"><input type="text" id="buysell-location" placeholder="'+ en4.core.language.translate("Add location (optional)")+'" name="buysell-location"><input type="hidden" name="activitybuyselllng" id="activitybuyselllng"><input type="hidden" name="activitybuyselllat" id="activitybuyselllat"></span></div>'; 1388 } else { 1389 var location = ''; 1390 } 1391 var description = '<div class="activity_sell_composer_des"><textarea id="buysell-description" placeholder="'+ en4.core.language.translate("Describe your item (optional)")+'" name="buysell-description"></textarea></div></div>'; 1392 scriptJquery(this.elements.body).html(title+wheretobuy+price+location+description); 1393 if(this.__proto__.options.photoUpload){ 1394 scriptJquery(this.elements.body).append('<input type="file" accept="image/x-png,image/jpeg" onchange="readImageUrlbuysell(this)" multiple="multiple" id="file_multi" name="file_multi" style="display:none"><div class="activity_compose_photo_container clearfix"><div id="activity_compose_photo_container_inner" class="clearfix"><div id="show_photo"></div><div id="dragandrophandlerbuysell" class="activity_compose_photo_uploader center_item" title="'+ en4.core.language.translate("Choose a file to upload")+'"><i class="fa fa-plus"></i></div></div></div>'); 1395 var byteMB = (post_max_size / (1024 * 1024)) + en4.core.language.translate("MB"); 1396 byteMB = en4.core.language.translate('Max size ') + byteMB; 1397 scriptJquery(this.elements.body).append('<span class="font_color_light">('+byteMB+')</span>'); 1398 } 1399 var input = document.getElementById('buysell-location'); 1400 if(isGoogleKeyEnabled && typeof input != 'undefined') { 1401 var autocomplete = new google.maps.places.Autocomplete(input); 1402 google.maps.event.addListener(autocomplete, 'place_changed', function () { 1403 var place = autocomplete.getPlace(); 1404 if (!place.geometry) { 1405 return; 1406 } 1407 scriptJquery('#locValuesbuysell-element').html('<span class="tag">'+scriptJquery('#buysell-location').val()+' <a href="javascript:void(0);" class="buysellloc_remove_act">x</a></span>'); 1408 scriptJquery('#locValuesbuysell-element').show(); 1409 scriptJquery('#buyselllocal').hide(); 1410 document.getElementById('activitybuyselllng').value = place.geometry.location.lng(); 1411 document.getElementById('activitybuyselllat').value = place.geometry.location.lat(); 1412 }); 1413 } 1414 scriptJquery('#buysell-description').hashtags(); 1415 } 1416 1417 this.deactivate = function() { 1418 if( !this.active ) return; 1419 this.active = false;
1420 this.__proto__.detach.call(this); 1421 this.request = false; 1422 } 1423}; 1424 1425function checkuploadfiletype(input,value){ 1426 var url = input.value; 1427 var ext = url.substring(url.lastIndexOf('.') + 1).toLowerCase(); 1428 if (input.files && input.files[0] && (ext == "exe" || ext == '.mp3')) { 1429 scriptJquery('#fileupload-input-type').val(''); 1430 return false; 1431 } 1432 if(input.files[0].size > value){ 1433 en4.core.showError("<p>" + en4.core.language.translate("Upload smaller file.") + '</p><button onclick="Smoothbox.close()">'+ en4.core.language.translate("Close")+'</button>'); 1434 scriptJquery('#fileupload-input-type').val(''); 1435 return false; 1436 } 1437 var field = '<input type="hidden" name="attachment[type]" value="fileupload">'; 1438 if(!scriptJquery('.fileupload-cnt').length) 1439 scriptJquery('#activity-form').append('<div style="display:none" class="fileupload-cnt">'+field+'</div>'); 1440 else 1441 scriptJquery('.fileupload-cnt').html(field); 1442 var plugin = composeInstance.getPlugin('fileupload'); 1443 plugin.ready(); 1444} 1445 1446 1447/* $Id:composer_fileupload.js 2017-01-12 00:00:00 SocialEngineSolutions $*/ 1448 1449Composer.Plugin.Fileupload = function(options){ 1450 1451 this.__proto__ = new Composer.Plugin.Interface(options); 1452 1453 this.name = 'fileupload' 1454 1455 this.options = { 1456 title : 'Add File', 1457 serverLimit : 0, 1458 lang : {}, 1459 // Options for the link preview request 1460 requestOptions : {}, 1461 debug : false 1462 }, 1463 1464 this.initialize = function(options) { 1465 this.params = new Hash(this.params); 1466 this.__proto__.initialize.call(this,scriptJquery.extend(options,this.__proto__.options)); 1467 }, 1468 1469 this.attach = function() { 1470 this.__proto__.attach.call(this); 1471 this.makeActivator(); 1472 return this; 1473 } 1474 1475 this.detach = function() { 1476 this.__proto__.detach.call(this); 1477 this.active = false 1478 if( this.interval ) $clear(this.interval); 1479 return this; 1480 } 1481 1482 this.activate = function() { 1483 if( this.active ) return; 1484 this.__proto__.activate.call(this); 1485 1486 this.makeMenu(); 1487 this.makeBody(); 1488 var byteMB = (post_max_size / (1024 * 1024)) + en4.core.language.translate("MB"); 1489 scriptJquery(this.elements.body).html('<input id="fileupload-input-type" type="file" name="fileupload" value="" onchange="checkuploadfiletype(this,'+this.options.serverLimitDigits+')"><span class="font_color_light">(Max size '+byteMB+')</span>'); 1490 }, 1491 1492 this.deactivate = function() { 1493 if( !this.active ) return; 1494 this.active = false; 1495 this.__proto__.detach.call(this); 1496 this.request = false; 1497 } 1498}; 1499 1500function checkuploadfiletype(input,value){ 1501 var url = input.value; 1502 var ext = url.substring(url.lastIndexOf('.') + 1).toLowerCase(); 1503 if (input.files && input.files[0] && (ext == "exe" || ext == '.mp3')) { 1504 scriptJquery('#fileupload-input-type').val(''); 1505 return false; 1506 } 1507 if(input.files[0].size > value){ 1508 en4.core.showError("<p>" + en4.core.language.translate("Upload smaller file.") + '</p><button onclick="Smoothbox.close()">'+en4.core.language.translate("Close")+'</button>'); 1509 scriptJquery('#fileupload-input-type').val(''); 1510 return false; 1511 } 1512 var field = '<input type="hidden" name="attachment[type]" value="fileupload">'; 1513 if(!scriptJquery('.fileupload-cnt').length) 1514 scriptJquery('#activity-form').append('<div style="display:none" class="fileupload-cnt">'+field+'</div>'); 1515 else 1516 scriptJquery('.fileupload-cnt').html(field); 1517 var plugin = composeInstance.getPlugin('fileupload'); 1518 plugin.ready(); 1519} 1520 1521 1522/* $Id:composer_link.js 2017-01-12 00:00:00 SocialEngineSolutions $*/ 1523 1524Composer.Plugin.Link = function(options){ 1525 this.__proto__ = new Composer.Plugin.Interface(options); 1526 1527 //Extends : Composer.Plugin.Interface, 1528 this.name = 'link' 1529 this.options = { 1530 title : 'Add Link', 1531 lang : {'Add Link': 'Add Link'}, 1532 // Options for the link preview request 1533 requestOptions : {}, 1534 // Various image filtering options 1535 imageMaxAspect : ( 10 / 3 ), 1536 imageMinAspect : ( 3 / 10 ), 1537 imageMinSize : 48, 1538 imageMaxSize : 5000, 1539 imageMinPixels : 2304, 1540 imageMaxPixels : 1000000, 1541 imageTimeout : 5000, 1542 // Delay to detect links in input 1543 monitorDelay : 600, 1544 debug : false 1545 } 1546 1547 this.initialize = function(options) { 1548 this.params = new Hash(this.params); 1549 this.__proto__.initialize.call(this,scriptJquery.extend(options,this.__proto__.options)); 1550 }, 1551 1552 this.attach = function() { 1553 this.__proto__.attach.call(this); 1554 // this.parent(); 1555 this.makeActivator(); 1556 1557 // Poll for links 1558 //this.interval = (function() { 1559 // this.poll(); 1560 //}).periodical(250, this); 1561 this.monitorLastContent = ''; 1562 this.monitorLastMatch = ''; 1563 this.monitorLastKeyPress = $time(); 1564 // this.getComposer().addEvent('editorKeyPress', function() { 1565 // this.monitorLastKeyPress = $time(); 1566 // }.bind(this)); 1567 1568 1569 return this; 1570 } 1571 1572 this.detach = function() { 1573 this.__proto__.detach.call(this); 1574 this.active = false 1575 if( this.interval ) $clear(this.interval); 1576 return this; 1577 } 1578 1579 this.activate = function() { 1580 if( this.active ) return; 1581 this.__proto__.activate.call(this); 1582 1583 this.makeMenu(); 1584 this.makeBody(); 1585 1586 // Generate body contents 1587 // Generate form 1588 this.elements.formInput = scriptJquery.crtEle('input', { 1589 'id' : 'compose-link-form-input', 1590 'class' : 'compose-form-input', 1591 'type' : 'text' 1592 }).appendTo(this.elements.body); 1593 1594 this.elements.formSubmit = scriptJquery.crtEle('button', { 1595 'id' : 'compose-link-form-submit', 1596 'class' : 'compose-form-submit', 1597 }).html(this._lang('Attach')).appendTo(this.elements.body).click(function(e) { 1598 e.preventDefault(); 1599 this.doAttach(); 1600 }.bind(this)); 1601 this.elements.formInput.focus(); 1602 } 1603 1604// this.deactivate = function() { 1605// if( !this.active ) return; 1606// //this.parent(); 1607// this.active = false;
1608// this.__proto__.detach.call(this); 1609// this.request = false; 1610// }, 1611 1612 this.deactivate = function() { 1613 if( !this.active ) return; 1614 this.__proto__.deactivate.call(this); 1615 1616 this.request = false; 1617 } 1618 1619 this.poll = function() { 1620 // Active plugin, ignore 1621 if( this.getComposer().hasActivePlugin() ) return; 1622 // Recent key press, ignore 1623 if( $time() < this.monitorLastKeyPress + this.options.monitorDelay ) return; 1624 // Get content and look for links 1625 var content = this.getComposer().getContent(); 1626 // Same as last body 1627 if( content == this.monitorLastContent ) return; 1628 this.monitorLastContent = content; 1629 // Check for match 1630 var m = content.match(/http:\/\/([-\w\.]+)+(:\d+)?(\/([-#:\w/_\.]*(\?\S+)?)?)?/); 1631 if( $type(m) && $type(m[0]) && this.monitorLastMatch != m[0] ) 1632 { 1633 this.monitorLastMatch = m[0]; 1634 this.activate(); 1635 this.elements.formInput.value = this.monitorLastMatch; 1636 this.doAttach(); 1637 } 1638 } 1639 1640 // Getting into the core stuff now 1641 1642 this.doAttach = function() { 1643 var val = this.elements.formInput.val(); 1644 if( !val ) { 1645 return; 1646 } 1647 if( !val.match(/^[a-zA-Z]{1,5}:\/\//) ) 1648 { 1649 val = 'http://' + val; 1650 } 1651 this.params.set('uri', val) 1652 // Input is empty, ignore attachment 1653 if( val == '' ) { 1654 return; 1655 } 1656 1657 // Send request to get attachment 1658 var options = scriptJquery.extend({ 1659 'dataType': 'json', 1660 'method': 'post', 1661 'data' : { 1662 'format' : 'json', 1663 'uri' : val 1664 }, 1665 'success' : this.doProcessResponse.bind(this) 1666 }, this.options.requestOptions); 1667 1668 // Inject loading 1669 this.makeLoading('empty'); 1670 1671 // Send request 1672 scriptJquery.ajax(options); 1673 } 1674 1675 this.doProcessResponse = function(responseJSON, responseText) { 1676 // Handle error 1677 if( $type(responseJSON) != 'object' ) { 1678 responseJSON = { 1679 'status' : false 1680 }; 1681 } 1682 this.params.set('uri', responseJSON.url); 1683 1684 // If google docs then just output Google Document for title and descripton 1685 var uristr = responseJSON.url; 1686 if (uristr.substr(0, 23) == 'https://docs.google.com') { 1687 var title = uristr; 1688 var description = 'Google Document'; 1689 } else { 1690 var title = responseJSON.title || responseJSON.url; 1691 var description = responseJSON.description || responseJSON.title || responseJSON.url; 1692 } 1693 1694 var images = responseJSON.images || []; 1695 if(responseJSON.gifUrl) 1696 title = responseJSON.gifImageUrl; 1697 this.params.set('title', title); 1698 this.params.set('description', description); 1699 this.params.set('images', images); 1700 this.params.set('loadedImages', []); 1701 this.params.set('thumb', ''); 1702 this.params.set('isGif', responseJSON.isGif); 1703 this.params.set('gifUrl',responseJSON.gifUrl); 1704 this.params.set('isIframe',responseJSON.isIframe); 1705 this.params.set('gifImageUrl',responseJSON.gifImageUrl); 1706 if(responseJSON.isGif){ 1707 this.elements.body.empty(); 1708 this.makeFormInputs(); 1709 scriptJquery('#compose-link-menu').hide(); 1710 scriptJquery('#compose-link-body').html('<div class="composer_link_gif_content_wrapper"><div class="composer_link_gif_content"><img src="'+responseJSON.gifImageUrl+'" data-original="'+responseJSON.gifUrl+'" data-still="'+responseJSON.gifImageUrl+'"><a href="javascript:;" class="link_play_activity notclose" title="'+en4.core.language.translate("PLAY")+'"></a><a href="javascript:;" class="link_cancel_activity"><i class="fas fa-times notclose" title="'+en4.core.language.translate("CANCEL")+'"></i></a></div></div>'); 1711 }else if(responseJSON.isIframe){ 1712 this.params.set('thumb', responseJSON.thumb); 1713 this.elements.body.empty(); 1714 this.makeFormInputs(); 1715 scriptJquery('#compose-link-menu').hide(); 1716 scriptJquery('#compose-link-body').html('<div class="composer_link_video_content_wrapper"><div class="composer_link_gif_content composer_link_iframe_content">'+responseJSON.thumb+'<a href="javascript:;" class="link_cancel_activity"><i class="fas fa-times notclose" title="'+en4.core.language.translate("CANCEL")+'"></i></a></div><div class="composer_link_iframe_content_body"><div class="compose-preview-title"><a target="_blank" href="'+responseJSON.url+'">'+title+'</a></div><div class="compose-preview-description">'+description+'</div></div></div>'); 1717 }else if( images.length > 0 ) { 1718 this.doLoadImages(); 1719 } else { 1720 this.doShowPreview(); 1721 } 1722 } 1723 1724 // Image loading 1725 1726 this.doLoadImages = function() { 1727 // Start image load timeout 1728 var interval = setTimeout(function() { 1729 // Debugging 1730 if( this.options.debug ) { 1731 console.log('Timeout reached'); 1732 } 1733 //this.doShowPreview(); 1734 }.bind(this),this.options.imageTimeout); 1735 1736 1737 // Load them images 1738 this.params.loadedImages = []; 1739 1740 let imgs = []; 1741 this.params.get('images').forEach(function(imgSrc){ 1742 let img = scriptJquery.crtEle('img',{ 1743 'src': imgSrc, 1744 'class' : 'compose-link-image' 1745 }); 1746 imgs.push(img); 1747 }); 1748 this.params.loadedImages = this.params.get('images'); 1749 this.params.set('assets',imgs); 1750 this.doShowPreview(); 1751 } 1752 1753 1754 // Preview generation 1755 1756 this.doShowPreview = function() { 1757 var self = this; 1758 this.elements.body.empty(); 1759 this.makeFormInputs(); 1760 1761 // Generate image thingy 1762 if( this.params.loadedImages.length > 0 ) { 1763 var tmp = new Array(); 1764 this.elements.previewImages = scriptJquery.crtEle('div', { 1765 'id' : 'compose-link-preview-images', 1766 'class' : 'compose-preview-images' 1767 }).appendTo(this.elements.body);
1768 this.params.assets.forEach(function(element, index) { 1769 if( !$type(this.params.loadedImages[index]) ) return; 1770 element.addClass('compose-preview-image-invisible').appendTo(this.elements.previewImages); 1771 if(false ) { 1772 delete this.params.images[index]; 1773 delete this.params.loadedImages[index]; 1774 element.destroy(); 1775 } else { 1776 element.removeClass('compose-preview-image-invisible').addClass('compose-preview-image-hidden'); 1777 tmp.push(this.params.loadedImages[index]); 1778 // element.erase('height'); 1779 // element.erase('width'); 1780 } 1781 }.bind(this)); 1782 1783 this.params.loadedImages = tmp; 1784 1785 if( this.params.loadedImages.length <= 0 ) { 1786 this.elements.previewImages.destroy(); 1787 } 1788 } 1789 1790 this.elements.previewInfo = scriptJquery.crtEle('div', { 1791 'id' : 'compose-link-preview-info', 1792 'class' : 'compose-preview-info' 1793 }).appendTo(this.elements.body); 1794 1795 // Generate title and description 1796 this.elements.previewTitle = scriptJquery.crtEle('div', { 1797 'id' : 'compose-link-preview-title', 1798 'class' : 'compose-preview-title' 1799 }).appendTo(this.elements.previewInfo); 1800 1801 this.elements.previewTitleLink = scriptJquery.crtEle('a', { 1802 'href' : this.params.uri, 1803 'events' : { 1804 'click' : function(e) { 1805 e.stop(); 1806 self.handleEditTitle(this); 1807 } 1808 } 1809 }).html(this.params.title).appendTo(this.elements.previewTitle).click((e) => { 1810 e.preventDefault(); 1811 self.handleEditTitle(e); 1812 });; 1813 1814 this.elements.previewDescription = scriptJquery.crtEle('div', { 1815 'id' : 'compose-link-preview-description', 1816 'class' : 'compose-preview-description', 1817 'events' : { 1818 'click' : function(e) { 1819 e.stop(); 1820 self.handleEditDescription(this); 1821 } 1822 } 1823 }).html(this.params.description).appendTo(this.elements.previewInfo).click((e) => { 1824 e.preventDefault(); 1825 self.handleEditDescription(e); 1826 }); 1827 1828 // Generate image selector thingy 1829 if( this.params.loadedImages.length > 0 ) { 1830 this.elements.previewOptions = scriptJquery.crtEle('div', { 1831 'id' : 'compose-link-preview-options', 1832 'class' : 'compose-preview-options' 1833 }).appendTo(this.elements.previewInfo); 1834 1835 if( this.params.loadedImages.length > 1 ) { 1836 this.elements.previewChoose = scriptJquery.crtEle('div', { 1837 'id' : 'compose-link-preview-options-choose', 1838 'class' : 'compose-preview-options-choose', 1839 'html' : '<span>' + this._lang('Choose Image:') + '</span>' 1840 }).html('<span>' + this._lang('Choose Image:') + '</span>').appendTo(this.elements.previewOptions); 1841 1842 this.elements.previewPrevious = scriptJquery.crtEle('a', { 1843 'id' : 'compose-link-preview-options-previous', 1844 'class' : 'compose-preview-options-previous', 1845 'href' : 'javascript:void(0);', 1846 'html' : '« ' + this._lang('Previous'), 1847 'events' : { 1848 'click' : this.doSelectImagePrevious.bind(this) 1849 } 1850 }).html('« ' + this._lang('Previous')).appendTo(this.elements.previewChoose).click((e) => { 1851 this.doSelectImagePrevious() 1852 }); 1853 1854 this.elements.previewCount = scriptJquery.crtEle('span', { 1855 'id' : 'compose-link-preview-options-count', 1856 'class' : 'compose-preview-options-count' 1857 }).appendTo(this.elements.previewChoose); 1858 1859 1860 this.elements.previewPrevious = scriptJquery.crtEle('a', { 1861 'id' : 'compose-link-preview-options-next', 1862 'class' : 'compose-preview-options-next', 1863 'href' : 'javascript:void(0);', 1864 'html' : this._lang('Next') + ' »', 1865 'events' : { 1866 'click' : this.doSelectImageNext() 1867 } 1868 }).html(this._lang('Next') + ' »').appendTo(this.elements.previewChoose).click((e)=>{ 1869 this.doSelectImageNext(); 1870 }); 1871 } 1872 1873 this.elements.previewNoImage = scriptJquery.crtEle('div', { 1874 'id' : 'compose-link-preview-options-none', 1875 'class' : 'compose-preview-options-none' 1876 }).appendTo(this.elements.previewOptions); 1877 1878 this.elements.previewNoImageInput = scriptJquery.crtEle('input', { 1879 'id' : 'compose-link-preview-options-none-input', 1880 'class' : 'compose-preview-options-none-input', 1881 'type' : 'checkbox', 1882 'events' : { 1883 'click' : this.doToggleNoImage.bind(this) 1884 } 1885 }).appendTo(this.elements.previewNoImage).change((e)=>{ 1886 this.doToggleNoImage(); 1887 }); 1888 1889 this.elements.previewNoImageLabel = scriptJquery.crtEle('label', { 1890 'for' : 'compose-link-preview-options-none-input', 1891 'html' : this._lang('Don\'t show an image'), 1892 'events' : { 1893 //'click' : this.doToggleNoImage.bind(this) 1894 } 1895 }).html(this._lang('Don\'t show an image')).appendTo(this.elements.previewNoImage); 1896 1897 // Show first image 1898 this.setImageThumb(this.elements.previewImages.children().eq(0)); 1899 } 1900 } 1901 1902 this.checkImageValid = function(element) { 1903 var size = element.getSize(); 1904 var sizeAlt = {x:element.get('width'),y:element.get('height')}; 1905 var width = sizeAlt.x || size.x; 1906 var height = sizeAlt.y || size.y; 1907 var pixels = width * height; 1908 var aspect = width / height; 1909 1910 // Debugging 1911 if( this.options.debug ) { 1912 console.log(element.get('src'), sizeAlt, size, width, height, pixels, aspect); 1913 } 1914 1915 // Check aspect 1916 if( aspect > this.options.imageMaxAspect ) { 1917 // Debugging 1918 if( this.options.debug ) { 1919 console.log('Aspect greater than max - ', element.get('src'), aspect, this.options.imageMaxAspect); 1920 } 1921 return false;
1922 } else if( aspect < this.options.imageMinAspect ) { 1923 // Debugging 1924 if( this.options.debug ) { 1925 console.log('Aspect less than min - ', element.get('src'), aspect, this.options.imageMinAspect); 1926 } 1927 return false; 1928 } 1929 // Check min size 1930 if( width < this.options.imageMinSize ) { 1931 // Debugging 1932 if( this.options.debug ) { 1933 console.log('Width less than min - ', element.get('src'), width, this.options.imageMinSize); 1934 } 1935 return false; 1936 } else if( height < this.options.imageMinSize ) { 1937 // Debugging 1938 if( this.options.debug ) { 1939 console.log('Height less than min - ', element.get('src'), height, this.options.imageMinSize); 1940 } 1941 return false; 1942 } 1943 // Check max size 1944 if( width > this.options.imageMaxSize ) { 1945 // Debugging 1946 if( this.options.debug ) { 1947 console.log('Width greater than max - ', element.get('src'), width, this.options.imageMaxSize); 1948 } 1949 return false; 1950 } else if( height > this.options.imageMaxSize ) { 1951 // Debugging 1952 if( this.options.debug ) { 1953 console.log('Height greater than max - ', element.get('src'), height, this.options.imageMaxSize); 1954 } 1955 return false; 1956 } 1957 // Check pixels 1958 if( pixels < this.options.imageMinPixels ) { 1959 // Debugging 1960 if( this.options.debug ) { 1961 console.log('Pixel count less than min - ', element.get('src'), pixels, this.options.imageMinPixels); 1962 } 1963 return false; 1964 } else if( pixels > this.options.imageMaxPixels ) { 1965 // Debugging 1966 if( this.options.debug ) { 1967 console.log('Pixel count greater than max - ', element.get('src'), pixels, this.options.imageMaxPixels); 1968 } 1969 return false; 1970 } 1971 1972 return true; 1973 } 1974 1975 this.doSelectImagePrevious = function() {
1976 let currentIndex = scriptJquery(this.elements.imageThumb).index(); 1977 let totalIndex = scriptJquery(this.elements.imageThumb).parent().children().length; 1978 let next = null; 1979 if(currentIndex != 0){ 1980 next = scriptJquery(this.elements.imageThumb).parent().children().eq(currentIndex-1); 1981 }else{ 1982 next = scriptJquery(this.elements.imageThumb).parent().children().eq(totalIndex-1); 1983 } 1984 if( this.elements.imageThumb && next.length > 0 ) { 1985 this.setImageThumb(next); 1986 } 1987 } 1988 1989 this.doSelectImageNext = function() { 1990 let currentIndex = scriptJquery(this.elements.imageThumb).index(); 1991 let totalIndex = scriptJquery(this.elements.imageThumb).parent().children().length; 1992 let next = null; 1993 if(currentIndex < totalIndex-1){ 1994 next = scriptJquery(this.elements.imageThumb).parent().children().eq(currentIndex+1); 1995 }else{ 1996 next = scriptJquery(this.elements.imageThumb).parent().children().eq(0); 1997 } 1998 if( this.elements.imageThumb && next.length > 0 ) { 1999 this.setImageThumb(next); 2000 } 2001 } 2002 this.setFormInputValue = function(key,value){ 2003 this.__proto__.setFormInputValue.call(this,key,value); 2004 } 2005 this.doToggleNoImage = function() { 2006 if( !scriptJquery("#compose-link-preview-options-none-input").is(':checked') ) { 2007 let elementA = scriptJquery(this.elements.imageThumb); 2008 this.params.thumb = elementA.attr("src"); 2009 this.setFormInputValue('thumb', this.params.thumb); 2010 this.elements.previewImages.css('display', ''); 2011 if( this.elements.previewChoose ) this.elements.previewChoose.css('display', ''); 2012 } else { 2013 delete this.params.thumb; 2014 this.setFormInputValue('thumb', ''); 2015 this.elements.previewImages.css('display', 'none'); 2016 if( this.elements.previewChoose ) this.elements.previewChoose.css('display', 'none'); 2017 } 2018 } 2019 2020 this.setImageThumb = function(element) { 2021 // Hide old thumb 2022 if( this.elements.imageThumb ) { 2023 this.elements.imageThumb.addClass('compose-preview-image-hidden'); 2024 } 2025 if( element ) { 2026 element.removeClass('compose-preview-image-hidden'); 2027 let elementA = scriptJquery(element); 2028 this.elements.imageThumb = element; 2029 this.params.thumb = elementA.attr("src"); 2030 this.setFormInputValue('thumb',elementA.attr("src")); 2031 if( this.elements.previewCount ) { 2032 var index = this.params.loadedImages.indexOf(elementA.attr("src")); 2033 //this.elements.previewCount.set('html', ' | ' + (index + 1) + ' of ' + this.params.loadedImages.length + ' | '); 2034 if ( index < 0 ) { index = 0; } 2035 this.elements.previewCount.html(' | ' + this._lang('%d of %d', index + 1, this.params.loadedImages.length) + ' | '); 2036 } 2037 } else { 2038 this.elements.imageThumb = false; 2039 delete this.params.thumb; 2040 } 2041 } 2042 2043 this.makeFormInputs = function() { 2044 this.ready(); 2045 2046 this.__proto__.makeFormInputs.call(this,{ 2047 'uri' : this.params.uri, 2048 'title' : this.params.title, 2049 'description' : this.params.description, 2050 'thumb' : this.params.thumb, 2051 'isGif' : this.params.isGif, 2052 'isIframe':this.params.isIframe, 2053 'gifUrl' : this.params.gifUrl, 2054 }); 2055 } 2056 2057 this.handleEditTitle = function(elementData) { 2058 let element = scriptJquery(elementData.target) 2059 element.css('display', 'none'); 2060 var input = scriptJquery.crtEle('input', { 2061 'type' : 'text', 2062 'value' : element.text().trim(), 2063 }).insertAfter(element).blur(function(e) { 2064 if( scriptJquery(e.target).val() != '' ) { 2065 this.params.title = scriptJquery(e.target).val(); 2066 element.text(this.params.title); 2067 this.setFormInputValue('title', this.params.title); 2068 } 2069 element.css('display', ''); 2070 input.remove(); 2071 }.bind(this)); 2072 input.focus(); 2073 } 2074 2075 this.handleEditDescription = function(elementData) { 2076 let element = scriptJquery(elementData.target) 2077 element.css('display', 'none'); 2078 var input = scriptJquery.crtEle('textarea', {}).html(element.text().trim()).insertAfter(element).blur(function(e) { 2079 if( scriptJquery(e.target).val() != '' ) { 2080 this.params.description = scriptJquery(e.target).val(); 2081 element.text(this.params.description); 2082 this.setFormInputValue('description', this.params.description); 2083 } 2084 element.css('display', ''); 2085 input.remove(); 2086 }.bind(this)); 2087 input.focus(); 2088 } 2089 this.initialize(options); 2090} 2091 2092 2093AttachEventListerSE('click','.link_play_activity',function(e){ 2094 scriptJquery('.link_play_activity').show(); 2095 //loop over all item and hide
2096 scriptJquery('.composer_link_gif_content').each(function(i, obj) { 2097 scriptJquery(obj).find('img').attr('src',scriptJquery(obj).find('img').attr('data-still')); 2098 }); 2099 scriptJquery(this).closest('.composer_link_gif_content').find('img').attr('src',scriptJquery(this).closest('.composer_link_gif_content').find('img').attr('data-original')); 2100 scriptJquery(this).hide(); 2101 if(!scriptJquery(this).closest('.feed_attachment_core_link').length) 2102 scriptJquery('.compose-link-menu').hide(); 2103}); 2104AttachEventListerSE('click','.composer_link_gif_content > img',function(){ 2105 scriptJquery(this).closest('.composer_link_gif_content').find('.link_play_activity').show(); 2106 scriptJquery(this).closest('.composer_link_gif_content').find('img').attr('src',scriptJquery(this).closest('.composer_link_gif_content').find('img').attr('data-still')); 2107}); 2108AttachEventListerSE('click','.link_cancel_activity',function(){ 2109 Object.entries(composeInstance.plugins).forEach(function([key,plugin]) { 2110 plugin.deactivate(); 2111 scriptJquery('#fancyalbumuploadfileids').val(''); 2112 }); 2113 composeInstance.getTray().empty(); 2114}); 2115 2116/* $Id:composer_targetpost.js 2017-01-12 00:00:00 SocialEngineSolutions $*/ 2117 2118Composer.Plugin.Activitytargetpost = function(options){ 2119 2120 this.__proto__ = new Composer.Plugin.Interface(options); 2121 this.name = 'targetpost' 2122 this.options = { 2123 title : en4.core.language.translate("Choose Preferred Audience"), 2124 lang : { 2125 'Choose Preferred Audience': 'Choose Preferred Audience' 2126 }, 2127 requestOptions : false 2128 } 2129 this.initialize = function(options) { 2130 this.elements = new Hash(this.elements); 2131 this.params = new Hash(this.params); 2132 this.__proto__.initialize.call(this,scriptJquery.extend(options,this.__proto__.options)); 2133 } 2134 this.attach = function() { 2135 var openWindow = ''; 2136 2137 this.elements.spanToggle = scriptJquery.crtEle('span', { 2138 'class' : 'composer_targetpost_toggle activity_tooltip', 2139 'href' : 'javascript:void(0);', 2140 'title' : this.options.lang['Choose Preferred Audience'] 2141 }) 2142 this.elements.formCheckbox = scriptJquery.crtEle('input', { 2143 'id' : 'compose-targetpost-form-input', 2144 'class' : 'compose-form-input', 2145 'type' : 'checkbox', 2146 'name' : 'post_to_targetpost', 2147 'style' : 'display:none;' 2148 }); 2149 2150 this.elements.formCheckbox.appendTo(this.elements.spanToggle) 2151 //this.elements.spanTooltip.inject(this.elements.spanToggle); 2152 this.elements.spanToggle.appendTo(scriptJquery('#compose-menu')).click((e) => { 2153 this.toggle(); 2154 });;; 2155 //this.parent(); 2156 //this.makeActivator(); 2157 return this; 2158 } 2159 this.detach = function() { 2160 this.__proto__.detach.call(this); 2161 this.active = false 2162 if( this.interval ) $clear(this.interval); 2163 return this; 2164 } 2165 this.toggle = function(event) { 2166 //open target post popup 2167 openTargetPostPopup(); 2168 composeInstance.plugins['targetpost'].active=true; 2169 setTimeout(function(){ 2170 composeInstance.plugins['targetpost'].active=false; 2171 }, 300); 2172 } 2173 this.initialize(options); 2174}; 2175 2176 2177/* $Id:editComposer.js 2017-01-12 00:00:00 SocialEngineSolutions $*/ 2178 2179AttachEventListerSE('click','#activity_location_edit, .seloc_clk_edit',function(e){ 2180 that = scriptJquery(this); 2181 if(scriptJquery(this).hasClass('.seloc_clk_edit')) 2182 that = scriptJquery('#activity_location_edit'); 2183 if(scriptJquery(this).hasClass('active')){ 2184 scriptJquery(this).removeClass('active'); 2185 scriptJquery('.activity_post_location_container_edit').hide(); 2186 return; 2187 } 2188 scriptJquery('.activity_post_location_container_edit').show(); 2189 scriptJquery(this).addClass('active'); 2190}); 2191AttachEventListerSE('click','#activity_tag_edit, .tag_clk_edit',function(e){ 2192 that = scriptJquery(this); 2193 if(scriptJquery(this).hasClass('.tag_clk_edit')) 2194 that = scriptJquery('#activity_tag_edit'); 2195 if(scriptJquery(that).hasClass('active')){ 2196 scriptJquery(that).removeClass('active'); 2197 scriptJquery('.activity_post_tag_cnt_edit').hide(); 2198 return; 2199 } 2200 scriptJquery('.activity_post_tag_cnt_edit').show(); 2201 scriptJquery(that).addClass('active'); 2202}); 2203 2204 2205//Feelings Work 2206AttachEventListerSE('click','#activity_feelings_editspan',function(e){ 2207 that = scriptJquery(this); 2208 if(scriptJquery(this).hasClass('.seloc_clk_edit')) 2209 that = scriptJquery('#activity_feelings_editspan'); 2210 if(scriptJquery(this).hasClass('active')){ 2211 scriptJquery(this).removeClass('active'); 2212 scriptJquery('.activity_post_feelingcontent_containeredit').hide(); 2213 scriptJquery('.activity_post_feeling_container_edit').hide(); 2214 return; 2215 } 2216 scriptJquery(this).addClass('active'); 2217 scriptJquery('.activity_post_feeling_container_edit').show(); 2218 if(scriptJquery('#feelingactivityidedit').val() == '') 2219 scriptJquery('.activity_post_feelingcontent_containeredit').show(); 2220}); 2221 2222AttachEventListerSE('click', '#feeling_activityedit', function(e){ 2223 2224 if(scriptJquery('#feelingactivityidedit').val() == '') 2225 scriptJquery('.activity_post_feelingcontent_containeredit').show(); 2226}); 2227 2228AttachEventListerSE('keyup', '#feeling_activityedit', function(e){ 2229 if (e.which == 8) { 2230 scriptJquery('#feelingactivityiconidedit').val() = ''; 2231 scriptJquery('#feeling_elem_actedit').html(''); 2232 scriptJquery('#feeling_activityedit').attr("placeholder", "How are you feeling?"); 2233 } 2234}); 2235 2236function showFeelingContanieredit() { 2237 2238 if(scriptJquery('#activity_post_feeling_container_edit').css("display") == '' || scriptJquery('#activity_post_feeling_container_edit').css("display") == 'table') { 2239 scriptJquery('#showFeelingContanieredit').removeClass('active'); 2240 scriptJquery('#activity_post_feeling_container_edit').hide(); 2241 } else { 2242 scriptJquery('#showFeelingContanieredit').addClass('active'); 2243 scriptJquery('#feeling_activity_remove_actedit').show(); 2244 scriptJquery('#activity_post_feeling_container_edit').show(); 2245 } 2246} 2247 2248function feelingactivityremoveactedit() { 2249 scriptJquery('#feeling_activity_remove_actedit').hide(); 2250 scriptJquery('#feelingActTypeedit').html(''); 2251 scriptJquery('#feelingActTypeedit').hide(); 2252 scriptJquery('.activityfeelingactivity-ul').html(''); 2253 if(scriptJquery('#feelingactivityidedit').val()) 2254 scriptJquery('#feelingactivityidedit').val(""); 2255 scriptJquery('#feeling_activityedit').val(''); 2256 scriptJquery('#feelingactivityiconidedit').val(""); 2257 scriptJquery('#feeling_elem_actedit').html(''); 2258 2259} 2260 2261//Autosuggest feeling work 2262AttachEventListerSE('click', '.activity_feelingactivitytypeliedit', function(e) { 2263 2264 scriptJquery('#feelingactivityiconidedit').val(scriptJquery(this).attr('data-rel')); 2265 scriptJquery('#feelingactivity_resource_typeedit').val(scriptJquery(this).attr('data-type')) 2266 2267 if(!scriptJquery(this).attr('data-rel')) { 2268 scriptJquery('#feelingactivity_customedit').val(1); 2269 scriptJquery('#feelingactivity_customtextedit').val(scriptJquery('#feeling_activityedit').val()); 2270 } 2271 2272 if(scriptJquery(this).attr('data-icon')) { 2273 var finalFeeling = '-- ' + '<img class="feeling_icon" title="'+scriptJquery(this).attr('data-title')+'" src="'+scriptJquery(this).attr('data-icon')+'"><span>' + ' ' + scriptJquery('#feelingActTypeedit').html().toLowerCase() + ' ' + '<a href="javascript:;" id="showFeelingContanieredit" class="" onclick="showFeelingContanieredit()">'+scriptJquery(this).attr('data-title')+'</a>'; 2274 } else { 2275 var finalFeeling = '-- ' + '<img class="feeling_icon" title="'+scriptJquery(this).attr('data-title')+'" src="'+scriptJquery(this).find('a').find('img').attr('src')+'"><span>' + ' ' + scriptJquery('#feelingActTypeedit').html().toLowerCase() + ' ' + '<a href="javascript:;" id="showFeelingContanieredit" class="" onclick="showFeelingContanieredit()">'+scriptJquery(this).attr('data-title')+'</a>'; 2276 } 2277 2278 scriptJquery('#feeling_activityedit').val(scriptJquery(this).attr('data-title')); 2279 scriptJquery('#feeling_elem_actedit').show(); 2280 scriptJquery('#feeling_elem_actedit').html(finalFeeling); 2281 scriptJquery('#dash_elem_act_edit').hide(); 2282 scriptJquery('#activity_post_feeling_container_edit').hide(); 2283}); 2284//Autosuggest feeling work 2285 2286 2287AttachEventListerSE('click', '.activity_feelingactivitytypeedit', function(e) { 2288 2289 var feelingsactivity = scriptJquery(this); 2290 var feelingIdEdit = scriptJquery(this).attr('data-rel'); 2291 var feelingTypeEdit = scriptJquery(this).attr('data-type'); 2292 var feelingTitleEdit = scriptJquery(this).attr('data-title'); 2293 scriptJquery('#feelingActTypeedit').show(); 2294 scriptJquery('#feelingActTypeedit').html(feelingTitleEdit); 2295 scriptJquery('#feeling_activityedit').attr("placeholder", "How are you feeling?"); 2296 2297 document.getElementById('feelingactivityidedit').value = feelingIdEdit; 2298 2299 document.getElementById('feelingactivitytypeedit').value = feelingTypeEdit; 2300 2301 scriptJquery('.activity_post_feelingcontent_containeredit').hide(); 2302 2303 scriptJquery('#feeling_activityedit').trigger('change').trigger('keyup').trigger('keydown'); 2304 2305// contentAutocompletefeelingedit.setOptions({ 2306// 'postData': { 2307// 'feeling_id': document.getElementById('feelingactivityidedit').value, 2308// 'feeling_type': document.getElementById('feelingactivitytypeedit').value, 2309// } 2310// }); 2311}); 2312 2313AttachEventListerSE('click','.select_feeling_emoji_advedit > img',function(e){ 2314 2315 var feeling_emoji_icon = scriptJquery(this).parent().parent().attr('data-icon'); 2316 var html = scriptJquery('#edit_activity_body').val(); 2317 if(html == '<br>') 2318 scriptJquery('#edit_activity_body').val(''); 2319 scriptJquery('textarea#edit_activity_body').val(scriptJquery('textarea#edit_activity_body').val()+' '+feeling_emoji_icon); 2320 2321 var data = scriptJquery('#edit_activity_body').val(); 2322 EditFieldValue = data; 2323 2324 scriptJquery('textarea#edit_activity_body').trigger('focus'); 2325// scriptJquery('#activityfeeling_emoji-edit-a').trigger('click'); 2326}); 2327//Feeling Work End 2328 2329var requestEmojiA; 2330AttachEventListerSE('click','#activityemoji-edit-a',function(){ 2331 2332 scriptJquery(this).parent().find('.comment_emotion_container').removeClass('from_bottom'); 2333 2334 var parentElem = scriptJquery('#ajaxsmoothbox_container'); 2335 var parentLeft = parentElem.css('left').replace('px',''); 2336 var parentTop = parentElem.css('top').replace('px',''); 2337 2338 var topPositionOfParentDiv = scriptJquery(this).offset().top + 35; 2339 topPositionOfParentDiv = topPositionOfParentDiv; 2340 var leftSub = 264; 2341 var leftPositionOfParentDiv = scriptJquery(this).offset().left - leftSub; 2342 leftPositionOfParentDiv = leftPositionOfParentDiv+'px'; 2343 scriptJquery(this).parent().find('.comment_emotion_container').css('right',0); 2344 //scriptJquery(this).parent().find('.comment_emotion_container').css('top',topPositionOfParentDiv+'px'); 2345 //scriptJquery(this).parent().find('.comment_emotion_container').css('left',leftPositionOfParentDiv).css('z-index',100); 2346 scriptJquery(this).parent().find('.comment_emotion_container').show(); 2347 2348 if(scriptJquery(this).hasClass('active')){ 2349 scriptJquery(this).removeClass('active'); 2350 scriptJquery('#activityemoji_edit').hide(); 2351 return false;
2352 } 2353 scriptJquery(this).addClass('active'); 2354 scriptJquery('#activityemoji_edit').show(); 2355 if(scriptJquery(this).hasClass('complete')) 2356 return false; 2357 2358 var that = this; 2359 var url = en4.core.baseUrl + 'activity/ajax/emoji/edit/true'; 2360 requestEmojiA = scriptJquery.ajax({ 2361 url : url, 2362 data : { 2363 format : 'html', 2364 }, 2365 evalScripts : true, 2366 success : function(responseHTML) { 2367 scriptJquery('#activityemoji_edit').find('.comment_emotion_container_inner').find('.comment_emotion_holder').html(responseHTML); 2368 scriptJquery(that).addClass('complete'); 2369 activitytooltip(); 2370 } 2371 }); 2372}); 2373 2374AttachEventListerSE('click','.select_emoji_advedit > img',function(e){ 2375 var code = scriptJquery(this).parent().parent().attr('rel'); 2376 var html = scriptJquery('#edit_activity_body').val(); 2377 if(html == '<br>') 2378 scriptJquery('#edit_activity_body').val(''); 2379 scriptJquery('#edit_activity_body').val( scriptJquery('#edit_activity_body').val()+' '+code); 2380 var data = scriptJquery('#edit_activity_body').val(); 2381 EditFieldValue = data; 2382 scriptJquery('#activityemoji-edit-a').trigger('click'); 2383}); 2384 2385AttachEventListerSE('click','.adv_privacy_optn_edit li a',function(e){ 2386 e.preventDefault(); 2387 if(!scriptJquery(this).parent().hasClass('multiple')){ 2388 scriptJquery('.adv_privacy_optn_edit > li').removeClass('active'); 2389 var text = scriptJquery(this).text(); 2390 scriptJquery('.activity_privacy_btn_edit').attr('title',text);; 2391 scriptJquery(this).parent().addClass('active'); 2392 scriptJquery('#adv_pri_option_edit').html(text); 2393 scriptJquery('#activity_privacy_icon').remove(); 2394 scriptJquery('<i id="activity_privacy_icon" class="'+scriptJquery(this).find('i').attr('class')+'"></i>').insertBefore('#adv_pri_option_edit'); 2395 2396 if(scriptJquery(this).parent().hasClass('activity_network_edit')) 2397 scriptJquery('#privacy_edit').val(scriptJquery(this).parent().attr('data-src')+'_'+scriptJquery(this).parent().attr('data-rel')); 2398 else if(scriptJquery(this).parent().hasClass('activity_list_edit')) 2399 scriptJquery('#privacy_edit').val(scriptJquery(this).parent().attr('data-src')+'_'+scriptJquery(this).parent().attr('data-rel')); 2400 else 2401 scriptJquery('#privacy_edit').val(scriptJquery(this).parent().attr('data-src')); 2402 } 2403 // scriptJquery('.activity_privacy_btn_edit').parent().removeClass('activity_pulldown_active'); 2404}); 2405 2406AttachEventListerSE('click','.mutiselectedit',function(e){ 2407 if(scriptJquery(this).attr('data-rel') == 'network-multi') 2408 var elem = 'activity_network_edit'; 2409 else 2410 var elem = 'activity_list_edit'; 2411 var elemens = scriptJquery('.'+elem); 2412 var html = ''; 2413 for(i=0;i<elemens.length;i++){ 2414 html += '<li><input class="checkbox" type="checkbox" value="'+scriptJquery(elemens[i]).attr('data-rel')+'">'+scriptJquery(elemens[i]).text()+'</li>'; 2415 } 2416 en4.core.showError('<form id="'+elem+'_select" class="activity_privacyselectpopup"><p>Please select network to display post</p><ul class="clearfix">'+html+'</ul><div class="activity_privacyselectpopup_btns clearfix"><button type="submit">Save</button><button class="close" onclick="Smoothbox.close();return false;">Close</button></div></form>'); 2417 scriptJquery ('.activity_privacyselectpopup').parent().parent().addClass('activity_privacyselectpopup_wrapper'); 2418 //pre populate 2419 var valueElem = scriptJquery('#privacy_edit').val(); 2420 if(valueElem && valueElem.indexOf('network_list_') > -1 && elem == 'activity_network_edit'){ 2421 var exploidV = valueElem.split(','); 2422 for(i=0;i<exploidV.length;i++){ 2423 var id = exploidV[i].replace('network_list_',''); 2424 scriptJquery('.checkbox[value="'+id+'"]').prop('checked', true); 2425 } 2426 }else if(valueElem && valueElem.indexOf('member_list_') > -1 && elem == 'activity_list_edit'){ 2427 var exploidV = valueElem.split(','); 2428 for(i=0;i<exploidV.length;i++){ 2429 var id = exploidV[i].replace('member_list_',''); 2430 scriptJquery('.checkbox[value="'+id+'"]').prop('checked', true); 2431 } 2432 } 2433}); 2434 2435AttachEventListerSE('submit','#activity_list_edit_select',function(e){ 2436 e.preventDefault(); 2437 var isChecked = false;
2438 var activity_list_select = scriptJquery('#activity_list_edit_select').find('[type="checkbox"]'); 2439 var valueL = ''; 2440 for(i=0;i<activity_list_select.length;i++){ 2441 if(!isChecked) 2442 scriptJquery('.adv_privacy_optn_edit > li').removeClass('active'); 2443 if(scriptJquery(activity_list_select[i]).is(':checked')){ 2444 isChecked = true; 2445 var el = scriptJquery(activity_list_select[i]).val(); 2446 scriptJquery('.lists[data-rel="'+el+'"]').addClass('active'); 2447 valueL = valueL+'member_list_'+el+','; 2448 } 2449 } 2450 if(isChecked){ 2451 scriptJquery('#privacy_edit').val(valueL); 2452 scriptJquery('#adv_pri_option_edit').html(en4.core.translate("Multiple Lists")); 2453 scriptJquery('.activity_privacy_btn_edit').attr('title',en4.core.translate("Multiple Lists")); 2454 scriptJquery(this).find('.close').trigger('click'); 2455 } 2456 scriptJquery('#activity_privacy_icon_edit').removeAttr('class').addClass('activity_list'); 2457}); 2458AttachEventListerSE('submit','#activity_network_edit_select',function(e){ 2459 e.preventDefault(); 2460 var isChecked = false; 2461 var activity_network_select = scriptJquery('#activity_network_edit_select').find('[type="checkbox"]'); 2462 var valueL = ''; 2463 for(i=0;i<activity_network_select.length;i++){ 2464 if(!isChecked) 2465 scriptJquery('.adv_privacy_optn_edit > li').removeClass('active'); 2466 if(scriptJquery(activity_network_select[i]).is(':checked')){ 2467 isChecked = true; 2468 var el = scriptJquery(activity_network_select[i]).val(); 2469 scriptJquery('.network[data-rel="'+el+'"]').addClass('active'); 2470 valueL = valueL+'network_list_'+el+','; 2471 } 2472 } 2473 if(isChecked){ 2474 scriptJquery('#privacy_edit').val(valueL); 2475 scriptJquery('#adv_pri_option_edit').html('Multiple Network'); 2476 scriptJquery('.activity_privacy_btn_edit').attr('title','Multiple Network');; 2477 scriptJquery(this).find('.close').trigger('click'); 2478 } 2479 scriptJquery('#activity_privacy_icon_edit').removeAttr('class').addClass('activity_network'); 2480}); 2481 2482function tagLocationWorkEdit(){ 2483 if(!scriptJquery('#tag_location_edit').val()) 2484 return; 2485 scriptJquery('#locValuesEdit-element').html('<span class="tag">'+scriptJquery('#tag_location_edit').val()+' <a href="javascript:void(0);" class="loc_remove_act_edit">x</a></span>'); 2486 scriptJquery('#dash_elem_act_edit').show(); 2487 scriptJquery('#location_elem_act_edit').show(); 2488 scriptJquery('#location_elem_act_edit').html('at <a href="javascript:;" class="seloc_clk_edit">'+scriptJquery('#tag_location_edit').val()+'</a>'); 2489 scriptJquery('#tag_location_edit').hide(); 2490 } 2491 2492 2493 AttachEventListerSE('click','.loc_remove_act_edit',function(e){ 2494 scriptJquery('#activitylngEdit').val(''); 2495 scriptJquery('#activitylatEdit').val(''); 2496 scriptJquery('#tag_location_edit').val(''); 2497 scriptJquery('#locValuesEdit-element').html(''); 2498 scriptJquery('#tag_location_edit').show(); 2499 scriptJquery('#location_elem_act_edit').hide(); 2500 if(!scriptJquery('#toValuesEdit-element').children().length) 2501 scriptJquery('#dash_elem_act_edit').hide(); 2502 }) 2503// Populate data 2504 var maxRecipientsEdit = 50; 2505 2506 function getMentionDataEdit(that,dataBody){ 2507 var data = scriptJquery('#edit_activity_body').val(); 2508 var data_status = scriptJquery(that).attr('data-status'); 2509 2510 if(scriptJquery('#buysell-title-edit').length) { 2511 if(!scriptJquery('#buysell-title-edit').val()) 2512 return false; 2513 else if(!scriptJquery('#buysell-price-edit').val()) 2514 return false; 2515 } 2516 //Feeling Work 2517 else if(!data && data_status == 1 && !scriptJquery('#toValuesEdit').val() && !scriptJquery('#tag_location_edit').val() && !scriptJquery('#feeling_activityedit').val()) 2518 return false; 2519 2520 data = scriptJquery(that).serialize()+'&bodyText='+dataBody; 2521 var url = en4.core.baseUrl + 'activity/index/edit-feed-post/userphotoalign/'+userphotoalign; 2522 scriptJquery(that).find('#compose-submit').attr('disabled',true); 2523 if(url.indexOf('&') <= 0) 2524 url = url+'?'; 2525 url = url+'is_ajax=true'; 2526 var that = that; 2527 scriptJquery(that).find('#compose-submit').html(savingtextActivityPost); 2528 //scriptJquery('#dots-animation-posting').show(); 2529 //dotsAnimationWhenPostingInterval = setInterval (function() { dotsAnimationWhenPostingFn(sharingPostText)}, 600); 2530 activityfeedactive2 = scriptJquery.ajax({ 2531 url : url, 2532 data:data, 2533 method:"POST", 2534 success : function( responseHTML){ 2535 try{ 2536 var parseJson = scriptJquery.parseJSON(responseHTML); 2537 if(parseJson.status){ 2538 scriptJquery('#activity-item-'+parseJson.last_id).replaceWith(parseJson.feed); 2539 2540 scriptJquery('#activity-item-'+parseJson.last_id).fadeOut("slow", function(){ 2541 scriptJquery('#activity-item-'+parseJson.last_id).replaceWith(parseJson.feed); 2542 scriptJquery('#activity-item-'+parseJson.last_id).fadeIn("slow"); 2543 activitytooltip(); 2544 }); 2545 2546 ajaxsmoothboxclose(); 2547 }else{ 2548 en4.core.showError("<p>" + en4.core.language.translate("An error occured. Please try again after some time.") + '</p><button onclick="Smoothbox.close()">Close</button>'); 2549 } 2550 }catch(e){ 2551 2552 } 2553 scriptJquery(that).find('#compose-submit').html(savingtextActivityPostOriginal); 2554 scriptJquery(that).find('#compose-submit').removeAttr('disabled'); 2555 2556 }, 2557 onError: function(){ 2558 en4.core.showError("<p>" + en4.core.language.translate("An error occured. Please try again after some time.") + '</p><button onclick="Smoothbox.close()">Close</button>'); 2559 }, 2560 }); 2561 } 2562 //submit form 2563 AttachEventListerSE('submit','.edit-activity-form',function(e){ 2564 e.preventDefault(); 2565 var that = this; 2566 scriptJquery('textarea#edit_activity_body').mentionsInput('val', function(data) { 2567 getMentionDataEdit(that,data); 2568 }); 2569 }); 2570 AttachEventListerSE('click','.composer_targetpost_edit_toggle',function(e){ 2571 openTargetPostPopupEdit(); 2572 }); 2573 2574 function setCaretPos(pos) { 2575 this.lastCaretPos = pos; 2576 var index = 0, range = document.createRange(), body = scriptJquery('#edit_activity_body')[0]; 2577 range.setStart(body, 0); 2578 range.collapse(true); 2579 var nodeArray = [body], node, isStart = false, stop = false;
2580 2581 while (!stop && (node = nodeArray.pop())) { 2582 if (node.nodeType === 3) { 2583 var nextIndex = index + node.length; 2584 if (!isStart && pos >= index && pos <= nextIndex) { 2585 range.setStart(node, pos - index); 2586 isStart = true; 2587 } else if (isStart && pos >= index && pos <= nextIndex) { 2588 range.setEnd(node, pos - index); 2589 stop = true; 2590 } 2591 index = nextIndex; 2592 } else { 2593 var i = node.childNodes.length; 2594 while (i--) { 2595 nodeArray.push(node.childNodes[i]); 2596 } 2597 } 2598 } 2599 var selection = window.getSelection(); 2600 selection.removeAllRanges(); 2601 selection.addRange(range); 2602 2603 } 2604 function checkPostLength(e) { 2605 var content = scriptJquery('#edit_activity_body').val(); 2606 content = content.replace(/ /g, ' '); 2607 content = content.replace(/&/g, '&'); 2608 content = content.replace(/</g, '<'); 2609 content = content.replace(/>/g, '>'); 2610 let activity_feedLimit = scriptJquery("#edit_activity_body").attr("data-length"); 2611 if(parseInt(activity_feedLimit) > 0){ 2612 activity_feedLimit = parseInt(activity_feedLimit); 2613 } 2614 if(activity_feedLimit && parseInt(activity_feedLimit) > 0 && activity_feedLimit < content.length){ 2615 content = content.substr(0,activity_feedLimit); 2616 scriptJquery("#edit_activity_body").html(content); 2617 } 2618 if(activity_feedLimit && parseInt(activity_feedLimit) > 0){ 2619 scriptJquery(".compose-content-counter-edit").css("display","inline-block"); 2620 scriptJquery(".compose-content-counter-edit").html(activity_feedLimit-content.length); 2621 return; 2622 } 2623 } 2624 2625 AttachEventListerSE('input','#edit_activity_body',function(e){ 2626 checkPostLength(e); 2627 }); 2628 2629 AttachEventListerSE('focus','#edit_activity_body',function(){ 2630if(!scriptJquery(this).attr('id')) 2631 scriptJquery(this).attr('id',new Date().getTime()); 2632 2633 isonCommentBox = true; 2634 var data = scriptJquery(this).val(); 2635 if(!scriptJquery(this).val() || isOnEditField){ 2636 if(!scriptJquery(this).val() ) 2637 EditFieldValue = ''; 2638 2639 //if(userTagsEnable) { 2640 scriptJquery(this).mentionsInput({ 2641 onDataRequest:function (mode, query, callback) { 2642 scriptJquery.getJSON('activity/ajax/friends/query/'+query, function(responseData) { 2643 responseData = _.filter(responseData, function(item) { return item.name.toLowerCase().indexOf(query.toLowerCase()) > -1 }); 2644 callback.call(this, responseData); 2645 }); 2646 }, 2647 //defaultValue: EditFieldValue, 2648 onCaret: true 2649 }); 2650 //} 2651 } 2652 2653 if(data){ 2654 getDataMentionEdit(this,data); 2655 } 2656 2657 if(!scriptJquery(this).parent().hasClass('typehead')){ 2658 scriptJquery(this).hashtags(); 2659 scriptJquery(this).focus(); 2660 } 2661 autosize(scriptJquery(this)); 2662}); 2663AttachEventListerSE('keyup','#edit_activity_body',function(){ 2664 var data = scriptJquery(this).val(); 2665 EditFieldValue = data; 2666}); 2667 2668 2669/* $Id: composer_music.js 9572 2011-12-27 23:41:06Z john $ */ 2670 2671var musicfeedupload = false;
2672Composer.Plugin.Music = function(options) { 2673 2674 this.__proto__ = new Composer.Plugin.Interface(options); 2675 2676 this.name = 'music'; 2677 2678 this.options = { 2679 title : 'Add Music', 2680 lang : {}, 2681 requestOptions : false, 2682 fancyUploadEnabled : true, 2683 fancyUploadOptions : {}, 2684 debug : ('en4' in window && en4.core.environment == 'production' ? false : true ) 2685 }; 2686 2687 this.initialize = function(options) { 2688 this.elements = new Hash(this.elements); 2689 this.params = new Hash(this.params); 2690 this.__proto__.initialize.call(this,scriptJquery.extend(options,this.__proto__.options)); 2691 }; 2692 2693 this.attach = function() { 2694 this.__proto__.attach.call(this); 2695 this.makeActivator(); 2696 return this; 2697 } 2698 2699 this.detach = function() { 2700 this.__proto__.detach.call(this); 2701 return this; 2702 } 2703 2704 this.activate = function() { 2705 if( this.active ) return; 2706 this.__proto__.activate.call(this); 2707 2708 this.makeMenu(); 2709 this.makeBody(); 2710 2711 2712 // Generate form 2713 var fullUrl = this.options.requestOptions.url; 2714 this.elements.form = scriptJquery.crtEle('form', { 2715 'id' : 'compose-music-form', 2716 'class' : 'compose-form', 2717 'method' : 'post', 2718 'action' : fullUrl, 2719 'enctype' : 'multipart/form-data' 2720 }).appendTo(this.elements.body); 2721 2722 this.elements.formInput = scriptJquery.crtEle('input', { 2723 'id' : 'compose-music-form-input', 2724 'class' : 'compose-form-input', 2725 'type' : 'file', 2726 'name' : 'file', 2727 'accept' : 'audio/*', 2728 }) 2729 .change(this.doRequest.bind(this)) 2730 .appendTo(this.elements.form); 2731 2732 var byteMB = (post_max_size / (1024 * 1024)) + en4.core.language.translate("MB"); 2733 byteMB = en4.core.language.translate('Max size ') + byteMB; 2734 scriptJquery(this.elements.form).append('<span class="font_color_light">('+byteMB+')</span>'); 2735 } 2736 2737 this.deactivate = function() { 2738 if (this.params.song_id) 2739 scriptJquery.ajax({ 2740 url: en4.core.basePath + 'music/remove-song', 2741 dataType : 'json', 2742 method : 'post', 2743 data: { 2744 format: 'json', 2745 song_id: this.params.song_id 2746 } 2747 }); 2748 if( !this.active ) return; 2749 this.__proto__.deactivate.call(this); 2750 }; 2751 2752 this.doRequest = function(that) { 2753 2754 if (this.elements.formInput[0].files.length > 0) { 2755 var FileSize = this.elements.formInput[0].files[0].size / 1024 / 1024; // in MB 2756 if(FileSize > post_max_size) { 2757 alert("The size of the file exceeds the limits set on the server."); 2758 scriptJquery(this.elements.formInput).val(''); 2759 return; 2760 } 2761 } 2762 2763 var submittedForm = false; 2764 this.elements.iframe = scriptJquery.crtEle('iframe',{ 2765 'name' : 'composeMusicFrame', 2766 'src' : 'javascript:false;', 2767 }) 2768 .css({'display' : 'none'}) 2769 .load(function() { 2770 if( !submittedForm ) { 2771 return; 2772 } 2773 musicfeedupload = false; 2774 this.doProcessResponse(window._composeMusicResponse); 2775 window._composeMusicResponse = false; 2776 }.bind(this)) 2777 .appendTo(this.elements.body); 2778 2779 window._composeMusicResponse = false; 2780 this.elements.form.attr('target', 'composeMusicFrame'); 2781 2782 musicfeedupload = true; 2783 // Submit and then remove form 2784 this.elements.form.trigger("submit"); 2785 submittedForm = true; 2786 this.elements.form.remove(); 2787 2788 // Start loading screen 2789 this.makeLoading(); 2790 } 2791 2792 this.makeLoading = function(action) { 2793 if( !this.elements.loading ) { 2794 if( action == 'empty' ) { 2795 this.elements.body.empty(); 2796 } else if( action == 'hide' ) { 2797 this.elements.body.children().each(function(e){ scriptJquery(this).css('display', 'none')}); 2798 } else if( action == 'invisible' ) { 2799 this.elements.body.children().each(function(e){ scriptJquery(this).css('height', '0px').css('visibility', 'hidden')}); 2800 } 2801 2802 this.elements.loading = scriptJquery.crtEle('div', { 2803 'id' : 'compose-' + this.getName() + '-loading', 2804 'class' : 'compose-loading' 2805 }).appendTo(this.elements.body); 2806 2807 var image = this.elements.loadingImage || (scriptJquery.crtEle('img', { 2808 'id' : 'compose-' + this.getName() + '-loading-image', 2809 'class' : 'compose-loading-image' 2810 })); 2811 2812 image.appendTo(this.elements.loading); 2813 2814 scriptJquery.crtEle('span', {}).html(this._lang('Loading song, please wait...')).appendTo(this.elements.loading); 2815 } 2816 } 2817 2818 this.doProcessResponse = function(responseJSON) { 2819 2820 if( typeof responseJSON == 'object' && typeof responseJSON.error != 'undefined' ) { 2821 if( this.elements.loading ) { 2822 this.elements.loading.remove(); 2823 } 2824 return this.makeError(responseJSON.error, 'empty'); 2825 } 2826 2827 // An error occurred 2828 if ( ($type(responseJSON) != 'object' && $type(responseJSON) != 'hash' )) { 2829 if( this.elements.loading ) 2830 this.elements.loading.remove(); 2831 this.makeError(this._lang('Unable to upload music. Please click cancel and try again'), 'empty'); 2832 return; 2833 } 2834 2835 if ( $type(parseInt(responseJSON.id)) != 'number' ) { 2836 if( this.elements.loading ) 2837 this.elements.loading.remove(); 2838 this.makeError(this._lang('Song got lost in the mail. Please click cancel and try again'), 'empty'); 2839 return; 2840 } 2841 // Success 2842 this.params.set('rawParams', responseJSON); 2843 this.params.set('song_id', responseJSON.id); 2844 this.params.set('song_title', responseJSON.fileName); 2845 this.params.set('song_url', responseJSON.song_url); 2846 this.elements.preview = scriptJquery.crtEle('a', { 2847 'href': 'javascript:void(0);', 2848 'class': 'compose-music-link', 2849 }).text(responseJSON.song_title); 2850 // .click(function(event) { 2851 // event.preventDefault(); 2852 // scriptJquery(this).toggleClass('compose-music-link-playing'); 2853 // scriptJquery(this).toggleClass('compose-music-link'); 2854 // // var song = (responseJSON.song_url.match(/\.mp3$/) 2855 // // ? soundManager.createSound({id:'s'+responseJSON.id, url:responseJSON.song_url}) 2856 // // : soundManager.createVideo({id:'s'+responseJSON.id, url:responseJSON.song_url})); 2857 // // song.togglePause(); 2858 // this.blur(); 2859 // }); 2860 this.elements.preview.text(responseJSON.fileName); 2861 this.doSongLoaded(); 2862 } 2863 2864 this.doSongLoaded = function() { 2865 if( this.elements.loading ) 2866 this.elements.loading.remove(); 2867 if( this.elements.formFancyContainer ) 2868 this.elements.formFancyContainer.remove(); 2869 if( this.elements.error ) { 2870 this.elements.error.remove(); 2871 } 2872 this.elements.preview.appendTo(this.elements.body); 2873 this.makeFormInputs(); 2874 } 2875 this.makeFormInputs = function() { 2876 this.ready(); 2877 this.__proto__.makeFormInputs.call(this,{ 2878 'song_id' : this.params.song_id 2879 }); 2880 } 2881 this.initialize(options); 2882}; 2883 2884 2885/* $Id: composer_albumvideo.js 10258 2014-06-04 16:07:47Z lucas $ */ 2886 2887Composer.Plugin.AlbumVideo = function(options){ 2888 this.__proto__ = new Composer.Plugin.Interface(options); 2889 2890 this.name = 'albumvideo'; 2891 this.options = { 2892 title : 'Add Photo / Video', 2893 lang : {}, 2894 // Options for the link preview request 2895 requestOptions : {}, 2896 // Various image filtering options 2897 imageMaxAspect : ( 10 / 3 ), 2898 imageMinAspect : ( 3 / 10 ), 2899 imageMinSize : 48, 2900 imageMaxSize : 5000,
2901 imageMinPixels : 2304, 2902 imageMaxPixels : 1000000, 2903 imageTimeout : 5000, 2904 // Delay to detect links in input 2905 monitorDelay : 250, 2906 isMessagePage: false, 2907 albumEnable: 0, 2908 videoEnable: 0, 2909 }; 2910 2911 this.initialize = function(options) { 2912 this.elements = new Hash(this.elements); 2913 this.params = new Hash(this.params); 2914 this.__proto__.initialize.call(this,options); 2915 } 2916 2917 this.attach = function() { 2918 this.__proto__.attach.call(this); 2919 this.makeActivator(); 2920 return this; 2921 } 2922 this.detach = function() { 2923 this.__proto__.detach.call(this); 2924 return this; 2925 } 2926 2927 this.activate = function() { 2928 2929 if( this.active && scriptJquery("#compose-video-body").length > 0) return; 2930 this.__proto__.activate.call(this); 2931 2932 this.makeMenu(); 2933 this.makeBody(); 2934 2935 // Generate form 2936 var fullUrl = this.options.requestOptions.url; 2937 if(this.options.albumEnable == 1 && this.options.videoEnable == 1) { 2938 var accepttype = 'video/*,image/*'; 2939 } else if(this.options.albumEnable == 1) { 2940 var accepttype = 'image/*'; 2941 } else if(this.options.videoEnable == 1) { 2942 var accepttype = 'video/*'; 2943 } 2944 if(isMessagePage) { 2945 scriptJquery(this.elements.body).html('<input type="file" accept="'+accepttype+'" onchange="readVideoImageUrl(this)" id="video_file_multi" name="video_file_multi" style="display:none"><div class="activity_compose_photo_container clearfix"><div id="activity_compose_video_container_inner" class="clearfix"><div id="show_video"></div><div id="videodragandrophandler" class="activity_compose_photo_uploader center_item" title="Choose a file to upload"><i class="fa fa-plus"></i></div></div></div>'); 2946 var byteMB = (post_max_size / (1024 * 1024)) + en4.core.language.translate("MB"); 2947 byteMB = en4.core.language.translate('Max size ') + byteMB; 2948 scriptJquery(this.elements.body).append('<span class="font_color_light">('+byteMB+')</span>'); 2949 } else { 2950 scriptJquery(this.elements.body).html('<input type="file" accept="'+accepttype+'" onchange="readVideoImageUrl(this)" multiple="multiple" id="video_file_multi" name="video_file_multi" style="display:none"><div class="activity_compose_photo_container"><div id="activity_compose_video_container_inner" class="clearfix"><div id="show_video"></div><div id="videodragandrophandler" class="activity_compose_photo_uploader center_item" title="Choose a file to upload"><i class="fa fa-plus"></i></div></div></div>'); 2951 var byteMB = (post_max_size / (1024 * 1024)) + en4.core.language.translate("MB"); 2952 byteMB = en4.core.language.translate('Max size ') + byteMB; 2953 scriptJquery(this.elements.body).append('<span class="font_color_light">('+byteMB+')</span>'); 2954 } 2955 2956 if(scriptJquery('#toValues-wrapper').length > 0 || scriptJquery('#submit-wrapper').length > 0) { 2957 //scriptJquery('#video_file_multi').removeAttr('multiple'); 2958 } 2959 2960 if(scriptJquery('#toValues-wrapper').length > 0){ 2961 scriptJquery('#toValues-wrapper').append('<div><input type="hidden" value="1" id="messageAttachment" name="attachment[messageAttachment]"><input type="hidden" name="attachment[multipleupload]" id="multipleupload"><input type="hidden" value="" id="fancyalbumuploadfileidsvideo" name="attachment[video_id]"><input type="hidden" value="video" id="videosealbum" name="attachment[type]"></div>'); 2962 } else if(scriptJquery('#submit-wrapper').length > 0){ 2963 scriptJquery('#body-wrapper').append('<div><input type="hidden" value="1" id="messageAttachment" name="attachment[messageAttachment]"><input type="hidden" value="video" id="videosealbum" name="attachment[type]"><input type="hidden" name="multipleupload" id="attachment[multipleupload]"><input type="hidden" value="" id="fancyalbumuploadfileidsvideo" name="attachment[video_id]"></div>'); 2964 } 2965 } 2966 2967 this.deactivate = function() { 2968 // clean video out if not attached 2969 if (this.params.video_id) 2970 scriptJquery.ajax({ 2971 url: en4.core.basePath + 'video/index/delete', 2972 data: { 2973 format: 'json', 2974 video_id: this.params.video_id 2975 } 2976 }); 2977 if( !this.active ) return; 2978 this.__proto__.deactivate.call(this); 2979 } 2980 2981 // Getting into the core stuff now 2982 this.doAttach = function(e) { 2983 var val = this.elements.formInput.val(); 2984 if( !val && !scriptJquery('#compose-video-upload-file').val()) 2985 { 2986 return; 2987 } 2988 if( !val.match(/^[a-zA-Z]{1,5}:\/\//) ) 2989 { 2990 //val = 'http://' + val; 2991 } 2992 this.params.set('uri', val)
2993 // Input is empty, ignore attachment 2994 if( val == '' && !scriptJquery('#compose-video-upload-file').val()) { 2995 e.preventDefault(); 2996 return; 2997 } 2998 var video_element = document.getElementById("compose-video-form-type"); 2999 var type = video_element.value; 3000 var formData = new FormData(); 3001 if(scriptJquery('#compose-video-upload-file').length){ 3002 var filesAttach = scriptJquery('#compose-video-upload-file')[0].files[0]; 3003 }else{ 3004 var filesAttach = ""; 3005 } 3006 formData.append('Filedata', filesAttach); 3007 formData.append('format', 'json'); 3008 formData.append('uri', val); 3009 formData.append('type', type); 3010 formData.append('uploadwall', 1); 3011 if(type == 3) 3012 var url = this.options.requestOptions.uploadurl; 3013 else 3014 var url = this.options.requestOptions.url; 3015 // Send request to get attachment 3016 /*var options = $merge({ 3017 'data' : { 3018 'format' : 'json', 3019 'uri' : val, 3020 'type': type, 3021 Filedata:formData, 3022 }, 3023 'onComplete' : this.doProcessResponse.bind(this) 3024 }, this.options.requestOptions); 3025 */ 3026 var that = this; 3027 scriptJquery.ajax({ 3028 type:'POST', 3029 url: url, 3030 data:formData, 3031 cache:false, 3032 contentType: false, 3033 processData: false, 3034 success:function(data){ 3035 that.doProcessResponse(data); 3036 }, 3037 error: function(data){ 3038 //silence 3039 } 3040 }); 3041 3042 // Inject loading 3043 this.makeLoading('empty'); 3044 // Send request 3045 // this.request = new Request.JSON(options); 3046 // this.request; 3047 3048 } 3049 3050 this.doProcessResponse = function(responseJSON, responseText) { 3051 // Handle error 3052 if( ($type(responseJSON) != 'hash' && $type(responseJSON) != 'object') || $type(responseJSON.src) != 'string' || $type(parseInt(responseJSON.video_id)) != 'number' ) { 3053 //this.elements.body.empty(); 3054 if( this.elements.loading ) this.elements.loading.remove(); 3055 //this.makeaError(responseJSON.message, 'empty'); 3056 this.makeError(responseJSON.message); 3057 //compose-video-error 3058 //ignore test 3059 this.elements.ignoreValidation = scriptJquery.crtEle('a', { 3060 'href' : this.params.uri, 3061 }).html(this.params.title) 3062 .click(function(e) { 3063 e.preventDefault(); 3064 self.doAttach(this); 3065 }) 3066 .appendTo(this.elements.previewTitle); 3067 return; 3068 //throw "unable to upload image"; 3069 } 3070 var title = responseJSON.title || this.params.get('uri').replace('http://', ''); 3071 this.params.set('title', responseJSON.title); 3072 this.params.set('description', responseJSON.description); 3073 this.params.set('photo_id', responseJSON.photo_id); 3074 this.params.set('video_id', responseJSON.video_id); 3075 3076 if (responseJSON.src) { 3077 this.elements.preview = scriptJquery.crtEle('img', { 3078 'id' : 'compose-video-preview-image', 3079 'class' : 'compose-preview-image', 3080 'src' : responseJSON.src, 3081 }).load(this.doImageLoaded.bind(this)); 3082 } else { 3083 this.doImageLoaded(); 3084 } 3085 }, 3086 this.doImageLoaded = function() { 3087 var self = this; 3088 if( this.elements.loading.length) this.elements.loading.remove(); 3089 if( this.elements.preview ) { 3090 this.elements.preview.attr('width',''); 3091 this.elements.preview.attr('height',''); 3092 this.elements.preview.appendTo(this.elements.body); 3093 } 3094 3095 this.elements.previewInfo = scriptJquery.crtEle('div', { 3096 'id' : 'compose-video-preview-info', 3097 'class' : 'compose-preview-info' 3098 }).appendTo(this.elements.body); 3099 3100 this.elements.previewTitle = scriptJquery.crtEle('div', { 3101 'id' : 'compose-video-preview-title', 3102 'class' : 'compose-preview-title' 3103 }).appendTo(this.elements.previewInfo); 3104 3105 this.elements.previewTitleLink = scriptJquery.crtEle('a', { 3106 'href' : this.params.uri, 3107 }) 3108 .html(this.params.title) 3109 .click(function(e) { 3110 e.preventDefault(); 3111 self.handleEditTitle(this); 3112 }) 3113 .appendTo(this.elements.previewTitle); 3114 3115 this.elements.previewDescription = scriptJquery.crtEle('div', { 3116 'id' : 'compose-video-preview-description', 3117 'class' : 'compose-preview-description', 3118 }) 3119 .html(this.params.description) 3120 .click(function(e) { 3121 e.preventDefault(); 3122 self.handleEditDescription(this); 3123 }) 3124 .appendTo(this.elements.previewInfo); 3125 this.makeFormInputs(); 3126 } 3127 3128 this.makeFormInputs = function() { 3129 this.ready(); 3130 this.__proto__.makeFormInputs.call(this,{ 3131 'photo_id' : this.params.photo_id, 3132 'video_id' : this.params.video_id, 3133 'title' : this.params.title, 3134 'description' : this.params.description 3135 }); 3136 } 3137 this.updateVideoFields = function(element) { 3138 var video_element = document.getElementById("compose-video-form-type"); 3139 var url_element = document.getElementById("compose-video-form-input"); 3140 var post_element = document.getElementById("compose-video-form-submit"); 3141 var upload_element = document.getElementById("compose-video-upload"); 3142 // clear url if input field on change 3143 scriptJquery('#compose-video-form-input').val(""); 3144 // If video source is empty 3145 if (video_element.value == 0) 3146 { 3147 upload_element.style.display = "none"; 3148 post_element.style.display = "none"; 3149 url_element.style.display = "none"; 3150 } 3151 3152 // if video source is upload 3153 if (video_element.value == 3) { 3154 upload_element.style.display = "block"; 3155 post_element.style.display = "block"; 3156 // if(this.options.advancedactvity == 1) 3157 // post_element.style.display = "block"; 3158 // else 3159 // post_element.style.display = "none"; 3160 url_element.style.display = "none"; 3161 } 3162 } 3163 this.handleEditTitle = function(element) { 3164 scriptJquery(element).css('display', 'none'); 3165 var input = scriptJquery.crtEle('input', { 3166 'type' : 'text', 3167 'value' : htmlspecialchars_decode(scriptJquery(element).html()), 3168 }) 3169 .blur(function() { 3170 if(scriptJquery(input).val().trim() != '' ) { 3171 this.params.title = scriptJquery(input).val(); 3172 scriptJquery(element).html(this.params.title); 3173 this.setFormInputValue('title', this.params.title); 3174 } 3175 scriptJquery(element).css('display', ''); 3176 input.remove(); 3177 }.bind(this)) 3178 .insertAfter(scriptJquery(element), 'after'); 3179 input.focus(); 3180 } 3181 this.handleEditDescription = function(element) { 3182 scriptJquery(element).css('display', 'none'); 3183 var input = scriptJquery.crtEle('textarea', {}) 3184 .html(htmlspecialchars_decode(scriptJquery(element).html())) 3185 .blur(function() { 3186 if( scriptJquery(input).val().trim() != '' ) { 3187 this.params.description = scriptJquery(input).val(); 3188 scriptJquery(element).html(this.params.description); 3189 this.setFormInputValue('description', this.params.description); 3190 } 3191 else { 3192 this.params.description = ''; 3193 scriptJquery(element).html(''); 3194 this.setFormInputValue('description', ''); 3195 } 3196 scriptJquery(element).css('display', ''); 3197 input.remove(); 3198 }.bind(this)) 3199 .insertAfter(scriptJquery(element), 'after'); 3200 input.focus(); 3201 } 3202 this.initialize(options); 3203} 3204; 3205 3206 // Underscore.js 1.8.3 3207// http://underscorejs.org
3208// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 3209// Underscore may be freely distributed under the MIT license. 3210(function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION="1.8.3";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w("length"),k=function(n){var t=O(n);return"number"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),("number"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;
3210if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])<u?i=a+1:o=a}return i},m.indexOf=r(1,m.findIndex,m.sortedIndex),m.lastIndexOf=r(-1,m.findLastIndex),m.range=function(n,t,r){null==t&&(t=n||0,n=0),r=r||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=Array(e),i=0;e>i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e<arguments.length;)i.push(arguments[e++]);return E(n,r,this,this,i)};return r},m.bindAll=function(n){var t,r,e=arguments.length;if(1>=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleStr
3210ing"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return"[object Array]"===s.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return s.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,L=function(n){return"\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||"obj";return c.source="function("+f+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each(["concat","join","slice"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this); 3211 3212 3213 3214 3215/* 3216 * Mentions Input 3217 * Version 1.0.2 3218 * Written by: Kenneth Auchenberg (Podio) 3219 * 3220 * Using underscore.js 3221 * 3222 * License: MIT License - http://www.opensource.org/licenses/mit-license.php 3223 */ 3224var nbr = 0; 3225var isoneditpage = false;
3226var mentionsCollectionValEdit = []; 3227(function ($, _, undefined) { 3228 3229 // Settings 3230 var KEY = { BACKSPACE : 8, TAB : 9, RETURN : 13, ESC : 27, LEFT : 37, UP : 38, RIGHT : 39, DOWN : 40, COMMA : 188, SPACE : 32, HOME : 36, END : 35 }; // Keys "enum" 3231 3232 //Default settings 3233 var defaultSettings = { 3234 triggerChar : '@', //Char that respond to event 3235 onDataRequest : $.noop, //Function where we can search the data 3236 minChars : 1, //Minimum chars to fire the event 3237 allowRepeat : true, //Allow repeat mentions 3238 showAvatars : true, //Show the avatars 3239 elastic : false, //Grow the textarea automatically 3240 defaultValue : '', 3241 onCaret : false, 3242 classes : { 3243 autoCompleteItemActive : "active" //Classes to apply in each item 3244 }, 3245 templates : { 3246 wrapper : _.template('<div class="mentions-input-box"></div>'), 3247 autocompleteList : _.template('<div class="mentions-autocomplete-list"></div>'), 3248 autocompleteListItem : _.template('<li data-ref-id="<%= id %>" data-ref-type="<%= type %>" data-display="<%= display %>"><%= content %></li>'), 3249 autocompleteListItemAvatar : _.template('<%= avatar %>'), 3250 autocompleteListItemIcon : _.template('<div class="icon <%= icon %>"></div>'), 3251 mentionsOverlay : _.template('<div class="highlighter"><div></div></div>'), 3252 mentionItemSyntax : _.template('@_user_<%= id %>'), 3253 mentionItemHighlight : _.template('<strong><span><%= value %></span></strong>') 3254 } 3255 }; 3256 3257 //Class util 3258 var utils = { 3259 //Encodes the character with _.escape function (undersocre) 3260 htmlEncode : function (str) { 3261 return _.escape(str); 3262 }, 3263 //Encodes the character to be used with RegExp 3264 regexpEncode : function (str) { 3265 return str;//str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); 3266 }, 3267 highlightTerm : function (value, term) { 3268 if (!term && !term.length) { 3269 return value; 3270 } 3271 return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<b>$1</b>"); 3272 }, 3273 //Sets the caret in a valid position 3274 setCaratPosition : function (domNode, caretPos) { 3275 if (domNode.createTextRange) { 3276 var range = domNode.createTextRange(); 3277 range.move('character', caretPos); 3278 range.select(); 3279 } else { 3280 if (domNode.selectionStart) { 3281 domNode.focus(); 3282 domNode.setSelectionRange(caretPos, caretPos); 3283 } else { 3284 domNode.focus(); 3285 } 3286 } 3287 }, 3288 //Deletes the white spaces 3289 rtrim: function(string) { 3290 return string.replace(/\s+$/,""); 3291 } 3292 }; 3293 3294 //Main class of MentionsInput plugin 3295 var MentionsInput = function (settings) { 3296 3297 var domInput, 3298 elmInputBox, 3299 elmInputWrapper, 3300 elmAutocompleteList, 3301 elmWrapperBox, 3302 elmMentionsOverlay, 3303 elmActiveAutoCompleteItem, 3304 autocompleteItemCollection = {}, 3305 inputBuffer = [], 3306 currentDataQuery = ''; 3307 3308 //Mix the default setting with the users settings 3309 settings = $.extend(true, {}, defaultSettings, settings ); 3310 3311 //Initializes the text area target 3312 function initTextarea() { 3313 elmInputBox = $(domInput); //Get the text area target 3314 //If the text area is already configured, return 3315 if (elmInputBox.attr('data-mentions-input') === 'true') { 3316 return; 3317 } 3318 elmInputWrapper = elmInputBox.parent(); //Get the DOM element parent 3319 elmWrapperBox = $(settings.templates.wrapper()); 3320 elmInputBox.wrapAll(elmWrapperBox); //Wrap all the text area into the div elmWrapperBox 3321 elmWrapperBox = elmInputWrapper.find('> div.mentions-input-box'); //Obtains the div elmWrapperBox that now contains the text area 3322 3323 elmInputBox.attr('data-mentions-input', 'true'); //Sets the attribute data-mentions-input to true -> Defines if the text area is already configured 3324 elmInputBox.bind('keydown', onInputBoxKeyDown); //Bind the keydown event to the text area 3325 //elmInputBox.bind('keypress', onInputBoxKeyPress); //Bind the keypress event to the text area 3326 elmInputBox.bind('click', onInputBoxClick); //Bind the click event to the text area 3327 elmInputBox.bind('blur', onInputBoxBlur); //Bind the blur event to the text area 3328 3329 elmInputBox[0].addEventListener('input', function(event) { 3330 onInputBoxKeyPress(event); 3331 }); 3332 3333 if (navigator.userAgent.indexOf("MSIE 8") > -1) { 3334 elmInputBox.bind('propertychange', onInputBoxInput); //IE8 won't fire the input event, so let's bind to the propertychange 3335 } else { 3336 elmInputBox.bind('input', onInputBoxInput); //Bind the input event to the text area 3337 } 3338 3339 // Elastic textareas, grow automatically 3340 if( settings.elastic ) { 3341 elmInputBox.elastic(); 3342 } 3343 } 3344 3345 //Initializes the autocomplete list, append to elmWrapperBox and delegate the mousedown event to li elements 3346 function initAutocomplete() { 3347 elmAutocompleteList = $(settings.templates.autocompleteList()); //Get the HTML code for the list
3348 elmAutocompleteList.appendTo(elmWrapperBox); //Append to elmWrapperBox element 3349 elmAutocompleteList.delegate('li', 'mousedown', onAutoCompleteItemClick); //Delegate the event 3350 } 3351 3352 //Initializes the mentions' overlay 3353 function initMentionsOverlay() { 3354 elmMentionsOverlay = $('.jqueryHashtags'); //Get the HTML code of the mentions' overlay 3355 //elmMentionsOverlay.prependTo(elmWrapperBox); //Insert into elmWrapperBox the mentions overlay 3356 } 3357 3358 //Updates the values of the main variables 3359 function updateValues() { 3360 3361 if(scriptJquery('#ajaxsmoothbox_main').length){ 3362 var className = 'highlighter_edit'; 3363 var textAreal ='edit_activity_body'; 3364 var elmMentionsOverlayElem = 'jqueryHashtags_edit'; 3365 }else{ 3366 var textAreal ='activity_body'; 3367 var className = 'highlighter'; 3368 var elmMentionsOverlayElem = 'jqueryHashtags'; 3369 } 3370 var classNameElem = $(domInput).closest('.jqueryHashtags').find('div').eq(0); 3371 // var textAreal = $(domInput); 3372 elmMentionsOverlay = $('.'+elmMentionsOverlayElem); 3373 var syntaxMessage = getInputBoxValue(); //Get the actual value of the text area 3374 3375 EditFieldValue = syntaxMessage; 3376 3377 var id = $(domInput).attr('id'); 3378 if(id){ 3379 if(typeof mentiondataarray["mention_data_"+id] != 'undefined'){ 3380 mentionsCollection = mentiondataarray["mention_data_"+id]; 3381 } 3382 } 3383 _.each(mentionsCollection, function (mention) { 3384 var textSyntax = settings.templates.mentionItemSyntax(mention); 3385 syntaxMessage = syntaxMessage.replace(new RegExp(utils.regexpEncode(mention.value), 'g'), textSyntax); 3386 }); 3387 3388 //var mentionText = utils.htmlEncode(syntaxMessage); //Encode the syntaxMessage 3389 var mentionText = syntaxMessage; 3390 _.each(mentionsCollection, function (mention) { 3391 var formattedMention = _.extend({}, mention, {value: utils.htmlEncode(mention.value)}); 3392 var textSyntax = settings.templates.mentionItemSyntax(formattedMention); 3393 var textHighlight = settings.templates.mentionItemHighlight(formattedMention); 3394 3395 mentionText = mentionText.replace(new RegExp(utils.regexpEncode(textSyntax), 'g'), textHighlight); 3396 }); 3397 3398 mentionText = mentionText.replace(/\n/g, '<br />'); //Replace the escape character for <br /> 3399 mentionText = mentionText.replace(/ {2}/g, ' '); //Replace the 2 preceding token to 3400 3401 elmInputBox.data('messageText', syntaxMessage); //Save the messageText to elmInputBox 3402 elmInputBox.trigger('updated'); 3403 3404 3405 var str = mentionText; 3406 3407 classNameElem.css("width",$(domInput).css("width")); 3408 str = str.replace(/\n/g, '<br>'); 3409 3410 var tagslistarr = str.match(/\B(#[^\s[!\"\#$%&'()*+,\-.\/\\:;<=>?@\[\]\^`{|}~]+)/g); 3411 if(tagslistarr && tagslistarr.length){ 3412 for(var i=0;i<tagslistarr.length;i++){ 3413 //hashtag must be on 1st position 3414 if(tagslistarr[i].indexOf('#') != 0 && str.indexOf(tagslistarr[i]) < 0 ) 3415 continue; 3416 var regex = new RegExp(tagslistarr[i], "g"); 3417 str = str.replace(regex, '<strong></span>'+tagslistarr[i]+'</span></strong>'); 3418 } 3419 } 3420 3421 3422 /*if(!str.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)?#([a-zA-Z0-9]+)/g) && !str.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)?@([a-zA-Z0-9]+)/g) && !str.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)?#([\u0600-\u06FF]+)/g) && !str.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)?@([\u0600-\u06FF]+)/g)) { 3423 if(!str.match(/#(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))#/g)) { //arabic support 3424 str = str.replace(/#(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))/g,'<strong><span>#$1</span></strong>'); 3425 }else{ 3426 str = str.replace(/#(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))#(([a-zA-Z0-9]+)|([\u0600-\u06FF]+))/g,'<strong></span>#$1</span></strong>'); 3427 } 3428 }*/ 3429 3430 var p = str; 3431 var rx = /([\uD800-\uDBFF][\uDC00-\uDFFF](?:[\u200D\uFE0F][\uD800-\uDBFF][\uDC00-\uDFFF]){2,}|\uD83D\uDC69(?:\u200D(?:(?:\uD83D\uDC69\u200D)?\uD83D\uDC67|(?:\uD83D\uDC69\u200D)?\uD83D\uDC66)|\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D(?:\uD83D\uDC69\u200D)?\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D(?:\uD83D\uDC69\u200D)?\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]\uFE0F|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC6F\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3C-\uDD3E\uDDD6-\uDDDF])\u200D[\u2640\u2642]\uFE0F|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F\u200D[\u2640\u2642]|(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642])\uFE0F|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\uD83D\uDC69\u200D[\u2695\u2696\u2708]|\uD83D\uDC68(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708]))\uFE0F|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83D\uDC69\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|\uD83D\uDC68(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:(?:\uD83D[\uDC68\uDC69])\u200D)?\uD83D\uDC66\u200D\uD83D\uDC66|(?:(?:\uD83D[\uDC68\uDC69])\u200D)?\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]))|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDD1-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\u200D(?:(?:(?:\uD83D[\uDC68\uDC69])\u200D)?\uD83D\uDC67|(?:(?:\uD83D[\uDC68\uDC69])\u200D)?\uD83D\uDC66)|\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uD
3431FC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDD1-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])?|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267B\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])\uFE0F)/; 3432 3433 //FeelingEmojis Work 3434 // if(scriptJquery('#activity_feeling_emojisa').length > 0) { 3435 // str = emojiscontent.toImage(str); 3436 // } 3437 //var res = str.replace(/<br ?\/\>|<br ?\/&rt;|\<br ?\/\>/g, "").split(' '); //p.split(customres).filter(Boolean); 3438 var checkEmoji = false; 3439 3440 //Text size increase in status box 3441 var composeInstancecheck = false; 3442 if(typeof composeInstance != 'undefined'){ 3443 Object.entries(composeInstance.plugins).forEach(function([key,plugin]) { 3444 if(plugin.active) { 3445 composeInstancecheck = true; 3446 } 3447 }); 3448 } else { 3449 isoneditpage = false; 3450 composeInstancecheck = true; 3451 } 3452 3453 if(!isonCommentBox){ 3454 if(!composeInstancecheck && !isoneditpage) { 3455 //var fontSize = $(domInput).css('font-size'); 3456 var textlength = $(domInput).val().length; 3457 var activitytextlimit = 120; 3458 var rows = $(domInput).val().split("\n").length; 3459 if(textlength <= activitytextlimit && rows <= 10) { 3460 classNameElem.css("font-size", ''); 3461 $(domInput).css("font-size", ''); 3462 3463 //Feed Background image work 3464 if($('feedbgid')) { 3465 3466 var feelingactivity_type = 1; 3467 if(document.getElementById('feelingactivity_type')) { 3468 var feelingactivity_type = document.getElementById('feelingactivity_type').value; 3469 } 3470 if(feelingactivity_type != 2) { 3471 var feedbgid = scriptJquery('#feedbgid').val(); 3472 var activitylng = scriptJquery('#activitylng').val(); 3473 if(feedbgid) { 3474 var feedagainsrcurl = scriptJquery('#feed_bg_image_' + feedbgid).attr('src'); 3475 scriptJquery('.activity_post_box').css("background-image", "url(" + feedagainsrcurl + ")"); 3476 scriptJquery('#feedbgid_isphoto').val(1); 3477 scriptJquery('#feedbg_main_continer').css('display','block'); 3478 } 3479 3480 if(feedbgid) { 3481 scriptJquery('#activity-form').addClass('feed_background_image'); 3482 } 3483 if(feedbgid == 0) { 3484 scriptJquery('#activity-form').removeClass('feed_background_image'); 3485 } 3486 if(activitylng) { 3487 scriptJquery('#feedbgid_isphoto').val(0); 3488 scriptJquery('.activity_post_box').css('background-image', 'none'); 3489 scriptJquery('#activity-form').removeClass('feed_background_image'); 3490 scriptJquery('#feedbg_main_continer').css('display','none'); 3491 } 3492 } 3493 }
3494 //Feed Background image work 3495 } else { 3496 classNameElem.css("font-size", ''); 3497 $(domInput).css("font-size", ''); 3498 3499 //Feed Background image work 3500 scriptJquery('#feedbgid_isphoto').val(0); 3501 scriptJquery('.activity_post_box').css('background-image', 'none'); 3502 scriptJquery('#activity-form').removeClass('feed_background_image'); 3503 scriptJquery('#feedbg_main_continer').css('display','none'); 3504 3505 } 3506 } else if(composeInstancecheck) { 3507 classNameElem.css("font-size", ''); 3508 $(domInput).css("font-size", ''); 3509 } 3510 } 3511 3512 //Text size increase in status box 3513 $(domInput).closest('.mentions-input-box').find('div').eq(0).find('div').eq(0).html(str); //Insert into a div of the elmMentionsOverlay the mention text 3514 3515 if((composeInstancecheck && !isoneditpage) || isonCommentBox) { 3516 // `mInput).css("fontSize", ''); 3517 } 3518 3519 if(typeof feedUpdateFunction != 'undefined'){ 3520 feedUpdateFunction(); 3521 } 3522 } 3523 3524 //Cleans the buffer 3525 function resetBuffer() { 3526 inputBuffer = []; 3527 } 3528 3529 //Updates the mentions collection 3530 function updateMentionsCollection() { 3531 var inputText = getInputBoxValue(); //Get the actual value of text area 3532 3533 //Returns the values that doesn't match the condition 3534 mentionsCollection = _.reject(mentionsCollection, function (mention, index) { 3535 return !mention.value || inputText.indexOf(mention.value) == -1; 3536 }); 3537 mentionsCollection = _.compact(mentionsCollection); //Delete all the falsy values of the array and return the new array 3538 } 3539 3540 //Adds mention to mentions collections 3541 function addMention(mention) { 3542 3543 var currentMessage = getInputBoxValue(), 3544 caretStart = elmInputBox[0].selectionStart, 3545 shortestDistance = false, 3546 bestLastIndex = false; 3547 3548 // Using a regex to figure out positions 3549 var regex = new RegExp("\\" + settings.triggerChar + currentDataQuery, "gi"), 3550 regexMatch; 3551 3552 while(regexMatch = regex.exec(currentMessage)) { 3553 if (shortestDistance === false || Math.abs(regex.lastIndex - caretStart) < shortestDistance) { 3554 shortestDistance = Math.abs(regex.lastIndex - caretStart); 3555 bestLastIndex = regex.lastIndex; 3556 } 3557 } 3558 3559 var startCaretPosition = bestLastIndex - currentDataQuery.length - 1; //Set the start caret position (right before the @) 3560 var currentCaretPosition = bestLastIndex; //Set the current caret position (right after the end of the "mention") 3561 3562 3563 var start = currentMessage.substr(0, startCaretPosition); 3564 var end = currentMessage.substr(currentCaretPosition, currentMessage.length); 3565 var startEndIndex = (start + mention.value).length + 1; 3566 3567 // See if there's the same mention in the list 3568 if( !_.find(mentionsCollection, function (object) { return object.id == mention.id; }) ) { 3569 mentionsCollection.push(mention);//Add the mention to mentionsColletions 3570 var id = $(domInput).attr('id'); 3571 if(id){ 3572 if(typeof mentiondataarray["mention_data_"+id] == 'undefined'){ 3573 mentiondataarray["mention_data_"+id] = mentionsCollection; 3574 }else{ 3575 mentiondataarray["mention_data_"+id].push(mention); 3576 } 3577 } 3578 } 3579 3580 // Cleaning before inserting the value, otherwise auto-complete would be triggered with "old" inputbuffer 3581 resetBuffer(); 3582 currentDataQuery = ''; 3583 hideAutoComplete(); 3584 3585 // Mentions and syntax message 3586 var updatedMessageText = start + mention.value + ' ' + end; 3587 elmInputBox.val(updatedMessageText); //Set the value to the txt area 3588 elmInputBox.trigger('mention');
3589 updateValues('addmention'); 3590 3591 // Set correct focus and selection 3592 elmInputBox.focus(); 3593 utils.setCaratPosition(elmInputBox[0], startEndIndex); 3594 } 3595 3596 //Gets the actual value of the text area without white spaces from the beginning and end of the value 3597 function getInputBoxValue() { 3598 //return $.trim(elmInputBox.val()); 3599 //return $.trim(EditFieldValue); 3600 //var html = $.trim($(domInput).html()); 3601 var value = $(domInput).val(); //$.trim($(domInput).val()); 3602 3603// if(!value) 3604// return html; 3605 return value; 3606 } 3607 3608 // This is taken straight from live (as of Sep 2012) GitHub code. The 3609 // technique is known around the web. Just google it. Github's is quite 3610 // succint though. NOTE: relies on selectionEnd, which as far as IE is concerned, 3611 // it'll only work on 9+. Good news is nothing will happen if the browser 3612 // doesn't support it. 3613 function textareaSelectionPosition($el) { 3614 var a, b, c, d, e, f, g, h, i, j, k; 3615 if (!(i = $el[0])) return; 3616 if (!$(i).is("textarea")) return; 3617 if (i.selectionEnd == null) return; 3618 g = { 3619 position: "absolute", 3620 overflow: "auto", 3621 whiteSpace: "pre-wrap", 3622 wordWrap: "break-word", 3623 boxSizing: "content-box", 3624 top: 0, 3625 left: -9999 3626 }, h = ["boxSizing", "fontFamily", "fontSize", "fontStyle", "fontVariant", "fontWeight", "height", "letterSpacing", "lineHeight", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "textDecoration", "textIndent", "textTransform", "width", "word-spacing"]; 3627 for (j = 0, k = h.length; j < k; j++) e = h[j], g[e] = $(i).css(e); 3628 return c = document.createElement("div"), $(c).css(g), $(i).after(c), b = document.createTextNode(i.value.substring(0, i.selectionEnd)), a = document.createTextNode(i.value.substring(i.selectionEnd)), d = document.createElement("span"), d.innerHTML = " ", c.appendChild(b), c.appendChild(d), c.appendChild(a), c.scrollTop = i.scrollTop, f = $(d).position(), $(c).remove(), f 3629 } 3630 3631 //same as above function but return offset instead of position 3632 function textareaSelectionOffset($el) { 3633 var a, b, c, d, e, f, g, h, i, j, k; 3634 if (!(i = $el[0])) return; 3635 if (!$(i).is("textarea")) return; 3636 if (i.selectionEnd == null) return; 3637 g = { 3638 position: "absolute", 3639 overflow: "auto", 3640 whiteSpace: "pre-wrap", 3641 wordWrap: "break-word", 3642 boxSizing: "content-box", 3643 top: 0, 3644 left: -9999 3645 }, h = ["boxSizing", "fontFamily", "fontSize", "fontStyle", "fontVariant", "fontWeight", "height", "letterSpacing", "lineHeight", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "textDecoration", "textIndent", "textTransform", "width", "word-spacing"]; 3646 for (j = 0, k = h.length; j < k; j++) e = h[j], g[e] = $(i).css(e); 3647 return c = document.createElement("div"), $(c).css(g), $(i).after(c), b = document.createTextNode(i.value.substring(0, i.selectionEnd)), a = document.createTextNode(i.value.substring(i.selectionEnd)), d = document.createElement("span"), d.innerHTML = " ", c.appendChild(b), c.appendChild(d), c.appendChild(a), c.scrollTop = i.scrollTop, f = $(d).offset(), $(c).remove(), f 3648 } 3649 3650 //Scrolls back to the input after autocomplete if the window has scrolled past the input 3651 function scrollToInput() { 3652 var elmDistanceFromTop = $(elmInputBox).offset().top; //input offset 3653 var bodyDistanceFromTop = $('body').offset().top; //body offset 3654 var distanceScrolled = $(window).scrollTop(); //distance scrolled 3655 3656 if (distanceScrolled > elmDistanceFromTop) { 3657 //subtracts body distance to handle fixed headers 3658 $(window).scrollTop(elmDistanceFromTop - bodyDistanceFromTop); 3659 } 3660 } 3661 3662 //Takes the click event when the user select a item of the dropdown
3663 function onAutoCompleteItemClick(e) { 3664 var elmTarget = $(this); //Get the item selected 3665 var mention = autocompleteItemCollection[elmTarget.attr('data-uid')]; //Obtains the mention 3666 3667 addMention(mention); 3668 scrollToInput(); 3669 return false; 3670 } 3671 3672 //Takes the click event on text area 3673 function onInputBoxClick(e) { 3674 resetBuffer(); 3675 } 3676 3677 //Takes the blur event on text area 3678 function onInputBoxBlur(e) { 3679 hideAutoComplete(); 3680 } 3681 3682 //Takes the input event when users write or delete something 3683 function onInputBoxInput(e) { 3684 updateValues(); 3685 updateMentionsCollection(); 3686 3687 var triggerCharIndex = _.lastIndexOf(inputBuffer, settings.triggerChar); //Returns the last match of the triggerChar in the inputBuffer 3688 if (triggerCharIndex > -1) { //If the triggerChar is present in the inputBuffer array 3689 currentDataQuery = inputBuffer.slice(triggerCharIndex + 1).join(''); //Gets the currentDataQuery 3690 currentDataQuery = utils.rtrim(currentDataQuery); //Deletes the whitespaces 3691 _.defer(_.bind(doSearch, this, currentDataQuery)); //Invoking the function doSearch ( Bind the function to this) 3692 } 3693 } 3694 3695 //Takes the keypress event 3696 function onInputBoxKeyPress(e) { 3697 if(e.keyCode !== KEY.BACKSPACE && typeof e.keyCode != 'undefined') { //If the key pressed is not the backspace 3698 var typedValue = String.fromCharCode(e.which || e.keyCode); //Takes the string that represent this CharCode 3699 inputBuffer.push(typedValue); //Push the value pressed into inputBuffer 3700 } else { 3701 const value = e.data; 3702 const lastChar = value.charAt(value.length - 1); 3703 if (lastChar && lastChar !== "") { 3704 inputBuffer.push(lastChar); 3705 console.log("Buffer:", inputBuffer); 3706 } 3707 } 3708 3709 3710 3711// //Background work 3712// if(e.which == 13) { 3713// nbr++; 3714// if(nbr > 4) { console.log('bada'); 3715// scriptJquery('#feedbgid_isphoto').val(0); 3716// scriptJquery('.activity_post_box').css('background-image', 'none'); 3717// scriptJquery('#activity-form').removeClass('feed_background_image'); 3718// } 3719// console.log(nbr); console.log(scriptJquery('#feedbgid_isphoto').val()); 3720// } 3721 } 3722 3723 //Takes the keydown event 3724 function onInputBoxKeyDown(e) { 3725 3726 // This also matches HOME/END on OSX which is CMD+LEFT, CMD+RIGHT 3727 if (e.keyCode === KEY.LEFT || e.keyCode === KEY.RIGHT || e.keyCode === KEY.HOME || e.keyCode === KEY.END) { 3728 // Defer execution to ensure carat pos has changed after HOME/END keys then call the resetBuffer function 3729 _.defer(resetBuffer); 3730 3731 // IE9 doesn't fire the oninput event when backspace or delete is pressed. This causes the highlighting 3732 // to stay on the screen whenever backspace is pressed after a highlighed word. This is simply a hack 3733 // to force updateValues() to fire when backspace/delete is pressed in IE9. 3734 if (navigator.userAgent.indexOf("MSIE 9") > -1) { 3735 _.defer(updateValues); //Call the updateValues function 3736 } 3737 3738 return; 3739 } 3740 3741 //If the key pressed was the backspace 3742 if (e.keyCode === KEY.BACKSPACE) { 3743 //Background work 3744// if(nbr > 0) 3745// nbr--; 3746 inputBuffer = inputBuffer.slice(0, -1 + inputBuffer.length); // Can't use splice, not available in IE 3747 return; 3748 } 3749 3750 //If the elmAutocompleteList is hidden 3751 if (!elmAutocompleteList.is(':visible')) { 3752 return true; 3753 } 3754 3755 switch (e.keyCode) { 3756 case KEY.UP: //If the key pressed was UP or DOWN 3757 case KEY.DOWN: 3758 var elmCurrentAutoCompleteItem = null; 3759 if (e.keyCode === KEY.DOWN) { //If the key pressed was DOWN 3760 if (elmActiveAutoCompleteItem && elmActiveAutoCompleteItem.length) { //If elmActiveAutoCompleteItem exits 3761 elmCurrentAutoCompleteItem = elmActiveAutoCompleteItem.next(); //Gets the next li element in the list 3762 } else { 3763 elmCurrentAutoCompleteItem = elmAutocompleteList.find('li').first(); //Gets the first li element found 3764 } 3765 } else { 3766 elmCurrentAutoCompleteItem = $(elmActiveAutoCompleteItem).prev(); //The key pressed was UP and gets the previous li element 3767 } 3768 if (elmCurrentAutoCompleteItem.length) { 3769 selectAutoCompleteItem(elmCurrentAutoCompleteItem); 3770 } 3771 return false;
3772 case KEY.RETURN: //If the key pressed was RETURN or TAB 3773 case KEY.TAB: 3774 if (elmActiveAutoCompleteItem && elmActiveAutoCompleteItem.length) { //If the elmActiveAutoCompleteItem exists 3775 elmActiveAutoCompleteItem.trigger('mousedown'); //Calls the mousedown event 3776 return false; 3777 } 3778 break; 3779 } 3780 3781 return true; 3782 } 3783 3784 //Hides the autoomplete 3785 function hideAutoComplete() { 3786 elmActiveAutoCompleteItem = null; 3787 elmAutocompleteList.empty().hide(); 3788 } 3789 3790 //Selects the item in the autocomplete list 3791 function selectAutoCompleteItem(elmItem) { 3792 elmItem.addClass(settings.classes.autoCompleteItemActive); //Add the class active to item 3793 elmItem.siblings().removeClass(settings.classes.autoCompleteItemActive); //Gets all li elements in autocomplete list and remove the class active 3794 3795 elmActiveAutoCompleteItem = elmItem; //Sets the item to elmActiveAutoCompleteItem 3796 } 3797 3798 //Populates dropdown 3799 function populateDropdown(query, results) { 3800 elmAutocompleteList.show(); //Shows the autocomplete list 3801 3802 if(!settings.allowRepeat) { 3803 // Filter items that has already been mentioned 3804 var mentionValues = _.pluck(mentionsCollection, 'value'); 3805 results = _.reject(results, function (item) { 3806 return _.include(mentionValues, item.name); 3807 }); 3808 } 3809 3810 if (!results.length) { //If there are not elements hide the autocomplete list 3811 hideAutoComplete(); 3812 return; 3813 } 3814 3815 elmAutocompleteList.empty(); //Remove all li elements in autocomplete list 3816 var elmDropDownList = $("<ul>").appendTo(elmAutocompleteList).hide(); //Inserts a ul element to autocomplete div and hide it 3817 3818 _.each(results, function (item, index) { 3819 var itemUid = _.uniqueId('mention_'); //Gets the item with unique id 3820 3821 autocompleteItemCollection[itemUid] = _.extend({}, item, {value: item.name}); //Inserts the new item to autocompleteItemCollection 3822 3823 var elmListItem = $(settings.templates.autocompleteListItem({ 3824 'id' : utils.htmlEncode(item.id), 3825 'display' : utils.htmlEncode(item.name), 3826 'type' : utils.htmlEncode(item.type), 3827 'content' : utils.highlightTerm(utils.htmlEncode((item.display ? item.display : item.name)), query) 3828 })).attr('data-uid', itemUid); //Inserts the new item to list 3829 3830 //If the index is 0 3831 if (index === 0) { 3832 selectAutoCompleteItem(elmListItem); 3833 } 3834 3835 //If show avatars is true 3836 if (settings.showAvatars) { 3837 var elmIcon; 3838 3839 //If the item has an avatar 3840 if (item.avatar) { 3841 elmIcon = $(settings.templates.autocompleteListItemAvatar({ avatar : item.avatar })); 3842 } else { //If not then we set an default icon 3843 elmIcon = $(settings.templates.autocompleteListItemIcon({ icon : item.icon })); 3844 } 3845 elmIcon.prependTo(elmListItem); //Inserts the elmIcon to elmListItem 3846 } 3847 elmListItem = elmListItem.appendTo(elmDropDownList); //Insets the elmListItem to elmDropDownList 3848 }); 3849 3850 elmAutocompleteList.show(); //Shows the elmAutocompleteList div 3851 if (settings.onCaret) { 3852 positionAutocomplete(elmAutocompleteList, elmInputBox); 3853 } 3854 elmDropDownList.show(); //Shows the elmDropDownList 3855 } 3856 3857 //Search into data list passed as parameter 3858 function doSearch(query) { 3859 //If the query is not null, undefined, empty and has the minimum chars 3860 if (query && query.length && query.length >= settings.minChars) { 3861 //Call the onDataRequest function and then call the populateDropDrown 3862 settings.onDataRequest.call(this, 'search', query, function (responseData) { 3863 populateDropdown(query, responseData); 3864 }); 3865 } else { //If the query is null, undefined, empty or has not the minimun chars 3866 hideAutoComplete(); //Hide the autocompletelist 3867 } 3868 } 3869 3870 function positionAutocomplete(elmAutocompleteList, elmInputBox) { 3871 var elmAutocompleteListPosition = elmAutocompleteList.css('position'); 3872 if (elmAutocompleteListPosition == 'absolute') { 3873 var position = textareaSelectionPosition(elmInputBox), 3874 lineHeight = parseInt(elmInputBox.css('line-height'), 10) || 18; 3875 elmAutocompleteList.css('width', '15em'); // Sort of a guess 3876 elmAutocompleteList.css('left', position.left); 3877 elmAutocompleteList.css('top', lineHeight + position.top); 3878 3879 //check if the right position of auto complete is larger than the right position of the input 3880 //if yes, reset the left of auto complete list to make it fit the input 3881 var elmInputBoxRight = elmInputBox.offset().left + elmInputBox.width(), 3882 elmAutocompleteListRight = elmAutocompleteList.offset().left + elmAutocompleteList.width(); 3883 if (elmInputBoxRight <= elmAutocompleteListRight) { 3884 elmAutocompleteList.css('left', Math.abs(elmAutocompleteList.position().left - (elmAutocompleteListRight - elmInputBoxRight))); 3885 } 3886 } 3887 else if (elmAutocompleteListPosition == 'fixed') { 3888 var offset = textareaSelectionOffset(elmInputBox), 3889 lineHeight = parseInt(elmInputBox.css('line-height'), 10) || 18; 3890 elmAutocompleteList.css('width', '15em'); // Sort of a guess 3891 elmAutocompleteList.css('left', offset.left + 10000); 3892 elmAutocompleteList.css('top', lineHeight + offset.top); 3893 } 3894 } 3895 3896 //Resets the text area 3897 function resetInput(currentVal) { 3898 if(EditFieldValue) 3899 currentVal = EditFieldValue; 3900 mentionsCollection = []; 3901 //var mentionText = utils.htmlEncode(currentVal); 3902 var mentionText = currentVal; 3903 var regex = new RegExp("(" + settings.triggerChar + ")\\[(.*?)\\]\\((.*?):(.*?)\\)", "gi"); 3904 var match, newMentionText = mentionText; 3905 while ((match = regex.exec(mentionText)) != null) { 3906 newMentionText = newMentionText.replace(match[0], match[1] + match[2]); 3907 mentionsCollection.push({ 'id': match[4], 'type': match[3], 'value': match[2], 'trigger': match[1] }); 3908 } 3909 3910 elmInputBox.val(newMentionText);
3911 updateValues(); 3912 } 3913 // Public methods 3914 return { 3915 //Initializes the mentionsInput component on a specific element. 3916 init : function (domTarget) { 3917 3918 domInput = domTarget; 3919 3920 initTextarea(); 3921 initAutocomplete(); 3922 initMentionsOverlay(); 3923 resetInput(settings.defaultValue); 3924 3925 //If the autocomplete list has prefill mentions 3926 if( settings.prefillMention ) { 3927 addMention( settings.prefillMention ); 3928 } 3929 }, 3930 3931 //An async method which accepts a callback function and returns a value of the input field (including markup) as a first parameter of this function. This is the value you want to send to your server. 3932 val : function (callback) { 3933 if (!_.isFunction(callback)) { 3934 return; 3935 } 3936 callback.call(this, mentionsCollection.length ? elmInputBox.data('messageText') : getInputBoxValue()); 3937 }, 3938 3939 //Resets the text area value and clears all mentions 3940 reset : function () { 3941 resetInput(); 3942 }, 3943 3944 //Reinit with the text area value if it was changed programmatically 3945 reinit : function () { 3946 resetInput(false); 3947 }, 3948 3949 addmention : function () { 3950 addMention(arguments[0]); 3951 }, 3952 //An async method which accepts a callback function and returns a collection of mentions as hash objects as a first parameter. 3953 getMentions : function (callback) { 3954 if (!_.isFunction(callback)) { 3955 return; 3956 } 3957 callback.call(this, mentionsCollection); 3958 }, 3959 update: function() { 3960 var messageText = getInputBoxValue(); 3961 // Strip codes 3962 // add each mention to mentionsCollection 3963 // And update 3964 3965 // var mentionText = utils.htmlEncode(getInputBoxValue()); 3966 var mentionText = getInputBoxValue(); 3967 var newMentionText = mentionText; 3968 if(typeof mentionsCollectionValEdit != 'undefined' && userTagsEnable){ 3969 for (i=0;i<mentionsCollectionValEdit.length;i++) { // Find all matches in a string 3970 newMentionText = newMentionText.replace('@_user_'+mentionsCollectionValEdit[i]['id'],mentionsCollectionValEdit[i]['name']); 3971 var mention = { 3972 'id': mentionsCollectionValEdit[i]['id'], 3973 'type': 'user', 3974 'name': mentionsCollectionValEdit[i]['name'], 3975 'avatar' : mentionsCollectionValEdit[i]['avatar'], 3976 'value' : mentionsCollectionValEdit[i]['name'], 3977 }; 3978 mentionsCollection.push(mention); 3979 var id = $(domInput).attr('id'); 3980 if(id){ 3981 if(typeof mentiondataarray["mention_data_"+id] == 'undefined'){ 3982 mentiondataarray["mention_data_"+id] = mentionsCollection; 3983 }else{ 3984 mentiondataarray["mention_data_"+id].push(mention); 3985 } 3986 } 3987 } 3988 elmInputBox.val(newMentionText); 3989 updateValues(); 3990 } 3991 }, 3992 }; 3993 }; 3994 3995 //Main function to include into jQuery and initialize the plugin 3996 $.fn.mentionsInput = function (method, settings) { 3997 3998 var outerArguments = arguments; //Gets the arguments 3999 //If method is not a function 4000 if (typeof method === 'object' || !method) { 4001 settings = method; 4002 } 4003 4004 return this.each(function () { 4005 var instance = $.data(this, 'mentionsInput') || $.data(this, 'mentionsInput', new MentionsInput(settings)); 4006 4007 if (_.isFunction(instance[method])) { 4008 return instance[method].apply(this, Array.prototype.slice.call(outerArguments, 1)); 4009 } else if (typeof method === 'object' || !method) { 4010 return instance.init.call(this, this); 4011 } else { 4012 $.error('Method ' + method + ' does not exist'); 4013 } 4014 }); 4015 }; 4016 4017})(scriptJquery, _); 4018; 4019 4020 /*! 4021* Bootstrap.js by @fat & @mdo 4022* Copyright 2012 Twitter, Inc. 4023* http://www.apache.org/licenses/LICENSE-2.0.txt 4024*/ 4025!function($){"use strict";$(function(){$.support.transition=function(){var transitionEnd=function(){var name,el=document.createElement("bootstrap"),transEndEventNames={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(name in transEndEventNames)if(void 0!==el.style[name])return transEndEventNames[name]}();return transitionEnd&&{end:transitionEnd}}()})}(window.jQuery),!function($){"use strict";var dismiss='[data-dismiss="alert"]',Alert=function(el){$(el).on("click",dismiss,this.close)};Alert.prototype.close=function(e){function removeElement(){$parent.trigger("closed").remove()}var $parent,$this=$(this),selector=$this.attr("data-target");selector||(selector=$this.attr("href"),selector=selector&&selector.replace(/.*(?=#[^\s]*$)/,"")),$parent=$(selector),e&&e.preventDefault(),$parent.length||($parent=$this.hasClass("alert")?$this:$this.parent()),$parent.trigger(e=$.Event("close")),e.isDefaultPrevented()||($parent.removeClass("in"),$.support.transition&&$parent.hasClass("fade")?$parent.on($.support.transition.end,removeElement):removeElement())};var old=$.fn.alert;$.fn.alert=function(option){return this.each(function(){var $this=$(this),data=$this.data("alert");data||$this.data("alert",data=new Alert(this)),"string"==typeof option&&data[option].call($this)})},$.fn.alert.Constructor=Alert,$.fn.alert.noConflict=function(){return $.fn.alert=old,this},$(document).on("click.alert.data-api",dismiss,Alert.prototype.close)}(window.jQuery),!function($){"use strict";var Button=function(element,options){this.$element=$(element),this.options=$.extend({},$.fn.button.defaults,options)};Button.prototype.setState=function(state){var d="disabled",$el=this.$element,data=$el.data(),val=$el.is("input")?"val":"html";state+="Text",data.resetText||$el.data("resetText",$el[val]()),$el[val](data[state]||this.options[state]),setTimeout(function(){"loadingText"==state?$el.addClass(d).attr(d,d):$el.removeClass(d).removeAttr(d)},0)},Button.prototype.toggle=function(){var $parent=this.$element.closest('[data-toggle="buttons-radio"]');$parent&&$parent.find(".active").removeClass("active"),this.$element.toggleClass("active")};var old=$.fn.button;$.fn.button=function(option){return this.each(function(){var $this=$(this),data=$this.data("button"),options="object"==typeof option&&option;data||$this.data("button",data=new Button(this,options)),"toggle"==option?data.toggle():option&&data.setState(option)})},$.fn.button.defaults={loadingText:"loading..."},$.fn.button.Constructor=Button,$.fn.button.noConflict=function(){return $.fn.button=old,this},$(document).on("click.button.data-api","[data-toggle^=button]",function(e){var $btn=$(e.target);$btn.hasClass("btn")||($btn=$btn.closest(".btn")),$btn.button("toggle")})}(window.jQuery),!function($){"use strict";var Carousel=function(element,options){this.$element=$(element),this.options=options,"hover"==this.options.pause&&this.$element.on("mouseenter",$.proxy(this.pause,this)).on("mouseleave",$.proxy(this.cycle,this))};Carousel.prototype={cycle:function(e){return e||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval($.proxy(this.next,this),this.options.interval)),this}
vendor: 4,571 bytes, line 4025
4025,to:function(pos){var $active=this.$element.find(".item.active"),children=$active.parent().children(),activePos=children.index($active),that=this;if(!(pos>children.length-1||0>pos))return this.sliding?this.$element.one("slid",function(){that.to(pos)}):activePos==pos?this.pause().cycle():this.slide(pos>activePos?"next":"prev",$(children[pos]))},pause:function(e){return e||(this.paused=!0),this.$element.find(".next, .prev").length&&$.support.transition.end&&(this.$element.trigger($.support.transition.end),this.cycle()),clearInterval(this.interval),this.interval=null,this},next:function(){return this.sliding?void 0:this.slide("next")},prev:function(){return this.sliding?void 0:this.slide("prev")},slide:function(type,next){var e,$active=this.$element.find(".item.active"),$next=next||$active[type](),isCycling=this.interval,direction="next"==type?"left":"right",fallback="next"==type?"first":"last",that=this;if(this.sliding=!0,isCycling&&this.pause(),$next=$next.length?$next:this.$element.find(".item")[fallback](),e=$.Event("slide",{relatedTarget:$next[0]}),!$next.hasClass("active")){if($.support.transition&&this.$element.hasClass("slide")){if(this.$element.trigger(e),e.isDefaultPrevented())return;$next.addClass(type),$next[0].offsetWidth,$active.addClass(direction),$next.addClass(direction),this.$element.one($.support.transition.end,function(){$next.removeClass([type,direction].join(" ")).addClass("active"),$active.removeClass(["active",direction].join(" ")),that.sliding=!1,setTimeout(function(){that.$element.trigger("slid")},0)})}else{if(this.$element.trigger(e),e.isDefaultPrevented())return;$active.removeClass("active"),$next.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return isCycling&&this.cycle(),this}}};var old=$.fn.carousel;$.fn.carousel=function(option){return this.each(function(){var $this=$(this),data=$this.data("carousel"),options=$.extend({},$.fn.carousel.defaults,"object"==typeof option&&option),action="string"==typeof option?option:options.slide;data||$this.data("carousel",data=new Carousel(this,options)),"number"==typeof option?data.to(option):action?data[action]():options.interval&&data.cycle()})},$.fn.carousel.defaults={interval:5e3,pause:"hover"},$.fn.carousel.Constructor=Carousel,$.fn.carousel.noConflict=function(){return $.fn.carousel=old,this},$(document).on("click.carousel.data-api","[data-slide]",function(e){var href,$this=$(this),$target=$($this.attr("data-target")||(href=$this.attr("href"))&&href.replace(/.*(?=#[^\s]+$)/,"")),options=$.extend({},$target.data(),$this.data());$target.carousel(options),e.preventDefault()})}(window.jQuery),!function($){"use strict";var Collapse=function(element,options){this.$element=$(element),this.options=$.extend({},$.fn.collapse.defaults,options),this.options.parent&&(this.$parent=$(this.options.parent)),this.options.toggle&&this.toggle()};Collapse.prototype={constructor:Collapse,dimension:function(){var hasWidth=this.$element.hasClass("width");return hasWidth?"width":"height"},show:function(){var dimension,scroll,actives,hasData;if(!this.transitioning){if(dimension=this.dimension(),scroll=$.camelCase(["scroll",dimension].join("-")),actives=this.$parent&&this.$parent.find("> .accordion-group > .in"),actives&&actives.length){if(hasData=actives.data("collapse"),hasData&&hasData.transitioning)return;actives.collapse("hide"),hasData||actives.data("collapse",null)}this.$element[dimension](0),this.transition("addClass",$.Event("show"),"shown"),$.support.transition&&this.$element[dimension](this.$element[0][scroll])}},hide:function(){var dimension;this.transitioning||(dimension=this.dimension(),this.reset(this.$element[dimension]()),this.transition("removeClass",$.Event("hide"),"hidden"),this.$element[dimension](0))},reset:function(size){var dimension=this.dimension();return this.$element.removeClass("collapse")[dimension](size||"auto")[0].offsetWidth,this.$element[null!==size?"addClass":"removeClass"]("collapse"),this},transition:function(method,startEvent,completeEvent){var that=this,complete=function(){"show"==startEvent.type&&that.reset(),that.transitioning=0,that.$element.trigger(completeEvent)};this.$element.trigger(startEvent),startEvent.isDefaultPrevented()||(this.transitioning=1,this.$element[method]("in"),$.support.transition&&this.$element.hasClass("collapse")?this.$element.one($.support.transition.end,complete):complete())},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}};var old=$.fn.collapse;$.fn.collapse=function(option){return this.each(function(){var $this=$(this),data=$this.data("c
4025ollapse"),options="object"==typeof option&&option;data||$this.data("collapse",data=new Collapse(this,options)),"string"==typeof option&&data[option]()})},$.fn.collapse.defaults={toggle:!0},$.fn.collapse.Constructor=Collapse,$.fn.collapse.noConflict=function(){return $.fn.collapse=old,this},$(document).on("click.collapse.data-api","[data-toggle=collapse]",function(e){var href,$this=$(this),target=$this.attr("data-target")||e.preventDefault()||(href=$this.attr("href"))&&href.replace(/.*(?=#[^\s]+$)/,""),option=$(target).data("collapse")?"toggle":$this.data();$this[$(target).hasClass("in")?"addClass":"removeClass"]("collapsed"),$(target).collapse(option)})}(scriptJq
vendor: 22,967 bytes, line 4025
4025uery),!function($){"use strict";function clearMenus(){$(toggle).each(function(){getParent($(this)).removeClass("open")})}function getParent($this){var $parent,selector=$this.attr("data-target");return selector||(selector=$this.attr("href"),selector=selector&&/#/.test(selector)&&selector.replace(/.*(?=#[^\s]*$)/,"")),$parent=$(selector),$parent.length||($parent=$this.parent()),$parent}var toggle="[data-toggle=dropdown]",Dropdown=function(element){var $el=$(element).on("click.dropdown.data-api",this.toggle);$("html").on("click.dropdown.data-api",function(){$el.parent().removeClass("open")})};Dropdown.prototype={constructor:Dropdown,toggle:function(){var $parent,isActive,$this=$(this);if(!$this.is(".disabled, :disabled"))return $parent=getParent($this),isActive=$parent.hasClass("open"),clearMenus(),isActive||$parent.toggleClass("open"),$this.focus(),!1},keydown:function(e){var $this,$items,$parent,isActive,index;if(/(38|40|27)/.test(e.keyCode)&&($this=$(this),e.preventDefault(),e.stopPropagation(),!$this.is(".disabled, :disabled"))){if($parent=getParent($this),isActive=$parent.hasClass("open"),!isActive||isActive&&27==e.keyCode)return $this.click();$items=$("[role=menu] li:not(.divider):visible a",$parent),$items.length&&(index=$items.index($items.filter(":focus")),38==e.keyCode&&index>0&&index--,40==e.keyCode&&$items.length-1>index&&index++,~index||(index=0),$items.eq(index).focus())}}};var old=$.fn.dropdown;$.fn.dropdown=function(option){return this.each(function(){var $this=$(this),data=$this.data("dropdown");data||$this.data("dropdown",data=new Dropdown(this)),"string"==typeof option&&data[option].call($this)})},$.fn.dropdown.Constructor=Dropdown,$.fn.dropdown.noConflict=function(){return $.fn.dropdown=old,this},$(document).on("click.dropdown.data-api touchstart.dropdown.data-api",clearMenus).on("click.dropdown touchstart.dropdown.data-api",".dropdown form",function(e){e.stopPropagation()}).on("touchstart.dropdown.data-api",".dropdown-menu",function(e){e.stopPropagation()}).on("click.dropdown.data-api touchstart.dropdown.data-api",toggle,Dropdown.prototype.toggle).on("keydown.dropdown.data-api touchstart.dropdown.data-api",toggle+", [role=menu]",Dropdown.prototype.keydown)}(window.jQuery),!function($){"use strict";var Modal=function(element,options){this.options=options,this.$element=$(element).delegate('[data-dismiss="modal"]',"click.dismiss.modal",$.proxy(this.hide,this)),this.options.remote&&this.$element.find(".modal-body").load(this.options.remote)};Modal.prototype={constructor:Modal,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var that=this,e=$.Event("show");this.$element.trigger(e),this.isShown||e.isDefaultPrevented()||(this.isShown=!0,this.escape(),this.backdrop(function(){var transition=$.support.transition&&that.$element.hasClass("fade");that.$element.parent().length||that.$element.appendTo(document.body),that.$element.show(),transition&&that.$element[0].offsetWidth,that.$element.addClass("in").attr("aria-hidden",!1),that.enforceFocus(),transition?that.$element.one($.support.transition.end,function(){that.$element.focus().trigger("shown")}):that.$element.focus().trigger("shown")}))},hide:function(e){e&&e.preventDefault(),e=$.Event("hide"),this.$element.trigger(e),this.isShown&&!e.isDefaultPrevented()&&(this.isShown=!1,this.escape(),$(document).off("focusin.modal"),this.$element.removeClass("in").attr("aria-hidden",!0),$.support.transition&&this.$element.hasClass("fade")?this.hideWithTransition():this.hideModal())},enforceFocus:function(){var that=this;$(document).on("focusin.modal",function(e){that.$element[0]===e.target||that.$element.has(e.target).length||that.$element.focus()})},escape:function(){var that=this;this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.modal",function(e){27==e.which&&that.hide()}):this.isShown||this.$element.off("keyup.dismiss.modal")},hideWithTransition:function(){var that=this,timeout=setTimeout(function(){that.$element.off($.support.transition.end),that.hideModal()},500);this.$element.one($.support.transition.end,function(){clearTimeout(timeout),that.hideModal()})},hideModal:function(){this.$element.hide().trigger("hidden"),this.backdrop()},removeBackdrop:function(){this.$backdrop.remove(),this.$backdrop=null},backdrop:function(callback){var animate=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var doAnimate=$.support.transition&&animate;this.$backdrop=$('<div class="modal-backdrop '+animate+'" />').appendTo(document.body),this.$backdrop.click("static"==this.options.backdrop?$.proxy(this.$element[0].focus,this.$element[0]):$.proxy(this.hide,this)),doAnimate&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),doAnimate?this.$backdrop.one($.support.transition.end,callback):callback()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),$.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one($.support.transition.end,$.proxy(this.removeBackdrop,this)):this.removeBackdrop()):callback&&callback()}};var old=$.fn.modal;$.fn.modal=function(option){return this.each(function(){var $this=$(this),data=$this.data("modal"),options=$.extend({},$.fn.modal.defaults,$this.data(),"object"==typeof option&&option);data||$this.data("modal",data=new Modal(this,options)),"string"==typeof option?data[option]():options.show&&data.show()})},$.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0},$.fn.modal.Constructor=Modal,$.fn.modal.noConflict=function(){return $.fn.modal=old,this},$(document).on("click.modal.data-api",'[data-toggle="modal"]',function(e){var $this=$(this),href=$this.attr("href"),$target=$($this.attr("data-target")||href&&href.replace(/.*(?=#[^\s]+$)/,"")),option=$target.data("modal")?"toggle":$.extend({remote:!/#/.test(href)&&href},$target.data(),$this.data());e.preventDefault(),$target.modal(option).one("hide",function(){$this.focus()})})}(window.jQuery),!function($){"use strict";var Tooltip=function(element,options){this.init("tooltip",element,options)};Tooltip.prototype={constructor:Tooltip,init:function(type,element,options){var eventIn,eventOut;this.type=type,this.$element=$(element),this.options=this.getOptions(options),this.enabled=!0,"click"==this.options.trigger?this.$element.on("click."+this.type,this.options.selector,$.proxy(this.toggle,this)):"manual"!=this.options.trigger&&(eventIn="hover"==this.options.trigger?"mouseenter":"focus",eventOut="hover"==this.options.trigger?"mouseleave":"blur",this.$element.on(eventIn+"."+this.type,this.options.selector,$.proxy(this.enter,this)),this.$element.on(eventOut+"."+this.type,this.options.selector,$.proxy(this.leave,this))),this.options.selector?this._options=$.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(options){return options=$.extend({},$.fn[this.type].defaults,options,this.$element.data()),options.delay&&"number"==typeof options.delay&&(options.delay={show:options.delay,hide:options.delay}),options},enter:function(e){var self=$(e.currentTarget)[this.type](this._options).data(this.type);return self.options.delay&&self.options.delay.show?(clearTimeout(this.timeout),self.hoverState="in",this.timeout=setTimeout(function(){"in"==self.hoverState&&self.show()},self.options.delay.show),void 0):self.show()},leave:function(e){var self=$(e.currentTarget)[this.type](this._options).data(this.type);return this.timeout&&clearTimeout(this.timeout),self.options.delay&&self.options.delay.hide?(self.hoverState="out",this.timeout=setTimeout(function(){"out"==self.hoverState&&self.hide()},self.options.delay.hide),void 0):self.hide()},show:function(){var $tip,inside,pos,actualWidth,actualHeight,placement,tp;if(this.hasContent()&&this.enabled){switch($tip=this.tip(),this.setContent(),this.options.animation&&$tip.addClass("fade"),placement="function"==typeof this.options.placement?this.options.placement.call(this,$tip[0],this.$element[0]):this.options.placement,inside=/in/.test(placement),$tip.detach().css({top:0,left:0,display:"block"}).insertAfter(this.$element),pos=this.getPosition(inside),actualWidth=$tip[0].offsetWidth,actualHeight=$tip[0].offsetHeight,inside?placement.split(" ")[1]:placement){case"bottom":tp={top:pos.top+pos.height,left:pos.left+pos.width/2-actualWidth/2};break;case"top":tp={top:pos.top-actualHeight,left:pos.left+pos.width/2-actualWidth/2};break;case"left":tp={top:pos.top+pos.height/2-actualHeight/2,left:pos.left-actualWidth};break;case"right":tp={top:pos.top+pos.height/2-actualHeight/2,left:pos.left+pos.width}}$tip.offset(tp).addClass(placement).addClass("in")}},setContent:function(){var $tip=this.tip(),title=this.getTitle();$tip.find(".tooltip-inner")[this.options.html?"html":"text"](title),$tip.removeClass("fade in top bottom left right")},hide:function(){function removeWithAnimation(){var timeout=setTimeout(function(){$tip.off($.support.transition.end).detach()},500);$tip.one($.support.transition.end,function(){clearTimeout(timeout),$tip.detach()})}var $tip=this.tip();return $tip.removeClass("in"),$.support.transition&&this.$tip.hasClass("fade")?removeWithAnimation():$tip.detach(),this},fixTitle:function(){var $e=this.$element;($e.attr("title")||"string"!=typeof $e.attr("data-original-title"))&&$e.attr("data-original-title",$e.attr("title")||"").removeAttr("title")},hasContent:function(){return this.getTitle()},getPosition:function(inside){return $.extend({},inside?{top:0,left:0}:this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var title,$e=this.$element,o=this.options;return title=$e.attr("data-original-title")||("function"==typeof o.title?o.title.call($e[0]):o.title)},tip:function(){return this.$tip=this.$tip||$(this.options.template)},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(e){var self=$(e.currentTarget)[this.type](this._options).data(this.type);self[self.tip().hasClass("in")?"hide":"show"]()},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}};var old=$.fn.tooltip;$.fn.tooltip=function(option){return this.each(function(){var $this=$(this),data=$this.data("tooltip"),options="object"==typeof option&&option;data||$this.data("tooltip",data=new Tooltip(this,options)),"string"==typeof option&&data[option]()})},$.fn.tooltip.Constructor=Tooltip,$.fn.tooltip.defaults={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover",title:"",delay:0,html:!1},$.fn.tooltip.noConflict=function(){return $.fn.tooltip=old,this}}(window.jQuery),!function($){"use strict";var Popover=function(element,options){this.init("popover",element,options)};Popover.prototype=$.extend({},$.fn.tooltip.Constructor.prototype,{constructor:Popover,setContent:function(){var $tip=this.tip(),title=this.getTitle(),content=this.getContent();$tip.find(".popover-title")[this.options.html?"html":"text"](title),$tip.find(".popover-content")[this.options.html?"html":"text"](content),$tip.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var content,$e=this.$element,o=this.options;return content=$e.attr("data-content")||("function"==typeof o.content?o.content.call($e[0]):o.content)},tip:function(){return this.$tip||(this.$tip=$(this.options.template)),this.$tip},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}});var old=$.fn.popover;$.fn.popover=function(option){return this.each(function(){var $this=$(this),data=$this.data("popover"),options="object"==typeof option&&option;data||$this.data("popover",data=new Popover(this,options)),"string"==typeof option&&data[option]()})},$.fn.popover.Constructor=Popover,$.fn.popover.defaults=$.extend({},$.fn.tooltip.defaults,{placement:"right",trigger:"click",content:"",template:'<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"></div></div></div>'}),$.fn.popover.noConflict=function(){return $.fn.popover=old,this}}(window.jQuery),!function($){"use strict";function ScrollSpy(element,options){var href,process=$.proxy(this.process,this),$element=$(element).is("body")?$(window):$(element);this.options=$.extend({},$.fn.scrollspy.defaults,options),this.$scrollElement=$element.on("scroll.scroll-spy.data-api",process),this.selector=(this.options.target||(href=$(element).attr("href"))&&href.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.$body=$("body"),this.refresh(),this.process()}ScrollSpy.prototype={constructor:ScrollSpy,refresh:function(){var $targets,self=this;this.offsets=$([]),this.targets=$([]),$targets=this.$body.find(this.selector).map(function(){var $el=$(this),href=$el.data("target")||$el.attr("href"),$href=/^#\w/.test(href)&&$(href);return $href&&$href.length&&[[$href.position().top+self.$scrollElement.scrollTop(),href]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){self.offsets.push(this[0]),self.targets.push(this[1])})},process:function(){var i,scrollTop=this.$scrollElement.scrollTop()+this.options.offset,scrollHeight=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,maxScroll=scrollHeight-this.$scrollElement.height(),offsets=this.offsets,targets=this.targets,activeTarget=this.activeTarget;if(scrollTop>=maxScroll)return activeTarget!=(i=targets.last()[0])&&this.activate(i);for(i=offsets.length;i--;)activeTarget!=targets[i]&&scrollTop>=offsets[i]&&(!offsets[i+1]||offsets[i+1]>=scrollTop)&&this.activate(targets[i])},activate:function(target){var active,selector;this.activeTarget=target,$(this.selector).parent(".active").removeClass("active"),selector=this.selector+'[data-target="'+target+'"],'+this.selector+'[href="'+target+'"]',active=$(selector).parent("li").addClass("active"),active.parent(".dropdown-menu").length&&(active=active.closest("li.dropdown").addClass("active")),active.trigger("activate")}};var old=$.fn.scrollspy;$.fn.scrollspy=function(option){return this.each(function(){var $this=$(this),data=$this.data("scrollspy"),options="object"==typeof option&&option;data||$this.data("scrollspy",data=new ScrollSpy(this,options)),"string"==typeof option&&data[option]()})},$.fn.scrollspy.Constructor=ScrollSpy,$.fn.scrollspy.defaults={offset:10},$.fn.scrollspy.noConflict=function(){return $.fn.scrollspy=old,this},$(window).on("load",function(){$('[data-spy="scroll"]').each(function(){var $spy=$(this);$spy.scrollspy($spy.data())})})}(window.jQuery),!function($){"use strict";var Tab=function(element){this.element=$(element)};Tab.prototype={constructor:Tab,show:function(){var previous,$target,e,$this=this.element,$ul=$this.closest("ul:not(.dropdown-menu)"),selector=$this.attr("data-target");selector||(selector=$this.attr("href"),selector=selector&&selector.replace(/.*(?=#[^\s]*$)/,"")),$this.parent("li").hasClass("active")||(previous=$ul.find(".active:last a")[0],e=$.Event("show",{relatedTarget:previous}),$this.trigger(e),e.isDefaultPrevented()||($target=$(selector),this.activate($this.parent("li"),$ul),this.activate($target,$target.parent(),function(){$this.trigger({type:"shown",relatedTarget:previous})})))},activate:function(element,container,callback){function next(){$active.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),element.addClass("active"),transition?(element[0].offsetWidth,element.addClass("in")):element.removeClass("fade"),element.parent(".dropdown-menu")&&element.closest("li.dropdown").addClass("active"),callback&&callback()}var $active=container.find("> .active"),transition=callback&&$.support.transition&&$active.hasClass("fade");transition?$active.one($.support.transition.end,next):next(),$active.removeClass("in")}};var old=$.fn.tab;$.fn.tab=function(option){return this.each(function(){var $this=$(this),data=$this.data("tab");data||$this.data("tab",data=new Tab(this)),"string"==typeof option&&data[option]()})},$.fn.tab.Constructor=Tab,$.fn.tab.noConflict=function(){return $.fn.tab=old,this},$(document).on("click.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(e){e.preventDefault(),$(this).tab("show")})}(window.jQuery),!function($){"use strict";var Typeahead=function(element,options){this.$element=$(element),this.options=$.extend({},$.fn.typeahead.defaults,options),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.highlighter=this.options.highlighter||this.highlighter,this.updater=this.options.updater||this.updater,this.source=this.options.source,this.$menu=$(this.options.menu),this.shown=!1,this.listen()};Typeahead.prototype={constructor:Typeahead,select:function(){var val=this.$menu.find(".active").attr("data-value");return this.$element.val(this.updater(val)).change(),this.hide()},updater:function(item){return item},show:function(){var pos=$.extend({},this.$element.position(),{height:this.$element[0].offsetHeight});return this.$menu.insertAfter(this.$element).css({top:pos.top+pos.height,left:pos.left}).show(),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(){var items;return this.query=this.$element.val(),!this.query||this.query.length<this.options.minLength?this.shown?this.hide():this:(items=$.isFunction(this.source)?this.source(this.query,$.proxy(this.process,this)):this.source,items?this.process(items):this)},process:function(items){var that=this;return items=$.grep(items,function(item){return that.matcher(item)}),items=this.sorter(items),items.length?this.render(items.slice(0,this.options.items)).show():this.shown?this.hide():this},matcher:function(item){return~item.toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(items){for(var item,beginswith=[],caseSensitive=[],caseInsensitive=[];item=items.shift();)item.toLowerCase().indexOf(this.query.toLowerCase())?~item.indexOf(this.query)?caseSensitive.push(item):caseInsensitive.push(item):beginswith.push(item);return beginswith.concat(caseSensitive,caseInsensitive)},highlighter:function(item){var query=this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return item.replace(RegExp("("+query+")","ig"),function($1,match){return"<strong>"+match+"</strong>"})},render:function(items){var that=this;return items=$(items).map(function(i,item){return i=$(that.options.item).attr("data-value",item),i.find("a").html(that.highlighter(item)),i[0]}),items.first().addClass("active"),this.$menu.html(items),this},next:function(){var active=this.$menu.find(".active").removeClass("active"),next=active.next();next.length||(next=$(this.$menu.find("li")[0])),next.addClass("active")},prev:function(){var active=this.$menu.find(".active").removeClass("active"),prev=active.prev();prev.length||(prev=this.$menu.find("li").last()),prev.addClass("active")},listen:function(){this.$element.on("blur",$.proxy(this.blur,this)).on("keypress",$.proxy(this.keypress,this)).on("keyup",$.proxy(this.keyup,this)),this.eventSupported("keydown")&&this.$element.on("keydown",$.proxy(this.keydown,this)),this.$menu.on("click",$.proxy(this.click,this)).on("mouseenter","li",$.proxy(this.mouseenter,this))},eventSupported:function(eventName){var isSupported=eventName in this.$element;return isSupported||(this.$element.setAttribute(eventName,"return;"),isSupported="function"==typeof this.$element[eventName]),isSupported},move:function(e){if(this.shown){switch(e.keyCode){case 9:case 13:case 27:e.preventDefault();break;case 38:e.preventDefault(),this.prev();break;case 40:e.preventDefault(),this.next()}e.stopPropagation()}},keydown:function(e){this.suppressKeyPressRepeat=~$.inArray(e.keyCode,[40,38,9,13,27]),this.move(e)},keypress:function(e){this.suppressKeyPressRepeat||this.move(e)},keyup:function(e){switch(e.keyCode){case 40:case 38:case 16:case 17:case 18:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:if(!this.shown)return;this.hide();break;default:this.lookup()}e.stopPropagation(),e.preventDefault()},blur:function(){var that=this;setTimeout(function(){that.hide()},150)},click:function(e){e.stopPropagation(),e.preventDefault(),this.select()},mouseenter:function(e){this.$menu.find(".active").removeClass("active"),$(e.currentTarget).addClass("active")}};var old=$.fn.typeahead;$.fn.typeahead=function(option){return this.each(function(){var $this=$(this),data=$this.data("typeahead"),options="object"==typeof option&&option;data||$this.data("typeahead",data=new Typeahead(this,options)),"string"==typeof option&&data[option]()})},$.fn.typeahead.defaults={source:[],items:8,menu:'<ul class="typeahead dropdown-menu"></ul>',item:'<li><a href="#"></a></li>',minLength:1},$.fn.typeahead.Constructor=Typeahead,$.fn.typeahead.noConflict=function(){return $.fn.typeahead=old,this},$(document).on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(e){var $this=$(this);$this.data("typeahead")||(e.preventDefault(),$this.typeahead($this.data()))})}(window.jQuery),!function($){"use strict";var Affix=function(element,options){this.options=$.extend({},$.fn.affix.defaults,options),this.$window=$(window).on("scroll.affix.data-api",$.proxy(this.checkPosition,this)).on("click.affix.data-api",$.proxy(function(){setTimeout($.proxy(this.checkPosition,this),1)},this)),this.$element=$(element),this.checkPosition()};Affix.prototype.checkPosition=function(){if(this.$element.is(":visible")){var affix,scrollHeight=$(document).height(),scrollTop=this.$window.scrollTop(),position=this.$element.offset(),offset=this.options.offset,offsetBottom=offset.bottom,offsetTop=offset.top,reset="affix affix-top affix-bottom";"object"!=typeof offset&&(offsetBottom=offsetTop=offset),"function"==typeof offsetTop&&(offsetTop=offset.top()),"function"==typeof offsetBottom&&(offsetBottom=offset.bottom()),affix=null!=this.unpin&&scrollTop+this.unpin<=position.top?!1:null!=offsetBottom&&position.top+this.$element.height()>=scrollHeight-offsetBottom?"bottom":null!=offsetTop&&offsetTop>=scrollTop?"top":!1,this.affixed!==affix&&(this.affixed=affix,this.unpin="bottom"==affix?position.top-scrollTop:null,this.$element.removeClass(reset).addClass("affix"+(affix?"-"+affix:"")))}};var old=$.fn.affix;$.fn.affix=function(option){return this.each(function(){var $this=$(this),data=$this.data("affix"),options="object"==typeof option&&option;data||$this.data("affix",data=new Affix(this,options)),"string"==typeof option&&data[option]()})},$.fn.affix.Constructor=Affix,$.fn.affix.defaults={offset:0},$.fn.affix.noConflict=function(){return $.fn.affix=old,this},$(window).on("load",function(){$('[data-spy="affix"]').each(function(){var $spy=$(this),data=$spy.data();data.offset=data.offset||{},data.offsetBottom&&(data.offset.bottom=data.offsetBottom),data.offsetTop&&(data.offset.top=data.offsetTop),$spy.affix(data)})})}(
4025scriptJquery);; 4026 4027 /** 4028 * @license 4029 * ========================================================= 4030 * bootstrap-datetimepicker.js 4031 * http://www.eyecon.ro/bootstrap-datepicker 4032 * ========================================================= 4033 * Copyright 2012 Stefan Petre 4034 * 4035 * Contributions: 4036 * - Andrew Rowls 4037 * - Thiago de Arruda 4038 * 4039 * Licensed under the Apache License, Version 2.0 (the "License"); 4040 * you may not use this file except in compliance with the License. 4041 * You may obtain a copy of the License at 4042 * 4043 * http://www.apache.org/licenses/LICENSE-2.0 4044 * 4045 * Unless required by applicable law or agreed to in writing, software 4046 * distributed under the License is distributed on an "AS IS" BASIS, 4047 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4048 * See the License for the specific language governing permissions and 4049 * limitations under the License. 4050 * ========================================================= 4051 */ 4052(function ($) { 4053 var smartPhone = window.orientation != undefined; 4054 var DateTimePicker = function (element, options) { 4055 this.id = dpgId++; 4056 this.init(element, options); 4057 }; 4058 var dateToDate = function (dt) { 4059 if (typeof dt === "string") { 4060 return new Date(dt); 4061 } 4062 return dt; 4063 }; 4064 DateTimePicker.prototype = { 4065 constructor: DateTimePicker, 4066 init: function (element, options) { 4067 var icon; 4068 if (!(options.pickTime || options.pickDate)) throw new Error("Mu
4068st choose at least one picker"); 4069 this.options = options; 4070 this.$element = $(element); 4071 this.language = options.language in dates ? options.language : "en"; 4072 this.pickDate = options.pickDate; 4073 this.pickTime = options.pickTime; 4074 this.isInput = this.$element.is("input"); 4075 this.component = false; 4076 if (this.$element.find(".input-append") || this.$element.find(".input-prepend")) this.component = this.$element.find(".add-on"); 4077 this.format = options.format; 4078 if (!this.format) { 4079 if (this.isInput) this.format = this.$element.data("format"); 4080 else this.format = this.$element.find("input").data("format"); 4081 if (!this.format) this.format = "MM/dd/yyyy"; 4082 } 4083 this._compileFormat(); 4084 if (this.component) { 4085 icon = this.component.find("i"); 4086 } 4087 if (this.pickTime) { 4088 if (icon && icon.length) this.timeIcon = icon.data("time-icon"); 4089 if (!this.timeIcon) this.timeIcon = "icon-time"; 4090 icon.addClass(this.timeIcon); 4091 } 4092 if (this.pickDate) { 4093 if (icon && icon.length) this.dateIcon = icon.data("date-icon"); 4094 if (!this.dateIcon) this.dateIcon = "icon-calendar"; 4095 icon.removeClass(this.timeIcon); 4096 icon.addClass(this.dateIcon); 4097 } 4098 this.widget = $(getTemplate(this.timeIcon, options.pickDate, options.pickTime, options.pick12HourFormat, options.pickSeconds, options.collapse)).appendTo("body"); 4099 this.minViewMode = options.minViewMode || this.$element.data("date-minviewmode") || 0; 4100 if (typeof this.minViewMode === "string") { 4101 switch (this.minViewMode) { 4102 case "months": 4103 this.minViewMode = 1; 4104 break; 4105 case "years": 4106 this.minViewMode = 2; 4107 break; 4108 default: 4109 this.minViewMode = 0; 4110 break; 4111 } 4112 } 4113 this.viewMode = options.viewMode || this.$element.data("date-viewmode") || 0; 4114 if (typeof this.viewMode === "string") { 4115 switch (this.viewMode) { 4116 case "months": 4117 this.viewMode = 1; 4118 break; 4119 case "years": 4120 this.viewMode = 2; 4121 break; 4122 default: 4123 this.viewMode = 0; 4124 break; 4125 } 4126 } 4127 this.startViewMode = this.viewMode; 4128 this.weekStart = options.weekStart || this.$element.data("date-weekstart") || 0; 4129 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1; 4130 this.setStartDate(options.startDate || this.$element.data("date-startdate")); 4131 this.setEndDate(options.endDate || this.$element.data("date-enddate")); 4132 this.fillDow(); 4133 this.fillMonths(); 4134 this.fillHours(); 4135 this.fillMinutes(); 4136 this.fillSeconds(); 4137 this.update(); 4138 this.showMode(); 4139 this._attachDatePickerEvents(); 4140 }, 4141 show: function (e) { 4142 this.widget.show(); 4143 this.height = this.component ? this.component.outerHeight() : this.$element.outerHeight(); 4144 this.place(); 4145 this.$element.trigger({ type: "show", date: this._date }); 4146 this._attachDatePickerGlobalEvents(); 4147 if (e) { 4148 e.stopPropagation(); 4149 e.preventDefault(); 4150 } 4151 }, 4152 disable: function () { 4153 this.$element.find("input").prop("disabled", true); 4154 this._detachDatePickerEvents(); 4155 }, 4156 enable: function () { 4157 this.$element.find("input").prop("disabled", false); 4158 this._attachDatePickerEvents(); 4159 }, 4160 hide: function () { 4161 var collapse = this.widget.find(".collapse"); 4162 for (var i = 0; i < collapse.length; i++) {
4163 var collapseData = collapse.eq(i).data("collapse"); 4164 if (collapseData && collapseData.transitioning) return; 4165 } 4166 this.widget.hide(); 4167 this.viewMode = this.startViewMode; 4168 this.showMode(); 4169 this.set(); 4170 this.$element.trigger({ type: "hide", date: this._date }); 4171 this._detachDatePickerGlobalEvents(); 4172 }, 4173 set: function () { 4174 var formatted = ""; 4175 if (!this._unset) formatted = this.formatDate(this._date); 4176 if (!this.isInput) { 4177 if (this.component) { 4178 var input = this.$element.find("input"); 4179 input.val(formatted); 4180 this._resetMaskPos(input); 4181 } 4182 this.$element.data("date", formatted); 4183 } else { 4184 this.$element.val(formatted); 4185 this._resetMaskPos(this.$element); 4186 } 4187 }, 4188 setValue: function (newDate) { 4189 if (!newDate) { 4190 this._unset = true; 4191 } else { 4192 this._unset = false; 4193 } 4194 if (typeof newDate === "string") { 4195 this._date = this.parseDate(newDate); 4196 } else if (newDate) { 4197 this._date = new Date(newDate); 4198 } 4199 this.set(); 4200 this.viewDate = UTCDate(this._date.getUTCFullYear(), this._date.getUTCMonth(), 1, 0, 0, 0, 0); 4201 this.fillDate(); 4202 this.fillTime(); 4203 }, 4204 getDate: function () { 4205 if (this._unset) return null; 4206 return new Date(this._date.valueOf()); 4207 }, 4208 setDate: function (date) { 4209 if (!date) this.setValue(null); 4210 else this.setValue(date.valueOf()); 4211 }, 4212 setStartDate: function (date) { 4213 if (date instanceof Date) { 4214 this.startDate = date; 4215 } else if (typeof date === "string") { 4216 this.startDate = new UTCDate(date); 4217 if (!this.startDate.getUTCFullYear()) { 4218 this.startDate = -Infinity; 4219 } 4220 } else { 4221 this.startDate = -Infinity; 4222 } 4223 if (this.viewDate) { 4224 this.update(); 4225 } 4226 }, 4227 setEndDate: function (date) { 4228 if (date instanceof Date) { 4229 this.endDate = date; 4230 } else if (typeof date === "string") { 4231 this.endDate = new UTCDate(date); 4232 if (!this.endDate.getUTCFullYear()) { 4233 this.endDate = Infinity; 4234 } 4235 } else { 4236 this.endDate = Infinity; 4237 } 4238 if (this.viewDate) { 4239 this.update(); 4240 } 4241 }, 4242 getLocalDate: function () { 4243 if (this._unset) return null; 4244 var d = this._date; 4245 return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()); 4246 }, 4247 setLocalDate: function (localDate) { 4248 if (!localDate) this.setValue(null); 4249 else this.setValue(Date.UTC(localDate.getFullYear(), localDate.getMonth(), localDate.getDate(), localDate.getHours(), localDate.getMinutes(), localDate.getSeconds(), localDate.getMilliseconds())); 4250 }, 4251 place: function () { 4252 var position = "absolute"; 4253 var offset = this.component ? this.component.offset() : this.$element.offset(); 4254 this.width = this.component ? this.component.outerWidth() : this.$element.outerWidth(); 4255 offset.top = offset.top + this.height; 4256 var $window = $(window); 4257 if (this.options.width != undefined) { 4258 this.widget.width(this.options.width); 4259 } 4260 if (this.options.orientation == "left") { 4261 this.widget.addClass("left-oriented"); 4262 offset.left = offset.left - this.widget.width() + 20; 4263 } 4264 if (this._isInFixed()) { 4265 position = "fixed"; 4266 offset.top -= $window.scrollTop(); 4267 offset.left -= $window.scrollLeft(); 4268 } 4269 if ($window.width() < offset.left + this.widget.outerWidth()) { 4270 offset.right = $window.width() - offset.left - this.width; 4271 offset.left = "auto"; 4272 this.widget.addClass("pull-right"); 4273 } else { 4274 offset.right = "auto"; 4275 this.widget.removeClass("pull-right"); 4276 } 4277 this.widget.css({ position: position, top: offset.top, left: offset.left, right: offset.right }); 4278 }, 4279 notifyChange: function () { 4280 this.$element.trigger({ type: "changeDate", date: this.getDate(), localDate: this.getLocalDate() }); 4281 }, 4282 update: function (newDate) { 4283 var dateStr = newDate; 4284 if (!dateStr) { 4285 if (this.isInput) { 4286 dateStr = this.$element.val(); 4287 } else { 4288 dateStr = this.$element.find("input").val(); 4289 } 4290 if (dateStr) { 4291 this._date = this.parseDate(dateStr); 4292 } 4293 if (!this._date) { 4294 var tmp = new Date(); 4295 this._date = UTCDate(tmp.getFullYear(), tmp.getMonth(), tmp.getDate(), tmp.getHours(), tmp.getMinutes(), tmp.getSeconds(), tmp.getMilliseconds()); 4296 } 4297 } 4298 this.viewDate = UTCDate(this._date.getUTCFullYear(), this._date.getUTCMonth(), 1, 0, 0, 0, 0); 4299 this.fillDate(); 4300 this.fillTime(); 4301 }, 4302 fillDow: function () { 4303 var dowCnt = this.weekStart; 4304 var html = $("<tr>"); 4305 while (dowCnt < this.weekStart + 7) { 4306 html.append('<th class="dow">' + dates[this.language].daysMin[dowCnt++ % 7] + "</th>"); 4307 } 4308 this.widget.find(".datepicker-days thead").append(html); 4309 }, 4310 fillMonths: function () { 4311 var html = ""; 4312 var i = 0; 4313 while (i < 12) { 4314 html += '<span class="month">' + dates[this.language].monthsShort[i++] + "</span>"; 4315 } 4316 this.widget.find(".datepicker-months td").append(html); 4317 }, 4318 fillDate: function () { 4319 var year = this.viewDate.getUTCFullYear();
4320 var month = this.viewDate.getUTCMonth(); 4321 var currentDate = UTCDate(this._date.getUTCFullYear(), this._date.getUTCMonth(), this._date.getUTCDate(), 0, 0, 0, 0); 4322 var startYear = typeof this.startDate === "object" ? this.startDate.getUTCFullYear() : -Infinity; 4323 var startMonth = typeof this.startDate === "object" ? this.startDate.getUTCMonth() : -1; 4324 var endYear = typeof this.endDate === "object" ? this.endDate.getUTCFullYear() : Infinity; 4325 var endMonth = typeof this.endDate === "object" ? this.endDate.getUTCMonth() : 12; 4326 this.widget.find(".datepicker-days").find(".disabled").removeClass("disabled"); 4327 this.widget.find(".datepicker-months").find(".disabled").removeClass("disabled"); 4328 this.widget.find(".datepicker-years").find(".disabled").removeClass("disabled"); 4329 this.widget.find(".datepicker-days th:eq(1)").text(dates[this.language].months[month] + " " + year); 4330 var prevMonth = UTCDate(year, month - 1, 28, 0, 0, 0, 0); 4331 var day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth()); 4332 prevMonth.setUTCDate(day); 4333 prevMonth.setUTCDate(day - ((prevMonth.getUTCDay() - this.weekStart + 7) % 7)); 4334 if ((year == startYear && month <= startMonth) || year < startYear) { 4335 this.widget.find(".datepicker-days th:eq(0)").addClass("disabled"); 4336 } 4337 if ((year == endYear && month >= endMonth) || year > endYear) { 4338 this.widget.find(".datepicker-days th:eq(2)").addClass("disabled"); 4339 } 4340 var nextMonth = new Date(prevMonth.valueOf()); 4341 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42); 4342 nextMonth = nextMonth.valueOf(); 4343 var html = []; 4344 var row; 4345 var clsName; 4346 while (prevMonth.valueOf() < nextMonth) { 4347 if (prevMonth.getUTCDay() === this.weekStart) { 4348 row = $("<tr>"); 4349 html.push(row); 4350 } 4351 clsName = ""; 4352 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) { 4353 clsName += " old"; 4354 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) { 4355 clsName += " new"; 4356 } 4357 if (prevMonth.valueOf() === currentDate.valueOf()) { 4358 clsName += " active"; 4359 } 4360 if (prevMonth.valueOf() + 864e5 <= this.startDate) { 4361 clsName += " disabled"; 4362 } 4363 if (prevMonth.valueOf() > this.endDate) { 4364 clsName += " disabled"; 4365 } 4366 row.append('<td class="day' + clsName + '">' + prevMonth.getUTCDate() + "</td>"); 4367 prevMonth.setUTCDate(prevMonth.getUTCDate() + 1); 4368 } 4369 this.widget.find(".datepicker-days tbody").empty().append(html); 4370 var currentYear = this._date.getUTCFullYear(); 4371 var months = this.widget.find(".datepicker-months").find("th:eq(1)").text(year).end().find("span").removeClass("active"); 4372 if (currentYear === year) { 4373 months.eq(this._date.getUTCMonth()).addClass("active"); 4374 } 4375 if (currentYear - 1 < startYear) { 4376 this.widget.find(".datepicker-months th:eq(0)").addClass("disabled"); 4377 } 4378 if (currentYear + 1 > endYear) { 4379 this.widget.find(".datepicker-months th:eq(2)").addClass("disabled"); 4380 } 4381 for (var i = 0; i < 12; i++) { 4382 if ((year == startYear && startMonth > i) || year < startYear) { 4383 $(months[i]).addClass("disabled"); 4384 } else if ((year == endYear && endMonth < i) || year > endYear) { 4385 $(months[i]).addClass("disabled"); 4386 } 4387 } 4388 html = ""; 4389 year = parseInt(year / 10, 10) * 10; 4390 var yearCont = this.widget 4391 .find(".datepicker-years") 4392 .find("th:eq(1)") 4393 .text(year + "-" + (year + 9)) 4394 .end() 4395 .find("td"); 4396 this.widget.find(".datepicker-years").find("th").removeClass("disabled"); 4397 if (startYear > year) { 4398 this.widget.find(".datepicker-years").find("th:eq(0)").addClass("disabled"); 4399 } 4400 if (endYear < year + 9) { 4401 this.widget.find(".datepicker-years").find("th:eq(2)").addClass("disabled"); 4402 } 4403 year -= 1;
4404 for (var i = -1; i < 11; i++) { 4405 html += '<span class="year' + (i === -1 || i === 10 ? " old" : "") + (currentYear === year ? " active" : "") + (year < startYear || year > endYear ? " disabled" : "") + '">' + year + "</span>"; 4406 year += 1; 4407 } 4408 yearCont.html(html); 4409 }, 4410 fillHours: function () { 4411 var table = this.widget.find(".timepicker .timepicker-hours table"); 4412 table.parent().hide(); 4413 var html = ""; 4414 if (this.options.pick12HourFormat) { 4415 var current = 1; 4416 for (var i = 0; i < 3; i += 1) { 4417 html += "<tr>"; 4418 for (var j = 0; j < 4; j += 1) { 4419 var c = current.toString(); 4420 html += '<td class="hour">' + padLeft(c, 2, "0") + "</td>"; 4421 current++; 4422 } 4423 html += "</tr>"; 4424 } 4425 } else { 4426 var current = 0; 4427 for (var i = 0; i < 6; i += 1) { 4428 html += "<tr>"; 4429 for (var j = 0; j < 4; j += 1) { 4430 var c = current.toString(); 4431 html += '<td class="hour">' + padLeft(c, 2, "0") + "</td>"; 4432 current++; 4433 } 4434 html += "</tr>"; 4435 } 4436 } 4437 table.html(html); 4438 }, 4439 fillMinutes: function () { 4440 var table = this.widget.find(".timepicker .timepicker-minutes table"); 4441 table.parent().hide(); 4442 var html = ""; 4443 var current = 0; 4444 for (var i = 0; i < 5; i++) { 4445 html += "<tr>"; 4446 for (var j = 0; j < 4; j += 1) { 4447 var c = current.toString(); 4448 html += '<td class="minute">' + padLeft(c, 2, "0") + "</td>"; 4449 current += 3; 4450 } 4451 html += "</tr>"; 4452 } 4453 table.html(html); 4454 }, 4455 fillSeconds: function () { 4456 var table = this.widget.find(".timepicker .timepicker-seconds table"); 4457 table.parent().hide(); 4458 var html = ""; 4459 var current = 0; 4460 for (var i = 0; i < 5; i++) { 4461 html += "<tr>"; 4462 for (var j = 0; j < 4; j += 1) { 4463 var c = current.toString(); 4464 html += '<td class="second">' + padLeft(c, 2, "0") + "</td>"; 4465 current += 3; 4466 } 4467 html += "</tr>"; 4468 } 4469 table.html(html); 4470 }, 4471 fillTime: function () { 4472 if (!this._date) return; 4473 var timeComponents = this.widget.find(".timepicker span[data-time-component]"); 4474 var table = timeComponents.closest("table"); 4475 var is12HourFormat = this.options.pick12HourFormat; 4476 var hour = this._date.getUTCHours(); 4477 var period = "AM"; 4478 if (is12HourFormat) { 4479 if (hour >= 12) period = "PM"; 4480 if (hour === 0) hour = 12; 4481 else if (hour != 12) hour = hour % 12; 4482 this.widget.find(".timepicker [data-action=togglePeriod]").text(period); 4483 } 4484 hour = padLeft(hour.toString(), 2, "0"); 4485 var minute = padLeft(this._date.getUTCMinutes().toString(), 2, "0"); 4486 var second = padLeft(this._date.getUTCSeconds().toString(), 2, "0"); 4487 timeComponents.filter("[data-time-component=hours]").text(hour); 4488 timeComponents.filter("[data-time-component=minutes]").text(minute); 4489 timeComponents.filter("[data-time-component=seconds]").text(second); 4490 }, 4491 click: function (e) { 4492 e.stopPropagation(); 4493 e.preventDefault(); 4494 this._unset = false; 4495 var target = $(e.target).closest("span, td, th"); 4496 if (target.length === 1) { 4497 if (!target.is(".disabled")) { 4498 switch (target[0].nodeName.toLowerCase()) { 4499 case "th": 4500 switch (target[0].className) { 4501 case "switch": 4502 this.showMode(1); 4503 break; 4504 case "prev": 4505 case "next": 4506 var vd = this.viewDate; 4507 var navFnc = DPGlobal.modes[this.viewMode].navFnc; 4508 var step = DPGlobal.modes[this.viewMode].navStep; 4509 if (target[0].className === "prev") step = step * -1; 4510 vd["set" + navFnc](vd["get" + navFnc]() + step); 4511 this.fillDate(); 4512 this.set(); 4513 break; 4514 } 4515 break; 4516 case "span": 4517 if (target.is(".month")) {
4518 var month = target.parent().find("span").index(target); 4519 this.viewDate.setUTCMonth(month); 4520 } else { 4521 var year = parseInt(target.text(), 10) || 0; 4522 this.viewDate.setUTCFullYear(year); 4523 } 4524 if (this.viewMode !== 0) { 4525 this._date = UTCDate( 4526 this.viewDate.getUTCFullYear(), 4527 this.viewDate.getUTCMonth(), 4528 this.viewDate.getUTCDate(), 4529 this._date.getUTCHours(), 4530 this._date.getUTCMinutes(), 4531 this._date.getUTCSeconds(), 4532 this._date.getUTCMilliseconds() 4533 ); 4534 this.notifyChange(); 4535 } 4536 this.showMode(-1); 4537 this.fillDate(); 4538 this.set(); 4539 break; 4540 case "td": 4541 if (target.is(".day")) { 4542 var day = parseInt(target.text(), 10) || 1; 4543 var month = this.viewDate.getUTCMonth(); 4544 var year = this.viewDate.getUTCFullYear(); 4545 if (target.is(".old")) { 4546 if (month === 0) { 4547 month = 11; 4548 year -= 1; 4549 } else { 4550 month -= 1; 4551 } 4552 } else if (target.is(".new")) { 4553 if (month == 11) { 4554 month = 0; 4555 year += 1; 4556 } else { 4557 month += 1; 4558 } 4559 } 4560 this._date = UTCDate(year, month, day, this._date.getUTCHours(), this._date.getUTCMinutes(), this._date.getUTCSeconds(), this._date.getUTCMilliseconds()); 4561 this.viewDate = UTCDate(year, month, Math.min(28, day), 0, 0, 0, 0); 4562 this.fillDate(); 4563 this.set(); 4564 this.notifyChange(); 4565 } 4566 break; 4567 } 4568 } 4569 } 4570 }, 4571 actions: { 4572 incrementHours: function (e) { 4573 this._date.setUTCHours(this._date.getUTCHours() + 1); 4574 }, 4575 incrementMinutes: function (e) { 4576 this._date.setUTCMinutes(this._date.getUTCMinutes() + 1); 4577 }, 4578 incrementSeconds: function (e) { 4579 this._date.setUTCSeconds(this._date.getUTCSeconds() + 1); 4580 }, 4581 decrementHours: function (e) { 4582 this._date.setUTCHours(this._date.getUTCHours() - 1); 4583 }, 4584 decrementMinutes: function (e) { 4585 this._date.setUTCMinutes(this._date.getUTCMinutes() - 1); 4586 }, 4587 decrementSeconds: function (e) { 4588 this._date.setUTCSeconds(this._date.getUTCSeconds() - 1); 4589 }, 4590 togglePeriod: function (e) { 4591 var hour = this._date.getUTCHours(); 4592 if (hour >= 12) hour -= 12; 4593 else hour += 12; 4594 this._date.setUTCHours(hour); 4595 }, 4596 showPicker: function () { 4597 this.widget.find(".timepicker > div:not(.timepicker-picker)").hide(); 4598 this.widget.find(".timepicker .timepicker-picker").show(); 4599 }, 4600 showHours: function () { 4601 this.widget.find(".timepicker .timepicker-picker").hide(); 4602 this.widget.find(".timepicker .timepicker-hours").show(); 4603 }, 4604 showMinutes: function () { 4605 this.widget.find(".timepicker .timepicker-picker").hide(); 4606 this.widget.find(".timepicker .timepicker-minutes").show(); 4607 }, 4608 showSeconds: function () { 4609 this.widget.find(".timepicker .timepicker-picker").hide(); 4610 this.widget.find(".timepicker .timepicker-seconds").show(); 4611 }, 4612 selectHour: function (e) { 4613 var tgt = $(e.target); 4614 var value = parseInt(tgt.text(), 10); 4615 if (this.options.pick12HourFormat) { 4616 var current = this._date.getUTCHours(); 4617 if (current >= 12) { 4618 if (value != 12) value = (value + 12) % 24; 4619 } else { 4620 if (value === 12) value = 0; 4621 else value = value % 12; 4622 } 4623 } 4624 this._date.setUTCHours(value); 4625 this.actions.showPicker.call(this); 4626 }, 4627 selectMinute: function (e) { 4628 var tgt = $(e.target); 4629 var value = parseInt(tgt.text(), 10); 4630 this._date.setUTCMinutes(value); 4631 this.actions.showPicker.call(this); 4632 }, 4633 selectSecond: function (e) { 4634 var tgt = $(e.target); 4635 var value = parseInt(tgt.text(), 10); 4636 this._date.setUTCSeconds(value); 4637 this.actions.showPicker.call(this); 4638 }, 4639 }, 4640 doAction: function (e) { 4641 e.stopPropagation(); 4642 e.preventDefault(); 4643 if (!this._date) this._date = UTCDate(1970, 0, 0, 0, 0, 0, 0); 4644 var action = $(e.currentTarget).data("action"); 4645 var rv = this.actions[action].apply(this, arguments); 4646 this.set(); 4647 this.fillTime(); 4648 this.notifyChange(); 4649 return rv; 4650 }, 4651 stopEvent: function (e) { 4652 e.stopPropagation(); 4653 e.preventDefault(); 4654 }, 4655 keydown: function (e) { 4656 var self = this, 4657 k = e.which, 4658 input = $(e.target); 4659 if (k == 8 || k == 46) { 4660 setTimeout(function () { 4661 self._resetMaskPos(input); 4662 }); 4663 } 4664 }, 4665 keypress: function (e) { 4666 var k = e.which; 4667 if (k == 8 || k == 46) { 4668 return; 4669 } 4670 var input = $(e.target); 4671 var c = String.fromCharCode(k); 4672 var val = input.val() || ""; 4673 val += c; 4674 var mask = this._mask[this._maskPos]; 4675 if (!mask) { 4676 return false;
4677 } 4678 if (mask.end != val.length) { 4679 return; 4680 } 4681 if (!mask.pattern.test(val.slice(mask.start))) { 4682 val = val.slice(0, val.length - 1); 4683 while ((mask = this._mask[this._maskPos]) && mask.character) { 4684 val += mask.character; 4685 this._maskPos++; 4686 } 4687 val += c; 4688 if (mask.end != val.length) { 4689 input.val(val); 4690 return false; 4691 } else { 4692 if (!mask.pattern.test(val.slice(mask.start))) { 4693 input.val(val.slice(0, mask.start)); 4694 return false; 4695 } else { 4696 input.val(val); 4697 this._maskPos++; 4698 return false; 4699 } 4700 } 4701 } else { 4702 this._maskPos++; 4703 } 4704 }, 4705 change: function (e) { 4706 var input = $(e.target); 4707 var val = input.val(); 4708 if (this._formatPattern.test(val)) { 4709 this.update(); 4710 this.setValue(this._date.getTime()); 4711 this.notifyChange(); 4712 this.set(); 4713 } else if (val && val.trim()) { 4714 this.setValue(this._date.getTime()); 4715 if (this._date) this.set(); 4716 else input.val(""); 4717 } else { 4718 if (this._date) { 4719 this.setValue(null); 4720 this.notifyChange(); 4721 this._unset = true; 4722 } 4723 } 4724 this._resetMaskPos(input); 4725 }, 4726 showMode: function (dir) { 4727 if (dir) { 4728 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir)); 4729 } 4730 this.widget 4731 .find(".datepicker > div") 4732 .hide() 4733 .filter(".datepicker-" + DPGlobal.modes[this.viewMode].clsName) 4734 .show(); 4735 }, 4736 destroy: function () { 4737 this._detachDatePickerEvents(); 4738 this._detachDatePickerGlobalEvents(); 4739 this.widget.remove(); 4740 this.$element.removeData("datetimepicker"); 4741 this.component.removeData("datetimepicker"); 4742 }, 4743 formatDate: function (d) { 4744 return this.format.replace(formatReplacer, function (match) { 4745 var methodName, 4746 property, 4747 rv, 4748 len = match.length; 4749 if (match === "ms") len = 1; 4750 property = dateFormatComponents[match].property; 4751 if (property === "Hours12") { 4752 rv = d.getUTCHours(); 4753 if (rv === 0) rv = 12; 4754 else if (rv !== 12) rv = rv % 12; 4755 } else if (property === "Period12") { 4756 if (d.getUTCHours() >= 12) return "PM"; 4757 else return "AM"; 4758 } else { 4759 methodName = "get" + property; 4760 rv = d[methodName](); 4761 } 4762 if (methodName === "getUTCMonth") rv = rv + 1; 4763 if (methodName === "getUTCYear") rv = rv + 1900 - 2e3; 4764 return padLeft(rv.toString(), len, "0"); 4765 }); 4766 }, 4767 parseDate: function (str) { 4768 var match, 4769 i, 4770 property, 4771 methodName, 4772 value, 4773 parsed = {}; 4774 if (!(match = this._formatPattern.exec(str))) return null; 4775 for (i = 1; i < match.length; i++) { 4776 property = this._propertiesByIndex[i]; 4777 if (!property) continue; 4778 value = match[i]; 4779 if (/^\d+$/.test(value)) value = parseInt(value, 10); 4780 parsed[property] = value; 4781 } 4782 return this._finishParsingDate(parsed); 4783 }, 4784 _resetMaskPos: function (input) { 4785 var val = input.val(); 4786 for (var i = 0; i < this._mask.length; i++) { 4787 if (this._mask[i].end > val.length) { 4788 this._maskPos = i; 4789 break; 4790 } else if (this._mask[i].end === val.length) { 4791 this._maskPos = i + 1; 4792 break; 4793 } 4794 } 4795 }, 4796 _finishParsingDate: function (parsed) { 4797 var year, month, date, hours, minutes, seconds, milliseconds; 4798 year = parsed.UTCFullYear; 4799 if (parsed.UTCYear) year = 2e3 + parsed.UTCYear; 4800 if (!year) year = 1970; 4801 if (parsed.UTCMonth) month = parsed.UTCMonth - 1; 4802 else month = 0; 4803 date = parsed.UTCDate || 1; 4804 hours = parsed.UTCHours || 0; 4805 minutes = parsed.UTCMinutes || 0; 4806 seconds = parsed.UTCSeconds || 0; 4807 milliseconds = parsed.UTCMilliseconds || 0; 4808 if (parsed.Hours12) { 4809 hours = parsed.Hours12; 4810 } 4811 if (parsed.Period12) { 4812 if (/pm/i.test(parsed.Period12)) { 4813 if (hours != 12) hours = (hours + 12) % 24; 4814 } else { 4815 hours = hours % 12; 4816 } 4817 } 4818 return UTCDate(year, month, date, hours, minutes, seconds, milliseconds); 4819 }, 4820 _compileFormat: function () { 4821 var match, 4822 component, 4823 components = [], 4824 mask = [], 4825 str = this.format, 4826 propertiesByIndex = {}, 4827 i = 0, 4828 pos = 0; 4829 while ((match = formatComponent.exec(str))) { 4830 component = match[0]; 4831 if (component in dateFormatComponents) { 4832 i++; 4833 propertiesByIndex[i] = dateFormatComponents[component].property; 4834 components.push("\\s*" + dateFormatComponents[component].getPattern(this) + "\\s*"); 4835 mask.push({ pattern: new RegExp(dateFormatComponents[component].getPattern(this)), property: dateFormatComponents[component].property, start: pos, end: (pos += component.length) }); 4836 } else { 4837 components.push(escapeRegExp(component)); 4838 mask.push({ pattern: new RegExp(escapeRegExp(component)), character: component, start: pos, end: ++pos }); 4839 } 4840 str = str.slice(component.length); 4841 } 4842 this._mask = mask; 4843 this._maskPos = 0; 4844 this._formatPattern = new RegExp("^\\s*" + components.join("") + "\\s*$"); 4845 this._propertiesByIndex = propertiesByIndex; 4846 }, 4847 _attachDatePickerEvents: function () { 4848 var self = this; 4849 this.widget.on("click", ".datepicker *", $.proxy(this.click, this)); 4850 this.widget.on("click", "[data-action]", $.proxy(this.doAction, this)); 4851 this.widget.on("mousedown", $.proxy(this.stopEvent, this)); 4852 if (this.pickDate && this.pickTime) { 4853 this.widget.on("click.togglePicker", ".accordion-toggle-sesadv", function (e) { 4854 e.stopPropagation(); 4855 var $this = $(this); 4856 var $parent = $this.closest("ul"); 4857 var expanded = $parent.find(".collapse.in"); 4858 var closed = $parent.find(".collapse:not(.in)"); 4859 if (expanded && expanded.length) {
4860 // var collapseData = expanded.data("collapse"); 4861 // if (collapseData && collapseData.transitioning) return; 4862 expanded.collapse("hide"); 4863 expanded.removeClass("in") 4864 closed.collapse("show"); 4865 closed.addClass("in"); 4866 $this.find("i").toggleClass(self.timeIcon + " " + self.dateIcon); 4867 self.$element.find(".add-on i").toggleClass(self.timeIcon + " " + self.dateIcon); 4868 if ($this.find("i").hasClass("icon-time")) { 4869 $this.find("i").parent().attr("title", "Select Time"); 4870 } else { 4871 $this.find("i").parent().attr("title", "Select Date"); 4872 } 4873 activitytooltip(); 4874 } 4875 }); 4876 } 4877 if (this.isInput) { 4878 this.$element.on({ focus: $.proxy(this.show, this), change: $.proxy(this.change, this) }); 4879 if (this.options.maskInput) { 4880 this.$element.on({ keydown: $.proxy(this.keydown, this), keypress: $.proxy(this.keypress, this) }); 4881 } 4882 } else { 4883 this.$element.on({ change: $.proxy(this.change, this) }, "input"); 4884 if (this.options.maskInput) { 4885 this.$element.on({ keydown: $.proxy(this.keydown, this), keypress: $.proxy(this.keypress, this) }, "input"); 4886 } 4887 if (this.component) { 4888 this.component.on("click", $.proxy(this.show, this)); 4889 } else { 4890 this.$element.on("click", $.proxy(this.show, this)); 4891 } 4892 } 4893 }, 4894 _attachDatePickerGlobalEvents: function () { 4895 $(window).on("resize.datetimepicker" + this.id, $.proxy(this.place, this)); 4896 if (!this.isInput) { 4897 $(document).on("mousedown.datetimepicker" + this.id, $.proxy(this.hide, this)); 4898 } 4899 }, 4900 _detachDatePickerEvents: function () { 4901 this.widget.off("click", ".datepicker *", this.click); 4902 this.widget.off("click", "[data-action]"); 4903 this.widget.off("mousedown", this.stopEvent); 4904 if (this.pickDate && this.pickTime) { 4905 this.widget.off("click.togglePicker"); 4906 } 4907 if (this.isInput) { 4908 this.$element.off({ focus: this.show, change: this.change }); 4909 if (this.options.maskInput) { 4910 this.$element.off({ keydown: this.keydown, keypress: this.keypress }); 4911 } 4912 } else { 4913 this.$element.off({ change: this.change }, "input"); 4914 if (this.options.maskInput) { 4915 this.$element.off({ keydown: this.keydown, keypress: this.keypress }, "input"); 4916 } 4917 if (this.component) { 4918 this.component.off("click", this.show); 4919 } else { 4920 this.$element.off("click", this.show); 4921 } 4922 } 4923 }, 4924 _detachDatePickerGlobalEvents: function () { 4925 $(window).off("resize.datetimepicker" + this.id); 4926 if (!this.isInput) { 4927 $(document).off("mousedown.datetimepicker" + this.id); 4928 } 4929 }, 4930 _isInFixed: function () { 4931 if (this.$element) { 4932 var parents = this.$element.parents(); 4933 var inFixed = false; 4934 for (var i = 0; i < parents.length; i++) { 4935 if ($(parents[i]).css("position") == "fixed") { 4936 inFixed = true; 4937 break; 4938 } 4939 } 4940 return inFixed; 4941 } else { 4942 return false; 4943 } 4944 }, 4945 }; 4946 $.fn.datetimepicker = function (option, val) { 4947 return this.each(function () { 4948 var $this = $(this), 4949 data = $this.data("datetimepicker"), 4950 options = typeof option === "object" && option; 4951 if (!data) {
4952 $this.data("datetimepicker", (data = new DateTimePicker(this, $.extend({}, $.fn.datetimepicker.defaults, options)))); 4953 } 4954 if (typeof option === "string") data[option](val); 4955 }); 4956 }; 4957 $.fn.datetimepicker.defaults = { maskInput: false, pickDate: true, pickTime: true, pick12HourFormat: false, pickSeconds: true, startDate: -Infinity, endDate: Infinity, collapse: true }; 4958 $.fn.datetimepicker.Constructor = DateTimePicker; 4959 var dpgId = 0; 4960 var dates = ($.fn.datetimepicker.dates = { 4961 en: { 4962 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], 4963 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], 4964 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"], 4965 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], 4966 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], 4967 }, 4968 }); 4969 var dateFormatComponents = { 4970 dd: { 4971 property: "UTCDate", 4972 getPattern: function () { 4973 return "(0?[1-9]|[1-2][0-9]|3[0-1])\\b"; 4974 }, 4975 }, 4976 MM: { 4977 property: "UTCMonth", 4978 getPattern: function () { 4979 return "(0?[1-9]|1[0-2])\\b"; 4980 }, 4981 }, 4982 yy: { 4983 property: "UTCYear", 4984 getPattern: function () { 4985 return "(\\d{2})\\b"; 4986 }, 4987 }, 4988 yyyy: { 4989 property: "UTCFullYear", 4990 getPattern: function () { 4991 return "(\\d{4})\\b"; 4992 }, 4993 }, 4994 hh: { 4995 property: "UTCHours", 4996 getPattern: function () { 4997 return "(0?[0-9]|1[0-9]|2[0-3])\\b"; 4998 }, 4999 }, 5000 mm: { 5001 property: "UTCMinutes", 5002 getPattern: function () { 5003 return "(0?[0-9]|[1-5][0-9])\\b"; 5004 }, 5005 }, 5006 ss: { 5007 property: "UTCSeconds", 5008 getPattern: function () { 5009 return "(0?[0-9]|[1-5][0-9])\\b"; 5010 }, 5011 }, 5012 ms: { 5013 property: "UTCMilliseconds", 5014 getPattern: function () { 5015 return "([0-9]{1,3})\\b"; 5016 }, 5017 }, 5018 HH: { 5019 property: "Hours12", 5020 getPattern: function () { 5021 return "(0?[1-9]|1[0-2])\\b"; 5022 }, 5023 }, 5024 PP: { 5025 property: "Period12", 5026 getPattern: function () { 5027 return "(AM|PM|am|pm|Am|aM|Pm|pM)\\b"; 5028 }, 5029 }, 5030 }; 5031 var keys = []; 5032 for (var k in dateFormatComponents) keys.push(k); 5033 keys[keys.length - 1] += "\\b"; 5034 keys.push("."); 5035 var formatComponent = new RegExp(keys.join("\\b|")); 5036 keys.pop(); 5037 var formatReplacer = new RegExp(keys.join("\\b|"), "g"); 5038 function escapeRegExp(str) { 5039 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 5040 } 5041 function padLeft(s, l, c) { 5042 if (l < s.length) return s; 5043 else return Array(l - s.length + 1).join(c || " ") + s; 5044 } 5045 function getTemplate(timeIcon, pickDate, pickTime, is12Hours, showSeconds, collapse) { 5046 if (pickDate && pickTime) { 5047 return ( 5048 '<div class="bootstrap-datetimepicker-widget dropdown-menu"><a class="fas fa-times activity_schedule_btn notclose" href="javascript:;" title="close"></a>' + 5049 "<ul>" + 5050 "<li" + 5051 (collapse ? ' class="collapse in"' : "") + 5052 ">" + 5053 '<div class="datepicker">' + 5054 DPGlobal.template + 5055 "</div>" + 5056 "</li>" + 5057 '<li class="picker-switch accordion-toggle-sesadv"><a class="activity_tooltip"><i class="' + 5058 timeIcon + 5059 '"></i></a></li>' + 5060 "<li" + 5061 (collapse ? ' class="collapse"' : "") + 5062 ">" + 5063 '<div class="timepicker">' + 5064 TPGlobal.getTemplate(is12Hours, showSeconds) + 5065 "</div>" + 5066 "</li>" + 5067 "</ul>" + 5068 "</div>" 5069 ); 5070 } else if (pickTime) { 5071 return '<div class="bootstrap-datetimepicker-widget dropdown-menu">' + '<div class="timepicker">' + TPGlobal.getTemplate(is12Hours, showSeconds) + "</div>" + "</div>"; 5072 } else { 5073 return '<div class="bootstrap-datetimepicker-widget dropdown-menu">' + '<div class="datepicker">' + DPGlobal.template + "</div>" + "</div>"; 5074 } 5075 } 5076 function UTCDate() { 5077 return new Date(Date.UTC.apply(Date, arguments)); 5078 } 5079 var DPGlobal = { 5080 modes: [ 5081 { clsName: "days", navFnc: "UTCMonth", navStep: 1 }, 5082 { clsName: "months", navFnc: "UTCFullYear", navStep: 1 }, 5083 { clsName: "years", navFnc: "UTCFullYear", navStep: 10 }, 5084 ], 5085 isLeapYear: function (year) { 5086 return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; 5087 }, 5088 getDaysInMonth: function (year, month) { 5089 return [31, DPGlobal.isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; 5090 }, 5091 headTemplate: "<thead>" + "<tr>" + '<th class="prev">‹</th>' + '<th colspan="5" class="switch"></th>' + '<th class="next">›</th>' + "</tr>" + "</thead>", 5092 contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>', 5093 }; 5094 DPGlobal.template = 5095 '<div class="datepicker-days">' + 5096 '<table class="table-condensed">' + 5097 DPGlobal.headTemplate + 5098 "<tbody></tbody>" + 5099 "</table>" + 5100 "</div>" + 5101 '<div class="datepicker-months">' + 5102 '<table class="table-condensed">' + 5103 DPGlobal.headTemplate + 5104 DPGlobal.contTemplate + 5105 "</table>" + 5106 "</div>" + 5107 '<div class="datepicker-years">' + 5108 '<table class="table-condensed">' + 5109 DPGlobal.headTemplate + 5110 DPGlobal.contTemplate + 5111 "</table>" + 5112 "</div>"; 5113 var TPGlobal = { 5114 hourTemplate: '<span data-action="showHours" data-time-component="hours" class="timepicker-hour"></span>', 5115 minuteTemplate: '<span data-action="showMinutes" data-time-component="minutes" class="timepicker-minute"></span>', 5116 secondTemplate: '<span data-action="showSeconds" data-time-component="seconds" class="timepicker-second"></span>', 5117 }; 5118 TPGlobal.getTemplate = function (is12Hours, showSeconds) { 5119 return ( 5120 '<div class="timepicker-picker">' + 5121 '<table class="table-condensed"' + 5122 (is12Hours ? ' data-hour-format="12"' : "") + 5123 ">" + 5124 "<tr>" + 5125 '<td><a href="#" class="btn" data-action="incrementHours"><i class="icon-chevron-up"></i></a></td>' + 5126 '<td class="separator"></td>' + 5127 '<td><a href="#" class="btn" data-action="incrementMinutes"><i class="icon-chevron-up"></i></a></td>' + 5128 (showSeconds ? '<td class="separator"></td>' + '<td><a href="#" class="btn" data-action="incrementSeconds"><i class="icon-chevron-up"></i></a></td>' : "") + 5129 (is12Hours ? '<td class="separator"></td>' : "") + 5130 "</tr>" + 5131 "<tr>" + 5132 "<td>" + 5133 TPGlobal.hourTemplate + 5134 "</td> " + 5135 '<td class="separator">:</td>' + 5136 "<td>" + 5137 TPGlobal.minuteTemplate + 5138 "</td> " + 5139 (showSeconds ? '<td class="separator">:</td>' + "<td>" + TPGlobal.secondTemplate + "</td>" : "") + 5140 (is12Hours ? '<td class="separator"></td>' + "<td>" + '<button type="button" class="btn btn-primary" data-action="togglePeriod"></button>' + "</td>" : "") + 5141 "</tr>" + 5142 "<tr>" + 5143 '<td><a href="#" class="btn" data-action="decrementHours"><i class="icon-chevron-down"></i></a></td>' + 5144 '<td class="separator"></td>' + 5145 '<td><a href="#" class="btn" data-action="decrementMinutes"><i class="icon-chevron-down"></i></a></td>' + 5146 (showSeconds ? '<td class="separator"></td>' + '<td><a href="#" class="btn" data-action="decrementSeconds"><i class="icon-chevron-down"></i></a></td>' : "") + 5147 (is12Hours ? '<td class="separator"></td>' : "") + 5148 "</tr>" + 5149 "</table>" + 5150 "</div>" + 5151 '<div class="timepicker-hours" data-action="selectHour">' + 5152 '<table class="table-condensed">' + 5153 "</table>" + 5154 "</div>" + 5155 '<div class="timepicker-minutes" data-action="selectMinute">' + 5156 '<table class="table-condensed">' + 5157 "</table>" + 5158 "</div>" + 5159 (showSeconds ? '<div class="timepicker-seconds" data-action="selectSecond">' + '<table class="table-condensed">' + "</table>" + "</div>" : "") 5160 ); 5161 }; 5162}
5162)(scriptJquery); 5163; 5164 5165 /** 5166 * TinyMCE version 6.7.0 (2023-08-30
vendor: 11,868 bytes, lines 5166-5168
5166) 5167 */ 5168!function(){"use strict";var e=function(e){if(null===e)return"null";if(void 0===e)return"undefined";var t=typeof e;return"object"===t&&(Array.prototype.isPrototypeOf(e)||e.constructor&&"Array"===e.constructor.name)?"array":"object"===t&&(String.prototype.isPrototypeOf(e)||e.constructor&&"String"===e.constructor.name)?"string":t},t=function(e){return{eq:e}},n=t((function(e,t){return e===t})),o=function(e){return t((function(t,n){if(t.length!==n.length)return!1;for(var o=t.length,r=0;r<o;r++)if(!e.eq(t[r],n[r]))return!1;return!0}))},r=function(e){return t((function(r,s){var a=Object.keys(r),i=Object.keys(s);if(!function(e,n){return function(e,n){return t((function(t,o){return e.eq(n(t),n(o))}))}(o(e),(function(e){return function(e,t){return Array.prototype.slice.call(e).sort(t)}(e,n)}))}(n).eq(a,i))return!1;for(var l=a.length,d=0;d<l;d++){var c=a[d];if(!e.eq(r[c],s[c]))return!1}return!0}))},s=t((function(t,n){if(t===n)return!0;var a=e(t);return a===e(n)&&(function(e){return-1!==["undefined","boolean","number","string","function","xml","null"].indexOf(e)}(a)?t===n:"array"===a?o(s).eq(t,n):"object"===a&&r(s).eq(t,n))}));const a=Object.getPrototypeOf,i=(e,t,n)=>{var o;return!!n(e,t.prototype)||(null===(o=e.constructor)||void 0===o?void 0:o.name)===t.name},l=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&i(e,String,((e,t)=>t.isPrototypeOf(e)))?"string":t})(t)===e,d=e=>t=>typeof t===e,c=e=>t=>e===t,u=(e,t)=>f(e)&&i(e,t,((e,t)=>a(e)===t)),m=l("string"),f=l("object"),g=e=>u(e,Object),p=l("array"),h=c(null),b=d("boolean"),v=c(void 0),y=e=>null==e,C=e=>!y(e),w=d("function"),x=d("number"),k=(e,t)=>{if(p(e)){for(let n=0,o=e.length;n<o;++n)if(!t(e[n]))return!1;return!0}return!1},E=()=>{},S=(e,t)=>(...n)=>e(t.apply(null,n)),_=(e,t)=>n=>e(t(n)),N=e=>()=>e,R=e=>e,A=(e,t)=>e===t;function O(e,...t){return(...n)=>{const o=t.concat(n);return e.apply(null,o)}}const T=e=>t=>!e(t),B=e=>()=>{throw new Error(e)},D=e=>e(),P=e=>{e()},L=N(!1),M=N(!0);class I{constructor(e,t){this.tag=e,this.value=t}static some(e){return new I(!0,e)}static none(){return I.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?I.some(e(this.value)):I.none()}bind(e){return this.tag?e(this.value):I.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:I.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return C(e)?I.some(e):I.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}I.singletonNone=new I(!1);const F=Array.prototype.slice,U=Array.prototype.indexOf,z=Array.prototype.push,j=(e,t)=>U.call(e,t),H=(e,t)=>j(e,t)>-1,$=(e,t)=>{for(let n=0,o=e.length;n<o;n++)if(t(e[n],n))return!0;return!1},V=(e,t)=>{const n=e.length,o=new Array(n);for(let r=0;r<n;r++){const n=e[r];o[r]=t(n,r)}return o},q=(e,t)=>{for(let n=0,o=e.length;n<o;n++)t(e[n],n)},W=(e,t)=>{for(let n=e.length-1;n>=0;n--)t(e[n],n)},K=(e,t)=>{const n=[],o=[];for(let r=0,s=e.length;r<s;r++){const s=e[r];(t(s,r)?n:o).push(s)}return{pass:n,fail:o}},G=(e,t)=>{const n=[];for(let o=0,r=e.length;o<r;o++){const r=e[o];t(r,o)&&n.push(r)}return n},Y=(e,t,n)=>(W(e,((e,o)=>{n=t(n,e,o)})),n),X=(e,t,n)=>(q(e,((e,o)=>{n=t(n,e,o)})),n),Q=(e,t,n)=>{for(let o=0,r=e.length;o<r;o++){const r=e[o];if(t(r,o))return I.some(r);if(n(r,o))break}return I.none()},J=(e,t)=>Q(e,t,L),Z=(e,t)=>{for(let n=0,o=e.length;n<o;n++)if(t(e[n],n))return I.some(n);return I.none()},ee=e=>{const t=[];for(let n=0,o=e.length;n<o;++n){if(!p(e[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+e);z.apply(t,e[n])}return t},te=(e,t)=>ee(V(e,t)),ne=(e,t)=>{for(let n=0,o=e.length;n<o;++n)if(!0!==t(e[n],n))return!1;return!0},oe=e=>{const t=F.call(e,0);return t.reverse(),t},re=(e,t)=>G(e,(e=>!H(t,e))),se=(e,t)=>{const n={};for(let o=0,r=e.length;o<r;o++){const r=e[o];n[String(r)]=t(r,o)}return n},ae=(e,t)=>{const n=F.call(e,0);return n.sort(t),n},ie=(e,t)=>t>=0&&t<e.length?I.some(e[t]):I.none(),le=e=>ie(e,0),de=e=>ie(e,e.length-1),ce=w(Array.from)?Array.from:e=>F.call(e),ue=(e,t)=>{for(let n=0;n<e.length;n++){const o=t(e[n],n);if(o.isSome())return o}return I.none()},me=Object.keys,fe=Object.hasOwnProperty,ge=(e,t)=>{const n=me(e);for(let o=0,r=n.length;o<r;o++){const r=n[o];t(e[r],r)}},pe=(e,t)=>he(e,((e,n)=>({k:n,v:t(e,n)}))),he=(e,t)=>{const n={};return ge(e,((e,o)=>{const r=t(e,o);n[r.k]=r.v})),n},be=e=>(t,n)=>{e[n]=t},ve=(e,t,n,o)=>{ge(e,((e,r)=>{(t(e,r)?n:o)(e,r)}))},ye=(e,t)=>{const n={};return ve(e,t,be(n),E),n},Ce=(e,t)=>{const n=[];return ge(e,((e,o)=>{n.push(t(e,o))})),n},we=e=>Ce(e,R),xe=(e,t)=>ke(e,t)?I.from(e[t]):I.none(),ke=(e,t)=>fe.call(e,t),Ee=(e,t)=>ke(e,t)&&void 0!==e[t]&&null!==e[t],Se=e=>{const t={};return q(e,(e=>{t[e]={}})),me(t)},_e=e=>void 0!==e.length,Ne=Array.isArray,Re=(e,t,n)=>{if(!e)return!1;if(n=n||e,_e(e)){for(let o=0,r=e.length;o<r;o++)if(!1===t.call(n,e[o],o,e))return!1}else for(const o in e)if(ke(e,o)&&!1===t.call(n,e[o],o,e))return!1;return!0},Ae=(e,t)=>{const n=[];return Re(e,((o,r)=>{n.push(t(o,r,e))})),n},Oe=(e,t)=>{const n=[];return Re(e,((o,r)=>{t&&!t(o,r,e)||n.push(o)})),n},Te=(e,t,n,o)=>{let r=v(n)?e[0]:n;for(let n=0;n<e.length;n++)r=t.call(o,r,e[n],n);return r},Be=(e,t,n)=>{for(let o=0,r=e.length;o<r;o++)if(t.call(n,e[o],o,e))return o;return-1},De=e=>e[e.length-1],Pe=e=>{let t,n=!1;return(...o)=>(n||(n=!0,t=e.apply(null,o)),t)},Le=()=>Me(0,0),Me=(e,t)=>({major:e,minor:t}),Ie={nu:Me,detect:(e,t)=>{const n=String(t).toLowerCase();return 0===e.length?Le():((e,t)=>{const n=((e,t)=>{for(let n=0;n<e.length;n++){const o=e[n];if(o.test(t))return o}})(e,t);if(!n)return{major:0,minor:0};const o=e=>Number(t.replace(n,"$"+e));return Me(o(1),o(2))})(e,n)},unknown:Le},Fe=(e,t)=>{const n=String(t).toLowerCase();return J(e,(e=>e.search(n)))},Ue=(e,t,n)=>""===t||e.length>=t.length&&e.substr(n,n+t.length)===t,ze=(e,t)=>He(e,t)?((e,t)=>e.substring(t))(e,t.length):e,je=(e,t,n=0,o)=>{const r=e.indexOf(t,n);return-1!==r&&(!!v(o)||r+t.length<=o)},He=(e,t)=>Ue(e,t,0),$e=(e,t)=>Ue(e,t,e.length-t.length),Ve=e=>t=>t.replace(e,""),qe=Ve(/^\s+|\s+$/g),We=Ve(/^\s+/g),Ke=Ve(/\s+$/g),Ge=e=>e.length>0,Ye=e=>!Ge(e),Xe=(e,t=10)=>{const n=parseInt(e,t);return isNaN(n)?I.none():I.some(n)},Qe=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,Je=e=>t=>je(t,e),Ze=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:e=>je(e,"edge/")&&je(e,"chrome")&&je(e,"safari")&&je(e,"applewebkit")},{name:"Chromium",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,Qe],search:e=>je(e,"chrome")&&!je(e,"chromeframe")},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:e=>je(e,"msie")||je(e,"trident")},{name:"Opera",versionRegexes:[Qe,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:Je("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:Je("firefox")},{name:"Safari",versionRegexes:[Qe,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:e=>(je(e,"safari")||je(e,"mobile/"))&&je(e,"applewebkit")}],et=[{name:"Windows",search:Je("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:e=>je(e,"iphone")||je(e,"ipad"),versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:Je("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"macOS",search:Je("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:Je("linux"),versionRegexes:[]},{name:"Solaris",search:Je("sunos"),versionRegexes:[]},{name:"FreeBSD",search:Je("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:Je("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],tt={browsers:N(Ze),oses:N(et)},nt="Edge",ot="Chromium",rt="Opera",st="Firefox",at="Safari",it=e=>{const t=e.current,n=e.version,o=e=>()=>t===e;return{current:t,version:n,isEdge:o(nt),isChromium:o(ot),isIE:o("IE"),isOpera:o(rt),isFirefox:o(st),isSafari:o(at)}},lt=()=>it({current:void 0,version:Ie.unknown()}),dt=it,ct=(N(nt),N(ot),N("IE"),N(rt),N(st),N(at),"Windows"),ut="Android",mt="Linux",ft="macOS",gt="Solaris",pt="FreeBSD",ht="ChromeOS",bt=e=>{const t=e.current,n=e.version,o=e=>()=>t===e;return{current:t,version:n,isWindows:o(ct),isiOS:o("iOS"),isAndroid:o(ut),isMacOS:o(ft),isLinux:o(mt),isSolaris:o(gt),isFreeBSD:o(pt),isChromeOS:o(ht)}},vt=()=>bt({current:void 0,version:Ie.unknown()}),yt=bt,Ct=(N(ct),N("iOS"),N(ut),N(mt),N(ft),N(gt),N(pt),N(ht),e=>window.matchMedia(e).matches);let wt=Pe((()=>((e,t,n)=>{const o=tt.browsers(),r=tt.oses(),s=t.bind((e=>((e,t)=>ue(t.brands,(t=>{const n=t.brand.toLowerCase();return J(e,(e=>{var t;return n===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())})).map((e=>({current:e.name,version:Ie.nu(parseInt(t.version,10),0)})))})))(o,e))).orThunk((()=>((e,t)=>Fe(e,t).map((e=>{const n=Ie.detect(e.versionRegexes,t);return{current:e.name,version:n}})))(o,e))).fold(lt,dt),a=((e,t)=>Fe(e,t).map((e=>{const n=Ie.detect(e.versionRegexes,t);return{current:e.name,version:n}})))(r,e).fold(vt,yt),i=((e,t,n,o)=>{const r=e.isiOS()&&!0===/ipad/i.test(n),s=e.isiOS()&&!r,a=e.isiOS()||e.isAndroid(),i=a||o("(pointer:coarse)"),l=r||!s&&a&&o("(min-device-width:768px)"),d=s||a&&!l,c=t.isSafari()&&e.isiOS()&&!1===/safari/i.test(n),u=!d&&!l&&!c;return{isiPad:N(r),isiPhone:N(s),isTablet:N(l),isPhone:N(d),isTouch:N(i),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:N(c),isDesktop:N(u)}})(a,s,e,n);return{browser:s,os:a,deviceType:i}})(navigator.userAgent,I.from(navigator.userAgentData),Ct)));const xt=()=>wt(),kt=navigator.userAgent,Et=xt(),St=Et.browser,_t=Et.os,Nt=Et.deviceType,Rt=-1!==kt.indexOf("Windows Phone"),At={transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",documentMode:St.isIE()?document.documentMode||7:10,cacheSuffix:null,container:null,canHaveCSP:!St.isIE(),windowsPhone:Rt,browser:{current:St.current,version:St.version,isChromium:St.isChromium,isEdge:St.isEdge,isFirefox:St.isFirefox,isIE:St.isIE,isOpera:St.isOpera,isSafari:St.isSafari},os:{current:_t.current,version:_t.version,isAndroid:_t.isAndroid,isChromeOS:_t.isChromeOS,isFreeBSD:_t.isFreeBSD,isiOS:_t.isiOS,isLinux:_t.isLinux,isMacOS:_t.isMacOS,isSolaris:_t.isSolaris,isWindows:_t.isWindows},deviceType:{isDesktop:Nt.isDesktop,isiPad:Nt.isiPad,isiPhone:Nt.isiPhone,isPhone:Nt.isPhone,isTablet:Nt.isTablet,isTouch:Nt.isTouch,isWebView:Nt.isWebView}},Ot=/^\s*|\s*$/g,Tt=e=>y(e)?"":(""+e).replace(Ot,""),Bt=function(e,t,n,o){o=o||this,e&&(n&&(e=e[n]),Re(e,((e,r)=>!1!==t.call(o,e,r,n)&&(Bt(e,t,n,o),!0))))},Dt={trim:Tt,isArray:Ne,is:(e,t)=>t?!("array"!==t||!Ne(e))||typeof e===t:void 0!==e,toArray:e=>{if(Ne(e))return e;{const t=[];for(let n=0,o=e.length;n<o;n++)t[n]=e[n];return t}},makeMap:(e,t,n={})=>{const o=m(e)?e.split(t||","):e||[];let r=o.length;for(;r--;)n[o[r]]={};return n},each:Re,map:Ae,grep:Oe,inArray:(e,t)=>{if(e)for(let n=0,o=e.length;n<o;n++)if(e[n]===t)return n;return-1},hasOwn:ke,extend:(e,...t)=>{for(let n=0;n<t.length;n++){const o=t[n];for(const t in o)if(ke(o,t)){const n=o[t];void 0!==n&&(e[t]=n)}}return e},walk:Bt,resolve:(e,t=window)=>{const n=e.split(".");for(let e=0,o=n.length;e<o&&(t=t[n[e]]);e++);return t},explode:(e,t)=>p(e)?e:""===e?[]:Ae(e.split(t||","),Tt),_addCacheSuffix:e=>{const t=At.cacheSuffix;return t&&(e+=(-1===e.indexOf("?")?"?":"&")+t),e}},Pt=(e,t,n=A)=>e.exists((e=>n(e,t))),Lt=(e,t,n
vendor: 780 bytes, line 5168
5168=A)=>Mt(e,t,n).getOr(e.isNone()&&t.isNone()),Mt=(e,t,n)=>e.isSome()&&t.isSome()?I.some(n(e.getOrDie(),t.getOrDie())):I.none(),It=(e,t)=>e?I.some(t):I.none(),Ft="undefined"!=typeof window?window:Function("return this;")(),Ut=(e,t)=>((e,t)=>{let n=null!=t?t:Ft;for(let t=0;t<e.length&&null!=n;++t)n=n[e[t]];return n})(e.split("."),t),zt=Object.getPrototypeOf,jt=e=>{const t=Ut("ownerDocument.defaultView",e);return f(e)&&((e=>((e,t)=>{const n=((e,t)=>Ut(e,t))(e,t);if(null==n)throw new Error(e+" not available on this browser");return n})("HTMLElement",e))(t).prototype.isPrototypeOf(e)||/^HTML\w*Element$/.test(zt(e).constructor.name))},Ht=e=>e.dom.nodeName.toLowerCase(),$t=e=>e.dom.nodeType,Vt=e=>t=>$t(t)===e,qt=e=>Wt(e)&&jt(e.dom),Wt=Vt(1),Kt=Vt(3),Gt=Vt(9),Yt=Vt(11),Xt=e=>t=>
vendor: 4,289 bytes, line 5168
5168Wt(t)&&Ht(t)===e,Qt=(e,t,n)=>{if(!(m(n)||b(n)||x(n)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",n,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,n+"")},Jt=(e,t,n)=>{Qt(e.dom,t,n)},Zt=(e,t)=>{const n=e.dom;ge(t,((e,t)=>{Qt(n,t,e)}))},en=(e,t)=>{const n=e.dom.getAttribute(t);return null===n?void 0:n},tn=(e,t)=>I.from(en(e,t)),nn=(e,t)=>{const n=e.dom;return!(!n||!n.hasAttribute)&&n.hasAttribute(t)},on=(e,t)=>{e.dom.removeAttribute(t)},rn=e=>X(e.dom.attributes,((e,t)=>(e[t.name]=t.value,e)),{}),sn=(e,t)=>{const n=en(e,t);return void 0===n||""===n?[]:n.split(" ")},an=e=>void 0!==e.dom.classList,ln=e=>sn(e,"class"),dn=(e,t)=>((e,t,n)=>{const o=sn(e,t).concat([n]);return Jt(e,t,o.join(" ")),!0})(e,"class",t),cn=(e,t)=>((e,t,n)=>{const o=G(sn(e,t),(e=>e!==n));return o.length>0?Jt(e,t,o.join(" ")):on(e,t),!1})(e,"class",t),un=(e,t)=>{an(e)?e.dom.classList.add(t):dn(e,t)},mn=e=>{0===(an(e)?e.dom.classList:ln(e)).length&&on(e,"class")},fn=(e,t)=>{an(e)?e.dom.classList.remove(t):cn(e,t),mn(e)},gn=(e,t)=>an(e)&&e.dom.classList.contains(t),pn=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},hn=(e,t)=>{const n=(t||document).createElement("div");if(n.innerHTML=e,!n.hasChildNodes()||n.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return pn(n.childNodes[0])},bn=(e,t)=>{const n=(t||document).createElement(e);return pn(n)},vn=(e,t)=>{const n=(t||document).createTextNode(e);return pn(n)},yn=pn,Cn=(e,t,n)=>I.from(e.dom.elementFromPoint(t,n)).map(pn),wn=(e,t)=>{const n=[],o=e=>(n.push(e),t(e));let r=t(e);do{r=r.bind(o)}while(r.isSome());return n},xn=(e,t)=>{const n=e.dom;if(1!==n.nodeType)return!1;{const e=n;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},kn=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,En=(e,t)=>e.dom===t.dom,Sn=(e,t)=>{const n=e.dom,o=t.dom;return n!==o&&n.contains(o)},_n=e=>yn(e.dom.ownerDocument),Nn=e=>Gt(e)?e:_n(e),Rn=e=>yn(Nn(e).dom.defaultView),An=e=>I.from(e.dom.parentNode).map(yn),On=e=>I.from(e.dom.parentElement).map(yn),Tn=(e,t)=>{const n=w(t)?t:L;let o=e.dom;const r=[];for(;null!==o.parentNode&&void 0!==o.parentNode;){const e=o.parentNode,t=yn(e);if(r.push(t),!0===n(t))break;o=e}return r},Bn=e=>I.from(e.dom.previousSibling).map(yn),Dn=e=>I.from(e.dom.nextSibling).map(yn),Pn=e=>oe(wn(e,Bn)),Ln=e=>wn(e,Dn),Mn=e=>V(e.dom.childNodes,yn),In=(e,t)=>{const n=e.dom.childNodes;return I.from(n[t]).map(yn)},Fn=e=>In(e,0),Un=e=>In(e,e.dom.childNodes.length-1),zn=e=>e.dom.childNodes.length,jn=e=>Yt(e)&&C(e.dom.host),Hn=w(Element.prototype.attachShadow)&&w(Node.prototype.getRootNode),$n=N(Hn),Vn=Hn?e=>yn(e.dom.getRootNode()):Nn,qn=e=>jn(e)?e:(e=>{const t=e.dom.head;if(null==t)throw new Error("Head is not available yet");return yn(t)})(Nn(e)),Wn=e=>yn(e.dom.host),Kn=e=>{if($n()&&C(e.target)){const t=yn(e.target);if(Wt(t)&&Gn(t)&&e.composed&&e.composedPath){const t=e.composedPath();if(t)return le(t)}}return I.from(e.target)},Gn=e=>C(e.dom.shadowRoot),Yn=e=>{const t=Kt(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const n=t.ownerDocument;return(e=>{const t=Vn(e);return jn(t)?I.some(t):I.none()})(yn(t)).fold((()=>n.body.contains(t)),_(Yn,Wn))};var Xn=(e,t,n,o,r)=>e(n,o)?I.some(n):w(r)&&r(n)?I.none():t(n,o,r);const Qn=(e,t,n)=>{let o=e.dom;const r=w(n)?n:L;for(;o.parentNode;){o=o.parentNode;const e=yn(o);if(t(e))return I.some(e);if(r(e))break}return I.none()},Jn=(e,t,n)=>Xn(((e,t)=>t(e)),Qn,e,t,n),Zn=(e,t,n)=>Qn(e,(e=>xn(e,t)),n),eo=(e,t)=>((e,t)=>{const n=void 0===t?document:t.dom;return kn(n)?I.none():I.from(n.querySelector(e)).map(yn)})(t,e),to=(e,t,n)=>Xn(((e,t)=>xn(e,t)),Zn,e,t,n),no=(e,t=!1)=>{return Yn(e)?e.dom.isContentEditable:(n=e,to(n,"[contenteditable]")).fold(N(t),(e=>"true"===oo(e)));var n},oo=e=>e.dom.contentEditable,ro=e=>void 0!==e.style&&w(e.style.getPropertyValue),so=(e,t,n)=>{if(!m(n))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",n,"::
5168Element ",e),new Error("CSS value must be a string: "+n);ro(e)&&e.style.setProperty(t,n)},ao=(e,t,n)=>{const o=e.dom;so(o,t,n)},io=(e,t)=>{const n=e.dom;ge(t,((e,t)=>{so(n,t,e)}))},lo=(e,t)=>{const n=e.dom,o=window.getComputedStyle(n).getPropertyValue(t);return""!==o||Yn(e)?o:co(n,t)},co=(e,t)=>ro(e)?e.style.getPropertyValue(t):"",uo=(e,t)=>{const n=e.dom,o=co(n,t);return I.from(o).filter((e=>e.length>0))},mo=e=>{const t={},n=e.dom;if(ro(n))for(let e=0;e<n.style.length;e++){const o=n.style.item(e);t[o]=n.style[o]}return t},fo=(e,t)=>{((e,t)=>{ro(e)&&e.style.removeProperty(t)})(e.dom,t),Pt(tn(e,"style").map(qe),"")&&on(e,"style")},go=(e,t)=>{An(e).each((n=>{n.dom.insertBefore(t.dom,e.dom)}))},po=(e,t)=>{Dn(e).fold((()=>{An(e).each((e=>{bo(e,t)}))}),(e=>{go(e,t)}))},ho=(e,t)=>{Fn(e).fold((()=>{bo(e,t)}),(n=>{e.dom.insertBefore(t.dom,n.dom)}))},bo=(e,t)=>{e.dom.appendChild(t.dom)},vo=(e,t)=>{go(e,t),bo(t,e)},yo=(e,t)=>{q(t,(t=>{bo(e,t)}))},Co=e=>{e.dom.textContent="",q(Mn(e),(e=>{wo(e)}))},wo=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},xo=e=>{const t=Mn(e);var n,o;t.length>0&&(n=e,q(o=t,((e,t)=>
vendor: 14,058 bytes, line 5168
5168{const r=0===t?n:o[t-1];po(r,e)}))),wo(e)},ko=e=>V(e,yn),Eo=e=>e.dom.innerHTML,So=(e,t)=>{const n=_n(e).dom,o=yn(n.createDocumentFragment()),r=((e,t)=>{const n=(t||document).createElement("div");return n.innerHTML=e,Mn(yn(n))})(t,n);yo(o,r),Co(e),bo(e,o)},_o=(e,t,n,o)=>((e,t,n,o,r)=>{const s=((e,t)=>n=>{e(n)&&t((e=>{const t=yn(Kn(e).getOr(e.target)),n=()=>e.stopPropagation(),o=()=>e.preventDefault(),r=S(o,n);return((e,t,n,o,r,s,a)=>({target:e,x:t,y:n,stop:o,prevent:r,kill:s,raw:a}))(t,e.clientX,e.clientY,n,o,r,e)})(n))})(n,o);return e.dom.addEventListener(t,s,false),{unbind:O(No,e,t,s,false)}})(e,t,n,o),No=(e,t,n,o)=>{e.dom.removeEventListener(t,n,o)},Ro=(e,t)=>({left:e,top:t,translate:(n,o)=>Ro(e+n,t+o)}),Ao=Ro,Oo=(e,t)=>void 0!==e?e:void 0!==t?t:0,To=e=>{const t=e.dom,n=t.ownerDocument.body;return n===t?Ao(n.offsetLeft,n.offsetTop):Yn(e)?(e=>{const t=e.getBoundingClientRect();return Ao(t.left,t.top)})(t):Ao(0,0)},Bo=e=>{const t=void 0!==e?e.dom:document,n=t.body.scrollLeft||t.documentElement.scrollLeft,o=t.body.scrollTop||t.documentElement.scrollTop;return Ao(n,o)},Do=(e,t,n)=>{const o=(void 0!==n?n.dom:document).defaultView;o&&o.scrollTo(e,t)},Po=(e,t)=>{xt().browser.isSafari()&&w(e.dom.scrollIntoViewIfNeeded)?e.dom.scrollIntoViewIfNeeded(!1):e.dom.scrollIntoView(t)},Lo=(e,t,n,o)=>({x:e,y:t,width:n,height:o,right:e+n,bottom:t+o}),Mo=e=>{const t=void 0===e?window:e,n=t.document,o=Bo(yn(n));return(e=>{const t=void 0===e?window:e;return xt().browser.isFirefox()?I.none():I.from(t.visualViewport)})(t).fold((()=>{const e=t.document.documentElement,n=e.clientWidth,r=e.clientHeight;return Lo(o.left,o.top,n,r)}),(e=>Lo(Math.max(e.pageLeft,o.left),Math.max(e.pageTop,o.top),e.width,e.height)))},Io=(e,t)=>{let n=[];return q(Mn(e),(e=>{t(e)&&(n=n.concat([e])),n=n.concat(Io(e,t))})),n},Fo=(e,t)=>((e,t)=>{const n=void 0===t?document:t.dom;return kn(n)?[]:V(n.querySelectorAll(e),yn)})(t,e),Uo=(e,t,n)=>Zn(e,t,n).isSome();class zo{constructor(e,t){this.node=e,this.rootNode=t,this.current=this.current.bind(this),this.next=this.next.bind(this),this.prev=this.prev.bind(this),this.prev2=this.prev2.bind(this)}current(){return this.node}next(e){return this.node=this.findSibling(this.node,"firstChild","nextSibling",e),this.node}prev(e){return this.node=this.findSibling(this.node,"lastChild","previousSibling",e),this.node}prev2(e){return this.node=this.findPreviousNode(this.node,e),this.node}findSibling(e,t,n,o){if(e){if(!o&&e[t])return e[t];if(e!==this.rootNode){let t=e[n];if(t)return t;for(let o=e.parentNode;o&&o!==this.rootNode;o=o.parentNode)if(t=o[n],t)return t}}}findPreviousNode(e,t){if(e){const n=e.previousSibling;if(this.rootNode&&n===this.rootNode)return;if(n){if(!t)for(let e=n.lastChild;e;e=e.lastChild)if(!e.lastChild)return e;return n}const o=e.parentNode;if(o&&o!==this.rootNode)return o}}}const jo=e=>t=>!!t&&t.nodeType===e,Ho=e=>!!e&&!Object.getPrototypeOf(e),$o=jo(1),Vo=e=>{const t=e.toLowerCase();return e=>C(e)&&e.nodeName.toLowerCase()===t},qo=e=>{const t=e.map((e=>e.toLowerCase()));return e=>{if(e&&e.nodeName){const n=e.nodeName.toLowerCase();return H(t,n)}return!1}},Wo=(e,t)=>{const n=t.toLowerCase().split(" ");return t=>{if($o(t)){const o=t.ownerDocument.defaultView;if(o)for(let r=0;r<n.length;r++){const s=o.getComputedStyle(t,null);if((s?s.getPropertyValue(e):null)===n[r])return!0}}return!1}},Ko=e=>t=>$o(t)&&t.hasAttribute(e),Go=e=>$o(e)&&e.hasAttribute("data-mce-bogus"),Yo=e=>$o(e)&&"TABLE"===e.tagName,Xo=e=>t=>{if($o(t)){if(t.contentEditable===e)return!0;if(t.getAttribute("data-mce-contenteditable")===e)return!0}return!1},Qo=qo(["textarea","input"]),Jo=jo(3),Zo=jo(4),er=jo(7),tr=jo(8),nr=jo(9),or=jo(11),rr=Vo("br"),sr=Vo("img"),ar=Xo("true"),ir=Xo("false"),lr=qo(["td","th"]),dr=qo(["td","th","caption"]),cr=qo(["video","audio","object","embed"]),ur=Vo("li"),mr=Vo("details"),fr=Vo("summary"),gr="\ufeff",pr="\xa0",hr=e=>e===gr,br=((e,t)=>{const n=t=>e(t)?I.from(t.dom.nodeValue):I.none();return{get:t=>{if(!e(t))throw new Error("Can only get text value of a text node");return n(t).getOr("")},getOption:n,set:(t,n)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=n}}})(Kt),vr=e=>br.get(e),yr=e=>br.getOption(e),Cr=["pre"].concat(["h1","h2","h3","h4","h5","h6"]),wr=e=>{let t;return n=>(t=t||se(e,M),ke(t,Ht(n)))},xr=wr(["article","aside","details","div","dt","figcaption","footer","form","fieldset","header","hgroup","html","main","nav","section","summary","body","p","dl","multicol","dd","figure","address","center","blockquote","h1","h2","h3","h4","h5","h6","listing","xmp","pre","plaintext","menu","dir","ul","ol","li","hr","table","tbody","thead","tfoot","th","tr","td","caption"]),kr=e=>Wt(e)&&!xr(e),Er=e=>Wt(e)&&"br"===Ht(e),Sr=wr(["h1","h2","h3","h4","h5","h6","p","div","address","pre","form","blockquote","center","dir","fieldset","header","footer","article","section","hgroup","aside","nav","figure"]),_r=wr(["ul","ol","dl"]),Nr=wr(["li","dd","dt"]),Rr=wr(["thead","tbody","tfoot"]),Ar=wr(["td","th"]),Or=wr(["pre","script","textarea","style"]),Tr=wr(Cr),Br=e=>Tr(e)||kr(e),Dr=()=>{const e=bn("br");return Jt(e,"data-mce-bogus","1"),e},Pr=e=>{Co(e),bo(e,Dr())},Lr=e=>{Un(e).each((t=>{Bn(t).each((n=>{xr(e)&&Er(t)&&xr(n)&&wo(t)}))}))},Mr=gr,Ir=hr,Fr=e=>e.replace(/\uFEFF/g,""),Ur=$o,zr=Jo,jr=e=>(zr(e)&&(e=e.parentNode),Ur(e)&&e.hasAttribute("data-mce-caret")),Hr=e=>zr(e)&&Ir(e.data),$r=e=>jr(e)||Hr(e),Vr=e=>e.firstChild!==e.lastChild||!rr(e.firstChild),qr=e=>{const t=e.container();return!!Jo(t)&&(t.data.charAt(e.offset())===Mr||e.isAtStart()&&Hr(t.previousSibling))},Wr=e=>{const t=e.container();return!!Jo(t)&&(t.data.charAt(e.offset()-1)===Mr||e.isAtEnd()&&Hr(t.nextSibling))},Kr=e=>zr(e)&&e.data[0]===Mr,Gr=e=>zr(e)&&e.data[e.data.length-1]===Mr,Yr=e=>e&&e.hasAttribute("data-mce-caret")?((e=>{var t;const n=e.getElementsByTagName("br"),o=n[n.length-1];Go(o)&&(null===(t=o.parentNode)||void 0===t||t.removeChild(o))})(e),e.removeAttribute("data-mce-caret"),e.removeAttribute("data-mce-bogus"),e.removeAttribute("style"),e.removeAttribute("data-mce-style"),e.removeAttribute("_moz_abspos"),e):null,Xr=e=>jr(e.startContainer),Qr=ar,Jr=ir,Zr=rr,es=Jo,ts=qo(["script","style","textarea"]),ns=qo(["img","input","textarea","hr","iframe","video","audio","object","embed"]),os=qo(["table"]),rs=$r,ss=e=>!rs(e)&&(es(e)?!ts(e.parentNode):ns(e)||Zr(e)||os(e)||as(e)),as=e=>!(e=>$o(e)&&"true"===e.getAttribute("unselectable"))(e)&&Jr(e),is=(e,t)=>ss(e)&&((e,t)=>{for(let n=e.parentNode;n&&n!==t;n=n.parentNode){if(as(n))return!1;if(Qr(n))return!0}return!0})(e,t),ls=/^[ \t\r\n]*$/,ds=e=>ls.test(e),cs=e=>{for(const t of e)if(!hr(t))return!1;return!0},us=e=>"\n"===e||"\r"===e,ms=(e,t=4,n=!0,o=!0)=>{const r=((e,t)=>t<=0?"":new Array(t+1).join(" "))(0,t),s=e.replace(/\t/g,r),a=X(s,((e,t)=>(e=>-1!==" \f\t\v".indexOf(e))(t)||t===pr?e.pcIsSpace||""===e.str&&n||e.str.length===s.length-1&&o||((e,t)=>t<e.length&&t>=0&&us(e[t]))(s,e.str.length+1)?{pcIsSpace:!1,str:e.str+pr}:{pcIsSpace:!0,str:e.str+" "}:{pcIsSpace:us(t),str:e.str+t}),{pcIsSpace:!1,str:""});return a.str},fs=(e,t)=>ss(e)&&!((e,t)=>Jo(e)&&ds(e.data)&&!((e,t)=>{const n=yn(t),o=yn(e);return Uo(o,"pre,code",O(En,n))})(e,t))(e,t)||(e=>$o(e)&&"A"===e.nodeName&&!e.hasAttribute("href")&&(e.hasAttribute("name")||e.hasAttribute("id")))(e)||gs(e),gs=Ko("data-mce-bookmark"),ps=Ko("data-mce-bogus"),hs=("data-mce-bogus","all",e=>$o(e)&&"all"===e.getAttribute("data-mce-bogus"));const bs=(e,t=!0)=>((e,t)=>{let n=0;if(fs(e,e))return!1;{let o=e.firstChild;if(!o)return!0;const r=new zo(o,e);do{if(t){if(hs(o)){o=r.next(!0);continue}if(ps(o)){o=r.next();continue}}if(rr(o))n++,o=r.next();else{if(fs(o,e))return!1;o=r.next()}}while(o);return n<=1}})(e.dom,t),vs="data-mce-block",ys=e=>(e=>G(me(e),(e=>!/[A-Z]/.test(e))))(e).join(","),Cs=(e,t)=>C(t.querySelector(e))?(t.setAttribute(vs,"true"),"inline-boundary"===t.getAttribute("data-mce-selected")&&t.removeAttribute("data-mce-selected"),!0):(t.removeAttribute(vs),!1),ws=(e,t)=>{const n=ys(e.getTransparentElements()),o=ys(e.getBlockElements());return G(t.querySelectorAll(n),(e=>Cs(o,e)))},xs=(e,t)=>{var n;const o=t?"lastChild":"firstChild";for(let t=e[o];t;t=t[o])if(bs(yn(t)))return void(null===(n=t.parentNode)||void 0===n||n.removeChild(t))},ks=(e,t,n)=>{const o=e.getBlockElements(),r=yn(t),s=e=>Ht(e)in o,a=e=>En(e,r);q(ko(n),(t=>{Qn(t,s,a).each((n=>{const o=((t,o)=>G(Mn(t),(t=>s(t)&&!e.isValidChild(Ht(n),Ht(t)))))(t);if(o.length>0){const t=On(n);q(o,(e=>{Qn(e,s,a).each((t=>{((e,t)=>{const n=document.createRange(),o=e.parentNode;if(o){n.setStartBefore(e),n.setEndBefore(t);const r=n.extractContents();xs(r,!0),n.setStartAfter(t),n.setEndAfter(e);const s=n.extractContents();xs(s,!1),bs(yn(r))||o.insertBefore(r,e),bs(yn(t))||o.insertBefore(t,e),bs(yn(s))||o.insertBefore(s,e),o.removeChild(e)}})(t.dom,e.dom)}))})),t.each((t=>ws(e,t.dom)))}}))}))},Es=(e,t)=>{const n=ws(e,t);ks(e,t,n),((e,t,n)=>{q([...n,...As(e,t)?[t]:[]],(t=>q(Fo(yn(t),t.nodeName.toLowerCase()),(t=>{Os(e,t.dom)&&xo(t)}))))})(e,t,n)},Ss=(e,t)=>{if(Rs(e,t)){const n=ys(e.getBlockElements());Cs(n,t)}},_s=e=>e.hasAttribute(vs),Ns=(e,t)=>ke(e.getTransparentElements(),t),Rs=(e,t)=>$o(t)&&Ns(e,t.nodeName),As=(e,t)=>Rs(e,t)&&_s(t),Os=(e,t)=>Rs(e,t)&&!_s(t),Ts=(e,t)=>1===t.type&&Ns(e,t.name)&&m(t.attr(vs)),Bs=xt().browser,Ds=e=>J(e,Wt),Ps=(e,t)=>e.children&&H(e.children,t),Ls=(e,t={})=>{let n=0;const o={},r=yn(e),s=Nn(r),a=e=>new Promise(((a,i)=>{let l;const d=Dt._addCacheSuffix(e),c=(e=>xe(o,e).getOrThunk((()=>({id:"mce-u"+n++,passed:[],failed:[],count:0}))))(d);o[d]=c,c.count++;const u=(e,t)=>{q(e,P),c.status=t,c.passed=[],c.failed=[],l&&(l.onload=null,l.onerror=null,l=null)},m=()=>u(c.passed,2),f=()=>u(c.failed,3);if(a&&c.passed.push(a),i&&c.failed.push(i),1===c.status)return;if(2===c.status)return void m();if(3===c.status)return void f();c.status=1;const g=bn("link",s.dom);var p;Zt(g,{rel:"stylesheet",type:"text/css",id:c.id}),t.contentCssCors&&Jt(g,"crossOrigin","anonymous"),t.referrerPolicy&&Jt(g,"referrerpolicy",t.referrerPolicy),l=g.dom,l.onload=m,l.onerror=f,p=g,bo(qn(r),p),Jt(g,"href",d)})),i=e=>{const t=Dt._addCacheSuffix(e);xe(o,t).each((e=>{0==--e.count&&(delete o[t],(e=>{const t=qn(r);eo(t,"#"+e).each(wo)})(e.id))}))};return{load:a,loadAll:e=>Promise.allSettled(V(e,(e=>a(e).then(N(e))))).then((e=>{const t=K(e,(e=>"fulfilled"===e.status));return t.fail.length>0?Promise.reject(V(t.fail,(e=>e.reason))):V(t.pass,(e=>e.value))})),unload:i,unloadAll:e=>{q(e,(e=>{i(e)}))},_setReferrerPolicy:e=>{t.referrerPolicy=e},_setContentCssCors:e=>{t.contentCssCors=e}}},Ms=(()=>{const e=new WeakMap;return{forElement:(t,n)=>{const o=Vn(t).dom;return I.from(e.get(o)).getOrThunk((()=>{const t=Ls(o,n);return e.set(o,t),t}))}}})(),Is=(e,t)=>C(e)&&(fs(e,t)||kr(yn(e))),Fs=e=>(e=>"span"===e.nodeName.toLowerCase())(e)&&"bookmark"===e.getAttribute("data-mce-type"),Us=(e,t,n)=>{var o;const r=n||t;if($o(t)&&Fs(t))return t;const s=t.childNodes;for(let t=s.length-1;t>=0;t--)Us(e,s[t],r);if($o(t)){const e=t.childNodes;1===e.length&&Fs(e[0])&&(null===(o=t.parentNode)||void 0===o||o.insertBefore(e[0],t))}return(e=>or(e)||nr(e))(t)||fs(t,r)||(e=>!!$o(e)&&e.childNodes.length>0)(t)||((e,t)=>Jo(e)&&e.data.length>0&&((e,t)=>{const n=new zo(e,t).prev(!1),o=new zo(e,t).next(!1),r=v(n)||Is(n,t),s=v(o)||Is(o,t);return r&&s})(e,t))(t,r)||e.remove(t),t},zs=Dt.makeMap,js=/[&<>\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Hs=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,$s=/[<>&\"\']/g,Vs=/&#([a-z0-9]+);?|&([a-z0-9]+);/gi,qs={128:"\u20ac",130:"\u201a",131:"\u0192",132:"\u201e",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02c6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017d",145:"\u2018",146:"\u2019",147:"\u201c",148:"\u201d",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02dc",153:"\u2122",154:"\u0161",155:"\u203a",156:"\u0153",158:"\u017e",159:"\u0178"},Ws={'"':""","'":"'","<":"<",">":">","&":"&","`":"`"},Ks={"<":"<",">":">","&":"&",""":'"',"'":"'"},Gs=(e,t)=>{const n={};if(e){const o=e.split(",");t=t||10;for(let e=0;e<o.length;e+=2){const r=String.fromCharCode(parseInt(o[e],t));if(!Ws[r]){const t="&"+o[e+1]+";";n[r]=t,n[t]=r}}return n}},Ys=Gs("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8
5168k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32),Xs=(e,t)=>e.replace(t?js:Hs,(e=>Ws[e]||e)),Qs=(e,t)=>e.replace(t?js:Hs,(e=>e.length>1?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":Ws[e]||"&#"+e.charCodeAt(0)+";")),Js=(e,t,n)=>{const o=n||Ys;return e.replace(t?js:Hs,(e=>Ws[e]||o[e]||e))},Zs={encodeRaw:Xs,encodeAllRaw:e=>(""+e).replace($s,(e=>Ws[e]||e)),encodeNumeric:Qs,encodeNamed:Js,getEncodeFunc:(e,t)=>{const n=Gs(t)||Ys,o=zs(e.replace(/\+/g,","));return o.named&&o.numeric?(e,t)=>e.replace(t?js:Hs,(e=>void 0!==Ws[e]?Ws[e]:void 0!==n[e]?n[e]:e.length>1?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":"&#"+e.charCodeAt(0)+";")):o.named?t?(e,t)=>Js(e,t,n):Js:o.numeric?Qs:Xs},decode:e=>e.replace(Vs,((e,t)=>t?(t="x"===t.charAt(0).toLowerCase()?parseInt(t.substr(1),16):parseInt(t,10))>65535?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):qs[t]||String.fromCharCode(t):Ks[e]||Ys[e]||(e=>{const t=bn("div").dom;return t.innerHTML=e,t.textContent||t.innerText||e})(e)))},ea=(e,t)=>(e=Dt.trim(e))?e.split(t||" "):[],ta=e=>new RegExp("^"+e.replace(/([?+*])/g,".$1")+"$"),na={},oa=Dt.makeMap,ra=Dt.each,sa=Dt.extend,aa=Dt.explode,ia=(e,t={})=>{const n=oa(e," ",oa(e.toUpperCase()," "));return sa(n,t)},la=e=>ia("td th li dt dd figcaption caption details summary",e.getTextBlockElements()),da=(e,t)=>{if(e){const n={};return m(e)&&(e={"*":e}),ra(e,((e,o)=>{n[o]=n[o.toUpperCase()]="map"===t?oa(e,/[, ]/):aa(e,/[, ]/)})),n}},ca=(e={})=>{var t;const n={},o={};let r=[];const s={},a={},i=(t,n,o)=>{const r=e[t];if(r)return oa(r,/[, ]/,oa(r.toUpperCase(),/[, ]/));{let e=na[t];return e||(e=ia(n,o),na[t]=e),e}},l=null!==(t=e.schema)&&void 0!==t?t:"html5",d=(e=>{const{globalAttributes:t,phrasingContent:n,flowContent:o}=(e=>{let t,n,o,r;return t="id accesskey class dir lang style tabindex title role",n="address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul",o="a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd label map noscript object q s samp script select small span strong sub sup textarea u var #text #comment","html4"!==e&&(t+=" contenteditable contextmenu draggable dropzone hidden spellcheck translate",n+=" article aside details dialog figure main header footer hgroup section nav a ins del canvas map",o+=" audio canvas command datalist mark meter output picture progress time wbr video ruby bdi keygen"),"html5-strict"!==e&&(t+=" xml:lang",o=[o,"acronym applet basefont big font strike tt"].join(" "),n=[n,"center dir isindex noframes"].join(" "),r=[n,o].join(" ")),r=r||[n,o].join(" "),{globalAttributes:t,blockContent:n,phrasingContent:o,flowContent:r}})(e),r={},s=(e,n="",o="")=>{const s=ea(o),a=ea(e);let i=a.length;for(;i--;){const e=ea([t,n].join(" "));r[a[i]]={attributes:se(e,N({})),attributesOrder:e,children:se(s,N({}))}}},a=(e,t)=>{const n=ea(e),o=ea(t);let s=n.length;for(;s--;){const e=r[n[s]];for(let t=0,n=o.length;t<n;t++)e.attributes[o[t]]={},e.attributesOrder.push(o[t])}};return"html5-strict"!==e&&(q(ea("acronym applet basefont big font strike tt"),(e=>{s(e,"",n)})),q(ea("center dir isindex noframes"),(e=>{s(e,"",o)}))),s("html","manifest","head body"),s("head","","base command link meta noscript script style title"),s("title hr noscript br"),s("base","href target"),s("link","href rel media hreflang type sizes hreflang"),s("meta","name http-equiv content charset"),s("style","media type scoped"),s("script","src async defer type charset"),s("body","onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload onmessage onoffline ononline onpagehide onpageshow onpopstate onresize onscroll onstorage onunload",o),s("dd div","",o),s("address dt caption","","html4"===e?n:o),s("h1 h2 h3 h4 h5 h6 pre p abbr co
5168de var samp kbd sub sup i b u bdo span legend em strong small s cite dfn","",n),s("blockquote","cite",o),s("ol","reversed start type","li"),s("ul","","li"),s("li","value",o),s("dl","","dt dd"),s("a","href target rel media hreflang type","html4"===e?n:o),s("q","cite",n),s("ins del","cite datetime",o),s("img","src sizes srcset alt usemap ismap width height"),s("iframe","src name width height",o),s("embed","src type width height"),s("object","data type typemustmatch name usemap form width height",[o,"param"].join(" ")),s("param","name value"),s("map","name",[o,"area"].join(" ")),s("area","alt coords shape href target rel media hreflang type"),s("table","border","caption colgroup thead tfoot tbody tr"+("html4"===e?" col":"")),s("colgroup","span","col"),s("col","span"),s("tbody thead tfoot","","tr"),s("tr","","td th"),s("td","colspan rowspan headers",o),s("th","colspan rowspan headers scope abbr",o),s("form","accept-charset action autocomplete enctype method name novalidate target",o),s("fieldset","disabled form name",[o,"legend"].join(" ")),s("label","form for",n),s("input","accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate formtarget height list max maxlength min multiple name pattern readonly required size src step type value width"),s("button","disabled form formaction formenctype formmethod formnovalidate formtarget name type value","html4"===e?o:n),s("select","disabled form multiple name required size","option optgroup"),s("optgroup","disabled label","option"),s("option","disabled label selected value"),s("textarea","cols dirname disabled form maxlength name readonly required rows wrap"),s("menu","type label",[o,"li"].join(" ")),s("noscript","",o),"html4"!==e&&(s("wbr"),s("ruby","",[n,"rt rp"].join(" ")),s("figcaption","",o),s("mark rt rp summary bdi","",n),s("canvas","width height",o),s("video","src crossorigin poster preload autoplay mediagroup loop muted controls width height buffered",[o,"track source"].join(" ")),s("audio","src crossorigin preload autoplay mediagroup loop muted controls buffered volume",[o,"track source"].join(" ")),s("picture","","img source"),s("source","src srcset type media sizes"),s("track","kind src srclang label default"),s("datalist","",[n,"option"].join(" ")),s("article section nav aside main header footer","",o),s("hgroup","","h1 h2 h3 h4 h5 h6"),s("figure","",[o,"figcaption"].join(" ")),s("time","datetime",n),s("dialog","open",o),s("command","type label icon disabled checked radiogroup command"),s("output","for form name",n),s("progress","value max",n),s("meter","value min max low high optimum",n),s("details","open",[o,"summary"].join(" ")),s("keygen","autofocus challenge disabled form keytype name")),"html5-strict"!==e&&(a("script","language xml:space"),a("style","xml:space"),a("object","declare classid code codebase codetype archive standby align border hspace vspace"),a("embed","align name hspace vspace"),a("param","valuetype type"),a("a","charset name rev shape coords"),a("br","clear"),a("applet","codebase archive code object alt name width height align hspace vspace"),a("img","name longdesc align border hspace vspace"),a("iframe","longdesc frameborder marginwidth marginheight scrolling align"),a("font basefont","size color face"),a("input","usemap align"),a("select"),a("textarea"),a("h1 h2 h3 h4 h5 h6 div p legend caption","align"),a("ul","type compact"),a("li","type"),a("ol dl menu dir","compact"),a("pre","width xml:space"),a("hr","align noshade size width"),a("isindex","prompt"),a("table","summary width frame rules cellspacing cellpadding align bgcolor"),a("col","width align char charoff valign"),a("colgroup","width align char charoff valign"),a("thead","align char charoff valign"),a("tr","align char charoff valign bgcolor"),a("th","axis align char charoff valign nowrap bgcolor width height"),a("form","accept"),a("td","abbr axis scope align char charoff valign nowrap bgcolor width height"),a("tfoot","align char charoff valign"),a("tbody","align char charoff valign"),a("area","nohref"),a("body","background bgcolor text link vlink alink")),"html4"!==e&&(a("input button select textarea","autofocus"),a("input textarea","placeholder"),a("a","download"),a("link script img","crossorigin"),a("img","loading"),a("iframe","sandbox seamless allow allowfullscreen loading")),"html4"!==e&&q([r.video,r.audio],(e=>{delete e.children.audio,delete e.children.video})),q(ea("a form meter progress dfn"),(e=>{r[e]&&delete r[e].children[e]})),delete r.caption.children.table,delete r.script,r})(l);!1===e.verify_html&&(e.valid_elements="*[*]");const c=da(e.valid_styles),u=da(e.invalid_styles,"map"),m=da(e.valid_classes,"map"),f=i("whitespace_elements","pre script noscript style textarea video audio iframe object c
5168ode"),g=i("self_closing_elements","colgroup dd dt li option p td tfoot th thead tr"),p=i("void_elements","area base basefont br col frame hr img input isindex link meta param embed source wbr track"),h=i("boolean_attributes","checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls allowfullscreen"),b="td th iframe video audio object script code",v=i("non_empty_elements",b+" pre",p),y=i("move_caret_before_on_enter_elements",b+" table",p),C=i("text_block_elements","h1 h2 h3 h4 h5 h6 p div address pre form blockquote center dir fieldset header footer article section hgroup aside main nav figure"),w=i("block_elements","hr table tbody thead tfoot th tr td li ol ul caption dl dt dd noscript menu isindex option datalist select optgroup figcaption details summary",C),x=i("text_inline_elements","span strong b em i font s strike u var cite dfn code mark q sup sub samp"),k=i("transparent_elements","a ins del canvas map");ra("script noscript iframe noframes noembed title style textarea xmp plaintext".split(" "),(e=>{a[e]=new RegExp("</"+e+"[^>]*>","gi")}));const E=e=>{const t=I.from(n["@"]),o=/[*?+]/;q(((e,t)=>{const n=/^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)])?$/;return te(ea(t,","),(t=>{const o=n.exec(t);if(o){const t=o[1],n=o[2],r=o[3],s=o[4],a=o[5],i={attributes:{},attributesOrder:[]};if(e.each((e=>((e,t)=>{ge(e.attributes,((e,n)=>{t.attributes[n]=e})),t.attributesOrder.push(...e.attributesOrder)})(e,i))),"#"===t?i.paddEmpty=!0:"-"===t&&(i.removeEmpty=!0),"!"===s&&(i.removeEmptyAttrs=!0),a&&((e,t)=>{const n=/^([!\-])?(\w+[\\:]:\w+|[^=~<]+)?(?:([=~<])(.*))?$/,o=/[*?+]/,{attributes:r,attributesOrder:s}=t;q(ea(e,"|"),(e=>{const a=n.exec(e);if(a){const e={},n=a[1],i=a[2].replace(/[\\:]:/g,":"),l=a[3],d=a[4];if("!"===n&&(t.attributesRequired=t.attributesRequired||[],t.attributesRequired.push(i),e.required=!0),"-"===n)return delete r[i],void s.splice(Dt.inArray(s,i),1);if(l&&("="===l?(t.attributesDefault=t.attributesDefault||[],t.attributesDefault.push({name:i,value:d}),e.defaultValue=d):"~"===l?(t.attributesForced=t.attributesForced||[],t.attributesForced.push({name:i,value:d}),e.forcedValue=d):"<"===l&&(e.validValues=Dt.makeMap(d,"?"))),o.test(i)){const n=e;t.attributePatterns=t.attributePatterns||[],n.pattern=ta(i),t.attributePatterns.push(n)}else r[i]||s.push(i),r[i]=e}}))})(a,i),r&&(i.outputName=n),"@"===n){if(!e.isNone())return[];e=I.some(i)}return[r?{name:n,element:i,aliasName:r}:{name:n,element:i}]}return[]}))})(t,null!=e?e:""),(({name:e,element:t,aliasName:s})=>{if(s&&(n[s]=t),o.test(e)){const n=t;n.pattern=ta(e),r.push(n)}else n[e]=t}))},S=e=>{r=[],q(me(n),(e=>{delete n[e]})),E(e)},_=e=>{delete na.text_block_elements,delete na.block_elements,q((e=>{const t=/^(~)?(.+)$/;return te(ea(e,","),(e=>{const n=t.exec(e);if(n){const e="~"===n[1];return[{inline:e,cloneName:e?"span":"div",name:n[2]}]}return[]}))})(null!=e?e:""),(({inline:e,name:t,cloneName:r})=>{if(o[t]=o[r],s[t]=r,v[t.toUpperCase()]={},v[t]={},e||(w[t.toUpperCase()]={},w[t]={}),!n[t]){let e=n[r];e=sa({},e),delete e.removeEmptyAttrs,delete e.removeEmpty,n[t]=e}ge(o,((e,n)=>{e[r]&&(o[n]=e=sa({},o[n]),e[t]=e[r])}))}))},R=e=>{q((e=>{const t=/^([+\-]?)([A-Za-z0-9_\-.\u00b7\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]+)\[([^\]]+)]$/;return te(ea(e,","),(e=>{const n=t.exec(e);if(n){const e=n[1],t=e?(e=>"-"===e?"remove":"add")(e):"replace";return[{operation:t,name:n[2],validChildren:ea(n[3],"|")}]}return[]}))})(null!=e?e:""),(({operation:e,name:t,validChildren:n})=>{const r="replace"===e?{"#comment":{}}:o[t];q(n,(t=>{"remove"===e?delete r[t]:r[t]={}})),o[t]=r}))},A=e=>{const t=n[e];if(t)return t;let o=r.length;for(;o--;){const t=r[o];if(t.pattern.test(e))return t}};e.valid_elements?(S(e.valid_elements),ra(d,((e,t)=>{o[t]=e.children}))):(ra(d,((e,t)=>{n[t]={attributes:e.attributes,attributesOrder:e.attributesOrder},o[t]=e.children})),ra(ea("strong/b em/i"),(e=>{const t=ea(e,"/");n[t[1]].outputName=t[0]})),ra(x,((t,o)=>{n[o]&&(e.padd_empty_block_inline_children&&(n[o].paddInEmptyBlock=!0),n[o].removeEmpty=!0)})),ra(ea("ol ul blockquote a table tbody"),(e=>{n[e]&&(n[e].removeEmpty=!0)})),ra(ea("p h1 h2 h3 h4 h5 h6 th td pre div address caption li summary"),(e=>{n[e]&&(n[e].paddEmpty=!0)})),ra(ea("span"),(e=>{n[e].removeEmptyAttrs=!0}))),_(e.custom_elements),R(e.valid_children),E(e.extended_valid_elements),R("+ol[ul|ol],+ul[ul|ol]"),ra({dd:"dl",dt:"dl",li:"ul ol",td:"tr",th:"tr",tr:"tbody thead tfoot",tbody:"table",thead:"table",tfoot:"table",legend:"fieldset",area:"map",param:"video audio object"},((e,t)=>{n[t]&&(n[t].parentsRequired=ea(e))}
vendor: 24,381 bytes, line 5168
5168)),e.invalid_elements&&ra(aa(e.invalid_elements),(e=>{n[e]&&delete n[e]})),A("span")||E("span[!data-mce-type|*]");const O=N(c),T=N(u),B=N(m),D=N(h),P=N(w),L=N(C),M=N(x),F=N(Object.seal(p)),U=N(g),z=N(v),j=N(y),H=N(f),$=N(k),V=N(Object.seal(a)),W=N(s);return{type:l,children:o,elements:n,getValidStyles:O,getValidClasses:B,getBlockElements:P,getInvalidStyles:T,getVoidElements:F,getTextBlockElements:L,getTextInlineElements:M,getBoolAttrs:D,getElementRule:A,getSelfClosingElements:U,getNonEmptyElements:z,getMoveCaretBeforeOnEnterElements:j,getWhitespaceElements:H,getTransparentElements:$,getSpecialElements:V,isValidChild:(e,t)=>{const n=o[e.toLowerCase()];return!(!n||!n[t.toLowerCase()])},isValid:(e,t)=>{const n=A(e);if(n){if(!t)return!0;{if(n.attributes[t])return!0;const e=n.attributePatterns;if(e){let n=e.length;for(;n--;)if(e[n].pattern.test(t))return!0}}}return!1},getCustomElements:W,addValidElements:E,setValidElements:S,addCustomElements:_,addValidChildren:R}},ua=(e={},t)=>{const n=/(?:url(?:(?:\(\s*\"([^\"]+)\"\s*\))|(?:\(\s*\'([^\']+)\'\s*\))|(?:\(\s*([^)\s]+)\s*\))))|(?:\'([^\']+)\')|(?:\"([^\"]+)\")/gi,o=/\s*([^:]+):\s*([^;]+);?/g,r=/\s+$/,s={};let a,i;const l=gr;t&&(a=t.getValidStyles(),i=t.getInvalidStyles());const d="\\\" \\' \\; \\: ; : \ufeff".split(" ");for(let e=0;e<d.length;e++)s[d[e]]=l+e,s[l+e]=d[e];const c={parse:t=>{const a={};let i=!1;const d=e.url_converter,u=e.url_converter_scope||c,m=(e,t,n)=>{const o=a[e+"-top"+t];if(!o)return;const r=a[e+"-right"+t];if(!r)return;const s=a[e+"-bottom"+t];if(!s)return;const i=a[e+"-left"+t];if(!i)return;const l=[o,r,s,i];let d=l.length-1;for(;d--&&l[d]===l[d+1];);d>-1&&n||(a[e+t]=-1===d?l[0]:l.join(" "),delete a[e+"-top"+t],delete a[e+"-right"+t],delete a[e+"-bottom"+t],delete a[e+"-left"+t])},f=e=>{const t=a[e];if(!t)return;const n=t.indexOf(",")>-1?[t]:t.split(" ");let o=n.length;for(;o--;)if(n[o]!==n[0])return!1;return a[e]=n[0],!0},g=e=>(i=!0,s[e]),p=(e,t)=>(i&&(e=e.replace(/\uFEFF[0-9]/g,(e=>s[e]))),t||(e=e.replace(/\\([\'\";:])/g,"$1")),e),h=e=>String.fromCharCode(parseInt(e.slice(1),16)),b=e=>e.replace(/\\[0-9a-f]+/gi,h),v=(t,n,o,r,s,a)=>{if(s=s||a)return"'"+(s=p(s)).replace(/\'/g,"\\'")+"'";if(n=p(n||o||r||""),!e.allow_script_urls){const t=n.replace(/[\s\r\n]+/g,"");if(/(java|vb)script:/i.test(t))return"";if(!e.allow_svg_data_urls&&/^data:image\/svg/i.test(t))return""}return d&&(n=d.call(u,n,"style")),"url('"+n.replace(/\'/g,"\\'")+"')"};if(t){let s;for(t=(t=t.replace(/[\u0000-\u001F]/g,"")).replace(/\\[\"\';:\uFEFF]/g,g).replace(/\"[^\"]+\"|\'[^\']+\'/g,(e=>e.replace(/[;:]/g,g)));s=o.exec(t);){o.lastIndex=s.index+s[0].length;let t=s[1].replace(r,"").toLowerCase(),d=s[2].replace(r,"");if(t&&d){if(t=b(t),d=b(d),-1!==t.indexOf(l)||-1!==t.indexOf('"'))continue;if(!e.allow_script_urls&&("behavior"===t||/expression\s*\(|\/\*|\*\//.test(d)))continue;"font-weight"===t&&"700"===d?d="bold":"color"!==t&&"background-color"!==t||(d=d.toLowerCase()),d=d.replace(n,v),a[t]=i?p(d,!0):d}}m("border","",!0),m("border","-width"),m("border","-color"),m("border","-style"),m("padding",""),m("margin",""),"border",C="border-style",w="border-color",f(y="border-width")&&f(C)&&f(w)&&(a.border=a[y]+" "+a[C]+" "+a[w],delete a[y],delete a[C],delete a[w]),"medium none"===a.border&&delete a.border,"none"===a["border-image"]&&delete a["border-image"]}var y,C,w;return a},serialize:(e,t)=>{let n="";const o=(t,o)=>{const r=o[t];if(r)for(let t=0,o=r.length;t<o;t++){const o=r[t],s=e[o];s&&(n+=(n.length>0?" ":"")+o+": "+s+";")}};return t&&a?(o("*",a),o(t,a)):ge(e,((e,o)=>{e&&((e,t)=>{if(!i||!t)return!0;let n=i["*"];return!(n&&n[e]||(n=i[t],n&&n[e]))})(o,t)&&(n+=(n.length>0?" ":"")+o+": "+e+";")})),n}};return c},ma={keyLocation:!0,layerX:!0,layerY:!0,returnValue:!0,webkitMovementX:!0,webkitMovementY:!0,keyIdentifier:!0,mozPressure:!0},fa=(e,t)=>{const n=null!=t?t:{};for(const t in e)ke(ma,t)||(n[t]=e[t]);return C(e.composedPath)&&(n.composedPath=()=>e.composedPath()),n},ga=(e,t,n,o)=>{var r;const s=fa(t,o);return s.type=e,y(s.target)&&(s.target=null!==(r=s.srcElement)&&void 0!==r?r:n),(e=>y(e.preventDefault)||(e=>e instanceof Event||w(e.initEvent))(e))(t)&&(s.preventDefault=()=>{s.defaultPrevented=!0,s.isDefaultPrevented=M,w(t.preventDefault)&&t.preventDefault()},s.stopPropagation=()=>{s.cancelBubble=!0,s.isPropagationStopped=M,w(t.stopPropagation)&&t.stopPropagation()},s.stopImmediatePropagation=()=>{s.isImmediatePropagationStopped=M,s.stopPropagation()},(e=>e.isDefaultPrevented===M||e.isDefaultPrevented===L)(s)||(s.isDefaultPrevented=!0===s.defaultPrevented?M:L,s.isPropagationStopped=!0===s.cancelBubble?M:L,s.isImmediatePropagationStopped=L)),s},pa=/^(?:mouse|contextmenu)|click/,ha=(e,t,n,o)=>{e.addEventListener(t,n,o||!1)},ba=(e,t,n,o)=>{e.removeEventListener(t,n,o||!1)},va=(e,t)=>{const n=ga(e.type,e,document,t);if((e=>C(e)&&pa.test(e.type))(e)&&v(e.pageX)&&!v(e.clientX)){const t=n.target.ownerDocument||document,o=t.documentElement,r=t.body,s=n;s.pageX=e.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),s.pageY=e.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)}return n},ya=(e,t,n)=>{const o=e.document,r={type:"ready"};if(n.domLoaded)return void t(r);const s=()=>{ba(e,"DOMContentLoaded",s),ba(e,"load",s),n.domLoaded||(n.domLoaded=!0,t(r)),e=null};"complete"===o.readyState||"interactive"===o.readyState&&o.body?s():ha(e,"DOMContentLoaded",s),n.domLoaded||ha(e,"load",s)};class Ca{constructor(){this.domLoaded=!1,this.events={},this.count=1,this.expando="mce-data-"+(+new Date).toString(32),this.hasFocusIn="onfocusin"in document.documentElement,this.count=1}bind(e,t,n,o){const r=this;let s;const a=window,i=e=>{r.executeHandlers(va(e||a.event),l)};if(!e||Jo(e)||tr(e))return n;let l;e[r.expando]?l=e[r.expando]:(l=r.count++,e[r.expando]=l,r.events[l]={}),o=o||e;const d=t.split(" ");let c=d.length;for(;c--;){let t=d[c],u=i,m=!1,f=!1;"DOMContentLoaded"===t&&(t="ready"),r.domLoaded&&"ready"===t&&"complete"===e.readyState?n.call(o,va({type:t})):(r.hasFocusIn||"focusin"!==t&&"focusout"!==t||(m=!0,f="focusin"===t?"focus":"blur",u=e=>{const t=va(e||a.event);t.type="focus"===t.type?"focusin":"focusout",r.executeHandlers(t,l)}),s=r.events[l][t],s?"ready"===t&&r.domLoaded?n(va({type:t})):s.push({func:n,scope:o}):(r.events[l][t]=s=[{func:n,scope:o}],s.fakeName=f,s.capture=m,s.nativeHandler=u,"ready"===t?ya(e,u,r):ha(e,f||t,u,m)))}return e=s=null,n}unbind(e,t,n){if(!e||Jo(e)||tr(e))return this;const o=e[this.expando];if(o){let r=this.events[o];if(t){const o=t.split(" ");let s=o.length;for(;s--;){const t=o[s],a=r[t];if(a){if(n){let e=a.length;for(;e--;)if(a[e].func===n){const n=a.nativeHandler,o=a.fakeName,s=a.capture,i=a.slice(0,e).concat(a.slice(e+1));i.nativeHandler=n,i.fakeName=o,i.capture=s,r[t]=i}}n&&0!==a.length||(delete r[t],ba(e,a.fakeName||t,a.nativeHandler,a.capture))}}}else ge(r,((t,n)=>{ba(e,t.fakeName||n,t.nativeHandler,t.capture)})),r={};for(const e in r)if(ke(r,e))return this;delete this.events[o];try{delete e[this.expando]}catch(t){e[this.expando]=null}}return this}fire(e,t,n){return this.dispatch(e,t,n)}dispatch(e,t,n){if(!e||Jo(e)||tr(e))return this;const o=va({type:t,target:e},n);do{const t=e[this.expando];t&&this.executeHandlers(o,t),e=e.parentNode||e.ownerDocument||e.defaultView||e.parentWindow}while(e&&!o.isPropagationStopped());return this}clean(e){if(!e||Jo(e)||tr(e))return this;if(e[this.expando]&&this.unbind(e),e.getElementsByTagName||(e=e.document),e&&e.getElementsByTagName){this.unbind(e);const t=e.getElementsByTagName("*");let n=t.length;for(;n--;)(e=t[n])[this.expando]&&this.unbind(e)}return this}destroy(){this.events={}}cancel(e){return e&&(e.preventDefault(),e.stopImmediatePropagation()),!1}executeHandlers(e,t){const n=this.events[t],o=n&&n[e.type];if(o)for(let t=0,n=o.length;t<n;t++){const n=o[t];if(n&&!1===n.func.call(n.scope,e)&&e.preventDefault(),e.isImmediatePropagationStopped())return}}}Ca.Event=new Ca;const wa=Dt.each,xa=Dt.grep,ka="data-mce-style",Ea=Dt.makeMap("fill-opacity font-weight line-height opacity orphans widows z-index zoom"," "),Sa=(e,t,n)=>{y(n)||""===n?on(e,t):Jt(e,t,n)},_a=e=>e.replace(/[A-Z]/g,(e=>"-"+e.toLowerCase())),Na=(e,t)=>{let n=0;if(e)for(let o=e.nodeType,r=e.previousSibling;r;r=r.previousSibling){const e=r.nodeType;(!t||!Jo(r)||e!==o&&r.data.length)&&(n++,o=e)}return n},Ra=(e,t)=>{const n=en(t,"style"),o=e.serialize(e.parse(n),Ht(t));Sa(t,ka,o)},Aa=(e,t,n)=>{const o=_a(t);y(n)||""===n?fo(e,o):ao(e,o,((e,t)=>x(e)?ke(Ea,t)?e+"":e+"px":e)(n,o))},Oa=(e,t={})=>{const n={},o=window,r={};let s=0;const a=Ms.forElement(yn(e),{contentCssCors:t.contentCssCors,referrerPolicy:t.referrerPolicy}),i=[],l=t.schema?t.schema:ca({}),d=ua({url_converter:t.url_converter,url_converter_scope:t.url_converter_scope},t.schema),c=t.ownEvents?new Ca:Ca.Event,u=l.getBlockElements(),f=t=>t&&e&&m(t)?e.getElementById(t):t,g=e=>{const t=f(e);return C(t)?yn(t):null},h=(e,t,n="")=>{let o;const r=g(e);if(C(r)&&Wt(r)){const e=Y[t];o=e&&e.get?e.get(r.dom,t):en(r,t)}return C(o)?o:n},b=e=>{const t=f(e);return y(t)?[]:t.attributes},v=(e,n,o)=>{T(e,(e=>{if($o(e)){const r=yn(e),s=""===o?null:o,a=en(r,n),i=Y[n];i&&i.set?i.set(r.dom,s,n):Sa(r,n,s),a!==s&&t.onSetAttrib&&t.onSetAttrib({attrElm:r.dom,attrName:n,attrValue:s})}}))},x=()=>t.root_element||e.body,k=(t,n)=>((e,t,n)=>{let o=0,r=0;const s=e.ownerDocument;if(n=n||e,t){if(n===e&&t.getBoundingClientRect&&"static"===lo(yn(e),"position")){const n=t.getBoundingClientRect();return o=n.left+(s.documentElement.scrollLeft||e.scrollLeft)-s.documentElement.clientLeft,r=n.top+(s.documentElement.scrollTop||e.scrollTop)-s.documentElement.clientTop,{x:o,y:r}}let a=t;for(;a&&a!==n&&a.nodeType&&!Ps(a,n);){const e=a;o+=e.offsetLeft||0,r+=e.offsetTop||0,a=e.offsetParent}for(a=t.parentNode;a&&a!==n&&a.nodeType&&!Ps(a,n);)o-=a.scrollLeft||0,r-=a.scrollTop||0,a=a.parentNode;r+=(e=>Bs.isFirefox()&&"table"===Ht(e)?Ds(Mn(e)).filter((e=>"caption"===Ht(e))).bind((e=>Ds(Ln(e)).map((t=>{const n=t.dom.offsetTop,o=e.dom.offsetTop,r=e.dom.offsetHeight;return n<=o?-r:0})))).getOr(0):0)(yn(t))}return{x:o,y:r}})(e.body,f(t),n),S=(e,t,n)=>{const o=f(e);if(!y(o)&&$o(o))return n?lo(yn(o),_a(t)):("float"===(t=t.replace(/-(\D)/g,((e,t)=>t.toUpperCase())))&&(t="cssFloat"),o.style?o.style[t]:void 0)},_=e=>{const t=f(e);if(!t)return{w:0,h:0};let n=S(t,"width"),o=S(t,"height");return n&&-1!==n.indexOf("px")||(n="0"),o&&-1!==o.indexOf("px")||(o="0"),{w:parseInt(n,10)||t.offsetWidth||t.clientWidth,h:parseInt(o,10)||t.offsetHeight||t.clientHeight}},R=(e,t)=>{if(!e)return!1;const n=p(e)?e:[e];return $(n,(e=>xn(yn(e),t)))},A=(e,t,n,o)=>{const r=[];let s=f(e);o=void 0===o;const a=n||("BODY"!==x().nodeName?x().parentNode:null);if(m(t))if("*"===t)t=$o;else{const e=t;t=t=>R(t,e)}for(;s&&!(s===a||y(s.nodeType)||nr(s)||or(s));){if(!t||t(s)){if(!o)return[s];r.push(s)}s=s.parentNode}return o?r:null},O=(e,t,n)=>{let o=t;if(e){m(t)&&(o=e=>R(e,t));for(let t=e[n];t;t=t[n])if(w(o)&&o(t))return t}return null},T=function(e,t,n){const o=null!=n?n:this;if(p(e)){const n=[];return wa(e,((e,r)=>{const s=f(e);s&&n.push(t.call(o,s,r))})),n}{const n=f(e);return!!n&&t.call(o,n)}},B=(e,t)=>{T(e,(e=>{ge(t,((t,n)=>{v(e,n,t)}))}))},D=(e,t)=>{T(e,(e=>{const n=yn(e);So(n,t)}))},P=(t,n,o,r,s)=>T(t,(t=>{const a=m(n)?e.createElement(n):n;return C(o)&&B(a,o),r&&(!m(r)&&r.nodeType?a.appendChild(r):m(r)&&D(a,r)),s?a:t.appendChild(a)})),L=(t,n,o)=>P(e.createElement(t),t,n,o,!0),M=Zs.encodeAllRaw,I=(e,t)=>T(e,(e=>{const n=yn(e);return t&&q(Mn(n),(e=>{Kt(e)&&0===e.dom.length?wo(e):go(n,e)})),wo(n),n.dom})),F=(e,t,n)=>{T(e,(e=>{if($o(e)){const o=yn(e),r=t.split(" ");q(r,(e=>{C(n)?(n?un:fn)(o,e):((e,t)=>{const n=an(e)?e.dom.classList.toggle(t):((e,t)=>H(ln(e),t)?cn(e,t):dn(e,t))(e,t);mn(e)})(o,e)}))}}))},U=(e,t,n)=>T(t,(o=>{var r;const s=p(t)?e.cloneNode(!0):e;return n&&wa(xa(o.childNodes),(e=>{s.appendChild(e)})),null===(r=o.parentNode)||void 0===r||r.replaceChild(s,o),o})),z=e=>{if($o(e)){const t="a"===e.nodeName.toLowerCase()&&!h(e,"href")&&h(e,"id");if(h(e,"name")||h(e,"data-mce-bookmark")||t)return!0}return!1},j=()=>e.createRange(),V=(n,r,s,a)=>{if(p(n)){let e=n.length;const t=[];for(;e--;)t[e]=V(n[e],r,s,a);return t}return!t.collect||n!==e&&n!==o||i.push([n,r,s,a]),c.bind(n,r,s,a||G)},W=(t,n,r)=>{if(p(t)){let e=t.length;const o=[];for(;e--;)o[e]=W(t[e],n,r);return o}if(i.length>0&&(t===e||t===o)){let e=i.length;for(;e--;){const[o,s,a]=i[e];t!==o||n&&n!==s||r&&r!==a||c.unbind(o,s,a)}}return c.unbind(t,n,r)},K=e=>{if(e&&$o(e)){const t=e.getAttribute("data-mce-contenteditable");return t&&"inherit"!==t?t:"inherit"!==e.contentEditable?e.contentEditable:null}return null},G={doc:e,settings:t,win:o,files:r,stdMode:!0,boxModel:!0,styleSheetLoader:a,boundEvents:i,styles:d,schema:l,events:c,isBlock:e=>m(e)?ke(u,e):$o(e)&&(ke(u,e.nodeName)||As(l,e)),root:null,clone:(e,t)=>e.cloneNode(t),getRoot:x,getViewPort:e=>{const t=Mo(e);return{x:t.x,y:t.y,w:t.width,h:t.height}},getRect:e=>{const t=f(e),n=k(t),o=_(t);return{x:n.x,y:n.y,w:o.w,h:o.h}},getSize:_,getParent:(e,t,n)=>{const o=A(e,t,n,!1);return o&&o.length>0?o[0]:null},getParents:A,get:f,getNext:(e,t)=>O(e,t,"nextSibling"),getPrev:(e,t)=>O(e,t,"previousSibling"),select:(n,o)=>{var r,s;const a=null!==(s=null!==(r=f(o))&&void 0!==r?r:t.root_element)&&void 0!==s?s:e;return w(a.querySelectorAll)?ce(a.querySelectorAll(n)):[]},is:R,add:P,create:L,createHTML:(e,t,n="")=>{let o="<"+e;for(const e in t)Ee(t,e)&&(o+=" "+e+'="'+M(t[e])+'"');return Ye(n)&&ke(l.getVoidElements(),e)?o+" />":o+">"+n+"</"+e+">"},createFragment:t=>{const n=e.createElement("div"),o=e.createDocumentFragment();let r;for(o.appendChild(n),t&&(n.innerHTML=t);r=n.firstChild;)o.appendChild(r);return o.removeChild(n),o},remove:I,setStyle:(e,n,o)=>{T(e,(e=>{const r=yn(e);Aa(r,n,o),t.update_styles&&Ra(d,r)}))},getStyle:S,setStyles:(e,n)=>{T(e,(e=>{const o=yn(e);ge(n,((e,t)=>{Aa(o,t,e)})),t.update_styles&&Ra(d,o)}))},removeAllAttribs:e=>T(e,(e=>{const t=e.attributes;for(let n=t.length-1;n>=0;n--)e.removeAttributeNode(t.item(n))})),setAttrib:v,setAttribs:B,getAttrib:h,getPos:k,parseStyle:e=>d.parse(e),serializeStyle:(e,t)=>d.serialize(e,t),addStyle:t=>{if(G!==Oa.DOM&&e===document){if(n[t])return;n[t]=!0}let o=e.getElementById("mceDefaultStyles");if(!o){o=e.createElement("style"),o.id="mceDefaultStyles",o.type="text/css";const t=e.head;t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o)}o.styleSheet?o.styleSheet.cssText+=t:o.appendChild(e.createTextNode(t))},loadCSS:e=>{e||(e=""),q(e.split(","),(e=>{r[e]=!0,a.load(e).catch(E)}))},addClass:(e,t)=>{F(e,t,!0)},removeClass:(e,t)=>{F(e,t,!1)},hasClass:(e,t)=>{const n=g(e),o=t.split(" ");return C(n)&&ne(o,(e=>gn(n,e)))},toggleClass:F,show:e=>{T(e,(e=>fo(yn(e),"display")))},hide:e=>{T(e,(e=>ao(yn(e),"display","none")))},isHidden:e=>{const t=g(e);return C(t)&&Pt(uo(t,"display"),"none")},uniqueId:e=>(e||"mce_")+s++,setHTML:D,getOuterHTML:e=>{const t=g(e);return C(t)?$o(t.dom)?t.dom.outerHTML:(e=>{const t=bn("div"),n=yn(e.dom.cloneNode(!0));return bo(t,n),Eo(t)})(t):""},setOuterHTML:(e,t)=>{T(e,(e=>{$o(e)&&(e.outerHTML=t)}))},decode:Zs.decode,encode:M,insertAfter:(e,t)=>{const n=f(t);return T(e,(e=>{const t=null==n?void 0:n.parentNode,o=null==n?void 0:n.nextSibling;return t&&(o?t.insertBefore(e,o):t.appendChild(e)),e}))},replace:U,rename:(e,t)=>{if(e.nodeName!==t.toUpperCase()){const n=L(t);return wa(b(e),(t=>{v(n,t.nodeName,h(e,t.nodeName))})),U(n,e,!0),n}return e},findCommonAncestor:(e,t)=>{let n=e;for(;n;){let e=t;for(;e&&n!==e;)e=e.parentNode;if(n===e)break;n=n.parentNode}return!n&&e.ownerDocument?e.ownerDocument.documentElement:n},run:T,getAttribs:b,isEmpty:(e,t,n)=>{let o=0;if(z(e))return!1;const r=e.firstChild;if(r){const s=new zo(r,e),a=l?l.getWhitespaceElements():{},i=t||(l?l.getNonEmptyElements():null);let d=r;do{if($o(d)){const e=d.getAttribute("data-mce-bogus");if(e){d=s.next("all"===e);continue}const t=d.nodeName.toLowerCase();if(i&&i[t]){if("br"===t){o++,d=s.next();continue}return!1}if(z(d))return!1}if(tr(d))return!1;if(Jo(d)&&!ds(d.data)&&(!(null==n?void 0:n.includeZwsp)||!cs(d.data)))return!1;if(Jo(d)&&d.parentNode&&a[d.parentNode.nodeName]&&ds(d.data))return!1;d=s.next()}while(d)}return o<=1},createRng:j,nodeIndex:Na,split:(e,t,n)=>{let o,r,s=j();if(e&&t&&e.parentNode&&t.parentNode){const a=e.parentNode;return s.setStart(a,Na(e)),s.setEnd(t.parentNode,Na(t)),o=s.extractContents(),s=j(),s.setStart(t.parentNode,Na(t)+1),s.setEnd(a,Na(e)+1),r=s.extractContents(),a.insertBefore(Us(G,o),e),n?a.insertBefore(n,e):a.insertBefore(t,e),a.insertBefore(Us(G,r),e),I(e),n||t}},bind:V,unbind:W,fire:(e,t,n)=>c.dispatch(e,t,n),dispatch:(e,t,n)=>c.dispatch(e,t,n),getContentEditable:K,getContentEditableParent:e=>{const t=x();let n=null;for(let o=e;o&&o!==t&&(n=K(o),null===n);o=o.parentNode);return n},isEditable:e=>{if(C(e)){const t=$o(e)?e:e.parentElement;return C(t)&&no(yn(t))}return!1},destroy:()=>{if(i.length>0){let e=i.length;for(;e--;){const[t,n,o]=i[e];c.unbind(t,n,o)}}ge(r,((e,t)=>{a.unload(t),delete r[t]}))},isChildOf:(e,t)=>e===t||t.contains(e),dumpRng:e=>"startContainer: "+e.startContainer.nodeName+", startOffset: "+e.startOffset+", endContainer: "+e.endContainer.nodeName+", endOffset: "+e.endOffset},Y=((e,t,n)=>{const o=t.keep_values,r={set:(e,o,r)=>{const s=yn(e);w(t.url_converter)&&C(o)&&(o=t.url_converter.call(t.url_converter_scope||n(),String(o),r,e)),Sa(s,"data-mce-"+r,o),Sa(s,r,o)},get:(e,t)=>{const n=yn(e);return en(n,"data-mce-"+t)||en(n,t)}},s={style:{set:(t,n)=>{const r=yn(t);o&&Sa(r,ka,n),on(r,"style"),m(n)&&io(r,e.parse(n))},get:t=>{const n=yn(t),o=en(n,ka)||en(n,"style");return e.serialize(e.parse(o),Ht(n))}}};return o&&(s.href=s.src=r),s})(d,t,N(G));return G};Oa.DOM=Oa(document),Oa.nodeIndex=Na;const Ta=Oa.DOM;class Ba{constructor(e={}){this.states={},this.queue=[],this.scriptLoadedCallbacks={},this.queueLoadedCallbacks=[],this.loading=!1,this.settings=e}_setReferrerPolicy(e){this.settings.referrerPolicy=e}loadScript(e){return new Promise(((t,n)=>{const o=Ta;let r;const s=()=>{o.remove(a),r&&(r.onerror=r.onload=r=null)},a=o.uniqueId();r=document.createElement("script"),r.id=a,r.type="text/javascript",r.src=Dt._addCacheSuffix(e),this.settings.referrerPolicy&&o.setAttrib(r,"referrerpolicy",this.settings.referrerPolicy),r.onload=()=>{s(),t()},r.onerror=()=>{s(),n("Failed to load script: "+e)},(document.getElementsByTagName("head")[0]||document.body).appendChild(r)}))}isDone(e){return 2===this.states[e]}markDone(e){this.states[e]=2}add(e){const t=this;return t.queue.push(e),void 0===t.states[e]&&(t.states[e]=0),new Promise(((n,o)=>{t.scriptLoadedCallbacks[e]||(t.scriptLoadedCallbacks[e]=[]),t.scriptLoadedCallbacks[e].push({resolve:n,reject:o})}))}load(e){return this.add(e)}remove(e){delete this.states[e],delete this.scriptLoadedCallbacks[e]}loadQueue(){const e=this.queue;return this.queue=[],this.loadScripts(e)}loadScripts(e){const t=this,n=(e,n)=>{xe(t.scriptLoadedCallbacks,n).each((t=>{q(t,(t=>t[e](n)))})),delete t.scriptLoadedCallbacks[n]},o=e=>{const t=G(e,(e=>"rejected"===e.status));return t.length>0?Promise.reject(te(t,(({reason:e})=>p(e)?e:[e]))):Promise.resolve()},r=e=>Promise.allSettled(V(e,(e=>2===t.states[e]?(n("resolve",e),Promise.resolve()):3===t.states[e]?(n("reject",e),Promise.reject(e)):(t.states[e]=1,t.loadScript(e).then((()=>{t.states[e]=2,n("resolve",e);const s=t.queue;return s.length>0?(t.queue=[],r(s).then(o)):Promise.resolve()}),(()=>(t.states[e]=3,n("reject",e),Promise.reject(e)))))))),s=e=>(t.loading=!0,r(e).then((e=>{t.loading=!1;const n=t.queueLoadedCallbacks.shift();return I.from(n).each(P),o(e)}))),a=Se(e);return t.loading?new Promise(((e,n)=>{t.queueLoadedCallbacks.push((()=>{s(a).then(e,n)}))})):s(a)}}Ba.ScriptLoader=new Ba;const Da=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Pa={},La=Da("en"),Ma=()=>xe(Pa,La.get()),Ia={getData:()=>pe(Pa,(e=>({...e}))),setCode:e=>{e&&La.set(e)},getCode:()=>La.get(),add:(e,t)=>{let n=Pa[e];n||(Pa[e]=n={});const o=V(me(t),(e=>e.toLowerCase()));ge(t,((e,r)=>{const s=r.toLowerCase();s!==r&&((e,t)=>{const n=e.indexOf(t);return-1!==n&&e.indexOf(t,n+1)>n})(o,s)?(ke(t,s)||(n[s]=e),n[r]=e):n[s]=e}))},translate:e=>{const t=Ma().getOr({}),n=e=>w(e)?Object.prototype.toString.call(e):o(e)?"":""+e,o=e=>""===e||null==e,r=e=>{const o=n(e);return ke(t,o)?n(t[o]):xe(t,o.toLowerCase()).map(n).getOr(o)},s=e=>e.replace(/{context:\w+}$/,"");if(o(e))return"";if(f(a=e)&&ke(a,"raw"))return n(e.raw);var a;if((e=>p(e)&&e.length>1)(e)){const t=e.slice(1);return s(r(e[0]).replace(/\{([0-9]+)\}/g,((e,o)=>ke(t,o)?n(t[o]):e)))}return s(r(e))},isRtl:()=>Ma().bind((e=>xe(e,"_dir"))).exists((e=>"rtl"===e)),hasCode:e=>ke(Pa,e)},Fa=()=>{const e=[],t={},n={},o=[],r=(e,t)=>{const n=G(o,(n=>n.name===e&&n.state===t));q(n,(e=>e.resolve()))},s=e=>ke(t,e),a=(e,n)=>{const o=Ia.getCode();!o||n&&-1===(","+(n||"")+",").indexOf(","+o+",")||Ba.ScriptLoader.add(t[e]+"/langs/"+o+".js")},i=(e,t="added")=>"added"===t&&(e=>ke(n,e))(e)||"loaded"===t&&s(e)?Promise.resolve():new Promise((n=>{o.push({name:e,state:t,resolve:n})}));return{items:e,urls:t,lookup:n,get:e=>{if(n[e])return n[e].instance},requireLangPack:(e,t)=>{!1!==Fa.languageLoad&&(s(e)?a(e,t):i(e,"loaded").then((()=>a(e,t))))},add:(t,o)=>(e.push(o),n[t]={instance:o},r(t,"added"),o),remove:e=>{delete t[e],delete n[e]},createUrl:(e,t)=>m(t)?m(e)?{prefix:"",resource:t,suffix:""}:{prefix:e.prefix,resource:t,suffix:e.suffix}:t,load:(e,o)=>{if(t[e])return Promise.resolve();let s=m(o)?o:o.prefix+o.resource+o.suffix;0!==s.indexOf("/")&&-1===s.indexOf("://")&&(s=Fa.baseURL+"/"+s),t[e]=s.substring(0,s.lastIndexOf("/"));const a=()=>(r(e,"loaded"),Promise.resolve());return n[e]?a():Ba.ScriptLoader.add(s).then(a)},waitFor:i}};Fa.languageLoad=!0,Fa.baseURL="",Fa.PluginManager=Fa(),Fa.ThemeManager=Fa(),Fa.ModelManager=Fa();const Ua=e=>{const t=Da(I.none()),n=()=>t.get().each((e=>clearInterval(e)));return{clear:()=>{n(),t.set(I.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:o=>{n(),t.set(I.some(setInterval(o,e)))}}},za=()=>{const e=(e=>{const t=Da(I.none()),n=()=>t.get().each(e);return{clear:()=>{n(),t.set(I.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{n(),t.set(I.some(e))}}})(E);return{...e,on:t=>e.get().each(t)}},ja=(e,t)=>{let n=null;return{cancel:()=>{h(n)||(clearTimeout(n),n=null)},throttle:(...o)=>{h(n)&&(n=setTimeout((()=>{n=null,e.apply(null,o)}),t))}}},Ha=(e,t)=>{let n=null;const o=()=>{h(n)||(clearTimeout(n),n=null)};return{cancel:o,throttle:(...r)=>{o(),n=setTimeout((()=>{n=null,e.apply(null,r)}),t)}}},$a=N("mce-annotation"),Va=N("data-mce-annotation"),qa=N("data-mce-annotation-uid"),Wa=N("data-mce-annotation-active"),Ka=N("data-mce-annotation-classes"),Ga=N("data-mce-annotation-attrs"),Ya=e=>t=>En(t,e),Xa=(e,t)=>{const n=e.selection.getRng(),o=yn(n.startContainer),r=yn(e.getBody()),s=t.fold((()=>"."+$a()),(e=>`[${Va()}="${e}"]`)),a=In(o,n.startOffset).getOr(o);return to(a,s,Ya(r)).bind((t=>tn(t,`${qa()}`).bind((n=>tn(t,`${Va()}`).map((t=>{const o=Ja(e,n);return{uid:n,name:t,elements:o}}))))))},Qa=(e,t)=>nn(e,"data-mce-bogus")||Uo(e,'[data-mce-bogus="all"]',Ya(t)),Ja=(e,t)=>{const n=yn(e.getBody()),o=Fo(n,`[${qa()}="${t}"]`);return G(o,(e=>!Qa(e,n)))},Za=(e,t)=>{const n=yn(e.getBody()),o=Fo(n,`[${Va()}="${t}"]`),r={};return q(o,(e=>{if(!Qa(e,n)){const t=en(e,qa()),n=xe(r,t).getOr([]);r[t]=n.concat([e])}})),r};let ei=0;const ti=e=>{const t=(new Date).getTime(),n=Math.floor(1e9*Math.random());return ei++,e+"_"+n+ei+String(t)},ni=(e,t)=>yn(e.dom.cloneNode(t)),oi=e=>ni(e,!1),ri=e=>ni(e,!0),si=(e,t,n=L)=>{const o=new zo(e,t),r=e=>{let t;do{t=o[e]()}while(t&&!Jo(t)&&!n(t));return I.from(t).filter(Jo)};return{current:()=>I.from(o.current()).filter(Jo),next:()=>r("next"),prev:()=>r("prev"),prev2:()=>r("prev2")}},ai=(e,t)=>{const n=t||(t=>e.isBlock(t)||rr(t)||ir(t)),o=(e,t,n,r)=>{if(Jo(e)){const n=r(e,t,e.data);if(-1!==n)return I.some({container:e,offset:n})}return n().bind((e=>o(e.container,e.offset,n,r)))};return{backwards:(t,r,s,a)=>{const i=si(t,null!=a?a:e.getRoot(),n);return o(t,r,(()=>i.prev().map((e=>({container:e,offset:e.length})))),s).getOrNull()},forwards:(t,r,s,a)=>{const i=si(t,null!=a?a:e.getRoot(),n);return o(t,r,(()=>i.next().map((e=>({container:e,offset:0})))),s).getOrNull()}}},ii=Math.round,li=e=>e?{left:ii(e.left),top:ii(e.top),bottom:ii(e.bottom),right:ii(e.right),width:ii(e.width),height:ii(e.he
vendor: 5,699 bytes, line 5168
5168ight)}:{left:0,top:0,bottom:0,right:0,width:0,height:0},di=(e,t)=>(e=li(e),t||(e.left=e.left+e.width),e.right=e.left,e.width=0,e),ci=(e,t,n)=>e>=0&&e<=Math.min(t.height,n.height)/2,ui=(e,t)=>{const n=Math.min(t.height/2,e.height/2);return e.bottom-n<t.top||!(e.top>t.bottom)&&ci(t.top-e.bottom,e,t)},mi=(e,t)=>e.top>t.bottom||!(e.bottom<t.top)&&ci(t.bottom-e.top,e,t),fi=(e,t,n)=>{const o=Math.max(Math.min(t,e.left+e.width),e.left),r=Math.max(Math.min(n,e.top+e.height),e.top);return Math.sqrt((t-o)*(t-o)+(n-r)*(n-r))},gi=e=>{const t=e.startContainer,n=e.startOffset;return t===e.endContainer&&t.hasChildNodes()&&e.endOffset===n+1?t.childNodes[n]:null},pi=(e,t)=>{if($o(e)&&e.hasChildNodes()){const n=e.childNodes,o=((e,t,n)=>Math.min(Math.max(e,0),n))(t,0,n.length-1);return n[o]}return e},hi=new RegExp("[\u0300-\u036f\u0483-\u0487\u0488-\u0489\u0591-\u05bd\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u0610-\u061a\u064b-\u065f\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e3-\u0902\u093a\u093c\u0941-\u0948\u094d\u0951-\u0957\u0962-\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2-\u09e3\u0a01-\u0a02\u0a3c\u0a41-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a51\u0a70-\u0a71\u0a75\u0a81-\u0a82\u0abc\u0ac1-\u0ac5\u0ac7-\u0ac8\u0acd\u0ae2-\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62-\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c00\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c62-\u0c63\u0c81\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc-\u0ccd\u0cd5-\u0cd6\u0ce2-\u0ce3\u0d01\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62-\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039-\u103a\u103d-\u103e\u1058-\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085-\u1086\u108d\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17b4-\u17b5\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927-\u1928\u1932\u1939-\u193b\u1a17-\u1a18\u1a1b\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1ab0-\u1abd\u1abe\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80-\u1b81\u1ba2-\u1ba5\u1ba8-\u1ba9\u1bab-\u1bad\u1be6\u1be8-\u1be9\u1bed\u1bef-\u1bf1\u1c2c-\u1c33\u1c36-\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1cf4\u1cf8-\u1cf9\u1dc0-\u1df5\u1dfc-\u1dff\u200c-\u200d\u20d0-\u20dc\u20dd-\u20e0\u20e1\u20e2-\u20e4\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302d\u302e-\u302f\u3099-\u309a\ua66f\ua670-\ua672\ua674-\ua67d\ua69e-\ua69f\ua6f0-\ua6f1\ua802\ua806\ua80b\ua825-\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\ua9e5\uaa29-\uaa2e\uaa31-\uaa32\uaa35-\uaa36\uaa43\uaa4c\uaa7c\uaab0\uaab2-\uaab4\uaab7-\uaab8\uaabe-\uaabf\uaac1\uaaec-\uaaed\uaaf6\uabe5\uabe8\uabed\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\uff9e-\uff9f]"),bi=e=>m(e)&&e.charCodeAt(0)>=768&&hi.test(e),vi=$o,yi=ss,Ci=Wo("display","block table"),wi=Wo("float","left right"),xi=((...e)=>t=>{for(let n=0;n<e.length;n++)if(!e[n](t))return!1;return!0})(vi,yi,T(wi)),ki=T(Wo("white-space","pre pre-line pre-wrap")),Ei=Jo,Si=rr,_i=Oa.nodeIndex,Ni=(e,t)=>t<0&&$o(e)&&e.hasChildNodes()?void 0:pi(e,t),Ri=e=>e?e.createRange():Oa.DOM.createRng(),Ai=e=>m(e)&&/[\r\n\t ]/.test(e),Oi=e=>!!e.setStart&&!!e.setEnd,Ti=e=>{const t=e.startContainer,n=e.startOffset;if(Ai(e.toString())&&ki(t.parentNode)&&Jo(t)){const e=t.data;if(Ai(e[n-1])||Ai(e[n+1]))return!0}return!1},Bi=e=>0===e.left&&0===e.right&&0===e.top&&0===e.bottom,Di=e=>{var t;let n;const o=e.getClientRects();return n=o.length>0?li(o[0]):li(e.getBoundingClientRect()),!Oi(e)&&Si(e)&&Bi(n)?(e=>{const t=e.ownerDocument,n=Ri(t),o=t.createTextNode(pr),r=e.parentNode;r.insertBefore(o,e),n.setStart(o,0),n.setEnd(o,1);const s=li(n.getBoundingClientRect());return r.removeChild(o),s})(e):Bi(n)&&Oi(e)&&null!==(t=(e=>{const t=e.startContainer,n=e.endContainer,o=e.startOffset,r=e.endOffset;if(t===n&&Jo(n)&&0===o&&1===r){const t=e.cloneRange();return t.setEndAfter(n),Di(t)}return null})(e))&&void 0!==t?t:n},Pi=(e,t)=>{const n=di(e,t);return n.width=1,n.right=n.left+1,n},Li=(e,t,n)=>{const o=()=>(n||(n=(e=>{const t=[],n=e=>{var n,o;0!==e.height&&(t.length>0&&(n=e,o=t[t.length-1],n.left===o.left&&n.top===o.top&&n.bottom===o.bottom&&n.right===o.right)||t.push(e))},o=(e,t)=>{const o=Ri(e.ownerDocument);if(t<e.data.length){if(bi(e.data[t]))return;if(bi(e.data[t-1])&&(o.setStart(e,t),o.setEnd(e,t+1),!Ti(o)))return void n(Pi(Di(o),!1))}t>0&&(o.setStart(e,t-1),o.setEnd(e,t),Ti(o)||n(Pi(Di(o),!1))),t<e.data.length&&(o.setStart(e,t),o.setEnd(e,t+1),Ti(o)||n(Pi(Di(o),!0)))},r=e.container(),s=e.offset();if(Ei(r))return o(r,s),t;if(vi(r))if(e.isAtEnd()){const e=Ni(r,s);Ei(e)&&o(e,e.data.length),xi(e)&&!Si(e)&&n(Pi(Di(e),!1))}else{const a=Ni(r,s);if(Ei(a)&&o(a,0),xi(a)&&e.isAtEnd())return n(Pi(Di(a),!1)),t;const i=Ni(e.container(),e.offset()-1);xi(i)&&!Si(i)&&(Ci(i)||Ci(a)||!xi(a))&&n(Pi(Di(i),!1)),xi(a)&&n(Pi(Di(a),!0))}return t})(Li(e,t))),n);return{container:N(e),offset:N(t),toRange:()=>{const n=Ri(e.ownerDocument);return n.setStart(e,t),n.setEnd(e,t),n},getClientRects:o,isVisible:()=>o().length>0,isAtStart:()=>(Ei(e),0===t),isAtEnd:()=>Ei(e)?t>=e.data.length:t>=e.childNodes.length,isEqual:n=>n&&e===n.container()&&t===n.offset(),getNode:n=>Ni(e,n?t-1:t)}};Li.fromRangeStart=e=>Li(e.startContainer,e.startOffset),Li.fromRangeEnd=e=>Li(e.endContainer,e.endOffset),Li.after=e=>Li(e.parentNode,_i(e)+1),Li.before=e=>Li(e.parentNode,_i(e)),Li.isAbove=(e,t)=>
vendor: 10,346 bytes, line 5168
5168Mt(le(t.getClientRects()),de(e.getClientRects()),ui).getOr(!1),Li.isBelow=(e,t)=>Mt(de(t.getClientRects()),le(e.getClientRects()),mi).getOr(!1),Li.isAtStart=e=>!!e&&e.isAtStart(),Li.isAtEnd=e=>!!e&&e.isAtEnd(),Li.isTextPosition=e=>!!e&&Jo(e.container()),Li.isElementPosition=e=>!Li.isTextPosition(e);const Mi=(e,t)=>{Jo(t)&&0===t.data.length&&e.remove(t)},Ii=(e,t,n)=>{or(n)?((e,t,n)=>{const o=I.from(n.firstChild),r=I.from(n.lastChild);t.insertNode(n),o.each((t=>Mi(e,t.previousSibling))),r.each((t=>Mi(e,t.nextSibling)))})(e,t,n):((e,t,n)=>{t.insertNode(n),Mi(e,n.previousSibling),Mi(e,n.nextSibling)})(e,t,n)},Fi=Jo,Ui=Go,zi=Oa.nodeIndex,ji=e=>{const t=e.parentNode;return Ui(t)?ji(t):t},Hi=e=>e?Te(e.childNodes,((e,t)=>(Ui(t)&&"BR"!==t.nodeName?e=e.concat(Hi(t)):e.push(t),e)),[]):[],$i=e=>t=>e===t,Vi=e=>(Fi(e)?"text()":e.nodeName.toLowerCase())+"["+(e=>{let t,n;t=Hi(ji(e)),n=Be(t,$i(e),e),t=t.slice(0,n+1);const o=Te(t,((e,n,o)=>(Fi(n)&&Fi(t[o-1])&&e++,e)),0);return t=Oe(t,qo([e.nodeName])),n=Be(t,$i(e),e),n-o})(e)+"]",qi=(e,t)=>{let n,o=[],r=t.container(),s=t.offset();if(Fi(r))n=((e,t)=>{let n=e;for(;(n=n.previousSibling)&&Fi(n);)t+=n.data.length;return t})(r,s);else{const e=r.childNodes;s>=e.length?(n="after",s=e.length-1):n="before",r=e[s]}o.push(Vi(r));let a=((e,t,n)=>{const o=[];for(let n=t.parentNode;n&&n!==e;n=n.parentNode)o.push(n);return o})(e,r);return a=Oe(a,T(Go)),o=o.concat(Ae(a,(e=>Vi(e)))),o.reverse().join("/")+","+n},Wi=(e,t)=>{if(!t)return null;const n=t.split(","),o=n[0].split("/"),r=n.length>1?n[1]:"before",s=Te(o,((e,t)=>{const n=/([\w\-\(\)]+)\[([0-9]+)\]/.exec(t);return n?("text()"===n[1]&&(n[1]="#text"),((e,t,n)=>{let o=Hi(e);return o=Oe(o,((e,t)=>!Fi(e)||!Fi(o[t-1]))),o=Oe(o,qo([t])),o[n]})(e,n[1],parseInt(n[2],10))):null}),e);if(!s)return null;if(!Fi(s)&&s.parentNode){let e;return e="after"===r?zi(s)+1:zi(s),Li(s.parentNode,e)}return((e,t)=>{let n=e,o=0;for(;Fi(n);){const r=n.data.length;if(t>=o&&t<=o+r){e=n,t-=o;break}if(!Fi(n.nextSibling)){e=n,t=r;break}o+=r,n=n.nextSibling}return Fi(e)&&t>e.data.length&&(t=e.data.length),Li(e,t)})(s,parseInt(r,10))},Ki=ir,Gi=(e,t,n,o,r)=>{const s=r?o.startContainer:o.endContainer;let a=r?o.startOffset:o.endOffset;const i=[],l=e.getRoot();if(Jo(s))i.push(n?((e,t,n)=>{let o=e(t.data.slice(0,n)).length;for(let n=t.previousSibling;n&&Jo(n);n=n.previousSibling)o+=e(n.data).length;return o})(t,s,a):a);else{let t=0;const o=s.childNodes;a>=o.length&&o.length&&(t=1,a=Math.max(0,o.length-1)),i.push(e.nodeIndex(o[a],n)+t)}for(let t=s;t&&t!==l;t=t.parentNode)i.push(e.nodeIndex(t,n));return i},Yi=(e,t,n)=>{let o=0;return Dt.each(e.select(t),(e=>"all"===e.getAttribute("data-mce-bogus")?void 0:e!==n&&void o++)),o},Xi=(e,t)=>{let n=t?e.startContainer:e.endContainer,o=t?e.startOffset:e.endOffset;if($o(n)&&"TR"===n.nodeName){const r=n.childNodes;n=r[Math.min(t?o:o-1,r.length-1)],n&&(o=t?0:n.childNodes.length,t?e.setStart(n,o):e.setEnd(n,o))}},Qi=e=>(Xi(e,!0),Xi(e,!1),e),Ji=(e,t)=>{if($o(e)&&(e=pi(e,t),Ki(e)))return e;if($r(e)){Jo(e)&&jr(e)&&(e=e.parentNode);let t=e.previousSibling;if(Ki(t))return t;if(t=e.nextSibling,Ki(t))return t}},Zi=(e,t,n)=>{const o=n.getNode(),r=n.getRng();if("IMG"===o.nodeName||Ki(o)){const e=o.nodeName;return{name:e,index:Yi(n.dom,e,o)}}const s=(e=>Ji(e.startContainer,e.startOffset)||Ji(e.endContainer,e.endOffset))(r);if(s){const e=s.tagName;return{name:e,index:Yi(n.dom,e,s)}}return((e,t,n,o)=>{const r=t.dom,s=Gi(r,e,n,o,!0),a=t.isForward(),i=Xr(o)?{isFakeCaret:!0}:{};return t.isCollapsed()?{start:s,forward:a,...i}:{start:s,end:Gi(r,e,n,o,!1),forward:a,...i}})(e,n,t,r)},el=(e,t,n)=>{const o={"data-mce-type":"bookmark",id:t,style:"overflow:hidden;line-height:0px"};return n?e.create("span",o,""):e.create("span",o)},tl=(e,t)=>{const n=e.dom;let o=e.getRng();const r=n.uniqueId(),s=e.isCollapsed(),a=e.getNode(),i=a.nodeName,l=e.isForward();if("IMG"===i)return{name:i,index:Yi(n,i,a)};const d=Qi(o.cloneRange());if(!s){d.collapse(!1);const e=el(n,r+"_end",t);Ii(n,d,e)}o=Qi(o),o.collapse(!0);const c=el(n,r+"_start",t);return Ii(n,o,c),e.moveToBookmark({id:r,keep:!0,forward:l}),{id:r,forward:l}},nl=O(Zi,R,!0),ol=e=>{const t=t=>t(e),n=N(e),o=()=>r,r={tag:!0,inner:e,fold:(t,n)=>n(e),isValue:M,isError:L,map:t=>sl.value(t(e)),mapError:o,bind:t,exists:t,forall:t,getOr:n,or:o,getOrThunk:n,orThunk:o,getOrDie:n,each:t=>{t(e)},toOptional:()=>I.some(e)};return r},rl=e=>{const t=()=>n,n={tag:!1,inner:e,fold:(t,n)=>t(e),isValue:L,isError:M,map:t,mapError:t=>sl.error(t(e)),bind:t,exists:L,forall:M,getOr:R,or:R,getOrThunk:D,orThunk:D,getOrDie:B(String(e)),each:E,toOptional:I.none};return n},sl={value:ol,error:rl,fromOption:(e,t)=>e.fold((()=>rl(t)),ol)},al=e=>{if(!p(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],n={};return q(e,((o,r)=>{const s=me(o);if(1!==s.length)throw new Error("one and only one name per case");const a=s[0],i=o[a];if(void 0!==n[a])throw new Error("duplicate key detected:"+a);if("cata"===a)throw new Error("cannot have a case named cata (sorry)");if(!p(i))throw new Error("case arguments must be an array");t.push(a),n[a]=(...n)=>{const o=n.length;if(o!==i.length)throw new Error("Wrong number of arguments to case "+a+". Expected "+i.length+" ("+i+"), got "+o);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,n)},match:e=>{const o=me(e);if(t.length!==o.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+o.join(","));if(!ne(t,(e=>H(o,e))))throw new Error("Not all branches were specified when using match. Specified: "+o.join(", ")+"\nRequired: "+t.join(", "));return e[a].apply(null,n)},log:e=>{console.log(e,{constructors:t,constructor:a,params:n})}}}})),n};al([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);const il=e=>"inline-command"===e.type||"inline-format"===e.type,ll=e=>"block-command"===e.type||"block-format"===e.type,dl=e=>{const t=t=>sl.error({message:t,pattern:e}),n=(n,o,r)=>{if(void 0!==e.format){let r;if(p(e.format)){if(!ne(e.format,m))return t(n+" pattern has non-string items in the `format` array");r=e.format}else{if(!m(e.format))return t(n+" pattern has non-string `format` parameter");r=[e.format]}return sl.value(o(r))}return void 0!==e.cmd?m(e.cmd)?sl.value(r(e.cmd,e.value)):t(n+" pattern has non-string `cmd` parameter"):t(n+" pattern is missing both `format` and `cmd` parameters")};if(!f(e))return t("Raw pattern is not an object");if(!m(e.start))return t("Raw pattern is missing `start` parameter");if(void 0!==e.end){if(!m(e.end))return t("Inline pattern has non-string `end` parameter");if(0===e.start.length&&0===e.end.length)return t("Inline pattern has empty `start` and `end` parameters");let o=e.start,r=e.end;return 0===r.length&&(r=o,o=""),n("Inline",(e=>({type:"inline-format",start:o,end:r,format:e})),((e,t)=>({type:"inline-command",start:o,end:r,cmd:e,value:t})))}return void 0!==e.replacement?m(e.replacement)?0===e.start.length?t("Replacement pattern has empty `start` parameter"):sl.value({type:"inline-command",start:"",end:e.start,cmd:"mceInsertContent",value:e.replacement}):t("Replacement pattern has non-string `replacement` parameter"):0===e.start.length?t("Block pattern has empty `start` parameter"):n("Block",(t=>({type:"block-format",start:e.start,format:t[0]})),((t,n)=>({type:"block-command",start:e.start,cmd:t,value:n})))},cl=e=>G(e,ll),ul=e=>G(e,il),ml=e=>{const t=(e=>{const t=[],n=[];return q(e,(e=>{e.fold((e=>{t.push(e)}),(e=>{n.push(e)}))})),{errors:t,values:n}})(V(e,dl));return q(t.errors,(e=>console.error(e.message,e.pattern))),t.values},fl=xt().deviceType,gl=fl.isTouch(),pl=Oa.DOM,hl=e=>u(e,RegExp),bl=e=>t=>t.options.get(e),vl=e=>m(e)||f(e),yl=(e,t="")=>n=>{const o=m(n);if(o){if(-1!==n.indexOf("=")){const r=(e=>{const t=e.indexOf("=")>0?e.split(/[;,](?![^=;,]*(?:[;,]|$))/):e.split(",");return X(t,((e,t)=>{const n=t.split("="),o=n[0],r=n.length>1?n[1]:o;return e[qe(o)]=qe(r),e}),{})})(n);return{value:xe(r,e.id).getOr(t),valid:o}}return{value:n,valid:o}}return{valid:!1,message:"Must be a string."}},Cl=bl("iframe_attrs"),wl=bl("doctype"),xl=bl("document_base_url"),kl=bl("body_id"),El=bl("body_class"),Sl=bl("content_security_policy"),_l=bl("br_in_pre"),Nl=bl("forced_root_block"),Rl=bl("forced_root_block_attrs"),Al=bl("newline_behavior"),Ol=bl("br_newline_selector"),Tl=bl("no_newline_selector"),Bl=bl("keep_styles"),Dl=bl("end_container_on_empty_block"),Pl=bl("automatic_uploads"),Ll=bl("images_reuse_filename"),Ml=bl("images_replace_blob_uris"),Il=bl("icons"),Fl=bl("icons_url"),Ul=bl("images_upload_url"),zl=bl("images_upload_base_path"),jl=bl("images_upload_credentials"),Hl=bl("images_upload_handler"),$l=bl("content_css_cors"),Vl=bl("referrer_policy"),ql=bl("language"),Wl=bl("language_url"),Kl=bl("indent_use_margin"),Gl=bl("indentation"),Yl=bl("content_css"),Xl=bl("content_style"),Ql=bl("font_css"),Jl=bl("directionality"),Zl=bl("inline_boundaries_selector"),ed=bl("object_resizing"),td=bl("resize_img_proportional"),nd=bl("placeholder"),od=bl("event_root"),rd=bl("service_message"),sd=bl("theme"),ad=bl("theme_url"),id=bl("model"),ld=bl("model_url"),dd=bl("inline_boundaries"),cd=bl("formats"),ud=bl("preview_styles"),md=bl("format_empty_lines"),fd=bl("format_noneditable_selector"),gd=bl("custom_ui_selector"),pd=bl("inline"),hd=bl("hidden_input"),bd=bl("submit_patch"),vd=bl("add_form_submit_trigger"),yd=bl("add_unload_trigger"),Cd=bl("custom_undo_redo_levels"),wd=bl("disable_nodechange"),xd=bl("readonly"),kd=bl("editable_root"),Ed=bl("content_css_cors"),Sd=bl("plugins"),_d=bl("external_plugins"),Nd=bl("block_unsupported_drop"),Rd=bl("visual"),Ad=bl("visual_table_class"),Od=bl("visual_anchor_class"),Td=bl("iframe_aria_text"),Bd=bl("setup"),Dd=bl("init_instance_callback"),Pd=bl("urlconverter_callback"),Ld=bl("auto_focus"),Md=bl("browser_spellcheck"),Id=bl("protect"),Fd=bl("paste_block_drop"),Ud=bl("paste_data_images"),zd=bl("paste_preprocess"),jd=bl("paste_postprocess"),Hd=bl("newdocument_content"),$d=bl("paste_webkit_styles"),Vd=bl("paste_remove_styles_if_webkit"),qd=bl("paste_merge_formats"),Wd=bl("smart_paste"),Kd=bl("paste_as_text"),Gd=bl("paste_tab_space
5168s"),Yd=bl("allow_html_data_urls"),Xd=bl("text_patterns"),Qd=bl("text_patterns_lookup"),Jd=bl("noneditable_class"),Zd=bl("editable_class"),ec=bl("noneditable_regexp"),tc=bl("preserve_cdata"),nc=bl("highlight_on_focus"),oc=bl("xss_sanitization"),rc=bl("init_content_sync"),sc=e=>Dt.explode(e.options.get("images_file_types")),ac=bl("table_tab_navigation"),ic=bl("details_initial_state"),lc=bl("details_serialized_state"),dc=$o,cc=Jo,uc=e=>{const t=e.parentNode;t&&t.removeChild(e)},mc=e=>{const t=Fr(e);return{count:e.length-t.length,text:t}},fc=e=>{let t;for(;-1!==(t=e.data.lastIndexOf(Mr));)e.deleteData(t,1)},gc=(e,t)=>(hc(e),t),pc=(e,t)=>Li.isTextPosition(t)?((e,t)=>cc(e)&&t.container()===e?((e,t)=>{const n=mc(e.data.substr(0,t.offset())),o=mc(e.data.substr(t.offset()));return(n.text+o.text).length>0?(fc(e),Li(e,t.offset()-n.count)):t})(e,t):gc(e,t))(e,t):((e,t)=>t.container()===e.parentNode?((e,t)=>{const n=t.container(),o=((e,t)=>{const n=j(e,t);return-1===n?I.none():I.some(n)})(ce(n.childNodes),e).map((e=>e<t.offset()?Li(n,t.offset()-1):t)).getOr(t);return hc(e),o})(e,t):gc(e,t))(e,t),hc=e=>{dc(e)&&$r(e)&&(Vr(e)?e.removeAttribute("data-mce-caret"):uc(e)),cc(e)&&(fc(e),0===e.data.length&&uc(e))},bc=ir,vc=cr,yc=lr,Cc=(e,t,n)=>{const o=di(t.getBoundingClientRect(),n);let r,s;if("BODY"===e.tagName){const t=e.ownerDocument.documentElement;r=e.scrollLeft||t.scrollLeft,s=e.scrollTop||t.scrollTop}else{const t=e.getBoundingClientRect();r=e.scrollLeft-t.left,s=e.scrollTop-t.top}o.left+=r,o.right+=r,o.top+=s,o.bottom+=s,o.width=1;let a=t.offsetWidth-t.clientWidth;return a>0&&(n&&(a*=-1),o.left+=a,o.right+=a),o},wc=(e,t,n,o)=>{const r=za();let s,a;const i=Nl(e),l=e.dom,d=()=>{(e=>{var t,n;const o=Fo(yn(e),"*[contentEditable=false],video,audio,embed,object");for(let e=0;e<o.length;e++){const r=o[e].dom;let s=r.previousSibling;if(Gr(s)){const e=s.data;1===e.length?null===(t=s.parentNode)||void 0===t||t.removeChild(s):s.deleteData(e.length-1,1)}s=r.nextSibling,Kr(s)&&(1===s.data.length?null===(n=s.parentNode)||void 0===n||n.removeChild(s):s.deleteData(0,1))}})(t),a&&(hc(a),a=null),r.on((e=>{l.remove(e.caret),r.clear()})),s&&(clearInterval(s),s=void 0)};return{show:(e,c)=>{let u;if(d(),yc(c))return null;if(!n(c))return a=((e,t)=>{var n;const o=(null!==(n=e.ownerDocument)&&void 0!==n?n:document).createTextNode(Mr),r=e.parentNode;if(t){const t=e.previousSibling;if(zr(t)){if($r(t))return t;if(Gr(t))return t.splitText(t.data.length-1)}null==r||r.insertBefore(o,e)}else{const t=e.nextSibling;if(zr(t)){if($r(t))return t;if(Kr(t))return t.splitText(1),t}e.nextSibling?null==r||r.insertBefore(o,e.nextSibling):null==r||r.appendChild(o)}return o})(c,e),u=c.ownerDocument.createRange(),kc(a.nextSibling)?(u.setStart(a,0),u.setEnd(a,0)):(u.setStart(a,1),u.setEnd(a,1)),u;{const n=((e,t,n)=>{var o;const r=(null!==(o=t.ownerDocument)&&void 0!==o?o:document).createElement(e);r.setAttribute("data-mce-caret",n?"before":"after"),r.setAttribute("data-mce-bogus","all"),r.appendChild(Dr().dom);const s=t.parentNode;return n?null==s||s.insertBefore(r,t):t.nextSibling?null==s||s.insertBefore(r,t.nextSibling):null==s||s.appendChild(r),r})(i,c,e),d=Cc(t,c,e);l.setStyle(n,"top",d.top),a=n;const m=l.create("div",{class:"mce-visual-caret","data-mce-bogus":"all"});l.setStyles(m,{...d}),l.add(t,m),r.set({caret:m,element:c,before:e}),e&&l.addClass(m,"mce-visual-caret-before"),s=setInterval((()=>{r.on((e=>{o()?l.toggleClass(e.caret,"mce-visual-caret-hidden"):l.addClass(e.caret,"mce-visual-caret-hidden")}))}),500),u=c.ownerDocument.createRange(),u.setStart(n,0),u.setEnd(n,0)}return u},hide:d,getCss:()=>".mce-visual-caret {position: absolute;background-color: black;background-color: currentcolor;}.mce-visual-caret-hidden {display: none;}*[data-mce-caret] {position: absolute;left: -1000px;right: auto;top: 0;margin: 0;padding: 0;}",reposition:()=>{r.on((e=>{const n=Cc(t,e.element,e.before);l.setStyles(e.caret,{...n})}))},destroy:()=>clearInterval(s)}},xc=()=>At.browser.isFirefox(),kc=e=>bc(e)||vc(e),Ec=e=>(kc(e)||Yo(e)&&xc())&&On(yn(e)).exists(no),Sc=ar,_c=ir,Nc=cr,Rc=Wo("display","block table table-cell table-caption list-item"),Ac=$r,Oc=jr,Tc=$o,Bc=Jo,Dc=ss,Pc=e=>e>0,Lc=e=>e<0,Mc=(e,t)=>{let n;for(;n=e(t);)if(!Oc(n))return n;return null},Ic=(e,t,n,o,r)=>{const s=new zo(e,o),a=_c(e)||Oc(e);let i;
vendor: 98,330 bytes, line 5168
5168if(Lc(t)){if(a&&(i=Mc(s.prev.bind(s),!0),n(i)))return i;for(;i=Mc(s.prev.bind(s),r);)if(n(i))return i}if(Pc(t)){if(a&&(i=Mc(s.next.bind(s),!0),n(i)))return i;for(;i=Mc(s.next.bind(s),r);)if(n(i))return i}return null},Fc=(e,t)=>{for(;e&&e!==t;){if(Rc(e))return e;e=e.parentNode}return null},Uc=(e,t,n)=>Fc(e.container(),n)===Fc(t.container(),n),zc=(e,t)=>{if(!t)return I.none();const n=t.container(),o=t.offset();return Tc(n)?I.from(n.childNodes[o+e]):I.none()},jc=(e,t)=>{var n;const o=(null!==(n=t.ownerDocument)&&void 0!==n?n:document).createRange();return e?(o.setStartBefore(t),o.setEndBefore(t)):(o.setStartAfter(t),o.setEndAfter(t)),o},Hc=(e,t,n)=>Fc(t,e)===Fc(n,e),$c=(e,t,n)=>{const o=e?"previousSibling":"nextSibling";let r=n;for(;r&&r!==t;){let e=r[o];if(e&&Ac(e)&&(e=e[o]),_c(e)||Nc(e)){if(Hc(t,e,r))return e;break}if(Dc(e))break;r=r.parentNode}return null},Vc=O(jc,!0),qc=O(jc,!1),Wc=(e,t,n)=>{let o;const r=O($c,!0,t),s=O($c,!1,t),a=n.startContainer,i=n.startOffset;if(jr(a)){const e=Bc(a)?a.parentNode:a,t=e.getAttribute("data-mce-caret");if("before"===t&&(o=e.nextSibling,Ec(o)))return Vc(o);if("after"===t&&(o=e.previousSibling,Ec(o)))return qc(o)}if(!n.collapsed)return n;if(Jo(a)){if(Ac(a)){if(1===e){if(o=s(a),o)return Vc(o);if(o=r(a),o)return qc(o)}if(-1===e){if(o=r(a),o)return qc(o);if(o=s(a),o)return Vc(o)}return n}if(Gr(a)&&i>=a.data.length-1)return 1===e&&(o=s(a),o)?Vc(o):n;if(Kr(a)&&i<=1)return-1===e&&(o=r(a),o)?qc(o):n;if(i===a.data.length)return o=s(a),o?Vc(o):n;if(0===i)return o=r(a),o?qc(o):n}return n},Kc=(e,t)=>zc(e?0:-1,t).filter(_c),Gc=(e,t,n)=>{const o=Wc(e,t,n);return-1===e?Li.fromRangeStart(o):Li.fromRangeEnd(o)},Yc=e=>I.from(e.getNode()).map(yn),Xc=(e,t)=>{let n=t;for(;n=e(n);)if(n.isVisible())return n;return n},Qc=(e,t)=>{const n=Uc(e,t);return!(n||!rr(e.getNode()))||n};var Jc;!function(e){e[e.Backwards=-1]="Backwards",e[e.Forwards=1]="Forwards"}(Jc||(Jc={}));const Zc=ir,eu=Jo,tu=$o,nu=rr,ou=ss,ru=e=>ns(e)||(e=>!!as(e)&&!X(ce(e.getElementsByTagName("*")),((e,t)=>e||Qr(t)),!1))(e),su=is,au=(e,t)=>e.hasChildNodes()&&t<e.childNodes.length?e.childNodes[t]:null,iu=(e,t)=>{if(Pc(e)){if(ou(t.previousSibling)&&!eu(t.previousSibling))return Li.before(t);if(eu(t))return Li(t,0)}if(Lc(e)){if(ou(t.nextSibling)&&!eu(t.nextSibling))return Li.after(t);if(eu(t))return Li(t,t.data.length)}return Lc(e)?nu(t)?Li.before(t):Li.after(t):Li.before(t)},lu=(e,t,n)=>{let o,r,s,a;if(!tu(n)||!t)return null;if(t.isEqual(Li.after(n))&&n.lastChild){if(a=Li.after(n.lastChild),Lc(e)&&ou(n.lastChild)&&tu(n.lastChild))return nu(n.lastChild)?Li.before(n.lastChild):a}else a=t;const i=a.container();let l=a.offset();if(eu(i)){if(Lc(e)&&l>0)return Li(i,--l);if(Pc(e)&&l<i.length)return Li(i,++l);o=i}else{if(Lc(e)&&l>0&&(r=au(i,l-1),ou(r)))return!ru(r)&&(s=Ic(r,e,su,r),s)?eu(s)?Li(s,s.data.length):Li.after(s):eu(r)?Li(r,r.data.length):Li.before(r);if(Pc(e)&&l<i.childNodes.length&&(r=au(i,l),ou(r)))return nu(r)?((e,t)=>{const n=t.nextSibling;return n&&ou(n)?eu(n)?Li(n,0):Li.before(n):lu(Jc.Forwards,Li.after(t),e)})(n,r):!ru(r)&&(s=Ic(r,e,su,r),s)?eu(s)?Li(s,0):Li.before(s):eu(r)?Li(r,0):Li.after(r);o=r||a.getNode()}if(o&&(Pc(e)&&a.isAtEnd()||Lc(e)&&a.isAtStart())&&(o=Ic(o,e,M,n,!0),su(o,n)))return iu(e,o);r=o?Ic(o,e,su,n):o;const d=De(G(((e,t)=>{const n=[];let o=e;for(;o&&o!==t;)n.push(o),o=o.parentNode;return n})(i,n),Zc));return!d||r&&d.contains(r)?r?iu(e,r):null:(a=Pc(e)?Li.after(d):Li.before(d),a)},du=e=>({next:t=>lu(Jc.Forwards,t,e),prev:t=>lu(Jc.Backwards,t,e)}),cu=e=>Li.isTextPosition(e)?0===e.offset():ss(e.getNode()),uu=e=>{if(Li.isTextPosition(e)){const t=e.container();return e.offset()===t.data.length}return ss(e.getNode(!0))},mu=(e,t)=>!Li.isTextPosition(e)&&!Li.isTextPosition(t)&&e.getNode()===t.getNode(!0),fu=(e,t,n)=>{const o=du(t);return I.from(e?o.next(n):o.prev(n))},gu=(e,t,n)=>fu(e,t,n).bind((o=>Uc(n,o,t)&&((e,t,n)=>{return e?!mu(t,n)&&(o=t,!(!Li.isTextPosition(o)&&rr(o.getNode())))&&uu(t)&&cu(n):!mu(n,t)&&cu(t)&&uu(n);var o})(e,n,o)?fu(e,t,o):I.some(o))),pu=(e,t,n,o)=>gu(e,t,n).bind((n=>o(n)?pu(e,t,n,o):I.some(n))),hu=(e,t)=>{const n=e?t.firstChild:t.lastChild;return Jo(n)?I.some(Li(n,e?0:n.data.length)):n?ss(n)?I.some(e?Li.before(n):rr(o=n)?Li.before(o):Li.after(o)):((e,t,n)=>{const o=e?Li.before(n):Li.after(n);return fu(e,t,o)})(e,t,n):I.none();var o},bu=O(fu,!0),vu=O(fu,!1),yu=O(hu,!0),Cu=O(hu,!1),wu="_mce_caret",xu=e=>$o(e)&&e.id===wu,ku=(e,t)=>{let n=t;for(;n&&n!==e;){if(xu(n))return n;n=n.parentNode}return null},Eu=e=>ke(e,"name"),Su=e=>Dt.isArray(e.start),_u=e=>!(!Eu(e)&&b(e.forward))||e.forward,Nu=(e,t)=>($o(t)&&e.isBlock(t)&&!t.innerHTML&&(t.innerHTML='<br data-mce-bogus="1" />'),t),Ru=(e,t)=>Cu(e).fold(L,(e=>(t.setStart(e.container(),e.offset()),t.setEnd(e.container(),e.offset()),!0))),Au=(e,t,n)=>!(!(e=>!e.hasChildNodes())(t)||!ku(e,t)||(((e,t)=>{var n;const o=(null!==(n=e.ownerDocument)&&void 0!==n?n:document).createTextNode(Mr);e.appendChild(o),t.setStart(o,0),t.setEnd(o,0)})(t,n),0)),Ou=(e,t,n,o)=>{const r=n[t?"start":"end"],s=e.getRoot();if(r){let e=s,n=r[0];for(let t=r.length-1;e&&t>=1;t--){const n=e.childNodes;if(Au(s,e,o))return!0;if(r[t]>n.length-1)return!!Au(s,e,o)||Ru(e,o);e=n[r[t]]}Jo(e)&&(n=Math.min(r[0],e.data.length)),$o(e)&&(n=Math.min(r[0],e.childNodes.length)),t?o.setStart(e,n):o.setEnd(e,n)}return!0},Tu=e=>Jo(e)&&e.data.length>0,Bu=(e,t,n)=>{const o=e.get(n.id+"_"+t),r=null==o?void 0:o.parentNode,s=n.keep;if(o&&r){let a,i;if("start"===t?s?o.hasChildNodes()?(a=o.firstChild,i=1):Tu(o.nextSibling)?(a=o.nextSibling,i=0):Tu(o.previousSibling)?(a=o.previousSibling,i=o.previousSibling.data.length):(a=r,i=e.nodeIndex(o)+1):(a=r,i=e.nodeIndex(o)):s?o.hasChildNodes()?(a=o.firstChild,i=1):Tu(o.previousSibling)?(a=o.previousSibling,i=o.previousSibling.data.length):(a=r,i=e.nodeIndex(o)):(a=r,i=e.nodeIndex(o)),!s){const r=o.previousSibling,s=o.nextSibling;let l;for(Dt.each(Dt.grep(o.childNodes),(e=>{Jo(e)&&(e.data=e.data.replace(/\uFEFF/g,""))}));l=e.get(n.id+"_"+t);)e.remove(l,!0);if(Jo(s)&&Jo(r)&&!At.browser.isOpera()){const t=r.data.length;r.appendData(s.data),e.remove(s),a=r,i=t}}return I.some(Li(a,i))}return I.none()},Du=(e,t,n)=>((e,t,n=!1)=>2===t?Zi(Fr,n,e):3===t?(e=>{const t=e.getRng();return{start:qi(e.dom.getRoot(),Li.fromRangeStart(t)),end:qi(e.dom.getRoot(),Li.fromRangeEnd(t)),forward:e.isForward()}})(e):t?(e=>({rng:e.getRng(),forward:e.isForward()}))(e):tl(e,!1))(e,t,n),Pu=(e,t)=>{((e,t)=>{const n=e.dom;if(t){if(Su(t))return((e,t)=>{const n=e.createRng();return Ou(e,!0,t,n)&&Ou(e,!1,t,n)?I.some({range:n,forward:_u(t)}):I.none()})(n,t);if((e=>m(e.start))(t))return((e,t)=>{const n=I.from(Wi(e.getRoot(),t.start)),o=I.from(Wi(e.getRoot(),t.end));return Mt(n,o,((n,o)=>{const r=e.createRng();return r.setStart(n.container(),n.offset()),r.setEnd(o.container(),o.offset()),{range:r,forward:_u(t)}}))})(n,t);if((e=>ke(e,"id"))(t))return((e,t)=>{const n=Bu(e,"start",t),o=Bu(e,"end",t);return Mt(n,o.or(n),((n,o)=>{const r=e.createRng();return r.setStart(Nu(e,n.container()),n.offset()),r.setEnd(Nu(e,o.container()),o.offset()),{range:r,forward:_u(t)}}))})(n,t);if(Eu(t))return((e,t)=>I.from(e.select(t.name)[t.index]).map((t=>{const n=e.createRng();return n.selectNode(t),{range:n,forward:!0}})))(n,t);if((e=>ke(e,"rng"))(t))return I.some({range:t.rng,forward:_u(t)})}return I.none()})(e,t).each((({range:t,forward:n})=>{e.setRng(t,n)}))},Lu=e=>$o(e)&&"SPAN"===e.tagName&&"bookmark"===e.getAttribute("data-mce-type"),Mu=(Iu=pr,e=>Iu===e);var Iu;const Fu=e=>""!==e&&-1!==" \f\n\r\t\v".indexOf(e),Uu=e=>!Fu(e)&&!Mu(e)&&!hr(e),zu=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},ju=e=>(e=>{return{value:(t=e,ze(t,"#").toUpperCase())};var t})(zu(e.red)+zu(e.green)+zu(e.blue)),Hu=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,$u=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,Vu=(e,t,n,o)=>({red:e,green:t,blue:n,alpha:o}),qu=(e,t,n,o)=>{const r=parseInt(e,10),s=parseInt(t,10),a=parseInt(n,10),i=parseFloat(o);return Vu(r,s,a,i)},Wu=e=>(e=>{if("transparent"===e)return I.some(Vu(0,0,0,0));const t=Hu.exec(e);if(null!==t)return I.some(qu(t[1],t[2],t[3],"1"));const n=$u.exec(e);return null!==n?I.some(qu(n[1],n[2],n[3],n[4])):I.none()})(e).map(ju).map((e=>"#"+e.value)).getOr(e),Ku=e=>{const t=[];if(e)for(let n=0;n<e.rangeCount;n++)t.push(e.getRangeAt(n));return t},Gu=(e,t)=>{const n=Fo(t,"td[data-mce-selected],th[data-mce-selected]");return n.length>0?n:(e=>G((e=>te(e,(e=>{const t=gi(e);return t?[yn(t)]:[]})))(e),Ar))(e)},Yu=e=>Gu(Ku(e.selection.getSel()),yn(e.getBody())),Xu=(e,t)=>Zn(e,"table",t),Qu=e=>Fn(e).fold(N([e]),(t=>[e].concat(Qu(t)))),Ju=e=>Un(e).fold(N([e]),(t=>"br"===Ht(t)?Bn(t).map((t=>[e].concat(Ju(t)))).getOr([]):[e].concat(Ju(t)))),Zu=(e,t)=>Mt((e=>{const t=e.startContainer,n=e.startOffset;return Jo(t)?0===n?I.some(yn(t)):I.none():I.from(t.childNodes[n]).map(yn)})(t),(e=>{const t=e.endContainer,n=e.endOffset;return Jo(t)?n===t.data.length?I.some(yn(t)):I.none():I.from(t.childNodes[n-1]).map(yn)})(t),((t,n)=>{const o=J(Qu(e),O(En,t)),r=J(Ju(e),O(En,n));return o.isSome()&&r.isSome()})).getOr(!1),em=(e,t,n,o)=>{const r=n,s=new zo(n,r),a=ye(e.schema.getMoveCaretBeforeOnEnterElements(),((e,t)=>!H(["td","th","table"],t.toLowerCase())));let i=n;do{if(Jo(i)&&0!==Dt.trim(i.data).length)return void(o?t.setStart(i,0):t.setEnd(i,i.data.length));if(a[i.nodeName])return void(o?t.setStartBefore(i):"BR"===i.nodeName?t.setEndBefore(i):t.setEndAfter(i))}while(i=o?s.next():s.prev());"BODY"===r.nodeName&&(o?t.setStart(r,0):t.setEnd(r,r.childNodes.length))},tm=e=>{const t=e.selection.getSel();return C(t)&&t.rangeCount>0},nm=(e,t)=>{const n=Yu(e);n.length>0?q(n,(n=>{const o=n.dom,r=e.dom.createRng();r.setStartBefore(o),r.setEndAfter(o),t(r,!0)})):t(e.selection.getRng(),!1)},om=(e,t,n)=>{const o=tl(e,t);n(o),e.moveToBookmark(o)},rm=e=>x(null==e?void 0:e.nodeType),sm=e=>$o(e)&&!Lu(e)&&!xu(e)&&!Go(e),am=e=>!0===e.isContentEditable,im=(e,t,n)=>{const{selection:o,dom:r}=e,s=o.getNode(),a=ir(s);om(o,!0,(()=>{t()})),a&&ir(s)&&r.isChildOf(s,e.getBody())?e.selection.select(s):n(o.getStart())&&lm(r,o)},lm=(e,t)=>{var n,o;const r=t.getRng(),{startContainer:s,startOffset:a}=r;if(!((e,t)=>{if(sm(t)&&!/^(TD|TH)$/.test(t.nodeName)){const n=e.getAttrib(t,"data-mce-selected"),o=parseInt(n,10);return!isNaN(o)&&o>0}return!1})(e,t.getNode())&&$o(s)){const i=s.childNodes,l=e.getRoot();let d;if(a<i.length){const t=i[a];d=new zo(t,null!==(n=e.getParent(t,e.isBlock))&&void 0!==n?n:l)}else{const t=i[i.length-1];d=new zo(t,null!==(o=e.getParent(t,e.isBlock))&&void 0!==o?o:l),d.next(!0)}for(let n=d.current();n;n=d.next()){if("false"===e.getContentEditable(n))return;if(Jo(n)&&!mm(n))return r.setStart(n,0),void t.setRng(r)}}},dm=(e,t,n)=>{if(e){const o=t?"nextSibling":"previousSibling";for(e=n?e:e[o];e;e=e[o])if($o(e)||!mm(e))return e}},cm=(e,t)=>!!e.getTextBlockElements()[t.nodeName.toLowerCase()]||As(e,t),um=(e,t,n)=>e.schema.isValidChild(t,n),mm=(e,t=!1)=>{if(C(e)&&Jo(e)){const n=t?e.data.replace(/ /g,"\xa0"):e.data;return ds(n)}return!1},fm=(e,t)=>{const n=e.dom;return sm(t)&&"false"===n.getContentEditable(t)&&((e,t)=>{const n="[data-mce-cef-wrappable]",o=fd(e),r=Ye(o)?n:`${n},${o}`;return xn(yn(t),r)})(e,t)&&0===n.select('[contenteditable="true"]',t).length},gm=(e,t)=>w(e)?e(t):(C(t)&&(e=e.replace(/%(\w+)/g,((e,n)=>t[n]||e))),e),pm=(e,t)=>(t=t||"",e=""+((e=e||"").nodeName||e),t=""+(t.nodeName||t),e.toLowerCase()===t.toLowerCase()),hm=(e,t)=>{if(y(e))return null;{let n=String(e);return"color"!==t&&"backgroundColor"!==t||(n=Wu(n)),"fontWeight"===t&&700===e&&(n="bold"),"fontFamily"===t&&(n=n.replace(/[\'\"]/g,"").replace(/,\s+/g,",")),n}},bm=(e,t,n)=>{const o=e.getStyle(t,n);return hm(o,n)},vm=(e,t)=>{let n;return e.getParent(t,(t=>!!$o(t)&&(n=e.getStyle(t,"text-decoration"),!!n&&"none"!==n))),n},ym=(e,t,n)=>e.getParents(t,n,e.getRoot()),Cm=(e,t,n)=>{const o=e.formatter.get(t);return C(o)&&$(o,n)},wm=e=>Ee(e,"block"),xm=e=>Ee(e,"selector"),km=e=>Ee(e,"inline"),Em=e=>xm(e)&&!1!==e.expand&&!km(e),Sm=Lu,_m=ym,Nm=mm,Rm=cm,Am=(e,t)=>{let n=t;for(;n;){if($o(n)&&e.getContentEditable(n))return"false"===e.getContentEditable(n)?n:t;n=n.parentNode}return t},Om=(e,t,n,o)=>{const r=t.data;if(e){for(let e=n;e>0;e--)if(o(r.charAt(e-1)))return e}else for(let e=n;e<r.length;e++)if(o(r.charAt(e)))return e;return-1},Tm=(e,t,n)=>Om(e,t,n,(e=>Mu(e)||Fu(e))),Bm=(e,t,n)=>Om(e,t,n,Uu),Dm=(e,t,n,o,r,s)=>{let a;const i=e.getParent(n,e.isBlock)||t,l=(t,n,o)=>{const s=ai(e),l=r?s.backwards:s.forwards;return I.from(l(t,n,((e,t)=>Sm(e.parentNode)?-1:(a=e,o(r,e,t))),i))};return l(n,o,Tm).bind((e=>s?l(e.container,e.offset+(r?-1:0),Bm):I.some(e))).orThunk((()=>a?I.some({container:a,offset:r?0:a.length}):I.none()))},Pm=(e,t,n,o,r)=>{const s=o[r];Jo(o)&&Ye(o.data)&&s&&(o=s);const a=_m(e,o);for(let o=0;o<a.length;o++)for(let r=0;r<t.length;r++){const s=t[r];if((!C(s.collapsed)||s.collapsed===n.collapsed)&&xm(s)&&e.is(a[o],s.selector))return a[o]}return o},Lm=(e,t,n,o)=>{var r;let s=n;const a=e.getRoot(),i=t[0];if(wm(i)&&(s=i.wrapper?null:e.getParent(n,i.block,a)),!s){const t=null!==(r=e.getParent(n,"LI,TD,TH"))&&void 0!==r?r:a;s=e.getParent(Jo(n)?n.parentNode:n,(t=>t!==a&&Rm(e.schema,t)),t)}if(s&&wm(i)&&i.wrapper&&(s=_m(e,s,"ul,ol").reverse()[0]||s),!s)for(s=n;s&&s[o]&&!e.isBlock(s[o])&&(s=s[o],!pm(s,"br")););return s||n},Mm=(e,t,n,o)=>{const r=n.parentNode;return!C(n[o])&&(!(r!==t&&!y(r)&&!e.isBlock(r))||Mm(e,t,r,o))},Im=(e,t,n,o,r)=>{let s=n;const a=r?"previousSibling":"nextSibling",i=e.getRoot();if(Jo(n)&&!Nm(n)&&(r?o>0:o<n.data.length))return n;for(;s;){if(!t[0].block_expand&&e.isBlock(s))return s;for(let t=s[a];t;t=t[a]){const n=Jo(t)&&!Mm(e,i,t,a);if(!Sm(t)&&(!rr(l=t)||!l.getAttribute("data-mce-bogus")||l.nextSibling)&&!Nm(t,n))return s}if(s===i||s.parentNode===i){n=s;break}s=s.parentNode}var l;return n},Fm=e=>Sm(e.parentNode)||Sm(e),Um=(e,t,n,o=!1)=>{let{startContainer:r,startOffset:s,endContainer:a,endOffset:i}=t;const l=n[0];return $o(r)&&r.hasChildNodes()&&(r=pi(r,s),Jo(r)&&(s=0)),$o(a)&&a.hasChildNodes()&&(a=pi(a,t.collapsed?i:i-1),Jo(a)&&(i=a.data.length)),r=Am(e,r),a=Am(e,a),Fm(r)&&(r=Sm(r)?r:r.parentNode,r=t.collapsed?r.previousSibling||r:r.nextSibling||r,Jo(r)&&(s=t.collapsed?r.length:0)),Fm(a)&&(a=Sm(a)?a:a.parentNode,a=t.collapsed?a.nextSibling||a:a.previousSibling||a,Jo(a)&&(i=t.collapsed?0:a.length)),t.collapsed&&(Dm(e,e.getRoot(),r,s,!0,o).each((({container:e,offset:t})=>{r=e,s=t})),Dm(e,e.getRoot(),a,i,!1,o).each((({container:e,offset:t})=>{a=e,i=t}))),(km(l)||l.block_expand)&&(km(l)&&Jo(r)&&0!==s||(r=Im(e,n,r,s,!0)),km(l)&&Jo(a)&&i!==a.data.length||(a=Im(e,n,a,i,!1))),Em(l)&&(r=Pm(e,n,t,r,"previousSibling"),a=Pm(e,n,t,a,"nextSibling")),(wm(l)||xm(l))&&(r=Lm(e,n,r,"previousSibling"),a=Lm(e,n,a,"nextSibling"),wm(l)&&(e.isBlock(r)||(r=Im(e,n,r,s,!0)),e.isBlock(a)||(a=Im(e,n,a,i,!1)))),$o(r)&&r.parentNode&&(s=e.nodeIndex(r),r=r.parentNode),$o(a)&&a.parentNode&&(i=e.nodeIndex(a)+1,a=a.parentNode),{startContainer:r,startOffset:s,endContainer:a,endOffset:i}},zm=(e,t,n)=>{var o;const r=t.startOffset,s=pi(t.startContainer,r),a=t.endOffset,i=pi(t.endContainer,a-1),l=e=>{const t=e[0];Jo(t)&&t===s&&r>=t.data.length&&e.splice(0,1);const n=e[e.length-1];return 0===a&&e.length>0&&n===i&&Jo(n)&&e.splice(e.length-1,1),e},d=(e,t,n)=>{const o=[];for(;e&&e!==n;e=e[t])o.push(e);return o},c=(t,n)=>e.getParent(t,(e=>e.parentNode===n),n),u=(e,t,o)=>{const r=o?"nextSibling":"previousSibling";for(let s=e,a=s.parentNode;s&&s!==t;s=a){a=s.parentNode;const t=d(s===e?s:s[r],r);t.length&&(o||t.reverse(),n(l(t)))}};if(s===i)return n(l([s]));const m=null!==(o=e.findCommonAncestor(s,i))&&void 0!==o?o:e.getRoot();if(e.isChildOf(s,i))return u(s,m,!0);if(e.isChildOf(i,s))return u(i,m);const f=c(s,m)||s,g=c(i,m)||i;u(s,f,!0);const p=d(f===s?f:f.nextSibling,"nextSibling",g===i?g.nextSibling:g);p.length&&n(l(p)),u(i,g)},jm=['pre[class*=language-][contenteditable="false"]',"figure.image","div[data-ephox-embed-iri]","div.tiny-pageembed","div.mce-toc","div[data-mce-toc]"],Hm=(e,t,n,o,r,s)=>{const{uid:a=t,...i}=n;un(e,$a()),Jt(e,`${qa()}`,a),Jt(e,`${Va()}`,o);const{attributes:l={},classes:d=[]}=r(a,i);if(Zt(e,l),((e,t)=>{q(t,(t=>{un(e,t)}))})(e,d),s){d.length>0&&Jt(e,`${Ka()}`,d.join(","));const t=me(l);t.length>0&&Jt(e,`${Ga()}`,t.join(","))}},$m=(e,t,n,o,r)=>{const s=bn("span",e);return Hm(s,t,n,o,r,!1),s},Vm=(e,t,n,o,r,s)=>{const a=[],i=$m(e.getDoc(),n,s,o,r),l=za(),d=()=>{l.clear()},c=e=>{q(e,u)},u=t=>{switch(((e,t,n,o)=>An(t).fold((()=>"skipping"),(r=>"br"===o||(e=>Kt(e)&&vr(e)===Mr)(t)?"valid":(e=>Wt(e)&&gn(e,$a()))(t)?"existing":xu(t.dom)?"caret":$(jm,(e=>xn(t,e)))?"valid-block":um(e,n,o)&&um(e,Ht(r),n)?"valid":"invalid-child")))(e,t,"span",Ht(t))){case"invalid-child":{d();const e=Mn(t);c(e),d();break}case"valid-block":d(),Hm(t,n,s,o,r,!0);break;case"valid":{const e=l.get().getOrThunk((()=>{const e=oi(i);return a.push(e),l.set(e),e}));vo(t,e);break}}};return zm(e.dom,t,(e=>{d(),(e=>{const t=V(e,yn);c(t)})(e)})),a},qm=e=>{const t=(()=>{const e={};return{register:(t,n)=>{e[t]={name:t,settings:n}},lookup:t=>xe(e,t).map((e=>e.settings)),getNames:()=>me(e)}})();((e,t)=>{const n=Va(),o=e=>I.from(e.attr(n)).bind(t.lookup),r=e=>{var t,n;e.attr(qa(),null),e.attr(Va(),null),e.attr(Wa(),null);const o=I.from(e.attr(Ga())).map((e=>e.split(","))).getOr([]),r=I.from(e.attr(Ka())).map((e=>e.split(","))).getOr([]);q(o,(t=>e.attr(t,null)));const s=null!==(n=null===(t=e.attr("class"))||void 0===t?void 0:t.split(" "))&&void 0!==n?n:[],a=re(s,[$a()].concat(r));e.attr("class",a.length>0?a.join(" "):null),e.attr(Ka(),null),e.attr(Ga(),null)};e.serializer.addTempAttr(Wa()),e.serializer.addAttributeFilter(n,(e=>{for(const t of e)o(t).each((e=>{!1===e.persistent&&("span"===t.name?t.unwrap():r(t))}))}))})(e,t);const n=((e,t)=>{const n=Da({}),o=()=>({listeners:[],previous:za()}),r=(e,t)=>{s(e,(e=>(t(e),e)))},s=(e,t)=>{const r=n.get(),s=t(xe(r,e).getOrThunk(o));r[e]=s,n.set(r)},a=(t,n)=>{q(Ja(e,t),(e=>{n?Jt(e,Wa(),"true"):on(e,Wa())}))},i=Ha((()=>{const n=ae(t.getNames());q(n,(t=>{s(t,(n=>{const o=n.previous.get();return Xa(e,I.some(t)).fold((()=>{o.each((e=>{(e=>{r(e,(t=>{q(t.listeners,(t=>t(!1,e)))}))})(t),n.previous.clear(),a(e,!1)}))}),(({uid:e,name:t,elements:s})=>{Pt(o,e)||(o.each((e=>a(e,!1))),((e,t,n)=>{r(e,(o=>{q(o.listeners,(o=>o(!0,e,{uid:t,nodes:V(n,(e=>e.dom))})))}))})(t,e,s),n.previous.set(e),a(e,!0))})),{previous:n.previous,listeners:n.listeners}}))}))}),30);return e.on("remove",(()=>{i.cancel()})),e.on("NodeChange",(()=>{i.throttle()})),{addListener:(e,t)=>{s(e,(e=>({previous:e.previous,listeners:e.listeners.concat([t])})))}}})(e,t),o=Xt("span"),r=e=>{q(e,(e=>{o(e)?xo(e):(e=>{fn(e,$a()),on(e,`${qa()}`),on(e,`${Va()}`),on(e,`${Wa()}`);const t=tn(e,`${Ga()}`).map((e=>e.split(","))).getOr([]),n=tn(e,`${Ka()}`).map((e=>e.split(","))).getOr([]);var o;q(t,(t=>on(e,t))),o=e,q(n,(e=>{fn(o,e)})),on(e,`${Ka()}`),on(e,`${Ga()}`)})(e)}))};return{register:(e,n)=>{t.register(e,n)},annotate:(n,o)=>{t.lookup(n).each((t=>{((e,t,n,o)=>{e.undoManager.transact((()=>{const r=e.selection,s=r.getRng(),a=Yu(e).length>0,i=ti("mce-annotation");if(s.collapsed&&!a&&((e,t)=>{const n=Um(e.dom,t,[{inline:"span"}]);t.setStart(n.startContainer,n.startOffset),t.setEnd(n.endContainer,n.endOffset),e.selection.setRng(t)})(e,s),r.getRng().collapsed&&!a){const s=$m(e.getDoc(),i,o,t,n.decorate);So(s,pr),r.getRng().insertNode(s.dom),r.select(s.dom)}else om(r,!1,(()=>{nm(e,(r=>{Vm(e,r,i,t,n.decorate,o)}))}))}))})(e,n,t,o)}))},annotationChanged:(e,t)=>{n.addListener(e,t)},remove:t=>{Xa(e,I.some(t)).each((({elements:t})=>{const n=e.selection.getBookmark();r(t),e.selection.moveToBookmark(n)}))},removeAll:t=>{const n=e.selection.getBookmark();ge(Za(e,t),((e,t)=>{r(e)})),e.selection.moveToBookmark(n)},getAll:t=>{const n=Za(e,t);return pe(n,(e=>V(e,(e=>e.dom))))}}},Wm=e=>({getBookmark:O(Du,e),moveToBookmark:O(Pu,e)});Wm.isBookmarkNode=Lu;const Km=(e,t,n)=>!n.collapsed&&$(n.getClientRects(),(n=>((e,t,n)=>t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom)(n,e,t))),Gm=(e,t,n)=>{e.dispatch(t,n)},Ym=(e,t,n,o)=>{e.dispatch("FormatApply",{format:t,node:n,vars:o})},Xm=(e,t,n,o)=>{e.dispatch("FormatRemove",{format:t,node:n,vars:o})},Qm=(e,t)=>e.dispatch("SetContent",t),Jm=(e,t)=>e.dispatch("GetContent",t),Zm=(e,t)=>e.dispatch("PastePlainTextToggle",{state:t}),ef={BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,ESC:27,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,modifierPressed:e=>e.shiftKey||e.ctrlKey||e.altKey||ef.metaKeyPressed(e),metaKeyPressed:e=>At.os.isMacOS()||At.os.isiOS()?e.metaKey:e.ctrlKey&&!e.altKey},tf="data-mce-selected",nf=Math.abs,of=Math.round,rf={nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]},sf=(e,t)=>{const n=t.dom,o=t.getDoc(),r=document,s=t.getBody();let a,i,l,d,c,u,m,f,g,p,h,b,v,y,w;const x=e=>C(e)&&(sr(e)||n.is(e,"figure.image")),k=e=>cr(e)||n.hasClass(e,"mce-preview-object"),E=e=>{const n=e.target;((e,t)=>{if((e=>"longpress"===e.type||0===e.type.indexOf("touch"))(e)){const n=e.touches[0];return x(e.target)&&!Km(n.clientX,n.clientY,t)}return x(e.target)&&!Km(e.clientX,e.clientY,t)})(e,t.selection.getRng())&&!e.isDefaultPrevented()&&t.selection.select(n)},S=e=>n.hasClass(e,"mce-preview-object")&&C(e.firstElementChild)?[e,e.firstElementChild]:n.is(e,"figure.image")?[e.querySelector("img")]:[e],_=e=>{const o=ed(t);return!!o&&"false"!==e.getAttribute("data-mce-resize")&&e!==t.getBody()&&(n.hasClass(e,"mce-preview-object")&&C(e.firstElementChild)?xn(yn(e.firstElementChild),o):xn(yn(e),o))},N=(e,o,r)=>{if(C(r)){const s=S(e);q(s,(e=>{e.style[o]||!t.schema.isValid(e.nodeName.toLowerCase(),o)?n.setStyle(e,o,r):n.setAttrib(e,o,""+r)}))}},R=(e,t,n)=>{N(e,"width",t),N(e,"height",n)},A=e=>{let o,r,c,C,E;o=e.screenX-u,r=e.screenY-m,b=o*d[2]+f,v=r*d[3]+g,b=b<5?5:b,v=v<5?5:v,c=(x(a)||k(a))&&!1!==td(t)?!ef.modifierPressed(e):ef.modifierPressed(e),c&&(nf(o)>nf(r)?(v=of(b*p),b=of(v/p)):(b=of(v/p),v=of(b*p))),R(i,b,v),C=d.startPos.x+o,E=d.startPos.y+r,C=C>0?C:0,E=E>0?E:0,n.setStyles(l,{left:C,top:E,display:"block"}),l.innerHTML=b+" × "+v,d[2]<0&&i.clientWidth<=b&&n.setStyle(i,"left",void 0+(f-b)),d[3]<0&&i.clientHeight<=v&&n.setStyle(i,"top",void 0+(g-v)),o=s.scrollWidth-y,r=s.scrollHeight-w,o+r!==0&&n.setStyles(l,{left:C-o,top:E-r}),h||(((e,t,n,o,r)=>{e.dispatch("ObjectResizeStart",{target:t,width:n,height:o,origin:r})})(t,a,f,g,"corner-"+d.name),h=!0)},O=()=>{const e=h;h=!1,e&&(N(a,"width",b),N(a,"height",v)),n.unbind(o,"mousemove",A),n.unbind(o,"mouseup",O),r!==o&&(n.unbind(r,"mousemove",A),n.unbind(r,"mouseup",O)),n.remove(i),n.remove(l),n.remove(c),T(a),e&&(((e,t,n,o,r)=>{e.dispatch("ObjectResized",{target:t,width:n,height:o,origin:r})})(t,a,b,v,"corner-"+d.name),n.setAttrib(a,"style",n.getAttrib(a,"style"))),t.nodeChanged()},T=e=>{M();const h=n.getPos(e,s),C=h.x,x=h.y,E=e.getBoundingClientRect(),N=E.width||E.right-E.left,T=E.height||E.bottom-E.top;a!==e&&(D(),a=e,b=v=0);const B=t.dispatch("ObjectSelected",{target:e});_(e)&&!B.isDefaultPrevented()?ge(rf,((e,t)=>{let h=n.get("mceResizeHandle"+t);h&&n.remove(h),h=n.add(s,"div",{id:"mceResizeHandle"+t,"data-mce-bogus":"all",class:"mce-resizehandle",unselectable:!0,style:"cursor:"+t+"-resize; margin:0; padding:0"}),n.bind(h,"mousedown",(h=>{h.stopImmediatePropagation(),h.preventDefault(),(h=>{const b=S(a)[0];var v;u=h.screenX,m=h.screenY,f=b.clientWidth,g=b.clientHeight,p=g/f,d=e,d.name=t,d.startPos={x:N*e[0]+C,y:T*e[1]+x},y=s.scrollWidth,w=s.scrollHeight,c=n.add(s,"div",{class:"mce-resize-backdrop","data-mce-bogus":"all"}),n.setStyles(c,{position:"fixed",left:"0",top:"0",width:"100%",height:"100%"}),i=k(v=a)?n.create("img",{src:At.transparentSrc}):v.cloneNode(!0),n.addClass(i,"mce-clonedresizable"),n.setAttrib(i,"data-mce-bogus","all"),i.contentEditable="false",n.setStyles(i,{left:C,top:x,margin:0}),R(i,N,T),i.removeAttribute(tf),s.appendChild(i),n.bind(o,"mousemove",A),n.bind(o,"mouseup",O),r!==o&&(n.bind(r,"mousemove",A),n.bind(r,"mouseup",O)),l=n.add(s,"div",{class:"mce-resize-helper","data-mce-bogus":"all"},f+" × "+g)})(h)})),e.elm=h,n.setStyles(h,{left:N*e[0]+C-h.offsetWidth/2,top:T*e[1]+x-h.offsetHeight/2})})):D(!1)},B=ja(T,0),D=(e=!0)=>{B.cancel(),M(),a&&e&&a.removeAttribute(tf),ge(rf,((e,t)=>{const o=n.get("mceResizeHandle"+t);o&&(n.unbind(o),n.remove(o))}))},P=(e,t)=>n.isChildOf(e,t),L=o=>{if(h||t.removed||t.composing)return;const r="mousedown"===o.type?o.target:e.getNode(),a=to(yn(r),"table,img,figure.image,hr,video,span.mce-preview-object,details").map((e=>e.dom)).filter((e=>n.isEditable(e.parentElement))).getOrUndefined(),i=C(a)?n.getAttrib(a,tf,"1"):"1";if(q(n.select(`img[${tf}],hr[${tf}]`),(e=>{e.removeAttribute(tf)})),C(a)&&P(a,s)&&t.hasFocus()){I();const t=e.getStart(!0);if(P(t,a)&&P(e.getEnd(!0),a))return n.setAttrib(a,tf,i),void B.throttle(a)}D()},M=()=>{ge(rf,(e=>{e.elm&&(n.unbind(e.elm),delete e.elm)}))},I=()=>{try{t.getDoc().execCommand("enableObjectResizing",!1,"false")}catch(e){}};return t.on("init",(()=>{I(),t.on("NodeChange ResizeEditor ResizeWindow ResizeContent drop",L),t.on("keyup compositionend",(e=>{a&&"TABLE"===a.nodeName&&L(e)})),t.on("hide blur",D),t.on("contextmenu longpress",E,!0)})),t.on("remove",M),{isResizable:_,showResizeRect:T,hideResizeRect:D,updateResizeRect:L,destroy:()=>{B.cancel(),a=i=c=null}}},af=(e,t,n)=>{const o=e.document.createRange();var r;return r=o,t.fold((e=>{r.setStartBefore(e.dom)}),((e,t)=>{r.setStart(e.dom,t)}),(e=>{r.setStartAfter(e.dom)})),((e,t)=>{t.fold((t=>{e.setEndBefore(t.dom)}),((t,n)=>{e.setEnd(t.dom,n)}),(t=>{e.setEndAfter(t.dom)}))})(o,n),o},lf=(e,t,n,o,r)=>{const s=e.document.createRange();return s.setStart(t.dom,n),s.setEnd(o.dom,r),s},df=al([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),cf=(e,t,n)=>t(yn(n.startContainer),n.startOffset,yn(n.endContainer),n.endOffset);df.ltr,df.rtl;const uf=(e,t,n,o)=>({start:e,soffset:t,finish:n,foffset:o}),mf=document.caretPositionFromPoint?(e,t,n)=>{var o,r;return I.from(null===(r=(o=e.dom).caretPositionFromPoint)||void 0===r?void 0:r.call(o,t,n)).bind((t=>{if(null===t.offsetNode)return I.none();const n=e.dom.createRange();return n.setStart(t.offsetNode,t.offset),n.collapse(),I.some(n)}))}:document.caretRangeFromPoint?(e,t,n)=>{var o,r;return I.from(null===(r=(o=e.dom).caretRangeFromPoint)||void 0===r?void 0:r.call(o,t,n))}:I.none,ff=al([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),gf={before:ff.before,on:ff.on,after:ff.after,cata:(e,t,n,o)=>e.fold(t,n,o),getStart:e=>e.fold(R,R,R)},pf=al([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),hf={domRange:pf.domRange,relative:pf.relative,exact:pf.exact,exactFromRange:e=>pf.exact(e.start,e.soffset,e.finish,e.foffset),getWin:e=>{const t=(e=>e.match({domRange:e=>yn(e.startContainer),relative:(e,t)=>gf.getStart(e),exact:(e,t,n,o)=>e}))(e);return Rn(t)},range:uf},bf=(e,t)=>{const n=Ht(e);return"input"===n?gf.after(e):H(["br","img"],n)?0===t?gf.before(e):gf.after(e):gf.on(e,t)},vf=(e,t)=>{const n=e.fold(gf.before,bf,gf.after),o=t.fold(gf.before,bf,gf.after);return hf.relative(n,o)},yf=(e,t,n,o)=>{const r=bf(e,t),s=bf(n,o);return hf.relative(r,s)},Cf=(e,t)=>{const n=(t||document).createDocumentFragment();return q(e,(e=>{n.appendChild(e.dom)})),yn(n)},wf=e=>{const t=hf.getWin(e).dom,n=(e,n,o,r)=>lf(t,e,n,o,r),o=(e=>e.match({domRange:e=>{const t=yn(e.startContainer),n=yn(e.endContainer);return yf(t,e.startOffset,n,e.endOffset)},relative:vf,exact:yf}))(e);return((e,t)=>{const n=((e,t)=>t.match({domRange:e=>({ltr:N(e),rtl:I.none}),relative:(t,n)=>({ltr:Pe((()=>af(e,t,n))),rtl:Pe((()=>I.some(af(e,n,t))))}),exact:(t,n,o,r)=>({ltr:Pe((()=>lf(e,t,n,o,r))),rtl:Pe((()=>I.some(lf(e,o,r,t,n))))})}))(e,t);return((e,t)=>{const n=t.ltr();return n.collapsed?t.rtl().filter((e=>!1===e.collapsed)).map((e=>df.rtl(yn(e.endContainer),e.endOffset,yn(e.startContainer),e.startOffset))).getOrThunk((()=>cf(0,df.ltr,n))):cf(0,df.ltr,n)})(0,n)})(t,o).match({ltr:n,rtl:n})},xf=(e,t,n)=>((e,t,n)=>((e,t,n)=>{const o=yn(e.document);return mf(o,t,n).map((e=>uf(yn(e.startContainer),e.startOffset,yn(e.endContainer),e.endOffset)))})(e,t,n))(Rn(yn(n)).dom,e,t).map((e=>{const t=n.createRange();return t.setStart(e.start.dom,e.soffset),t.setEnd(e.finish.dom,e.foffset),t})).getOrUndefined(),kf=(e,t)=>C(e)&&C(t)&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset,Ef=(e,t,n)=>null!==((e,t,n)=>{let o=e;for(;o&&o!==t;){if(n(o))return o;o=o.parentNode}return null})(e,t,n),Sf=(e,t,n)=>Ef(e,t,(e=>e.nodeName===n)),_f=(e,t)=>$r(e)&&!Ef(e,t,xu),Nf=(e,t,n)=>{const o=t.parentNode;if(o){const r=new zo(t,e.getParent(o,e.isBlock)||e.getRoot());let s;for(;s=r[n?"prev":"next"]();)if(rr(s))return!0}return!1},Rf=(e,t,n,o,r)=>{const s=e.getRoot(),a=e.schema.getNonEmptyElements(),i=r.parentNode;let l,d;if(!i)return I.none();const c=e.getParent(i,e.isBlock)||s;if(o&&rr(r)&&t&&e.isEmpty(c))return I.some(Li(i,e.nodeIndex(r)));const u=new zo(r,c);for(;d=u[o?"prev":"next"]();){if("false"===e.getContentEditableParent(d)||_f(d,s))return I.none();if(Jo(d)&&d.data.length>0)return Sf(d,s,"A")?I.none():I.some(Li(d,o?d.data.length:0));if(e.isBlock(d)||a[d.nodeName.toLowerCase()])return I.none();l=d}return tr(l)?I.none():n&&l?I.some(Li(l,0)):I.none()},Af=(e,t,n,o)=>{const r=e.getRoot();let s,a=!1,i=n?o.startContainer:o.endContainer,l=n?o.startOffset:o.endOffset;const d=$o(i)&&l===i.childNodes.length,c=e.schema.getNonEmptyElements();let u=n;if($r(i))return I.none();if($o(i)&&l>i.childNodes.length-1&&(u=!1),nr(i)&&(i=r,l=0),i===r){if(u&&(s=i.childNodes[l>0?l-1:0],s)){if($r(s))return I.none();if(c[s.nodeName]||Yo(s))return I.none()}if(i.hasChildNodes()){if(l=Math.min(!u&&l>0?l-1:l,i.childNodes.length-1),i=i.childNodes[l],l=Jo(i)&&d?i.data.length:0,!t&&i===r.lastChild&&Yo(i))return I.none();if(((e,t)=>{let n=t;for(;n&&n!==e;){if(ir(n))return!0;n=n.parentNode}return!1})(r,i)||$r(i))return I.none();if(i.hasChildNodes()&&!Yo(i)){s=i;const t=new zo(i,r);do{if(ir(s)||$r(s)){a=!1;break}if(Jo(s)&&s.data.length>0){l=u?0:s.data.length,i=s,a=!0;break}if(c[s.nodeName.toLowerCase()]&&!dr(s)){l=e.nodeIndex(s),i=s.parentNode,u||l++,a=!0;break}}while(s=u?t.next():t.prev())}}}return t&&(Jo(i)&&0===l&&Rf(e,d,t,!0,i).each((e=>{i=e.container(),l=e.offset(),a=!0})),$o(i)&&(s=i.childNodes[l],s||(s=i.childNodes[l-1]),!s||!rr(s)||((e,t)=>{var n;return"A"===(null===(n=e.previousSibling)||void 0===n?void 0:n.nodeName)})(s)||Nf(e,s,!1)||Nf(e,s,!0)||Rf(e,d,t,!0,s).each((e=>{i=e.container(),l=e.offset(),a=!0})))),u&&!t&&Jo(i)&&l===i.data.length&&Rf(e,d,t,!1,i).each((e=>{i=e.container(),l=e.offset(),a=!0})),a&&i?I.some(Li(i,l)):I.none()},Of=(e,t)=>{const n=t.collapsed,o=t.cloneRange(),r=Li.fromRangeStart(t);return Af(e,n,!0,o).each((e=>{n&&Li.isAbove(r,e)||o.setStart(e.container(),e.offset())})),n||Af(e,n,!1,o).each((e=>{o.setEnd(e.container(),e.offset())})),n&&o.collapse(!0),kf(t,o)?I.none():I.some(o)},Tf=(e,t)=>e.splitText(t),Bf=e=>{let t=e.startContainer,n=e.startOffset,o=e.endContainer,r=e.endOffset;if(t===o&&Jo(t)){if(n>0&&n<t.data.length)if(o=Tf(t,n),t=o.previousSibling,r>n){r-=n;const e=Tf(o,r).previousSibling;t=o=e,r=e.data.length,n=0}else r=0}else if(Jo(t)&&n>0&&n<t.data.length&&(t=Tf(t,n),n=0),Jo(o)&&r>0&&r<o.data.length){const e=Tf(o,r).previousSibling;o=e,r=e.data.length}return{startContainer:t,startOffset:n,endContainer:o,endOffset:r}},Df=e=>({walk:(t,n)=>zm(e,t,n),split:Bf,expand:(t,n={type:"word"})=>{if("word"===n.type){const n=Um(e,t,[{inline:"span"}]),o=e.createRng();return o.setStart(n.startContainer,n.startOffset),o.setEnd(n.endContainer,n.endOffset),o}return t},normalize:t=>Of(e,t).fold(L,(e=>(t.setStart(e.startContainer,e.startOffset),t.setEnd(e.endContainer,e.endOffset),!0)))});Df.compareRanges=kf,Df.getCaretRangeFromPoint=xf,Df.getSelectedNode=gi,Df.getNode=pi;const Pf=((e,t)=>{const n=t=>{const n=(e=>{const t=e.dom;return Yn(e)?t.getBoundingClientRect().height:t.offsetHeight})(t);if(n<=0||null===n){const n=lo(t,e);return parseFloat(n)||0}return n},o=(e,t)=>X(t,((t,n)=>{const o=lo(e,n),r=void 0===o?0:parseInt(o,10);return isNaN(r)?t:t+r}),0);return{set:(t,n)=>{if(!x(n)&&!n.match(/^[0-9]+$/))throw new Error(e+".set accepts only positive integer values. Value was "+n);const o=t.dom;ro(o)&&(o.style[e]=n+"px")},get:n,getOuter:n,aggregate:o,max:(e,t,n)=>{const r=o(e,n);return t>r?t-r:0}}})("height"),Lf=()=>yn(document),Mf=(e,t)=>e.view(t).fold(N([]),(t=>{const n=e.owner(t),o=Mf(e,n);return[t].concat(o)}));var If=Object.freeze({__proto__:null,view:e=>{var t;return(e.dom===document?I.none():I.from(null===(t=e.dom.defaultView)||void 0===t?void 0:t.frameElement)).map(yn)},owner:e=>Nn(e)});const Ff=e=>"textarea"===Ht(e),Uf=(e,t)=>{const n=(e=>{const t=e.dom.ownerDocument,n=t.body,o=t.defaultView,r=t.documentElement;if(n===e.dom)return Ao(n.offsetLeft,n.offsetTop);const s=Oo(null==o?void 0:o.pageYOffset,r.scrollTop),a=Oo(null==o?void 0:o.pageXOffset,r.scrollLeft),i=Oo(r.clientTop,n.clientTop),l=Oo(r.clientLeft,n.clientLeft);return To(e).translate(a-l,s-i)})(e),o=(e=>Pf.get(e))(e);return{element:e,bottom:n.top+o,height:o,pos:n,cleanup:t}},zf=(e,t,n,o)=>{Vf(e,((r,s)=>Hf(e,t,n,o)),n)},jf=(e,t,n,o,r)=>{const s={elm:o.element.dom,alignToTop:r};((e,t)=>e.dispatch("ScrollIntoView",t).isDefaultPrevented())(e,s)||(n(e,t,Bo(t).top,o,r),((e,t)=>{e.dispatch("AfterScrollIntoView",t)})(e,s))},Hf=(e,t,n,o)=>{const r=yn(e.getBody()),s=yn(e.getDoc());r.dom.offsetWidth;const a=((e,t)=>{const n=((e,t)=>{const n=Mn(e);if(0===n.length||Ff(e))return{element:e,offset:t};if(t<n.length&&!Ff(n[t]))return{element:n[t],offset:0};{const o=n[n.length-1];return Ff(o)?{element:e,offset:t}:"img"===Ht(o)?{element:o,offset:1}:Kt(o)?{element:o,offset:vr(o).length}:{element:o,offset:Mn(o).length}}})(e,t),o=hn('<span data-mce-bogus="all" style="display: inline-block;">\ufeff</span>');return go(n.element,o),Uf(o,(()=>wo(o)))})(yn(n.startContainer),n.startOffset);jf(e,s,t,a,o),a.cleanup()},$f=(e,t,n,o)=>{const r=yn(e.getDoc());jf(e,r,n,(e=>Uf(yn(e),E))(t),o)},Vf=(e,t,n)=>{const o=n.startContainer,r=n.startOffset,s=n.endContainer,a=n.endOffset;t(yn(o),yn(s));const i=e.dom.createRng();i.setStart(o,r),i.setEnd(s,a),e.selection.setRng(n)},qf=(e,t,n,o,r)=>{const s=t.pos;if(o)Do(s.left,s.top,r);else{const o=s.top-n+t.height;Do(-e.getBody().getBoundingClientRect().left,o,r)}},Wf=(e,t,n,o,r,s)=>{const a=o+n,i=r.pos.top,l=r.bottom,d=l-i>=o;i<n?qf(e,r,o,!1!==s,t):i>a?qf(e,r,o,d?!1!==s:!0===s,t):l>a&&!d&&qf(e,r,o,!0===s,t)},Kf=(e,t,n,o,r)=>{const s=Rn(t).dom.innerHeight;Wf(e,t,n,s,o,r)},Gf=(e,t,n,o,r)=>{const s=Rn(t).dom.innerHeight;Wf(e,t,n,s,o,r);const a=(e=>{const t=Lf(),n=Bo(t),o=((e,t)=>{const n=t.owner(e);return Mf(t,n)})(e,If),r=To(e),s=Y(o,((e,t)=>{const n=To(t);return{left:e.left+n.left,top:e.top+n.top}}),{left:0,top:0});return Ao(s.left+r.left+n.left,s.top+r.top+n.top)})(o.element),i=Mo(window);a.top<i.y?Po(o.element,!1!==r):a.top>i.bottom&&Po(o.element,!0===r)},Yf=(e,t,n)=>zf(e,Kf,t,n),Xf=(e,t,n)=>$f(e,t,Kf,n),Qf=(e,t,n)=>zf(e,Gf,t,n),Jf=(e,t,n)=>$f(e,t,Gf,n),Zf=(e,t,n)=>{(e.inline?Yf:Qf)(e,t,n)},eg=e=>e.dom.focus(),tg=e=>{const t=Vn(e).dom;return e.dom===t.activeElement},ng=(e=Lf())=>I.from(e.dom.activeElement).map(yn),og=(e,t)=>{const n=Kt(t)?vr(t).length:Mn(t).length+1;return e>n?n:e<0?0:e},rg=e=>hf.range(e.start,og(e.soffset,e.start),e.finish,og(e.foffset,e.finish)),sg=(e,t)=>!Ho(t.dom)&&(Sn(e,t)||En(e,t)),ag=e=>t=>sg(e,t.start)&&sg(e,t.finish),ig=e=>hf.range(yn(e.startContainer),e.startOffset,yn(e.endContainer),e.endOffset),lg=e=>{const t=document.createRange();try{return t.setStart(e.start.dom,e.soffset),t.setEnd(e.finish.dom,e.foffset),I.some(t)}catch(e){return I.none()}},dg=e=>{const t=(e=>e.inline||At.browser.isFirefox())(e)?(n=yn(e.getBody()),(e=>{const t=e.getSelection();return(t&&0!==t.rangeCount?I.from(t.getRangeAt(0)):I.none()).map(ig)})(Rn(n).dom).filter(ag(n))):I.none();var n;e.bookmark=t.isSome()?t:e.bookmark},cg=e=>(e.bookmark?e.bookmark:I.none()).bind((t=>{return n=yn(e.getBody()),o=t,I.from(o).filter(ag(n)).map(rg);var n,o})).bind(lg),ug={isEditorUIElement:e=>{const t=e.className.toString();return-1!==t.indexOf("tox-")||-1!==t.indexOf("mce-")}},mg={setEditorTimeout:(e,t,n)=>((e,t)=>(x(t)||(t=0),setTimeout(e,t)))((()=>{e.removed||t()}),n),setEditorInterval:(e,t,n)=>{const o=((e,t)=>(x(t)||(t=0),setInterval(e,t)))((()=>{e.removed?clearInterval(o):t()}),n);return o}};let fg;const gg=Oa.DOM,pg=e=>{const t=e.classList;return void 0!==t&&(t.contains("tox-edit-area")||t.contains("tox-edit-area__iframe")||t.contains("mce-content-body"))},hg=(e,t)=>{const n=gd(e),o=gg.getParent(t,(t=>(e=>$o(e)&&ug.isEditorUIElement(e))(t)||!!n&&e.dom.is(t,n)));return null!==o},bg=e=>{try{const t=Vn(yn(e.getElement()));return ng(t).fold((()=>document.body),(e=>e.dom))}catch(e){return document.body}},vg=(e,t)=>{const n=t.editor;(e=>{const t=ja((()=>{dg(e)}),0);e.on("init",(()=>{e.inline&&((e,t)=>{const n=()=>{t.throttle()};Oa.DOM.bind(document,"mouseup",n),e.on("remove",(()=>{Oa.DOM.unbind(document,"mouseup",n)}))})(e,t),((e,t)=>{((e,t)=>{e.on("mouseup touchend",(e=>{t.throttle()}))})(e,t),e.on("keyup NodeChange AfterSetSelectionRange",(t=>{(e=>"nodechange"===e.type&&e.selectionChange)(t)||dg(e)}))})(e,t)})),e.on("remove",(()=>{t.cancel()}))})(n);const o=(e,t)=>{nc(e)&&!0!==e.inline&&t(yn(e.getContainer()),"tox-edit-focus")};n.on("focusin",(()=>{const t=e.focusedEditor;pg(bg(n))&&o(n,un),t!==n&&(t&&t.dispatch("blur",{focusedEditor:n}),e.setActive(n),e.focusedEditor=n,n.dispatch("focus",{blurredEditor:t}),n.focus(!0))})),n.on("focusout",(()=>{mg.setEditorTimeout(n,(()=>{const t=e.focusedEditor;pg(bg(n))&&t===n||o(n,fn),hg(n,bg(n))||t!==n||(n.dispatch("blur",{focusedEditor:null}),e.focusedEditor=null)}))})),fg||(fg=t=>{const n=e.activeEditor;n&&Kn(t).each((t=>{const o=t;o.ownerDocument===document&&(o===document.body||hg(n,o)||e.focusedEditor!==n||(n.dispatch("blur",{focusedEditor:null}),e.focusedEditor=null))}))},gg.bind(document,"focusin",fg))},yg=(e,t)=>{e.focusedEditor===t.editor&&(e.focusedEditor=null),!e.activeEditor&&fg&&(gg.unbind(document,"focusin",fg),fg=null)},Cg=(e,t)=>{((e,t)=>(e=>e.collapsed?I.from(pi(e.startContainer,e.startOffset)).map(yn):I.none())(t).bind((t=>Rr(t)?I.some(t):Sn(e,t)?I.none():I.some(e))))(yn(e.getBody()),t).bind((e=>yu(e.dom))).fold((()=>{e.selection.normalize()}),(t=>e.selection.setRng(t.toRange())))},wg=e=>{if(e.setActive)try{e.setActive()}catch(t){e.focus()}else e.focus()},xg=e=>e.inline?(e=>{const t=e.getBody();return t&&(n=yn(t),tg(n)||(o=n,ng(Vn(o)).filter((e=>o.dom.contains(e.dom)))).isSome());var n,o})(e):(e=>C(e.iframeElement)&&tg(yn(e.iframeElement)))(e),kg=e=>e.editorManager.setActive(e),Eg=(e,t,n,o,r)=>{const s=n?t.startContainer:t.endContainer,a=n?t.startOffset:t.endOffset;return I.from(s).map(yn).map((e=>o&&t.collapsed?e:In(e,r(e,a)).getOr(e))).bind((e=>Wt(e)?I.some(e):An(e).filter(Wt))).map((e=>e.dom)).getOr(e)},Sg=(e,t,n=!1)=>Eg(e,t,!0,n,((e,t)=>Math.min(zn(e),t))),_g=(e,t,n=!1)=>Eg(e,t,!1,n,((e,t)=>t>0?t-1:t)),Ng=(e,t)=>{const n=e;for(;e&&Jo(e)&&0===e.length;)e=t?e.nextSibling:e.previousSibling;return e||n},Rg=(e,t)=>V(t,(t=>{const n=e.dispatch("GetSelectionRange",{range:t});return n.range!==t?n.range:t})),Ag=["img","br"],Og=e=>{const t=yr(e).filter((e=>0!==e.trim().length||e.indexOf(pr)>-1)).isSome();return t||H(Ag,Ht(e))||(e=>qt(e)&&"false"===en(e,"contenteditable"))(e)},Tg="[data-mce-autocompleter]",Bg=(e,t)=>{if(Dg(yn(e.getBody())).isNone()){const o=hn('<span data-mce-autocompleter="1" data-mce-bogus="1"></span>',e.getDoc());bo(o,yn(t.extractContents())),t.insertNode(o.dom),An(o).each((e=>e.dom.normalize())),(n=o,((e,t)=>{const n=e=>{const o=Mn(e);for(let e=o.length-1;e>=0;e--){const r=o[e];if(t(r))return I.some(r);const s=n(r);if(s.isSome())return s}return I.none()};return n(e)})(n,Og)).map((t=>{e.selection.setCursorLocation(t.dom,(e=>"img"===Ht(e)?1:yr(e).fold((()=>Mn(e).length),(e=>e.length)))(t))}))}var n},Dg=e=>eo(e,Tg),Pg={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11},Lg=(e,t,n)=>{const o=n?"lastChild":"firstChild",r=n?"prev":"next";if(e[o])return e[o];if(e!==t){let n=e[r];if(n)return n;for(let o=e.parent;o&&o!==t;o=o.parent)if(n=o[r],n)return n}},Mg=e=>{var t;const n=null!==(t=e.value)&&void 0!==t?t:"";if(!ds(n))return!1;const o=e.parent;return!o||"span"===o.name&&!o.attr("style")||!/^[ ]+$/.test(n)},Ig=e=>{const t="a"===e.name&&!e.attr("href")&&e.attr("id");return e.attr("name")||e.attr("id")&&!e.firstChild||e.attr("data-mce-bookmark")||t};class Fg{static create(e,t){const n=new Fg(e,Pg[e]||1);return t&&ge(t,((e,t)=>{n.attr(t,e)})),n}constructor(e,t){this.name=e,this.type=t,1===t&&(this.attributes=[],this.attributes.map={})}replace(e){const t=this;return e.parent&&e.remove(),t.insert(e,t),t.remove(),t}attr(e,t){const n=this;if(!m(e))return C(e)&&ge(e,((e,t)=>{n.attr(t,e)})),n;const o=n.attributes;if(o){if(void 0!==t){if(null===t){if(e in o.map){delete o.map[e];let t=o.length;for(;t--;)if(o[t].name===e)return o.splice(t,1),n}return n}if(e in o.map){let n=o.length;for(;n--;)if(o[n].name===e){o[n].value=t;break}}else o.push({name:e,value:t});return o.map[e]=t,n}return o.map[e]}}clone(){const e=this,t=new Fg(e.name,e.type),n=e.attributes;if(n){const e=[];e.map={};for(let t=0,o=n.length;t<o;t++){const o=n[t];"id"!==o.name&&(e[e.length]={name:o.name,value:o.value},e.map[o.name]=o.value)}t.attributes=e}return t.value=e.value,t}wrap(e){const t=this;return t.parent&&(t.parent.insert(e,t),e.append(t)),t}unwrap(){const e=this;for(let t=e.firstChild;t;){const n=t.next;e.insert(t,e,!0),t=n}e.remove()}remove(){const e=this,t=e.parent,n=e.next,o=e.prev;return t&&(t.firstChild===e?(t.firstChild=n,n&&(n.prev=null)):o&&(o.next=n),t.lastChild===e?(t.lastChild=o,o&&(o.next=null)):n&&(n.prev=o),e.parent=e.next=e.prev=null),e}append(e){const t=this;e.parent&&e.remove();const n=t.lastChild;return n?(n.next=e,e.prev=n,t.lastChild=e):t.lastChild=t.firstChild=e,e.parent=t,e}insert(e,t,n){e.parent&&e.remove();const o=t.parent||this;return n?(t===o.firstChild?o.firstChild=e:t.prev&&(t.prev.next=e),e.prev=t.prev,e.next=t,t.prev=e):(t===o.lastChild?o.lastChild=e:t.next&&(t.next.prev=e),e.next=t.next,e.prev=t,t.next=e),e.parent=o,e}getAll(e){const t=this,n=[];for(let o=t.firstChild;o;o=Lg(o,t))o.name===e&&n.push(o);return n}children(){const e=[];for(let t=this.firstChild;t;t=t.next)e.push(t);return e}empty(){const e=this;if(e.firstChild){const t=[];for(let n=e.firstChild;n;n=Lg(n,e))t.push(n);let n=t.length;for(;n--;){const e=t[n];e.parent=e.firstChild=e.lastChild=e.next=e.prev=null}}return e.firstChild=e.lastChild=null,e}isEmpty(e,t={},n){var o;const r=this;let s=r.firstChild;if(Ig(r))return!1;if(s)do{if(1===s.type){if(s.attr("data-mce-bogus"))continue;if(e[s.name])return!1;if(Ig(s))return!1}if(8===s.type)return!1;if(3===s.type&&!Mg(s))return!1;if(3===s.type&&s.parent&&t[s.parent.name]&&ds(null!==(o=s.value)&&void 0!==o?o:""))return!1;if(n&&n(s))return!1}while(s=Lg(s,r));return!0}walk(e){return Lg(this,null,e)}}const Ug=(e,t,n=0)=>{const o=e.toLowerCase();if(-1!==o.indexOf("[if ",n)&&((e,t)=>/^\s*\[if [\w\W]+\]>.*<!\[endif\](--!?)?>/.test(e.substr(t)))(o,n)){const e=o.indexOf("[endif]",n);return o.indexOf(">",e)}if(t){const e=o.indexOf(">",n);return-1!==e?e:o.length}{const t=/--!?>/g;t.lastIndex=n;const r=t.exec(e);return r?r.index+r[0].length:o.length}},zg=(e,t,n)=>{const o=/<([!?\/])?([A-Za-z0-9\-_:.]+)/g,r=/(?:\s(?:[^'">]+(?:"[^"]*"|'[^']*'))*[^"'>]*(?:"[^">]*|'[^'>]*)?|\s*|\/)>/g,s=e.getVoidElements();let a=1,i=n;for(;0!==a;)for(o.lastIndex=i;;){const e=o.exec(t);if(null===e)return i;if("!"===e[1]){i=He(e[2],"--")?Ug(t,!1,e.index+3):Ug(t,!0,e.index+1);break}{r.lastIndex=o.lastIndex;const n=r.exec(t);if(h(n)||n.index!==o.lastIndex)continue;"/"===e[1]?a-=1:ke(s,e[2])||(a+=1),i=o.lastIndex+n[0].length;break}}return i},jg=(e,t)=>{const n=/<(\w+) [^>]*data-mce-bogus="all"[^>]*>/g,o=e.schema;let r=((e,t)=>{const n=new RegExp(["\\s?("+e.join("|")+')="[^"]+"'].join("|"),"gi");return t.replace(n,"")})(e.getTempAttrs(),t);const s=o.getVoidElements();let a;for(;a=n.exec(r);){const e=n.lastIndex,t=a[0].length;let i;i=s[a[1]]?e:zg(o,r,e),r=r.substring(0,e-t)+r.substring(i),n.lastIndex=e-t}return Fr(r)},Hg=jg,$g=e=>{const t=Fo(e,"[data-mce-bogus]");q(t,(e=>{"all"===en(e,"data-mce-bogus")?wo(e):Er(e)?(go(e,vn(gr)),wo(e)):xo(e)}))},Vg=e=>{const t=Fo(e,"input");q(t,(e=>{on(e,"name")}))},qg=(e,t,n)=>{let o;return o="raw"===t.format?Dt.trim(Hg(e.serializer,n.innerHTML)):"text"===t.format?((e,t)=>{const n=e.getDoc(),o=Vn(yn(e.getBody())),r=bn("div",n);Jt(r,"data-mce-bogus","all"),io(r,{position:"fixed",left:"-9999999px",top:"0"}),So(r,t.innerHTML),$g(r),Vg(r);const s=(e=>jn(e)?e:yn(Nn(e).dom.body))(o);bo(s,r);const a=Fr(r.dom.innerText);return wo(r),a})(e,n):"tree"===t.format?e.serializer.serialize(n,t):((e,t)=>{const n=Nl(e),o=new RegExp(`^(<${n}[^>]*>( | |\\s|\xa0|<br \\/>|)<\\/${n}>[\r\n]*|<br \\/>[\r\n]*)$`);return t.replace(o,"")})(e,e.serializer.serialize(n,t)),"text"!==t.format&&!Or(yn(n))&&m(o)?Dt.trim(o):o},Wg=Dt.makeMap,Kg=e=>{const t=[],n=(e=e||{}).indent,o=Wg(e.indent_before||""),r=Wg(e.indent_after||""),s=Zs.getEncodeFunc(e.entity_encoding||"raw",e.entities),a="xhtml"!==e.element_format;return{start:(e,i,l)=>{if(n&&o[e]&&t.length>0){const e=t[t.length-1];e.length>0&&"\n"!==e&&t.push("\n")}if(t.push("<",e),i)for(let e=0,n=i.length;e<n;e++){const n=i[e];t.push(" ",n.name,'="',s(n.value,!0),'"')}if(t[t.length]=!l||a?">":" />",l&&n&&r[e]&&t.length>0){const e=t[t.length-1];e.length>0&&"\n"!==e&&t.push("\n")}},end:e=>{let o;t.push("</",e,">"),n&&r[e]&&t.length>0&&(o=t[t.length-1],o.length>0&&"\n"!==o&&t.push("\n"))},text:(e,n)=>{e.length>0&&(t[t.length]=n?e:s(e))},cdata:e=>{t.push("<![CDATA[",e,"]]>")},comment:e=>{t.push("\x3c!--",e,"--\x3e")},pi:(e,o)=>{o?t.push("<?",e," ",s(o),"?>"):t.push("<?",e,"?>"),n&&t.push("\n")},doctype:e=>{t.push("<!DOCTYPE",e,">",n?"\n":"")},reset:()=>{t.length=0},getContent:()=>t.join("").replace(/\n$/,"")}},Gg=(e={},t=ca())=>{const n=Kg(e);return e.validate=!("validate"in e)||e.validate,{serialize:o=>{const r=e.validate,s={3:e=>{var t;n.text(null!==(t=e.value)&&void 0!==t?t:"",e.raw)},8:e=>{var t;n.comment(null!==(t=e.value)&&void 0!==t?t:"")},7:e=>{n.pi(e.name,e.value)},10:e=>{var t;n.doctype(null!==(t=e.value)&&void 0!==t?t:"")},4:e=>{var t;n.cdata(null!==(t=e.value)&&void 0!==t?t:"")},11:e=>{let t=e;if(t=t.firstChild)do{a(t)}while(t=t.next)}};n.reset();const a=e=>{var o;const i=s[e.type];if(i)i(e);else{const s=e.name,i=s in t.getVoidElements();let l=e.attributes;if(r&&l&&l.length>1){const n=[];n.map={};const o=t.getElementRule(e.name);if(o){for(let e=0,t=o.attributesOrder.length;e<t;e++){const t=o.attributesOrder[e];if(t in l.map){const e=l.map[t];n.map[t]=e,n.push({name:t,value:e})}}for(let e=0,t=l.length;e<t;e++){const t=l[e].name;if(!(t in n.map)){const e=l.map[t];n.map[t]=e,n.push({name:t,value:e})}}l=n}}if(n.start(s,l,i),!i){let t=e.firstChild;if(t){"pre"!==s&&"textarea"!==s||3!==t.type||"\n"!==(null===(o=t.value)||void 0===o?void 0:o[0])||n.text("\n",!0);do{a(t)}while(t=t.next)}n.end(s)}}};return 1!==o.type||e.inner?3===o.type?s[3](o):s[11](o):a(o),n.getContent()}}},Yg=new Set;q(["margin","margin-left","margin-right","margin-top","margin-bottom","padding","padding-left","padding-right","padding-top","padding-bottom","border","border-width","border-style","border-color","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","float","position","left","right","top","bottom","z-index","display","transform","width","max-width","min-width","height","max-height","min-height","overflow","overflow-x","overflow-y","text-overflow","vertical-align","transition","transition-delay","transition-duration","transition-property","transition-timing-function"],(e=>{Yg.add(e)}));const Xg=["font","text-decoration","text-emphasis"],Qg=(e,t)=>me(e.parseStyle(e.getAttrib(t,"style"))),Jg=(e,t,n)=>{const o=Qg(e,t),r=Qg(e,n),s=o=>{var r,s;const a=null!==(r=e.getStyle(t,o))&&void 0!==r?r:"",i=null!==(s=e.getStyle(n,o))&&void 0!==s?s:"";return Ge(a)&&Ge(i)&&a!==i};return $(o,(e=>{const t=t=>$(t,(t=>t===e));if(!t(r)&&t(Xg)){const e=G(r,(e=>$(Xg,(t=>He(e,t)))));return $(e,s)}return s(e)}))},Zg=(e,t,n)=>I.from(n.container()).filter(Jo).exists((o=>{const r=e?0:-1;return t(o.data.charAt(n.offset()+r))})),ep=O(Zg,!0,Fu),tp=O(Zg,!1,Fu),np=e=>{const t=e.container();return Jo(t)&&(0===t.data.length||Ir(t.data)&&Wm.isBookmarkNode(t.parentNode))},op=(e,t)=>n=>zc(e?0:-1,n).filter(t).isSome(),rp=e=>sr(e)&&"block"===lo(yn(e),"display"),sp=e=>ir(e)&&!(e=>$o(e)&&"all"===e.getAttribute("data-mce-bogus"))(e),ap=op(!0,rp),ip=op(!1,rp),lp=op(!0,cr),dp=op(!1,cr),cp=op(!0,Yo),up=op(!1,Yo),mp=op(!0,sp),fp=op(!1,sp),gp=(e,t)=>((e,t,n)=>Sn(t,e)?Tn(e,(e=>n(e)||En(e,t))).slice(0,-1):[])(e,t,L),pp=(e,t)=>[e].concat(gp(e,t)),hp=(e,t,n)=>pu(e,t,n,np),bp=(e,t)=>J(pp(yn(t.container()),e),xr),vp=(e,t,n)=>hp(e,t.dom,n).forall((e=>bp(t,n).fold((()=>!Uc(e,n,t.dom)),(o=>!Uc(e,n,t.dom)&&Sn(o,yn(e.container())))))),yp=(e,t,n)=>bp(t,n).fold((()=>hp(e,t.dom,n).forall((e=>!Uc(e,n,t.dom)))),(t=>hp(e,t.dom,n).isNone())),Cp=O(yp,!1),wp=O(yp,!0),xp=O(vp,!1),kp=O(vp,!0),Ep=e=>Yc(e).exists(Er),Sp=(e,t,n)=>{const o=G(pp(yn(n.container()),t),xr),r=le(o).getOr(t);return fu(e,r.dom,n).filter(Ep)},_p=(e,t)=>Yc(t).exists(Er)||Sp(!0,e,t).isSome(),Np=(e,t)=>(e=>I.from(e.getNode(!0)).map(yn))(t).exists(Er)||Sp(!1,e,t).isSome(),Rp=O(Sp,!1),Ap=O(Sp,!0),Op=e=>Li.isTextPosition(e)&&!e.isAtStart()&&!e.isAtEnd(),Tp=(e,t)=>{const n=G(pp(yn(t.container()),e),xr);return le(n).getOr(e)},Bp=(e,t)=>Op(t)?tp(t):tp(t)||vu(Tp(e,t).dom,t).exists(tp),Dp=(e,t)=>Op(t)?ep(t):ep(t)||bu(Tp(e,t).dom,t).exists(ep),Pp=e=>Yc(e).bind((e=>Jn(e,Wt))).exists((e=>(e=>H(["pre","pre-wrap"],e))(lo(e,"white-space")))),Lp=(e,t)=>n=>{return o=new zo(n,e)[t](),C(o)&&ir(o)&&Rc(o);var o},Mp=(e,t)=>!Pp(t)&&(((e,t)=>((e,t)=>vu(e.dom,t).isNone())(e,t)||((e,t)=>bu(e.dom,t).isNone())(e,t)||Cp(e,t)||wp(e,t)||Np(e,t)||_p(e,t))(e,t)||Bp(e,t)||Dp(e,t)),Ip=(e,t)=>!Pp(t)&&(Cp(e,t)||xp(e,t)||Np(e,t)||Bp(e,t)||((e,t)=>{const n=vu(e.dom,t).getOr(t),o=Lp(e.dom,"prev");return t.isAtStart()&&(o(t.container())||o(n.container()))})(e,t)),Fp=(e,t)=>!Pp(t)&&(wp(e,t)||kp(e,t)||_p(e,t)||Dp(e,t)||((e,t)=>{const n=bu(e.dom,t).getOr(t),o=Lp(e.dom,"next");return t.isAtEnd()&&(o(t.container())||o(n.container()))})(e,t)),Up=(e,t)=>Ip(e,t)||Fp(e,(e=>{const t=e.container(),n=e.offset();return Jo(t)&&n<t.data.length?Li(t,n+1):e})(t)),zp=(e,t)=>Mu(e.charAt(t)),jp=(e,t)=>Fu(e.charAt(t)),Hp=(e,t,n)=>{const o=t.data,r=Li(t,0);return n||!zp(o,0)||Up(e,r)?!!(n&&jp(o,0)&&Ip(e,r))&&(t.data=pr+o.slice(1),!0):(t.data=" "+o.slice(1),!0)},$p=(e,t,n)=>{const o=t.data,r=Li(t,o.length-1);return n||!zp(o,o.length-1)||Up(e,r)?!!(n&&jp(o,o.length-1)&&Fp(e,r))&&(t.data=o.slice(0,-1)+pr,!0):(t.data=o.slice(0,-1)+" ",!0)},Vp=(e,t)=>{const n=t.container();if(!Jo(n))return I.none();if((e=>{const t=e.container();return Jo(t)&&je(t.data,pr)})(t)){const o=Hp(e,n,!1)||(e=>{const t=e.data,n=(e=>{const t=e.split("");return V(t,((e,n)=>Mu(e)&&n>0&&n<t.length-1&&Uu(t[n-1])&&Uu(t[n+1])?" ":e)).join("")})(t);return n!==t&&(e.data=n,!0)})(n)||$p(e,n,!1);return It(o,t)}if(Up(e,t)){const o=Hp(e,n,!0)||$p(e,n,!0);return It(o,t)}return I.none()},qp=(e,t,n)=>{if(0===n)return;const o=yn(e),r=Qn(o,xr).getOr(o),s=e.data.slice(t,t+n),a=t+n>=e.data.length&&Fp(r,Li(e,e.data.length)),i=0===t&&Ip(r,Li(e,0));e.replaceData(t,n,ms(s,4,i,a))},Wp=(e,t)=>{const n=e.data.slice(t),o=n.length-We(n).length;qp(e,t,o)},Kp=(e,t)=>{const n=e.data.slice(0,t),o=n.length-Ke(n).length;qp(e,t-o,o)},Gp=(e,t,n,o=!0)=>{const r=Ke(e.data).length,s=o?e:t,a=o?t:e;return o?s.appendData(a.data):s.insertData(0,a.data),wo(yn(a)),n&&Wp(s,r),s},Yp=(e,t)=>((e,t)=>{const n=e.container(),o=e.offset();return!Li.isTextPosition(e)&&n===t.parentNode&&o>Li.before(t).offset()})(t,e)?Li(t.container(),t.offset()-1):t,Xp=e=>{return ss(e.previousSibling)?I.some((t=e.previousSibling,Jo(t)?Li(t,t.data.length):Li.after(t))):e.previousSibling?Cu(e.previousSibling):I.none();var t},Qp=e=>{return ss(e.nextSibling)?I.some((t=e.nextSibling,Jo(t)?Li(t,0):Li.before(t))):e.nextSibling?yu(e.nextSibling):I.none();var t},Jp=(e,t,n)=>((e,t,n)=>e?((e,t)=>Qp(t).orThunk((()=>Xp(t))).orThunk((()=>((e,t)=>bu(e,Li.after(t)).orThunk((()=>vu(e,Li.before(t)))))(e,t))))(t,n):((e,t)=>Xp(t).orThunk((()=>Qp(t))).orThunk((()=>((e,t)=>I.from(t.previousSibling?t.previousSibling:t.parentNode).bind((t=>vu(e,Li.before(t)))).orThunk((()=>bu(e,Li.after(t)))))(e,t))))(t,n))(e,t,n).map(O(Yp,n)),Zp=(e,t,n)=>{n.fold((()=>{e.focus()}),(n=>{e.selection.setRng(n.toRange(),t)}))},eh=(e,t)=>t&&ke(e.schema.getBlockElements(),Ht(t)),th=e=>{if(bs(e)){const t=hn('<br data-mce-bogus="1">');return Co(e),bo(e,t),I.some(Li.before(t.dom))}return I.none()},nh=(e,t,n,o=!0)=>{const r=Jp(t,e.getBody(),n.dom),s=Qn(n,O(eh,e),(a=e.getBody(),e=>e.dom===a));var a;const i=((e,t,n)=>{const o=Bn(e).filter(Kt),r=Dn(e).filter(Kt);return wo(e),(s=o,a=r,i=t,l=(e,t,o)=>{const r=e.dom,s=t.dom,a=r.data.length;return Gp(r,s,n),o.container()===s?Li(r,a):o},s.isSome()&&a.isSome()&&i.isSome()?I.some(l(s.getOrDie(),a.getOrDie(),i.getOrDie())):I.none()).orThunk((()=>(n&&(o.each((e=>Kp(e.dom,e.dom.length))),r.each((e=>Wp(e.dom,0)))),t)));var s,a,i,l})(n,r,((e,t)=>ke(e.schema.getTextInlineElements(),Ht(t)))(e,n));e.dom.isEmpty(e.getBody())?(e.setContent(""),e.selection.setCursorLocation()):s.bind(th).fold((()=>{o&&Zp(e,t,i)}),(n=>{o&&Zp(e,t,I.some(n))}))},oh=/[\u0591-\u07FF\uFB1D-\uFDFF\uFE70-\uFEFC]/,rh=(e,t)=>xn(yn(t),Zl(e))&&!As(e.schema,t)&&e.dom.isEditable(t),sh=e=>{var t;return"rtl"===Oa.DOM.getStyle(e,"direction",!0)||(e=>oh.test(e))(null!==(t=e.textContent)&&void 0!==t?t:"")},ah=(e,t,n)=>{const o=((e,t,n)=>G(Oa.DOM.getParents(n.container(),"*",t),e))(e,t,n);return I.from(o[o.length-1])},ih=(e,t)=>{const n=t.container(),o=t.offset();return e?Hr(n)?Jo(n.nextSibling)?Li(n.nextSibling,0):Li.after(n):qr(t)?Li(n,o+1):t:Hr(n)?Jo(n.previousSibling)?Li(n.previousSibling,n.previousSibling.data.length):Li.before(n):Wr(t)?Li(n,o-1):t},lh=O(ih,!0),dh=O(ih,!1),ch=(e,t)=>{const n=e=>e.stopImmediatePropagation();e.on("beforeinput input",n,!0),e.getDoc().execCommand(t),e.off("beforeinput input",n)},uh=e=>ch(e,"Delete"),mh=e=>Sr(e)||Nr(e),fh=(e,t)=>Sn(e,t)?Jn(t,mh,(e=>t=>Pt(An(t),e,En))(e)):I.none(),gh=(e,t=!0)=>{e.dom.isEmpty(e.getBody())&&e.setContent("",{no_selection:!t})},ph=(e,t,n)=>Mt(yu(n),Cu(n),((o,r)=>{const s=ih(!0,o),a=ih(!1,r),i=ih(!1,t);return e?bu(n,i).exists((e=>e.isEqual(a)&&t.isEqual(s))):vu(n,i).exists((e=>e.isEqual(s)&&t.isEqual(a)))})).getOr(!0),hh=e=>{var t;return(8===$t(t=e)||"#comment"===Ht(t)?Bn(e):Un(e)).bind(hh).orThunk((()=>I.some(e)))},bh=(e,t,n,o=!0)=>{var r;t.deleteContents();const s=hh(n).getOr(n),a=yn(null!==(r=e.dom.getParent(s.dom,e.dom.isBlock))&&void 0!==r?r:n.dom);if(a.dom===e.getBody()?gh(e,o):bs(a)&&(Pr(a),o&&e.selection.setCursorLocation(a.dom,0)),!En(n,a)){const e=Pt(An(a),n)?[]:An(i=a).map(Mn).map((e=>G(e,(e=>!En(i,e))))).getOr([]);q(e.concat(Mn(n)),(e=>{En(e,a)||Sn(e,a)||!bs(e)||wo(e)}))}var i},vh=e=>Fo(e,"td,th"),yh=(e,t)=>({start:e,end:t}),Ch=al([{singleCellTable:["rng","cell"]},{fullTable:["table"]},{partialTable:["cells","outsideDetails"]},{multiTable:["startTableCells","endTableCells","betweenRng"]}]),wh=(e,t)=>to(yn(e),"td,th",t),xh=e=>!En(e.start,e.end),kh=(e,t)=>Xu(e.start,t).bind((n=>Xu(e.end,t).bind((e=>It(En(n,e),n))))),Eh=e=>t=>kh(t,e).map((e=>((e,t,n)=>({rng:e,table:t,cells:n}))(t,e,vh(e)))),Sh=(e,t,n,o)=>{if(n.collapsed||!e.forall(xh))return I.none();if(t.isSameTable){const t=e.bind(Eh(o));return I.some({start:t,end:t})}{const e=wh(n.startContainer,o),t=wh(n.endContainer,o),r=e.bind((e=>t=>Xu(t,e).bind((e=>de(vh(e)).map((e=>yh(t,e))))))(o)).bind(Eh(o)),s=t.bind((e=>t=>Xu(t,e).bind((e=>le(vh(e)).map((e=>yh(e,t))))))(o)).bind(Eh(o));return I.some({start:r,end:s})}},_h=(e,t)=>Z(e,(e=>En(e,t))),Nh=e=>Mt(_h(e.cells,e.rng.start),_h(e.cells,e.rng.end),((t,n)=>e.cells.slice(t,n+1))),Rh=(e,t)=>{const{startTable:n,endTable:o}=t,r=e.cloneRange();return n.each((e=>r.setStartAfter(e.dom))),o.each((e=>r.setEndBefore(e.dom))),r},Ah=(e,t)=>{const n=(e=>t=>En(e,t))(e),o=((e,t)=>{const n=wh(e.startContainer,t),o=wh(e.endContainer,t);return Mt(n,o,yh)})(t,n),r=((e,t)=>{const n=e=>Xu(yn(e),t),o=n(e.startContainer),r=n(e.endContainer),s=o.isSome(),a=r.isSome(),i=Mt(o,r,En).getOr(!1);return{startTable:o,endTable:r,isStartInTable:s,isEndInTable:a,isSameTable:i,isMultiTable:!i&&s&&a}})(t,n);return((e,t,n)=>e.exists((e=>((e,t)=>!xh(e)&&kh(e,t).exists((e=>{const t=e.dom.rows;return 1===t.length&&1===t[0].cells.length})))(e,n)&&Zu(e.start,t))))(o,t,n)?o.map((e=>Ch.singleCellTable(t,e.start))):r.isMultiTable?((e,t,n,o)=>Sh(e,t,n,o).bind((({start:e,end:o})=>{const r=e.bind(Nh).getOr([]),s=o.bind(Nh).getOr([]);if(r.length>0&&s.length>0){const e=Rh(n,t);return I.some(Ch.multiTable(r,s,e))}return I.none()})))(o,r,t,n):((e,t,n,o)=>Sh(e,t,n,o).bind((({start:e,end:t})=>e.or(t))).bind((e=>{const{isSameTable:o}=t,r=Nh(e).getOr([]);if(o&&e.cells.length===r.length)return I.some(Ch.fullTable(e.table));if(r.length>0){if(o)return I.some(Ch.partialTable(r,I.none()));{const e=Rh(n,t);return I.some(Ch.partialTable(r,I.some({...t,rng:e})))}}return I.none()})))(o,r,t,n)},Oh=e=>q(e,(e=>{on(e,"contenteditable"),Pr(e)})),Th=(e,t,n,o)=>{const r=n.cloneRange();o?(r.setStart(n.startContainer,n.startOffset),r.setEndAfter(t.dom.lastChild)):(r.setStartBefore(t.dom.firstChild),r.setEnd(n.endContainer,n.endOffset)),Lh(e,r,t,!1).each((e=>e()))},Bh=e=>{const t=Yu(e),n=yn(e.selection.getNode());lr(n.dom)&&bs(n)?e.selection.setCursorLocation(n.dom,0):e.selection.collapse(!0),t.length>1&&$(t,(e=>En(e,n)))&&Jt(n,"data-mce-selected","1")},Dh=(e,t,n)=>I.some((()=>{const o=e.selection.getRng(),r=n.bind((({rng:n,isStartInTable:r})=>{const s=((e,t)=>I.from(e.dom.getParent(t,e.dom.isBlock)).map(yn))(e,r?n.endContainer:n.startContainer);n.deleteContents(),((e,t,n)=>{n.each((n=>{t?wo(n):(Pr(n),e.selection.setCursorLocation(n.dom,0))}))})(e,r,s.filter(bs));const a=r?t[0]:t[t.length-1];return Th(e,a,o,r),bs(a)?I.none():I.some(r?t.slice(1):t.slice(0,-1))})).getOr(t);Oh(r),Bh(e)})),Ph=(e,t,n,o)=>I.some((()=>{const r=e.selection.getRng(),s=t[0],a=n[n.length-1];Th(e,s,r,!0),Th(e,a,r,!1);const i=bs(s)?t:t.slice(1),l=bs(a)?n:n.slice(0,-1);Oh(i.concat(l)),o.deleteContents(),Bh(e)})),Lh=(e,t,n,o=!0)=>I.some((()=>{bh(e,t,n,o)})),Mh=(e,t)=>I.some((()=>nh(e,!1,t))),Ih=(e,t)=>J(pp(t,e),Ar),Fh=(e,t)=>J(pp(t,e),Xt("caption")),Uh=(e,t)=>I.some((()=>{Pr(t),e.selection.setCursorLocation(t.dom,0)})),zh=(e,t)=>e?cp(t):up(t),jh=(e,t,n)=>{const o=yn(e.getBody());return Fh(o,n).fold((()=>((e,t,n,o)=>{const r=Li.fromRangeStart(e.selection.getRng());return Ih(n,o).bind((o=>bs(o)?Uh(e,o):((e,t,n,o,r)=>gu(n,e.getBody(),r).bind((e=>Ih(t,yn(e.getNode())).bind((e=>En(e,o)?I.none():I.some(E))))))(e,n,t,o,r)))})(e,t,o,n).orThunk((()=>It(((e,t)=>{const n=Li.fromRangeStart(e.selection.getRng());return zh(t,n)||fu(t,e.getBody(),n).exists((e=>zh(t,e)))})(e,t),E)))),(n=>((e,t,n,o)=>{const r=Li.fromRangeStart(e.selection.getRng());return bs(o)?Uh(e,o):((e,t,n,o,r)=>gu(n,e.getBody(),r).fold((()=>I.some(E)),(s=>((e,t,n,o)=>yu(e.dom).bind((r=>Cu(e.dom).map((e=>t?n.isEqual(r)&&o.isEqual(e):n.isEqual(e)&&o.isEqual(r))))).getOr(!0))(o,n,r,s)?((e,t)=>Uh(e,t))(e,o):((e,t,n)=>Fh(e,yn(n.getNode())).fold((()=>I.some(E)),(e=>It(!En(e,t),E))))(t,o,s))))(e,n,t,o,r)})(e,t,o,n)))},Hh=(e,t)=>{const n=yn(e.selection.getStart(!0)),o=Yu(e);return e.selection.isCollapsed()&&0===o.length?jh(e,t,n):((e,t,n)=>{const o=yn(e.getBody()),r=e.selection.getRng();return 0!==n.length?Dh(e,n,I.none()):((e,t,n,o)=>Fh(t,o).fold((()=>((e,t,n)=>Ah(t,n).bind((t=>t.fold(O(Lh,e),O(Mh,e),O(Dh,e),O(Ph,e)))))(e,t,n)),(t=>((e,t)=>Uh(e,t))(e,t))))(e,o,r,t)})(e,n,o)},$h=(e,t)=>{let n=t;for(;n&&n!==e;){if(ar(n)||ir(n))return n;n=n.parentNode}return null},Vh=["data-ephox-","data-mce-","data-alloy-","data-snooker-","_"],qh=Dt.each,Wh=e=>{const t=e.dom,n=new Set(e.serializer.getTempAttrs()),o=e=>$(Vh,(t=>He(e,t)))||n.has(e);return{compare:(e,n)=>{if(e.nodeName!==n.nodeName||e.nodeType!==n.nodeType)return!1;const r=e=>{const n={};return qh(t.getAttribs(e),(r=>{const s=r.nodeName.toLowerCase();"style"===s||o(s)||(n[s]=t.getAttrib(e,s))})),n},s=(e,t)=>{for(const n in e)if(ke(e,n)){const o=t[n];if(v(o))return!1;if(e[n]!==o)return!1;delete t[n]}for(const e in t)if(ke(t,e))return!1;return!0};if($o(e)&&$o(n)){if(!s(r(e),r(n)))return!1;if(!s(t.parseStyle(t.getAttrib(e,"style")),t.parseStyle(t.getAttrib(n,"style"))))return!1}return!Lu(e)&&!Lu(n)},isAttributeInternal:o}},Kh=(e,t,n,o)=>{const r=n.name;for(let t=0,s=e.length;t<s;t++){const s=e[t];if(s.name===r){const e=o.nodes[r];e?e.nodes.push(n):o.nodes[r]={filter:s,nodes:[n]}}}if(n.attributes)for(let e=0,r=t.length;e<r;e++){const r=t[e],s=r.name;if(s in n.attributes.map){const e=o.attributes[s];e?e.nodes.push(n):o.attributes[s]={filter:r,nodes:[n]}}}},Gh=(e,t)=>{const n=(e,n)=>{ge(e,(e=>{const o=ce(e.nodes);q(e.filter.callbacks,(r=>{for(let t=o.length-1;t>=0;t--){const r=o[t];(n?void 0!==r.attr(e.filter.name):r.name===e.filter.name)&&!y(r.parent)||o.splice(t,1)}o.length>0&&r(o,e.filter.name,t)}))}))};n(e.nodes,!1),n(e.attributes,!0)},Yh=(e,t,n,o={})=>{const r=((e,t,n)=>{const o={nodes:{},attributes:{}};return n.firstChild&&((n,r)=>{let s=n;for(;s=s.walk();)Kh(e,t,s,o)})(n),o})(e,t,n);Gh(r,o)},Xh=(e,t,n,o)=>{if((e.pad_empty_with_br||t.insert)&&n(o)){const e=new Fg("br",1);t.insert&&e.attr("data-mce-bogus","1"),o.empty().append(e)}else o.empty().append(new Fg("#text",3)).value=pr},Qh=(e,t)=>{const n=null==e?void 0:e.firstChild;return C(n)&&n===e.lastChild&&n.name===t},Jh=(e,t,n,o)=>o.isEmpty(t,n,(t=>((e,t)=>{const n=e.getElementRule(t.name);return!0===(null==n?void 0:n.paddEmpty)})(e,t))),Zh=e=>{let t;for(let n=e;n;n=n.parent){const e=n.attr("contenteditable");if("false"===e)break;"true"===e&&(t=n)}return I.from(t)},eb=(e,t,n=e.parent)=>{if(t.getSpecialElements()[e.name])e.empty().remove();else{const o=e.children();for(const e of o)n&&!t.isValidChild(n.name,e.name)&&eb(e,t,n);e.unwrap()}},tb=(e,t,n,o=E)=>{const r=t.getTextBlockElements(),s=t.getNonEmptyElements(),a=t.getWhitespaceElements(),i=Dt.makeMap("tr,td,th,tbody,thead,tfoot,table,summary"),l=new Set,d=e=>e!==n&&!i[e.name];for(let n=0;n<e.length;n++){const i=e[n];let c,u,m;if(!i.parent||l.has(i))continue;if(r[i.name]&&"li"===i.parent.name){let e=i.next;for(;e&&r[e.name];)e.name="li",l.add(e),i.parent.insert(e,i.parent),e=e.next;i.unwrap();continue}const f=[i];for(c=i.parent;c&&!t.isValidChild(c.name,i.name)&&d(c);c=c.parent)f.push(c);if(c&&f.length>1)if(t.isValidChild(c.name,i.name)){f.reverse(),u=f[0].clone(),o(u);let e=u;for(let n=0;n<f.length-1;n++){t.isValidChild(e.name,f[n].name)&&n>0?(m=f[n].clone(),o(m),e.append(m)):m=e;for(let e=f[n].firstChild;e&&e!==f[n+1];){const t=e.next;m.append(e),e=t}e=m}Jh(t,s,a,u)?c.insert(i,f[0],!0):(c.insert(u,f[0],!0),c.insert(i,u)),c=f[0],(Jh(t,s,a,c)||Qh(c,"br"))&&c.empty().remove()}else eb(i,t);else if(i.parent){if("li"===i.name){let e=i.prev;if(e&&("ul"===e.name||"ol"===e.name)){e.append(i);continue}if(e=i.next,e&&("ul"===e.name||"ol"===e.name)&&e.firstChild){e.insert(i,e.firstChild,!0);continue}const t=new Fg("ul",1);o(t),i.wrap(t);continue}if(t.isValidChild(i.parent.name,"div")&&t.isValidChild("div",i.name)){const e=new Fg("div",1);o(e),i.wrap(e)}else eb(i,t)}}},nb=(e,t,n=t.parent)=>!(!n||!e.children[t.name]||e.isValidChild(n.name,t.name))||!(!n||"a"!==t.name||!((e,t)=>{let n=e;for(;n;){if("a"===n.name)return!0;n=n.parent}return!1})(n)),ob=e=>e.collapsed?e:(e=>{const t=Li.fromRangeStart(e),n=Li.fromRangeEnd(e),o=e.commonAncestorContainer;return fu(!1,o,n).map((r=>!Uc(t,n,o)&&Uc(t,r,o)?((e,t,n,o)=>{const r=document.createRange();return r.setStart(e,t),r.setEnd(n,o),r})(t.container(),t.offset(),r.container(),r.offset()):e)).getOr(e)})(e),rb=(e,t)=>{let n=t.firstChild,o=t.lastChild;return n&&"meta"===n.name&&(n=n.next),o&&"mce_marker"===o.attr("id")&&(o=o.prev),((e,t)=>{const n=e.getNonEmptyElements();return C(t)&&(t.isEmpty(n)||((e,t)=>e.getBlockElements()[t.name]&&(e=>C(e.firstChild)&&e.firstChild===e.lastChild)(t)&&(e=>"br"===e.name||e.value===pr)(t.firstChild))(e,t))})(e,o)&&(o=null==o?void 0:o.prev),!(!n||n!==o||"ul"!==n.name&&"ol"!==n.name)},sb=e=>{return e.length>0&&(!(n=e[e.length-1]).firstChild||C(null==(t=n)?void 0:t.firstChild)&&t.firstChild===t.lastChild&&(e=>e.data===pr||rr(e))(t.firstChild))?e.slice(0,-1):e;var t,n},ab=(e,t)=>{const n=e.getParent(t,e.isBlock);return n&&"LI"===n.nodeName?n:null},ib=(e,t)=>{const n=Li.after(e),o=du(t).prev(n);return o?o.toRange():null},lb=(e,t,n,o)=>{const r=((e,t,n)=>{const o=t.serialize(n);return(e=>{var t,n;const o=e.firstChild,r=e.lastChild;return o&&"META"===o.nodeName&&(null===(t=o.parentNode)||void 0===t||t.removeChild(o)),r&&"mce_marker"===r.id&&(null===(n=r.parentNode)||void 0===n||n.removeChild(r)),e})(e.createFragment(o))})(t,e,o),s=ab(t,n.startContainer),a=sb((i=r.firstChild,G(null!==(l=null==i?void 0:i.childNodes)&&void 0!==l?l:[],(e=>"LI"===e.nodeName))));var i,l;const d=t.getRoot(),c=e=>{const o=Li.fromRangeStart(n),r=du(t.getRoot()),a=1===e?r.prev(o):r.next(o),i=null==a?void 0:a.getNode();return!i||ab(t,i)!==s};return s?c(1)?((e,t,n)=>{const o=e.parentNode;return o&&Dt.each(t,(t=>{o.insertBefore(t,e)})),((e,t)=>{const n=Li.before(e),o=du(t).next(n);return o?o.toRange():null})(e,n)})(s,a,d):c(2)?((e,t,n,o)=>(o.insertAfter(t.reverse(),e),ib(t[0],n)))(s,a,d,t):((e,t,n,o)=>{const r=((e,t)=>{const n=t.cloneRange(),o=t.cloneRange();return n.setStartBefore(e),o.setEndAfter(e),[n.cloneContents(),o.cloneContents()]})(e,o),s=e.parentNode;return s&&(s.insertBefore(r[0],e),Dt.each(t,(t=>{s.insertBefore(t,e)})),s.insertBefore(r[1],e),s.removeChild(e)),ib(t[t.length-1],n)})(s,a,d,n):null},db=["pre"],cb=lr,ub=(e,t,n)=>{var o,r;const s=e.selection,a=e.dom,i=e.parser,l=n.merge,d=Gg({validate:!0},e.schema),c='<span id="mce_marker" data-mce-type="bookmark"></span>';-1===t.indexOf("{$caret}")&&(t+="{$caret}"),t=t.replace(/\{\$caret\}/,c);let u=s.getRng();const m=u.startContainer,f=e.getBody();m===f&&s.isCollapsed()&&a.isBlock(f.firstChild)&&((e,t)=>C(t)&&!e.schema.getVoidElements()[t.nodeName])(e,f.firstChild)&&a.isEmpty(f.firstChild)&&(u=a.createRng(),u.setStart(f.firstChild,0),u.setEnd(f.firstChild,0),s.setRng(u)),s.isCollapsed()||(e=>{const t=e.dom,n=ob(e.selection.getRng());e.selection.setRng(n);const o=t.getParent(n.startContainer,cb);((e,t,n)=>!!C(n)&&n===e.getParent(t.endContainer,cb)&&Zu(yn(n),t))(t,n,o)?Lh(e,n,yn(o)):n.startContainer===n.endContainer&&n.endOffset-n.startOffset==1&&Jo(n.startContainer.childNodes[n.startOffset])?n.deleteContents():e.getDoc().execCommand("Delete",!1)})(e);const g=s.getNode(),p={context:g.nodeName.toLowerCase(),data:n.data,insert:!0},h=i.parse(t,p);if(!0===n.paste&&rb(e.schema,h)&&((e,t)=>!!ab(e,t))(a,g))return u=lb(d,a,s.getRng(),h),u&&s.setRng(u),t;!0===n.paste&&((e,t,n,o)=>{var r;const s=t.firstChild,a=t.lastChild,i=s===("bookmark"===a.attr("data-mce-type")?a.prev:a),l=H(db,s.name);if(i&&l){const t="false"!==s.attr("contenteditable"),a=(null===(r=e.getParent(n,e.isBlock))||void 0===r?void 0:r.nodeName.toLowerCase())===s.name,i=I.from($h(o,n)).forall(ar);return t&&a&&i}return!1})(a,h,g,e.getBody())&&(null===(o=h.firstChild)||void 0===o||o.unwrap()),(e=>{let t=e;for(;t=t.walk();)1===t.type&&t.attr("data-mce-fragment","1")})(h);let b=h.lastChild;if(b&&"mce_marker"===b.attr("id")){const t=b;for(b=b.prev;b;b=b.walk(!0))if(3===b.type||!a.isBlock(b.name)){b.parent&&e.schema.isValidChild(b.parent.name,"span")&&b.parent.insert(t,b,"br"===b.name);break}}if(e._selectionOverrides.showBlockCaretContainer(g),p.invalid){e.selection.setContent(c);let n,o=s.getNode();const l=e.getBody();for(nr(o)?o=n=l:n=o;n&&n!==l;)o=n,n=n.parentNode;t=o===l?l.innerHTML:a.getOuterHTML(o);const u=i.parse(t),m=(e=>{for(let t=e;t;t=t.walk())if("mce_marker"===t.attr("id"))return I.some(t);return I.none()})(u),f=m.bind(Zh).getOr(u);m.each((e=>e.replace(h)));const g=h.children(),p=null!==(r=h.parent)&&void 0!==r?r:u;h.unwrap();const b=G(g,(t=>nb(e.schema,t,p)));tb(b,e.schema,f),Yh(i.getNodeFilters(),i.getAttributeFilters(),u),t=d.serialize(u),o===l?a.setHTML(l,t):a.setOuterHTML(o,t)}else t=d.serialize(h),((e,t,n)=>{var o;if("all"===n.getAttribute("data-mce-bogus"))null===(o=n.parentNode)||void 0===o||o.insertBefore(e.dom.createFragment(t),n);else{const o=n.firstChild,r=n.lastChild;!o||o===r&&"BR"===o.nodeName?e.dom.setHTML(n,t):e.selection.setContent(t,{no_events:!0})}})(e,t,g);var v;return((e,t)=>{const n=e.schema.getTextInlineElements(),o=e.dom;if(t){const t=e.getBody(),r=Wh(e);Dt.each(o.select("*[data-mce-fragment]"),(e=>{if(C(n[e.nodeName.toLowerCase()])&&((e,t)=>ne(Qg(e,t),(e=>!(e=>Yg.has(e))(e))))(o,e))for(let n=e.parentElement;C(n)&&n!==t&&!Jg(o,e,n);n=n.parentElement)if(r.compare(n,e)){o.remove(e,!0);break}}))}})(e,l),((e,t)=>{var n,o,r;let s;const a=e.dom,i=e.selection;if(!t)return;i.scrollIntoView(t);const l=$h(e.getBody(),t);if(l&&"false"===a.getContentEditable(l))return a.remove(t),void i.select(l);let d=a.createRng();const c=t.previousSibling;if(Jo(c)){d.setStart(c,null!==(o=null===(n=c.nodeValue)||void 0===n?void 0:n.length)&&void 0!==o?o:0);const e=t.nextSibling;Jo(e)&&(c.appendData(e.data),null===(r=e.parentNode)||void 0===r||r.removeChild(e))}else d.setStartBefore(t),d.setEndBefore(t);const u=a.getParent(t,a.isBlock);if(a.remove(t),u&&a.isEmpty(u)){const t=cb(u);Co(yn(u)),d.setStart(u,0),d.setEnd(u,0),t||(e=>!!e.getAttribute("data-mce-fragment"))(u)||!(s=(t=>{let n=Li.fromRangeStart(t);return n=du(e.getBody()).next(n),null==n?void 0:n.toRange()})(d))?a.add(u,a.create("br",t?{}:{"data-mce-bogus":"1"})):(d=s,a.remove(u))}i.setRng(d)})(e,a.get("mce_marker")),v=e.getBody(),Dt.each(v.getElementsByTagName("*"),(e=>{e.removeAttribute("data-mce-fragment")})),((e,t)=>{I.from(e.getParent(t,"td,th")).map(yn).each(Lr)})(a,s.getStart()),((e,t,n)=>{const o=Tn(yn(n),(e=>En(e,yn(t))));ie(o,o.length-2).filter(Wt).fold((()=>Es(e,t)),(t=>Es(e,t.dom)))})(e.schema,e.getBody(),s.getStart()),t},mb=e=>e instanceof Fg,fb=(e,t,n)=>{e.dom.setHTML(e.getBody(),t),!0!==n&&(e=>{xg(e)&&yu(e.getBody()).each((t=>{const n=t.getNode(),o=Yo(n)?yu(n).getOr(t):t;e.selection.setRng(o.toRange())}))})(e)},gb=(e,t)=>((e,t)=>{const n=e.dom;return n.parentNode?((e,t)=>J(e.dom.childNodes,(e=>t(yn(e)))).map(yn))(yn(n.parentNode),(n=>!En(e,n)&&t(n))):I.none()})(e,t).isSome(),pb=e=>w(e)?e:L,hb=(e,t,n)=>{const o=t(e),r=pb(n);return o.orThunk((()=>r(e)?I.none():((e,t,n)=>{let o=e.dom;const r=pb(n);for(;o.parentNode;){o=o.parentNode;const e=yn(o),n=t(e);if(n.isSome())return n;if(r(e))break}return I.none()})(e,t,r)))},bb=pm,vb=(e,t,n)=>{const o=e.formatter.get(n);if(o)for(let n=0;n<o.length;n++){const r=o[n];if(xm(r)&&!1===r.inherit&&e.dom.is(t,r.selector))return!0}return!1},yb=(e,t,n,o,r)=>{const s=e.dom.getRoot();if(t===s)return!1;const a=e.dom.getParent(t,(t=>!!vb(e,t,n)||t.parentNode===s||!!xb(e,t,n,o,!0)));return!!xb(e,a,n,o,r)},Cb=(e,t,n)=>!(!km(n)||!bb(t,n.inline))||!(!wm(n)||!bb(t,n.block))||!!xm(n)&&$o(t)&&e.is(t,n.selector),wb=(e,t,n,o,r,s)=>{const a=n[o],i="attributes"===o;if(w(n.onmatch))return n.onmatch(t,n,o);if(a)if(_e(a)){for(let n=0;n<a.length;n++)if(i?e.getAttrib(t,a[n]):bm(e,t,a[n]))return!0}else for(const o in a)if(ke(a,o)){const l=i?e.getAttrib(t,o):bm(e,t,o),d=gm(a[o],s),c=y(l)||Ye(l);if(c&&y(d))continue;if(r&&c&&!n.exact)return!1;if((!r||n.exact)&&!bb(l,hm(d,o)))return!1}return!0},xb=(e,t,n,o,r)=>{const s=e.formatter.get(n),a=e.dom;if(s&&$o(t))for(let n=0;n<s.length;n++){const i=s[n];if(Cb(e.dom,t,i)&&wb(a,t,i,"attributes",r,o)&&wb(a,t,i,"styles",r,o)){const n=i.classes;if(n)for(let r=0;r<n.length;r++)if(!e.dom.hasClass(t,gm(n[r],o)))return;return i}}},kb=(e,t,n,o,r)=>{if(o)return yb(e,o,t,n,r);if(o=e.selection.getNode(),yb(e,o,t,n,r))return!0;const s=e.selection.getStart();return!(s===o||!yb(e,s,t,n,r))},Eb=Mr,Sb=e=>(e=>{const t=[];let n=e;for(;n;){if(Jo(n)&&n.data!==Eb||n.childNodes.length>1)return[];$o(n)&&t.push(n),n=n.firstChild}return t})(e).length>0,_b=e=>{if(e){const t=new zo(e,e);for(let e=t.current();e;e=t.next())if(Jo(e))return e}return null},Nb=e=>{const t=bn("span");return Zt(t,{id:wu,"data-mce-bogus":"1","data-mce-type":"format-caret"}),e&&bo(t,vn(Eb)),t},Rb=(e,t,n=!0)=>{const o=e.dom,r=e.selection;if(Sb(t))nh(e,!1,yn(t),n);else{const e=r.getRng(),n=o.getParent(t,o.isBlock),s=e.startContainer,a=e.startOffset,i=e.endContainer,l=e.endOffset,d=(e=>{const t=_b(e);return t&&t.data.charAt(0)===Eb&&t.deleteData(0,1),t})(t);o.remove(t,!0),s===d&&a>0&&e.setStart(d,a-1),i===d&&l>0&&e.setEnd(d,l-1),n&&o.isEmpty(n)&&Pr(yn(n)),r.setRng(e)}},Ab=(e,t,n=!0)=>{const o=e.dom,r=e.selection;if(t)Rb(e,t,n);else if(!(t=ku(e.getBody(),r.getStart())))for(;t=o.get(wu);)Rb(e,t,n)},Ob=(e,t)=>(e.appendChild(t),t),Tb=(e,t)=>{var n;const o=Y(e,((e,t)=>Ob(e,t.cloneNode(!1))),t),r=null!==(n=o.ownerDocument)&&void 0!==n?n:document;return Ob(o,r.createTextNode(Eb))},Bb=(e,t,n,o)=>{const a=e.dom,i=e.selection;let l=!1;const d=e.formatter.get(t);if(!d)return;const c=i.getRng(),u=c.startContainer,m=c.startOffset;let f=u;Jo(u)&&(m!==u.data.length&&(l=!0),f=f.parentNode);const g=[];let h;for(;f;){if(xb(e,f,t,n,o)){h=f;break}f.nextSibling&&(l=!0),g.push(f),f=f.parentNode}if(h)if(l){const r=i.getBookmark();c.collapse(!0);let s=Um(a,c,d,!0);s=Bf(s),e.formatter.remove(t,n,s,o),i.moveToBookmark(r)}else{const l=ku(e.getBody(),h),d=Nb(!1).dom;((e,t,n)=>{var o,r;const s=e.dom,a=s.getParent(n,O(cm,e.schema));a&&s.isEmpty(a)?null===(o=n.parentNode)||void 0===o||o.replaceChild(t,n):((e=>{const t=Fo(e,"br"),n=G((e=>{const t=[];let n=e.dom;for(;n;)t.push(yn(n)),n=n.lastChild;return t})(e).slice(-1),Er);t.length===n.length&&q(n,wo)})(yn(n)),s.isEmpty(n)?null===(r=n.parentNode)||void 0===r||r.replaceChild(t,n):s.insertAfter(t,n))})(e,d,null!=l?l:h);const c=((e,t,n,o,a,i)=>{const l=e.formatter,d=e.dom,c=G(me(l.get()),(e=>e!==o&&!je(e,"removeformat"))),u=((e,t,n)=>X(n,((n,o)=>{const r=((e,t)=>Cm(e,t,(e=>{const t=e=>w(e)||e.length>1&&"%"===e.charAt(0);return $(["styles","attributes"],(n=>xe(e,n).exists((e=>{const n=p(e)?e:we(e);return $(n,t)}))))})))(e,o);return e.formatter.matchNode(t,o,{},r)?n.concat([o]):n}),[]))(e,n,c);if(G(u,(t=>!((e,t,n)=>{const o=["inline","block","selector","attributes","styles","classes"],a=e=>ye(e,((e,t)=>$(o,(e=>e===t))));return Cm(e,t,(t=>{const o=a(t);return Cm(e,n,(e=>{const t=a(e);return((e,t,n=s)=>r(n).eq(e,t))(o,t)}))}))})(e,t,o))).length>0){const e=n.cloneNode(!1);return d.add(t,e),l.remove(o,a,e,i),d.remove(e),I.some(e)}return I.none()})(e,d,h,t,n,o),u=Tb(g.concat(c.toArray()),d);l&&Rb(e,l,!1),i.setCursorLocation(u,1),a.isEmpty(h)&&a.remove(h)}},Db=e=>{const t=Nb(!1),n=Tb(e,t.dom);return{caretContainer:t,caretPosition:Li(n,0)}},Pb=(e,t)=>{const{caretContainer:n,caretPosition:o}=Db(t);return go(yn(e),n),wo(yn(e)),o},Lb=(e,t)=>{const n=e.schema.getTextInlineElements();return ke(n,Ht(t))&&!xu(t.dom)&&!Go(t.dom)},Mb=e=>xu(e.dom)&&Sb(e.dom),Ib={},Fb=qo(["pre"]);((e,t)=>{Ib[e]||(Ib[e]=[]),Ib[e].push((e=>{if(!e.selection.getRng().collapsed){const t=e.selection.getSelectedBlocks(),n=G(G(t,Fb),(e=>t=>{const n=t.previousSibling;return Fb(n)&&H(e,n)})(t));q(n,(e=>{((e,t)=>{const n=yn(t),o=Nn(n).dom;wo(n),yo(yn(e),[bn("br",o),bn("br",o),...Mn(n)])})(e.previousSibling,e)}))}}))})("pre");const Ub=["fontWeight","fontStyle","color","fontSize","fontFamily"],zb=(e,t)=>{const n=e.get(t);return p(n)?J(n,(e=>km(e)&&"span"===e.inline&&(e=>f(e.styles)&&$(me(e.styles),(e=>H(Ub,e))))(e))):I.none()},jb=(e,t)=>vu(t,Li.fromRangeStart(e)).isNone(),Hb=(e,t)=>!1===bu(t,Li.fromRangeEnd(e)).exists((e=>!rr(e.getNode())||bu(t,e).isSome())),$b=e=>t=>ur(t)&&e.isEditable(t),Vb=e=>G(e.getSelectedBlocks(),$b(e.dom)),qb=Dt.each,Wb=e=>$o(e)&&!Lu(e)&&!xu(e)&&!Go(e),Kb=(e,t)=>{for(let n=e;n;n=n[t]){if(Jo(n)&&Ge(n.data))return e;if($o(n)&&!Lu(n))return n}return e},Gb=(e,t,n)=>{const o=Wh(e),r=$o(t)&&am(t),s=$o(n)&&am(n);if(r&&s){const r=Kb(t,"previousSibling"),s=Kb(n,"nextSibling");if(o.compare(r,s)){for(let e=r.nextSibling;e&&e!==s;){const t=e;e=e.nextSibling,r.appendChild(t)}return e.dom.remove(s),Dt.each(Dt.grep(s.childNodes),(e=>{r.appendChild(e)})),r}}return n},Yb=(e,t,n,o)=>{var r;if(o&&!1!==t.merge_siblings){const t=null!==(r=Gb(e,dm(o),o))&&void 0!==r?r:o;Gb(e,t,dm(t,!0))}},Xb=(e,t,n)=>{qb(e.childNodes,(e=>{Wb(e)&&(t(e)&&n(e),e.hasChildNodes()&&Xb(e,t,n))}))},Qb=(e,t)=>n=>!(!n||!bm(e,n,t)),Jb=(e,t,n)=>o=>{e.setStyle(o,t,n),""===o.getAttribute("style")&&o.removeAttribute("style"),((e,t)=>{"SPAN"===t.nodeName&&0===e.getAttribs(t).length&&e.remove(t,!0)})(e,o)},Zb=al([{keep:[]},{rename:["name"]},{removed:[]}]),ev=/^(src|href|style)$/,tv=Dt.each,nv=pm,ov=(e,t,n)=>e.isChildOf(t,n)&&t!==n&&!e.isBlock(n),rv=(e,t,n)=>{let o=t[n?"startContainer":"endContainer"],r=t[n?"startOffset":"endOffset"];if($o(o)){const e=o.childNodes.length-1;!n&&r&&r--,o=o.childNodes[r>e?e:r]}return Jo(o)&&n&&r>=o.data.length&&(o=new zo(o,e.getBody()).next()||o),Jo(o)&&!n&&0===r&&(o=new zo(o,e.getBody()).prev()||o),o},sv=(e,t)=>{const n=t?"firstChild":"lastChild",o=e[n];return(e=>/^(TR|TH|TD)$/.test(e.nodeName))(e)&&o?"TR"===e.nodeName&&o[n]||o:e},av=(e,t,n,o)=>{var r;const s=e.create(n,o);return null===(r=t.parentNode)||void 0===r||r.insertBefore(s,t),s.appendChild(t),s},iv=(e,t,n,o,r)=>{const s=yn(t),a=yn(e.create(o,r)),i=n?Ln(s):Pn(s);return yo(a,i),n?(go(s,a),ho(a,s)):(po(s,a),bo(a,s)),a.dom},lv=(e,t,n)=>{const o=t.parentNode;let r;const s=e.dom,a=Nl(e);wm(n)&&o===s.getRoot()&&(n.list_block&&nv(t,n.list_block)||q(ce(t.childNodes),(t=>{um(e,a,t.nodeName.toLowerCase())?r?r.appendChild(t):(r=av(s,t,a),s.setAttribs(r,Rl(e))):r=null}))),(e=>xm(e)&&km(e)&&Pt(xe(e,"mixed"),!0))(n)&&!nv(n.inline,t)||s.remove(t,!0)},dv=(e,t,n)=>x(e)?{name:t,value:null}:{name:e,value:gm(t,n)},cv=(e,t)=>{""===e.getAttrib(t,"style")&&(t.removeAttribute("style"),t.removeAttribute("data-mce-style"))},uv=(e,t,n,o,r)=>{let s=!1;tv(n.styles,((a,i)=>{const{name:l,value:d}=dv(i,a,o),c=hm(d,l);(n.remove_similar||h(d)||!$o(r)||nv(bm(e,r,l),c))&&e.setStyle(t,l,""),s=!0})),s&&cv(e,t)},mv=(e,t,n,o,r)=>{const s=e.dom,a=Wh(e),i=e.schema;if(km(t)&&Ns(i,t.inline)&&As(i,o)&&o.parentElement===e.getBody())return lv(e,o,t),Zb.removed();if(!t.ceFalseOverride&&o&&"false"===s.getContentEditableParent(o))return Zb.keep();if(o&&!Cb(s,o,t)&&!((e,t)=>t.links&&"A"===e.nodeName)(o,t))return Zb.keep();const l=o,d=t.preserve_attributes;if(km(t)&&"all"===t.remove&&p(d)){const e=G(s.getAttribs(l),(e=>H(d,e.name.toLowerCase())));if(s.removeAllAttribs(l),q(e,(e=>s.setAttrib(l,e.name,e.value))),e.length>0)return Zb.rename("span")}if("all"!==t.remove){uv(s,l,t,n,r),tv(t.attributes,((e,o)=>{const{name:a,value:i}=dv(o,e,n);if(t.remove_similar||h(i)||!$o(r)||nv(s.getAttrib(r,a),i)){if("class"===a){const e=s.getAttrib(l,a);if(e){let t="";if(q(e.split(/\s+/),(e=>{/mce\-\w+/.test(e)&&(t+=(t?" ":"")+e)})),t)return void s.setAttrib(l,a,t)}}if(ev.test(a)&&l.removeAttribute("data-mce-"+a),"style"===a&&qo(["li"])(l)&&"none"===s.getStyle(l,"list-style-type"))return l.removeAttribute(a),void s.setStyle(l,"list-style-type","none");"class"===a&&l.removeAttribute("className"),l.removeAttribute(a)}})),tv(t.classes,(e=>{e=gm(e,n),$o(r)&&!s.hasClass(r,e)||s.removeClass(l,e)}));const e=s.getAttribs(l);for(let t=0;t<e.length;t++){const n=e[t].nodeName;if(!a.isAttributeInternal(n))return Zb.keep()}}return"none"!==t.remove?(lv(e,l,t),Zb.removed()):Zb.keep()},fv=(e,t,n,o)=>mv(e,t,n,o,o).fold(N(o),(t=>(e.dom.createFragment().appendChild(o),e.dom.rename(o,t))),N(null)),gv=(e,t,n,o,r)=>{(o||e.selection.isEditable())&&((e,t,n,o,r)=>{const s=e.formatter.get(t),a=s[0],i=e.dom,l=e.selection,d=o=>{const i=((e,t,n,o,r)=>{let s;return t.parentNode&&q(ym(e.dom,t.parentNode).reverse(),(t=>{if(!s&&$o(t)&&"_start"!==t.id&&"_end"!==t.id){const a=xb(e,t,n,o,r);a&&!1!==a.split&&(s=t)}})),s})(e,o,t,n,r);return((e,t,n,o,r,s,a,i)=>{var l,d;let c,u;const m=e.dom;if(n){const s=n.parentNode;for(let n=o.parentNode;n&&n!==s;n=n.parentNode){let o=m.clone(n,!1);for(let n=0;n<t.length&&(o=fv(e,t[n],i,o),null!==o);n++);o&&(c&&o.appendChild(c),u||(u=o),c=o)}a.mixed&&m.isBlock(n)||(o=null!==(l=m.split(n,o))&&void 0!==l?l:o),c&&u&&(null===(d=r.parentNode)||void 0===d||d.insertBefore(c,r),u.appendChild(r),km(a)&&Yb(e,a,0,c))}return o})(e,s,i,o,o,0,a,n)},c=t=>$(s,(o=>pv(e,o,n,t,t))),u=t=>{const n=ce(t.childNodes),o=c(t)||$(s,(e=>Cb(i,t,e))),r=t.parentNode;if(!o&&C(r)&&Em(a)&&c(r),a.deep&&n.length)for(let e=0;e<n.length;e++)u(n[e]);q(["underline","line-through","overline"],(n=>{$o(t)&&e.dom.getStyle(t,"text-decoration")===n&&t.parentNode&&vm(i,t.parentNode)===n&&pv(e,{deep:!1,exact:!0,inline:"span",styles:{textDecoration:n}},void 0,t)}))},m=e=>{const t=i.get(e?"_start":"_end");if(t){let n=t[e?"firstChild":"lastChild"];return(e=>Lu(e)&&$o(e)&&("_start"===e.id||"_end"===e.id))(n)&&(n=n[e?"firstChild":"lastChild"]),Jo(n)&&0===n.data.length&&(n=e?t.previousSibling||t.nextSibling:t.nextSibling||t.previousSibling),i.remove(t,!0),n}return null},f=t=>{let n,o,r=Um(i,t,s,t.collapsed);if(a.split){if(r=Bf(r),n=rv(e,r,!0),o=rv(e,r),n!==o){if(n=sv(n,!0),o=sv(o,!1),ov(i,n,o)){const e=I.from(n.firstChild).getOr(n);return d(iv(i,e,!0,"span",{id:"_start","data-mce-type":"bookmark"})),void m(!0)}if(ov(i,o,n)){const e=I.from(o.lastChild).getOr(o);return d(iv(i,e,!1,"span",{id:"_end","data-mce-type":"bookmark"})),void m(!1)}n=av(i,n,"span",{id:"_start","data-mce-type":"bookmark"}),o=av(i,o,"span",{id:"_end","data-mce-type":"bookmark"});const e=i.createRng();e.setStartAfter(n),e.setEndBefore(o),zm(i,e,(e=>{q(e,(e=>{Lu(e)||Lu(e.parentNode)||d(e)}))})),d(n),d(o),n=m(!0),o=m()}else n=o=d(n);r.startContainer=n.parentNode?n.parentNode:n,r.startOffset=i.nodeIndex(n),r.endContainer=o.parentNode?o.parentNode:o,r.endOffset=i.nodeIndex(o)+1}zm(i,r,(e=>{q(e,u)}))};if(o){if(rm(o)){const e=i.createRng();e.setStartBefore(o),e.setEndAfter(o),f(e)}else f(o);Xm(e,t,o,n)}else l.isCollapsed()&&km(a)&&!Yu(e).length?Bb(e,t,n,r):(im(e,(()=>nm(e,f)),(o=>km(a)&&kb(e,t,n,o))),e.nodeChanged()),((e,t,n)=>{"removeformat"===t?q(Vb(e.selection),(t=>{q(Ub,(n=>e.dom.setStyle(t,n,""))),cv(e.dom,t)})):zb(e.formatter,t).each((t=>{q(Vb(e.selection),(o=>uv(e.dom,o,t,n,null)))}))})(e,t,n),Xm(e,t,o,n)})(e,t,n,o,r)},pv=(e,t,n,o,r)=>mv(e,t,n,o,r).fold(L,(t=>(e.dom.rename(o,t),!0)),M),hv=Dt.each,bv=Dt.each,vv=(e,t,n,o)=>{if(bv(n.styles,((n,r)=>{e.setStyle(t,r,gm(n,o))})),n.styles){const n=e.getAttrib(t,"style");n&&e.setAttrib(t,"data-mce-style",n)}},yv=(e,t,n,o)=>{const r=e.formatter.get(t),s=r[0],a=!o&&e.selection.isCollapsed(),i=e.dom,l=e.selection,d=(e,t=s)=>{w(t.onformat)&&t.onformat(e,t,n,o),vv(i,e,t,n),bv(t.attributes,((t,o)=>{i.setAttrib(e,o,gm(t,n))})),bv(t.classes,(t=>{const o=gm(t,n);i.hasClass(e,o)||i.addClass(e,o)}))},c=(e,t)=>{let n=!1;return bv(e,(e=>!(!xm(e)||("false"!==i.getContentEditable(t)||e.ceFalseOverride)&&(!C(e.collapsed)||e.collapsed===a)&&i.is(t,e.selector)&&!xu(t)&&(d(t,e),n=!0,1)))),n},u=e=>{if(m(e)){const t=i.create(e);return d(t),t}return null},f=(o,a,i)=>{const l=[];let m=!0;const f=s.inline||s.block,g=u(f);zm(o,a,(a=>{let u;const p=a=>{let h=!1,b=m,v=!1;const y=a.parentNode,w=y.nodeName.toLowerCase(),x=o.getContentEditable(a);C(x)&&(b=m,m="true"===x,h=!0,v=fm(e,a));const k=m&&!h;if(rr(a)&&!((e,t,n,o)=>{if(md(e)&&km(t)&&n.parentNode){const t=la(e.schema),r=gb(yn(n),(e=>xu(e.dom)));return Ee(t,o)&&bs(yn(n.parentNode),!1)&&!r}return!1})(e,s,a,w))return u=null,void(wm(s)&&o.remove(a));if((o=>(e=>wm(e)&&!0===e.wrapper)(s)&&xb(e,o,t,n))(a))u=null;else{if(((t,n,o)=>{const r=(e=>wm(e)&&!0!==e.wrapper)(s)&&cm(e.schema,t)&&um(e,n,f);return o&&r})(a,w,k)){const e=o.rename(a,f);return d(e),l.push(e),void(u=null)}if(xm(s)){let e=c(r,a);if(!e&&C(y)&&Em(s)&&(e=c(r,y)),!km(s)||e)return void(u=null)}C(g)&&((t,n,r,a)=>{const l=t.nodeName.toLowerCase(),d=um(e,f,l)&&um(e,n,f),c=!i&&Jo(t)&&Ir(t.data),u=xu(t),m=!km(s)||!o.isBlock(t);return(r||a)&&d&&!c&&!u&&m})(a,w,k,v)?(u||(u=o.clone(g,!1),y.insertBefore(u,a),l.push(u)),v&&h&&(m=b),u.appendChild(a)):(u=null,q(ce(a.childNodes),p),h&&(m=b),u=null)}};q(a,p)})),!0===s.links&&q(l,(e=>{const t=e=>{"A"===e.nodeName&&d(e,s),q(ce(e.childNodes),t)};t(e)})),q(l,(a=>{const i=(e=>{let t=0;return q(e.childNodes,(e=>{(e=>C(e)&&Jo(e)&&0===e.length)(e)||Lu(e)||t++})),t})(a);!(l.length>1)&&o.isBlock(a)||0!==i?(km(s)||wm(s)&&s.wrapper)&&(s.exact||1!==i||(a=(e=>{const t=J(e.childNodes,sm).filter((e=>"false"!==o.getContentEditable(e)&&Cb(o,e,s)));return t.map((t=>{const n=o.clone(t,!1);return d(n),o.replace(n,e,!0),o.remove(t,!0),n})).getOr(e)})(a)),((e,t,n,o)=>{hv(t,(t=>{km(t)&&hv(e.dom.select(t.inline,o),(o=>{Wb(o)&&pv(e,t,n,o,t.exact?o:null)})),((e,t,n)=>{if(t.clear_child_styles){const o=t.links?"*:not(a)":"*";qb(e.select(o,n),(n=>{Wb(n)&&am(n)&&qb(t.styles,((t,o)=>{e.setStyle(n,o,"")}))}))}})(e.dom,t,o)}))})(e,r,n,a),((e,t,n,o,r)=>{const s=r.parentNode;xb(e,s,n,o)&&pv(e,t,o,r)||t.merge_with_parents&&s&&e.dom.getParent(s,(s=>!!xb(e,s,n,o)&&(pv(e,t,o,r),!0)))})(e,s,t,n,a),((e,t,n,o)=>{if(t.styles&&t.styles.backgroundColor){const r=Qb(e,"fontSize");Xb(o,(e=>r(e)&&am(e)),Jb(e,"backgroundColor",gm(t.styles.backgroundColor,n)))}})(o,s,n,a),((e,t,n,o)=>{const r=t=>{if($o(t)&&$o(t.parentNode)&&am(t)){const n=vm(e,t.parentNode);e.getStyle(t,"color")&&n?e.setStyle(t,"text-decoration",n):e.getStyle(t,"text-decoration")===n&&e.setStyle(t,"text-decoration",null)}};t.styles&&(t.styles.color||t.styles.textDecoration)&&(Dt.walk(o,r,"childNodes"),r(o))})(o,s,0,a),((e,t,n,o)=>{if(km(t)&&("sub"===t.inline||"sup"===t.inline)){const n=Qb(e,"fontSize");Xb(o,(e=>n(e)&&am(e)),Jb(e,"fontSize",""));const r=G(e.select("sup"===t.inline?"sub":"sup",o),am);e.remove(r,!0)}})(o,s,0,a),Yb(e,s,0,a)):o.remove(a,!0)}))},g=rm(o)?o:l.getNode();if("false"===i.getContentEditable(g)&&!fm(e,g))return c(r,o=g),void Ym(e,t,o,n);if(s){if(o)if(rm(o)){if(!c(r,o)){const e=i.createRng();e.setStartBefore(o),e.setEndAfter(o),f(i,Um(i,e,r),!0)}}else f(i,o,!0);else a&&km(s)&&!Yu(e).length?((e,t,n)=>{let o;const r=e.selection,s=e.formatter.get(t);if(!s)return;const a=r.getRng();let i=a.startOffset;const l=a.startContainer.nodeValue;o=ku(e.getBody(),r.getStart());const d=/[^\s\u00a0\u00ad\u200b\ufeff]/;if(l&&i>0&&i<l.length&&d.test(l.charAt(i))&&d.test(l.charAt(i-1))){const o=r.getBookmark();a.collapse(!0);let i=Um(e.dom,a,s);i=Bf(i),e.formatter.apply(t,n,i),r.moveToBookmark(o)}else{let s=o?_b(o):null;o&&(null==s?void 0:s.data)===Eb||(c=e.getDoc(),u=Nb(!0).dom,o=c.importNode(u,!0),s=o.firstChild,a.insertNode(o),i=1),e.formatter.apply(t,n,o),r.setCursorLocation(s,i)}var c,u})(e,t,n):(l.setRng(ob(l.getRng())),im(e,(()=>{nm(e,((e,t)=>{const n=t?e:Um(i,e,r);f(i,n,!1)}))}),M),e.nodeChanged()),zb(e.formatter,t).each((t=>{q((e=>G((e=>{const t=e.getSelectedBlocks(),n=e.getRng();if(e.isCollapsed())return[];if(1===t.length)return jb(n,t[0])&&Hb(n,t[0])?t:[];{const e=le(t).filter((e=>jb(n,e))).toArray(),o=de(t).filter((e=>Hb(n,e))).toArray(),r=t.slice(1,-1);return e.concat(r).concat(o)}})(e),$b(e.dom)))(e.selection),(e=>vv(i,e,t,n)))}));((e,t)=>{ke(Ib,e)&&q(Ib[e],(e=>{e(t)}))})(t,e)}Ym(e,t,o,n)},Cv=(e,t,n,o)=>{(o||e.selection.isEditable())&&yv(e,t,n,o)},wv=e=>ke(e,"vars"),xv=e=>e.selection.getStart(),kv=(e,t,n,o,r)=>Q(t,(t=>{const s=e.formatter.matchNode(t,n,null!=r?r:{},o);return!v(s)}),(t=>!!vb(e,t,n)||!o&&C(e.formatter.matchNode(t,n,r,!0)))),Ev=(e,t)=>{const n=null!=t?t:xv(e);return G(ym(e.dom,n),(e=>$o(e)&&!Go(e)))},Sv=(e,t,n)=>{const o=Ev(e,t);ge(n,((n,r)=>{const s=n=>{const s=kv(e,o,r,n.similar,wv(n)?n.vars:void 0),a=s.isSome();if(n.state.get()!==a){n.state.set(a);const e=s.getOr(t);wv(n)?n.callback(a,{node:e,format:r,parents:o}):q(n.callbacks,(t=>t(a,{node:e,format:r,parents:o})))}};q([n.withSimilar,n.withoutSimilar],s),q(n.withVars,s)}))},_v=Dt.explode,Nv=()=>{const e={};return{addFilter:(t,n)=>{q(_v(t),(t=>{ke(e,t)||(e[t]={name:t,callbacks:[]}),e[t].callbacks.push(n)}))},getFilters:()=>we(e),removeFilter:(t,n)=>{q(_v(t),(t=>{if(ke(e,t))if(C(n)){const o=e[t],r=G(o.callbacks,(e=>e!==n));r.length>0?o.callbacks=r:delete e[t]}else delete e[t]}))}}},Rv=(e,t,n)=>{var o;const r=ua();t.convert_fonts_to_spans&&((e,t,n)=>{e.addNodeFilter("font",(e=>{q(e,(e=>{const o=t.parse(e.attr("style")),r=e.attr("color"),s=e.attr("face"),a=e.attr("size");r&&(o.color=r),s&&(o["font-family"]=s),a&&Xe(a).each((e=>{o["font-size"]=n[e-1]})),e.name="span",e.attr("style",t.serialize(o)),((e,t)=>{q(["color","face","size"],(t=>{e.attr(t,null)}))})(e)}))}))})(e,r,Dt.explode(null!==(o=t.font_size_legacy_values)&&void 0!==o?o:"")),((e,t,n)=>{e.addNodeFilter("strike",(e=>{const o="html4"!==t.type;q(e,(e=>{if(o)e.name="s";else{const t=n.parse(e.attr("style"));t["text-decoration"]="line-through",e.name="span",e.attr("style",n.serialize(t))}}))}))})(e,n,r)},Av=(e,t,n)=>{t.addNodeFilter("br",((t,o,r)=>{const s=Dt.extend({},n.getBlockElements()),a=n.getNonEmptyElements(),i=n.getWhitespaceElements();s.body=1;const l=e=>e.name in s||Ts(n,e);for(let o=0,d=t.length;o<d;o++){let d=t[o],c=d.parent;if(c&&l(c)&&d===c.lastChild){let t=d.prev;for(;t;){const e=t.name;if("span"!==e||"bookmark"!==t.attr("data-mce-type")){"br"===e&&(d=null);break}t=t.prev}if(d&&(d.remove(),Jh(n,a,i,c))){const t=n.getElementRule(c.name);t&&(t.removeEmpty?c.remove():t.paddEmpty&&Xh(e,r,l,c))}}else{let e=d;for(;c&&c.firstChild===e&&c.lastChild===e&&(e=c,!s[c.name]);)c=c.parent;if(e===c){const e=new Fg("#text",3);e.value=pr,d.replace(e)}}}}))},Ov=e=>{const[t,...n]=e.split(","),o=n.join(","),r=/data:([^/]+\/[^;]+)(;.+)?/.exec(t);if(r){const e=";base64"===r[2],t=e?(e=>{const t=/([a-z0-9+\/=\s]+)/i.exec(e);return t?t[1]:""})(o):decodeURIComponent(o);return I.some({type:r[1],data:t,base64Encoded:e})}return I.none()},Tv=(e,t,n=!0)=>{let o=t;if(n)try{o=atob(t)}catch(e){return I.none()}const r=new Uint8Array(o.length);for(let e=0;e<r.length;e++)r[e]=o.charCodeAt(e);return I.some(new Blob([r],{type:e}))},Bv=e=>new Promise(((t,n)=>{const o=new FileReader;o.onloadend=()=>{t(o.result)},o.onerror=()=>{var e;n(null===(e=o.error)||void 0===e?void 0:e.message)},o.readAsDataURL(e)}));let Dv=0;const Pv=(e,t,n)=>Ov(e).bind((({data:e,type:o,base64Encoded:r})=>{if(t&&!r)return I.none();{const t=r?e:btoa(e);return n(t,o)}})),Lv=(e,t,n)=>{const o=e.create("blobid"+Dv++,t,n);return e.add(o),o},Mv=(e,t,n=!1)=>Pv(t,n,((t,n)=>I.from(e.getByData(t,n)).orThunk((()=>Tv(n,t).map((n=>Lv(e,n,t))))))),Iv=(e,t)=>{const n=e.schema;t.remove_trailing_brs&&Av(t,e,n),e.addAttributeFilter("href",(e=>{let n=e.length;const o=e=>{const t=e?Dt.trim(e):"";return/\b(noopener)\b/g.test(t)?t:(e=>e.split(" ").filter((e=>e.length>0)).concat(["noopener"]).sort().join(" "))(t)};if(!t.allow_unsafe_link_target)for(;n--;){const t=e[n];"a"===t.name&&"_blank"===t.attr("target")&&t.attr("rel",o(t.attr("rel")))}})),t.allow_html_in_named_anchor||e.addAttributeFilter("id,name",(e=>{let t,n,o,r,s=e.length;for(;s--;)if(r=e[s],"a"===r.name&&r.firstChild&&!r.attr("href"))for(o=r.parent,t=r.lastChild;t&&o;)n=t.prev,o.insert(t,r),t=n})),t.fix_list_elements&&e.addNodeFilter("ul,ol",(e=>{let t,n,o=e.length;for(;o--;)if(t=e[o],n=t.parent,n&&("ul"===n.name||"ol"===n.name))if(t.prev&&"li"===t.prev.name)t.prev.append(t);else{const e=new Fg("li",1);e.attr("style","list-style-type: none"),t.wrap(e)}}));const o=n.getValidClasses();t.validate&&o&&e.addAttributeFilter("class",(e=>{var t;let n=e.length;for(;n--;){const r=e[n],s=null!==(t=r.attr("class"))&&void 0!==t?t:"",a=Dt.explode(s," ");let i="";for(let e=0;e<a.length;e++){const t=a[e];let n=!1,s=o["*"];s&&s[t]&&(n=!0),s=o[r.name],!n&&s&&s[t]&&(n=!0),n&&(i&&(i+=" "),i+=t)}i.length||(i=null),r.attr("class",i)}})),((e,t)=>{const{blob_cache:n}=t;if(n){const t=e=>{const t=e.attr("src");(e=>e.attr("src")===At.transparentSrc||C(e.attr("data-mce-placeholder")))(e)||(e=>C(e.attr("data-mce-bogus")))(e)||y(t)||Mv(n,t,!0).each((t=>{e.attr("src",t.blobUri())}))};e.addAttributeFilter("src",(e=>q(e,t)))}})(e,t)};function Fv(e){return Fv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fv(e)}function Uv(e,t){return Uv=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Uv(e,t)}function zv(e,t,n){return zv=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&Uv(r,n.prototype),r},zv.apply(null,arguments)}function jv(e){return function(e){if(Array.isArray(e))return Hv(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Hv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hv(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Hv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var $v=Object.hasOwnProperty,Vv=Object.setPrototypeOf,qv=Object.isFrozen,Wv=Object.getPrototypeOf,Kv=Object.getOwnPropertyDescriptor,Gv=Object.freeze,Yv=Object.seal,Xv=Object.create,Qv="undefined"!=typeof Reflect&&Reflect,Jv=Qv.apply,Zv=Qv.construct;Jv||(Jv=function(e,t,n){return e.apply(t,n)}),Gv||(Gv=function(e){return e}),Yv||(Yv=function(e){return e}),Zv||(Zv=function(e,t){return zv(e,jv(t))});var ey,ty=uy(Array.prototype.forEach),ny=uy(Array.prototype.pop),oy=uy(Array.prototype.push),ry=uy(String.prototype.toLowerCase),sy=uy(String.prototype.match),ay=uy(String.prototype.replace),iy=uy(String.prototype.indexOf),ly=uy(String.prototype.trim),dy=uy(RegExp.prototype.test),cy=(ey=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Zv(ey,t)});function uy(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return Jv(e,t,o)}}function my(e,t){Vv&&Vv(e,null);for(var n=t.length;n--;){var o=t[n];if("string"==typeof o){var r=ry(o);r!==o&&(qv(t)||(t[n]=r),o=r)}e[o]=!0}return e}function fy(e){var t,n=Xv(null);for(t in e)Jv($v,e,[t])&&(n[t]=e[t]);return n}function gy(e,t){for(;null!==e;){var n=Kv(e,t);if(n){if(n.get)return uy(n.get);if("function"==typeof n.value)return uy(n.value)}e=Wv(e)}return function(e){return console.warn("fallback value for",e),null}}var py=Gv(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),hy=Gv(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),by=Gv(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),vy=Gv(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),yy=Gv(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),Cy=Gv(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wy=Gv(["#text"]),xy=Gv(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","
5168spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),ky=Gv(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ey=Gv(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Sy=Gv(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),_y=Yv(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ny=Yv(/<%[\w\W]*|[\w\W]*%>/gm),Ry=Yv(/^data-[\-\w.\u00B7-\uFFFF]/),Ay=Yv(/^aria-[\-\w]+$/),Oy=Yv(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ty=Yv(/^(?:\w+script|data):/i),By=Yv(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Dy=Yv(/^html$/i),Py=function(){return"undefined"==typeof window?null:window},Ly=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Py(),n=function(t){return e(t)};if(n.version="2.3.8",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var o=t.document,r=t.document,s=t.DocumentFragment,a=t.HTMLTemplateElement,i=t.Node,l=t.Element,d=t.NodeFilter,c=t.NamedNodeMap,u=void 0===c?t.NamedNodeMap||t.MozNamedAttrMap:c,m=t.HTMLFormElement,f=t.DOMParser,g=t.trustedTypes,p=l.prototype,h=gy(p,"cloneNode"),b=gy(p,"nextSibling"),v=gy(p,"childNodes"),y=gy(p,"parentNode");if("function"==typeof a){var C=r.createElement("template");C.content&&C.content.ownerDocument&&(r=C.content.ownerDocument)}var w=function(e,t){if("object"!==Fv(e)||"function"!=typeof e.createPolicy)return null;
vendor: 6,791 bytes, line 5168
5168var n=null,o="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(o)&&(n=t.currentScript.getAttribute(o));var r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(g,o),x=w?w.createHTML(""):"",k=r,E=k.implementation,S=k.createNodeIterator,_=k.createDocumentFragment,N=k.getElementsByTagName,R=o.importNode,A={};try{A=fy(r).documentMode?r.documentMode:{}}catch(e){}var O={};n.isSupported="function"==typeof y&&E&&void 0!==E.createHTMLDocument&&9!==A;var T,B,D=_y,P=Ny,L=Ry,M=Ay,I=Ty,F=By,U=Oy,z=null,j=my({},[].concat(jv(py),jv(hy),jv(by),jv(yy),jv(wy))),H=null,$=my({},[].concat(jv(xy),jv(ky),jv(Ey),jv(Sy))),V=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),q=null,W=null,K=!0,G=!0,Y=!1,X=!1,Q=!1,J=!1,Z=!1,ee=!1,te=!1,ne=!1,oe=!0,re=!0,se=!1,ae={},ie=null,le=my({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),de=null,ce=my({},["audio","video","img","source","image","track"]),ue=null,me=my({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),fe="http://www.w3.org/1998/Math/MathML",ge="http://www.w3.org/2000/svg",pe="http://www.w3.org/1999/xhtml",he=pe,be=!1,ve=["application/xhtml+xml","text/html"],ye=null,Ce=r.createElement("form"),we=function(e){return e instanceof RegExp||e instanceof Function},xe=function(e){ye&&ye===e||(e&&"object"===Fv(e)||(e={}),e=fy(e),z="ALLOWED_TAGS"in e?my({},e.ALLOWED_TAGS):j,H="ALLOWED_ATTR"in e?my({},e.ALLOWED_ATTR):$,ue="ADD_URI_SAFE_ATTR"in e?my(fy(me),e.ADD_URI_SAFE_ATTR):me,de="ADD_DATA_URI_TAGS"in e?my(fy(ce),e.ADD_DATA_URI_TAGS):ce,ie="FORBID_CONTENTS"in e?my({},e.FORBID_CONTENTS):le,q="FORBID_TAGS"in e?my({},e.FORBID_TAGS):{},W="FORBID_ATTR"in e?my({},e.FORBID_ATTR):{},ae="USE_PROFILES"in e&&e.USE_PROFILES,K=!1!==e.ALLOW_ARIA_ATTR,G=!1!==e.ALLOW_DATA_ATTR,Y=e.ALLOW_UNKNOWN_PROTOCOLS||!1,X=e.SAFE_FOR_TEMPLATES||!1,Q=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,ne=e.RETURN_TRUSTED_TYPE||!1,Z=e.FORCE_BODY||!1,oe=!1!==e.SANITIZE_DOM,re=!1!==e.KEEP_CONTENT,se=e.IN_PLACE||!1,U=e.ALLOWED_URI_REGEXP||U,he=e.NAMESPACE||pe,e.CUSTOM_ELEMENT_HANDLING&&we(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(V.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&we(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(V.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(V.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),T=T=-1===ve.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,B="application/xhtml+xml"===T?function(e){return e}:ry,X&&(G=!1),te&&(ee=!0),ae&&(z=my({},jv(wy)),H=[],!0===ae.html&&(my(z,py),my(H,xy)),!0===ae.svg&&(my(z,hy),my(H,ky),my(H,Sy)),!0===ae.svgFilters&&(my(z,by),my(H,ky),my(H,Sy)),!0===ae.mathMl&&(my(z,yy),my(H,Ey),my(H,Sy))),e.ADD_TAGS&&(z===j&&(z=fy(z)),my(z,e.ADD_TAGS)),e.ADD_ATTR&&(H===$&&(H=fy(H)),my(H,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&my(ue,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(ie===le&&(ie=fy(ie)),my(ie,e.FORBID_CONTENTS)),re&&(z["#text"]=!0),Q&&my(z,["html","head","body"]),z.table&&(my(z,["tbody"]),delete q.tbody),Gv&&Gv(e),ye=e)},ke=my({},["mi","mo","mn","ms","mtext"]),Ee=my({},["foreignobject","desc","title","annotation-xml"]),Se=my({},["title","style","font","a","script"]),_e=my({},hy);my(_e,by),my(_e,vy);var Ne=my({},yy);my(Ne,Cy);var Re=function(e){oy(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=x}catch(t){e.remove()}}},Ae=function(e,t){try{oy(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){oy(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!H[e])if(ee||te)try{Re(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Oe=function(e){var t,n;if(Z)e="<remove></remove>"+e;else{var o=sy(e,/^[\r\n\t ]+/);n=o&&o[0]}"application/xhtml+xml"===T&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");var s=w?w.createHTML(e):e;if(he===pe)try{t=(new f).parseFromString(s,T)}catch(e){}if(!t||!t.documentElement){t=E.createDocument(he,"template",null);try{t.documentElement.innerHTML=be?"":s}catch(e){}}var a=t.body||t.documentElement;return e&&n&&a.insertBefore(r.createTextNode(n),a.childNodes[0]||null),he===pe?N.call(t,Q?"html":"body")[0]:Q?t.documentElement:a},Te=function(e){return S.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT,null,!1)},Be=function(e){return"object"===Fv(i)?e instanceof i:e&&"object"===Fv(e)&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},De=function(e,t,o){O[e]&&ty(O[e],(function(e){e.call(n,t,o,ye)}))},Pe=function(e){var t,o;if(De("beforeSanitizeElements",e,null),(o=e)instanceof m&&("string"!=typeof o.nodeName||"string"!=typeof o.textContent||"function"!=typeof o.removeChild||!(o.attributes instanceof u)||"function"!=typeof o.removeAttribute||"function"!=typeof o.setAttribute||"string"!=typeof o.namespaceURI||"function"!=typeof o.insertBefore))return Re(e),!0;if(dy(/[\u0080-\uFFFF]/,e.nodeName))return Re(e),!0;var r=B(e.nodeName);if(De("uponSanitizeElement",e,{tagName:r,allowedTags:z}),e.hasChildNodes()&&!Be(e.firstElementChild)&&(!Be(e.content)||!Be(e.content.firstElementChild))&&dy(/<[/\w]/g,e.innerHTML)&&dy(/<[/\w]/g,e.textContent))return Re(e),!0;if("select"===r&&dy(/<template/i,e.innerHTML))return Re(e),!0;if(!z[r]||q[r]){if(!q[r]&&Me(r)){if(V.tagNameCheck instanceof RegExp&&dy(V.tagNameCheck,r))return!1;if(V.tagNameCheck instanceof Function&&V.tagNameCheck(r))return!1}if(re&&!ie[r]){var s=y(e)||e.parentNode,a=v(e)||e.childNodes;if(a&&s)for(var i=a.length-1;i>=0;--i)s.insertBefore(h(a[i],!0),b(e))}return Re(e),!0}return e instanceof l&&!function(e){var t=y(e);t&&t.tagName||(t={namespaceURI:pe,tagName:"template"});var n=ry(e.tagName),o=ry(t.tagName);return e.namespaceURI===ge?t.namespaceURI===pe?"svg"===n:t.namespaceURI===fe?"svg"===n&&("annotation-xml"===o||ke[o]):Boolean(_e[n]):e.namespaceURI===fe?t.namespaceURI===pe?"math"===n:t.namespaceURI===ge?"math"===n&&Ee[o]:Boolean(Ne[n]):e.namespaceURI===pe&&!(t.namespaceURI===ge&&!Ee[o])&&!(t.namespaceURI===fe&&!ke[o])&&!Ne[n]&&(Se[n]||!_e[n])}(e)?(Re(e),!0):"noscript"!==r&&"noembed"!==r||!dy(/<\/no(script|embed)/i,e.innerHTML)?(X&&3===e.n
vendor: 100,165 bytes, line 5168
5168odeType&&(t=e.textContent,t=ay(t,D," "),t=ay(t,P," "),e.textContent!==t&&(oy(n.removed,{element:e.cloneNode()}),e.textContent=t)),De("afterSanitizeElements",e,null),!1):(Re(e),!0)},Le=function(e,t,n){if(oe&&("id"===t||"name"===t)&&(n in r||n in Ce))return!1;if(G&&!W[t]&&dy(L,t));else if(K&&dy(M,t));else if(!H[t]||W[t]){if(!(Me(e)&&(V.tagNameCheck instanceof RegExp&&dy(V.tagNameCheck,e)||V.tagNameCheck instanceof Function&&V.tagNameCheck(e))&&(V.attributeNameCheck instanceof RegExp&&dy(V.attributeNameCheck,t)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(t))||"is"===t&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&dy(V.tagNameCheck,n)||V.tagNameCheck instanceof Function&&V.tagNameCheck(n))))return!1}else if(ue[t]);else if(dy(U,ay(n,F,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==iy(n,"data:")||!de[e])if(Y&&!dy(I,ay(n,F,"")));else if(n)return!1;return!0},Me=function(e){return e.indexOf("-")>0},Ie=function(e){var t,n,o,r;De("beforeSanitizeAttributes",e,null);var s=e.attributes;if(s){var a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:H};for(r=s.length;r--;){var i=t=s[r],l=i.name,d=i.namespaceURI;n="value"===l?t.value:ly(t.value),o=B(l);var c=n;if(a.attrName=o,a.attrValue=n,a.keepAttr=!0,a.forceKeepAttr=void 0,De("uponSanitizeAttribute",e,a),n=a.attrValue,!a.forceKeepAttr)if(a.keepAttr)if(dy(/\/>/i,n))Ae(l,e);else{X&&(n=ay(n,D," "),n=ay(n,P," "));var u=B(e.nodeName);if(Le(u,o,n)){if(n!==c)try{d?e.setAttributeNS(d,l,n):e.setAttribute(l,n)}catch(t){Ae(l,e)}}else Ae(l,e)}else Ae(l,e)}De("afterSanitizeAttributes",e,null)}},Fe=function e(t){var n,o=Te(t);for(De("beforeSanitizeShadowDOM",t,null);n=o.nextNode();)De("uponSanitizeShadowNode",n,null),Pe(n)||(n.content instanceof s&&e(n.content),Ie(n));De("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e,r){var a,l,d,c,u;if((be=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Be(e)){if("function"!=typeof e.toString)throw cy("toString is not a function");if("string"!=typeof(e=e.toString()))throw cy("dirty is not a string, aborting")}if(!n.isSupported){if("object"===Fv(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(Be(e))return t.toStaticHTML(e.outerHTML)}return e}if(J||xe(r),n.removed=[],"string"==typeof e&&(se=!1),se){if(e.nodeName){var m=B(e.nodeName);if(!z[m]||q[m])throw cy("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof i)1===(l=(a=Oe("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?a=l:a.appendChild(l);else{if(!ee&&!X&&!Q&&-1===e.indexOf("<"))return w&&ne?w.createHTML(e):e;if(!(a=Oe(e)))return ee?null:ne?x:""}a&&Z&&Re(a.firstChild);for(var f=Te(se?e:a);d=f.nextNode();)3===d.nodeType&&d===c||Pe(d)||(d.content instanceof s&&Fe(d.content),Ie(d),c=d);if(c=null,se)return e;if(ee){if(te)for(u=_.call(a.ownerDocument);a.firstChild;)u.appendChild(a.firstChild);else u=a;return H.shadowroot&&(u=R.call(o,u,!0)),u}var g=Q?a.outerHTML:a.innerHTML;return Q&&z["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&dy(Dy,a.ownerDocument.doctype.name)&&(g="<!DOCTYPE "+a.ownerDocument.doctype.name+">\n"+g),X&&(g=ay(g,D," "),g=ay(g,P," ")),w&&ne?w.createHTML(g):g},n.setConfig=function(e){xe(e),J=!0},n.clearConfig=function(){ye=null,J=!1},n.isValidAttribute=function(e,t,n){ye||xe({});var o=B(e),r=B(t);return Le(o,r,n)},n.addHook=function(e,t){"function"==typeof t&&(O[e]=O[e]||[],oy(O[e],t))},n.removeHook=function(e){if(O[e])return ny(O[e])},n.removeHooks=function(e){O[e]&&(O[e]=[])},n.removeAllHooks=function(){O={}},n}();const My=Dt.each,Iy=Dt.trim,Fy=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Uy={ftp:21,http:80,https:443,mailto:25},zy=["img","video"],jy=(e,t,n)=>{const o=(e=>{try{return decodeURIComponent(e)}catch(t){return unescape(e)}})(t).replace(/\s/g,"");return!e.allow_script_urls&&(!!/((java|vb)script|mhtml):/i.test(o)||!e.allow_html_data_urls&&(/^data:image\//i.test(o)?((e,t)=>C(e)?!e:!C(t)||!H(zy,t))(e.allow_svg_data_urls,n)&&/^data:image\/svg\+xml/i.test(o):/^data:/i.test(o)))};class Hy{static parseDataUri(e){let t;const n=decodeURIComponent(e).split(","),o=/data:([^;]+)/.exec(n[0]);return o&&(t=o[1]),{type:t,data:n[1]}}static isDomSafe(e,t,n={}){if(n.allow_script_urls)return!0;{const o=Zs.decode(e).replace(/[\s\u0000-\u001F]+/g,"");return!jy(n,o,t)}}static getDocumentBaseUrl(e){var t;let n;return n=0!==e.protocol.indexOf("http")&&"file:"!==e.protocol?null!==(t=e.href)&&void 0!==t?t:"":e.protocol+"//"+e.host+e.pathname,/^[^:]+:\/\/\/?[^\/]+\//.test(n)&&(n=n.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(n)||(n+="/")),n}constructor(e,t={}){this.path="",this.directory="",e=Iy(e),this.settings=t;const n=t.base_uri,o=this;if(/^([\w\-]+):([^\/]{2})/i.test(e)||/^\s*#/.test(e))return void(o.source=e);const r=0===e.indexOf("//");if(0!==e.indexOf("/")||r||(e=(n&&n.protocol||"http")+"://mce_host"+e),!/^[\w\-]*:?\/\//.test(e)){const t=n?n.path:new Hy(document.location.href).directory;if(""===(null==n?void 0:n.protocol))e="//mce_host"+o.toAbsPath(t,e);else{const r=/([^#?]*)([#?]?.*)/.exec(e);r&&(e=(n&&n.protocol||"http")+"://mce_host"+o.toAbsPath(t,r[1])+r[2])}}e=e.replace(/@@/g,"(mce_at)");const s=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?(\[[a-zA-Z0-9:.%]+\]|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(e);s&&My(Fy,((e,t)=>{let n=s[t];n&&(n=n.replace(/\(mce_at\)/g,"@@")),o[e]=n})),n&&(o.protocol||(o.protocol=n.protocol),o.userInfo||(o.userInfo=n.userInfo),o.port||"mce_host"!==o.host||(o.port=n.port),o.host&&"mce_host"!==o.host||(o.host=n.host),o.source=""),r&&(o.protocol="")}setPath(e){const t=/^(.*?)\/?(\w+)?$/.exec(e);t&&(this.path=t[0],this.directory=t[1],this.file=t[2]),this.source="",this.getURI()}toRelative(e){if("./"===e)return e;const t=new Hy(e,{base_uri:this});if("mce_host"!==t.host&&this.host!==t.host&&t.host||this.port!==t.port||this.protocol!==t.protocol&&""!==t.protocol)return t.getURI();const n=this.getURI(),o=t.getURI();if(n===o||"/"===n.charAt(n.length-1)&&n.substr(0,n.length-1)===o)return n;let r=this.toRelPath(this.path,t.path);return t.query&&(r+="?"+t.query),t.anchor&&(r+="#"+t.anchor),r}toAbsolute(e,t){const n=new Hy(e,{base_uri:this});return n.getURI(t&&this.isSameOrigin(n))}isSameOrigin(e){if(this.host==e.host&&this.protocol==e.protocol){if(this.port==e.port)return!0;const t=this.protocol?Uy[this.protocol]:null;if(t&&(this.port||t)==(e.port||t))return!0}return!1}toRelPath(e,t){let n,o,r=0,s="";const a=e.substring(0,e.lastIndexOf("/")).split("/"),i=t.split("/");if(a.length>=i.length)for(n=0,o=a.length;n<o;n++)if(n>=i.length||a[n]!==i[n]){r=n+1;break}if(a.length<i.length)for(n=0,o=i.length;n<o;n++)if(n>=a.length||a[n]!==i[n]){r=n+1;break}if(1===r)return t;for(n=0,o=a.length-(r-1);n<o;n++)s+="../";for(n=r-1,o=i.length;n<o;n++)s+=n!==r-1?"/"+i[n]:i[n];return s}toAbsPath(e,t){let n=0;const o=/\/$/.test(t)?"/":"",r=e.split("/"),s=t.split("/"),a=[];My(r,(e=>{e&&a.push(e)}));const i=[];for(let e=s.length-1;e>=0;e--)0!==s[e].length&&"."!==s[e]&&(".."!==s[e]?n>0?n--:i.push(s[e]):n++);const l=a.length-n;let d;return d=l<=0?oe(i).join("/"):a.slice(0,l).join("/")+"/"+oe(i).join("/"),0!==d.indexOf("/")&&(d="/"+d),o&&d.lastIndexOf("/")!==d.length-1&&(d+=o),d}getURI(e=!1){let t;return this.source&&!e||(t="",e||(this.protocol?t+=this.protocol+"://":t+="//",this.userInfo&&(t+=this.userInfo+"@"),this.host&&(t+=this.host),this.port&&(t+=":"+this.port)),this.path&&(t+=this.path),this.query&&(t+="?"+this.query),this.anchor&&(t+="#"+this.anchor),this.source=t),this.source}}const $y=Dt.makeMap("src,href,data,background,action,formaction,poster,xlink:href"),Vy="data-mce-type";let qy=0;const Wy=(e,t,n,o)=>{var r,s,a,i;const l=t.validate,d=n.getSpecialElements();8===e.nodeType&&!t.allow_conditional_comments&&/^\[if/i.test(null!==(r=e.nodeValue)&&void 0!==r?r:"")&&(e.nodeValue=" "+e.nodeValue);const c=null!==(s=null==o?void 0:o.tagName)&&void 0!==s?s:e.nodeName.toLowerCase();if(1!==e.nodeType||"body"===c)return;const u=yn(e),f=nn(u,Vy),g=en(u,"data-mce-bogus");if(!f&&m(g))return void("all"===g?wo(u):xo(u));const p=n.getElementRule(c);if(!l||p){if(C(o)&&(o.allowedTags[c]=!0),l&&p&&!f){if(q(null!==(a=p.attributesForced)&&void 0!==a?a:[],(e=>{Jt(u,e.name,"{$uid}"===e.value?"mce_"+qy++:e.value)})),q(null!==(i=p.attributesDefault)&&void 0!==i?i:[],(e=>{nn(u,e.name)||Jt(u,e.name,"{$uid}"===e.value?"mce_"+qy++:e.value)})),p.attributesRequired&&!$(p.attributesRequired,(e=>nn(u,e))))return void xo(u);if(p.removeEmptyAttrs&&(e=>{const t=e.dom.attributes;return null==t||0===t.length})(u))return void xo(u);p.outputName&&p.outputName!==c&&((e,t)=>{const n=((e,t)=>{const n=bn(t),o=rn(e);return Zt(n,o),n})(e,t);po(e,n);const o=Mn(e);yo(n,o),wo(e)})(u,p.outputName)}}else ke(d,c)?wo(u):xo(u)},Ky=(e,t,n,o,r)=>!(o in $y&&jy(e,r,n))&&(!e.validate||t.isValid(n,o)||He(o,"data-")||He(o,"aria-")),Gy=(e,t)=>e.hasAttribute(Vy)&&("id"===t||"class"===t||"style"===t),Yy=(e,t)=>e in t.getBoolAttrs(),Xy=(e,t,n)=>{const{attributes:o}=e;for(let r=o.length-1;r>=0;r--){const s=o[r],a=s.name,i=s.value;Ky(t,n,e.tagName.toLowerCase(),a,i)||Gy(e,a)?Yy(a,n)&&e.setAttribute(a,a):e.removeAttribute(a)}},Qy=(e,t)=>{const n=Ly();return n.addHook("uponSanitizeElement",((n,o)=>{Wy(n,e,t,o)})),n.addHook("uponSanitizeAttribute",((n,o)=>{const r=n.tagName.toLowerCase(),{attrName:s,attrValue:a}=o;o.keepAttr=Ky(e,t,r,s,a),o.keepAttr?(o.allowedAttributes[s]=!0,Yy(s,t)&&(o.attrValue=s),e.allow_svg_data_urls&&He(a,"data:image/svg+xml")&&(o.forceKeepAttr=!0)):Gy(n,s)&&(o.forceKeepAttr=!0)})),n},Jy=Dt.makeMap,Zy=Dt.extend,eC=(e,t,n)=>{const o=e.name,r=o in n&&"title"!==o&&"textarea"!==o,s=t.childNodes;for(let t=0,o=s.length;t<o;t++){const o=s[t],a=new Fg(o.nodeName.toLowerCase(),o.nodeType);if($o(o)){const e=o.attributes;for(let t=0,n=e.length;t<n;t++){const n=e[t];a.attr(n.name,n.value)}}else Jo(o)?(a.value=o.data,r&&(a.raw=!0)):(tr(o)||Zo(o)||er(o))&&(a.value=o.data);eC(a,o,n),e.append(a)}},tC=(e={},t=ca())=>{const n=Nv(),o=Nv(),r={validate:!0,root_name:"body",sanitize:!0,...e},s=new DOMParser,a=((e,t)=>{if(e.sanitize){const n=Qy(e,t);return(t,o)=>{n.sanitize(t,((e,t)=>{const n={IN_PLACE:!0,ALLOW_UNKNOWN_PROTOCOLS:!0,ALLOWED_TAGS:["#comment","#cdata-section","body"],ALLOWED_ATTR:[]};return n.PARSER_MEDIA_TYPE=t,e.allow_script_urls?n.ALLOWED_URI_REGEXP=/.*/:e.allow_html_data_urls&&(n.ALLOWED_URI_REGEXP=/^(?!(\w+script|mhtml):)/i),n})(e,o)),n.removed=[]}}return(n,o)=>{const r=document.createNodeIterator(n,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);let s;for(;s=r.nextNode();)Wy(s,e,t),$o(s)&&Xy(s,e,t)}})(r,t),i=n.addFilter,l=n.getFilters,d=n.removeFilter,c=o.addFilter,u=o.getFilters,f=o.removeFilter,g=(e,n)=>{const o=m(n.attr(Vy)),r=1===n.type&&!ke(e,n.name)&&!Ts(t,n);return 3===n.type||r&&!o},p={schema:t,addAttributeFilter:c,getAttributeFilters:u,removeAttributeFilter:f,addNodeFilter:i,getNodeFilters:l,removeNodeFilter:d,parse:(e,n={})=>{var o;const i=r.validate,d=null!==(o=n.context)&&void 0!==o?o:r.root_name,c=((e,n,o="html")=>{const r="xhtml"===o?"application/xhtml+xml":"text/html",i=ke(t.getSpecialElements(),n.toLowerCase()),l=i?`<${n}>${e}</${n}>`:e,d="xhtml"===o?`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>${l}</body></html>`:`<body>${l}</body>`,c=s.parseFromString(d,r).body;return a(c,r),i?c.firstChild:c})(e,d,n.format);Es(t,c);const m=new Fg(d,11);eC(m,c,t.getSpecialElements()),c.innerHTML="";const[f,p]=((e,t,n,o)=>{const r=n.validate,s=t.getNonEmptyElements(),a=t.getWhitespaceElements(),i=Zy(Jy("script,style,head,html,body,title,meta,param"),t.getBlockElements()),l=la(t),d=/[ \t\r\n]+/g,c=/^[ \t\r\n]+/,u=/[ \t\r\n]+$/,m=e=>{let t=e.parent;for(;C(t);){if(t.name in a)return!0;t=t.parent}return!1},f=e=>e.name in i||Ts(t,e),g=(t,n)=>{const r=n?t.prev:t.next;return!C(r)&&!y(t.parent)&&f(t.parent)&&(t.parent!==e||!0===o.isRootContent)};return[e=>{var t;if(3===e.type&&!m(e)){let n=null!==(t=e.value)&&void 0!==t?t:"";n=n.replace(d," "),(((e,t)=>C(e)&&(t(e)||"br"===e.name))(e.prev,f)||g(e,!0))&&(n=n.replace(c,"")),0===n.length?e.remove():e.value=n}},e=>{var i;if(1===e.type){const i=t.getElementRule(e.name);if(r&&i){const r=Jh(t,s,a,e);i.paddInEmptyBlock&&r&&(e=>{let n=e;for(;C(n);){if(n.name in l)return Jh(t,s,a,n);n=n.parent}return!1})(e)?Xh(n,o,f,e):i.removeEmpty&&r?f(e)?e.remove():e.unwrap():i.paddEmpty&&(r||(e=>{var t;return Qh(e,"#text")&&(null===(t=null==e?void 0:e.firstChild)||void 0===t?void 0:t.value)===pr})(e))&&Xh(n,o,f,e)}}else if(3===e.type&&!m(e)){let t=null!==(i=e.value)&&void 0!==i?i:"";(e.next&&f(e.next)||g(e,!1))&&(t=t.replace(u,"")),0===t.length?e.remove():e.value=t}}]})(m,t,r,n),h=[],b=i?e=>((e,n)=>{nb(t,e)&&n.push(e)})(e,h):E,v={nodes:{},attributes:{}},w=e=>Kh(l(),u(),e,v);if(((e,t,n)=>{const o=[];for(let n=e,r=n;n;r=n,n=n.walk()){const s=n;q(t,(e=>e(s))),y(s.parent)&&s!==e?n=r:o.push(s)}for(let e=o.length-1;e>=0;e--){const t=o[e];q(n,(e=>e(t)))}})(m,[f,w],[p,b]),h.reverse(),i&&h.length>0)if(n.context){const{pass:e,fail:o}=K(h,(e=>e.parent===m));tb(o,t,m,w),n.invalid=e.length>0}else tb(h,t,m,w);const x=((e,t)=>{var n;const o=null!==(n=t.forced_root_block)&&void 0!==n?n:e.forced_root_block;return!1===o?"":!0===o?"p":o})(r,n);return x&&("body"===m.name||n.isRootContent)&&((e,n)=>{const o=Zy(Jy("script,style,head,html,body,title,meta,param"),t.getBlockElements()),s=/^[ \t\r\n]+/,a=/[ \t\r\n]+$/;let i=e.firstChild,l=null;const d=e=>{var t,n;e&&(i=e.firstChild,i&&3===i.type&&(i.value=null===(t=i.value)||void 0===t?void 0:t.replace(s,"")),i=e.lastChild,i&&3===i.type&&(i.value=null===(n=i.value)||void 0===n?void 0:n.replace(a,"")))};if(t.isValidChild(e.name,n.toLowerCase())){for(;i;){const t=i.next;g(o,i)?(l||(l=new Fg(n,1),l.attr(r.forced_root_block_attrs),e.insert(l,i)),l.append(i)):(d(l),l=null),i=t}d(l)}})(m,x),n.invalid||Gh(v,n),m}};return Iv(p,r),((e,t,n)=>{t.inline_styles&&Rv(e,t,n)})(p,r,t),p},nC=(e,t,n)=>{const o=(e=>mb(e)?Gg({validate:!1}).serialize(e):e)(e),r=t(o);if(r.isDefaultPrevented())return r;if(mb(e)){if(r.content!==o){const t=tC({validate:!1,forced_root_block:!1,sanitize:n}).parse(r.content,{context:e.name});return{...r,content:t}}return{...r,content:e}}return r},oC=(e,t)=>{if(t.no_events)return sl.value(t);{const n=((e,t)=>e.dispatch("BeforeGetContent",t))(e,t);return n.isDefaultPrevented()?sl.error(Jm(e,{content:"",...n}).content):sl.value(n)}},rC=(e,t,n)=>{if(n.no_events)return t;{const o=nC(t,(t=>Jm(e,{...n,content:t})),oc(e));return o.content}},sC=(e,t)=>{if(t.no_events)return sl.value(t);{const n=nC(t.content,(n=>((e,t)=>e.dispatch("BeforeSetContent",t))(e,{...t,content:n})),oc(e));return n.isDefaultPrevented()?(Qm(e,n),sl.error(void 0)):sl.value(n)}},aC=(e,t,n)=>{n.no_events||Qm(e,{...n,content:t})},iC=(e,t,n)=>({element:e,width:t,rows:n}),lC=(e,t)=>({element:e,cells:t}),dC=(e,t)=>({x:e,y:t}),cC=(e,t)=>tn(e,t).bind(Xe).getOr(1),uC=(e,t,n)=>{const o=e.rows;return!!(o[n]?o[n].cells:[])[t]},mC=e=>X(e,((e,t)=>t.cells.length>e?t.cells.length:e),0),fC=(e,t)=>{const n=e.rows;for(let e=0;e<n.length;e++){const o=n[e].cells;for(let n=0;n<o.length;n++)if(En(o[n],t))return I.some(dC(n,e))}return I.none()},gC=(e,t,n,o,r)=>{const s=[],a=e.rows;for(let e=n;e<=r;e++){const n=a[e].cells,r=t<o?n.slice(t,o+1):n.slice(o,t+1);s.push(lC(a[e].element,r))}return s},pC=e=>((e,t)=>{const n=oi(e.element),o=bn("tbody");return yo(o,t),bo(n,o),n})(e,(e=>V(e.rows,(e=>{const t=V(e.cells,(e=>{const t=ri(e);return on(t,"colspan"),on(t,"rowspan"),t})),n=oi(e.element);return yo(n,t),n})))(e)),hC=(e,t)=>{const n=yn(t.commonAncestorContainer),o=pp(n,e),r=G(o,Br),s=((e,t)=>J(e,(e=>"li"===Ht(e)&&Zu(e,t))).fold(N([]),(t=>(e=>J(e,(e=>"ul"===Ht(e)||"ol"===Ht(e))))(e).map((e=>{const t=bn(Ht(e)),n=ye(mo(e),((e,t)=>He(t,"list-style")));return io(t,n),[bn("li"),t]})).getOr([]))))(o,t),a=r.concat(s.length?s:(e=>Nr(e)?An(e).filter(_r).fold(N([]),(t=>[e,t])):_r(e)?[e]:[])(n));return V(a,oi)},bC=()=>Cf([]),vC=(e,t)=>((e,t)=>Zn(t,"table",O(En,e)))(e,t[0]).bind((e=>{const n=t[0],o=t[t.length-1],r=(e=>{const t=iC(oi(e),0,[]);return q(Fo(e,"tr"),((e,n)=>{q(Fo(e,"td,th"),((o,r)=>{((e,t,n,o,r)=>{const s=cC(r,"rowspan"),a=cC(r,"colspan"),i=e.rows;for(let e=n;e<n+s;e++){i[e]||(i[e]=lC(ri(o),[]));for(let o=t;o<t+a;o++)i[e].cells[o]=e===n&&o===t?r:oi(r)}})(t,((e,t,n)=>{for(;uC(e,t,n);)t++;return t})(t,r,n),n,e,o)}))})),iC(t.element,mC(t.rows),t.rows)})(e);return((e,t,n)=>fC(e,t).bind((t=>fC(e,n).map((n=>((e,t,n)=>{const o=t.x,r=t.y,s=n.x,a=n.y,i=r<a?gC(e,o,r,s,a):gC(e,o,a,s,r);return iC(e.element,mC(i),i)})(e,t,n))))))(r,n,o).map((e=>Cf([pC(e)])))})).getOrThunk(bC),yC=(e,t)=>{const n=Gu(t,e);return n.length>0?vC(e,n):((e,t)=>t.length>0&&t[0].collapsed?bC():((e,t)=>((e,t)=>{const n=X(t,((e,t)=>(bo(t,e),t)),e);return t.length>0?Cf([n]):n})(yn(t.cloneContents()),hC(e,t)))(e,t[0]))(e,t)},CC=(e,t)=>t>=0&&t<e.length&&Fu(e.charAt(t)),wC=e=>Fr(e.innerText),xC=e=>$o(e)?e.outerHTML:Jo(e)?Zs.encodeRaw(e.data,!1):tr(e)?"\x3c!--"+e.data+"--\x3e":"",kC=(e,t)=>(((e,t)=>{let n=0;q(e,(e=>{0===e[0]?n++:1===e[0]?(((e,t,n)=>{const o=(e=>{let t;const n=document.createElement("div"),o=document.createDocumentFragment();for(e&&(n.innerHTML=e);t=n.firstChild;)o.appendChild(t);return o})(t);if(e.hasChildNodes()&&n<e.childNodes.length){const t=e.childNodes[n];e.insertBefore(o,t)}else e.appendChild(o)})(t,e[1],n),n++):2===e[0]&&((e,t)=>{if(e.hasChildNodes()&&t<e.childNodes.length){const n=e.childNodes[t];e.removeChild(n)}})(t,n)}))})(((e,t)=>{const n=e.length+t.length+2,o=new Array(n),r=new Array(n),s=(n,o,r,a,l)=>{const d=i(n,o,r,a);if(null===d||d.start===o&&d.diag===o-a||d.end===n&&d.diag===n-r){let s=n,i=r;for(;s<o||i<a;)s<o&&i<a&&e[s]===t[i]?(l.push([0,e[s]]),++s,++i):o-n>a-r?(l.push([2,e[s]]),++s):(l.push([1,t[i]]),++i)}else{s(n,d.start,r,d.start-d.diag,l);for(let t=d.start;t<d.end;++t)l.push([0,e[t]]);s(d.end,o,d.end-d.diag,a,l)}},a=(n,o,r,s)=>{let a=n;for(;a-o<s&&a<r&&e[a]===t[a-o];)++a;return((e,t,n)=>({start:e,end:t,diag:n}))(n,a,o)},i=(n,s,i,l)=>{const d=s-n,c=l-i;if(0===d||0===c)return null;const u=d-c,m=c+d,f=(m%2==0?m:m+1)/2;let g,p,h,b,v;for(o[1+f]=n,r[1+f]=s+1,g=0;g<=f;++g){for(p=-g;p<=g;p+=2){for(h=p+f,p===-g||p!==g&&o[h-1]<o[h+1]?o[h]=o[h+1]:o[h]=o[h-1]+1,b=o[h],v=b-n+i-p;b<s&&v<l&&e[b]===t[v];)o[h]=++b,++v;if(u%2!=0&&u-g<=p&&p<=u+g&&r[h-u]<=o[h])return a(r[h-u],p+n-i,s,l)}for(p=u-g;p<=u+g;p+=2){for(h=p+f-u,p===u-g||p!==u+g&&r[h+1]<=r[h-1]?r[h]=r[h+1]-1:r[h]=r[h-1],b=r[h]-1,v=b-n+i-p;b>=n&&v>=i&&e[b]===t[v];)r[h]=b--,v--;if(u%2==0&&-g<=p&&p<=g&&r[h]<=o[h+u])return a(r[h],p+n-i,s,l)}}return null},l=[];return s(0,e.length,0,t.length,l),l})(V(ce(t.childNodes),xC),e),t),t),EC=Pe((()=>document.implementation.createHTMLDocument("undo"))),SC=e=>{const t=(n=e.getBody(),G(V(ce(n.childNodes),xC),(e=>e.length>0)));var n;const o=te(t,(t=>{const n=jg(e.serializer,t);return n.length>0?[n]:[]})),r=o.join("");return(e=>-1!==e.indexOf("</iframe>"))(r)?(e=>({type:"fragmented",fragments:e,content:"",bookmark:null,beforeBookmark:null}))(o):(e=>({type:"complete",fragments:null,content:e,bookmark:null,beforeBookmark:null}))(r)},_C=(e,t,n)=>{const o=n?t.beforeBookmark:t.bookmark;"fragmented"===t.type?kC(t.fragments,e.getBody()):e.setContent(t.content,{format:"raw",no_selection:!C(o)||!Su(o)||!o.isFakeCaret}),o&&(e.selection.moveToBookmark(o),e.selection.scrollIntoView())},NC=e=>"fragmented"===e.type?e.fragments.join(""):e.content,RC=e=>{const t=bn("body",EC());return So(t,NC(e)),q(Fo(t,"*[data-mce-bogus]"),xo),Eo(t)},AC=(e,t)=>!(!e||!t)&&(!!((e,t)=>NC(e)===NC(t))(e,t)||((e,t)=>RC(e)===RC(t))(e,t)),OC=e=>0===e.get(),TC=(e,t,n)=>{OC(n)&&(e.typing=t)},BC=(e,t)=>{e.typing&&(TC(e,!1,t),e.add())},DC=e=>({init:{bindEvents:E},undoManager:{beforeChange:(t,n)=>((e,t,n)=>{OC(t)&&n.set(nl(e.selection))})(e,t,n),add:(t,n,o,r,s,a)=>((e,t,n,o,r,s,a)=>{const i=SC(e),l=Dt.extend(s||{},i);if(!OC(o)||e.removed)return null;const d=t.data[n.get()];if(e.dispatch("BeforeAddUndo",{level:l,lastLevel:d,originalEvent:a}).isDefaultPrevented())return null;if(d&&AC(d,l))return null;t.data[n.get()]&&r.get().each((e=>{t.data[n.get()].beforeBookmark=e}));const c=Cd(e);if(c&&t.data.length>c){for(let e=0;e<t.data.length-1;e++)t.data[e]=t.data[e+1];t.data.length--,n.set(t.data.length)}l.bookmark=nl(e.selection),n.get()<t.data.length-1&&(t.data.length=n.get()+1),t.data.push(l),n.set(t.data.length-1);const u={level:l,lastLevel:d,originalEvent:a};return n.get()>0?(e.setDirty(!0),e.dispatch("AddUndo",u),e.dispatch("change",u)):e.dispatch("AddUndo",u),l})(e,t,n,o,r,s,a),undo:(t,n,o)=>((e,t,n,o)=>{let r;return t.typing&&(t.add(),t.typing=!1,TC(t,!1,n)),o.get()>0&&(o.set(o.get()-1),r=t.data[o.get()],_C(e,r,!0),e.setDirty(!0),e.dispatch("Undo",{level:r})),r})(e,t,n,o),redo:(t,n)=>((e,t,n)=>{let o;return t.get()<n.length-1&&(t.set(t.get()+1),o=n[t.get()],_C(e,o,!1),e.setDirty(!0),e.dispatch("Redo",{level:o})),o})(e,t,n),clear:(t,n)=>((e,t,n)=>{t.data=[],n.set(0),t.typing=!1,e.dispatch("ClearUndos")})(e,t,n),reset:e=>(e=>{e.clear(),e.add()})(e),hasUndo:(t,n)=>((e,t,n)=>n.get()>0||t.typing&&t.data[0]&&!AC(SC(e),t.data[0]))(e,t,n),hasRedo:(e,t)=>((e,t)=>t.get()<e.data.length-1&&!e.typing)(e,t),transact:(e,t,n)=>((e,t,n)=>(BC(e,t),e.beforeChange(),e.ignore(n),e.add()))(e,t,n),ignore:(e,t)=>((e,t)=>{try{e.set(e.get()+1),t()}finally{e.set(e.get()-1)}})(e,t),extra:(t,n,o,r)=>((e,t,n,o,r)=>{if(t.transact(o)){const o=t.data[n.get()].bookmark,s=t.data[n.get()-1];_C(e,s,!0),t.transact(r)&&(t.data[n.get()-1].beforeBookmark=o)}})(e,t,n,o,r)},formatter:{match:(t,n,o,r)=>kb(e,t,n,o,r),matchAll:(t,n)=>((e,t,n)=>{const o=[],r={},s=e.selection.getStart();return e.dom.getParent(s,(s=>{for(let a=0;a<t.length;a++){const i=t[a];!r[i]&&xb(e,s,i,n)&&(r[i]=!0,o.push(i))}}),e.dom.getRoot()),o})(e,t,n),matchNode:(t,n,o,r)=>xb(e,t,n,o,r),canApply:t=>((e,t)=>{const n=e.formatter.get(t),o=e.dom;if(n&&e.selection.isEditable()){const t=e.selection.getStart(),r=ym(o,t);for(let e=n.length-1;e>=0;e--){const t=n[e];if(!xm(t))return!0;for(let e=r.length-1;e>=0;e--)if(o.is(r[e],t.selector))return!0}}return!1})(e,t),closest:t=>((e,t)=>{const n=t=>En(t,yn(e.getBody()));return I.from(e.selection.getStart(!0)).bind((o=>hb(yn(o),(n=>ue(t,(t=>((t,n)=>xb(e,t.dom,n)?I.some(n):I.none())(n,t)))),n))).getOrNull()})(e,t),apply:(t,n,o)=>Cv(e,t,n,o),remove:(t,n,o,r)=>gv(e,t,n,o,r),toggle:(t,n,o)=>((e,t,n,o)=>{const r=e.formatter.get(t);r&&(!kb(e,t,n,o)||"toggle"in r[0]&&!r[0].toggle?Cv(e,t,n,o):gv(e,t,n,o))})(e,t,n,o),formatChanged:(t,n,o,r,s)=>((e,t,n,o,r,s)=>(((e,t,n,o,r,s)=>{const a=t.get();q(n.split(","),(t=>{const n=xe(a,t).getOrThunk((()=>{const e={withSimilar:{state:Da(!1),similar:!0,callbacks:[]},withoutSimilar:{state:Da(!1),similar:!1,callbacks:[]},withVars:[]};return a[t]=e,e})),i=()=>{const n=Ev(e);return kv(e,n,t,r,s).isSome()};if(v(s)){const e=r?n.withSimilar:n.withoutSimilar;e.callbacks.push(o),1===e.callbacks.length&&e.state.set(i())}else n.withVars.push({state:Da(i()),similar:r,vars:s,callback:o})})),t.set(a)})(e,t,n,o,r,s),{unbind:()=>((e,t,n)=>{const o=e.get();q(t.split(","),(e=>xe(o,e).each((t=>{o[e]={withSimilar:{...t.withSimilar,callbacks:G(t.withSimilar.callbacks,(e=>e!==n))},withoutSimilar:{...t.withoutSimilar,callbacks:G(t.withoutSimilar.callbacks,(e=>e!==n))},withVars:G(t.withVars,(e=>e.callback!==n))}})))),e.set(o)})(t,n,o)}))(e,t,n,o,r,s)},editor:{getContent:t=>((e,t)=>I.from(e.getBody()).fold(N("tree"===t.format?new Fg("body",11):""),(n=>qg(e,t,n))))(e,t),setContent:(t,n)=>((e,t,n)=>I.from(e.getBody()).map((o=>mb(t)?((e,t,n,o)=>{Yh(e.parser.getNodeFilters(),e.parser.getAttributeFilters(),n);const r=Gg({validate:!1},e.schema).serialize(n),s=Or(yn(t))?r:Dt.trim(r);return fb(e,s,o.no_selection),{content:n,html:s}})(e,o,t,n):((e,t,n,o)=>{if(0===n.length||/^\s+$/.test(n)){const r='<br data-mce-bogus="1">';"TABLE"===t.nodeName?n="<tr><td>"+r+"</td></tr>":/^(UL|OL)$/.test(t.nodeName)&&(n="<li>"+r+"</li>");const s=Nl(e);return e.schema.isValidChild(t.nodeName.toLowerCase(),s.toLowerCase())?(n=r,n=e.dom.createHTML(s,Rl(e),n)):n||(n=r),fb(e,n,o.no_selection),{content:n,html:n}}{"raw"!==o.format&&(n=Gg({validate:!1},e.schema).serialize(e.parser.parse(n,{isRootContent:!0,insert:!0})));const r=Or(yn(t))?n:Dt.trim(n);return fb(e,r,o.no_selection),{content:r,html:r}}})(e,o,t,n))).getOr({content:t,html:mb(n.content)?"":n.content}))(e,t,n),insertContent:(t,n)=>ub(e,t,n),addVisual:t=>((e,t)=>{const n=e.dom,o=C(t)?t:e.getBody();q(n.select("table,a",o),(t=>{switch(t.nodeName){case"TABLE":const o=Ad(e),r=n.getAttrib(t,"border");r&&"0"!==r||!e.hasVisual?n.removeClass(t,o):n.addClass(t,o);break;case"A":if(!n.getAttrib(t,"href")){const o=n.getAttrib(t,"name")||t.id,r=Od(e);o&&e.hasVisual?n.addClass(t,r):n.removeClass(t,r)}}})),e.dispatch("VisualAid",{element:t,hasVisual:e.hasVisual})})(e,t)},selection:{getContent:(t,n)=>((e,t,n={})=>{const o=((e,t)=>({...e,format:t,get:!0,selection:!0,getInner:!0}))(n,t);return oC(e,o).fold(R,(t=>{const n=((e,t)=>{if("text"===t.format)return(e=>I.from(e.selection.getRng()).map((t=>{var n;const o=I.from(e.dom.getParent(t.commonAncestorContainer,e.dom.isBlock)),r=e.getBody(),s=(e=>e.map((e=>e.nodeName)).getOr("div").toLowerCase())(o),a=yn(t.cloneContents());$g(a),Vg(a);const i=e.dom.add(r,s,{"data-mce-bogus":"all",style:"overflow: hidden; opacity: 0;"},a.dom),l=wC(i),d=Fr(null!==(n=i.textContent)&&void 0!==n?n:"");if(e.dom.remove(i),CC(d,0)||CC(d,d.length-1)){const e=o.getOr(r),t=wC(e),n=t.indexOf(l);return-1===n?l:(CC(t,n-1)?" ":"")+l+(CC(t,n+l.length)?" ":"")}return l})).getOr(""))(e);{const n=((e,t)=>{const n=e.selection.getRng(),o=e.dom.create("body"),r=e.selection.getSel(),s=Rg(e,Ku(r)),a=t.contextual?yC(yn(e.getBody()),s).dom:n.cloneContents();return a&&o.appendChild(a),e.selection.serializer.serialize(o,t)})(e,t);return"tree"===t.format?n:e.selection.isCollapsed()?"":n}})(e,t);return rC(e,n,t)}))})(e,t,n)},autocompleter:{addDecoration:t=>Bg(e,t),removeDecoration:()=>((e,t)=>Dg(t).each((t=>{const n=e.selection.getBookmark();xo(t),e.selection.moveToBookmark(n)})))(e,yn(e.getBody()))},raw:{getModel:()=>I.none()}}),PC=e=>ke(e.plugins,"rtc"),LC=e=>e.rtcInstance?e.rtcInstance:DC(e),MC=e=>{const t=e.rtcInstance;if(t)return t;throw new Error("Failed to get RTC instance not yet initialized.")},IC=e=>MC(e).init.bindEvents(),FC=e=>0===e.dom.length?(wo(e),I.none()):I.some(e),UC=(e,t,n,o)=>{e.bind((e=>((o?Kp:Wp)(e.dom,o?e.dom.length:0),t.filter(Kt).map((t=>((e,t,n,o)=>{const r=e.dom,s=t.dom,a=o?r.length:s.length;o?(Gp(r,s,!1,!o),n.setStart(s,a)):(Gp(s,r,!1,!o),n.setEnd(s,a))})(e,t,n,o)))))).orThunk((()=>{const e=((e,t)=>e.filter((e=>Wm.isBookmarkNode(e.dom))).bind(t?Dn:Bn))(t,o).or(t).filter(Kt);return e.map((e=>((e,t)=>{An(e).each((n=>{const o=e.dom;t&&Ip(n,Li(o,0))?Wp(o,0):!t&&Fp(n,Li(o,o.length))&&Kp(o,o.length)}))})(e,o)))}))},zC=(e,t,n)=>{if(ke(e,t)){const o=G(e[t],(e=>e!==n));0===o.length?delete e[t]:e[t]=o}};const jC=e=>!(!e||!e.ownerDocument)&&Sn(yn(e.ownerDocument),yn(e)),HC=(e,t,n,o)=>{let r,s;const{selectorChangedWithUnbind:a}=((e,t)=>{let n,o;const r=(t,n)=>J(n,(n=>e.is(n,t))),s=t=>e.getParents(t,void 0,e.getRoot());return{selectorChangedWithUnbind:(e,a)=>(n||(n={},o={},t.on("NodeChange",(e=>{const t=e.element,a=s(t),i={};ge(n,((e,t)=>{r(t,a).each((n=>{o[t]||(q(e,(e=>{e(!0,{node:n,selector:t,parents:a})})),o[t]=e),i[t]=e}))})),ge(o,((e,n)=>{i[n]||(delete o[n],q(e,(e=>{e(!1,{node:t,selector:n,parents:a})})))}))}))),n[e]||(n[e]=[]),n[e].push(a),r(e,s(t.selection.getStart())).each((()=>{o[e]=n[e]})),{unbind:()=>{zC(n,e,a),zC(o,e,a)}})}})(e,o),i=(e,t)=>((e,t,n={})=>{const o=((e,t)=>({format:"html",...e,set:!0,selection:!0,content:t}))(n,t);sC(e,o).each((t=>{const n=((e,t)=>{if("raw"!==t.format){const n=e.selection.getRng(),o=e.dom.getParent(n.commonAncestorContainer,e.dom.isBlock),r=o?{context:o.nodeName.toLowerCase()}:{},s=e.parser.parse(t.content,{forced_root_block:!1,...r,...t});return Gg({validate:!1},e.schema).serialize(s)}return t.content})(e,t),o=e.selection.getRng();((e,t)=>{const n=I.from(t.firstChild).map(yn),o=I.from(t.lastChild).map(yn);e.deleteContents(),e.insertNode(t);const r=n.bind(Bn).filter(Kt).bind(FC),s=o.bind(Dn).filter(Kt).bind(FC);UC(r,n,e,!0),UC(s,o,e,!1),e.collapse(!1)})(o,o.createContextualFragment(n)),e.selection.setRng(o),Zf(e,o),aC(e,n,t)}))})(o,e,t),l=e=>{const t=c();t.collapse(!!e),u(t)},d=()=>t.getSelection?t.getSelection():t.document.selection,c=()=>{let n;const a=(e,t,n)=>{try{return t.compareBoundaryPoints(e,n)}catch(e){return-1}},i=t.document;if(C(o.bookmark)&&!xg(o)){const e=cg(o);if(e.isSome())return e.map((e=>Rg(o,[e])[0])).getOr(i.createRange())}try{const e=d();e&&!Ho(e.anchorNode)&&(n=e.rangeCount>0?e.getRangeAt(0):i.createRange(),n=Rg(o,[n])[0])}catch(e){}if(n||(n=i.createRange()),nr(n.startContainer)&&n.collapsed){const t=e.getRoot();n.setStart(t,0),n.setEnd(t,0)}return r&&s&&(0===a(n.START_TO_START,n,r)&&0===a(n.END_TO_END,n,r)?n=s:(r=null,s=null)),n},u=(e,t)=>{if(!(e=>!!e&&jC(e.startContainer)&&jC(e.endContainer))(e))return;const n=d();if(e=o.dispatch("SetSelectionRange",{range:e,forward:t}).range,n){s=e;try{n.removeAllRanges(),n.addRange(e)}catch(e){}!1===t&&n.extend&&(n.collapse(e.endContainer,e.endOffset),n.extend(e.startContainer,e.startOffset)),r=n.rangeCount>0?n.getRangeAt(0):null}if(!e.collapsed&&e.startContainer===e.endContainer&&(null==n?void 0:n.setBaseAndExtent)&&e.endOffset-e.startOffset<2&&e.startContainer.hasChildNodes()){const t=e.startContainer.childNodes[e.startOffset];t&&"IMG"===t.nodeName&&(n.setBaseAndExtent(e.startContainer,e.startOffset,e.endContainer,e.endOffset),n.anchorNode===e.startContainer&&n.focusNode===e.endContainer||n.setBaseAndExtent(t,0,t,1))}o.dispatch("AfterSetSelectionRange",{range:e,forward:t})},m=()=>{const t=d(),n=null==t?void 0:t.anchorNode,o=null==t?void 0:t.focusNode;if(!t||!n||!o||Ho(n)||Ho(o))return!0;const r=e.createRng(),s=e.createRng();try{r.setStart(n,t.anchorOffset),r.collapse(!0),s.setStart(o,t.focusOffset),s.collapse(!0)}catch(e){return!0}return r.compareBoundaryPoints(r.START_TO_START,s)<=0},f={dom:e,win:t,serializer:n,editor:o,expand:(t={type:"word"})=>u(Df(e).expand(c(),t)),collapse:l,setCursorLocation:(t,n)=>{const r=e.createRng();C(t)&&C(n)?(r.setStart(t,n),r.setEnd(t,n),u(r),l(!1)):(em(e,r,o.getBody(),!0),u(r))},getContent:e=>((e,t={})=>((e,t,n)=>MC(e).selection.getContent(t,n))(e,t.format?t.format:"html",t))(o,e),setContent:i,getBookmark:(e,t)=>g.getBookmark(e,t),moveToBookmark:e=>g.moveToBookmark(e),select:(t,n)=>(((e,t,n)=>I.from(t).bind((t=>I.from(t.parentNode).map((o=>{const r=e.nodeIndex(t),s=e.createRng();return s.setStart(o,r),s.setEnd(o,r+1),n&&(em(e,s,t,!0),em(e,s,t,!1)),s})))))(e,t,n).each(u),t),isCollapsed:()=>{const e=c(),t=d();return!(!e||e.item)&&(e.compareEndPoints?0===e.compareEndPoints("StartToEnd",e):!t||e.collapsed)},isEditable:()=>{const t=c(),n=o.getBody().querySelectorAll('[data-mce-selected="1"]');return n.length>0?ne(n,(t=>e.isEditable(t.parentElement))):t.startContainer===t.endContainer?e.isEditable(t.startContainer):e.isEditable(t.startContainer)&&e.isEditable(t.endContainer)},isForward:m,setNode:t=>(i(e.getOuterHTML(t)),t),getNode:()=>((e,t)=>{if(!t)return e;let n=t.startContainer,o=t.endContainer;const r=t.startOffset,s=t.endOffset;let a=t.commonAncestorContainer;t.collapsed||(n===o&&s-r<2&&n.hasChildNodes()&&(a=n.childNodes[r]),Jo(n)&&Jo(o)&&(n=n.length===r?Ng(n.nextSibling,!0):n.parentNode,o=0===s?Ng(o.previousSibling,!1):o.parentNode,n&&n===o&&(a=n)));const i=Jo(a)?a.parentNode:a;return $o(i)?i:e})(o.getBody(),c()),getSel:d,setRng:u,getRng:c,getStart:e=>Sg(o.getBody(),c(),e),getEnd:e=>_g(o.getBody(),c(),e),getSelectedBlocks:(t,n)=>((e,t,n,o)=>{const r=[],s=e.getRoot(),a=e.getParent(n||Sg(s,t,t.collapsed),e.isBlock),i=e.getParent(o||_g(s,t,t.collapsed),e.isBlock);if(a&&a!==s&&r.push(a),a&&i&&a!==i){let t;const n=new zo(a,s);for(;(t=n.next())&&t!==i;)e.isBlock(t)&&r.push(t)}return i&&a!==i&&i!==s&&r.push(i),r})(e,c(),t,n),normalize:()=>{const t=c(),n=d();if(!(Ku(n).length>1)&&tm(o)){const n=Of(e,t);return n.each((e=>{u(e,m())})),n.getOr(t)}return t},selectorChanged:(e,t)=>(a(e,t),f),selectorChangedWithUnbind:a,getScrollContainer:()=>{let t,n=e.getRoot();for(;n&&"BODY"!==n.nodeName;){if(n.scrollHeight>n.clientHeight){t=n;break}n=n.parentNode}return t},scrollIntoView:(e,t)=>{C(e)?((e,t,n)=>{(e.inline?Xf:Jf)(e,t,n)})(o,e,t):Zf(o,c(),t)},placeCaretAt:(e,t)=>u(xf(e,t,o.getDoc())),getBoundingClientRect:()=>{const e=c();return e.collapsed?Li.fromRangeStart(e).getClientRects()[0]:e.getBoundingClientRect()},destroy:()=>{t=r=s=null,p.destroy()}},g=Wm(f),p=sf(f,o);return f.bookmarkManager=g,f.controlSelection=p,f},$C=(e,t,n)=>{-1===Dt.inArray(t,n)&&(e.addAttributeFilter(n,((e,t)=>{let n=e.length;for(;n--;)e[n].attr(t,null)})),t.push(n))},VC=(e,t)=>{const n=["data-mce-selected"],o={entity_encoding:"named",remove_trailing_brs:!0,pad_empty_with_br:!1,...e},r=t&&t.dom?t.dom:Oa.DOM,s=t&&t.schema?t.schema:ca(o),a=tC(o,s);return((e,t,n)=>{e.addAttributeFilter("data-mce-tabindex",((e,t)=>{let n=e.length;for(;n--;){const o=e[n];o.attr("tabindex",o.attr("data-mce-tabindex")),o.attr(t,null)}})),e.addAttributeFilter("src,href,style",((e,o)=>{const r="data-mce-"+o,s=t.url_converter,a=t.url_converter_scope;let i=e.length;for(;i--;){const t=e[i];let l=t.attr(r);void 0!==l?(t.attr(o,l.length>0?l:null),t.attr(r,null)):(l=t.attr(o),"style"===o?l=n.serializeStyle(n.parseStyle(l),t.name):s&&(l=s.call(a,l,o,t.name)),t.attr(o,l.length>0?l:null))}})),e.addAttributeFilter("class",(e=>{let t=e.length;for(;t--;){const n=e[t];let o=n.attr("class");o&&(o=o.replace(/(?:^|\s)mce-item-\w+(?!\S)/g,""),n.attr("class",o.length>0?o:null))}})),e.addAttributeFilter("data-mce-type",((e,t,n)=>{let o=e.length;for(;o--;){const t=e[o];if("bookmark"===t.attr("data-mce-type")&&!n.cleanup){const e=I.from(t.firstChild).exists((e=>{var t;return!Ir(null!==(t=e.value)&&void 0!==t?t:"")}));e?t.unwrap():t.remove()}}})),e.addNodeFilter("noscript",(e=>{var t;let n=e.length;for(;n--;){const o=e[n].firstChild;o&&(o.value=Zs.decode(null!==(t=o.value)&&void 0!==t?t:""))}})),e.addNodeFilter("script,style",((e,n)=>{var o;const r=e=>e.replace(/(<!--\[CDATA\[|\]\]-->)/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*((<!--)?(\s*\/\/)?\s*<!\[CDATA\[|(<!--\s*)?\/\*\s*<!\[CDATA\[\s*\*\/|(\/\/)?\s*<!--|\/\*\s*<!--\s*\*\/)\s*[\r\n]*/gi,"").replace(/\s*(\/\*\s*\]\]>\s*\*\/(-->)?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"");let s=e.length;for(;s--;){const a=e[s],i=a.firstChild,l=null!==(o=null==i?void 0:i.value)&&void 0!==o?o:"";if("script"===n){const e=a.attr("type");e&&a.attr("type","mce-no/type"===e?null:e.replace(/^mce\-/,"")),"xhtml"===t.element_format&&i&&l.length>0&&(i.value="// <![CDATA[\n"+r(l)+"\n// ]]>")}else"xhtml"===t.element_format&&i&&l.length>0&&(i.value="\x3c!--\n"+r(l)+"\n--\x3e")}})),e.addNodeFilter("#comment",(e=>{let o=e.length;for(;o--;){const r=e[o],s=r.value;t.preserve_cdata&&0===(null==s?void 0:s.indexOf("[CDATA["))?(r.name="#cdata",r.type=4,r.value=n.decode(s.replace(/^\[CDATA\[|\]\]$/g,""))):0===(null==s?void 0:s.indexOf("mce:protected "))&&(r.name="#text",r.type=3,r.raw=!0,r.value=unescape(s).substr(14))}})),e.addNodeFilter("xml:namespace,input",((e,t)=>{let n=e.length;for(;n--;){const o=e[n];7===o.type?o.remove():1===o.type&&("input"!==t||o.attr("type")||o.attr("type","text"))}})),e.addAttributeFilter("data-mce-type",(t=>{q(t,(t=>{"format-caret"===t.attr("data-mce-type")&&(t.isEmpty(e.schema.getNonEmptyElements())?t.remove():t.unwrap())}))})),e.addAttributeFilter("data-mce-src,data-mce-href,data-mce-style,data-mce-selected,data-mce-expando,data-mce-block,data-mce-type,data-mce-resize,data-mce-placeholder",((e,t)=>{let n=e.length;for(;n--;)e[n].attr(t,null)})),t.remove_trailing_brs&&Av(t,e,e.schema)})(a,o,r),{schema:s,addNodeFilter:a.addNodeFilter,addAttributeFilter:a.addAttributeFilter,serialize:(e,n={})=>{const i={format:"html",...n},l=((e,t,n)=>((e,t)=>C(e)&&e.hasEventListeners("PreProcess")&&!t.no_events)(e,n)?((e,t,n)=>{let o;const r=e.dom;let s=t.cloneNode(!0);const a=document.implementation;if(a.createHTMLDocument){const e=a.createHTMLDocument("");Dt.each("BODY"===s.nodeName?s.childNodes:[s],(t=>{e.body.appendChild(e.importNode(t,!0))})),s="BODY"!==s.nodeName?e.body.firstChild:e.body,o=r.doc,r.doc=e}return((e,t)=>{e.dispatch("PreProcess",t)})(e,{...n,node:s}),o&&(r.doc=o),s})(e,t,n):t)(t,e,i),d=((e,t,n)=>{const o=Fr(n.getInner?t.innerHTML:e.getOuterHTML(t));return n.selection||Or(yn(t))?o:Dt.trim(o)})(r,l,i),c=((e,t,n)=>{const o=n.selection?{forced_root_block:!1,...n}:n,r=e.parse(t,o);return(e=>{const t=e=>"br"===(null==e?void 0:e.name),n=e.lastChild;if(t(n)){const e=n.prev;t(e)&&(n.remove(),e.remove())}})(r),r})(a,d,i);return"tree"===i.format?c:((e,t,n,o,r)=>{const s=((e,t,n)=>Gg(e,t).serialize(n))(t,n,o);return((e,t,n)=>{if(!t.no_events&&e){const o=((e,t)=>e.dispatch("PostProcess",t))(e,{...t,content:n});return o.content}return n})(e,r,s)})(t,o,s,c,i)},addRules:s.addValidElements,setRules:s.setValidElements,addTempAttr:O($C,a,n),getTempAttrs:N(n),getNodeFilters:a.getNodeFilters,getAttributeFilters:a.getAttributeFilters,removeNodeFilter:a.removeNodeFilter,removeAttributeFilter:a.removeAttributeFilter}},qC=(e,t)=>{const n=VC(e,t);return{schema:n.schema,addNodeFilter:n.addNodeFilter,addAttributeFilter:n.addAttributeFilter,serialize:n.serialize,addRules:n.addRules,setRules:n.setRules,addTempAttr:n.addTempAttr,getTempAttrs:n.getTempAttrs,getNodeFilters:n.getNodeFilters,getAttributeFilters:n.getAttributeFilters,removeNodeFilter:n.removeNodeFilter,removeAttributeFilter:n.removeAttributeFilter}},WC=(e,t,n={})=>{const o=((e,t)=>({format:"html",...e,set:!0,content:t}))(n,t);return sC(e,o).map((t=>{const n=((e,t,n)=>LC(e).editor.setContent(t,n))(e,t.content,t);return aC(e,n.html,t),n.content})).getOr(t)},KC="autoresize_on_init,content_editable_state,padd_empty_with_br,block_elements,boolean_attributes,editor_deselector,editor_selector,elements,file_browser_callback_types,filepicker_validator_handler,force_hex_style_colors,force_p_newlines,gecko_spellcheck,images_dataimg_filter,media_scripts,mode,move_caret_before_on_enter_elements,non_empty_elements,self_closing_elements,short_ended_elements,special,spellchecker_select_languages,spellchecker_whitelist,tab_focus,tabfocus_elements,table_responsive_width,text_block_elements,text_inline_elements,toolbar_drawer,types,validate,whitespace_elements,paste_enable_default_filters,paste_filter_drop,paste_word_valid_elements,paste_retain_style_properties,paste_convert_word_fake_lists".split(","),GC="template_cdate_classes,template_mdate_classes,template_selected_content_classes,template_preview_replace_values,template_replace_values,templates,template_cdate_format,template_mdate_format".split(","),YC="bbcode,colorpicker,contextmenu,fullpage,legacyoutput,spellchecker,textcolor".split(","),XC=[{name:"template",replacedWith:"Advanced Template"},{name:"rtc"}],QC=(e,t)=>{const n=G(t,(t=>ke(e,t)));return ae(n)},JC=e=>{const t=QC(e,KC),n=e.forced_root_block;return!1!==n&&""!==n||t.push("forced_root_block (false only)"),ae(t)},ZC=e=>QC(e,GC),ew=(e,t)=>{const n=Dt.makeMap(e.plugins," "),o=G(t,(e=>ke(n,e)));return ae(o)},tw=e=>ew(e,YC),nw=e=>ew(e,XC.map((e=>e.name))),ow=e=>J(XC,(t=>t.name===e)).fold((()=>e),(t=>t.replacedWith?`${e}, replaced by ${t.replacedWith}`:e)),rw=Oa.DOM,sw=e=>I.from(e).each((e=>e.destroy())),aw=(()=>{const e={};return{add:(t,n)=>{e[t]=n},get:t=>e[t]?e[t]:{icons:{}},has:t=>ke(e,t)}})(),iw=Fa.ModelManager,lw=(e,t)=>t.dom[e],dw=(e,t)=>parseInt(lo(t,e),10),cw=O(lw,"clientWidth"),uw=O(lw,"clientHeight"),mw=O(dw,"margin-top"),fw=O(dw,"margin-left"),gw=e=>{const t=[],n=()=>{const t=e.theme;return t&&t.getNotificationManagerImpl?t.getNotificationManagerImpl():(()=>{const e=()=>{throw new Error("Theme did not provide a NotificationManager implementation.")};return{open:e,close:e,getArgs:e}})()},o=()=>I.from(t[0]),r=()=>{q(t,(e=>{e.reposition()}))},s=e=>{Z(t,(t=>t===e)).each((e=>{t.splice(e,1)}))},a=(a,i=!0)=>e.removed||!(e=>{return(t=e.inline?e.getBody():e.getContentAreaContainer(),I.from(t).map(yn)).map(Yn).getOr(!1);var t})(e)?{}:(i&&e.dispatch("BeforeOpenNotification",{notification:a}),J(t,(e=>{return t=n().getArgs(e),o=a,!(t.type!==o.type||t.text!==o.text||t.progressBar||t.timeout||o.progressBar||o.timeout);var t,o})).getOrThunk((()=>{e.editorManager.setActive(e);const i=n().open(a,(()=>{s(i),r(),o().fold((()=>e.focus()),(e=>eg(yn(e.getEl()))))}));return(e=>{t.push(e)})(i),r(),e.dispatch("OpenNotification",{notification:{...i}}),i}))),i=N(t);return(e=>{e.on("SkinLoaded",(()=>{const t=rd(e);t&&a({text:t,type:"warning",timeout:0},!1),r()})),e.on("show ResizeEditor ResizeWindow NodeChange",(()=>{requestAnimationFrame(r)})),e.on("remove",(()=>{q(t.slice(),(e=>{n().close(e)}))}))})(e),{open:a,close:()=>{o().each((e=>{n().close(e),s(e),r()}))},getNotifications:i}},pw=Fa.PluginManager,hw=Fa.ThemeManager,bw=e=>{let t=[];const n=()=>{const t=e.theme;return t&&t.getWindowManagerImpl?t.getWindowManagerImpl():(()=>{const e=()=>{throw new Error("Theme did not provide a WindowManager implementation.")};return{open:e,openUrl:e,alert:e,confirm:e,close:e}})()},o=(e,t)=>(...n)=>t?t.apply(e,n):void 0,r=n=>{(t=>{e.dispatch("CloseWindow",{dialog:t})})(n),t=G(t,(e=>e!==n)),0===t.length&&e.focus()},s=n=>{e.editorManager.setActive(e),dg(e),e.ui.show();const o=n();return(n=>{t.push(n),(t=>{e.dispatch("OpenWindow",{dialog:t})})(n)})(o),o};return e.on("remove",(()=>{q(t,(e=>{n().close(e)}))})),{open:(e,t)=>s((()=>n().open(e,t,r))),openUrl:e=>s((()=>n().openUrl(e,r))),alert:(e,t,r)=>{const s=n();s.alert(e,o(r||s,t))},confirm:(e,t,r)=>{const s=n();s.confirm(e,o(r||s,t))},close:()=>{I.from(t[t.length-1]).each((e=>{n().close(e),r(e)}))}}},vw=(e,t)=>{e.notificationManager.open({type:"error",text:t})},yw=(e,t)=>{e._skinLoaded?vw(e,t):e.on("SkinLoaded",(()=>{vw(e,t)}))},Cw=(e,t,n)=>{Gm(e,t,{message:n}),console.error(n)},ww=(e,t,n)=>n?`Failed to load ${e}: ${n} from url ${t}`:`Failed to load ${e} url: ${t}`,xw=(e,...t)=>{const n=window.console;n&&(n.error?n.error(e,...t):n.log(e,...t))},kw=(e,t)=>{const n=e.editorManager.baseURL+"/skins/content",o=`content${e.editorManager.suffix}.min.css`;return V(t,(t=>(e=>/^[a-z0-9\-]+$/i.test(e))(t)&&!e.inline?`${n}/${t}/${o}`:e.documentBaseURI.toAbsolute(t)))},Ew=(e,t)=>{const n={};return{findAll:(o,r=M)=>{const s=G((e=>e?ce(e.getElementsByTagName("img")):[])(o),(t=>{const n=t.src;return!t.hasAttribute("data-mce-bogus")&&!t.hasAttribute("data-mce-placeholder")&&!(!n||n===At.transparentSrc)&&(He(n,"blob:")?!e.isUploaded(n)&&r(t):!!He(n,"data:")&&r(t))})),a=V(s,(e=>{const o=e.src;if(ke(n,o))return n[o].then((t=>m(t)?t:{image:e,blobInfo:t.blobInfo}));{const r=((e,t)=>{const n=()=>Promise.reject("Invalid data URI");if(He(t,"blob:")){const s=e.getByUri(t);return C(s)?Promise.resolve(s):(o=t,He(o,"blob:")?(e=>fetch(e).then((e=>e.ok?e.blob():Promise.reject())).catch((()=>Promise.reject({message:`Cannot convert ${e} to Blob. Resource might not exist or is inaccessible.`,uriType:"blob"}))))(o):He(o,"data:")?(r=o,new Promise(((e,t)=>{Ov(r).bind((({type:e,data:t,base64Encoded:n})=>Tv(e,t,n))).fold((()=>t("Invalid data URI")),e)}))):Promise.reject("Unknown URI format")).then((t=>Bv(t).then((o=>Pv(o,!1,(n=>I.some(Lv(e,t,n)))).getOrThunk(n)))))}var o,r;return He(t,"data:")?Mv(e,t).fold(n,(e=>Promise.resolve(e))):Promise.reject("Unknown image data format")})(t,o).then((t=>(delete n[o],{image:e,blobInfo:t}))).catch((e=>(delete n[o],e)));return n[o]=r,r}}));return Promise.all(a)}}},Sw=()=>{let e={};const t=(e,t)=>({status:e,resultUri:t}),n=t=>t in e;return{hasBlobUri:n,getResultUri:t=>{const n=e[t];return n?n.resultUri:null},isPending:t=>!!n(t)&&1===e[t].status,isUploaded:t=>!!n(t)&&2===e[t].status,markPending:n=>{e[n]=t(1,null)},markUploaded:(n,o)=>{e[n]=t(2,o)},removeFailed:t=>{delete e[t]},destroy:()=>{e={}}}};let _w=0;const Nw=(e,t)=>{const n={},o=(e,n)=>new Promise(((o,r)=>{const s=new XMLHttpRequest;s.open("POST",t.url),s.withCredentials=t.credentials,s.upload.onprogress=e=>{n(e.loaded/e.total*100)},s.onerror=()=>{r("Image upload failed due to a XHR Transport error. Code: "+s.status)},s.onload=()=>{if(s.status<200||s.status>=300)return void r("HTTP Error: "+s.status);const e=JSON.parse(s.responseText);var n,a;e&&m(e.location)?o((n=t.basePath,a=e.location,n?n.replace(/\/$/,"")+"/"+a.replace(/^\//,""):a)):r("Invalid JSON: "+s.responseText)};const a=new FormData;a.append("fromTinyMce",1),a.append("userfile",e.blob(),e.filename()),s.send(a)})),r=w(t.handler)?t.handler:o,s=(e,t)=>({url:t,blobInfo:e,status:!0}),a=(e,t)=>({url:"",blobInfo:e,status:!1,error:t}),i=(e,t)=>{Dt.each(n[e],(e=>{e(t)})),delete n[e]};return{upload:(l,d)=>t.url||r!==o?((t,o)=>(t=Dt.grep(t,(t=>!e.isUploaded(t.blobUri()))),Promise.all(Dt.map(t,(t=>e.isPending(t.blobUri())?(e=>{const t=e.blobUri();return new Promise((e=>{n[t]=n[t]||[],n[t].push(e)}))})(t):((t,n,o)=>(e.markPending(t.blobUri()),new Promise((r=>{let l,d;try{const c=()=>{l&&(l.close(),d=E)},u=n=>{c(),e.markUploaded(t.blobUri(),n),i(t.blobUri(),s(t,n)),r(s(t,n))},f=n=>{c(),e.removeFailed(t.blobUri()),i(t.blobUri(),a(t,n)),r(a(t,n))};d=e=>{e<0||e>100||I.from(l).orThunk((()=>I.from(o).map(D))).each((t=>{l=t,t.progressBar.value(e)}))},n(t,d).then(u,(e=>{f(m(e)?{message:e}:e)}))}catch(e){r(a(t,e))}}))))(t,r,o))))))(l,d):new Promise((e=>{e([])}))}},Rw=e=>()=>e.notificationManager.open({text:e.translate("Image uploading..."),type:"info",timeout:-1,progressBar:!0}),Aw=(e,t)=>Nw(t,{url:Ul(e),basePath:zl(e),credentials:jl(e),handler:Hl(e)}),Ow=e=>{const t=(()=>{let e=[];const t=e=>{if(!e.blob||!e.base64)throw new Error("blob and base64 representations of the image are required for BlobInfo to be created");const t=e.id||"blobid"+_w+++(()=>{const e=()=>Math.round(4294967295*Math.random()).toString(36);return"s"+(new Date).getTime().toString(36)+e()+e()+e()})(),n=e.name||t,o=e.blob;var r;return{id:N(t),name:N(n),filename:N(e.filename||n+"."+(r=o.type,{"image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/png":"png","image/apng":"apng","image/avif":"avif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff"}[r.toLowerCase()]||"dat")),blob:N(o),base64:N(e.base64),blobUri:N(e.blobUri||URL.createObjectURL(o)),uri:N(e.uri)}},n=t=>J(e,t).getOrUndefined(),o=e=>n((t=>t.id()===e));return{create:(e,n,o,r,s)=>{if(m(e))return t({id:e,name:r,filename:s,blob:n,base64:o});if(f(e))return t(e);throw new Error("Unknown input type")},add:t=>{o(t.id())||e.push(t)},get:o,getByUri:e=>n((t=>t.blobUri()===e)),getByData:(e,t)=>n((n=>n.base64()===e&&n.blob().type===t)),findFirst:n,removeByUri:t=>{e=G(e,(e=>e.blobUri()!==t||(URL.revokeObjectURL(e.blobUri()),!1)))},destroy:()=>{q(e,(e=>{URL.revokeObjectURL(e.blobUri())})),e=[]}}})();let n,o;const r=Sw(),s=[],a=t=>n=>e.selection?t(n):[],i=(e,t,n)=>{let o=0;do{o=e.indexOf(t,o),-1!==o&&(e=e.substring(0,o)+n+e.substr(o+t.length),o+=n.length-t.length+1)}while(-1!==o);return e},l=(e,t,n)=>{const o=`src="${n}"${n===At.transparentSrc?' data-mce-placeholder="1"':""}`;return e=i(e,`src="${t}"`,o),i(e,'data-mce-src="'+t+'"','data-mce-src="'+n+'"')},d=(t,n)=>{q(e.undoManager.data,(e=>{"fragmented"===e.type?e.fragments=V(e.fragments,(e=>l(e,t,n))):e.content=l(e.content,t,n)}))},c=()=>(n||(n=Aw(e,r)),p().then(a((o=>{const r=V(o,(e=>e.blobInfo));return n.upload(r,Rw(e)).then(a((n=>{const r=[];let s=!1;const a=V(n,((n,a)=>{const{blobInfo:i,image:l}=o[a];let c=!1;return n.status&&Ml(e)?(n.url&&!je(l.src,n.url)&&(s=!0),t.removeByUri(l.src),PC(e)||((t,n)=>{const o=e.convertURL(n,"src");var r;d(t.src,n),Zt(yn(t),{src:Ll(e)?(r=n,r+(-1===r.indexOf("?")?"?":"&")+(new Date).getTime()):n,"data-mce-src":o})})(l,n.url)):n.error&&(n.error.remove&&(d(l.src,At.transparentSrc),r.push(l),c=!0),((e,t)=>{yw(e,Ia.translate(["Failed to upload image: {0}",t]))})(e,n.error.message)),{element:l,status:n.status,uploadUri:n.url,blobInfo:i,removed:c}}));return r.length>0&&!PC(e)?e.undoManager.transact((()=>{q(ko(r),(n=>{const o=An(n);wo(n),o.each((e=>t=>{((e,t)=>e.dom.isEmpty(t.dom)&&C(e.schema.getTextBlockElements()[Ht(t)]))(e,t)&&bo(t,hn('<br data-mce-bogus="1" />'))})(e)),t.removeByUri(n.dom.src)}))})):s&&e.undoManager.dispatchChange(),a})))})))),u=()=>Pl(e)?c():Promise.resolve([]),g=e=>ne(s,(t=>t(e))),p=()=>(o||(o=Ew(r,t)),o.findAll(e.getBody(),g).then(a((t=>{const n=G(t,(t=>m(t)?(yw(e,t),!1):"blob"!==t.uriType));return PC(e)||q(n,(e=>{d(e.image.src,e.blobInfo.blobUri()),e.image.src=e.blobInfo.blobUri(),e.image.removeAttribute("data-mce-src")})),n})))),h=n=>n.replace(/src="(blob:[^"]+)"/g,((n,o)=>{const s=r.getResultUri(o);if(s)return'src="'+s+'"';let a=t.getByUri(o);return a||(a=X(e.editorManager.get(),((e,t)=>e||t.editorUpload&&t.editorUpload.blobCache.getByUri(o)),void 0)),a?'src="data:'+a.blob().type+";base64,"+a.base64()+'"':n}));return e.on("SetContent",(()=>{Pl(e)?u():p()})),e.on("RawSaveContent",(e=>{e.content=h(e.content)})),e.on("GetContent",(e=>{e.source_view||"raw"===e.format||"tree"===e.format||(e.content=h(e.content))})),e.on("PostRender",(()=>{e.parser.addNodeFilter("img",(e=>{q(e,(e=>{const n=e.attr("src");if(!n||t.getByUri(n))return;const o=r.getResultUri(n);o&&e.attr("src",o)}))}))})),{blobCache:t,addFilter:e=>{s.push(e)},uploadImages:c,uploadImagesAuto:u,scanForImages:p,destroy:()=>{t.destroy(),r.destroy(),o=n=null}}},Tw={remove_similar:!0,inherit:!1},Bw={selector:"td,th",...Tw},Dw={tablecellbackgroundcolor:{styles:{backgroundColor:"%value"},...Bw},tablecellverticalalign:{styles:{"vertical-align":"%value"},...Bw},tablecellbordercolor:{styles:{borderColor:"%value"},...Bw},tablecellclass:{classes:["%value"],...Bw},tableclass:{selector:"table",classes:["%value"],...Tw},tablecellborderstyle:{styles:{borderStyle:"%value"},...Bw},tablecellborderwidth:{styles:{borderWidth:"%value"},...Bw}},Pw=N(Dw),Lw=Dt.each,Mw=Oa.DOM,Iw=e=>C(e)&&f(e),Fw=(e,t)=>{const n=t&&t.schema||ca({}),o=e=>{const t=m(e)?{name:e,classes:[],attrs:{}}:e,n=Mw.create(t.name);return((e,t)=>{t.classes.length>0&&Mw.addClass(e,t.classes.join(" ")),Mw.setAttribs(e,t.attrs)})(n,t),n},r=(e,t,s)=>{let a;const i=t[0],l=Iw(i)?i.name:void 0,d=((e,t)=>{const o=n.getElementRule(e.nodeName.toLowerCase()),r=null==o?void 0:o.parentsRequired;return!(!r||!r.length)&&(t&&H(r,t)?t:r[0])})(e,l);if(d)l===d?(a=i,t=t.slice(1)):a=d;else if(i)a=i,t=t.slice(1);else if(!s)return e;const c=a?o(a):Mw.create("div");c.appendChild(e),s&&Dt.each(s,(t=>{const n=o(t);c.insertBefore(n,e)}));const u=Iw(a)?a.siblings:void 0;return r(c,t,u)},s=Mw.create("div");if(e.length>0){const t=e[0],n=o(t),a=Iw(t)?t.siblings:void 0;s.appendChild(r(n,e.slice(1),a))}return s},Uw=e=>{let t="div";const n={name:t,classes:[],attrs:{},selector:e=Dt.trim(e)};return"*"!==e&&(t=e.replace(/(?:([#\.]|::?)([\w\-]+)|(\[)([^\]]+)\]?)/g,((e,t,o,r,s)=>{switch(t){case"#":n.attrs.id=o;break;case".":n.classes.push(o);break;case":":-1!==Dt.inArray("checked disabled enabled read-only required".split(" "),o)&&(n.attrs[o]=o)}if("["===r){const e=s.match(/([\w\-]+)(?:\=\"([^\"]+))?/);e&&(n.attrs[e[1]]=e[2])}return""}))),n.name=t||"div",n},zw=(e,t)=>{let n="",o=ud(e);if(""===o)return"";const r=e=>m(e)?e.replace(/%(\w+)/g,""):"",s=(t,n)=>Mw.getStyle(null!=n?n:e.getBody(),t,!0);if(m(t)){const n=e.formatter.get(t);if(!n)return"";t=n[0]}if("preview"in t){const e=t.preview;if(!1===e)return"";o=e||o}let a,i=t.block||t.inline||"span";const l=(d=t.selector,m(d)?(d=(d=d.split(/\s*,\s*/)[0]).replace(/\s*(~\+|~|\+|>)\s*/g,"$1"),Dt.map(d.split(/(?:>|\s+(?![^\[\]]+\]))/),(e=>{const t=Dt.map(e.split(/(?:~\+|~|\+)/),Uw),n=t.pop();return t.length&&(n.siblings=t),n})).reverse()):[]);var d;l.length>0?(l[0].name||(l[0].name=i),i=t.selector,a=Fw(l,e)):a=Fw([i],e);const c=Mw.select(i,a)[0]||a.firstChild;Lw(t.styles,((e,t)=>{const n=r(e);n&&Mw.setStyle(c,t,n)})),Lw(t.attributes,((e,t)=>{const n=r(e);n&&Mw.setAttrib(c,t,n)})),Lw(t.classes,(e=>{const t=r(e);Mw.hasClass(c,t)||Mw.addClass(c,t)})),e.dispatch("PreviewFormats"),Mw.setStyles(a,{position:"absolute",left:-65535}),e.getBody().appendChild(a);const u=s("fontSize"),f=/px$/.test(u)?parseInt(u,10):0;return Lw(o.split(" "),(e=>{let t=s(e,c);if(!("background-color"===e&&/transparent|rgba\s*\([^)]+,\s*0\)/.test(t)&&(t=s(e),"#ffffff"===Wu(t).toLowerCase())||"color"===e&&"#000000"===Wu(t).toLowerCase())){if("font-size"===e&&/em|%$/.test(t)){if(0===f)return;t=parseFloat(t)/(/%$/.test(t)?100:1)*f+"px"}"border"===e&&t&&(n+="padding:0 2px;"),n+=e+":"+t+";"}})),e.dispatch("AfterPreviewFormats"),Mw.remove(a),n},jw=e=>{const t=(e=>{const t={},n=(e,o)=>{e&&(m(e)?(p(o)||(o=[o]),q(o,(e=>{v(e.deep)&&(e.deep=!xm(e)),v(e.split)&&(e.split=!xm(e)||km(e)),v(e.remove)&&xm(e)&&!km(e)&&(e.remove="none"),xm(e)&&km(e)&&(e.mixed=!0,e.block_expand=!0),m(e.classes)&&(e.classes=e.classes.split(/\s+/))})),t[e]=o):ge(e,((e,t)=>{n(t,e)})))};return n((e=>{const t=e.dom,n=e.schema.type,o={valigntop:[{selector:"td,th",styles:{verticalAlign:"top"}}],valignmiddle:[{selector:"td,th",styles:{verticalAlign:"middle"}}],valignbottom:[{selector:"td,th",styles:{verticalAlign:"bottom"}}],alignleft:[{selector:"figure.image",collapsed:!1,classes:"align-left",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"left"},inherit:!1,preview:!1},{selector:"img,audio,video",collapsed:!1,styles:{float:"left"},preview:"font-family font-size"},{selector:"table",collapsed:!1,styles:{marginLeft:"0px",marginRight:"auto"},onformat:e=>{t.setStyle(e,"float",null)},preview:"font-family font-size"},{selector:".mce-preview-object,[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{float:"left"}}],aligncenter:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"center"},inherit:!1,preview:"font-family font-size"},{selector:"figure.image",collapsed:!1,classes:"align-center",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"img,audio,video",collapsed:!1,styles:{display:"block",marginLeft:"auto",marginRight:"auto"},preview:!1},{selector:"table",collapsed:!1,styles:{marginLeft:"auto",marginRight:"auto"},preview:"font-family font-size"},{selector:".mce-preview-object",ceFalseOverride:!0,styles:{display:"table",marginLeft:"auto",marginRight:"auto"},preview:!1},{selector:"[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{marginLeft:"auto",marginRight:"auto"},preview:!1}],alignright:[{selector:"figure.image",collapsed:!1,classes:"align-right",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"right"},inherit:!1,preview:"font-family font-size"},{selector:"img,audio,video",collapsed:!1,styles:{float:"right"},preview:"font-family font-size"},{selector:"table",collapsed:!1,styles:{marginRight:"0px",marginLeft:"auto"},onformat:e=>{t.setStyle(e,"float",null)},preview:"font-family font-size"},{selector:".mce-preview-object,[data-ephox-embed-iri]",ceFalseOverride:!0,styles:{float:"right"},preview:!1}],alignjustify:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li,pre",styles:{textAlign:"justify"},inherit:!1,preview:"font-family font-size"}],bold:[{inline:"strong",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontWeight:"bold"}},{inline:"b",remove:"all",preserve_attributes:["class","style"]}],italic:[{inline:"em",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontStyle:"italic"}},{inline:"i",remove:"all",preserve_attributes:["class","style"]}],underline:[{inline:"span",styles:{textDecoration:"underline"},exact:!0},{inline:"u",remove:"all",preserve_attributes:["class","style"]}],strikethrough:(()=>{const e={inline:"span",styles:{textDecoration:"line-through"},exact:!0},t={inline:"strike",remove:"all",preserve_attributes:["class","style"]},o={inline:"s",remove:"all",preserve_attributes:["class","style"]};return"html4"!==n?[o,e,t]:[e,o,t]})(),forecolor:{inline:"span",styles:{color:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0},hilitecolor:{inline:"span",styles:{backgroundColor:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0},fontname:{inline:"span",toggle:!1,styles:{fontFamily:"%value"},clear_child_styles:!0},fontsize:{inline:"span",toggle:!1,styles:{fontSize:"%value"},clear_child_styles:!0},lineheight:{selector:"h1,h2,h3,h4,h5,h6,p,li,td,th,div",styles:{lineHeight:"%value"}},fontsize_class:{inline:"span",attributes:{class:"%value"}},blockquote:{block:"blockquote",wrapper:!0,remove:"all"},subscript:{inline:"sub"},superscript:{inline:"sup"},code:{inline:"code"},link:{inline:"a",selector:"a",remove:"all",split:!0,deep:!0,onmatch:(e,t,n)=>$o(e)&&e.hasAttribute("href"),onformat:(e,n,o)=>{Dt.each(o,((n,o)=>{t.setAttrib(e,o,n)}))}},lang:{inline:"span",clear_child_styles:!0,remove_similar:!0,attributes:{lang:"%value","data-mce-lang":e=>{var t;return null!==(t=null==e?void 0:e.customValue)&&void 0!==t?t:null}}},removeformat:[{selector:"b,strong,em,i,font,u,strike,s,sub,sup,dfn,code,samp,kbd,var,cite,mark,q,del,ins,small",remove:"all",split:!0,expand:!1,block_expand:!0,deep:!0},{selector:"span",attributes:["style","class"],remove:"empty",split:!0,expand:!1,deep:!0},{selector:"*",attributes:["style","class"],split:!1,expand:!1,deep:!0}]};return Dt.each("p h1 h2 h3 h4 h5 h6 div address pre dt dd samp".split(/\s/),(e=>{o[e]={block:e,remove:"all"}})),o})(e)),n(Pw()),n(cd(e)),{get:e=>C(e)?t[e]:t,has:e=>ke(t,e),register:n,unregister:e=>(e&&t[e]&&delete t[e],t)}})(e),n=Da({});return(e=>{e.addShortcut("meta+b","","Bold"),e.addShortcut("meta+i","","Italic"),e.addShortcut("meta+u","","Underline");for(let t=1;t<=6;t++)e.addShortcut("access+"+t,"",["FormatBlock",!1,"h"+t]);e.addShortcut("access+7","",["FormatBlock",!1,"p"]),e.addShortcut("access+8","",["FormatBlock",!1,"div"]),e.addShortcut("access+9","",["FormatBlock",!1,"address"])})(e),(e=>{e.on("mouseup keydown",(t=>{var n;((e,t,n)=>{const o=e.selection,r=e.getBody();Ab(e,null,n),8!==t&&46!==t||!o.isCollapsed()||o.getStart().innerHTML!==Eb||Ab(e,ku(r,o.getStart())),37!==t&&39!==t||Ab(e,ku(r,o.getStart()))})(e,t.keyCode,(n=e.selection.getRng().endContainer,Jo(n)&&$e(n.data,pr)))}))})(e),PC(e)||((e,t)=>{e.set({}),t.on("NodeChange",(n=>{Sv(t,n.element,e.get())})),t.on("FormatApply FormatRemove",(n=>{const o=I.from(n.node).map((e=>rm(e)?e:e.startContainer)).bind((e=>$o(e)?I.some(e):I.from(e.parentElement))).getOrThunk((()=>xv(t)));Sv(t,o,e.get())}))})(n,e),{get:t.get,has:t.has,register:t.register,unregister:t.unregister,apply:(t,n,o)=>{((e,t,n,o)=>{MC(e).formatter.apply(t,n,o)})(e,t,n,o)},remove:(t,n,o,r)=>{((e,t,n,o,r)=>{MC(e).formatter.remove(t,n,o,r)})(e,t,n,o,r)},toggle:(t,n,o)=>{((e,t,n,o)=>{MC(e).formatter.toggle(t,n,o)})(e,t,n,o)},match:(t,n,o,r)=>((e,t,n,o,r)=>MC(e).formatter.match(t,n,o,r))(e,t,n,o,r),closest:t=>((e,t)=>MC(e).formatter.closest(t))(e,t),matchAll:(t,n)=>((e,t,n)=>MC(e).formatter.matchAll(t,n))(e,t,n),matchNode:(t,n,o,r)=>((e,t,n,o,r)=>MC(e).formatter.matchNode(t,n,o,r))(e,t,n,o,r),canApply:t=>((e,t)=>MC(e).formatter.canApply(t))(e,t),formatChanged:(t,o,r,s)=>((e,t,n,o,r,s)=>MC(e).formatter.formatChanged(t,n,o,r,s))(e,n,t,o,r,s),getCssText:O(zw,e)}},Hw=e=>{switch(e.toLowerCase()){case"undo":case"redo":case"mcefocus":return!0;default:return!1}},$w=e=>{const t=za(),n=Da(0),o=Da(0),r={data:[],typing:!1,beforeChange:()=>{((e,t,n)=>{MC(e).undoManager.beforeChange(t,n)})(e,n,t)},add:(s,a)=>((e,t,n,o,r,s,a)=>MC(e).undoManager.add(t,n,o,r,s,a))(e,r,o,n,t,s,a),dispatchChange:()=>{e.setDirty(!0);const t=SC(e);t.bookmark=nl(e.selection),e.dispatch("change",{level:t,lastLevel:ie(r.data,o.get()).getOrUndefined()})},undo:()=>((e,t,n,o)=>MC(e).undoManager.undo(t,n,o))(e,r,n,o),redo:()=>((e,t,n)=>MC(e).undoManager.redo(t,n))(e,o,r.data),clear:()=>{((e,t,n)=>{MC(e).undoManager.clear(t,n)})(e,r,o)},reset:()=>{((e,t)=>{MC(e).undoManager.reset(t)})(e,r)},hasUndo:()=>((e,t,n)=>MC(e).undoManager.hasUndo(t,n))(e,r,o),hasRedo:()=>((e,t,n)=>MC(e).undoManager.hasRedo(t,n))(e,r,o),transact:t=>((e,t,n,o)=>MC(e).undoManager.transact(t,n,o))(e,r,n,t),ignore:t=>{((e,t,n)=>{MC(e).undoManager.ignore(t,n)})(e,n,t)},extra:(t,n)=>{((e,t,n,o,r)=>{MC(e).undoManager.extra(t,n,o,r)})(e,r,o,t,n)}};return PC(e)||((e,t,n)=>{const o=Da(!1),r=e=>{TC(t,!1,n),t.add({},e)};e.on("init",(()=>{t.add()})),e.on("BeforeExecCommand",(e=>{const o=e.command;Hw(o)||(BC(t,n),t.beforeChange())})),e.on("ExecCommand",(e=>{const t=e.command;Hw(t)||r(e)})),e.on("ObjectResizeStart cut",(()=>{t.beforeChange()})),e.on("SaveContent ObjectResized blur",r),e.on("dragend",r),e.on("keyup",(n=>{const s=n.keyCode;if(n.isDefaultPrevented())return;const a=At.os.isMacOS()&&"Meta"===n.key;(s>=33&&s<=36||s>=37&&s<=40||45===s||n.ctrlKey||a)&&(r(),e.nodeChanged()),46!==s&&8!==s||e.nodeChanged(),o.get()&&t.typing&&!AC(SC(e),t.data[0])&&(e.isDirty()||e.setDirty(!0),e.dispatch("TypingUndo"),o.set(!1),e.nodeChanged())})),e.on("keydown",(e=>{const s=e.keyCode;if(e.isDefaultPrevented())return;if(s>=33&&s<=36||s>=37&&s<=40||45===s)return void(t.typing&&r(e));const a=e.ctrlKey&&!e.altKey||e.metaKey;if((s<16||s>20)&&224!==s&&91!==s&&!t.typing&&!a)return t.beforeChange(),TC(t,!0,n),t.add({},e),void o.set(!0);(At.os.isMacOS()?e.metaKey:e.ctrlKey&&!e.altKey)&&t.beforeChange()})),e.on("mousedown",(e=>{t.typing&&r(e)})),e.on("input",(e=>{var t;e.inputType&&("insertReplacementText"===e.inputType||"insertText"===(t=e).inputType&&null===t.data||(e=>"insertFromPaste"===e.inputType||"insertFromDrop"===e.inputType)(e))&&r(e)})),e.on("AddUndo Undo Redo ClearUndos",(t=>{t.isDefaultPrevented()||e.nodeChanged()}))})(e,r,n),(e=>{e.addShortcut("meta+z","","Undo"),e.addShortcut("meta+y,meta+shift+z","","Redo")})(e),r},Vw=[9,27,ef.HOME,ef.END,19,20,44,144,145,33,34,45,16,17,18,91,92,93,ef.DOWN,ef.UP,ef.LEFT,ef.RIGHT].concat(At.browser.isFirefox()?[224]:[]),qw="data-mce-placeholder",Ww=e=>"keydown"===e.type||"keyup"===e.type,Kw=e=>{const t=e.keyCode;return t===ef.BACKSPACE||t===ef.DELETE},Gw=(e,t)=>({from:e,to:t}),Yw=(e,t)=>{const n=yn(e),o=yn(t.container());return fh(n,o).map((e=>((e,t)=>({block:e,position:t}))(e,t)))},Xw=(e,t)=>Jn(t,(e=>Ar(e)||ar(e.dom)),(t=>En(t,e))).filter(Wt).getOr(e),Qw=e=>{const t=(e=>{const t=Mn(e);return Z(t,xr).fold(N(t),(e=>t.slice(0,e)))})(e);return q(t,wo),t},Jw=(e,t)=>{const n=pp(t,e);return J(n.reverse(),(e=>bs(e))).each(wo)},Zw=(e,t,n,o)=>{if(bs(n))return Pr(n),yu(n.dom);0===G(Pn(o),(e=>!bs(e))).length&&bs(t)&&go(o,bn("br"));const r=vu(n.dom,Li.before(o.dom));return q(Qw(t),(e=>{go(o,e)})),Jw(e,t),r},ex=(e,t,n)=>{if(bs(n)){if(bs(t)){const e=e=>{const t=(e,n)=>Fn(e).fold((()=>n),(e=>kr(e)?t(e,n.concat(oi(e))):n));return t(e,[])},o=Y(e(n),((e,t)=>(vo(e,t),t)),Dr());Co(t),bo(t,o)}return wo(n),yu(t.dom)}const o=Cu(n.dom);return q(Qw(t),(e=>{bo(n,e)})),Jw(e,t),o},tx=(e,t)=>{hu(e,t.dom).bind((e=>I.from(e.getNode()))).map(yn).filter(Er).each(wo)},nx=(e,t,n)=>(tx(!0,t),tx(!1,n),((e,t)=>Sn(t,e)?((e,t)=>{const n=pp(t,e);return I.from(n[n.length-1])})(t,e):I.none())(t,n).fold(O(ex,e,t,n),O(Zw,e,t,n))),ox=(e,t,n,o)=>t?nx(e,o,n):nx(e,n,o),rx=(e,t)=>{const n=yn(e.getBody()),o=((e,t,n)=>n.collapsed?((e,t,n)=>{const o=Yw(e,Li.fromRangeStart(n)),r=o.bind((n=>fu(t,e,n.position).bind((n=>Yw(e,n).map((n=>((e,t,n)=>rr(n.position.getNode())&&!bs(n.block)?hu(!1,n.block.dom).bind((o=>o.isEqual(n.position)?fu(t,e,o).bind((t=>Yw(e,t))):I.some(n))).getOr(n):n)(e,t,n)))))));return Mt(o,r,Gw).filter((t=>(e=>!En(e.from.block,e.to.block))(t)&&((e,t)=>{const n=yn(e);return En(Xw(n,t.from.block),Xw(n,t.to.block))})(e,t)&&(e=>!1===ir(e.from.block.dom)&&!1===ir(e.to.block.dom))(t)&&(e=>{const t=e=>Sr(e)||_s(e.dom);return t(e.from.block)&&t(e.to.block)})(t)))})(e,t,n):I.none())(n.dom,t,e.selection.getRng()).map((o=>()=>{ox(n,t,o.from.block,o.to.block).each((t=>{e.selection.setRng(t.toRange())}))}));return o},sx=(e,t)=>{const n=yn(t),o=O(En,e);return Qn(n,Ar,o).isSome()},ax=e=>{const t=yn(e.getBody());return((e,t)=>{const n=vu(e.dom,Li.fromRangeStart(t)).isNone(),o=bu(e.dom,Li.fromRangeEnd(t)).isNone();return!((e,t)=>sx(e,t.startContainer)||sx(e,t.endContainer))(e,t)&&n&&o})(t,e.selection.getRng())?(e=>I.some((()=>{e.setContent(""),e.selection.setCursorLocation()})))(e):((e,t)=>{const n=t.getRng();return Mt(fh(e,yn(n.startContainer)),fh(e,yn(n.endContainer)),((o,r)=>En(o,r)?I.none():I.some((()=>{n.deleteContents(),ox(e,!0,o,r).each((e=>{t.setRng(e.toRange())}))})))).getOr(I.none())})(t,e.selection)},ix=(e,t)=>e.selection.isCollapsed()?I.none():ax(e),lx=(e,t,n,o,r)=>I.from(t._selectionOverrides.showCaret(e,n,o,r)),dx=(e,t)=>e.dispatch("BeforeObjectSelected",{target:t}).isDefaultPrevented()?I.none():I.some((e=>{const t=e.ownerDocument.createRange();return t.selectNode(e),t})(t)),cx=(e,t,n)=>t.collapsed?((e,t,n)=>{const o=Wc(1,e.getBody(),t),r=Li.fromRangeStart(o),s=r.getNode();if(kc(s))return lx(1,e,s,!r.isAtEnd(),!1);const a=r.getNode(!0);if(kc(a))return lx(1,e,a,!1,!1);const i=$h(e.dom.getRoot(),r.getNode());return kc(i)?lx(1,e,i,!1,n):I.none()})(e,t,n).getOr(t):t,ux=e=>mp(e)||lp(e),mx=e=>fp(e)||dp(e),fx=(e,t,n,o,r,s)=>{lx(o,e,s.getNode(!r),r,!0).each((n=>{if(t.collapsed){const e=t.cloneRange();r?e.setEnd(n.startContainer,n.startOffset):e.setStart(n.endContainer,n.endOffset),e.deleteContents()}else t.deleteContents();e.selection.setRng(n)})),((e,t)=>{Jo(t)&&0===t.data.length&&e.remove(t)})(e.dom,n)},gx=(e,t)=>((e,t)=>{const n=e.selection.getRng();if(!Jo(n.commonAncestorContainer))return I.none();const o=t?Jc.Forwards:Jc.Backwards,r=du(e.getBody()),s=O(Xc,t?r.next:r.prev),a=t?ux:mx,i=Gc(o,e.getBody(),n),l=s(i),d=l?ih(t,l):l;if(!d||!Qc(i,d))return I.none();if(a(d))return I.some((()=>fx(e,n,i.getNode(),o,t,d)));const c=s(d);return c&&a(c)&&Qc(d,c)?I.some((()=>fx(e,n,i.getNode(),o,t,c))):I.none()})(e,t),px=(e,t)=>{const n=e.getBody();return t?yu(n).filter(mp):Cu(n).filter(fp)},hx=e=>{const t=e.selection.getRng();return!t.collapsed&&(px(e,!0).exists((e=>e.isEqual(Li.fromRangeStart(t))))||px(e,!1).exists((e=>e.isEqual(Li.fromRangeEnd(t)))))},bx=al([{remove:["element"]},{moveToElement:["element"]},{moveToPosition:["position"]}]),vx=(e,t,n)=>fu(t,e,n).bind((o=>{return r=o.getNode(),C(r)&&(Ar(yn(r))||Nr(yn(r)))||((e,t,n,o)=>{const r=t=>kr(yn(t))&&!Uc(n,o,e);return Kc(!t,n).fold((()=>Kc(t,o).fold(L,r)),r)})(e,t,n,o)?I.none():t&&ir(o.getNode())||!t&&ir(o.getNode(!0))?((e,t,n,o)=>{const r=o.getNode(!t);return fh(yn(e),yn(n.getNode())).map((e=>bs(e)?bx.remove(e.dom):bx.moveToElement(r))).orThunk((()=>I.some(bx.moveToElement(r))))})(e,t,n,o):t&&fp(n)||!t&&mp(n)?I.some(bx.moveToPosition(o)):I.none();var r})),yx=(e,t)=>I.from($h(e.getBody(),t)),Cx=(e,t)=>{const n=e.selection.getNode();return yx(e,n).filter(ir).fold((()=>((e,t,n)=>{const o=Wc(t?1:-1,e,n),r=Li.fromRangeStart(o),s=yn(e);return!t&&fp(r)?I.some(bx.remove(r.getNode(!0))):t&&mp(r)?I.some(bx.remove(r.getNode())):!t&&mp(r)&&Np(s,r)?Rp(s,r).map((e=>bx.remove(e.getNode()))):t&&fp(r)&&_p(s,r)?Ap(s,r).map((e=>bx.remove(e.getNode()))):((e,t,n)=>((e,t)=>{const n=t.getNode(!e),o=e?"after":"before";return $o(n)&&n.getAttribute("data-mce-caret")===o})(t,n)?((e,t)=>y(t)?I.none():e&&ir(t.nextSibling)?I.some(bx.moveToElement(t.nextSibling)):!e&&ir(t.previousSibling)?I.some(bx.moveToElement(t.previousSibling)):I.none())(t,n.getNode(!t)).orThunk((()=>vx(e,t,n))):vx(e,t,n).bind((t=>((e,t,n)=>n.fold((e=>I.some(bx.remove(e))),(e=>I.some(bx.moveToElement(e))),(n=>Uc(t,n,e)?I.none():I.some(bx.moveToPosition(n)))))(e,n,t))))(e,t,r)})(e.getBody(),t,e.selection.getRng()).map((n=>()=>n.fold(((e,t)=>n=>(e._selectionOverrides.hideFakeCaret(),nh(e,t,yn(n)),!0))(e,t),((e,t)=>n=>{const o=t?Li.before(n):Li.after(n);return e.selection.setRng(o.toRange()),!0})(e,t),(e=>t=>(e.selection.setRng(t.toRange()),!0))(e))))),(()=>I.some(E)))},wx=e=>{const t=e.dom,n=e.selection,o=$h(e.getBody(),n.getNode());if(ar(o)&&t.isBlock(o)&&t.isEmpty(o)){const e=t.create("br",{"data-mce-bogus":"1"});t.setHTML(o,""),o.appendChild(e),n.setRng(Li.before(e).toRange())}return!0},xx=(e,t)=>e.selection.isCollapsed()?Cx(e,t):((e,t)=>{const n=e.selection.getNode();return ir(n)&&!lr(n)?yx(e,n.parentNode).filter(ir).fold((()=>I.some((()=>{var n;n=yn(e.getBody()),q(Fo(n,".mce-offscreen-selection"),wo),nh(e,t,yn(e.selection.getNode())),gh(e)}))),(()=>I.some(E))):hx(e)?I.some((()=>{bh(e,e.selection.getRng(),yn(e.getBody()))})):I.none()})(e,t),kx=(e,t)=>e.selection.isCollapsed()?((e,t)=>{const n=Li.fromRangeStart(e.selection.getRng());return fu(t,e.getBody(),n).filter((e=>t?ap(e):ip(e))).bind((e=>zc(t?0:-1,e))).map((t=>()=>e.selection.select(t)))})(e,t):I.none(),Ex=Jo,Sx=e=>Ex(e)&&e.data[0]===Mr,_x=e=>Ex(e)&&e.data[e.data.length-1]===Mr,Nx=e=>{var t;return(null!==(t=e.ownerDocument)&&void 0!==t?t:document).createTextNode(Mr)},Rx=(e,t)=>e?(e=>{var t;if(Ex(e.previousSibling))return _x(e.previousSibling)||e.previousSibling.appendData(Mr),e.previousSibling;if(Ex(e))return Sx(e)||e.insertData(0,Mr),e;{const n=Nx(e);return null===(t=e.parentNode)||void 0===t||t.insertBefore(n,e),n}})(t):(e=>{var t,n;if(Ex(e.nextSibling))return Sx(e.nextSibling)||e.nextSibling.insertData(0,Mr),e.nextSibling;if(Ex(e))return _x(e)||e.appendData(Mr),e;{const o=Nx(e);return e.nextSibling?null===(t=e.parentNode)||void 0===t||t.insertBefore(o,e.nextSibling):null===(n=e.parentNode)||void 0===n||n.appendChild(o),o}})(t),Ax=O(Rx,!0),Ox=O(Rx,!1),Tx=(e,t)=>Jo(e.container())?Rx(t,e.container()):Rx(t,e.getNode()),Bx=(e,t)=>{const n=t.get();return n&&e.container()===n&&Hr(n)},Dx=(e,t)=>t.fold((t=>{hc(e.get());const n=Ax(t);return e.set(n),I.some(Li(n,n.length-1))}),(t=>yu(t).map((t=>{if(Bx(t,e)){const t=e.get();return Li(t,1)}{hc(e.get());const n=Tx(t,!0);return e.set(n),Li(n,1)}}))),(t=>Cu(t).map((t=>{if(Bx(t,e)){const t=e.get();return Li(t,t.length-1)}{hc(e.get());const n=Tx(t,!1);return e.set(n),Li(n,n.length-1)}}))),(t=>{hc(e.get());const n=Ox(t);return e.set(n),I.some(Li(n,1))})),Px=(e,t)=>{for(let n=0;n<e.length;n++){const o=e[n].apply(null,t);if(o.isSome())return o}return I.none()},Lx=al([{before:["element"]},{start:["element"]},{end:["element"]},{after:["element"]}]),Mx=(e,t)=>Fc(t,e)||e,Ix=(e,t,n)=>{const o=lh(n),r=Mx(t,o.container());return ah(e,r,o).fold((()=>bu(r,o).bind(O(ah,e,r)).map((e=>Lx.before(e)))),I.none)},Fx=(e,t)=>null===ku(e,t),Ux=(e,t,n)=>ah(e,t,n).filter(O(Fx,t)),zx=(e,t,n)=>{const o=dh(n);return Ux(e,t,o).bind((e=>vu(e,o).isNone()?I.some(Lx.start(e)):I.none()))},jx=(e,t,n)=>{const o=lh(n);return Ux(e,t,o).bind((e=>bu(e,o).isNone()?I.some(Lx.end(e)):I.none()))},Hx=(e,t,n)=>{const o=dh(n),r=Mx(t,o.container());return ah(e,r,o).fold((()=>vu(r,o).bind(O(ah,e,r)).map((e=>Lx.after(e)))),I.none)},$x=e=>!sh(qx(e)),Vx=(e,t,n)=>Px([Ix,zx,jx,Hx],[e,t,n]).filter($x),qx=e=>e.fold(R,R,R,R),Wx=e=>e.fold(N("before"),N("start"),N("end"),N("after")),Kx=e=>e.fold(Lx.before,Lx.before,Lx.after,Lx.after),Gx=e=>e.fold(Lx.start,Lx.start,Lx.end,Lx.end),Yx=(e,t,n,o,r,s)=>Mt(ah(t,n,o),ah(t,n,r),((t,o)=>t!==o&&((e,t,n)=>{const o=Fc(t,e),r=Fc(n,e);return C(o)&&o===r})(n,t,o)?Lx.after(e?t:o):s)).getOr(s),Xx=(e,t)=>e.fold(M,(e=>{return o=t,!(Wx(n=e)===Wx(o)&&qx(n)===qx(o));var n,o})),Qx=(e,t)=>e?t.fold(S(I.some,Lx.start),I.none,S(I.some,Lx.after),I.none):t.fold(I.none,S(I.some,Lx.before),I.none,S(I.some,Lx.end)),Jx=(e,t,n)=>{const o=e?1:-1;return t.setRng(Li(n.container(),n.offset()+o).toRange()),t.getSel().modify("move",e?"forward":"backward","word"),!0};var Zx;!function(e){e[e.Br=0]="Br",e[e.Block=1]="Block",e[e.Wrap=2]="Wrap",e[e.Eol=3]="Eol"}(Zx||(Zx={}));const ek=(e,t)=>e===Jc.Backwards?oe(t):t,tk=(e,t,n)=>e===Jc.Forwards?t.next(n):t.prev(n),nk=(e,t,n,o)=>rr(o.getNode(t===Jc.Forwards))?Zx.Br:!1===Uc(n,o)?Zx.Block:Zx.Wrap,ok=(e,t,n,o)=>{const r=du(n);let s=o;const a=[];for(;s;){const n=tk(t,r,s);if(!n)break;if(rr(n.getNode(!1)))return t===Jc.Forwards?{positions:ek(t,a).concat([n]),breakType:Zx.Br,breakAt:I.some(n)}:{positions:ek(t,a),breakType:Zx.Br,breakAt:I.some(n)};if(n.isVisible()){if(e(s,n)){const e=nk(0,t,s,n);return{positions:ek(t,a),breakType:e,breakAt:I.some(n)}}a.push(n),s=n}else s=n}return{positions:ek(t,a),breakType:Zx.Eol,breakAt:I.none()}},rk=(e,t,n,o)=>t(n,o).breakAt.map((o=>{const r=t(n,o).positions;return e===Jc.Backwards?r.concat(o):[o].concat(r)})).getOr([]),sk=(e,t)=>X(e,((e,n)=>e.fold((()=>I.some(n)),(o=>Mt(le(o.getClientRects()),le(n.getClientRects()),((e,r)=>{const s=Math.abs(t-e.left);return Math.abs(t-r.left)<=s?n:o})).or(e)))),I.none()),ak=(e,t)=>le(t.getClientRects()).bind((t=>sk(e,t.left))),ik=O(ok,Li.isAbove,-1),lk=O(ok,Li.isBelow,1),dk=O(rk,-1,ik),ck=O(rk,1,lk),uk=(e,t)=>ik(e,t).breakAt.isNone(),mk=(e,t)=>lk(e,t).breakAt.isNone(),fk=(e,t)=>ak(dk(e,t),t),gk=(e,t)=>ak(ck(e,t),t),pk=ir,hk=(e,t)=>Math.abs(e.left-t),bk=(e,t)=>Math.abs(e.right-t),vk=(e,t)=>Te(e,((e,n)=>{const o=Math.min(hk(e,t),bk(e,t)),r=Math.min(hk(n,t),bk(n,t));return r===o&&Ee(n,"node")&&pk(n.node)||r<o?n:e})),yk=e=>{const t=t=>V(t,(t=>{const n=li(t);return n.node=e,n}));if($o(e))return t(e.getClientRects());if(Jo(e)){const n=e.ownerDocument.createRange();return n.setStart(e,0),n.setEnd(e,e.data.length),t(n.getClientRects())}return[]},Ck=e=>te(e,yk);var wk;!function(e){e[e.Up=-1]="Up",e[e.Down=1]="Down"}(wk||(wk={}));const xk=(e,t,n,o,r,s)=>{let a=0;const i=[],l=o=>{let s=Ck([o]);-1===e&&(s=s.reverse());for(let e=0;e<s.length;e++){const o=s[e];if(!n(o,d)){if(i.length>0&&t(o,De(i))&&a++,o.line=a,r(o))return!0;i.push(o)}}return!1},d=De(s.getClientRects());if(!d)return i;const c=s.getNode();return c&&(l(c),((e,t,n,o)=>{let r=o;for(;r=Ic(r,e,is,t);)if(n(r))return})(e,o,l,c)),i},kk=O(xk,wk.Up,ui,mi),Ek=O(xk,wk.Down,mi,ui),Sk=e=>De(e.getClientRects()),_k=e=>t=>((e,t)=>t.line>e)(e,t),Nk=e=>t=>((e,t)=>t.line===e)(e,t),Rk=(e,t)=>{e.selection.setRng(t),Zf(e,e.selection.getRng())},Ak=(e,t,n)=>I.some(cx(e,t,n)),Ok=(e,t,n,o,r,s)=>{const a=t===Jc.Forwards,i=du(e.getBody()),l=O(Xc,a?i.next:i.prev),d=a?o:r;if(!n.collapsed){const o=gi(n);if(s(o))return lx(t,e,o,t===Jc.Backwards,!1);if(hx(e)){const e=n.cloneRange();return e.collapse(t===Jc.Backwards),I.from(e)}}const c=Gc(t,e.getBody(),n);if(d(c))return dx(e,c.getNode(!a));let u=l(c);const m=Xr(n);if(!u)return m?I.some(n):I.none();if(u=ih(a,u),d(u))return lx(t,e,u.getNode(!a),a,!1);const f=l(u);return f&&d(f)&&Qc(u,f)?lx(t,e,f.getNode(!a),a,!1):m?Ak(e,u.toRange(),!1):I.none()},Tk=(e,t,n,o,r,s)=>{const a=Gc(t,e.getBody(),n),i=De(a.getClientRects()),l=t===wk.Down,d=e.getBody();if(!i)return I.none();if(hx(e)){const e=l?Li.fromRangeEnd(n):Li.fromRangeStart(n);return(l?gk:fk)(d,e).orThunk((()=>I.from(e))).map((e=>e.toRange()))}const c=(l?Ek:kk)(d,_k(1),a),u=G(c,Nk(1)),m=i.left,f=vk(u,m);if(f&&s(f.node)){const n=Math.abs(m-f.left),o=Math.abs(m-f.right);return lx(t,e,f.node,n<o,!1)}let g;if(g=o(a)?a.getNode():r(a)?a.getNode(!0):gi(n),g){const n=((e,t,n,o)=>{const r=du(t);let s,a,i,l;const d=[];let c=0;1===e?(s=r.next,a=mi,i=ui,l=Li.after(o)):(s=r.prev,a=ui,i=mi,l=Li.before(o));const u=Sk(l);do{if(!l.isVisible())continue;const e=Sk(l);if(i(e,u))continue;d.length>0&&a(e,De(d))&&c++;const t=li(e);if(t.position=l,t.line=c,n(t))return d;d.push(t)}while(l=s(l));return d})(t,d,_k(1),g);let o=vk(G(n,Nk(1)),m);if(o)return Ak(e,o.position.toRange(),!1);if(o=De(G(n,Nk(0))),o)return Ak(e,o.position.toRange(),!1)}return 0===u.length?Bk(e,l).filter(l?r:o).map((t=>cx(e,t.toRange(),!1))):I.none()},Bk=(e,t)=>{const n=e.selection.getRng(),o=t?Li.fromRangeEnd(n):Li.fromRangeStart(n),r=(s=o.container(),a=e.getBody(),Qn(yn(s),(e=>Sc(e.dom)),(e=>e.dom===a)).map((e=>e.dom)).getOr(a));var s,a;if(t){const e=lk(r,o);return de(e.positions)}{const e=ik(r,o);return le(e.positions)}},Dk=(e,t,n)=>Bk(e,t).filter(n).exists((t=>(e.selection.setRng(t.toRange()),!0))),Pk=(e,t)=>{const n=e.dom.createRng();n.setStart(t.container(),t.offset()),n.setEnd(t.container(),t.offset()),e.selection.setRng(n)},Lk=(e,t)=>{e?t.setAttribute("data-mce-selected","inline-boundary"):t.removeAttribute("data-mce-selected")},Mk=(e,t,n)=>Dx(t,n).map((t=>(Pk(e,t),n))),Ik=(e,t,n)=>{const o=e.getBody(),r=((e,t,n)=>{const o=Li.fromRangeStart(e);if(e.collapsed)return o;{const r=Li.fromRangeEnd(e);return n?vu(t,r).getOr(r):bu(t,o).getOr(o)}})(e.selection.getRng(),o,n);return((e,t,n,o)=>{const r=ih(e,o),s=Vx(t,n,r);return Vx(t,n,r).bind(O(Qx,e)).orThunk((()=>((e,t,n,o,r)=>{const s=ih(e,r);return fu(e,n,s).map(O(ih,e)).fold((()=>o.map(Kx)),(r=>Vx(t,n,r).map(O(Yx,e,t,n,s,r)).filter(O(Xx,o)))).filter($x)})(e,t,n,s,o)))})(n,O(rh,e),o,r).bind((n=>Mk(e,t,n)))},Fk=(e,t,n)=>!!dd(e)&&Ik(e,t,n).isSome(),Uk=(e,t,n)=>!!dd(t)&&((e,t)=>{const n=t.selection.getRng(),o=e?Li.fromRangeEnd(n):Li.fromRangeStart(n);return!!(e=>w(e.selection.getSel().modify))(t)&&(e&&qr(o)?Jx(!0,t.selection,o):!(e||!Wr(o))&&Jx(!1,t.selection,o))})(e,t),zk=e=>{const t=Da(null),n=O(rh,e);return e.on("NodeChange",(o=>{dd(e)&&(((e,t,n)=>{const o=V(Fo(yn(t.getRoot()),'*[data-mce-selected="inline-boundary"]'),(e=>e.dom)),r=G(o,e),s=G(n,e);q(re(r,s),O(Lk,!1)),q(re(s,r),O(Lk,!0))})(n,e.dom,o.parents),((e,t)=>{const n=t.get();if(e.selection.isCollapsed()&&!e.composing&&n){const o=Li.fromRangeStart(e.selection.getRng());Li.isTextPosition(o)&&!(e=>qr(e)||Wr(e))(o)&&(Pk(e,pc(n,o)),t.set(null))}})(e,t),((e,t,n,o)=>{if(t.selection.isCollapsed()){const r=G(o,e);q(r,(o=>{const r=Li.fromRangeStart(t.selection.getRng());Vx(e,t.getBody(),r).bind((e=>Mk(t,n,e)))}))}})(n,e,t,o.parents))})),t},jk=O(Uk,!0),Hk=O(Uk,!1),$k=(e,t,n)=>{if(dd(e)){const o=Bk(e,t).getOrThunk((()=>{const n=e.selection.getRng();return t?Li.fromRangeEnd(n):Li.fromRangeStart(n)}));return Vx(O(rh,e),e.getBody(),o).exists((t=>{const o=Kx(t);return Dx(n,o).exists((t=>(Pk(e,t),!0)))}))}return!1},Vk=(e,t)=>n=>Dx(t,n).map((t=>()=>Pk(e,t))),qk=(e,t,n,o)=>{const r=e.getBody(),s=O(rh,e);e.undoManager.ignore((()=>{e.selection.setRng(((e,t)=>{const n=document.createRange();return n.setStart(e.container(),e.offset()),n.setEnd(t.container(),t.offset()),n})(n,o)),uh(e),Vx(s,r,Li.fromRangeStart(e.selection.getRng())).map(Gx).bind(Vk(e,t)).each(P)})),e.nodeChanged()},Wk=(e,t,n)=>{if(e.selection.isCollapsed()&&dd(e)){const o=Li.fromRangeStart(e.selection.getRng());return((e,t,n,o)=>{const r=((e,t)=>Fc(t,e)||e)(e.getBody(),o.container()),s=O(rh,e),a=Vx(s,r,o);return a.bind((e=>n?e.fold(N(I.some(Gx(e))),I.none,N(I.some(Kx(e))),I.none):e.fold(I.none,N(I.some(Kx(e))),I.none,N(I.some(Gx(e)))))).map(Vk(e,t)).getOrThunk((()=>{const i=gu(n,r,o),l=i.bind((e=>Vx(s,r,e)));return Mt(a,l,(()=>ah(s,r,o).bind((t=>(e=>Mt(yu(e),Cu(e),((t,n)=>{const o=ih(!0,t),r=ih(!1,n);return bu(e,o).forall((e=>e.isEqual(r)))})).getOr(!0))(t)?I.some((()=>{nh(e,n,yn(t))})):I.none())))).getOrThunk((()=>l.bind((()=>i.map((r=>()=>{n?qk(e,t,o,r):qk(e,t,r,o)}))))))}))})(e,t,n,o)}return I.none()},Kk=(e,t)=>{const n=yn(e.getBody()),o=yn(e.selection.getStart()),r=pp(o,n);return Z(r,t).fold(N(r),(e=>r.slice(0,e)))},Gk=e=>1===zn(e),Yk=(e,t)=>{const n=O(Lb,e);return te(t,(e=>n(e)?[e.dom]:[]))},Xk=e=>{const t=(e=>Kk(e,xr))(e);return Yk(e,t)},Qk=(e,t)=>{const n=G((e=>Kk(e,(e=>xr(e)||(e=>zn(e)>1)(e))))(e),Gk);return de(n).bind((o=>{const r=Li.fromRangeStart(e.selection.getRng());return ph(t,r,o.dom)&&!Mb(o)?I.some((()=>((e,t,n,o)=>{const r=Yk(t,o);if(0===r.length)nh(t,e,n);else{const e=Pb(n.dom,r);t.selection.setRng(e.toRange())}})(t,e,o,n))):I.none()}))},Jk=(e,t)=>{const n=e.selection.getStart(),o=((e,t)=>{const n=t.parentElement;return rr(t)&&!h(n)&&e.dom.isEmpty(n)})(e,n)||Mb(yn(n))?Pb(n,t):((e,t)=>{const{caretContainer:n,caretPosition:o}=Db(t);return e.insertNode(n.dom),o})(e.selection.getRng(),t);e.selection.setRng(o.toRange())},Zk=e=>Jo(e.startContainer),eE=e=>{const t=e.selection.getRng();return(e=>0===e.startOffset&&Zk(e))(t)&&((e,t)=>{const n=t.startContainer.parentElement;return!h(n)&&Lb(e,yn(n))})(e,t)&&(e=>(e=>(e=>{const t=e.startContainer.parentNode,n=e.endContainer.parentNode;return!h(t)&&!h(n)&&t.isEqualNode(n)})(e)&&(e=>{const t=e.endContainer;return e.endOffset===(Jo(t)?t.length:t.childNodes.length)})(e))(e)||(e=>!e.endContainer.isEqualNode(e.commonAncestorContainer))(e))(t)},tE=(e,t)=>e.selection.isCollapsed()?Qk(e,t):(e=>{if(eE(e)){const t=Xk(e);return I.some((()=>{uh(e),((e,t)=>{const n=re(t,Xk(e));n.length>0&&Jk(e,n)})(e,t)}))}return I.none()})(e),nE=e=>((e,t,n)=>Qn(e,(e=>xu(e.dom)),n).isSome())(e,0,xr),oE=e=>((e=>{const t=e.selection.getRng();return t.collapsed&&(Zk(t)||e.dom.isEmpty(t.startContainer))&&!(e=>nE(yn(e.selection.getStart())))(e)})(e)&&Jk(e,[]),!0),rE=(e,t,n)=>C(n)?I.some((()=>{e._selectionOverrides.hideFakeCaret(),nh(e,t,yn(n))})):I.none(),sE=(e,t)=>e.selection.isCollapsed()?((e,t)=>{const n=t?lp:dp,o=t?Jc.Forwards:Jc.Backwards,r=Gc(o,e.getBody(),e.selection.getRng());return n(r)?rE(e,t,r.getNode(!t)):I.from(ih(t,r)).filter((e=>n(e)&&Qc(r,e))).bind((n=>rE(e,t,n.getNode(!t))))})(e,t):((e,t)=>{const n=e.selection.getNode();return cr(n)?rE(e,t,n):I.none()})(e,t),aE=e=>Xe(null!=e?e:"").getOr(0),iE=(e,t)=>(e||"table"===Ht(t)?"margin":"padding")+("rtl"===lo(t,"direction")?"-right":"-left"),lE=e=>{const t=cE(e);return!e.mode.isReadOnly()&&(t.length>1||((e,t)=>ne(t,(t=>{const n=iE(Kl(e),t),o=uo(t,n).map(aE).getOr(0);return"false"!==e.dom.getContentEditable(t.dom)&&o>0})))(e,t))},dE=e=>_r(e)||Nr(e),cE=e=>G(ko(e.selection.getSelectedBlocks()),(e=>!dE(e)&&!(e=>An(e).exists(dE))(e)&&Jn(e,(e=>ar(e.dom)||ir(e.dom))).exists((e=>ar(e.dom))))),uE=(e,t)=>{var n,o;const{dom:r}=e,s=Gl(e),a=null!==(o=null===(n=/[a-z%]+$/i.exec(s))||void 0===n?void 0:n[0])&&void 0!==o?o:"px",i=aE(s),l=Kl(e);q(cE(e),(e=>{((e,t,n,o,r,s)=>{const a=iE(n,yn(s)),i=aE(e.getStyle(s,a));if("outdent"===t){const t=Math.max(0,i-o);e.setStyle(s,a,t?t+r:"")}else{const t=i+o+r;e.setStyle(s,a,t)}})(r,t,l,i,a,e.dom)}))},mE=e=>uE(e,"outdent"),fE=e=>{if(e.selection.isCollapsed()&&lE(e)){const t=e.dom,n=e.selection.getRng(),o=Li.fromRangeStart(n),r=t.getParent(n.startContainer,t.isBlock);if(null!==r&&Cp(yn(r),o))return I.some((()=>mE(e)))}return I.none()},gE=(e,t,n)=>ue([fE,xx,gx,(e,n)=>Wk(e,t,n),rx,Hh,kx,sE,ix,tE],(t=>t(e,n))).filter((t=>e.selection.isEditable())),pE=(e,t)=>{e.addCommand("delete",(()=>{((e,t)=>{gE(e,t,!1).fold((()=>{uh(e),gh(e)}),P)})(e,t)})),e.addCommand("forwardDelete",(()=>{((e,t)=>{gE(e,t,!0).fold((()=>(e=>ch(e,"ForwardDelete"))(e)),P)})(e,t)}))},hE=e=>void 0===e.touches||1!==e.touches.length?I.none():I.some(e.touches[0]),bE=(e,t)=>ke(e,t.nodeName),vE=(e,t)=>!!Jo(t)||!!$o(t)&&!bE(e.getBlockElements(),t)&&!Lu(t)&&!As(e,t),yE=(e,t)=>{if(Jo(t)){if(0===t.data.length)return!0;if(/^\s+$/.test(t.data)&&(!t.nextSibling||bE(e,t.nextSibling)))return!0}return!1},CE=e=>e.dom.create(Nl(e),Rl(e)),wE=e=>{const t=e.dom,n=e.selection,o=e.schema,r=o.getBlockElements(),s=n.getStart(),a=e.getBody();let i,l,d=!1;const c=Nl(e);if(!s||!$o(s))return;const u=a.nodeName.toLowerCase();if(!o.isValidChild(u,c.toLowerCase())||((e,t,n)=>$(gp(yn(n),yn(t)),(t=>bE(e,t.dom))))(r,a,s))return;const m=n.getRng(),{startContainer:f,startOffset:g,endContainer:p,endOffset:h}=m,b=xg(e);let v=a.firstChild;for(;v;)if($o(v)&&Ss(o,v),vE(o,v)){if(yE(r,v)){l=v,v=v.nextSibling,t.remove(l);continue}i||(i=CE(e),a.insertBefore(i,v),d=!0),l=v,v=v.nextSibling,i.appendChild(l)}else i=null,v=v.nextSibling;d&&b&&(m.setStart(f,g),m.setEnd(p,h),n.setRng(m),e.nodeChanged())},xE=(e,t,n)=>{const o=yn(CE(e)),r=Dr();bo(o,r),n(t,o);const s=document.createRange();return s.setStartBefore(r.dom),s.setEndBefore(r.dom),s},kE=e=>t=>-1!==(" "+t.attr("class")+" ").indexOf(e),EE=(e,t,n)=>function(o){const r=arguments,s=r[r.length-2],a=s>0?t.charAt(s-1):"";if('"'===a)return o;if(">"===a){const e=t.lastIndexOf("<",s);if(-1!==e&&-1!==t.substring(e,s).indexOf('contenteditable="false"'))return o}return'<span class="'+n+'" data-mce-content="'+e.dom.encode(r[0])+'">'+e.dom.encode("string"==typeof r[1]?r[1]:r[0])+"</span>"},SE=(e,t)=>{t.hasAttribute("data-mce-caret")&&(Yr(t),e.selection.setRng(e.selection.getRng()),e.selection.scrollIntoView(t))},_E=(e,t)=>{const n=(e=>eo(yn(e.getBody()),"*[data-mce-caret]").map((e=>e.dom)).getOrNull())(e);if(n)return"compositionstart"===t.type?(t.preventDefault(),t.stopPropagation(),void SE(e,n)):void(Vr(n)&&(SE(e,n),e.undoManager.add()))},NE=ir,RE=(e,t,n)=>{const o=du(e.getBody()),r=O(Xc,1===t?o.next:o.prev);if(n.collapsed){const o=e.dom.getParent(n.startContainer,"PRE");if(!o)return;if(!r(Li.fromRangeStart(n))){const n=yn((e=>{const t=e.dom.create(Nl(e));return t.innerHTML='<br data-mce-bogus="1">',t})(e));1===t?po(yn(o),n):go(yn(o),n),e.selection.select(n.dom,!0),e.selection.collapse()}}},AE=(e,t)=>((e,t)=>{const n=t?Jc.Forwards:Jc.Backwards,o=e.selection.getRng();return((e,t,n)=>Ok(t,e,n,mp,fp,NE))(n,e,o).orThunk((()=>(RE(e,n,o),I.none())))})(e,((e,t)=>{const n=t?e.getEnd(!0):e.getStart(!0);return sh(n)?!t:t})(e.selection,t)).exists((t=>(Rk(e,t),!0))),OE=(e,t)=>((e,t)=>{const n=t?1:-1,o=e.selection.getRng();return((e,t,n)=>Tk(t,e,n,(e=>mp(e)||cp(e)),(e=>fp(e)||up(e)),NE))(n,e,o).orThunk((()=>(RE(e,n,o),I.none())))})(e,t).exists((t=>(Rk(e,t),!0))),TE=(e,t)=>Dk(e,t,t?fp:mp),BE=(e,t)=>px(e,!t).map((n=>{const o=n.toRange(),r=e.selection.getRng();return t?o.setStart(r.startContainer,r.startOffset):o.setEnd(r.endContainer,r.endOffset),o})).exists((t=>(Rk(e,t),!0))),DE=e=>H(["figcaption"],Ht(e)),PE=(e,t)=>!!e.selection.isCollapsed()&&((e,t)=>{const n=yn(e.getBody()),o=Li.fromRangeStart(e.selection.getRng());return((e,t)=>{const n=O(En,t);return Jn(yn(e.container()),xr,n).filter(DE)})(o,n).exists((()=>{if(((e,t,n)=>t?mk(e.dom,n):uk(e.dom,n))(n,t,o)){const o=xE(e,n,t?bo:ho);return e.selection.setRng(o),!0}return!1}))})(e,t),LE=(e,t)=>((e,t)=>t?I.from(e.dom.getParent(e.selection.getNode(),"details")).map((t=>((e,t)=>{const n=e.selection.getRng(),o=Li.fromRangeStart(n);return!(e.getBody().lastChild!==t||!mk(t,o)||(e.execCommand("InsertNewBlockAfter"),0))})(e,t))).getOr(!1):I.from(e.dom.getParent(e.selection.getNode(),"summary")).bind((t=>I.from(e.dom.getParent(t,"details")).map((n=>((e,t,n)=>{const o=e.selection.getRng(),r=Li.fromRangeStart(o);return!(e.getBody().firstChild!==t||!uk(n,r)||(e.execCommand("InsertNewBlockBefore"),0))})(e,n,t))))).getOr(!1))(e,t),ME={shiftKey:!1,altKey:!1,ctrlKey:!1,metaKey:!1,keyCode:0},IE=(e,t)=>t.keyCode===e.keyCode&&t.shiftKey===e.shiftKey&&t.altKey===e.altKey&&t.ctrlKey===e.ctrlKey&&t.metaKey===e.metaKey,FE=(e,...t)=>()=>e.apply(null,t),UE=(e,t)=>J(((e,t)=>te((e=>V(e,(e=>({...ME,...e}))))(e),(e=>IE(e,t)?[e]:[])))(e,t),(e=>e.action())),zE=(e,t)=>ue(((e,t)=>te((e=>V(e,(e=>({...ME,...e}))))(e),(e=>IE(e,t)?[e]:[])))(e,t),(e=>e.action())),jE=(e,t)=>{const n=t?Jc.Forwards:Jc.Backwards,o=e.selection.getRng();return Ok(e,n,o,lp,dp,cr).exists((t=>(Rk(e,t),!0)))},HE=(e,t)=>{const n=t?1:-1,o=e.selection.getRng();return Tk(e,n,o,lp,dp,cr).exists((t=>(Rk(e,t),!0)))},$E=(e,t)=>Dk(e,t,t?dp:lp),VE=al([{none:["current"]},{first:["current"]},{middle:["current","target"]},{last:["current"]}]),qE={...VE,none:e=>VE.none(e)},WE=(e,t,n)=>te(Mn(e),(e=>xn(e,t)?n(e)?[e]:[]:WE(e,t,n))),KE=(e,t)=>to(e,"table",t),GE=(e,t,n,o,r=M)=>{const s=1===o;if(!s&&n<=0)return qE.first(e[0]);if(s&&n>=e.length-1)return qE.last(e[e.length-1]);{const s=n+o,a=e[s];return r(a)?qE.middle(t,a):GE(e,t,s,o,r)}},YE=(e,t)=>KE(e,t).bind((t=>{const n=WE(t,"th,td",M);return Z(n,(t=>En(e,t))).map((e=>({index:e,all:n})))})),XE=(e,t,n,o,r)=>{const s=Fo(yn(n),"td,th,caption").map((e=>e.dom)),a=G(((e,t)=>te(t,(t=>{const n=((e,t)=>({left:e.left-t,top:e.top-t,right:e.right+-2,bottom:e.bottom+-2,width:e.width+t,height:e.height+t}))(li(t.getBoundingClientRect()),-1);return[{x:n.left,y:e(n),cell:t},{x:n.right,y:e(n),cell:t}]})))(e,s),(e=>t(e,r)));return((e,t,n)=>X(e,((e,o)=>e.fold((()=>I.some(o)),(e=>{const r=Math.sqrt(Math.abs(e.x-t)+Math.abs(e.y-n)),s=Math.sqrt(Math.abs(o.x-t)+Math.abs(o.y-n));return I.some(s<r?o:e)}))),I.none()))(a,o,r).map((e=>e.cell))},QE=O(XE,(e=>e.bottom),((e,t)=>e.y<t)),JE=O(XE,(e=>e.top),((e,t)=>e.y>t)),ZE=(e,t,n)=>{const o=e(t,n);return(e=>e.breakType===Zx.Wrap&&0===e.positions.length)(o)||!rr(n.getNode())&&(e=>e.breakType===Zx.Br&&1===e.positions.length)(o)?!((e,t,n)=>n.breakAt.exists((n=>e(t,n).breakAt.isSome())))(e,t,o):o.breakAt.isNone()},eS=O(ZE,ik),tS=O(ZE,lk),nS=(e,t,n,o)=>{const r=e.selection.getRng(),s=t?1:-1;return!(!xc()||!((e,t,n)=>{const o=Li.fromRangeStart(t);return hu(!e,n).exists((e=>e.isEqual(o)))})(t,r,n)||(lx(s,e,n,!t,!1).each((t=>{Rk(e,t)})),0))},oS=(e,t,n)=>{const o=((e,t)=>{const n=t.getNode(e);return Yo(n)?I.some(n):I.none()})(!!t,n),r=!1===t;o.fold((()=>Rk(e,n.toRange())),(o=>hu(r,e.getBody()).filter((e=>e.isEqual(n))).fold((()=>Rk(e,n.toRange())),(n=>((e,t,n)=>{t.undoManager.transact((()=>{const o=e?po:go,r=xE(t,yn(n),o);Rk(t,r)}))})(t,e,o)))))},rS=(e,t,n,o)=>{const r=e.selection.getRng(),s=Li.fromRangeStart(r),a=e.getBody();if(!t&&eS(o,s)){const o=((e,t,n)=>((e,t)=>le(t.getClientRects()).bind((t=>QE(e,t.left,t.top))).bind((e=>{return ak(Cu(n=e).map((e=>ik(n,e).positions.concat(e))).getOr([]),t);var n})))(t,n).orThunk((()=>le(n.getClientRects()).bind((n=>sk(dk(e,Li.before(t)),n.left))))).getOr(Li.before(t)))(a,n,s);return oS(e,t,o),!0}if(t&&tS(o,s)){const o=((e,t,n)=>((e,t)=>de(t.getClientRects()).bind((t=>JE(e,t.left,t.top))).bind((e=>{return ak(yu(n=e).map((e=>[e].concat(lk(n,e).positions))).getOr([]),t);var n})))(t,n).orThunk((()=>le(n.getClientRects()).bind((n=>sk(ck(e,Li.after(t)),n.left))))).getOr(Li.after(t)))(a,n,s);return oS(e,t,o),!0}return!1},sS=(e,t,n)=>I.from(e.dom.getParent(e.selection.getNode(),"td,th")).bind((o=>I.from(e.dom.getParent(o,"table")).map((r=>n(e,t,r,o))))).getOr(!1),aS=(e,t)=>sS(e,t,nS),iS=(e,t)=>sS(e,t,rS),lS=(e,t,n)=>n.fold(I.none,I.none,((e,t)=>{return(n=t,((e,t)=>{const n=e=>{for(let o=0;o<e.childNodes.length;o++){const r=yn(e.childNodes[o]);if(t(r))return I.some(r);const s=n(e.childNodes[o]);if(s.isSome())return s}return I.none()};return n(e.dom)})(n,Og)).map((e=>(e=>{const t=hf.exact(e,0,e,0);return wf(t)})(e)));var n}),(n=>(e.execCommand("mceTableInsertRowAfter"),dS(e,t,n)))),dS=(e,t,n)=>{return lS(e,t,(r=no,YE(o=n,void 0).fold((()=>qE.none(o)),(e=>GE(e.all,o,e.index,1,r)))));var o,r},cS=(e,t,n)=>{return lS(e,t,(r=no,YE(o=n,void 0).fold((()=>qE.none()),(e=>GE(e.all,o,e.index,-1,r)))));var o,r},uS=(e,t)=>{const n=["table","li","dl"],o=yn(e.getBody()),r=e=>{const t=Ht(e);return En(e,o)||H(n,t)},s=e.selection.getRng();return((e,t)=>((e,t,n=L)=>n(t)?I.none():H(e,Ht(t))?I.some(t):Zn(t,e.join(","),(e=>xn(e,"table")||n(e))))(["td","th"],e,t))(yn(t?s.endContainer:s.startContainer),r).map((n=>(KE(n,r).each((t=>{e.model.table.clearSelectedCells(t.dom)})),e.selection.collapse(!t),(t?dS:cS)(e,r,n).each((t=>{e.selection.setRng(t)})),!0))).getOr(!1)},mS=(e,t)=>({container:e,offset:t}),fS=Oa.DOM,gS=e=>t=>e===t?-1:0,pS=(e,t,n)=>{if(Jo(e)&&t>=0)return I.some(mS(e,t));{const o=ai(fS);return I.from(o.backwards(e,t,gS(e),n)).map((e=>mS(e.container,e.container.data.length)))}},hS=(e,t,n)=>{if(!Jo(e))return I.none();const o=e.data;if(t>=0&&t<=o.length)return I.some(mS(e,t));{const o=ai(fS);return I.from(o.backwards(e,t,gS(e),n)).bind((e=>{const o=e.container.data;return hS(e.container,t+o.length,n)}))}},bS=(e,t,n)=>{if(!Jo(e))return I.none();const o=e.data;if(t<=o.length)return I.some(mS(e,t));{const r=ai(fS);return I.from(r.forwards(e,t,gS(e),n)).bind((e=>bS(e.container,t-o.length,n)))}},vS=(e,t,n,o,r)=>{const s=ai(e,(e=>t=>e.isBlock(t)||H(["BR","IMG","HR","INPUT"],t.nodeName)||"false"===e.getContentEditable(t))(e));return I.from(s.backwards(t,n,o,r))},yS=e=>Fr(e.toString().replace(/\u00A0/g," ")),CS=e=>""!==e&&-1!==" \xa0\f\n\r\t\v".indexOf(e),wS=(e,t)=>e.substring(t.length),xS=(e,t,n,o=0)=>{return(r=yn(t.startContainer),to(r,Tg)).fold((()=>((e,t,n,o=0)=>{if(!(r=t).collapsed||!Jo(r.startContainer))return I.none();var r;const s={text:"",offset:0},a=e.getParent(t.startContainer,e.isBlock)||e.getRoot();return vS(e,t.startContainer,t.startOffset,((e,t,o)=>(s.text=o+s.text,s.offset+=t,((e,t,n)=>{let o;const r=n.charAt(0);for(o=t-1;o>=0;o--){const s=e.charAt(o);if(CS(s))return I.none();if(r===s&&je(e,n,o,t))break}return I.some(o)})(s.text,s.offset,n).getOr(t))),a).bind((e=>{const r=t.cloneRange();if(r.setStart(e.container,e.offset),r.setEnd(t.endContainer,t.endOffset),r.collapsed)return I.none();const s=yS(r);return 0!==s.lastIndexOf(n)||wS(s,n).length<o?I.none():I.some({text:wS(s,n),range:r,trigger:n})}))})(e,t,n,o)),(t=>{const o=e.createRng();o.selectNode(t.dom);const r=yS(o);return I.some({range:o,text:wS(r,n),trigger:n})}));var r},kS=e=>{if((e=>3===e.nodeType)(e))return mS(e,e.data.length);{const t=e.childNodes;return t.length>0?kS(t[t.length-1]):mS(e,t.length)}},ES=(e,t)=>{const n=e.childNodes;return n.length>0&&t<n.length?ES(n[t],0):n.length>0&&(e=>1===e.nodeType)(e)&&n.length===t?kS(n[n.length-1]):mS(e,t)},SS=(e,t,n,o={})=>{var r;const s=t(),a=null!==(r=e.selection.getRng().startContainer.nodeValue)&&void 0!==r?r:"",i=G(s.lookupByTrigger(n.trigger),(t=>n.text.length>=t.minChars&&t.matches.getOrThunk((()=>(e=>t=>{const n=ES(t.startContainer,t.startOffset);return!((e,t)=>{var n;const o=null!==(n=e.getParent(t.container,e.isBlock))&&void 0!==n?n:e.getRoot();return vS(e,t.container,t.offset,((e,t)=>0===t?-1:t),o).filter((e=>{const t=e.container.data.charAt(e.offset-1);return!CS(t)})).isSome()})(e,n)})(e.dom)))(n.range,a,n.text)));if(0===i.length)return I.none();const l=Promise.all(V(i,(e=>e.fetch(n.text,e.maxResults,o).then((t=>({matchText:n.text,items:t,columns:e.columns,onAction:e.onAction,highlightOn:e.highlightOn}))))));return I.some({lookupData:l,context:n})};var _S;!function(e){e[e.Error=0]="Error",e[e.Value=1]="Value"}(_S||(_S={}));const NS=(e,t,n)=>e.stype===_S.Error?t(e.serror):n(e.svalue),RS=e=>({stype:_S.Value,svalue:e}),AS=e=>({stype:_S.Error,serror:e}),OS=NS,TS=e=>f(e)&&me(e).length>100?" removed due to size":JSON.stringify(e,null,2),BS=(e,t)=>AS([{path:e,getErrorInfo:t}]),DS=(e,t)=>({extract:(n,o)=>xe(o,e).fold((()=>((e,t)=>BS(e,(()=>'Choice schema did not contain choice key: "'+t+'"')))(n,e)),(e=>((e,t,n,o)=>xe(n,o).fold((()=>((e,t,n)=>BS(e,(()=>'The chosen schema: "'+n+'" did not exist in branches: '+TS(t))))(e,n,o)),(n=>n.extract(e.concat(["branch: "+o]),t))))(n,o,t,e))),toString:()=>"chooseOn("+e+"). Possible values: "+me(t)}),PS=e=>(...t)=>{if(0===t.length)throw new Error("Can't merge zero objects");const n={};for(let o=0;o<t.length;o++){const r=t[o];for(const t in r)ke(r,t)&&(n[t]=e(n[t],r[t]))}return n},LS=PS(((e,t)=>g(e)&&g(t)?LS(e,t):t)),MS=(PS(((e,t)=>t)),e=>({tag:"defaultedThunk",process:N(e)})),IS=e=>{const t=(e=>{const t=[],n=[];return q(e,(e=>{NS(e,(e=>n.push(e)),(e=>t.push(e)))})),{values:t,errors:n}})(e);return t.errors.length>0?(n=t.errors,S(AS,ee)(n)):RS(t.values);var n},FS=(e,t,n)=>{switch(e.tag){case"field":return t(e.key,e.newKey,e.presence,e.prop);case"custom":return n(e.newKey,e.instantiator)}},US=e=>({extract:(t,n)=>{return o=e(n),r=e=>((e,t)=>BS(e,N(t)))(t,e),o.stype===_S.Error?r(o.serror):o;var o,r},toString:N("val")}),zS=US(RS),jS=(e,t,n,o)=>o(xe(e,t).getOrThunk((()=>n(e)))),HS=(e,t,n,o,r)=>{const s=e=>r.extract(t.concat([o]),e),a=e=>e.fold((()=>RS(I.none())),(e=>{const n=r.extract(t.concat([o]),e);return s=n,a=I.some,s.stype===_S.Value?{stype:_S.Value,svalue:a(s.svalue)}:s;var s,a}));switch(e.tag){case"required":return((e,t,n,o)=>xe(t,n).fold((()=>((e,t,n)=>BS(e,(()=>'Could not find valid *required* value for "'+t+'" in '+TS(n))))(e,n,t)),o))(t,n,o,s);case"defaultedThunk":return jS(n,o,e.process,s);case"option":return((e,t,n)=>n(xe(e,t)))(n,o,a);case"defaultedOptionThunk":return((e,t,n,o)=>o(xe(e,t).map((t=>!0===t?n(e):t))))(n,o,e.process,a);case"mergeWithThunk":return jS(n,o,N({}),(t=>{const o=LS(e.process(n),t);return s(o)}))}},$S=e=>({extract:(t,n)=>((e,t,n)=>{const o={},r=[];for(const s of n)FS(s,((n,s,a,i)=>{const l=HS(a,e,t,n,i);OS(l,(e=>{r.push(...e)}),(e=>{o[s]=e}))}),((e,n)=>{o[e]=n(t)}));return r.length>0?AS(r):RS(o)})(t,n,e),toString:()=>{const t=V(e,(e=>FS(e,((e,t,n,o)=>e+" -> "+o.toString()),((e,t)=>"state("+e+")"))));return"obj{\n"+t.join("\n")+"}"}}),VS=e=>({extract:(t,n)=>{const o=V(n,((n,o)=>e.extract(t.concat(["["+o+"]"]),n)));return IS(o)},toString:()=>"array("+e.toString()+")"}),qS=(e,t,n)=>{return o=((e,t,n)=>((e,t)=>e.stype===_S.Error?{stype:_S.Error,serror:t(e.serror)}:e)(t.extract([e],n),(e=>({input:n,errors:e}))))(e,t,n),NS(o,sl.error,sl.value);var o},WS=(e,t)=>DS(e,pe(t,$S)),KS=N(zS),GS=(e,t)=>US((n=>{const o=typeof n;return e(n)?RS(n):AS(`Expected type: ${t} but got: ${o}`)})),YS=GS(x,"number"),XS=GS(m,"string"),QS=GS(b,"boolean"),JS=GS(w,"function"),ZS=(e,t,n,o)=>({tag:"field",key:e,newKey:t,presence:n,prop:o}),e_=(e,t)=>({tag:"custom",newKey:e,instantiator:t}),t_=(e,t)=>ZS(e,e,{tag:"required",process:{}},t),n_=e=>t_(e,XS),o_=e=>t_(e,JS),r_=(e,t)=>ZS(e,e,{tag:"option",process:{}},t),s_=e=>r_(e,XS),a_=(e,t,n)=>ZS(e,e,MS(t),n),i_=(e,t)=>a_(e,t,YS),l_=(e,t,n)=>a_(e,t,(e=>{return t=t=>H(e,t)?sl.value(t):sl.error(`Unsupported value: "${t}", choose one of "${e.join(", ")}".`),US((e=>t(e).fold(AS,RS)));var t})(n)),d_=(e,t)=>a_(e,t,QS),c_=(e,t)=>a_(e,t,JS),u_=n_("type"),m_=o_("fetch"),f_=o_("onAction"),g_=c_("onSetup",(()=>E)),p_=s_("text"),h_=s_("icon"),b_=s_("tooltip"),v_=s_("label"),y_=d_("active",!1),C_=d_("enabled",!0),w_=d_("primary",!1),x_=e=>((e,t)=>a_("type",t,XS))(0,e),k_=$S([u_,n_("trigger"),i_("minChars",1),(1,((e,t)=>ZS(e,e,MS(1),KS()))("columns")),i_("maxResults",10),("matches",r_("matches",JS)),m_,f_,(E_=XS,a_("highlightOn",[],VS(E_)))]);var E_;const S_=[C_,b_,h_,p_,g_],__=[y_].concat(S_),N_=[c_("predicate",L),l_("scope","node",["node","editor"]),l_("position","selection",["node","selection","line"])],R_=S_.concat([x_("contextformbutton"),w_,f_,e_("original",R)]),A_=__.concat([x_("contextformbutton"),w_,f_,e_("original",R)]),O_=S_.concat([x_("contextformbutton")]),T_=__.concat([x_("contextformtogglebutton")]),B_=WS("type",{contextformbutton:R_,contextformtogglebutton:A_});$S([x_("contextform"),c_("initValue",N("")),v_,((e,t)=>ZS(e,e,{tag:"required",process:{}},VS(t)))("commands",B_),r_("launch",WS("type",{contextformbutton:O_,contextformtogglebutton:T_}))].concat(N_));const D_=e=>{const t=e.ui.registry.getAll().popups,n=pe(t,(e=>{return(t=e,qS("Autocompleter",k_,{trigger:t.ch,...t})).fold((e=>{throw new Error("Errors: \n"+(e=>{const t=e.length>10?e.slice(0,10).concat([{path:[],getErrorInfo:N("... (only showing first ten failures)")}]):e;return V(t,(e=>"Failed path: ("+e.path.join(" > ")+")\n"+e.getErrorInfo()))})((t=e).errors).join("\n")+"\n\nInput object: "+TS(t.input));var t}),R);var t})),o=Se(Ce(n,(e=>e.trigger))),r=we(n);return{dataset:n,triggers:o,lookupByTrigger:e=>G(r,(t=>t.trigger===e))}},P_=e=>{const t=za(),n=Da(!1),o=t.isSet,r=()=>{o()&&((e=>{MC(e).autocompleter.removeDecoration()})(e),(e=>{e.dispatch("AutocompleterEnd")})(e),n.set(!1),t.clear())},s=Pe((()=>D_(e))),a=a=>{(n=>t.get().map((t=>xS(e.dom,e.selection.getRng(),t.trigger).bind((t=>SS(e,s,t,n))))).getOrThunk((()=>((e,t)=>{const n=t(),o=e.selection.getRng();return((e,t,n)=>ue(n.triggers,(n=>xS(e,t,n))))(e.dom,o,n).bind((n=>SS(e,t,n)))})(e,s))))(a).fold(r,(s=>{(n=>{o()||(((e,t)=>{MC(e).autocompleter.addDecoration(t)})(e,n.range),t.set({trigger:n.trigger,matchLength:n.text.length}))})(s.context),s.lookupData.then((o=>{t.get().map((a=>{const i=s.context;a.trigger===i.trigger&&(i.text.length-a.matchLength>=10?r():(t.set({...a,matchLength:i.text.length}),n.get()?((e,t)=>{e.dispatch("AutocompleterUpdate",t)})(e,{lookupData:o}):(n.set(!0),((e,t)=>{e.dispatch("AutocompleterStart",t)})(e,{lookupData:o}))))}))}))}))};e.addCommand("mceAutocompleterReload",((e,t)=>{const n=f(t)?t.fetchOptions:{};a(n)})),e.addCommand("mceAutocompleterClose",r),((e,t)=>{const n=Ha(t.load,50);e.on("keypress compositionend",(e=>{27!==e.which&&n.throttle()})),e.on("keydown",(e=>{const o=e.which;8===o?n.throttle():27===o&&t.cancelIfNecessary()})),e.on("remove",n.cancel)})(e,{cancelIfNecessary:r,load:a})},L_=xt().browser.isSafari(),M_=e=>Pr(yn(e)),I_=(e,t)=>{var n;return 0===e.startOffset&&e.endOffset===(null===(n=t.textContent)||void 0===n?void 0:n.length)},F_=(e,t)=>I.from(e.getParent(t.container(),"details")),U_=(e,t)=>F_(e,t).isSome(),z_=(e,t)=>
5168{const n=t.getNode();v(n)||e.selection.setCursorLocation(n,t.offset())},j_=(e,t,n)=>{const o=e.dom.getParent(t.container(),"details");if(o&&!o.open){const t=e.dom.select("summary",o)[0];t&&(n?yu(t):Cu(t)).each((t=>z_(e,t)))}else z_(e,t)},H_=(e,t,n)=>{const{dom:o,selection:r}=e,s=e.getBody();if("character"===n){const n=Li.fromRangeStart(r.getRng()),a=o.getParent(n.container(),o.isBlock),i=F_(o,n),l=a&&o.isEmpty(a),d=h(null==a?void 0:a.previousSibling),c=h(null==a?void 0:a.nextSibling);return!!(l&&(t?c:d)&&gu(!t,s,n).exists((e=>U_(o,e)&&!Lt(i,F_(o,e)))))||gu(t,s,n).fold(L,(n=>{const r=F_(o,n);if(U_(o,n)&&!Lt(i,r)){if(t||j_(e,n,!1),a&&l){if(t&&d)return!0;if(!t&&c)return!0;j_(e,n,t),e.dom.remove(a)}return!0}return!1}))}return!1},$_=(e,t,n,o)=>{const r=e.selection.getRng(),s=Li.fromRangeStart(r),a=e.getBody();return"selection"===o?((e,t)=>{const n=t.startSummary.exists((t=>t.contains(e.startContainer))),o=t.startSummary.exists((t=>t.contains(e.endContainer))),r=t.startDetails.forall((e=>t.endDetails.forall((t=>e!==t))));return(n||o)&&!(n&&o)||r})(r,t):n?((e,t)=>t.startSummary.exists((t=>((e,t)=>Cu(t).exists((n=>rr(n.getNode())&&vu(t,n).exists((t=>t.isEqual(e)))||n.isEqual(e))))(e,t))))(s,t)||((e,t,n)=>n.startDetails.exists((n=>bu(e,t).forall((e=>!n.contains(e.container()))))))(a,s,t):((e,t)=>t.startSummary.exists((t=>((e,t)=>yu(t).exists((t=>t.isEqual(e))))(e,t))))(s,t)||((e,t)=>t.startDetails.exists((n=>vu(n,e).forall((n=>t.startSummary.exists((t=>!t.contains(e.container())&&t.contains(n.container()))))))))(s,t)},V_=(e,t,n)=>((e,t,n)=>((e,t)=>{const n=I.from(e.getParent(t.startContainer,"details")),o=I.from(e.getParent(t.endContainer,"details"));if(n.isSome()||o.isSome()){const t=n.bind((t=>I.from(e.select("summary",t)[0])));return I.some({startSummary:t,startDetails:n,endDetails:o})}return I.none()})(e.dom,e.selection.getRng()).fold((()=>H_(e,t,n)),(o=>$_(e,o,t,n)||H_(e,t,n))))(e,t,n)||L_&&((e,t,n)=>{const o=e.selection,r=o.getNode(),s=o.getRng(),a=Li.fromRangeStart(s);return!!fr(r)&&("selection"===n&&I_(s,r)||ph(t,a,r)?M_(r):e.undoManager.transact((()=>{const s=o.getSel();let{anchorNode:a,anchorOffset:i,focusNode:l,focusOffset:d}=null!=s?s:{};const c=()=>{C(a)&&C(i)&&C(l)&&C(d)&&(null==s||s.setBaseAndExtent(a,i,l,d))},u=(e,t)=>{q(e.childNodes,(e=>{rm(e)&&t.appendChild(e)}))},m=e.dom.create("span",{"data-mce-bogus":"1"});u(r,m),r.appendChild(m),c(),"word"!==n&&"line"!==n||null==s||s.modify("extend",t?"right":"left",n),!o.isCollapsed()&&I_(o.getRng(),m)?M_(r):(e.execCommand(t?"ForwardDelete":"Delete"),a=null==s?void 0:s.anchorNode,i=null==s?void 0:s.anchorOffset,l=null==s?void 0:s.focusNode,d=null==s?void 0:s.focusOffset,u(m,r),c()),e.dom.remove(m)})),!0)})(e,t,n)?I.some(E):I.none(),q_=e=>(t,n,o={})=>{const r=t.getBody(),s={bubbles:!0,composed:!0,data:null,isComposing:!1,detail:0,view:null,target:r,currentTarget:r,eventPhase:Event.AT_TARGET,originalTarget:r,explicitOriginalTarget:r,isTrusted:!1,srcElement:r,cancelable:!1,preventDefault:E,inputType:n},a=fa(new InputEvent(e));return t.dispatch(e,{...a,...s,...o})},W_=q_("input"),K_=q_("beforeinput"),G_=xt(),Y_=G_.os,X_=Y_.isMacOS()||Y_.isiOS(),Q_=G_.browser.isFirefox(),J_=(e,t)=>{const n=e.dom,o=e.schema.getMoveCaretBeforeOnEnterElements();if(!t)return;if(/^(LI|DT|DD)$/.test(t.nodeName)){const e=(e=>{for(;e;){if($o(e)||Jo(e)&&e.data&&/[\r\n\s]/.test(e.data))return e;e=e.nextSibling}return null})(t.firstChild);e&&/^(UL|OL|DL)$/.test(e.nodeName)&&t.insertBefore(n.doc.createTextNode(pr),t.firstChild)}const r=n.createRng();if(t.normalize(),t.hasChildNodes()){const e=new zo(t,t);let n,s=t;for(;n=e.current();){if(Jo(n)){r.setStart(n,0),r.setEnd(n,0);break}if(o[n.nodeName.toLowerCase()]){r.setStartBefore(n),r.setEndBefore(n);break}s=n,n=e.next()}n||(r.setStart(s,0),r.setEnd(s,0))}else rr(t)?t.nextSibling&&n.isBlock(t.nextSibling)?(r.setStartBefore(t),r.setEndBefore(t)):(r.setStartAfter(t),r.setEndAfter(t)):(r.setStart(t,0),r.setEnd(t,0));e.selection.setRng(r),Zf(e,r)},Z_=(e,t)=>{const n=e.getRoot();let o,r=t;for(;r!==n&&r&&"false"!==e.getContentEditable(r);){if("true"===e.getContentEditable(r)){o=r;break}r=r.parentNode}return r!==n?o:n},eN=e=>I.from(e.dom.getParent(e.selection.getStart(!0),e.dom.isBlock)),tN=e=>{e.innerHTML='<br data-mce-bogus="1">'},nN=(e,t)=>{Nl(e).toLowerCase()===t.tagName.toLowerCase()&&((e,t,n)=>{const o=e.dom;I.from(n.style).map(o.parseStyle).each((e=>{const n={...mo(yn(t)),...e};o.setStyles(t,n)}));const r=I.from(n.class).map((e=>e.split(/\s+/))),s=I.from(t.className).map((e=>G(e.split(/\s+/),(e=>""!==e))));
vendor: 12,454 bytes, line 5168
5168Mt(r,s,((e,n)=>{const r=G(n,(t=>!H(e,t))),s=[...e,...r];o.setAttrib(t,"class",s.join(" "))}));const a=["style","class"],i=ye(n,((e,t)=>!H(a,t)));o.setAttribs(t,i)})(e,t,Rl(e))},oN=(e,t,n,o,r=!0,s)=>{const a=e.dom,i=e.schema,l=Nl(e),d=n?n.nodeName.toUpperCase():"";let c=t;const u=i.getTextInlineElements();let m;m=s||"TABLE"===d||"HR"===d?a.create(s||l):n.cloneNode(!1);let f=m;if(r){do{if(u[c.nodeName]){if(xu(c)||Lu(c))continue;const e=c.cloneNode(!1);a.setAttrib(e,"id",""),m.hasChildNodes()?(e.appendChild(m.firstChild),m.appendChild(e)):(f=e,m.appendChild(e))}}while((c=c.parentNode)&&c!==o)}else a.setAttrib(m,"style",null),a.setAttrib(m,"class",null);return nN(e,m),tN(f),m},rN=(e,t)=>{const n=null==e?void 0:e.parentNode;return C(n)&&n.nodeName===t},sN=e=>C(e)&&/^(OL|UL|LI)$/.test(e.nodeName),aN=e=>{const t=e.parentNode;return C(n=t)&&/^(LI|DT|DD)$/.test(n.nodeName)?t:e;var n},iN=(e,t,n)=>{let o=e[n?"firstChild":"lastChild"];for(;o&&!$o(o);)o=o[n?"nextSibling":"previousSibling"];return o===t},lN=(e,t)=>t&&"A"===t.nodeName&&e.isEmpty(t),dN=(e,t)=>e.nodeName===t||e.previousSibling&&e.previousSibling.nodeName===t,cN=(e,t)=>C(t)&&e.isBlock(t)&&!/^(TD|TH|CAPTION|FORM)$/.test(t.nodeName)&&!/^(fixed|absolute)/i.test(t.style.position)&&e.isEditable(t.parentNode)&&"false"!==e.getContentEditable(t),uN=(e,t,n)=>Jo(t)?e?1===n&&t.data.charAt(n-1)===Mr?0:n:n===t.data.length-1&&t.data.charAt(n)===Mr?t.data.length:n:n,mN={insert:(e,t)=>{let n,o,r,s,a=!1;const i=e.dom,l=e.schema.getNonEmptyElements(),d=e.selection.getRng(),c=Nl(e),u=yn(d.startContainer),f=In(u,d.startOffset),g=f.exists((e=>qt(e)&&!no(e))),p=d.collapsed&&g,b=t=>oN(e,n,S,E,Bl(e),t),v=e=>{const t=uN(e,n,o);if(Jo(n)&&(e?t>0:t<n.data.length))return!1;if(n.parentNode===S&&a&&!e)return!0;if(e&&$o(n)&&n===S.firstChild)return!0;if(dN(n,"TABLE")||dN(n,"HR"))return a&&!e||!a&&e;const r=new zo(n,S);let s;for(Jo(n)&&(e&&0===t?r.prev():e||t!==n.data.length||r.next());s=r.current();){if($o(s)){if(!s.getAttribute("data-mce-bogus")){const e=s.nodeName.toLowerCase();if(l[e]&&"br"!==e)return!1}}else if(Jo(s)&&!ds(s.data))return!1;e?r.prev():r.next()}return!0},w=()=>{let t;return t=/^(H[1-6]|PRE|FIGURE)$/.test(r)&&"HGROUP"!==_?b(c):b(),((e,t)=>{const n=Dl(e);return!y(t)&&(m(n)?H(Dt.explode(n),t.nodeName.toLowerCase()):n)})(e,s)&&cN(i,s)&&i.isEmpty(S,void 0,{includeZwsp:!0})?t=i.split(s,S):i.insertAfter(t,S),J_(e,t),t};Of(i,d).each((e=>{d.setStart(e.startContainer,e.startOffset),d.setEnd(e.endContainer,e.endOffset)})),n=d.startContainer,o=d.startOffset;const x=!(!t||!t.shiftKey),k=!(!t||!t.ctrlKey);$o(n)&&n.hasChildNodes()&&!p&&(a=o>n.childNodes.length-1,n=n.childNodes[Math.min(o,n.childNodes.length-1)]||n,o=a&&Jo(n)?n.data.length:0);const E=Z_(i,n);if(!E||((e,t)=>{const n=e.dom.getParent(t,"ol,ul,dl");return null!==n&&"false"===e.dom.getContentEditableParent(n)})(e,n))return;x||(n=((e,t,n,o,r)=>{var s,a;const i=e.dom,l=null!==(s=Z_(i,o))&&void 0!==s?s:i.getRoot();let d=i.getParent(o,i.isBlock);if(!d||!cN(i,d)){if(d=d||l,!d.hasChildNodes()){const o=i.create(t);return nN(e,o),d.appendChild(o),n.setStart(o,0),n.setEnd(o,0),o}let s,c=o;for(;c&&c.parentNode!==d;)c=c.parentNode;for(;c&&!i.isBlock(c);)s=c,c=c.previousSibling;const u=null===(a=null==s?void 0:s.parentElement)||void 0===a?void 0:a.nodeName;if(s&&u&&e.schema.isValidChild(u,t.toLowerCase())){const a=s.parentNode,l=i.create(t);for(nN(e,l),a.insertBefore(l,s),c=s;c&&!i.isBlock(c);){const e=c.nextSibling;l.appendChild(c),c=e}n.setStart(o,r),n.setEnd(o,r)}}return o})(e,c,d,n,o));let S=i.getParent(n,i.isBlock)||i.getRoot();s=C(null==S?void 0:S.parentNode)?i.getParent(S.parentNode,i.isBlock):null,r=S?S.nodeName.toUpperCase():"";const _=s?s.nodeName.toUpperCase():"";if("LI"!==_||k||(S=s,s=s.parentNode,r=_),$o(s)&&((e,t,n)=>!t&&n.nodeName.toLowerCase()===Nl(e)&&e.dom.isEmpty(n)&&((t,n,o)=>{let r=n;for(;r&&r!==t&&h(r.nextSibling);){const t=r.parentElement;if(!t||(s=t,!ke(e.schema.getTextBlockElements(),s.nodeName.toLowerCase())))return mr(t);r=t}var s;return!1})(e.getBody(),n))(e,x,S))return((e,t,n)=>{var o,r,s;const a=t(Nl(e)),i=((e,t)=>e.dom.getParent(t,mr))(e,n);i&&(e.dom.insertAfter(a,i),J_(e,a),(null!==(s=null===(r=null===(o=n.parentElement)||void 0===o?void 0:o.childNodes)||void 0===r?void 0:r.length)&&void 0!==s?s:0)>1&&e.dom.remove(n))})(e,b,S);if(/^(LI|DT|DD)$/.test(r)&&$o(s)&&i.isEmpty(S))return void((e,t,n,o,r)=>{const s=e.dom,a=e.selection.getRng(),i=n.parentNode;if(n===e.getBody()||!i)return;var l;sN(l=n)&&sN(l.parentNode)&&(r="LI");let d=t(r);if(iN(n,o,!0)&&iN(n,o,!1))if(rN(n,"LI")){const e=aN(n);s.insertAfter(d,e),(e=>{var t;return(null===(t=e.parentNode)||void 0===t?void 0:t.firstChild)===e})(n)?s.remove(e):s.remove(n)}else s.replace(d,n);else if(iN(n,o,!0))rN(n,"LI")?(s.insertAfter(d,aN(n)),d.appendChild(s.doc.createTextNode(" ")),d.appendChild(n)):i.insertBefore(d,n),s.remove(o);else if(iN(n,o,!1))s.insertAfter(d,aN(n)),s.remove(o);else{n=aN(n);const e=a.cloneRange();e.setStartAfter(o),e.setEndAfter(n);const t=e.extractContents();"LI"===r&&((e,t)=>e.firstChild&&"LI"===e.firstChild.nodeName)(t)?(d=t.firstChild,s.insertAfter(t,n)):(s.insertAfter(t,n),s.insertAfter(d,n)),s.remove(o)}J_(e,d)})(e,b,s,S,c);if(!(p||S!==e.getBody()&&cN(i,S)))return;const N=S.parentNode;let R;if(p)R=b(c),f.fold((()=>{bo(u,yn(R))}),(e=>{go(e,yn(R))})),e.selection.setCursorLocation(R,0);else if(jr(S))R=Yr(S),i.isEmpty(S)&&tN(S),nN(e,R),J_(e,R);else if(v(!1))R=w();else if(v(!0)&&N){R=N.insertBefore(b(),S);const t=yn(d.startContainer).dom.hasChildNodes()&&d.collapsed;J_(e,dN(S,"HR")||t?R:S)}else{const t=(e=>{const t=e.cloneRange();return t.setStart(e.startContainer,uN(!0,e.startContainer,e.startOffset)),t.setEnd(e.endContainer,uN(!1,e.endContainer,e.endOffset)),t})(d).cloneRange();t.setEndAfter(S);const n=t.extractContents();(e=>{q(Io(yn(e),Kt),(e=>{const t=e.dom;t.nodeValue=Fr(t.data)}))})(n),(e=>{let t=e;do{Jo(t)&&(t.data=t.data.replace(/^[\r\n]+/,"")),t=t.firstChild}while(t)})(n),R=n.firstChild,i.insertAfter(n,S),((e,t,n)=>{var o;const r=[];if(!n)return;let s=n;for(;s=s.firstChild;){if(e.isBlock(s))return;$o(s)&&!t[s.nodeName.toLowerCase()]&&r.push(s)}let a=r.length;for(;a--;)s=r[a],(!s.hasChildNodes()||s.firstChild===s.lastChild&&""===(null===(o=s.firstChild)||void 0===o?void 0:o.nodeValue)||lN(e,s))&&e.remove(s)})(i,l,R),((e,t)=>{t.normalize();const n=t.lastChild;(!n||$o(n)&&/^(left|right)$/gi.test(e.getStyle(n,"float",!0)))&&e.add(t,"br")})(i,S),i.isEmpty(S)&&tN(S),R.normalize(),i.isEmpty(R)?(i.remove(R),w()):(nN(e,R),J_(e,R))}i.setAttrib(R,"id",""),e.dispatch("NewBlock",{newBlock:R})},fakeEventName:"insertParagraph"},fN=(e,t,n)=>{const o=e.dom.createRng();n?(o.setStartBefore(t),o.setEndBefore(t)):(o.setStartAfter(t),o.setEndAfter(t)),e.selection.setRng(o),Zf(e,o)},gN=(e,t)=>{const n=bn("br");go(yn(t),n),e.undoManager.add()},pN=(e,t)=>{hN(e.getBody(),t)||po(yn(t),bn("br"));const n=bn("br");po(yn(t),n),fN(e,n.dom,!1),e.undoManager.add()},hN=(e,t)=>{return n=Li.after(t),!!rr(n.getNode())||bu(e,Li.after(t)).map((e=>rr(e.getNode()))).getOr(!1);var n},bN=e=>e&&"A"===e.nodeName&&"href"in e,vN=e=>e.fold(L,bN,bN,L),yN=(e,t)=>{t.fold(E,O(gN,e),O(pN,e),E)},CN={insert:(e,t)=>{const n=(e=>{const t=O(rh,e),n=Li.fromRangeStart(e.selection.getRng());return Vx(t,e.getBody(),n).filter(vN)})(e);n.isSome()?n.each(O(yN,e)):((e,t)=>{const n=e.selection,o=e.dom,r=n.getRng();let s,a=!1;Of(o,r).each((e=>{r.setStart(e.startContainer,e.startOffset),r.setEnd(e.endContainer,e.endOffset)}));let i=r.startOffset,l=r.startContainer;if($o(l)&&l.hasChildNodes()){const e=i>l.childNodes.length-1;l=l.childNodes[Math.min(i,l.childNodes.length-1)]||l,i=e&&Jo(l)?l.data.length:0}let d=o.getParent(l,o.isBlock);const c=d&&d.parentNode?o.getParent(d.parentNode,o.isBlock):null,u=c?c.nodeName.toUpperCase():"",m=!(!t||!t.ctrlKey);"LI"!==u||m||(d=c),Jo(l)&&i>=l.data.length&&(((e,t,n)=>{const o=new zo(t,n);let r;const s=e.getNonEmptyElements();for(;r=o.next();)if(s[r.nodeName.toLowerCase()]||Jo(r)&&r.length>0)return!0;return!1})(e.schema,l,d||o.getRoot())||(s=o.create("br"),r.insertNode(s),r.setStartAfter(s),r.setEndAfter(s),a=!0)),s=o.create("br"),Ii(o,r,s),fN(e,s,a),e.undoManager.add()})(e,t)},fakeEventName:"insertLineBreak"},wN=(e,t)=>eN(e).filter((e=>t.length>0&&xn(yn(e),t))).isSome(),xN=al([{br:[]},{block:[]},{none:[]}]),kN=(e,t)=>(e=>wN(e,Tl(e)))(e),EN=e=>(t,n)=>(e=>eN(e).filter((e=>Nr(yn(e)))).isSome())(t)===e,SN=(e,t)=>(n,o)=>{const r=(e=>eN(e).fold(N(""),(e=>e.nodeName.toUpperCase())))(n)===e.toUpperCase();return r===t},_N=e=>{const t=Z_(e.dom,e.selection.getStart());return y(t)},NN=e=>SN("pre",e),RN=e=>(t,n)=>_l(t)===e,AN=(e,t)=>(e=>wN(e,Ol(e)))(e),ON=(e,t)=>t,TN=e=>{const t=Nl(e),n=Z_(e.dom,e.selection.getStart());return C(n)&&e.schema.isValidChild(n.nodeName,t)},BN=e=>{const t=e.selection.getRng(),n=yn(t.startContainer),o=In(n,t.startOffset).map((e=>qt(e)&&!no(e)));return t.collapsed&&o.getOr(!0)},DN=(e,t)=>(n,o)=>X(e,((e,t)=>e&&t(n,o)),!0)?I.some(t):I.none(),PN=(e,t,n)=>{t.selection.isCollapsed()||(e=>{e.execCommand("delete")})(t),C(n)&&K_(t,e.fakeEventName).isDefaultPrevented()||(e.insert(t,n),C(n)&&W_(t,e.fakeEventName))},LN=(e,t)=>{const n=()=>PN(CN,e,t),o=()=>PN(mN,e,t),r=((e,t)=>Px([DN([kN],xN.none()),DN([NN(!0),_N],xN.none()),DN([SN("summary",!0)],xN.br()),DN([NN(!0),RN(!1),ON],xN.br()),DN([NN(!0),RN(!1)],xN.block()),DN([NN(!0),RN(!0),ON],xN.block()),DN([NN(!0),RN(!0)],xN.br()),DN([EN(!0),ON],xN.br()),DN([EN(!0)],xN.block()),DN([AN],xN.br()),DN([ON],xN.br()),DN([TN],xN.block()),DN([BN],xN.block())],[e,!(!t||!t.shiftKey)]).getOr(xN.none()))(e,t);switch(Al(e)){case"linebreak":r.fold(n,n,E);break;case"block":r.fold(o,o,E);break;case"invert":r.fold(o,n,E);break;default:r.fold(n,o,E)}},MN=xt(),IN=MN.os.isiOS()&&MN.browser.isSafari(),FN=(e,t)=>{var n;t.isDefaultPrevented()||(t.preventDefault(),(n=e.undoManager).typing&&(n.typing=!1,n.add()),e.undoManager.transact((()=>{LN(e,t)})))},UN=xt(),zN=e=>e.stopImmediatePropagation(),jN=e=>e.keyCode===ef.PAGE_UP||e.keyCode===ef.PAGE_DOWN,HN=(e,t,n)=>{n&&!e.get()?t.on("NodeChange",zN,!0):!n&&e.get()&&t.off("NodeChange",zN),e.set(n)},$N=(e,t)=>{const n=t.container(),o=t.offset();return Jo(n)?(n.insertData(o,e),I.some(Li(n,o+e.length))):Yc(t).map((n=>{const o=vn(e);return t.isAtEnd()?po(n,o):go(n,o),Li(o.dom,e.length)}))},VN=O($N,pr),qN=O($N," "),WN=e=>t=>{e.selection.setRng(t.toRange()),e.nodeChanged()},KN=e=>{const t=Li.fromRangeStart(e.selection.getRng()),n=yn(e.getBody());if(e.selection.isCollapsed()){const o=O(rh,e),r=Li.fromRangeStart(e.selection.getRng());return Vx(o,e.getBody(),r).bind((e=>t=>t.fold((t=>vu(e.dom,Li.before(t))),(e=>yu(e)),(e=>Cu(e)),(t=>bu(e.dom,Li.after(t)))))(n)).map((o=>()=>((e,t)=>n=>Mp(e,n)?VN(t):qN(t))(n,t)(o).each(WN(e))))}return I.none()},GN=e=>{return It(At.browser.isFirefox()&&e.selection.isEditable()&&(t=e.dom,n=e.selection.getRng().startContainer,t.isEditable(t.getParent(n,"summary"))),(()=>{const t=yn(e.getBody());e.selection.isCollapsed()||e.getDoc().execCommand("Delete"),((e,t)=>Mp(e,t)?VN(t):qN(t))(t,Li.fromRangeStart(e.selection.getRng())).each(WN(e))}));var t,n},YN=e=>ac(e)?[{keyCode:ef.TAB,action:FE(uS,e,!0)},{keyCode:ef.TAB,shiftKey:!0,action:FE(uS,e,!1)}]:[],XN=e=>{if(e.addShortcut("Meta+P","","mcePrint"),P_(e),PC(e))return Da(null);{const t=zk(e);return(e=>{e.on("keyup compositionstart",O(_E,e))})(e),((e,t)=>{e.on("keydown",(n=>{n.isDefaultPrevented()||((e,t,n)=>{const o=At.os.isMacOS()||At.os.isiOS();UE([{keyCode:ef.RIGHT,action:FE(AE,e,!0)},{keyCode:ef.LEFT,action:FE(AE,e,!1)},{keyCode:ef.UP,action:FE(OE,e,!1)},{keyCode:ef.DOWN,action:FE(OE,e,!0)},...o?[{keyCode:ef.UP,action:FE(BE,e,!1),metaKey:!0,shiftKey:!0},{keyCode:ef.DOWN,action:FE(BE,e,!0),metaKey:!0,shiftKey:!0}]:[],{keyCode:ef.RIGHT,action:FE(aS,e,!0)},{keyCode:ef.LEFT,action:FE(aS,e,!1)},{keyCode:ef.UP,action:FE(iS,e,!1)},{keyCode:ef.DOWN,action:FE(iS,e,!0)},{keyCode:ef.UP,action:FE(iS,e,!1)},{keyCode:ef.UP,action:FE(LE,e,!1)},{keyCode:ef.DOWN,action:FE(LE,e,!0)},{keyCode:ef.RIGHT,action:FE(jE,e,!0)},{keyCode:ef.LEFT,action:FE(jE,e,!1)},{keyCode:ef.UP,action:FE(HE,e,!1)},{keyCode:ef.DOWN,action:FE(HE,e,!0)},{keyCode:ef.RIGHT,action:FE(Fk,e,t,!0)},{keyCode:ef.LEFT,action:FE(Fk,e,t,!1)},{keyCode:ef.RIGHT,ctrlKey:!o,altKey:o,action:FE(jk,e,t)},{keyCode:ef.LEFT,ctrlKey:!o,altKey:o,action:FE(Hk,e,t)},{keyCode:ef.UP,action:FE(PE,e,!1)},{keyCode:ef.DOWN,action:FE(PE,e,!0)}],n).each((e=>{n.preventDefault()}))})(e,t,n)}))})(e,t),((e,t)=>{let n=!1;
vendor: 4,200 bytes, line 5168
5168e.on("keydown",(o=>{n=o.keyCode===ef.BACKSPACE,o.isDefaultPrevented()||((e,t,n)=>{const o=n.keyCode===ef.BACKSPACE?"deleteContentBackward":"deleteContentForward",r=e.selection.isCollapsed(),s=r?"character":"selection",a=e=>r?e?"word":"line":"selection";zE([{keyCode:ef.BACKSPACE,action:FE(fE,e)},{keyCode:ef.BACKSPACE,action:FE(xx,e,!1)},{keyCode:ef.DELETE,action:FE(xx,e,!0)},{keyCode:ef.BACKSPACE,action:FE(gx,e,!1)},{keyCode:ef.DELETE,action:FE(gx,e,!0)},{keyCode:ef.BACKSPACE,action:FE(Wk,e,t,!1)},{keyCode:ef.DELETE,action:FE(Wk,e,t,!0)},{keyCode:ef.BACKSPACE,action:FE(Hh,e,!1)},{keyCode:ef.DELETE,action:FE(Hh,e,!0)},{keyCode:ef.BACKSPACE,action:FE(V_,e,!1,s)},{keyCode:ef.DELETE,action:FE(V_,e,!0,s)},...X_?[{keyCode:ef.BACKSPACE,altKey:!0,action:FE(V_,e,!1,a(!0))},{keyCode:ef.DELETE,altKey:!0,action:FE(V_,e,!0,a(!0))},{keyCode:ef.BACKSPACE,metaKey:!0,action:FE(V_,e,!1,a(!1))}]:[{keyCode:ef.BACKSPACE,ctrlKey:!0,action:FE(V_,e,!1,a(!0))},{keyCode:ef.DELETE,ctrlKey:!0,action:FE(V_,e,!0,a(!0))}],{keyCode:ef.BACKSPACE,action:FE(kx,e,!1)},{keyCode:ef.DELETE,action:FE(kx,e,!0)},{keyCode:ef.BACKSPACE,action:FE(sE,e,!1)},{keyCode:ef.DELETE,action:FE(sE,e,!0)},{keyCode:ef.BACKSPACE,action:FE(ix,e,!1)},{keyCode:ef.DELETE,action:FE(ix,e,!0)},{keyCode:ef.BACKSPACE,action:FE(rx,e,!1)},{keyCode:ef.DELETE,action:FE(rx,e,!0)},{keyCode:ef.BACKSPACE,action:FE(tE,e,!1)},{keyCode:ef.DELETE,action:FE(tE,e,!0)}],n).filter((t=>e.selection.isEditable())).each((t=>{n.preventDefault(),K_(e,o).isDefaultPrevented()||(t(),W_(e,o))}))})(e,t,o)})),e.on("keyup",(t=>{t.isDefaultPrevented()||((e,t,n)=>{UE([{keyCode:ef.BACKSPACE,action:FE(wx,e)},{keyCode:ef.DELETE,action:FE(wx,e)},...X_?[{keyCode:ef.BACKSPACE,altKey:!0,action:FE(oE,e)},{keyCode:ef.DELETE,altKey:!0,action:FE(oE,e)},...n?[{keyCode:Q_?224:91,action:FE(oE,e)}]:[]]:[{keyCode:ef.BACKSPACE,ctrlKey:!0,action:FE(oE,e)},{keyCode:ef.DELETE,ctrlKey:!0,action:FE(oE,e)}]],t)})(e,t,n),n=!1}))})(e,t),(e=>{let t=I.none();e.on("keydown",(n=>{n.keyCode===ef.ENTER&&(IN&&(e=>{if(!e.collapsed)return!1;const t=e.startContainer;if(Jo(t)){const n=/^[\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F\uA960-\uA97F\uD7B0-\uD7FF]$/,o=t.data.charAt(e.startOffset-1);return n.test(o)}return!1})(e.selection.getRng())?(e=>{t=I.some(e.selection.getBookmark()),e.undoManager.add()})(e):FN(e,n))})),e.on("keyup",(n=>{n.keyCode===ef.ENTER&&t.each((()=>((e,n)=>{e.undoManager.undo(),t.fold(E,(t=>e.selection.moveToBookmark(t))),FN(e,n),t=I.none()})(e,n)))}))})(e),(e=>{e.on("keydown",(t=>{t.isDefaultPrevented()||((e,t)=>{zE([{keyCode:ef.SPACEBAR,action:FE(KN,e)},{keyCode:ef.SPACEBAR,action:FE(GN,e)}],t).each((n=>{t.preventDefault(),K_(e,"insertText",{data:" "}).isDefaultPrevented()||(n(),W_(e,"insertText",{data:" "}))}))})(e,t)}))})(e),(e=>{e.on("input",(t=>{t.isComposing||(e=>{const t=yn(e.getBody());e.selection.isCollapsed()&&Vp(t,Li.fromRangeStart(e.selection.getRng())).each((t=>{e.selection.setRng(t.toRange())}))})(e)}))})(e),(e=>{e.on("keydown",(t=>{t.isDefaultPrevented()||((e,t)=>{UE([...YN(e)],t).each((e=>{t.preventDefault()}))})(e,t)}))})(e),((e,t)=>{e.on("keydown",(n=>{n.isDefaultPrevented()||((e,t,n)=>{const o=At.os.isMacOS()||At.os.isiOS();UE([{keyCode:ef.END,action:FE(TE,e,!0)},{keyCode:ef.HOME,action:FE(TE,e,!1)},...o?[]:[{keyCode:ef.HOME,action:FE(BE,e,!1),ctrlKey:!0,shiftKey:!0},{keyCode:ef.END,action:FE(BE,e,!0),ctrlKey:!0,shiftKey:!0}],{keyCode:ef.END,action:FE($E,e,!0)},{keyCode:ef.HOME,action:FE($E,e,!1)},{keyCode:ef.END,action:FE($k,e,!0,t)},{keyCode:ef.HOME,action:FE($k,e,!1,t)}],n).each((e=>{n.preventDefault()}))})(e,t,n)}))})(e,t),((e,t)=>{if(UN.os.isMacOS())return;const n=Da(!1);e.on("keydown",(t=>{jN(t)&&HN(n,e,!0)})),e.on("keyup",(o=>{o.isDefaultPrevented()||((e,t,n)=>{UE([{keyCode:ef.PAGE_UP,action:FE($k,e,!1,t)},{keyCode:ef.PAGE_DOWN,action:FE($k,e,!0,t)}],n)})(e,t,o),jN(o)&&n.get()&&(HN(n,e,!1),e.nodeChanged())}))})(e,t),t}};class QN{constructor(e){let t;this.lastPath=[],this.editor=e;const n=this;"onselectionchange"in e.getDoc()||e.on("NodeChange click mouseup keyup focus",(n=>{const o=e.selection.getRng(),r={startContainer:o.startContainer,startOffset:o.startOffset,endContainer:o.endContainer,endOffset:o.endOffset};
vendor: 15,807 bytes, line 5168
5168"nodechange"!==n.type&&kf(r,t)||e.dispatch("SelectionChange"),t=r})),e.on("contextmenu",(()=>{e.dispatch("SelectionChange")})),e.on("SelectionChange",(()=>{const t=e.selection.getStart(!0);t&&tm(e)&&!n.isSameElementPath(t)&&e.dom.isChildOf(t,e.getBody())&&e.nodeChanged({selectionChange:!0})})),e.on("mouseup",(t=>{!t.isDefaultPrevented()&&tm(e)&&("IMG"===e.selection.getNode().nodeName?mg.setEditorTimeout(e,(()=>{e.nodeChanged()})):e.nodeChanged())}))}nodeChanged(e={}){const t=this.editor.selection;let n;if(this.editor.initialized&&t&&!wd(this.editor)&&!this.editor.mode.isReadOnly()){const o=this.editor.getBody();n=t.getStart(!0)||o,n.ownerDocument===this.editor.getDoc()&&this.editor.dom.isChildOf(n,o)||(n=o);const r=[];this.editor.dom.getParent(n,(e=>e===o||(r.push(e),!1))),this.editor.dispatch("NodeChange",{...e,element:n,parents:r})}}isSameElementPath(e){let t;const n=this.editor,o=oe(n.dom.getParents(e,M,n.getBody()));if(o.length===this.lastPath.length){for(t=o.length;t>=0&&o[t]===this.lastPath[t];t--);if(-1===t)return this.lastPath=o,!0}return this.lastPath=o,!1}}const JN=ti("image"),ZN=ti("event"),eR=e=>t=>{t[ZN]=e},tR=eR(0),nR=eR(2),oR=eR(1),rR=(0,e=>{const t=e;return I.from(t[ZN]).exists((e=>0===e))});const sR=ti("mode"),aR=e=>t=>{t[sR]=e},iR=(e,t)=>aR(t)(e),lR=aR(0),dR=aR(2),cR=aR(1),uR=e=>t=>{const n=t;return I.from(n[sR]).exists((t=>t===e))},mR=uR(0),fR=uR(1),gR=["none","copy","link","move"],pR=["none","copy","copyLink","copyMove","link","linkMove","move","all","uninitialized"],hR=()=>{const e=new window.DataTransfer;let t="move",n="all";const o={get dropEffect(){return t},set dropEffect(e){H(gR,e)&&(t=e)},get effectAllowed(){return n},set effectAllowed(e){rR(o)&&H(pR,e)&&(n=e)},get items(){return((e,t)=>({...t,get length(){return t.length},add:(n,o)=>{if(mR(e)){if(!m(n))return t.add(n);if(!v(o))return t.add(n,o)}return null},remove:n=>{mR(e)&&t.remove(n)},clear:()=>{mR(e)&&t.clear()}}))(o,e.items)},get files(){return fR(o)?Object.freeze({length:0,item:e=>null}):e.files},get types(){return e.types},setDragImage:(t,n,r)=>{var s;mR(o)&&(s={image:t,x:n,y:r},o[JN]=s,e.setDragImage(t,n,r))},getData:t=>fR(o)?"":e.getData(t),setData:(t,n)=>{mR(o)&&e.setData(t,n)},clearData:t=>{mR(o)&&e.clearData(t)}};return lR(o),o},bR=(e,t)=>e.setData("text/html",t),vR="x-tinymce/html",yR=N(vR),CR="\x3c!-- "+vR+" --\x3e",wR=e=>CR+e,xR=e=>-1!==e.indexOf(CR),kR="%MCEPASTEBIN%",ER=e=>e.dom.get("mcepastebin"),SR=e=>C(e)&&"mcepastebin"===e.id,_R=e=>e===kR,NR=(e,t)=>(Dt.each(t,(t=>{e=u(t,RegExp)?e.replace(t,""):e.replace(t[0],t[1])})),e),RR=e=>NR(e,[/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/<!--StartFragment-->|<!--EndFragment-->/g,[/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g,(e,t,n)=>t||n?pr:" "],/<br class="Apple-interchange-newline">/g,/<br>$/i]),AR=(e,t)=>({content:e,cancelled:t}),OR=(e,t)=>(e.insertContent(t,{merge:qd(e),paste:!0}),!0),TR=e=>/^https?:\/\/[\w\-\/+=.,!;:&%@^~(){}?#]+$/i.test(e),BR=(e,t,n)=>!(e.selection.isCollapsed()||!TR(t))&&((e,t,n)=>(e.undoManager.extra((()=>{n(e,t)}),(()=>{e.execCommand("mceInsertLink",!1,t)})),!0))(e,t,n),DR=(e,t,n)=>!!((e,t)=>TR(t)&&$(sc(e),(e=>$e(t.toLowerCase(),`.${e.toLowerCase()}`))))(e,t)&&((e,t,n)=>(e.undoManager.extra((()=>{n(e,t)}),(()=>{e.insertContent('<img src="'+t+'">')})),!0))(e,t,n),PR=(e=>{let t=0;return()=>"mceclip"+t++})(),LR=e=>{const t=hR();return bR(t,e),dR(t),t},MR=(e,t,n,o,r)=>{const s=((e,t,n)=>((e,t,n)=>{const o=((e,t,n)=>e.dispatch("PastePreProcess",{content:t,internal:n}))(e,t,n),r=((e,t)=>{const n=tC({sanitize:oc(e)},e.schema);n.addNodeFilter("meta",(e=>{Dt.each(e,(e=>{e.remove()}))}));const o=n.parse(t,{forced_root_block:!1,isRootContent:!0});return Gg({validate:!0},e.schema).serialize(o)})(e,o.content);return e.hasEventListeners("PastePostProcess")&&!o.isDefaultPrevented()?((e,t,n)=>{const o=e.dom.create("div",{style:"display:none"},t),r=((e,t,n)=>e.dispatch("PastePostProcess",{node:t,internal:n}))(e,o,n);return AR(r.node.innerHTML,r.isDefaultPrevented())})(e,r,n):AR(r,o.isDefaultPrevented())})(e,t,n))(e,t,n);if(!s.cancelled){const t=s.content,n=()=>((e,t,n)=>{n||!Wd(e)?OR(e,t):((e,t)=>{Dt.each([BR,DR,OR],(n=>!n(e,t,OR)))})(e,t)})(e,t,o);r?K_(e,"insertFromPaste",{dataTransfer:LR(t)}).isDefaultPrevented()||(n(),W_(e,"insertFromPaste")):n()}},IR=(e,t,n,o)=>{const r=n||xR(t);MR(e,(e=>e.replace(CR,""))(t),r,!1,o)},FR=(e,t,n)=>{const o=e.dom.encode(t).replace(/\r\n/g,"\n"),r=((e,t,n)=>{const o=e.split(/\n\n/),r=((e,t)=>{let n="<"+e;const o=Ce(t,((e,t)=>t+'="'+Zs.encodeAllRaw(e)+'"'));return o.length&&(n+=" "+o.join(" ")),n+">"})(t,n),s="</"+t+">",a=V(o,(e=>e.split(/\n/).join("<br />")));return 1===a.length?a[0]:V(a,(e=>r+e+s)).join("")})(ms(o,Gd(e)),Nl(e),Rl(e));MR(e,r,!1,!0,n)},UR=e=>{const t={};if(e&&e.types)for(let n=0;n<e.types.length;n++){const o=e.types[n];try{t[o]=e.getData(o)}catch(e){t[o]=""}}return t},zR=(e,t)=>t in e&&e[t].length>0,jR=e=>zR(e,"text/html")||zR(e,"text/plain"),HR=(e,t,n)=>{const o="paste"===t.type?t.clipboardData:t.dataTransfer;var r;if(Ud(e)&&o){const s=((e,t)=>{const n=t.items?te(ce(t.items),(e=>"file"===e.kind?[e.getAsFile()]:[])):[],o=t.files?ce(t.files):[];return G(n.length>0?n:o,(e=>{const t=sc(e);return e=>He(e.type,"image/")&&$(t,(t=>(e=>{const t=e.toLowerCase(),n={jpg:"jpeg",jpe:"jpeg",jfi:"jpeg",jif:"jpeg",jfif:"jpeg",pjpeg:"jpeg",pjp:"jpeg",svg:"svg+xml"};return Dt.hasOwn(n,t)?"image/"+n[t]:"image/"+t})(t)===e.type))})(e))})(e,o);if(s.length>0)return t.preventDefault(),(r=s,Promise.all(V(r,(e=>Bv(e).then((t=>({file:e,uri:t}))))))).then((t=>{n&&e.selection.setRng(n),q(t,(t=>{((e,t)=>{Ov(t.uri).each((({data:n,type:o,base64Encoded:r})=>{const s=r?n:btoa(n),a=t.file,i=e.editorUpload.blobCache,l=i.getByData(s,o),d=null!=l?l:((e,t,n,o)=>{const r=PR(),s=Ll(e)&&C(n.name),a=s?((e,t)=>{const n=t.match(/([\s\S]+?)(?:\.[a-z0-9.]+)$/i);return C(n)?e.dom.encode(n[1]):void 0})(e,n.name):r,i=s?n.name:void 0,l=t.create(r,n,o,a,i);return t.add(l),l})(e,i,a,s);IR(e,`<img src="${d.blobUri()}">`,!1,!0)}))})(e,t)}))})),!0}return!1},$R=(e,t,n,o,r)=>{let s=RR(n);const a=zR(t,yR())||xR(n),i=!a&&(e=>!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(e))(s),l=TR(s);(_R(s)||!s.length||i&&!l)&&(o=!0),(o||l)&&(s=zR(t,"text/plain")&&i?t["text/plain"]:(e=>{const t=ca(),n=tC({},t);let o="";const r=t.getVoidElements(),s=Dt.makeMap("script noscript style textarea video audio iframe object"," "),a=t.getBlockElements(),i=e=>{const n=e.name,l=e;if("br"!==n){if("wbr"!==n)if(r[n]&&(o+=" "),s[n])o+=" ";else{if(3===e.type&&(o+=e.value),!(e.name in t.getVoidElements())){let t=e.firstChild;if(t)do{i(t)}while(t=t.next)}a[n]&&l.next&&(o+="\n","p"===n&&(o+="\n"))}}else o+="\n"};return e=NR(e,[/<!\[[^\]]+\]>/g]),i(n.parse(e)),o})(s)),_R(s)||(o?FR(e,s,r):IR(e,s,a,r))},VR=(e,t,n)=>{((e,t,n)=>{let o;e.on("keydown",(e=>{(e=>ef.metaKeyPressed(e)&&86===e.keyCode||e.shiftKey&&45===e.keyCode)(e)&&!e.isDefaultPrevented()&&(o=e.shiftKey&&86===e.keyCode)})),e.on("paste",(r=>{if(r.isDefaultPrevented()||(e=>{var t,n;return At.os.isAndroid()&&0===(null===(n=null===(t=e.clipboardData)||void 0===t?void 0:t.items)||void 0===n?void 0:n.length)})(r))return;const s="text"===n.get()||o;o=!1;const a=UR(r.clipboardData);!jR(a)&&HR(e,r,t.getLastRng()||e.selection.getRng())||(zR(a,"text/html")?(r.preventDefault(),$R(e,a,a["text/html"],s,!0)):zR(a,"text/plain")&&zR(a,"text/uri-list")?(r.preventDefault(),$R(e,a,a["text/plain"],s,!0)):(t.create(),mg.setEditorTimeout(e,(()=>{const n=t.getHtml();t.remove(),$R(e,a,n,s,!1)}),0)))}))})(e,t,n),(e=>{const t=e=>He(e,"webkit-fake-url"),n=e=>He(e,"data:");e.parser.addNodeFilter("img",((o,r,s)=>{if(!Ud(e)&&(e=>{var t;return!0===(null===(t=e.data)||void 0===t?void 0:t.paste)})(s))for(const r of o){const o=r.attr("src");m(o)&&!r.attr("data-mce-object")&&o!==At.transparentSrc&&(t(o)||!Yd(e)&&n(o))&&r.remove()}}))})(e)},qR=(e,t,n,o)=>{((e,t,n)=>{if(!e)return!1;try{return e.clearData(),e.setData("text/html",t),e.setData("text/plain",n),e.setData(yR(),t),!0}catch(e){return!1}})(e.clipboardData,t.html,t.text)?(e.preventDefault(),o()):n(t.html,o)},WR=e=>(t,n)=>{const{dom:o,selection:r}=e,s=o.create("div",{contenteditable:"false","data-mce-bogus":"all"}),a=o.create("div",{contenteditable:"true"},t);o.setStyles(s,{position:"fixed",top:"0",left:"-3000px",width:"1000px",overflow:"hidden"}),s.appendChild(a),o.add(e.getBody(),s);const i=r.getRng();a.focus();const l=o.createRng();l.selectNodeContents(a),r.setRng(l),mg.setEditorTimeout(e,(()=>{r.setRng(i),o.remove(s),n()}),0)},KR=e=>({html:wR(e.selection.getContent({contextual:!0})),text:e.selection.getContent({format:"text"})}),GR=e=>!e.selection.isCollapsed()||(e=>!!e.dom.getParent(e.selection.getStart(),"td[data-mce-selected],th[data-mce-selected]",e.getBody()))(e),YR=(e,t)=>{var n,o;return Df.getCaretRangeFromPoint(null!==(n=t.clientX)&&void 0!==n?n:0,null!==(o=t.clientY)&&void 0!==o?o:0,e.getDoc())},XR=(e,t)=>{e.focus(),t&&e.selection.setRng(t)},QR=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/gi,JR=e=>Dt.trim(e).replace(QR,Wu).toLowerCase(),ZR=(e,t,n)=>{const o=$d(e);if(n||"all"===o||!Vd(e))return t;const r=o?o.split(/[, ]/):[];if(r&&"none"!==o){const n=e.dom,o=e.selection.getNode();t=t.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,((e,t,s,a)=>{const i=n.parseStyle(n.decode(s)),l={};for(let e=0;e<r.length;e++){const t=i[r[e]];let s=t,a=n.getStyle(o,r[e],!0);/color/.test(r[e])&&(s=JR(s),a=JR(a)),a!==s&&(l[r[e]]=t)}const d=n.serializeStyle(l,"span");return d?t+' style="'+d+'"'+a:t+a}))}else t=t.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return t=t.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,((e,t,n,o)=>t+' style="'+n+'"'+o)),t},eA=e=>{const t=Da(!1),n=Da(Kd(e)?"text":"html"),o=(e=>{const t=Da(null);return{create:()=>((e,t)=>{const{dom:n,selection:o}=e,r=e.getBody();t.set(o.getRng());const s=n.add(e.getBody(),"div",{id:"mcepastebin",class:"mce-pastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0"},kR);At.browser.isFirefox()&&n.setStyle(s,"left","rtl"===n.getStyle(r,"direction",!0)?65535:-65535),n.bind(s,"beforedeactivate focusin focusout",(e=>{e.stopPropagation()})),s.focus(),o.select(s,!0)})(e,t),remove:()=>((e,t)=>{const n=e.dom;if(ER(e)){let o;const r=t.get();for(;o=ER(e);)n.remove(o),n.unbind(o);r&&e.selection.setRng(r)}t.set(null)})(e,t),getEl:()=>ER(e),getHtml:()=>(e=>{const t=e.dom,n=(e,n)=>{e.appendChild(n),t.remove(n,!0)},[o,...r]=G(e.getBody().childNodes,SR);q(r,(e=>{n(o,e)}));const s=t.select("div[id=mcepastebin]",o);for(let e=s.length-1;e>=0;e--){const r=t.create("div");o.insertBefore(r,s[e]),n(r,s[e])}return o?o.innerHTML:""})(e),getLastRng:t.get}})(e);(e=>{(At.browser.isChromium()||At.browser.isSafari())&&((e,t)=>{e.on("PastePreProcess",(n=>{n.content=t(e,n.content,n.internal)}))})(e,ZR)})(e),((e,t)=>{e.addCommand("mceTogglePlainTextPaste",(()=>{((e,t)=>{"text"===t.get()?(t.set("html"),Zm(e,!1)):(t.set("text"),Zm(e,!0)),e.focus()})(e,t)})),e.addCommand("mceInsertClipboardContent",((t,n)=>{n.html&&IR(e,n.html,n.internal,!1),n.text&&FR(e,n.text,!1)}))})(e,n),(e=>{const t=t=>n=>{t(e,n)},n=zd(e);w(n)&&e.on("PastePreProcess",t(n));const o=jd(e);w(o)&&e.on("PastePostProcess",t(o))})(e),e.on("PreInit",(()=>{(e=>{e.on("cut",(e=>t=>{!t.isDefaultPrevented()&&GR(e)&&qR(t,KR(e),WR(e),(()=>{if(At.browser.isChromium()||At.browser.isFirefox()){const t=e.selection.getRng();mg.setEditorTimeout(e,(()=>{e.selection.setRng(t),e.execCommand("Delete")}),0)}else e.execCommand("Delete")}))})(e)),e.on("copy",(e=>t=>{!t.isDefaultPrevented()&&GR(e)&&qR(t,KR(e),WR(e),E)})(e))})(e),((e,t)=>{Fd(e)&&e.on("dragend dragover draggesture dragdrop drop drag",(e=>{e.preventDefault(),e.stopPropagation()})),Ud(e)||e.on("drop",(e=>{const t=e.dataTransfer;t&&(e=>$(e.files,(e=>/^image\//.test(e.type))))(t)&&e.preventDefault()})),e.on("drop",(n=>{if(n.isDefaultPrevented())return;const o=YR(e,n);if(y(o))return;const r=UR(n.dataTransfer),s=zR(r,yR());if((!jR(r)||(e=>{const t=e["text/plain"];return!!t&&0===t.indexOf("file://")})(r))&&HR(e,n,o))return;const a=r[yR()],i=a||r["text/html"]||r["text/plain"],l=((e,t,n,o)=>{const r=e.getParent(n,(e=>As(t,e)));if(!h(e.getParent(n,"summary")))return!0;if(r&&ke(o,"text/html")){const e=(new DOMParser).parseFromString(o["text/html"],"text/html").body;return!h(e.querySelector(r.nodeName.toLowerCase()))}return!1})(e.dom,e.schema,o.startContainer,r),d=t.get();d&&!l||i&&(n.preventDefault(),mg.setEditorTimeout(e,(()=>{e.undoManager.transact((()=>{(a||d&&l)&&e.execCommand("Delete"),XR(e,o);const t=RR(i);r["text/html"]?IR(e,t,s,!0):FR(e,t,!0)}))})))})),e.on("dragstart",(e=>{t.set(!0)})),e.on("dragover dragend",(n=>{Ud(e)&&!t.get()&&(n.preventDefault(),XR(e,YR(e,n))),"dragend"===n.type&&t.set(!1)})),(e=>{e.on("input",(t=>{const n=e=>h(e.querySelector("summary"));if("deleteByDrag"===t.inputType){const t=G(e.dom.select("details"),n);q(t,(t=>{rr(t.firstChild)&&t.firstChild.remove();const n=e.dom.create("summary");n.appendChild(Dr().dom),t.prepend(n)}))}}))})(e)})(e,t),VR(e,o,n)}))},tA=rr,nA=Jo,oA=e=>ir(e.dom),rA=e=>t=>En(yn(e),t),sA=(e,t)=>Jn(yn(e),oA,rA(t)),aA=(e,t,n)=>{const o=new zo(e,t),r=n?o.next.bind(o):o.prev.bind(o);let s=e;for(let t=n?e:r();t&&!tA(t);t=r())ss(t)&&(s=t);return s},iA=e=>{const t=((e,t)=>{const n=Li.fromRangeStart(e).getNode(),o=((e,t)=>Jn(yn(e),(e=>(e=>ar(e.dom))(e)||xr(e)),rA(t)).getOr(yn(t)).dom)(n,t),r=aA(n,o,!1),s=aA(n,o,!0),a=document.createRange();return sA(r,o).fold((()=>{nA(r)?a.setStart(r,0):a.setStartBefore(r)}),(e=>a.setStartBefore(e.dom))),sA(s,o).fold((()=>{nA(s)?a.setEnd(s,s.data.length):a.setEndAfter(s)}),(e=>a.setEndAfter(e.dom))),a})(e.selection.getRng(),e.getBody());e.selection.setRng(ob(t))};var lA;!function(e){e.Before="before",e.After="after"}(lA||(lA={}));const dA=(e,t)=>Math.abs(e.left-t),cA=(e,t)=>Math.abs(e.right-t),uA=(e,t)=>(e=>X(e,((e,t)=>e.fold((()=>I.some(t)),(e=>{const n=Math.min(t.left,e.left),o=Math.min(t.top,e.top),r=Math.max(t.right,e.right),s=Math.max(t.bottom,e.bottom);return I.some({top:o,right:r,bottom:s,left:n,width:r-n,height:s-o})}))),I.none()))(G(e,(e=>{return(n=t)>=(o=e).top&&n<=o.bottom;var n,o}))).fold((()=>[[],e]),(t=>{const{pass:n,fail:o}=K(e,(e=>((e,t)=>{const n=((e,t)=>Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top)))(e,t)/Math.min(e.height,t.height);return((e,t)=>e.top<t.bottom&&e.bottom>t.top)(e,t)&&n>.5})(e,t)));return[n,o]})),mA=(e,t,n)=>t>e.left&&t<e.right?0:Math.min(Math.abs(e.left-t),Math.abs(e.right-t)),fA=(e,t,n)=>{const o=e=>ss(e.node)?I.some(e):$o(e.node)?fA(ce(e.node.childNodes),t,n):I.none(),r=(e,r)=>{const s=ae(e,((e,o)=>r(e,t,n)-r(o,t,n)));return((e,r)=>{if(e.length>=2){const s=o(e[0]).getOr(e[0]),a=o(e[1]).getOr(e[1]);if(Math.abs(r(s,t,n)-r(a,t,n))<2){if(Jo(s.node))return I.some(s);if(Jo(a.node))return I.some(a)}}return I.none()})(s,r).orThunk((()=>ue(s,o)))},[s,a]=uA(Ck(e),n),{pass:i,fail:l}=K(a,(e=>e.top<n));return r(s,mA).orThunk((()=>r(l,fi))).orThunk((()=>r(i,fi)))},gA=(e,t,n)=>((e,t,n)=>{const o=yn(e),r=Nn(o),s=Cn(r,t,n).filter((e=>Sn(o,e))).getOr(o);return((e,t,n,o)=>{const r=(t,s)=>{const a=G(t.dom.childNodes,T((e=>$o(e)&&e.classList.contains("mce-drag-container"))));return s.fold((()=>fA(a,n,o)),(e=>{const t=G(a,(t=>t!==e.dom));return fA(t,n,o)})).orThunk((()=>(En(t,e)?I.none():On(t)).bind((e=>r(e,I.some(t))))))};return r(t,I.none())})(o,s,t,n)})(e,t,n).filter((e=>Ec(e.node))).map((e=>((e,t)=>({node:e.node,position:dA(e,t)<cA(e,t)?lA.Before:lA.After}))(e,t))),pA=e=>{var t,n;const o=e.getBoundingClientRect(),r=e.ownerDocument,s=r.documentElement,a=r.defaultView;return{top:o.top+(null!==(t=null==a?void 0:a.scrollY)&&void 0!==t?t:0)-s.clientTop,left:o.left+(null!==(n=null==a?void 0:a.scrollX)&&void 0!==n?n:0)-s.
vendor: 2,542 bytes, line 5168
5168clientLeft}},hA=e=>({target:e,srcElement:e}),bA=(e,t,n,o)=>{const r=((e,t)=>{const n=(e=>{const t=hR(),n=(e=>{const t=e;return I.from(t[sR])})(e);return dR(e),tR(t),t.dropEffect=e.dropEffect,t.effectAllowed=e.effectAllowed,(e=>{const t=e;return I.from(t[JN])})(e).each((e=>t.setDragImage(e.image,e.x,e.y))),q(e.types,(n=>{"Files"!==n&&t.setData(n,e.getData(n))})),q(e.files,(e=>t.items.add(e))),(e=>{const t=e;return I.from(t[ZN])})(e).each((e=>{((e,t)=>{eR(t)(e)})(t,e)})),n.each((n=>{iR(e,n),iR(t,n)})),t})(e);return"dragstart"===t?(tR(n),lR(n)):"drop"===t?(nR(n),dR(n)):(oR(n),cR(n)),n})(n,e);return v(o)?((e,t,n)=>{const o=B("Function not supported on simulated event.");return{bubbles:!0,cancelBubble:!1,cancelable:!0,composed:!1,currentTarget:null,defaultPrevented:!1,eventPhase:0,isTrusted:!0,returnValue:!1,timeStamp:0,type:e,composedPath:o,initEvent:o,preventDefault:E,stopImmediatePropagation:E,stopPropagation:E,AT_TARGET:window.Event.AT_TARGET,BUBBLING_PHASE:window.Event.BUBBLING_PHASE,CAPTURING_PHASE:window.Event.CAPTURING_PHASE,NONE:window.Event.NONE,altKey:!1,button:0,buttons:0,clientX:0,clientY:0,ctrlKey:!1,metaKey:!1,movementX:0,movementY:0,offsetX:0,offsetY:0,pageX:0,pageY:0,relatedTarget:null,screenX:0,screenY:0,shiftKey:!1,x:0,y:0,detail:0,view:null,which:0,initUIEvent:o,initMouseEvent:o,getModifierState:o,dataTransfer:n,...hA(t)}})(e,t,r):((e,t,n,o)=>({...t,dataTransfer:o,type:e,...hA(n)}))(e,o,t,r)},vA=ir,yA=((...e)=>t=>{for(let n=0;n<e.length;n++)if(e[n](t))return!0;return!1})(vA,ar),CA=(e,t,n,o)=>{const r=e.dom,s=t.cloneNode(!0);r.setStyles(s,{width:n,height:o}),r.setAttrib(s,"data-mce-selected",null);const a=r.create("div",{class:"mce-drag-container","data-mce-bogus":"all",unselectable:"on",contenteditable:"false"});return r.setStyles(a,{position:"absolute",opacity:.5,overflow:"hidden",border:0,padding:0,margin:0,width:n,height:o}),r.setStyles(s,{margin:0,boxSizing:"border-box"}),a.appendChild(s),a},wA=(e,t)=>n=>()=>{const o="left"===e?n.scrollX:n.scrollY;n.scroll({[e]:o+t,behavior:"smooth"})},xA=wA("left",-32),kA=wA("left",32),EA=wA("top",-32),SA=wA("top",32),_A=e=>{e&&e.parentNode&&e.parentNode.removeChild(e)},NA=(e,t,n,o,r)=>{"dragstart"===t&&bR(o,e.dom.getOuterHTML(n));const s=bA(t,n,o,r);return e.dispatch(t,s)},RA=(e,t)=>{const n=ja(((e,n)=>((e,t,n)=>{e._selectionOverrides.hideFakeCaret(),gA(e.getBody(),t,n).fold((()=>e.selection.placeCaretAt(t,n)),(o=>{const r=e._selectionOverrides.showCaret(1,o.node,o.position===lA.Before,!1);r?e.selection.setRng(r):e.selection.placeCaretAt(t,n)}
vendor: 7,588 bytes, line 5168
5168))})(t,e,n)),0);t.on("remove",n.cancel);const o=e;return r=>e.on((e=>{const s=Math.max(Math.abs(r.screenX-e.screenX),Math.abs(r.screenY-e.screenY));if(!e.dragging&&s>10){const n=NA(t,"dragstart",e.element,e.dataTransfer,r);if(C(n.dataTransfer)&&(e.dataTransfer=n.dataTransfer),n.isDefaultPrevented())return;e.dragging=!0,t.focus()}if(e.dragging){const s=r.currentTarget===t.getDoc().documentElement,l=((e,t)=>({pageX:t.pageX-e.relX,pageY:t.pageY+5}))(e,((e,t)=>{return n=(e=>e.inline?pA(e.getBody()):{left:0,top:0})(e),o=(e=>{const t=e.getBody();return e.inline?{left:t.scrollLeft,top:t.scrollTop}:{left:0,top:0}})(e),r=((e,t)=>{if(t.target.ownerDocument!==e.getDoc()){const n=pA(e.getContentAreaContainer()),o=(e=>{const t=e.getBody(),n=e.getDoc().documentElement,o={left:t.scrollLeft,top:t.scrollTop},r={left:t.scrollLeft||n.scrollLeft,top:t.scrollTop||n.scrollTop};return e.inline?o:r})(e);return{left:t.pageX-n.left+o.left,top:t.pageY-n.top+o.top}}return{left:t.pageX,top:t.pageY}})(e,t),{pageX:r.left-n.left+o.left,pageY:r.top-n.top+o.top};var n,o,r})(t,r));a=e.ghost,i=t.getBody(),a.parentNode!==i&&i.appendChild(a),((e,t,n,o,r,s,a,i,l,d,c,u)=>{let m=0,f=0;e.style.left=t.pageX+"px",e.style.top=t.pageY+"px",t.pageX+n>r&&(m=t.pageX+n-r),t.pageY+o>s&&(f=t.pageY+o-s),e.style.width=n-m+"px",e.style.height=o-f+"px";const g=l.clientHeight,p=l.clientWidth,h=a+l.getBoundingClientRect().top,b=i+l.getBoundingClientRect().left;c.on((e=>{e.intervalId.clear(),e.dragging&&u&&(a+8>=g?e.intervalId.set(SA(d)):a-8<=0?e.intervalId.set(EA(d)):i+8>=p?e.intervalId.set(kA(d)):i-8<=0?e.intervalId.set(xA(d)):h+16>=window.innerHeight?e.intervalId.set(SA(window)):h-16<=0?e.intervalId.set(EA(window)):b+16>=window.innerWidth?e.intervalId.set(kA(window)):b-16<=0&&e.intervalId.set(xA(window)))}))})(e.ghost,l,e.width,e.height,e.maxX,e.maxY,r.clientY,r.clientX,t.getContentAreaContainer(),t.getWin(),o,s),n.throttle(r.clientX,r.clientY)}var a,i}))},AA=(e,t,n)=>{e.on((e=>{e.intervalId.clear(),e.dragging&&n.fold((()=>NA(t,"dragend",e.element,e.dataTransfer)),(n=>NA(t,"dragend",e.element,e.dataTransfer,n)))})),OA(e)},OA=e=>{e.on((e=>{e.intervalId.clear(),_A(e.ghost)})),e.clear()},TA=e=>{const t=za(),n=Oa.DOM,o=document,r=((e,t)=>n=>{if((e=>0===e.button)(n)){const o=J(t.dom.getParents(n.target),yA).getOr(null);if(C(o)&&((e,t,n)=>vA(n)&&n!==t&&e.isEditable(n.parentElement))(t.dom,t.getBody(),o)){const r=t.dom.getPos(o),s=t.getBody(),a=t.getDoc().documentElement;e.set({element:o,dataTransfer:hR(),dragging:!1,screenX:n.screenX,screenY:n.screenY,maxX:(t.inline?s.scrollWidth:a.offsetWidth)-2,maxY:(t.inline?s.scrollHeight:a.offsetHeight)-2,relX:n.pageX-r.x,relY:n.pageY-r.y,width:o.offsetWidth,height:o.offsetHeight,ghost:CA(t,o,o.offsetWidth,o.offsetHeight),intervalId:Ua(100)})}}})(t,e),s=RA(t,e),a=((e,t)=>n=>{e.on((e=>{var o;if(e.intervalId.clear(),e.dragging){if(((e,t,n)=>!y(t)&&t!==n&&!e.dom.isChildOf(t,n)&&e.dom.isEditable(t))(t,(e=>{const t=e.getSel();if(C(t)){const e=t.getRangeAt(0).startContainer;return Jo(e)?e.parentNode:e}return null})(t.selection),e.element)){const r=null!==(o=t.getDoc().elementFromPoint(n.clientX,n.clientY))&&void 0!==o?o:t.getBody();NA(t,"drop",r,e.dataTransfer,n).isDefaultPrevented()||t.undoManager.transact((()=>{((e,t)=>{const n=e.getParent(t.parentNode,e.isBlock);_A(t),n&&n!==e.getRoot()&&e.isEmpty(n)&&Pr(yn(n))})(t.dom,e.element),(e=>{const t=e.getData("text/html");return""===t?I.none():I.some(t)})(e.dataTransfer).each((e=>t.insertContent(e))),t._selectionOverrides.hideFakeCaret()}))}NA(t,"dragend",t.getBody(),e.dataTransfer,n)}})),OA(e)})(t,e),i=((e,t)=>n=>AA(e,t,I.some(n)))(t,e);e.on("mousedown",r),e.on("mousemove",s),e.on("mouseup",a),n.bind(o,"mousemove",s),n.bind(o,"mouseup",i),e.on("remove",(()=>{n.unbind(o,"mousemove",s),n.unbind(o,"mouseup",i)})),e.on("keydown",(n=>{n.keyCode===ef.ESC&&AA(t,e,I.none())}))},BA=ir,DA=(e,t)=>$h(e.getBody(),t),PA=e=>{const t=e.selection,n=e.dom,o=e.getBody(),r=wc(e,o,n.isBlock,(()=>xg(e))),s="sel-"+n.uniqueId(),a="data-mce-selected";let i;const l=e=>e!==o&&(BA(e)||cr(e))&&n.isChildOf(e,o)&&n.isEditable(e.parentNode),d=(n,o,s,a=!0)=>e.dispatch("ShowCaret",{target:o,direction:n,before:s}).isDefaultPrevented()?null:(a&&t.scrollIntoView(o,-1===n),r.show(s,o)),c=e=>$r(e)||Kr(e)||Gr(e),u=e=>c(e.startContainer)||c(e.endContainer),m=t=>{const o=e.schema.getVoidElements(),r=n.createRng(),s=t.startContainer,a=t.startOffset,i=t.endContainer,l=t.endOffset;return ke(o,s.nodeName.toLowerCase())?0===a?r.setStartBefore(s):r.setStartAfter(s):r.setStart(s,a),ke(o,i.nodeName.toLowerCase())?0===l?r.setEndBefore(i):r.setEndAfter(i):r.setEnd(i,l),r},f=(r,c)=>{if(!r)return null;if(r.collapsed){if(!u(r)){const e=c?1:-1,t=Gc(e,o,r),s=t.getNode(!c);if(C(s)){if(Ec(s))return d(e,s,!!c&&!t.isAtEnd(),!1);if(Hr(s)&&ir(s.nextSibling)){const e=n.createRng();return e.setStart(s,0),e.setEnd(s,0),e}}const a=t.getNode(c);if(C(a)){if(Ec(a))return d(e,a,!c&&!t.isAtEnd(),!1);if(Hr(a)&&ir(a.previousSibling)){const e=n.createRng();return e.setStart(a,1),e.setEnd(a,1),e}}}return null}let m=r.startContainer,f=r.startOffset;const g=r.endOffset;if(Jo(m)&&0===f&&BA(m.parentNode)&&(m=m.parentNode,f=n.nodeIndex(m),m=m.parentNode),!$o(m))return null;if(g===f+1&&m===r.endContainer){const o=m.childNodes[f];if(l(o))return(o=>{const r=o.cloneNode(!0),l=e.dispatch("ObjectSelected",{target:o,targetClone:r});if(l.isDefaultPrevented())return null;const d=((o,r)=>{const a=yn(e.getBody()),i=e.getDoc(),l=eo(a,"#"+s).getOrThunk((()=>{const e=hn('<div data-mce-bogus="all" class="mce-offscreen-selection"></div>',i);return Jt(e,"id",s),bo(a,e),e})),d=n.createRng();Co(l),yo(l,[vn(pr,i),yn(r),vn(pr,i)]),d.setStart(l.dom.firstChild,1),d.setEnd(l.dom.lastChild,0),io(l,{top:n.getPos(o,e.getBody()).y+"px"}),eg(l);const c=t.getSel();return c&&(c.removeAllRanges(),c.addRange(d)),d})(o,l.targetClone),c=yn(o);return q(Fo(yn(e.getBody()),`*[${a}]`),(e=>{En(c,e)||on(e,a)})),n.getAttrib(o,a)||o.setAttribute(a,"1"),i=o,p(),d})(o)}return null},g=()=>{i&&i.removeAttribute(a),eo(yn(e.getBody()),"#"+s).each(wo),i=null},p=()=>{r.hide()};return PC(e)||(e.on("click",(t=>{n.isEditable(t.target)||(t.preventDefault(),e.focus())})),e.on("blur NewBlock",g),e.on("ResizeWindow FullscreenStateChanged",r.reposition),e.on("tap",(t=>{const n=t.target,o=DA(e,n);BA(o)?(t.preventDefault(),dx(e,o).each(f)):l(n)&&dx(e,n).each(f)}),!0),e.on("mousedown",(r=>{const s=r.target;if(s!==o&&"HTML"!==s.nodeName&&!n.isChildOf(s,o))return;if(!((e,t,n)=>{const o=yn(e.getBody()),r=e.inline?o:yn(Nn(o).dom.documentElement),s=((e,t,n,o)=>{const r=(e=>e.dom.getBoundingClientRect())(t);return{x:n-(e?r.left+t.dom.clientLeft+fw(t):0),y:o-(e?r.top+t.dom.clientTop+mw(t):0)}})(e.inline,r,t,n);return((e,t,n)=>{const o=cw(e),r=uw(e);return t>=0&&n>=0&&t<=o&&n<=r})(r,s.x,s.y)})(e,r.clientX,r.clientY))return;g(),p();const a=DA(e,s);BA(a)?(r.preventDefault(),dx(e,a).each(f)):gA(o,r.clientX,r.clientY).each((n=>{var o;r.preventDefault(),(o=d(1,n.node,n.position===lA.Before,!1))&&t.setRng(o),$o(a)?a.focus():e.getBody().focus()}))})),e.on("keypress",(e=>{ef.modifierPressed(e)||BA(t.getNode())&&e.preventDefault()})),e.on("GetSelectionRange",(e=>{let t=e.range;if(i){if(!i.parentNode)return void(i=null);t=t.cloneRange(),t.selectNode(i),e.range=t}})),e.on("SetSelectionRange",(e=>{e.range=m(e.range);const t=f(e.range,e.forward);t&&(e.range=t)})),e.on("AfterSetSelectionRange",(e=>{const t=e.range,o=t.startContainer.parentElement;var r;u(t)||$o(r=o)&&"mcepastebin"===r.id||p(),(e=>C(e)&&n.hasClass(e,"mce-offscreen-selection"))(o)||g()})),(e=>{TA(e),Nd(e)&&(e=>{const t=t=>
vendor: 2,298 bytes, line 5168
5168{if(!t.isDefaultPrevented()){const n=t.dataTransfer;n&&(H(n.types,"Files")||n.files.length>0)&&(t.preventDefault(),"drop"===t.type&&yw(e,"Dropped file type is not supported"))}},n=n=>{hg(e,n.target)&&t(n)},o=()=>{const o=Oa.DOM,r=e.dom,s=document,a=e.inline?e.getBody():e.getDoc(),i=["drop","dragover"];q(i,(e=>{o.bind(s,e,n),r.bind(a,e,t)})),e.on("remove",(()=>{q(i,(e=>{o.unbind(s,e,n),r.unbind(a,e,t)}))}))};e.on("init",(()=>{mg.setEditorTimeout(e,o,0)}))})(e)})(e),(e=>{const t=ja((()=>{if(!e.removed&&e.getBody().contains(document.activeElement)){const t=e.selection.getRng();if(t.collapsed){const n=cx(e,t,!1);e.selection.setRng(n)}}}),0);e.on("focus",(()=>{t.throttle()})),e.on("blur",(()=>{t.cancel()}))})(e),(e=>{e.on("init",(()=>{e.on("focusin",(t=>{const n=t.target;if(cr(n)){const t=$h(e.getBody(),n),o=ir(t)?t:n;e.selection.getNode()!==o&&dx(e,o).each((t=>e.selection.setRng(t)))}}))}))})(e)),{showCaret:d,showBlockCaretContainer:e=>{e.hasAttribute("data-mce-caret")&&(Yr(e),t.scrollIntoView(e))},hideFakeCaret:p,destroy:()=>{r.destroy(),i=null}}},LA=(e,t)=>{let n=t;for(let t=e.previousSibling;Jo(t);t=t.previousSibling)n+=t.data.length;return n},MA=(e,t,n,o,r)=>{if(Jo(n)&&(o<0||o>n.data.length))return[];const s=r&&Jo(n)?[LA(n,o)]:[o];let a=n;for(;a!==t&&a.parentNode;)s.push(e.nodeIndex(a,r)),a=a.parentNode;return a===t?s.reverse():[]},IA=(e,t,n,o,r,s,a=!1)=>({start:MA(e,t,n,o,a),end:MA(e,t,r,s,a)}),FA=(e,t)=>{const n=t.slice(),o=n.pop();return x(o)?X(n,((e,t)=>e.bind((e=>I.from(e.childNodes[t])))),I.some(e)).bind((e=>Jo(e)&&(o<0||o>e.data.length)?I.none():I.some({node:e,offset:o}))):I.none()},UA=(e,t)=>FA(e,t.start).bind((({node:n,offset:o})=>FA(e,t.end).map((({node:e,offset:t})=>{const r=document.createRange();return r.setStart(n,o),r.setEnd(e,t),r})))),zA=(e,t,n)=>{if(t&&e.isEmpty(t)&&!n(t)){const o=t.parentNode;e.remove(t,Jo(t.firstChild)&&ds(t.firstChild.data)),zA(e,o,n)}},jA=(e,t,n,o=!0)=>{const r=t.startContainer.parentNode,s=t.endContainer.parentNode;t.deleteContents(),o&&!n(t.startContainer)&&(Jo(t.startContainer)&&0===t.startContainer.data.length&&e.remove(t.startContainer),Jo(t.endContainer)&&0===t.endContainer.data.length&&e.remove(t.endContainer),zA(e,r,n),r!==s&&zA(e,s,n))},HA=(e,t)=>I.from(e.dom.getParent(t.startContainer,e.dom.isBlock)),$A=(e,t,n
vendor: 21,388 bytes, line 5168
5168)=>{const o=e.dynamicPatternsLookup({text:n,block:t});return{...e,blockPatterns:cl(o).concat(e.blockPatterns),inlinePatterns:ul(o).concat(e.inlinePatterns)}},VA=(e,t,n,o)=>{const r=e.createRng();return r.setStart(t,0),r.setEnd(n,o),r.toString()},qA=(e,t,n)=>{((e,t,n)=>{if(Jo(e)&&0>=e.length)return I.some(mS(e,0));{const t=ai(fS);return I.from(t.forwards(e,0,gS(e),n)).map((e=>mS(e.container,0)))}})(t,0,t).each((o=>{const r=o.container;bS(r,n.start.length,t).each((n=>{const o=e.createRng();o.setStart(r,0),o.setEnd(n.container,n.offset),jA(e,o,(e=>e===t))}));const s=yn(r),a=vr(s);/^\s[^\s]/.test(a)&&((e,t)=>{br.set(e,t)})(s,a.slice(1))}))},WA=(e,t)=>e.create("span",{"data-mce-type":"bookmark",id:t}),KA=(e,t)=>{const n=e.createRng();return n.setStartAfter(t.start),n.setEndBefore(t.end),n},GA=(e,t,n)=>{const o=UA(e.getRoot(),n).getOrDie("Unable to resolve path range"),r=o.startContainer,s=o.endContainer,a=0===o.endOffset?s:s.splitText(o.endOffset),i=0===o.startOffset?r:r.splitText(o.startOffset),l=i.parentNode;return{prefix:t,end:a.parentNode.insertBefore(WA(e,t+"-end"),a),start:l.insertBefore(WA(e,t+"-start"),i)}},YA=(e,t,n)=>{zA(e,e.get(t.prefix+"-end"),n),zA(e,e.get(t.prefix+"-start"),n)},XA=e=>0===e.start.length,QA=(e,t,n,o)=>{const r=t.start;var s;return vS(e,o.container,o.offset,(s=r,(e,t)=>{const n=e.data.substring(0,t),o=n.lastIndexOf(s.charAt(s.length-1)),r=n.lastIndexOf(s);return-1!==r?r+s.length:-1!==o?o+1:-1}),n).bind((o=>{var s,a;const i=null!==(a=null===(s=n.textContent)||void 0===s?void 0:s.indexOf(r))&&void 0!==a?a:-1;if(-1!==i&&o.offset>=i+r.length){const t=e.createRng();return t.setStart(o.container,o.offset-r.length),t.setEnd(o.container,o.offset),I.some(t)}{const s=o.offset-r.length;return hS(o.container,s,n).map((t=>{const n=e.createRng();return n.setStart(t.container,t.offset),n.setEnd(o.container,o.offset),n})).filter((e=>e.toString()===r)).orThunk((()=>QA(e,t,n,mS(o.container,0))))}}))},JA=(e,t,n,o)=>{const r=e.dom,s=r.getRoot(),a=n.pattern,i=n.position.container,l=n.position.offset;return hS(i,l-n.pattern.end.length,t).bind((d=>{const c=IA(r,s,d.container,d.offset,i,l,o);if(XA(a))return I.some({matches:[{pattern:a,startRng:c,endRng:c}],position:d});{const i=ZA(e,n.remainingPatterns,d.container,d.offset,t,o),l=i.getOr({matches:[],position:d}),u=l.position,m=((e,t,n,o,r,s=!1)=>{if(0===t.start.length&&!s){const t=e.createRng();return t.setStart(n,o),t.setEnd(n,o),I.some(t)}return pS(n,o,r).bind((n=>QA(e,t,r,n).bind((e=>{var t;if(s){if(e.endContainer===n.container&&e.endOffset===n.offset)return I.none();if(0===n.offset&&(null===(t=e.endContainer.textContent)||void 0===t?void 0:t.length)===e.endOffset)return I.none()}return I.some(e)}))))})(r,a,u.container,u.offset,t,i.isNone());return m.map((e=>{const t=((e,t,n,o=!1)=>IA(e,t,n.startContainer,n.startOffset,n.endContainer,n.endOffset,o))(r,s,e,o);return{matches:l.matches.concat([{pattern:a,startRng:t,endRng:c}]),position:mS(e.startContainer,e.startOffset)}}))}}))},ZA=(e,t,n,o,r,s)=>{const a=e.dom;return pS(n,o,a.getRoot()).bind((i=>{const l=VA(a,r,n,o);for(let a=0;a<t.length;a++){const d=t[a];if(!$e(l,d.end))continue;const c=t.slice();c.splice(a,1);const u=JA(e,r,{pattern:d,remainingPatterns:c,position:i},s);if(u.isNone()&&o>0)return ZA(e,t,n,o-1,r,s);if(u.isSome())return u}return I.none()}))},eO=(e,t,n)=>{e.selection.setRng(n),"inline-format"===t.type?q(t.format,(t=>{e.formatter.apply(t)})):e.execCommand(t.cmd,!1,t.value)},tO=(e,t,n,o,r,s)=>{var a;return((e,t)=>{const n=ne(e,(e=>$(t,(t=>e.pattern.start===t.pattern.start&&e.pattern.end===t.pattern.end))));return e.length===t.length?n?e:t:e.length>t.length?e:t})(ZA(e,r.inlinePatterns,n,o,t,s).fold((()=>[]),(e=>e.matches)),ZA(e,(a=r.inlinePatterns,ae(a,((e,t)=>t.end.length-e.end.length))),n,o,t,s).fold((()=>[]),(e=>e.matches)))},nO=(e,t)=>{if(0===t.length)return;const n=e.dom,o=e.selection.getBookmark(),r=((e,t)=>{const n=ti("mce_textpattern"),o=Y(t,((t,o)=>{const r=GA(e,n+`_end${t.length}`,o.endRng);return t.concat([{...o,endMarker:r}])}),[]);return Y(o,((t,r)=>{const s=o.length-t.length-1,a=XA(r.pattern)?r.endMarker:GA(e,n+`_start${s}`,r.startRng);return t.concat([{...r,startMarker:a}])}),[])})(n,t);q(r,(t=>{const o=n.getParent(t.startMarker.start,n.isBlock),r=e=>e===o;XA(t.pattern)?((e,t,n,o)=>{const r=KA(e.dom,n);jA(e.dom,r,o),eO(e,t,r)})(e,t.pattern,t.endMarker,r):((e,t,n,o,r)=>{const s=e.dom,a=KA(s,o),i=KA(s,n);jA(s,i,r),jA(s,a,r);const l={prefix:n.prefix,start:n.end,end:o.start},d=KA(s,l);eO(e,t,d)})(e,t.pattern,t.startMarker,t.endMarker,r),YA(n,t.endMarker,r),YA(n,t.startMarker,r)})),e.selection.moveToBookmark(o)},oO=(e,t)=>{const n=e.selection.getRng();return HA(e,n).map((o=>{var r;const s=Math.max(0,n.startOffset),a=$A(t,o,null!==(r=o.textContent)&&void 0!==r?r:""),i=tO(e,o,n.startContainer,s,a,!0),l=((e,t,n,o)=>{var r;const s=e.dom,a=Nl(e);if(!s.is(t,a))return[];const i=null!==(r=t.textContent)&&void 0!==r?r:"";return((e,t)=>{const n=(e=>ae(e,((e,t)=>t.start.length-e.start.length)))(e),o=t.replace(pr," ");return J(n,(e=>0===t.indexOf(e.start)||0===o.indexOf(e.start)))})(n.blockPatterns,i).map((e=>Dt.trim(i).length===e.start.length?[]:[{pattern:e,range:IA(s,s.getRoot(),t,0,t,0,true)}])).getOr([])})(e,o,a);return(l.length>0||i.length>0)&&(e.undoManager.add(),e.undoManager.extra((()=>{e.execCommand("mceInsertNewLine")}),(()=>{e.insertContent(gr),nO(e,i),((e,t)=>{if(0===t.length)return;const n=e.selection.getBookmark();q(t,(t=>((e,t)=>{const n=e.dom,o=t.pattern,r=UA(n.getRoot(),t.range).getOrDie("Unable to resolve path range");return HA(e,r).each((t=>{"block-format"===o.type?((e,t)=>{const n=t.get(e);return p(n)&&le(n).exists((e=>ke(e,"block")))})(o.format,e.formatter)&&e.undoManager.transact((()=>{qA(e.dom,t,o),e.formatter.apply(o.format)})):"block-command"===o.type&&e.undoManager.transact((()=>{qA(e.dom,t,o),e.execCommand(o.cmd,!1,o.value)}))})),!0})(e,t))),e.selection.moveToBookmark(n)})(e,l);const t=e.selection.getRng(),n=pS(t.startContainer,t.startOffset,e.dom.getRoot());e.execCommand("mceInsertNewLine"),n.each((t=>{const n=t.container;n.data.charAt(t.offset-1)===gr&&(n.deleteData(t.offset-1,1),zA(e.dom,n.parentNode,(t=>t===e.dom.getRoot())))}))})),!0)})).getOr(!1)},rO=(e,t,n)=>{for(let o=0;o<e.length;o++)if(n(e[o],t))return!0;return!1},sO=e=>{const t=Dt.each,n=ef.BACKSPACE,o=ef.DELETE,r=e.dom,s=e.selection,a=e.parser,i=At.browser,l=i.isFirefox(),d=i.isChromium()||i.isSafari(),c=At.deviceType.isiPhone()||At.deviceType.isiPad(),u=At.os.isMacOS()||At.os.isiOS(),f=(t,n)=>{try{e.getDoc().execCommand(t,!1,String(n))}catch(e){}},g=e=>e.isDefaultPrevented(),p=()=>{e.shortcuts.add("meta+a",null,"SelectAll")},h=()=>{e.inline||r.bind(e.getDoc(),"mousedown mouseup",(t=>{let n;if(t.target===e.getDoc().documentElement)if(n=s.getRng(),e.getBody().focus(),"mousedown"===t.type){if($r(n.startContainer))return;s.placeCaretAt(t.clientX,t.clientY)}else s.setRng(n)}))},b=()=>{Range.prototype.getClientRects||e.on("mousedown",(t=>{if(!g(t)&&"HTML"===t.target.nodeName){const t=e.getBody();t.blur(),mg.setEditorTimeout(e,(()=>{t.focus()}))}}))},v=()=>{const t=Od(e);e.on("click",(n=>{const o=n.target;/^(IMG|HR)$/.test(o.nodeName)&&r.isEditable(o.parentNode)&&(n.preventDefault(),e.selection.select(o),e.nodeChanged()),"A"===o.nodeName&&r.hasClass(o,t)&&0===o.childNodes.length&&r.isEditable(o.parentNode)&&(n.preventDefault(),s.select(o))}))},y=()=>{e.on("keydown",(e=>{if(!g(e)&&e.keyCode===n&&s.isCollapsed()&&0===s.getRng().startOffset){const t=s.getNode().previousSibling;if(t&&t.nodeName&&"table"===t.nodeName.toLowerCase())return e.preventDefault(),!1}return!0}))},C=()=>{xd(e)||e.on("BeforeExecCommand mousedown",(()=>{f("StyleWithCSS",!1),f("enableInlineTableEditing",!1),ed(e)||f("enableObjectResizing",!1)}))},w=()=>{e.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")},x=()=>{e.inline||e.on("keydown",(()=>{document.activeElement===document.body&&e.getWin().focus()}))},k=()=>{e.inline||(e.contentStyles.push("body {min-height: 150px}"),e.on("click",(t=>{let n;"HTML"===t.target.nodeName&&(n=e.selection.getRng(),e.getBody().focus(),e.selection.setRng(n),e.selection.normalize(),e.nodeChanged())})))},S=()=>{u&&e.on("keydown",(t=>{!ef.metaKeyPressed(t)||t.shiftKey||37!==t.keyCode&&39!==t.keyCode||(t.preventDefault(),e.selection.getSel().modify("move",37===t.keyCode?"backward":"forward","lineboundary"))}))},_=()=>{e.on("click",(e=>{let t=e.target;do{if("A"===t.tagName)return void e.preventDefault()}while(t=t.parentNode)})),e.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")},N=()=>{e.on("init",(()=>{e.dom.bind(e.getBody(),"submit",(e=>{e.preventDefault()}))}))},R=E;return PC(e)?(d&&(h(),v(),N(),p(),c&&(x(),k(),_())),l&&(b(),C(),w(),S())):(e.on("keydown",(t=>{if(g(t)||t.keyCode!==ef.BACKSPACE)return;let n=s.getRng();const o=n.startContainer,a=n.startOffset,i=r.getRoot();let l=o;if(n.collapsed&&0===a){for(;l.parentNode&&l.parentNode.firstChild===l&&l.parentNode!==i;)l=l.parentNode;"BLOCKQUOTE"===l.nodeName&&(e.formatter.toggle("blockquote",void 0,l),n=r.createRng(),n.setStart(o,0),n.setEnd(o,0),s.setRng(n))}})),(()=>{const t=e=>{const t=r.create("body"),n=e.cloneContents();return t.appendChild(n),s.serializer.serialize(t,{format:"html"})};e.on("keydown",(s=>{const a=s.keyCode;if(!g(s)&&(a===o||a===n)&&e.selection.isEditable()){const n=e.selection.isCollapsed(),o=e.getBody();if(n&&(!r.isEmpty(o)||(e=>{const t=yn(e);return $(Fo(t,'[contenteditable="true"]'),(e=>On(e).exists((e=>!no(e)))))})(o)))return;if(!n&&!(n=>{const o=t(n),s=r.createRng();return s.selectNode(e.getBody()),o===t(s)})(e.selection.getRng()))return;s.preventDefault(),e.setContent(""),o.firstChild&&r.isBlock(o.firstChild)?e.selection.setCursorLocation(o.firstChild,0):e.selection.setCursorLocation(o,0),e.nodeChanged()}}))})(),At.windowsPhone||e.on("keyup focusin mouseup",(t=>{ef.modifierPressed(t)||(e=>{const t=e.getBody(),n=e.selection.getRng();return n.startContainer===n.endContainer&&n.startContainer===t&&0===n.startOffset&&n.endOffset===t.childNodes.length})(e)||s.normalize()}),!0),d&&(h(),v(),e.on("init",(()=>{f("DefaultParagraphSeparator",Nl(e))})),N(),y(),a.addNodeFilter("br",(e=>{let t=e.length;for(;t--;)"Apple-interchange-newline"===e[t].attr("class")&&e[t].remove()})),c?(x(),k(),_()):p()),l&&(e.on("keydown",(t=>{if(!g(t)&&t.keyCode===n){if(!e.getBody().getElementsByTagName("hr").length)return;if(s.isCollapsed()&&0===s.getRng().startOffset){const e=s.getNode(),n=e.previousSibling;if("HR"===e.nodeName)return r.remove(e),void t.preventDefault();n&&n.nodeName&&"hr"===n.nodeName.toLowerCase()&&(r.remove(n),t.preventDefault())}}})),b(),(()=>{const n=()=>{const n=r.getAttribs(s.getStart().cloneNode(!1));return()=>{const o=s.getStart();o!==e.getBody()&&(r.setAttrib(o,"style",null),t(n,(e=>{o.setAttributeNode(e.cloneNode(!0))})))}},o=()=>!s.isCollapsed()&&r.getParent(s.getStart(),r.isBlock)!==r.getParent(s.getEnd(),r.isBlock);e.on("keypress",(t=>{let r;return!(!(g(t)||8!==t.keyCode&&46!==t.keyCode)&&o()&&(r=n(),e.getDoc().execCommand("delete",!1),r(),t.preventDefault(),1))})),r.bind(e.getDoc(),"cut",(t=>{if(!g(t)&&o()){const t=n();mg.setEditorTimeout(e,(()=>{t()}))}}))})(),C(),e.on("SetContent ExecCommand",(e=>{"setcontent"!==e.type&&"mceInsertLink"!==e.command||t(r.select("a:not([data-mce-block])"),(e=>{var t;let n=e.parentNode;const o=r.getRoot();if((null==n?void 0:n.lastChild)===e){for(;n&&!r.isBlock(n);){if((null===(t=n.parentNode)||void 0===t?void 0:t.lastChild)!==n||n===o)return;n=n.parentNode}r.add(n,"br",{"data-mce-bogus":1})}}))})),w(),S(),y(),e.on("drop",(t=>{var n;const o=null===(n=t.dataTransfer)||void 0===n?void 0:n.getData("text/html");m(o)&&/^<img[^>]*>$/.test(o)&&e.dispatch("dragend",new window.DragEvent("dragend",t))})))),{refreshContentEditable:R,isHidden:()=>{if(!l||e.removed)return!1;const t=e.selection.getSel();return!t||!t.rangeCount||0===t.rangeCount}}},aO=Oa.DOM,iO=e=>e.inline?e.getElement().nodeName.toLowerCase():void 0,lO=e=>ye(e,(e=>!1===v(e))),dO=e=>{const t=e.options.get,n=e.editorUpload.blobCache;return lO({allow_conditional_comments:t("allow_conditional_comments"),allow_html_data_urls:t("allow_html_data_urls"),allow_svg_data_urls:t("allow_svg_data_urls"),allow_html_in_named_anchor:t("allow_html_in_named_anchor"),allow_script_urls:t("allow_script_urls"),allow_unsafe_link_target:t("allow_unsafe_link_target"),convert_fonts_to_spans:t("convert_fonts_to_spans"),fix_list_elements:t("fix_list_elements"),font_size_legacy_values:t("font_size_legacy_values"),forced_root_block:t("forced_root_block"),forced_root_block_attrs:t("forced_root_block_attrs"),preserve_cdata:t("preserve_cdata"),inline_styles:t("inline_styles"),root_name:iO(e),sanitize:t("xss_sanitization"),validate:!0,blob_cache:n,document:e.getDoc()})},cO=e=>{const t=e.options.get;return lO({custom_elements:t("custom_elements"),extended_valid_elements:t("extended_valid_elements"),invalid_elements:t("invalid_elements"),invalid_styles:t("invalid_styles"),schema:t("schema"),valid_children:t("valid_children"),valid_classes:t("valid_classes"),valid_elements:t("valid_elements"),valid_styles:t("valid_styles"),verify_html:t("verify_html"),padd_empty_block_inline_children:t("format_empty_lines")})},uO=e=>e.inline?e.ui.styleSheetLoader:e.dom.styleSheetLoader,mO=e=>{const t=uO(e),n=Ql(e),o=e.contentCSS,r=()=>{t.unloadAll(o),e.inline||e.ui.styleSheetLoader.unloadAll(n)},s=()=>{e.removed?r():e.on("remove",r)};if(e.contentStyles.length>0){let t="";Dt.each(e.contentStyles,(e=>{t+=e+"\r\n"})),e.dom.addStyle(t)}const a=Promise.all(((e,t,n)=>{const o=[uO(e).loadAll(t)];return e.inline?o:o.concat([e.ui.styleSheetLoader.loadAll(n)])})(e,o,n)).then(s).catch(s),i=Xl(e);return i&&((e,t)=>{const n=yn(e.getBody()),o=qn(Vn(n)),r=bn("style");Jt(r,"type","text/css"),bo(r,vn(t)),bo(o,r),e.on("remove",(()=>{wo(r)}))})(e,i),a},fO=e=>{!0!==e.removed&&((e=>{PC(e)||e.load({initial:!0,format:"html"}),e.startContent=e.getContent({format:"raw"})})(e),(e=>{e.bindPendingEventDelegates(),e.initialized=!0,(e=>{e.dispatch("Init")})(e),e.focus(!0),(e=>{const t=e.dom.getRoot();e.inline||tm(e)&&e.selection.getStart(!0)!==t||yu(t).each((t=>{const n=t.getNode(),o=Yo(n)?yu(n).getOr(t):t;e.selection.setRng(o.toRange())}))})(e),e.nodeChanged({initial:!0});const t=Dd(e);w(t)&&t.call(e,e),(e=>{const t=Ld(e);t&&mg.setEditorTimeout(e,(()=>{let n;n=!0===t?e:e.editorManager.get(t),n&&!n.destroyed&&(n.focus(),n.selection.scrollIntoView())}),100)})(e)})(e))},gO=e=>{const t=e.getElement();let n=e.getDoc();e.inline&&(aO.addClass(t,"mce-content-body"),e.contentDocument=n=document,e.contentWindow=window,e.bodyElement=t,e.contentAreaContainer=t);const o=e.getBody();o.disabled=!0,e.readonly=xd(e),e._editableRoot=kd(e),!e.readonly&&e.hasEditableRoot()&&(e.inline&&"static"===aO.getStyle(o,"position",!0)&&(o.style.position="relative"),o.contentEditable="true"),o.disabled=!1,e.editorUpload=Ow(e),e.schema=ca(cO(e)),e.dom=Oa(n,{keep_values:!0,url_converter:e.convertURL,url_converter_scope:e,update_styles:!0,root_element:e.inline?e.getBody():null,collect:e.inline,schema:e.schema,contentCssCors:$l(e),referrerPolicy:Vl(e),onSetAttrib:t=>{e.dispatch("SetAttrib",t)}}),e.parser=(e=>{const t=tC(dO(e),e.schema);return t.addAttributeFilter("src,href,style,tabindex",((t,n)=>{const o=e.dom,r="data-mce-"+n;let s=t.length;for(;s--;){const a=t[s];let i=a.attr(n);if(i&&!a.attr(r)){if(0===i.indexOf("data:")||0===i.indexOf("blob:"))continue;"style"===n?(i=o.serializeStyle(o.parseStyle(i),a.name),i.length||(i=null),a.attr(r,i),a.attr(n,i)):"tabindex"===n?(a.attr(r,i),a.attr(n,null)):a.attr(r,e.convertURL(i,n,a.name))}}})),t.addNodeFilter("script",(e=>{let t=e.length;for(;t--;){const n=e[t],o=n.attr("type")||"no/type";0!==o.indexOf("mce-")&&n.attr("type","mce-"+o)}})),tc(e)&&t.addNodeFilter("#cdata",(t=>{var n;let o=t.length;for(;o--;){const r=t[o];r.type=8,r.name="#comment",r.value="[CDATA["+e.dom.encode(null!==(n=r.value)&&void 0!==n?n:"")+"]]"}})),t.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",(t=>{let n=t.length;const o=e.schema.getNonEmptyElements();for(;n--;){const e=t[n];e.isEmpty(o)&&0===e.getAll("br").length&&e.append(new Fg("br",1))}})),t})(e),e.serializer=qC((e=>{const t=e.options.get;return{...dO(e),...cO(e),...lO({remove_trailing_brs:t("remove_trailing_brs"),pad_empty_with_br:t("pad_empty_with_br"),url_converter:t("url_converter"),url_converter_scope:t("url_converter_scope"),element_format:t("element_format"),entities:t("entities"),entity_encoding:t("entity_encoding"),indent:t("indent"),indent_after:t("indent_after"),indent_before:t("indent_before")})}})(e),e),e.selection=HC(e.dom,e.getWin(),e.serializer,e),e.annotator=qm(e),e.formatter=jw(e),e.undoManager=$w(e),e._nodeChangeDispatcher=new QN(e),e._selectionOverrides=PA(e),(e=>{const t=za(),n=Da(!1),o=Ha((t=>{e.dispatch("longpress",{...t,type:"longpress"}),n.set(!0)}),400);e.on("touchstart",(e=>{hE(e).each((r=>{o.cancel();const s={x:r.clientX,y:r.clientY,target:e.target};o.throttle(e),n.set(!1),t.set(s)}))}),!0),e.on("touchmove",(r=>{o.cancel(),hE(r).each((o=>{t.on((r=>{((e,t)=>{const n=Math.abs(e.clientX-t.x),o=Math.abs(e.clientY-t.y);return n>5||o>5})(o,r)&&(t.clear(),n.set(!1),e.dispatch("longpresscancel"))}))}))}),!0),e.on("touchend touchcancel",(r=>{o.cancel(),"touchcancel"!==r.type&&t.get().filter((e=>e.target.isEqualNode(r.target))).each((()=>{n.get()?r.preventDefault():e.dispatch("tap",{...r,type:"tap"})}))}),!0)})(e),(e=>{(e=>{e.on("click",(t=>{e.dom.getParent(t.target,"details")&&t.preventDefault()}))})(e),(e=>{e.parser.addNodeFilter("details",(t=>{const n=ic(e);q(t,(e=>{"expanded"===n?e.attr("open","open"):"collapsed"===n&&e.attr("open",null)}))})),e.serializer.addNodeFilter("details",(t=>{const n=lc(e);q(t,(e=>{"expanded"===n?e.attr("open","open"):"collapsed"===n&&e.attr("open",null)}))}))})(e)})(e),(e=>{const t="contenteditable",n=" "+Dt.trim(Zd(e))+" ",o=" "+Dt.trim(Jd(e))+" ",r=kE(n),s=kE(o),a=ec(e);a.length>0&&e.on("BeforeSetContent",(t=>{((e,t,n)=>{let o=t.length,r=n.content;if("raw"!==n.format){for(;o--;)r=r.replace(t[o],EE(e,r,Jd(e)));n.content=r}})(e,a,t)})),e.parser.addAttributeFilter("class",(e=>{let n=e.length;for(;n--;){const o=e[n];r(o)?o.attr(t,"true"):s(o)&&o.attr(t,"false")}})),e.serializer.addAttributeFilter(t,(e=>{let n=e.length;for(;n--;){const o=e[n];(r(o)||s(o))&&(a.length>0&&o.attr("data-mce-content")?(o.name="#text",o.type=3,o.raw=!0,o.value=o.attr("data-mce-content")):o.attr(t,null))}}))})(e),PC(e)||((e=>{e.on("mousedown",(t=>{t.detail>=3&&(t.preventDefault(),iA(e))}))})(e),(e=>{(e=>{const t=[",",".",";",":","!","?"],n=[32],o=()=>{return t=Xd(e),n=Qd(e),{inlinePatterns:ul(t),blockPatterns:cl(t),dynamicPatternsLookup:n};var t,n},r=()=>(e=>e.options.isSet("text_patterns_lookup"))(e);e.on("keydown",(t=>{if(13===t.keyCode&&!ef.modifierPressed(t)&&e.selection.isCollapsed()){const n=o();(n.inlinePatterns.length>0||n.blockPatterns.length>0||r())&&oO(e,n)&&t.preventDefault()}}),!0);const s=()=>{if(e.selection.isCollapsed()){const t=o();(t.inlinePatterns.length>0||r())&&((e,t)=>{const n=e.selection.getRng();HA(e,n).map((o=>{const r=Math.max(0,n.startOffset-1),s=VA(e.dom,o,n.startContainer,r),a=$A(t,o,s),i=tO(e,o,n.startContainer,r,a,!1);i.length>0&&e.undoManager.transact((()=>{nO(e,i)}))}))})(e,t)}};e.on("keyup",(e=>{rO(n,e,((e,t)=>e===t.keyCode&&!ef.modifierPressed(t)))&&s()})),e.on("keypress",(n=>{rO(t,n,((e,t)=>e.charCodeAt(0)===t.charCode))&&mg.setEditorTimeout(e,s)}))})(e)})(e));const r=XN(e);pE(e,r),(e=>{e.on("NodeChange",O(wE,e))})(e),(e=>{var t;const n=e.dom,o=Nl(e),r=null!==(t=nd(e))&&void 0!==t?t:"",s=(t,a)=>{if((e=>{if(Ww(e)){const t=e.keyCode;return!Kw(e)&&(ef.metaKeyPressed(e)||e.altKey||t>=112&&t<=123||H(Vw,t))}return!1})(t))return;const i=e.getBody(),l=!(e=>Ww(e)&&!(Kw(e)||"keyup"===e.type&&229===e.keyCode))(t)&&((e,t,n)=>{if(bs(yn(t),!1)){const o=t.firstElementChild;return!o||!e.getStyle(t.firstElementChild,"padding-left")&&!e.getStyle(t.firstElementChild,"padding-right")&&n===o.nodeName.toLowerCase()}return!1})(n,i,o);(""!==n.getAttrib(i,qw)!==l||a)&&(n.setAttrib(i,qw,l?r:null),n.setAttrib(i,"aria-placeholder",l?r:null),((e,t)=>{e.dispatch("PlaceholderToggle",{state:t})})(e,l),e.on(l?"keydown":"keyup",s),e.off(l?"keyup":"keydown",s))};Ge(r)&&e.on("init",(t=>{s(t,!0),e.on("change SetContent ExecCommand",s),e.on("paste",(t=>mg.setEditorTimeout(e,(()=>s(t)))))}))})(e),eA(e);const s=(e=>{const t=e;return(e=>xe(e.plugins,"rtc").bind((e=>I.from(e.setup))))(e).fold((()=>(t.rtcInstance=DC(e),I.none())),(e=>(t.rtcInstance=(()=>{const e=N(null),t=N("");return{init:{bindEvents:E},undoManager:{beforeChange:E,add:e,undo:e,redo:e,clear:E,reset:E,hasUndo:L,hasRedo:L,transact:e,ignore:E,extra:E},formatter:{match:L,matchAll:N([]),matchNode:N(void 0),canApply:L,closest:t,apply:E,remove:E,toggle:E,formatChanged:N({unbind:E})},editor:{getContent:t,setContent:N({content:"",html:""}),insertContent:N(""),addVisual:E},selection:{getContent:t},autocompleter:{addDecoration:E,removeDecoration:E},raw:{getModel:N(I.none())}}})(),I.some((()=>e().then((e=>(t.rtcInstance=(e=>{const t=e=>f(e)?e:{},{init:n,undoManager:o,formatter:r,editor:s,selection:a,autocompleter:i,raw:l}=e;return{init:{bindEvents:n.bindEvents},undoManager:{beforeChange:o.beforeChange,add:o.add,undo:o.undo,redo:o.redo,clear:o.clear,reset:o.reset,hasUndo:o.hasUndo,hasRedo:o.hasRedo,transact:(e,t,n)=>o.transact(n),ignore:(e,t)=>
vendor: 2,477 bytes, line 5168
5168o.ignore(t),extra:(e,t,n,r)=>o.extra(n,r)},formatter:{match:(e,n,o,s)=>r.match(e,t(n),s),matchAll:r.matchAll,matchNode:r.matchNode,canApply:e=>r.canApply(e),closest:e=>r.closest(e),apply:(e,n,o)=>r.apply(e,t(n)),remove:(e,n,o,s)=>r.remove(e,t(n)),toggle:(e,n,o)=>r.toggle(e,t(n)),formatChanged:(e,t,n,o,s)=>r.formatChanged(t,n,o,s)},editor:{getContent:e=>s.getContent(e),setContent:(e,t)=>({content:s.setContent(e,t),html:""}),insertContent:(e,t)=>(s.insertContent(e),""),addVisual:s.addVisual},selection:{getContent:(e,t)=>a.getContent(t)},autocompleter:{addDecoration:i.addDecoration,removeDecoration:i.removeDecoration},raw:{getModel:()=>I.some(l.getRawModel())}}})(e),e.rtc.isRemote))))))))})(e);(e=>{const t=e.getDoc(),n=e.getBody();(e=>{e.dispatch("PreInit")})(e),Md(e)||(t.body.spellcheck=!1,aO.setAttrib(n,"spellcheck","false")),e.quirks=sO(e),(e=>{e.dispatch("PostRender")})(e);const o=Jl(e);void 0!==o&&(n.dir=o);const r=Id(e);r&&e.on("BeforeSetContent",(e=>{Dt.each(r,(t=>{e.content=e.content.replace(t,(e=>"\x3c!--mce:protected "+escape(e)+"--\x3e"))}))})),e.on("SetContent",(()=>{e.addVisual(e.getBody())})),e.on("compositionstart compositionend",(t=>{e.composing="compositionstart"===t.type}))})(e),s.fold((()=>{const t=(e=>{let t=!1;const n=setTimeout((()=>{t||e.setProgressState(!0)}),500);return()=>{clearTimeout(n),t=!0,e.setProgressState(!1)}})(e);mO(e).then((()=>{fO(e),t()}))}),(t=>{e.setProgressState(!0),mO(e).then((()=>{t().then((t=>{e.setProgressState(!1),fO(e),IC(e)}),(t=>{e.notificationManager.open({type:"error",text:String(t)}),fO(e),IC(e)}))}))}))},pO=M,hO=Oa.DOM,bO=Oa.DOM,vO=(e,t)=>({editorContainer:e,iframeContainer:t,api:{}}),yO=e=>{const t=e.getElement();return e.inline?vO(null):(e=>{const t=bO.create("div");return bO.insertAfter(t,e),vO(t,t)})(t)},CO=async e=>{e.dispatch("ScriptsLoaded"),(e=>{const t=Dt.trim(Il(e)),n=e.ui.registry.getAll().icons,o={...aw.get("default").icons,...aw.get(t).icons};ge(o,((t,o)=>{ke(n,o)||e.ui.registry.addIcon(o,t)}))})(e),(e=>{const t=sd(e);if(m(t)){const n=hw.get(t);e.theme=n(e,hw.urls[t])||{},w(e.theme.init)&&e.theme.init(e,hw.urls[t]||e.documentBaseUrl.replace(/\/$/,""))}else e.theme={}})(e),(e=>{const t=id(e),n=iw.get(t);e.model=n(e,iw.urls[t])})(e),(e=>{const t=[];q(Sd(e),(n=>{((e,t,n)=>{const o=pw.get(n),r=pw.urls[n]||e.documentBaseUrl.replace(/\/$/,"");if(n=Dt.trim(n),o&&-1===Dt.inArray(t,n)){if(e.plugins[n])return;try{const s=o(e,r)||{};e.plugins[n]=s,w(s.init)&&(s.init(e,r),t.push(n))}
vendor: 6,659 bytes, line 5168
5168catch(t){((e,t,n)=>{const o=Ia.translate(["Failed to initialize plugin: {0}",t]);Gm(e,"PluginLoadError",{message:o}),xw(o,n),yw(e,o)})(e,n,t)}}})(e,t,(e=>e.replace(/^\-/,""))(n))}))})(e);const t=await(e=>{const t=e.getElement();return e.orgDisplay=t.style.display,m(sd(e))?(e=>{const t=e.theme.renderUI;return t?t():yO(e)})(e):w(sd(e))?(e=>{const t=e.getElement(),n=sd(e)(e,t);return n.editorContainer.nodeType&&(n.editorContainer.id=n.editorContainer.id||e.id+"_parent"),n.iframeContainer&&n.iframeContainer.nodeType&&(n.iframeContainer.id=n.iframeContainer.id||e.id+"_iframecontainer"),n.height=n.iframeHeight?n.iframeHeight:t.offsetHeight,n})(e):yO(e)})(e);((e,t)=>{const n={show:I.from(t.show).getOr(E),hide:I.from(t.hide).getOr(E),isEnabled:I.from(t.isEnabled).getOr(M),setEnabled:n=>{e.mode.isReadOnly()||I.from(t.setEnabled).each((e=>e(n)))}};e.ui={...e.ui,...n}})(e,I.from(t.api).getOr({})),e.editorContainer=t.editorContainer,(e=>{e.contentCSS=e.contentCSS.concat((e=>kw(e,Yl(e)))(e),(e=>kw(e,Ql(e)))(e))})(e),e.inline?gO(e):((e,t)=>{((e,t)=>{const n=e.translate("Rich Text Area"),o=tn(yn(e.getElement()),"tabindex").bind(Xe),r=((e,t,n,o)=>{const r=bn("iframe");return o.each((e=>Jt(r,"tabindex",e))),Zt(r,n),Zt(r,{id:e+"_ifr",frameBorder:"0",allowTransparency:"true",title:t}),un(r,"tox-edit-area__iframe"),r})(e.id,n,Cl(e),o).dom;r.onload=()=>{r.onload=null,e.dispatch("load")},e.contentAreaContainer=t.iframeContainer,e.iframeElement=r,e.iframeHTML=(e=>{let t=wl(e)+"<html><head>";xl(e)!==e.documentBaseUrl&&(t+='<base href="'+e.documentBaseURI.getURI()+'" />'),t+='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';const n=kl(e),o=El(e),r=e.translate(Td(e));return Sl(e)&&(t+='<meta http-equiv="Content-Security-Policy" content="'+Sl(e)+'" />'),t+=`</head><body id="${n}" class="mce-content-body ${o}" data-id="${e.id}" aria-label="${r}"><br></body></html>`,t})(e),hO.add(t.iframeContainer,r)})(e,t),t.editorContainer&&(t.editorContainer.style.display=e.orgDisplay,e.hidden=hO.isHidden(t.editorContainer)),e.getElement().style.display="none",hO.setAttrib(e.id,"aria-hidden","true"),e.getElement().style.visibility=e.orgVisibility,(e=>{const t=e.iframeElement,n=()=>{e.contentDocument=t.contentDocument,gO(e)};if(rc(e)||At.browser.isFirefox()){const t=e.getDoc();t.open(),t.write(e.iframeHTML),t.close(),n()}else{const r=(o=yn(t),_o(o,"load",pO,(()=>{r.unbind(),n()})));t.srcdoc=e.iframeHTML}var o})(e)})(e,{editorContainer:t.editorContainer,iframeContainer:t.iframeContainer})},wO=Oa.DOM,xO=e=>"-"===e.charAt(0),kO=(e,t,n)=>I.from(t).filter((e=>Ge(e)&&!aw.has(e))).map((t=>({url:`${e.editorManager.baseURL}/icons/${t}/icons.min.js`,name:I.some(t)}))),EO=(e,t)=>{const n=Ba.ScriptLoader,o=()=>{!e.removed&&(e=>{const t=sd(e);return!m(t)||C(hw.get(t))})(e)&&(e=>{const t=id(e);return C(iw.get(t))})(e)&&CO(e)};((e,t)=>{const n=sd(e);if(m(n)&&!xO(n)&&!ke(hw.urls,n)){const o=ad(e),r=o?e.documentBaseURI.toAbsolute(o):`themes/${n}/theme.min.js`;hw.load(n,r).catch((()=>{((e,t,n)=>{Cw(e,"ThemeLoadError",ww("theme",t,n))})(e,r,n)}))}})(e,t),((e,t)=>{const n=id(e);if("plugin"!==n&&!ke(iw.urls,n)){const o=ld(e),r=m(o)?e.documentBaseURI.toAbsolute(o):`models/${n}/model.min.js`;iw.load(n,r).catch((()=>{((e,t,n)=>{Cw(e,"ModelLoadError",ww("model",t,n))})(e,r,n)}))}})(e,t),((e,t)=>{const n=ql(t),o=Wl(t);if(!Ia.hasCode(n)&&"en"!==n){const r=Ge(o)?o:`${t.editorManager.baseURL}/langs/${n}.js`;e.add(r).catch((()=>{((e,t,n)=>{Cw(e,"LanguageLoadError",ww("language",t,n))})(t,r,n)}))}})(n,e),((e,t,n)=>{const o=kO(t,"default",n),r=(e=>I.from(Fl(e)).filter(Ge).map((e=>({url:e,name:I.none()}))))(t).orThunk((()=>kO(t,Il(t),"")));q((e=>{const t=[],n=e=>{t.push(e)};for(let t=0;t<e.length;t++)e[t].each(n);return t})([o,r]),(n=>{e.add(n.url).catch((()=>{((e,t,n)=>{Cw(e,"IconsLoadError",ww("icons",t,n))})(t,n.url,n.name.getOrUndefined())}))}))})(n,e,t),((e,t)=>{const n=(t,n)=>{pw.load(t,n).catch((()=>{((e,t,n)=>{Cw(e,"PluginLoadError",ww("plugin",t,n))})(e,n,t)}))};ge(_d(e),((t,o)=>{n(o,t),e.options.set("plugins",Sd(e).concat(o))})),q(Sd(e),(e=>{!(e=Dt.trim(e))||pw.urls[e]||xO(e)||n(e,`plugins/${e}/plugin.min.js`)}))})(e,t),n.loadQueue().then(o,o)},SO=xt().deviceType,_O=SO.isPhone(),NO=SO.isTablet(),RO=e=>{if(y(e))return[];{const t=p(e)?e:e.split(/[ ,]/),n=V(t,qe);return G(n,Ge)}},AO=(e,t)=>{const n=((t,n)=>{const o={},r={};return ve(t,((t,n)=>H(e,n)),be(o),be(r)),{t:o,f:r}})(t);return o=n.t,r=n.f,{sections:N(o),options:N(r)};var o,r},OO=(e,t)=>ke(e.sections(),t),TO=(e,t)=>({table_grid:!1,object_resizing:!1,resize:!1,toolbar_mode:xe(e,"toolbar_mode").getOr("scrolling"),toolbar_sticky:!1,...t?{menubar:!1}:{}}),BO=(e,t)=>{var n;const o=null!==(n=t.external_plugins)&&void 0!==n?n:{};return e&&e.external_plugins?Dt.extend({},e.external_plugins,o):o},DO=(e,t,n,o,r)=>{var s;const a=e?{mobile:TO(null!==(s=r.mobile)&&void 0!==s?s:{},t)}:{},i=AO(["mobile"],LS(a,r)),l=Dt.extend(n,o,i.options(),((e,t)=>e&&OO(t,"mobile"))(e,i)?((e,t,n={})=>{const o=e.sections(),r=xe(o,t).getOr({});return Dt.extend({},n,r)})(i,"mobile"):{},{external_plugins:BO(o,i.options())});return((e,t,n,o)=>{const r=RO(n.forced_plugins),s=RO(o.plugins),a=((e,t)=>OO(e,t)?e.sections()[t]:{})(t,"mobile"),i=((e,t,n,o)=>e&&OO(t,"mobile")?o:n)(e,t,s,a.plugins?RO(a.plugins):s),l=((e,t)=>[...RO(e),...RO(t)])(r,i);return Dt.extend(o,{forced_plugins:r,plugins:l})})(e,i,o,l)},PO=e=>{(e=>{const t=t=>()=>{q("left,center,right,justify".split(","),(n=>{t!==n&&e.formatter.remove("align"+n)})),"none"!==t&&((t,n)=>{e.formatter.toggle(t,void 0),e.nodeChanged()})("align"+t)};e.editorCommands.addCommands({JustifyLeft:t("left"),JustifyCenter:t("center"),JustifyRight:t("right"),JustifyFull:t("justify"),JustifyNone:t("none")})})(e),(e=>{const t=t=>()=>{const n=e.selection,o=n.isCollapsed()?[e.dom.getParent(n.getNode(),e.dom.isBlock)]:n.getSelectedBlocks();return $(o,(n=>C(e.formatter.matchNode(n,t))))};e.editorCommands.addCommands({JustifyLeft:t("alignleft"),JustifyCenter:t("aligncenter"),JustifyRight:t("alignright"),JustifyFull:t("alignjustify")},"state")})(e)},LO=(e,t)=>{const n=e.selection,o=e.dom;return/^ | $/.test(t)?((e,t,n)=>{const o=yn(e.getRoot());return n=Ip(o,Li.fromRangeStart(t))?n.replace(/^ /," "):n.replace(/^ /," "),Fp(o,Li.fromRangeEnd(t))?n.replace(/( | )(<br( \/)>)?$/," "):n.replace(/ (<br( \/)?>)?$/," ")})(o,n.getRng(),t):t},MO=(e,t)=>{if(e.selection.isEditable()){const{content:n,details:o}=(e=>{if("string"!=typeof e){const t=Dt.extend({paste:e.paste,data:{paste:e.paste}},e);return{content:e.content,details:t}}return{content:e,details:{}}})(t);sC(e,{...o,content:LO(e,n),format:"html",set:!1,selection:!0}
vendor: 4,438 bytes, line 5168
5168).each((t=>{const n=((e,t,n)=>LC(e).editor.insertContent(t,n))(e,t.content,o);aC(e,n,t),e.addVisual()}))}},IO={"font-size":"size","font-family":"face"},FO=Xt("font"),UO=e=>(t,n)=>I.from(n).map(yn).filter(Wt).bind((n=>((e,t,n)=>hb(yn(n),(t=>(t=>uo(t,e).orThunk((()=>FO(t)?xe(IO,e).bind((e=>tn(t,e))):I.none())))(t)),(e=>En(yn(t),e))))(e,t,n.dom).or(((e,t)=>I.from(Oa.DOM.getStyle(t,e,!0)))(e,n.dom)))).getOr(""),zO=UO("font-size"),jO=S((e=>e.replace(/[\'\"\\]/g,"").replace(/,\s+/g,",")),UO("font-family")),HO=e=>yu(e.getBody()).bind((e=>{const t=e.container();return I.from(Jo(t)?t.parentNode:t)})),$O=(e,t)=>((e,t)=>(e=>I.from(e.selection.getRng()).bind((t=>{const n=e.getBody();return t.startContainer===n&&0===t.startOffset?I.none():I.from(e.selection.getStart(!0))})))(e).orThunk(O(HO,e)).map(yn).filter(Wt).bind(t))(e,_(I.some,t)),VO=(e,t)=>{if(/^[0-9.]+$/.test(t)){const n=parseInt(t,10);if(n>=1&&n<=7){const o=(e=>Dt.explode(e.options.get("font_size_style_values")))(e),r=(e=>Dt.explode(e.options.get("font_size_classes")))(e);return r.length>0?r[n-1]||t:o[n-1]||t}return t}return t},qO=e=>{const t=e.split(/\s*,\s*/);return V(t,(e=>-1===e.indexOf(" ")||He(e,'"')||He(e,"'")?e:`'${e}'`)).join(",")},WO=(e,t)=>{const n=e.dom,o=e.selection.getRng(),r=t?e.selection.getStart():e.selection.getEnd(),s=t?o.startContainer:o.endContainer,a=Z_(n,s);if(!a||!a.isContentEditable)return;const i=t?go:po,l=Nl(e);((e,t,n,o)=>{const r=e.dom,s=e=>r.isBlock(e)&&e.parentElement===n,a=s(t)?t:r.getParent(o,s,n);return I.from(a).map(yn)})(e,r,a,s).each((t=>{const n=oN(e,s,t.dom,a,!1,l);i(t,yn(n)),e.selection.setCursorLocation(n,0),e.dispatch("NewBlock",{newBlock:n}),W_(e,"insertParagraph")}))},KO=e=>{PO(e),(e=>{e.editorCommands.addCommands({"Cut,Copy,Paste":t=>{const n=e.getDoc();let o;try{n.execCommand(t)}catch(e){o=!0}if("paste"!==t||n.queryCommandEnabled(t)||(o=!0),o||!n.queryCommandSupported(t)){let t=e.translate("Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.");(At.os.isMacOS()||At.os.isiOS())&&(t=t.replace(/Ctrl\+/g,"\u2318+")),e.notificationManager.open({text:t,type:"error"})}}})})(e),(e=>{e.editorCommands.addCommands({mceAddUndoLevel:()=>{e.undoManager.add()},mceEndUndoLevel:()=>{e.undoManager.add()},Undo:()=>{e.undoManager.undo()},Redo:()=>{e.undoManager.redo()}})})(e),(e=>{e.editorCommands.addCommands({mceSelectNodeDepth:(t,n,o)=>{let r=0;e.dom.getParent(e.selection.getNode(),(t=>!$o(t)||r++!==o||(e.selection.select(t),!1)),e.getBody())},mceSelectNode:(t,n,o)=>{e.selection.select(o)},selectAll:()=>{const t=e.dom.getParent(e.selection.getStart(),ar);if(t){const n=e.dom.createRng();n.selectNodeContents(t),e.selection.setRng(n)}}})})(e),(e=>{e.editorCommands.addCommands({mceCleanup:()=>{const t=e.selection.getBookmark();e.setContent(e.getContent()),e.selection.moveToBookmark(t)},insertImage:(t,n,o)=>{MO(e,e.dom.createHTML("img",{src:o}))},insertHorizontalRule:()=>{e.execCommand("mceInsertContent",!1,"<hr>")},insertText:(t,n,o)=>{MO(e,e.dom.encode(o))},insertHTML:(t,n,o)=>{MO(e,o)},mceInsertContent:(t,n,o)=>{MO(e,o)},mceSetContent:(t,n,o)=>{e.setContent(o)},mceReplaceContent:(t,n,o)=>{e.execCommand("mceInsertContent",!1,o.replace(/\{\$selection\}/g,e.selection.getContent({format:"text"})))},mceNewDocument:()=>{e.setContent(Hd(e))}})})(e),(e=>{const t=(t,n,o)=>{const r=m(o)?{href:o}:o,s=e.dom.getParent(e.selection.getNode(),"a");f(r)&&m(r.href)&&(r.href=r.href.replace(/ /g,"%20"),s&&r.href||e.formatter.remove("link"),r.href&&e.formatter.apply("link",r,s))};e.editorCommands.addCommands({unlink:()=>{if(e.selection.isEditable()){if(e.selection.isCollapsed()){const t=e.dom.getParent(e.selection.getStart(),"a");return void(t&&e.dom.remove(t,!0))}e.formatter.remove("link")}},mceInsertLink:t,createLink:t})})(e),(e=>{e.editorCommands.addCommands({Indent:()=>{(e=>{uE(e,"indent")})(e)},Outdent:()=>{mE(e)}}),e.editorCommands.addCommands({Outdent:()=>lE(e)},"state")})(e),(e=>{e.editorCommands.addCommands({InsertNewBlockBefore:()=>{(e=>{WO(e,!0)})(e)},InsertNewBlockAfter:()=>{(e=>{WO(e,!1)})(e)}})})(e),(e=>{e.editorCommands.addCommands({insertParagraph:()=>{PN(mN,e)},mceInsertNewLine:(t,n,o)=>{LN(e,o)},InsertLineBreak:(t,n,o)=>{PN(CN,e)}})})(e),(e=>{(e=>{e.editorCommands.addCommands({"InsertUnorderedList,InsertOrderedList":t=>{e.getDoc().execCommand(t);const n=e.dom.getParent(e.selection.getNode(),"ol,ul");if(n){const t=n.parentNode;
vendor: 18,221 bytes, line 5168
5168if(t&&/^(H[1-6]|P|ADDRESS|PRE)$/.test(t.nodeName)){const o=e.selection.getBookmark();e.dom.split(t,n),e.selection.moveToBookmark(o)}}}})})(e),(e=>{e.editorCommands.addCommands({"InsertUnorderedList,InsertOrderedList":t=>{const n=e.dom.getParent(e.selection.getNode(),"ul,ol");return n&&("insertunorderedlist"===t&&"UL"===n.tagName||"insertorderedlist"===t&&"OL"===n.tagName)}},"state")})(e)})(e),(e=>{(e=>{const t=(t,n)=>{e.formatter.toggle(t,n),e.nodeChanged()};e.editorCommands.addCommands({"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":e=>{t(e)},"ForeColor,HiliteColor":(e,n,o)=>{t(e,{value:o})},BackColor:(e,n,o)=>{t("hilitecolor",{value:o})},FontName:(t,n,o)=>{((e,t)=>{const n=VO(e,t);e.formatter.toggle("fontname",{value:qO(n)}),e.nodeChanged()})(e,o)},FontSize:(t,n,o)=>{((e,t)=>{e.formatter.toggle("fontsize",{value:VO(e,t)}),e.nodeChanged()})(e,o)},LineHeight:(t,n,o)=>{((e,t)=>{e.formatter.toggle("lineheight",{value:String(t)}),e.nodeChanged()})(e,o)},Lang:(e,n,o)=>{var r;t(e,{value:o.code,customValue:null!==(r=o.customCode)&&void 0!==r?r:null})},RemoveFormat:t=>{e.formatter.remove(t)},mceBlockQuote:()=>{t("blockquote")},FormatBlock:(e,n,o)=>{t(m(o)?o:"p")},mceToggleFormat:(e,n,o)=>{t(o)}})})(e),(e=>{const t=t=>e.formatter.match(t);e.editorCommands.addCommands({"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":e=>t(e),mceBlockQuote:()=>t("blockquote")},"state"),e.editorCommands.addQueryValueHandler("FontName",(()=>(e=>$O(e,(t=>jO(e.getBody(),t.dom))).getOr(""))(e))),e.editorCommands.addQueryValueHandler("FontSize",(()=>(e=>$O(e,(t=>zO(e.getBody(),t.dom))).getOr(""))(e))),e.editorCommands.addQueryValueHandler("LineHeight",(()=>(e=>$O(e,(t=>{const n=yn(e.getBody()),o=hb(t,(e=>uo(e,"line-height")),O(En,n));return o.getOrThunk((()=>{const e=parseFloat(lo(t,"line-height")),n=parseFloat(lo(t,"font-size"));return String(e/n)}))})).getOr(""))(e)))})(e)})(e),(e=>{e.editorCommands.addCommands({mceRemoveNode:(t,n,o)=>{const r=null!=o?o:e.selection.getNode();if(r!==e.getBody()){const t=e.selection.getBookmark();e.dom.remove(r,!0),e.selection.moveToBookmark(t)}},mcePrint:()=>{e.getWin().print()},mceFocus:(t,n,o)=>{((e,t)=>{e.removed||(t?kg(e):(e=>{const t=e.selection,n=e.getBody();let o=t.getRng();e.quirks.refreshContentEditable(),C(e.bookmark)&&!xg(e)&&cg(e).each((t=>{e.selection.setRng(t),o=t}));const r=((e,t)=>e.dom.getParent(t,(t=>"true"===e.dom.getContentEditable(t))))(e,t.getNode());if(r&&e.dom.isChildOf(r,n))return wg(r),Cg(e,o),void kg(e);e.inline||(At.browser.isOpera()||wg(n),e.getWin().focus()),(At.browser.isFirefox()||e.inline)&&(wg(n),Cg(e,o)),kg(e)})(e))})(e,!0===o)},mceToggleVisualAid:()=>{e.hasVisual=!e.hasVisual,e.addVisual()}})})(e)},GO=["toggleview"],YO=e=>H(GO,e.toLowerCase());class XO{constructor(e){this.commands={state:{},exec:{},value:{}},this.editor=e}execCommand(e,t=!1,n,o){const r=this.editor,s=e.toLowerCase(),a=null==o?void 0:o.skip_focus;if(r.removed)return!1;if("mcefocus"!==s&&(/^(mceAddUndoLevel|mceEndUndoLevel)$/i.test(s)||a?(e=>{cg(e).each((t=>e.selection.setRng(t)))})(r):r.focus()),r.dispatch("BeforeExecCommand",{command:e,ui:t,value:n}).isDefaultPrevented())return!1;const i=this.commands.exec[s];return!!w(i)&&(i(s,t,n),r.dispatch("ExecCommand",{command:e,ui:t,value:n}),!0)}queryCommandState(e){if(!YO(e)&&this.editor.quirks.isHidden()||this.editor.removed)return!1;const t=e.toLowerCase(),n=this.commands.state[t];return!!w(n)&&n(t)}queryCommandValue(e){if(!YO(e)&&this.editor.quirks.isHidden()||this.editor.removed)return"";const t=e.toLowerCase(),n=this.commands.value[t];return w(n)?n(t):""}addCommands(e,t="exec"){const n=this.commands;ge(e,((e,o)=>{q(o.toLowerCase().split(","),(o=>{n[t][o]=e}))}))}addCommand(e,t,n){const o=e.toLowerCase();this.commands.exec[o]=(e,o,r)=>t.call(null!=n?n:this.editor,o,r)}queryCommandSupported(e){const t=e.toLowerCase();return!!this.commands.exec[t]}addQueryStateHandler(e,t,n){this.commands.state[e.toLowerCase()]=()=>t.call(null!=n?n:this.editor)}addQueryValueHandler(e,t,n){this.commands.value[e.toLowerCase()]=()=>t.call(null!=n?n:this.editor)}}const QO="data-mce-contenteditable",JO=(e,t,n)=>{try{e.getDoc().execCommand(t,!1,String(n))}catch(e){}},ZO=(e,t)=>{e.dom.contentEditable=t?"true":"false"},eT=(e,t)=>{const n=yn(e.getBody());((e,t,n)=>{gn(e,t)&&!n?fn(e,t):n&&un(e,t)})(n,"mce-content-readonly",t),t?(e.selection.controlSelection.hideResizeRect(),e._selectionOverrides.hideFakeCaret(),(e=>{I.from(e.selection.getNode()).each((e=>{e.removeAttribute("data-mce-selected")}))})(e),e.readonly=!0,ZO(n,!1),q(Fo(n,'*[contenteditable="true"]'),(e=>{Jt(e,QO,"true"),ZO(e,!1)}))):(e.readonly=!1,e.hasEditableRoot()&&ZO(n,!0),q(Fo(n,`*[${QO}="true"]`),(e=>{on(e,QO),ZO(e,!0)})),JO(e,"StyleWithCSS",!1),JO(e,"enableInlineTableEditing",!1),JO(e,"enableObjectResizing",!1),(e=>xg(e)||(e=>{const t=Vn(yn(e.getElement()));return ng(t).filter((t=>!pg(t.dom)&&hg(e,t.dom))).isSome()})(e))(e)&&e.focus(),(e=>{e.selection.setRng(e.selection.getRng())})(e),e.nodeChanged())},tT=e=>e.readonly,nT=e=>{e.parser.addAttributeFilter("contenteditable",(t=>{tT(e)&&q(t,(e=>{e.attr(QO,e.attr("contenteditable")),e.attr("contenteditable","false")}))})),e.serializer.addAttributeFilter(QO,(t=>{tT(e)&&q(t,(e=>{e.attr("contenteditable",e.attr(QO))}))})),e.serializer.addTempAttr(QO)},oT=["copy"],rT=Dt.makeMap("focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange mouseout mouseenter mouseleave wheel keydown keypress keyup input beforeinput contextmenu dragstart dragend dragover draggesture dragdrop drop drag submit compositionstart compositionend compositionupdate touchstart touchmove touchend touchcancel"," ");class sT{static isNative(e){return!!rT[e.toLowerCase()]}constructor(e){this.bindings={},this.settings=e||{},this.scope=this.settings.scope||this,this.toggleEvent=this.settings.toggleEvent||L}fire(e,t){return this.dispatch(e,t)}dispatch(e,t){const n=e.toLowerCase(),o=ga(n,null!=t?t:{},this.scope);this.settings.beforeFire&&this.settings.beforeFire(o);const r=this.bindings[n];if(r)for(let e=0,t=r.length;e<t;e++){const t=r[e];if(!t.removed){if(t.once&&this.off(n,t.func),o.isImmediatePropagationStopped())return o;if(!1===t.func.call(this.scope,o))return o.preventDefault(),o}}return o}on(e,t,n,o){if(!1===t&&(t=L),t){const r={func:t,removed:!1};o&&Dt.extend(r,o);const s=e.toLowerCase().split(" ");let a=s.length;for(;a--;){const e=s[a];let t=this.bindings[e];t||(t=[],this.toggleEvent(e,!0)),t=n?[r,...t]:[...t,r],this.bindings[e]=t}}return this}off(e,t){if(e){const n=e.toLowerCase().split(" ");let o=n.length;for(;o--;){const r=n[o];let s=this.bindings[r];if(!r)return ge(this.bindings,((e,t)=>{this.toggleEvent(t,!1),delete this.bindings[t]})),this;if(s){if(t){const e=K(s,(e=>e.func===t));s=e.fail,this.bindings[r]=s,q(e.pass,(e=>{e.removed=!0}))}else s.length=0;s.length||(this.toggleEvent(e,!1),delete this.bindings[r])}}}else ge(this.bindings,((e,t)=>{this.toggleEvent(t,!1)})),this.bindings={};return this}once(e,t,n){return this.on(e,t,n,{once:!0})}has(e){e=e.toLowerCase();const t=this.bindings[e];return!(!t||0===t.length)}}const aT=e=>(e._eventDispatcher||(e._eventDispatcher=new sT({scope:e,toggleEvent:(t,n)=>{sT.isNative(t)&&e.toggleNativeEvent&&e.toggleNativeEvent(t,n)}})),e._eventDispatcher),iT={fire(e,t,n){return this.dispatch(e,t,n)},dispatch(e,t,n){const o=this;if(o.removed&&"remove"!==e&&"detach"!==e)return ga(e.toLowerCase(),null!=t?t:{},o);const r=aT(o).dispatch(e,t);if(!1!==n&&o.parent){let t=o.parent();for(;t&&!r.isPropagationStopped();)t.dispatch(e,r,!1),t=t.parent?t.parent():void 0}return r},on(e,t,n){return aT(this).on(e,t,n)},off(e,t){return aT(this).off(e,t)},once(e,t){return aT(this).once(e,t)},hasEventListeners(e){return aT(this).has(e)}},lT=Oa.DOM;let dT;const cT=(e,t)=>{if("selectionchange"===t)return e.getDoc();if(!e.inline&&/^(?:mouse|touch|click|contextmenu|drop|dragover|dragend)/.test(t))return e.getDoc().documentElement;const n=od(e);return n?(e.eventRoot||(e.eventRoot=lT.select(n)[0]),e.eventRoot):e.getBody()},uT=(e,t,n)=>{(e=>!e.hidden&&!tT(e))(e)?e.dispatch(t,n):tT(e)&&((e,t)=>{if((e=>"click"===e.type)(t)&&!ef.metaKeyPressed(t)){const n=yn(t.target);((e,t)=>to(t,"a",(t=>En(t,yn(e.getBody())))).bind((e=>tn(e,"href"))))(e,n).each((n=>{if(t.preventDefault(),/^#/.test(n)){const t=e.dom.select(`${n},[name="${ze(n,"#")}"]`);t.length&&e.selection.scrollIntoView(t[0],!0)}else window.open(n,"_blank","rel=noopener noreferrer,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes")}))}else(e=>H(oT,e.type))(t)&&e.dispatch(t.type,t)})(e,n)},mT=(e,t)=>{if(e.delegates||(e.delegates={}),e.delegates[t]||e.removed)return;const n=cT(e,t);if(od(e)){if(dT||(dT={},e.editorManager.on("removeEditor",(()=>{e.editorManager.activeEditor||dT&&(ge(dT,((t,n)=>{e.dom.unbind(cT(e,n))})),dT=null)}))),dT[t])return;const o=n=>{const o=n.target,r=e.editorManager.get();let s=r.length;for(;s--;){const e=r[s].getBody();(e===o||lT.isChildOf(o,e))&&uT(r[s],t,n)}};dT[t]=o,lT.bind(n,t,o)}else{const o=n=>{uT(e,t,n)};lT.bind(n,t,o),e.delegates[t]=o}},fT={...iT,bindPendingEventDelegates(){const e=this;Dt.each(e._pendingNativeEvents,(t=>{mT(e,t)}))},toggleNativeEvent(e,t){const n=this;"focus"!==e&&"blur"!==e&&(n.removed||(t?n.initialized?mT(n,e):n._pendingNativeEvents?n._pendingNativeEvents.push(e):n._pendingNativeEvents=[e]:n.initialized&&n.delegates&&(n.dom.unbind(cT(n,e),e,n.delegates[e]),delete n.delegates[e])))},unbindAllNativeEvents(){const e=this,t=e.getBody(),n=e.dom;e.delegates&&(ge(e.delegates,((t,n)=>{e.dom.unbind(cT(e,n),n,t)})),delete e.delegates),!e.inline&&t&&n&&(t.onload=null,n.unbind(e.getWin()),n.unbind(e.getDoc())),n&&(n.unbind(t),n.unbind(e.getContainer()))}},gT=e=>m(e)?{value:e.split(/[ ,]/),valid:!0}:k(e,m)?{value:e,valid:!0}:{valid:!1,message:"The value must be a string[] or a comma/space separated string."},pT=(e,t)=>e+(Ye(t.message)?"":`. ${t.message}`),hT=e=>e.valid,bT=(e,t,n="")=>{const o=t(e);return b(o)?o?{value:e,valid:!0}:{valid:!1,message:n}:o},vT=["design","readonly"],yT=(e,t,n,o)=>{const r=n[t.get()],s=n[o];try{s.activate()}catch(e){return void console.error(`problem while activating editor mode ${o}:`,e)}r.deactivate(),r.editorReadOnly!==s.editorReadOnly&&eT(e,s.editorReadOnly),t.set(o),((e,t)=>{e.dispatch("SwitchMode",{mode:t})})(e,o)},CT=Dt.each,wT=Dt.explode,xT={f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123},kT=Dt.makeMap("alt,ctrl,shift,meta,access"),ET=e=>{const t={},n=At.os.isMacOS()||At.os.isiOS();CT(wT(e.toLowerCase(),"+"),(e=>{(e=>e in kT)(e)?t[e]=!0:/^[0-9]{2,}$/.test(e)?t.keyCode=parseInt(e,10):(t.charCode=e.charCodeAt(0),t.keyCode=xT[e]||e.toUpperCase().charCodeAt(0))}));const o=[t.keyCode];let r;for(r in kT)t[r]?o.push(r):t[r]=!1;return t.id=o.join(","),t.access&&(t.alt=!0,n?t.ctrl=!0:t.shift=!0),t.meta&&(n?t.meta=!0:(t.ctrl=!0,t.meta=!1)),t};class ST{constructor(e){this.shortcuts={},this.pendingPatterns=[],this.editor=e;const t=this;e.on("keyup keypress keydown",(e=>{!t.hasModifier(e)&&!t.isFunctionKey(e)||e.isDefaultPrevented()||(CT(t.shortcuts,(n=>{t.matchShortcut(e,n)&&(t.pendingPatterns=n.subpatterns.slice(0),"keydown"===e.type&&t.executeShortcutAction(n))})),t.matchShortcut(e,t.pendingPatterns[0])&&(1===t.pendingPatterns.length&&"keydown"===e.type&&t.executeShortcutAction(t.pendingPatterns[0]),t.pendingPatterns.shift()))}))}add(e,t,n,o){const r=this,s=r.normalizeCommandFunc(n);return CT(wT(Dt.trim(e)),(e=>{const n=r.createShortcut(e,t,s,o);r.shortcuts[n.id]=n})),!0}remove(e){const t=this.createShortcut(e);return!!this.shortcuts[t.id]&&(delete this.shortcuts[t.id],!0)}normalizeCommandFunc(e){const t=this,n=e;return"string"==typeof n?()=>{t.editor.execCommand(n,!1,null)}:Dt.isArray(n)?()=>{t.editor.execCommand(n[0],n[1],n[2])}:n}createShortcut(e,t,n,o){const r=Dt.map(wT(e,">"),ET);return r[r.length-1]=Dt.extend(r[r.length-1],{func:n,scope:o||this.editor}),Dt.extend(r[0],{desc:this.editor.translate(t),subpatterns:r.slice(1)})}hasModifier(e){return e.altKey||e.ctrlKey||e.metaKey}isFunctionKey(e){return"keydown"===e.type&&e.keyCode>=112&&e.keyCode<=123}matchShortcut(e,t){return!!t&&t.ctrl===e.ctrlKey&&t.meta===e.metaKey&&t.alt===e.altKey&&t.shift===e.shiftKey&&!!(e.keyCode===t.keyCode||e.charCode&&e.charCode===t.charCode)&&(e.preventDefault(),!0)}executeShortcutAction(e){return e.func?e.func.call(e.scope):null}}const _T=()=>{const e=(()=>{const e={},t={},n={},o={},r={},s={},a={},i={},l=(e,t)=>(n,o)=>{e[n.toLowerCase()]={...o,type:t}};return{addButton:l(e,"button"),addGroupToolbarButton:l(e,"grouptoolbarbutton"),addToggleButton:l(e,"togglebutton"),addMenuButton:l(e,"menubutton"),addSplitButton:l(e,"splitbutton"),addMenuItem:l(t,"menuitem"),addNestedMenuItem:l(t,"nestedmenuitem"),addToggleMenuItem:l(t,"togglemenuitem"),addAutocompleter:l(n,"autocompleter"),addContextMenu:l(r,"contextmenu"),addContextToolbar:l(s,"contexttoolbar"),addContextForm:l(s,"contextform"),addSidebar:l(a,"sidebar"),addView:l(i,"views"),addIcon:(e,t)=>o[e.toLowerCase()]=t,getAll:()=>({buttons:e,menuItems:t,icons:o,popups:n,contextMenus:r,contextToolbars:s,sidebars:a,views:i})}})();return{addAutocompleter:e.addAutocompleter,addButton:e.addButton,addContextForm:e.addContextForm,addContextMenu:e.addContextMenu,addContextToolbar:e.addContextToolbar,addIcon:e.addIcon,addMenuButton:e.addMenuButton,addMenuItem:e.addMenuItem,addNestedMenuItem:e.addNestedMenuItem,addSidebar:e.addSidebar,addSplitButton:e.addSplitButton,addToggleButton:e.addToggleButton,addGroupToolbarButton:e.addGroupToolbarButton,addToggleMenuItem:e.addToggleMenuItem,addView:e.addView,getAll:e.getAll}},NT=Oa.DOM,RT=Dt.extend,AT=Dt.each;class OT{constructor(e,t,n){this.plugins={},this.contentCSS=[],this.contentStyles=[],this.loadedCSS={},this.isNotDirty=!1,this.composing=!1,this.destroyed=!1,this.hasHiddenInput=!1,this.iframeElement=null,this.initialized=!1,this.readonly=!1,this.removed=!1,this.startContent="",this._pendingNativeEvents=[],this._skinLoaded=!1,this._editableRoot=!0,this.editorManager=n,this.documentBaseUrl=n.documentBaseURL,RT(this,fT);const o=this;this.id=e,this.hidden=!1;const r=((e,t)=>DO(_O||NO,_O,t,e,t))(n.defaultOptions,t);this.options=((e,t)=>{const n={},o={},r=(e,t,n)=>{const r=bT(t,n);return hT(r)?(o[e]=r.value,!0):(console.warn(pT(`Invalid value passed for the ${e} option`,r)),!1)},s=e=>ke(n,e);return{register:(e,s)=>{const a=(e=>m(e.processor))(s)?(e=>{const t=(()=>{switch(e){case"array":return p;case"boolean":return b;case"function":return w;case"number":return x;case"object":return f;case"string":return m;case"string[]":return gT;case"object[]":return e=>k(e,f);case"regexp":return e=>u(e,RegExp);default:return M}})();return n=>bT(n,t,`The value must be a ${e}.`)})(s.processor):s.processor,i=((e,t,n)=>{if(!v(t)){const o=bT(t,n);if(hT(o))return o.value;console.error(pT(`Invalid default value passed for the "${e}" option`,o))}})(e,s.default,a);n[e]={...s,default:i,processor:a},xe(o,e).orThunk((()=>xe(t,e))).each((t=>r(e,t,a)))},isRegistered:s,get:e=>xe(o,e).orThunk((()=>xe(n,e).map((e=>e.default)))).getOrUndefined(),set:(e,t)=>{if(s(e)){const o=n[e];return o.immutable?(console.error(`"${e}" is an immutable option and cannot be updated`),!1):r(e,t,o.processor)}return console.warn(`"${e}" is not a registered option. Ensure the option has been registered before setting a value.`),!1},unset:e=>{const t=s(e);return t&&delete o[e],t},isSet:e=>ke(o,e)}})(0,r),(e=>{const t=e.options.register;t("id",{processor:"string",default:e.id}),t("selector",{processor:"string"}),t("target",{processor:"object"}),t("suffix",{processor:"string"}),t("cache_suffix",{processor:"string"}),t("base_url",{processor:"string"}),t("referrer_policy",{processor:"string",default:""}),t("language_load",{processor:"boolean",default:!0}),t("inline",{processor:"boolean",default:!1}),t("iframe_attrs",{processor:"object",default:{}}),t("doctype",{processor:"string",default:"<!DOCTYPE html>"}),t("document_base_url",{processor:"string",default:e.documentBaseUrl}),t("body_id",{processor:yl(e,"tinymce"),default:"tinymce"}),t("body_class",{processor:yl(e),default:""}),t("content_security_policy",{processor:"string",default:""}),t("br_in_pre",{processor:"boolean",default:!0}),t("forced_root_block",{processor:e=>{const t=m(e)&&Ge(e);return t?{value:e,valid:t}:{valid:!1,message:"Must be a non-empty string."}},default:"p"}),t("forced_root_block_attrs",{processor:"object",default:{}}),t("newline_behavior",{processor:e=>{const t=H(["block","linebreak","invert","default"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: block, linebreak, invert or default."}},default:"default"}),t("br_newline_selector",{processor:"string",default:".mce-toc h2,figcaption,caption"}),t("no_newline_selector",{processor:"string",default:""}),t("keep_styles",{processor:"boolean",default:!0}),t("end_container_on_empty_block",{processor:e=>b(e)||m(e)?{valid:!0,value:e}:{valid:!1,message:"Must be boolean or a string"},default:"blockquote"}),t("font_size_style_values",{processor:"string",default:"xx-small,x-small,small,medium,large,x-large,xx-large"}),t("font_size_legacy_values",{processor:"string",default:"xx-small,small,medium,large,x-large,xx-large,300%"}),t("font_size_classes",{processor:"string",default:""}),t("automatic_uploads",{processor:"boolean",default:!0}),t("images_reuse_filename",{processor:"boolean",default:!1}),t("images_replace_blob_uris",{processor:"boolean",default:!0}),t("icons",{processor:"string",default:""}),t("icons_url",{processor:"string",default:""}),t("images_upload_url",{processor:"string",default:""}),t("images_upload_base_path",{processor:"string",default:""}),t("images_upload_credentials",{processor:"boolean",default:!1}),t("images_upload_handler",{processor:"function"}),t("language",{processor:"string",default:"en"}),t("language_url",{processor:"string",default:""}),t("entity_encoding",{processor:"string",default:"named"}),t("indent",{processor:"boolean",default:!0}),t("indent_before",{processor:"string",default:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,details,summary,article,hgroup,aside,f
5168igure,figcaption,option,optgroup,datalist"}),t("indent_after",{processor:"string",default:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,details,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist"}),t("indent_use_margin",{processor:"boolean",default:!1}),t("indentation",{processor:"string",default:"40px"}),t("content_css",{processor:e=>{const t=!1===e||m(e)||k(e,m);return t?m(e)?{value:V(e.split(","),qe),valid:t}:p(e)?{value:e,valid:t}:!1===e?{value:[],valid:t}:{value:e,valid:t}:{valid:!1,message:"Must be false, a string or an array of strings."}},default:pd(e)?[]:["default"]}),t("content_style",{processor:"string"}),t("content_css_cors",{processor:"boolean",default:!1}),t("font_css",{processor:e=>{const t=m(e)||k(e,m);return t?{value:p(e)?e:V(e.split(","),qe),valid:t}:{valid:!1,message:"Must be a string or an array of strings."}},default:[]}),t("inline_boundaries",{processor:"boolean",default:!0}),t("inline_boundaries_selector",{processor:"string",default:"a[href],code,span.mce-annotation"}),t("object_resizing",{processor:e=>{const t=b(e)||m(e);return t?!1===e||fl.isiPhone()||fl.isiPad()?{value:"",valid:t}:{value:!0===e?"table,img,figure.image,div,video,iframe":e,valid:t}:{valid:!1,message:"Must be boolean or a string"}},default:!gl}),t("resize_img_proportional",{processor:"boolean",default:!0}),t("event_root",{processor:"object"}),t("service_message",{processor:"string"}),t("theme",{processor:e=>!1===e||m(e)||w(e),default:"silver"}),t("theme_url",{processor:"string"}),t("formats",{processor:"object"}),t("format_empty_lines",{processor:"boolean",default:!1}),t("format_noneditable_selector",{processor:"string",default:""}),t("preview_styles",{processor:e=>{const t=!1===e||m(e);return t?{value:!1===e?"":e,valid:t}:{valid:!1,message:"Must be false or a string"}},default:"font-family font-size font-weight font-style text-decoration text-transform color background-color border border-radius outline text-shadow"}),t("custom_ui_selector",{processor:"string",default:""}),t("hidden_input",{processor:"boolean",default:!0}),t("submit_patch",{processor:"boolean",default:!0}),t("encoding",{processor:"string"}),t("add_form_submit_trigger",{processor:"boolean",default:!0}),t("add_unload_trigger",{processor:"boolean",default:!0}),t("custom_undo_redo_levels",{processor:"number",default:0}),t("disable_nodechange",{processor:"boolean",default:!1}),t("readonly",{processor:"boolean",default:!1}),t("editable_root",{processor:"boolean",default:!0}),t("plugins",{processor:"string[]",default:[]}),t("external_plugins",{processor:"object"}),t("forced_plugins",{processor:"string[]"}),t("model",{processor:"string",default:e.hasPlugin("rtc")?"plugin":"dom"}),t("model_url",{processor:"string"}),t("block_unsupported_drop",{processor:"boolean",default:!0}),t("visual",{processor:"boolean",default:!0}),t("visual_table_class",{processor:"string",default:"mce-item-table"}),t("visual_anchor_class",{processor:"string",default:"mce-item-anchor"}),t("iframe_aria_text",{processor:"string",default:"Rich Text Area. Press ALT-0 for help."}),t("setup",{processor:"function"}),t("init_instance_callback",{processor:"function"}),t("url_converter",{processor:"function",default:e.convertURL}),t("url_converter_scope",{processor:"object",default:e}),t("urlconverter_callback",{processor:"function"}),t("allow_conditional_comments",{processor:"boolean",default:!1}),t("allow_html_data_urls",{processor:"boolean",default:!1}),t("allow_svg_data_urls",{processor:"boolean"}),t("allow_html_in_named_anchor",{processor:"boolean",default:!1}),t("allow_script_urls",{processor:"boolean",default:!1}),t("allow_unsafe_link_target",{processor:"boolean",default:!1}),t("convert_fonts_to_spans",{processor:"boolean",default:!0,deprecated:!0}),t("fix_list_elements",{processor:"boolean",default:!1}),t("preserve_cdata",{processor:"boolean",default:!1}),t("remove_trailing_brs",{processor:"boolean",default:!0}),t("pad_empty_with_br",{processor:"boolean",default:!1}),t("inline_styles",{processor:"boolean",default:!0,deprecated:!0}),t("element_format",{processor:"string",default:"html"}),t("entities",{processor:"string"}),t("schema",{processor:"string",default:"html5"}),t("convert_urls",{processor:"boolean",default:!0}),t("relative_urls",{processor:"boolean",default:!0}),t("remove_script_host",{processor:"boolean",default:!0}),t("custom_elements",{processor:"string"}),t("extended_valid_elements",{processor:"string"}),t("invalid_elements",{processor:"string"}),t("invalid_styles",{processor:vl}),t("valid_children",{processor:"string"}),t("valid_classes",{processor:vl}),t("valid_elements",{processor:"string"}),t("valid_styles",{processor:vl}),t("verify_html",{processor:"boolean",default:!0}),t("auto_focus",{processor:e=>m(e)||!0===e}),t("browser_spellcheck",{processor:"boolean",default:!1}),t("protect",{processor:"array"}),t("images_file_types",{processor:"string",default:"jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp"}),t("deprecation_warnings",{processor:"boolean",default:!0}),t("a11y_advanced_options",{processor:"boolean",default:!1}),t("api_key",{processor:"string"}),t("paste_block_drop",{processor:"boolean",default:!1}),t("paste_data_images",{processor:"boolean",default:!0}),t("paste_preprocess",{processor:"function"}),t("paste_postprocess",{processor:"function"}),t("paste_webkit_styles",{processor:"string",default:"none"}),t("paste_remove_styles_if_webkit",{processor:"boolean",default:!0}),t("paste_merge_formats",{processor:"boolean",default:!0}),t("smart_paste",{processor:"boolean",default:!0}),t("paste_as_text",{processor:"boolean",default:!1}
vendor: 19,889 bytes, lines 5168-5170
5168),t("paste_tab_spaces",{processor:"number",default:4}),t("text_patterns",{processor:e=>k(e,f)||!1===e?{value:ml(!1===e?[]:e),valid:!0}:{valid:!1,message:"Must be an array of objects or false."},default:[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}]}),t("text_patterns_lookup",{processor:e=>{return w(e)?{value:(t=e,e=>{const n=t(e);return ml(n)}),valid:!0}:{valid:!1,message:"Must be a single function"};var t},default:e=>[]}),t("noneditable_class",{processor:"string",default:"mceNonEditable"}),t("editable_class",{processor:"string",default:"mceEditable"}),t("noneditable_regexp",{processor:e=>k(e,hl)?{value:e,valid:!0}:hl(e)?{value:[e],valid:!0}:{valid:!1,message:"Must be a RegExp or an array of RegExp."},default:[]}),t("table_tab_navigation",{processor:"boolean",default:!0}),t("highlight_on_focus",{processor:"boolean",default:!1}),t("xss_sanitization",{processor:"boolean",default:!0}),t("details_initial_state",{processor:e=>{const t=H(["inherited","collapsed","expanded"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: inherited, collapsed, or expanded."}},default:"inherited"}),t("details_serialized_state",{processor:e=>{const t=H(["inherited","collapsed","expanded"],e);return t?{value:e,valid:t}:{valid:!1,message:"Must be one of: inherited, collapsed, or expanded."}},default:"inherited"}),t("init_content_sync",{processor:"boolean",default:!1}),t("newdocument_content",{processor:"string",default:""}),e.on("ScriptsLoaded",(()=>{t("directionality",{processor:"string",default:Ia.isRtl()?"rtl":void 0}),t("placeholder",{processor:"string",default:pl.getAttrib(e.getElement(),"placeholder")})}))})(o);const s=this.options.get;s("deprecation_warnings")&&((e,t)=>{((e,t)=>{const n=JC(e),o=tw(t),r=o.length>0,s=n.length>0,a="mobile"===t.theme;if(r||s||a){const e="\n- ",t=a?`\n\nThemes:${e}mobile`:"",i=r?`\n\nPlugins:${e}${o.join(e)}`:"",l=s?`\n\nOptions:${e}${n.join(e)}`:"";console.warn("The following deprecated features are currently enabled and have been removed in TinyMCE 6.0. These features will no longer work and should be removed from the TinyMCE configuration. See https://www.tiny.cloud/docs/tinymce/6/migration-from-5x/ for more information."+t+i+l)}})(e,t),((e,t)=>{const n=ZC(e),o=nw(t),r=o.length>0,s=n.length>0;if(r||s){const e="\n- ",t=r?`\n\nPlugins:${e}${o.map(ow).join(e)}`:"",a=s?`\n\nOptions:${e}${n.join(e)}`:"";console.warn("The following deprecated features are currently enabled but will be removed soon."+t+a)}})(e,t)})(t,r);const a=s("suffix");a&&(n.suffix=a),this.suffix=n.suffix;const i=s("base_url");i&&n._setBaseUrl(i),this.baseUri=n.baseURI;const l=Vl(o);l&&(Ba.ScriptLoader._setReferrerPolicy(l),Oa.DOM.styleSheetLoader._setReferrerPolicy(l));const d=Ed(o);C(d)&&Oa.DOM.styleSheetLoader._setContentCssCors(d),Fa.languageLoad=s("language_load"),Fa.baseURL=n.baseURL,this.setDirty(!1),this.documentBaseURI=new Hy(xl(o),{base_uri:this.baseUri}),this.baseURI=this.baseUri,this.inline=pd(o),this.hasVisual=Rd(o),this.shortcuts=new ST(this),this.editorCommands=new XO(this),KO(this);const c=s("cache_suffix");c&&(At.cacheSuffix=c.replace(/^[\?\&]+/,"")),this.ui={registry:_T(),styleSheetLoader:void 0,show:E,hide:E,setEnabled:E,isEnabled:M},this.mode=(e=>{const t=Da("design"),n=Da({design:{activate:E,deactivate:E,editorReadOnly:!1},readonly:{activate:E,deactivate:E,editorReadOnly:!0}});return(e=>{e.serializer?nT(e):e.on("PreInit",(()=>{nT(e)}))})(e),(e=>{e.on("ShowCaret",(t=>{tT(e)&&t.preventDefault()})),e.on("ObjectSelected",(t=>{tT(e)&&t.preventDefault()}))})(e),{isReadOnly:()=>tT(e),set:o=>((e,t,n,o)=>{if(o!==n.get()){if(!ke(t,o))throw new Error(`Editor mode '${o}' is invalid`);e.initialized?yT(e,n,t,o):e.on("init",(()=>yT(e,n,t,o)))}})(e,n.get(),t,o),get:()=>t.get(),register:(e,t)=>{n.set(((e,t,n)=>{if(H(vT,t))throw new Error(`Cannot override default mode ${t}`);return{...e,[t]:{...n,deactivate:()=>{try{n.deactivate()}catch(e){console.error(`problem while deactivating editor mode ${t}:`,e)}}}}})(n.get(),e,t))}}})(o),n.dispatch("SetupEditor",{editor:this});const g=Bd(o);w(g)&&g.call(o,o)}render(){(e=>{const t=e.id;Ia.setCode(ql(e));const n=()=>{wO.unbind(window,"ready",n),e.render()};if(!Ca.Event.domLoaded)return void wO.bind(window,"ready",n);if(!e.getElement())return;const o=yn(e.getElement()),r=rn(o);e.on("remove",(()=>{W(o.dom.attributes,(e=>on(o,e.name))),Zt(o,r)})),e.ui.styleSheetLoader=((e,t)=>Ms.forElement(e,{contentCssCors:Ed(t),referrerPolicy:Vl(t)}))(o,e),pd(e)?e.inline=!0:(e.orgVisibility=e.getElement().style.visibility,e.getElement().style.visibility="hidden");const s=e.getElement().form||wO.getParent(t,"form");s&&(e.formElement=s,hd(e)&&!Qo(e.getElement())&&(wO.insertAfter(wO.create("input",{type:"hidden",name:t}),t),e.hasHiddenInput=!0),e.formEventDelegate=t=>{e.dispatch(t.type,t)},wO.bind(s,"submit reset",e.formEventDelegate),e.on("reset",(()=>{e.resetContent()})),!bd(e)||s.submit.nodeType||s.submit.length||s._mceOldSubmit||(s._mceOldSubmit=s.submit,s.submit=()=>(e.editorManager.triggerSave(),e.setDirty(!1),s._mceOldSubmit(s)))),e.windowManager=bw(e),e.notificationManager=gw(e),(e=>"xml"===e.options.get("encoding"))(e)&&e.on("GetContent",(e=>{e.save&&(e.content=wO.encode(e.content))})),vd(e)&&e.on("submit",(()=>{e.initialized&&e.save()})),yd(e)&&(e._beforeUnload=()=>{!e.initialized||e.destroyed||e.isHidden()||e.save({format:"raw",no_events:!0,set_dirty:!1})},e.editorManager.on("BeforeUnload",e._beforeUnload)),e.editorManager.add(e),EO(e,e.suffix)})(this)}focus(e){this.execCommand("mceFocus",!1,e)}hasFocus(){return xg(this)}translate(e){return Ia.translate(e)}getParam(e,t,n){const o=this.options;return o.isRegistered(e)||(C(n)?o.register(e,{processor:n,default:t}):o.register(e,{processor:M,default:t})),o.isSet(e)||v(t)?o.get(e):t}hasPlugin(e,t){return!(!H(Sd(this),e)||t&&void 0===pw.get(e))}nodeChanged(e){this._nodeChangeDispatcher.nodeChanged(e)}addCommand(e,t,n){this.editorCommands.addCommand(e,t,n)}addQueryStateHandler(e,t,n){this.editorCommands.addQueryStateHandler(e,t,n)}addQueryValueHandler(e,t,n){this.editorCommands.addQueryValueHandler(e,t,n)}addShortcut(e,t,n,o){this.shortcuts.add(e,t,n,o)}execCommand(e,t,n,o){return this.editorCommands.execCommand(e,t,n,o)}queryCommandState(e){return this.editorCommands.queryCommandState(e)}queryCommandValue(e){return this.editorCommands.queryCommandValue(e)}queryCommandSupported(e){return this.editorCommands.queryCommandSupported(e)}show(){const e=this;e.hidden&&(e.hidden=!1,e.inline?e.getBody().contentEditable="true":(NT.show(e.getContainer()),NT.hide(e.id)),e.load(),e.dispatch("show"))}hide(){const e=this;e.hidden||(e.save(),e.inline?(e.getBody().contentEditable="false",e===e.editorManager.focusedEditor&&(e.editorManager.focusedEditor=null)):(NT.hide(e.getContainer()),NT.setStyle(e.id,"display",e.orgDisplay)),e.hidden=!0,e.dispatch("hide"))}isHidden(){return this.hidden}setProgressState(e,t){this.dispatch("ProgressState",{state:e,time:t})}load(e={}){const t=this,n=t.getElement();if(t.removed)return"";if(n){const o={...e,load:!0},r=Qo(n)?n.value:n.innerHTML,s=t.setContent(r,o);return o.no_events||t.dispatch("LoadContent",{...o,element:n}),s}return""}save(e={}){const t=this;let n=t.getElement();if(!n||!t.initialized||t.removed)return"";const o={...e,save:!0,element:n};let r=t.getContent(o);const s={...o,content:r};if(s.no_events||t.dispatch("SaveContent",s),"raw"===s.format&&t.dispatch("RawSaveContent",s),r=s.content,Qo(n))n.value=r;else{!e.is_removing&&t.inline||(n.innerHTML=r);const o=NT.getParent(t.id,"form");o&&AT(o.elements,(e=>e.name!==t.id||(e.value=r,!1)))}return s.element=o.element=n=null,!1!==s.set_dirty&&t.setDirty(!1),r}setContent(e,t){return WC(this,e,t)}getContent(e){return((e,t={})=>{const n=((e,t)=>({...e,format:t,get:!0,getInner:!0}))(t,t.format?t.format:"html");return oC(e,n).fold(R,(t=>{const n=((e,t)=>LC(e).editor.getContent(t))(e,t);return rC(e,n,t)}))})(this,e)}insertContent(e,t){t&&(e=RT({content:e},t)),this.execCommand("mceInsertContent",!1,e)}resetContent(e){void 0===e?WC(this,this.startContent,{format:"raw"}):WC(this,e),this.undoManager.reset(),this.setDirty(!1),this.nodeChanged()}isDirty(){return!this.isNotDirty}setDirty(e){const t=!this.isNotDirty;this.isNotDirty=!e,e&&e!==t&&this.dispatch("dirty")}getContainer(){const e=this;return e.container||(e.container=e.editorContainer||NT.get(e.id+"_parent")),e.container}getContentAreaContainer(){return this.contentAreaContainer}getElement(){return this.targetElm||(this.targetElm=NT.get(this.id)),this.targetElm}getWin(){const e=this;if(!e.contentWindow){const t=e.iframeElement;t&&(e.contentWindow=t.contentWindow)}return e.contentWindow}getDoc(){const e=this;if(!e.contentDocument){const t=e.getWin();t&&(e.contentDocument=t.document)}return e.contentDocument}getBody(){var e,t;const n=this.getDoc();return null!==(t=null!==(e=this.bodyElement)&&void 0!==e?e:null==n?void 0:n.body)&&void 0!==t?t:null}convertURL(e,t,n){const o=this,r=o.options.get,s=Pd(o);return w(s)?s.call(o,e,n,!0,t):!r("convert_urls")||"link"===n||f(n)&&"LINK"===n.nodeName||0===e.indexOf("file:")||0===e.length?e:r("relative_urls")?o.documentBaseURI.toRelative(e):e=o.documentBaseURI.toAbsolute(e,r("remove_script_host"))}addVisual(e){((e,t)=>{((e,t)=>{MC(e).editor.addVisual(t)})(e,t)})(this,e)}setEditableRoot(e){((e,t)=>{e._editableRoot!==t&&(e._editableRoot=t,e.readonly||(e.getBody().contentEditable=String(e.hasEditableRoot()),e.nodeChanged()),((e,t)=>{e.dispatch("EditableRootStateChange",{state:t})})(e,t))})(this,e)}hasEditableRoot(){return this._editableRoot}remove(){(e=>{if(!e.removed){const{_selectionOverrides:t,editorUpload:n}=e,o=e.getBody(),r=e.getElement();o&&e.save({is_removing:!0}),e.removed=!0,e.unbindAllNativeEvents(),e.hasHiddenInput&&C(null==r?void 0:r.nextSibling)&&rw.remove(r.nextSibling),(e=>{e.dispatch("remove")})(e),e.editorManager.remove(e),!e.inline&&o&&(e=>{rw.setStyle(e.id,"display",e.orgDisplay)})(e),(e=>{e.dispatch("detach")})(e),rw.remove(e.getContainer()),sw(t),sw(n),e.destroy()}})(this)}destroy(e){((e,t)=>{const{selection:n,dom:o}=e;e.destroyed||(t||e.removed?(t||(e.editorManager.off("beforeunload",e._beforeUnload),e.theme&&e.theme.destroy&&e.theme.destroy(),sw(n),sw(o)),(e=>{const t=e.formElement;t&&(t._mceOldSubmit&&(t.submit=t._mceOldSubmit,delete t._mceOldSubmit),rw.unbind(t,"submit reset",e.formEventDelegate))})(e),(e=>{const t=e;t.contentAreaContainer=t.formElement=t.container=t.editorContainer=null,t.bodyElement=t.contentDocument=t.contentWindow=null,t.iframeElement=t.targetElm=null;const n=e.selection;if(n){const e=n.dom;t.selection=n.win=n.dom=e.doc=null}})(e),e.destroyed=!0):e.remove())})(this,e)}uploadImages(){return this.editorUpload.uploadImages()}_scanForImages(){return this.editorUpload.scanForImages()}}const TT=Oa.DOM,BT=Dt.each;let DT,PT=!1,LT=[];const MT=e=>{const t=e.type;BT(zT.get(),(n=>{switch(t){case"scroll":n.dispatch("ScrollWindow",e);break;case"resize":n.dispatch("ResizeWindow",e)}}))},IT=e=>{if(e!==PT){const t=Oa.DOM;e?(t.bind(window,"resize",MT),t.bind(window,"scroll",MT)):(t.unbind(window,"resize",MT),t.unbind(window,"scroll",MT)),PT=e}},FT=e=>{const t=LT;return LT=G(LT,(t=>e!==t)),zT.activeEditor===e&&(zT.activeEditor=LT.length>0?LT[0]:null),zT.focusedEditor===e&&(zT.focusedEditor=null),t.length!==LT.length},UT="CSS1Compat"!==document.compatMode,zT={...iT,baseURI:null,baseURL:null,defaultOptions:{},documentBaseURL:null,suffix:null,majorVersion:"6",minorVersion:"7.0",releaseDate:"2023-08-30",i18n:Ia,activeEditor:null,focusedEditor:null,setup(){const e=this;let t="",n="",o=Hy.getDocumentBaseUrl(document.location);/^[^:]+:\/\/\/?[^\/]+\//.test(o)&&(o=o.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(o)||(o+="/"));const r=window.tinymce||window.tinyMCEPreInit;if(r)t=r.base||r.baseURL,n=r.suffix;else{const e=document.getElementsByTagName("script");for(let o=0;o<e.length;o++){const r=e[o].src||"";if(""===r)continue;const s=r.substring(r.lastIndexOf("/"));if(/tinymce(\.full|\.jquery|)(\.min|\.dev|)\.js/.test(r)){-1!==s.indexOf(".min")&&(n=".min"),t=r.substring(0,r.lastIndexOf("/"));break}}if(!t&&document.currentScript){const e=document.currentScript.src;-1!==e.indexOf(".min")&&(n=".min"),t=e.substring(0,e.lastIndexOf("/"))}}var s;e.baseURL=new Hy(o).toAbsolute(t),e.documentBaseURL=o,e.baseURI=new Hy(e.baseURL),e.suffix=n,(s=e).on("AddEditor",O(vg,s)),s.on("RemoveEditor",O(yg,s))},overrideDefaults(e){const t=e.base_url;t&&this._setBaseUrl(t);const n=e.suffix;n&&(this.suffix=n),this.defaultOptions=e;const o=e.plugin_base_urls;void 0!==o&&ge(o,((e,t)=>{Fa.PluginManager.urls[t]=e}))},init(e){const t=this;let n;const o=Dt.makeMap("area base basefont br col frame hr img input isindex link meta param embed source wbr track colgroup option table tbody tfoot thead tr th td script noscript style textarea video audio iframe object menu"," ");let r=e=>{n=e};const s=()=>{let n=0;const a=[];let i;TT.unbind(window,"ready",s),(n=>{const o=e.onpageload;o&&o.apply(t,[])})(),i=((e,t)=>{const n=[],o=w(t)?e=>$(n,(n=>t(n,e))):e=>H(n,e);for(let t=0,r=e.length;t<r;t++){const r=e[t];o(r)||n.push(r)}return n})((e=>At.browser.isIE()||At.browser.isEdge()?(xw("TinyMCE does not support the browser you are using. For a list of supported browsers please see: https://www.tiny.cloud/docs/tinymce/6/support/#supportedwebbrowsers"),[]):UT?(xw("Failed to initialize the editor as the document is not in standards mode. TinyMCE requires standards mode."),[]):m(e.selector)?TT.select(e.selector):C(e.target)?[e.target]:[])(e)),Dt.each(i,(e=>{var n;(n=t.get(e.id))&&n.initialized&&!(n.getContainer()||n.getBody()).parentNode&&(FT(n),n.unbindAllNativeEvents(),n.destroy(!0),n.removed=!0)})),i=Dt.grep(i,(e=>!t.get(e.id))),0===i.length?r([]):BT(i,(s=>{((e,t)=>e.inline&&t.tagName.toLowerCase()in o)(e,s)?xw("Could not initialize inline editor on invalid inline target element",s):((e,o,s)=>{const l=new OT(e,o,t);a.push(l),l.on("init",(()=>{++n===i.length&&r(a)})),l.targetElm=l.targetElm||s,l.render()})((e=>{let t=e.id;return t||(t=xe(e,"name").filter((e=>!TT.get(e))).getOrThunk(TT.uniqueId),e.setAttribute("id",t)),t})(s),e,s)}))};return TT.bind(window,"ready",s),new Promise((e=>{n?e(n):r=t=>{e(t)}}))},get(e){return 0===arguments.length?LT.slice(0):m(e)?J(LT,(t=>t.id===e)).getOr(null):x(e)&<[e]?LT[e]:null},add(e){const t=this,n=t.get(e.id);return n===e||(null===n&<.push(e),IT(!0),t.activeEditor=e,t.dispatch("AddEditor",{editor:e}),DT||(DT=e=>{const n=t.dispatch("BeforeUnload");if(n.returnValue)return e.preventDefault(),e.returnValue=n.returnValue,n.returnValue},window.addEventListener("beforeunload",DT))),e},createEditor(e,t){return this.add(new OT(e,t,this))},remove(e){const t=this;let n;if(e){if(!m(e))return n=e,h(t.get(n.id))?null:(FT(n)&&t.dispatch("RemoveEditor",{editor:n}),0===LT.length&&window.removeEventListener("beforeunload",DT),n.remove(),IT(LT.length>0),n);BT(TT.select(e),(e=>{n=t.get(e.id),n&&t.remove(n)}))}else for(let e=LT.length-1;e>=0;e--)t.remove(LT[e])},execCommand(e,t,n){var o;const r=this,s=f(n)?null!==(o=n.id)&&void 0!==o?o:n.index:n;switch(e){case"mceAddEditor":if(!r.get(s)){const e=n.options;new OT(s,e,r).render()}return!0;case"mceRemoveEditor":{const e=r.get(s);return e&&e.remove(),!0}case"mceToggleEditor":{const e=r.get(s);return e?(e.isHidden()?e.show():e.hide(),!0):(r.execCommand("mceAddEditor",!1,n),!0)}}return!!r.activeEditor&&r.activeEditor.execCommand(e,t,n)},triggerSave:()=>{BT(LT,(e=>{e.save()}))},addI18n:(e,t)=>{Ia.add(e,t)},translate:e=>Ia.translate(e),setActive(e){const t=this.activeEditor;this.activeEditor!==e&&(t&&t.dispatch("deactivate",{relatedTarget:e}),e.dispatch("activate",{relatedTarget:t})),this.activeEditor=e},_setBaseUrl(e){this.baseURL=new Hy(this.documentBaseURL).toAbsolute(e.replace(/\/+$/,"")),this.baseURI=new Hy(this.baseURL)}};zT.setup();const jT=(()=>{const e=za();return{FakeClipboardItem:e=>({items:e,types:me(e),getType:t=>xe(e,t).getOrUndefined()}),write:t=>{e.set(t)},read:()=>e.get().getOrUndefined(),clear:e.clear}})(),HT=Math.min,$T=Math.max,VT=Math.round,qT=(e,t,n)=>{let o=t.x,r=t.y;const s=e.w,a=e.h,i=t.w,l=t.h,d=(n||"").split("");return"b"===d[0]&&(r+=l),"r"===d[1]&&(o+=i),"c"===d[0]&&(r+=VT(l/2)),"c"===d[1]&&(o+=VT(i/2)),"b"===d[3]&&(r-=a),"r"===d[4]&&(o-=s),"c"===d[3]&&(r-=VT(a/2)),"c"===d[4]&&(o-=VT(s/2)),WT(o,r,s,a)},WT=(e,t,n,o)=>({x:e,y:t,w:n,h:o}),KT={inflate:(e,t,n)=>WT(e.x-t,e.y-n,e.w+2*t,e.h+2*n),relativePosition:qT,findBestRelativePosition:(e,t,n,o)=>{for(let r=0;r<o.length;r++){const s=qT(e,t,o[r]);if(s.x>=n.x&&s.x+s.w<=n.w+n.x&&s.y>=n.y&&s.y+s.h<=n.h+n.y)return o[r]}return null},intersect:(e,t)=>{const n=$T(e.x,t.x),o=$T(e.y,t.y),r=HT(e.x+e.w,t.x+t.w),s=HT(e.y+e.h,t.y+t.h);return r-n<0||s-o<0?null:WT(n,o,r-n,s-o)},clamp:(e,t,n)=>{let o=e.x,r=e.y,s=e.x+e.w,a=e.y+e.h;const i=t.x+t.w,l=t.y+t.h,d=$T(0,t.x-o),c=$T(0,t.y-r),u=$T(0,s-i),m=$T(0,a-l);return o+=d,r+=c,n&&(s+=d,a+=c,o-=u,r-=m),s-=u,a-=m,WT(o,r,s-o,a-r)},create:WT,fromClientRect:e=>WT(e.left,e.top,e.width,e.height)},GT=(()=>{const e={},t={};return{load:(n,o)=>{const r=`Script at URL "${o}" failed to load`,s=`Script at URL "${o}" did not call \`tinymce.Resource.add('${n}', data)\` within 1 second`;if(void 0!==e[n])return e[n];{const a=new Promise(((e,a)=>{const i=((e,t,n=1e3)=>{let o=!1,r=null;const s=e=>(...t)=>{o||(o=!0,null!==r&&(clearTimeout(r),r=null),e.apply(null,t))},a=s(e),i=s(t);return{start:(...e)=>{o||null!==r||(r=setTimeout((()=>i.apply(null,e)),n))},resolve:a,reject:i}})(e,a);t[n]=i.resolve,Ba.ScriptLoader.loadScript(o).then((()=>i.start(s)),(()=>i.reject(r)))}));return e[n]=a,a}},add:(n,o)=>{void 0!==t[n]&&(t[n](o),delete t[n]),e[n]=Promise.resolve(o)},unload:t=>{delete e[t]}}})();let YT;try{const e="__storage_test__";YT=window.localStorage,YT.setItem(e,e),YT.removeItem(e)}catch(e){YT=(()=>{let e={},t=[];const n={getItem:t=>e[t]||null,setItem:(n,o)=>{t.push(n),e[n]=String(o)},key:e=>t[e],removeItem:n=>{t=t.filter((e=>e===n)),delete e[n]},clear:()=>{t=[],e={}},length:0};return Object.defineProperty(n,"length",{get:()=>t.length,configurable:!1,enumerable:!1}),n})()}const XT={geom:{Rect:KT},util:{Delay:mg,Tools:Dt,VK:ef,URI:Hy,EventDispatcher:sT,Observable:iT,I18n:Ia,LocalStorage:YT,ImageUploader:e=>{const t=Sw(),n=Aw(e,t);return{upload:(t,o=!0)=>n.upload(t,o?Rw(e):void 0)}}},dom:{EventUtils:Ca,TreeWalker:zo,TextSeeker:ai,DOMUtils:Oa,ScriptLoader:Ba,RangeUtils:Df,Serializer:qC,StyleSheetLoader:Ls,ControlSelection:sf,BookmarkManager:Wm,Selection:HC,Event:Ca.Event},html:{Styles:ua,Entities:Zs,Node:Fg,Schema:ca,DomParser:tC,Writer:Kg,Serializer:Gg},Env:At,AddOnManager:Fa,Annotator:qm,Formatter:jw,UndoManager:$w,EditorCommands:XO,WindowManager:bw,NotificationManager:gw,EditorObservable:fT,Shortcuts:ST,Editor:OT,FocusManager:ug,EditorManager:zT,DOM:Oa.DOM,ScriptLoader:Ba.ScriptLoader,PluginManager:pw,ThemeManager:hw,ModelManager:iw,IconManager:aw,Resource:GT,FakeClipboard:jT,trim:Dt.trim,isArray:Dt.isArray,is:Dt.is,toArray:Dt.toArray,makeMap:Dt.makeMap,each:Dt.each,map:Dt.map,grep:Dt.grep,inArray:Dt.inArray,extend:Dt.extend,walk:Dt.walk,resolve:Dt.resolve,explode:Dt.explode,_addCacheSuffix:Dt._addCacheSuffix},QT=Dt.extend(zT,XT);(e=>{window.tinymce=e,window.tinyMCE=e})(QT),(e=>{if("object"==typeof module)try{module.exports=e}catch(e){}})(QT)}();; 5169 5170 !function(b,a){"function"==typeof define&&define.amd?define("sifter",a):"object"==typeof exports?module.exports=a():b.Sifter=a()}(this,function(){var a=function(a,b){this.items=a,this.settings=b||{diacritics:!0}};a.prototype.tokenize=function(b){if(!(b=e(String(b||"").toLowerCase()))||!b.length)return[];
5170var a,i,c,d,j=[],g=b.split(/ +/);for(a=0,i=g.length;a<i;a++){if(c=f(g[a]),this.settings.diacritics)for(d in h)h.hasOwnProperty(d)&&(c=c.replace(new RegExp(d,"g"),h[d]));j.push({string:g[a],regex:new RegExp(c,"i")})}return j},a.prototype.iterator=function(a,b){(g(a)?Array.prototype.forEach||function(b){for(var a=0,c=this.length;a<c;a++)b(this[a],a,this)}:function(b){for(var a in this)this.hasOwnProperty(a)&&b(this[a],a,this)}).apply(a,[b])},a.prototype.getScoreFunction=function(a,e){g=this,h=(a=g.prepareSearch(a,e)).tokens,f=a.options.fields,b=h.length,i=a.options.nesting;var g,f,h,b,i,c,j=function(a,c){var b,d;return a&& -1!==(d=(a=String(a||"")).search(c.regex))?(b=c.string.length/a.length,0===d&&(b+=.5),b):0},k=(c=f.length)?1===c?function(a,b){return j(d(b,f[0],i),a)}:function(e,g){for(var a=0,b=0;a<c;a++)b+=j(d(g,f[a],i),e);return b/c}:function(){return 0};return b?1===b?function(a){return k(h[0],a)}:"and"===a.options.conjunction?function(e){for(var c,a=0,d=0;a<b;a++){if((c=k(h[a],e))<=0)return 0;d+=c}return d/b}:function(d){for(var a=0,c=0;a<b;a++)c+=k(h[a],d);return c/b}:function(){return 0}},a.prototype.getSortFunction=function(g,h){var a,e,k,m,c,l,n,i,o,j,f;if(k=this,f=!(g=k.prepareSearch(g,h)).query&&h.sort_empty||h.sort,o=function(a,b){return"$score"===a?b.score:d(k.items[b.id],a,h.nesting)},c=[],f)for(a=0,e=f.length;a<e;a++)(g.query||"$score"!==f[a].field)&&c.push(f[a]);if(g.query){for(a=0,j=!0,e=c.length;a<e;a++)if("$score"===c[a].field){j=!1;break}j&&c.unshift({field:"$score",direction:"desc"})}else for(a=0,e=c.length;a<e;a++)if("$score"===c[a].field){c.splice(a,1);break}for(a=0,i=[],e=c.length;a<e;a++)i.push("desc"===c[a].direction?-1:1);return(l=c.length)?1===l?(m=c[0].field,n=i[0],function(a,c){return n*b(o(m,a),o(m,c))}):function(f,g){var a,e,d;for(a=0;a<l;a++)if(d=c[a].field,e=i[a]*b(o(d,f),o(d,g)))return e;return 0}:null},a.prototype.prepareSearch=function(b,a){if("object"==typeof b)return b;var d=(a=c({},a)).fields,e=a.sort,f=a.sort_empty;return d&&!g(d)&&(a.fields=[d]),e&&!g(e)&&(a.sort=[e]),f&&!g(f)&&(a.sort_empty=[f]),{options:a,query:String(b||"").toLowerCase(),tokens:this.tokenize(b),total:0,items:[]}},a.prototype.search=function(c,b){var d,e,f,a;return b=(a=this.prepareSearch(c,b)).options,c=a.query,e=b.score||this.getScoreFunction(a),c.length?this.iterator(this.items,function(c,d){f=e(c),(!1===b.filter||f>0)&&a.items.push({score:f,id:d})}):this.iterator(this.items,function(c,b){a.items.push({score:1,id:b})}),d=this.getSortFunction(a,b),d&&a.items.sort(d),a.total=a.items.length,"number"==typeof b.limit&&(a.items=a.items.slice(0,b.limit)),a};var b=function(a,b){return"number"==typeof a&&"number"==typeof b?a>b?1:a<b?-1:0:(a=i(String(a||"")),b=i(String(b||"")),a>b)?1:b>a?-1:0},c=function(d,f){var a,e,b,c;for(a=1,e=arguments.length;a<e;a++)if(c=arguments[a])for(b in c)c.hasOwnProperty(b)&&(d[b]=c[b]);return d},d=function(a,b,d){if(a&&b){if(!d)return a[b];for(var c=b.split(".");c.length&&(a=a[c.shift()]););return a}},e=function(a){return(a+"").replace(/^\s+|\s+$|/g,"")},f=function(a){return(a+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")},g=Array.isArray||"undefined"!=typeof $&&$.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},h={a:"[a\u1E00\u1E01\u0102\u0103\xc2\xe2\u01CD\u01CE\u023A\u2C65\u0226\u0227\u1EA0\u1EA1\xc4\xe4\xc0\xe0\xc1\xe1\u0100\u0101\xc3\xe3\xc5\xe5\u0105\u0104\xc3\u0105\u0104]",b:"[b\u2422\u03B2\u0392B\u0E3F\u{10301}\u16D2]",c:"[c\u0106\u0107\u0108\u0109\u010C\u010D\u010A\u010BC\u0304c\u0304\xc7\xe7\u1E08\u1E09\u023B\u023C\u0187\u0188\u0255\u1D04\uFF23\uFF43]",d:"[d\u010E\u010F\u1E0A\u1E0B\u1E10\u1E11\u1E0C\u1E0D\u1E12\u1E13\u1E0E\u1E0F\u0110\u0111D\u0326d\u0326\u0189\u0256\u018A\u0257\u018B\u018C\u1D6D\u1D81\u1D91\u0221\u1D05\uFF24\uFF44\xf0]",e:"[e\xc9\xe9\xc8\xe8\xca\xea\u1E18\u1E19\u011A\u011B\u0114\u0115\u1EBC\u1EBD\u1E1A\u1E1B\u1EBA\u1EBB\u0116\u0117\xcb\xeb\u0112\u0113\u0228\u0229\u0118\u0119\u1D92\u0246\u0247\u0204\u0205\u1EBE\u1EBF\u1EC0\u1EC1\u1EC4\u1EC5\u1EC2\u1EC3\u1E1C\u1E1D\u1E16\u1E17\u1E14\u1E15\u0206\u0207\u1EB8\u1EB9\u1EC6\u1EC7\u2C78\u1D0
51707\uFF25\uFF45\u0258\u01DD\u018F\u0190\u03B5]",f:"[f\u0191\u0192\u1E1E\u1E1F]",g:"[g\u0262\u20B2\u01E4\u01E5\u011C\u011D\u011E\u011F\u0122\u0123\u0193\u0260\u0120\u0121]",h:"[h\u0124\u0125\u0126\u0127\u1E28\u1E29\u1E96\u1E96\u1E24\u1E25\u1E22\u1E23\u0266\u02B0\u01F6\u0195]",i:"[i\xcd\xed\xcc\xec\u012C\u012D\xce\xee\u01CF\u01D0\xcf\xef\u1E2E\u1E2F\u0128\u0129\u012E\u012F\u012A\u012B\u1EC8\u1EC9\u0208\u0209\u020A\u020B\u1ECA\u1ECB\u1E2C\u1E2D\u0197\u0268\u0268\u0306\u1D7B\u1D96\u0130iI\u0131\u026A\uFF29\uFF49]",j:"[j\u0237\u0134\u0135\u0248\u0249\u029D\u025F\u02B2]",k:"[k\u0198\u0199\uA740\uA741\u1E30\u1E31\u01E8\u01E9\u1E32\u1E33\u1E34\u1E35\u03BA\u03F0\u20AD]",l:"[l\u0141\u0142\u013D\u013E\u013B\u013C\u0139\u013A\u1E36\u1E37\u1E38\u1E39\u1E3C\u1E3D\u1E3A\u1E3B\u013F\u0140\u023D\u019A\u2C60\u2C61\u2C62\u026B\u026C\u1D85\u026D\u0234\u029F\uFF2C\uFF4C]",n:"[n\u0143\u0144\u01F8\u01F9\u0147\u0148\xd1\xf1\u1E44\u1E45\u0145\u0146\u1E46\u1E47\u1E4A\u1E4B\u1E48\u1E49N\u0308n\u0308\u019D\u0272\u0220\u019E\u1D70\u1D87\u0273\u0235\u0274\uFF2E\uFF4E\u014A\u014B]",o:"[o\xd8\xf8\xd6\xf6\xd3\xf3\xd2\xf2\xd4\xf4\u01D1\u01D2\u0150\u0151\u014E\u014F\u022E\u022F\u1ECC\u1ECD\u019F\u0275\u01A0\u01A1\u1ECE\u1ECF\u014C\u014D\xd5\xf5\u01EA\u01EB\u020C\u020D\u0555\u0585]",p:"[p\u1E54\u1E55\u1E56\u1E57\u2C63\u1D7D\u01A4\u01A5\u1D71]",q:"[q\uA756\uA757\u02A0\u024A\u024B\uA758\uA759q\u0303]",r:"[r\u0154\u0155\u024C\u024D\u0158\u0159\u0156\u0157\u1E58\u1E59\u0210\u0211\u0212\u0213\u1E5A\u1E5B\u2C64\u027D]",s:"[s\u015A\u015B\u1E60\u1E61\u1E62\u1E63\uA7A8\uA7A9\u015C\u015D\u0160\u0161\u015E\u015F\u0218\u0219S\u0308s\u0308]",t:"[t\u0164\u0165\u1E6A\u1E6B\u0162\u0163\u1E6C\u1E6D\u01AE\u0288\u021A\u021B\u1E70\u1E71\u1E6E\u1E6F\u01AC\u01AD]",u:"[u\u016C\u016D\u0244\u0289\u1EE4\u1EE5\xdc\xfc\xda\xfa\xd9\xf9\xdb\xfb\u01D3\u01D4\u0170\u0171\u016C\u016D\u01AF\u01B0\u1EE6\u1EE7\u016A\u016B\u0168\u0169\u0172\u0173\u0214\u0215\u222A]",v:"[v\u1E7C\u1E7D\u1E7E\u1E7F\u01B2\u028B\uA75E\uA75F\u2C71\u028B]",w:"[w\u1E82\u1E83\u1E80\u1E81\u0174\u0175\u1E84\u1E85\u1E86\u1E87\u1E88\u1E89]",x:"[x\u1E8C\u1E8D\u1E8A\u1E8B\u03C7]",y:"[y\xdd\xfd\u1EF2\u1EF3\u0176\u0177\u0178\xff\u1EF8\u1EF9\u1E8E\u1E8F\u1EF4\u1EF5\u024E\u024F\u01B3\u01B4]",z:"[z\u0179\u017A\u1E90\u1E91\u017D\u017E\u017B\u017C\u1E92\u1E93\u1E94\u1E95\u01B5\u01B6]"},i=function(){var b,d,a,c,e="",f={};for(a in h)if(h.hasOwnProperty(a))for(e+=c=h[a].substring(2,h[a].length-1),b=0,d=c.length;b<d;b++)f[c.charAt(b)]=a;var g=new RegExp("["+e+"]","g");return function(a){return a.replace(g,function(a){return f[a]}).toLowerCase()}}();return a}),function(b,a){"function"==typeof define&&define.amd?define("microplugin",a):"object"==typeof exports?module.exports=a():b.MicroPlugin=a()}(this,function(){var a={};a.mixin=function(a){a.plugins={},a.prototype.initializePlugins=function(a){var c,g,d,f=this,e=[];if(f.plugins={names:[],settings:{},requested:{},loaded:{}},b.isArray(a))for(c=0,g=a.length;c<g;c++)"string"==typeof a[c]?e.push(a[c]):(f.plugins.settings[a[c].name]=a[c].options,e.push(a[c].name));else if(a)for(d in a)a.hasOwnProperty(d)&&(f.plugins.settings[d]=a[d],e.push(d));for(;e.length;)f.require(e.shift())},a.prototype.loadPlugin=function(b){var c=this.plugins,d=a.plugins[b];if(!a.plugins.hasOwnProperty(b))throw new Error('Unable to find "'+b+'" plugin');c.requested[b]=!0,c.loaded[b]=d.fn.apply(this,[this.plugins.settings[b]||{}]),c.names.push(b)},a.prototype.require=function(a){var b=this.plugins;if(!this.plugins.loaded.hasOwnProperty(a)){if(b.requested[a])throw new Error('Plugin has circular dependency ("'+a+'")');this.loadPlugin(a)}return b.loaded[a]},a.define=function(b,c){a.plugins[b]={name:b,fn:c}}};var b={isArray:Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)}};return a}),function(a,b){"function"==typeof define&&define.amd?define("selectize",["jquery","sifter","microplugin"],b):"object"==typeof exports?module.exports=b(require("jquery"),require("sifter"),require("microplugin")):a.Selectize=b(scriptJquery,a.Sifter,a.MicroPlugin)}(this,function($,i,d){"use strict";var e,b,j=function(b,a){if("string"!=typeof a||a.length){var c="string"==typeof a?new RegExp(a,"i"):a,d=function(a){var g=0;if(3===a.nodeType){var h=a.data.search(c);if(h>=0&&a.data.length>0){var i=a.data.match(c),f=document.createElement("span");f.className="highlight";var b=a.splitText(h);b.splitText(i[0].length);var j=b.cloneNode(!0);f.appendChild(j),b.parentNode.replaceChild(f,b),g=1}}else if(1===a.nodeType&&a.childNodes&&!/(script|style)/i.test(a.tagName)&&("highlight"!==a.className||"SPAN"!==a.tagName))for(var e=0;e<a.childNodes.length;++e)e+=d(a.childNodes[e]);return g};return b.each(function(){d(this)})}};$.fn.removeHighlight=function(){return this.find("span.highlight").each(function(){this.parentNode.firstChild.nodeName;var a=this.parentNode;a.replaceChild(this.firstChild,this),a.normalize()}).end()};var c=function(){};c.prototype={on:function(a,b){this._events=this._events||{},this._events[a]=this._events[a]||[],this._events[a].push(b)},off:function(a,c){var b=arguments.length;return 0===b?delete this._events:1===b?delete this._events[a]:void(this._events=this._events||{},a in this._events!= !1&&this._events[a].splice(this._events[a].indexOf(c),1))}
5170,trigger:function(a){if(this._events=this._events||{},a in this._events!= !1)for(var b=0;b<this._events[a].length;b++)this._events[a][b].apply(this,Array.prototype.slice.call(arguments,1))}},c.mixin=function(d){for(var b=["on","off","trigger"],a=0;a<b.length;a++)d.prototype[b[a]]=c.prototype[b[a]]};var f=/Mac/.test(navigator.userAgent),k=f?91:17,l=f?18:17,h=!/android/i.test(window.navigator.userAgent)&&!!document.createElement("input").validity,m=function(a){return void 0!==a},n=function(a){return null==a?null:"boolean"==typeof a?a?"1":"0":a+""},o=function(a){return(a+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},g={};g.before=function(a,b,c){var d=a[b];a[b]=function(){return c.apply(a,arguments),d.apply(a,arguments)}},g.after=function(a,b,c){var d=a[b];a[b]=function(){var b=d.apply(a,arguments);return c.apply(a,arguments),b}};var p=function(a){var b=!1;return function(){b||(b=!0,a.apply(this,arguments))}},q=function(a,b){var c;return function(){var d=this,e=arguments;window.clearTimeout(c),c=window.setTimeout(function(){a.apply(d,e)},b)}},r=function(a,f,e){var b,d=a.trigger,c={};for(b in a.trigger=function(){var b=arguments[0];if(-1===f.indexOf(b))return d.apply(a,arguments);c[b]=arguments},e.apply(a,[]),a.trigger=d,c)c.hasOwnProperty(b)&&d.apply(a,c[b])},s=function(a,b,c,d){a.on(b,c,function(c){for(var b=c.target;b&&b.parentNode!==a[0];)b=b.parentNode;return c.currentTarget=b,d.apply(this,[c])})},t=function(b){var a={};if("selectionStart"in b)a.start=b.selectionStart,a.length=b.selectionEnd-a.start;else if(document.selection){b.focus();var c=document.selection.createRange(),d=document.selection.createRange().text.length;c.moveStart("character",-b.value.length),a.start=c.text.length-d,a.length=d}return a},u=function(d,f,b){var a,e,c={};if(b)for(a=0,e=b.length;a<e;a++)c[b[a]]=d.css(b[a]);else c=d.css();f.css(c)},v=function(c){var d=null,b=function(g,i){var b,e,m,j,k,n,h,f,l,o;g=g||window.event||{},i=i||{},g.metaKey||g.altKey||(i.force|| !1!==c.data("grow"))&&(b=c.val(),g.type&&"keydown"===g.type.toLowerCase()&&(m=(e=g.keyCode)>=48&&e<=57||e>=65&&e<=90||e>=96&&e<=111||e>=186&&e<=222||32===e,46===e||8===e?(f=t(c[0])).length?b=b.substring(0,f.start)+b.substring(f.start+f.length):8===e&&f.start?b=b.substring(0,f.start-1)+b.substring(f.start+1):46===e&& void 0!==f.start&&(b=b.substring(0,f.start)+b.substring(f.start+1)):m&&(n=g.shiftKey,h=String.fromCharCode(g.keyCode),b+=h=n?h.toUpperCase():h.toLowerCase())),j=c.attr("placeholder"),!b&&j&&(b=j),(k=(l=b,o=c,(l?(a.$testInput||(a.$testInput=$("<span />").css({position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}).appendTo("body")),a.$testInput.text(l),u(o,a.$testInput,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),a.$testInput.width()):0)+4))!==d&&(d=k,c.width(k),c.triggerHandler("resize")))};c.on("keydown keyup update blur",b),b()},w=function(b){var a=document.createElement("div");return a.appendChild(b.cloneNode(!0)),a.innerHTML},a=function(d,f){var c,g,h,e,b=this;(e=d[0]).selectize=b;var j=window.getComputedStyle&&window.getComputedStyle(e,null);if(h=(h=j?j.getPropertyValue("direction"):e.currentStyle&&e.currentStyle.direction)||d.parents("[dir]:first").attr("dir")||"",$.extend(b,{order:0,settings:f,$input:d,tabIndex:d.attr("tabindex")||"",tagType:"select"===e.tagName.toLowerCase()?1:2,rtl:/rtl/i.test(h),eventNS:".selectize"+ ++a.count,highlightedValue:null,isBlurring:!1,isOpen:!1,isDisabled:!1,isRequired:d.is("[required]"),isInvalid:!1,isLocked:!1,isFocused:!1,isInputHidden:!1,isSetup:!1,isShiftDown:!1,isCmdDown:!1,isCtrlDown:!1,ignoreFocus:!1,ignoreBlur:!1,ignoreHover:!1,hasOptions:!1,currentResults:null,lastValue:"",caretPos:0,loading:0,loadedSearches:{},$activeOption:null,$activeItems:[],optgroups:{},options:{},userOptions:{},items:[],renderCache:{},onSearchChange:null===f.loadThrottle?b.onSearchChange:q(b.onSearchChange,f.loadThrottle)}),b.sifter=new i(this.options,{diacritics:f.diacritics}),b.settings.options){for(c=0,g=b.settings.options.length;c<g;c++)b.registerOption(b.settings.options[c]);delete b.settings.options}
5170if(b.settings.optgroups){for(c=0,g=b.settings.optgroups.length;c<g;c++)b.registerOptionGroup(b.settings.optgroups[c]);delete b.settings.optgroups}b.settings.mode=b.settings.mode||(1===b.settings.maxItems?"single":"multi"),"boolean"!=typeof b.settings.hideSelected&&(b.settings.hideSelected="multi"===b.settings.mode),b.initializePlugins(b.settings.plugins),b.setupCallbacks(),b.setupTemplates(),b.setup()};return(c.mixin(a),void 0!==d)?d.mixin(a):(e="Dependency MicroPlugin is missing",b={explanation:'Make sure you either: (1) are using the "standalone" version of Selectize, or (2) require MicroPlugin before you load Selectize.'},console.error("Selectize: "+e),b.explanation&&(console.group&&console.group(),console.error(b.explanation),console.group&&console.groupEnd())),$.extend(a.prototype,{setup:function(){var i,j,d,e,r,t,n,o,p,m,a=this,c=a.settings,g=a.eventNS,u=$(window),q=$(document),b=a.$input;if(n=a.settings.mode,o=b.attr("class")||"",i=$("<div>").addClass(c.wrapperClass).addClass(o).addClass(n),j=$("<div>").addClass(c.inputClass).addClass("items").appendTo(i),d=$('<input type="text" autocomplete="off" />').appendTo(j).attr("tabindex",b.is(":disabled")?"-1":a.tabIndex),t=$(c.dropdownParent||i),e=$("<div>").addClass(c.dropdownClass).addClass(n).hide().appendTo(t),r=$("<div>").addClass(c.dropdownContentClass).appendTo(e),(m=b.attr("id"))&&(d.attr("id",m+"-selectized"),$("label[for='"+m+"']").attr("for",m+"-selectized")),a.settings.copyClassesToDropdown&&e.addClass(o),i.css({width:b[0].style.width}),a.plugins.names.length&&(p="plugin-"+a.plugins.names.join(" plugin-"),i.addClass(p),e.addClass(p)),(null===c.maxItems||c.maxItems>1)&&1===a.tagType&&b.attr("multiple","multiple"),a.settings.placeholder&&d.attr("placeholder",c.placeholder),!a.settings.splitOn&&a.settings.delimiter){var w=a.settings.delimiter.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");a.settings.splitOn=new RegExp("\\s*"+w+"+\\s*")}b.attr("autocorrect")&&d.attr("autocorrect",b.attr("autocorrect")),b.attr("autocapitalize")&&d.attr("autocapitalize",b.attr("autocapitalize")),d[0].type=b[0].type,a.$wrapper=i,a.$control=j,a.$control_input=d,a.$dropdown=e,a.$dropdown_content=r,e.on("mouseenter mousedown click","[data-disabled]>[data-selectable]",function(a){a.stopImmediatePropagation()}),e.on("mouseenter","[data-selectable]",function(){return a.onOptionHover.apply(a,arguments)}),e.on("mousedown click","[data-selectable]",function(){return a.onOptionSelect.apply(a,arguments)}),s(j,"mousedown","*:not(input)",function(){return a.onItemSelect.apply(a,arguments)}),v(d),j.on({mousedown:function(){return a.onMouseDown.apply(a,arguments)},click:function(){return a.onClick.apply(a,arguments)}}),d.on({mousedown:function(a){a.stopPropagation()},keydown:function(){return a.onKeyDown.apply(a,arguments)},keyup:function(){return a.onKeyUp.apply(a,arguments)},keypress:function(){return a.onKeyPress.apply(a,arguments)},resize:function(){a.positionDropdown.apply(a,[])},blur:function(){return a.onBlur.apply(a,arguments)},focus:function(){return a.ignoreBlur=!1,a.onFocus.apply(a,arguments)},paste:function(){return a.onPaste.apply(a,arguments)}}),q.on("keydown"+g,function(b){a.isCmdDown=b[f?"metaKey":"ctrlKey"],a.isCtrlDown=b[f?"altKey":"ctrlKey"],a.isShiftDown=b.shiftKey}),q.on("keyup"+g,function(b){b.keyCode===l&&(a.isCtrlDown=!1),16===b.keyCode&&(a.isShiftDown=!1),b.keyCode===k&&(a.isCmdDown=!1)}),q.on("mousedown"+g,function(b){if(a.isFocused){if(b.target===a.$dropdown[0]||b.target.parentNode===a.$dropdown[0])return!1;a.$control.has(b.target).length||b.target===a.$control[0]||a.blur(b.target)}}),u.on(["scroll"+g,"resize"+g].join(" "),function(){a.isOpen&&a.positionDropdown.apply(a,arguments)}),u.on("mousemove"+g,function(){a.ignoreHover=!1}),this.revertSettings={$children:b.children().detach(),tabindex:b.attr("tabindex")},b.attr("tabindex",-1).hide().after(a.$wrapper),$.isArray(c.items)&&(a.setValue(c.items),delete c.items),h&&b.on("invalid"+g,function(b){b.preventDefault(),a.isInvalid=!0,a.refreshState()}),a.updateOriginalInput(),a.refreshItems(),a.refreshState(),a.updatePlaceholder(),a.isSetup=!0,b.is(":disabled")&&a.disable(),a.on("change",this.onChange),b.data("selectize",a),b.addClass("selectized"),a.trigger("initialize"),!0===c.preload&&a.onSearchChange("")},setupTemplates:function(){var a=this,b=a.settings.labelField,c=a.settings.optgroupLabelField;a.settings.render=$.extend({},{optgroup:function(a){return'<div class="optgroup">'+a.html+"</div>"},optgroup_header:function(a,b){return'<div class="optgroup-header">'+b(a[c])+"</div>"},option:function(a,c){return'<div class="option">'+c(a[b])+"</div>"},item:function(a,c){return'<div class="item">'+c(a[b])+"</div>"},option_create:function(a,b){return'<div class="create">Add <strong>'+b(a.input)+"</strong>…</div>"}},a.settings.render)},setupCallbacks:function(){var a,c,b={initialize:"onInitialize",change:"onChange",item_add:"onItemAdd",item_remove:"onItemRemove",clear:"onClear",option_add:"onOptionAdd",option_remove:"onOptionRemove",option_clear:"onOptionClear",optgroup_add:"onOptionGroupAdd",optgroup_remove:"onOptionGroupRemove",optgroup_clear:"onOptionGroupClear",dropdown_open:"onDropdownOpen",dropdown_close:"onDropdownClose",type:"onType",load:"onLoad",focus:"onFocus",blur:"onBlur"};for(a in b)b.hasOwnProperty(a)&&(c=this.settings[b[a]])&&this.on(a,c)},onClick:function(a){this.isFocused&&this.isOpen||(this.focus(),a.preventDefault())},onMouseDown:function(b){var a=this,c=b.isDefaultPrevented();if($(b.target),a.isFocused){if(b.target!==a.$control_input[0])return"single"===a.settings.mode?a.isOpen?a.close():a.open():c||a.setActiveItem(null),!1}else c||window.setTimeout(function(){a.focus()},0)},onChange:function(){this.$input.trigger("change")},onPaste:function(b){var a=this;if(a.isFull()||a.isInputHidden||a.isLocked){b.preventDefault();return}a.settings.splitOn&&setTimeout(function(){var c=a.$control_input.val();if(c.match(a.settings.splitOn))for(var d=$.trim(c).split(a.settings.splitOn),b=0,e=d.length;b<e;b++)a.createItem(d[b])},0)}
5170,onKeyPress:function(a){if(this.isLocked)return a&&a.preventDefault();var b=String.fromCharCode(a.keyCode||a.which);if(this.settings.create&&"multi"===this.settings.mode&&b===this.settings.delimiter)return this.createItem(),a.preventDefault(),!1},onKeyDown:function(b){b.target,this.$control_input[0];var a=this;if(a.isLocked){9!==b.keyCode&&b.preventDefault();return}switch(b.keyCode){case 65:if(a.isCmdDown){a.selectAll();return}break;case 27:a.isOpen&&(b.preventDefault(),b.stopPropagation(),a.close());return;case 78:if(!b.ctrlKey||b.altKey)break;case 40:if(!a.isOpen&&a.hasOptions)a.open();else if(a.$activeOption){a.ignoreHover=!0;var c=a.getAdjacentOption(a.$activeOption,1);c.length&&a.setActiveOption(c,!0,!0)}b.preventDefault();return;case 80:if(!b.ctrlKey||b.altKey)break;case 38:if(a.$activeOption){a.ignoreHover=!0;var d=a.getAdjacentOption(a.$activeOption,-1);d.length&&a.setActiveOption(d,!0,!0)}b.preventDefault();return;case 13:a.isOpen&&a.$activeOption&&(a.onOptionSelect({currentTarget:a.$activeOption}),b.preventDefault());return;case 37:a.advanceSelection(-1,b);return;case 39:a.advanceSelection(1,b);return;case 9:a.settings.selectOnTab&&a.isOpen&&a.$activeOption&&(a.onOptionSelect({currentTarget:a.$activeOption}),a.isFull()||b.preventDefault()),a.settings.create&&a.createItem()&&b.preventDefault();return;case 8:case 46:a.deleteSelection(b);return}if((a.isFull()||a.isInputHidden)&&!(f?b.metaKey:b.ctrlKey)){b.preventDefault();return}},onKeyUp:function(c){var a=this;if(a.isLocked)return c&&c.preventDefault();var b=a.$control_input.val()||"";a.lastValue!==b&&(a.lastValue=b,a.onSearchChange(b),a.refreshOptions(),a.trigger("type",b))},onSearchChange:function(b){var a=this,c=a.settings.load;c&&(a.loadedSearches.hasOwnProperty(b)||(a.loadedSearches[b]=!0,a.load(function(d){c.apply(a,[b,d])})))},onFocus:function(b){var a=this,c=a.isFocused;if(a.isDisabled)return a.blur(),b&&b.preventDefault(),!1;a.ignoreFocus||(a.isFocused=!0,"focus"===a.settings.preload&&a.onSearchChange(""),c||a.trigger("focus"),a.$activeItems.length||(a.showInput(),a.setActiveItem(null),a.refreshOptions(!!a.settings.openOnFocus)),a.refreshState())},onBlur:function(c,d){var a=this;if(a.isFocused){if(a.isFocused=!1,a.ignoreFocus)return;if(!a.ignoreBlur&&document.activeElement===a.$dropdown_content[0]){a.ignoreBlur=!0,a.onFocus(c);return}var b=function(){a.close(),a.setTextboxValue(""),a.setActiveItem(null),a.setActiveOption(null),a.setCaret(a.items.length),a.refreshState(),d&&d.focus&&d.focus(),a.isBlurring=!1,a.ignoreFocus=!1,a.trigger("blur")};a.isBlurring=!0,a.ignoreFocus=!0,a.settings.create&&a.settings.createOnBlur?a.createItem(null,!1,b):b()}},onOptionHover:function(a){this.ignoreHover||this.setActiveOption(a.currentTarget,!1)},onOptionSelect:function(b){var c,d,a=this;b.preventDefault&&(b.preventDefault(),b.stopPropagation()),(d=$(b.currentTarget)).hasClass("create")?a.createItem(null,function(){a.settings.closeAfterSelect&&a.close()}):void 0!==(c=d.attr("data-value"))&&(a.lastQuery=null,a.setTextboxValue(""),a.addItem(c),a.settings.closeAfterSelect?a.close():!a.settings.hideSelected&&b.type&&/mouse/.test(b.type)&&a.setActiveOption(a.getOption(c)))},onItemSelect:function(a){this.isLocked||"multi"===this.settings.mode&&(a.preventDefault(),this.setActiveItem(a.currentTarget,a))},load:function(b){var a=this,c=a.$wrapper.addClass(a.settings.loadingClass);a.loading++,b.apply(a,[function(b){a.loading=Math.max(a.loading-1,0),b&&b.length&&(a.addOption(b),a.refreshOptions(a.isFocused&&!a.isInputHidden)),a.loading||c.removeClass(a.settings.loadingClass),a.trigger("load",b)}])},setTextboxValue:function(a){var b=this.$control_input;b.val()!==a&&(b.val(a).triggerHandler("update"),this.lastValue=a)},getValue:function(){return 1===this.tagType&&this.$input.attr("multiple")?this.items:this.items.join(this.settings.delimiter)},setValue:function(b,a){r(this,a?[]:["change"],function(){this.clear(a),this.addItems(b,a)})},setActiveItem:function(b,g){var h,e,i,c,d,f,j,k,a=this;if("single"!==a.settings.mode){if(!(b=$(b)).length){$(a.$activeItems).removeClass("active"),a.$activeItems=[],a.isFocused&&a.showInput();return}if("mousedown"===(h=g&&g.type.toLowerCase())&&a.isShiftDown&&a.$activeItems.length){for(k=a.$control.children(".active:last"),c=Array.prototype.indexOf.apply(a.$control[0].childNodes,[k[0]]),d=Array.prototype.indexOf.apply(a.$control[0].childNodes,[b[0]]),c>d&&(j=c,c=d,d=j),e=c;e<=d;e++)f=a.$control[0].childNodes[e],-1===a.$activeItems.indexOf(f)&&($(f).addClass("active"),a.$activeItems.push(f));g.preventDefault()}else"mousedown"===h&&a.isCtrlDown||"keydown"===h&&this.isShiftDown?b.hasClass("active")?(i=a.$activeItems.indexOf(b[0]),a.$activeItems.splice(i,1),b.removeClass("active")):a.$activeItems.push(b.addClass("active")[0]):($(a.$activeItems).removeClass("active"),a.$activeItems=[b.addClass("active")[0]]);a.hideInput(),this.isFocused||a.focus()}}
5170,setActiveOption:function(d,b,g){var e,f,c,h,i,a=this;a.$activeOption&&a.$activeOption.removeClass("active"),a.$activeOption=null,(d=$(d)).length&&(a.$activeOption=d.addClass("active"),(b||!m(b))&&(e=a.$dropdown_content.height(),f=a.$activeOption.outerHeight(!0),b=a.$dropdown_content.scrollTop()||0,c=a.$activeOption.offset().top-a.$dropdown_content.offset().top+b,h=c,i=c-e+f,c+f>e+b?a.$dropdown_content.stop().animate({scrollTop:i},g?a.settings.scrollDuration:0):c<b&&a.$dropdown_content.stop().animate({scrollTop:h},g?a.settings.scrollDuration:0)))},selectAll:function(){var a=this;"single"!==a.settings.mode&&(a.$activeItems=Array.prototype.slice.apply(a.$control.children(":not(input)").addClass("active")),a.$activeItems.length&&(a.hideInput(),a.close()),a.focus())},hideInput:function(){var a=this;a.setTextboxValue(""),a.$control_input.css({opacity:0,position:"absolute",left:a.rtl?1e4:-1e4}),a.isInputHidden=!0},showInput:function(){this.$control_input.css({opacity:1,position:"relative",left:0}),this.isInputHidden=!1},focus:function(){var a=this;a.isDisabled||(a.ignoreFocus=!0,a.$control_input[0].focus(),window.setTimeout(function(){a.ignoreFocus=!1,a.onFocus()},0))},blur:function(a){this.$control_input[0].blur(),this.onBlur(null,a)},getScoreFunction:function(a){return this.sifter.getScoreFunction(a,this.get
5170SearchOptions())},getSearchOptions:function(){var a=this.settings,b=a.sortField;return"string"==typeof b&&(b=[{field:b}]),{fields:a.searchField,conjunction:a.searchConjunction,sort:b,nesting:a.nesting}},search:function(d){var c,b,e,a=this,f=a.settings,g=this.getSearchOptions();if(f.score&&"function"!=typeof(e=a.settings.score.apply(this,[d])))throw new Error('Selectize "score" setting must be a function that returns a function');if(d!==a.lastQuery?(a.lastQuery=d,b=a.sifter.search(d,$.extend(g,{score:e})),a.currentResults=b):b=$.extend(!0,{},a.currentResults),f.hideSelected)for(c=b.items.length-1;c>=0;c--)-1!==a.items.indexOf(n(b.items[c].id))&&b.items.splice(c,1);return b},refreshOptions:function(k){void 0===k&&(k=!0);var c,l,u,d,f,i,r,v,b,m,o,p,x,g,s,q,a=this,t=$.trim(a.$control_input.val()),e=a.search(t),h=a.$dropdown_content,y=a.$activeOption&&n(a.$activeOption.attr("data-value"));for(d=e.items.length,"number"==typeof a.settings.maxOptions&&(d=Math.min(d,a.settings.maxOptions)),f={},i=[],c=0;c<d;c++)for(l=0,r=a.options[e.items[c].id],v=a.render("option",r),b=r[a.settings.optgroupField]||"",m=$.isArray(b)?b:[b],u=m&&m.length;l<u;l++)b=m[l],a.optgroups.hasOwnProperty(b)||(b=""),f.hasOwnProperty(b)||(f[b]=document.createDocumentFragment(),i.push(b)),f[b].appendChild(v);for(this.settings.lockOptgroupOrder&&i.sort(function(b,c){var d=a.optgroups[b].$order||0,e=a.optgroups[c].$order||0;return d-e}),o=document.createDocumentFragment(),c=0,d=i.length;c<d;c++)b=i[c],a.optgroups.hasOwnProperty(b)&&f[b].childNodes.length?((p=document.createDocumentFragment()).appendChild(a.render("optgroup_header",a.optgroups[b])),p.appendChild(f[b]),o.appendChild(a.render("optgroup",$.extend({},a.optgroups[b],{html:w(p),dom:p})))):o.appendChild(f[b]);if(h.html(o),a.settings.highlight&&(h.removeHighlight(),e.query.length&&e.tokens.length))for(c=0,d=e.tokens.length;c<d;c++)j(h,e.tokens[c].regex);if(!a.settings.hideSelected)for(c=0,d=a.items.length;c<d;c++)a.getOption(a.items[c]).addClass("selected");(x=a.canCreate(t))&&(h.prepend(a.render("option_create",{input:t})),q=$(h[0].childNodes[0])),a.hasOptions=e.items.length>0||x,a.hasOptions?(e.items.length>0?((s=y&&a.getOption(y))&&s.length?g=s:"single"===a.settings.mode&&a.items.length&&(g=a.getOption(a.items[0])),g&&g.length||(g=q&&!a.settings.addPrecedence?a.getAdjacentOption(q,1):h.find("[data-selectable]:first"))):g=q,a.setActiveOption(g),k&&!a.isOpen&&a.open()):(a.setActiveOption(null),k&&a.isOpen&&a.close())},addOption:function(a){var c,e,d,b=this;if($.isArray(a)){for(c=0,e=a.length;c<e;c++)b.addOption(a[c]);return}(d=b.registerOption(a))&&(b.userOptions[d]=!0,b.lastQuery=null,b.trigger("option_add",d,a))},registerOption:function(a){var b=n(a[this.settings.valueField]);return!(null==b||this.options.hasOwnProperty(b))&&(a.$order=a.$order|| ++this.order,this.options[b]=a,b)},registerOptionGroup:function(a){var b=n(a[this.settings.optgroupValueField]);return!!b&&(a.$order=a.$order|| ++this.order,this.optgroups[b]=a,b)},addOptionGroup:function(a,b){b[this.settings.optgroupValueField]=a,(a=this.registerOptionGroup(b))&&this.trigger("optgroup_add",a,b)},removeOptionGroup:function(a){this.optgroups.hasOwnProperty(a)&&(delete this.optgroups[a],this.renderCache={},this.trigger("optgroup_remove",a))},clearOptionGroups:function(){this.optgroups={},this.renderCache={},this.trigger("optgroup_clear")},updateOption:function(b,d){var g,h,c,i,e,f,j,a=this;if(b=n(b),c=n(d[a.settings.valueField]),null!==b&&a.options.hasOwnProperty(b)){if("string"!=typeof c)throw new Error("Value must be set in option data");j=a.options[b].$order,c!==b&&(delete a.options[b],-1!==(i=a.items.indexOf(b))&&a.items.splice(i,1,c)),d.$order=d.$order||j,a.options[c]=d,e=a.renderCache.item,f=a.renderCache.option,e&&(delete e[b],delete e[c]),f&&(delete f[b],delete f[c]),-1!==a.items.indexOf(c)&&(g=a.getItem(b),h=$(a.render("item",d)),g.hasClass("active")&&h.addClass("active"),g.replaceWith(h)),a.lastQuery=null,a.isOpen&&a.refreshOptions(!1)}},removeOption:function(a,e){var b=this;a=n(a);var c=b.renderCache.item,d=b.renderCache.option;c&&delete c[a],d&&delete d[a],delete b.userOptions[a],delete b.options[a],b.lastQuery=null,b.trigger("option_remove",a),b.removeItem(a,e)},clearOptions:function(){var a=this;a.loadedSearches={},a.userOptions={},a.renderCache={};var b=a.options;$.each(a.options,function(c,d){-1==a.items.indexOf(c)&&delete b[c]}),a.options=a.sifter.items=b,a.lastQuery=null,a.trigger("option_clear")},getOption:function(a){return this.getElementWithValue(a,this.$dropdown_content.find("[data-selectable]"))},getAdjacentOption:function(c,d){var a=this.$dropdown.find("[data-selectable]"),b=a.index(c)+d;return b>=0&&b<a.length?a.eq(b):$()},getElementWithValue:function(b,c){if(null!=(b=n(b))){for(var a=0,d=c.length;a<d;a++)if(c[a].getAttribute("data-value")===b)return $(c[a])}return $()},getItem:function(a){return this.getElementWithValue(a,this.$control.children())},addItems:function(b,g){this.buffer=document.createDocumentFragment();for(var c=this.$control[0].childNodes,a=0;a<c.length;
5170a++)this.buffer.appendChild(c[a]);for(var d=$.isArray(b)?b:[b],a=0,e=d.length;a<e;a++)this.isPending=a<e-1,this.addItem(d[a],g);var f=this.$control[0];f.insertBefore(this.buffer,f.firstChild),this.buffer=null},addItem:function(b,a){r(this,a?[]:["change"],function(){var d,f,g,e,h,c=this.settings.mode;if(b=n(b),-1!==this.items.indexOf(b)){"single"===c&&this.close();return}this.options.hasOwnProperty(b)&&("single"===c&&this.clear(a),"multi"===c&&this.isFull()||(d=$(this.render("item",this.options[b])),h=this.isFull(),this.items.splice(this.caretPos,0,b),this.insertAtCaret(d),(!this.isPending|| !h&&this.isFull())&&this.refreshState(),this.isSetup&&(g=this.$dropdown_content.find("[data-selectable]"),!this.isPending&&(f=this.getOption(b),e=this.getAdjacentOption(f,1).attr("data-value"),this.refreshOptions(this.isFocused&&"single"!==c),e&&this.setActiveOption(this.getOption(e))),!g.length||this.isFull()?this.close():this.isPending||this.positionDropdown(),this.updatePlaceholder(),this.trigger("item_add",b,d),this.isPending||this.updateOriginalInput({silent:a}))))})},removeItem:function(b,e){var c,d,f,a=this;b=n((c=b instanceof $?b:a.getItem(b)).attr("data-value")),d=a.items.indexOf(b),-1!==d&&(c.remove(),c.hasClass("active")&&(f=a.$activeItems.indexOf(c[0]),a.$activeItems.splice(f,1)),a.items.splice(d,1),a.lastQuery=null,!a.settings.persist&&a.userOptions.hasOwnProperty(b)&&a.removeOption(b,e),d<a.caretPos&&a.setCaret(a.caretPos-1),a.refreshState(),a.updatePlaceholder(),a.updateOriginalInput({silent:e}),a.positionDropdown(),a.trigger("item_remove",b,c))},createItem:function(b,d){var a=this,h=a.caretPos;b=b||$.trim(a.$control_input.val()||"");var c=arguments[arguments.length-1];if("function"!=typeof c&&(c=function(){}),"boolean"!=typeof d&&(d=!0),!a.canCreate(b))return c(),!1;a.lock();var g="function"==typeof a.settings.create?this.settings.create:function(c){var b={};return b[a.settings.labelField]=c,b[a.settings.valueField]=c,b},e=p(function(b){if(a.unlock(),!b||"object"!=typeof b)return c();var e=n(b[a.settings.valueField]);if("string"!=typeof e)return c();a.setTextboxValue(""),a.addOption(b),a.setCaret(h),a.addItem(e),a.refreshOptions(d&&"single"!==a.settings.mode),c(b)}),f=g.apply(this,[b,e]);return void 0!==f&&e(f),!0},refreshItems:function(){this.lastQuery=null,this.isSetup&&this.addItem(this.items),this.refreshState(),this.updateOriginalInput()},refreshState:function(){this.refreshValidityState(),this.refreshClasses()},refreshValidityState:function(){if(!this.isRequired)return!1;var a=!this.items.length;this.isInvalid=a,this.$control_input.prop("required",a),this.$input.prop("required",!a)},refreshClasses:function(){var a=this.isFull(),b=this.isLocked;this.$wrapper.toggleClass("rtl",this.rtl),this.$control.toggleClass("focus",this.isFocused).toggleClass("disabled",this.isDisabled).toggleClass("required",this.isRequired).toggleClass("invalid",this.isInvalid).toggleClass("locked",b).toggleClass("full",a).toggleClass("not-full",!a).toggleClass("input-active",this.isFocused&&!this.isInputHidden).toggleClass("dropdown-active",this.isOpen).toggleClass("has-options",!$.isEmptyObject(this.options)).toggleClass("has-items",this.items.length>0),this.$control_input.data("grow",!a&&!b)},isFull:function(){return null!==this.settings.maxItems&&this.items.length>=this.settings.maxItems},updateOriginalInput:function(c){var a,d,b,e;if(c=c||{},1===this.tagType){for(a=0,b=[],d=this.items.length;a<d;a++)e=this.options[this.items[a]][this.settings.labelField]||"",b.push('<option value="'+o(this.items[a])+'" selected="selected">'+o(e)+"</option>");b.length||this.$input.attr("multiple")||b.push('<option value="" selected="selected"></option>'),this.$input.html(b.join(""))}else this.$input.val(this.getValue()),this.$input.attr("value",this.$input.val());this.isSetup&&(c.silent||this.trigger("change",this.$input.val()))},updatePlaceholder:function(){if(this.settings.placeholder){var a=this.$control_input;this.items.length?a.removeAttr("placeholder"):a.attr("placeholder",this.settings.placeholder),a.triggerHandler("update",{force:!0})}},open:function(){var a=this;a.isLocked||a.isOpen||"multi"===a.settings.mode&&a.isFull()||(a.focus(),a.isOpen=!0,a.refreshState(),a.$dropdown.css({visibility:"hidden",display:"block"}),a.positionDropdown(),a.$dropdown.css({visibility:"visible"}),a.trigger("dropdown_open",a.$dropdown))},close:function(){var a=this,b=a.isOpen;"single"===a.settings.mode&&a.items.length&&(a.hideInput(),a.isBlurring||a.$control_input.blur()),a.isOpen=!1,a.$dropdown.hide(),a.setActiveOption(null),a.refreshState(),b&&a.trigger("dropdown_close",a.$dropdown)},positionDropdown:function(){var a=this.$control,b="body"===this.settings.dropdownParent?a.offset():a.position();b.top+=a.outerHeight(!0),this.$dropdown.css({width:a[0].getBoundingClientRect().width,top:b.top,left
5170:b.left})},clear:function(b){var a=this;a.items.length&&(a.$control.children(":not(input)").remove(),a.items=[],a.lastQuery=null,a.setCaret(0),a.setActiveItem(null),a.updatePlaceholder(),a.updateOriginalInput({silent:b}),a.refreshState(),a.showInput(),a.trigger("clear"))},insertAtCaret:function(d){var b=Math.min(this.caretPos,this.items.length),c=d[0],a=this.buffer||this.$control[0];0===b?a.insertBefore(c,a.firstChild):a.insertBefore(c,a.childNodes[b]),this.setCaret(b+1)},deleteSelection:function(b){var d,h,c,e,a,f,g,i,j;if(c=b&&8===b.keyCode?-1:1,e=t(this.$control_input[0]),this.$activeOption&&!this.settings.hideSelected&&(g=this.getAdjacentOption(this.$activeOption,-1).attr("data-value")),a=[],this.$activeItems.length){for(j=this.$control.children(".active:"+(c>0?"last":"first")),f=this.$control.children(":not(input)").index(j),c>0&&f++,d=0,h=this.$activeItems.length;d<h;d++)a.push($(this.$activeItems[d]).attr("data-value"));b&&(b.preventDefault(),b.stopPropagation())}else(this.isFocused||"single"===this.settings.mode)&&this.items.length&&(c<0&&0===e.start&&0===e.length?a.push(this.items[this.caretPos-1]):c>0&&e.start===this.$control_input.val().length&&a.push(this.items[this.caretPos]));if(!a.length||"function"==typeof this.settings.onDelete&& !1===this.settings.onDelete.apply(this,[a]))return!1;for(void 0!==f&&this.setCaret(f);a.length;)this.removeItem(a.pop());return this.showInput(),this.positionDropdown(),this.refreshOptions(!0),g&&(i=this.getOption(g)).length&&this.setActiveOption(i),!0},advanceSelection:function(a,g){var e,b,c,d,f;0!==a&&(this.rtl&&(a*=-1),e=a>0?"last":"first",b=t(this.$control_input[0]),this.isFocused&&!this.isInputHidden?(d=this.$control_input.val().length,(a<0?0!==b.start||0!==b.length:b.start!==d)||d||this.advanceCaret(a,g)):(f=this.$control.children(".active:"+e)).length&&(c=this.$control.children(":not(input)").index(f),this.setActiveItem(null),this.setCaret(a>0?c+1:c)))},advanceCaret:function(a,b){var c,d;0!==a&&(c=a>0?"next":"prev",this.isShiftDown?(d=this.$control_input[c]()).length&&(this.hideInput(),this.setActiveItem(d),b&&b.preventDefault()):this.setCaret(this.caretPos+a))},setCaret:function(c){var b,e,f,d,a=this;if(c="single"===a.settings.mode?a.items.length:Math.max(0,Math.min(a.items.length,c)),!a.isPending)for(b=0,e=(f=a.$control.children(":not(input)")).length;b<e;b++)d=$(f[b]).detach(),b<c?a.$control_input.before(d):a.$control.append(d);a.caretPos=c},lock:function(){this.close(),this.isLocked=!0,this.refreshState()},unlock:function(){this.isLocked=!1,this.refreshState()},disable:function(){var a=this;a.$input.prop("disabled",!0),a.$control_input.prop("disabled",!0).prop("tabindex",-1),a.isDisabled=!0,a.lock()},enable:function(){var a=this;a.$input.prop("disabled",!1),a.$control_input.prop("disabled",!1).prop("tabindex",a.tabIndex),a.isDisabled=!1,a.unlock()},destroy:function(){var b=this.eventNS,c=this.revertSettings;this.trigger("destroy"),this.off(),this.$wrapper.remove(),this.$dropdown.remove(),this.$input.html("").append(c.$children).removeAttr("tabindex").removeClass("selectized").attr({tabindex:c.tabindex}).show(),this.$control_input.removeData("grow"),this.$input.removeData("selectize"),0== --a.count&&a.$testInput&&(a.$testInput.remove(),a.$testInput=void 0),$(window).off(b),$(document).off(b),$(document.body).off(b),delete this.$input[0].selectize},render:function(a,d){var e,g,c="",f=!1,b=this;return(("option"===a||"item"===a)&&(f=!!(e=n(d[b.settings.valueField]))),f&&(m(b.renderCache[a])||(b.renderCache[a]={}),b.renderCache[a].hasOwnProperty(e)))?b.renderCache[a][e]:(c=$(b.settings.render[a].apply(this,[d,o])),"option"===a||"option_create"===a?d[b.settings.disabledField]||c.attr("data-selectable",""):"optgroup"===a&&(g=d[b.settings.optgroupValueField]||"",c.attr("data-group",g),d[b.settings.disabledField]&&c.attr("data-disabled","")),("option"===a||"item"===a)&&c.attr("data-value",e||""),f&&(b.renderCache[a][e]=c[0]),c[0])},clearCache:function(a){var b=this;void 0===a?b.renderCache={}:delete b.renderCache[a]},canCreate:function(b){if(!this.settings.create)return!1;var a=this.settings.createFilter;return b.length&&("function"!=typeof a||a.apply(this,[b]))&&("string"!=typeof a||new RegExp(a).test(b))&&(!(a instanceof RegExp)||a.test(b))}}),a.count=0,a.defaults={options:[],optgroups:[],plugins:[],delimiter:",",splitOn:null,persist:!0,diacritics:!0,create:!1,
5170createOnBlur:!1,createFilter:null,highlight:!0,openOnFocus:!0,maxOptions:1e3,maxItems:null,hideSelected:null,addPrecedence:!1,selectOnTab:!1,preload:!1,allowEmptyOption:!1,closeAfterSelect:!1,scrollDuration:60,loadThrottle:300,loadingClass:"loading",dataAttr:"data-data",optgroupField:"optgroup",valueField:"value",labelField:"text",disabledField:"disabled",optgroupLabelField:"label",optgroupValueField:"value",lockOptgroupOrder:!1,sortField:"$order",searchField:["text"],searchConjunction:"and",mode:null,wrapperClass:"selectize-control",inputClass:"selectize-input",dropdownClass:"selectize-dropdown",dropdownContentClass:"selectize-dropdown-content",dropdownParent:null,copyClassesToDropdown:!0,render:{}},$.fn.selectize=function(c){var d=$.fn.selectize.defaults,b=$.extend({},d,c),e=b.dataAttr,f=b.labelField,g=b.valueField,h=b.disabledField,i=b.optgroupField,j=b.optgroupLabelField,k=b.optgroupValueField,l=function(j,c){var a,d,h,i,k=j.attr(e);if(k)for(a=0,c.options=JSON.parse(k),d=c.options.length;a<d;a++)c.items.push(c.options[a][g]);else{var l=$.trim(j.val()||"");if(!b.allowEmptyOption&&!l.length)return;for(a=0,d=(h=l.split(b.delimiter)).length;a<d;a++)(i={})[f]=h[a],i[g]=h[a],c.options.push(i);c.items=h}},m=function(d,l){var a,m,o,c,q=l.options,r={},s=function(b){var a=e&&b.attr(e);return"string"==typeof a&&a.length?JSON.parse(a):null},p=function(d,e){d=$(d);var c=n(d.val());if(c||b.allowEmptyOption){if(r.hasOwnProperty(c)){if(e){var j=r[c][i];j?$.isArray(j)?j.push(e):r[c][i]=[j,e]:r[c][i]=e}return}var a=s(d)||{};a[f]=a[f]||d.text(),a[g]=a[g]||c,a[h]=a[h]||d.prop("disabled"),a[i]=a[i]||e,r[c]=a,q.push(a),d.is(":selected")&&l.items.push(c)}};for(a=0,l.maxItems=d.attr("multiple")?null:1,m=(c=d.children()).length;a<m;a++)"optgroup"===(o=c[a].tagName.toLowerCase())?function(a){var b,f,c,d,e;for((c=(a=$(a)).attr("label"))&&((d=s(a)||{})[j]=c,d[k]=c,d[h]=a.prop("disabled"),l.optgroups.push(d)),e=$("option",a),b=0,f=e.length;b<f;b++)p(e[b],c)}(c[a]):"option"===o&&p(c[a])};return this.each(function(){if(!this.selectize){var e=$(this),h=this.tagName.toLowerCase(),f=e.attr("placeholder")||e.attr("data-placeholder");f||b.allowEmptyOption||(f=e.children('option[value=""]').text());var g={placeholder:f,options:[],optgroups:[],items:[]};"select"===h?m(e,g):l(e,g),new a(e,$.extend(!0,{},d,g,c))}})},$.fn.selectize.defaults=a.defaults,$.fn.selectize.support={validity:h},a.define("drag_drop",function(e){if(!$.fn.sortable)throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');if("multi"===this.settings.mode){var b,c,d,a=this;a.lock=(b=a.lock,function(){var c=a.$control.data("sortable");return c&&c.disable(),b.apply(a,arguments)}),a.unlock=(c=a.unlock,function(){var b=a.$control.data("sortable");return b&&b.enable(),c.apply(a,arguments)}),a.setup=(d=a.setup,function(){d.apply(this,arguments);var b=a.$control.sortable({items:"[data-value]",forcePlaceholderSize:!0,disabled:a.isLocked,start:function(c,a){a.placeholder.css("width",a.helper.css("width")),b.css({overflow:"visible"})},stop:function(){b.css({overflow:"hidden"});var c=a.$activeItems?a.$activeItems.slice():null,d=[];b.children("[data-value]").each(function(){d.push($(this).attr("data-value"))}),a.setValue(d),a.setActiveItem(c)}})})}}),a.define("dropdown_header",function(a){var c,b=this;a=$.extend({title:"Untitled",headerClass:"selectize-dropdown-header",titleRowClass:"selectize-dropdown-header-title",labelClass:"selectize-dropdown-header-label",closeClass:"selectize-dropdown-header-close",html:function(a){return'<div class="'+a.headerClass+'"><div class="'+a.titleRowClass+'"><span class="'+a.labelClass+'">'+a.title+'</span><a href="javascript:void(0)" class="'+a.closeClass+'">×</a></div></div>'}},a),b.setup=(c=b.setup,function(){c.apply(b,arguments),b.$dropdown_header=$(a.html(a)),b.$dropdown.prepend(b.$dropdown_header)})}),a.define("optgroup_columns",function(a){var c,d=this;a=$.extend({equalizeWidth:!0,equalizeHeight:!0},a),this.getAdjacentOption=function(c,d){var a=c.closest("[data-group]").find("[data-selectable]"),b=a.index(c)+d;return b>=0&&b<a.length?a.eq(b):$()},this.onKeyDown=(c=d.onKeyDown,function(b){var e,f,g,a;
5170if(this.isOpen&&(37===b.keyCode||39===b.keyCode)){d.ignoreHover=!0,e=(a=this.$activeOption.closest("[data-group]")).find("[data-selectable]").index(this.$activeOption),(f=(g=(a=37===b.keyCode?a.prev("[data-group]"):a.next("[data-group]")).find("[data-selectable]")).eq(Math.min(g.length-1,e))).length&&this.setActiveOption(f);return}return c.apply(this,arguments)});var e=function(){var a,b=e.width,c=document;return void 0===b&&((a=c.createElement("div")).innerHTML='<div style="width:50px;height:50px;position:absolute;left:-50px;top:-50px;overflow:auto;"><div style="width:1px;height:100px;"></div></div>',a=a.firstChild,c.body.appendChild(a),b=e.width=a.offsetWidth-a.clientWidth,c.body.removeChild(a)),b},b=function(){var f,b,g,h,i,j,c;if((b=(c=$("[data-group]",d.$dropdown_content)).length)&&d.$dropdown_content.width()){if(a.equalizeHeight){for(f=0,g=0;f<b;f++)g=Math.max(g,c.eq(f).height());c.css({height:g})}a.equalizeWidth&&(h=Math.round((j=d.$dropdown_content.innerWidth()-e())/b),c.css({width:h}),b>1&&(i=j-h*(b-1),c.eq(b-1).css({width:i})))}};(a.equalizeHeight||a.equalizeWidth)&&(g.after(this,"positionDropdown",b),g.after(this,"refreshOptions",b))}),a.define("remove_button",function(a){var d,b,f,h,i,e,c,g,j,k,l;if(a=$.extend({label:"×",title:"Remove",className:"remove",append:!0},a),"single"===this.settings.mode){d=this,(b=a).className="remove-single",f=d,h='<a href="javascript:void(0)" class="'+b.className+'" tabindex="-1" title="'+o(b.title)+'">'+b.label+"</a>",d.setup=(i=f.setup,function(){if(b.append){var a=$(f.$input.context).attr("id");$("#"+a);var c=f.settings.render.item;f.settings.render.item=function(e){var a,b;return a=c.apply(d,arguments),b=h,$("<span>").append(a).append(b)}}i.apply(d,arguments),d.$control.on("click","."+b.className,function(a){a.preventDefault(),f.isLocked||f.clear()})});return}e=this,c=a,g=e,j='<a href="javascript:void(0)" class="'+c.className+'" tabindex="-1" title="'+o(c.title)+'">'+c.label+"</a>",k=function(a,c){var b=a.search(/(<\/[^>]+>\s*)$/);return a.substring(0,b)+c+a.substring(b)},e.setup=(l=g.setup,function(){if(c.append){var a=g.settings.render.item;g.settings.render.item=function(b){return k(a.apply(e,arguments),j)}}l.apply(e,arguments),e.$control.on("click","."+c.className,function(a){if(a.preventDefault(),!g.isLocked){var b=$(a.currentTarget).parent();g.setActiveItem(b),g.deleteSelection()&&g.setCaret(g.items.length)}})})}),a.define("restore_on_backspace",function(a){var b;a.text=a.text||function(a){return a[this.settings.labelField]},this.onKeyDown=(b=this.onKeyDown,function(c){var d,e;if(8===c.keyCode&&""===this.$control_input.val()&&!this.$activeItems.length&&(d=this.caretPos-1)>=0&&d<this.items.length){e=this.options[this.items[d]],this.deleteSelection(c)&&(this.setTextboxValue(a.text.apply(this,[e])),this.refreshOptions(!0)),c.preventDefault();return}return b.apply(this,arguments)})}),a}) 5171; 5172 5173 /*! 5174 Wookmark plugin 5175 @name wookmark.js 5176 @author Christoph Ono ([email protected] or @gbks) 5177 @author Sebastian Helzle ([email protected] or @sebobo) 5178 @version 2.0.1 5179 @date 06/16/2015 5180 @category jQuery plugin 5181 @copyright (c) 2009-2015 Christoph Ono (www.wookmark.com) 5182 @license Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. 5183*/ 5184/*global define, window, jQuery*/ 5185/*jslint plusplus: true, bitwise: true */ 5186(function (factory) { 5187 if (typeof define === 'function' && define.amd) { 5188 define(['window', 'document'], factory); 5189 } else { 5190 factory(window, document); 5191 } 5192}(function (window, document) { 5193 5194 // Wookmark default options 5195 // ------------------------ 5196 var defaultOptions = { 5197 align: 'center', 5198 autoResize: true, 5199 comparator: null, 5200 direction: undefined, 5201 ignoreInactiveItems: true, 5202 inactiveClass: 'wookmark-inactive', 5203 itemSelector: undefined, 5204 itemWidth: 0, 5205 fillEmptySpace: false, 5206 flexibleWidth: 0, 5207 offset: 5, 5208 outerOffset: 0, 5209 onLayoutChanged: undefined, 5210 onLayoutCreated:undefined, 5211 placeholderClass: 'wookmark-placeholder', 5212 possibleFilters: [], 5213 resizeDelay: 50, 5214 verticalOffset: undefined 5215 }; 5216 5217 // Helper functions 5218 // ---------------- 5219 5220 // Bind function to set the context for the Wookmark instance function 5221 function __bind(fn, me) { 5222 return function () { 5223 return fn.apply(me, arguments); 5224 }; 5225 } 5226 5227 // Function for executing css writes to dom on the next animation frame if supported 5228 var executeNextFrame = window.requestAnimationFrame || function (callback) { callback(); }; 5229 5230 // Update multiple css values on an object 5231 function setCSS(el, properties) { 5232 var key; 5233 for (key in properties) { 5234 if (properties.hasOwnProperty(key)) { 5235 el.style[key] = properties[key]; 5236 } 5237 } 5238 } 5239 5240 // Update the css properties of multiple elements at the same time 5241 // befor the browsers next animation frame. 5242 // The parameter `data` has to be an array containing objects, each 5243 // with the element and the desired css properties. 5244 function bulkUpdateCSS(data) { 5245 executeNextFrame(function () { 5246 var i, item; 5247 for (i = 0; i < data.length; i++) { 5248 item = data[i]; 5249 setCSS(item.el, item.css); 5250 } 5251 }); 5252 } 5253 5254 // Remove whitespace around filter names 5255 function cleanFilterName(filterName) { 5256 return filterName.replace(/^\s+|\s+$/g, '').toLowerCase(); 5257 } 5258 5259 // Remove listener from an element (IE8 compatible) 5260 function removeEventListener(el, eventName, handler) { 5261 if (el.removeEventListener) { 5262 el.removeEventListener(eventName, handler); 5263 } else { 5264 el.detachEvent('on' + eventName, handler); 5265 } 5266 } 5267 5268 // Add listener to an element (IE8 compatible) 5269 function addEventListener(el, eventName, handler) { 5270 removeEventListener(el, eventName, handler); 5271 if (el.addEventListener) { 5272 el.addEventListener(eventName, handler); 5273 } else { 5274 el.attachEvent('on' + eventName, function () { 5275 handler.call(el); 5276 }); 5277 } 5278 } 5279 5280 // Checks if element `el` is not visible in the browser 5281 function isHidden(el) { 5282 return el.offsetParent === null; 5283 } 5284 5285 // Returns the elements height without margin 5286 function getHeight(el) { 5287 return el.offsetHeight; 5288 } 5289 5290 // Returns the elements width without margin 5291 function getWidth(el) { 5292 return el.offsetWidth; 5293 } 5294 5295 // Return true if element has class 5296 function hasClass(el, className) { 5297 if (el.classList) { 5298 return el.classList.contains(className); 5299 } 5300 return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className); 5301 } 5302 5303 // Add class to element (IE8+) 5304 function addClass(el, className) { 5305 if (el.classList) { 5306 el.classList.add(className); 5307 } else { 5308 el.className += ' ' + className; 5309 } 5310 } 5311 5312 // Remove class from element (IE8+) 5313 function removeClass(el, className) { 5314 if (el.classList) { 5315 el.classList.remove(className); 5316 } else { 5317 el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' '); 5318 } 5319 } 5320 5321 // Get value of specified data attribute 5322 function getData(el, attr, isInt, prefix) { 5323 if (prefix === undefined) { 5324 prefix = 'wookmark-'; 5325 } 5326 var val = el.getAttribute('data-' + prefix + attr); 5327 if (isInt === true) { 5328 return parseInt(val, 10); 5329 } 5330 return val; 5331 } 5332 5333 // Set value of specified data attribute 5334 function setData(el, attr, val, prefix) { 5335 if (prefix === undefined) { 5336 prefix = 'wookmark-'; 5337 } 5338 el.setAttribute('data-' + prefix + attr, val); 5339 } 5340 5341 // Remove duplicates from given array 5342 function removeDuplicates(items) { 5343 var temp = {}, result = [], x, i = items.length; 5344 while (i--) { 5345 x = getData(items[i], 'id', true); 5346 if (!temp.hasOwnProperty(x)) { 5347 temp[x] = 1; 5348 result.push(items[i]); 5349 } 5350 } 5351 return result; 5352 } 5353 5354 // Get the computed style from an element (IE 8 compatible) 5355 function getStyle(el, prop) { 5356 return window.getComputedStyle !== undefined ? window.getComputedStyle(el, null).getPropertyValue(prop) : el.currentStyle[prop]; 5357 } 5358 5359 5360 // IE 8 compatible indexOf 5361 function indexOf(items, item) { 5362 var len = items.length, i; 5363 for (i = 0; i < len; i++) { 5364 if (items[i] === item) { 5365 return i; 5366 } 5367 } 5368 return -1; 5369 } 5370 5371 // Main wookmark plugin class 5372 // -------------------------- 5373 function Wookmark(container, options) { 5374 options = options || {}; 5375 5376 if (typeof container === 'string') { 5377 container = document.querySelector(container); 5378 } 5379 5380 // Instance variables. 5381 this.container = container; 5382 this.columns = this.containerWidth = this.resizeTimer = null;
5383 this.activeItemCount = 0; 5384 this.placeholders = []; 5385 this.itemHeightsInitialized = false; 5386 this.itemHeightsDirty = false; 5387 this.elementTag = 'div'; 5388 5389 // Bind instance methods 5390 this.initItems = __bind(this.initItems, this); 5391 this.updateOptions = __bind(this.updateOptions, this); 5392 this.onResize = __bind(this.onResize, this); 5393 this.onRefresh = __bind(this.onRefresh, this); 5394 this.getItemWidth = __bind(this.getItemWidth, this); 5395 this.layout = __bind(this.layout, this); 5396 this.layoutFull = __bind(this.layoutFull, this); 5397 this.layoutColumns = __bind(this.layoutColumns, this); 5398 this.filter = __bind(this.filter, this); 5399 this.clear = __bind(this.clear, this); 5400 this.getActiveItems = __bind(this.getActiveItems, this); 5401 this.refreshPlaceholders = __bind(this.refreshPlaceholders, this); 5402 this.sortElements = __bind(this.sortElements, this); 5403 this.updateFilterClasses = __bind(this.updateFilterClasses, this); 5404 5405 // Initialize children of the container 5406 this.initItems(); 5407 5408 // Initial update and layout 5409 this.container.style.display = 'block'; 5410 this.updateOptions(options); 5411 5412 // Collect filter classes after items have been initialized 5413 this.updateFilterClasses(); 5414 5415 // Listen to resize event of the browser if enabled 5416 if (this.autoResize) { 5417 addEventListener(window, 'resize', this.onResize); 5418 } 5419 5420 // Listen to external refresh event 5421 addEventListener(this.container, 'refreshWookmark', this.onRefresh); 5422 5423 if (this.onLayoutCreated !== undefined && typeof this.onLayoutCreated === 'function') { 5424 this.onLayoutCreated(); 5425 } 5426 } 5427 5428 // Get all valid children of the container object and store them 5429 Wookmark.prototype.initItems = function () { 5430 // By select all children of the container if no selector is specified 5431 if (this.itemSelector === undefined) { 5432 var items = [], child, children = this.container.children, 5433 i = children.length; 5434 while (i--) { 5435 child = children[i]; 5436 //if(child.tagName === 'DIV') continue; 5437 // Skip comment nodes on IE8 5438 if (child.nodeType !== 8) { 5439 // Show item 5440 child.style.display = ''; 5441 setData(child, 'id', i); 5442 items.unshift(child); 5443 } 5444 } 5445 this.items = items; 5446 } else { 5447 this.items = this.container.querySelectorAll(this.itemSelector); 5448 } 5449 5450 if (this.items.length) { 5451 this.elementTag = this.items[0].tagName; 5452 } 5453 this.itemHeightsDirty = true; 5454 }; 5455 5456 // Reload all filter classes from all items and cache them 5457 Wookmark.prototype.updateFilterClasses = function () { 5458 // Collect filter data 5459 var i = this.items.length, j, filterClasses = {}, itemFilterClasses, 5460 item, filterClass, possibleFilters = this.possibleFilters, 5461 k = possibleFilters.length, possibleFilter; 5462 5463 while (i--) { 5464 item = this.items[i]; 5465 5466 // Read filter classes and globally store each filter class as object and the fitting items in the array 5467 itemFilterClasses = JSON.parse(getData(item, 'filter-class', false, '')); 5468 if (itemFilterClasses && typeof itemFilterClasses === 'object') { 5469 j = itemFilterClasses.length; 5470 while (j--) { 5471 filterClass = cleanFilterName(itemFilterClasses[j]); 5472 if (!filterClasses.hasOwnProperty(filterClass)) { 5473 filterClasses[filterClass] = []; 5474 } 5475 filterClasses[filterClass].push(item); 5476 } 5477 } 5478 } 5479 5480 while (k--) { 5481 possibleFilter = cleanFilterName(possibleFilters[k]); 5482 if (!filterClasses.hasOwnProperty(possibleFilter)) { 5483 filterClasses[possibleFilter] = []; 5484 } 5485 } 5486 5487 this.filterClasses = filterClasses; 5488 }; 5489 5490 // Method for updating the plugins options 5491 Wookmark.prototype.updateOptions = function (options) { 5492 var key; 5493 this.itemHeightsDirty = true; 5494 options = options || {}; 5495 5496 // Overwrite non existing instance variables with the ones from options or the defaults 5497 for (key in defaultOptions) { 5498 if (defaultOptions.hasOwnProperty(key)) { 5499 if (options.hasOwnProperty(key)) { 5500 this[key] = options[key]; 5501 } else if (!this.hasOwnProperty(key)) { 5502 this[key] = defaultOptions[key]; 5503 } 5504 } 5505 } 5506 5507 // Vertical offset uses a fallback to offset 5508 this.verticalOffset = this.verticalOffset || this.offset; 5509 5510 // Update layout so changes apply 5511 this.layout(true); 5512 }; 5513 5514 // This timer ensures that layout is not continuously called as window is being dragged. 5515 Wookmark.prototype.onResize = function () { 5516 clearTimeout(this.resizeTimer);
5517 this.itemHeightsDirty = this.flexibleWidth !== 0; 5518 this.resizeTimer = setTimeout(this.layout, this.resizeDelay); 5519 }; 5520 5521 // Marks the items heights as dirty and does a relayout 5522 Wookmark.prototype.onRefresh = function () { 5523 this.itemHeightsDirty = true; 5524 this.layout(); 5525 }; 5526 5527 // Filters the active items with the given string filters. 5528 // @param filters array of string 5529 // @param mode 'or' or 'and' 5530 Wookmark.prototype.filter = function (filters, mode, dryRun) { 5531 var activeFilters = [], activeFiltersLength, activeItems = [], 5532 i, j, k, filter; 5533 5534 filters = filters || []; 5535 mode = mode || 'or'; 5536 dryRun = dryRun || false; 5537 5538 if (filters.length) { 5539 // Collect active filters 5540 for (i = 0; i < filters.length; i++) { 5541 filter = cleanFilterName(filters[i]); 5542 if (this.filterClasses.hasOwnProperty(filter)) { 5543 activeFilters.push(this.filterClasses[filter]); 5544 } 5545 } 5546 5547 // Get items for active filters with the selected mode 5548 i = activeFiltersLength = activeFilters.length; 5549 if (mode === 'or' || activeFiltersLength === 1) { 5550 // Set all items in all active filters active 5551 while (i--) { 5552 activeItems = activeItems.concat(activeFilters[i]); 5553 } 5554 } else if (mode === 'and') { 5555 var shortestFilter = activeFilters[0], itemValid = true, 5556 foundInFilter, currentItem, currentFilter; 5557 5558 // Find shortest filter class 5559 while (i--) { 5560 if (activeFilters[i].length < shortestFilter.length) { 5561 shortestFilter = activeFilters[i]; 5562 } 5563 } 5564 5565 // Iterate over shortest filter and find elements in other filter classes 5566 shortestFilter = shortestFilter || []; 5567 i = shortestFilter.length; 5568 while (i--) { 5569 currentItem = shortestFilter[i]; 5570 j = activeFiltersLength; 5571 itemValid = true; 5572 5573 while (j-- && itemValid) { 5574 currentFilter = activeFilters[j]; 5575 if (shortestFilter !== currentFilter) { 5576 // Search for current item in each active filter class 5577 foundInFilter = false; 5578 k = currentFilter.length; 5579 while (k-- && !foundInFilter) { 5580 foundInFilter = currentFilter[k] === currentItem; 5581 } 5582 itemValid &= foundInFilter; 5583 } 5584 } 5585 5586 if (itemValid) { 5587 activeItems = activeItems.concat(shortestFilter[i]); 5588 } 5589 } 5590 } 5591 5592 // Remove duplicates from active items 5593 if (activeFiltersLength > 1) { 5594 activeItems = removeDuplicates(activeItems); 5595 } 5596 5597 // Hide inactive items 5598 if (!dryRun) { 5599 i = this.items.length; 5600 while (i--) { 5601 if (indexOf(activeItems, this.items[i]) === -1) { 5602 addClass(this.items[i], this.inactiveClass); 5603 } 5604 } 5605 } 5606 } else { 5607 // Show all items if no filter is selected 5608 activeItems = this.items; 5609 } 5610 5611 // Show active items 5612 if (!dryRun) { 5613 i = activeItems.length; 5614 while (i--) { 5615 removeClass(activeItems[i], this.inactiveClass); 5616 } 5617 // Unset columns and refresh grid for a full layout 5618 this.columns = null; 5619 this.layout(); 5620 } 5621 return activeItems; 5622 }; 5623 5624 // Creates or updates existing placeholders to create columns of even height 5625 Wookmark.prototype.refreshPlaceholders = function (columnWidth, sideOffset) { 5626 var i, 5627 containerHeight = getHeight(this.container), 5628 columnsLength = this.columns.length, 5629 column, 5630 height, 5631 innerOffset, 5632 lastColumnItem, 5633 placeholdersHtml = '', 5634 placeholder, 5635 top; 5636 5637 // Add more placeholders if necessary 5638 if (this.placeholders.length < columnsLength) { 5639 for (i = 0; i < columnsLength - this.placeholders.length; i++) { 5640 placeholdersHtml += '<' + this.elementTag + ' class="' + this.placeholderClass + '"/>'; 5641 } 5642 this.container.insertAdjacentHTML('beforeend', placeholdersHtml); 5643 this.placeholders = this.container.querySelectorAll('.' + this.placeholderClass); 5644 } 5645 5646 innerOffset = (this.offset + parseInt(getStyle(this.placeholders[0], 'border-left-width'), 10) * 2) || 0; 5647 innerOffset += (parseInt(getStyle(this.placeholders[0], 'padding-left'), 10) * 2) || 0; 5648 5649 // Update each placeholder 5650 for (i = 0; i < this.placeholders.length; i++) { 5651 placeholder = this.placeholders[i]; 5652 column = this.columns[i]; 5653 5654 if (i >= columnsLength || column.length === 0) { 5655 placeholder.style.display = 'none'; 5656 } else { 5657 lastColumnItem = column[column.length - 1]; 5658 top = getData(lastColumnItem, 'top', true) + getData(lastColumnItem, 'height', true) + this.verticalOffset; 5659 height = Math.max(0, containerHeight - top - innerOffset); 5660 5661 setCSS(placeholder, { 5662 position: 'absolute', 5663 display: height > 0 ? 'block' : 'none', 5664 left: (i * columnWidth + sideOffset) + 'px', 5665 top: top + 'px', 5666 width: (columnWidth - innerOffset) + 'px', 5667 height: height + 'px' 5668 }); 5669 } 5670 } 5671 }; 5672 5673 // Method the get active items which are not disabled and visible 5674 Wookmark.prototype.getActiveItems = function () { 5675 var inactiveClass = this.inactiveClass, 5676 i, 5677 result = [], 5678 item, 5679 items = this.items; 5680 5681 if (this.ignoreInactiveItems) { 5682 for (i = 0; i < items.length; i++) { 5683 item = items[i]; 5684 if (!hasClass(item, inactiveClass)) { 5685 result.push(item); 5686 } 5687 } 5688 } 5689 return result; 5690 }; 5691 5692 // Method to get the standard item width 5693 Wookmark.prototype.getItemWidth = function () { 5694 var itemWidth = this.itemWidth, 5695 innerWidth = getWidth(this.container) - 2 * this.outerOffset, 5696 flexibleWidth = this.flexibleWidth; 5697 5698 if (typeof itemWidth === 'function') { 5699 itemWidth = this.itemWidth(); 5700 } 5701 5702 if (this.items.length > 0 && (itemWidth === undefined || (itemWidth === 0 && !this.flexibleWidth))) { 5703 itemWidth = getWidth(this.items[0]); 5704 } else if (typeof itemWidth === 'string' && itemWidth.indexOf('%') >= 0) { 5705 itemWidth = parseFloat(this.itemWidth) / 100 * innerWidth; 5706 } 5707 5708 // Calculate flexible item width if option is set 5709 if (flexibleWidth) { 5710 if (typeof flexibleWidth === 'function') { 5711 flexibleWidth = flexibleWidth(); 5712 } 5713 5714 if (typeof flexibleWidth === 'string' && flexibleWidth.indexOf('%') >= 0) { 5715 flexibleWidth = parseFloat(flexibleWidth) / 100 * innerWidth; 5716 } 5717 5718 // Find highest column count 5719 var paddedInnerWidth = (innerWidth + this.offset), 5720 flexibleColumns = Math.floor(0.5 + paddedInnerWidth / (flexibleWidth + this.offset)), 5721 fixedColumns = Math.floor(paddedInnerWidth / (itemWidth + this.offset)), 5722 columns = Math.max(flexibleColumns, fixedColumns), 5723 columnWidth = Math.min(flexibleWidth, Math.floor((innerWidth - (columns - 1) * this.offset) / columns)); 5724 5725 itemWidth = Math.max(itemWidth, columnWidth); 5726 } 5727 5728 return itemWidth; 5729 }; 5730 5731 // Main layout method. 5732 Wookmark.prototype.layout = function (force, callback) {
5733 // Do nothing if container isn't visible 5734 if (isHidden(this.container)) { return; } 5735 5736 // Calculate basic layout parameters. 5737 var calculatedItemWidth = this.getItemWidth(), 5738 columnWidth = calculatedItemWidth + this.offset, 5739 containerWidth = getWidth(this.container), 5740 innerWidth = containerWidth - 2 * this.outerOffset, 5741 columns = Math.floor((innerWidth + this.offset) / columnWidth), 5742 offset = 0, 5743 maxHeight = 0, 5744 activeItems = this.getActiveItems(), 5745 activeItemsLength = activeItems.length, 5746 item, 5747 i = activeItemsLength; 5748 var slideshowItem = scriptJquery('.pinboard_list_item_slideshow'); 5749 if(slideshowItem.length){ 5750 slideshowItem.css('width',calculatedItemWidth + 'px'); 5751 var imgSlideshow = slideshowItem.find('.pinboard_list_item_thumb').find('a').find('img').css('width',calculatedItemWidth + 'px'); 5752 } 5753 // Cache item heights 5754 if (this.itemHeightsDirty || !this.itemHeightsInitialized) { 5755 while (i--) { 5756 item = activeItems[i]; 5757 5758 if (this.flexibleWidth) { 5759 // Stretch items to fill calculated width 5760 item.style.width = calculatedItemWidth + 'px'; 5761 } 5762 setData(item, 'height', item.offsetHeight); 5763 } 5764 this.itemHeightsDirty = false; 5765 this.itemHeightsInitialized = true; 5766 } 5767 5768 // Use less columns if there are to few items 5769 columns = Math.max(1, Math.min(columns, activeItemsLength)); 5770 5771 // Calculate the offset based on the alignment of columns to the parent container 5772 offset = this.outerOffset; 5773 if (this.align === 'center') { 5774 offset += Math.floor(0.5 + (innerWidth - (columns * columnWidth - this.offset)) >> 1); 5775 } 5776 5777 // Get direction for positioning 5778 this.direction = this.direction || (this.align === 'right' ? 'right' : 'left'); 5779 5780 // If container and column count hasn't changed, we can only update the columns. 5781 if (!force && this.columns !== null && this.columns.length === columns && this.activeItemCount === activeItemsLength) { 5782 maxHeight = this.layoutColumns(columnWidth, offset); 5783 } else { 5784 maxHeight = this.layoutFull(columnWidth, columns, offset); 5785 } 5786 this.activeItemCount = activeItemsLength; 5787 this.container.style.height = maxHeight + 'px'; 5788 // Set container height to height of the grid. 5789 /*var classExists = document.getElementsByClassName("sesbasic_view_type_options"); 5790 if(classExists.length > 0){ 5791 if(scriptJquery('.sesbasic_view_type_options').find('.active').attr('rel') == 'pinboard') 5792 this.container.style.height = maxHeight + 'px'; 5793 } else { 5794 this.container.style.height = maxHeight + 'px'; 5795 }*/ 5796 5797 // Update placeholders 5798 if (this.fillEmptySpace) { 5799 this.refreshPlaceholders(columnWidth, offset); 5800 } 5801 5802 if (this.onLayoutChanged !== undefined && typeof this.onLayoutChanged === 'function') { 5803 this.onLayoutChanged(); 5804 } 5805 5806 // Run optional callback 5807 if (typeof callback === 'function') { 5808 callback(); 5809 } 5810 }; 5811 5812 // Sort elements with configurable comparator 5813 Wookmark.prototype.sortElements = function (elements) { 5814 return typeof this.comparator === 'function' ? elements.sort(this.comparator) : elements; 5815 }; 5816 5817 // Perform a full layout update. 5818 Wookmark.prototype.layoutFull = function (columnWidth, columns, offset) { 5819 var item, k = 0, i = 0, activeItems, activeItemCount, shortest = null, shortestIndex = null, 5820 sideOffset, heights = [], itemBulkCSS = [], leftAligned = this.align === 'left'; 5821 5822 this.columns = []; 5823 5824 // Sort elements before layouting 5825 activeItems = this.sortElements(this.getActiveItems()); 5826 activeItemCount = activeItems.length; 5827 5828 // Prepare arrays to store height of columns and items. 5829 while (heights.length < columns) { 5830 heights.push(this.outerOffset); 5831 this.columns.push([]); 5832 } 5833 5834 // Loop over items. 5835 while (i < activeItemCount) { 5836 item = activeItems[i]; 5837 scriptJquery(item).removeClass('activity_pinfeed_hidden'); 5838 // Find the shortest column. 5839 shortest = heights[0]; 5840 shortestIndex = 0; 5841 for (k = 0; k < columns; k++) { 5842 if (heights[k] < shortest) { 5843 shortest = heights[k]; 5844 shortestIndex = k; 5845 } 5846 } 5847 setData(item, 'top', shortest); 5848 5849 // stick to left side if alignment is left and this is the first column 5850 sideOffset = offset; 5851 if (shortestIndex > 0 || !leftAligned) { 5852 sideOffset += shortestIndex * columnWidth; 5853 } 5854 5855 // Position the item. 5856 itemBulkCSS[i] = { 5857 el: item, 5858 css: { 5859 position: 'absolute', 5860 top: shortest + 'px' 5861 } 5862 }; 5863 itemBulkCSS[i].css[this.direction] = sideOffset + 'px'; 5864 5865 // Update column height and store item in shortest column 5866 heights[shortestIndex] += getData(item, 'height', true) + this.verticalOffset; 5867 this.columns[shortestIndex].push(item); 5868 i++; 5869 } 5870 5871 bulkUpdateCSS(itemBulkCSS); 5872 5873 // Return longest column 5874 return Math.max.apply(Math, heights); 5875 }; 5876 5877 // This layout method only updates the vertical position of the 5878 // existing column assignments. 5879 Wookmark.prototype.layoutColumns = function (columnWidth, offset) { 5880 var heights = [], itemBulkCSS = [], k = 0, j = 0, 5881 i = this.columns.length, currentHeight, 5882 column, item, sideOffset; 5883 5884 while (i--) { 5885 currentHeight = this.outerOffset; 5886 heights.push(currentHeight); 5887 column = this.columns[i]; 5888 sideOffset = i * columnWidth + offset; 5889 5890 for (k = 0; k < column.length; k++, j++) { 5891 item = column[k]; 5892 setData(item, 'top', currentHeight); 5893 itemBulkCSS[j] = { 5894 el: item, 5895 css: { 5896 top: currentHeight + 'px' 5897 } 5898 }; 5899 itemBulkCSS[j].css[this.direction] = sideOffset + 'px'; 5900 5901 currentHeight += getData(item, 'height', true) + this.verticalOffset; 5902 } 5903 heights[i] = currentHeight; 5904 } 5905 5906 bulkUpdateCSS(itemBulkCSS); 5907 5908 // Return longest column 5909 return Math.max.apply(Math, heights); 5910 }; 5911 5912 // Clear event listeners and time outs and the instance itself 5913 Wookmark.prototype.clear = function () { 5914 clearTimeout(this.resizeTimer); 5915 var i = this.placeholders.length; 5916 while (i--) { 5917 this.container.removeChild(this.placeholders[i]); 5918 } 5919 removeEventListener(window, 'resize', this.onResize); 5920 removeEventListener(this.container, 'refreshWookmark', this.onRefresh); 5921 }; 5922 5923 // Register as jQuery plugin if jQuery is loaded 5924 if (window.jQuery !== undefined) { 5925 jQuery.fn.wookmark = function (options) { 5926 var i = this.length; 5927 // Use first element if container is an jQuery object 5928 if (options !== undefined && options.container instanceof jQuery) { 5929 options.container = options.container[0]; 5930 } 5931 5932 // Call plugin multiple times if there are multiple elements selected 5933 if (i > 1) { 5934 while (i--) { 5935 sesVideo(this).eq(i).wookmark(options); 5936 } 5937 } else if (i === 1) { 5938 // Create a wookmark instance or update an existing one 5939 if (!this.wookmarkInstance) { 5940 this.wookmarkInstance = new Wookmark(this[0], options || {}); 5941 } else { 5942 this.wookmarkInstance.updateOptions(options || {}); 5943 } 5944 } 5945 return this; 5946 }; 5947 } 5948 5949 window.Wookmark = Wookmark; 5950 return Wookmark; 5951})); 5952; 5953 5954 /*! 5955 * imagesLoaded PACKAGED v3.1.8 5956 * JavaScript is all like "You images are done yet or what?" 5957 * MIT License 5958 */ 5959 5960 5961/*! 5962 * EventEmitter v4.2.6 - git.io/ee 5963 * Oliver Caldwell 5964 * MIT license 5965 * @preserve 5966 */ 5967(function () { 5968 5969 5970 /** 5971 * Class for managing events. 5972 * Can be extended to provide event functionality in other classes. 5973 * 5974 * @class EventEmitter Manages event registering and emitting. 5975 */ 5976 function EventEmitter() {} 5977 5978 // Shortcuts to improve speed and size 5979 var proto = EventEmitter.prototype; 5980 var exports = this; 5981 var originalGlobalValue = exports.EventEmitter; 5982 5983 /** 5984 * Finds the index of the listener for the event in it's storage array. 5985 * 5986 * @param {Function[]} listeners Array of listeners to search through. 5987 * @param {Function} listener Method to look for. 5988 * @return {Number} Index of the specified listener, -1 if not found 5989 * @api private 5990 */ 5991 function indexOfListener(listeners, listener) { 5992 var i = listeners.length; 5993 while (i--) { 5994 if (listeners[i].listener === listener) { 5995 return i; 5996 } 5997 } 5998 5999 return -1; 6000 } 6001 6002 /** 6003 * Alias a method while keeping the context correct, to allow for over
vendor: 11,346 bytes, lines 6003-6311
6003writing of target method. 6004 * 6005 * @param {String} name The name of the target method. 6006 * @return {Function} The aliased method 6007 * @api private 6008 */ 6009 function alias(name) { 6010 return function aliasClosure() { 6011 return this[name].apply(this, arguments); 6012 }; 6013 } 6014 6015 /** 6016 * Returns the listener array for the specified event. 6017 * Will initialise the event object and listener arrays if required. 6018 * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them. 6019 * Each property in the object response is an array of listener functions. 6020 * 6021 * @param {String|RegExp} evt Name of the event to return the listeners from. 6022 * @return {Function[]|Object} All listener functions for the event. 6023 */ 6024 proto.getListeners = function getListeners(evt) { 6025 var events = this._getEvents(); 6026 var response; 6027 var key; 6028 6029 // Return a concatenated array of all matching events if 6030 // the selector is a regular expression. 6031 if (typeof evt === 'object') { 6032 response = {}; 6033 for (key in events) { 6034 if (events.hasOwnProperty(key) && evt.test(key)) { 6035 response[key] = events[key]; 6036 } 6037 } 6038 } 6039 else { 6040 response = events[evt] || (events[evt] = []); 6041 } 6042 6043 return response; 6044 }; 6045 6046 /** 6047 * Takes a list of listener objects and flattens it into a list of listener functions. 6048 * 6049 * @param {Object[]} listeners Raw listener objects. 6050 * @return {Function[]} Just the listener functions. 6051 */ 6052 proto.flattenListeners = function flattenListeners(listeners) { 6053 var flatListeners = []; 6054 var i; 6055 6056 for (i = 0; i < listeners.length; i += 1) { 6057 flatListeners.push(listeners[i].listener); 6058 } 6059 6060 return flatListeners; 6061 }; 6062 6063 /** 6064 * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful. 6065 * 6066 * @param {String|RegExp} evt Name of the event to return the listeners from. 6067 * @return {Object} All listener functions for an event in an object. 6068 */ 6069 proto.getListenersAsObject = function getListenersAsObject(evt) { 6070 var listeners = this.getListeners(evt); 6071 var response; 6072 6073 if (listeners instanceof Array) { 6074 response = {}; 6075 response[evt] = listeners; 6076 } 6077 6078 return response || listeners; 6079 }; 6080 6081 /** 6082 * Adds a listener function to the specified event. 6083 * The listener will not be added if it is a duplicate. 6084 * If the listener returns true then it will be removed after it is called. 6085 * If you pass a regular expression as the event name then the listener will be added to all events that match it. 6086 * 6087 * @param {String|RegExp} evt Name of the event to attach the listener to. 6088 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. 6089 * @return {Object} Current instance of EventEmitter for chaining. 6090 */ 6091 proto.addListener = function addListener(evt, listener) { 6092 var listeners = this.getListenersAsObject(evt); 6093 var listenerIsWrapped = typeof listener === 'object'; 6094 var key; 6095 6096 for (key in listeners) { 6097 if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) { 6098 listeners[key].push(listenerIsWrapped ? listener : { 6099 listener: listener, 6100 once: false 6101 }); 6102 } 6103 } 6104 6105 return this; 6106 }; 6107 6108 /** 6109 * Alias of addListener 6110 */ 6111 proto.on = alias('addListener'); 6112 6113 /** 6114 * Semi-alias of addListener. It will add a listener that will be 6115 * automatically removed after it's first execution. 6116 * 6117 * @param {String|RegExp} evt Name of the event to attach the listener to. 6118 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. 6119 * @return {Object} Current instance of EventEmitter for chaining. 6120 */ 6121 proto.addOnceListener = function addOnceListener(evt, listener) { 6122 return this.addListener(evt, { 6123 listener: listener, 6124 once: true 6125 }); 6126 }; 6127 6128 /** 6129 * Alias of addOnceListener. 6130 */ 6131 proto.once = alias('addOnceListener'); 6132 6133 /** 6134 * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad. 6135 * You need to tell it what event names should be matched by a regex. 6136 * 6137 * @param {String} evt Name of the event to create. 6138 * @return {Object} Current instance of EventEmitter for chaining. 6139 */ 6140 proto.defineEvent = function defineEvent(evt) { 6141 this.getListeners(evt); 6142 return this; 6143 }; 6144 6145 /** 6146 * Uses defineEvent to define multiple events. 6147 * 6148 * @param {String[]} evts An array of event names to define. 6149 * @return {Object} Current instance of EventEmitter for chaining. 6150 */ 6151 proto.defineEvents = function defineEvents(evts) { 6152 for (var i = 0; i < evts.length; i += 1) { 6153 this.defineEvent(evts[i]); 6154 } 6155 return this; 6156 }; 6157 6158 /** 6159 * Removes a listener function from the specified event. 6160 * When passed a regular expression as the event name, it will remove the listener from all events that match it. 6161 * 6162 * @param {String|RegExp} evt Name of the event to remove the listener from. 6163 * @param {Function} listener Method to remove from the event. 6164 * @return {Object} Current instance of EventEmitter for chaining. 6165 */ 6166 proto.removeListener = function removeListener(evt, listener) { 6167 var listeners = this.getListenersAsObject(evt); 6168 var index; 6169 var key; 6170 6171 for (key in listeners) { 6172 if (listeners.hasOwnProperty(key)) { 6173 index = indexOfListener(listeners[key], listener); 6174 6175 if (index !== -1) { 6176 listeners[key].splice(index, 1); 6177 } 6178 } 6179 } 6180 6181 return this; 6182 }; 6183 6184 /** 6185 * Alias of removeListener 6186 */ 6187 proto.off = alias('removeListener'); 6188 6189 /** 6190 * Adds listeners in bulk using the manipulateListeners method. 6191 * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added. 6192 * You can also pass it a regular expression to add the array of listeners to all events that match it. 6193 * Yeah, this function does quite a bit. That's probably a bad thing. 6194 * 6195 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once. 6196 * @param {Function[]} [listeners] An optional array of listener functions to add. 6197 * @return {Object} Current instance of EventEmitter for chaining. 6198 */ 6199 proto.addListeners = function addListeners(evt, listeners) { 6200 // Pass through to manipulateListeners 6201 return this.manipulateListeners(false, evt, listeners); 6202 }; 6203 6204 /** 6205 * Removes listeners in bulk using the manipulateListeners method. 6206 * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. 6207 * You can also pass it an event name and an array of listeners to be removed. 6208 * You can also pass it a regular expression to remove the listeners from all events that match it. 6209 * 6210 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once. 6211 * @param {Function[]} [listeners] An optional array of listener functions to remove. 6212 * @return {Object} Current instance of EventEmitter for chaining. 6213 */ 6214 proto.removeListeners = function removeListeners(evt, listeners) { 6215 // Pass through to manipulateListeners 6216 return this.manipulateListeners(true, evt, listeners); 6217 }; 6218 6219 /** 6220 * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level. 6221 * The first argument will determine if the listeners are removed (true) or added (false). 6222 * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. 6223 * You can also pass it an event name and an array of listeners to be added/removed. 6224 * You can also pass it a regular expression to manipulate the listeners of all events that match it. 6225 * 6226 * @param {Boolean} remove True if you want to remove listeners, false if you want to add. 6227 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once. 6228 * @param {Function[]} [listeners] An optional array of listener functions to add/remove. 6229 * @return {Object} Current instance of EventEmitter for chaining. 6230 */ 6231 proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) { 6232 var i; 6233 var value; 6234 var single = remove ? this.removeListener : this.addListener; 6235 var multiple = remove ? this.removeListeners : this.addListeners; 6236 6237 // If evt is an object then pass each of it's properties to this method 6238 if (typeof evt === 'object' && !(evt instanceof RegExp)) { 6239 for (i in evt) { 6240 if (evt.hasOwnProperty(i) && (value = evt[i])) { 6241 // Pass the single listener straight through to the singular method 6242 if (typeof value === 'function') { 6243 single.call(this, i, value); 6244 } 6245 else { 6246 // Otherwise pass back to the multiple function 6247 multiple.call(this, i, value); 6248 } 6249 } 6250 } 6251 } 6252 else { 6253 // So evt must be a string 6254 // And listeners must be an array of listeners 6255 // Loop over it and pass each one to the multiple method 6256 i = listeners.length; 6257 while (i--) { 6258 single.call(this, evt, listeners[i]); 6259 } 6260 } 6261 6262 return this; 6263 }; 6264 6265 /** 6266 * Removes all listeners from a specified event. 6267 * If you do not specify an event then all listeners will be removed. 6268 * That means every event will be emptied. 6269 * You can also pass a regex to remove all events that match it. 6270 * 6271 * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed. 6272 * @return {Object} Current instance of EventEmitter for chaining. 6273 */ 6274 proto.removeEvent = function removeEvent(evt) { 6275 var type = typeof evt; 6276 var events = this._getEvents(); 6277 var key; 6278 6279 // Remove different things depending on the state of evt 6280 if (type === 'string') { 6281 // Remove all listeners for the specified event 6282 delete events[evt]; 6283 } 6284 else if (type === 'object') { 6285 // Remove all events matching the regex. 6286 for (key in events) { 6287 if (events.hasOwnProperty(key) && evt.test(key)) { 6288 delete events[key]; 6289 } 6290 } 6291 } 6292 else { 6293 // Remove all listeners in all events 6294 delete this._events; 6295 } 6296 6297 return this; 6298 }; 6299 6300 /** 6301 * Alias of removeEvent. 6302 * 6303 * Added to mirror the node API. 6304 */ 6305 proto.removeAllListeners = alias('removeEvent'); 6306 6307 /** 6308 * Emits an event of your choice. 6309 * When emitted, every listener attached to that event will be executed. 6310 * If you pass the optional argument array then those arguments will be passed to every listener upon execution. 6311 * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
6312 * So they will not arrive within the array on the other side, they will be separate. 6313 * You can also pass a regular expression to emit to all events that match it. 6314 * 6315 * @param {String|RegExp} evt Name of the event to emit and execute listeners for. 6316 * @param {Array} [args] Optional array of arguments to be passed to each listener. 6317 * @return {Object} Current instance of EventEmitter for chaining. 6318 */ 6319 proto.emitEvent = function emitEvent(evt, args) { 6320 var listeners = this.getListenersAsObject(evt); 6321 var listener; 6322 var i; 6323 var key; 6324 var response; 6325 6326 for (key in listeners) { 6327 if (listeners.hasOwnProperty(key)) { 6328 i = listeners[key].length; 6329 6330 while (i--) { 6331 // If the listener returns true then it shall be removed from the event 6332 // The function is executed either with a basic call or an apply if there is an args array 6333 listener = listeners[key][i]; 6334 6335 if (listener.once === true) { 6336 this.removeListener(evt, listener.listener); 6337 } 6338 6339 response = listener.listener.apply(this, args || []); 6340 6341 if (response === this._getOnceReturnValue()) { 6342 this.removeListener(evt, listener.listener); 6343 } 6344 } 6345 } 6346 } 6347 6348 return this; 6349 }; 6350 6351 /** 6352 * Alias of emitEvent 6353 */ 6354 proto.trigger = alias('emitEvent'); 6355 6356 /** 6357 * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on. 6358 * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it. 6359 * 6360 * @param {String|RegExp} evt Name of the event to emit and execute listeners for. 6361 * @param {...*} Optional additional arguments to be passed to each listener. 6362 * @return {Object} Current instance of EventEmitter for chaining. 6363 */ 6364 proto.emit = function emit(evt) { 6365 var args = Array.prototype.slice.call(arguments, 1); 6366 return this.emitEvent(evt, args); 6367 }; 6368 6369 /** 6370 * Sets the current value to check against when executing listeners. If a 6371 * listeners return value matches the one set here then it will be removed 6372 * after execution. This value defaults to true. 6373 * 6374 * @param {*} value The new value to check for when executing listeners. 6375 * @return {Object} Current instance of EventEmitter for chaining. 6376 */ 6377 proto.setOnceReturnValue = function setOnceReturnValue(value) { 6378 this._onceReturnValue = value; 6379 return this; 6380 }; 6381 6382 /** 6383 * Fetches the current value to check against when executing listeners. If 6384 * the listeners return value matches this one then it should be removed 6385 * automatically. It will return true by default. 6386 * 6387 * @return {*|Boolean} The current value to check for or the default, true. 6388 * @api private 6389 */ 6390 proto._getOnceReturnValue = function _getOnceReturnValue() { 6391 if (this.hasOwnProperty('_onceReturnValue')) { 6392 return this._onceReturnValue; 6393 } 6394 else { 6395 return true; 6396 } 6397 }; 6398 6399 /** 6400 * Fetches the events object and creates one if required. 6401 * 6402 * @return {Object} The events storage object. 6403 * @api private 6404 */ 6405 proto._getEvents = function _getEvents() { 6406 return this._events || (this._events = {}); 6407 }; 6408 6409 /** 6410 * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version. 6411 * 6412 * @return {Function} Non conflicting EventEmitter class. 6413 */ 6414 EventEmitter.noConflict = function noConflict() { 6415 exports.EventEmitter = originalGlobalValue; 6416 return EventEmitter; 6417 }; 6418 6419 // Expose the class either via AMD, CommonJS or the global object 6420 if (typeof define === 'function' && define.amd) { 6421 define('eventEmitter/EventEmitter',[],function () { 6422 return EventEmitter; 6423 }); 6424 } 6425 else if (typeof module === 'object' && module.exports){ 6426 module.exports = EventEmitter; 6427 } 6428 else { 6429 this.EventEmitter = EventEmitter; 6430 } 6431}.call(this)); 6432 6433/*! 6434 * eventie v1.0.4 6435 * event binding helper 6436 * eventie.bind( elem, 'click', myFn ) 6437 * eventie.unbind( elem, 'click', myFn ) 6438 */ 6439 6440/*jshint browser: true, undef: true, unused: true */ 6441/*global define: false */ 6442 6443( function( window ) { 6444 6445 6446 6447var docElem = document.documentElement; 6448 6449var bind = function() {}; 6450 6451function getIEEvent( obj ) { 6452 var event = window.event; 6453 // add event.target 6454 event.target = event.target || event.srcElement || obj; 6455 return event; 6456} 6457 6458if ( docElem.addEventListener ) { 6459 bind = function( obj, type, fn ) { 6460 obj.addEventListener( type, fn, false ); 6461 }; 6462} else if ( docElem.attachEvent ) { 6463 bind = function( obj, type, fn ) { 6464 obj[ type + fn ] = fn.handleEvent ? 6465 function() { 6466 var event = getIEEvent( obj ); 6467 fn.handleEvent.call( fn, event ); 6468 } : 6469 function() { 6470 var event = getIEEvent( obj ); 6471 fn.call( obj, event ); 6472 }; 6473 obj.attachEvent( "on" + type, obj[ type + fn ] ); 6474 }; 6475} 6476 6477var unbind = function() {}; 6478 6479if ( docElem.removeEventListener ) { 6480 unbind = function( obj, type, fn ) { 6481 obj.removeEventListener( type, fn, false ); 6482 }; 6483} else if ( docElem.detachEvent ) { 6484 unbind = function( obj, type, fn ) { 6485 obj.detachEvent( "on" + type, obj[ type + fn ] ); 6486 try { 6487 delete obj[ type + fn ]; 6488 } catch ( err ) { 6489 // can't delete window object properties 6490 obj[ type + fn ] = undefined; 6491 } 6492 }; 6493} 6494 6495var eventie = { 6496 bind: bind, 6497 unbind: unbind 6498}; 6499 6500// transport 6501if ( typeof define === 'function' && define.amd ) { 6502 // AMD 6503 define( 'eventie/eventie',eventie ); 6504} else { 6505 // browser global 6506 window.eventie = eventie; 6507} 6508 6509})( this ); 6510 6511/*! 6512 * imagesLoaded v3.1.8 6513 * JavaScript is all like "You images are done yet or what?" 6514 * MIT License 6515 */ 6516 6517( function( window, factory ) { 6518 // universal module definition 6519 6520 /*global define: false, module: false, require: false */ 6521 6522 if ( typeof define === 'function' && define.amd ) { 6523 // AMD 6524 define( [ 6525 'eventEmitter/EventEmitter', 6526 'eventie/eventie' 6527 ], function( EventEmitter, eventie ) { 6528 return factory( window, EventEmitter, eventie ); 6529 }); 6530 } else if ( typeof exports === 'object' ) { 6531 // CommonJS 6532 module.exports = factory( 6533 window, 6534 require('wolfy87-eventemitter'), 6535 require('eventie') 6536 ); 6537 } else { 6538 // browser global 6539 window.imagesLoaded = factory( 6540 window, 6541 window.EventEmitter, 6542 window.eventie 6543 ); 6544 } 6545 6546})( window, 6547 6548// -------------------------- factory -------------------------- // 6549 6550function factory( window, EventEmitter, eventie ) { 6551 6552 6553 6554var $ = scriptJquery; 6555var console = window.console; 6556var hasConsole = typeof console !== 'undefined'; 6557 6558// -------------------------- helpers -------------------------- // 6559 6560// extend objects 6561function extend( a, b ) { 6562 for ( var prop in b ) { 6563 a[ prop ] = b[ prop ]; 6564 } 6565 return a; 6566} 6567 6568var objToString = Object.prototype.toString; 6569function isArray( obj ) { 6570 return objToString.call( obj ) === '[object Array]'; 6571} 6572 6573// turn element or nodeList into an array 6574function makeArray( obj ) { 6575 var ary = []; 6576 if ( isArray( obj ) ) { 6577 // use object if already an array 6578 ary = obj; 6579 } else if ( typeof obj.length === 'number' ) { 6580 // convert nodeList to array 6581 for ( var i=0, len = obj.length; i < len; i++ ) { 6582 ary.push( obj[i] ); 6583 } 6584 } else { 6585 // array of single index 6586 ary.push( obj ); 6587 } 6588 return ary; 6589} 6590 6591 // -------------------------- imagesLoaded -------------------------- // 6592 6593 /** 6594 * @param {Array, Element, NodeList, String} elem 6595 * @param {Object or Function} options - if function, use as callback 6596 * @param {Function} onAlways - callback function 6597 */ 6598 function ImagesLoaded( elem, options, onAlways ) { 6599 // coerce ImagesLoaded() without new, to be new ImagesLoaded() 6600 if ( !( this instanceof ImagesLoaded ) ) { 6601 return new ImagesLoaded( elem, options ); 6602 } 6603 // use elem as selector string 6604 if ( typeof elem === 'string' ) { 6605 elem = document.querySelectorAll( elem ); 6606 } 6607 6608 this.elements = makeArray( elem ); 6609 this.options = extend( {}, this.options ); 6610 6611 if ( typeof options === 'function' ) { 6612 onAlways = options; 6613 } else { 6614 extend( this.options, options ); 6615 } 6616 6617 if ( onAlways ) { 6618 this.on( 'always', onAlways ); 6619 } 6620 6621 this.getImages(); 6622 6623 if ( $ ) { 6624 // add jQuery Deferred object 6625 this.jqDeferred = new $.Deferred(); 6626 } 6627 6628 // HACK check async to allow time to bind listeners 6629 var _this = this; 6630 setTimeout( function() { 6631 _this.check(); 6632 }); 6633 } 6634 6635 ImagesLoaded.prototype = new EventEmitter(); 6636 6637 ImagesLoaded.prototype.options = {}; 6638 6639 ImagesLoaded.prototype.getImages = function() { 6640 this.images = []; 6641 6642 // filter & find items if we have an item selector 6643 for ( var i=0, len = this.elements.length; i < len; i++ ) { 6644 var elem = this.elements[i]; 6645 // filter siblings 6646 if ( elem.nodeName === 'IMG' ) { 6647 this.addImage( elem ); 6648 } 6649 // find children 6650 // no non-element nodes, #143 6651 var nodeType = elem.nodeType; 6652 if ( !nodeType || !( nodeType === 1 || nodeType === 9 || nodeType === 11 ) ) { 6653 continue; 6654 } 6655 var childElems = elem.querySelectorAll('li > div > div > div > a > img'); 6656 // concat childElems to filterFound array 6657 for ( var j=0, jLen = childElems.length; j < jLen; j++ ) { 6658 var img = childElems[j]; 6659 this.addImage( img ); 6660 } 6661 } 6662 }; 6663 6664 /** 6665 * @param {Image} img 6666 */ 6667 ImagesLoaded.prototype.addImage = function( img ) { 6668 var loadingImage = new LoadingImage( img ); 6669 this.images.push( loadingImage ); 6670 }; 6671
6672 ImagesLoaded.prototype.check = function() { 6673 var _this = this; 6674 var checkedCount = 0; 6675 var length = this.images.length; 6676 this.hasAnyBroken = false; 6677 // complete if no images 6678 if ( !length ) { 6679 this.complete(); 6680 return; 6681 } 6682 6683 function onConfirm( image, message ) { 6684 if ( _this.options.debug && hasConsole ) { 6685 console.log( 'confirm', image, message ); 6686 } 6687 6688 _this.progress( image ); 6689 checkedCount++; 6690 if ( checkedCount === length ) { 6691 _this.complete(); 6692 } 6693 return true; // bind once 6694 } 6695 6696 for ( var i=0; i < length; i++ ) { 6697 var loadingImage = this.images[i]; 6698 loadingImage.on( 'confirm', onConfirm ); 6699 loadingImage.check(); 6700 } 6701 }; 6702 6703 ImagesLoaded.prototype.progress = function( image ) { 6704 this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded; 6705 // HACK - Chrome triggers event before object properties have changed. #83 6706 var _this = this; 6707 setTimeout( function() { 6708 _this.emit( 'progress', _this, image ); 6709 if ( _this.jqDeferred && _this.jqDeferred.notify ) { 6710 _this.jqDeferred.notify( _this, image ); 6711 } 6712 }); 6713 }; 6714 6715 ImagesLoaded.prototype.complete = function() { 6716 var eventName = this.hasAnyBroken ? 'fail' : 'done'; 6717 this.isComplete = true; 6718 var _this = this; 6719 // HACK - another setTimeout so that confirm happens after progress 6720 setTimeout( function() { 6721 _this.emit( eventName, _this ); 6722 _this.emit( 'always', _this ); 6723 if ( _this.jqDeferred ) { 6724 var jqMethod = _this.hasAnyBroken ? 'reject' : 'resolve'; 6725 _this.jqDeferred[ jqMethod ]( _this ); 6726 } 6727 }); 6728 }; 6729 6730 // -------------------------- jquery -------------------------- // 6731 6732 if ( $ ) { 6733 $.fn.imagesLoaded = function( options, callback ) { 6734 var instance = new ImagesLoaded( this, options, callback ); 6735 return instance.jqDeferred.promise( $(this) ); 6736 }; 6737 } 6738 6739 6740 // -------------------------- -------------------------- // 6741 6742 function LoadingImage( img ) { 6743 this.img = img; 6744 } 6745 6746 LoadingImage.prototype = new EventEmitter(); 6747 6748 LoadingImage.prototype.check = function() { 6749 // first check cached any previous images that have same src 6750 var resource = cache[ this.img.src ] || new Resource( this.img.src ); 6751 if ( resource.isConfirmed ) { 6752 this.confirm( resource.isLoaded, 'cached was confirmed' ); 6753 return; 6754 } 6755 6756 // If complete is true and browser supports natural sizes, 6757 // try to check for image status manually. 6758 if ( this.img.complete && this.img.naturalWidth !== undefined ) { 6759 // report based on naturalWidth 6760 this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' ); 6761 return; 6762 } 6763 6764 // If none of the checks above matched, simulate loading on detached element. 6765 var _this = this; 6766 resource.on( 'confirm', function( resrc, message ) { 6767 _this.confirm( resrc.isLoaded, message ); 6768 return true; 6769 }); 6770 6771 resource.check(); 6772 }; 6773 6774 LoadingImage.prototype.confirm = function( isLoaded, message ) { 6775 this.isLoaded = isLoaded; 6776 this.emit( 'confirm', this, message ); 6777 }; 6778 6779 // -------------------------- Resource -------------------------- // 6780 6781 // Resource checks each src, only once 6782 // separate class from LoadingImage to prevent memory leaks. See #115 6783 6784 var cache = {}; 6785 6786 function Resource( src ) { 6787 this.src = src; 6788 // add to cache 6789 cache[ src ] = this; 6790 } 6791 6792 Resource.prototype = new EventEmitter(); 6793 6794 Resource.prototype.check = function() { 6795 // only trigger checking once 6796 if ( this.isChecked ) { 6797 return; 6798 } 6799 // simulate loading on detached element 6800 var proxyImage = new Image(); 6801 eventie.bind( proxyImage, 'load', this ); 6802 eventie.bind( proxyImage, 'error', this ); 6803 proxyImage.src = this.src; 6804 // set flag 6805 this.isChecked = true; 6806 }; 6807 6808 // ----- events ----- // 6809 6810 // trigger specified handler for event type 6811 Resource.prototype.handleEvent = function( event ) { 6812 var method = 'on' + event.type; 6813 if ( this[ method ] ) { 6814 this[ method ]( event ); 6815 } 6816 }; 6817 6818 Resource.prototype.onload = function( event ) { 6819 this.confirm( true, 'onload' ); 6820 this.unbindProxyEvents( event ); 6821 }; 6822 6823 Resource.prototype.onerror = function( event ) { 6824 this.confirm( false, 'onerror' ); 6825 this.unbindProxyEvents( event ); 6826 }; 6827 6828 // ----- confirm ----- // 6829 6830 Resource.prototype.confirm = function( isLoaded, message ) { 6831 this.isConfirmed = true; 6832 this.isLoaded = isLoaded;
6833 this.emit( 'confirm', this, message ); 6834 }; 6835 6836 Resource.prototype.unbindProxyEvents = function( event ) { 6837 eventie.unbind( event.target, 'load', this ); 6838 eventie.unbind( event.target, 'error', this ); 6839 }; 6840 6841 // ----- ----- // 6842 6843 return ImagesLoaded; 6844 6845});; 6846 6847 /*! 6848 * jquery.drag-n-crop 6849 * https://github.com/lukaszfiszer/drag-n-crop 6850 * 6851 * Copyright (c) 2013 Lukasz Fiszer 6852 * Licensed under the MIT license. 6853 */ 6854 6855;(function ( $, window, document, undefined ) { 6856 $.widget( "lukaszfiszer.dragncrop" , { 6857 6858 classes: { 6859 // Basic classes 6860 container: 'dragncrop', 6861 containerActive: 'dragncrop-dragging', 6862 containment: 'dragncrop-containment', 6863 horizontal: 'dragncrop-horizontal', 6864 vertical: 'dragncrop-vertical', 6865 6866 // Options' classes 6867 overflow: 'dragncrop-overflow', 6868 overlay: 'dragncrop-overlay', 6869 instruction: 'dragncrop-instruction', 6870 instructionHide: 'dragncrop-instruction-autohide', 6871 instructionText: 'dragncrop-instruction-text' 6872 }, 6873 6874 options: { 6875 // Initial position 6876 position: {}, 6877 centered: false, 6878 6879 // Simple overflow: 6880 overflow: false, 6881 6882 // Overflaid overflow 6883 overlay: false, 6884 6885 // Drag instruction 6886 instruction: false, 6887 instructionText: 'Drag to crop', 6888 instructionHideOnHover: true, 6889 }, 6890 6891 move: function ( position ) { 6892 6893 var left, top, x, y; 6894 6895 if( !position ){ 6896 throw new Error('position object must be provided'); 6897 } 6898 6899 if (position.offset === undefined && position.dimension === undefined ) { 6900 throw new Error('position object must contain "left" or "top" props'); 6901 } 6902 6903 if( this.axis === 'x' && position.offset ){ 6904 left = -position.offset[0] * this.offsetX; 6905 this.element.css('left', left); 6906 this.element.css('top', 0); 6907 } else 6908 if( this.axis === 'x' && position.dimension ){ 6909 left = -position.dimension[0] * this.width; 6910 this.element.css('left', left); 6911 this.element.css('top', 0); 6912 } else 6913 6914 if( this.axis === 'y' && position.offset ){ 6915 top = -position.offset[1] * this.offsetY; 6916 this.element.css('left', 0); 6917 this.element.css('top', top); 6918 } else 6919 if( this.axis === 'y' && position.dimension ){ 6920 top = -position.dimension[1] * this.height; 6921 this.element.css('left', 0); 6922 this.element.css('top', top); 6923 } 6924 6925 this._setPosition( { left: left, top: top }); 6926 6927 }, 6928 6929 _create: function () { 6930 6931 this.container = $(this.element.parent()); 6932 this.container.addClass(this.classes.container); 6933 6934 if( this.options.overflow || this.options.overlay){ 6935 $(this.container).addClass(this.classes.overflow); 6936 } 6937 6938 var dfd = this.element.imagesLoaded(); 6939 var self = this; 6940 6941 dfd.done(function(){ 6942 if(self._setAxis.call(self)){ 6943 self._getDimensions.call(self); 6944 self._makeDraggable.call(self); 6945 if (self.options.loaded) { 6946 self.options.loaded(); 6947 } 6948 } 6949 } ); 6950 6951 }, 6952 6953 _destroy: function() { 6954 this.draggable && this.draggable.draggable('destroy'); 6955 this.container.find('.' + this.classes.containment + ',' + 6956 '.' + this.classes.overlay + ',' + 6957 '.' + this.classes.instruction).remove(); 6958 this.element.removeClass(this.classes.horizontal) 6959 .removeClass(this.classes.vertical); 6960 }, 6961 6962 getPosition: function() { 6963 return { 6964 offset : [ 6965 ( -this.position.left / this.offsetX) || 0, 6966 ( -this.position.top / this.offsetY) || 0 6967 ], 6968 dimension : [ 6969 ( -this.position.left / this.width) || 0, 6970 ( -this.position.top / this.height) || 0 6971 ] 6972 }; 6973 6974 }, 6975 6976 _getDimensions: function() { 6977 6978 this.width = this.element.width(); 6979 this.height = this.element.height(); 6980 6981 this.containerWidth = this.container.width(); 6982 this.containerHeight = this.container.height(); 6983 6984 this.offsetX = this.width - this.containerWidth; 6985 this.offsetY = this.height - this.containerHeight; 6986 6987 }, 6988 6989 _setAxis: function() { 6990 6991 this.photoRatio = this.element.width() / this.element.height(); 6992 this.containerRatio = this.container.width() / this.container.height(); 6993 6994 if (this.photoRatio > this.containerRatio) { 6995 6996 this.axis = 'x'; 6997 $(this.element).addClass(this.classes.horizontal); 6998 return true; 6999 7000 } else if (this.photoRatio < this.containerRatio) { 7001 7002 this.axis = 'y'; 7003 $(this.element).addClass(this.classes.vertical); 7004 return true; 7005 7006 }else{ 7007 7008 return false;
7009 7010 } 7011 7012 }, 7013 7014 _setPosition: function( obj ) { 7015 this.position = obj; 7016 }, 7017 7018 _makeDraggable : function () { 7019 7020 var axis = this.axis; 7021 var position = this.options.position; 7022 var containement = this._insertContainment(); 7023 7024 var draggable = this.draggable = this.element.draggable({ 7025 axis: axis, 7026 containment: containement 7027 }); 7028 7029 this._on({ 7030 dragstart: function (event, ui) { 7031 this._dragStart( event , ui ); 7032 this.container.addClass( this.classes.containerActive ); 7033 }, 7034 drag: function( event, ui ){ 7035 this._dragging( event , ui ); 7036 if (this.options.overlay) { 7037 this._adaptOverlay( ui ); 7038 } 7039 }, 7040 dragstop: function( event, ui ){ 7041 this._dragStop( event , ui ); 7042 this.container.removeClass( this.classes.containerActive ); 7043 } 7044 }); 7045 7046 if(this.options.overlay){ 7047 this._insertOverlay(); 7048 } 7049 7050 if(this.options.instruction){ 7051 this._insertInstruction(); 7052 } 7053 7054 if(this.options.centered){ 7055 position = { offset : [0.5, 0.5] }; 7056 } 7057 7058 if( position && ( position.offset || position.coordinates)) { 7059 this.move(position); 7060 }else{ 7061 this._setPosition({ left: 0, top: 0 }); 7062 } 7063 7064 }, 7065 7066 _dragStart: function( event, ui ) { 7067 this._setPosition(ui.position); 7068 this._trigger('start', event, this.getPosition() ); 7069 }, 7070 7071 _dragging: function( event, ui ) { 7072 this._setPosition(ui.position); 7073 this._trigger('drag', event, this.getPosition() ); 7074 }, 7075 7076 _dragStop: function( event, ui ) { 7077 this._setPosition(ui.position); 7078 this._trigger('stop', event, this.getPosition() ); 7079 }, 7080 7081 7082 _insertOverlay: function(){ 7083 7084 var overlay = $('<div>').addClass(this.classes.overlay); 7085 this.overlay = overlay.insertBefore(this.element); 7086 return this.overlay; 7087 7088 }, 7089 7090 _adaptOverlay: function( ui ) { 7091 7092 if ( this.axis === 'x' ) { 7093 7094 this.overlay.css('left', ui.position.left) 7095 .css('border-left-width', -ui.position.left) 7096 .css('right', -ui.position.left - this.offsetX) 7097 .css('border-right-width', ui.position.left + this.offsetX); 7098 7099 } else if ( this.axis === 'y' ){ 7100 7101 this.overlay.css('top', ui.position.top) 7102 .css('border-top-width', -ui.position.top) 7103 .css('bottom', -ui.position.top - this.offsetY ) 7104 .css('border-bottom-width', ui.position.top + this.offsetY ); 7105 } 7106 7107 }, 7108 7109 _insertContainment: function() { 7110 7111 var top = - this.offsetY; 7112 var bottom = - this.offsetY; 7113 var left = - this.offsetX; 7114 var right = - this.offsetX; 7115 7116 var containment = $('<div/>').addClass(this.classes.containment) 7117 .css('top',top).css('bottom', bottom) 7118 .css('left',left).css('right',right) 7119 .css('position','absolute'); 7120 7121 this.containment = containment.insertBefore(this.element); 7122 return this.containment; 7123 7124 }, 7125 7126 _insertInstruction: function() { 7127 this.instruction = $('<div>').addClass(this.classes.instruction); 7128 if(this.options.instructionHideOnHover){ 7129 this.instruction.addClass(this.classes.instructionHide); 7130 } 7131 this.instruction.append( 7132 $('<span></span>').text(this.options.instructionText) 7133 .addClass(this.classes.instructionText) 7134 ); 7135 this.instruction.insertAfter(this.element); 7136 return this.instruction; 7137 }, 7138 7139 }); 7140 7141})( scriptJquery, window, document ); 7142; 7143 7144 /*! 7145 * Theia Sticky Sidebar v1.7.0 7146 * https://github.com/WeCodePixels/theia-sticky-sidebar 7147 * 7148 * Glues your website's sidebars, making them permanently visible while scrolling. 7149 * 7150 * Copyright 2013-2016 WeCodePixels and other contributors 7151 * Released under the MIT license 7152 */ 7153 7154(function ($) { 7155 $.fn.theiaStickySidebar = function (options) { 7156 var defaults = { 7157 'containerSelector': '', 7158 'additionalMarginTop': 0, 7159 'additionalMarginBottom': 0, 7160 'updateSidebarHeight': true, 7161 'minWidth': 0, 7162 'disableOnResponsiveLayouts': true, 7163 'sidebarBehavior': 'modern', 7164 'defaultPosition': 'relative', 7165 'namespace': 'TSS' 7166 }; 7167 options = $.extend(defaults, options); 7168 7169 // Validate options 7170 options.additionalMarginTop = parseInt(options.additionalMarginTop) || 0; 7171 options.additionalMarginBottom = parseInt(options.additionalMarginBottom) || 0; 7172
7173 tryInitOrHookIntoEvents(options, this); 7174 7175 // Try doing init, otherwise hook into window.resize and document.scroll and try again then. 7176 function tryInitOrHookIntoEvents(options, $that) { 7177 var success = tryInit(options, $that); 7178 7179 if (!success) { 7180 console.log('TSS: Body width smaller than options.minWidth. Init is delayed.'); 7181 7182 $(document).on('scroll.' + options.namespace, function (options, $that) { 7183 return function (evt) { 7184 var success = tryInit(options, $that); 7185 7186 if (success) { 7187 $(this).unbind(evt); 7188 } 7189 }; 7190 }(options, $that)); 7191 $(window).on('resize.' + options.namespace, function (options, $that) { 7192 return function (evt) { 7193 var success = tryInit(options, $that); 7194 7195 if (success) { 7196 $(this).unbind(evt); 7197 } 7198 }; 7199 }(options, $that)) 7200 } 7201 } 7202 7203 // Try doing init if proper conditions are met. 7204 function tryInit(options, $that) { 7205 if (options.initialized === true) { 7206 return true; 7207 } 7208 7209 if ($('body').width() < options.minWidth) { 7210 return false; 7211 } 7212 7213 init(options, $that); 7214 7215 return true; 7216 } 7217 7218 // Init the sticky sidebar(s). 7219 function init(options, $that) { 7220 options.initialized = true; 7221 7222 // Add CSS 7223 var existingStylesheet = $('#theia-sticky-sidebar-stylesheet-' + options.namespace); 7224 if (existingStylesheet.length === 0) { 7225 $('head').append($('<style id="theia-sticky-sidebar-stylesheet-' + options.namespace + '">.theiaStickySidebar:after {content: ""; display: table; clear: both;}</style>')); 7226 } 7227 7228 $that.each(function () { 7229 var o = {}; 7230 7231 o.sidebar = $(this); 7232 7233 // Save options 7234 o.options = options || {}; 7235 7236 // Get container 7237 o.container = $(o.options.containerSelector); 7238 if (o.container.length == 0) { 7239 o.container = o.sidebar.parent(); 7240 } 7241 7242 // Create sticky sidebar 7243 o.sidebar.parents().css('-webkit-transform', 'none'); // Fix for WebKit bug - https://code.google.com/p/chromium/issues/detail?id=20574 7244 o.sidebar.css({ 7245 'position': o.options.defaultPosition, 7246 'overflow': 'visible', 7247 // The "box-sizing" must be set to "content-box" because we set a fixed height to this element when the sticky
7247sidebar has a fixed position. 7248 '-webkit-box-sizing': 'border-box', 7249 '-moz-box-sizing': 'border-box', 7250 'box-sizing': 'border-box' 7251 }); 7252 7253 // Get the sticky sidebar element. If none has been found, then create one. 7254 o.stickySidebar = o.sidebar.find('.theiaStickySidebar'); 7255 if (o.stickySidebar.length == 0) { 7256 // Remove <script> tags, otherwise they will be run again when added to the stickySidebar. 7257 var javaScriptMIMETypes = /(?:text|application)\/(?:x-)?(?:javascript|ecmascript)/i; 7258 o.sidebar.find('script').filter(function (index, script) { 7259 return script.type.length === 0 || script.type.match(javaScriptMIMETypes); 7260 }).remove(); 7261 7262 o.stickySidebar = $('<div>').addClass('theiaStickySidebar').append(o.sidebar.children()); 7263 o.sidebar.append(o.stickySidebar); 7264 } 7265 7266 // Get existing top and bottom margins and paddings 7267 o.marginBottom = parseInt(o.sidebar.css('margin-bottom')); 7268 o.paddingTop = parseInt(o.sidebar.css('padding-top')); 7269 o.paddingBottom = parseInt(o.sidebar.css('padding-bottom')); 7270
7271 // Add a temporary padding rule to check for collapsable margins. 7272 var collapsedTopHeight = o.stickySidebar.offset().top; 7273 var collapsedBottomHeight = o.stickySidebar.outerHeight(); 7274 o.stickySidebar.css('padding-top', 1); 7275 o.stickySidebar.css('padding-bottom', 1); 7276 collapsedTopHeight -= o.stickySidebar.offset().top; 7277 collapsedBottomHeight = o.stickySidebar.outerHeight() - collapsedBottomHeight - collapsedTopHeight; 7278 if (collapsedTopHeight == 0) { 7279 o.stickySidebar.css('padding-top', 0); 7280 o.stickySidebarPaddingTop = 0; 7281 } 7282 else { 7283 o.stickySidebarPaddingTop = 1; 7284 } 7285 7286 if (collapsedBottomHeight == 0) { 7287 o.stickySidebar.css('padding-bottom', 0); 7288 o.stickySidebarPaddingBottom = 0; 7289 } 7290 else { 7291 o.stickySidebarPaddingBottom = 1; 7292 } 7293 7294 // We use this to know whether the user is scrolling up or down. 7295 o.previousScrollTop = null; 7296 7297 // Scroll top (value) when the sidebar has fixed position. 7298 o.fixedScrollTop = 0; 7299 7300 // Set sidebar to default values. 7301 resetSidebar(); 7302 7303 o.onScroll = function (o) { 7304 // Stop if the sidebar isn't visible. 7305 if (!o.stickySidebar.is(":visible")) { 7306 return; 7307 } 7308 7309 // Stop if the window is too small. 7310 if ($('body').width() < o.options.minWidth) { 7311 resetSidebar(); 7312 return; 7313 } 7314 7315 // Stop if the sidebar width is larger than the container width (e.g. the theme is responsive and the sidebar is now below the content) 7316 if (o.options.disableOnResponsiveLayouts) { 7317 var sidebarWidth = o.sidebar.outerWidth(o.sidebar.css('float') == 'none'); 7318 7319 if (sidebarWidth + 50 > o.container.width()) { 7320 resetSidebar(); 7321 return; 7322 } 7323 } 7324 7325 var scrollTop = $(document).scrollTop(); 7326 var position = 'static'; 7327 7328 // If the user has scrolled down enough for the sidebar to be clipped at the top, then we can consider changing its position. 7329 if (scrollTop >= o.sidebar.offset().top + (o.paddingTop - o.options.additionalMarginTop)) { 7330 // The top and bottom offsets, used in various calculations. 7331 var offsetTop = o.paddingTop + options.additionalMarginTop; 7332 var offsetBottom = o.paddingBottom + o.marginBottom + options.additionalMarginBottom; 7333 7334 // All top and bottom positions are relative to the window, not to the parent elemnts. 7335 var containerTop = o.sidebar.offset().top; 7336 var containerBottom = o.sidebar.offset().top + getClearedHeight(o.container); 7337 7338 // The top and bottom offsets relative to the window screen top (zero) and bottom (window height). 7339 var windowOffsetTop = 0 + options.additionalMarginTop; 7340 var windowOffsetBottom; 7341 7342 var sidebarSmallerThanWindow = (o.stickySidebar.outerHeight() + offsetTop + offsetBottom) < $(window).height(); 7343 if (sidebarSmallerThanWindow) { 7344 windowOffsetBottom = windowOffsetTop + o.stickySidebar.outerHeight(); 7345 } 7346 else { 7347 windowOffsetBottom = $(window).height() - o.marginBottom - o.paddingBottom - options.additionalMarginBottom; 7348 } 7349 7350 var staticLimitTop = containerTop - scrollTop + o.paddingTop; 7351 var staticLimitBottom = containerBottom - scrollTop - o.paddingBottom - o.marginBottom; 7352 7353 var top = o.stickySidebar.offset().top - scrollTop; 7354 var scrollTopDiff = o.previousScrollTop - scrollTop; 7355 7356 // If the sidebar position is fixed, then it won't move up or down by itself. So, we manually adjust the top coordinate. 7357 if (o.stickySidebar.css('position') == 'fixed') { 7358 if (o.options.sidebarBehavior == 'modern') { 7359 top += scrollTopDiff; 7360 } 7361 } 7362 7363 if (o.options.sidebarBehavior == 'stick-to-top') { 7364 top = options.additionalMarginTop; 7365 } 7366 7367 if (o.options.sidebarBehavior == 'stick-to-bottom') { 7368 top = windowOffsetBottom - o.stickySidebar.outerHeight(); 7369 } 7370 7371 if (scrollTopDiff > 0) { // If the user is scrolling up. 7372 top = Math.min(top, windowOffsetTop); 7373 } 7374 else { // If the user is scrolling down. 7375 top = Math.max(top, windowOffsetBottom - o.stickySidebar.outerHeight()); 7376 } 7377 7378 top = Math.max(top, staticLimitTop); 7379 7380 top = Math.min(top, staticLimitBottom - o.stickySidebar.outerHeight()); 7381 7382 // If the sidebar is the same height as the container, we won't use fixed positioning. 7383 var sidebarSameHeightAsContainer = o.container.height() == o.stickySidebar.outerHeight(); 7384 7385 if (!sidebarSameHeightAsContainer && top == windowOffsetTop) { 7386 position = 'fixed'; 7387 } 7388 else if (!sidebarSameHeightAsContainer && top == windowOffsetBottom - o.stickySidebar.outerHeight()) { 7389 position = 'fixed'; 7390 } 7391 else if (scrollTop + top - o.sidebar.offset().top - o.paddingTop <= options.additionalMarginTop) { 7392 // Stuck to the top of the page. No special behavior. 7393 position = 'static'; 7394 } 7395 else { 7396 // Stuck to the bottom of the page. 7397 position = 'absolute'; 7398 } 7399 } 7400 7401 /*
7402 * Performance notice: It's OK to set these CSS values at each resize/scroll, even if they don't change. 7403 * It's way slower to first check if the values have changed. 7404 */ 7405 if (position == 'fixed') { 7406 var scrollLeft = $(document).scrollLeft(); 7407 7408 o.stickySidebar.css({ 7409 'position': 'fixed', 7410 'width': getWidthForObject(o.stickySidebar) + 'px', 7411 'transform': 'translateY(' + top + 'px)', 7412 'left': (o.sidebar.offset().left + parseInt(o.sidebar.css('padding-left')) - scrollLeft) + 'px', 7413 'top': '0px' 7414 }); 7415 } 7416 else if (position == 'absolute') { 7417 var css = {}; 7418 7419 if (o.stickySidebar.css('position') != 'absolute') { 7420 css.position = 'absolute'; 7421 css.transform = 'translateY(' + (scrollTop + top - o.sidebar.offset().top - o.stickySidebarPaddingTop - o.stickySidebarPaddingBottom) + 'px)'; 7422 css.top = '0px'; 7423 } 7424 7425 css.width = getWidthForObject(o.stickySidebar) + 'px'; 7426 css.left = ''; 7427 7428 o.stickySidebar.css(css); 7429 } 7430 else if (position == 'static') { 7431 resetSidebar(); 7432 } 7433 7434 if (position != 'static') { 7435 if (o.options.updateSidebarHeight == true) { 7436 o.sidebar.css({ 7437 'min-height': o.stickySidebar.outerHeight() + o.stickySidebar.offset().top - o.sidebar.offset().top + o.paddingBottom 7438 }); 7439 } 7440 } 7441 7442 o.previousScrollTop = scrollTop; 7443 }; 7444 7445 // Initialize the sidebar's position. 7446 o.onScroll(o); 7447 7448 // Recalculate the sidebar's position on every scroll and resize. 7449 $(document).on('scroll.' + o.options.namespace, function (o) { 7450 return function () { 7451 o.onScroll(o); 7452 }; 7453 }(o)); 7454 $(window).on('resize.' + o.options.namespace, function (o) { 7455 return function () { 7456 o.stickySidebar.css({'position': 'static'}); 7457 o.onScroll(o); 7458 }; 7459 }(o)); 7460 7461 // Recalculate the sidebar's position every time the sidebar changes its size. 7462 if (typeof ResizeSensor !== 'undefined') { 7463 new ResizeSensor(o.stickySidebar[0], function (o) { 7464 return function () { 7465 o.onScroll(o); 7466 }; 7467 }(o)); 7468 } 7469 7470 // Reset the sidebar to its default state 7471 function resetSidebar() { 7472 o.fixedScrollTop = 0; 7473 o.sidebar.css({ 7474 'min-height': '1px' 7475 }); 7476 o.stickySidebar.css({ 7477 'position': 'static', 7478 'width': '', 7479 'transform': 'none' 7480 }); 7481 } 7482 7483 // Get the height of a div as if its floated children were cleared. Note that this function fails if the floats are more than one level deep. 7484 function getClearedHeight(e) { 7485 var height = e.height(); 7486 7487 e.children().each(function () { 7488 height = Math.max(height, $(this).height()); 7489 }); 7490 7491 return height; 7492 } 7493 }); 7494 } 7495 7496 function getWidthForObject(object) { 7497 var width; 7498 7499 try { 7500 width = object[0].getBoundingClientRect().width; 7501 } 7502 catch (err) { 7503 } 7504 7505 if (typeof width === "undefined") { 7506 width = object.width(); 7507 } 7508 7509 return width; 7510 } 7511 7512 return this; 7513 } 7514}
vendor: 11,483 bytes, lines 7514-7529
7514)(scriptJquery);; 7515 7516 /*! 7517 * jQuery JavaScript Library v3.1.1 7518 * https://jquery.com/ 7519 * 7520 * Includes Sizzle.js 7521 * https://sizzlejs.com/ 7522 * 7523 * Copyright jQuery Foundation and other contributors 7524 * Released under the MIT license 7525 * https://jquery.org/license 7526 * 7527 * Date: 2016-09-22T22:30Z 7528 */ 7529!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}function w(a){var b=!!a&&"length"in a&&a.length,c=r.type(a);return"function"!==c&&!r.isWindow(a)&&("array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a)}function D(a,b,c){return r.isFunction(b)?r.grep(a,function(a,d){return!!b.call(a,d,a)!==c}):b.nodeType?r.grep(a,function(a){return a===b!==c}):"string"!=typeof b?r.grep(a,function(a){return i.call(b,a)>-1!==c}):C.test(b)?r.filter(b,a,c):(b=r.filter(b,a),r.grep(a,function(a){return i.call(b,a)>-1!==c&&1===a.nodeType}))}function J(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function L(a){var b={};return r.each(a.match(K)||[],function(a,c){b[c]=!0}),b}function M(a){return a}function N(a){throw a}function O(a,b,c){var d;try{a&&r.isFunction(d=a.promise)?d.call(a).done(b).fail(c):a&&r.isFunction(d=a.then)?d.call(a,b,c):b.call(void 0,a)}catch(a){c.call(void 0,a)}}function R(){d.removeEventListener("DOMContentLoaded",R),a.removeEventListener("load",R),r.ready()}function U(){this.expando=r.expando+U.uid++}function Z(a){return"true"===a||"false"!==a&&("null"===a?null:a===+a+""?+a:X.test(a)?JSON.parse(a):a)}function $(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(Y,"-$&").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c=Z(c)}catch(a){}W.set(a,b,c)}else c=void 0;return c}function ea(a,b,c,d){var e,f=1,g=20,h=d?function(){return d.cur()}:function(){return r.css(a,b,"")},i=h(),j=c&&c[3]||(r.cssNumber[b]?"":"px"),k=(r.cssNumber[b]||"px"!==j&&+i)&&aa.exec(r.css(a,b));if(k&&k[3]!==j){j=j||k[3],c=c||[],k=+i||1;do f=f||".5",k/=f,r.style(a,b,k+j);while(f!==(f=h()/i)&&1!==f&&--g)}return c&&(k=+k||+i||0,e=c[1]?k+(c[1]+1)*c[2]:+c[2],d&&(d.unit=j,d.start=k,d.end=e)),e}function ga(a){var b,c=a.ownerDocument,d=a.nodeName,e=fa[d];return e?e:(b=c.body.appendChild(c.createElement(d)),e=r.css(b,"display"),b.parentNode.removeChild(b),"none"===e&&(e="block"),fa[d]=e,e)}function ha(a,b){for(var c,d,e=[],f=0,g=a.length;f<g;f++)d=a[f],d.style&&(c=d.style.display,b?("none"===c&&(e[f]=V.get(d,"display")||null,e[f]||(d.style.display="")),""===d.style.display&&ca(d)&&(e[f]=ga(d))):"none"!==c&&(e[f]="none",V.set(d,"display",c)));for(f=0;f<g;f++)null!=e[f]&&(a[f].style.display=e[f]);return a}function ma(a,b){var c;return c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[],void 0===b||b&&r.nodeName(a,b)?r.merge([a],c):c}function na(a,b){for(var c=0,d=a.length;c<d;c++)V.set(a[c],"globalEval",!b||V.get(b[c],"globalEval"))}function pa(a,b,c,d,e){for(var f,g,h,i,j,k,l=b.createDocumentFragment(),m=[],n=0,o=a.length;n<o;n++)if(f=a[n],f||0===f)if("object"===r.type(f))r.merge(m,f.nodeType?[f]:f);else if(oa.test(f)){for(g=g||l.appendChild(b.createElement("div")),h=(ja.exec(f)||["",""])[1].toLowerCase(),i=la[h]||la._default,g.innerHTML=i[1]+r.htmlPrefilter(f)+i[2],k=i[0];k--;)g=g.lastChild;r.merge(m,g.childNodes),g=l.firstChild,g.textContent=""}else m.push(b.createTextNode(f));for(l.textContent="",n=0;f=m[n++];)if(d&&r.inArray(f,d)>-1)e&&e.push(f);else if(j=r.contains(f.ownerDocument,f),g=ma(l.appendChild(f),"script"),j&&na(g),c)for(k=0;f=g[k++];)ka.test(f.type||"")&&c.push(f);return l}function ua(){return!0}function va(){return!1}function wa(){try{return d.activeElement}catch(a){}}function xa(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)xa(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=va;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}function Da(a,b){return r.nodeName(a,"table")&&r.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a:a}function Ea(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function Fa(a){var b=Ba.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ga(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(V.hasData(a)&&(f=V.access(a),g=V.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;c<d;c++)r.event.add(b,e,j[e][c])}W.hasData(a)&&(h=W.access(a),i=r.extend({},h),W.set(b,i))}}function Ha(a,b){var c=b.nodeName.toLowerCase();"input"===c&&ia.test(a.type)?b.checked=a.checked:"input"!==c&&"textarea"!==c||(b.defaultValue=a.defaultValue)}function Ia(a,b,c,d){b=g.apply([],b);var e,f,h,i,j,k,l=0,m=a.length,n=m-1,q=b[0],s=r.isFunction(q);if(s||m>1&&"string"==typeof q&&!o.checkClone&&Aa.test(q))return a.each(function(e){var f=a.eq(e);s&&(b[0]=q.call(this,e,f.html())),Ia(f,b,c,d)});if(m&&(e=pa(b,a[0].ownerDocument,!1,a,d),f=e.firstChild,1===e.childNodes.length&&(e=f),f||d)){for(h=r.map(ma(e,"script"),Ea),i=h.length;l<m;l++)j=e,l!==n&&(j=r.clone(j,!0,!0),i&&r.merge(h,ma(j,"script"))),c.call(a[l],j,l);if(i)for(k=h[h.length-1].ownerDocument,r.map(h,Fa),l=0;l<i;l++)j=h[l],ka.test(j.type||"")&&!V.access(j,"globalEval")&&r.contains(k,j)&&(j.src?r._evalUrl&&r._evalUrl(j.src):p(j.textContent.replace(Ca,""),k))}return a}function Ja(a,b,c){for(var d,e=b?r.filter(b,a):a,f=0;null!=(d=e[f]);f++)c||1!==d.nodeType||r.cleanData(ma(d)),d.parentNode&&(c&&r.contains(d.ownerDocument,d)&&na(ma(d,"script")),d.parentNode.removeChild(d));return a}function Na(a,b,c){var d,e,f,g,h=a.style;return c=c||Ma(a),c&&(g=c.getPropertyValue(b)||c[b],""!==g||r.contains(a.ownerDocument,a)||(g=r.style(a,b)),!o.pixelMarginRight()&&La.test(g)&&Ka.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function Oa(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}function Ua(a){if(a in Ta)return a;for(var b=a[0].toUpperCase()+a.slice(1),c=Sa.length;c--;)if(a=Sa[c]+b,a in Ta)return a}function Va(a,b,c){var d=aa.exec(b);return d?Math.max(0,d[2]-(c||0))+(d[3]||"px"):b}function Wa(a,b,c,d,e){var f,g=0;for(f=c===(d?"border":"content")?4:"width"===b?1:0;f<4;f+=2)"margin"===c&&(g+=r.css(a,c+ba[f],!0,e)),d?("content"===c&&(g-=r.css(a,"padding"+ba[f],!0,e)),"margin"!==c&&(g-=r.css(a,"border"+ba[f]+"Width",!0,e))):(g+=r.css(a,"padding"+ba[f],!0,e),"padding"!==c&&(g+=r.css(a,"border"+ba[f]+"Width",!0,e)));return g}function Xa(a,b,c){var d,e=!0,f=Ma(a),g="border-box"===r.css(a,"boxSizing",!1,f);if(a.getClientRects().length&&(d=a.getBoundingClientRect()[b]),d<=0||null==d){if(d=Na(a,b,f),(d<0||null==d)&&(d=a.style[b]),La.test(d))return d;e=g&&(o.boxSizingReliable()||d===a.style[b]),d=parseFloat(d)||0}return d+Wa(a,b,c||(g?"border":"content"),e,f)+"px"}function Ya(a,b,c,d,e){return new Ya.prototype.init(a,b,c,d,e)}function bb(){$a&&(a.requestAnimationFrame(bb),r.fx.tick())}function cb(){return a.setTimeout(function(){Za=void 0}),Za=r.now()}function db(a,b){var c,d=0,e={height:a};for(b=b?1:0;d<4;d+=2-b)c=ba[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function eb(a,b,c){for(var d,e=(hb.tweeners[b]||[]).concat(hb.tweeners["*"]),f=0,g=e.length;f<g;f++)if(d=e[f].call(c,b,a))return d}function fb(a,b,c){var d,e,f,g,h,i,j,k,l="width"in b||"height"in b,m=this,n={},o=a.style,p=a.nodeType&&ca(a),q=V.get(a,"fxshow");c.queue||(g=r._queueHooks(a,"fx"),null==g.unqueued&&(g.unqueued=0,h=g.empty.fire,g.empty.fire=function(){g.unqueued||h()}),g.unqueued++,m.always(function(){m.always(function(){g.unqueued--,r.queue(a,"fx").length||g.empty.fire()})}));for(d in b)if(e=b[d],_a.test(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}n[d]=q&&q[d]||r.style(a,d)}if(i=!r.isEmptyObject(b),i||!r.isEmptyObject(n)){l&&1===a.nodeType&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=q&&q.display,null==j&&(j=V.get(a,"display")),k=r.css(a,"display"),"none"===k&&(j?k=j:(ha([a],!0),j=a.style.display||j,k=r.css(a,"display"),ha([a]))),("inline"===k||"inline-block"===k&&null!=j)&&"none"===r.css(a,"float")&&(i||(m.done(function(){o.display=j}),null==j&&(k=o.display,j="none"===k?"":k)),o.display="inline-block")),c.overflow&&(o.overflow="hidden",m.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]})),i=!1;for(d in n)i||(q?"hidden"in q&&(p=q.hidden):q=V.access(a,"fxshow",{display:j}),f&&(q.hidden=!p),p&&ha([a],!0),m.done(function(){p||ha([a]),V.remove(a,"fxshow");for(d in n)r.style(a,d,n[d])})),i=eb(p?q[d]:0,d,m),d in q||(q[d]=i.start,p&&(i.end=i.start,i.start=0))}}function gb(a,b){var c,d,e,f,g;for(c in a)if(d=r.camelCase(c),e=b[d],f=a[c],r.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=r.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function hb(a,b,c){var d,e,f=0,g=hb.prefilters.length,h=r.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Za||cb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;g<i;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),f<1&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:r.extend({},b),opts:r.extend(!0,{specialEasing:{},easing:r.easing._default},c),originalProperties:b,originalOptions:c,startTime:Za||cb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=r.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;c<d;c++)j.tweens[c].run(1);return b?(h.notifyWith(a,[j,1,0]),h.resolveWith(a,[j,b])):h.rejectWith(a,[j,b]),this}}),k=j.props;for(gb(k,j.opts.specialEasing);f<g;f++)if(d=hb.prefilters[f].call(j,a,k,j.opts))return r.isFunction(d.stop)&&(r._queueHooks(j.elem,j.opts.queue).stop=r.proxy(d.stop,d)),d;return r.map(k,eb,j),r.isFunction(j.opts.start)&&j.opts.start.call(a,j),r.fx.timer(r.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}function mb(a){var b=a.match(K)||[];return b.join(" ")}function nb(a){return a.getAttribute&&a.getAttribute("class")||""}function xb(a,b,c,d){var e;if(r.isArray(b))r.each(b,function(b,e){c||tb.test(a)?d(a,e):xb(a+"["+("object"==typeof e&&null!=e?b:"")+"]",e,c,d)});else if(c||"object"!==r.type(b))d(a,b);else for(e in b)xb(a+"["+e+"]",b[e],c,d)}function Jb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(K)||[];if(r.isFunction(c))for(;d=f[e++];)"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Kb(a,b,c,d){function g(h){var i;return e[h]=!0,r.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}var e={},f=a===Gb;return g(b.dataTypes[0])||!e["*"]&&g("*")}
vendor: 5,851 bytes, line 7529
7529function Lb(a,b){var c,d,e=r.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&r.extend(!0,a,d),a}function Mb(a,b,c){for(var d,e,f,g,h=a.contents,i=a.dataTypes;"*"===i[0];)i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}if(f)return f!==i[0]&&i.unshift(f),c[f]}function Nb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];for(f=k.shift();f;)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a.throws)b=g(b);else try{b=g(b)}catch(a){return{state:"parsererror",error:g?a:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}function Sb(a){return r.isWindow(a)?a:9===a.nodeType&&a.defaultView}var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={},q="3.1.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c<b?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:h,sort:c.sort,splice:c.splice},r.extend=r.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||r.isFunction(g)||(g={}),h===i&&(g=this,h--);h<i;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(r.isPlainObject(d)||(e=r.isArray(d)))?(e?(e=!1,f=c&&r.isArray(c)?c:[]):f=c&&r.isPlainObject(c)?c:{},g[b]=r.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},r.extend({expando:"jQuery"+(q+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===r.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){var b=r.type(a);return("number"===b||"string"===b)&&!isNaN(a-parseFloat(a))},isPlainObject:function(a){var b,c;return!(!a||"[object Object]"!==k.call(a))&&(!(b=e(a))||(c=l.call(b,"constructor")&&b.constructor,"function"==typeof c&&m.call(c)===n))},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?j[k.call(a)]||"object":typeof a},globalEval:function(a){p(a)},camelCase:function(a){return a.replace(t,"ms-").replace(u,v)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b){var c,d=0;if(w(a))for(c=a.length;d<c&&b.call(a[d],d,a[d])!==!1;d++);else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(s,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(w(Object(a))?r.merge(c,"string"==typeof a?[a]:a):h.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:i.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;d<c;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;f<g;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,f=0,h=[];if(w(a))for(d=a.length;f<d;f++)e=b(a[f],f,c),null!=e&&h.push(e);else for(f in a)e=b(a[f],f,c),null!=e&&h.push(e);return g.apply([],h)},guid:1,proxy:function(a,b){var c,d,e;if("string"==typeof b&&(c=a[b],b=a,a=c),r.isFunction(a))return d=f.call(arguments,2),e=function(){return a.apply(b||this,d.concat(f.call(arguments)))},e.guid=a.guid=a.guid||r.guid++,e},now:Date.now,support:o}),"function"==typeof Symbol&&(r.fn[Symbol.iterator]=c[Symbol.iterator]),r.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){j["[object "+b+"]"]=b.toLowerCase()});var x=function(a){function fa(a,b,d,e){var f,h,j,k,l,o,r,s=b&&b.ownerDocument,w=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==w&&9!==w&&11!==w)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==w&&(l=Z.exec(a)))if(f=l[1]){if(9===w){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(s&&(j=s.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(l[2])return G.apply(d,b.getElementsByTagName(a)),d;if((f=l[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==w)s=b,r=a;else if("object"!==b.nodeName.toLowerCase()){for((k=b.getAttribute("id"))?k=k.replace(ba,ca):b.setAttribute("id",k=u),o=g(a),h=o.length;h--;)o[h]="#"+k+" "+ra(o[h]);r=o.join(","),s=$.test(a)&&pa(b.parentNode)||b}if(r)try{return G.apply(d,s.querySelectorAll(r)),d}catch(a){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(P,"$1"),b,d,e)}function ga(){function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}var a=[];return b}function ha(a){return a[u]=!0,a}
vendor: 5,528 bytes, line 7529
7529function ia(a){var b=n.createElement("fieldset");try{return!!a(b)}catch(a){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ja(a,b){for(var c=a.split("|"),e=c.length;e--;)d.attrHandle[c[e]]=b}function ka(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&a.sourceIndex-b.sourceIndex;if(d)return d;if(c)for(;c=c.nextSibling;)if(c===b)return-1;return a?1:-1}function la(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function na(a){return function(b){return"form"in b?b.parentNode&&b.disabled===!1?"label"in b?"label"in b.parentNode?b.parentNode.disabled===a:b.disabled===a:b.isDisabled===a||b.isDisabled!==!a&&ea(b)===a:b.disabled===a:"label"in b&&b.disabled===a}}function oa(a){return ha(function(b){return b=+b,ha(function(c,d){for(var e,f=a([],c.length,b),g=f.length;g--;)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}function qa(){}function ra(a){for(var b=0,c=a.length,d="";b<c;b++)d+=a[b].value;return d}function sa(a,b,c){var d=b.dir,e=b.next,f=e||d,g=c&&"parentNode"===f,h=x++;return b.first?function(b,c,e){for(;b=b[d];)if(1===b.nodeType||g)return a(b,c,e);return!1}:function(b,c,i){var j,k,l,m=[w,h];if(i){for(;b=b[d];)if((1===b.nodeType||g)&&a(b,c,i))return!0}else for(;b=b[d];)if(1===b.nodeType||g)if(l=b[u]||(b[u]={}),k=l[b.uniqueID]||(l[b.uniqueID]={}),e&&e===b.nodeName.toLowerCase())b=b[d]||b;else{if((j=k[f])&&j[0]===w&&j[1]===h)return m[2]=j[2];if(k[f]=m,m[2]=a(b,c,i))return!0}return!1}}function ta(a){return a.length>1?function(b,c,d){for(var e=a.length;e--;)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ua(a,b,c){for(var d=0,e=b.length;d<e;d++)fa(a,b[d],c);return c}function va(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;h<i;h++)(f=a[h])&&(c&&!c(f,d,e)||(g.push(f),j&&b.push(h)));return g}function wa(a,b,c,d,e,f){return d&&!d[u]&&(d=wa(d)),e&&!e[u]&&(e=wa(e,f)),ha(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ua(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:va(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d)for(j=va(r,n),d(j,[],h,i),k=j.length;k--;)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l));if(f){if(e||a){if(e){for(j=[],k=r.length;k--;)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}for(k=r.length;k--;)(l=r[k])&&(j=e?I(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=va(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function xa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sa(function(a){return a===b},h,!0),l=sa(function(a){return I(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];i<f;i++)if(c=d.relative[a[i].type])m=[sa(ta(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;e<f&&!d.relative[a[e].type];e++);return wa(i>1&&ta(m),i>1&&ra(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(P,"$1"),c,i<e&&xa(a.slice(i,e)),e<f&&xa(a=a.slice(e)),e<f&&ra(a))}m.push(c)}return ta(m)}function ya(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){for(o=0,g||l.ownerDocument===n||(m(l),h=!p);q=a[o++];)if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){for(o=0;q=b[o++];)q(t,u,g,h);if(f){if(r>0)for(;s--;)t[s]||u[s]||(u[s]=E.call(i));u=va(u)}G.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&fa.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ha(f):f}var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ga(),z=ga(),A=ga(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",M="\\["+K+"*("+L+")(?:"+K+"*([*^$|!~]?=)"+K+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+L+"))|)"+K+"*\\]",N=":("+L+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+M+")*)|.*)\\)|)",O=new RegExp(K+"+","g"),P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+N),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),aa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ba=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ca=function(a,b){return b?"\0"===a?"�":a.slice(0,-1)+"\\"+a.charCo
vendor: 4,895 bytes, line 7529
7529deAt(a.length-1).toString(16)+" ":"\\"+a},da=function(){m()},ea=sa(function(a){return a.disabled===!0&&("form"in a||"label"in a)},{dir:"parentNode",next:"legend"});try{G.apply(D=H.call(v.childNodes),v.childNodes),D[v.childNodes.length].nodeType}catch(a){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){for(var c=a.length,d=0;a[c++]=b[d++];);a.length=c-1}}}c=fa.support={},f=fa.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},m=fa.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),v!==n&&(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ia(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ia(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(n.getElementsByClassName),c.getById=ia(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){return a.getAttribute("id")===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}}):(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c,d,e,f=b.getElementById(a);if(f){if(c=f.getAttributeNode("id"),c&&c.value===a)return[f];for(e=b.getElementsByName(a),d=0;f=e[d++];)if(c=f.getAttributeNode("id"),c&&c.value===a)return[f]}return[]}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){for(;c=f[e++];)1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){if("undefined"!=typeof b.getElementsByClassName&&p)return b.getElementsByClassName(a)},r=[],q=[],(c.qsa=Y.test(n.querySelectorAll))&&(ia(function(a){o.appendChild(a).innerHTML="<a id='"+u+"'></a><select id='"+u+"-\r\\' msallowcapture=''><option selected=''></option></select>",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ia(function(a){a.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+K+"*[*^$|!~]?="),2!==a.querySelectorAll(":enabled").length&&q.push(":enabled",":disabled"),o.appendChild(a).disabled=!0,2!==a.querySelectorAll(":disabled").length&&q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Y.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ia(function(a){c.disconnectedMatch=s.call(a,"*"),s.call(a,"[s!='']:x"),r.push("!=",N)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Y.test(o.compareDocumentPosition),t=b||Y.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?I(k,a)-I(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?I(k,a)-I(k,b):0;if(e===f)return ka(a,b);for(c=a;c=c.parentNode;)g.unshift(c);for(c=b;c=c.parentNode;)h.unshift(c);for(;g[d]===h[d];)d++;return d?ka(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},fa.matches=function(a,b){return fa(a,null,null,b)},fa.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(S,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(a){}return fa(b,n,null,[a]).length>0}
vendor: 5,057 bytes, lines 7529-7530
7529,fa.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fa.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fa.escape=function(a){return(a+"").replace(ba,ca)},fa.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fa.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){for(;b=a[f++];)b===a[f]&&(e=d.push(f));for(;e--;)a.splice(d[e],1)}return k=null,a},e=fa.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else for(;b=a[d++];)c+=e(b);return c},d=fa.selectors={cacheLength:50,createPseudo:ha,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(_,aa),a[3]=(a[3]||a[4]||a[5]||"").replace(_,aa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fa.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fa.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return V.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&T.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(_,aa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fa.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(O," ")+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){for(;p;){for(m=b;m=m[p];)if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){for(m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];m=++n&&m&&m[p]||(t=n=0)||o.pop();)if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)for(;(m=++n&&m&&m[p]||(t=n=0)||o.pop())&&((h?m.nodeName.toLowerCase()!==r:1!==m.nodeType)||!++t||(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m!==b)););return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fa.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ha(function(a,c){for(var d,f=e(a,b),g=f.length;g--;)d=I(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ha(function(a){var b=[],c=[],d=h(a.replace(P,"$1"));return d[u]?ha(function(a,b,c,e){for(var f,g=d(a,null,e,[]),h=a.length;h--;)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ha(function(a){return function(b){return fa(a,b).length>0}}),contains:ha(function(a){return a=a.replace(_,aa),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ha(function(a){return U.test(a||"")||fa.error("unsupported lang: "+a),a=a.replace(_,aa).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){ 7530return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:na(!1),disabled:na(!0),checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)}
vendor: 5,342 bytes, line 7530
7530,input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:oa(function(){return[0]}),last:oa(function(a,b){return[b-1]}),eq:oa(function(a,b,c){return[c<0?c+b:c]}),even:oa(function(a,b){for(var c=0;c<b;c+=2)a.push(c);return a}),odd:oa(function(a,b){for(var c=1;c<b;c+=2)a.push(c);return a}),lt:oa(function(a,b,c){for(var d=c<0?c+b:c;--d>=0;)a.push(d);return a}),gt:oa(function(a,b,c){for(var d=c<0?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=la(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=ma(b);return qa.prototype=d.filters=d.pseudos,d.setFilters=new qa,g=fa.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);for(h=a,i=[],j=d.preFilter;h;){c&&!(e=Q.exec(h))||(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=R.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(P," ")}),h=h.slice(c.length));for(g in d.filter)!(e=V[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?fa.error(a):z(a,i).slice(0)},h=fa.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){for(b||(b=g(a)),c=b.length;c--;)f=xa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,ya(e,d)),f.selector=a}return f},i=fa.select=function(a,b,c,e){var f,i,j,k,l,m="function"==typeof a&&a,n=!e&&g(a=m.selector||a);if(c=c||[],1===n.length){if(i=n[0]=n[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&9===b.nodeType&&p&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(_,aa),b)||[])[0],!b)return c;m&&(b=b.parentNode),a=a.slice(i.shift().value.length)}for(f=V.needsContext.test(a)?0:i.length;f--&&(j=i[f],!d.relative[k=j.type]);)if((l=d.find[k])&&(e=l(j.matches[0].replace(_,aa),$.test(i[0].type)&&pa(b.parentNode)||b))){if(i.splice(f,1),a=e.length&&ra(i),!a)return G.apply(c,e),c;break}}return(m||h(a,n))(e,b,!p,c,!b||$.test(a)&&pa(b.parentNode)||b),c},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ia(function(a){return 1&a.compareDocumentPosition(n.createElement("fieldset"))}),ia(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||ja("type|href|height|width",function(a,b,c){if(!c)return a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ia(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ja("value",function(a,b,c){if(!c&&"input"===a.nodeName.toLowerCase())return a.defaultValue}),ia(function(a){return null==a.getAttribute("disabled")})||ja(J,function(a,b,c){var d;if(!c)return a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fa}(a);r.find=x,r.expr=x.selectors,r.expr[":"]=r.expr.pseudos,r.uniqueSort=r.unique=x.uniqueSort,r.text=x.getText,r.isXMLDoc=x.isXML,r.contains=x.contains,r.escapeSelector=x.escape;var y=function(a,b,c){for(var d=[],e=void 0!==c;(a=a[b])&&9!==a.nodeType;)if(1===a.nodeType){if(e&&r(a).is(c))break;d.push(a)}return d},z=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},A=r.expr.match.needsContext,B=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,C=/^.[^:#\[\.,]*$/;r.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?r.find.matchesSelector(d,a)?[d]:[]:r.find.matches(a,r.grep(b,function(a){return 1===a.nodeType}))},r.fn.extend({find:function(a){var b,c,d=this.length,e=this;if("string"!=typeof a)return this.pushStack(r(a).filter(function(){for(b=0;b<d;b++)if(r.contains(e[b],this))return!0}));for(c=this.pushStack([]),b=0;b<d;b++)r.find(a,e[b],c);return d>1?r.uniqueSort(c):c},filter:function(a){return this.pushStack(D(this,a||[],!1))},not:function(a){return this.pushStack(D(this,a||[],!0))},is:function(a){return!!D(this,"string"==typeof a&&A.test(a)?r(a):a||[],!1).length}});var E,F=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,G=r.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||E,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:F.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof r?b[0]:b,r.merge(this,r.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),B.test(e[1])&&r.isPlainObject(b))for(e in b)r.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&(this[0]=f,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):r.isFunction(a)?void 0!==c.ready?c.ready(a):a(r):r.makeArray(a,this)};G.prototype=r.fn,E=r(d);var H=/^(?:parents|prev(?:Until|All))/,I={children:!0,contents:!0,next:!0,prev:!0};r.fn.extend({has:function(a){var b=r(a,this),c=b.length;return this.filter(function(){for(var a=0;a<c;a++)if(r.contains(this,b[a]))return!0})},closest:function(a,b){var c,d=0,e=this.length,f=[],g="string"!=typeof a&&r(a);if(!A.test(a))for(;d<e;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&r.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?r.uniqueSort(f):f)}
vendor: 9,790 bytes, line 7530
7530,index:function(a){return a?"string"==typeof a?i.call(r(a),this[0]):i.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(r.uniqueSort(r.merge(this.get(),r(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}}),r.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return y(a,"parentNode")},parentsUntil:function(a,b,c){return y(a,"parentNode",c)},next:function(a){return J(a,"nextSibling")},prev:function(a){return J(a,"previousSibling")},nextAll:function(a){return y(a,"nextSibling")},prevAll:function(a){return y(a,"previousSibling")},nextUntil:function(a,b,c){return y(a,"nextSibling",c)},prevUntil:function(a,b,c){return y(a,"previousSibling",c)},siblings:function(a){return z((a.parentNode||{}).firstChild,a)},children:function(a){return z(a.firstChild)},contents:function(a){return a.contentDocument||r.merge([],a.childNodes)}},function(a,b){r.fn[a]=function(c,d){var e=r.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=r.filter(d,e)),this.length>1&&(I[a]||r.uniqueSort(e),H.test(a)&&e.reverse()),this.pushStack(e)}});var K=/[^\x20\t\r\n\f]+/g;r.Callbacks=function(a){a="string"==typeof a?L(a):r.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=a.once,d=b=!0;g.length;h=-1)for(c=g.shift();++h<f.length;)f[h].apply(c[0],c[1])===!1&&a.stopOnFalse&&(h=f.length,c=!1);a.memory||(c=!1),b=!1,e&&(f=c?[]:"")},j={add:function(){return f&&(c&&!b&&(h=f.length-1,g.push(c)),function b(c){r.each(c,function(c,d){r.isFunction(d)?a.unique&&j.has(d)||f.push(d):d&&d.length&&"string"!==r.type(d)&&b(d)})}(arguments),c&&!b&&i()),this},remove:function(){return r.each(arguments,function(a,b){for(var c;(c=r.inArray(b,f,c))>-1;)f.splice(c,1),c<=h&&h--}),this},has:function(a){return a?r.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||b||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j},r.extend({Deferred:function(b){var c=[["notify","progress",r.Callbacks("memory"),r.Callbacks("memory"),2],["resolve","done",r.Callbacks("once memory"),r.Callbacks("once memory"),0,"resolved"],["reject","fail",r.Callbacks("once memory"),r.Callbacks("once memory"),1,"rejected"]],d="pending",e={state:function(){return d},always:function(){return f.done(arguments).fail(arguments),this},catch:function(a){return e.then(null,a)},pipe:function(){var a=arguments;return r.Deferred(function(b){r.each(c,function(c,d){var e=r.isFunction(a[d[4]])&&a[d[4]];f[d[1]](function(){var a=e&&e.apply(this,arguments);a&&r.isFunction(a.promise)?a.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[d[0]+"With"](this,e?[a]:arguments)})}),a=null}).promise()},then:function(b,d,e){function g(b,c,d,e){return function(){var h=this,i=arguments,j=function(){var a,j;if(!(b<f)){if(a=d.apply(h,i),a===c.promise())throw new TypeError("Thenable self-resolution");j=a&&("object"==typeof a||"function"==typeof a)&&a.then,r.isFunction(j)?e?j.call(a,g(f,c,M,e),g(f,c,N,e)):(f++,j.call(a,g(f,c,M,e),g(f,c,N,e),g(f,c,M,c.notifyWith))):(d!==M&&(h=void 0,i=[a]),(e||c.resolveWith)(h,i))}},k=e?j:function(){try{j()}catch(a){r.Deferred.exceptionHook&&r.Deferred.exceptionHook(a,k.stackTrace),b+1>=f&&(d!==N&&(h=void 0,i=[a]),c.rejectWith(h,i))}};b?k():(r.Deferred.getStackHook&&(k.stackTrace=r.Deferred.getStackHook()),a.setTimeout(k))}}var f=0;return r.Deferred(function(a){c[0][3].add(g(0,a,r.isFunction(e)?e:M,a.notifyWith)),c[1][3].add(g(0,a,r.isFunction(b)?b:M)),c[2][3].add(g(0,a,r.isFunction(d)?d:N))}).promise()},promise:function(a){return null!=a?r.extend(a,e):e}},f={};return r.each(c,function(a,b){var g=b[2],h=b[5];e[b[1]]=g.add,h&&g.add(function(){d=h},c[3-a][2].disable,c[0][2].lock),g.add(b[3].fire),f[b[0]]=function(){return f[b[0]+"With"](this===f?void 0:this,arguments),this},f[b[0]+"With"]=g.fireWith}),e.promise(f),b&&b.call(f,f),f},when:function(a){var b=arguments.length,c=b,d=Array(c),e=f.call(arguments),g=r.Deferred(),h=function(a){return function(c){d[a]=this,e[a]=arguments.length>1?f.call(arguments):c,--b||g.resolveWith(d,e)}};if(b<=1&&(O(a,g.done(h(c)).resolve,g.reject),"pending"===g.state()||r.isFunction(e[c]&&e[c].then)))return g.then();for(;c--;)O(e[c],h(c),g.reject);return g.promise()}});var P=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;r.Deferred.exceptionHook=function(b,c){a.console&&a.console.warn&&b&&P.test(b.name)&&a.console.warn("jQuery.Deferred exception: "+b.message,b.stack,c)},r.readyException=function(b){a.setTimeout(function(){throw b})};var Q=r.Deferred();r.fn.ready=function(a){return Q.then(a).catch(function(a){r.readyException(a)}),this},r.extend({isReady:!1,readyWait:1,holdReady:function(a){a?r.readyWait++:r.ready(!0)},ready:function(a){(a===!0?--r.readyWait:r.isReady)||(r.isReady=!0,a!==!0&&--r.readyWait>0||Q.resolveWith(d,[r]))}}),r.ready.then=Q.then,"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",R),a.addEventListener("load",R));var S=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)S(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h<i;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},T=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};U.uid=1,U.prototype={cache:function(a){var b=a[this.expando];return b||(b={},T(a)&&(a.nodeType?a[this.expando]=b:Object.defineProperty(a,this.expando,{value:b,configurable:!0}))),b},set:function(a,b,c){var d,e=this.cache(a);if("string"==typeof b)e[r.camelCase(b)]=c;else for(d in b)e[r.camelCase(d)]=b[d];return e},get:function(a,b){return void 0===b?this.cache(a):a[this.expando]&&a[this.expando][r.camelCase(b)]},access:function(a,b,c){return void 0===b||b&&"string"==typeof b&&void 0===c?this.get(a,b):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d=a[this.expando];if(void 0!==d){if(void 0!==b){r.isArray(b)?b=b.map(r.camelCase):(b=r.camelCase(b),b=b in d?[b]:b.match(K)||[]),c=b.length;for(;c--;)delete d[b[c]]}(void 0===b||r.isEmptyObject(d))&&(a.nodeType?a[this.expando]=void 0:delete a[this.expando])}},hasData:function(a){var b=a[this.expando];return void 0!==b&&!r.isEmptyObject(b)}};var V=new U,W=new U,X=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Y=/[A-Z]/g;r.extend({hasData:function(a){return W.hasData(a)||V.hasData(a)},data:function(a,b,c){return W.access(a,b,c)},removeData:function(a,b){W.remove(a,b)},_data:function(a,b,c){return V.access(a,b,c)},_removeData:function(a,b){V.remove(a,b)}}),r.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=W.get(f),1===f.nodeType&&!V.get(f,"hasDataAttrs"))){for(c=g.length;c--;)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=r.camelCase(d.slice(5)),$(f,d,e[d])));V.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){W.set(this,a)}):S(this,function(b){var c;if(f&&void 0===b){if(c=W.get(f,a),void 0!==c)return c;if(c=$(f,a),void 0!==c)return c}else this.each(function(){W.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){W.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=V.get(a,b),c&&(!d||r.isArray(c)?d=V.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return V.get(a,c)||V.access(a,c,{empty:r.Callbacks("once memory").add(function(){V.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?r.queue(this[0],a):void 0===b?this:this.each(function(){var c=r.queue(this,a,b);r._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&r.dequeue(this,a)})},dequeue:function(a){return this.each(function(){r.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=r.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};for("string"!=typeof a&&(b=a,a=void 0),a=a||"fx";g--;)c=V.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var _=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,aa=new RegExp("^(?:([+-])=|)("+_+")([a-z%]*)$","i"),ba=["Top","Right","Bottom","Left"],ca=function(a,b){return a=b||a,"none"===a.style.display||""===a.style.display&&r.contains(a.ownerDocument,a)&&"none"===r.css(a,"display")},da=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e},fa={};r.fn.extend({show:function(){return ha(this,!0)},hide:function(){return ha(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){ca(this)?r(this).show():r(this).hide()})}});var ia=/^(?:checkbox|radio)$/i,ja=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,ka=/^$|\/(?:java|ecma)script/i,la={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};
7530la.optgroup=la.option,la.tbody=la.tfoot=la.colgroup=la.caption=la.thead,la.th=la.td;var oa=/<|&#?\w+;/;!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),o.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var qa=d.documentElement,ra=/^key/,sa=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ta=/^([^.]*)(?:\.(.+)|)/;r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.get(a);if(q)for(c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(qa,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(K)||[""],j=b.length;j--;)h=ta.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=V.hasData(a)&&V.get(a);if(q&&(i=q.events)){for(b=(b||"").match(K)||[""],j=b.length;j--;)if(h=ta.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){for(l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;f--;)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&V.remove(a,"handle events")}},dispatch:function(a){var c,d,e,f,g,h,b=r.event.fix(a),i=new Array(arguments.length),j=(V.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;c<arguments.length;c++)i[c]=arguments[c];if(b.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,b)!==!1){for(h=r.event.handlers.call(this,b,j),c=0;(f=h[c++])&&!b.isPropagationStopped();)for(b.currentTarget=f.elem,d=0;(g=f.handlers[d++])&&!b.isImmediatePropagationStopped();)b.rnamespace&&!b.rnamespace.test(g.namespace)||(b.handleObj=g,b.data=g.data,e=((r.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(b.result=e)===!1&&(b.preventDefault(),b.stopPropagation()));return k.postDispatch&&k.postDispatch.call(this,b),b.result}},handlers:function(a,b){var c,d,e,f,g,h=[],i=b.delegateCount,j=a.target;if(i&&j.nodeType&&!("click"===a.type&&a.button>=1))for(;j!==this;j=j.parentNode||this)if(1===j.nodeType&&("click"!==a.type||j.disabled!==!0)){for(f=[],g={},c=0;c<i;c++)d=b[c],e=d.selector+" ",void 0===g[e]&&(g[e]=d.needsContext?r(e,this).index(j)>-1:r.find(e,this,null,[j]).length),g[e]&&f.push(d);f.length&&h.push({elem:j,handlers:f})}return j=this,i<b.length&&h.push({elem:j,handlers:b.slice(i)}),h},addProp:function(a,b){Object.defineProperty(r.Event.prototype,a,{enumerable:!0,configurable:!0,get:r.isFunction(b)?function(){if(this.originalEvent)return b(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[a]},set:function(b){Object.defineProperty(this,a,{enumerable:!0,configurable:!0,writable:!0,value:b})}})},fix:function(a){return a[r.expando]?a:new r.Event(a)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==wa()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===wa()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&r.nodeName(this,"input"))return this.click(),!1},_default:function(a){return r.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}}},r.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c)},r.Event=function(a,b){return this instanceof r.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?ua:va,this.target=a.target&&3===a.target.nodeType?a.target.parentNode:a.target,this.currentTarget=a.currentTarget,this.relatedTarget=a.relatedTarget):this.type=a,b&&r.extend(this,b),this.timeStamp=a&&a.timeStamp||r.now(),void(this[r.expando]=!0)):new r.Event(a,b)},r.Event.prototype={constructor:r.Event,isDefaultPrevented:va,isPropagationStopped:va,isImmediatePropagationStopped:va,isSimulated:!1,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=ua,a&&!this.isSimulated&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=ua,a&&!this.isSimulated&&a.stopPropagation()},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=ua,a&&!this.isSimulated&&a.stopImmediatePropagation(),this.stopPropagation()}},r.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(a){var b=a.button;
vendor: 10,833 bytes, lines 7530-7531
7530return null==a.which&&ra.test(a.type)?null!=a.charCode?a.charCode:a.keyCode:!a.which&&void 0!==b&&sa.test(a.type)?1&b?1:2&b?3:4&b?2:0:a.which}},r.event.addProp),r.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){r.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return e&&(e===d||r.contains(d,e))||(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),r.fn.extend({on:function(a,b,c,d){return xa(this,a,b,c,d)},one:function(a,b,c,d){return xa(this,a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,r(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return b!==!1&&"function"!=typeof b||(c=b,b=void 0),c===!1&&(c=va),this.each(function(){r.event.remove(this,a,c,b)})}});var ya=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,za=/<script|<style|<link/i,Aa=/checked\s*(?:[^=]|=\s*.checked.)/i,Ba=/^true\/(.*)/,Ca=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;r.extend({htmlPrefilter:function(a){return a.replace(ya,"<$1></$2>")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=r.contains(a.ownerDocument,a);if(!(o.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||r.isXMLDoc(a)))for(g=ma(h),f=ma(a),d=0,e=f.length;d<e;d++)Ha(f[d],g[d]);if(b)if(c)for(f=f||ma(a),g=g||ma(h),d=0,e=f.length;d<e;d++)Ga(f[d],g[d]);else Ga(a,h);return g=ma(h,"script"),g.length>0&&na(g,!i&&ma(a,"script")),h},cleanData:function(a){for(var b,c,d,e=r.event.special,f=0;void 0!==(c=a[f]);f++)if(T(c)){if(b=c[V.expando]){if(b.events)for(d in b.events)e[d]?r.event.remove(c,d):r.removeEvent(c,d,b.handle);c[V.expando]=void 0}c[W.expando]&&(c[W.expando]=void 0)}}}),r.fn.extend({detach:function(a){return Ja(this,a,!0)},remove:function(a){return Ja(this,a)},text:function(a){return S(this,function(a){return void 0===a?r.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=a)})},null,a,arguments.length)},append:function(){return Ia(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Da(this,a);b.appendChild(a)}})},prepend:function(){return Ia(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Da(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ia(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ia(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(r.cleanData(ma(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return r.clone(this,a,b)})},html:function(a){return S(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!za.test(a)&&!la[(ja.exec(a)||["",""])[1].toLowerCase()]){a=r.htmlPrefilter(a);try{for(;c<d;c++)b=this[c]||{},1===b.nodeType&&(r.cleanData(ma(b,!1)),b.innerHTML=a);b=0}catch(a){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=[];return Ia(this,arguments,function(b){var c=this.parentNode;r.inArray(this,a)<0&&(r.cleanData(ma(this)),c&&c.replaceChild(b,this))},a)}}),r.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){r.fn[a]=function(a){for(var c,d=[],e=r(a),f=e.length-1,g=0;g<=f;g++)c=g===f?this:this.clone(!0),r(e[g])[b](c),h.apply(d,c.get());return this.pushStack(d)}});var Ka=/^margin/,La=new RegExp("^("+_+")(?!px)[a-z%]+$","i"),Ma=function(b){var c=b.ownerDocument.defaultView;return c&&c.opener||(c=a),c.getComputedStyle(b)};!function(){function b(){if(i){i.style.cssText="box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%",i.innerHTML="",qa.appendChild(h);var b=a.getComputedStyle(i);c="1%"!==b.top,g="2px"===b.marginLeft,e="4px"===b.width,i.style.marginRight="50%",f="4px"===b.marginRight,qa.removeChild(h),i=null}}var c,e,f,g,h=d.createElement("div"),i=d.createElement("div");i.style&&(i.style.backgroundClip="content-box",i.cloneNode(!0).style.backgroundClip="",o.clearCloneStyle="content-box"===i.style.backgroundClip,h.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",h.appendChild(i),r.extend(o,{pixelPosition:function(){return b(),c},boxSizingReliable:function(){return b(),e},pixelMarginRight:function(){return b(),f},reliableMarginLeft:function(){return b(),g}}))}();var Pa=/^(none|table(?!-c[ea]).+)/,Qa={position:"absolute",visibility:"hidden",display:"block"},Ra={letterSpacing:"0",fontWeight:"400"},Sa=["Webkit","Moz","ms"],Ta=d.createElement("div").style;r.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Na(a,"opacity");return""===c?"1":c}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{float:"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=r.camelCase(b),i=a.style;return b=r.cssProps[h]||(r.cssProps[h]=Ua(h)||h),g=r.cssHooks[b]||r.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=aa.exec(c))&&e[1]&&(c=ea(a,b,e),f="number"),null!=c&&c===c&&("number"===f&&(c+=e&&e[3]||(r.cssNumber[h]?"":"px")),o.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=r.camelCase(b);return b=r.cssProps[h]||(r.cssProps[h]=Ua(h)||h),g=r.cssHooks[b]||r.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=Na(a,b,d)),"normal"===e&&b in Ra&&(e=Ra[b]),""===c||c?(f=parseFloat(e),c===!0||isFinite(f)?f||0:e):e}}),r.each(["height","width"],function(a,b){r.cssHooks[b]={get:function(a,c,d){if(c)return!Pa.test(r.css(a,"display"))||a.getClientRects().length&&a.getBoundingClientRect().width?Xa(a,b,d):da(a,Qa,function(){return Xa(a,b,d)})},set:function(a,c,d){var e,f=d&&Ma(a),g=d&&Wa(a,b,d,"border-box"===r.css(a,"boxSizing",!1,f),f);return g&&(e=aa.exec(c))&&"px"!==(e[3]||"px")&&(a.style[b]=c,c=r.css(a,b)),Va(a,c,g)}}}),r.cssHooks.marginLeft=Oa(o.reliableMarginLeft,function(a,b){if(b)return(parseFloat(Na(a,"marginLeft"))||a.getBoundingClientRect().left-da(a,{marginLeft:0},function(){return a.getBoundingClientRect().left}))+"px"}),r.each({margin:"",padding:"",border:"Width"},function(a,b){r.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];d<4;d++)e[a+ba[d]+b]=f[d]||f[d-2]||f[0];return e}},Ka.test(a)||(r.cssHooks[a+b].set=Va)}),r.fn.extend({css:function(a,b){return S(this,function(a,b,c){var d,e,f={},g=0;if(r.isArray(b)){for(d=Ma(a),e=b.length;g<e;g++)f[b[g]]=r.css(a,b[g],!1,d);return f}return void 0!==c?r.style(a,b,c):r.css(a,b)},a,b,arguments.length>1)}}),r.Tween=Ya,Ya.prototype={constructor:Ya,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||r.easing._default,this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(r.cssNumber[c]?"":"px")},cur:function(){var a=Ya.propHooks[this.prop];return a&&a.get?a.get(this):Ya.propHooks._default.get(this)},run:function(a){var b,c=Ya.propHooks[this.prop];return this.options.duration?this.pos=b=r.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Ya.propHooks._default.set(this),this}},Ya.prototype.init.prototype=Ya.prototype,Ya.propHooks={_default:{get:function(a){var b;return 1!==a.elem.nodeType||null!=a.elem[a.prop]&&null==a.elem.style[a.prop]?a.elem[a.prop]:(b=r.css(a.elem,a.prop,""),b&&"auto"!==b?b:0)},set:function(a){r.fx.step[a.prop]?r.fx.step[a.prop](a):1!==a.elem.nodeType||null==a.elem.style[r.cssProps[a.prop]]&&!r.cssHooks[a.prop]?a.elem[a.prop]=a.now:r.style(a.elem,a.prop,a.now+a.unit)}}},Ya.propHooks.scrollTop=Ya.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},r.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2},_default:"swing"},r.fx=Ya.prototype.init,r.fx.step={};var Za,$a,_a=/^(?:toggle|show|hide)$/,ab=/queueHooks$/;r.Animation=r.extend(hb,{tweeners:{"*":[function(a,b){var c=this.createTween(a,b);return ea(c.elem,a,aa.exec(b),c),c}]},tweener:function(a,b){r.isFunction(a)?(b=a,a=["*"]):a=a.match(K);for(var c,d=0,e=a.length;d<e;d++)c=a[d],hb.tweeners[c]=hb.tweeners[c]||[],hb.tweeners[c].unshift(b)},prefilters:[fb],prefilter:function(a,b){b?hb.prefilters.unshift(a):hb.prefilters.push(a)}}),r.speed=function(a,b,c){var e=a&&"object"==typeof a?r.extend({},a):{complete:c||!c&&b||r.isFunction(a)&&a,duration:a,easing:c&&b||b&&!r.isFunction(b)&&b};return r.fx.off||d.hidden?e.duration=0:"number"!=typeof e.duration&&(e.duration in r.fx.speeds?e.duration=r.fx.speeds[e.duration]:e.duration=r.fx.speeds._default),null!=e.queue&&e.queue!==!0||(e.queue="fx"),e.old=e.complete,e.complete=function(){r.isFunction(e.old)&&e.old.call(this),e.queue&&r.dequeue(this,e.queue)},e},r.fn.extend({fadeTo:function(a,b,c,d){return this.filter(ca).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=r.isEmptyObject(a),f=r.speed(b,c,d),g=function(){var b=hb(this,r.extend({},a),f);(e||V.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=r.timers,g=V.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&ab.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));!b&&c||r.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=V.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=r.timers,g=d?d.length:0;for(c.finish=!0,r.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0), 7531b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;b<g;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),r.each(["toggle","show","hide"],function(a,b){var c=r.fn[b];r.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(db
vendor: 11,263 bytes, line 7531
7531(b,!0),a,d,e)}}),r.each({slideDown:db("show"),slideUp:db("hide"),slideToggle:db("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){r.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),r.timers=[],r.fx.tick=function(){var a,b=0,c=r.timers;for(Za=r.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||r.fx.stop(),Za=void 0},r.fx.timer=function(a){r.timers.push(a),a()?r.fx.start():r.timers.pop()},r.fx.interval=13,r.fx.start=function(){$a||($a=a.requestAnimationFrame?a.requestAnimationFrame(bb):a.setInterval(r.fx.tick,r.fx.interval))},r.fx.stop=function(){a.cancelAnimationFrame?a.cancelAnimationFrame($a):a.clearInterval($a),$a=null},r.fx.speeds={slow:600,fast:200,_default:400},r.fn.delay=function(b,c){return b=r.fx?r.fx.speeds[b]||b:b,c=c||"fx",this.queue(c,function(c,d){var e=a.setTimeout(c,b);d.stop=function(){a.clearTimeout(e)}})},function(){var a=d.createElement("input"),b=d.createElement("select"),c=b.appendChild(d.createElement("option"));a.type="checkbox",o.checkOn=""!==a.value,o.optSelected=c.selected,a=d.createElement("input"),a.value="t",a.type="radio",o.radioValue="t"===a.value}();var ib,jb=r.expr.attrHandle;r.fn.extend({attr:function(a,b){return S(this,r.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){r.removeAttr(this,a)})}}),r.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return"undefined"==typeof a.getAttribute?r.prop(a,b,c):(1===f&&r.isXMLDoc(a)||(e=r.attrHooks[b.toLowerCase()]||(r.expr.match.bool.test(b)?ib:void 0)),void 0!==c?null===c?void r.removeAttr(a,b):e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!==(d=e.get(a,b))?d:(d=r.find.attr(a,b),null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&r.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(K);if(e&&1===a.nodeType)for(;c=e[d++];)a.removeAttribute(c)}}),ib={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=jb[b]||r.find.attr;jb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=jb[g],jb[g]=e,e=null!=c(a,b,d)?g:null,jb[g]=f),e}});var kb=/^(?:input|select|textarea|button)$/i,lb=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return S(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):kb.test(a.nodeName)||lb.test(a.nodeName)&&a.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this}),r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,nb(this)))});if("string"==typeof a&&a)for(b=a.match(K)||[];c=this[i++];)if(e=nb(c),d=1===c.nodeType&&" "+mb(e)+" "){for(g=0;f=b[g++];)d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=mb(d),e!==h&&c.setAttribute("class",h)}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,nb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a)for(b=a.match(K)||[];c=this[i++];)if(e=nb(c),d=1===c.nodeType&&" "+mb(e)+" "){for(g=0;f=b[g++];)for(;d.indexOf(" "+f+" ")>-1;)d=d.replace(" "+f+" "," ");h=mb(d),e!==h&&c.setAttribute("class",h)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,nb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c)for(d=0,e=r(this),f=a.match(K)||[];b=f[d++];)e.hasClass(b)?e.removeClass(b):e.addClass(b);else void 0!==a&&"boolean"!==c||(b=nb(this),b&&V.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":V.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;for(b=" "+a+" ";c=this[d++];)if(1===c.nodeType&&(" "+mb(nb(c))+" ").indexOf(b)>-1)return!0;return!1}});var ob=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":r.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(ob,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:mb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d<i;d++)if(c=e[d],(c.selected||d===f)&&!c.disabled&&(!c.parentNode.disabled||!r.nodeName(c.parentNode,"optgroup"))){if(b=r(c).val(),g)return b;h.push(b)}return h},set:function(a,b){for(var c,d,e=a.options,f=r.makeArray(b),g=e.length;g--;)d=e[g],(d.selected=r.inArray(r.valHooks.option.get(d),f)>-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(r.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var pb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!pb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?b:new r.Event(p,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=q.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:r.makeArray(c,[b]),n=r.event.special[p]||{},f||!n.trigger||n.trigger.apply(e,c)!==!1)){if(!f&&!n.noBubble&&!r.isWindow(e)){for(j=n.delegateType||p,pb.test(j+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),i=h;i===(e.ownerDocument||d)&&o.push(i.defaultView||i.parentWindow||a)}for(g=0;(h=o[g++])&&!b.isPropagationStopped();)b.type=g>1?j:n.bindType||p,m=(V.get(h,"events")||{})[b.type]&&V.get(h,"handle"),m&&m.apply(h,c),m=k&&h[k],m&&m.apply&&T(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=p,f||b.isDefaultPrevented()||n._default&&n._default.apply(o.pop(),c)!==!1||!T(e)||k&&r.isFunction(e[p])&&!r.isWindow(e)&&(i=e[k],i&&(e[k]=null),r.event.triggered=p,e[p](),r.event.triggered=void 0,i&&(e[k]=i)),b.result}},simulate:function(a,b,c){var d=r.extend(new r.Event,c,{type:a,isSimulated:!0});r.event.trigger(d,null,b)}}),r.fn.extend({trigger:function(a,b){return this.each(function(){r.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];if(c)return r.event.trigger(a,b,c,!0)}}),r.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,b){r.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),r.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),o.focusin="onfocusin"in a,o.focusin||r.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){r.event.simulate(b,a.target,r.event.fix(a))};r.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=V.access(d,b);e||d.addEventListener(a,c,!0),V.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=V.access(d,b)-1;e?V.access(d,b,e):(d.removeEventListener(a,c,!0),V.remove(d,b))}}});var qb=a.location,rb=r.now(),sb=/\?/;r.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(a){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||r.error("Invalid XML: "+b),c};var tb=/\[\]$/,ub=/\r?\n/g,vb=/^(?:submit|button|image|reset|file)$/i,wb=/^(?:input|select|textarea|keygen)/i;r.param=function(a,b){var c,d=[],e=function(a,b){var c=r.isFunction(b)?b():b;d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==c?"":c)};if(r.isArray(a)||a.jquery&&!r.isPlainObject(a))r.each(a,function(){e(this.name,this.value)});else for(c in a)xb(c,a[c],b,e);return d.join("&")},r.fn.extend({serialize:function(){return r.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=r.prop(this,"elements");return a?r.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!r(this).is(":disabled")&&wb.test(this.nodeName)&&!vb.test(a)&&(this.checked||!ia.test(a))}).map(function(a,b){var c=r(this).val();return null==c?null:r.isArray(c)?r.map(c,function(a){return{name:b.name,value:a.replace(ub,"\r\n")}}):{name:b.name,value:c.replace(ub,"\r\n")}}).get()}});var yb=/%20/g,zb=/#.*$/,Ab=/([?&])_=[^&]*/,Bb=/^(.*?):[ \t]*([^\r\n]*)$/gm,Cb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Db=/^(?:GET|HEAD)$/,Eb=/^\/\//,Fb={},Gb={},Hb="*/".concat("*"),Ib=d.createElement("a");Ib.href=qb.href,r.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:qb.href,type:"GET",isLocal:Cb.test(qb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Hb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":r.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Lb(Lb(a,r.ajaxSettings),b):Lb(r.ajaxSettings,a)},ajaxPrefilter:Jb(Fb),ajaxTransport:Jb(Gb),ajax:function(b,c){function z(b,c,d,h){var j,m,n,v,w,x=c;k||(k=!0,i&&a.clearTimeout(i),e=void 0,g=h||"",y.readyState=b>0?4:0,j=b>=200&&b<300||304===b,d&&(v=Mb(o,y,d)),v=Nb(o,v,y,j),j?(o.ifModified&&(w=y.getResponseHeader("Last-Modified"),w&&(r.lastModified[f]=w),w=y.getResponseHeader("etag"),w&&(r.etag[f]=w)),204===b||"HEAD"===o.type?x="nocontent":304===b?x="notmodified":(x=v.state,m=v.data,n=v.error,j=!n)):(n=x,!b&&x||(x="error",b<0&&(b=0))
vendor: 11,066 bytes, lines 7531-7538
7531),y.status=b,y.statusText=(c||x)+"",j?s.resolveWith(p,[m,x,y]):s.rejectWith(p,[y,x,n]),y.statusCode(u),u=void 0,l&&q.trigger(j?"ajaxSuccess":"ajaxError",[y,o,j?m:n]),t.fireWith(p,[y,x]),l&&(q.trigger("ajaxComplete",[y,o]),--r.active||r.event.trigger("ajaxStop")))}"object"==typeof b&&(c=b,b=void 0),c=c||{};var e,f,g,h,i,j,k,l,m,n,o=r.ajaxSetup({},c),p=o.context||o,q=o.context&&(p.nodeType||p.jquery)?r(p):r.event,s=r.Deferred(),t=r.Callbacks("once memory"),u=o.statusCode||{},v={},w={},x="canceled",y={readyState:0,getResponseHeader:function(a){var b;if(k){if(!h)for(h={};b=Bb.exec(g);)h[b[1].toLowerCase()]=b[2];b=h[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return k?g:null},setRequestHeader:function(a,b){return null==k&&(a=w[a.toLowerCase()]=w[a.toLowerCase()]||a,v[a]=b),this},overrideMimeType:function(a){return null==k&&(o.mimeType=a),this},statusCode:function(a){var b;if(a)if(k)y.always(a[y.status]);else for(b in a)u[b]=[u[b],a[b]];return this},abort:function(a){var b=a||x;return e&&e.abort(b),z(0,b),this}};if(s.promise(y),o.url=((b||o.url||qb.href)+"").replace(Eb,qb.protocol+"//"),o.type=c.method||c.type||o.method||o.type,o.dataTypes=(o.dataType||"*").toLowerCase().match(K)||[""],null==o.crossDomain){j=d.createElement("a");try{j.href=o.url,j.href=j.href,o.crossDomain=Ib.protocol+"//"+Ib.host!=j.protocol+"//"+j.host}catch(a){o.crossDomain=!0}}if(o.data&&o.processData&&"string"!=typeof o.data&&(o.data=r.param(o.data,o.traditional)),Kb(Fb,o,c,y),k)return y;l=r.event&&o.global,l&&0===r.active++&&r.event.trigger("ajaxStart"),o.type=o.type.toUpperCase(),o.hasContent=!Db.test(o.type),f=o.url.replace(zb,""),o.hasContent?o.data&&o.processData&&0===(o.contentType||"").indexOf("application/x-www-form-urlencoded")&&(o.data=o.data.replace(yb,"+")):(n=o.url.slice(f.length),o.data&&(f+=(sb.test(f)?"&":"?")+o.data,delete o.data),o.cache===!1&&(f=f.replace(Ab,"$1"),n=(sb.test(f)?"&":"?")+"_="+rb++ +n),o.url=f+n),o.ifModified&&(r.lastModified[f]&&y.setRequestHeader("If-Modified-Since",r.lastModified[f]),r.etag[f]&&y.setRequestHeader("If-None-Match",r.etag[f])),(o.data&&o.hasContent&&o.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",o.contentType),y.setRequestHeader("Accept",o.dataTypes[0]&&o.accepts[o.dataTypes[0]]?o.accepts[o.dataTypes[0]]+("*"!==o.dataTypes[0]?", "+Hb+"; q=0.01":""):o.accepts["*"]);for(m in o.headers)y.setRequestHeader(m,o.headers[m]);if(o.beforeSend&&(o.beforeSend.call(p,y,o)===!1||k))return y.abort();if(x="abort",t.add(o.complete),y.done(o.success),y.fail(o.error),e=Kb(Gb,o,c,y)){if(y.readyState=1,l&&q.trigger("ajaxSend",[y,o]),k)return y;o.async&&o.timeout>0&&(i=a.setTimeout(function(){y.abort("timeout")},o.timeout));try{k=!1,e.send(v,z)}catch(a){if(k)throw a;z(-1,a)}}else z(-1,"No Transport");return y},getJSON:function(a,b,c){return r.get(a,b,c,"json")},getScript:function(a,b){return r.get(a,void 0,b,"script")}}),r.each(["get","post"],function(a,b){r[b]=function(a,c,d,e){return r.isFunction(c)&&(e=e||d,d=c,c=void 0),r.ajax(r.extend({url:a,type:b,dataType:e,data:c,success:d},r.isPlainObject(a)&&a))}}),r._evalUrl=function(a){return r.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,throws:!0})},r.fn.extend({wrapAll:function(a){var b;return this[0]&&(r.isFunction(a)&&(a=a.call(this[0])),b=r(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){for(var a=this;a.firstElementChild;)a=a.firstElementChild;return a}).append(this)),this},wrapInner:function(a){return r.isFunction(a)?this.each(function(b){r(this).wrapInner(a.call(this,b))}):this.each(function(){var b=r(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=r.isFunction(a);return this.each(function(c){r(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){r(this).replaceWith(this.childNodes)}),this}}),r.expr.pseudos.hidden=function(a){return!r.expr.pseudos.visible(a)},r.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},r.ajaxSettings.xhr=function(){try{return new a.XMLHttpRequest}catch(a){}};var Ob={0:200,1223:204},Pb=r.ajaxSettings.xhr();o.cors=!!Pb&&"withCredentials"in Pb,o.ajax=Pb=!!Pb,r.ajaxTransport(function(b){var c,d;if(o.cors||Pb&&!b.crossDomain)return{send:function(e,f){var g,h=b.xhr();if(h.open(b.type,b.url,b.async,b.username,b.password),b.xhrFields)for(g in b.xhrFields)h[g]=b.xhrFields[g];b.mimeType&&h.overrideMimeType&&h.overrideMimeType(b.mimeType),b.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");for(g in e)h.setRequestHeader(g,e[g]);c=function(a){return function(){c&&(c=d=h.onload=h.onerror=h.onabort=h.onreadystatechange=null,"abort"===a?h.abort():"error"===a?"number"!=typeof h.status?f(0,"error"):f(h.status,h.statusText):f(Ob[h.status]||h.status,h.statusText,"text"!==(h.responseType||"text")||"string"!=typeof h.responseText?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=c(),d=h.onerror=c("error"),void 0!==h.onabort?h.onabort=d:h.onreadystatechange=function(){4===h.readyState&&a.setTimeout(function(){c&&d()})},c=c("abort");try{h.send(b.hasContent&&b.data||null)}catch(a){if(c)throw a}},abort:function(){c&&c()}}}),r.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),r.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return r.globalEval(a),a}}}),r.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),r.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(e,f){b=r("<script>").prop({charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&f("error"===a.type?404:200,a.type)}),d.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Qb=[],Rb=/(=)\?(?=&|$)|\?\?/;r.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Qb.pop()||r.expando+"_"+rb++;return this[a]=!0,a}}),r.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Rb.test(b.url)?"url":"string"==typeof b.data&&0===(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Rb.test(b.data)&&"data");if(h||"jsonp"===b.dataTypes[0])return e=b.jsonpCallback=r.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Rb,"$1"+e):b.jsonp!==!1&&(b.url+=(sb.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||r.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){void 0===f?r(a).removeProp(e):a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Qb.push(e)),g&&r.isFunction(f)&&f(g[0]),g=f=void 0}),"script"}),o.createHTMLDocument=function(){var a=d.implementation.createHTMLDocument("").body;return a.innerHTML="<form></form><form></form>",2===a.childNodes.length}(),r.parseHTML=function(a,b,c){if("string"!=typeof a)return[];"boolean"==typeof b&&(c=b,b=!1);var e,f,g;return b||(o.createHTMLDocument?(b=d.implementation.createHTMLDocument(""),e=b.createElement("base"),e.href=d.location.href,b.head.appendChild(e)):b=d),f=B.exec(a),g=!c&&[],f?[b.createElement(f[1])]:(f=pa([a],b,g),g&&g.length&&r(g).remove(),r.merge([],f.childNodes))},r.fn.load=function(a,b,c){var d,e,f,g=this,h=a.indexOf(" ");return h>-1&&(d=mb(a.slice(h)),a=a.slice(0,h)),r.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&r.ajax({url:a,type:e||"GET",dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?r("<div>").append(r.parseHTML(a)).find(d):a)}).always(c&&function(a,b){g.each(function(){c.apply(this,f||[a.responseText,b,a])})}),this},r.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){r.fn[b]=function(a){return this.on(b,a)}}),r.expr.pseudos.animated=function(a){return r.grep(r.timers,function(b){return a===b.elem}).length},r.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=r.css(a,"position"),l=r(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=r.css(a,"top"),i=r.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),r.isFunction(b)&&(b=b.call(a,c,r.extend({},h))),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},r.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){r.offset.setOffset(this,a,b)});var b,c,d,e,f=this[0];if(f)return f.getClientRects().length?(d=f.getBoundingClientRect(),d.width||d.height?(e=f.ownerDocument,c=Sb(e),b=e.documentElement,{top:d.top+c.pageYOffset-b.clientTop,left:d.left+c.pageXOffset-b.clientLeft}):d):{top:0,left:0}},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===r.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),r.nodeName(a[0],"html")||(d=a.offset()),d={top:d.top+r.css(a[0],"borderTopWidth",!0),left:d.left+r.css(a[0],"borderLeftWidth",!0)}),{top:b.top-d.top-r.css(c,"marginTop",!0),left:b.left-d.left-r.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent;a&&"static"===r.css(a,"position");)a=a.offsetParent;return a||qa})}}),r.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c="pageYOffset"===b;r.fn[a]=function(d){return S(this,function(a,d,e){var f=Sb(a);return void 0===e?f?f[b]:a[d]:void(f?f.scrollTo(c?f.pageXOffset:e,c?e:f.pageYOffset):a[d]=e)},a,d,arguments.length)}}),r.each(["top","left"],function(a,b){r.cssHooks[b]=Oa(o.pixelPosition,function(a,c){if(c)return c=Na(a,b),La.test(c)?r(a).position()[b]+"px":c})}),r.each({Height:"height",Width:"width"},function(a,b){r.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){r.fn[d]=function(e,f){var g=arguments.length&&(c||"boolean"!=typeof e),h=c||(e===!0||f===!0?"margin":"border");return S(this,function(b,c,e){var f;return r.isWindow(b)?0===d.indexOf("outer")?b["inner"+a]:b.document.documentElement["client"+a]:9===b.nodeType?(f=b.documentElement,Math.max(b.body["scroll"+a],f["scroll"+a],b.body["offset"+a],f["offset"+a],f["client"+a])):void 0===e?r.css(b,c,h):r.style(b,c,e,h)},b,g?e:void 0,g)}})}),r.fn.extend({bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}}),r.parseJSON=JSON.parse,"function"==typeof define&&define.amd&&define("jquery",[],function(){return r});var Tb=a.jQuery,Ub=a.$;return r.noConflict=function(b){return a.$===r&&(a.$=Ub),b&&a.jQuery===r&&(a.jQuery=Tb),r},b||(a.jQuery=a.$=r),r});var owlJqueryObject=$.noConflict();; 7532 7533 !/** 7534 * Owl Carousel v2.2.1 7535 * Copyright 2013-2017 David Deutsch 7536 * Licensed under () 7537 */ /** 7538 * Owl carousel
vendor: 4,631 bytes, lines 7539-7548
7539 * @version 2.1.6 7540 * @author Bartosz Wojciechowski 7541 * @author David Deutsch 7542 * @license The MIT License (MIT) 7543 * @todo Lazy Load Icon 7544 * @todo prevent animationend bubling 7545 * @todo itemsScaleUp 7546 * @todo Test Zepto 7547 * @todo stagePadding calculate wrong active classes 7548 */ function($,b,c,d){function a(b,c){this.settings=null,this.options=$.extend({},a.Defaults,c),this.$element=$(b),this._handlers={},this._plugins={},this._supress={},this._current=null,this._speed=null,this._coordinates=[],this._breakpoint=null,this._width=null,this._items=[],this._clones=[],this._mergers=[],this._widths=[],this._invalidated={},this._pipe=[],this._drag={time:null,target:null,pointer:null,stage:{start:null,current:null},direction:null},this._states={current:{},tags:{initializing:["busy"],animating:["busy"],dragging:["interacting"]}},$.each(["onResize","onThrottledResize"],$.proxy(function(b,a){this._handlers[a]=$.proxy(this[a],this)},this)),$.each(a.Plugins,$.proxy(function(a,b){this._plugins[a.charAt(0).toLowerCase()+a.slice(1)]=new b(this)},this)),$.each(a.Workers,$.proxy(function(b,a){this._pipe.push({filter:a.filter,run:$.proxy(a.run,this)})},this)),this.setup(),this.initialize()}a.Defaults={items:3,loop:!1,center:!1,rewind:!1,mouseDrag:!0,touchDrag:!0,pullDrag:!0,freeDrag:!1,margin:0,stagePadding:0,merge:!1,mergeFit:!0,autoWidth:!1,startPosition:0,rtl:!1,smartSpeed:250,fluidSpeed:!1,dragEndSpeed:!1,responsive:{},responsiveRefreshRate:200,responsiveBaseElement:b,fallbackEasing:"swing",info:!1,nestedItemSelector:!1,itemElement:"div",stageElement:"div",refreshClass:"owl-refresh",loadedClass:"owl-loaded",loadingClass:"owl-loading",rtlClass:"owl-rtl",responsiveClass:"owl-responsive",dragClass:"owl-drag",itemClass:"owl-item",stageClass:"owl-stage",stageOuterClass:"owl-stage-outer",grabClass:"owl-grab"},a.Width={Default:"default",Inner:"inner",Outer:"outer"},a.Type={Event:"event",State:"state"},a.Plugins={},a.Workers=[{filter:["width","settings"],run:function(){this._width=this.$element.width()}},{filter:["width","items","settings"],run:function(a){a.current=this._items&&this._items[this.relative(this._current)]}},{filter:["items","settings"],run:function(){this.$stage.children(".cloned").remove()}},{filter:["width","items","settings"],run:function(d){var a=this.settings.margin||"",e=!this.settings.autoWidth,b=this.settings.rtl,c={width:"auto","margin-left":b?a:"","margin-right":b?"":a};e||this.$stage.children().css(c),d.css=c}},{filter:["width","items","settings"],run:function(c){var d=(this.width()/this.settings.items).toFixed(3)-this.settings.margin,a=null,b=this._items.length,f=!this.settings.autoWidth,e=[];for(c.items={merge:!1,width:d};b--;)a=this._mergers[b],a=this.settings.mergeFit&&Math.min(a,this.settings.items)||a,c.items.merge=a>1||c.items.merge,e[b]=f?d*a:this._items[b].width();this._widths=e}},{filter:["items","settings"],run:function(){var a=[],b=this._items,c=this.settings,e=Math.max(2*c.items,4),h=2*Math.ceil(b.length/2),f=c.loop&&b.length?c.rewind?e:Math.max(e,h):0,g="",d="";for(f/=2;f--;)a.push(this.normalize(a.length/2,!0)),g+=b[a[a.length-1]][0].outerHTML,a.push(this.normalize(b.length-1-(a.length-1)/2,!0)),d=b[a[a.length-1]][0].outerHTML+d;this._clones=a,$(g).addClass("cloned").appendTo(this.$stage),$(d).addClass("cloned").prependTo(this.$stage)}},{filter:["width","items","settings"],run:function(){for(var e=this.settings.rtl?1:-1,f=this._clones.length+this._items.length,a=-1,c=0,d=0,b=[];++a<f;)c=b[a-1]||0,d=this._widths[this.relative(a)]+this.settings.margin,b.push(c+d*e);this._coordinates=b}},{filter:["width","items","settings"],run:function(){var a=this.settings.stagePadding,b=this._coordinates,c={width:Math.ceil(Math.abs(b[b.length-1]))+2*a,"padding-left":a||"","padding-right":a||""};this.$stage.css(c)}},{filter:["width","items","settings"],run:function(a){var b=this._coordinates.length,c=!this.settings.autoWidth,d=this.$stage.children();if(c&&a.items.merge)for(;b--;)a.css.width=this._widths[this.relative(b)],d.eq(b).css(a.css);else c&&(a.css.width=a.items.width,d.css(a.css))}},{filter:["items"],run:function(){this._coordinates.length<1&&this.$stage.removeAttr("style")}},{filter:["width","items","settings"],run:function(a){a.current=a.current?this.$stage.children().index(a.current):0,a.current=Math.max(this.minimum(),Math.min(this.maximum(),a.current)),this.reset(a.current)}},{filter:["position"],run:function(){this.animate(this.coordinates(this._current))}},{filter:["width","position","items","settings"],run:function(){var b,c,a,e,f=this.settings.rtl?1:-1,g=2*this.settings.stagePadding,d=this.coordinates(this.current())+g,h=d+this.width()*f,
7548i=[];for(a=0,e=this._coordinates.length;a<e;a++)b=this._coordinates[a-1]||0,c=Math.abs(this._coordinates[a])+g*f,(this.op(b,"<=",d)&&this.op(b,">",h)||this.op(c,"<",d)&&this.op(c,">",h))&&i.push(a);this.$stage.children(".active").removeClass("active"),this.$stage.children(":eq("+i.join("), :eq(")+")").addClass("active"),this.settings.center&&(this.$stage.children(".center").removeClass("center"),this.$stage.children().eq(this.current()).addClass("center"))}}],a.prototype.initialize=function(){if(this.enter("initializing"),this.trigger("initialize"),this.$element.toggleClass(this.settings.rtlClass,this.settings.rtl),this.settings.autoWidth&&!this.is("pre-loading")){var a,b,c;a=this.$element.find("img"),b=this.settings.nestedItemSelector?"."+this.settings.nestedItemSelector:d,c=this.$element.children(b).width(),a.length&&c<=0&&this.preloadAutoWidthImages(a)}this.$element.addClass(this.options.loadingClass),this.$stage=$("<"+this.settings.stageElement+' class="'+this.settings.stageClass+'"/>').wrap('<div class="'+this.settings.stageOuterClass+'"/>'),this.$element.append(this.$stage.parent()),this.replace(this.$element.children().not(this.$stage.parent())),this.$element.is(":visible")?this.refresh():this.invalidate("width"),this.$element.removeClass(this.options.loadingClass).addClass(this.options.loadedClass),this.registerEventHandlers(),this.leave("initializing"),this.trigger("initialized")},a.prototype.setup=function(){var d=this.viewport(),b=this.options.responsive,c=-1,a=null;b?($.each(b,function(a){a<=d&&a>c&&(c=Number(a))}),"function"==typeof(a=$.extend({},this.options,b[c])).stagePadding&&(a.stagePadding=a.stagePadding()),delete a.responsive,a.responsiveClass&&this.$element.attr("class",this.$element.attr("class").replace(new RegExp("("+this.options.responsiveClass+"-)\\S+\\s","g"),"$1"+c))):a=$.extend({},this.options),this.trigger("change",{property:{name:"settings",value:a}}),this._breakpoint=c,this.settings=a,this.invalidate("settings"),this.trigger("changed",{property:{name:"settings",value:this.settings}})},a.prototype.optionsLogic=function(){this.settings.autoWidth&&(this.settings.stagePadding=!1,this.settings.merge=!1)},a.prototype.prepare=function(b){var a=this.trigger("prepare",{content:b});return a.data||(a.data=$("<"+this.settings.itemElement+"/>").addClass(this.options.itemClass).append(b)),this.trigger("prepared",{content:a.data}),a.data},a.prototype.update=function(){for(var a=0,b=this._pipe.length,c=$.proxy(function(a){return this[a]},this._invalidated),d={};a<b;)(this._invalidated.all||$.grep(this._pipe[a].filter,c).length>0)&&this._pipe[a].run(d),a++;this._invalidated={},this.is("valid")||this.enter("valid")},a.prototype.width=function(b){switch(b=b||a.Width.Default){case a.Width.Inner:case a.Width.Outer:return this._width;default:return this._width-2*this.settings.stagePadding+this.settings.margin}},a.prototype.refresh=function(){this.enter("refreshing"),this.trigger("refresh"),this.setup(),this.optionsLogic(),this.$element.addClass(this.options.refreshClass),this.update(),this.$element.removeClass(this.options.refreshClass),this.leave("refreshing"),this.trigger("refreshed")},a.prototype.onThrottledResize=function(){b.clearTimeout(this.resizeTimer),this.resizeTimer=b.setTimeout(this._handlers.onResize,this.settings.responsiveRefreshRate)},a.prototype.onResize=function(){return!!(this._items.length&&this._width!==this.$element.width()&&this.$element.is(":visible"))&&((this.enter("resizing"),this.trigger("resize").isDefaultPrevented())?(this.leave("resizing"),!1):void(this.invalidate("width"),this.refresh(),this.leave("resizing"),this.trigger("resized")))},a.prototype.registerEventHandlers=function(){$.support.transition&&this.$stage.on($.support.transition.end+".owl.core",$.proxy(this.onTransitionEnd,this)),!1!==this.settings.responsive&&this.on(b,"resize",this._handlers.onThrottledResize),this.settings.mouseDrag&&(this.$element.addClass(this.options.dragClass),this.$stage.on("mousedown.owl.core",$.proxy(this.onDragStart,this)),this.$stage.on("dragstart.owl.core selectstart.owl.core",function(){return!1})),this.settings.touchDrag&&(this.$stage.on("touchstart.owl.core",$.proxy(this.onDragStart,this)),this.$stage.on("touchcancel.owl.core",$.proxy(this.onDragEnd,this)))},a.prototype.onDragStart=function(b){var a=null;
vendor: 6,363 bytes, line 7548
75483!==b.which&&($.support.transform?a={x:(a=this.$stage.css("transform").replace(/.*\(|\)| /g,"").split(","))[16===a.length?12:4],y:a[16===a.length?13:5]}:(a=this.$stage.position(),a={x:this.settings.rtl?a.left+this.$stage.width()-this.width()+this.settings.margin:a.left,y:a.top}),this.is("animating")&&($.support.transform?this.animate(a.x):this.$stage.stop(),this.invalidate("position")),this.$element.toggleClass(this.options.grabClass,"mousedown"===b.type),this.speed(0),this._drag.time=new Date().getTime(),this._drag.target=$(b.target),this._drag.stage.start=a,this._drag.stage.current=a,this._drag.pointer=this.pointer(b),$(c).on("mouseup.owl.core touchend.owl.core",$.proxy(this.onDragEnd,this)),$(c).one("mousemove.owl.core touchmove.owl.core",$.proxy(function(a){var b=this.difference(this._drag.pointer,this.pointer(a));$(c).on("mousemove.owl.core touchmove.owl.core",$.proxy(this.onDragMove,this)),Math.abs(b.x)<Math.abs(b.y)&&this.is("valid")||(a.preventDefault(),this.enter("dragging"),this.trigger("drag"))},this)))},a.prototype.onDragMove=function(e){var a=null,b=null,d=null,f=this.difference(this._drag.pointer,this.pointer(e)),c=this.difference(this._drag.stage.start,f);this.is("dragging")&&(e.preventDefault(),this.settings.loop?(a=this.coordinates(this.minimum()),b=this.coordinates(this.maximum()+1)-a,c.x=((c.x-a)%b+b)%b+a):(a=this.settings.rtl?this.coordinates(this.maximum()):this.coordinates(this.minimum()),b=this.settings.rtl?this.coordinates(this.minimum()):this.coordinates(this.maximum()),d=this.settings.pullDrag?-1*f.x/5:0,c.x=Math.max(Math.min(c.x,a+d),b+d)),this._drag.stage.current=c,this.animate(c.x))},a.prototype.onDragEnd=function(d){var a=this.difference(this._drag.pointer,this.pointer(d)),e=this._drag.stage.current,b=a.x>0^this.settings.rtl?"left":"right";$(c).off(".owl.core"),this.$element.removeClass(this.options.grabClass),(0!==a.x&&this.is("dragging")||!this.is("valid"))&&(this.speed(this.settings.dragEndSpeed||this.settings.smartSpeed),this.current(this.closest(e.x,0!==a.x?b:this._drag.direction)),this.invalidate("position"),this.update(),this._drag.direction=b,(Math.abs(a.x)>3||new Date().getTime()-this._drag.time>300)&&this._drag.target.one("click.owl.core",function(){return!1})),this.is("dragging")&&(this.leave("dragging"),this.trigger("dragged"))},a.prototype.closest=function(a,d){var b=-1,e=this.width(),c=this.coordinates();return this.settings.freeDrag||$.each(c,$.proxy(function(g,f){return"left"===d&&a>f-30&&a<f+30?b=g:"right"===d&&a>f-e-30&&a<f-e+30?b=g+1:this.op(a,"<",f)&&this.op(a,">",c[g+1]||f-e)&&(b="left"===d?g+1:g),-1===b},this)),!this.settings.loop&&(this.op(a,">",c[this.minimum()])?b=a=this.minimum():this.op(a,"<",c[this.maximum()])&&(b=a=this.maximum())),b},a.prototype.animate=function(a){var b=this.speed()>0;this.is("animating")&&this.onTransitionEnd(),b&&(this.enter("animating"),this.trigger("translate")),$.support.transform3d&&$.support.transition?this.$stage.css({transform:"translate3d("+a+"px,0px,0px)",transition:this.speed()/1e3+"s"}):b?this.$stage.animate({left:a+"px"},this.speed(),this.settings.fallbackEasing,$.proxy(this.onTransitionEnd,this)):this.$stage.css({left:a+"px"})},a.prototype.is=function(a){return this._states.current[a]&&this._states.current[a]>0},a.prototype.current=function(a){if(a===d)return this._current;if(0!==this._items.length){if(a=this.normalize(a),this._current!==a){var b=this.trigger("change",{property:{name:"position",value:a}});d!==b.data&&(a=this.normalize(b.data)),this._current=a,this.invalidate("position"),this.trigger("changed",{property:{name:"position",value:this._current}})}return this._current}},a.prototype.invalidate=function(a){return"string"===$.type(a)&&(this._invalidated[a]=!0,this.is("valid")&&this.leave("valid")),$.map(this._invalidated,function(b,a){return a})},a.prototype.reset=function(a){d!==(a=this.normalize(a))&&(this._speed=0,this._current=a,this.suppress(["translate","translated"]),this.animate(this.coordinates(a)),this.release(["translate","translated"]))},a.prototype.normalize=function(a,e){var b=this._items.length,c=e?0:this._clones.length;return!this.isNumeric(a)||b<1?a=d:(a<0||a>=b+c)&&(a=((a-c/2)%b+b)%b+c/2),a},a.prototype.relative=function(a){return a-=this._clones.length/2,this.normalize(a,!0)},a.prototype.maximum=function(f){var a,d,e,b=this.settings,c=this._coordinates.length;if(b.loop)c=this._clones.length/2+this._items.length-1;else if(b.autoWidth||b.merge){for(a=this._items.length,d=this._items[--a].width(),e=this.$element.width();(a--)&&!((d+=this._items[a].width()+this.settings.margin)>e););c=a+1}else c=b.center?this._items.length-1:this._items.length-b.items;return f&&(c-=this._clones.length/2),Math.max(c,0)},a.prototype.minimum=function(a){return a?0:this._clones.length/2},a.prototype.items=function(a){return a===d?this._items.slice():(a=this.normalize(a,!0),this._items[a])},a.prototype.mergers=function(a){return a===d?this._mergers.slice():(a=this.normalize(a,!0),this._mergers[a])},a.prototype.clones=function(a){var b=this._clones.length/2,c=b+this._items.length,e=function(a){return a%2==0?c+a/2:b-(a+1)/2};return a===d?$.map(this._clones,function(b,a){return e(a)}):$.map(this._clones,function(b,c){return b===a?e(c):null})},a.prototype.speed=function(a){return a!==d&&(this._speed=a),this._speed},a.prototype.coordinates=function(b){var a,e=1,c=b-1;return b===d?$.map(this._coordinates,$.proxy(function(b,a){return this.coordinates(a)},this)):(this.settings.center?(this.settings.rtl&&(e=-1,c=b+1),a=this._coordinates[b],a+=(this.width()-a+(this._coordinates[c]||0))/2*e):a=this._coordinates[c]||0,a=Math.ceil(a))},a.prototype.duration=function(b,c,a){return 0===a?0:Math.min(Math.max(Math.abs(c-b),1),6)*Math.abs(a||this.settings.smartSpeed)},a.prototype.to=function(a,h){var d=this.current(),e=null,b=a-this.relative(d),f=this._items.length,g=this.minimum(),c=this.maximum();this.settings.loop?(!this.settings.rewind&&Math.abs(b)>f/2&&(b+=-1*((b>0)-(b<0))*f),(e=(((a=d+b)-g)%f+f)%f+g)!==a&&e-b<=c&&e-b>0&&(d=e-b,a=e,this.reset(d))):this.settings.rewind?(c+=1,a=(a%c+c)%c):a=Math.max(g,Math.min(c,a)),this.speed(this.duration(d,a,h)),this.current(a),this.$element.is(":visible")&&this.update()},a.prototype.next=function(a){a=a||!1,this.to(this.relative(this.current())+1,a)},a.prototype.prev=function(a){a=a||!1,this.to(this.relative(this.current())-1,a)}
vendor: 11,110 bytes, line 7548
7548,a.prototype.onTransitionEnd=function(a){if(a!==d&&(a.stopPropagation(),(a.target||a.srcElement||a.originalTarget)!==this.$stage.get(0)))return!1;this.leave("animating"),this.trigger("translated")},a.prototype.viewport=function(){var a;return this.options.responsiveBaseElement!==b?a=$(this.options.responsiveBaseElement).width():b.innerWidth?a=b.innerWidth:c.documentElement&&c.documentElement.clientWidth?a=c.documentElement.clientWidth:console.warn("Can not detect viewport width."),a},a.prototype.replace=function(a){this.$stage.empty(),this._items=[],a&&(a=a instanceof jQuery?a:$(a)),this.settings.nestedItemSelector&&(a=a.find("."+this.settings.nestedItemSelector)),a.filter(function(){return 1===this.nodeType}).each($.proxy(function(b,a){a=this.prepare(a),this.$stage.append(a),this._items.push(a),this._mergers.push(1*a.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)},this)),this.reset(this.isNumeric(this.settings.startPosition)?this.settings.startPosition:0),this.invalidate("items")},a.prototype.add=function(a,b){var c=this.relative(this._current);b=b===d?this._items.length:this.normalize(b,!0),a=a instanceof jQuery?a:$(a),this.trigger("add",{content:a,position:b}),a=this.prepare(a),0===this._items.length||b===this._items.length?(0===this._items.length&&this.$stage.append(a),0!==this._items.length&&this._items[b-1].after(a),this._items.push(a),this._mergers.push(1*a.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)):(this._items[b].before(a),this._items.splice(b,0,a),this._mergers.splice(b,0,1*a.find("[data-merge]").addBack("[data-merge]").attr("data-merge")||1)),this._items[c]&&this.reset(this._items[c].index()),this.invalidate("items"),this.trigger("added",{content:a,position:b})},a.prototype.remove=function(a){d!==(a=this.normalize(a,!0))&&(this.trigger("remove",{content:this._items[a],position:a}),this._items[a].remove(),this._items.splice(a,1),this._mergers.splice(a,1),this.invalidate("items"),this.trigger("removed",{content:null,position:a}))},a.prototype.preloadAutoWidthImages=function(a){a.each($.proxy(function(b,a){this.enter("pre-loading"),a=$(a),$(new Image).one("load",$.proxy(function(b){a.attr("src",b.target.src),a.css("opacity",1),this.leave("pre-loading"),this.is("pre-loading")||this.is("initializing")||this.refresh()},this)).attr("src",a.attr("src")||a.attr("data-src")||a.attr("data-src-retina"))},this))},a.prototype.destroy=function(){for(var a in this.$element.off(".owl.core"),this.$stage.off(".owl.core"),$(c).off(".owl.core"),!1!==this.settings.responsive&&(b.clearTimeout(this.resizeTimer),this.off(b,"resize",this._handlers.onThrottledResize)),this._plugins)this._plugins[a].destroy();this.$stage.children(".cloned").remove(),this.$stage.unwrap(),this.$stage.children().contents().unwrap(),this.$stage.children().unwrap(),this.$element.removeClass(this.options.refreshClass).removeClass(this.options.loadingClass).removeClass(this.options.loadedClass).removeClass(this.options.rtlClass).removeClass(this.options.dragClass).removeClass(this.options.grabClass).attr("class",this.$element.attr("class").replace(new RegExp(this.options.responsiveClass+"-\\S+\\s","g"),"")).removeData("owl.carousel")},a.prototype.op=function(a,d,b){var c=this.settings.rtl;switch(d){case"<":return c?a>b:a<b;case">":return c?a<b:a>b;case">=":return c?a<=b:a>=b;case"<=":return c?a>=b:a<=b}},a.prototype.on=function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d):a.attachEvent&&a.attachEvent("on"+b,c)},a.prototype.off=function(a,b,c,d){a.removeEventListener?a.removeEventListener(b,c,d):a.detachEvent&&a.detachEvent("on"+b,c)},a.prototype.trigger=function(b,f,d,h,i){var g={item:{count:this._items.length,index:this.current()}},e=$.camelCase($.grep(["on",b,d],function(a){return a}).join("-").toLowerCase()),c=$.Event([b,"owl",d||"carousel"].join(".").toLowerCase(),$.extend({relatedTarget:this},g,f));return!this._supress[b]&&($.each(this._plugins,function(b,a){a.onTrigger&&a.onTrigger(c)}),this.register({type:a.Type.Event,name:b}),this.$element.trigger(c),this.settings&&"function"==typeof this.settings[e]&&this.settings[e].call(this,c)),c},a.prototype.enter=function(a){$.each([a].concat(this._states.tags[a]||[]),$.proxy(function(b,a){d===this._states.current[a]&&(this._states.current[a]=0),this._states.current[a]++},this))},a.prototype.leave=function(a){$.each([a].concat(this._states.tags[a]||[]),$.proxy(function(b,a){this._states.current[a]--},this))},a.prototype.register=function(b){if(b.type===a.Type.Event){if($.event.special[b.name]||($.event.special[b.name]={}),!$.event.special[b.name].owl){var c=$.event.special[b.name]._default;$.event.special[b.name]._default=function(a){return c&&c.apply&&(!a.namespace|| -1===a.namespace.indexOf("owl"))?c.apply(this,arguments):a.namespace&&a.namespace.indexOf("owl")> -1},$.event.special[b.name].owl=!0}}else b.type===a.Type.State&&(this._states.tags[b.name]?this._states.tags[b.name]=this._states.tags[b.name].concat(b.tags):this._states.tags[b.name]=b.tags,this._states.tags[b.name]=$.grep(this._states.tags[b.name],$.proxy(function(a,c){return $.inArray(a,this._states.tags[b.name])===c},this)))},a.prototype.suppress=function(a){$.each(a,$.proxy(function(b,a){this._supress[a]=!0},this))},a.prototype.release=function(a){$.each(a,$.proxy(function(b,a){delete this._supress[a]},this))},a.prototype.pointer=function(a){var c={x:null,y:null};return(a=(a=a.originalEvent||a||b.event).touches&&a.touches.length?a.touches[0]:a.changedTouches&&a.changedTouches.length?a.changedTouches[0]:a).pageX?(c.x=a.pageX,c.y=a.pageY):(c.x=a.clientX,c.y=a.clientY),c},a.prototype.isNumeric=function(a){return!isNaN(parseFloat(a))},a.prototype.difference=function(a,b){return{x:a.x-b.x,y:a.y-b.y}},$.fn.owlCarousel=function(b){var c=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=$(this),d=e.data("owl.carousel");d||(d=new a(this,"object"==typeof b&&b),e.data("owl.carousel",d),$.each(["next","prev","to","destroy","refresh","replace","add","remove"],function(c,b){d.register({type:a.Type.Event,name:b}),d.$element.on(b+".owl.carousel.core",$.proxy(function(a){a.namespace&&a.relatedTarget!==this&&(this.suppress([b]),d[b].apply(this,[].slice.call(arguments,1)),this.release([b]))},d))})),"string"==typeof b&&"_"!==b.charAt(0)&&d[b].apply(d,c)})},$.fn.owlCarousel.Constructor=a}(owlJqueryObject,window,document),function($,b,c,d){var a=function(b){this._core=b,this._interval=null,this._visible=null,this._handlers={"initialized.owl.carousel":$.proxy(function(a){a.namespace&&this._core.settings.autoRefresh&&this.watch()},this)},this._core.options=$.extend({},a.Defaults,this._core.options),this._core.$element.on(this._handlers)};a.Defaults={autoRefresh:!0,autoRefreshInterval:500},a.prototype.watch=function(){this._interval||(this._visible=this._core.$element.is(":visible"),this._interval=b.setInterval($.proxy(this.refresh,this),this._core.settings.autoRefreshInterval))},a.prototype.refresh=function(){this._core.$element.is(":visible")!==this._visible&&(this._visible=!this._visible,this._core.$element.toggleClass("owl-hidden",!this._visible),this._visible&&this._core.invalidate("width")&&this._core.refresh())},a.prototype.destroy=function(){var a,c;for(a in b.clearInterval(this._interval),this._handlers)this._core.$element.off(a,this._handlers[a]);for(c in Object.getOwnPropertyNames(this))"function"!=typeof this[c]&&(this[c]=null)},$.fn.owlCarousel.Constructor.Plugins.AutoRefresh=a}(owlJqueryObject,window,document),function($,b,c,d){var a=function(b){this._core=b,this._loaded=[],this._handlers={"initialized.owl.carousel change.owl.carousel resized.owl.carousel":$.proxy(function(a){if(a.namespace&&this._core.settings&&this._core.settings.lazyLoad&&(a.property&&"position"==a.property.name||"initialized"==a.type))for(var b=this._core.settings,d=b.center&&Math.ceil(b.items/2)||b.items,e=b.center&& -1*d||0,c=(a.property&& void 0!==a.property.value?a.property.value:this._core.current())+e,f=this._core.clones().length,g=$.proxy(function(b,a){this.load(a)},this);(e++)<d;)this.load(f/2+this._core.relative(c)),f&&$.each(this._core.clones(this._core.relative(c)),g),c++},this)},this._core.options=$.extend({},a.Defaults,this._core.options),this._core.$element.on(this._handlers)};a.Defaults={lazyLoad:!1},a.prototype.load=function(d){var a=this._core.$stage.children().eq(d),c=a&&a.find(".owl-lazy");!c||$.inArray(a.get(0),this._loaded)> -1||(c.each($.proxy(function(f,e){var d,a=$(e),c=b.devicePixelRatio>1&&a.attr("data-src-retina")||a.attr("data-src");this._core.trigger("load",{element:a,url:c},"lazy"),a.is("img")?a.one("load.owl.lazy",$.proxy(function(){a.css("opacity",1),this._core.trigger("loaded",{element:a,url:c},"lazy")},this)).attr("src",c):((d=new Image).onload=$.proxy(function(){a.css({"background-image":'url("'+c+'")',opacity:"1"}),this._core.trigger("loaded",{element:a,url:c},"lazy")},this),d.src=c)},this)),this._loaded.push(a.get(0)))},a.prototype.destroy=function(){var a,b;for(a in this.handlers)this._core.$element.off(a,this.handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},$.fn.owlCarousel.Constructor.Plugins.Lazy=a}(owlJqueryObject,window,document),function($,b,c,d){var a=function(b){this._core=b,this._handlers={"initialized.owl.carousel refreshed.owl.carousel":$.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&this.update()},this),"changed.owl.carousel":$.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&"position"==a.property.name&&this.update()},this),"loaded.owl.lazy":$.proxy(function(a){a.namespace&&this._core.settings.autoHeight&&a.element.closest("."+this._core.settings.itemClass).index()===this._core.current()&&this.update()},this)},this._core.options=$.extend({},a.Defaults,this._core.options),this._core.$element.on(this._handlers)};a.Defaults={autoHeight:!1,autoHeightClass:"owl-height"},a.prototype.update=function(){var a=this._core._current,c=a+this._core.settings.items,d=this._core.$stage.children().toArray().slice(a,c),e=[],b=0;$.each(d,function(b,a){e.push($(a).height())}),b=Math.max.apply(null,e),this._core.$stage.parent().height(b).addClass(this._core.settings.autoHeightClass)},a.prototype.destroy=function(){var a,b;for(a in this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},$.fn.owlCarousel.Constructor.Plugins.AutoHeight=a}(owlJqueryObject,window,document),function($,b,c,d){var a=function(b){this._core=b,this._videos={},this._playing=null,this._handlers={"initialized.owl.carousel":$.proxy(function(a){a.namespace&&this._core.register({type:"state",name:"playing",tags:["interacting"]})},this),"resize.owl.carousel":$.proxy(function(a){a.namespace&&this._core.settings.video&&this.isInFullScreen()&&a.preventDefault()},this),"refreshed.owl.carousel":$.proxy(function(a){a.namespace&&this._core.is("resizing")&&this._core.$stage.find(".cloned .owl-video-frame").remove()},this),"changed.owl.carousel":$.proxy(function(a){a.namespace&&"position"===a.property.name&&this._playing&&this.stop()}
7548,this),"prepared.owl.carousel":$.proxy(function(a){if(a.namespace){var b=$(a.content).find(".owl-video");b.length&&(b.css("display","none"),this.fetch(b,$(a.content)))}},this)},this._core.options=$.extend({},a.Defaults,this._core.options),this._core.$element.on(this._handlers),this._core.$element.on("click.owl.video",".owl-video-play-icon",$.proxy(function(a){this.play(a)},this))};a.Defaults={video:!1,videoHeight:!1,videoWidth:!1},a.prototype.fetch=function(a,e){var d=a.attr("data-vimeo-id")?"vimeo":a.attr("data-vzaar-id")?"vzaar":"youtube",b=a.attr("data-vimeo-id")||a.attr("data-youtube-id")||a.attr("data-vzaar-id"),f=a.attr("data-width")||this._core.settings.videoWidth,g=a.attr("data-height")||this._core.settings.videoHeight,c=a.attr("href");if(c){if((b=c.match(/(http:|https:|)\/\/(player.|www.|app.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com)|vzaar\.com)\/(video\/|videos\/|embed\/|channels\/.+\/|groups\/.+\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/))[3].indexOf("youtu")> -1)d="youtube";else if(b[3].indexOf("vimeo")> -1)d="vimeo";else if(b[3].indexOf("vzaar")> -1)d="vzaar";else throw new Error("Video URL not supported.");b=b[6]}else throw new Error("Missing video URL.");this._videos[c]={type:d,id:b,width:f,height:g},e.attr("data-video",c),this.thumbnail(a,this._videos[c])},a.prototype.thumbnail=function(c,a){var i,j,f,g=a.width&&a.height?'style="width:'+a.width+"px;height:"+a.height+'px;"':"",b=c.find("img"),d="src",h="",k=this._core.settings,e=function(a){j='<div class="owl-video-play-icon"></div>',i=k.lazyLoad?'<div class="owl-video-tn '+h+'" '+d+'="'+a+'"></div>':'<div class="owl-video-tn" style="opacity:1;background-image:url('+a+')"></div>',c.after(i),c.after(j)};if(c.wrap('<div class="owl-video-wrapper"'+g+"></div>"),this._core.settings.lazyLoad&&(d="data-src",h="owl-lazy"),b.length)return e(b.attr(d)),b.remove(),!1;"youtube"===a.type?e(f="//img.youtube.com/vi/"+a.id+"/hqdefault.jpg"):"vimeo"===a.type?$.ajax({type:"GET",url:"//vimeo.com/api/v2/video/"+a.id+".json",jsonp:"callback",dataType:"jsonp",success:function(a){e(f=a[0].thumbnail_large)}}):"vzaar"===a.type&&$.ajax({type:"GET",url:"//vzaar.com/api/videos/"+a.id+".json",jsonp:"callback",dataType:"jsonp",success:function(a){e(f=a.framegrab_url)}})},a.prototype.stop=function(){this._core.trigger("stop",null,"video"),this._playing.find(".owl-video-frame").remove(),this._playing.removeClass("owl-video-playing"),this._playing=null,this._core.leave("playing"),this._core.trigger("stopped",null,"video")},a.prototype.play=function(f){var c,b=$(f.target).closest("."+this._core.settings.itemClass),a=this._videos[b.attr("data-video")],d=a.width||"100%",e=a.height||this._core.$stage.height();this._playing||(this._core.enter("playing"),this._core.trigger("play",null,"video"),b=this._core.items(this._core.relative(b.index())),this._core.reset(b.index()),"youtube"===a.type?c='<iframe width="'+d+'" height="'+e+'" src="//www.youtube.com/embed/'+a.id+"?autoplay=1&rel=0&v="+a.id+'" frameborder="0" allowfullscreen></iframe>':"vimeo"===a.type?c='<iframe src="//player.vimeo.com/video/'+a.id+'?autoplay=1" width="'+d+'" height="'+e+'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>':"vzaar"===a.type&&(c='<iframe frameborder="0"height="'+e+'"width="'+d+'" allowfullscreen mozallowfullscreen webkitAllowFullScreen src="//view.vzaar.com/'+a.id+'/player?autoplay=true"></iframe>'),$('<div class="owl-video-frame">'+c+"</div>").insertAfter(b.find(".owl-video")),this._playing=b.addClass("owl-video-playing"))},a.prototype.isInFullScreen=function(){var a=c.fullscreenElement||c.mozFullScreenElement||c.webkitFullscreenElement;return a&&$(a).parent().hasClass("owl-video-frame")},a.prototype.destroy=function(){var a,b;for(a in this._core.$element.off("click.owl.video"),this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},$.fn.owlCarousel.Constructor.Plugins.Video=a}(owlJqueryObject,window,document),function($,b,c,d){var a=function(b){this.core=b,this.core.options=$.extend({},a.Defaults,this.core.options),this.swapping=!0,this.previous=d,this.next=d,this.handlers={"change.owl.carousel":$.proxy(function(a){a.namespace&&"position"==a.property.name&&(this.previous=this.core.current(),this.next=a.property.value)},this),"drag.owl.carousel dragged.owl.carousel translated.owl.carousel":$.proxy(function(a){a.namespace&&(this.swapping="translated"==a.type)},this),"translate.owl.carousel":$.proxy(function(a){a.namespace&&this.swapping&&(this.core.options.animateOut||this.core.options.animateIn)&&this.swap()},this)},this.core.$element.on(this.handlers)};a.Defaults={animateOut:!1,animateIn:!1},a.prototype.swap=function(){if(1===this.core.settings.items&&$.support.animation&&$.support.transition){this.core.speed(0);var a,b=$.proxy(this.clear,this),e=this.core.$stage.children().eq(this.previous),f=this.core.$stage.children().eq(this.next),c=this.core.settings.animateIn,d=this.core.settings.animateOut;this.core.current()!==this.previous&&(d&&(a=this.core.coordinates(this.previous)-this.core.coordinates(this.next),e.one($.support.animation.end,b).
vendor: 6,381 bytes, line 7548
7548css({left:a+"px"}).addClass("animated owl-animated-out").addClass(d)),c&&f.one($.support.animation.end,b).addClass("animated owl-animated-in").addClass(c))}},a.prototype.clear=function(a){$(a.target).css({left:""}).removeClass("animated owl-animated-out owl-animated-in").removeClass(this.core.settings.animateIn).removeClass(this.core.settings.animateOut),this.core.onTransitionEnd()},a.prototype.destroy=function(){var a,b;for(a in this.handlers)this.core.$element.off(a,this.handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},$.fn.owlCarousel.Constructor.Plugins.Animate=a}(owlJqueryObject,window,document),function($,b,c,d){var a=function(b){this._core=b,this._timeout=null,this._paused=!1,this._handlers={"changed.owl.carousel":$.proxy(function(a){a.namespace&&"settings"===a.property.name?this._core.settings.autoplay?this.play():this.stop():a.namespace&&"position"===a.property.name&&this._core.settings.autoplay&&this._setAutoPlayInterval()},this),"initialized.owl.carousel":$.proxy(function(a){a.namespace&&this._core.settings.autoplay&&this.play()},this),"play.owl.autoplay":$.proxy(function(a,b,c){a.namespace&&this.play(b,c)},this),"stop.owl.autoplay":$.proxy(function(a){a.namespace&&this.stop()},this),"mouseover.owl.autoplay":$.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"mouseleave.owl.autoplay":$.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.play()},this),"touchstart.owl.core":$.proxy(function(){this._core.settings.autoplayHoverPause&&this._core.is("rotating")&&this.pause()},this),"touchend.owl.core":$.proxy(function(){this._core.settings.autoplayHoverPause&&this.play()},this)},this._core.$element.on(this._handlers),this._core.options=$.extend({},a.Defaults,this._core.options)};a.Defaults={autoplay:!1,autoplayTimeout:5e3,autoplayHoverPause:!1,autoplaySpeed:!1},a.prototype.play=function(a,b){this._paused=!1,this._core.is("rotating")||(this._core.enter("rotating"),this._setAutoPlayInterval())},a.prototype._getNextTimeout=function(a,d){return this._timeout&&b.clearTimeout(this._timeout),b.setTimeout($.proxy(function(){this._paused||this._core.is("busy")||this._core.is("interacting")||c.hidden||this._core.next(d||this._core.settings.autoplaySpeed)},this),a||this._core.settings.autoplayTimeout)},a.prototype._setAutoPlayInterval=function(){this._timeout=this._getNextTimeout()},a.prototype.stop=function(){this._core.is("rotating")&&(b.clearTimeout(this._timeout),this._core.leave("rotating"))},a.prototype.pause=function(){this._core.is("rotating")&&(this._paused=!0)},a.prototype.destroy=function(){var a,b;for(a in this.stop(),this._handlers)this._core.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},$.fn.owlCarousel.Constructor.Plugins.autoplay=a}(owlJqueryObject,window,document),function($,b,c,d){"use strict";var a=function(b){this._core=b,this._initialized=!1,this._pages=[],this._controls={},this._templates=[],this.$element=this._core.$element,this._overrides={next:this._core.next,prev:this._core.prev,to:this._core.to},this._handlers={"prepared.owl.carousel":$.proxy(function(a){a.namespace&&this._core.settings.dotsData&&this._templates.push('<div class="'+this._core.settings.dotClass+'">'+$(a.content).find("[data-dot]").addBack("[data-dot]").attr("data-dot")+"</div>")},this),"added.owl.carousel":$.proxy(function(a){a.namespace&&this._core.settings.dotsData&&this._templates.splice(a.position,0,this._templates.pop())},this),"remove.owl.carousel":$.proxy(function(a){a.namespace&&this._core.settings.dotsData&&this._templates.splice(a.position,1)},this),"changed.owl.carousel":$.proxy(function(a){a.namespace&&"position"==a.property.name&&this.draw()},this),"initialized.owl.carousel":$.proxy(function(a){a.namespace&&!this._initialized&&(this._core.trigger("initialize",null,"navigation"),this.initialize(),this.update(),this.draw(),this._initialized=!0,this._core.trigger("initialized",null,"navigation"))},this),"refreshed.owl.carousel":$.proxy(function(a){a.namespace&&this._initialized&&(this._core.trigger("refresh",null,"navigation"),this.update(),this.draw(),this._core.trigger("refreshed",null,"navigation"))},this)},this._core.options=$.extend({},a.Defaults,this._core.options),this.$element.on(this._handlers)};a.Defaults={nav:!1,navText:["prev","next"],navSpeed:!1,navElement:"div",navContainer:!1,navContainerClass:"owl-nav",navClass:["owl-prev","owl-next"],slideBy:1,dotClass:"owl-dot",dotsClass:"owl-dots",dots:!0,dotsEach:!1,dotsData:!1,dotsSpeed:!1,dotsContainer:!1},a.prototype.initialize=function(){var b,a=this._core.settings;for(b in this._controls.$relative=(a.navContainer?$(a.navContainer):$("<div>").addClass(a.navContainerClass).appendTo(this.$element)).addClass("disabled"),this._controls.$previous=$("<"+a.navElement+">").addClass(a.navClass[0]).html(a.navText[0]).prependTo(this._controls.$relative).on("click",$.proxy(function(b){this.prev(a.navSpeed)},this)),this._controls.$next=$("<"+a.navElement+">").addClass(a.navClass[1]).html(a.navText[1]).appendTo(this._controls.$relative).on("click",$.proxy(function(b){this.next(a.navSpeed)},this)),a.dotsData||(this._templates=[$("<div>").addClass(a.dotClass).append($("<span>")).prop("outerHTML")]),this._controls.$absolute=(a.dotsContainer?$(a.dotsContainer):$("<div>").addClass(a.dotsClass).appendTo(this.$element)).addClass("disabled"),this._controls.$absolute.on("click","div",$.proxy(function(b){var c=$(b.target).parent().is(this._controls.$absolute)?$(b.target).index():$(b.target).parent().index();b.preventDefault(),this.to(c,a.dotsSpeed)},this)),this._overrides)this._core[b]=$.proxy(this[b],this)},a.prototype.destroy=function(){var a,d,b,c;for(a in this._handlers)this.$element.off(a,this._handlers[a]);for(d in this._controls)this._controls[d].remove();for(c in this.overides)this._core[c]=this._overrides[c];for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.prototype.update=function(){var b,c,d=this._core.clones().length/2,g=d+this._core.items().length,e=this._core.maximum(!0),a=this._core.settings,f=a.center||a.autoWidth||a.dotsData?1:a.dotsEach||a.items;if("page"!==a.slideBy&&(a.slideBy=Math.min(a.slideBy,a.items)),a.dots||"page"==a.slideBy)for(this._pages=[],b=d,c=0;b<g;
7548b++){if(c>=f||0===c){if(this._pages.push({start:Math.min(e,b-d),end:b-d+f-1}),Math.min(e,b-d)===e)break;c=0}c+=this._core.mergers(this._core.relative(b))}},a.prototype.draw=function(){var b,a=this._core.settings,c=this._core.items().length<=a.items,d=this._core.relative(this._core.current()),e=a.loop||a.rewind;this._controls.$relative.toggleClass("disabled",!a.nav||c),a.nav&&(this._controls.$previous.toggleClass("disabled",!e&&d<=this._core.minimum(!0)),this._controls.$next.toggleClass("disabled",!e&&d>=this._core.maximum(!0))),this._controls.$absolute.toggleClass("disabled",!a.dots||c),a.dots&&(b=this._pages.length-this._controls.$absolute.children().length,a.dotsData&&0!==b?this._controls.$absolute.html(this._templates.join("")):b>0?this._controls.$absolute.append(new Array(b+1).join(this._templates[0])):b<0&&this._controls.$absolute.children().slice(b).remove(),this._controls.$absolute.find(".active").removeClass("active"),this._controls.$absolute.children().eq($.inArray(this.current(),this._pages)).addClass("active"))},a.prototype.onTrigger=function(b){var a=this._core.settings;b.page={index:$.inArray(this.current(),this._pages),count:this._pages.length,size:a&&(a.center||a.autoWidth||a.dotsData?1:a.dotsEach||a.items)}},a.prototype.current=function(){var a=this._core.relative(this._core.current());return $.grep(this._pages,$.proxy(function(b,c){return b.start<=a&&b.end>=a},this)).pop()},a.prototype.getPosition=function(d){var a,b,c=this._core.settings;return"page"==c.slideBy?(a=$.inArray(this.current(),this._pages),b=this._pages.length,d?++a:--a,a=this._pages[(a%b+b)%b].start):(a=this._core.relative(this._core.current()),b=this._core.items().length,d?a+=c.slideBy:a-=c.slideBy),a},a.prototype.next=function(a){$.proxy(this._overrides.to,this._core)(this.getPosition(!0),a)},a.prototype.prev=function(a){$.proxy(this._overrides.to,this._core)(this.getPosition(!1),a)},a.prototype.to=function(b,c,d){var a;!d&&this._pages.length?(a=this._pages.length,$.proxy(this._overrides.to,this._core)(this._pages[(b%a+a)%a].start,c)):$.proxy(this._overrides.to,this._core)(b,c)},$.fn.owlCarousel.Constructor.Plugins.Navigation=a}(owlJqueryObject,window,document),function($,b,c,d){"use strict";var a=function(c){this._core=c,this._hashes={},this.$element=this._core.$element,this._handlers={"initialized.owl.carousel":$.proxy(function(a){a.namespace&&"URLHash"===this._core.settings.startPosition&&$(b).trigger("hashchange.owl.navigation")},this),"prepared.owl.carousel":$.proxy(function(a){if(a.namespace){var b=$(a.content).find("[data-hash]").addBack("[data-hash]").attr("data-hash");b&&(this._hashes[b]=a.content)}},this),"changed.owl.carousel":$.proxy(function(c){if(c.namespace&&"position"===c.property.name){var d=this._core.items(this._core.relative(this._core.current())),a=$.map(this._hashes,function(a,b){return a===d?b:null}).join();a&&b.location.hash.slice(1)!==a&&(b.location.hash=a)}},this)},this._core.options=$.extend({},a.Defaults,this._core.options),this.$element.on(this._handlers),$(b).on("hashchange.owl.navigation",$.proxy(function(e){var c=b.location.hash.substring(1),d=this._core.$stage.children(),a=this._hashes[c]&&d.index(this._hashes[c]);void 0!==a&&a!==this._core.current()&&this._core.to(this._core.relative(a),!1,!0)},this))};a.Defaults={URLhashListener:!1},a.prototype.destroy=function(){var a,c;for(a in $(b).off("hashchange.owl.navigation"),this._handlers)this._core.$element.off(a,this._handlers[a]);for(c in Object.getOwnPropertyNames(this))"function"!=typeof this[c]&&(this[c]=null)},$.fn.owlCarousel.Constructor.Plugins.Hash=a}(owlJqueryObject,window,document),function($,d,e,f){var g=$("<support>").get(0).style,h="Webkit Moz O ms".split(" "),c={transition:{end:{WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",transition:"transitionend"}},animation:{end:{WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oAnimationEnd",animation:"animationend"}}},a={csstransforms:function(){return!!i("transform")},csstransforms3d:function(){return!!i("perspective")},csstransitions:function(){return!!i("transition")},cssanimations:function(){return!!i("animation")}};function i(a,d){var c=!1,b=a.charAt(0).toUpperCase()+a.slice(1);return $.each((a+" "+h.join(b+" ")+b).split(" "),function(b,a){if(void 0!==g[a])return c=!d||a,!1}),c}function b(a){return i(a,!0)}
7548a.csstransitions()&&($.support.transition=new String(b("transition")),$.support.transition.end=c.transition.end[$.support.transition]),a.cssanimations()&&($.support.animation=new String(b("animation")),$.support.animation.end=c.animation.end[$.support.animation]),a.csstransforms()&&($.support.transform=new String(b("transform")),$.support.transform3d=a.csstransforms3d())}(owlJqueryObject,window,document) 7549; 7550 7551 /* ******************************************* 7552// Copyright 2010, Anthony Hand 7553// 7554// File version date: November 28, 2010 7555// 7556// LICENSE INFORMATION 7557// Licensed under the Apache License, Version 2.0 (the "License"); 7558// you may not use this file except in compliance with the License. 7559// You may obtain a copy of the License at 7560// http://www.apache.org/licenses/LICENSE-2.0 7561// Unless required by applicable law or agreed to in writing, 7562// software distributed under the License is distributed on an 7563// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 7564// either express or implied. See the License for the specific 7565// language governing permissions and limitations under the License. 7566// 7567// 7568// ABOUT THIS PROJECT 7569// Project Owner: Anthony Hand 7570// Email: [email protected] 7571// Web Site: http://www.mobileesp.com 7572// Source Files: http://code.google.com/p/mobileesp/ 7573// 7574// Versions of this code are available for: 7575// PHP, JavaScript, Java, ASP.NET (C#), and Ruby 7576// 7577// 7578// WARNING: 7579// These JavaScript-based device detection features may ONLY work 7580// for the newest generation of smartphones, such as the iPhone, 7581// Android and Palm WebOS devices. 7582// These device detection features may NOT work for older smartphones 7583// which had poor support for JavaScript, including 7584// older BlackBerry, PalmOS, and Windows Mobile devices. 7585// Additionally, because JavaScript support is extremely poor among 7586// 'feature phones', these features may not work at all on such devices. 7587// For better results, consider using a server-based version of this code, 7588// such as Java, APS.NET, PHP, or Ruby. 7589// 7590// ******************************************* 7591*/ 7592 7593//Optional: Store values for quickly accessing same info multiple times. 7594//Stores whether the device is an iPhone or iPod Touch. 7595var isIphone = false; 7596//Stores whether is the iPhone tier of devices. 7597var isTierIphone = false; 7598//Stores whether the device can probably support Rich CSS, but JavaScript support is not assumed. (e.g., newer BlackBerry, Windows Mobile) 7599var isTierRichCss = false; 7600//Stores whether it is another mobile device, which cannot be assumed to support CSS or JS (eg, older BlackBerry, RAZR) 7601var isTierGenericMobile = false; 7602 7603//Initialize some initial string variables we'll look for later. 7604var engineWebKit = "webkit"; 7605var deviceIphone = "iphone"; 7606var deviceIpod = "ipod"; 7607var deviceIpad = "ipad"; 7608var deviceMacPpc = "macintosh"; //Used for disambiguation 7609 7610var deviceAndroid = "android"; 7611var deviceGoogleTV = "googletv"; 7612 7613var deviceNuvifone = "nuvifone"; //Garmin Nuvifone 7614 7615var deviceSymbian = "symbian"; 7616var deviceS60 = "series60"; 7617var deviceS70 = "series70"; 7618var deviceS80 = "series80"; 7619var deviceS90 = "series90"; 7620 7621var deviceWinPhone7 = "windows phone os 7"; 7622var deviceWinMob = "windows ce"; 7623var deviceWindows = "windows"; 7624var deviceIeMob = "iemobile"; 7625var devicePpc = "ppc"; //Stands for PocketPC 7626var enginePie = "wm5 pie"; //An old Windows Mobile 7627 7628var deviceBB = "blackberry"; 7629var vndRIM = "vnd.rim"; //Detectable when BB devices emulate IE or Firefox 7630var deviceBBStorm = "blackberry95"; //Storm 1 and 2 7631var deviceBBBold = "blackberry97"; //Bold 7632var deviceBBTour = "blackberry96"; //Tour 7633var deviceBBCurve = "blackberry89"; //Curve 2 7634var deviceBBTorch = "blackberry 98"; //Torch 7635 7636var devicePalm = "palm"; 7637var deviceWebOS = "webos"; //For Palm's new WebOS devices 7638var engineBlazer = "blazer"; //Old Palm browser 7639var engineXiino = "xiino"; 7640 7641var deviceKindle = "kindle"; //Amazon Kindle, eInk one. 7642 7643//Initialize variables for mobile-specific content. 7644var vndwap = "vnd.wap"; 7645var wml = "wml"; 7646 7647//Initialize variables for random devices and mobile browsers. 7648//Some of these may not support JavaScript 7649var deviceBrew = "brew"; 7650var deviceDanger = "danger"; 7651var deviceHiptop = "hiptop"; 7652var devicePlaystation = "playstation"; 7653var deviceNintendoDs = "nitro"; 7654var deviceNintendo = "nintendo"; 7655var deviceWii = "wii"; 7656var deviceXbox = "xbox"; 7657var deviceArchos = "archos"; 7658 7659var engineOpera = "opera"; //Popular browser 7660var engineNetfront = "netfront"; //Common embedded OS browser 7661var engineUpBrowser = "up.browser"; //common on some phones 7662var engineOpenWeb = "openweb"; //Transcoding by OpenWave server 7663var deviceMidp = "midp"; //a mobile Java technology 7664var uplink = "up.link"; 7665var engineTelecaQ = 'teleca q'; //a modern feature phone browser 7666 7667var devicePda = "pda"; 7668var mini = "mini"; //Some mobile browsers put 'mini' in their names. 7669var mobile = "mobile"; //Some mobile browsers put 'mobile' in their user agent strings. 7670var mobi = "mobi"; //Some mobile browsers put 'mobi' in their user agent strings. 7671 7672//Use Maemo, Tablet, and Linux to test for Nokia's Internet Tablets. 7673var maemo = "maemo"; 7674var maemoTablet = "tablet"; 7675var linux = "linux"; 7676var qtembedded = "qt embedded"; //for Sony Mylo and others 7677var mylocom2 = "com2"; //for Sony Mylo also 7678 7679//In some UserAgents, the only clue is the manufacturer. 7680var manuSonyEricsson = "sonyericsson"; 7681var manuericsson = "ericsson"; 7682var manuSamsung1 = "sec-sgh"; 7683var manuSony = "sony"; 7684var manuHtc = "htc"; //Popular Android and WinMo manufacturer 7685 7686//In some UserAgents, the only clue is the operator. 7687var svcDocomo = "docomo"; 7688var svcKddi = "kddi"; 7689var svcVodafone = "vodafone"; 7690 7691//Disambiguation strings. 7692var disUpdate = "update"; //pda vs. update 7693 7694 7695 7696//Initialize our user agent string. 7697var uagent = navigator.userAgent.toLowerCase(); 7698 7699 7700//************************** 7701// Detects if the current device is an iPhone. 7702function DetectIphone() 7703{ 7704 if (uagent.search(deviceIphone) > -1) 7705 { 7706 //The iPad and iPod Touch say they're an iPhone! So let's disambiguate. 7707 if (DetectIpad() || 7708 DetectIpod()) 7709 return false;
7710 else 7711 return true; 7712 } 7713 else 7714 return false; 7715} 7716 7717//************************** 7718// Detects if the current device is an iPod Touch. 7719function DetectIpod() 7720{ 7721 if (uagent.search(deviceIpod) > -1) 7722 return true; 7723 else 7724 return false; 7725} 7726 7727//************************** 7728// Detects if the current device is an iPad tablet. 7729function DetectIpad() 7730{ 7731 if (uagent.search(deviceIpad) > -1 && DetectWebkit()) 7732 return true; 7733 else 7734 return false; 7735} 7736 7737//************************** 7738// Detects if the current device is an iPhone or iPod Touch. 7739function DetectIphoneOrIpod() 7740{ 7741 //We repeat the searches here because some iPods 7742 // may report themselves as an iPhone, which is ok. 7743 if (uagent.search(deviceIphone) > -1 || 7744 uagent.search(deviceIpod) > -1) 7745 return true; 7746 else 7747 return false; 7748} 7749 7750//************************** 7751// Detects if the current device is an Android OS-based device. 7752function DetectAndroid() 7753{ 7754 if (uagent.search(deviceAndroid) > -1) 7755 return true; 7756 else 7757 return false; 7758} 7759 7760 7761//************************** 7762// Detects if the current device is an Android OS-based device and 7763// the browser is based on WebKit. 7764function DetectAndroidWebKit() 7765{ 7766 if (DetectAndroid() && DetectWebkit()) 7767 return true; 7768 else 7769 return false; 7770} 7771 7772 7773//************************** 7774// Detects if the current device is a GoogleTV. 7775function DetectGoogleTV() 7776{ 7777 if (uagent.search(deviceGoogleTV) > -1) 7778 return true; 7779 else 7780 return false; 7781} 7782 7783 7784//************************** 7785// Detects if the current browser is based on WebKit. 7786function DetectWebkit() 7787{ 7788 if (uagent.search(engineWebKit) > -1) 7789 return true; 7790 else 7791 return false; 7792} 7793 7794//************************** 7795// Detects if the current browser is the Nokia S60 Open Source Browser. 7796function DetectS60OssBrowser() 7797{ 7798 if (DetectWebkit()) 7799 { 7800 if ((uagent.search(deviceS60) > -1 || 7801 uagent.search(deviceSymbian) > -1)) 7802 return true; 7803 else 7804 return false; 7805 } 7806 else 7807 return false; 7808} 7809 7810//************************** 7811// Detects if the current device is any Symbian OS-based device, 7812// including older S60, Series 70, Series 80, Series 90, and UIQ, 7813// or other browsers running on these devices. 7814function DetectSymbianOS() 7815{ 7816 if (uagent.search(deviceSymbian) > -1 || 7817 uagent.search(deviceS60) > -1 || 7818 uagent.search(deviceS70) > -1 || 7819 uagent.search(deviceS80) > -1 || 7820 uagent.search(deviceS90) > -1) 7821 return true; 7822 else 7823 return false; 7824} 7825 7826//************************** 7827// Detects if the current browser is a 7828// Windows Phone 7 device. 7829function DetectWindowsPhone7() 7830{ 7831 if (uagent.search(deviceWinPhone7) > -1) 7832 return true; 7833 else 7834 return false; 7835} 7836 7837//************************** 7838// Detects if the current browser is a Windows Mobile device. 7839// Excludes Windows Phone 7 devices. 7840// Focuses on Windows Mobile 6.xx and earlier. 7841function DetectWindowsMobile() 7842{ 7843 //Exclude new Windows Phone 7. 7844 if (DetectWindowsPhone7()) 7845 return false; 7846 //Most devices use 'Windows CE', but some report 'iemobile' 7847 // and some older ones report as 'PIE' for Pocket IE. 7848 if (uagent.search(deviceWinMob) > -1 || 7849 uagent.search(deviceIeMob) > -1 || 7850 uagent.search(enginePie) > -1) 7851 return true; 7852 //Test for Windows Mobile PPC but not old Macintosh PowerPC. 7853 if ((uagent.search(devicePpc) > -1) && 7854 !(uagent.search(deviceMacPpc) > -1)) 7855 return true; 7856 //Test for Windwos Mobile-based HTC devices. 7857 if (uagent.search(manuHtc) > -1 && 7858 uagent.search(deviceWindows) > -1) 7859 return true; 7860 else 7861 return false; 7862} 7863 7864//************************** 7865// Detects if the current browser is a BlackBerry of some sort. 7866function DetectBlackBerry() 7867{ 7868 if (uagent.search(deviceBB) > -1) 7869 return true; 7870 if (uagent.search(vndRIM) > -1) 7871 return true; 7872 else 7873 return false; 7874} 7875 7876//************************** 7877// Detects if the current browser is a BlackBerry device AND uses a 7878// WebKit-based browser. These are signatures for the new BlackBerry OS 6. 7879// Examples: Torch 7880function DetectBlackBerryWebKit() 7881{ 7882 if (uagent.search(deviceBB) > -1 && 7883 uagent.search(engineWebKit) > -1) 7884 return true; 7885 else 7886 return false;
7887} 7888 7889//************************** 7890// Detects if the current browser is a BlackBerry Touch 7891// device, such as the Storm or Torch. 7892function DetectBlackBerryTouch() 7893{ 7894 if ((uagent.search(deviceBBStorm) > -1) || 7895 (uagent.search(deviceBBTorch) > -1)) 7896 return true; 7897 else 7898 return false; 7899} 7900 7901//************************** 7902// Detects if the current browser is a BlackBerry OS 5 device AND 7903// has a more capable recent browser. 7904// Examples, Storm, Bold, Tour, Curve2 7905// Excludes the new BlackBerry OS 6 browser!! 7906function DetectBlackBerryHigh() 7907{ 7908 //Disambiguate for BlackBerry OS 6 (WebKit) browser 7909 if (DetectBlackBerryWebKit()) 7910 return false; 7911 if (DetectBlackBerry()) 7912 { 7913 if (DetectBlackBerryTouch() || 7914 uagent.search(deviceBBBold) > -1 || 7915 uagent.search(deviceBBTour) > -1 || 7916 uagent.search(deviceBBCurve) > -1) 7917 return true; 7918 else 7919 return false; 7920 } 7921 else 7922 return false; 7923} 7924 7925//************************** 7926// Detects if the current browser is a BlackBerry device AND 7927// has an older, less capable browser. 7928// Examples: Pearl, 8800, Curve1. 7929function DetectBlackBerryLow() 7930{ 7931 if (DetectBlackBerry()) 7932 { 7933 //Assume that if it's not in the High tier, then it's Low. 7934 if (DetectBlackBerryHigh()) 7935 return false; 7936 else 7937 return true; 7938 } 7939 else 7940 return false; 7941} 7942 7943 7944//************************** 7945// Detects if the current browser is on a PalmOS device. 7946function DetectPalmOS() 7947{ 7948 //Most devices nowadays report as 'Palm', 7949 // but some older ones reported as Blazer or Xiino. 7950 if (uagent.search(devicePalm) > -1 || 7951 uagent.search(engineBlazer) > -1 || 7952 uagent.search(engineXiino) > -1) 7953 { 7954 //Make sure it's not WebOS first 7955 if (DetectPalmWebOS()) 7956 return false; 7957 else 7958 return true; 7959 } 7960 else 7961 return false; 7962} 7963 7964//************************** 7965// Detects if the current browser is on a Palm device 7966// running the new WebOS. 7967function DetectPalmWebOS() 7968{ 7969 if (uagent.search(deviceWebOS) > -1) 7970 return true; 7971 else 7972 return false; 7973} 7974 7975//************************** 7976// Detects if the current browser is a 7977// Garmin Nuvifone. 7978function DetectGarminNuvifone() 7979{ 7980 if (uagent.search(deviceNuvifone) > -1) 7981 return true; 7982 else 7983 return false; 7984} 7985 7986 7987//************************** 7988// Check to see whether the device is a 'smartphone'. 7989// You might wish to send smartphones to a more capable web page 7990// than a dumbed down WAP page. 7991function DetectSmartphone() 7992{ 7993 if (DetectIphoneOrIpod()) 7994 return true; 7995 if (DetectS60OssBrowser()) 7996 return true; 7997 if (DetectSymbianOS()) 7998 return true; 7999 if (DetectWindowsMobile()) 8000 return true; 8001 if (DetectWindowsPhone7()) 8002 return true; 8003 if (DetectAndroid()) 8004 return true; 8005 if (DetectBlackBerry()) 8006 return true; 8007 if (DetectPalmWebOS()) 8008 return true; 8009 if (DetectPalmOS()) 8010 return true; 8011 if (DetectGarminNuvifone()) 8012 return true; 8013 8014 //Otherwise, return false. 8015 return false; 8016}; 8017 8018//************************** 8019// Detects if the current device is an Archos media player/Internet tablet. 8020function DetectArchos() 8021{ 8022 if (uagent.search(deviceArchos) > -1) 8023 return true; 8024 else 8025 return false; 8026} 8027 8028//************************** 8029// Detects whether the device is a Brew-powered device. 8030function DetectBrewDevice() 8031{ 8032 if (uagent.search(deviceBrew) > -1) 8033 return true; 8034 else 8035 return false; 8036} 8037 8038//************************** 8039// Detects the Danger Hiptop device. 8040function DetectDangerHiptop() 8041{ 8042 if (uagent.search(deviceDanger) > -1 || 8043 uagent.search(deviceHiptop) > -1) 8044 return true; 8045 else 8046 return false; 8047} 8048 8049//************************** 8050// Detects if the current device is on one of 8051// the Maemo-based Nokia Internet Tablets. 8052function DetectMaemoTablet() 8053{ 8054 if (uagent.search(maemo) > -1) 8055 return true; 8056 //Must be Linux + Tablet, or else it could be something else. 8057 if (uagent.search(maemoTablet) > -1 && 8058 uagent.search(linux) > -1) 8059 return true; 8060 else 8061 return false;
8062} 8063 8064//************************** 8065// Detects if the current browser is a Sony Mylo device. 8066function DetectSonyMylo() 8067{ 8068 if (uagent.search(manuSony) > -1) 8069 { 8070 if (uagent.search(qtembedded) > -1 || 8071 uagent.search(mylocom2) > -1) 8072 return true; 8073 else 8074 return false; 8075 } 8076 else 8077 return false; 8078} 8079 8080//************************** 8081// Detects if the current browser is Opera Mobile or Mini. 8082function DetectOperaMobile() 8083{ 8084 if (uagent.search(engineOpera) > -1) 8085 { 8086 if (uagent.search(mini) > -1 || 8087 uagent.search(mobi) > -1) 8088 return true; 8089 else 8090 return false; 8091 } 8092 else 8093 return false; 8094} 8095 8096//************************** 8097// Detects if the current device is a Sony Playstation. 8098function DetectSonyPlaystation() 8099{ 8100 if (uagent.search(devicePlaystation) > -1) 8101 return true; 8102 else 8103 return false; 8104}; 8105 8106//************************** 8107// Detects if the current device is a Nintendo game device. 8108function DetectNintendo() 8109{ 8110 if (uagent.search(deviceNintendo) > -1 || 8111 uagent.search(deviceWii) > -1 || 8112 uagent.search(deviceNintendoDs) > -1) 8113 return true; 8114 else 8115 return false; 8116}; 8117 8118//************************** 8119// Detects if the current device is a Microsoft Xbox. 8120function DetectXbox() 8121{ 8122 if (uagent.search(deviceXbox) > -1) 8123 return true; 8124 else 8125 return false; 8126}; 8127 8128//************************** 8129// Detects if the current device is an Internet-capable game console. 8130function DetectGameConsole() 8131{ 8132 if (DetectSonyPlaystation()) 8133 return true; 8134 if (DetectNintendo()) 8135 return true; 8136 if (DetectXbox()) 8137 return true; 8138 else 8139 return false; 8140}; 8141 8142//************************** 8143// Detects if the current device is a Kindle. 8144function DetectKindle() 8145{ 8146 if (uagent.search(deviceKindle) > -1) 8147 return true; 8148 else 8149 return false; 8150} 8151 8152//************************** 8153// Detects if the current device is a mobile device. 8154// This method catches most of the popular modern devices. 8155// Excludes Apple iPads. 8156function DetectMobileQuick() 8157{ 8158 //Let's say no if it's an iPad, which contains 'mobile' in its user agent. 8159 if (DetectIpad()) 8160 return false; 8161 8162 //Most mobile browsing is done on smartphones 8163 if (DetectSmartphone()) 8164 return true; 8165 8166 if (uagent.search(deviceMidp) > -1 || 8167 DetectBrewDevice()) 8168 return true; 8169 8170 if (DetectOperaMobile()) 8171 return true; 8172 8173 if (uagent.search(engineNetfront) > -1) 8174 return true; 8175 if (uagent.search(engineUpBrowser) > -1) 8176 return true; 8177 if (uagent.search(engineOpenWeb) > -1) 8178 return true; 8179 8180 if (DetectDangerHiptop()) 8181 return true; 8182 8183 if (DetectMaemoTablet()) 8184 return true; 8185 if (DetectArchos()) 8186 return true; 8187 8188 if ((uagent.search(devicePda) > -1) && 8189 (uagent.search(disUpdate) < 0)) //no index found 8190 return true; 8191 if (uagent.search(mobile) > -1) 8192 return true; 8193 8194 if (DetectKindle()) 8195 return true; 8196 8197 return false; 8198}; 8199 8200 8201//************************** 8202// Detects in a more comprehensive way if the current device is a mobile device. 8203function DetectMobileLong() 8204{ 8205 if (DetectMobileQuick()) 8206 return true; 8207 if (DetectGameConsole()) 8208 return true; 8209 if (DetectSonyMylo()) 8210 return true; 8211 8212 //Detect for certain very old devices with stupid useragent strings. 8213 if (uagent.search(manuSamsung1) > -1 || 8214 uagent.search(manuSonyEricsson) > -1 || 8215 uagent.search(manuericsson) > -1) 8216 return true; 8217 8218 if (uagent.search(svcDocomo) > -1) 8219 return true; 8220 if (uagent.search(svcKddi) > -1) 8221 return true; 8222 if (uagent.search(svcVodafone) > -1) 8223 return true; 8224 8225 8226 return false; 8227}; 8228 8229 8230//***************************** 8231// For Mobile Web Site Design 8232//***************************** 8233 8234//************************** 8235// The quick way to detect for a tier of devices. 8236// This method detects for devices which can 8237// display iPhone-optimized web content. 8238// Includes iPhone, iPod Touch, Android, WebOS, etc. 8239function DetectTierIphone() 8240{ 8241 if (DetectIphoneOrIpod()) 8242 return true; 8243 if (DetectAndroid()) 8244 return true; 8245 if (DetectAndroidWebKit()) 8246 return true; 8247 if (DetectWindowsPhone7()) 8248 return true; 8249 if (DetectBlackBerryWebKit()) 8250 return true; 8251 if (DetectPalmWebOS()) 8252 return true; 8253 if (DetectGarminNuvifone()) 8254 return true; 8255 if (DetectMaemoTablet()) 8256 return true; 8257 else 8258 return false;
8259}; 8260 8261//************************** 8262// The quick way to detect for a tier of devices. 8263// This method detects for devices which are likely to be 8264// capable of viewing CSS content optimized for the iPhone, 8265// but may not necessarily support JavaScript. 8266// Excludes all iPhone Tier devices. 8267function DetectTierRichCss() 8268{ 8269 if (DetectMobileQuick()) 8270 { 8271 if (DetectTierIphone()) 8272 return false; 8273 8274 //The following devices are explicitly ok. 8275 if (DetectWebkit()) 8276 return true; 8277 if (DetectS60OssBrowser()) 8278 return true; 8279 8280 //Note: 'High' BlackBerry devices ONLY 8281 if (DetectBlackBerryHigh()) 8282 return true; 8283 8284 if (DetectWindowsMobile()) 8285 return true; 8286 8287 if (uagent.search(engineTelecaQ) > -1) 8288 return true; 8289 8290 else 8291 return false; 8292 } 8293 else 8294 return false; 8295}; 8296 8297//************************** 8298// The quick way to detect for a tier of devices. 8299// This method detects for all other types of phones, 8300// but excludes the iPhone and RichCSS Tier devices. 8301// NOTE: This method probably won't work due to poor 8302// support for JavaScript among other devices. 8303function DetectTierOtherPhones() 8304{ 8305 if (DetectMobileLong()) 8306 { 8307 //Exclude devices in the other 2 categories 8308 if (DetectTierIphone()) 8309 return false; 8310 if (DetectTierRichCss()) 8311 return false; 8312 8313 //Otherwise, it's a YES 8314 else 8315 return true; 8316 } 8317 else 8318 return false; 8319};; 8320 8321 8322var Tagger = function(el,options){ 8323 defaultOptions = { 8324 'title' : false, 8325 'description' : false, 8326 'transImage' : 'application/modules/Core/externals/images/trans.gif', 8327 'existingTags' : [], 8328 'tagListElement' : false, 8329 'linkElement' : false, 8330 'noTextTagHref' : true, 8331 'guid' : false, 8332 'enableCreate' : false, 8333 'enableDelete' : false, 8334 'createRequestOptions' : { 8335 'url' : '', 8336 'data' : { 8337 'format' : 'json' 8338 } 8339 }, 8340 'deleteRequestOptions' : { 8341 'url' : '', 8342 'data' : { 8343 'format' : 'json' 8344 } 8345 }, 8346 // Cropper options 8347 'cropOptions' : { 8348 'preset' : [10,10,58,58], 8349 'min' : [48,48], 8350 'max' : [128,128], 8351 'handleSize' : 8, 8352 'opacity' : .6, 8353 'color' : '#7389AE', 8354 'border' : 'externals/moolasso/crop.gif' 8355 }, 8356 8357 // Autosuggest options 8358 'suggestProto' : 'local', 8359 'suggestParam' : [ 8360 8361 ], 8362 'suggestOptions' : { 8363 'minLength': 0, 8364 'maxChoices' : 100, 8365 'delay' : 250, 8366 'selectMode': 'pick', 8367 //'autocompleteType': 'message', 8368 'multiple': false, 8369 'className': 'message-autosuggest', 8370 'filterSubset' : true, 8371 'tokenFormat' : 'object', 8372 'tokenValueKey' : 'label', 8373 'injectChoice': function(){}, 8374 'onPush' : function(){}, 8375 8376 'prefetchOnInit' : true, 8377 'alwaysOpen' : true, 8378 'ignoreKeys' : true 8379 } 8380 }; 8381 8382 this.options = scriptJquery.extend(true,{},defaultOptions, options); 8383 el = scriptJquery(el); 8384 if(el.prop("tagName") != 'IMG' ) { 8385 this.image = el.find('img:first'); 8386 } else { 8387 this.image = el; 8388 } 8389 this.element = el; 8390 this.count = 0; 8391 this.initialize = function(){ 8392 try{ 8393 this.options.existingTags.forEach((params)=>{ 8394 this.addTag(params); 8395 }); 8396 } catch(error){ console.log(error); } 8397 } 8398 this.begin = function() { 8399 if( !this.options.enableCreate ) return; 8400 this.getForm(); 8401 this.getSuggest(); 8402 this.element.click(this.makeTagForm.bind(this)); 8403 this.onMove({y:78,x:78,w:48,h:48}); 8404 if(this.input.hasClass("ui-draggable")){ 8405 this.input.trigger("drag"); 8406 } 8407 } 8408 this.end = function() { 8409 if( this.form ) { 8410 this.form.remove(); 8411 delete this.form; 8412 } 8413 if( this.suggest ) { 8414 delete this.suggest; 8415 } 8416 } 8417 this.makeTagForm = function(e){ 8418 var imgtag = scriptJquery(e.target); 8419 if(imgtag.closest("#tagger_form").length){ 8420 return false; 8421 } 8422 var mouseX = ( e.pageX - imgtag.offset().left ) - 50; 8423 var mouseY = ( e.pageY - imgtag.offset().top ) - 50; 8424 //this.onMove({y:parseInt(mouseY),x:parseInt(mouseX),w:48,h:48}); 8425 //imgtag.parent().find('#tagger_form').css({position:"absolute"}); 8426 } 8427 this.getForm = function() { 8428 if( !this.form ) { 8429 this.form = scriptJquery.crtEle('div', { 8430 'id' : 'tagger_form', 8431 'class' : 'tagger_form', 8432 }).css({ 8433 'position' : 'absolute', 8434 'z-index' : '10000', 8435 'width' : '150px' 8436 //'height' : '300px' 8437 }).appendTo(this.element); 8438 8439 scriptJquery.crtEle('div', { 8440 'class' : 'box_area' 8441 }).appendTo(this.form); 8442 8443 // Title 8444 if( this.options.title ) { 8445 scriptJquery.crtEle('div', { 8446 'class' : 'media_photo_tagform_titlebar' 8447 }).html(this.options.title).appendTo(this.form); 8448 } 8449 8450 // Container 8451 this.formContainer = scriptJquery.crtEle('div', { 8452 'class' : 'media_photo_tagform_container' 8453 }).appendTo(this.form); 8454 8455 // Description 8456 if( this.options.description ) { 8457 scriptJquery.crtEle('div', { 8458 'class' : 'media_photo_tagform_text', 8459 }).html(this.options.description).appendTo(this.formContainer); 8460 } 8461
8462 // Input 8463 this.input = scriptJquery.crtEle('input', { 8464 'id' : 'tagger_input', 8465 'class' : 'tagger_input', 8466 'type' : 'text', 8467 }).appendTo(this.formContainer); 8468 8469 // Choices 8470 this.choices = scriptJquery.crtEle('div', { 8471 'class' : 'tagger_list' 8472 }).appendTo(this.formContainer); 8473 8474 // Submit container 8475 var submitContainer = scriptJquery.crtEle('div', { 8476 'class' : 'media_photo_tagform_submits' 8477 }).appendTo(this.formContainer); 8478 8479 var self = this; 8480 // var tag_save = scriptJquery.crtEle('a', { 8481 // 'id' : 'tag_save', 8482 // 'href' : 'javascript:void(0);', 8483 // }).html(en4.core.language.translate('Save')).appendTo(submitContainer); 8484 8485 // tag_save.click(function() { 8486 // var data = {}; 8487 // data.label = self.input.value; 8488 // if( $type(data.label) && data.label != '' ) { 8489 // data.extra = self.coords; 8490 // self.createTag(data); 8491 // } 8492 // }); 8493 var tag_cancel = scriptJquery.crtEle('a', { 8494 'id' : 'tag_cancel', 8495 'href' : 'javascript:void(0);', 8496 }).html(en4.core.language.translate('Cancel')).appendTo(submitContainer); 8497 tag_cancel.click(function() { 8498 this.end(); 8499 }.bind(self)); 8500 this.form.css({ top:0, left:0,position:"absolute"}); 8501 this.input.focus(); 8502 this.draggable(this.form); 8503 } 8504 return this.form; 8505 } 8506 8507 this.draggable = function(element){ 8508 var self = this; 8509 var draggableOptions = { 8510 zIndex: 10000, 8511 drag: function(event, ui) { 8512 var newTop = ui.position.top; 8513 var newLeft = ui.position.left; 8514 newTop = self.image.height() < newTop ? self.image.height()-48 : (newTop < 1 ? 1 : newTop); 8515 newLeft = self.image.width() < newLeft ? self.image.width()-48 : (newLeft < 1 ? 1 : newLeft); 8516 ui.position.top = newTop; 8517 ui.position.left = newLeft; 8518 self.coords = {y:parseInt(newTop),x:parseInt(newLeft),w:48,h:48} 8519 }, 8520 }; 8521 element.draggable(draggableOptions); 8522 } 8523 this.cache = {}; 8524 this.getSuggest = function() { 8525 if(!this.suggest ) { 8526 var self = this; 8527 var options = { 8528 disabledSuggest: true, 8529 select: function(event, ui) { 8530 var data = ui.item; 8531 data.extra = self.coords; 8532 let tagexisted = self.options.existingTags.find((item)=> { 8533 return item.guid == token.guid; 8534 }); 8535 if (tagexisted) { 8536 return false; 8537 } 8538 self.createTag(data); 8539 self.options.existingTags.push(data); 8540 }, 8541 response: function(event, ui ) { 8542 self.choices.html(""); 8543 if(typeof ui.content === "undefined"){ 8544 return false; 8545 } 8546 ui.content.forEach((token)=>{ 8547 let tagexisted = self.options.existingTags.find((item)=> { 8548 return item.guid == token.guid; 8549 }); 8550 if (tagexisted) { 8551 return false; 8552 } 8553 8554 var choice = scriptJquery.crtEle('li', { 8555 'class': 'autocompleter-choices', 8556 //'value': token.id, 8557 'id': token.guid 8558 }).appendTo(token.photo); 8559 8560 if(token.photo) { 8561 scriptJquery.crtEle('div', { 8562 'class' : 'autocompleter-choice' 8563 }).html(token.photo).appendTo(choice); 8564 } 8565 8566 scriptJquery.crtEle('div', { 8567 'class' : 'autocompleter-choice' 8568 }).html(token.label).appendTo(choice); 8569 8570 scriptJquery.crtEle('input', { 8571 'type' : 'hidden', 8572 'value' : JSON.stringify(token) 8573 }).appendTo(choice); 8574 choice.data('autocompleteChoice', token); 8575 choice.click(self.createTag.bind(self,token)); 8576 choice.appendTo(self.choices); 8577 }); 8578 }, 8579 close: function(event, ui ) { 8580 scriptJquery("#tagfriends").val(""); 8581 }, 8582 }; 8583 if( this.options.suggestProto == 'local' ) { 8584 options['source'] = this.options.suggestParam; 8585 this.suggest = this.input.autocomplete(options); 8586 } else if( this.options.suggestProto == 'request.json' ) { 8587 options['source'] = function (request, response) {
8588 if(self.cache[request.term]){ 8589 response(self.cache[request.term]); 8590 } else { 8591 scriptJquery.ajax({ 8592 url: self.options.suggestParam, 8593 data: { value: request.term.replace('initial_autocomplete','') }, 8594 success: function (transformed) { 8595 response(transformed); 8596 self.cache[request.term] = transformed; 8597 }, 8598 error: function () { 8599 response([]); 8600 } 8601 }); 8602 } 8603 }; 8604 this.suggest = this.input.autocomplete(options); 8605 } 8606 } 8607 this.input.autocomplete('search','initial_autocomplete'); 8608 scriptJquery('.ui-autocomplete').remove(); 8609 return this.suggest; 8610 } 8611 this.getTagList = function() { 8612 if( !this.tagList ) { 8613 if( !this.options.tagListElement ) { 8614 this.tagList = scriptJquery.crtEle('div', { 8615 'class' : 'tag_list' 8616 }).appendTo(this.element); 8617 } else { 8618 this.tagList = scriptJquery(this.options.tagListElement); 8619 } 8620 } 8621 return this.tagList; 8622 } 8623 this.onMove = function(coords) { 8624 this.coords = coords; 8625 var pos = {x:0,y:0}; //this.element.getPosition(); 8626 var form = this.getForm(); 8627 form.css({ 8628 'top' : pos.y + coords.h + 20, 8629 'left' : pos.x + coords.x + coords.w + 20 8630 }); 8631 } 8632 8633 // Tagging stuff 8634 this.addTag = function(params) { 8635 // Required: id, text, x, y, w, h 8636 if ( 'object' != $type(params) ) { 8637 //alert('This entry has already been tagged.'); 8638 return; 8639 } 8640 if (params.extra === null) { 8641 return; 8642 } 8643 var baseX = 0, baseY = 0, baseW = 0, baseH = 0; 8644 ["x", "y", "w", "h"].forEach(function([key,value]) { 8645 params.extra[key] = parseInt(params.extra[key]); 8646 }); 8647 8648 if( this.options.noTextTagHref && params.tag_type == 'core_tag' ) { 8649 delete params.href; 8650 } 8651 var self = this; 8652 // Make tag 8653 var tag = scriptJquery.crtEle('div', { 8654 'id' : 'tag_' + params.id, 8655 'class' : 'tag_div' 8656 }).css({ 8657 'position' : 'absolute', 8658 'width' : params.extra.w, 8659 'height' : params.extra.h, 8660 'top' : baseY + params.extra.y, 8661 'left' : baseX + params.extra.x 8662 }).html('<img src="'+this.options.transImage+'" width="100%" height="100%" />').appendTo(this.element); 8663 8664 tag.mouseover(function() { 8665 self.showTag(params.id); 8666 }.bind(self)).mouseout(function() { 8667 self.hideTag(params.id); 8668 }.bind(self)); 8669 8670 // Make label 8671 // Note: we need to use visibility hidden to position correctly in IE 8672 var label = scriptJquery.crtEle("span", { 8673 'id' : 'tag_label_' + params.id, 8674 'class' : 'tag_label' 8675 }).css({'position' : 'absolute'}).html(params.text).appendTo(this.element); 8676 8677 var labelPos = {}; 8678 labelPos.top = ( baseY + params.extra.y + tag.height()); 8679 labelPos.left = Math.round( ( baseX + params.extra.x ) + ( tag.width() / 2 ) - (label.width() / 2) ); 8680 8681 if( this.element.height() < parseInt(labelPos.top) + 20 ){ 8682 labelPos.top = baseY + params.extra.y - label.height(); 8683 } 8684 label.css(labelPos); 8685 8686 this.hideTag(params.id); 8687 8688 var isFirst = ( !$type(this.count) || this.count == 0 ); 8689 this.getTagList().css('display', ''); 8690 8691 // Make list 8692 if( !isFirst ) scriptJquery.crtEle('span', { 8693 'id' : 'tag_comma_' + params.id, 8694 'class' : 'tag_comma', 8695 }).html(',').appendTo(this.getTagList()); 8696 8697 // Make other thingy 8698 var info = scriptJquery.crtEle('span', { 8699 'id' : 'tag_info_' + params.id, 8700 'class' : 'tag_info media_tag_listcontainer' 8701 }).appendTo(this.getTagList()); 8702 8703 var activator = scriptJquery.crtEle('a', { 8704 'id' : 'tag_activator_' + params.id, 8705 'class' : 'tag_activator', 8706 'href' : params.href || null, 8707 }).html(params.text).appendTo(info); 8708 8709 activator.mouseover(function() { 8710 self.showTag(params.id); 8711 }.bind(self)).mouseout(function() { 8712 self.hideTag(params.id); 8713 }.bind(self)); 8714 8715 // Delete 8716 if(this.checkCanRemove(params.id)) 8717 { 8718 info.append(' ('); 8719 var destroyer = scriptJquery.crtEle('a', { 8720 'id' : 'tag_destroyer_' + params.id, 8721 'class' : 'tag_destroyer albums_tag_delete', 8722 'href' : 'javascript:void(0);', 8723 }).html(en4.core.language.translate('delete')).click(function() { 8724 this.removeTag(params.id); 8725 }.bind(this)).appendTo(info); 8726 info.append(')'); 8727 } 8728 this.count++; 8729 } 8730 8731 this.createTag = function(params) { 8732 params.extra = this.coords; 8733 if( !this.options.enableCreate ) return; 8734 var request = scriptJquery.ajax({ 8735 url: this.options.createRequestOptions.url, 8736 data: scriptJquery.extend(params,{format : 'json'},this.options.createRequestOptions.data), 8737 method:'post', 8738 dataType: 'json', 8739 success: function (response) { 8740 this.addTag(response); 8741 }.bind(this), 8742 error: function () { 8743 8744 } 8745 }); 8746 // End tagging 8747 this.end(); 8748 } 8749 8750 this.removeTag = function(id) { 8751 if( !this.checkCanRemove(id) ) return; 8752 // Remove from frontend 8753 var next = scriptJquery('#tag_info_' + id).next(); 8754 if( next.length && next.html().trim() == ',' ) next.remove(); 8755 scriptJquery('#tag_' + id).remove(); 8756 scriptJquery('#tag_label_' + id).remove(); 8757 scriptJquery('#tag_info_' + id).remove(); 8758 this.count--; 8759 let self = this; 8760 scriptJquery.ajax({ 8761 url: this.options.deleteRequestOptions.url, 8762 data: scriptJquery.extend({ 8763 'tagmap_id' : id 8764 },{format : 'json'},this.options.createRequestOptions.data), 8765 method:'post', 8766 dataType: 'json', 8767 success: function (response) {
8768 self.options.existingTags.forEach((datum,i)=>{ 8769 if( datum.tagmap_id == id ) { 8770 self.options.existingTags.splice(i,1); 8771 } 8772 }); 8773 }, 8774 error: function () { 8775 } 8776 }); 8777 } 8778 this.checkCanRemove = function(id) { 8779 // Check if can remove 8780 var tagData; 8781 this.options.existingTags.forEach(function(datum) { 8782 if( datum.tagmap_id == id ) { 8783 tagData = datum; 8784 } 8785 }); 8786 if(this.options.enableDelete) return true; 8787 if(tagData) { 8788 if( tagData.tag_type + '_' + tagData.tag_id == this.options.guid ) return true; 8789 if( tagData.tagger_type + '_' + tagData.tagger_id == this.options.guid ) return true; 8790 } 8791 return false; 8792 } 8793 8794 this.showTag = function(id) { 8795 scriptJquery('#tag_' + id).removeClass('tag_div_hidden'); 8796 scriptJquery('#tag_label_' + id).removeClass('tag_label_hidden'); 8797 } 8798 8799 this.hideTag = function(id) { 8800 scriptJquery('#tag_' + id).addClass('tag_div_hidden'); 8801 scriptJquery('#tag_label_' + id).addClass('tag_label_hidden'); 8802 } 8803 this.initialize(); 8804}; 8805; 8806 8807 /* 8808 8809Tooltipster 3.2.6 | 2014-07-16 8810A rockin' custom tooltip jQuery plugin 8811 8812Developed by Caleb Jacob under the MIT license http://opensource.org/licenses/MIT 8813 8814THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8815 8816*/ 8817 8818;(function ($, window, document) { 8819 8820 var pluginName = "tooltipster", 8821 defaults = { 8822 animation: 'fade', 8823 arrow: true, 8824 arrowColor: '', 8825 autoClose: true, 8826 content: null, 8827 contentAsHTML: false, 8828 contentCloning: true, 8829 debug: true, 8830 delay: 200, 8831 minWidth: 0, 8832 maxWidth: null, 8833 functionComplete:function(origin,tooltip){}, 8834 functionInit: function(origin, content) {}, 8835 functionBefore: function(origin, continueTooltip) { 8836 continueTooltip(); 8837 }, 8838 functionReady: function(origin, tooltip) {}, 8839 functionAfter: function(origin) {}, 8840 icon: '(?)', 8841 iconCloning: true, 8842 iconDesktop: false, 8843 iconTouch: false, 8844 iconTheme: 'tooltipster-icon', 8845 interactive: false, 8846 interactiveTolerance: 350, 8847 multiple: false, 8848 offsetX: 0, 8849 offsetY: 0, 8850 onlyOne: false, 8851 position: 'top', 8852 positionTracker: false, 8853 speed: 350, 8854 timer: 0, 8855 theme: 'tooltipster-default', 8856 touchDevices: true, 8857 trigger: 'hover', 8858 updateAnimation: true 8859 }; 8860 8861 function Plugin(element, options) { 8862 8863 // list of instance variables 8864 8865 this.bodyOverflowX; 8866 // stack of custom callbacks provided as parameters to API methods 8867 this.callbacks = { 8868 hide: [], 8869 show: [] 8870 }; 8871 this.checkInterval = null; 8872 // this will be the user content shown in the tooltip. A capital "C" is used because there is also a method called content() 8873 this.Content; 8874 // this is the original element which is being applied the tooltipster plugin 8875 this.$el = $(element); 8876 // this will be the element which triggers the appearance of the tooltip on hover/click/custom events. 8877 // it will be the same as this.$el if icons are not used (see in the options), otherwise it will correspond to the created icon 8878 this.$elProxy; 8879 this.elProxyPosition; 8880 this.enabled = true; 8881 this.options = $.extend({}, defaults, options); 8882 this.mouseIsOverProxy = false; 8883 // a unique namespace per instance, for easy selective unbinding 8884 this.namespace = 'tooltipster-'+ Math.round(Math.random()*100000); 8885 // Status (capital S) can be either : appearing, shown, disappearing, hidden 8886 this.Status = 'hidden'; 8887 this.timerHide = null; 8888 this.timerShow = null; 8889 // this will be the tooltip element (jQuery wrapped HTML element) 8890 this.$tooltip; 8891 8892 // for backward compatibility 8893 this.options.iconTheme = this.options.iconTheme.replace('.', ''); 8894 this.options.theme = this.options.theme.replace('.', ''); 8895
8896 // launch 8897 8898 this._init(); 8899 } 8900 8901 Plugin.prototype = { 8902 8903 _init: function() { 8904 8905 var self = this; 8906 8907 // disable the plugin on old browsers (including IE7 and lower) 8908 if (document.querySelector) { 8909 8910 // note : the content is null (empty) by default and can stay that way if the plugin remains initialized but not fed any content. The tooltip will just not appear. 8911 8912 // if content is provided in the options, its has precedence over the title attribute. Remark : an empty string is considered content, only 'null' represents the absence of content. 8913 if (self.options.content !== null){ 8914 self._content_set(self.options.content); 8915 } 8916 else { 8917 // the same remark as above applies : empty strings (like title="") are considered content and will be shown. Do not define any attribute at all if you want to initialize the plugin without content at start. 8918 var t = self.$el.attr('title'); 8919 if(typeof t === 'undefined') t = null; 8920 8921 self._content_set(t); 8922 } 8923 8924 var c = self.options.functionInit.call(self.$el, self.$el, self.Content); 8925 if(typeof c !== 'undefined') self._content_set(c); 8926 8927 self.$el 8928 // strip the title off of the element to prevent the default tooltips from popping up 8929 .removeAttr('title') 8930 // to be able to find all instances on the page later (upon window events in particular) 8931 .addClass('tooltipstered'); 8932 8933 // detect if we're changing the tooltip origin to an icon 8934 // note about this condition : if the device has touch capability and self.options.iconTouch is false, you'll have no icons event though you may consider your device as a desktop if it also has a mouse. Not sure why someone would have this use case though. 8935 if ((!deviceHasTouchCapability && self.options.iconDesktop) || (deviceHasTouchCapability && self.options.iconTouch)) { 8936 8937 // TODO : the tooltip should be automatically be given an absolute position to be near the origin. Otherwise, when the origin is floating or what, it's going to be nowhere near it and disturb the position flow of the page elements. It will imply that the icon also detects when its origin moves, to follow it : not trivial. 8938 // Until it's done, the icon feature does not really make sense since the user still has most of the work to do by himself 8939 8940 // if the icon provided is in the form of a string 8941 if(typeof self.options.icon === 'string'){ 8942 // wrap it in a span with the icon class 8943 self.$elProxy = $('<span class="'+ self.options.iconTheme +'"></span>'); 8944 self.$elProxy.text(self.options.icon); 8945 } 8946 // if it is an object (sensible choice) 8947 else { 8948 // (deep) clone the object if iconCloning == true, to make sure every instance has its own proxy. We use the icon without wrapping, no need to. We do not give it a class either, as the user will undoubtedly style the object on his own and since our css properties may conflict with his own 8949 if (self.options.iconCloning) self.$elProxy = self.options.icon.clone(true); 8950 else self.$elProxy = self.options.icon; 8951 } 8952 8953 self.$elProxy.insertAfter(self.$el); 8954 } 8955 else { 8956 self.$elProxy = self.$el; 8957 } 8958 8959 // for 'click' and 'hover' triggers : bind on events to open the tooltip. Closing is now handled in _showNow() because of its bindings. 8960 // Notes about touch events : 8961 // - mouseenter, mouseleave and clicks happen even on pure touch devices because they are emulated. deviceIsPureTouch() is a simple attempt to detect them. 8962 // - on hybrid devices, we do not prevent touch gesture from opening tooltips. It would be too complex to differentiate real mouse events from emulated ones. 8963 // - we check deviceIsPureTouch() at each event rather than prior to binding because the situation may change during browsing 8964 if (self.options.trigger == 'hover') { 8965 8966 // these binding are for mouse interaction only 8967 self.$elProxy 8968 .on('mouseenter.'+ self.namespace, function() { 8969 if (!deviceIsPureTouch() || self.options.touchDevices) { 8970 self.mouseIsOverProxy = true; 8971 self._show(); 8972 } 8973 }) 8974 .on('mouseleave.'+ self.namespace, function() { 8975 if (!deviceIsPureTouch() || self.options.touchDevices) { 8976 self.mouseIsOverProxy = false;
8977 } 8978 }); 8979 8980 // for touch interaction only 8981 if (deviceHasTouchCapability && self.options.touchDevices) { 8982 8983 // for touch devices, we immediately display the tooltip because we cannot rely on mouseleave to handle the delay 8984 self.$elProxy.on('touchstart.'+ self.namespace, function() { 8985 self._showNow(); 8986 }); 8987 } 8988 } 8989 else if (self.options.trigger == 'click') { 8990 8991 // note : for touch devices, we do not bind on touchstart, we only rely on the emulated clicks (triggered by taps) 8992 self.$elProxy.on('click.'+ self.namespace, function() { 8993 if (!deviceIsPureTouch() || self.options.touchDevices) { 8994 self._show(); 8995 } 8996 }); 8997 } 8998 } 8999 }, 9000 9001 // this function will schedule the opening of the tooltip after the delay, if there is one 9002 _show: function() { 9003 9004 var self = this; 9005 9006 if (self.Status != 'shown' && self.Status != 'appearing') { 9007 9008 if (self.options.delay) { 9009 self.timerShow = setTimeout(function(){ 9010 9011 // for hover trigger, we check if the mouse is still over the proxy, otherwise we do not show anything 9012 if (self.options.trigger == 'click' || (self.options.trigger == 'hover' && self.mouseIsOverProxy)) { 9013 self._showNow(); 9014 } 9015 }, self.options.delay); 9016 } 9017 else self._showNow(); 9018 } 9019 }, 9020 9021 // this function will open the tooltip right away 9022 _showNow: function(callback) { 9023 9024 var self = this; 9025 9026 // call our constructor custom function before continuing 9027 self.options.functionBefore.call(self.$el, self.$el, function() { 9028 9029 // continue only if the tooltip is enabled and has any content 9030 if (self.enabled && self.Content !== null) { 9031 9032 // save the method callback and cancel hide method callbacks 9033 if (callback) self.callbacks.show.push(callback); 9034 self.callbacks.hide = []; 9035 9036 //get rid of any appearance timer 9037 clearTimeout(self.timerShow); 9038 self.timerShow = null; 9039 clearTimeout(self.timerHide); 9040 self.timerHide = null; 9041 9042 // if we only want one tooltip open at a time, close all auto-closing tooltips currently open and not already disappearing 9043 if (self.options.onlyOne) { 9044 $('.tooltipstered').not(self.$el).each(function(i,el) { 9045 9046 var $el = $(el), 9047 nss = $el.data('tooltipster-ns'); 9048 9049 // iterate on all tooltips of the element 9050 $.each(nss, function(i, ns){ 9051 var instance = $el.data(ns), 9052 // we have to use the public methods here 9053 s = instance.status(), 9054 ac = instance.option('autoClose'); 9055 9056 if (s !== 'hidden' && s !== 'disappearing' && ac) { 9057 instance.hide(); 9058 } 9059 }); 9060 }); 9061 } 9062 9063 var finish = function() { 9064 self.Status = 'shown'; 9065 9066 // trigger any show method custom callbacks and reset them 9067 $.each(self.callbacks.show, function(i,c) { c.call(self.$el); }); 9068 self.callbacks.show = []; 9069 }; 9070 9071 // if this origin already has its tooltip open 9072 if (self.Status !== 'hidden') { 9073 9074 // the timer (if any) will start (or restart) right now 9075 var extraTime = 0; 9076 9077 // if it was disappearing, cancel that 9078 if (self.Status === 'disappearing') { 9079 9080 self.Status = 'appearing'; 9081 9082 if (supportsTransitions()) { 9083 9084 self.$tooltip 9085 .clearQueue() 9086 .removeClass('tooltipster-dying') 9087 .addClass('tooltipster-'+ self.options.animation +'-show'); 9088 9089 if (self.options.speed > 0) self.$tooltip.delay(self.options.speed); 9090 9091 self.$tooltip.queue(finish); 9092 } 9093 else { 9094 // in case the tooltip was currently fading out, bring it back to life 9095 self.$tooltip 9096 .stop() 9097 .fadeIn(finish); 9098 } 9099 } 9100 // if the tooltip is already open, we still need to trigger the method custom callback 9101 else if(self.Status === 'shown') { 9102 finish(); 9103 } 9104 } 9105 // if the tooltip isn't already open, open that sucker up! 9106 else { 9107 9108 self.Status = 'appearing';
9109 9110 // the timer (if any) will start when the tooltip has fully appeared after its transition 9111 var extraTime = self.options.speed; 9112 9113 // disable horizontal scrollbar to keep overflowing tooltips from jacking with it and then restore it to its previous value 9114 self.bodyOverflowX = $('body').css('overflow-x'); 9115 $('body').css('overflow-x', 'hidden'); 9116 9117 // get some other settings related to building the tooltip 9118 var animation = 'tooltipster-' + self.options.animation, 9119 animationSpeed = '-webkit-transition-duration: '+ self.options.speed +'ms; -webkit-animation-duration: '+ self.options.speed +'ms; -moz-transition-duration: '+ self.options.speed +'ms; -moz-animation-duration: '+ self.options.speed +'ms; -o-transition-duration: '+ self.options.speed +'ms; -o-animation-duration: '+ self.options.speed +'ms; -ms-transition-duration: '+ self.options.speed +'ms; -ms-animation-duration: '+ self.options.speed +'ms; transition-duration: '+ self.options.speed +'ms; animation-duration: '+ self.options.speed +'ms;', 9120 minWidth = self.options.minWidth ? 'min-width:'+ Math.round(self.options.minWidth) +'px;' : '', 9121 maxWidth = self.options.maxWidth ? 'max-width:'+ Math.round(self.options.maxWidth) +'px;' : '', 9122 pointerEvents = self.options.interactive ? 'pointer-events: auto;' : ''; 9123 9124 // build the base of our tooltip 9125 self.$tooltip = $('<div class="tooltipster-base '+ self.options.theme +'" style="'+ minWidth +' '+ maxWidth +' '+ pointerEvents +' '+ animationSpeed +'"><div class="tooltipster-content"></div></div>'); 9126 9127 // only add the animation class if the user has a browser that supports animations 9128 if (supportsTransitions()) self.$tooltip.addClass(animation); 9129 9130 // insert the content 9131 self._content_insert(); 9132 9133 // attach 9134 self.$tooltip.appendTo('body'); 9135 9136 // do all the crazy calculations and positioning 9137 self.reposition(); 9138 // call our custom callback since the content of the tooltip is now part of the DOM 9139 self.options.functionReady.call(self.$el, self.$el, self.$tooltip); 9140 9141 // animate in the tooltip 9142 if (supportsTransitions()) { 9143 9144 self.$tooltip.addClass(animation + '-show'); 9145 9146 if(self.options.speed > 0) self.$tooltip.delay(self.options.speed); 9147 9148 self.$tooltip.queue(finish); 9149 } 9150 else { 9151 self.$tooltip.css('display', 'none').fadeIn(self.options.speed, finish); 9152 } 9153 9154 // will check if our tooltip origin is removed while the tooltip is shown 9155 self._interval_set(); 9156 9157 // reposition on scroll (otherwise position:fixed element's tooltips will move away form their origin) and on resize (in case position can/has to be changed) 9158 $(window).on('scroll.'+ self.namespace +' resize.'+ self.namespace, function() { 9159 self.reposition(); 9160 }); 9161 9162 // auto-close bindings 9163 if (self.options.autoClose) { 9164 9165 // in case a listener is already bound for autoclosing (mouse or touch, hover or click), unbind it first 9166 $('body').off('.'+ self.namespace); 9167 9168 // here we'll have to set different sets of bindings for both touch and mouse 9169 if (self.options.trigger == 'hover') { 9170 9171 // if the user touches the body, hide 9172 if (deviceHasTouchCapability) { 9173 // timeout 0 : explanation below in click section 9174 setTimeout(function() { 9175 // we don't want to bind on click here because the initial touchstart event has not yet triggered its click event, which is thus about to happen 9176 $('body').on('touchstart.'+ self.namespace, function() { 9177 self.hide(); 9178 }); 9179 }, 0); 9180 } 9181 9182 // if we have to allow interaction 9183 if (self.options.interactive) { 9184 9185 // touch events inside the tooltip must not close it 9186 if (deviceHasTouchCapability) { 9187 self.$tooltip.on('touchstart.'+ self.namespace, function(event) { 9188 event.stopPropagation(); 9189 }); 9190 } 9191 9192 // as for mouse interaction, we get rid of the tooltip only after the mouse has spent some time out of it 9193 var tolerance = null; 9194 9195 self.$elProxy.add(self.$tooltip) 9196 // hide after some time out of the proxy and the tooltip 9197 .on('mouseleave.'+ self.namespace + '-autoClose', function() { 9198 clearTimeout(tolerance); 9199 tolerance = setTimeout(function(){ 9200 self.hide(); 9201 }, self.options.interactiveTolerance); 9202 }) 9203 // suspend timeout when the mouse is over the proxy or the tooltip 9204 .on('mouseenter.'+ self.namespace + '-autoClose', function() { 9205 clearTimeout(tolerance); 9206 }); 9207 } 9208 // if this is a non-interactive tooltip, get rid of it if the mouse leaves 9209 else { 9210 self.$elProxy.on('mouseleave.'+ self.namespace + '-autoClose', function() { 9211 self.hide(); 9212 }); 9213 } 9214 } 9215 // here we'll set the same bindings for both clicks and touch on the body to hide the tooltip 9216 else if(self.options.trigger == 'click'){ 9217 9218 // use a timeout to prevent immediate closing if the method was called on a click event and if options.delay == 0 (because of bubbling) 9219 setTimeout(function() { 9220 $('body').on('click.'+ self.namespace +' touchstart.'+ self.namespace, function() { 9221 self.hide(); 9222 }); 9223 }, 0); 9224 9225 // if interactive, we'll stop the events that were emitted from inside the tooltip to stop autoClosing 9226 if (self.options.interactive) { 9227 9228 // note : the touch events will just not be used if the plugin is not enabled on touch devices 9229 self.$tooltip.on('click.'+ self.namespace +' touchstart.'+ self.namespace, function(event) { 9230 event.stopPropagation(); 9231 }); 9232 } 9233 } 9234 } 9235 } 9236 9237 // if we have a timer set, let the countdown begin 9238 if (self.options.timer > 0) { 9239 9240 self.timerHide = setTimeout(function() { 9241 self.timerHide = null; 9242 self.hide(); 9243 }, self.options.timer + extraTime); 9244 } 9245 9246 9247 self.options.functionComplete.call(self.$el, self.$el, self.$tooltip); 9248 } 9249 }); 9250 }, 9251 9252 _interval_set: function() { 9253 9254 var self = this; 9255 9256 self.checkInterval = setInterval(function() { 9257 9258 // if the tooltip and/or its interval should be stopped 9259 if ( 9260 // if the origin has been removed 9261 $('body').find(self.$el).length === 0 9262 // if the elProxy has been removed 9263 || $('body').find(self.$elProxy).length === 0 9264 // if the tooltip has been closed 9265 || self.Status == 'hidden' 9266 // if the tooltip has somehow been removed 9267 || $('body').find(self.$tooltip).length === 0 9268 ) { 9269 // remove the tooltip if it's still here 9270 if (self.Status == 'shown' || self.Status == 'appearing') self.hide(); 9271 9272 // clear this interval as it is no longer necessary 9273 self._interval_cancel(); 9274 } 9275 // if everything is alright 9276 else { 9277 // compare the former and current positions of the elProxy to reposition the tooltip if need be 9278 if(self.options.positionTracker){ 9279 9280 var p = self._repositionInfo(self.$elProxy), 9281 identical = false;
9282 9283 // compare size first (a change requires repositioning too) 9284 if(areEqual(p.dimension, self.elProxyPosition.dimension)){ 9285 9286 // for elements with a fixed position, we track the top and left properties (relative to window) 9287 if(self.$elProxy.css('position') === 'fixed'){ 9288 if(areEqual(p.position, self.elProxyPosition.position)) identical = true; 9289 } 9290 // otherwise, track total offset (relative to document) 9291 else { 9292 if(areEqual(p.offset, self.elProxyPosition.offset)) identical = true; 9293 } 9294 } 9295 9296 if(!identical){ 9297 self.reposition(); 9298 } 9299 } 9300 } 9301 }, 200); 9302 }, 9303 9304 _interval_cancel: function() { 9305 clearInterval(this.checkInterval); 9306 // clean delete 9307 this.checkInterval = null; 9308 }, 9309 9310 _content_set: function(content) { 9311 // clone if asked. Cloning the object makes sure that each instance has its own version of the content (in case a same object were provided for several instances) 9312 // reminder : typeof null === object 9313 if (typeof content === 'object' && content !== null && this.options.contentCloning) { 9314 content = content.clone(true); 9315 } 9316 this.Content = content; 9317 }, 9318 9319 _content_insert: function() { 9320 9321 var self = this, 9322 $d = this.$tooltip.find('.tooltipster-content'); 9323 9324 if (typeof self.Content === 'string' && !self.options.contentAsHTML) { 9325 $d.text(self.Content); 9326 } 9327 else { 9328 $d 9329 .empty() 9330 .append(self.Content); 9331 } 9332 }, 9333 9334 _update: function(content) { 9335 9336 var self = this; 9337 9338 // change the content 9339 self._content_set(content); 9340 9341 if (self.Content !== null) { 9342 9343 // update the tooltip if it is open 9344 if (self.Status !== 'hidden') { 9345 9346 // reset the content in the tooltip 9347 self._content_insert(); 9348 9349 // reposition and resize the tooltip 9350 self.reposition(); 9351 9352 // if we want to play a little animation showing the content changed 9353 if (self.options.updateAnimation) { 9354 9355 if (supportsTransitions()) { 9356 9357 self.$tooltip.css({ 9358 'width': '', 9359 '-webkit-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms', 9360 '-moz-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms', 9361 '-o-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms', 9362 '-ms-transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms', 9363 'transition': 'all ' + self.options.speed + 'ms, width 0ms, height 0ms, left 0ms, top 0ms' 9364 }).addClass('tooltipster-content-changing'); 9365 9366 // reset the CSS transitions and finish the change animation 9367 setTimeout(function() { 9368 9369 if(self.Status != 'hidden'){ 9370 9371 self.$tooltip.removeClass('tooltipster-content-changing'); 9372 9373 // after the changing animation has completed, reset the CSS transitions 9374 setTimeout(function() { 9375 9376 if(self.Status !== 'hidden'){ 9377 self.$tooltip.css({ 9378 '-webkit-transition': self.options.speed + 'ms', 9379 '-moz-transition': self.options.speed + 'ms', 9380 '-o-transition': self.options.speed + 'ms', 9381 '-ms-transition': self.options.speed + 'ms', 9382 'transition': self.options.speed + 'ms' 9383 }); 9384 } 9385 }, self.options.speed); 9386 } 9387 }, self.options.speed); 9388 } 9389 else { 9390 self.$tooltip.fadeTo(self.options.speed, 0.5, function() { 9391 if(self.Status != 'hidden'){ 9392 self.$tooltip.fadeTo(self.options.speed, 1); 9393 } 9394 }); 9395 } 9396 } 9397 } 9398 } 9399 else { 9400 self.hide(); 9401 } 9402 }, 9403 9404 _repositionInfo: function($el) { 9405 return { 9406 dimension: { 9407 height: $el.outerHeight(false), 9408 width: $el.outerWidth(false) 9409 }, 9410 offset: $el.offset(), 9411 position: { 9412 left: parseInt($el.css('left')), 9413 top: parseInt($el.css('top')) 9414 } 9415 }; 9416 }, 9417 9418 hide: function(callback) { 9419 9420 var self = this; 9421 9422 // save the method custom callback and cancel any show method custom callbacks 9423 if (callback) self.callbacks.hide.push(callback); 9424 self.callbacks.show = []; 9425 9426 // get rid of any appearance timeout 9427 clearTimeout(self.timerShow); 9428 self.timerShow = null; 9429 clearTimeout(self.timerHide); 9430 self.timerHide = null; 9431 9432 var finishCallbacks = function() { 9433 // trigger any hide method custom callbacks and reset them 9434 $.each(self.callbacks.hide, function(i,c) { c.call(self.$el); }); 9435 self.callbacks.hide = []; 9436 }; 9437 9438 // hide 9439 if (self.Status == 'shown' || self.Status == 'appearing') { 9440 9441 self.Status = 'disappearing';
9442 9443 var finish = function() { 9444 9445 self.Status = 'hidden'; 9446 9447 // detach our content object first, so the next jQuery's remove() call does not unbind its event handlers 9448 if (typeof self.Content == 'object' && self.Content !== null) { 9449 self.Content.detach(); 9450 } 9451 9452 self.$tooltip.remove(); 9453 self.$tooltip = null; 9454 9455 // unbind orientationchange, scroll and resize listeners 9456 $(window).off('.'+ self.namespace); 9457 9458 $('body') 9459 // unbind any auto-closing click/touch listeners 9460 .off('.'+ self.namespace) 9461 .css('overflow-x', self.bodyOverflowX); 9462 9463 // unbind any auto-closing click/touch listeners 9464 $('body').off('.'+ self.namespace); 9465 9466 // unbind any auto-closing hover listeners 9467 self.$elProxy.off('.'+ self.namespace + '-autoClose'); 9468 9469 // call our constructor custom callback function 9470 self.options.functionAfter.call(self.$el, self.$el); 9471 9472 // call our method custom callbacks functions 9473 finishCallbacks(); 9474 }; 9475 9476 if (supportsTransitions()) { 9477 9478 self.$tooltip 9479 .clearQueue() 9480 .removeClass('tooltipster-' + self.options.animation + '-show') 9481 // for transitions only 9482 .addClass('tooltipster-dying'); 9483 9484 if(self.options.speed > 0) self.$tooltip.delay(self.options.speed); 9485 9486 self.$tooltip.queue(finish); 9487 } 9488 else { 9489 self.$tooltip 9490 .stop() 9491 .fadeOut(self.options.speed, finish); 9492 } 9493 } 9494 // if the tooltip is already hidden, we still need to trigger the method custom callback 9495 else if(self.Status == 'hidden') { 9496 finishCallbacks(); 9497 } 9498 9499 return self; 9500 }, 9501 9502 // the public show() method is actually an alias for the private showNow() method 9503 show: function(callback) { 9504 this._showNow(callback); 9505 return this; 9506 }, 9507 9508 // 'update' is deprecated in favor of 'content' but is kept for backward compatibility 9509 update: function(c) { 9510 return this.content(c); 9511 }, 9512 content: function(c) { 9513 // getter method 9514 if(typeof c === 'undefined'){ 9515 return this.Content; 9516 } 9517 // setter method 9518 else { 9519 this._update(c); 9520 return this; 9521 } 9522 }, 9523 9524 reposition: function() { 9525 9526 var self = this; 9527 9528 // in case the tooltip has been removed from DOM manually 9529 if ($('body').find(self.$tooltip).length !== 0) { 9530 9531 // reset width 9532 self.$tooltip.css('width', ''); 9533 9534 // find variables to determine placement 9535 self.elProxyPosition = self._repositionInfo(self.$elProxy); 9536 var arrowReposition = null, 9537 windowWidth = $(window).width(), 9538 // shorthand 9539 proxy = self.elProxyPosition, 9540 tooltipWidth = self.$tooltip.outerWidth(false), 9541 tooltipInnerWidth = self.$tooltip.innerWidth() + 1, // this +1 stops FireFox from sometimes forcing an additional text line 9542 tooltipHeight = self.$tooltip.outerHeight(false); 9543 9544 // if this is an <area> tag inside a <map>, all hell breaks loose. Recalculate all the measurements based on coordinates 9545 if (self.$elProxy.is('area')) { 9546 var areaShape = self.$elProxy.attr('shape'), 9547 mapName = self.$elProxy.parent().attr('name'), 9548 map = $('img[usemap="#'+ mapName +'"]'), 9549 mapOffsetLeft = map.offset().left, 9550 mapOffsetTop = map.offset().top, 9551 areaMeasurements = self.$elProxy.attr('coords') !== undefined ? self.$elProxy.attr('coords').split(',') : undefined; 9552 9553 if (areaShape == 'circle') { 9554 var areaLeft = parseInt(areaMeasurements[0]), 9555 areaTop = parseInt(areaMeasurements[1]), 9556 areaWidth = parseInt(areaMeasurements[2]); 9557 proxy.dimension.height = areaWidth * 2; 9558 proxy.dimension.width = areaWidth * 2; 9559 proxy.offset.top = mapOffsetTop + areaTop - areaWidth; 9560 proxy.offset.left = mapOffsetLeft + areaLeft - areaWidth; 9561 } 9562 else if (areaShape == 'rect') { 9563 var areaLeft = parseInt(areaMeasurements[0]), 9564 areaTop = parseInt(areaMeasurements[1]), 9565 areaRight = parseInt(areaMeasurements[2]), 9566 areaBottom = parseInt(areaMeasurements[3]); 9567 proxy.dimension.height = areaBottom - areaTop; 9568 proxy.dimension.width = areaRight - areaLeft; 9569 proxy.offset.top = mapOffsetTop + areaTop; 9570 proxy.offset.left = mapOffsetLeft + areaLeft; 9571 } 9572 else if (areaShape == 'poly') { 9573 var areaXs = [], 9574 areaYs = [], 9575 areaSmallestX = 0, 9576 areaSmallestY = 0, 9577 areaGreatestX = 0, 9578 areaGreatestY = 0, 9579 arrayAlternate = 'even'; 9580 9581 for (var i = 0; i < areaMeasurements.length; i++) { 9582 var areaNumber = parseInt(areaMeasurements[i]); 9583 9584 if (arrayAlternate == 'even') { 9585 if (areaNumber > areaGreatestX) { 9586 areaGreatestX = areaNumber; 9587 if (i === 0) { 9588 areaSmallestX = areaGreatestX; 9589 } 9590 } 9591 9592 if (areaNumber < areaSmallestX) { 9593 areaSmallestX = areaNumber; 9594 } 9595 9596 arrayAlternate = 'odd'; 9597 } 9598 else { 9599 if (areaNumber > areaGreatestY) { 9600 areaGreatestY = areaNumber; 9601 if (i == 1) { 9602 areaSmallestY = areaGreatestY; 9603 } 9604 } 9605 9606 if (areaNumber < areaSmallestY) { 9607 areaSmallestY = areaNumber; 9608 } 9609 9610 arrayAlternate = 'even'; 9611 } 9612 } 9613 9614 proxy.dimension.height = areaGreatestY - areaSmallestY; 9615 proxy.dimension.width = areaGreatestX - areaSmallestX; 9616 proxy.offset.top = mapOffsetTop + areaSmallestY; 9617 proxy.offset.left = mapOffsetLeft + areaSmallestX; 9618 } 9619 else { 9620 proxy.dimension.height = map.outerHeight(false); 9621 proxy.dimension.width = map.outerWidth(false); 9622 proxy.offset.top = mapOffsetTop; 9623 proxy.offset.left = mapOffsetLeft; 9624 } 9625 } 9626 9627 // our function and global vars for positioning our tooltip 9628 var myLeft = 0, 9629 myLeftMirror = 0, 9630 myTop = 0, 9631 offsetY = parseInt(self.options.offsetY), 9632 offsetX = parseInt(self.options.offsetX), 9633 // this is the arrow position that will eventually be used. It may differ from the position option if the tooltip cannot be displayed in this position 9634 practicalPosition = self.options.position; 9635 9636 // a function to detect if the tooltip is going off the screen horizontally. If so, reposition the crap out of it! 9637 function dontGoOffScreenX() { 9638 9639 var windowLeft = $(window).scrollLeft(); 9640 9641 // if the tooltip goes off the left side of the screen, line it up with the left side of the window 9642 if((myLeft - windowLeft) < 0) { 9643 arrowReposition = myLeft - windowLeft; 9644 myLeft = windowLeft; 9645 } 9646 9647 // if the tooltip goes off the right of the screen, line it up with the right side of the window 9648 if (((myLeft + tooltipWidth) - windowLeft) > windowWidth) { 9649 arrowReposition = myLeft - ((windowWidth + windowLeft) - tooltipWidth); 9650 myLeft = (windowWidth + windowLeft) - tooltipWidth; 9651 } 9652 } 9653 9654 // a function to detect if the tooltip is going off the screen vertically. If so, switch to the opposite! 9655 function dontGoOffScreenY(switchTo, switchFrom) { 9656 // if it goes off the top off the page 9657 if(((proxy.offset.top - $(window).scrollTop() - tooltipHeight - offsetY - 12) < 0) && (switchFrom.indexOf('top') > -1)) { 9658 practicalPosition = switchTo; 9659 } 9660 9661 // if it goes off the bottom of the page 9662 if (((proxy.offset.top + proxy.dimension.height + tooltipHeight + 12 + offsetY) > ($(window).scrollTop() + $(window).height())) && (switchFrom.indexOf('bottom') > -1)) { 9663 practicalPosition = switchTo; 9664 myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12; 9665 } 9666 } 9667 9668 if(practicalPosition == 'top') { 9669 var leftDifference = (proxy.offset.left + tooltipWidth) - (proxy.offset.left + proxy.dimension.width); 9670 myLeft = (proxy.offset.left + offsetX) - (leftDifference / 2); 9671 myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12; 9672 dontGoOffScreenX(); 9673 dontGoOffScreenY('bottom', 'top'); 9674 } 9675 9676 if(practicalPosition == 'top-left') { 9677 myLeft = proxy.offset.left + offsetX; 9678 myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12; 9679 dontGoOffScreenX(); 9680 dontGoOffScreenY('bottom-left', 'top-left'); 9681 } 9682 9683 if(practicalPosition == 'top-right') { 9684 myLeft = (proxy.offset.left + proxy.dimension.width + offsetX) - tooltipWidth; 9685 myTop = (proxy.offset.top - tooltipHeight) - offsetY - 12; 9686 dontGoOffScreenX(); 9687 dontGoOffScreenY('bottom-right', 'top-right'); 9688 } 9689 9690 if(practicalPosition == 'bottom') { 9691 var leftDifference = (proxy.offset.left + tooltipWidth) - (proxy.offset.left + proxy.dimension.width); 9692 myLeft = proxy.offset.left - (leftDifference / 2) + offsetX; 9693 myTop = (proxy.offset.top + proxy.dimension.height) + offsetY + 12; 9694 dontGoOffScreenX(); 9695 dontGoOffScreenY('top', 'bottom'); 9696 } 9697 9698 if(practicalPosition == 'bottom-left') { 9699 myLeft = proxy.offset.left + offsetX; 9700 myTop = (proxy.offset.top + proxy.dimension.height) + offsetY + 12; 9701 dontGoOffScreenX(); 9702 dontGoOffScreenY('top-left', 'bottom-left'); 9703 } 9704 9705 if(practicalPosition == 'bottom-right') { 9706 myLeft = (proxy.offset.left + proxy.dimension.width + offsetX) - tooltipWidth; 9707 myTop = (proxy.offset.top + proxy.dimension.height) + offsetY + 12; 9708 dontGoOffScreenX(); 9709 dontGoOffScreenY('top-right', 'bottom-right'); 9710 } 9711 9712 if(practicalPosition == 'left') { 9713 myLeft = proxy.offset.left - offsetX - tooltipWidth - 12; 9714 myLeftMirror = proxy.offset.left + offsetX + proxy.dimension.width + 12; 9715 var topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height); 9716 myTop = proxy.offset.top - (topDifference / 2) - offsetY; 9717 9718 // if the tooltip goes off boths sides of the page 9719 if((myLeft < 0) && ((myLeftMirror + tooltipWidth) > windowWidth)) { 9720 var borderWidth = parseFloat(self.$tooltip.css('border-width')) * 2, 9721 newWidth = (tooltipWidth + myLeft) - borderWidth; 9722 self.$tooltip.css('width', newWidth + 'px'); 9723 9724 tooltipHeight = self.$tooltip.outerHeight(false); 9725 myLeft = proxy.offset.left - offsetX - newWidth - 12 - borderWidth; 9726 topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height); 9727 myTop = proxy.offset.top - (topDifference / 2) - offsetY; 9728 } 9729 9730 // if it only goes off one side, flip it to the other side
9731 else if(myLeft < 0) { 9732 myLeft = proxy.offset.left + offsetX + proxy.dimension.width + 12; 9733 arrowReposition = 'left'; 9734 } 9735 } 9736 9737 if(practicalPosition == 'right') { 9738 myLeft = proxy.offset.left + offsetX + proxy.dimension.width + 12; 9739 myLeftMirror = proxy.offset.left - offsetX - tooltipWidth - 12; 9740 var topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height); 9741 myTop = proxy.offset.top - (topDifference / 2) - offsetY; 9742 9743 // if the tooltip goes off boths sides of the page 9744 if(((myLeft + tooltipWidth) > windowWidth) && (myLeftMirror < 0)) { 9745 var borderWidth = parseFloat(self.$tooltip.css('border-width')) * 2, 9746 newWidth = (windowWidth - myLeft) - borderWidth; 9747 self.$tooltip.css('width', newWidth + 'px'); 9748 9749 tooltipHeight = self.$tooltip.outerHeight(false); 9750 topDifference = (proxy.offset.top + tooltipHeight) - (proxy.offset.top + proxy.dimension.height); 9751 myTop = proxy.offset.top - (topDifference / 2) - offsetY; 9752 } 9753 9754 // if it only goes off one side, flip it to the other side 9755 else if((myLeft + tooltipWidth) > windowWidth) { 9756 myLeft = proxy.offset.left - offsetX - tooltipWidth - 12; 9757 arrowReposition = 'right'; 9758 } 9759 } 9760 9761 // if arrow is set true, style it and append it 9762 if (self.options.arrow) { 9763 9764 var arrowClass = 'tooltipster-arrow-' + practicalPosition; 9765 9766 // set color of the arrow 9767 if(self.options.arrowColor.length < 1) { 9768 var arrowColor = self.$tooltip.css('background-color'); 9769 } 9770 else { 9771 var arrowColor = self.options.arrowColor; 9772 } 9773 9774 // if the tooltip was going off the page and had to re-adjust, we need to update the arrow's position 9775 if (!arrowReposition) { 9776 arrowReposition = ''; 9777 } 9778 else if (arrowReposition == 'left') { 9779 arrowClass = 'tooltipster-arrow-right'; 9780 arrowReposition = ''; 9781 } 9782 else if (arrowReposition == 'right') { 9783 arrowClass = 'tooltipster-arrow-left'; 9784 arrowReposition = ''; 9785 } 9786 else { 9787 arrowReposition = 'left:'+ Math.round(arrowReposition) +'px;'; 9788 } 9789 9790 // building the logic to create the border around the arrow of the tooltip 9791 if ((practicalPosition == 'top') || (practicalPosition == 'top-left') || (practicalPosition == 'top-right')) { 9792 var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-bottom-width')), 9793 tooltipBorderColor = self.$tooltip.css('border-bottom-color'); 9794 } 9795 else if ((practicalPosition == 'bottom') || (practicalPosition == 'bottom-left') || (practicalPosition == 'bottom-right')) { 9796 var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-top-width')), 9797 tooltipBorderColor = self.$tooltip.css('border-top-color'); 9798 } 9799 else if (practicalPosition == 'left') { 9800 var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-right-width')), 9801 tooltipBorderColor = self.$tooltip.css('border-right-color'); 9802 } 9803 else if (practicalPosition == 'right') { 9804 var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-left-width')), 9805 tooltipBorderColor = self.$tooltip.css('border-left-color'); 9806 } 9807 else { 9808 var tooltipBorderWidth = parseFloat(self.$tooltip.css('border-bottom-width')), 9809 tooltipBorderColor = self.$tooltip.css('border-bottom-color'); 9810 } 9811 9812 if (tooltipBorderWidth > 1) { 9813 tooltipBorderWidth++; 9814 } 9815 9816 var arrowBorder = ''; 9817 if (tooltipBorderWidth !== 0) { 9818 var arrowBorderSize = '', 9819 arrowBorderColor = 'border-color: '+ tooltipBorderColor +';'; 9820 if (arrowClass.indexOf('bottom') !== -1) { 9821 arrowBorderSize = 'margin-top: -'+ Math.round(tooltipBorderWidth) +'px;'; 9822 } 9823 else if (arrowClass.indexOf('top') !== -1) { 9824 arrowBorderSize = 'margin-bottom: -'+ Math.round(tooltipBorderWidth) +'px;'; 9825 } 9826 else if (arrowClass.indexOf('left') !== -1) { 9827 arrowBorderSize = 'margin-right: -'+ Math.round(tooltipBorderWidth) +'px;'; 9828 } 9829 else if (arrowClass.indexOf('right') !== -1) { 9830 arrowBorderSize = 'margin-left: -'+ Math.round(tooltipBorderWidth) +'px;'; 9831 } 9832 arrowBorder = '<span class="tooltipster-arrow-border" style="'+ arrowBorderSize +' '+ arrowBorderColor +';"></span>'; 9833 } 9834 9835 // if the arrow already exists, remove and replace it 9836 self.$tooltip.find('.tooltipster-arrow').remove(); 9837 9838 // build out the arrow and append it 9839 var arrowConstruct = '<div class="'+ arrowClass +' tooltipster-arrow" style="'+ arrowReposition +'">'+ arrowBorder +'<span style="border-color:'+ arrowColor +';"></span></div>'; 9840 self.$tooltip.append(arrowConstruct); 9841 } 9842 9843 // position the tooltip 9844 self.$tooltip.css({'top': Math.round(myTop) + 'px', 'left': Math.round(myLeft) + 'px'}); 9845 } 9846 9847 return self; 9848 }, 9849 9850 enable: function() { 9851 this.enabled = true; 9852 return this; 9853 }, 9854 9855 disable: function() { 9856 // hide first, in case the tooltip would not disappear on its own (autoClose false) 9857 this.hide(); 9858 this.enabled = false;
9859 return this; 9860 }, 9861 9862 destroy: function() { 9863 9864 var self = this; 9865 9866 self.hide(); 9867 9868 // remove the icon, if any 9869 if(self.$el[0] !== self.$elProxy[0]) self.$elProxy.remove(); 9870 9871 self.$el 9872 .removeData(self.namespace) 9873 .off('.'+ self.namespace); 9874 9875 var ns = self.$el.data('tooltipster-ns'); 9876 9877 // if there are no more tooltips on this element 9878 if(ns.length === 1){ 9879 9880 // old school technique when outerHTML is not supported 9881 var stringifiedContent = (typeof self.Content === 'string') ? self.Content : $('<div></div>').append(self.Content).html(); 9882 9883 self.$el 9884 .removeClass('tooltipstered') 9885 .attr('title', stringifiedContent) 9886 .removeData(self.namespace) 9887 .removeData('tooltipster-ns') 9888 .off('.'+ self.namespace); 9889 } 9890 else { 9891 // remove the instance namespace from the list of namespaces of tooltips present on the element 9892 ns = $.grep(ns, function(el, i){ 9893 return el !== self.namespace; 9894 }); 9895 self.$el.data('tooltipster-ns', ns); 9896 } 9897 9898 return self; 9899 }, 9900 9901 elementIcon: function() { 9902 return (this.$el[0] !== this.$elProxy[0]) ? this.$elProxy[0] : undefined; 9903 }, 9904 9905 elementTooltip: function() { 9906 return this.$tooltip ? this.$tooltip[0] : undefined; 9907 }, 9908 9909 // public methods but for internal use only 9910 // getter if val is ommitted, setter otherwise 9911 option: function(o, val) { 9912 if (typeof val == 'undefined') return this.options[o]; 9913 else { 9914 this.options[o] = val; 9915 return this; 9916 } 9917 }, 9918 status: function() { 9919 return this.Status; 9920 } 9921 }; 9922 9923 $.fn[pluginName] = function () { 9924 9925 // for using in closures 9926 var args = arguments; 9927 9928 // if we are not in the context of jQuery wrapped HTML element(s) : 9929 // this happens when calling static methods in the form $.fn.tooltipster('methodName'), or when calling $(sel).tooltipster('methodName or options') where $(sel) does not match anything 9930 if (this.length === 0) { 9931 9932 // if the first argument is a method name 9933 if (typeof args[0] === 'string') { 9934 9935 var methodIsStatic = true; 9936 9937 // list static methods here (usable by calling $.fn.tooltipster('methodName');) 9938 switch (args[0]) { 9939 9940 case 'setDefaults': 9941 // change default options for all future instances 9942 $.extend(defaults, args[1]); 9943 break; 9944 9945 default: 9946 methodIsStatic = false; 9947 break; 9948 } 9949 9950 // $.fn.tooltipster('methodName') calls will return true 9951 if (methodIsStatic) return true; 9952 // $(sel).tooltipster('methodName') calls will return the list of objects event though it's empty because chaining should work on empty lists 9953 else return this; 9954 } 9955 // the first argument is undefined or an object of options : we are initalizing but there is no element matched by selector 9956 else { 9957 // still chainable : same as above 9958 return this; 9959 } 9960 } 9961 // this happens when calling $(sel).tooltipster('methodName or options') where $(sel) matches one or more elements 9962 else { 9963 9964 // method calls 9965 if (typeof args[0] === 'string') { 9966 9967 var v = '#*$~&'; 9968 9969 this.each(function() { 9970 9971 // retrieve the namepaces of the tooltip(s) that exist on that element. We will interact with the first tooltip only. 9972 var ns = $(this).data('tooltipster-ns'), 9973 // self represents the instance of the first tooltipster plugin associated to the current HTML object of the loop 9974 self = ns ? $(this).data(ns[0]) : null; 9975 9976 // if the current element holds a tooltipster instance 9977 if (self) { 9978 9979 if (typeof self[args[0]] === 'function') { 9980 // note : args[1] and args[2] may not be defined 9981 var resp = self[args[0]](args[1], args[2]); 9982 } 9983 else { 9984 throw new Error('Unknown method .tooltipster("' + args[0] + '")'); 9985 } 9986 9987 // if the function returned anything other than the instance itself (which implies chaining) 9988 if (resp !== self){ 9989 v = resp; 9990 // return false to stop .each iteration on the first element matched by the selector 9991 return false; 9992 } 9993 } 9994 else {
9995 throw new Error('You called Tooltipster\'s "' + args[0] + '" method on an uninitialized element'); 9996 } 9997 }); 9998 9999 return (v !== '#*$~&') ? v : this; 10000 } 10001 // first argument is undefined or an object : the tooltip is initializing 10002 else { 10003 10004 var instances = [], 10005 // is there a defined value for the multiple option in the options object ? 10006 multipleIsSet = args[0] && typeof args[0].multiple !== 'undefined', 10007 // if the multiple option is set to true, or if it's not defined but set to true in the defaults 10008 multiple = (multipleIsSet && args[0].multiple) || (!multipleIsSet && defaults.multiple), 10009 // same for debug 10010 debugIsSet = args[0] && typeof args[0].debug !== 'undefined', 10011 debug = (debugIsSet && args[0].debug) || (!debugIsSet && defaults.debug); 10012 10013 // initialize a tooltipster instance for each element if it doesn't already have one or if the multiple option is set, and attach the object to it 10014 this.each(function () { 10015 10016 var go = false, 10017 ns = $(this).data('tooltipster-ns'), 10018 instance = null; 10019 10020 if (!ns) { 10021 go = true; 10022 } 10023 else if (multiple) { 10024 go = true; 10025 } 10026 else if (debug) { 10027 //console.log('Tooltipster: one or more tooltips are already attached to this element: ignoring. Use the "multiple" option to attach more tooltips.'); 10028 } 10029 10030 if (go) { 10031 instance = new Plugin(this, args[0]); 10032 10033 // save the reference of the new instance 10034 if (!ns) ns = []; 10035 ns.push(instance.namespace); 10036 $(this).data('tooltipster-ns', ns) 10037 10038 // save the instance itself 10039 $(this).data(instance.namespace, instance); 10040 } 10041 10042 instances.push(instance); 10043 }); 10044 10045 if (multiple) return instances; 10046 else return this; 10047 } 10048 } 10049 }; 10050 10051 // quick & dirty compare function (not bijective nor multidimensional) 10052 function areEqual(a,b) { 10053 var same = true; 10054 $.each(a, function(i, el){ 10055 if(typeof b[i] === 'undefined' || a[i] !== b[i]){ 10056 same = false; 10057 return false; 10058 } 10059 }); 10060 return same; 10061 } 10062 10063 // detect if this device can trigger touch events 10064 var deviceHasTouchCapability = !!('ontouchstart' in window); 10065 10066 // we'll assume the device has no mouse until we detect any mouse movement 10067 var deviceHasMouse = false; 10068 $('body').one('mousemove', function() { 10069 deviceHasMouse = true; 10070 }); 10071 10072 function deviceIsPureTouch() { 10073 return (!deviceHasMouse && deviceHasTouchCapability); 10074 } 10075 10076 // detecting support for CSS transitions 10077 function supportsTransitions() { 10078 var b = document.body || document.documentElement, 10079 s = b.style, 10080 p = 'transition'; 10081 10082 if(typeof s[p] == 'string') {return true; } 10083 10084 v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'], 10085 p = p.charAt(0).toUpperCase() + p.substr(1); 10086 for(var i=0; i<v.length; i++) { 10087 if(typeof s[v[i] + p] == 'string') { return true; } 10088 } 10089 return false; 10090 } 10091})( scriptJquery, window, document ); 10092; 10093 10094 var Coverphoto = function(options) { 10095 this.defaultOptions = { 10096 element : null, 10097 buttons : '#cover_photo_options', 10098 photoUrl : '', 10099 positionUrl : '', 10100 position : { 10101 top : 0, 10102 left : 0 10103 } 10104 } 10105 this.block = null; 10106 this.buttons = null; 10107 this.element = null; 10108 this.changeButton = null; 10109 this.saveButton = null; 10110 this.options = scriptJquery.extend(this.defaultOptions,options); 10111 10112 if (this.options.block == null) { 10113 return; 10114 } 10115 this.block = this.options.block; 10116 10117 this.attach = function () { 10118 var self = this; 10119 if (!scriptJquery(this.options.buttons).length) { 10120 return; 10121 } 10122 this.element = self.block.find('.cover_photo:first'); 10123 this.buttons = scriptJquery(this.options.buttons); 10124 this.editButton = this.buttons.find('.edit-button:first'); 10125 this.saveButton = this.buttons.find('.save-button:first'); 10126 if (this.saveButton) { 10127 this.saveButton.find('.save-positions:first').on('click', function () { 10128 self.reposition.save(); 10129 }); 10130 this.saveButton.find('.cancel:first').on('click', function () { 10131 self.reposition.stop(1); 10132 }); 10133 } 10134 } 10135 10136 this.getCoverPhoto = function (canRepostion) { 10137 var self = this; 10138 scriptJquery.ajax({ 10139 method : 'get', 10140 url : self.options.photoUrl, 10141 dataType : 'html', 10142 data : { 10143 format : 'html', 10144 subject : en4.core.subject.guid, 10145 }, 10146 success : function (responseHTML) { 10147 if ( responseHTML.length <= 0) { 10148 return; 10149 } 10150 self.block.html(responseHTML); 10151 Smoothbox.bind(self.block); 10152 self.attach(); 10153 if (canRepostion === 0) { 10154 return; 10155 } 10156 self.options.position = { 10157 top: 0, 10158 left : 0 10159 }; 10160 Smoothbox.close(); 10161 setTimeout(function () { 10162 self.reposition.start() 10163 }, '1000'); 10164 } 10165 }); 10166 }; 10167 this.reposition = { 10168 drag : null, 10169 active : false, 10170 start : function () { 10171 if (this.active) { 10172 return; 10173 } 10174 10175 var self = document.coverPhoto; 10176 var cover = self.getCover(); 10177 this.active = true; 10178 self.getButton().addClass('is_hidden'); 10179 self.buttons.addClass('cover_photo_options'); 10180 self.getButton('save').removeClass('is_hidden'); 10181 self.block.find('.cover_tip_wrap:first').removeClass('is_hidden'); 10182 if(scriptJquery('.cover_photo_profile_information').length) { 10183 scriptJquery('.cover_photo_profile_information').addClass('is_hidden'); 10184 // scriptJquery('.profile_main_photo_wrapper').addClass('is_hidden'); 10185 scriptJquery('.profile_cover_photo').addClass('remove_overlay'); 10186 } 10187 cover.addClass('draggable'); 10188 var content = cover.parent(); 10189 var verticalLimit = parseInt(cover.offsetHeight) - parseInt(content.offsetHeight); 10190 var horizontalLimit = parseInt(cover.offsetWidth) - parseInt(content.offsetWidth); 10191 var limit = { 10192 x:[0, 0], 10193 y:[0, 0] 10194 }; 10195 limit.y = verticalLimit > 0 ? [-verticalLimit, 0] : limit.y; 10196 limit.x = horizontalLimit > 0 ? [-horizontalLimit, 0] : limit.x; 10197 10198 //Drag Photo on cover 10199 scriptJqueryUIMin('#cover_photo_image').dragncrop({instruction: true}); 10200 }, 10201 stop : function() { 10202 var self = document.coverPhoto; 10203 //self.reposition.drag.detach(); 10204 self.getButton('save').addClass('is_hidden'); 10205 //self.block.getElement('.cover_tip_wrap').addClass('is_hidden'); 10206 self.buttons.removeClass('cover_photo_options'); 10207 self.getButton().removeClass('is_hidden'); 10208 10209 if(scriptJquery('.cover_photo_profile_information').length) { 10210 scriptJquery('.cover_photo_profile_information').removeClass('is_hidden'); 10211 // scriptJquery('.profile_main_photo_wrapper').removeClass('is_hidden'); 10212 scriptJquery('.profile_cover_photo').removeClass('remove_overlay'); 10213 } 10214 self.getCover().removeClass('draggable'); 10215 self.reposition.drag = null; 10216 self.reposition.active = false;
10217 }, 10218 save : function () { 10219 if (!this.active) { 10220 return; 10221 } 10222 var self = document.coverPhoto; 10223 var current = this; 10224 self.options.position.top = parseInt(scriptJquery('#cover_photo_image').css('top'), 10); 10225 self.options.position.left = parseInt(scriptJquery('#cover_photo_image').css('left'), 10); 10226 scriptJquery.ajax({ 10227 method : 'get', 10228 url : self.options.positionUrl, 10229 format : 'json', 10230 data : { 10231 'position' : self.options.position 10232 }, 10233 success:function () { 10234 if(scriptJquery('.cover_photo_profile_information').length) { 10235 scriptJquery('.cover_photo_profile_information').removeClass('is_hidden'); 10236 self.reposition.stop(1); 10237 scriptJquery('.dragncrop-instruction').remove(); 10238 } 10239 //current.preventDefault(); 10240 } 10241 }); 10242 } 10243 }; 10244 this.getCover = function (type) { 10245 if (type == 'block') { 10246 return this.block; 10247 } 10248 return this.element; 10249 }; 10250 this.getButton = function (type) { 10251 if (type == 'save') { 10252 return this.saveButton; 10253 } 10254 return this.editButton; 10255 } 10256 this.getCoverPhoto(0); 10257}; 10258 10259var Mainphoto = function(options){ 10260 this.defaultOptions = { 10261 element : null, 10262 buttons : 'mainphoto_options', 10263 photoUrl : '', 10264 showContent : {}, 10265 position : { 10266 top : 0, 10267 left : 0 10268 } 10269 }; 10270 this.block = null; 10271 this.buttons = null; 10272 this.element = null; 10273 this.changeButton = null; 10274 this.saveButton = null; 10275 this.options = scriptJquery.extend(this.defaultOptions,options); 10276 if (this.options.block == null) { 10277 return; 10278 } 10279 this.block = this.options.block; 10280 10281 this.attach = function () { 10282 var self = this; 10283 if(!scriptJquery(this.options.buttons).length){ 10284 return; 10285 } 10286 this.element = self.block.find('.cover_photo:first'); 10287 }; 10288 10289 this.getMainPhoto = function () { 10290 var self = this; 10291 scriptJquery.ajax({ 10292 method : 'get', 10293 url : self.options.photoUrl, 10294 dataType : 'html', 10295 data : { 10296 format : 'html', 10297 subject : en4.core.subject.guid, 10298 }, 10299 success:function (responseHTML) { 10300 if (responseHTML.length <= 0) { 10301 return; 10302 } 10303 self.block.html(responseHTML); 10304 // Smoothbox.bind(self.block); 10305 self.attach(); 10306 // en4.core.runonce.trigger(); 10307 Smoothbox.close(); 10308 } 10309 }); 10310 } 10311 this.getMainPhoto(); 10312}; 10313; 10314 10315 10316Uploader = class { 10317 uploadedFileArray = []; 10318 options = { 10319 uploadLinkClass : '', 10320 uploadLinkTitle : '', 10321 uploadLinkDesc : '', 10322 removePhotoURL: '', 10323 }; 10324 10325 constructor(uploadElement, options) { 10326 this.uploadElement = scriptJquery(uploadElement); 10327 scriptJquery.extend(this.options,options); 10328 this.attachUploadEvent(); 10329 } 10330 10331 attachUploadEvent() { 10332 var self = this; 10333 var FileSize; 10334 var valid = true; 10335 var fileStatusElement = scriptJquery.crtEle('div', { 10336 }).html(self.options.uploadLinkDesc).prependTo(scriptJquery('#file-status')); 10337 10338 scriptJquery.crtEle('a', { 10339 id: "upload_file_link", 10340 class: self.options.uploadLinkClass, 10341 href:"#" 10342 }).html(self.options.uploadLinkTitle).click(function(e) { 10343 e.preventDefault(); 10344 self.uploadElement.trigger("click"); 10345 }).appendTo(scriptJquery('#file-status')); 10346 10347 this.uploadElement.on('change', function () { 10348 var files = scriptJquery(this)[0].files; 10349 var total = files.length; 10350 //Maximum photo upload 10351 if(total > max_photo_upload_limit) { 10352 alert(photo_upload_text); 10353 return; 10354 } 10355 var iteration = 0; 10356 for(var i = 0; i < files.length; i++) { 10357 FileSize = files[i].size / 1024 / 1024; // in MB 10358 if(FileSize > post_max_size) { 10359 valid = false; 10360 continue; 10361 } 10362 iteration++; 10363 self.uploadFile(self.uploadElement,files[i], iteration, total); 10364 } 10365 //if(!valid) alert("The size of the file exceeds the limits set on the server."); 10366 }); 10367 this.uploadElement.on('click', function () { 10368 scriptJquery(this).val(''); 10369 }); 10370 scriptJquery('#remove_all_files').on('click', function () { 10371 scriptJquery('.file-remove').each(function (el) { 10372 self.removeFile(scriptJquery(this)); 10373 }); 10374 scriptJquery('.file-error').each(function (el) { 10375 scriptJquery(this).remove(); 10376 }); 10377 scriptJquery('remove_all_files').hide(); 10378 scriptJquery('uploaded-file-list').hide(); 10379 }); 10380 } 10381 10382 uploadFile(obj, file, iteration, total) { 10383 var self = this; 10384 10385 //Upload file size check 10386 var FileSize = file.size / 1024 / 1024; // in MB 10387 if(FileSize > post_max_size) { 10388 return; 10389 } 10390 10391 //Check image 10392 if(obj.attr('accept').split('/')[0] == 'image') { 10393 if(file.type.split('/')[0] != 'image') { 10394 return self.processUploadError(file['name'] + ' is not an image.'); 10395 } 10396 } 10397 10398 if (this.alreadyUploaded(file)) { 10399 return self.processUploadError(file['name'] + ' already added.'); 10400 } 10401 10402 var url = obj.attr('data-url'); 10403 if (url === '') { 10404 return; 10405 } 10406 10407 var xhr = new XMLHttpRequest(); 10408 var fd = new FormData(); 10409 xhr.open("POST", url, true); 10410 document.getElementById('files-status-overall').style.display = 'block'; 10411 if( document.getElementById('submit-wrapper')) 10412 document.getElementById('submit-wrapper').style.display = 'none'; 10413 xhr.upload.addEventListener('progress', function (e) { 10414 var per = (total <= 1 ? e.loaded/e.total : iteration/total).toFixed(2) * 100; 10415 var overAllFileProgress = -400 + ((per) * 2.5); 10416 scriptJquery('div#files-status-overall img').css('background-position', overAllFileProgress + 'px 0px'); 10417 scriptJquery('div#files-status-overall span').html(per + '%'); 10418 }, false); 10419 10420 xhr.onreadystatechange = function() { 10421 if (xhr.readyState === 4 && xhr.status === 200) { 10422 try { 10423 // Show progress 10424 var res = JSON.parse(xhr.responseText); 10425 } catch (err) { 10426 self.processUploadError('An error occurred.'); 10427 return false;
10428 } 10429 10430 if (res['error'] !== undefined || res['error'] == false) { 10431 self.processUploadError('FAILED (' + res['name'] + ') : ' + res['error']); 10432 return false; 10433 } 10434 self.processResponseData(res); 10435 if (typeof self.processCustomResponse !== "undefined") { 10436 self.processCustomResponse(res); 10437 } 10438 10439 if (iteration === total) { 10440 self.showButton(); 10441 } 10442 } 10443 }; 10444 fd.append('ajax-upload', 'true'); 10445 fd.append(obj.attr('name'), file); 10446 xhr.send(fd); 10447 } 10448 10449 alreadyUploaded(file) { 10450 if (this.uploadedFileArray.length === 0) { 10451 return false; 10452 } 10453 return false; 10454 return this.uploadedFileArray.every(function (uploadedFile) { 10455 return uploadedFile === file.name; 10456 }); 10457 } 10458 10459 processResponseData(response) { 10460 var self = this; 10461 var fancyUploadFileds = scriptJquery('#fancyuploadfileids'); 10462 var currentValue = fancyUploadFileds.attr('value'); 10463 currentValue += response['id'] + ' '; 10464 10465 fancyUploadFileds.val(currentValue); 10466 this.uploadedFileArray[response['id']] = response['fileName']; 10467 var uploadedFileList = scriptJquery("#uploaded-file-list"); 10468 var uploadedFile = scriptJquery.crtEle('li', { 10469 'class': 'file file-success', 10470 }).appendTo(uploadedFileList); 10471 10472 var fileLink = scriptJquery.crtEle('a', { 10473 class: "file-remove", 10474 href: 'javascript:void(0);', 10475 title: 'Click to remove this entry.', 10476 'data-file_id': response['id'], 10477 }).html('<b>Remove</b>').click(function() { 10478 self.removeFile(scriptJquery(this)); 10479 }).appendTo(uploadedFile); 10480 10481 scriptJquery.crtEle('span', { 10482 class: 'file-name', 10483 }).html(response['fileName']).appendTo(uploadedFile); 10484 10485 // If hidden show upload list 10486 if (uploadedFileList.is(":hidden")) { 10487 uploadedFileList.show(); 10488 } 10489 if (scriptJquery('#remove_all_files').is(":hidden")) { 10490 scriptJquery('#remove_all_files').css('display', 'inline'); 10491 } 10492 } 10493 10494 processUploadError(errorMessage) { 10495 var uploadedFileList = scriptJquery("uploaded-file-list"); 10496 var uploadedFile = scriptJquery.crtEle('li', { 10497 'class': 'file file-error', 10498 }).html('<span class="validation-error" title="Click to remove this entry.">' + errorMessage + '</span>').click( 10499 function() { 10500 scriptJquery(this).remove(); 10501 if (scriptJquery('ul#uploaded-file-list li').length === 0) { 10502 scriptJquery('#submit-wrapper').css('display', 'none'); 10503 scriptJquery('#remove_all_files').css('display', 'none'); 10504 scriptJquery('#uploaded-file-list').css('display', 'none'); 10505 } 10506 } 10507 ).prependTo(uploadedFileList); 10508 // If hidden show upload list 10509 if (uploadedFile.is(":hidden")) { 10510 uploadedFileList.show(); 10511 } 10512 scriptJquery('#files-status-overall').css('display', 'none'); 10513 return false; 10514 } 10515 10516 showButton() { 10517 scriptJquery("#submit-wrapper").show(); 10518 scriptJquery('#files-status-overall').css('display', 'none'); 10519 } 10520 10521 removeFile(el) { 10522 var file_id = el.attr('data-file_id'); 10523 10524 if(this.options.removePhotoURL) { 10525 scriptJquery.ajax({ 10526 dataType: 'json', 10527 'url' : this.options.removePhotoURL, 10528 'data': { 10529 'photo_id' : file_id 10530 }, 10531 success : function(responseJSON) { 10532 } 10533 }); 10534 } 10535 10536 delete this.uploadedFileArray[file_id]; 10537 var fancyUploadFileds = scriptJquery('#fancyuploadfileids'); 10538 var currentValue = fancyUploadFileds.val(); 10539 currentValue = currentValue.replace(file_id + ' ', ''); 10540 10541 if (typeof deleteFile !== "undefined") { 10542 deleteFile(el); 10543 } 10544 fancyUploadFileds.val(currentValue); 10545 el.parent().remove(); 10546 if (scriptJquery('ul#uploaded-file-list li').length === 0) { 10547 scriptJquery('#remove_all_files').css('display', 'none'); 10548 scriptJquery('#uploaded-file-list').css('display', 'none'); 10549 document.getElementById("submit-wrapper").style.display = "none"; 10550 } 10551 } 10552}; 10553; 10554 10555 !function(i){"use strict";"function"==typeof define&&define.amd?define(["jquery"],i):"undefined"!=typeof exports?module.exports=i(require("jquery")):i(scriptJquery
10555)}(function(i){"use strict";var e=window.Slick||{};(e=function(){var e=0;return function(t,o){var s,n=this;n.defaults={accessibility:!0,adaptiveHeight:!1,appendArrows:i(t),appendDots:i(t),arrows:!0,asNavFor:null,prevArrow:'<button class="slick-prev" aria-label="Previous" type="button">Previous</button>',nextArrow:'<button class="slick-next" aria-label="Next" type="button">Next</button>',autoplay:!1,autoplaySpeed:3e3,centerMode:!1,centerPadding:"50px",cssEase:"ease",customPaging:function(e,t){return i('<button type="button" />').text(t+1)},dots:!1,dotsClass:"slick-dots",draggable:!0,easing:"linear",edgeFriction:.35,fade:!1,focusOnSelect:!1,focusOnChange:!1,infinite:!0,initialSlide:0,lazyLoad:"ondemand",mobileFirst:!1,pauseOnHover:!0,pauseOnFocus:!0,pauseOnDotsHover:!1,respondTo:"window",responsive:null,rows:1,rtl:!1,slide:"",slidesPerRow:1,slidesToShow:1,slidesToScroll:1,speed:500,swipe:!0,swipeToSlide:!1,touchMove:!0,touchThreshold:5,useCSS:!0,useTransform:!0,variableWidth:!1,vertical:!1,verticalSwiping:!1,waitForAnimate:!0,zIndex:1e3},n.initials={animating:!1,dragging:!1,autoPlayTimer:null,currentDirection:0,currentLeft:null,currentSlide:0,direction:1,$dots:null,listWidth:null,listHeight:null,loadIndex:0,$nextArrow:null,$prevArrow:null,scrolling:!1,slideCount:null,slideWidth:null,$slideTrack:null,$slides:null,sliding:!1,slideOffset:0,swipeLeft:null,swiping:!1,$list:null,touchObject:{},transformsEnabled:!1,unslicked:!1},i.extend(n,n.initials),n.activeBreakpoint=null,n.animType=null,n.animProp=null,n.breakpoints=[],n.breakpointSettings=[],n.cssTransitions=!1,n.focussed=!1,n.interrupted=!1,n.hidden="hidden",n.paused=!0,n.positionProp=null,n.respondTo=null,n.rowCount=1,n.shouldClick=!0,n.$slider=i(t),n.$slidesCache=null,n.transformType=null,n.transitionType=null,n.visibilityChange="visibilitychange",n.windowWidth=0,n.windowTimer=null,s=i(t).data("slick")||{},n.options=i.extend({},n.defaults,o,s),n.currentSlide=n.options.initialSlide,n.originalSettings=n.options,void 0!==document.mozHidden?(n.hidden="mozHidden",n.visibilityChange="mozvisibilitychange"):void 0!==document.webkitHidden&&(n.hidden="webkitHidden",n.visibilityChange="webkitvisibilitychange"),n.autoPlay=i.proxy(n.autoPlay,n),n.autoPlayClear=i.proxy(n.autoPlayClear,n),n.autoPlayIterator=i.proxy(n.autoPlayIterator,n),n.changeSlide=i.proxy(n.changeSlide,n),n.clickHandler=i.proxy(n.clickHandler,n),n.selectHandler=i.proxy(n.selectHandler,n),n.setPosition=i.proxy(n.setPosition,n),n.swipeHandler=i.proxy(n.swipeHandler,n),n.dragHandler=i.proxy(n.dragHandler,n),n.keyHandler=i.proxy(n.keyHandler,n),n.instanceUid=e++,n.htmlExpr=/^(?:\s*(<[\w\W]+>)[^>]*)$/,n.registerBreakpoints(),n.init(!0)}}()).prototype.activateADA=function(){this.$slideTrack.find(".slick-active").attr({"aria-hidden":"false"}).find("a, input, button, select").attr({tabindex:"0"})},e.prototype.addSlide=e.prototype.slickAdd=function(e,t,o){var s=this;if("boolean"==typeof t)o=t,t=null;else if(t<0||t>=s.slideCount)return!1;s.unload(),"number"==typeof t?0===t&&0===s.$slides.length?i(e).appendTo(s.$slideTrack):o?i(e).insertBefore(s.$slides.eq(t)):i(e).insertAfter(s.$slides.eq(t)):!0===o?i(e).prependTo(s.$slideTrack):i(e).appendTo(s.$slideTrack),s.$slides=s.$slideTrack.children(this.options.slide),s.$slideTrack.children(this.options.slide).detach(),s.$slideTrack.append(s.$slides),s.$slides.each(function(e,t){i(t).attr("data-slick-index",e)}),s.$slidesCache=s.$slides,s.reinit()},e.prototype.animateHeight=function(){var i=this;if(1===i.options.slidesToShow&&!0===i.options.adaptiveHeight&&!1===i.options.vertical){var e=i.$slides.eq(i.currentSlide).outerHeight(!0);i.$list.animate({height:e},i.options.speed)}},e.prototype.animateSlide=function(e,t){var o={},s=this;s.animateHeight(),!0===s.options.rtl&&!1===s.options.vertical&&(e=-e),!1===s.transformsEnabled?!1===s.options.vertical?s.$slideTrack.animate({left:e},s.options.speed,s.options.easing,t):s.$slideTrack.animate({top:e},s.options.speed,s.options.easing,t):!1===s.cssTransitions?(!0===s.options.rtl&&(s.currentLeft=-s.currentLeft),i({animStart:s.currentLeft}).animate({animStart:e},{duration:s.options.speed,easing:s.options.easing,step:function(i){i=Math.ceil(i),!1===s.options.vertical?(o[s.animType]="translate("+i+"px, 0px)",s.$slideTrack.css(o)):(o[s.animType]="translate(0px,"+i+"px)",s.$slideTrack.css(o))},complete:function(){t&&t.call()}})):(s.applyTransition(),e=Math.ceil(e),!1===s.options.vertical?o[s.animType]="translate3d("+e+"px, 0px, 0px)":o[s.animType]="translate3d(0px,"+e+"px, 0px)",s.$slideTrack.css(o),t&&setTimeout(function(){s.disableTransition(),t.call()},s.options.speed))},e.prototype.getNavTarget=function(){var e=this,t=e.options.asNavFor;return t&&null!==t&&(t=i(t).not(e.$slider)),t},e.prototype.asNavFor=function(e){var t=this.getNavTarget();null!==t&&"object"==typeof t&&t.each(function(){var t=i(this).slick("getSlick");t.unslicked||t.slideHandler(e,!0)})},e.prototype.applyTransition=function(i){var e=this,t={};!1===e.options.fade?t[e.transitionType]=e.transformType+" "+e.options.speed+"ms "+e.options.cssEase:t[e.transitionType]="opacity "+e.options.speed+"ms "+e.options.cssEase,!1===e.options.fade?e.$slideTrack.css(t):e.$slides.eq(i).css(t)},e.prototype.autoPlay=function(){var i=this;i.autoPlayClear(),i.slideCount>i.options.slidesToShow&&(i.autoPlayTimer=setInterval(i.autoPlayIterator,i.options.autoplaySpeed))},e.prototype.autoPlayClear=function(){var i=this;i.autoPlayTimer&&clearInterval(i.autoPlayTimer)},e.prototype.autoPlayIterator=function(){var i=this,e=i.currentSlide+i.options.slidesToScroll;i.paused||i.interrupted||i.focussed||(!1===i.options.infinite&&(1===i.direction&&i.currentSlide+1===i.slideCount-1?i.direction=0:0===i.direction&&(e=i.currentSlide-i.options.slidesToScroll,i.currentSlide-1==0&&(i.direction=1))),i.slideHandler(e))},e.prototype.buildArrows=function(){var e=this;!0===e.options.arrows&&(e.$prevArrow=i(e.options.prevArrow).addClass("slick-arrow"),e.$nextArrow=i(e.options.nextArrow).addClass("slick-arrow"),e.slideCount>e.options.slidesToShow?(e.$prevArrow.removeClass("slick-hidden").removeAttr("aria-hidden tabindex"),e.$nextArrow.removeClass("slick-hidden").removeAttr("aria-hidden tabindex"),e.htmlExpr.test(e.options.prevArrow)&&e.$prevArrow.prependTo(e.options.appendArrows),e.htmlExpr.test(e.options.nextArrow)&&e.$nextArrow.appendTo(e.options.appendArrows),!0!==e.options.infinite&&e.$prevArrow.addClass("slick-disabled").attr("aria-disabled","true")):e.$prevArrow.add(e.$nextArrow).addClass("slick-hidden").attr({"aria-disabled":"true",tabindex:"-1"}))},e.prototype.buildDots=function(){var e,t,o=this;if(!0===o.options.dots){for(o.$slider.addClass("slick-dotted"),t=i("<ul />").addClass(o.options.dotsClass),e=0;e<=o.getDotCount();e+=1)t.append(i("<li />").append(o.options.customPaging.call(this,o,e)));o.$dots=t.appendTo(o.options.appendDots),o.$dots.find("li").first().addClass("slick-active")}},e.prototype.buildOut=function(){var e=this;e.$slides=e.$slider.children(e.options.slide+":not(.slick-cloned)").addClass("slick-slide"),e.slideCount=e.$slides.length,e.$slides.each(function(e,t){i(t).attr("data-slick-index",e).data("originalStyling",i(t).attr("style")||"")}),e.$slider.addClass("slick-slider"),e.$slideTrack=0===e.slideCount?i('<div class="slick-track"/>').appendTo(e.$slider):e.$slides.wrapAll('<div class="slick-track"/>').parent(),e.$list=e.$slideTrack.wrap('<div class="slick-list"/>').parent(),e.$slideTrack.css("opacity",0),!0!==e.options.centerMode&&!0!==e.options.swipeToSlide||(e.options.slidesToScroll=1),i("img[data-lazy]",e.$slider).not("[src]").addClass("slick-loading"),e.setupInfinite(),e.buildArrows(),e.buildDots(),e.updateDots(),e.setSlideClasses("number"==typeof e.currentSlide?e.currentSlide:0),!0===e.options.draggable&&e.$list.addClass("draggable")},e.prototype.buildRows=function(){var i,e,t,o,s,n,r,l=this;if(o=document.createDocumentFragment(),n=l.$slider.children(),l.o
10555ptions.rows>1){for(r=l.options.slidesPerRow*l.options.rows,s=Math.ceil(n.length/r),i=0;i<s;i++){var d=document.createElement("div");for(e=0;e<l.options.rows;e++){var a=document.createElement("div");for(t=0;t<l.options.slidesPerRow;t++){var c=i*r+(e*l.options.slidesPerRow+t);n.get(c)&&a.appendChild(n.get(c))}d.appendChild(a)}o.appendChild(d)}l.$slider.empty().append(o),l.$slider.children().children().children().css({width:100/l.options.slidesPerRow+"%",display:"inline-block"})}},e.prototype.checkResponsive=function(e,t){var o,s,n,r=this,l=!1,d=r.$slider.width(),a=window.innerWidth||i(window).width();if("window"===r.respondTo?n=a:"slider"===r.respondTo?n=d:"min"===r.respondTo&&(n=Math.min(a,d)),r.options.responsive&&r.options.responsive.length&&null!==r.options.responsive){s=null;for(o in r.breakpoints)r.breakpoints.hasOwnProperty(o)&&(!1===r.originalSettings.mobileFirst?n<r.breakpoints[o]&&(s=r.breakpoints[o]):n>r.breakpoints[o]&&(s=r.breakpoints[o]));null!==s?null!==r.activeBreakpoint?(s!==r.activeBreakpoint||t)&&(r.activeBreakpoint=s,"unslick"===r.breakpointSettings[s]?r.unslick(s):(r.options=i.extend({},r.originalSettings,r.breakpointSettings[s]),!0===e&&(r.currentSlide=r.options.initialSlide),r.refresh(e)),l=s):(r.activeBreakpoint=s,"unslick"===r.breakpointSettings[s]?r.unslick(s):(r.options=i.extend({},r.originalSettings,r.breakpointSettings[s]),!0===e&&(r.currentSlide=r.options.initialSlide),r.refresh(e)),l=s):null!==r.activeBreakpoint&&(r.activeBreakpoint=null,r.options=r.originalSettings,!0===e&&(r.currentSlide=r.options.initialSlide),r.refresh(e),l=s),e||!1===l||r.$slider.trigger("breakpoint",[r,l])}},e.prototype.changeSlide=function(e,t){var o,s,n,r=this,l=i(e.currentTarget);switch(l.is("a")&&e.preventDefault(),l.is("li")||(l=l.closest("li")),n=r.slideCount%r.options.slidesToScroll!=0,o=n?0:(r.slideCount-r.currentSlide)%r.options.slidesToScroll,e.data.message){case"previous":s=0===o?r.options.slidesToScroll:r.options.slidesToShow-o,r.slideCount>r.options.slidesToShow&&r.slideHandler(r.currentSlide-s,!1,t);break;case"next":s=0===o?r.options.slidesToScroll:o,r.slideCount>r.options.slidesToShow&&r.slideHandler(r.currentSlide+s,!1,t);break;case"index":var d=0===e.data.index?0:e.data.index||l.index()*r.options.slidesToScroll;r.slideHandler(r.checkNavigable(d),!1,t),l.children().trigger("focus");break;default:return}},e.prototype.checkNavigable=function(i){var e,t;if(e=this.getNavigableIndexes(),t=0,i>e[e.length-1])i=e[e.length-1];else for(var o in e){if(i<e[o]){i=t;break}t=e[o]}return i},e.prototype.cleanUpEvents=function(){var e=this;e.options.dots&&null!==e.$dots&&(i("li",e.$dots).off("click.slick",e.changeSlide).off("mouseenter.slick",i.proxy(e.interrupt,e,!0)).off("mouseleave.slick",i.proxy(e.interrupt,e,!1)),!0===e.options.accessibility&&e.$dots.off("keydown.slick",e.keyHandler)),e.$slider.off("focus.slick blur.slick"),!0===e.options.arrows&&e.slideCount>e.options.slidesToShow&&(e.$prevArrow&&e.$prevArrow.off("click.slick",e.changeSlide),e.$nextArrow&&e.$nextArrow.off("click.slick",e.changeSlide),!0===e.options.accessibility&&(e.$prevArrow&&e.$prevArrow.off("keydown.slick",e.keyHandler),e.$nextArrow&&e.$nextArrow.off("keydown.slick",e.keyHandler))),e.$list.off("touchstart.slick mousedown.slick",e.swipeHandler),e.$list.off("touchmove.slick mousemove.slick",e.swipeHandler),e.$list.off("touchend.slick mouseup.slick",e.swipeHandler),e.$list.off("touchcancel.slick mouseleave.
10555slick",e.swipeHandler),e.$list.off("click.slick",e.clickHandler),i(document).off(e.visibilityChange,e.visibility),e.cleanUpSlideEvents(),!0===e.options.accessibility&&e.$list.off("keydown.slick",e.keyHandler),!0===e.options.focusOnSelect&&i(e.$slideTrack).children().off("click.slick",e.selectHandler),i(window).off("orientationchange.slick.slick-"+e.instanceUid,e.orientationChange),i(window).off("resize.slick.slick-"+e.instanceUid,e.resize),i("[draggable!=true]",e.$slideTrack).off("dragstart",e.preventDefault),i(window).off("load.slick.slick-"+e.instanceUid,e.setPosition)},e.prototype.cleanUpSlideEvents=function(){var e=this;e.$list.off("mouseenter.slick",i.proxy(e.interrupt,e,!0)),e.$list.off("mouseleave.slick",i.proxy(e.interrupt,e,!1))},e.prototype.cleanUpRows=function(){var i,e=this;e.options.rows>1&&((i=e.$slides.children().children()).removeAttr("style"),e.$slider.empty().append(i))},e.prototype.clickHandler=function(i){!1===this.shouldClick&&(i.stopImmediatePropagation(),i.stopPropagation(),i.preventDefault())},e.prototype.destroy=function(e){var t=this;t.autoPlayClear(),t.touchObject={},t.cleanUpEvents(),i(".slick-cloned",t.$slider).detach(),t.$dots&&t.$dots.remove(),t.$prevArrow&&t.$prevArrow.length&&(t.$prevArrow.removeClass("slick-disabled slick-arrow slick-hidden").removeAttr("aria-hidden aria-disabled tabindex").css("display",""),t.htmlExpr.test(t.options.prevArrow)&&t.$prevArrow.remove()),t.$nextArrow&&t.$nextArrow.length&&(t.$nextArrow.removeClass("slick-disabled slick-arrow slick-hidden").removeAttr("aria-hidden aria-disabled tabindex").css("display",""),t.htmlExpr.test(t.options.nextArrow)&&t.$nextArrow.remove()),t.$slides&&(t.$slides.removeClass("slick-slide slick-active slick-center slick-visible slick-current").removeAttr("aria-hidden").removeAttr("data-slick-index").each(function(){i(this).attr("style",i(this).data("originalStyling"))}),t.$slideTrack.children(this.options.slide).detach(),t.$slideTrack.detach(),t.$list.detach(),t.$slider.append(t.$slides)),t.cleanUpRows(),t.$slider.removeClass("slick-slider"),t.$slider.removeClass("slick-initialized"),t.$slider.removeClass("slick-dotted"),t.unslicked=!0,e||t.$slider.trigger("destroy",[t])},e.prototype.disableTransition=function(i){var e=this,t={};t[e.transitionType]="",!1===e.options.fade?e.$slideTrack.css(t):e.$slides.eq(i).css(t)},e.prototype.fadeSlide=function(i,e){var t=this;!1===t.cssTransitions?(t.$slides.eq(i).css({zIndex:t.options.zIndex}),t.$slides.eq(i).animate({opacity:1},t.options.speed,t.options.easing,e)):(t.applyTransition(i),t.$slides.eq(i).css({opacity:1,zIndex:t.options.zIndex}),e&&setTimeout(function(){t.disableTransition(i),e.call()},t.options.speed))},e.prototype.fadeSlideOut=function(i){var e=this;!1===e.cssTransitions?e.$slides.eq(i).animate({opacity:0,zIndex:e.options.zIndex-2},e.options.speed,e.options.easing):(e.applyTransition(i),e.$slides.eq(i).css({opacity:0,zIndex:e.options.zIndex-2}))},e.prototype.filterSlides=e.prototype.slickFilter=function(i){var e=this;null!==i&&(e.$slidesCache=e.$slides,e.unload(),e.$slideTrack.children(this.options.slide).detach(),e.$slidesCache.filter(i).appendTo(e.$slideTrack),e.reinit())},e.prototype.focusHandler=function(){var e=this;e.$slider.off("focus.slick blur.slick").on("focus.slick blur.slick","*",function(t){t.stopImmediatePropagation();var o=i(this);setTimeout(function(){e.options.pauseOnFocus&&(e.focussed=o.is(":focus"),e.autoPlay())},0)})},e.prototype.getCurrent=e.prototype.slickCurrentSlide=function(){return this.currentSlide},e.prototype.getDotCount=function(){var i=this,e=0,t=0,o=0;if(!0===i.options.infinite)if(i.slideCount<=i.options.slidesToShow)++o;else for(;e<i.slideCount;)++o,e=t+i.options.slidesToScroll,t+=i.options.slidesToScroll<=i.options.slidesToShow?i.options.slidesToScroll:i.options.slidesToShow;else if(!0===i.options.centerMode)o=i.slideCount;else if(i.options.asNavFor)for(;e<i.slideCount;)++o,e=t+i.options.slidesToScroll,t+=i.options.slidesToScroll<=i.options.slidesToShow?i.options.slidesToScroll:i.options.slidesToShow;else o=1+Math.ceil((i.slideCount-i.options.slidesToShow)/i.options.slidesToScroll);return o-1},e.prototype.getLeft=function(i){var e,t,o,s,n=this,r=0;return n.slideOffset=0,t=n.$slides.first().outerHeight(!0),!0===n.options.infinite?(n.slideCount>n.options.slidesToShow&&(n.slideOffset=n.slideWidth*n.options.slidesToShow*-1,s=-1,!0===n.options.vertical&&!0===n.options.centerMode&&(2===n.options.slidesToShow?s=-1.5:1===n.options.slidesToShow&&(s=-2)),r=t*n.options.slidesToShow*s),n.slideCount%n.options.slidesToScroll!=0&&i+n.options.slidesToScroll>n.slideCount&&n.slideCount>n.options.slidesToShow&&(i>n.slideCount?(n.slideOffset=(n.options.slidesToShow-(i-n.slideCount))*n.slideWidth*-1,r=(n.options.slidesToShow-(i-n.slideCount))*t*-1):(n.slideOffset=n.slideCount%n.options.slidesToScroll*n.slideWidth*-1,r=n.slideCount%n.options.slidesToScroll*t*-1))):i+n.options.slidesToShow>n.slideCount&&(n.slideOffset=(i+n.options.slidesToShow-n.slideCount)*n.slideWidth,r=(i+n.options.slidesToShow-n.slideCount)*t),n.slideCount<=n.options.slidesToShow&&(n.slideOffset=0,r=0),!0===n.options.centerMode&&n.slideCount<=n.options.slidesToShow?n.slideOffset=n.slideWidth*Math.floor(n.options.slidesToShow)/2-n.slideWidth*n.slideCount/2:!0===n.options.centerMode&&!0===n.options.infinite?n.slideOffset+=n.slideWidth*Math.floor(n.options.slidesToShow/2)-n.slideWidth:!0===n.options.centerMode&&(n.slideOffset=0,n.slideOffset+=n.slideWidth*Math.floor(n.options.slidesToShow/2)),e=!1===n.options.vertical?i*n.slideWidth*-1+n.slideOffset:i*t*-1+r,!0===n.options.variableWidth&&(o=n.slideCount<=n.options.slidesToShow||!1===n.options.infinite?n.$slideTrack.children(".slick-slide").eq(i):n.$slideTrack.children(".slick-slide").eq(i+n.options.slidesToShow),e=!0===n.options.rtl?o[0]?-1*(n.$slideTrack.width()-o[0].offsetLeft-o.width()):0:o[0]?-1*o[0].offsetLeft:0,!0===n.options.centerMode&&(o=n.slideCount<=n.options.slidesToShow||!1===n.options.infinite?n.$slideTrack.children(".slick-slide").eq(i):n.$slideTrack.children(".slick-slide").eq(i+n.options.slidesToShow+1),e=!0===n.options.rtl?o[0]?-1*(n.$slideTrack.width()-o[0].offsetLeft-o.width()):0:o[0]?-1*o[0].offsetLeft:0,e+=(n.$list.width()-o.outerWidth())/2)),e},e.prototype.getOption=e.prototype.slickGetOption=function(i){return this.options[i]},e.prototype.getNavigableIndexes=function(){var i,e=this,t=0,o=0,s=[];for(!1===e.options.infinite?i=e.slideCount:(t=-1*e.options.slidesToScroll,o=-1*e.options.slidesToScroll,i=2*e.slideCount);t<i;)s.push(t),t=o+e.options.slidesToScroll,o+=e.options.slidesToScroll<=e.options.slidesToShow?e.options.slidesToScroll:e.options.slidesToShow;return s},e.prototype.getSlick=function(){return this},e.prototype.getSlideCount=function(){var e,t,o=this;return t=!0===o.options.centerMode?o.slideWidth*Math.floor(o.options.slidesToShow/2):0,!0===o.options.swipeToSlide?(o.$slideTrack.find(".slick-slide").each(function(s,n){if(n.offsetLeft-t+i(n).outerWidth()/2>-1*o.swipeLeft)return e=n,!1}),Math.abs(i(e).attr("data-slick-index")-o.currentSlide)||1):o.options.slidesToScroll},e.prototype.goTo=e.prototype.slickGoTo=function(i,e){this.changeSlide({data:{message:"index",index:
10555parseInt(i)}},e)},e.prototype.init=function(e){var t=this;i(t.$slider).hasClass("slick-initialized")||(i(t.$slider).addClass("slick-initialized"),t.buildRows(),t.buildOut(),t.setProps(),t.startLoad(),t.loadSlider(),t.initializeEvents(),t.updateArrows(),t.updateDots(),t.checkResponsive(!0),t.focusHandler()),e&&t.$slider.trigger("init",[t]),!0===t.options.accessibility&&t.initADA(),t.options.autoplay&&(t.paused=!1,t.autoPlay())},e.prototype.initADA=function(){var e=this,t=Math.ceil(e.slideCount/e.options.slidesToShow),o=e.getNavigableIndexes().filter(function(i){return i>=0&&i<e.slideCount});e.$slides.add(e.$slideTrack.find(".slick-cloned")).attr({"aria-hidden":"true",tabindex:"-1"}).find("a, input, button, select").attr({tabindex:"-1"}),null!==e.$dots&&(e.$slides.not(e.$slideTrack.find(".slick-cloned")).each(function(t){var s=o.indexOf(t);i(this).attr({role:"tabpanel",id:"slick-slide"+e.instanceUid+t,tabindex:-1}),-1!==s&&i(this).attr({"aria-describedby":"slick-slide-control"+e.instanceUid+s})}),e.$dots.attr("role","tablist").find("li").each(function(s){var n=o[s];i(this).attr({role:"presentation"}),i(this).find("button").first().attr({role:"tab",id:"slick-slide-control"+e.instanceUid+s,"aria-controls":"slick-slide"+e.instanceUid+n,"aria-label":s+1+" of "+t,"aria-selected":null,tabindex:"-1"})}).eq(e.currentSlide).find("button").attr({"aria-selected":"true",tabindex:"0"}).end());for(var s=e.currentSlide,n=s+e.options.slidesToShow;s<n;s++)e.$slides.eq(s).attr("tabindex",0);e.activateADA()},e.prototype.initArrowEvents=function(){var i=this;!0===i.options.arrows&&i.slideCount>i.options.slidesToShow&&(i.$prevArrow.off("click.slick").on("click.slick",{message:"previous"},i.changeSlide),i.$nextArrow.off("click.slick").on("click.slick",{message:"next"},i.changeSlide),!0===i.options.accessibility&&(i.$prevArrow.on("keydown.slick",i.keyHandler),i.$nextArrow.on("keydown.slick",i.keyHandler)))},e.prototype.initDotEvents=function(){var e=this;!0===e.options.dots&&(i("li",e.$dots).on("click.slick",{message:"index"},e.changeSlide),!0===e.options.accessibility&&e.$dots.on("keydown.slick",e.keyHandler)),!0===e.options.dots&&!0===e.options.pauseOnDotsHover&&i("li",e.$dots).on("mouseenter.slick",i.proxy(e.interrupt,e,!0)).on("mouseleave.slick",i.proxy(e.interrupt,e,!1))},e.prototype.initSlideEvents=function(){var e=this;e.options.pauseOnHover&&(e.$list.on("mouseenter.slick",i.proxy(e.interrupt,e,!0)),e.$list.on("mouseleave.slick",i.proxy(e.interrupt,e,!1)))},e.prototype.initializeEvents=function(){var e=this;e.initArrowEvents(),e.initDotEvents(),e.initSlideEvents(),e.$list.on("touchstart.slick mousedown.slick",{action:"start"},e.swipeHandler),e.$list.on("touchmove.slick mousemove.slick",{action:"move"},e.swipeHandler),e.$list.on("touchend.slick mouseup.slick",{action:"end"}
10555,e.swipeHandler),e.$list.on("touchcancel.slick mouseleave.slick",{action:"end"},e.swipeHandler),e.$list.on("click.slick",e.clickHandler),i(document).on(e.visibilityChange,i.proxy(e.visibility,e)),!0===e.options.accessibility&&e.$list.on("keydown.slick",e.keyHandler),!0===e.options.focusOnSelect&&i(e.$slideTrack).children().on("click.slick",e.selectHandler),i(window).on("orientationchange.slick.slick-"+e.instanceUid,i.proxy(e.orientationChange,e)),i(window).on("resize.slick.slick-"+e.instanceUid,i.proxy(e.resize,e)),i("[draggable!=true]",e.$slideTrack).on("dragstart",e.preventDefault),i(window).on("load.slick.slick-"+e.instanceUid,e.setPosition),i(e.setPosition)},e.prototype.initUI=function(){var i=this;!0===i.options.arrows&&i.slideCount>i.options.slidesToShow&&(i.$prevArrow.show(),i.$nextArrow.show()),!0===i.options.dots&&i.slideCount>i.options.slidesToShow&&i.$dots.show()},e.prototype.keyHandler=function(i){var e=this;i.target.tagName.match("TEXTAREA|INPUT|SELECT")||(37===i.keyCode&&!0===e.options.accessibility?e.changeSlide({data:{message:!0===e.options.rtl?"next":"previous"}}):39===i.keyCode&&!0===e.options.accessibility&&e.changeSlide({data:{message:!0===e.options.rtl?"previous":"next"}}))},e.prototype.lazyLoad=function(){function e(e){i("img[data-lazy]",e).each(function(){var e=i(this),t=i(this).attr("data-lazy"),o=i(this).attr("data-srcset"),s=i(this).attr("data-sizes")||n.$slider.attr("data-sizes"),r=document.createElement("img");r.onload=function(){e.animate({opacity:0}
vendor: 5,619 bytes, line 10555
10555,100,function(){o&&(e.attr("srcset",o),s&&e.attr("sizes",s)),e.attr("src",t).animate({opacity:1},200,function(){e.removeAttr("data-lazy data-srcset data-sizes").removeClass("slick-loading")}),n.$slider.trigger("lazyLoaded",[n,e,t])})},r.onerror=function(){e.removeAttr("data-lazy").removeClass("slick-loading").addClass("slick-lazyload-error"),n.$slider.trigger("lazyLoadError",[n,e,t])},r.src=t})}var t,o,s,n=this;if(!0===n.options.centerMode?!0===n.options.infinite?s=(o=n.currentSlide+(n.options.slidesToShow/2+1))+n.options.slidesToShow+2:(o=Math.max(0,n.currentSlide-(n.options.slidesToShow/2+1)),s=n.options.slidesToShow/2+1+2+n.currentSlide):(o=n.options.infinite?n.options.slidesToShow+n.currentSlide:n.currentSlide,s=Math.ceil(o+n.options.slidesToShow),!0===n.options.fade&&(o>0&&o--,s<=n.slideCount&&s++)),t=n.$slider.find(".slick-slide").slice(o,s),"anticipated"===n.options.lazyLoad)for(var r=o-1,l=s,d=n.$slider.find(".slick-slide"),a=0;a<n.options.slidesToScroll;a++)r<0&&(r=n.slideCount-1),t=(t=t.add(d.eq(r))).add(d.eq(l)),r--,l++;e(t),n.slideCount<=n.options.slidesToShow?e(n.$slider.find(".slick-slide")):n.currentSlide>=n.slideCount-n.options.slidesToShow?e(n.$slider.find(".slick-cloned").slice(0,n.options.slidesToShow)):0===n.currentSlide&&e(n.$slider.find(".slick-cloned").slice(-1*n.options.slidesToShow))},e.prototype.loadSlider=function(){var i=this;i.setPosition(),i.$slideTrack.css({opacity:1}),i.$slider.removeClass("slick-loading"),i.initUI(),"progressive"===i.options.lazyLoad&&i.progressiveLazyLoad()},e.prototype.next=e.prototype.slickNext=function(){this.changeSlide({data:{message:"next"}})},e.prototype.orientationChange=function(){var i=this;i.checkResponsive(),i.setPosition()},e.prototype.pause=e.prototype.slickPause=function(){var i=this;i.autoPlayClear(),i.paused=!0},e.prototype.play=e.prototype.slickPlay=function(){var i=this;i.autoPlay(),i.options.autoplay=!0,i.paused=!1,i.focussed=!1,i.interrupted=!1},e.prototype.postSlide=function(e){var t=this;t.unslicked||(t.$slider.trigger("afterChange",[t,e]),t.animating=!1,t.slideCount>t.options.slidesToShow&&t.setPosition(),t.swipeLeft=null,t.options.autoplay&&t.autoPlay(),!0===t.options.accessibility&&(t.initADA(),t.options.focusOnChange&&i(t.$slides.get(t.currentSlide)).attr("tabindex",0).focus()))},e.prototype.prev=e.prototype.slickPrev=function(){this.changeSlide({data:{message:"previous"}})},e.prototype.preventDefault=function(i){i.preventDefault()},e.prototype.progressiveLazyLoad=function(e){e=e||1;var t,o,s,n,r,l=this,d=i("img[data-lazy]",l.$slider);d.length?(t=d.first(),o=t.attr("data-lazy"),s=t.attr("data-srcset"),n=t.attr("data-sizes")||l.$slider.attr("data-sizes"),(r=document.createElement("img")).onload=function(){s&&(t.attr("srcset",s),n&&t.attr("sizes",n)),t.attr("src",o).removeAttr("data-lazy data-srcset data-sizes").removeClass("slick-loading"),!0===l.options.adaptiveHeight&&l.setPosition(),l.$slider.trigger("lazyLoaded",[l,t,o]),l.progressiveLazyLoad()},r.onerror=function(){e<3?setTimeout(function(){l.progressiveLazyLoad(e+1)},500):(t.removeAttr("data-lazy").removeClass("slick-loading").addClass("slick-lazyload-error"),l.$slider.trigger("lazyLoadError",[l,t,o]),l.progressiveLazyLoad())},r.src=o):l.$slider.trigger("allImagesLoaded",[l])},e.prototype.refresh=function(e){var t,o,s=this;o=s.slideCount-s.options.slidesToShow,!s.options.infinite&&s.currentSlide>o&&(s.currentSlide=o),s.slideCount<=s.options.slidesToShow&&(s.currentSlide=0),t=s.currentSlide,s.destroy(!0),i.extend(s,s.initials,{currentSlide:t}),s.init(),e||s.changeSlide({data:{message:"index",index:t}},!1)},e.prototype.registerBreakpoints=function(){var e,t,o,s=this,n=s.options.responsive||null;if("array"===i.type(n)&&n.length){s.respondTo=s.options.respondTo||"window";for(e in n)if(o=s.breakpoints.length-1,n.hasOwnProperty(e)){for(t=n[e].breakpoint;o>=0;)s.breakpoints[o]&&s.breakpoints[o]===t&&s.breakpoints.splice(o,1),o--;s.breakpoints.push(t),s.breakpointSettings[t]=n[e].settings}s.breakpoints.sort(function(i,e){return s.options.mobileFirst?i-e:e-i})}},e.prototype.reinit=function(){var e=this;e.$slides=e.$slideTrack.children(e.options.slide).addClass("slick-slide"),e.slideCount=e.$slides.length,e.currentSlide>=e.slideCount&&0!==e.currentSlide&&(e.currentSlide=e.currentSlide-e.options.slidesToScroll),e.slideCount<=e.options.slidesToShow&&(e.currentSlide=0),e.registerBreakpoints(),e.setProps(),e.setupInfinite(),e.buildArrows(),e.updateArrows(),e.initArrowEvents(),e.buildDots(),e.updateDots(),e.initDotEvents(),e.cleanUpSlideEvents(),e.initSlideEvents(),e.checkResponsive(!1,!0),!0===e.options.focusOnSelect&&i(e.$slideTrack).children().on("click.slick",e.selectHandler),e.setSlideClasses("number"==typeof e.currentSlide?e.currentSlide:0),e.setPosition(),e.focusHandler(),e.paused=!e.options.autoplay,e.autoPlay(),e.$slider.trigger("reInit",[e])},e.prototype.resize=function(){var e=this;i(window).width()!==e.windowWidth&&(clearTimeout(e.windowDelay),e.windowDelay=window.setTimeout(function(){e.windowWidth=i(window).width(),e.checkResponsive(),e.unslicked||e.setPosition()},50))},e.prototype.removeSlide=e.prototype.slickRemove=function(i,e,t){var o=this;if(i="boolean"==typeof i?!0===(e=i)?0:o.slideCount-1:!0===e?--i:i,o.slideCount<1||i<0||i>o.slideCount-1)return!1;o.unload(),!0===t?o.$slideTrack.children().remove():o.$slideTrack.children(this.options.slide).eq(i).remove(),o.$slides=o.$slideTrack.children(this.options.slide),o.$slideTrack.children(this.options.slide).detach(),o.$slideTrack.append(o.$slides),o.$slidesCache=o.$slides,o.reinit()},e.prototype.setCSS=function(i){var e,t,o=this,s={};
10555!0===o.options.rtl&&(i=-i),e="left"==o.positionProp?Math.ceil(i)+"px":"0px",t="top"==o.positionProp?Math.ceil(i)+"px":"0px",s[o.positionProp]=i,!1===o.transformsEnabled?o.$slideTrack.css(s):(s={},!1===o.cssTransitions?(s[o.animType]="translate("+e+", "+t+")",o.$slideTrack.css(s)):(s[o.animType]="translate3d("+e+", "+t+", 0px)",o.$slideTrack.css(s)))},e.prototype.setDimensions=function(){var i=this;!1===i.options.vertical?!0===i.options.centerMode&&i.$list.css({padding:"0px "+i.options.centerPadding}):(i.$list.height(i.$slides.first().outerHeight(!0)*i.options.slidesToShow),!0===i.options.centerMode&&i.$list.css({padding:i.options.centerPadding+" 0px"})),i.listWidth=i.$list.width(),i.listHeight=i.$list.height(),!1===i.options.vertical&&!1===i.options.variableWidth?(i.slideWidth=Math.ceil(i.listWidth/i.options.slidesToShow),i.$slideTrack.width(Math.ceil(i.slideWidth*i.$slideTrack.children(".slick-slide").length))):!0===i.options.variableWidth?i.$slideTrack.width(5e3*i.slideCount):(i.slideWidth=Math.ceil(i.listWidth),i.$slideTrack.height(Math.ceil(i.$slides.first().outerHeight(!0)*i.$slideTrack.children(".slick-slide").length)));var e=i.$slides.first().outerWidth(!0)-i.$slides.first().width();!1===i.options.variableWidth&&i.$slideTrack.children(".slick-slide").width(i.slideWidth-e)},e.prototype.setFade=function(){var e,t=this;t.$slides.each(function(o,s){e=t.slideWidth*o*-1,!0===t.options.rtl?i(s).css({position:"relative",right:e,top:0,zIndex:t.options.zIndex-2,opacity:0}
10555):i(s).css({position:"relative",left:e,top:0,zIndex:t.options.zIndex-2,opacity:0})}),t.$slides.eq(t.currentSlide).css({zIndex:t.options.zIndex-1,opacity:1})},e.prototype.setHeight=function(){var i=this;if(1===i.options.slidesToShow&&!0===i.options.adaptiveHeight&&!1===i.options.vertical){var e=i.$slides.eq(i.currentSlide).outerHeight(!0);i.$list.css("height",e)}},e.prototype.setOption=e.prototype.slickSetOption=function(){var e,t,o,s,n,r=this,l=!1;if("object"===i.type(arguments[0])?(o=arguments[0],l=arguments[1],n="multiple"):"string"===i.type(arguments[0])&&(o=arguments[0],s=arguments[1],l=arguments[2],"responsive"===arguments[0]&&"array"===i.type(arguments[1])?n="responsive":void 0!==arguments[1]&&(n="single")),"single"===n)r.options[o]=s;else if("multiple"===n)i.each(o,function(i,e){r.options[i]=e});else if("responsive"===n)for(t in s)if("array"!==i.type(r.options.responsive))r.options.responsive=[s[t]];else{for(e=r.options.responsive.length-1;e>=0;)r.options.responsive[e].breakpoint===s[t].breakpoint&&r.options.responsive.splice(e,1),e--;r.options.responsive.push(s[t])}l&&(r.unload(),r.reinit())},e.prototype.setPosition=function(){var i=this;i.setDimensions(),i.setHeight(),!1===i.options.fade?i.setCSS(i.getLeft(i.currentSlide)):i.setFade(),i.$slider.trigger("setPosition",[i])},e.prototype.setProps=function(){var i=this,e=document.body.style;i.positionProp=!0===i.options.vertical?"top":"left","top"===i.positionProp?i.$slider.addClass("slick-vertical"):i.$slider.removeClass("slick-vertical"),void 0===e.WebkitTransition&&void 0===e.MozTransition&&void 0===e.msTransition||!0===i.options.useCSS&&(i.cssTransitions=!0),i.options.fade&&("number"==typeof i.options.zIndex?i.options.zIndex<3&&(i.options.zIndex=3):i.options.zIndex=i.defaults.zIndex),void 0!==e.OTransform&&(i.animType="OTransform",i.transformType="-o-transform",i.transitionType="OTransition",void 0===e.perspectiveProperty&&void 0===e.webkitPerspective&&(i.animType=!1)),void 0!==e.MozTransform&&(i.animType="MozTransform",i.transformType="-moz-transform",i.transitionType="MozTransition",void 0===e.perspectiveProperty&&void 0===e.MozPerspective&&(i.animType=!1)),void 0!==e.webkitTransform&&(i.animType="webkitTransform",i.transformType="-webkit-transform",i.transitionType="webkitTransition",void 0===e.perspectiveProperty&&void 0===e.webkitPerspective&&(i.animType=!1)),void 0!==e.msTransform&&(i.animType="msTransform",i.transformType="-ms-transform",i.transitionType="msTransition",void 0===e.msTransform&&(i.animType=!1)),void 0!==e.transform&&!1!==i.animType&&(i.animType="transform",i.transformType="transform",i.transitionType="transition"),i.transformsEnabled=i.options.useTransform&&null!==i.animType&&!1!==i.animType},e.prototype.setSlideClasses=function(i){var e,t,o,s,n=this;if(t=n.$slider.find(".slick-slide").removeClass("slick-active slick-center slick-current").attr("aria-hidden","true"),n.$slides.eq(i).addClass("slick-current"),!0===n.options.centerMode){var r=n.options.slidesToShow%2==0?1:0;e=Math.floor(n.options.slidesToShow/2),!0===n.options.infinite&&(i>=e&&i<=n.slideCount-1-e?n.$slides.slice(i-e+r,i+e+1).addClass("slick-active").attr("aria-hidden","false"):(o=n.options.slidesToShow+i,t.slice(o-e+1+r,o+e+2).addClass("slick-active").attr("aria-hidden","false")),0===i?t.eq(t.length-1-n.options.slidesToShow).addClass("slick-center"):i===n.slideCount-1&&t.eq(n.options.slidesToShow).addClass("slick-center")),n.$slides.eq(i).addClass("slick-center")}else i>=0&&i<=n.slideCount-n.options.slidesToShow?n.$slides.slice(i,i+n.options.slidesToShow).addClass("slick-active").attr("aria-hidden","false"):t.length<=n.options.slidesToShow?t.addClass("slick-active").attr("aria-hidden","false"):(s=n.slideCount%n.options.slidesToShow,o=!0===n.options.infinite?n.options.slidesToShow+i:i,n.options.slidesToShow==n.options.slidesToScroll&&n.slideCount-i<n.options.slidesToShow?t.slice(o-(n.options.slidesToShow-s),o+s).addClass("slick-active").attr("aria-hidden","false"):t.slice(o,o+n.options.slidesToShow).addClass("slick-active").attr("aria-hidden","false"));"ondemand"!==n.options.lazyLoad&&"anticipated"!==n.options.lazyLoad||n.lazyLoad()},e.prototype.setupInfinite=function(){var e,t,o,s=this;if(!0===s.options.fade&&(s.options.centerMode=!1),!0===s.options.infinite&&!1===s.options.fade&&(t=null,s.slideCount>s.options.slidesToShow)){for(o=!0===s.options.centerMode?s.options.slidesToShow+1:s.options.slidesToShow,e=s.slideCount;e>s.slideCount-o;e-=1)t=e-1,i(s.$slides[t]).clone(!0).attr("id","").attr("data-slick-index",t-s.slideCount).prependTo(s.$slideTrack).addClass("slick-cloned");for(e=0;e<o+s.slideCount;e+=1)t=e,i(s.$slides[t]).clone(!0).attr("id","").attr("data-slick-index",t+s.slideCount).appendTo(s.$slideTrack).addClass("slick-cloned");s.$slideTrack.find(".slick-cloned").find("[id]").each(function(){i(this).attr("id","")})}},e.prototype.interrupt=function(i){var e=this;i||e.autoPlay(),e.interrupted=i},e.prototype.selectHandler=function(e){var t=this,o=i(e.target).is(".slick-slide")?i(e.target):i(e.target).parents(".slick-slide"),s=parseInt(o.attr("data-slick-index"));s||(s=0),t.slideCount<=t.options.slidesToShow?t.slideHandler(s,!1,!0):t.slideHandler(s)},e.prototype.slideHandler=function(i,e,t){var o,s,n,r,l,d=null,a=this;if(e=e||!1,!(!0===a.animating&&!0===a.options.waitForAnimate||!0===a.options.fade&&a.currentSlide===i))if(!1===e&&a.asNavFor(i),o=i,d=a.getLeft(o),r=a.getLeft(a.currentSlide),a.currentLeft=null===a.swipeLeft?r:a.swipeLeft,!1===a.options.infinite&&!1===a.options.centerMode&&(i<0||i>a.getDotCount()*a.options.slidesToScroll))!1===a.options.fade&&(o=a.currentSlide,!0!==t?a.animateSlide(r,function(){a.postSlide(o)}):a.postSlide(o));else if(!1===a.options.infinite&&!0===a.options.centerMode&&(i<0||i>a.slideCount-a.options.slidesToScroll))!1===a.options.fade&&(o=a.currentSlide,!0!==t?a.animateSlide(r,function(){a.postSlide(o)}):a.postSlide(o));else{if(a.options.autoplay&&clearInterval(a.autoPlayTimer),s=o<0?a.slideCount%a.options.slidesToScroll!=0?a.slideCount-a.slideCount%a.options.slidesToScroll:a.slideCount+
10555o:o>=a.slideCount?a.slideCount%a.options.slidesToScroll!=0?0:o-a.slideCount:o,a.animating=!0,a.$slider.trigger("beforeChange",[a,a.currentSlide,s]),n=a.currentSlide,a.currentSlide=s,a.setSlideClasses(a.currentSlide),a.options.asNavFor&&(l=(l=a.getNavTarget()).slick("getSlick")).slideCount<=l.options.slidesToShow&&l.setSlideClasses(a.currentSlide),a.updateDots(),a.updateArrows(),!0===a.options.fade)return!0!==t?(a.fadeSlideOut(n),a.fadeSlide(s,function(){a.postSlide(s)})):a.postSlide(s),void a.animateHeight();!0!==t?a.animateSlide(d,function(){a.postSlide(s)}):a.postSlide(s)}},e.prototype.startLoad=function(){var i=this;!0===i.options.arrows&&i.slideCount>i.options.slidesToShow&&(i.$prevArrow.hide(),i.$nextArrow.hide()),!0===i.options.dots&&i.slideCount>i.options.slidesToShow&&i.$dots.hide(),i.$slider.addClass("slick-loading")},e.prototype.swipeDirection=function(){var i,e,t,o,s=this;return i=s.touchObject.startX-s.touchObject.curX,e=s.touchObject.startY-s.touchObject.curY,t=Math.atan2(e,i),(o=Math.round(180*t/Math.PI))<0&&(o=360-Math.abs(o)),o<=45&&o>=0?!1===s.options.rtl?"left":"right":o<=360&&o>=315?!1===s.options.rtl?"left":"right":o>=135&&o<=225?!1===s.options.rtl?"right":"left":!0===s.options.verticalSwiping?o>=35&&o<=135?"down":"up":"vertical"},e.prototype.swipeEnd=function(i){var e,t,o=this;if(o.dragging=!1,o.swiping=!1,o.scrolling)return o.scrolling=!1,!1;if(o.interrupted=!1,o.shouldClick=!(o.touchObject.swipeLength>10),void 0===o.touchObject.curX)return!1;if(!0===o.touchObject.edgeHit&&o.$slider.trigger("edge",[o,o.swipeDirection()]),o.touchObject.swipeLength>=o.touchObject.minSwipe){switch(t=o.swipeDirection()){case"left":case"down":e=o.options.swipeToSlide?o.checkNavigable(o.currentSlide+o.getSlideCount()):o.currentSlide+o.getSlideCount(),o.currentDirection=0;break;case"right":case"up":e=o.options.swipeToSlide?o.checkNavigable(o.currentSlide-o.getSlideCount()):o.currentSlide-o.getSlideCount(),o.currentDirection=1}"vertical"!=t&&(o.slideHandler(e),o.touchObject={},o.$slider.trigger("swipe",[o,t]))}else o.touchObject.startX!==o.touchObject.curX&&(o.slideHandler(o.currentSlide),o.touchObject={})},e.prototype.swipeHandler=function(i){var e=this;if(!(!1===e.options.swipe||"ontouchend"in document&&!1===e.options.swipe||!1===e.options.draggable&&-1!==i.type.indexOf("mouse")))switch(e.touchObject.fingerCount=i.originalEvent&&void 0!==i.originalEvent.touches?i.originalEvent.touches.length:1,e.touchObject.minSwipe=e.listWidth/e.options.touchThreshold,!0===e.options.verticalSwiping&&(e.touchObject.minSwipe=e.listHeight/e.options.touchThreshold),i.data.action){case"start":e.swipeStart(i);break;case"move":e.swipeMove(i);break;case"end":e.swipeEnd(i)}},e.prototype.swipeMove=function(i){var e,t,o,s,n,r,l=this;return n=void 0!==i.originalEvent?i.originalEvent.touches:null,!(!l.dragging||l.scrolling||n&&1!==n.length)&&(e=l.getLeft(l.currentSlide),l.touchObject.curX=void 0!==n?n[0].pageX:i.clientX,l.touchObject.curY=void 0!==n?n[0].pageY:i.clientY,l.touchObject.swipeLength=Math.round(Math.sqrt(Math.pow(l.touchObject.curX-l.touchObject.startX,2))),r=Math.round(Math.sqrt(Math.pow(l.touchObject.curY-l.touchObject.startY,2))),!l.options.verticalSwiping&&!l.swiping&&r>4?(l.scrolling=!0,!1):(!0===l.options.verticalSwiping&&(l.touchObject.swipeLength=r),t=l.swipeDirection(),void 0!==i.originalEvent&&l.touchObject.swipeLength>4&&(l.swiping=!0,i.preventDefault()),s=(!1===l.options.rtl?1:-1)*(l.touchObject.curX>l.touchObject.startX?1:-1),!0===l.options.verticalSwiping&&(s=l.touchObject.curY>l.touchObject.startY?1:-1),o=l.touchObject.swipeLength,l.touchObject.edgeHit=!1,!1===l.options.infinite&&(0===l.currentSlide&&"right"===t||l.currentSlide>=l.getDotCount()&&"left"===t)&&(o=l.touchObject.swipeLength*l.options.edgeFriction,l.touchObject.edgeHit=!0),!1===l.options.vertical?l.swipeLeft=e+o*s:l.swipeLeft=e+o*(l.$list.height()/l.listWidth)*s,!0===l.options.verticalSwiping&&(l.swipeLeft=e+o*s),!0!==l.options.fade&&!1!==l.options.touchMove&&(!0===l.animating?(l.swipeLeft=null,!1):void l.setCSS(l.swipeLeft))))},e.prototype.swipeStart=function(i){var e,t=this;if(t.interrupted=!0,1!==t.touchObject.fingerCount||t.slideCount<=t.options.slidesToShow)return t.touchObject={},!1;void 0!==i.originalEvent&&void 0!==i.originalEvent.touches&&(e=i.originalEvent.touches[0]),t.touchObject.startX=t.touchObject.curX=void 0!==e?e.pageX:i.clientX,t.touchObject.startY=t.touchObject.curY=void 0!==e?e.pageY:i.clientY,t.dragging=!0},e.prototype.unfilterSlides=e.prototype.slickUnfilter=function(){var i=this;null!==i.$slidesCache&&(i.unload(),i.$slideTrack.children(this.options.slide).detach(),i.$slidesCache.appendTo(i.$slideTrack),i.reinit())},e.prototype.unload=function(){var e=this;i(".slick-cloned",e.$slider).remove(),e.$dots&&e.$dots.remove(),e.$prevArrow&&e.htmlExpr.test(e.options.prevArrow)&&e.$prevArrow.remove(),e.$nextArrow&&e.htmlExpr.test(e.options.nextArrow)&&e.$nextArrow.remove(),e.$slides.removeClass("slick-slide slick-active slick-visible slick-current").attr("aria-hidden","true").css("width","")}
10555,e.prototype.unslick=function(i){var e=this;e.$slider.trigger("unslick",[e,i]),e.destroy()},e.prototype.updateArrows=function(){var i=this;Math.floor(i.options.slidesToShow/2),!0===i.options.arrows&&i.slideCount>i.options.slidesToShow&&!i.options.infinite&&(i.$prevArrow.removeClass("slick-disabled").attr("aria-disabled","false"),i.$nextArrow.removeClass("slick-disabled").attr("aria-disabled","false"),0===i.currentSlide?(i.$prevArrow.addClass("slick-disabled").attr("aria-disabled","true"),i.$nextArrow.removeClass("slick-disabled").attr("aria-disabled","false")):i.currentSlide>=i.slideCount-i.options.slidesToShow&&!1===i.options.centerMode?(i.$nextArrow.addClass("slick-disabled").attr("aria-disabled","true"),i.$prevArrow.removeClass("slick-disabled").attr("aria-disabled","false")):i.currentSlide>=i.slideCount-1&&!0===i.options.centerMode&&(i.$nextArrow.addClass("slick-disabled").attr("aria-disabled","true"),i.$prevArrow.removeClass("slick-disabled").attr("aria-disabled","false")))},e.prototype.updateDots=function(){var i=this;null!==i.$dots&&(i.$dots.find("li").removeClass("slick-active").end(),i.$dots.find("li").eq(Math.floor(i.currentSlide/i.options.slidesToScroll)).addClass("slick-active"))},e.prototype.visibility=function(){var i=this;i.options.autoplay&&(document[i.hidden]?i.interrupted=!0:i.interrupted=!1)},i.fn.slick=function(){var i,t,o=this,s=arguments[0],n=Array.prototype.slice.call(arguments,1),r=o.length;for(i=0;i<r;i++)if("object"==typeof s||void 0===s?o[i].slick=new e(o[i],s):t=o[i].slick[s].apply(o[i].slick,n),void 0!==t)return t;return o}}); 10556; 10557 10558 /** 10559 * Darkbox - by Roko.CB 10560 * https://github.com/rokobuljan/Darkbox-Gallery 10561 */ 10562;(function() { 10563 scriptJquery(function($) { 10564 10565 var $imagesGroup, 10566 n = 0, // number of images 10567 c = 0, // current image index (counter 0-based) 10568 10569 $prevNext = $("<a id='darkbox_prev'/><a id='darkbox_next'/>").on("touchstart mousedown", function(e) { 10570 e.preventDefault(); 10571 e.stopPropagation(); 10572 var isNext = this.id === "darkbox_next"; 10573 c = isNext ? ++c : --c; 10574 showImage(); 10575 }), 10576 10577 $darkbox = $("<div/>", { 10578 id: "darkbox", 10579 append: $prevNext, 10580 appendTo : "body" 10581 }), 10582 10583 $darkboxClose = $("<a/>", { 10584 id: "darkbox_close", 10585 appendTo: $darkbox, 10586 on: { 10587 "touchstart mousedown" : function(e) { 10588 e.preventDefault(); 10589 $darkbox.removeClass("show"); 10590 } 10591 } 10592 }), 10593 10594 $darkboxDescription = $("<div/>", { 10595 id: "darkbox_description", 10596 appendTo : $darkbox 10597 }), 10598 10599 $darkboxStats = $("<div/>", { 10600 id: "darkbox_stats", 10601 appendTo : $darkbox 10602 }); 10603 10604 function showImage() { 10605 10606 // Prevent counter going out of bounds 10607 c = c < 0 ? n - 1 : c % n; 10608 10609 // Get size of window so that we can define if 10610 // background-size needs to be "contain" or "auto". 10611 var doc = document.documentElement, 10612 docW = Math.max(doc.clientWidth, window.innerWidth || 0), 10613 docH = Math.max(doc.clientHeight, window.innerHeight || 0), 10614 $cur = $imagesGroup.eq(c), 10615 description = $cur.data("darkbox-description"), 10616 src = $cur.data("darkbox"); 10617 10618 $darkbox.addClass("show spinner"); 10619 $darkboxDescription.html(description); 10620 $darkboxStats.html(n < 2 ? "" : (c+1) +"/"+ n); 10621 10622 scriptJquery("<img/>").on("load", function() { 10623 var bigger = (this.width > docW || this.height > docH); 10624 $darkbox.removeClass("spinner").css({ 10625 backgroundImage: "url('" + this.src + "')", 10626 backgroundSize: bigger ? "contain" : "auto" 10627 }); 10628 }).attr("src", src); 10629 10630 } 10631 10632 // Call darkbox 10633 scriptJquery(document).on("click", "[data-darkbox],[data-darkbox-group]", function(e) { 10634 10635 var src = $(this).data("darkbox"), 10636 isDummy = !src, // (is just a link calling a group) 10637 groupID = $(this).data("darkbox-group"); 10638 10639 $imagesGroup = !groupID ? $(this) : $('[data-darkbox-group="'+ groupID +'"]').filter("[data-darkbox]"); 10640 n = $imagesGroup.length; 10641 c = isDummy ? 0 : $imagesGroup.index( this ); 10642 10643 $prevNext.toggle(n>1); // Hide prev/next if we have a single image 10644 $darkbox.css({backgroundImage:"none"}); 10645 10646 showImage(); // aand, ACTION! 10647 }); 10648 10649 // Keyboard navigation 10650 scriptJquery(document).on("keyup", function (e) { 10651 10652 var k = e.which; 10653 10654 if (k === 27) /*ESC */ { 10655 $darkbox.removeClass("show"); 10656 } 10657 if (k === 37) /*LEFT*/ { 10658 --c; 10659 showImage(); 10660 } 10661 if (k === 39) /*RIGHT*/ { 10662 ++c; 10663 showImage(); 10664 } 10665 }); 10666 10667 }); 10668}()); 10669; 10670 10671 /*! Lity - v2.2.2 - 2016-12-14 10672* http://sorgalla.com/lity/ 10673* Copyright (c) 2015-2016 Jan Sorgalla; Licensed MIT */ 10674(function(window, factory) { 10675 if (typeof define === 'function' && define.amd) { 10676 define(['jquery'], function($) { 10677 return factory(window, $); 10678 }); 10679 } else if (typeof module === 'object' && typeof module.exports === 'object') { 10680 module.exports = factory(window, require('jquery')); 10681 } else { 10682 window.lity = factory(window, window.jQuery || window.Zepto); 10683 } 10684}(typeof window !== "undefined" ? window : this, function(window, $) { 10685 'use strict'; 10686 10687 var document = window.document; 10688 10689 var _win = $(window); 10690 var _deferred = $.Deferred; 10691 var _html = $('html'); 10692 var _instances = []; 10693 10694 var _attrAriaHidden = 'aria-hidden'; 10695 var _dataAriaHidden = 'lity-' + _attrAriaHidden; 10696 10697 var _focusableElementsSelector = 'a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,[contenteditable],[tabindex]:not
vendor: 17,353 bytes, lines 10697-11327
10697([tabindex^="-"])'; 10698 10699 var _defaultOptions = { 10700 handler: null, 10701 handlers: { 10702 image: imageHandler, 10703 inline: inlineHandler, 10704 youtube: youtubeHandler, 10705 vimeo: vimeoHandler, 10706 googlemaps: googlemapsHandler, 10707 facebookvideo: facebookvideoHandler, 10708 iframe: iframeHandler 10709 }, 10710 template: '<div class="lity" role="dialog" aria-label="Dialog Window (Press escape to close)" tabindex="-1"><div class="lity-wrap" data-lity-close role="document"><div class="lity-loader" aria-hidden="true">Loading...</div><div class="lity-container"><div class="lity-content"></div><button class="lity-close" type="button" aria-label="Close (Press escape to close)" data-lity-close>×</button></div></div></div>' 10711 }; 10712 10713 var _imageRegexp = /(^data:image\/)|(\.(png|jpe?g|gif|svg|webp|bmp|ico|tiff?)(\?\S*)?$)/i; 10714 var _youtubeRegex = /(youtube(-nocookie)?\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed\/?)?([\w-]{11})(.*)?/i; 10715 var _vimeoRegex = /(vimeo(pro)?.com)\/(?:[^\d]+)?(\d+)\??(.*)?$/; 10716 var _googlemapsRegex = /((maps|www)\.)?google\.([^\/\?]+)\/?((maps\/?)?\?)(.*)/i; 10717 var _facebookvideoRegex = /(facebook\.com)\/([a-z0-9_-]*)\/videos\/([0-9]*)(.*)?$/i; 10718 10719 var _transitionEndEvent = (function() { 10720 var el = document.createElement('div'); 10721 10722 var transEndEventNames = { 10723 WebkitTransition: 'webkitTransitionEnd', 10724 MozTransition: 'transitionend', 10725 OTransition: 'oTransitionEnd otransitionend', 10726 transition: 'transitionend' 10727 }; 10728 10729 for (var name in transEndEventNames) { 10730 if (el.style[name] !== undefined) { 10731 return transEndEventNames[name]; 10732 } 10733 } 10734 10735 return false; 10736 })(); 10737 10738 function transitionEnd(element) { 10739 var deferred = _deferred(); 10740 10741 if (!_transitionEndEvent || !element.length) { 10742 deferred.resolve(); 10743 } else { 10744 element.one(_transitionEndEvent, deferred.resolve); 10745 setTimeout(deferred.resolve, 500); 10746 } 10747 10748 return deferred.promise(); 10749 } 10750 10751 function settings(currSettings, key, value) { 10752 if (arguments.length === 1) { 10753 return $.extend({}, currSettings); 10754 } 10755 10756 if (typeof key === 'string') { 10757 if (typeof value === 'undefined') { 10758 return typeof currSettings[key] === 'undefined' 10759 ? null 10760 : currSettings[key]; 10761 } 10762 10763 currSettings[key] = value; 10764 } else { 10765 $.extend(currSettings, key); 10766 } 10767 10768 return this; 10769 } 10770 10771 function parseQueryParams(params) { 10772 var pairs = decodeURI(params.split('#')[0]).split('&'); 10773 var obj = {}, p; 10774 10775 for (var i = 0, n = pairs.length; i < n; i++) { 10776 if (!pairs[i]) { 10777 continue; 10778 } 10779 10780 p = pairs[i].split('='); 10781 obj[p[0]] = p[1]; 10782 } 10783 10784 return obj; 10785 } 10786 10787 function appendQueryParams(url, params) { 10788 return url + (url.indexOf('?') > -1 ? '&' : '?') + $.param(params); 10789 } 10790 10791 function transferHash(originalUrl, newUrl) { 10792 var pos = originalUrl.indexOf('#'); 10793 10794 if (-1 === pos) { 10795 return newUrl; 10796 } 10797 10798 if (pos > 0) { 10799 originalUrl = originalUrl.substr(pos); 10800 } 10801 10802 return newUrl + originalUrl; 10803 } 10804 10805 function error(msg) { 10806 return $('<span class="lity-error"/>').append(msg); 10807 } 10808 10809 function imageHandler(target, instance) { 10810 var desc = (instance.opener() && instance.opener().data('lity-desc')) || 'Image with no description'; 10811 var img = $('<img src="' + target + '" alt="' + desc + '"/>'); 10812 var deferred = _deferred(); 10813 var failed = function() { 10814 deferred.reject(error('Failed loading image')); 10815 }; 10816 10817 img 10818 .on('load', function() { 10819 if (this.naturalWidth === 0) { 10820 return failed(); 10821 } 10822 10823 deferred.resolve(img); 10824 }) 10825 .on('error', failed) 10826 ; 10827 10828 return deferred.promise(); 10829 } 10830 10831 imageHandler.test = function(target) { 10832 return _imageRegexp.test(target); 10833 }; 10834 10835 function inlineHandler(target, instance) { 10836 var el, placeholder, hasHideClass; 10837 10838 try { 10839 el = $(target); 10840 } catch (e) { 10841 return false; 10842 } 10843 10844 if (!el.length) { 10845 return false; 10846 } 10847 10848 placeholder = $('<i style="display:none !important"/>'); 10849 hasHideClass = el.hasClass('lity-hide'); 10850 10851 instance 10852 .element() 10853 .one('lity:remove', function() { 10854 placeholder 10855 .before(el) 10856 .remove() 10857 ; 10858 10859 if (hasHideClass && !el.closest('.lity-content').length) { 10860 el.addClass('lity-hide'); 10861 } 10862 }) 10863 ; 10864 10865 return el 10866 .removeClass('lity-hide') 10867 .after(placeholder) 10868 ; 10869 } 10870 10871 function youtubeHandler(target) { 10872 var matches = _youtubeRegex.exec(target); 10873 10874 if (!matches) { 10875 return false; 10876 } 10877 10878 return iframeHandler( 10879 transferHash( 10880 target, 10881 appendQueryParams( 10882 'https://www.youtube' + (matches[2] || '') + '.com/embed/' + matches[4], 10883 $.extend( 10884 { 10885 autoplay: 1 10886 }, 10887 parseQueryParams(matches[5] || '') 10888 ) 10889 ) 10890 ) 10891 ); 10892 } 10893 10894 function vimeoHandler(target) { 10895 var matches = _vimeoRegex.exec(target); 10896 10897 if (!matches) { 10898 return false; 10899 } 10900 10901 return iframeHandler( 10902 transferHash( 10903 target, 10904 appendQueryParams( 10905 'https://player.vimeo.com/video/' + matches[3], 10906 $.extend( 10907 { 10908 autoplay: 1 10909 }, 10910 parseQueryParams(matches[4] || '') 10911 ) 10912 ) 10913 ) 10914 ); 10915 } 10916 10917 function facebookvideoHandler(target) { 10918 var matches = _facebookvideoRegex.exec(target); 10919 10920 if (!matches) { 10921 return false; 10922 } 10923 10924 if (0 !== target.indexOf('http')) { 10925 target = 'https:' + target; 10926 } 10927 10928 return iframeHandler( 10929 transferHash( 10930 target, 10931 appendQueryParams( 10932 'https://www.facebook.com/plugins/video.php?href=' + target, 10933 $.extend( 10934 { 10935 autoplay: 1 10936 }, 10937 parseQueryParams(matches[4] || '') 10938 ) 10939 ) 10940 ) 10941 ); 10942 } 10943 10944 function googlemapsHandler(target) { 10945 var matches = _googlemapsRegex.exec(target); 10946 10947 if (!matches) { 10948 return false; 10949 } 10950 10951 return iframeHandler( 10952 transferHash( 10953 target, 10954 appendQueryParams( 10955 'https://www.google.' + matches[3] + '/maps?' + matches[6], 10956 { 10957 output: matches[6].indexOf('layer=c') > 0 ? 'svembed' : 'embed' 10958 } 10959 ) 10960 ) 10961 ); 10962 } 10963 10964 function iframeHandler(target) { 10965 return '<div class="lity-iframe-container"><iframe frameborder="0" allowfullscreen src="' + target + '"/></div>'; 10966 } 10967 10968 function winHeight() { 10969 return document.documentElement.clientHeight 10970 ? document.documentElement.clientHeight 10971 : Math.round(_win.height()); 10972 } 10973 10974 function keydown(e) { 10975 var current = currentInstance(); 10976 10977 if (!current) { 10978 return; 10979 } 10980 10981 // ESC key 10982 if (e.keyCode === 27) { 10983 current.close(); 10984 } 10985 10986 // TAB key 10987 if (e.keyCode === 9) { 10988 handleTabKey(e, current); 10989 } 10990 } 10991 10992 function handleTabKey(e, instance) { 10993 var focusableElements = instance.element().find(_focusableElementsSelector); 10994 var focusedIndex = focusableElements.index(document.activeElement); 10995 10996 if (e.shiftKey && focusedIndex <= 0) { 10997 focusableElements.get(focusableElements.length - 1).focus(); 10998 e.preventDefault(); 10999 } else if (!e.shiftKey && focusedIndex === focusableElements.length - 1) { 11000 focusableElements.get(0).focus(); 11001 e.preventDefault(); 11002 } 11003 } 11004 11005 function resize() { 11006 $.each(_instances, function(i, instance) { 11007 instance.resize(); 11008 }); 11009 } 11010 11011 function registerInstance(instanceToRegister) { 11012 if (1 === _instances.unshift(instanceToRegister)) { 11013 _html.addClass('lity-active'); 11014 11015 _win 11016 .on({ 11017 resize: resize, 11018 keydown: keydown 11019 }) 11020 ; 11021 } 11022 11023 $('body > *').not(instanceToRegister.element()) 11024 .addClass('lity-hidden') 11025 .each(function() { 11026 var el = $(this); 11027 11028 if (undefined !== el.data(_dataAriaHidden)) { 11029 return; 11030 } 11031 11032 el.data(_dataAriaHidden, el.attr(_attrAriaHidden) || null); 11033 }) 11034 .attr(_attrAriaHidden, 'true') 11035 ; 11036 } 11037 11038 function removeInstance(instanceToRemove) { 11039 var show; 11040 11041 instanceToRemove 11042 .element() 11043 .attr(_attrAriaHidden, 'true') 11044 ; 11045 11046 if (1 === _instances.length) { 11047 _html.removeClass('lity-active'); 11048 11049 _win 11050 .off({ 11051 resize: resize, 11052 keydown: keydown 11053 }) 11054 ; 11055 } 11056 11057 _instances = $.grep(_instances, function(instance) { 11058 return instanceToRemove !== instance; 11059 }); 11060 11061 if (!!_instances.length) { 11062 show = _instances[0].element(); 11063 } else { 11064 show = $('.lity-hidden'); 11065 } 11066 11067 show 11068 .removeClass('lity-hidden') 11069 .each(function() { 11070 var el = $(this), oldAttr = el.data(_dataAriaHidden); 11071 11072 if (!oldAttr) { 11073 el.removeAttr(_attrAriaHidden); 11074 } else { 11075 el.attr(_attrAriaHidden, oldAttr); 11076 } 11077 11078 el.removeData(_dataAriaHidden); 11079 }) 11080 ; 11081 } 11082 11083 function currentInstance() { 11084 if (0 === _instances.length) { 11085 return null; 11086 } 11087 11088 return _instances[0]; 11089 } 11090 11091 function factory(target, instance, handlers, preferredHandler) { 11092 var handler = 'inline', content; 11093 11094 var currentHandlers = $.extend({}, handlers); 11095 11096 if (preferredHandler && currentHandlers[preferredHandler]) { 11097 content = currentHandlers[preferredHandler](target, instance); 11098 handler = preferredHandler; 11099 } else { 11100 // Run inline and iframe handlers after all other handlers 11101 $.each(['inline', 'iframe'], function(i, name) { 11102 delete currentHandlers[name]; 11103 11104 currentHandlers[name] = handlers[name]; 11105 }); 11106 11107 $.each(currentHandlers, function(name, currentHandler) { 11108 // Handler might be "removed" by setting callback to null 11109 if (!currentHandler) { 11110 return true; 11111 } 11112 11113 if ( 11114 currentHandler.test && 11115 !currentHandler.test(target, instance) 11116 ) { 11117 return true; 11118 } 11119 11120 content = currentHandler(target, instance); 11121 11122 if (false !== content) { 11123 handler = name; 11124 return false; 11125 } 11126 }); 11127 } 11128 11129 return {handler: handler, content: content || ''}; 11130 } 11131 11132 function Lity(target, options, opener, activeElement) { 11133 var self = this; 11134 var result; 11135 var isReady = false; 11136 var isClosed = false; 11137 var element; 11138 var content; 11139 11140 options = $.extend( 11141 {}, 11142 _defaultOptions, 11143 options 11144 ); 11145 11146 element = $(options.template); 11147 11148 // -- API -- 11149 11150 self.element = function() { 11151 return element; 11152 }; 11153 11154 self.opener = function() { 11155 return opener; 11156 }; 11157 11158 self.options = $.proxy(settings, self, options); 11159 self.handlers = $.proxy(settings, self, options.handlers); 11160 11161 self.resize = function() { 11162 if (!isReady || isClosed) { 11163 return; 11164 } 11165 11166 content 11167 .css('max-height', winHeight() + 'px') 11168 .trigger('lity:resize', [self]) 11169 ; 11170 }; 11171 11172 self.close = function() { 11173 if (!isReady || isClosed) { 11174 return; 11175 } 11176 11177 isClosed = true; 11178 11179 removeInstance(self); 11180 11181 var deferred = _deferred(); 11182 11183 // We return focus only if the current focus is inside this instance 11184 if ( 11185 activeElement && 11186 ( 11187 document.activeElement === element[0] || 11188 $.contains(element[0], document.activeElement) 11189 ) 11190 ) { 11191 try { 11192 activeElement.focus(); 11193 } catch (e) { 11194 // Ignore exceptions, eg. for SVG elements which can't be 11195 // focused in IE11 11196 } 11197 } 11198 11199 content.trigger('lity:close', [self]); 11200 11201 element 11202 .removeClass('lity-opened') 11203 .addClass('lity-closed') 11204 ; 11205 11206 transitionEnd(content.add(element)) 11207 .always(function() { 11208 content.trigger('lity:remove', [self]); 11209 element.remove(); 11210 element = undefined; 11211 deferred.resolve(); 11212 }) 11213 ; 11214 11215 return deferred.promise(); 11216 }; 11217 11218 // -- Initialization -- 11219 11220 result = factory(target, self, options.handlers, options.handler); 11221 11222 element 11223 .attr(_attrAriaHidden, 'false') 11224 .addClass('lity-loading lity-opened lity-' + result.handler) 11225 .appendTo('body') 11226 .focus() 11227 .on('click', '[data-lity-close]', function(e) { 11228 if ($(e.target).is('[data-lity-close]')) { 11229 self.close(); 11230 } 11231 }) 11232 .trigger('lity:open', [self]) 11233 ; 11234 11235 registerInstance(self); 11236 11237 $.when(result.content) 11238 .always(ready) 11239 ; 11240 11241 function ready(result) { 11242 content = $(result) 11243 .css('max-height', winHeight() + 'px') 11244 ; 11245 11246 element 11247 .find('.lity-loader') 11248 .each(function() { 11249 var loader = $(this); 11250 11251 transitionEnd(loader) 11252 .always(function() { 11253 loader.remove(); 11254 }) 11255 ; 11256 }) 11257 ; 11258 11259 element 11260 .removeClass('lity-loading') 11261 .find('.lity-content') 11262 .empty() 11263 .append(content) 11264 ; 11265 11266 isReady = true; 11267 11268 content 11269 .trigger('lity:ready', [self]) 11270 ; 11271 } 11272 } 11273 11274 function lity(target, options, opener) { 11275 if (!target.preventDefault) { 11276 opener = $(opener); 11277 } else { 11278 target.preventDefault(); 11279 opener = $(this); 11280 target = opener.data('lity-target') || opener.attr('href') || opener.attr('src'); 11281 } 11282 11283 var instance = new Lity( 11284 target, 11285 $.extend( 11286 {}, 11287 opener.data('lity-options') || opener.data('lity'), 11288 options 11289 ), 11290 opener, 11291 document.activeElement 11292 ); 11293 11294 if (!target.preventDefault) { 11295 return instance; 11296 } 11297 } 11298 11299 lity.version = '2.2.2'; 11300 lity.options = $.proxy(settings, lity, _defaultOptions); 11301 lity.handlers = $.proxy(settings, lity, _defaultOptions.handlers); 11302 lity.current = currentInstance; 11303 11304 $(document).on('click.lity', '[data-lity]', lity); 11305 11306 return lity; 11307})); 11308; 11309 11310 /* $Id: composer_video.js 10258 2014-06-04 16:07:47Z lucas $ */ 11311(function() { // START NAMESPACE 11312 var $ = 'id' in document ? document.id : window.$; 11313 Composer.Plugin.Coursesvideo = function(options){ 11314 this.__proto__ = new Composer.Plugin.Interface(options) 11315 11316 this.name = 'coursesvideo'; 11317 this.options = { 11318 fullupload:"", 11319 title : 'Add Video', 11320 lang : {}, 11321 // Options for the link preview request 11322 requestOptions : {}, 11323 // Various image filtering options 11324 imageMaxAspect : ( 10 / 3 ), 11325 imageMinAspect : ( 3 / 10 ), 11326 imageMinSize : 48, 11327 imageMaxSize : 5000,
11328 imageMinPixels : 2304, 11329 imageMaxPixels : 1000000, 11330 imageTimeout : 5000, 11331 // Delay to detect links in input 11332 monitorDelay : 250 11333 }; 11334 this.initialize = function(options) { 11335 this.elements = new Hash(this.elements); 11336 this.params = new Hash(this.params); 11337 this.__proto__.initialize.call(this,scriptJquery.extend(options,this.__proto__.options)); 11338 } 11339 11340 this.attach = function() { 11341 this.__proto__.attach.call(this); 11342 this.makeActivator(); 11343 return this; 11344 } 11345 this.detach = function() { 11346 this.__proto__.detach.call(this); 11347 return this; 11348 } 11349 11350 this.activate = function() { 11351 if( this.active ) return; 11352 this.__proto__.activate.call(this); 11353 11354 this.makeMenu(); 11355 this.makeBody(); 11356 // Generate body contents 11357 // Generate form 11358 this.elements.formInput = scriptJquery.crtEle('select', { 11359 'id' : 'compose-video-form-type', 11360 'class' : 'compose-form-input', 11361 'option' : 'test', 11362 }).change(this.updateVideoFields.bind(this)).appendTo(this.elements.body); 11363 var options = 0; 11364 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11365 'value': 0, 11366 }).html(this._lang('Choose Source'))); 11367 if (this.options.iframelyCheck == 1) { 11368 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11369 'value': 1, 11370 }).html(this._lang('External Sites'))); 11371 } 11372 if (this.options.youtubeEnabled == 1 && this.options.youtubeCheck == 1) { 11373 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11374 'value': 1, 11375 }).html(this._lang('YouTube'))); 11376 } 11377 if (this.options.vimeoCheck == 1) { 11378 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11379 'value': 2, 11380 }).html(this._lang('Vimeo'))); 11381 } 11382 if (this.options.dailymotionCheck == 1) { 11383 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11384 'value': 4, 11385 }).html(this._lang('Dailymotion'))); 11386 } 11387 11388 11389 if (this.options.fromURL == 1) { 11390 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11391 'value': 16, 11392 }).html(this._lang('From URL'))); 11393 } 11394 if (this.options.embedcode == 1) { 11395 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11396 'value': 17, 11397 }).html(this._lang('From Embed Code'))); 11398 } 11399 if (this.options.fbembedcode == 1) { 11400 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11401 'value': 105, 11402 }).html(this._lang('Facebook Embed Code'))); 11403 } 11404 if (this.options.twitterembedcode == 1) { 11405 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11406 'value': 106, 11407 }).html(this._lang('Twitter Embed Code'))); 11408 } 11409 if (this.options.streamableembedcode == 1) { 11410 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11411 'value': 107, 11412 }).html(this._lang('Streamable Embed Code'))); 11413 } 11414 11415 this.elements.formInput = scriptJquery.crtEle('input', { 11416 'id' : 'compose-video-form-input', 11417 'class' : 'compose-form-input', 11418 'type' : 'text', 11419 'style': 'display:none;' 11420 }).appendTo(this.elements.body); 11421 11422 if(DetectMobileQuick() || DetectIpad()){ 11423 if (this.options.allowed == 1 && this.options.type != 'message' && this.options.myComputerCheck == 1){ 11424 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11425 'value': 3, 11426 }).html(this._lang('My Device'))); 11427 } 11428 this.elements.previewDescription = scriptJquery.crtEle('div', { 11429 'id' : 'compose-video-upload', 11430 'class' : 'compose-video-upload', 11431 'style': 'display:none;' 11432 }).html(this._lang(this.options.fullupload)).appendTo(this.elements.body); 11433 if(this.options.advancedactvity == 1) 11434 scriptJquery('#compose-video-upload').html('<input value="" type="file" name="video_upload" id="compose-video-upload-file">'); 11435 }else{ 11436 if (this.options.allowed == 1 && this.options.type != 'message' && this.options.myComputerCheck == 1){ 11437 scriptJquery('#compose-video-form-type').append(scriptJquery.crtEle('option',{ 11438 'value': 3, 11439 }).html(this._lang('My Computer'))); 11440 } 11441 this.elements.previewDescription = scriptJquery.crtEle('div', { 11442 'id' : 'compose-video-upload', 11443 'class' : 'compose-video-upload', 11444 'style': 'display:none;' 11445 }).html(this._lang(this.options.fullupload)).appendTo(this.elements.body); 11446 if(this.options.advancedactvity == 1) 11447 scriptJquery('#compose-video-upload').html('<input value="" type="file" name="video_upload" id="compose-video-upload-file">'); 11448 } 11449 this.elements.formSubmit = scriptJquery.crtEle('button', { 11450 'id' : 'compose-video-form-submit', 11451 'class' : 'compose-form-submit', 11452 'style': 'display:none;', 11453 }).html(this._lang('Attach')).click(function(e) { 11454 e.preventDefault(); 11455 this.doAttach(); 11456 }.bind(this)) 11457 .appendTo(this.elements.body); 11458 11459 this.elements.formInput.focus(); 11460 } 11461 this.deactivate = function() { 11462 // clean video out if not attached 11463 if (this.params.video_id) 11464 scriptJquery.ajax({ 11465 url: en4.core.basePath + 'coursesvideo/index/delete', 11466 data: { 11467 format: 'json', 11468 video_id: this.params.video_id 11469 } 11470 }); 11471 if( !this.active ) return; 11472 this.__proto__.deactivate.call(this); 11473 } 11474 // Getting into the core stuff now 11475 this.doAttach = function(e) { 11476 var val = this.elements.formInput.val(); 11477 if( !val && !scriptJquery('#compose-video-upload-file').val()) 11478 { 11479 return; 11480 } 11481 if( !val.match(/^[a-zA-Z]{1,5}:\/\//) ) 11482 { 11483 //val = 'http://' + val; 11484 } 11485 this.params.set('uri', val)
11486 // Input is empty, ignore attachment 11487 if( val == '' && !scriptJquery('#compose-video-upload-file').val()) { 11488 e.preventDefault(); 11489 return; 11490 } 11491 var video_element = document.getElementById("compose-video-form-type"); 11492 var type = video_element.value; 11493 var formData = new FormData(); 11494 if(scriptJquery('#compose-video-upload-file').length){ 11495 var filesAttach = scriptJquery('#compose-video-upload-file')[0].files[0]; 11496 }else{ 11497 var filesAttach = ""; 11498 } 11499 formData.append('Filedata', filesAttach); 11500 formData.append('format', 'json'); 11501 formData.append('uri', val); 11502 formData.append('type', type); 11503 formData.append('uploadwall', 1); 11504 if(type == 3) 11505 var url = this.options.requestOptions.uploadurl; 11506 else 11507 var url = this.options.requestOptions.url; 11508 // Send request to get attachment 11509 /*var options = $merge({ 11510 ' data' : { * 11511 'format' : 'json', 11512 'uri' : val, 11513 'type': type, 11514 Filedata:formData, 11515 }, 11516 'onComplete' : this.doProcessResponse.bind(this) 11517 }, this.options.requestOptions); 11518*/ 11519 var that = this; 11520 scriptJquery.ajax({ 11521 type:'POST', 11522 url: url, 11523 data:formData, 11524 cache:false, 11525 contentType: false, 11526 processData: false, 11527 success:function(data){ 11528 that.doProcessResponse(data); 11529 }, 11530 error: function(data){ 11531 //silence 11532 } 11533 }); 11534 11535 // Inject loading 11536 this.makeLoading('empty'); 11537 // Send request 11538 // this.request = new Request.JSON(options); 11539 // this.request; 11540 } 11541 this.doProcessResponse = function(responseJSON, responseText) { 11542 // Handle error 11543 if( ($type(responseJSON) != 'hash' && $type(responseJSON) != 'object') || $type(responseJSON.src) != 'string' || $type(parseInt(responseJSON.video_id)) != 'number' ) { 11544 //this.elements.body.empty(); 11545 if( this.elements.loading ) this.elements.loading.remove(); 11546 //this.makeaError(responseJSON.message, 'empty'); 11547 this.makeError(responseJSON.message); 11548 //compose-video-error 11549 //ignore test 11550 this.elements.ignoreValidation = scriptJquery.crtEle('a', { 11551 'href' : this.params.uri, 11552 }).html(this.params.title) 11553 .click(function(e) { 11554 e.preventDefault(); 11555 self.doAttach(this); 11556 }) 11557 .appendTo(this.elements.previewTitle); 11558 return; 11559 //throw "unable to upload image"; 11560 } 11561 var title = responseJSON.title || this.params.get('uri').replace('http://', ''); 11562 this.params.set('title', responseJSON.title); 11563 this.params.set('description', responseJSON.description); 11564 this.params.set('photo_id', responseJSON.photo_id); 11565 this.params.set('video_id', responseJSON.video_id); 11566 11567 if (responseJSON.src) { 11568 this.elements.preview = scriptJquery.crtEle('img', { 11569 'id' : 'compose-video-preview-image', 11570 'class' : 'compose-preview-image', 11571 'src' : responseJSON.src, 11572 }).load(this.doImageLoaded.bind(this)); 11573 } else { 11574 this.doImageLoaded(); 11575 } 11576 }, 11577 this.doImageLoaded = function() { 11578 var self = this; 11579 if( this.elements.loading.length) this.elements.loading.remove(); 11580 if( this.elements.preview ) { 11581 this.elements.preview.attr('width',''); 11582 this.elements.preview.attr('height',''); 11583 this.elements.preview.appendTo(this.elements.body); 11584 } 11585 11586 this.elements.previewInfo = scriptJquery.crtEle('div', { 11587 'id' : 'compose-video-preview-info', 11588 'class' : 'compose-preview-info' 11589 }).appendTo(this.elements.body); 11590 11591 this.elements.previewTitle = scriptJquery.crtEle('div', { 11592 'id' : 'compose-video-preview-title', 11593 'class' : 'compose-preview-title' 11594 }).appendTo(this.elements.previewInfo); 11595 11596 this.elements.previewTitleLink = scriptJquery.crtEle('a', { 11597 'href' : this.params.uri, 11598 }) 11599 .html(this.params.title) 11600 .click(function(e) { 11601 e.preventDefault(); 11602 self.handleEditTitle(this); 11603 }) 11604 .appendTo(this.elements.previewTitle); 11605 11606 this.elements.previewDescription = scriptJquery.crtEle('div', { 11607 'id' : 'compose-video-preview-description', 11608 'class' : 'compose-preview-description', 11609 }) 11610 .html(this.params.description) 11611 .click(function(e) { 11612 e.preventDefault(); 11613 self.handleEditDescription(this); 11614 }) 11615 .appendTo(this.elements.previewInfo); 11616 this.makeFormInputs(); 11617 } 11618 11619 this.makeFormInputs = function() { 11620 this.ready(); 11621 this.__proto__.makeFormInputs.call(this,{ 11622 'photo_id' : this.params.photo_id, 11623 'video_id' : this.params.video_id, 11624 'title' : this.params.title, 11625 'description' : this.params.description 11626 }); 11627 } 11628 this.updateVideoFields = function(element) { 11629 var video_element = document.getElementById("compose-video-form-type"); 11630 var url_element = document.getElementById("compose-video-form-input"); 11631 var post_element = document.getElementById("compose-video-form-submit"); 11632 var upload_element = document.getElementById("compose-video-upload"); 11633 // clear url if input field on change 11634 scriptJquery('#compose-video-form-input').val(""); 11635 // If video source is empty 11636 if (video_element.value == 0) 11637 { 11638 upload_element.style.display = "none"; 11639 post_element.style.display = "none"; 11640 url_element.style.display = "none"; 11641 } 11642 // If video source is youtube or vimeo 11643 if (video_element.value == 1 || video_element.value == 2 || video_element.value == 4 || video_element.value == 16 || video_element.value == 17 || video_element.value == 105 || video_element.value == 106 || video_element.value == 107 ) 11644 { 11645 upload_element.style.display = "none"; 11646 post_element.style.display = "block"; 11647 url_element.style.display = "block"; 11648 url_element.focus(); 11649 } 11650 // if video source is upload 11651 if (video_element.value == 3) 11652 { 11653 upload_element.style.display = "block"; 11654 if(this.options.advancedactvity == 1) 11655 post_element.style.display = "block"; 11656 else 11657 post_element.style.display = "none"; 11658 url_element.style.display = "none"; 11659 } 11660 } 11661 this.handleEditTitle = function(element) { 11662 element.css('display', 'none'); 11663 var input = scriptJquery.crtEle('input', { 11664 'type' : 'text', 11665 'value' : htmlspecialchars_decode(element.get('html').trim()), 11666 }) 11667 .blur(function() { 11668 if(input.value.trim() != '' ) { 11669 this.params.title = input.value; 11670 element.html(this.params.title); 11671 this.setFormInputValue('title', this.params.title); 11672 } 11673 element.css('display', ''); 11674 input.remove(); 11675 }.bind(this)) 11676 .insertAfter(element, 'after'); 11677 input.focus(); 11678 } 11679 this.handleEditDescription = function(element) { 11680 element.css('display', 'none'); 11681 var input = scriptJquery.crtEle('textarea', {}) 11682 .html(htmlspecialchars_decode(element.html().trim())) 11683 .blur(function() { 11684 if( input.val().trim() != '' ) { 11685 this.params.description = input.val(); 11686 element.html(this.params.description); 11687 this.setFormInputValue('description', this.params.description); 11688 } 11689 else{ 11690 this.params.description = ''; 11691 element.html(''); 11692 this.setFormInputValue('description', ''); 11693 } 11694 element.css('display', ''); 11695 input.remove(); 11696 }.bind(this)) 11697 .insertAfter(element, 'after'); 11698 input.focus(); 11699 } 11700 this.initialize(options); 11701 11702 } 11703})(); 11704; 11705 11706 //feed change user tabs work 11707function getClassroomSwitchData(obj,imageTab){ 11708 (scriptJquery.ajax({ 11709 dataType: 'html',
11710 url : en4.core.baseUrl + 'eclassroom/ajax/get-user-classrooms', 11711 data : { 11712 format : 'html', 11713 }, 11714 success: function(responseHTML) { 11715 imageTab.attr('src',scriptJquery(obj).attr('data-src')); 11716 scriptJquery('#eclassroom_switch_cnt').html(responseHTML); 11717 scriptJquery('#eclassroom_switch_cnt').show(); 11718 changeSwittcherPositionClassroom(obj); 11719 } 11720 })); 11721} 11722function changeSwittcherPositionClassroom(obj){ 11723 var position = scriptJquery(currentClickElem).offset(); 11724 scriptJquery('#eclassroom_switch_cnt').css('left',position.left); 11725 scriptJquery('#eclassroom_switch_cnt').css('top',position.top+24); 11726 markSwitcherCheckedClassroom(obj); 11727} 11728function markSwitcherCheckedClassroom(obj){ 11729 var dataRel = scriptJquery(obj).attr('data-rel'); 11730 scriptJquery('._selected').removeClass('_selected'); 11731 scriptJquery('.eclassroom_switcher_li[data-rel="'+dataRel+'"]').addClass('_selected'); 11732} 11733AttachEventListerSE('click','.eclassroom_switcher_li',function(e){ 11734 scriptJquery('#eclassroom_switch_cnt').hide(); 11735 changeUserImagesInCommentClassroom(this); 11736 closeSwitcherDivClassroom(); 11737 getCommentDataForChangeUserClassroom(this); 11738}) 11739function changeUserImagesInCommentClassroom(obj){ 11740 var data = scriptJquery(obj).attr('data-rel'); 11741 scriptJquery(currentClickElem).attr('data-rel',data); 11742 scriptJquery(currentClickElem).find('img').attr('src',scriptJquery(obj).find('div').find('img').attr('src')); 11743 scriptJquery(currentClickElem).attr('data-src',scriptJquery(obj).find('div').find('img').attr('src')); 11744 if(scriptJquery(currentClickElem).closest('#activity_post_box_status').length){ 11745 scriptJquery(currentClickElem).closest('#activity_post_box_status').find('.activity_post_box_img').find('a').find('img').attr('src',scriptJquery(obj).find('div').find('img').attr('src')); 11746 return; 11747 } 11748 scriptJquery(currentClickElem).closest('.comment-feed').find('.sesadvcmt_comments').find('form').find('.comments_author_photo').find('img').attr('src',scriptJquery(obj).find('div').find('img').attr('src')); 11749} 11750function getCommentDataForChangeUserClassroom(obj){ 11751 var action_id = scriptJquery(currentClickElem).attr('data-actionid'); 11752 var dataGuid = scriptJquery(currentClickElem).attr('data-rel'); 11753 var subject = scriptJquery(currentClickElem).attr('data-subject'); 11754 scriptJquery.ajax({ 11755 dataType: 'html', 11756 url : en4.core.baseUrl + 'comment/index/get-comment', 11757 data : { 11758 format : 'html', 11759 dataGuid:dataGuid, 11760 action_id:action_id, 11761 subject:subject, 11762 }, 11763 success: function(responseHTML) { 11764 var dataJson = scriptJquery.parseJSON(responseHTML); 11765 scriptJquery(currentClickElem).closest('.activity_comments').html(dataJson.body); 11766 //changeUserImagesInCommentClassroom(obj); 11767 } 11768 }); 11769} 11770function closeSwitcherDivClassroom(){ 11771 if(scriptJquery(currentClickElem).hasClass('active')){ 11772 scriptJquery(currentClickElem).removeClass('active'); 11773 scriptJquery('#eclassroom_switch_cnt').hide(); 11774 } 11775} 11776var currentClickElem = ""; 11777AttachEventListerSE('click','.eclassroom_feed_change_option',function(){ 11778 currentClickElem = scriptJquery(this).parent().find('.eclassroom_feed_change_option_a'); 11779 if(scriptJquery(currentClickElem).hasClass('active')){ 11780 closeSwitcherDivClassroom(); 11781 return; 11782 } 11783 scriptJquery(currentClickElem).addClass('active'); 11784 var classroomContentData = true; 11785 if(!scriptJquery('#eclassroom_switch_cnt').length) 11786 classroomContentData = false; 11787 var imageTab = scriptJquery(currentClickElem).find('img'); 11788 imageTab.attr('src','application/modules/Core/externals/images/loading.gif'); 11789 11790 if(!classroomContentData){ 11791 //create container div 11792 scriptJquery('<div id="eclassroom_switch_cnt" class="activity_owner_selector_pulldown sesbasic_bxs"></div>').appendTo('body'); 11793 getClassroomSwitchData(currentClickElem,imageTab); 11794 }else{ 11795 imageTab.attr('src',scriptJquery(currentClickElem).attr('data-src')); 11796 scriptJquery('#eclassroom_switch_cnt').show(); 11797 changeSwittcherPositionClassroom(currentClickElem); 11798 } 11799}); 11800AttachEventListerSE('click','.eclassroom_elem_cnt',function(){ 11801 scriptJquery(this).parent().trigger('click'); 11802}) 11803AttachEventListerSE('click',function (e){ 11804 var elem = scriptJquery('#eclassroom_switch_cnt'); 11805 if(!elem.has(e.target).length && !scriptJquery(e.target).hasClass('eclassroom_feed_change_option')){ 11806 closeSwitcherDivClassroom(); 11807 } 11808}) 11809//end feed switcher work 11810; 11811 11812 /* $Id: composer_photo.js 9930 2013-02-18 21:02:11Z jung $ */ 11813(function() { // START NAMESPACE 11814 var $ = 'id' in document ? document.id : window.$; 11815 Composer.Plugin.Eclassroomphoto = function(options){ 11816 11817 this.__proto__ = new Composer.Plugin.Interface(options); 11818 11819 this.name = 'eclassroom_photo' 11820 11821 this.options = { 11822 title : 'Add Photo', 11823 lang : {}, 11824 requestOptions : false, 11825 fancyUploadEnabled : true, 11826 fancyUploadOptions : {}, 11827 } 11828 11829 this.initialize = function(options) { 11830 this.elements = new Hash(this.elements); 11831 this.params = new Hash(this.params); 11832 this.__proto__.initialize.call(this,options); 11833 this.uploadedPhotos = []; 11834 } 11835 11836 this.attach = function() { 11837 this.__proto__.activate.call(this); 11838 this.makeActivator(); 11839 return this; 11840 } 11841 11842 this.detach = function() { 11843 this.__proto__.deactivate.call(this); 11844 return this; 11845 } 11846 11847 this.activate = function() { 11848 if( this.active && scriptJquery("#compose-photo-body").length > 0) return; 11849 this.__proto__.activate.call(this); 11850 11851 this.makeMenu(); 11852 this.makeBody(); 11853 11854 // Generate form 11855 var fullUrl = this.options.requestOptions.url; 11856 if(typeof sesAdvancedActivity == 'undefined'){ 11857 var fullUrl = this.options.requestOptions.url; 11858 var hasFlash = false;
11859 11860 this.elements.formFancyContainer = scriptJquery.crtEle('div', { 11861 }) 11862 .css({ 11863 'display' : 'none', 11864 'visibility' : 'hidden' 11865 }) 11866 .appendTo(this.elements.body); 11867 11868 this.elements.scrollContainer = scriptJquery.crtEle('div', { 11869 'class': 'scrollbars', 11870 }) 11871 .css({ 11872 'width' : this.elements.body.width() + 'px', 11873 }) 11874 .appendTo(this.elements.formFancyContainer); 11875 11876 // This is the list 11877 this.elements.formFancyList = scriptJquery.crtEle('ul', { 11878 'class': 'compose-photos-fancy-list', 11879 }).appendTo(this.elements.scrollContainer); 11880 11881 // This is the browse button 11882 this.elements.formFancyFile = scriptJquery.crtEle('div', { 11883 'id' : 'compose-photo-form-fancy-file', 11884 'class' : '', 11885 }).appendTo(this.elements.scrollContainer); 11886 11887 this.elements.selectFileLink = scriptJquery.crtEle('a', { 11888 'class' : 'buttonlink', 11889 }) 11890 .html(this._lang('Select File')) 11891 .css({ 11892 'cursor' : 'pointer' 11893 }) 11894 .appendTo(this.elements.formFancyFile); 11895 11896 // this.elements.scrollContainer.scrollbars({ 11897 // scrollBarSize: 5, 11898 // fade: true 11899 // }); 11900 11901 // Ajax Upload Work 11902 this.elements.formInput = scriptJquery.crtEle('input', { 11903 'id' : 'compose-photo-form-input', 11904 'class' : 'compose-form-input', 11905 'type' : 'file', 11906 'multiple': this.options.fancyUploadOptions.limitFiles != 1, 11907 'value': '', 11908 'accepts': 'images/*', 11909 }) 11910 .change(this.onFileSelectAfter.bind(this)) 11911 .appendTo(this.elements.scrollContainer); 11912 11913 bindEvent = window.matchMedia("(min-width: 400px)").matches ? 'click' : 'touchend'; 11914 this.elements.selectFileLink.on(bindEvent, this.onSelectFileClick.bind(this)); 11915 this.showForm(); 11916 if (en4.isMobile) { 11917 this.elements.scrollContainer.find("ul.scrollbar.vertical").addClass('inactive'); 11918 this.elements.scrollContainer.find("ul.scrollbar.horizontal").addClass('inactive'); 11919 } 11920 }else{ 11921 11922 scriptJquery(this.elements.body).html('<input type="file" accept="image/x-png,image/jpeg" onchange="readImageUrlSesalbum(this)" multiple="multiple" id="file_multi" name="file_multi" style="display:none"><div class="advact_compose_photo_container sesbasic_custom_horizontal_scroll sesbasic_clearfix"><div id="advact_compose_photo_container_inner" class="sesbasic_clearfix"><div id="show_photo"></div><div id="dragandrophandler" class="advact_compose_photo_uploader" title="Choose a file to upload"><i class="fa fa-plus"></i></div></div></div>'); 11923 } 11924 if(scriptJquery('#toValues-wrapper').length > 0 || scriptJquery('#submit-wrapper').length > 0){ 11925 //scriptJquery('#file_multi').removeAttr('multiple'); 11926 } 11927 if(scriptJquery('#toValues-wrapper').length > 0){ 11928 scriptJquery('#toValues-wrapper').append('<div><input type="hidden" value="1" id="messageAttachment" name="attachment[messageAttachment]"><input type="hidden" value="" id="fancyalbumuploadfileids" name="attachment[photo_id]"><input type="hidden" value="photo" id="photosesalbum" name="attachment[type]"></div>'); 11929 }else if(scriptJquery('#submit-wrapper').length > 0){ 11930 scriptJquery('#body-wrapper').append('<div><input type="hidden" value="1" id="messageAttachment" name="attachment[messageAttachment]"><input type="hidden" value="photo" id="photosesalbum" name="attachment[type]"><input type="hidden" value="" id="fancyalbumuploadfileids" name="attachment[photo_id]"></div>'); 11931 } 11932 11933 /* 11934 * this.elements.formSubmit = scriptJquery.crtEle('button', { 11935 * 'id' : 'compose-photo-form-submit', 11936 * 'class' : 'compose-form-submit', 11937 * 'html' : 'Attach', 11938 * 'events' : { 11939 * 'click' : function(e) { 11940 * e.stop(); 11941 * this.doAttach(); 11942 }.bind(this) 11943 } 11944 }).appendTo(this.elements.body); 11945*/ 11946 } 11947 11948 this.deactivate = function() { 11949 if( !this.active ) return; 11950 this.__proto__.deactivate.call(this); 11951 this.uploadedPhotos = []; 11952 scriptJquery('#fancyalbumuploadfileids').remove(); 11953 scriptJquery('#photosesalbum').remove(); 11954 scriptJquery('#messageAttachment').remove(); 11955 } 11956 11957 this.onSelectFileClick = function () { 11958 this.elements.formInput.click(); 11959 } 11960 11961 this.onFileSelectAfter = function() { 11962 this.elements.formFancyList.css("display",'inline-block'); 11963 this.getComposer().getMenu().css('display', 'none'); 11964 if (this.elements.formInput[0].files.length === 0) { 11965 return; 11966 } 11967 11968 var FileSize;
11969 var valid = true; 11970 this.elements.fileElement = []; 11971 this.elements.filePreview = []; 11972 this.elements.fileRemoveLink = []; 11973 for (var i = 0; i < this.elements.formInput[0].files.length; i++) { 11974 FileSize = this.elements.formInput[0].files[i].size / 1024 / 1024; // in MB 11975 if(FileSize > post_max_size) { 11976 valid = false; 11977 continue; 11978 } 11979 11980 if (!this.canUploadPhoto(this.elements.formInput[0].files[i])) { 11981 this.getComposer().getMenu().css('display', ''); 11982 continue; 11983 } 11984 this.elements.fileElement[i] = scriptJquery.crtEle('li', { 11985 'class' : 'file compose-photo-preview', 11986 }).appendTo(this.elements.formFancyList); 11987 11988 this.elements.filePreview[i] = scriptJquery.crtEle('span', { 11989 'class' : 'compose-photo-preview-image compose-photo-preview-loading', 11990 }).appendTo(this.elements.fileElement[i]); 11991 11992 var overlay = scriptJquery.crtEle('span', { 11993 'class' : 'compose-photo-preview-overlay', 11994 }).appendTo(this.elements.filePreview[i], 'after'); 11995 11996 this.elements.fileRemoveLink[i] = scriptJquery.crtEle('a', { 11997 'class': 'file-remove', 11998 title: 'Click to remove this entry.', 11999 }) 12000 .html('X') 12001 .appendTo(overlay); 12002 this.uploadFile(this.elements.formInput[0].files[i], i); 12003 12004 if (this.canUploadPhoto(null) !== true) { 12005 this.elements.formFancyFile.css('display', 'none'); 12006 break; 12007 } 12008 } 12009 12010 if(!valid) alert("The size of the file exceeds the limits set on the server."); 12011 12012 this.elements.formInput.val(''); 12013 this.updateScrollBar(); 12014 var scrollbarContent = this.elements.formFancyList.closest('.scrollbars'); 12015 scrollbarContent.scrollLeft(this.elements.formFancyFile.offset().left, scrollbarContent.scrollTop()); 12016 scrollbarContent.scrollTop(scrollbarContent.scrollTop()); 12017 } 12018 12019 this.uploadFile = function (file, iteration) { 12020 var xhr = new XMLHttpRequest(); 12021 var fd = new FormData(); 12022 xhr.open("POST", this.options.requestOptions.url, true); 12023 var composerInstance = this; 12024 xhr.onreadystatechange = function() { 12025 if (xhr.readyState === 4 && xhr.status === 200) { 12026 var res = JSON.parse(xhr.responseText); 12027 if (res['error'] !== undefined) { 12028 //return false; 12029 }else{ 12030 res['iteration'] = iteration; 12031 composerInstance.uploadedPhotos[res.photo_id] = res.fileName; 12032 } 12033 composerInstance.doProcessResponse(res); 12034 } 12035 }; 12036 fd.append('ajax-upload', 'true'); 12037 fd.append('Filedata', file); 12038 xhr.send(fd); 12039 } 12040 this.doProcessResponse = function(responseJSON, file) { 12041 if( typeof responseJSON == 'object' && typeof responseJSON.error != 'undefined' ) { 12042 if( this.elements.loading ) { 12043 this.elements.loading.remove(); 12044 } 12045 this.elements.body.empty(); 12046 return this.makeError(responseJSON.error, 'empty'); 12047 } 12048 12049 // An error occurred 12050 if( ($type(responseJSON) != 'hash' && $type(responseJSON) != 'object') || $type(responseJSON.src) != 'string' || $type(parseInt(responseJSON.photo_id)) != 'number' ) { 12051 this.elements.loading ? this.elements.loading.remove() : ''; 12052 this.elements.body.empty(); 12053 if( responseJSON.error == 'Invalid data' ) { 12054 this.makeError(this._lang('The image you tried to upload exceeds the maximum file size.'), 'empty'); 12055 } else { 12056 this.makeError(this._lang(responseJSON.error), 'empty'); 12057 } 12058 return; 12059 //throw "unable to upload image"; 12060 } 12061 12062 // Success 12063 if (file) { 12064 file = file || {}; 12065 file.rawParams = responseJSON; 12066 this.setPhotoId(responseJSON.photo_id); 12067 this.elements.preview = scriptJquery('img', { 12068 'id' : 'compose-photo-preview-image', 12069 'class' : 'compose-preview-image', 12070 'src' : responseJSON.src, 12071 }).load(function() { 12072 this.doImageLoaded(file); 12073 }.bind(this)); 12074 return; 12075 } 12076 // In case of ajax upload 12077 this.elements.filePreview[responseJSON['iteration']].removeClass('compose-photo-preview-loading'); 12078 this.elements.filePreview[responseJSON['iteration']].css( 12079 'backgroundImage', 12080 'url(' + responseJSON.src + ')' 12081 ); 12082 this.elements.fileRemoveLink[responseJSON['iteration']].attr('id', 'file_remove-' + responseJSON.photo_id); 12083 this.elements.fileRemoveLink[responseJSON['iteration']].on('click',this.removeFile.bind(this, responseJSON.photo_id)); 12084 12085 this.setPhotoId(responseJSON.photo_id); 12086 this.makeFormInputs(); 12087 } 12088 12089 this.removeFile = function(photo_id) { 12090 var composerInstance = this; 12091 scriptJquery('#file_remove-' + photo_id).parent().parent().parent().remove(); 12092 composerInstance.removePhoto(photo_id); 12093 delete composerInstance.uploadedPhotos[photo_id]; 12094 if (this.canUploadPhoto(null)) { 12095 this.elements.formFancyFile.css('display', ''); 12096 } 12097 setTimeout(function() {composerInstance.updateScrollBar();},1000); 12098 } 12099 this.doImageLoaded = function(file) { 12100 //compose-photo-error 12101 if(scriptJquery('#compose-photo-error').length){ 12102 scriptJquery('#compose-photo-error').remove(); 12103 } 12104 12105 if( this.elements.loading ) this.elements.loading.remove(); 12106 if( this.elements.formFancyContainer ) { 12107 file.preview.removeClass('compose-photo-preview-loading'); 12108 file.preview.css('backgroundImage', 'url(' + this.elements.preview.src + ')' ); 12109 } else { 12110 this.elements.preview.attr('width',''); 12111 this.elements.preview.attr('height',''); 12112 this.elements.preview.appendTo(this.elements.body); 12113 } 12114 if(this.allowToSetInInput) { 12115 this.makeFormInputs(); 12116 } 12117 } 12118 12119 this.removePhoto = function(removePhotoId) { 12120 this.setPhotoId(removePhotoId, 'remove'); 12121 var photo_id = this.setPhotoId(removePhotoId, 'remove'); 12122 const index = photo_id.indexOf(removePhotoId); 12123 if (index > -1) { 12124 photo_id.splice(index, 1); 12125 } 12126 if (photo_id.length === 0) { 12127 this.getComposer().deactivate(); 12128 this.activate(); 12129 return; 12130 } 12131 this.makeFormInputs(); 12132 } 12133 this.getPhotoIdsString = function() { 12134 var photo_id_str = '';
12135 this.params.photo_id.forEach(function(value) { 12136 photo_id_str += value + ','; 12137 }); 12138 return photo_id_str.substr(0, photo_id_str.length-1); 12139 } 12140 this.setPhotoId = function (photoId, action) { 12141 var photo_id = this.params.get('photo_id') || []; 12142 if (action === 'remove') { 12143 var index = photo_id.indexOf(photoId); 12144 if (index > -1) { 12145 photo_id.splice(index, 1); 12146 } 12147 } else { 12148 photo_id.push(photoId); 12149 } 12150 this.params.set('photo_id', photo_id); 12151 return photo_id; 12152 } 12153 this.showForm = function () { 12154 this.elements.formFancyContainer.css('display', ''); 12155 this.elements.formInput.css('display', 'none'); 12156 this.elements.formFancyContainer.css('visibility', 'visible'); 12157 } 12158 12159 this.canUploadPhoto = function (photo) { 12160 if (photo === null) { 12161 return this.options.fancyUploadOptions.limitFiles === 0 || 12162 scriptJquery('ul.compose-photos-fancy-list li').length < this.options.fancyUploadOptions.limitFiles; 12163 } 12164 if (this.uploadedPhotos.length === 0) { 12165 return true; 12166 } 12167 return this.uploadedPhotos.every(function (uploadedPhoto) { 12168 return uploadedPhoto !== photo.name; 12169 }); 12170 } 12171 12172 this.updateScrollBar = function () { 12173 var height = this.elements.formFancyFile.offsetHeight; 12174 if( height == 0 ) { 12175 height = 106; 12176 } 12177 var scrollbarContent = this.elements.formFancyList.parent(); 12178 scrollbarContent.css('height', height + 20); 12179 var li = this.elements.formFancyList.find('li'); 12180 scrollbarContent.css('width', ((li.width() + 11) * li.length) + this.elements.formFancyFile.height() + 10); 12181 //this.elements.scrollContainer.data('scrollbars').updateScrollBars(); 12182 scrollbarContent.parent().css('overflow', 'hidden'); 12183 } 12184 12185 // this.makeFormInputs = function() { 12186 // this.ready(); 12187 // this.__proto__.makeFormInputs.call(this,{ 12188 // 'photo_id' : this.params.photo_id, 12189 12190 // }); 12191 12192 // } 12193 this.makeFormInputs = function() { 12194 this.ready(); 12195 if( this.elements.has('attachmentFormPhoto_id') ) { 12196 return this.setFormInputValue('photo_id', this.getPhotoIdsString()); 12197 } 12198 12199 this.__proto__.makeFormInputs.call(this,{ 12200 'photo_id': this.getPhotoIdsString() 12201 }); 12202 } 12203 this.initialize(options); 12204 12205 }; 12206})(); // END NAMESPACE 12207; 12208 12209 /* $Id: composer_event.js 9930 2013-02-18 21:02:11Z jung $ */ 12210(function() { // START NAMESPACE 12211var $ = 'id' in document ? document.id : window.$; 12212Composer.Plugin.Elivestreaming = function(options){ 12213 12214 this.__proto__ = new Composer.Plugin.Interface(options); 12215 12216 this.name = 'elivestreaming' 12217 12218 this.options = { 12219 title : 'Live Video', 12220 url:'', 12221 lang : {} 12222 } 12223 12224 this.initialize = function(options) { 12225 this.elements = new Hash(this.elements); 12226 this.params = new Hash(this.params); 12227 this.__proto__.initialize.call(this,scriptJquery.extend(options,this.__proto__.options)); 12228 } 12229 12230 this.attach = function() { 12231 this.__proto__.attach.call(this); 12232 //this.parent(); 12233 this.makeActivator(); 12234 scriptJquery('#compose-elivestreaming-activator').addClass('elivestreaming_a').attr('href','javascript:;'); 12235 return this; 12236 } 12237 12238 this.detach = function() { 12239 this.__proto__.detach.call(this); 12240 //this.parent(); 12241 return this; 12242 } 12243 12244 this.activate = function() { 12245 if( this.active ) return; 12246 this.__proto__.activate.call(this); 12247 //this.parent(); 12248 // this.getComposer().getMenu().getElements('.compose-activator').each(function(element) { 12249 // element.setStyle('display', ''); 12250 // }); 12251 } 12252 12253 this.deactivate = function() { 12254 if (!this.active) 12255 return; 12256 this.__proto__.detach.call(this); 12257 //this.parent(); 12258 } 12259 12260}; 12261 12262 12263 12264})(); // END NAMESPACE 12265; 12266 12267 /** 12268 * AgoraWebSDK_N-v4.23.2-0-g1599fdac-dirty Copyright AgoraInc. 12269 */ 12270 12271!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).AgoraRTC=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(i){if("default"!==i&&!(i in e)){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}}))})),Object.freeze(e)}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};
12271function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n=function(e){try{return!!e()}catch(e){return!0}},r=!n((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),o=r,s=Function.prototype,a=s.call,c=o&&s.bind.bind(a,a),d=o?c:function(e){return function(){return a.apply(e,arguments)}},l=d({}.isPrototypeOf),u=function(e){return e&&e.Math==Math&&e},h=u("object"==typeof globalThis&&globalThis)||u("object"==typeof window&&window)||u("object"==typeof self&&self)||u("object"==typeof t&&t)||function(){return this}()||t||Function("return this")(),p=r,_=Function.prototype,E=_.apply,m=_.call,f="object"==typeof Reflect&&Reflect.apply||(p?m.bind(E):function(){return m.apply(E,arguments)}),T=d,S=T({}.toString),g=T("".slice),R=function(e){return g(S(e),8,-1)},v=R,C=d,I=function(e){if("Function"===v(e))return C(e)},y="object"==typeof document&&document.all,A={all:y,IS_HTMLDDA:void 0===y&&void 0!==y},b=A.all,w=A.IS_HTMLDDA?function(e){return"function"==typeof e||e===b}:function(e){return"function"==typeof e},O={},N=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),D=r,P=Function.prototype.call,L=D?P.bind(P):function(){return P.apply(P,arguments)},k={},M={}.propertyIsEnumerable,U=Object.getOwnPropertyDescriptor,x=U&&!M.call({1:2},1);k.f=x?function(e){var t=U(this,e);return!!t&&t.enumerable}:M;var V,F,B=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},j=n,G=R,W=Object,H=d("".split),K=j((function(){return!W("z").propertyIsEnumerable(0)}))?function(e){return"String"==G(e)?H(e,""):W(e)}:W,Y=function(e){return null==e},q=Y,z=TypeError,X=function(e){if(q(e))throw z("Can't call method on "+e);return e},J=K,Q=X,Z=function(e){return J(Q(e))},$=w,ee=A.all,te=A.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:$(e)||e===ee}:function(e){return"object"==typeof e?null!==e:$(e)},ie={},ne=ie,re=h,oe=w,se=function(e){return oe(e)?e:void 0},ae=function(e,t){return arguments.length<2?se(ne[e])||se(re[e]):ne[e]&&ne[e][t]||re[e]&&re[e][t]},ce="undefined"!=typeof navigator&&String(navigator.userAgent)||"",de=h,le=ce,ue=de.process,he=de.Deno,pe=ue&&ue.versions||he&&he.version,_e=pe&&pe.v8;_e&&(F=(V=_e.split("."))[0]>0&&V[0]<4?1:+(V[0]+V[1])),!F&&le&&(!(V=le.match(/Edge\/(\d+)/))||V[1]>=74)&&(V=le.match(/Chrome\/(\d+)/))&&(F=+V[1]);var Ee=F,me=Ee,fe=n,Te=h.String,Se=!!Object.getOwnPropertySymbols&&!fe((function(){var e=Symbol();return!Te(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&me&&me<41})),ge=Se&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Re=ae,ve=w,Ce=l,Ie=Object,ye=ge?function(e){return"symbol"==typeof e}:function(e){var t=Re("Symbol");return ve(t)&&Ce(t.prototype,Ie(e))},Ae=String,be=function(e){try{return Ae(e)}catch(e){return"Object"}},we=w,Oe=be,Ne=TypeError,De=function(e){if(we(e))return e;throw Ne(Oe(e)+" is not a function")},Pe=De,Le=Y,ke=function(e,t){var i=e[t];return Le(i)?void 0:Pe(i)},Me=L,Ue=w,xe=te,Ve=TypeError,Fe={exports:{}},Be=h,je=Object.defineProperty,Ge=function(e,t){try{je(Be,e,{value:t,configurable:!0,writable:!0})}catch(i){Be[e]=t}return t},We="__core-js_shared__",He=h[We]||Ge(We,{}),Ke=He;(Fe.exports=function(e,t){return Ke[e]||(Ke[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.31.1",mode:"pure",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Ye=Fe.exports,qe=X,ze=Object,Xe=function(e){return ze(qe(e))},Je=Xe,Qe=d({}.hasOwnProperty),Ze=Object.hasOwn||function(e,t){return Qe(Je(e),t)},$e=d,et=0,tt=Math.random(),it=$e(1..toString),nt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+it(++et+tt,36)},rt=Ye,ot=Ze,st=nt,at=Se,ct=ge,dt=h.Symbol,lt=rt("wks"),ut=ct?dt.for||dt:dt&&dt.withoutSetter||st,ht=function(e){return ot(lt,e)||(lt[e]=at&&ot(dt,e)?dt[e]:ut("Symbol."+e)),lt[e]},pt=L,_t=te,Et=ye,mt=ke,ft=function(e,t){var i,n;if("string"===t&&Ue(i=e.toString)&&!xe(n=Me(i,e)))return n;if(Ue(i=e.valueOf)&&!xe(n=Me(i,e)))return n;if("string"!==t&&Ue(i=e.toString)&&!xe(n=Me(i,e)))return n;throw Ve("Can't convert object to primitive value")},Tt=TypeError,St=ht("toPrimitive"),gt=function(e,t){if(!_t(e)||Et(e))return e;var i,n=mt(e,St);if(n){if(void 0===t&&(t="default"),i=pt(n,e,t),!_t(i)||Et(i))return i;throw Tt("Can't convert object to primitive value")}return void 0===t&&(t="number"),ft(e,t)},Rt=ye,vt=function(e){var t=gt(e,"string");return Rt(t)?t:t+""},Ct=te,It=h.document,yt=Ct(It)&&Ct(It.createElement),At=function(e){return yt?It.createElement(e):{}},bt=At,wt=!N&&!n((function(){return 7!=Object.defineProperty(bt("div"),"a",{get:function(){return 7}}).a}
12271)),Ot=N,Nt=L,Dt=k,Pt=B,Lt=Z,kt=vt,Mt=Ze,Ut=wt,xt=Object.getOwnPropertyDescriptor;O.f=Ot?xt:function(e,t){if(e=Lt(e),t=kt(t),Ut)try{return xt(e,t)}catch(e){}if(Mt(e,t))return Pt(!Nt(Dt.f,e,t),e[t])};var Vt=n,Ft=w,Bt=/#|\.prototype\./,jt=function(e,t){var i=Wt[Gt(e)];return i==Kt||i!=Ht&&(Ft(t)?Vt(t):!!t)},Gt=jt.normalize=function(e){return String(e).replace(Bt,".").toLowerCase()},Wt=jt.data={},Ht=jt.NATIVE="N",Kt=jt.POLYFILL="P",Yt=jt,qt=De,zt=r,Xt=I(I.bind),Jt=function(e,t){return qt(e),void 0===t?e:zt?Xt(e,t):function(){return e.apply(t,arguments)}},Qt={},Zt=N&&n((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),$t=te,ei=String,ti=TypeError,ii=function(e){if($t(e))return e;throw ti(ei(e)+" is not an object")},ni=N,ri=wt,oi=Zt,si=ii,ai=vt,ci=TypeError,di=Object.defineProperty,li=Object.getOwnPropertyDescriptor,ui="enumerable",hi="configurable",pi="writable";Qt.f=ni?oi?function(e,t,i){if(si(e),t=ai(t),si(i),"function"==typeof e&&"prototype"===t&&"value"in i&&pi in i&&!i[pi]){var n=li(e,t);n&&n[pi]&&(e[t]=i.value,i={configurable:hi in i?i[hi]:n[hi],enumerable:ui in i?i[ui]:n[ui],writable:!1})}return di(e,t,i)}:di:function(e,t,i){if(si(e),t=ai(t),si(i),ri)try{return di(e,t,i)}catch(e){}if("get"in i||"set"in i)throw ci("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var _i=Qt,Ei=B,mi=N?function(e,t,i){return _i.f(e,t,Ei(1,i))}:function(e,t,i){return e[t]=i,e},fi=h,Ti=f,Si=I,gi=w,Ri=O.f,vi=Yt,Ci=ie,Ii=Jt,yi=mi,Ai=Ze,bi=function(e){var t=function(i,n,r){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(i);case 2:return new e(i,n)}return new e(i,n,r)}return Ti(e,this,arguments)};return t.prototype=e.prototype,t},wi=function(e,t){var i,n,r,o,s,a,c,d,l,u=e.target,h=e.global,p=e.stat,_=e.proto,E=h?fi:p?fi[u]:(fi[u]||{}).prototype,m=h?Ci:Ci[u]||yi(Ci,u,{})[u],f=m.prototype;for(o in t)n=!(i=vi(h?o:u+(p?".":"#")+o,e.forced))&&E&&Ai(E,o),a=m[o],n&&(c=e.dontCallGetSet?(l=Ri(E,o))&&l.value:E[o]),s=n&&c?c:t[o],n&&typeof a==typeof s||(d=e.bind&&n?Ii(s,fi):e.wrap&&n?bi(s):_&&gi(s)?Si(s):s,(e.sham||s&&s.sham||a&&a.sham)&&yi(d,"sham",!0),yi(m,o,d),_&&(Ai(Ci,r=u+"Prototype")||yi(Ci,r,{}),yi(Ci[r],o,s),e.real&&f&&(i||!f[o])&&yi(f,o,s)))},Oi=Math.ceil,Ni=Math.floor,Di=Math.trunc||function(e){var t=+e;return(t>0?Ni:Oi)(t)},Pi=Di,Li=function(e){var t=+e;return t!=t||0===t?0:Pi(t)},ki=Li,Mi=Math.max,Ui=Math.min,xi=function(e,t){var i=ki(e);return i<0?Mi(i+t,0):Ui(i,t)},Vi=Li,Fi=Math.min,Bi=function(e){return e>0?Fi(Vi(e),9007199254740991):0},ji=Bi,Gi=function(e){return ji(e.length)},Wi=Z,Hi=xi,Ki=Gi,Yi=function(e){return function(t,i,n){var r,o=Wi(t),s=Ki(o),a=Hi(n,s);if(e&&i!=i){for(;s>a;)if((r=o[a++])!=r)return!0}else for(;s>a;a++)if((e||a in o)&&o[a]===i)return e||a||0;return!e&&-1}},qi={includes:Yi(!0),indexOf:Yi(!1)},zi=qi.includes;wi({target:"Array",proto:!0,forced:n((function(){return!Array(1).includes()}))},{includes:function(e){return zi(this,e,arguments.length>1?arguments[1]:void 0)}});var Xi=ie,Ji=function(e){return Xi[e+"Prototype"]},Qi=Ji("Array").includes,Zi=te,$i=R,en=ht("match"),tn=function(e){var t;return Zi(e)&&(void 0!==(t=e[en])?!!t:"RegExp"==$i(e))},nn=tn,rn=TypeError,on={};on[ht("toStringTag")]="z";var sn="[object z]"===String(on),an=sn,cn=w,dn=R,ln=ht("toStringTag"),un=Object,hn="Arguments"==dn(function(){return arguments}()),pn=an?dn:function(e){var t,i,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(i=function(e,t){try{return e[t]}catch(e){}}(t=un(e),ln))?i:hn?dn(t):"Object"==(n=dn(t))&&cn(t.callee)?"Arguments":n},_n=pn,En=String,mn=function(e){if("Symbol"===_n(e))throw TypeError("Cannot convert a Symbol value to a string");return En(e)},fn=ht("match"),Tn=wi,Sn=function(e){if(nn(e))throw rn("The method doesn't accept regular expressions");return e},gn=X,Rn=mn,vn=function(e){var t=/./;try{"/./"[e](t)}catch(i){try{return t[fn]=!1,"/./"[e](t)}catch(e){}}return!1},Cn=d("".indexOf);Tn({target:"String",proto:!0,forced:!vn("includes")},{includes:function(e){return!!~Cn(Rn(gn(this)),Rn(Sn(e)),arguments.length>1?arguments[1]:void 0)}});
vendor: 4,729 bytes, line 12271
12271var In=Ji("String").includes,yn=l,An=Qi,bn=In,wn=Array.prototype,On=String.prototype,Nn=function(e){var t=e.includes;return e===wn||yn(wn,e)&&t===wn.includes?An:"string"==typeof e||e===On||yn(On,e)&&t===On.includes?bn:t},Dn=i(Nn),Pn=De,Ln=Xe,kn=K,Mn=Gi,Un=TypeError,xn=function(e){return function(t,i,n,r){Pn(i);var o=Ln(t),s=kn(o),a=Mn(o),c=e?a-1:0,d=e?-1:1;if(n<2)for(;;){if(c in s){r=s[c],c+=d;break}if(c+=d,e?c<0:a<=c)throw Un("Reduce of empty array with no initial value")}for(;e?c>=0:a>c;c+=d)c in s&&(r=i(r,s[c],c,o));return r}},Vn={left:xn(!1),right:xn(!0)},Fn=n,Bn=function(e,t){var i=[][e];return!!i&&Fn((function(){i.call(null,t||function(){return 1},1)}))},jn="undefined"!=typeof process&&"process"==R(process),Gn=Vn.left;wi({target:"Array",proto:!0,forced:!jn&&Ee>79&&Ee<83||!Bn("reduce")},{reduce:function(e){var t=arguments.length;return Gn(this,e,t,t>1?arguments[1]:void 0)}});var Wn=Ji("Array").reduce,Hn=l,Kn=Wn,Yn=Array.prototype,qn=function(e){var t=e.reduce;return e===Yn||Hn(Yn,e)&&t===Yn.reduce?Kn:t},zn=qn,Xn=i(zn),Jn=R,Qn=Array.isArray||function(e){return"Array"==Jn(e)},Zn=wi,$n=Qn,er=d([].reverse),tr=[1,2];Zn({target:"Array",proto:!0,forced:String(tr)===String(tr.reverse())},{reverse:function(){return $n(this)&&(this.length=this.length),er(this)}});var ir=Ji("Array").reverse,nr=l,rr=ir,or=Array.prototype,sr=function(e){var t=e.reverse;return e===or||nr(or,e)&&t===or.reverse?rr:t},ar=sr,cr=i(ar),dr=nt,lr=Ye("keys"),ur=function(e){return lr[e]||(lr[e]=dr(e))},hr=!n((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),pr=Ze,_r=w,Er=Xe,mr=hr,fr=ur("IE_PROTO"),Tr=Object,Sr=Tr.prototype,gr=mr?Tr.getPrototypeOf:function(e){var t=Er(e);if(pr(t,fr))return t[fr];var i=t.constructor;return _r(i)&&t instanceof i?i.prototype:t instanceof Tr?Sr:null},Rr=d,vr=De,Cr=w,Ir=String,yr=TypeError,Ar=function(e,t,i){try{return Rr(vr(Object.getOwnPropertyDescriptor(e,t)[i]))}catch(e){}},br=ii,wr=function(e){if("object"==typeof e||Cr(e))return e;throw yr("Can't set "+Ir(e)+" as a prototype")},Or=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,i={};try{(e=Ar(Object.prototype,"__proto__","set"))(i,[]),t=i instanceof Array}catch(e){}return function(i,n){return br(i),wr(n),t?e(i,n):i.__proto__=n,i}}():void 0),Nr={},Dr={},Pr=Ze,Lr=Z,kr=qi.indexOf,Mr=Dr,Ur=d([].push),xr=function(e,t){var i,n=Lr(e),r=0,o=[];for(i in n)!Pr(Mr,i)&&Pr(n,i)&&Ur(o,i);for(;t.length>r;)Pr(n,i=t[r++])&&(~kr(o,i)||Ur(o,i));return o},Vr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Fr=xr,Br=Vr.concat("length","prototype");Nr.f=Object.getOwnPropertyNames||function(e){return Fr(e,Br)};var jr={};jr.f=Object.getOwnPropertySymbols;var Gr=ae,Wr=Nr,Hr=jr,Kr=ii,Yr=d([].concat),qr=Gr("Reflect","ownKeys")||function(e){var t=Wr.f(Kr(e)),i=Hr.f;return i?Yr(t,i(e)):t},zr=Ze,Xr=qr,Jr=O,Qr=Qt,Zr={},$r=xr,eo=Vr,to=Object.keys||function(e){return $r(e,eo)},io=N,no=Zt,ro=Qt,oo=ii,so=Z,ao=to;Zr.f=io&&!no?Object.defineProperties:function(e,t){oo(e);for(var i,n=so(t),r=ao(t),o=r.length,s=0;o>s;)ro.f(e,i=r[s++],n[i]);return e};var co,lo=ae("document","documentElement"),uo=ii,ho=Zr,po=Vr,_o=Dr,Eo=lo,mo=At,fo="prototype",To="script",So=ur("IE_PROTO"),go=function(){},Ro=function(e){return"<"+To+">"+e+"</"+To+">"},vo=function(e){e.write(Ro("")),e.close();var t=e.parentWindow.Object;return e=null,t},Co=function(){try{co=new ActiveXObject("htmlfile")}catch(e){}var e,t,i;Co="undefined"!=typeof document?document.domain&&co?vo(co):(t=mo("iframe"),i="java"+To+":",t.style.display="none",Eo.appendChild(t),t.src=String(i),(e=t.contentWindow.document).open(),e.write(Ro("document.F=Object")),e.close(),e.F):vo(co);for(var n=po.length;n--;)delete Co[fo][po[n]];return Co()};_o[So]=!0;var Io=Object.create||function(e,t){var i;return null!==e?(go[fo]=uo(e),i=new go,go[fo]=null,i[So]=e):i=Co(),void 0===t?i:ho.f(i,t)},yo=te,Ao=mi,bo=Error,wo=d("".replace),Oo=String(bo("zxcasd").stack),No=/\n\s*at [^:]*:[^\n]*/,Do=No.test(Oo),Po=B,Lo=!n((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Po(1,7)),7!==e.stack)})),ko=mi,Mo=function(e,t){if(Do&&"string"==typeof e&&!bo.prepareStackTrace)for(;t--;)e=wo(e,No,"");return e},Uo=Lo,xo=Error.captureStackTrace,Vo={},Fo=Vo,Bo=ht("iterator"),jo=Array.prototype,Go=function(e){return void 0!==e&&(Fo.Array===e||jo[Bo]===e)},Wo=pn,Ho=ke,Ko=Y,Yo=Vo,qo=ht("iterator"),zo=function(e){if(!Ko(e))return Ho(e,qo)||Ho(e,"@@iterator")||Yo[Wo(e)]},Xo=L,Jo=De,Qo=ii,Zo=be,$o=zo,es=TypeError,ts=function(e,t){var i=arguments.length<2?$o(e):t;if(Jo(i))return Qo(Xo(i,e));throw es(Zo(e)+" is not iterable")},is=L,ns=ii,rs=ke,os=function(e,t,i){var n,r;ns(e);
12271try{if(!(n=rs(e,"return"))){if("throw"===t)throw i;return i}n=is(n,e)}catch(e){r=!0,n=e}if("throw"===t)throw i;if(r)throw n;return ns(n),i},ss=Jt,as=L,cs=ii,ds=be,ls=Go,us=Gi,hs=l,ps=ts,_s=zo,Es=os,ms=TypeError,fs=function(e,t){this.stopped=e,this.result=t},Ts=fs.prototype,Ss=function(e,t,i){var n,r,o,s,a,c,d,l=i&&i.that,u=!(!i||!i.AS_ENTRIES),h=!(!i||!i.IS_RECORD),p=!(!i||!i.IS_ITERATOR),_=!(!i||!i.INTERRUPTED),E=ss(t,l),m=function(e){return n&&Es(n,"normal",e),new fs(!0,e)},f=function(e){return u?(cs(e),_?E(e[0],e[1],m):E(e[0],e[1])):_?E(e,m):E(e)};if(h)n=e.iterator;else if(p)n=e;else{if(!(r=_s(e)))throw ms(ds(e)+" is not iterable");if(ls(r)){for(o=0,s=us(e);s>o;o++)if((a=f(e[o]))&&hs(Ts,a))return a;return new fs(!1)}n=ps(e,r)}for(c=h?e.next:n.next;!(d=as(c,n)).done;){try{a=f(d.value)}catch(e){Es(n,"throw",e)}if("object"==typeof a&&a&&hs(Ts,a))return a}return new fs(!1)},gs=mn,Rs=wi,vs=l,Cs=gr,Is=Or,ys=function(e,t,i){for(var n=Xr(t),r=Qr.f,o=Jr.f,s=0;s<n.length;s++){var a=n[s];zr(e,a)||i&&zr(i,a)||r(e,a,o(t,a))}},As=Io,bs=mi,ws=B,Os=function(e,t){yo(t)&&"cause"in t&&Ao(e,"cause",t.cause)},Ns=function(e,t,i,n){Uo&&(xo?xo(e,t):ko(e,"stack",Mo(i,n)))},Ds=Ss,Ps=function(e,t){return void 0===e?arguments.length<2?"":t:gs(e)},Ls=ht("toStringTag"),ks=Error,Ms=[].push,Us=function(e,t){var i,n=vs(xs,this);Is?i=Is(ks(),n?Cs(this):xs):(i=n?this:As(xs),bs(i,Ls,"Error")),void 0!==t&&bs(i,"message",Ps(t)),Ns(i,Us,i.stack,1),arguments.length>2&&Os(i,arguments[2]);var r=[];return Ds(e,Ms,{that:r}),bs(i,"errors",r),i};Is?Is(Us,ks):ys(Us,ks,{name:!0});var xs=Us.prototype=As(ks.prototype,{constructor:ws(1,Us),message:ws(1,""),name:ws(1,"AggregateError")});Rs({global:!0,constructor:!0,arity:2},{AggregateError:Us});var Vs,Fs,Bs,js=w,Gs=h.WeakMap,Ws=js(Gs)&&/native code/.test(String(Gs)),Hs=h,Ks=te,Ys=mi,qs=Ze,zs=He,Xs=ur,Js=Dr,Qs="Object already initialized",Zs=Hs.TypeError,$s=Hs.WeakMap;if(Ws||zs.state){var ea=zs.state||(zs.state=new $s);ea.get=ea.get,ea.has=ea.has,ea.set=ea.set,Vs=function(e,t){if(ea.has(e))throw Zs(Qs);return t.facade=e,ea.set(e,t),t},Fs=function(e){return ea.get(e)||{}},Bs=function(e){return ea.has(e)}}else{var ta=Xs("state");Js[ta]=!0,Vs=function(e,t){if(qs(e,ta))throw Zs(Qs);return t.facade=e,Ys(e,ta,t),t},Fs=function(e){return qs(e,ta)?e[ta]:{}},Bs=function(e){return qs(e,ta)}}var ia,na,ra,oa={set:Vs,get:Fs,has:Bs,enforce:function(e){return Bs(e)?Fs(e):Vs(e,{})},getterFor:function(e){return function(t){var i;if(!Ks(t)||(i=Fs(t)).type!==e)throw Zs("Incompatible receiver, "+e+" required");return i}}},sa=N,aa=Ze,ca=Function.prototype,da=sa&&Object.getOwnPropertyDescriptor,la=aa(ca,"name"),ua={EXISTS:la,PROPER:la&&"something"===function(){}.name,CONFIGURABLE:la&&(!sa||sa&&da(ca,"name").configurable)},ha=mi,pa=function(e,t,i,n){return n&&n.enumerable?e[t]=i:ha(e,t,i),e},_a=n,Ea=w,ma=te,fa=Io,Ta=gr,Sa=pa,ga=ht("iterator"),Ra=!1;[].keys&&("next"in(ra=[].keys())?(na=Ta(Ta(ra)))!==Object.prototype&&(ia=na):Ra=!0);var va=!ma(ia)||_a((function(){var e={};return ia[ga].call(e)!==e}));Ea((ia=va?{}:fa(ia))[ga])||Sa(ia,ga,(function(){return this}));var Ca={IteratorPrototype:ia,BUGGY_SAFARI_ITERATORS:Ra},Ia=pn,ya=sn?{}.toString:function(){return"[object "+Ia(this)+"]"},Aa=sn,ba=Qt.f,wa=mi,Oa=Ze,Na=ya,Da=ht("toStringTag"),Pa=function(e,t,i,n){if(e){var r=i?e:e.prototype;Oa(r,Da)||ba(r,Da,{configurable:!0,value:t}),n&&!Aa&&wa(r,"toString",Na)}},La=Ca.IteratorPrototype,ka=Io,Ma=B,Ua=Pa,xa=Vo,Va=function(){return this},Fa=function(e,t,i,n){var r=t+" Iterator";return e.prototype=ka(La,{next:Ma(+!n,i)}),Ua(e,r,!1,!0),xa[r]=Va,e},Ba=wi,ja=L,Ga=ua,Wa=Fa,Ha=gr,Ka=Pa,Ya=pa,qa=Vo,za=Ca,Xa=Ga.PROPER,Ja=za.BUGGY_SAFARI_ITERATORS,Qa=ht("iterator"),Za="keys",$a="values",ec="entries",tc=function(){return this},ic=function(e,t,i,n,r,o,s){Wa(i,t,n);var a,c,d,l=function(e){if(e===r&&E)return E;if(!Ja&&e in p)return p[e];switch(e){case Za:case $a:case ec:return function(){return new i(this,e)}}return function(){return new i(this)}},u=t+" Iterator",h=!1,p=e.prototype,_=p[Qa]||p["@@iterator"]||r&&p[r],E=!Ja&&_||l(r),m="Array"==t&&p.entries||_;if(m&&(a=Ha(m.call(new e)))!==Object.prototype&&a.next&&(Ka(a,u,!0,!0),qa[u]=tc),Xa&&r==$a&&_&&_.name!==$a&&(h=!0,E=function(){return ja(_,this)}),r)if(c={values:l($a),keys:o?E:l(Za),entries:l(ec)},s)for(d in c)(Ja||h||!(d in p))&&Ya(p,d,c[d]);else Ba({target:t,proto:!0,forced:Ja||h},c);return s&&p[Qa]!==E&&Ya(p,Qa,E,{name:r}),qa[t]=E,c},nc=function(e,t){return{value:e,done:t}},rc=Z,oc=Vo,sc=oa;Qt.f;var ac=ic,cc=nc,dc="Array Iterator",lc=sc.set,uc=sc.getterFor(dc);ac(Array,"Array",(function(e,t){lc(this,{type:dc,target:rc(e),index:0,kind:t})}),(function(){var e=uc(this),t=e.target,i=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,cc(void 0,!0)):cc("keys"==i?n:"values"==i?t[n]:[n,t[n]],!1)}),"values"),oc.Arguments=oc.Array;var hc=Qt,pc=function(e,t,i){return hc.f(e,t,i)},_c=ae,Ec=pc,mc=N,fc=ht("species"),Tc=l,Sc=TypeError,gc=function(e,t){if(Tc(t,e))return e;throw Sc("Incorrect invocation")},Rc=w,vc=He,Cc=d(Function.toString);Rc(vc.inspectSource)||(vc.inspectSource=function(e){return Cc(e)});var Ic=vc.inspectSource,yc=d,Ac=n,bc=w,wc=pn,Oc=Ic,Nc=function(){},Dc=[],Pc=ae("Reflect","construct"),Lc=/^\s*(?:class|function)\b/,kc=yc(Lc.exec),Mc=!Lc.exec(Nc),Uc=function(e){if(!bc(e))return!1;try{return Pc(Nc,Dc,e),!0}catch(e){return!1}},xc=function(e){if(!bc(e))return!1;switch(wc(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Mc||!!kc(Lc,Oc(e))}catch(e){return!0}};xc.sham=!0;var Vc,Fc,Bc,jc,Gc=!Pc||Ac((function(){var e;return Uc(Uc.call)||!Uc(Object)||!Uc((function(){e=!0}))||e}))?xc:Uc,Wc=Gc,Hc=be,Kc=TypeError,Yc=ii,qc=function(e){if(Wc(e))return e;throw Kc(Hc(e)+" is not a constructor")},zc=Y,Xc=ht("species"),Jc=function(e,t){var i,n=Yc(e).constructor;return void 0===n||zc(i=Yc(n)[Xc])?t:qc(i)},Qc=d([].slice),Zc=TypeError,$c=function(e,t){if(e<t)throw Zc("Not enough arguments");return e},ed=/(?:ipad|iphone|ipod).*applewebkit/i.test(ce),td=h,id=f,nd=Jt,rd=w,od=Ze,sd=n,ad=lo,cd=Qc,dd=At,ld=$c,ud=ed,hd=jn,pd=td.setImmediate,_d=td.clearImmediate,Ed=td.process,md=td.Dispatch,fd=td.Function,Td=td.MessageChannel,Sd=td.String,gd=0,Rd={},vd="onreadystatechange";sd((function(){Vc=td.location}));var Cd=function(e){if(od(Rd,e)){var t=Rd[e];delete Rd[e],t()}},Id=function(e){return function(){Cd(e)}},yd=function(e){Cd(e.data)},Ad=function(e){td.postMessage(Sd(e),Vc.protocol+"//"+Vc.host)};pd&&_d||(pd=function(e){ld(arguments.length,1);
vendor: 4,423 bytes, line 12271
12271var t=rd(e)?e:fd(e),i=cd(arguments,1);return Rd[++gd]=function(){id(t,void 0,i)},Fc(gd),gd},_d=function(e){delete Rd[e]},hd?Fc=function(e){Ed.nextTick(Id(e))}:md&&md.now?Fc=function(e){md.now(Id(e))}:Td&&!ud?(jc=(Bc=new Td).port2,Bc.port1.onmessage=yd,Fc=nd(jc.postMessage,jc)):td.addEventListener&&rd(td.postMessage)&&!td.importScripts&&Vc&&"file:"!==Vc.protocol&&!sd(Ad)?(Fc=Ad,td.addEventListener("message",yd,!1)):Fc=vd in dd("script")?function(e){ad.appendChild(dd("script"))[vd]=function(){ad.removeChild(this),Cd(e)}}:function(e){setTimeout(Id(e),0)});var bd={set:pd,clear:_d},wd=function(){this.head=null,this.tail=null};wd.prototype={add:function(e){var t={item:e,next:null},i=this.tail;i?i.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var Od,Nd,Dd,Pd,Ld,kd=wd,Md=/ipad|iphone|ipod/i.test(ce)&&"undefined"!=typeof Pebble,Ud=/web0s(?!.*chrome)/i.test(ce),xd=h,Vd=Jt,Fd=O.f,Bd=bd.set,jd=kd,Gd=ed,Wd=Md,Hd=Ud,Kd=jn,Yd=xd.MutationObserver||xd.WebKitMutationObserver,qd=xd.document,zd=xd.process,Xd=xd.Promise,Jd=Fd(xd,"queueMicrotask"),Qd=Jd&&Jd.value;if(!Qd){var Zd=new jd,$d=function(){var e,t;for(Kd&&(e=zd.domain)&&e.exit();t=Zd.get();)try{t()}catch(e){throw Zd.head&&Od(),e}e&&e.enter()};Gd||Kd||Hd||!Yd||!qd?!Wd&&Xd&&Xd.resolve?((Pd=Xd.resolve(void 0)).constructor=Xd,Ld=Vd(Pd.then,Pd),Od=function(){Ld($d)}):Kd?Od=function(){zd.nextTick($d)}:(Bd=Vd(Bd,xd),Od=function(){Bd($d)}):(Nd=!0,Dd=qd.createTextNode(""),new Yd($d).observe(Dd,{characterData:!0}),Od=function(){Dd.data=Nd=!Nd}),Qd=function(e){Zd.head||Od(),Zd.add(e)}}var el=Qd,tl=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},il=h.Promise,nl="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,rl=!nl&&!jn&&"object"==typeof window&&"object"==typeof document,ol=h,sl=il,al=w,cl=Yt,dl=Ic,ll=ht,ul=rl,hl=nl,pl=Ee,_l=sl&&sl.prototype,El=ll("species"),ml=!1,fl=al(ol.PromiseRejectionEvent),Tl=cl("Promise",(function(){var e=dl(sl),t=e!==String(sl);if(!t&&66===pl)return!0;if(!_l.catch||!_l.finally)return!0;if(!pl||pl<51||!/native code/.test(e)){var i=new sl((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((i.constructor={})[El]=n,!(ml=i.then((function(){}))instanceof n))return!0}return!t&&(ul||hl)&&!fl})),Sl={CONSTRUCTOR:Tl,REJECTION_EVENT:fl,SUBCLASSING:ml},gl={},Rl=De,vl=TypeError,Cl=function(e){var t,i;this.promise=new e((function(e,n){if(void 0!==t||void 0!==i)throw vl("Bad Promise constructor");t=e,i=n})),this.resolve=Rl(t),this.reject=Rl(i)};gl.f=function(e){return new Cl(e)};var Il,yl,Al=wi,bl=jn,wl=h,Ol=L,Nl=pa,Dl=Pa,Pl=function(e){var t=_c(e);mc&&t&&!t[fc]&&Ec(t,fc,{configurable:!0,get:function(){return this}})},Ll=De,kl=w,Ml=te,Ul=gc,xl=Jc,Vl=bd.set,Fl=el,Bl=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}},jl=tl,Gl=kd,Wl=oa,Hl=il,Kl=Sl,Yl=gl,ql="Promise",zl=Kl.CONSTRUCTOR,Xl=Kl.REJECTION_EVENT,Jl=Wl.getterFor(ql),Ql=Wl.set,Zl=Hl&&Hl.prototype,$l=Hl,eu=Zl,tu=wl.TypeError,iu=wl.document,nu=wl.process,ru=Yl.f,ou=ru,su=!!(iu&&iu.createEvent&&wl.dispatchEvent),au="unhandledrejection",cu=function(e){var t;return!(!Ml(e)||!kl(t=e.then))&&t},du=function(e,t){var i,n,r,o=t.value,s=1==t.state,a=s?e.ok:e.fail,c=e.resolve,d=e.reject,l=e.domain;try{a?(s||(2===t.rejection&&_u(t),t.rejection=1),!0===a?i=o:(l&&l.enter(),i=a(o),l&&(l.exit(),r=!0)),i===e.promise?d(tu("Promise-chain cycle")):(n=cu(i))?Ol(n,i,c,d):c(i)):d(o)}catch(e){l&&!r&&l.exit(),d(e)}},lu=function(e,t){e.notified||(e.notified=!0,Fl((function(){for(var i,n=e.reactions;i=n.get();)du(i,e);e.notified=!1,t&&!e.rejection&&hu(e)})))},uu=function(e,t,i){var n,r;su?((n=iu.createEvent("Event")).promise=t,n.reason=i,n.initEvent(e,!1,!0),wl.dispatchEvent(n)):n={promise:t,reason:i},!Xl&&(r=wl["on"+e])?r(n):e===au&&Bl("Unhandled promise rejection",i)},hu=function(e){Ol(Vl,wl,(function(){var t,i=e.facade,n=e.value;if(pu(e)&&(t=jl((function(){bl?nu.emit("unhandledRejection",n,i):uu(au,i,n)})),e.rejection=bl||pu(e)?2:1,t.error))throw t.value}))},pu=function(e){return 1!==e.rejection&&!e.parent},_u=function(e){Ol(Vl,wl,(function(){var t=e.facade;bl?nu.emit("rejectionHandled",t):uu("rejectionhandled",t,e.value)}))},Eu=function(e,t,i){return function(n){e(t,n,i)}},mu=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,lu(e,!0))},fu=function(e,t,i){if(!e.done){e.done=!0,i&&(e=i);
vendor: 5,702 bytes, line 12271
12271try{if(e.facade===t)throw tu("Promise can't be resolved itself");var n=cu(t);n?Fl((function(){var i={done:!1};try{Ol(n,t,Eu(fu,i,e),Eu(mu,i,e))}catch(t){mu(i,t,e)}})):(e.value=t,e.state=1,lu(e,!1))}catch(t){mu({done:!1},t,e)}}};zl&&(eu=($l=function(e){Ul(this,eu),Ll(e),Ol(Il,this);var t=Jl(this);try{e(Eu(fu,t),Eu(mu,t))}catch(e){mu(t,e)}}).prototype,(Il=function(e){Ql(this,{type:ql,done:!1,notified:!1,parent:!1,reactions:new Gl,rejection:!1,state:0,value:void 0})}).prototype=Nl(eu,"then",(function(e,t){var i=Jl(this),n=ru(xl(this,$l));return i.parent=!0,n.ok=!kl(e)||e,n.fail=kl(t)&&t,n.domain=bl?nu.domain:void 0,0==i.state?i.reactions.add(n):Fl((function(){du(n,i)})),n.promise})),yl=function(){var e=new Il,t=Jl(e);this.promise=e,this.resolve=Eu(fu,t),this.reject=Eu(mu,t)},Yl.f=ru=function(e){return e===$l||undefined===e?new yl(e):ou(e)}),Al({global:!0,constructor:!0,wrap:!0,forced:zl},{Promise:$l}),Dl($l,ql,!1,!0),Pl(ql);var Tu=ht("iterator"),Su=!1;try{var gu=0,Ru={next:function(){return{done:!!gu++}},return:function(){Su=!0}};Ru[Tu]=function(){return this},Array.from(Ru,(function(){throw 2}))}catch(e){}var vu=il,Cu=function(e,t){if(!t&&!Su)return!1;var i=!1;try{var n={};n[Tu]=function(){return{next:function(){return{done:i=!0}}}},e(n)}catch(e){}return i},Iu=Sl.CONSTRUCTOR||!Cu((function(e){vu.all(e).then(void 0,(function(){}))})),yu=L,Au=De,bu=gl,wu=tl,Ou=Ss;wi({target:"Promise",stat:!0,forced:Iu},{all:function(e){var t=this,i=bu.f(t),n=i.resolve,r=i.reject,o=wu((function(){var i=Au(t.resolve),o=[],s=0,a=1;Ou(e,(function(e){var c=s++,d=!1;a++,yu(i,t,e).then((function(e){d||(d=!0,o[c]=e,--a||n(o))}),r)})),--a||n(o)}));return o.error&&r(o.value),i.promise}});var Nu=wi,Du=Sl.CONSTRUCTOR;il&&il.prototype,Nu({target:"Promise",proto:!0,forced:Du,real:!0},{catch:function(e){return this.then(void 0,e)}});var Pu=L,Lu=De,ku=gl,Mu=tl,Uu=Ss;wi({target:"Promise",stat:!0,forced:Iu},{race:function(e){var t=this,i=ku.f(t),n=i.reject,r=Mu((function(){var r=Lu(t.resolve);Uu(e,(function(e){Pu(r,t,e).then(i.resolve,n)}))}));return r.error&&n(r.value),i.promise}});var xu=L,Vu=gl;wi({target:"Promise",stat:!0,forced:Sl.CONSTRUCTOR},{reject:function(e){var t=Vu.f(this);return xu(t.reject,void 0,e),t.promise}});var Fu=ii,Bu=te,ju=gl,Gu=function(e,t){if(Fu(e),Bu(t)&&t.constructor===e)return t;var i=ju.f(e);return(0,i.resolve)(t),i.promise},Wu=wi,Hu=il,Ku=Sl.CONSTRUCTOR,Yu=Gu,qu=ae("Promise"),zu=!Ku;Wu({target:"Promise",stat:!0,forced:true},{resolve:function(e){return Yu(zu&&this===qu?Hu:this,e)}});var Xu=L,Ju=De,Qu=gl,Zu=tl,$u=Ss;wi({target:"Promise",stat:!0,forced:Iu},{allSettled:function(e){var t=this,i=Qu.f(t),n=i.resolve,r=i.reject,o=Zu((function(){var i=Ju(t.resolve),r=[],o=0,s=1;$u(e,(function(e){var a=o++,c=!1;s++,Xu(i,t,e).then((function(e){c||(c=!0,r[a]={status:"fulfilled",value:e},--s||n(r))}),(function(e){c||(c=!0,r[a]={status:"rejected",reason:e},--s||n(r))}))})),--s||n(r)}));return o.error&&r(o.value),i.promise}});var eh=L,th=De,ih=ae,nh=gl,rh=tl,oh=Ss,sh="No one promise resolved";wi({target:"Promise",stat:!0,forced:Iu},{any:function(e){var t=this,i=ih("AggregateError"),n=nh.f(t),r=n.resolve,o=n.reject,s=rh((function(){var n=th(t.resolve),s=[],a=0,c=1,d=!1;oh(e,(function(e){var l=a++,u=!1;c++,eh(n,t,e).then((function(e){u||d||(d=!0,r(e))}),(function(e){u||d||(u=!0,s[l]=e,--c||o(new i(s,sh)))}))})),--c||o(new i(s,sh))}));return s.error&&o(s.value),n.promise}});var ah=wi,ch=il,dh=n,lh=ae,uh=w,hh=Jc,ph=Gu,_h=ch&&ch.prototype;ah({target:"Promise",proto:!0,real:!0,forced:!!ch&&dh((function(){_h.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=hh(this,lh("Promise")),i=uh(e);return this.then(i?function(i){return ph(t,e()).then((function(){return i}))}:e,i?function(i){return ph(t,e()).then((function(){throw i}))}:e)}});var Eh=d,mh=Li,fh=mn,Th=X,Sh=Eh("".charAt),gh=Eh("".charCodeAt),Rh=Eh("".slice),vh=function(e){return function(t,i){var n,r,o=fh(Th(t)),s=mh(i),a=o.length;return s<0||s>=a?e?"":void 0:(n=gh(o,s))<55296||n>56319||s+1===a||(r=gh(o,s+1))<56320||r>57343?e?Sh(o,s):n:e?Rh(o,s,s+2):r-56320+(n-55296<<10)+65536}},Ch={codeAt:vh(!1),charAt:vh(!0)},Ih=Ch.charAt,yh=mn,Ah=oa,bh=ic,wh=nc,Oh="String Iterator",Nh=Ah.set,Dh=Ah.getterFor(Oh);bh(String,"String",(function(e){Nh(this,{type:Oh,string:yh(e),index:0})}),(function(){var e,t=Dh(this),i=t.string,n=t.index;return n>=i.length?wh(void 0,!0):(e=Ih(i,n),t.index+=e.length,wh(e,!1))}));var Ph=ie.Promise,Lh={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},kh=h,Mh=pn,Uh=mi,xh=Vo,Vh=ht("toStringTag");for(var Fh in Lh){var Bh=kh[Fh],jh=Bh&&Bh.prototype;jh&&Mh(jh)!==Vh&&Uh(jh,Vh,Fh),xh[Fh]=xh.Array}var Gh=Ph,Wh=i(Gh),Hh=Ji("Array").values,Kh=pn,Yh=Ze,qh=l,zh=Hh,Xh=Array.prototype,Jh={DOMTokenList:!0,NodeList:!0},Qh=function(e){var t=e.values;return e===Xh||qh(Xh,e)&&t===Xh.values||Yh(Jh,Kh(e))?zh:t},Zh=i(Qh),$h=n,ep=ht("iterator"),tp=!$h((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,i=new URLSearchParams("a=1&a=2"),n="";return e.pathname="c%20d",t.forEach((function(e,i){t.delete("b"),n+=i+e})),i.delete("a",2),!e.toJSON||!i.has("a",1)||i.has("a",2)||!t.size&&true||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[ep
12271]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://ÑеÑÑ").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host})),ip=pa,np=vt,rp=Qt,op=B,sp=function(e,t,i){var n=np(t);n in e?rp.f(e,n,op(0,i)):e[n]=i},ap=xi,cp=Gi,dp=sp,lp=Array,up=Math.max,hp=function(e,t,i){for(var n=cp(e),r=ap(t,n),o=ap(void 0===i?n:i,n),s=lp(up(o-r,0)),a=0;r<o;r++,a++)dp(s,a,e[r]);return s.length=a,s},pp=hp,_p=Math.floor,Ep=function(e,t){var i=e.length,n=_p(i/2);return i<8?mp(e,t):fp(e,Ep(pp(e,0,n),t),Ep(pp(e,n),t),t)},mp=function(e,t){for(var i,n,r=e.length,o=1;o<r;){for(n=o,i=e[o];n&&t(e[n-1],i)>0;)e[n]=e[--n];n!==o++&&(e[n]=i)}return e},fp=function(e,t,i,n){for(var r=t.length,o=i.length,s=0,a=0;s<r||a<o;)e[s+a]=s<r&&a<o?n(t[s],i[a])<=0?t[s++]:i[a++]:s<r?t[s++]:i[a++];return e},Tp=Ep,Sp=wi,gp=h,Rp=L,vp=d,Cp=N,Ip=tp,yp=pa,Ap=pc,bp=function(e,t,i){for(var n in t)i&&i.unsafe&&e[n]?e[n]=t[n]:ip(e,n,t[n],i);return e},wp=Pa,Op=Fa,Np=oa,Dp=gc,Pp=w,Lp=Ze,kp=Jt,Mp=pn,Up=ii,xp=te,Vp=mn,Fp=Io,Bp=B,jp=ts,Gp=zo,Wp=$c,Hp=Tp,Kp=ht("iterator"),Yp="URLSearchParams",qp=Yp+"Iterator",zp=Np.set,Xp=Np.getterFor(Yp),Jp=Np.getterFor(qp),Qp=Object.getOwnPropertyDescriptor,Zp=function(e){if(!Cp)return gp[e];var t=Qp(gp,e);return t&&t.value},$p=Zp("fetch"),e_=Zp("Request"),t_=Zp("Headers"),i_=e_&&e_.prototype,n_=t_&&t_.prototype,r_=gp.RegExp,o_=gp.TypeError,s_=gp.decodeURIComponent,a_=gp.encodeURIComponent,c_=vp("".charAt),d_=vp([].join),l_=vp([].push),u_=vp("".replace),h_=vp([].shift),p_=vp([].splice),__=vp("".split),E_=vp("".slice),m_=/\+/g,f_=Array(4),T_=function(e){return f_[e-1]||(f_[e-1]=r_("((?:%[\\da-f]{2}){"+e+"})","gi"))},S_=function(e){try{return s_(e)}catch(t){return e}},g_=function(e){var t=u_(e,m_," "),i=4;try{return s_(t)}catch(e){for(;i;)t=u_(t,T_(i--),S_);return t}},R_=/[!'()~]|%20/g,v_={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},C_=function(e){return v_[e]},I_=function(e){return u_(a_(e),R_,C_)},y_=Op((function(e,t){zp(this,{type:qp,iterator:jp(Xp(e).entries),kind:t})}),"Iterator",(function(){var e=Jp(this),t=e.kind,i=e.iterator.next(),n=i.value;return i.done||(i.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),i}),!0),A_=function(e){this.entries=[],this.url=null,void 0!==e&&(xp(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===c_(e,0)?E_(e,1):e:Vp(e)))};A_.prototype={type:Yp,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,i,n,r,o,s,a,c=Gp(e);if(c)for(i=(t=jp(e,c)).next;!(n=Rp(i,t)).done;){if(o=(r=jp(Up(n.value))).next,(s=Rp(o,r)).done||(a=Rp(o,r)).done||!Rp(o,r).done)throw o_("Expected sequence with length 2");l_(this.entries,{key:Vp(s.value),value:Vp(a.value)})}else for(var d in e)Lp(e,d)&&l_(this.entries,{key:d,value:Vp(e[d])})},parseQuery:function(e){if(e)for(var t,i,n=__(e,"&"),r=0;r<n.length;)(t=n[r++]).length&&(i=__(t,"="),l_(this.entries,{key:g_(h_(i)),value:g_(d_(i,"="))}))},serialize:function(){for(var e,t=this.entries,i=[],n=0;n<t.length;)e=t[n++],l_(i,I_(e.key)+"="+I_(e.value));return d_(i,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var b_=function(){Dp(this,w_);var e=zp(this,new A_(arguments.length>0?arguments[0]:void 0));Cp||(this.size=e.entries.length)},w_=b_.prototype;if(bp(w_,{append:function(e,t){var i=Xp(this);Wp(arguments.length,2),l_(i.entries,{key:Vp(e),value:Vp(t)}),Cp||this.length++,i.updateURL()},delete:function(e){for(var t=Xp(this),i=Wp(arguments.length,1),n=t.entries,r=Vp(e),o=i<2?void 0:arguments[1],s=void 0===o?o:Vp(o),a=0;a<n.length;){var c=n[a];if(c.key!==r||void 0!==s&&c.value!==s)a++;else if(p_(n,a,1),void 0!==s)break}Cp||(this.size=n.length),t.updateURL()},get:function(e){var t=Xp(this).entries;Wp(arguments.length,1);for(var i=Vp(e),n=0;n<t.length;n++)if(t[n].key===i)return t[n].value;return null},getAll:function(e){var t=Xp(this).entries;Wp(arguments.length,1);for(var i=Vp(e),n=[],r=0;r<t.length;r++)t[r].key===i&&l_(n,t[r].value);return n},has:function(e){for(var t=Xp(this).entries,i=Wp(arguments.length,1),n=Vp(e),r=i<2?void 0:arguments[1],o=void 0===r?r:Vp(r),s=0;s<t.length;){var a=t[s++];if(a.key===n&&(void 0===o||a.value===o))return!0}return!1},set:function(e,t){var i=Xp(this);Wp(arguments.length,1);for(var n,r=i.entries,o=!1,s=Vp(e),a=Vp(t),c=0;c<r.length;c++)(n=r[c]).key===s&&(o?p_(r,c--,1):(o=!0,n.value=a));o||l_(r,{key:s,value:a}),Cp||(this.size=r.length),i.updateURL()},sort:function(){var e=Xp(this);Hp(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()}
vendor: 13,726 bytes, line 12271
12271,forEach:function(e){for(var t,i=Xp(this).entries,n=kp(e,arguments.length>1?arguments[1]:void 0),r=0;r<i.length;)n((t=i[r++]).value,t.key,this)},keys:function(){return new y_(this,"keys")},values:function(){return new y_(this,"values")},entries:function(){return new y_(this,"entries")}},{enumerable:!0}),yp(w_,Kp,w_.entries,{name:"entries"}),yp(w_,"toString",(function(){return Xp(this).serialize()}),{enumerable:!0}),Cp&&Ap(w_,"size",{get:function(){return Xp(this).entries.length},configurable:!0,enumerable:!0}),wp(b_,Yp),Sp({global:!0,constructor:!0,forced:!Ip},{URLSearchParams:b_}),!Ip&&Pp(t_)){var O_=vp(n_.has),N_=vp(n_.set),D_=function(e){if(xp(e)){var t,i=e.body;if(Mp(i)===Yp)return t=e.headers?new t_(e.headers):new t_,O_(t,"content-type")||N_(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Fp(e,{body:Bp(0,Vp(i)),headers:Bp(0,t)})}return e};if(Pp($p)&&Sp({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return $p(e,arguments.length>1?D_(arguments[1]):{})}}),Pp(e_)){var P_=function(e){return Dp(this,i_),new e_(e,arguments.length>1?D_(arguments[1]):{})};i_.constructor=P_,P_.prototype=i_,Sp({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:P_})}}var L_,k_={URLSearchParams:b_,getState:Xp},M_=ie.URLSearchParams,U_=N,x_=d,V_=L,F_=n,B_=to,j_=jr,G_=k,W_=Xe,H_=K,K_=Object.assign,Y_=Object.defineProperty,q_=x_([].concat),z_=!K_||F_((function(){if(U_&&1!==K_({b:1},K_(Y_({},"a",{enumerable:!0,get:function(){Y_(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},i=Symbol(),n="abcdefghijklmnopqrst";return e[i]=7,n.split("").forEach((function(e){t[e]=e})),7!=K_({},e)[i]||B_(K_({},t)).join("")!=n}))?function(e,t){for(var i=W_(e),n=arguments.length,r=1,o=j_.f,s=G_.f;n>r;)for(var a,c=H_(arguments[r++]),d=o?q_(B_(c),o(c)):B_(c),l=d.length,u=0;l>u;)a=d[u++],U_&&!V_(s,c,a)||(i[a]=c[a]);return i}:K_,X_=ii,J_=os,Q_=Jt,Z_=L,$_=Xe,eE=function(e,t,i,n){try{return n?t(X_(i)[0],i[1]):t(i)}catch(t){J_(e,"throw",t)}},tE=Go,iE=Gc,nE=Gi,rE=sp,oE=ts,sE=zo,aE=Array,cE=d,dE=2147483647,lE=/[^\0-\u007E]/,uE=/[.\u3002\uFF0E\uFF61]/g,hE="Overflow: input needs wider integers to process",pE=RangeError,_E=cE(uE.exec),EE=Math.floor,mE=String.fromCharCode,fE=cE("".charCodeAt),TE=cE([].join),SE=cE([].push),gE=cE("".replace),RE=cE("".split),vE=cE("".toLowerCase),CE=function(e){return e+22+75*(e<26)},IE=function(e,t,i){var n=0;for(e=i?EE(e/700):e>>1,e+=EE(e/t);e>455;)e=EE(e/35),n+=36;return EE(n+36*e/(e+38))},yE=function(e){var t=[];e=function(e){for(var t=[],i=0,n=e.length;i<n;){var r=fE(e,i++);if(r>=55296&&r<=56319&&i<n){var o=fE(e,i++);56320==(64512&o)?SE(t,((1023&r)<<10)+(1023&o)+65536):(SE(t,r),i--)}else SE(t,r)}return t}(e);var i,n,r=e.length,o=128,s=0,a=72;for(i=0;i<e.length;i++)(n=e[i])<128&&SE(t,mE(n));var c=t.length,d=c;for(c&&SE(t,"-");d<r;){var l=dE;for(i=0;i<e.length;i++)(n=e[i])>=o&&n<l&&(l=n);var u=d+1;if(l-o>EE((dE-s)/u))throw pE(hE);for(s+=(l-o)*u,o=l,i=0;i<e.length;i++){if((n=e[i])<o&&++s>dE)throw pE(hE);if(n==o){for(var h=s,p=36;;){var _=p<=a?1:p>=a+26?26:p-a;if(h<_)break;var E=h-_,m=36-_;SE(t,mE(CE(_+E%m))),h=EE(E/m),p+=36}SE(t,mE(CE(h))),a=IE(s,u,d==c),s=0,d++}}s++,o++}return TE(t,"")},AE=wi,bE=N,wE=tp,OE=h,NE=Jt,DE=d,PE=pa,LE=pc,kE=gc,ME=Ze,UE=z_,xE=function(e){var t=$_(e),i=iE(this),n=arguments.length,r=n>1?arguments[1]:void 0,o=void 0!==r;o&&(r=Q_(r,n>2?arguments[2]:void 0));var s,a,c,d,l,u,h=sE(t),p=0;if(!h||this===aE&&tE(h))for(s=nE(t),a=i?new this(s):aE(s);s>p;p++)u=o?r(t[p],p):t[p],rE(a,p,u);else for(l=(d=oE(t,h)).next,a=i?new this:[];!(c=Z_(l,d)).done;p++)u=o?eE(d,r,[c.value,p],!0):c.value,rE(a,p,u);return a.length=p,a},VE=hp,FE=Ch.codeAt,BE=function(e){var t,i,n=[],r=RE(gE(vE(e),uE,"."),".");for(t=0;t<r.length;t++)i=r[t],SE(n,_E(lE,i)?"xn--"+yE(i):i);return TE(n,".")},jE=mn,GE=Pa,WE=$c,HE=k_,KE=oa,YE=KE.set,qE=KE.getterFor("URL"),zE=HE.URLSearchParams,XE=HE.getState,JE=OE.URL,QE=OE.TypeError,ZE=OE.parseInt,$E=Math.floor,em=Math.pow,tm=DE("".charAt),im=DE(/./.exec),nm=DE([].join),rm=DE(1..toString),om=DE([].pop),sm=DE([].push),am=DE("".replace),cm=DE([].shift),dm=DE("".split),lm=DE("".slice),um=DE("".toLowerCase),hm=DE([].unshift),pm="Invalid scheme",_m="Invalid host",Em="Invalid port",mm=/[a-z]/i,fm=/[\d+-.a-z]/i,Tm=/\d/,Sm=/^0x/i,gm=/^[0-7]+$/,Rm=/^\d+$/,vm=/^[\da-f]+$/i,Cm=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Im=/[\0\t\n\r #/:<>?@[\\\]^|]/,ym=/^[\u0000-\u0020]+/,Am=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,bm=/[\t\n\r]/g,wm=function(e){var t,i,n,r;if("number"==typeof e){for(t=[],i=0;i<4;i++)hm(t,e%256),e=$E(e/256);return nm(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,i=1,n=null,r=0,o=0;o<8;o++)0!==e[o]?(r>i&&(t=n,i=r),n=null,r=0):(null===n&&(n=o),++r);return r>i&&(t=n,i=r),t}(e),i=0;i<8;i++)r&&0===e[i]||(r&&(r=!1),n===i?(t+=i?":":"::",r=!0):(t+=rm(e[i],16),i<7&&(t+=":")));return"["+t+"]"}return e},Om={},Nm=UE({},Om,{" ":1,'"':1,"<":1,">":1,"`":1}),Dm=UE({},Nm,{"#":1,"?":1,"{":1,"}":1}),Pm=UE({},Dm,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Lm=function(e,t){var i=FE(e,0);return i>32&&i<127&&!ME(t,e)?e:encodeURIComponent(e)},km={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Mm=function(e,t){var i;return 2==e.length&&im(mm,tm(e,0))&&(":"==(i=tm(e,1))||!t&&"|"==i)},Um=function(e){var t;return e.length>1&&Mm(lm(e,0,2))&&(2==e.length||"/"===(t=tm(e,2))||"\\"===t||"?"===t||"#"===t)},xm=function(e){return"."===e||"%2e"===um(e)},Vm={},Fm={},Bm={},jm={},Gm={},Wm={},Hm={},Km={},Ym={},qm={},zm={},Xm={},Jm={},Qm={},Zm={},$m={},ef={},tf={},nf={},rf={},of={},sf=function(e,t,i){var n,r,o,s=jE(e);if(t){if(r=this.parse(s))throw QE(r);this.searchParams=null}else{if(void 0!==i&&(n=new sf(i,!0)),r=this.parse(s,null,n))throw QE(r);(o=XE(new zE)).bindURL(this),this.searchParams=o}};sf.prototype={type:"URL",parse:function(e,t,i){var n,r,o,s,a,c=this,d=t||Vm,l=0,u="",h=!1,p=!1,_=!1;for(e=jE(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=am(e,ym,""),e=am(e,Am,"$1")),e=am(e,bm,""),n=xE(e);l<=n.length;){switch(r=n[l],d){case Vm:if(!r||!im(mm,r)){if(t)return pm;d=Bm;continue}u+=um(r),d=Fm;break;case Fm:if(r&&(im(fm,r)||"+"==r||"-"==r||"."==r))u+=um(r);else{if(":"!=r){if(t)return pm;u="",d=Bm,l=0;continue}if(t&&(c.isSpecial()!=ME(km,u)||"file"==u&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=u,t)return void(c.isSpecial()&&km[c.scheme]==c.port&&(c.port=null));u="","file"==c.scheme?d=Qm:c.isSpecial()&&i&&i.scheme==c.scheme?d=jm:c.isSpecial()?d=Km:"/"==n[l+1]?(d=Gm,l++):(c.cannotBeABaseURL=!0,sm(c.path,""),d=nf)}break;case Bm:if(!i||i.cannotBeABaseURL&&"#"!=r)return pm;if(i.cannotBeABaseURL&&"#"==r){c.scheme=i.scheme,c.path=VE(i.path),c.query=i.query,c.fragment="",c.cannotBeABaseURL=!0,d=of;break}d="file"==i.scheme?Qm:Wm;continue;case jm:if("/"!=r||"/"!=n[l+1]){d=Wm;continue}d=Ym,l++;break;case Gm:if("/"==r){d=qm;break}d=tf;continue;case Wm:if(c.scheme=i.scheme,r==L_)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=VE(i.path),c.query=i.query;else if("/"==r||"\\"==r&&c.isSpecial())d=Hm;else if("?"==r)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=VE(i.path),c.query="",d=rf;else{if("#"!=r){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=VE(i.path),c.path.length--,d=tf;continue}c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=VE(i.path),c.query=i.query,c.fragment="",d=of}break;case Hm:if(!c.isSpecial()||"/"!=r&&"\\"!=r){if("/"!=r){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,d=tf;continue}d=qm}else d=Ym;break;case Km:if(d=Ym,"/"!=r||"/"!=tm(u,l+1))continue;l++;break;case Ym:if("/"!=r&&"\\"!=r){d=qm;continue}break;case qm:if("@"==r){h&&(u="%40"+u),h=!0,o=xE(u);for(var E=0;E<o.length;E++){var m=o[E];if(":"!=m||_){var f=Lm(m,Pm);_?c.password+=f:c.username+=f}else _=!0}u=""}else if(r==L_||"/"==r||"?"==r||"#"==r||"\\"==r&&c.isSpecial()){if(h&&""==u)return"Invalid authority";l-=xE(u).length+1,u="",d=zm}else u+=r;break;case zm:case Xm:if(t&&"file"==c.scheme){d=$m;continue}if(":"!=r||p){if(r==L_||"/"==r||"?"==r||"#"==r||"\\"==r&&c.isSpecial()){if(c.isSpecial()&&""==u)return _m;if(t&&""==u&&(c.includesCredentials()||null!==c.port))return;if(s=c.parseHost(u))return s;if(u="",d=ef,t)return;continue}"["==r?p=!0:"]"==r&&(p=!1),u+=r}else{if(""==u)return _m;if(s=c.parseHost(u))return s;if(u="",d=Jm,t==Xm)return}break;case Jm:if(!im(Tm,r)){if(r==L_||"/"==r||"?"==r||"#"==r||"\\"==r&&c.isSpecial()||t){if(""!=u){var T=ZE(u,10);if(T>65535)return Em;c.port=c.isSpecial()&&T===km[c.scheme]?null:T,u=""}if(t)return;d=ef;continue}return Em}u+=r;break;case Qm:if(c.scheme="file","/"==r||"\\"==r)d=Zm;else{if(!i||"file"!=i.scheme){d=tf;continue}if(r==L_)c.host=i.host,c.path=VE(i.path),c.query=i.query;else if("?"==r)c.host=i.host,c.path=VE(i.path),c.query="",d=rf;else{if("#"!=r){Um(nm(VE(n,l),""))||(c.host=i.host,c.path=VE(i.path),c.shortenPath()),d=tf;continue}c.host=i.host,c.path=VE(i.path),c.query=i.query,c.fragment="",d=of}}break;case Zm:if("/"==r||"\\"==r){d=$m;break}i&&"file"==i.scheme&&!Um(nm(VE(n,l),""))&&(Mm(i.path[0],!0)?sm(c.path,i.path[0]):c.host=i.host),d=tf;continue;case $m:if(r==L_||"/"==r||"\\"==r||"?"==r||"#"==r){if(!t&&Mm(u))d=tf;else if(""==u){if(c.host="",t)return;d=ef}else{if(s=c.parseHost(u))return s;if("localhost"==c.host&&(c.host=""),t)return;u="",d=ef}continue}u+=r;break;case ef:if(c.isSpecial()){if(d=tf,"/"!=r&&"\\"!=r)continue}else if(t||"?"!=r)if(t||"#"!=r){if(r!=L_&&(d=tf,"/"!=r))continue}else c.fragment="",d=of;else c.query="",d=rf;break;case tf:if(r==L_||"/"==r||"\\"==r&&c.isSpecial()||!t&&("?"==r||"#"==r)){if(".."===(a=um(a=u))||"%2e."===a||".%2e"===a||"%2e%2e"===a?(c.shortenPath(),"/"==r||"\\"==r&&c.isSpecial()||sm(c.path,"")):xm(u)?"/"==r||"\\"==r&&c.isSpecial()||sm(c.path,""):("file"==c.scheme&&!c.path.length&&Mm(u)&&(c.host&&(c.host=""),u=tm(u,0)+":"),sm(c.path,u)),u="","file"==c.scheme&&(r==L_||"?"==r||"#"==r))for(;c.path.length>1&&""===c.path[0];)cm(c.path);"?"==r?(c.query="",d=rf):"#"==r&&(c.fragment="",d=of)}else u+=Lm(r,Dm);break;case nf:"?"==r?(c.query="",d=rf):"#"==r?(c.fragment="",d=of):r!=L_&&(c.path[0]+=Lm(r,Om));break;case rf:t||"#"!=r?r!=L_&&("'"==r&&c.isSpecial()?c.query+="%27":c.query+="#"==r?"%23":Lm(r,Om)):(c.fragment="",d=of);break;case of:r!=L_&&(c.fragment+=Lm(r,Nm))}l++}},parseHost:function(e){var t,i,n;if("["==tm(e,0)){if("]"!=tm(e,e.length-1))return _m;if(t=function(e){var t,i,n,r,o,s,a,c=[0,0,0,0,0,0,0,0],d=0,l=null,u=0,h=function(){return tm(e,u)};if(":"==h()){if(":"!=tm(e,1))return;u+=2,l=++d}for(;h();){if(8==d)return;if(":"!=h()){for(t=i=0;i<4&&im(vm,h());)t=16*t+ZE(h(),16),u++,i++;if("."==h()){if(0==i)return;if(u-=i,d>6)return;for(n=0;h();){if(r=null,n>0){if(!("."==h()&&n<4))return;u++}if(!im(Tm,h()))return;for(;im(Tm,h());){if(o=ZE(h(),10),null===r)r=o;else{if(0==r)return;r=10*r+o}if(r>255)return;u++}c[d]=256*c[d]+r,2!=++n&&4!=n||d++}if(4!=n)return;break}if(":"==h()){if(u++,!h())return}else if(h())return;c[d++]=t}else{if(null!==l)return;u++,l=++d}}if(null!==l)for(s=d-l,d=7;0!=d&&s>0;)a=c[d],c[d--]=c[l+s-1],c[l+--s]=a;else if(8!=d)return;return c}(lm(e,1,-1)),!t)return _m;this.host=t}else if(this.isSpecial()){if(e=BE(e),im(Cm,e))return _m;if(t=function(e){var t,i,n,r,o,s,a,c=dm(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(i=[],n=0;n<t;n++){if(""==(r=c[n]))return e;if(o=10,r.length>1&&"0"==tm(r,0)&&(o=im(Sm,r)?16:8,r=lm(r,8==o?1:2)),""===r)s=0;else{if(!im(10==o?Rm:8==o?gm:vm,r))return e;s=ZE(r,o)}sm(i,s)}for(n=0;n<t;n++)if(s=i[n],n==t-1){if(s>=em(256,5-t))return null}else if(s>255)return null;for(a=om(i),n=0;n<i.length;n++)a+=i[n]*em(256,3-n);return a}(e),null===t)return _m;this.host=t}else{if(im(Im,e))return _m;for(t="",i=xE(e),n=0;n<i.length;n++)t+=Lm(i[n],Om);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return ME(km,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&Mm(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,i=e.username,n=e.password,r=e.host,o=e.port,s=e.path,a=e.query,c=e.fragment,d=t+":";return null!==r?(d+="//",e.includesCredentials()&&(d+=i+(n?":"+n:"")+"@"),d+=wm(r),null!==o&&(d+=":"+o)):"file"==t&&(d+="//"),d+=e.cannotBeABaseURL?s[0]:s.length?"/"+nm(s,"/"):"",null!==a&&(d+="?"+a),null!==c&&(d+="#"+c),d},setHref:function(e){var t=this.parse(e);if(t)throw QE(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new af(e.path[0]).origin}catch(e){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+wm(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(jE(e)+":",Vm)},getUsername:function(){return this.username},setUsername:function(e){var t=xE(jE(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var i=0;i<t.length;i++)this.username+=Lm(t[i],Pm)}},getPassword:function(){return this.password},setPassword:function(e){var t=xE(jE(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var i=0;i<t.length;i++)this.password+=Lm(t[i],Pm)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?wm(e):wm(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,zm)},getHostname:function(){var e=this.host;return null===e?"":wm(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Xm)},getPort:function(){var e=this.port;return null===e?"":jE(e)}
vendor: 4,633 bytes, line 12271
12271,setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=jE(e))?this.port=null:this.parse(e,Jm))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+nm(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,ef))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=jE(e))?this.query=null:("?"==tm(e,0)&&(e=lm(e,1)),this.query="",this.parse(e,rf)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=jE(e))?("#"==tm(e,0)&&(e=lm(e,1)),this.fragment="",this.parse(e,of)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var af=function(e){var t=kE(this,cf),i=WE(arguments.length,1)>1?arguments[1]:void 0,n=YE(t,new sf(e,!1,i));bE||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},cf=af.prototype,df=function(e,t){return{get:function(){return qE(this)[e]()},set:t&&function(e){return qE(this)[t](e)},configurable:!0,enumerable:!0}};if(bE&&(LE(cf,"href",df("serialize","setHref")),LE(cf,"origin",df("getOrigin")),LE(cf,"protocol",df("getProtocol","setProtocol")),LE(cf,"username",df("getUsername","setUsername")),LE(cf,"password",df("getPassword","setPassword")),LE(cf,"host",df("getHost","setHost")),LE(cf,"hostname",df("getHostname","setHostname")),LE(cf,"port",df("getPort","setPort")),LE(cf,"pathname",df("getPathname","setPathname")),LE(cf,"search",df("getSearch","setSearch")),LE(cf,"searchParams",df("getSearchParams")),LE(cf,"hash",df("getHash","setHash"))),PE(cf,"toJSON",(function(){return qE(this).serialize()}),{enumerable:!0}),PE(cf,"toString",(function(){return qE(this).serialize()}),{enumerable:!0}),JE){var lf=JE.createObjectURL,uf=JE.revokeObjectURL;lf&&PE(af,"createObjectURL",NE(lf,JE)),uf&&PE(af,"revokeObjectURL",NE(uf,JE))}GE(af,"URL"),AE({global:!0,constructor:!0,forced:!wE,sham:!bE},{URL:af});var hf=wi,pf=n,_f=$c,Ef=mn,mf=tp,ff=ae("URL");hf({target:"URL",stat:!0,forced:!(mf&&pf((function(){ff.canParse()})))},{canParse:function(e){var t=_f(arguments.length,1),i=Ef(e),n=t<2||void 0===arguments[1]?void 0:Ef(arguments[1]);try{return!!new ff(i,n)}catch(e){return!1}}});var Tf=i(ie.URL);let Sf=!0,gf=!0;function Rf(e,t,i){const n=e.match(t);return n&&n.length>=i&&parseInt(n[i],10)}function vf(e,t,i){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,r=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return r.apply(this,arguments);const o=e=>{const t=i(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,o),r.apply(this,[e,o])};const o=n.removeEventListener;n.removeEventListener=function(e,i){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(i))return o.apply(this,arguments);const n=this._eventMap[t].get(i);return this._eventMap[t].delete(i),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function Cf(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(Sf=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function If(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(gf=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function yf(){if("object"==typeof window){if(Sf)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Af(e,t){gf&&console.warn(e+" is deprecated, please use "+t+" instead.")}function bf(e){return"[object Object]"===Object.prototype.toString.call(e)}function wf(e){var t;return bf(e)?Xn(t=Object.keys(e)).call(t,(function(t,i){const n=bf(e[i]),r=n?wf(e[i]):e[i],o=n&&!Object.keys(r).length;return void 0===r||o?t:Object.assign(t,{[i]:r})}),{}):e}function Of(e,t,i){t&&!i.has(t.id)&&(i.set(t.id,t),Object.keys(t).forEach((n=>{n.endsWith("Id")?Of(e,e.get(t[n]),i):n.endsWith("Ids")&&t[n].forEac
vendor: 1,666 bytes, line 12271
12271h((t=>{Of(e,e.get(t),i)}))})))}function Nf(e,t,i){const n=i?"outbound-rtp":"inbound-rtp",r=new Map;if(null===t)return r;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((i=>{i.type===n&&i.trackId===t.id&&Of(e,i,r)}))})),r}const Df=yf;function Pf(e,t){const i=e&&e.navigator;if(!i.mediaDevices)return;const n=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((i=>{if("require"===i||"advanced"===i||"mediaSource"===i)return;const n="object"==typeof e[i]?e[i]:{ideal:e[i]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const r=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[r("min",i)]=n.ideal,t.optional.push(e),e={},e[r("max",i)]=n.ideal,t.optional.push(e)):(e[r("",i)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[r("",i)]=n.exact):["min","max"].forEach((e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[r(e,i)]=n[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},r=function(e,r){if(t.version>=61)return r(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});
vendor: 4,238 bytes, line 12271
12271const s=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!i.mediaDevices.getSupportedConstraints||!i.mediaDevices.getSupportedConstraints().facingMode||s)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return i.mediaDevices.enumerateDevices().then((i=>{let s=(i=i.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>{var i;return Dn(i=e.label.toLowerCase()).call(i,t)}))));return!s&&i.length&&Dn(t).call(t,"back")&&(s=i[i.length-1]),s&&(e.video.deviceId=o.exact?{exact:s.deviceId}:{ideal:s.deviceId}),e.video=n(e.video),Df("chrome: "+JSON.stringify(e)),r(e)}))}e.video=n(e.video)}return Df("chrome: "+JSON.stringify(e)),r(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(i.getUserMedia=function(e,t,n){r(e,(e=>{i.webkitGetUserMedia(e,t,(e=>{n&&n(o(e))}))}))}.bind(i),i.mediaDevices.getUserMedia){const e=i.mediaDevices.getUserMedia.bind(i.mediaDevices);i.mediaDevices.getUserMedia=function(t){return r(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Wh.reject(o(e))))))}}}function Lf(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function kf(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(i=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.track.id)):{track:i.track};const r=new Event("track");r.track=i.track,r.receiver=n,r.transceiver={receiver:n},r.streams=[t.stream],this.dispatchEvent(r)})),t.stream.getTracks().forEach((i=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.id)):{track:i};const r=new Event("track");r.track=i,r.receiver=n,r.transceiver={receiver:n},r.streams=[t.stream],this.dispatchEvent(r)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else vf(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function Mf(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){let r=i.apply(this,arguments);return r||(r=t(this,e),this._senders.push(r)),r};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEac
vendor: 4,134 bytes, line 12271
12271h((e=>{this._senders.push(t(this,e))}))};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Uf(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,n]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const r=function(e){const t={};return e.result().forEach((e=>{const i={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{i[t]=e.stat(t)})),t[i.id]=i})),t},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const n=function(e){i(o(r(e)))};return t.apply(this,[n,e])}return new Wh(((e,i)=>{t.apply(this,[function(t){e(o(r(t)))},i])})).then(i,n)}}function xf(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>Nf(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),vf(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>Nf(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,i,n;return this.getSenders().forEach((i=>{i.track===e&&(t?n=!0:t=i)})),this.getReceivers().forEach((t=>(t.track===e&&(i?n=!0:i=t),t.track===e))),n||t&&i?Wh.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():i?i.getStats():Wh.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function Vf(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){if(!i)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const n=t.apply(this,arguments);return this._shimmedLocalStreams[i.id]?-1===this._shimmedLocalStreams[i.id].indexOf(n)&&this._shimmedLocalStreams[i.id].push(n):this._shimmedLocalStreams[i.id]=[i,n],n};const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{}
vendor: 13,234 bytes, line 12271
12271,e.getTracks().forEach((e=>{const t=this.getSenders().find((t=>t.track===e));if(t)throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();i.apply(this,arguments);const n=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(n)};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const i=this._shimmedLocalStreams[t].indexOf(e);-1!==i&&this._shimmedLocalStreams[t].splice(i,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),r.apply(this,arguments)}}function Ff(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Vf(e);const i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=i.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{const t=this.getSenders().find((t=>t.track===e));if(t)throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};const r=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t],r=e._streams[n.id];i=i.replace(new RegExp(r.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:i})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,i){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const r=this.getSenders().find((e=>e.track===t));if(r)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const o=this._streams[i.id];if(o)o.addTrack(t),Wh.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const n=new e.MediaStream([t]);this._streams[i.id]=n,this._reverseStreams[n.id]=i,this.addStream(n)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?i.apply(this,[t=>{const i=o(this,t);e[0].apply(null,[i])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):i.apply(this,arguments).then((e=>o(this,e)))}};e.RTCPeerConnection.prototype[t]=n[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t],r=e._streams[n.id];i=i.replace(new RegExp(n.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:i})}(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=a.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((i=>{this._streams[i].getTracks().find((t=>e.track===t))&&(t=this._streams[i])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Bf(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}))}function jf(e,t){vf(e,"negotiationneeded",(e=>{const i=e.target;if(!(t.version<72||i.getConfiguration&&"plan-b"===i.getConfiguration().sdpSemantics)||"stable"===i.signalingState)return e}))}var Gf=Object.freeze({__proto__:null,fixNegotiationNeeded:jf,shimAddTrackRemoveTrack:Ff,shimAddTrackRemoveTrackWithNative:Vf,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then((t=>{const n=i.video&&i.video.width,r=i.video&&i.video.height,o=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(i.video.mandatory.maxWidth=n),r&&(i.video.mandatory.maxHeight=r),e.navigator.mediaDevices.getUserMedia(i)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))},shimGetSendersWithDtmf:Mf,shimGetStats:Uf,shimGetUserMedia:Pf,shimMediaStream:Lf,shimOnTrack:kf,shimPeerConnection:Bf,shimSenderReceiverGetStats:xf});function Wf(e,t){const i=e&&e.navigator,n=e&&e.MediaStreamTrack;if(i.getUserMedia=function(e,t,n){Af("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),i.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in i.mediaDevices.getSupportedConstraints())){const e=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])},t=i.mediaDevices.getUserMedia.bind(i.mediaDevices);if(i.mediaDevices.getUserMedia=function(i){return"object"==typeof i&&"object"==typeof i.audio&&(i=JSON.parse(JSON.stringify(i)),e(i.audio,"autoGainControl","mozAutoGainControl"),e(i.audio,"noiseSuppression","mozNoiseSuppression")),t(i)},n&&n.prototype.getSettings){const t=n.prototype.getSettings;n.prototype.getSettings=function(){const i=t.apply(this,arguments);return e(i,"mozAutoGainControl","autoGainControl"),e(i,"mozNoiseSuppression","noiseSuppression"),i}}if(n&&n.prototype.applyConstraints){const t=n.prototype.applyConstraints;n.prototype.applyConstraints=function(i){return"audio"===this.kind&&"object"==typeof i&&(i=JSON.parse(JSON.stringify(i)),e(i,"autoGainControl","mozAutoGainControl"),e(i,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[i])}}}}function Hf(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Kf(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}));const i={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,o]=arguments;return n.apply(this,[e||null]).then((e=>{if(t.version<53&&!r)try{e.forEach((e=>{e.type=i[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,n)=>{e.set(n,Object.assign({},t,{type:i[t.type]||t.type}))}))}return e})).then(r,o)}}function Yf(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Wh.resolve(new Map)}}function qf(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),vf(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function zf(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){Af("removeStream","removeTrack"),this.getSenders().forEach((t=>{var i;t.track&&Dn(i=e.getTracks()).call(i,t.track)&&this.removeTrack(t)}))})}function Xf(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function Jf(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]),e=[...e];const i=e.length>0;i&&e.forEach((e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const n=t.apply(this,arguments);if(i){const{sender:t}=n,i=t.getParameters();(!("encodings"in i)||1===i.encodings.length&&0===Object.keys(i.encodings[0]).length)&&(i.encodings=e,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(i).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return n})}function Qf(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function Zf(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Wh.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function $f(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Wh.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var eT=Object.freeze({__proto__:null,shimAddTransceiver:Jf,shimCreateAnswer:$f,shimCreateOffer:Zf,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(i){if(!i||!i.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Wh.reject(e)}return!0===i.video?i.video={mediaSource:t}:i.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(i)})},shimGetParameters:Qf,shimGetUserMedia:Wf,shimOnTrack:Hf,shimPeerConnection:Kf,shimRTCDataChannel:Xf,shimReceiverGetStats:qf,shimRemoveStream:zf,shimSenderGetStats:Yf});function tT(e){if("object"==typeof e&&e.RTCPeerConnection){if("getL
12271ocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var i;this._localStreams||(this._localStreams=[]),Dn(i=this._localStreams).call(i,e)||this._localStreams.push(e),e.getAudioTracks().forEach((i=>t.call(this,i,e))),e.getVideoTracks().forEach((i=>t.call(this,i,e)))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return n&&n.forEach((e=>{var t;this._localStreams?Dn(t=this._localStreams).call(t,e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const i=e.getTracks();this.getSenders().forEach((e=>{Dn(i).call(i,e.track)&&this.removeTrack(e)}))})}}function iT(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{var t;if(this._remoteStreams||(this._remoteStreams=[]),Dn(t=this._remoteStreams).call(t,e))return;this._remoteStreams.push(e);const i=new Event("addstream");i.stream=e,this.dispatchEvent(i)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const i=new Event("addstream");i.stream=t,e.dispatchEvent(i)}))}),t.apply(e,arguments)}}}function nT(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,i=t.createOffer,n=t.createAnswer,r=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],r=i.apply(this,[n]);return t?(r.then(e,t),Wh.resolve()):r},t.createAnswer=function(e,t){const i=arguments.length>=2?arguments[2]:arguments[0],r=n.apply(this,[i]);return t?(r.then(e,t),Wh.resolve()):r};let a=function(e,t,i){const n=r.apply(this,[e]);return i?(n.then(t,i),Wh.resolve()):n};t.setLocalDescription=a,a=function(e,t,i){const n=o.apply(this,[e]);return i?(n.then(t,i),Wh.resolve()):n},t.setRemoteDescription=a,a=function(e,t,i){const n=s.apply(this,[e]);return i?(n.then(t,i),Wh.resolve()):n},t.addIceCandidate=a}function rT(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,i=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>i(oT(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,i,n){t.mediaDevices.getUserMedia(e).then(i,n)}.bind(t))}function oT(e){return e&&void 0!==e.video?Object.assign({},e,{video:wf(e.video)}):e}function sT(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,i){if(e&&e.iceServers){const t=[];for(let i=0;i<e.iceServers.length;i++){let n=e.iceServers[i];!n.hasOwnProperty("urls")&&n.hasOwnProperty("url")?(Af("RTCIceServer.url","RTCIceServer.urls"),n=JSON.parse(JSON.stringify(n)),n.urls=n.url,delete n.url,t.push(n)):t.push(e.iceServers[i])}e.iceServers=t}return new t(e,i)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function aT(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function cT(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const i=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveVideo||i||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function dT(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var lT=Object.freeze({__proto__:null,shimAudioContext:dT,shimCallbacksAPI:nT,shimConstraints:oT,shimCreateOfferLegacy:cT,shimGetUserMedia:rT,shimLocalStreamsAPI:tT,shimRTCIceServerUrls:sT,shimRemoteStreamsAPI:iT,shimTrackEventTransceiver:aT}),uT="\t\n\v\f\r  áââââââ
ââââââ¯âã\u2028\u2029\ufeff",hT=X,pT=mn,_T=uT,ET=d("".replace),mT=RegExp("^["+_T+"]+"),fT=RegExp("(^|[^"+_T+"])["+_T+"]+$"),TT=function(e){return function(t){var i=pT(hT(t));return 1&e&&(i=ET(i,mT,"")),2&e&&(i=ET(i,fT,"$1")),i}},ST={start:TT(1),end:TT(2),trim:TT(3)},gT=ua.PROPER,RT=n,vT=uT,CT=ST.trim;wi({target:"String",proto:!0,forced:function(e){return RT((function(){return!!vT[e]()||"âÂ
á "!=="âÂ
á "[e]()||gT&&vT[e].name!==e}))}("trim")},{trim:function(){return CT(this)}});var IT=Ji("String").trim,yT=l,AT=IT,bT=String.prototype,wT=function(e){var t=e.trim;return"string"==typeof e||e===bT||yT(bT,e)&&t===bT.trim?AT:t},OT=i(wT),NT={exports:{}};!function(e){const t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((e=>e.trim()))},t.splitSections=function(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+"\r\n"))},t.getDescription=function(e){const i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){const i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter((e=>0===e.indexOf(i)))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const i={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let e=8;e<t.length;e+=2)switch(t[e]){case"raddr":i.relatedAddress=t[e+1];break;case"rport":i.relatedPort=parseInt(t[e+1],10);break;case"tcptype":i.tcpType=t[e+1];break;case"ufrag":i.ufrag=t[e+1],i.usernameFragment=t[e+1];break;default:void 0===i[t[e]]&&(i[t[e]]=t[e+1])}return i},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const i=e.component;"rtp"===i?t.push(1):"rtcp"===i?t.push(2):t.push(i),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.pu
vendor: 4,948 bytes, line 12271
12271sh(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){let t=e.substring(9).split(" ");const i={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),i.name=t[0],i.clockRate=parseInt(t[1],10),i.channels=3===t.length?parseInt(t[2],10):1,i.numChannels=i.channels,i},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const i=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==i?"/"+i:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){const t={};let i;const n=e.substring(e.indexOf(" ")+1).split(";");for(let e=0;e<n.length;e++)i=n[e].trim().split("="),t[i[0].trim()]=i[1];return t},t.writeFmtp=function(e){let t="",i=e.payloadType;if(void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const n=[];Object.keys(e.parameters).forEach((t=>{void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+i+" "+n.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",i=e.payloadType;return void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((e=>{t+="a=rtcp-fb:"+i+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),i={ssrc:parseInt(e.substring(7,t),10)},n=e.indexOf(":",t);return n>-1?(i.attribute=e.substring(t+1,n),i.value=e.substring(n+1)):i.attribute=e.substring(t+1),i},t.parseSsrcGroup=function(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((e=>parseInt(e,10)))}},t.getMid=function(e){const i=t.matchPrefix(e,"a=mid:")[0];if(i)return i.substring(6)},t.parseFingerprint=function(e){const t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,i){return{role:"auto",fingerprints:t.matchPrefix(e+i,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let i="a=setup:"+t+"\r\n";return e.fingerprints.forEach((e=>{i+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),i},t.parseCryptoLine=function(e){const t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substring(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){return t.matchPrefix(e+i,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,i){const n=t.matchPrefix(e+i,"a=ice-ufrag:")[0],r=t.matchPrefix(e+i,"a=ice-pwd:")[0];return n&&r?{usernameFragment:n.substring(12),password:r.substring(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e)[0].split(" ");i.profile=n[2];for(let r=3;r<n.length;r++){const o=n[r],s=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(s){const n=t.parseRtpMap(s),r=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(n.parameters=r.length?t.parseFmtp(r[0]):{},n.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),i.codecs.push(n),n.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(n.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach((e=>{i.headerExtensions.push(t.parseExtmap(e))}));const r=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return i.codecs.forEach((e=>{r.forEach((t=>{e.rtcpFeedback.find((e=>e.type===t.type&&e.parameter===t.parameter))||e.rtcpFeedback.push(t)}))})),i},t.writeRtpDescription=function(e,i){let n="";
vendor: 4,912 bytes, line 12271
12271n+="m="+e+" ",n+=i.codecs.length>0?"9":"0",n+=" "+(i.profile||"UDP/TLS/RTP/SAVPF")+" ",n+=i.codecs.map((e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType)).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",i.codecs.forEach((e=>{n+=t.writeRtpMap(e),n+=t.writeFmtp(e),n+=t.writeRtcpFb(e)}));let r=0;return i.codecs.forEach((e=>{e.maxptime>r&&(r=e.maxptime)})),r>0&&(n+="a=maxptime:"+r+"\r\n"),i.headerExtensions&&i.headerExtensions.forEach((e=>{n+=t.writeExtmap(e)})),n},t.parseRtpEncodingParameters=function(e){const i=[],n=t.parseRtpParameters(e),r=-1!==n.fecMechanisms.indexOf("RED"),o=-1!==n.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute)),a=s.length>0&&s[0].ssrc;let c;const d=t.matchPrefix(e,"a=ssrc-group:FID").map((e=>e.substring(17).split(" ").map((e=>parseInt(e,10)))));d.length>0&&d[0].length>1&&d[0][0]===a&&(c=d[0][1]),n.codecs.forEach((e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:a,codecPayloadType:parseInt(e.parameters.apt,10)};a&&c&&(t.rtx={ssrc:c}),i.push(t),r&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:a,mechanism:o?"red+ulpfec":"red"},i.push(t))}})),0===i.length&&a&&i.push({ssrc:a});let l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substring(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substring(5),10)*.95-16e3:void 0,i.forEach((e=>{e.maxBitrate=l}))),i},t.parseRtcpParameters=function(e){const i={},n=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute))[0];n&&(i.cname=n.value,i.ssrc=n.ssrc);const r=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=r.length>0,i.compound=0===r.length;const o=t.matchPrefix(e,"a=rtcp-mux");return i.mux=o.length>0,i},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let i;const n=t.matchPrefix(e,"a=msid:");if(1===n.length)return i=n[0].substring(7).split(" "),{stream:i[0],track:i[1]};const r=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return r.length>0?(i=r[0].value.split(" "),{stream:i[0],track:i[1]}):void 0},t.parseSctpDescription=function(e){const i=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:");let r;n.length>0&&(r=parseInt(n[0].substring(19),10)),isNaN(r)&&(r=65536);const o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:i.fmt,maxMessageSize:r};const s=t.matchPrefix(e,"a=sctpmap:");if(s.length>0){const e=s[0].substring(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:r}}},t.writeSctpDescription=function(e,t){let i=[];return i="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&i.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),i.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,i,n){let r;const o=void 0!==i?i:2;r=e||t.generateSessionId();return"v=0\r\no="+(n||"thisisadapterortc")+" "+r+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,i){const n=t.splitLines(e);for(let e=0;e<n.length;e++)switch(n[e]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[e].substring(2)}return i?t.getDirection(i):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const i=t.splitLines(e)[0].substring(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},t.parseOLine=function(e){const i=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const i=t.splitLines(e);for(let e=0;e<i.length;e++)if(i[e].length<2||"="!==i[e].charAt(1))return!1;return!0},e.exports=t}(NT);var DT=NT.exports,PT=i(DT),LT=e({__proto__:null,default:PT},[DT]);function kT(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const i=new t(e),n=PT.parseCandidate(e.candidate),r=Object.assign(i,n);return r.toJSON=function(){return{candidate:r.candidate,sdpMid:r.sdpMid,sdpMLineIndex:r.
vendor: 4,119 bytes, line 12271
12271sdpMLineIndex,usernameFragment:r.usernameFragment}},r}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,vf(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function MT(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||vf(e,"icecandidate",(e=>{if(e.candidate){const t=PT.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function UT(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const i=function(e){if(!e||!e.sdp)return!1;const t=PT.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=PT.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))},n=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const i=parseInt(t[1],10);return i!=i?-1:i},r=function(e){let i=65536;return"firefox"===t.browser&&(i=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),i},o=function(e,i){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const r=PT.matchPrefix(e.sdp,"a=max-message-size:");return r.length>0?n=parseInt(r[0].substr(19),10):"firefox"===t.browser&&-1!==i&&(n=2147483637),n},s=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(i(arguments[0])){const e=n(arguments[0]),t=r(e),i=o(arguments[0],e);let s;s=0===t&&0===i?Number.POSITIVE_INFINITY:0===t||0===i?Math.max(t,i):Math.min(t,i);const a={};Object.defineProperty(a,"maxMessageSize",{get:()=>s}),this._sctp=a}return s.apply(this,arguments)}}function xT(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const i=e.send;e.send=function(){const n=arguments[0],r=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&r>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return i.apply(e,arguments)}}const i=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=i.apply(this,arguments);return t(e,this),e},vf(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function VT(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const i=new Event("connectionstatechange",e);t.dispatchEvent(i)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}}))}function FT(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.s
vendor: 4,143 bytes, line 12271
12271dp.indexOf("\na=extmap-allow-mixed")){const i=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==OT(e).call(e))).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:i}):t.sdp=i}return i.apply(this,arguments)}}function BT(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.addIceCandidate;i&&0!==i.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Wh.resolve():i.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Wh.resolve())})}function jT(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.setLocalDescription;i&&0!==i.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return i.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}if(e.sdp||"offer"!==e.type&&"answer"!==e.type)return i.apply(this,[e]);return("offer"===e.type?this.createOffer:this.createAnswer).apply(this).then((e=>i.apply(this,[e])))})}var GT=Object.freeze({__proto__:null,removeExtmapAllowMixed:FT,shimAddIceCandidateNullOrEmpty:BT,shimConnectionState:VT,shimMaxMessageSize:UT,shimParameterlessSetLocalDescription:jT,shimRTCIceCandidate:kT,shimRTCIceCandidateRelayProtocol:MT,shimSendThrowTypeError:xT});!function(){let{window:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0};const i=yf,n=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:i}=e;if(i.mozGetUserMedia)t.browser="firefox",t.version=Rf(i.userAgent,/Firefox\/(\d+)\./,1);else if(i.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=Rf(i.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!i.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=Rf(i.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),r={browserDetails:n,commonShim:GT,extractVersion:Rf,disableLog:Cf,disableWarnings:If,sdp:LT};switch(n.browser){case"chrome":if(!Gf||!Bf||!t.shimChrome)return i("Chrome shim is not included in this adapter release."),r;if(null===n.version)return i("Chrome shim can not determine version, not shimming."),r;i("adapter.js shimming chrome."),r.browserShim=Gf,BT(e,n),jT(e),Pf(e,n),Lf(e),Bf(e,n),kf(e),Ff(e,n),Mf(e),Uf(e),xf(e),jf(e,n),kT(e),MT(e),VT(e),UT(e,n),xT(e),FT(e,n);break;case"firefox":if(!eT||!Kf||!t.shimFirefox)return i("Firefox shim is not included in this adapter release."),r;i("adapter.js shimming firefox."),r.browserShim=eT,BT(e,n),jT(e),Wf(e,n),Kf(e,n),Hf(e),zf(e),Yf(e),qf(e),Xf(e),Jf(e),Qf(e),Zf(e),$f(e),kT(e),VT(e),UT(e,n),xT(e);break;case"safari":if(!lT||!t.shimSafari)return i("Safari shim is not included in this adapter release."),r;i("adapter.js shimming safari."),r.browserShim=lT,BT(e,n),jT(e),sT(e),cT(e),nT(e),tT(e),iT(e),aT(e),rT(e),dT(e),kT(e),MT(e),UT(e,n),xT(e),FT(e,n);break;default:i("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var WT=be,HT=TypeError,KT=ce.match(/firefox\/(\d+)/i),YT=!!KT&&+KT[1],qT=/MSIE|Trident/.test(ce),zT=ce.match(/AppleWebKit\/(\d+)\./),XT=!!zT&&+zT[1],JT=wi,QT=d,ZT=De,$T=Xe,eS=Gi,tS=function(e,t){if(!delete e[t])throw HT("Cannot delete property "+WT(t)+" of "+WT(e))},iS=mn,nS=n,rS=Tp,oS=Bn,sS=YT,aS=qT,cS=Ee,dS=XT,lS=[],uS=QT(lS.sort),hS=QT(lS.push),pS=nS((function(){lS.sort(void 0)})),_S=nS((function(){lS.sort(null)})),ES=oS("sort"),mS=!nS((function(){if(cS)return cS<70;if(!(sS&&sS>3)){if(aS)return!0;
vendor: 4,899 bytes, line 12271
12271if(dS)return dS<603;var e,t,i,n,r="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:i=3;break;case 68:case 71:i=4;break;default:i=2}for(n=0;n<47;n++)lS.push({k:t+n,v:i})}for(lS.sort((function(e,t){return t.v-e.v})),n=0;n<lS.length;n++)t=lS[n].k.charAt(0),r.charAt(r.length-1)!==t&&(r+=t);return"DGBEFHACIJK"!==r}}));JT({target:"Array",proto:!0,forced:pS||!_S||!ES||!mS},{sort:function(e){void 0!==e&&ZT(e);var t=$T(this);if(mS)return void 0===e?uS(t):uS(t,e);var i,n,r=[],o=eS(t);for(n=0;n<o;n++)n in t&&hS(r,t[n]);for(rS(r,function(e){return function(t,i){return void 0===i?-1:void 0===t?1:void 0!==e?+e(t,i)||0:iS(t)>iS(i)?1:-1}}(e)),i=eS(r),n=0;n<i;)t[n]=r[n++];for(;n<o;)tS(t,n++);return t}});var fS=Ji("Array").sort,TS=l,SS=fS,gS=Array.prototype,RS=function(e){var t=e.sort;return e===gS||TS(gS,e)&&t===gS.sort?SS:t},vS=i(RS),CS=h;wi({global:!0,forced:CS.globalThis!==CS},{globalThis:CS});var IS=i(h),yS={exports:{}};!function(e,i){!function(t,n){var r="function",o="undefined",s="object",a="string",c="major",d="model",l="name",u="type",h="vendor",p="version",_="architecture",E="console",m="mobile",f="tablet",T="smarttv",S="wearable",g="embedded",R="Amazon",v="Apple",C="ASUS",I="BlackBerry",y="Browser",A="Chrome",b="Firefox",w="Google",O="Huawei",N="LG",D="Microsoft",P="Motorola",L="Opera",k="Samsung",M="Sharp",U="Sony",x="Xiaomi",V="Zebra",F="Facebook",B="Chromium OS",j="Mac OS",G=function(e){for(var t={},i=0;i<e.length;i++)t[e[i].toUpperCase()]=e[i];return t},W=function(e,t){return typeof e===a&&-1!==H(t).indexOf(H(e))},H=function(e){return e.toLowerCase()},K=function(e,t){if(typeof e===a)return e=e.replace(/^\s\s*/,""),typeof t===o?e:e.substring(0,350)},Y=function(e,t){for(var i,o,a,c,d,l,u=0;u<t.length&&!d;){var h=t[u],p=t[u+1];for(i=o=0;i<h.length&&!d&&h[i];)if(d=h[i++].exec(e))for(a=0;a<p.length;a++)l=d[++o],typeof(c=p[a])===s&&c.length>0?2===c.length?typeof c[1]==r?this[c[0]]=c[1].call(this,l):this[c[0]]=c[1]:3===c.length?typeof c[1]!==r||c[1].exec&&c[1].test?this[c[0]]=l?l.replace(c[1],c[2]):n:this[c[0]]=l?c[1].call(this,l,c[2]):n:4===c.length&&(this[c[0]]=l?c[3].call(this,l.replace(c[1],c[2])):n):this[c]=l||n;u+=2}},q=function(e,t){for(var i in t)if(typeof t[i]===s&&t[i].length>0){for(var r=0;r<t[i].length;r++)if(W(t[i][r],e))return"?"===i?n:i}else if(W(t[i],e))return"?"===i?n:i;return e},z={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},X={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[p,[l,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[p,[l,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[l,p],[/opios[\/ ]+([\w\.]+)/i],[p,[l,L+" Mini"]],[/\bopr\/([\w\.]+)/i],[p,[l,L]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(weibo)__([\d\.]+)/i],[l,p],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[p,[l,"UC"+y]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[p,[l,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[p,[l,"WeChat"]],[/konqueror\/([\w\.]+)/i],[p,[l,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[p,[l,"IE"]],[/yabrowser\/([\w\.]+)/i],[p,[l,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[l,/(.+)/,"$1 Secure "+y],p],[/\bfocus\/([\w\.]+)/i],[p,[l,b+" Focus"]],[/\bopt\/([\w\.]+)/i],[p,[l,L+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[p,[l,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[p,[l,"Dolphin"]],[/coast\/([\w\.]+)/i],[p,[l,L+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[p,[l,"MIUI "+y]],[/fxios\/([-\w\.]+)/i],[p,[l,b]],[/\bqihu|(qi?ho?o?|360)browser/i],[[l,"360 "+y]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[l,/(.+)/,"$1 "+y],p],[/(comodo_dragon)\/([\w\.]+)/i],[[l,/_/g," "],p],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[l,p],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[l],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[l,F],p],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[l,p],[/\bgsa\/([\w\.]+) .*safari\//i],[p,[l,"GSA"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[p,[l,A+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[l,A+" WebView"],p],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[p,[l,"Android "+y]],[/(chrome|omniweb|arora|[t
vendor: 4,813 bytes, line 12271
12271izenoka]{5} ?browser)\/v?([\w\.]+)/i],[l,p],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[p,[l,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[p,l],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[l,[p,q,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[l,p],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[l,"Netscape"],p],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[p,[l,b+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[l,p],[/(cobalt)\/([\w\.]+)/i],[l,[p,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[_,"amd64"]],[/(ia32(?=;))/i],[[_,H]],[/((?:i[346]|x)86)[;\)]/i],[[_,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[_,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[_,"armhf"]],[/windows (ce|mobile); ppc;/i],[[_,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[_,/ower/,"",H]],[/(sun4\w)[;\)]/i],[[_,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[_,H]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[h,k],[u,f]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[d,[h,k],[u,m]],[/\((ip(?:hone|od)[\w ]*);/i],[d,[h,v],[u,m]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[h,v],[u,f]],[/(macintosh);/i],[d,[h,v]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[h,M],[u,m]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[h,O],[u,f]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[h,O],[u,m]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[d,/_/g," "],[h,x],[u,m]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/g," "],[h,x],[u,f]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[d,[h,"OPPO"],[u,m]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[h,"Vivo"],[u,m]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[d,[h,"Realme"],[u,m]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[d,[h,P],[u,m]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[h,P],[u,f]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[h,N],[u,f]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[d,[h,N],[u,m]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[h,"Lenovo"],[u,f]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g," "],[h,"Nokia"],[u,m]],[/(pixel c)\b/i],[d,[h,w],[u,f]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[h,w],[u,m]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[d,[h,U],[u,m]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,"Xperia Tablet"],[h,U],[u,f]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[h,"OnePlus"],[u,m]],[/(alexa)webm/i,/(kf[a-z]{2}wi)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[h,R],[u,f]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,"Fire Phone $1"],[h,R],[u,m]],[/(playbook);[-\w\),; ]+(rim)/i],[d,h,[u,f]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[h,I],[u,m]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[h,C],[u,f]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[h,C],[u,m]],[/(nexus 9)/i],[d,[h,"HTC"],[u,f]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[d,/_/g," "],[u,m]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[h,"Acer"],[u,f]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[h,"Meizu"],[u,m]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asu
vendor: 5,737 bytes, line 12271
12271s)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,d,[u,m]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,d,[u,f]],[/(surface duo)/i],[d,[h,D],[u,f]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[h,"Fairphone"],[u,m]],[/(u304aa)/i],[d,[h,"AT&T"],[u,m]],[/\bsie-(\w*)/i],[d,[h,"Siemens"],[u,m]],[/\b(rct\w+) b/i],[d,[h,"RCA"],[u,f]],[/\b(venue[\d ]{2,7}) b/i],[d,[h,"Dell"],[u,f]],[/\b(q(?:mv|ta)\w+) b/i],[d,[h,"Verizon"],[u,f]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[d,[h,"Barnes & Noble"],[u,f]],[/\b(tm\d{3}\w+) b/i],[d,[h,"NuVision"],[u,f]],[/\b(k88) b/i],[d,[h,"ZTE"],[u,f]],[/\b(nx\d{3}j) b/i],[d,[h,"ZTE"],[u,m]],[/\b(gen\d{3}) b.+49h/i],[d,[h,"Swiss"],[u,m]],[/\b(zur\d{3}) b/i],[d,[h,"Swiss"],[u,f]],[/\b((zeki)?tb.*\b) b/i],[d,[h,"Zeki"],[u,f]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],d,[u,f]],[/\b(ns-?\w{0,9}) b/i],[d,[h,"Insignia"],[u,f]],[/\b((nxa|next)-?\w{0,9}) b/i],[d,[h,"NextBook"],[u,f]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],d,[u,m]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],d,[u,m]],[/\b(ph-1) /i],[d,[h,"Essential"],[u,m]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[d,[h,"Envizen"],[u,f]],[/\b(trio[-\w\. ]+) b/i],[d,[h,"MachSpeed"],[u,f]],[/\btu_(1491) b/i],[d,[h,"Rotor"],[u,f]],[/(shield[\w ]+) b/i],[d,[h,"Nvidia"],[u,f]],[/(sprint) (\w+)/i],[h,d,[u,m]],[/(kin\.[onetw]{3})/i],[[d,/\./g," "],[h,D],[u,m]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[h,V],[u,f]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[h,V],[u,m]],[/smart-tv.+(samsung)/i],[h,[u,T]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,"SmartTV"],[h,k],[u,T]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,N],[u,T]],[/(apple) ?tv/i],[h,[d,v+" TV"],[u,T]],[/crkey/i],[[d,A+"cast"],[h,w],[u,T]],[/droid.+aft(\w)( bui|\))/i],[d,[h,R],[u,T]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[h,M],[u,T]],[/(bravia[\w ]+)( bui|\))/i],[d,[h,U],[u,T]],[/(mitv-\w{5}) bui/i],[d,[h,x],[u,T]],[/Hbbtv.*(technisat) (.*);/i],[h,d,[u,T]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,K],[d,K],[u,T]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[u,T]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,d,[u,E]],[/droid.+; (shield) bui/i],[d,[h,"Nvidia"],[u,E]],[/(playstation [345portablevi]+)/i],[d,[h,U],[u,E]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[h,D],[u,E]],[/((pebble))app/i],[h,d,[u,S]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[h,v],[u,S]],[/droid.+; (glass) \d/i],[d,[h,w],[u,S]],[/droid.+; (wt63?0{2,3})\)/i],[d,[h,V],[u,S]],[/(quest( 2| pro)?)/i],[d,[h,F],[u,S]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[u,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[d,[u,m]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[u,f]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[u,f]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[u,m]],[/(android[-\w\. ]{0,9});.+buil/i],[d,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[p,[l,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[p,[l,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i],[l,p],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[p,l]],os:[[/microsoft (windows) (vista|xp)/i],[l,p],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[l,[p,q,z]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[l,"Windows"],[p,q,z]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/cfnetwork\/.+darwin/i],[[p,/_/g,"."],[l,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[l,j],[p,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[p,l],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[l,p],[/\(bb(10);/i],[p,[l,I]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[p,[l,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[p,[l,b+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[p,[l,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[p,[l,"watchOS"]],[/crkey\/([\d\.]+)/i],[p,[l,A+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[l,B],p],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[l,p],[/(sunos) ?([\w\.\d]*)/i],[[l,"Solaris"],p],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux)/i,/(unix) ?([\w\.]*)/i],[l,p]]},J=function(e,i){if(typeof e===s&&(i=e,e=n),!(this instanceof J))return new J
12271(e,i).getResult();var E=typeof t!==o&&t.navigator?t.navigator:n,T=e||(E&&E.userAgent?E.userAgent:""),S=E&&E.userAgentData?E.userAgentData:n,g=i?function(e,t){var i={};for(var n in e)t[n]&&t[n].length%2==0?i[n]=t[n].concat(e[n]):i[n]=e[n];return i}(X,i):X;return this.getBrowser=function(){var e={};return e[l]=n,e[p]=n,Y.call(e,T,g.browser),e[c]=function(e){return typeof e===a?e.replace(/[^\d\.]/g,"").split(".")[0]:n}(e[p]),E&&E.brave&&typeof E.brave.isBrave==r&&(e[l]="Brave"),e},this.getCPU=function(){var e={};return e[_]=n,Y.call(e,T,g.cpu),e},this.getDevice=function(){var e={};return e[h]=n,e[d]=n,e[u]=n,Y.call(e,T,g.device),!e[u]&&S&&S.mobile&&(e[u]=m),"Macintosh"==e[d]&&E&&typeof E.standalone!==o&&E.maxTouchPoints&&E.maxTouchPoints>2&&(e[d]="iPad",e[u]=f),e},this.getEngine=function(){var e={};return e[l]=n,e[p]=n,Y.call(e,T,g.engine),e},this.getOS=function(){var e={};return e[l]=n,e[p]=n,Y.call(e,T,g.os),!e[l]&&S&&"Unknown"!=S.platform&&(e[l]=S.platform.replace(/chrome os/i,B).replace(/macos/i,j)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return T},this.setUA=function(e){return T=typeof e===a&&e.length>350?K(e,350):e,this},this.setUA(T),this};J.VERSION="0.7.34",J.BROWSER=G([l,p,c]),J.CPU=G([_]),J.DEVICE=G([d,h,u,E,m,T,f,S,g]),J.ENGINE=J.OS=G([l,p]),e.exports&&(i=e.exports=J),i.UAParser=J;var Q=typeof t!==o&&(t.jQuery||t.Zepto);if(Q&&!Q.ua){var Z=new J;Q.ua=Z.getResult(),Q.ua.get=function(){return Z.getUA()},Q.ua.set=function(e){Z.setUA(e);var t=Z.getResult();for(var i in t)Q.ua[i]=t[i]}}}("object"==typeof window?window:t)}(yS,yS.exports);var AS=i(yS.exports),bS=pn,wS=Ze,OS=Y,NS=Vo,DS=ht("iterator"),PS=Object,LS=function(e){if(OS(e))return!1;var t=PS(e);return void 0!==t[DS]||"@@iterator"in t||wS(NS,bS(t))},kS=i(LS),MS=bd.clear;wi({global:!0,bind:!0,enumerable:!0,forced:h.clearImmediate!==MS},{clearImmediate:MS});var US="function"==typeof Bun&&Bun&&"string"==typeof Bun.version,xS=h,VS=f,FS=w,BS=US,jS=ce,GS=Qc,WS=$c,HS=xS.Function,KS=/MSIE .\./.test(jS)||BS&&function(){var e=xS.Bun.version.split(".");return e.length<3||0==e[0]&&(e[1]<3||3==e[1]&&0==e[2])}(),YS=wi,qS=h,zS=bd.set,XS=function(e,t){var i=t?2:1;return KS?function(n,r){var o=WS(arguments.length,1)>i,s=FS(n)?n:HS(n),a=o?GS(arguments,i):[],c=o?function(){VS(s,this,a)}:s;return t?e(c,r):e(c)}:e},JS=qS.setImmediate?XS(zS,!1):zS;YS({global:!0,bind:!0,enumerable:!0,forced:qS.setImmediate!==JS},{setImmediate:JS});var QS=i(ie.setImmediate),ZS=wi,$S=el,eg=De,tg=$c,ig=jn,ng=h.process;ZS({global:!0,enumerable:!0,dontCallGetSet:!0},{queueMicrotask:function(e){tg(arguments.length,1),eg(e);var t=ig&&ng.domain;$S(t?t.bind(e):e)}});var rg=i(ie.queueMicrotask);function og(e,t){return function(){return e.apply(t,arguments)}}const{toString:sg}=Object.prototype,{getPrototypeOf:ag}=Object,cg=(dg=Object.create(null),e=>{const t=sg.call(e);return dg[t]||(dg[t]=t.slice(8,-1).toLowerCase())});var dg;const lg=e=>(e=e.toLowerCase(),t=>cg(t)===e),ug=e=>t=>typeof t===e,{isArray:hg}=Array,pg=ug("undefined");const _g=lg("ArrayBuffer");const Eg=ug("string"),mg=ug("function"),fg=ug("number"),Tg=e=>null!==e&&"object"==typeof e,Sg=e=>{if("object"!==cg(e))return!1;const t=ag(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||kS(e))},gg=lg("Date"),Rg=lg("File"),vg=lg("Blob"),Cg=lg("FileList"),Ig=lg("URLSearchParams"),[yg,Ag,bg,wg]=["ReadableStream","Request","Response","Headers"].map(lg);function Og(e,t){let i,n,{allOwnKeys:r=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null!=e)if("object"!=typeof e&&(e=[e]),hg(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{const n=r?Object.getOwnPropertyNames(e):Object.keys(e),o=n.length;let s;for(i=0;i<o;i++)s=n[i],t.call(null,e[s],s,e)}}function Ng(e,t){t=t.toLowerCase();const i=Object.keys(e);let n,r=i.length;for(;r-- >0;)if(n=i[r],t===n.toLowerCase())return n;return null}const Dg=void 0!==IS?IS:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Pg=e=>!pg(e)&&e!==Dg;const Lg=(kg="undefined"!=typeof Uint8Array&&ag(Uint8Array),e=>kg&&e instanceof kg);var kg;const Mg=lg("HTMLFormElement"),Ug=(e=>{let{hasOwnProperty:t}=e;return(e,i)=>t.call(e,i)})(Object.prototype),xg=lg("RegExp"),Vg=(e,t)=>
vendor: 5,062 bytes, line 12271
12271{const i=Object.getOwnPropertyDescriptors(e),n={};Og(i,((i,r)=>{let o;!1!==(o=t(i,r,e))&&(n[r]=o||i)})),Object.defineProperties(e,n)},Fg="abcdefghijklmnopqrstuvwxyz",Bg="0123456789",jg={DIGIT:Bg,ALPHA:Fg,ALPHA_DIGIT:Fg+Fg.toUpperCase()+Bg};const Gg=lg("AsyncFunction"),Wg=(Hg="function"==typeof QS,Kg=mg(Dg.postMessage),Hg?QS:Kg?(Yg="axios@".concat(Math.random()),qg=[],Dg.addEventListener("message",(e=>{let{source:t,data:i}=e;t===Dg&&i===Yg&&qg.length&&qg.shift()()}),!1),e=>{qg.push(e),Dg.postMessage(Yg,"*")}):e=>setTimeout(e));var Hg,Kg,Yg,qg;const zg=void 0!==rg?rg.bind(Dg):"undefined"!=typeof process&&process.nextTick||Wg;var Xg={isArray:hg,isArrayBuffer:_g,isBuffer:function(e){return null!==e&&!pg(e)&&null!==e.constructor&&!pg(e.constructor)&&mg(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||mg(e.append)&&("formdata"===(t=cg(e))||"object"===t&&mg(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&_g(e.buffer),t},isString:Eg,isNumber:fg,isBoolean:e=>!0===e||!1===e,isObject:Tg,isPlainObject:Sg,isReadableStream:yg,isRequest:Ag,isResponse:bg,isHeaders:wg,isUndefined:pg,isDate:gg,isFile:Rg,isBlob:vg,isRegExp:xg,isFunction:mg,isStream:e=>Tg(e)&&mg(e.pipe),isURLSearchParams:Ig,isTypedArray:Lg,isFileList:Cg,forEach:Og,merge:function e(){const{caseless:t}=Pg(this)&&this||{},i={},n=(n,r)=>{const o=t&&Ng(i,r)||r;Sg(i[o])&&Sg(n)?i[o]=e(i[o],n):Sg(n)?i[o]=e({},n):hg(n)?i[o]=n.slice():i[o]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&Og(arguments[e],n);return i},extend:function(e,t,i){let{allOwnKeys:n}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Og(t,((t,n)=>{i&&mg(t)?e[n]=og(t,i):e[n]=t}),{allOwnKeys:n}),e},trim:e=>OT(e)?OT(e).call(e):e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,i,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),i&&Object.assign(e.prototype,i)},toFlatObject:(e,t,i,n)=>{let r,o,s;const a={};if(t=t||{},null==e)return t;do{for(r=Object.getOwnPropertyNames(e),o=r.length;o-- >0;)s=r[o],n&&!n(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==i&&ag(e)}while(e&&(!i||i(e,t))&&e!==Object.prototype);return t},kindOf:cg,kindOfTest:lg,endsWith:(e,t,i)=>{e=String(e),(void 0===i||i>e.length)&&(i=e.length),i-=t.length;const n=e.indexOf(t,i);return-1!==n&&n===i},toArray:e=>{if(!e)return null;if(hg(e))return e;let t=e.length;if(!fg(t))return null;const i=new Array(t);for(;t-- >0;)i[t]=e[t];return i},forEachEntry:(e,t)=>{const i=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=i.next())&&!n.done;){const i=n.value;t.call(e,i[0],i[1])}},matchAll:(e,t)=>{let i;const n=[];for(;null!==(i=e.exec(t));)n.push(i);return n},isHTMLForm:Mg,hasOwnProperty:Ug,hasOwnProp:Ug,reduceDescriptors:Vg,freezeMethods:e=>{Vg(e,((t,i)=>{if(mg(e)&&-1!==["arguments","caller","callee"].indexOf(i))return!1;const n=e[i];mg(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")}))}))},toObjectSet:(e,t)=>{const i={},n=e=>{e.forEach((e=>{i[e]=!0}))};return hg(e)?n(e):n(String(e).split(t)),i},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,i){return t.toUpperCase()+i})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:Ng,global:Dg,isContextDefined:Pg,ALPHABET:jg,generateString:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jg.ALPHA_DIGIT,i="";const{length:n}=t;for(;e--;)i+=t[Math.random()*n|0];return i},isSpecCompliantForm:function(e){return!!(e&&mg(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),i=(e,n)=>{if(Tg(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const r=hg(e)?[]:{};return Og(e,((e,t)=>{const o=i(e,n+1);!pg(o)&&(r[t]=o)})),t[n]=void 0,r}}return e};return i(e,0)},isAsyncFn:Gg,isThenable:e=>e&&(Tg(e)||mg(e))&&mg(e.then)&&mg(e.catch),setImmediate:Wg,asap:zg};function Jg(e,t,i,n,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),i&&(this.config=i),n&&(this.request=n),r&&(this.response=r,this.status=r.status?r.status:null)}Xg.inherits(Jg,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Xg.toJSONObject(this.config),code:this.code,status:this.status}}});const Qg=Jg.prototype,Zg={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","E
12271RR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Zg[e]={value:e}})),Object.defineProperties(Jg,Zg),Object.defineProperty(Qg,"isAxiosError",{value:!0}),Jg.from=(e,t,i,n,r,o)=>{const s=Object.create(Qg);return Xg.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),Jg.call(s,e.message,t,i,n,r),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};function $g(e){return Xg.isPlainObject(e)||Xg.isArray(e)}function eR(e){return Xg.endsWith(e,"[]")?e.slice(0,-2):e}function tR(e,t,i){return e?e.concat(t).map((function(e,t){return e=eR(e),!i&&t?"["+e+"]":e})).join(i?".":""):t}const iR=Xg.toFlatObject(Xg,{},null,(function(e){return/^is[A-Z]/.test(e)}));function nR(e,t,i){if(!Xg.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(i=Xg.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!Xg.isUndefined(t[e])}))).metaTokens,r=i.visitor||d,o=i.dots,s=i.indexes,a=(i.Blob||"undefined"!=typeof Blob&&Blob)&&Xg.isSpecCompliantForm(t);if(!Xg.isFunction(r))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(Xg.isDate(e))return e.toISOString();if(!a&&Xg.isBlob(e))throw new Jg("Blob is not supported. Use a Buffer instead.");return Xg.isArrayBuffer(e)||Xg.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function d(e,i,r){let a=e;if(e&&!r&&"object"==typeof e)if(Xg.endsWith(i,"{}"))i=n?i:i.slice(0,-2),e=JSON.stringify(e);else if(Xg.isArray(e)&&function(e){return Xg.isArray(e)&&!e.some($g)}(e)||(Xg.isFileList(e)||Xg.endsWith(i,"[]"))&&(a=Xg.toArray(e)))return i=eR(i),a.forEach((function(e,n){!Xg.isUndefined(e)&&null!==e&&t.append(!0===s?tR([i],n,o):null===s?i:i+"[]",c(e))})),!1;return!!$g(e)||(t.append(tR(r,i,o),c(e)),!1)}const l=[],u=Object.assign(iR,{defaultVisitor:d,convertValue:c,isVisitable:$g});if(!Xg.isObject(e))throw new TypeError("data must be an object");return function e(i,n){if(!Xg.isUndefined(i)){if(-1!==l.indexOf(i))throw Error("Circular reference detected in "+n.join("."));l.push(i),Xg.forEach(i,(function(i,o){!0===(!(Xg.isUndefined(i)||null===i)&&r.call(t,i,Xg.isString(o)?OT(o).call(o):o,n,u))&&e(i,n?n.concat(o):[o])})),l.pop()}}(e),t}function rR(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function oR(e,t){this._pairs=[],e&&nR(e,this,t)}const sR=oR.prototype;function aR(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function cR(e,t,i){if(!t)return e;const n=i&&i.encode||aR;Xg.isFunction(i)&&(i={serialize:i});const r=i&&i.serialize;let o;if(o=r?r(t,i):Xg.isURLSearchParams(t)?t.toString():new oR(t,i).toString(n),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}sR.append=function(e,t){this._pairs.push([e,t])},sR.toString=function(e){const t=e?function(t){return e.call(this,t,rR)}:rR;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var dR=class{constructor(){this.handlers=[]}use(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!i&&i.synchronous,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Xg.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},lR={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},uR={exports:{}},hR=wi,pR=N,_R=Qt.f;hR({target:"Object",stat:!0,forced:Object.defineProperty!==_R,sham:!pR},{defineProperty:_R});var ER=ie.Object,mR=uR.exports=function(e,t,i){return ER.defineProperty(e,t,i)};ER.defineProperty.sham&&(mR.sham=!0);var fR=i(uR.exports),TR=TypeError,SR=Qn,gR=Gc,RR=te,vR=ht("species"),CR=Array,IR=function(e){var t;return SR(e)&&(t=e.constructor,(gR(t)&&(t===CR||SR(t.prototype))||RR(t)&&null===(t=t[vR]))&&(t=void 0)),void 0===t?CR:t},yR=function(e,t){return new(IR(e))(0===t?0:t)},AR=n,bR=Ee,wR=ht("species"),OR=function(e){return bR>=51||!AR((function(){var t=[];return(t.constructor={})[wR]=function(){return{foo:1}
vendor: 4,403 bytes, line 12271
12271},1!==t[e](Boolean).foo}))},NR=wi,DR=n,PR=Qn,LR=te,kR=Xe,MR=Gi,UR=function(e){if(e>9007199254740991)throw TR("Maximum allowed index exceeded");return e},xR=sp,VR=yR,FR=OR,BR=Ee,jR=ht("isConcatSpreadable"),GR=BR>=51||!DR((function(){var e=[];return e[jR]=!1,e.concat()[0]!==e})),WR=function(e){if(!LR(e))return!1;var t=e[jR];return void 0!==t?!!t:PR(e)};NR({target:"Array",proto:!0,arity:1,forced:!GR||!FR("concat")},{concat:function(e){var t,i,n,r,o,s=kR(this),a=VR(s,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(WR(o=-1===t?s:arguments[t]))for(r=MR(o),UR(c+r),i=0;i<r;i++,c++)i in o&&xR(a,c,o[i]);else UR(c+1),xR(a,c++,o);return a.length=c,a}});var HR={},KR=R,YR=Z,qR=Nr.f,zR=hp,XR="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];HR.f=function(e){return XR&&"Window"==KR(e)?function(e){try{return qR(e)}catch(e){return zR(XR)}}(e):qR(YR(e))};var JR={},QR=ht;JR.f=QR;var ZR=ie,$R=Ze,ev=JR,tv=Qt.f,iv=function(e){var t=ZR.Symbol||(ZR.Symbol={});$R(t,e)||tv(t,e,{value:ev.f(e)})},nv=L,rv=ae,ov=ht,sv=pa,av=function(){var e=rv("Symbol"),t=e&&e.prototype,i=t&&t.valueOf,n=ov("toPrimitive");t&&!t[n]&&sv(t,n,(function(e){return nv(i,this)}),{arity:1})},cv=Jt,dv=K,lv=Xe,uv=Gi,hv=yR,pv=d([].push),_v=function(e){var t=1==e,i=2==e,n=3==e,r=4==e,o=6==e,s=7==e,a=5==e||o;return function(c,d,l,u){for(var h,p,_=lv(c),E=dv(_),m=cv(d,l),f=uv(E),T=0,S=u||hv,g=t?S(c,f):i||s?S(c,0):void 0;f>T;T++)if((a||T in E)&&(p=m(h=E[T],T,_),e))if(t)g[T]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return T;case 2:pv(g,h)}else switch(e){case 4:return!1;case 7:pv(g,h)}return o?-1:n||r?r:g}},Ev={forEach:_v(0),map:_v(1),filter:_v(2),some:_v(3),every:_v(4),find:_v(5),findIndex:_v(6),filterReject:_v(7)},mv=wi,fv=h,Tv=L,Sv=d,gv=N,Rv=Se,vv=n,Cv=Ze,Iv=l,yv=ii,Av=Z,bv=vt,wv=mn,Ov=B,Nv=Io,Dv=to,Pv=Nr,Lv=HR,kv=jr,Mv=O,Uv=Qt,xv=Zr,Vv=k,Fv=pa,Bv=pc,jv=Ye,Gv=Dr,Wv=nt,Hv=ht,Kv=JR,Yv=iv,qv=av,zv=Pa,Xv=oa,Jv=Ev.forEach,Qv=ur("hidden"),Zv="Symbol",$v="prototype",eC=Xv.set,tC=Xv.getterFor(Zv),iC=Object[$v],nC=fv.Symbol,rC=nC&&nC[$v],oC=fv.TypeError,sC=fv.QObject,aC=Mv.f,cC=Uv.f,dC=Lv.f,lC=Vv.f,uC=Sv([].push),hC=jv("symbols"),pC=jv("op-symbols"),_C=jv("wks"),EC=!sC||!sC[$v]||!sC[$v].findChild,mC=gv&&vv((function(){return 7!=Nv(cC({},"a",{get:function(){return cC(this,"a",{value:7}).a}})).a}))?function(e,t,i){var n=aC(iC,t);n&&delete iC[t],cC(e,t,i),n&&e!==iC&&cC(iC,t,n)}:cC,fC=function(e,t){var i=hC[e]=Nv(rC);return eC(i,{type:Zv,tag:e,description:t}),gv||(i.description=t),i},TC=function(e,t,i){e===iC&&TC(pC,t,i),yv(e);var n=bv(t);return yv(i),Cv(hC,n)?(i.enumerable?(Cv(e,Qv)&&e[Qv][n]&&(e[Qv][n]=!1),i=Nv(i,{enumerable:Ov(0,!1)})):(Cv(e,Qv)||cC(e,Qv,Ov(1,{})),e[Qv][n]=!0),mC(e,n,i)):cC(e,n,i)},SC=function(e,t){yv(e);var i=Av(t),n=Dv(i).concat(CC(i));return Jv(n,(function(t){gv&&!Tv(gC,i,t)||TC(e,t,i[t])})),e},gC=function(e){var t=bv(e),i=Tv(lC,this,t);return!(this===iC&&Cv(hC,t)&&!Cv(pC,t))&&(!(i||!Cv(this,t)||!Cv(hC,t)||Cv(this,Qv)&&this[Qv][t])||i)},RC=function(e,t){var i=Av(e),n=bv(t);if(i!==iC||!Cv(hC,n)||Cv(pC,n)){var r=aC(i,n);return!r||!Cv(hC,n)||Cv(i,Qv)&&i[Qv][n]||(r.enumerable=!0),r}},vC=function(e){var t=dC(Av(e)),i=[];return Jv(t,(function(e){Cv(hC,e)||Cv(Gv,e)||uC(i,e)})),i},CC=function(e){var t=e===iC,i=dC(t?pC:Av(e)),n=[];return Jv(i,(function(e){!Cv(hC,e)||t&&!Cv(iC,e)||uC(n,hC[e])})),n};Rv||(nC=function(){if(Iv(rC,this))throw oC("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?wv(arguments[0]):void 0,t=Wv(e),i=function(e){this===iC&&Tv(i,pC,e),Cv(this,Qv)&&Cv(this[Qv],t)&&(this[Qv][t]=!1),mC(this,t,Ov(1,e))};return gv&&EC&&mC(iC,t,{configurable:!0,set:i}),fC(t,e)},Fv(rC=nC[$v],"toString",(function(){return tC(this).tag})),Fv(nC,"withoutSetter",(function(e){return fC(Wv(e),e)})),Vv.f=gC,Uv.f=TC,xv.f=SC,Mv.f=RC,Pv.f=Lv.f=vC,kv.f=CC,Kv.f=function(e){return fC(Hv(e),e)},gv&&Bv(rC,"description",{configurable:!0,get:function(){return tC(this).description}})),mv({global:!0,constructor:!0,wrap:!0,forced:!Rv,sham:!Rv},{Symbol:nC}),Jv(Dv(_C),(function(e){Yv(e)})),mv({target:Zv,stat:!0,forced:!Rv},{useSetter:function(){EC=!0},useSimple:function(){EC=!1}}),mv({target:"Object",stat:!0,forced:!Rv,sham:!gv},{create:function(e,t){return void 0===t?Nv(e):SC(Nv(e),t)},defineProperty:TC,defineProperties:SC,getOwnPropertyDescriptor:RC}),mv({target:"Object",stat:!0,forced:!Rv},{getOwnPropertyNames:vC}
12271),qv(),zv(nC,Zv),Gv[Qv]=!0;var IC=Se&&!!Symbol.for&&!!Symbol.keyFor,yC=wi,AC=ae,bC=Ze,wC=mn,OC=Ye,NC=IC,DC=OC("string-to-symbol-registry"),PC=OC("symbol-to-string-registry");yC({target:"Symbol",stat:!0,forced:!NC},{for:function(e){var t=wC(e);if(bC(DC,t))return DC[t];var i=AC("Symbol")(t);return DC[t]=i,PC[i]=t,i}});var LC=wi,kC=Ze,MC=ye,UC=be,xC=IC,VC=Ye("symbol-to-string-registry");LC({target:"Symbol",stat:!0,forced:!xC},{keyFor:function(e){if(!MC(e))throw TypeError(UC(e)+" is not a symbol");if(kC(VC,e))return VC[e]}});var FC=Qn,BC=w,jC=R,GC=mn,WC=d([].push),HC=wi,KC=ae,YC=f,qC=L,zC=d,XC=n,JC=w,QC=ye,ZC=Qc,$C=function(e){if(BC(e))return e;if(FC(e)){for(var t=e.length,i=[],n=0;n<t;n++){var r=e[n];"string"==typeof r?WC(i,r):"number"!=typeof r&&"Number"!=jC(r)&&"String"!=jC(r)||WC(i,GC(r))}var o=i.length,s=!0;return function(e,t){if(s)return s=!1,t;if(FC(this))return t;for(var n=0;n<o;n++)if(i[n]===e)return t}}},eI=Se,tI=String,iI=KC("JSON","stringify"),nI=zC(/./.exec),rI=zC("".charAt),oI=zC("".charCodeAt),sI=zC("".replace),aI=zC(1..toString),cI=/[\uD800-\uDFFF]/g,dI=/^[\uD800-\uDBFF]$/,lI=/^[\uDC00-\uDFFF]$/,uI=!eI||XC((function(){var e=KC("Symbol")();return"[null]"!=iI([e])||"{}"!=iI({a:e})||"{}"!=iI(Object(e))})),hI=XC((function(){return'"\\udf06\\ud834"'!==iI("\udf06\ud834")||'"\\udead"'!==iI("\udead")})),pI=function(e,t){var i=ZC(arguments),n=$C(t);if(JC(n)||void 0!==e&&!QC(e))return i[1]=function(e,t){if(JC(n)&&(t=qC(n,this,tI(e),t)),!QC(t))return t},YC(iI,null,i)},_I=function(e,t,i){var n=rI(i,t-1),r=rI(i,t+1);return nI(dI,e)&&!nI(lI,r)||nI(lI,e)&&!nI(dI,n)?"\\u"+aI(oI(e,0),16):e};iI&&HC({target:"JSON",stat:!0,arity:3,forced:uI||hI},{stringify:function(e,t,i){var n=ZC(arguments),r=YC(uI?pI:iI,null,n);return hI&&"string"==typeof r?sI(r,cI,_I):r}});var EI=jr,mI=Xe;wi({target:"Object",stat:!0,forced:!Se||n((function(){EI.f(1)}))},{getOwnPropertySymbols:function(e){var t=EI.f;return t?t(mI(e)):[]}}),iv("asyncIterator"),iv("hasInstance"),iv("isConcatSpreadable"),iv("iterator"),iv("match"),iv("matchAll"),iv("replace"),iv("search"),iv("species"),iv("split");var fI=av;iv("toPrimitive"),fI();var TI=ae,SI=Pa;iv("toStringTag"),SI(TI("Symbol"),"Symbol"),iv("unscopables"),Pa(h.JSON,"JSON",!0);var gI=ie.Symbol,RI=ht,vI=Qt.f,CI=RI("metadata"),II=Function.prototype;void 0===II[CI]&&vI(II,CI,{value:null}),iv("dispose"),iv("metadata");var yI=gI;iv("asyncDispose");var AI=d,bI=ae("Symbol"),wI=bI.keyFor,OI=AI(bI.prototype.valueOf),NI=bI.isRegisteredSymbol||function(e){try{return void 0!==wI(OI(e))}catch(e){return!1}};wi({target:"Symbol",stat:!0},{isRegisteredSymbol:NI});for(var DI=Ye,PI=ae,LI=d,kI=ye,MI=ht,UI=PI("Symbol"),xI=UI.isWellKnownSymbol,VI=PI("Object","getOwnPropertyNames"),FI=LI(UI.prototype.valueOf),BI=DI("wks"),jI=0,GI=VI(UI),WI=GI.length;jI<WI;jI++)try{var HI=GI[jI];kI(UI[HI])&&MI(HI)}catch(e){}var KI=function(e){if(xI&&xI(e))return!0;try{for(var t=FI(e),i=0,n=VI(BI),r=n.length;i<r;i++)if(BI[n[i]]==t)return!0}catch(e){}return!1};wi({target:"Symbol",stat:!0,forced:!0},{isWellKnownSymbol:KI}),iv("matcher"),iv("observable"),wi({target:"Symbol",stat:!0,name:"isRegisteredSymbol"},{isRegistered:NI}),wi({target:"Symbol",stat:!0,name:"isWellKnownSymbol",forced:!0},{isWellKnown:KI}),iv("metadataKey"),iv("patternMatch"),iv("replaceAll");var YI=i(yI),qI=i(JR.f("iterator"));function zI(e){return zI="function"==typeof YI&&"symbol"==typeof qI?function(e){return typeof e}:function(e){return e&&"function"==typeof YI&&e.constructor===YI&&e!==YI.prototype?"symbol":typeof e},zI(e)}var XI=i(JR.f("toPrimitive"));function JI(e){var t=function(e,t){if("object"!==zI(e)||null===e)return e;var i=e[XI];if(void 0!==i){var n=i.call(e,t||"default");if("object"!==zI(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===zI(t)?t:String(t)}function QI(e,t,i){return(t=JI(t))in e?fR(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var ZI=i(M_),$I={isBrowser:!0,classes:{URLSearchParams:void 0!==ZI?ZI:oR,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ey="undefined"!=typeof window&&"undefined"!=typeof document,ty="object"==typeof navigator&&navigator||void 0,iy=ey&&(!ty||["ReactNative","NativeScript","NS"].indexOf(ty.product)<0),ny="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,ry=ey&&window.location.href||"http://localhost";function oy(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function sy(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};
12271t%2?oy(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):oy(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var ay=sy(sy({},Object.freeze({__proto__:null,hasBrowserEnv:ey,hasStandardBrowserEnv:iy,hasStandardBrowserWebWorkerEnv:ny,navigator:ty,origin:ry})),$I);var cy=ii,dy=L,ly=Ze,uy=l,hy=function(){var e=cy(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},py=RegExp.prototype,_y=function(e){var t=e.flags;return void 0!==t||"flags"in py||ly(e,"flags")||!uy(py,e)?t:dy(hy,e)},Ey=Ch.charAt,my=L,fy=ii,Ty=w,Sy=R,gy=/./.exec,Ry=TypeError,vy=wi,Cy=L,Iy=I,yy=Fa,Ay=nc,by=X,wy=Bi,Oy=mn,Ny=ii,Dy=Y,Py=R,Ly=tn,ky=_y,My=ke,Uy=n,xy=Jc,Vy=function(e,t,i){return t+(i?Ey(e,t).length:1)},Fy=function(e,t){var i=e.exec;if(Ty(i)){var n=my(i,e,t);return null!==n&&fy(n),n}if("RegExp"===Sy(e))return my(gy,e,t);throw Ry("RegExp#exec called on incompatible receiver")},By=oa,jy=ht("matchAll"),Gy="RegExp String",Wy=Gy+" Iterator",Hy=By.set,Ky=By.getterFor(Wy),Yy=TypeError,qy=Iy("".indexOf),zy=Iy("".matchAll),Xy=!!zy&&!Uy((function(){zy("a",/./)})),Jy=yy((function(e,t,i,n){Hy(this,{type:Wy,regexp:e,string:t,global:i,unicode:n,done:!1})}),Gy,(function(){var e=Ky(this);if(e.done)return Ay(void 0,!0);var t=e.regexp,i=e.string,n=Fy(t,i);return null===n?(e.done=!0,Ay(void 0,!0)):e.global?(""===Oy(n[0])&&(t.lastIndex=Vy(i,wy(t.lastIndex),e.unicode)),Ay(n,!1)):(e.done=!0,Ay(n,!1))})),Qy=function(e){var t,i,n,r=Ny(this),o=Oy(e),s=xy(r,RegExp),a=Oy(ky(r));return t=new s(s===RegExp?r.source:r,a),i=!!~qy(a,"g"),n=!!~qy(a,"u"),t.lastIndex=wy(r.lastIndex),new Jy(t,o,i,n)};vy({target:"String",proto:!0,forced:Xy},{matchAll:function(e){var t,i,n,r,o=by(this);if(Dy(e)){if(Xy)return zy(o,e)}else{if(Ly(e)&&(t=Oy(by(ky(e))),!~qy(t,"g")))throw Yy("`.matchAll` does not allow non-global regexes");if(Xy)return zy(o,e);if(void 0===(n=My(e,jy))&&"RegExp"==Py(e)&&(n=Qy),n)return Cy(n,e,o)}return i=Oy(o),r=new RegExp(e,"g"),Cy(Qy,r,i)}});
12271var Zy=Ji("String").matchAll,$y=l,eA=Zy,tA=String.prototype,iA=function(e){var t=e.matchAll;return"string"==typeof e||e===tA||$y(tA,e)&&t===tA.matchAll?eA:t},nA=i(iA);function rA(e){function t(e,i,n,r){let o=e[r++];if("__proto__"===o)return!0;const s=Number.isFinite(+o),a=r>=e.length;if(o=!o&&Xg.isArray(n)?n.length:o,a)return Xg.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!s;n[o]&&Xg.isObject(n[o])||(n[o]=[]);return t(e,i,n[o],r)&&Xg.isArray(n[o])&&(n[o]=function(e){const t={},i=Object.keys(e);let n;const r=i.length;let o;for(n=0;n<r;n++)o=i[n],t[o]=e[o];return t}(n[o])),!s}if(Xg.isFormData(e)&&Xg.isFunction(e.entries)){const i={};return Xg.forEachEntry(e,((e,n)=>{t(function(e){return nA(Xg).call(Xg,/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,i,0)})),i}return null}const oA={transitional:lR,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const i=t.getContentType()||"",n=i.indexOf("application/json")>-1,r=Xg.isObject(e);r&&Xg.isHTMLForm(e)&&(e=new FormData(e));if(Xg.isFormData(e))return n?JSON.stringify(rA(e)):e;if(Xg.isArrayBuffer(e)||Xg.isBuffer(e)||Xg.isStream(e)||Xg.isFile(e)||Xg.isBlob(e)||Xg.isReadableStream(e))return e;if(Xg.isArrayBufferView(e))return e.buffer;if(Xg.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(r){if(i.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return nR(e,new ay.classes.URLSearchParams,Object.assign({visitor:function(e,t,i,n){return ay.isNode&&Xg.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((o=Xg.isFileList(e))||i.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return nR(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return r||n?(t.setContentType("application/json",!1),function(e,t,i){if(Xg.isString(e))try{return(t||JSON.parse)(e),OT(Xg).call(Xg,e)}catch(e){if("SyntaxError"!==e.name)throw e}return(i||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||oA.transitional,i=t&&t.forcedJSONParsing,n="json"===this.responseType;if(Xg.isResponse(e)||Xg.isReadableStream(e))return e;if(e&&Xg.isString(e)&&(i&&!this.responseType||n)){const i=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw Jg.from(e,Jg.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ay.classes.FormData,Blob:ay.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Xg.forEach(["delete","get","head","post","put","patch"],(e=>{oA.headers[e]={}}));var sA=oA;const aA=Xg.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const cA=Symbol("internals");function dA(e){var t;return e&&OT(t=String(e)).call(t).toLowerCase()}function lA(e){return!1===e||null==e?e:Xg.isArray(e)?e.map(lA):String(e)}function uA(e,t,i,n,r){return Xg.isFunction(n)?n.call(this,t,i):(r&&(t=i),Xg.isString(t)?Xg.isString(n)?-1!==t.indexOf(n):Xg.isRegExp(n)?n.test(t):void 0:void 0)}class hA{constructor(e){e&&this.set(e)}set(e,t,i){const n=this;function r(e,t,i){const r=dA(t);if(!r)throw new Error("header name must be a non-empty string");const o=Xg.findKey(n,r);(!o||void 0===n[o]||!0===i||void 0===i&&!1!==n[o])&&(n[o||t]=lA(e))}const o=(e,t)=>Xg.forEach(e,((e,i)=>r(e,i,t)));if(Xg.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Xg.isString(e)&&(e=OT(e).call(e))&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(OT(s=e).call(s)))o((e=>{const t={};let i,n,r;return e&&e.split("\n").forEach((function(e){var o,s;r=e.indexOf(":"),i=OT(o=e.substring(0,r)).call(o).toLowerCase(),n=OT(s=e.substring(r+1)).call(s),!i||t[i]&&aA[i]||("set-cookie"===i?t[i]?t[i].push(n):t[i]=[n]:t[i]=t[i]?t[i]+", "+n:n)})),t})(e),t);else if(Xg.isHeaders(e))for(const[t,n]of e.entries())r(n,t,i);else null!=e&&r(t,e,i);var s;return this}get(e,t){if(e=dA(e)){const i=Xg.findKey(this,e);if(i){const e=this[i];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),i=/([^\s,;
12271=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=i.exec(e);)t[n[1]]=n[2];return t}(e);if(Xg.isFunction(t))return t.call(this,e,i);if(Xg.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=dA(e)){const i=Xg.findKey(this,e);return!(!i||void 0===this[i]||t&&!uA(0,this[i],i,t))}return!1}delete(e,t){const i=this;let n=!1;function r(e){if(e=dA(e)){const r=Xg.findKey(i,e);!r||t&&!uA(0,i[r],r,t)||(delete i[r],n=!0)}}return Xg.isArray(e)?e.forEach(r):r(e),n}clear(e){const t=Object.keys(this);let i=t.length,n=!1;for(;i--;){const r=t[i];e&&!uA(0,this[r],r,e,!0)||(delete this[r],n=!0)}return n}normalize(e){const t=this,i={};return Xg.forEach(this,((n,r)=>{var o;const s=Xg.findKey(i,r);if(s)return t[s]=lA(n),void delete t[r];const a=e?function(e){return OT(e).call(e).toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,i)=>t.toUpperCase()+i))}(r):OT(o=String(r)).call(o);a!==r&&delete t[r],t[a]=lA(n),i[a]=!0})),this}concat(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.constructor.concat(this,...t)}toJSON(e){const t=Object.create(null);return Xg.forEach(this,((i,n)=>{null!=i&&!1!==i&&(t[n]=e&&Xg.isArray(i)?i.join(", "):i)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((e=>{let[t,i]=e;return t+": "+i})).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e){const t=new this(e);for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return n.forEach((e=>t.set(e))),t}static accessor(e){const t=(this[cA]=this[cA]={accessors:{}}).accessors,i=this.prototype;function n(e){const n=dA(e);t[n]||(!function(e,t){const i=Xg.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+i,{value:function(e,i,r){return this[n].call(this,t,e,i,r)},configurable:!0})}))}(i,e),t[n]=!0)}return Xg.isArray(e)?e.forEach(n):n(e),this}}hA.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Xg.reduceDescriptors(hA.prototype,((e,t)=>{let{value:i}=e,n=t[0].toUpperCase()+t.slice(1);return{get:()=>i,set(e){this[n]=e}}})),Xg.freezeMethods(hA);var pA=hA;function _A(e,t){const i=this||sA,n=t||i,r=pA.from(n.headers);let o=n.data;return Xg.forEach(e,(function(e){o=e.call(i,o,r.normalize(),t?t.status:void 0)})),r.normalize(),o}function EA(e){return!(!e||!e.__CANCEL__)}function mA(e,t,i){Jg.call(this,null==e?"canceled":e,Jg.ERR_CANCELED,t,i),this.name="CanceledError"}function fA(e,t,i){const n=i.config.validateStatus;i.status&&n&&!n(i.status)?t(new Jg("Request failed with status code "+i.status,[Jg.ERR_BAD_REQUEST,Jg.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i)):e(i)}Xg.inherits(mA,Jg,{__CANCEL__:!0});const TA=function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3,n=0;const r=function(e,t){e=e||10;const i=new Array(e),n=new Array(e);let r,o=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),d=n[s];r||(r=c),i[o]=a,n[o]=c;let l=s,u=0;for(;l!==o;)u+=i[l++],l%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-r<t)return;const h=d&&c-d;return h?Math.round(1e3*u/h):void 0}}(50,250);return function(e,t){let i,n,r=0,o=1e3/t;const s=function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();r=o,i=null,n&&(clearTimeout(n),n=null),e.apply(null,t)};return[function(){const e=Date.now(),t=e-r;for(var a=arguments.length,c=new Array(a),d=0;d<a;d++)c[d]=arguments[d];t>=o?s(c,e):(i=c,n||(n=setTimeout((()=>{n=null,s(i)}),o-t)))},()=>i&&s(i)]}((i=>{const o=i.loaded,s=i.lengthComputable?i.total:void 0,a=o-n,c=r(a);n=o;e({loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&o<=s?(s-o)/c:void 0,event:i,lengthComputable:null!=s,[t?"download":"upload"]:!0})}),i)},SA=(e,t)=>{const i=null!=e;return[n=>t[0]({lengthComputable:i,total:e,loaded:n}),t[1]]},gA=e=>function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];return Xg.asap((()=>e(...i)))};var RA=ay.hasStandardBrowserEnv?((e,t)=>i=>(i=new Tf(i,ay.origin),e.protocol===i.protocol&&e.host===i.host&&(t||e.port===i.port)))(new Tf(ay.origin),ay.navigator&&/(msie|trident)/i.test(ay.navigator.userAgent)):()=>!0,vA=ay.hasStandardBrowserEnv?{write(e,t,i,n,r,o){const s=[e+"="+encodeURIComponent(t)];Xg.isNumber(i)&&s.push("expires="+new Date(i).toGMTString()),Xg.isString(n)&&s.push("path="+n),Xg.isString(r)&&s.push("domain="+r),!0===o&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function CA(e,t){return e&&!function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}function IA(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}const yA=e=>e instanceof pA?function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};
vendor: 4,214 bytes, line 12271
12271t%2?IA(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):IA(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({},e):e;function AA(e,t){t=t||{};const i={};function n(e,t,i,n){return Xg.isPlainObject(e)&&Xg.isPlainObject(t)?Xg.merge.call({caseless:n},e,t):Xg.isPlainObject(t)?Xg.merge({},t):Xg.isArray(t)?t.slice():t}function r(e,t,i,r){return Xg.isUndefined(t)?Xg.isUndefined(e)?void 0:n(void 0,e,0,r):n(e,t,0,r)}function o(e,t){if(!Xg.isUndefined(t))return n(void 0,t)}function s(e,t){return Xg.isUndefined(t)?Xg.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(i,r,o){return o in t?n(i,r):o in e?n(void 0,i):void 0}const c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t,i)=>r(yA(e),yA(t),0,!0)};return Xg.forEach(Object.keys(Object.assign({},e,t)),(function(n){const o=c[n]||r,s=o(e[n],t[n],n);Xg.isUndefined(s)&&o!==a||(i[n]=s)})),i}var bA=e=>{const t=AA({},e);let i,{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:a,auth:c}=t;if(t.headers=a=pA.from(a),t.url=cR(CA(t.baseURL,t.url),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Xg.isFormData(n))if(ay.hasStandardBrowserEnv||ay.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(i=a.getContentType())){const[e,...t]=i?i.split(";").map((e=>OT(e).call(e))).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(ay.hasStandardBrowserEnv&&(r&&Xg.isFunction(r)&&(r=r(t)),r||!1!==r&&RA(t.url))){const e=o&&s&&vA.read(s);e&&a.set(o,e)}return t};var wA="undefined"!=typeof XMLHttpRequest&&function(e){return new Wh((function(t,i){const n=bA(e);let r=n.data;const o=pA.from(n.headers).normalize();let s,a,c,d,l,{responseType:u,onUploadProgress:h,onDownloadProgress:p}=n;function _(){d&&d(),l&&l(),n.cancelToken&&n.cancelToken.unsubscribe(s),n.signal&&n.signal.removeEventListener("abort",s)}let E=new XMLHttpRequest;function m(){if(!E)return;const n=pA.from("getAllResponseHeaders"in E&&E.getAllResponseHeaders());fA((function(e){t(e),_()}),(function(e){i(e),_()}),{data:u&&"text"!==u&&"json"!==u?E.response:E.responseText,status:E.status,statusText:E.statusText,headers:n,config:e,request:E}),E=null}E.open(n.method.toUpperCase(),n.url,!0),E.timeout=n.timeout,"onloadend"in E?E.onloadend=m:E.onreadystatechange=function(){E&&4===E.readyState&&(0!==E.status||E.responseURL&&0===E.responseURL.indexOf("file:"))&&setTimeout(m)},E.onabort=function(){E&&(i(new Jg("Request aborted",Jg.ECONNABORTED,e,E)),E=null)},E.onerror=function(){i(new Jg("Network Error",Jg.ERR_NETWORK,e,E)),E=null},E.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const r=n.transitional||lR;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),i(new Jg(t,r.clarifyTimeoutError?Jg.ETIMEDOUT:Jg.ECONNABORTED,e,E)),E=null},void 0===r&&o.setContentType(null),"setRequestHeader"in E&&Xg.forEach(o.toJSON(),(function(e,t){E.setRequestHeader(t,e)})),Xg.isUndefined(n.withCredentials)||(E.withCredentials=!!n.withCredentials),u&&"json"!==u&&(E.responseType=n.responseType),p&&([c,l]=TA(p,!0),E.addEventListener("progress",c)),h&&E.upload&&([a,d]=TA(h),E.upload.addEventListener("progress",a),E.upload.addEventListener("loadend",d)),(n.cancelToken||n.signal)&&(s=t=>{E&&(i(!t||t.type?new mA(null,e,E):t),E.abort(),E=null)},n.cancelToken&&n.cancelToken.subscribe(s),n.signal&&(n.signal.aborted?s():n.signal.addEventListener("abort",s)));const f=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);f&&-1===ay.protocols.indexOf(f)?i(new Jg("Unsupported protocol "+f+":",Jg.ERR_BAD_REQUEST,e)):E.send(r||null)}))};var OA=(e,t)=>
vendor: 4,552 bytes, line 12271
12271{const{length:i}=e=e?e.filter(Boolean):[];if(t||i){let i,n=new AbortController;const r=function(e){if(!i){i=!0,s();const t=e instanceof Error?e:this.reason;n.abort(t instanceof Jg?t:new mA(t instanceof Error?t.message:t))}};let o=t&&setTimeout((()=>{o=null,r(new Jg("timeout ".concat(t," of ms exceeded"),Jg.ETIMEDOUT))}),t);const s=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(r):e.removeEventListener("abort",r)})),e=null)};e.forEach((e=>e.addEventListener("abort",r)));const{signal:a}=n;return a.unsubscribe=()=>Xg.asap(s),a}},NA=Gh,DA=gl;wi({target:"Promise",stat:!0,forced:!0},{withResolvers:function(){var e=DA.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject}}});var PA=gl,LA=tl;wi({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=PA.f(this),i=LA(e);return(i.error?t.reject:t.resolve)(i.value),t.promise}});var kA=i(NA),MA=JR.f("asyncIterator"),UA=i(MA);function xA(e,t){this.v=e,this.k=t}function VA(e){var t,i;function n(t,i){try{var o=e[t](i),s=o.value,a=s instanceof xA;kA.resolve(a?s.v:s).then((function(i){if(a){var c="return"===t?"return":"next";if(!s.k||i.done)return n(c,i);i=e[c](i).value}r(o.done?"return":"normal",i)}),(function(e){n("throw",e)}))}catch(e){r("throw",e)}}function r(e,r){switch(e){case"return":t.resolve({value:r,done:!0});break;case"throw":t.reject(r);break;default:t.resolve({value:r,done:!1})}(t=t.next)?n(t.key,t.arg):i=null}this._invoke=function(e,r){return new kA((function(o,s){var a={key:e,arg:r,resolve:o,reject:s,next:null};i?i=i.next=a:(t=i=a,n(e,r))}))},"function"!=typeof e.return&&(this.return=void 0)}function FA(e){return function(){return new VA(e.apply(this,arguments))}}function BA(e){return new xA(e,0)}function jA(e){var t={},i=!1;function n(t,n){return i=!0,{done:!1,value:new xA(n=new kA((function(i){i(e[t](n))})),1)}}return t[void 0!==YI&&qI||"@@iterator"]=function(){return this},t.next=function(e){return i?(i=!1,e):n("next",e)},"function"==typeof e.throw&&(t.throw=function(e){if(i)throw i=!1,e;return n("throw",e)}),"function"==typeof e.return&&(t.return=function(e){return i?(i=!1,e):n("return",e)}),t}VA.prototype["function"==typeof YI&&UA||"@@asyncIterator"]=function(){return this},VA.prototype.next=function(e){return this._invoke("next",e)},VA.prototype.throw=function(e){return this._invoke("throw",e)},VA.prototype.return=function(e){return this._invoke("return",e)};var GA=i(MA);function WA(e){var t,i,n,r=2;for("undefined"!=typeof Symbol&&(i=GA,n=Symbol.iterator);r--;){if(i&&null!=(t=e[i]))return t.call(e);if(n&&null!=(t=e[n]))return new HA(t.call(e));i="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function HA(e){function t(e){if(Object(e)!==e)return Wh.reject(new TypeError(e+" is not an object."));var t=e.done;return Wh.resolve(e.value).then((function(e){return{value:e,done:t}}))}return HA=function(e){this.s=e,this.n=e.next},HA.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var i=this.s.return;return void 0===i?Wh.resolve({value:e,done:!0}):t(i.apply(this.s,arguments))},throw:function(e){var i=this.s.return;return void 0===i?Wh.reject(e):t(i.apply(this.s,arguments))}},new HA(e)}const KA=function*(e,t){let i=e.byteLength;if(!t||i<t)return void(yield e);let n,r=0;for(;r<i;)n=r+t,yield e.slice(r,n),r=n},YA=function(){var e=FA((function*(e,t){var i,n=!1,r=!1;try{for(var o,s=WA(qA(e));n=!(o=yield BA(s.next())).done;n=!1){const e=o.value;yield*jA(WA(KA(e,t)))}}catch(e){r=!0,i=e}finally{try{n&&null!=s.return&&(yield BA(s.return()))}finally{if(r)throw i}}}));return function(t,i){return e.apply(this,arguments)}}(),qA=function(){var e=FA((function*(e){if(e[GA])return void(yield*jA(WA(e)));const t=e.getReader();try{for(;;){const{done:e,value:i}=yield BA(t.read());if(e)break;yield i}}finally{yield BA(t.cancel())}}));return function(t){return e.apply(this,arguments)}}(),zA=(e,t,i,n)=>{const r=YA(e,t);let o,s=0,a=e=>{o||(o=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await r.next();if(t)return a(),void e.close();let o=n.byteLength;if(i){let e=s+=o;i(e)}e.enqueue(new Uint8Array(n))}catch(e){throw a(e),e}},cancel:e=>(a(e),r.return())},{highWaterMark:2})};function XA(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function JA(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};
12271t%2?XA(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):XA(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}const QA="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,ZA=QA&&"function"==typeof ReadableStream,$A=QA&&("function"==typeof TextEncoder?(eb=new TextEncoder,e=>eb.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var eb;const tb=function(e){try{for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return!!e(...i)}catch(e){return!1}},ib=ZA&&tb((()=>{let e=!1;const t=new Request(ay.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),nb=ZA&&tb((()=>Xg.isReadableStream(new Response("").body))),rb={stream:nb&&(e=>e.body)};var ob;QA&&(ob=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!rb[e]&&(rb[e]=Xg.isFunction(ob[e])?t=>t[e]():(t,i)=>{throw new Jg("Response type '".concat(e,"' is not supported"),Jg.ERR_NOT_SUPPORT,i)})})));const sb=async(e,t)=>{const i=Xg.toFiniteNumber(e.getContentLength());return null==i?(async e=>{if(null==e)return 0;if(Xg.isBlob(e))return e.size;if(Xg.isSpecCompliantForm(e)){const t=new Request(ay.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Xg.isArrayBufferView(e)||Xg.isArrayBuffer(e)?e.byteLength:(Xg.isURLSearchParams(e)&&(e+=""),Xg.isString(e)?(await $A(e)).byteLength:void 0)})(t):i};var ab=QA&&(async e=>{let{url:t,method:i,data:n,signal:r,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:c,responseType:d,headers:l,withCredentials:u="same-origin",fetchOptions:h}=bA(e);d=d?(d+"").toLowerCase():"text";let p,_=OA([r,o&&o.toAbortSignal()],s);const E=_&&_.unsubscribe&&(()=>{_.unsubscribe()});let m;try{if(c&&ib&&"get"!==i&&"head"!==i&&0!==(m=await sb(l,n))){let e,i=new Request(t,{method:"POST",body:n,duplex:"half"});if(Xg.isFormData(n)&&(e=i.headers.get("content-type"))&&l.setContentType(e),i.body){const[e,t]=SA(m,TA(gA(c)));n=zA(i.body,65536,e,t)}}Xg.isString(u)||(u=u?"include":"omit");const r="credentials"in Request.prototype;p=new Request(t,JA(JA({},h),{},{signal:_,method:i.toUpperCase(),headers:l.normalize().toJSON(),body:n,duplex:"half",credentials:r?u:void 0}));let o=await fetch(p);const s=nb&&("stream"===d||"response"===d);if(nb&&(a||s&&E)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=o[t]}));const t=Xg.toFiniteNumber(o.headers.get("content-length")),[i,n]=a&&SA(t,TA(gA(a),!0))||[];o=new Response(zA(o.body,65536,i,(()=>{n&&n(),E&&E()})),e)}d=d||"text";let f=await rb[Xg.findKey(rb,d)||"text"](o,e);return!s&&E&&E(),await new Wh(((t,i)=>{fA(t,i,{data:f,headers:pA.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:p})}))}catch(t){if(E&&E(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new Jg("Network Error",Jg.ERR_NETWORK,e,p),{cause:t.cause||t});throw Jg.from(t,t&&t.code,e,p)}});const cb={http:null,xhr:wA,fetch:ab};Xg.forEach(cb,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const db=e=>"- ".concat(e),lb=e=>Xg.isFunction(e)||null===e||!1===e;var ub={getAdapter:e=>{e=Xg.isArray(e)?e:[e];const{length:t}=e;let i,n;const r={};for(let o=0;o<t;o++){let t;if(i=e[o],n=i,!lb(i)&&(n=cb[(t=String(i)).toLowerCase()],void 0===n))throw new Jg("Unknown adapter '".concat(t,"'"));if(n)break;r[t||"#"+o]=n}if(!n){const e=Object.entries(r).map((e=>{let[t,i]=e;return"adapter ".concat(t," ")+(!1===i?"is not supported by the environment":"is not available in the build")}));throw new Jg("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(db).join("\n"):" "+db(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n},adapters:cb};function hb(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new mA(null,e)}function pb(e){hb(e),e.headers=pA.from(e.headers),e.data=_A.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return ub.getAdapter(e.adapter||sA.adapter)(e).then((function(t){return hb(e),t.data=_A.call(e,e.transformResponse,t),t.headers=pA.from(t.headers),t}),(function(t){return EA(t)||(hb(e),t&&t.response&&(t.response.data=_A.call(e,e.transformResponse,t.response),t.response.headers=pA.from(t.response.headers))),Wh.reject(t)}))}const _b="1.7.9",Eb={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{Eb[e]=function(i){return typeof i===e||"a"+(t<1?"n ":" ")+e}}));const mb={};Eb.transitional=function(e,t,i){function n(e,t){return"[Axios v"+_b+"] Transitional option '"+e+"'"+t+(i?". "+i:"")}return(i,r,o)=>{if(!1===e)throw new Jg(n(r," has been removed"+(t?" in "+t:"")),Jg.ERR_DEPRECATED);return t&&!mb[r]&&(mb[r]=!0,console.warn(n(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(i,r,o)}},Eb.spelling=function(e){return(t,i)=>(console.warn("".concat(i," is likely a misspelling of ").concat(e)),!0)};var fb={assertOptions:function(e,t,i){if("object"!=typeof e)throw new Jg("options must be an object",Jg.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let r=n.length;for(;r-- >0;){const o=n[r],s=t[o];if(s){const t=e[o],i=void 0===t||s(t,o,e);
vendor: 3,646 bytes, line 12271
12271if(!0!==i)throw new Jg("option "+o+" must be "+i,Jg.ERR_BAD_OPTION_VALUE)}else if(!0!==i)throw new Jg("Unknown option "+o,Jg.ERR_BAD_OPTION)}},validators:Eb};const Tb=fb.validators;let Sb=class{constructor(e){this.defaults=e,this.interceptors={request:new dR,response:new dR}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const i=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?i&&!String(e.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+i):e.stack=i}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=AA(this.defaults,t);const{transitional:i,paramsSerializer:n,headers:r}=t;void 0!==i&&fb.assertOptions(i,{silentJSONParsing:Tb.transitional(Tb.boolean),forcedJSONParsing:Tb.transitional(Tb.boolean),clarifyTimeoutError:Tb.transitional(Tb.boolean)},!1),null!=n&&(Xg.isFunction(n)?t.paramsSerializer={serialize:n}:fb.assertOptions(n,{encode:Tb.function,serialize:Tb.function},!0)),fb.assertOptions(t,{baseUrl:Tb.spelling("baseURL"),withXsrfToken:Tb.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=r&&Xg.merge(r.common,r[t.method]);r&&Xg.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete r[e]})),t.headers=pA.concat(o,r);const s=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const c=[];let d;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let l,u=0;if(!a){const e=[pb.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,c),l=e.length,d=Wh.resolve(t);u<l;)d=d.then(e[u++],e[u++]);return d}l=s.length;let h=t;for(u=0;u<l;){const e=s[u++],t=s[u++];try{h=e(h)}catch(e){t.call(this,e);break}}try{d=pb.call(this,h)}catch(e){return Wh.reject(e)}for(u=0,l=c.length;u<l;)d=d.then(c[u++],c[u++]);return d}getUri(e){return cR(CA((e=AA(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}};Xg.forEach(["delete","get","head","options"],(function(e){Sb.prototype[e]=function(t,i){return this.request(AA(i||{},{method:e,url:t,data:(i||{}).data}))}})),Xg.forEach(["post","put","patch"],(function(e){function t(t){return function(i,n,r){return this.request(AA(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:i,data:n}))}}Sb.prototype[e]=t(),Sb.prototype[e+"Form"]=t(!0)}));var gb=Sb;class Rb{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Wh((function(e){t=e}));const i=this;this.promise.then((e=>{if(!i._listeners)return;let t=i._listeners.length;for(;t-- >0;)i._listeners[t](e);i._listeners=null})),this.promise.then=e=>{let t;const n=new Wh((e=>{i.subscribe(e),t=e})).then(e);return n.cancel=function(){i.unsubscribe(t)},n},e((function(e,n,r){i.reason||(i.reason=new mA(e,n,r),t(i.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;const t=new Rb((function(t){e=t}));return{token:t,cancel:e}}}var vb=Rb;const Cb={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,Parti
vendor: 69,864 bytes, line 12271
12271alContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Cb).forEach((e=>{let[t,i]=e;Cb[i]=t}));var Ib=Cb;const yb=function e(t){const i=new gb(t),n=og(gb.prototype.request,i);return Xg.extend(n,gb.prototype,i,{allOwnKeys:!0}),Xg.extend(n,i,null,{allOwnKeys:!0}),n.create=function(i){return e(AA(t,i))},n}(sA);yb.Axios=gb,yb.CanceledError=mA,yb.CancelToken=vb,yb.isCancel=EA,yb.VERSION=_b,yb.toFormData=nR,yb.AxiosError=Jg,yb.Cancel=yb.CanceledError,yb.all=function(e){return Wh.all(e)},yb.spread=function(e){return function(t){return e.apply(null,t)}},yb.isAxiosError=function(e){return Xg.isObject(e)&&!0===e.isAxiosError},yb.mergeConfig=AA,yb.AxiosHeaders=pA,yb.formToJSON=e=>rA(Xg.isHTMLForm(e)?new FormData(e):e),yb.getAdapter=ub.getAdapter,yb.HttpStatusCode=Ib,yb.default=yb;var Ab=yb;const bb=()=>{};function wb(){const e={promise:void 0,isResolved:!1,isRejected:!1,isFinished:!1,resolve:void 0,reject:void 0,cancel:bb};return e.promise=new Wh(((t,i)=>{e.resolve=i=>{e.isFinished||(e.isResolved=!0,e.isFinished=!0,t(i),e.value=i)},e.reject=t=>{e.isFinished||(e.isRejected=!0,e.isFinished=!0,i(t))}})),e}const Ob=new Map,Nb=new Map,Db=new Map;let Pb=function(e){return e.WIN_10="Windows 10",e.WIN_81="Windows 8.1",e.WIN_8="Windows 8",e.WIN_7="Windows 7",e.WIN_VISTA="Windows Vista",e.WIN_SERVER_2003="Windows Server 2003",e.WIN_XP="Windows XP",e.WIN_2000="Windows 2000",e.ANDROID="Android",e.HARMONY_OS="HarmonyOS",e.OPEN_BSD="Open BSD",e.SUN_OS="Sun OS",e.LINUX="Linux",e.IOS="iOS",e.MAC_OS="Mac OS",e.CHROMIUM_OS="Chromium OS",e.QNX="QNX",e.UNIX="UNIX",e.BEOS="BeOS",e.OS_2="OS/2",e.SEARCH_BOT="Search Bot",e}({}),Lb=function(e){return e.CHROME="Chrome",e.SAFARI="Safari",e.EDGE="Edge",e.FIREFOX="Firefox",e.OPERA="OPR",e.QQ="QQBrowser",e.WECHAT="MicroMessenger",e}({});const kb=new AS;let Mb=kb.getResult(),Ub=null;function xb(e){if(!Ub){e&&kb.setUA(e),Mb=kb.getResult();const t=function(e){if("Blink"===e.engine.name&&"WeChat"!==e.browser.name)return Lb.CHROME;switch(e.browser.name){case"Chrome Headless":case"Chrome":case"Chromium":return Lb.CHROME;case"Safari":case"Mobile Safari":return Lb.SAFARI;case"Edge":return Lb.EDGE;case"Firefox":return Lb.FIREFOX;case"QQ":case"QQBrowser":return Lb.QQ;case"Opera":return Lb.OPERA;case"WeChat":return Lb.WECHAT;default:return e.browser.name||""}}(Mb),i=Vb(Mb),n=function(e){return"Windows"===e.os.name?e.os.version?e.os.name+" "+e.os.version:e.os.name:e.os.name||""}(Mb),r=Mb.os.version,o=Vb(Mb,!1),s=Mb.device.type;if(!(t&&i&&n&&r))return{name:t,version:i,os:n,osVersion:r,browserVersion:o,deviceType:s};Ub={name:t,version:i,os:n,osVersion:r,browserVersion:o,deviceType:s}}return Ub}function Vb(e){let t,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t="Blink"===e.engine.name?e.engine.version||"":e.browser.version||"",i?t.split(".")[0]:t}function Fb(){return xb().os}function Bb(){const e=xb();return"".concat(e.os," ").concat(e.osVersion)}function jb(){const e=xb();return!!("WebKit"===Mb.engine.name&&e.os===Pb.MAC_OS&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0&&e.name!==Lb.SAFARI||Yb()&&e.name!==Lb.SAFARI)}function Gb(){return xb().name===Lb.CHROME}function Wb(){return xb().name===Lb.SAFARI}function Hb(){return xb().name===Lb.EDGE}function Kb(){return xb().name===Lb.FIREFOX}function Yb(){return xb().os===Pb.IOS}function qb(e){const t=xb();return!(t.name!==Lb.CHROME||!t.osVersion)&&Number(t.version)>=e}function zb(e){const t=xb();return!(t.name!==Lb.CHROME||!t.osVersion)&&Number(t.version)<e}function Xb(e,t,i){const n=xb();return!(n.name!==e||!n.osVersion)&&(i?Number(n.version)>=t&&Number(n.version)<=i:Number(n.version)===t)}function Jb(e){const t=xb();return!(t.name!==Lb.EDGE||!t.osVersion)&&Number(t.version)>=e}function Qb(e){const t=xb();return!(t.name!==Lb.SAFARI||!t.osVersion)&&Number(t.version)>=e}function Zb(e,t,i){const n=xb();if(n.os!==Pb.IOS||!n.osVersion)return!1;const r=n.osVersion.split(".");return i?t&&Number(r[0])===e&&Number(r[1])<t||Number(r[0])<e:t?Number(r[0])===e&&Number(r[1])<=t||Number(r[0])<e:Number(r[0])<=e}function $b(e,t,i){const n=xb();if(n.name!==Lb.SAFARI||!n.osVersion||!n.browserVersion)return!1;const r=n.browserVersion.split(".");return i?t&&Number(r[0])===e&&Number(r[1])<t||Number(r[0])<e:t?Number(r[0])===e&&Number(r[1])<=t||Number(r[0])<e:Number(r[0])<=e}function ew(e){const t=xb();return!(t.name!==Lb.OPERA||!t.osVersion)&&Number(t.version)>=e}function tw(){const e=xb();if(e.os!==Pb.IOS||!e.osVersion)return!1;const t=e.osVersion.split(".");return Number(t[0])<14||14===Number(t[0])&&Number(t[1])<=6}function iw(){const e=xb();if(e.os!==Pb.IOS||!e.osVersion)return!1;const t=e.osVersion.split(".");return 15===Number(t[0])}function nw(){const e=xb();if(e.os!==Pb.IOS||!e.osVersion)return!1;const t=e.osVersion.split(".");return 16===Number(t[0])}function rw(){const e=xb();if(e.os!==Pb.IOS||!e.osVersion)return!1;const t=e.osVersion.split(".");return 15===Number(t[0])&&Number(t[1])>=1}function ow(){return Wb()&&navigator.maxTouchPoints>0}function sw(){return xb().name===Lb.WECHAT}function aw(){return window.navigator.appVersion&&null!==window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)&&window.navigator.appVersion.match(/Chrome\/([\w\W]*?)\./)[1]<=35}function cw(){const e=Fb();return function(){const{deviceType:e}=xb();return"mobile"===e||"tablet"===e}()||e===Pb.ANDROID||e===Pb.IOS||e===Pb.HARMONY_OS}function dw(){const e=xb();return e.name!==Lb.EDGE&&e.name!==Lb.SAFARI&&!!navigator.userAgent.toLocaleLowerCase().match(/chrome\/[\d]./i)}function lw(){return Fb()===Pb.ANDROID}function uw(){const e=xb();return lw()&&(e.name===Lb.CHROME||e.name===Lb.WECHAT||/chrome|chromium/i.test(navigator.userAgent))}function hw(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function pw(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?hw(Object(i),!0).forEach((function(t){_w(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):hw(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function _w(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}let Ew=function(e){return e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.UNEXPECTED_RESPONSE="UNEXPECTED_RESPONSE",e.TIMEOUT="TIMEOUT",e.INVALID_PARAMS="INVALID_PARAMS",e.NOT_READABLE="NOT_READABLE",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INVALID_OPERATION="INVALID_OPERATION",e.OPERATION_ABORTED="OPERATION_ABORTED",e.WEB_SECURITY_RESTRICT="WEB_SECURITY_RESTRICT",e.EXCHANGE_SDP_FAILED="EXCHANGE_SDP_FAILED",e.ADD_CANDIDATE_FAILED="ADD_CANDIDATE_FAILED",e.DATACHANNEL_FAILED="DATACHANNEL_FAILED",e.NETWORK_ERROR="NETWORK_ERROR",e.NETWORK_TIMEOUT="NETWORK_TIMEOUT",e.NETWORK_RESPONSE_ERROR="NETWORK_RESPONSE_ERROR",e.API_INVOKE_TIMEOUT="API_INVOKE_TIMEOUT",e.ENUMERATE_DEVICES_FAILED="ENUMERATE_DEVICES_FAILED",e.DEVICE_NOT_FOUND="DEVICE_NOT_FOUND",e.ELECTRON_IS_NULL="ELECTRON_IS_NULL",e.ELECTRON_DESKTOP_CAPTURER_GET_SOURCES_ERROR="ELECTRON_DESKTOP_CAPTURER_GET_SOURCES_ERROR",e.CHROME_PLUGIN_NO_RESPONSE="CHROME_PLUGIN_NO_RESPONSE",e.CHROME_PLUGIN_NOT_INSTALL="CHROME_PLUGIN_NOT_INSTALL",e.MEDIA_OPTION_INVALID="MEDIA_OPTION_INVALID",e.PERMISSION_DENIED="PERMISSION_DENIED",e.CONSTRAINT_NOT_SATISFIED="CONSTRAINT_NOT_SATISFIED",e.TRACK_IS_DISABLED="TRACK_IS_DISABLED",e.GET_VIDEO_ELEMENT_VISIBLE_ERROR="GET_VIDEO_ELEMENT_VISIBLE_ERROR",e.SHARE_AUDIO_NOT_ALLOWED="SHARE_AUDIO_NOT_ALLOWED",e.LOW_STREAM_ENCODING_ERROR="LOW_STREAM_ENCODING_ERROR",e.SET_ENCODING_PARAMETER_ERROR="SET_ENCODING_PARAMETER_ERROR",e.TRACK_STATE_UNREACHABLE="TRACK_STATE_UNREACHABLE",e.INVALID_UINT_UID_FROM_STRING_UID="INVALID_UINT_UID_FROM_STRING_UID",e.CAN_NOT_GET_PROXY_SERVER="CAN_NOT_GET_PROXY_SERVER",e.CAN_NOT_GET_GATEWAY_SERVER="CAN_NOT_GET_GATEWAY_SERVER",e.VOID_GATEWAY_ADDRESS="VOID_GATEWAY_ADDRESS",e.UID_CONFLICT="UID_CONFLICT",e.MULTI_UNILBS_RESPONSE_ERROR="MULTI_UNILBS_RESPONSE_ERROR",e.UPDATE_TICKET_FAILED="UPDATE_TICKET_FAILED",e.TOKEN_EXPIRE="TOKEN_EXPIRE",e.INVALID_LOCAL_TRACK="INVALID_LOCAL_TRACK",e.INVALID_TRACK="INVALID_TRACK",e.SENDER_NOT_FOUND="SENDER_NOT_FOUND",e.CREATE_OFFER_FAILED="CREATE_OFFER_FAILED",e.SET_ANSWER_FAILED="SET_ANSWER_FAILED",e.ICE_FAILED="ICE_FAILED",e.PC_CLOSED="PC_CLOSED",e.SENDER_REPLACE_FAILED="SENDER_REPLACE_FAILED",e.GET_LOCAL_CAPABILITIES_FAILED="GET_LOCAL_CAPABILITIES_FAILED",e.GET_LOCAL_CONNECTION_PARAMS_FAILED="GET_LOCAL_CONNECTION_PARAMS_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.GATEWAY_P2P_LOST="GATEWAY_P2P_LOST",e.NO_ICE_CANDIDATE="NO_ICE_CANDIDATE",e.CAN_NOT_PUBLISH_MULTIPLE_VIDEO_TRACKS="CAN_NOT_PUBLISH_MULTIPLE_VIDEO_TRACKS",e.EXIST_DISABLED_VIDEO_TRACK="EXIST_DISABLED_VIDEO_TRACK",e.INVALID_REMOTE_USER="INVALID_REMOTE_USER",e.REMOTE_USER_IS_NOT_PUBLISHED="REMOTE_USER_IS_NOT_PUBLISHED",e.CUSTOM_REPORT_SEND_FAILED="CUSTOM_REPORT_SEND_FAILED",e.CUSTOM_REPORT_FREQUENCY_TOO_HIGH="CUSTOM_REPORT_FREQUENCY_TOO_HIGH",e.FETCH_AUDIO_FILE_FAILED="FETCH_AUDIO_FILE_FAILED",e.READ_LOCAL_AUDIO_FILE_ERROR="READ_LOCAL_AUDIO_FILE_ERROR",e.DECODE_AUDIO_FILE_FAILED="DECODE_AUDIO_FILE_FAILED",e.WS_ABORT="WS_ABORT",e.WS_DISCONNECT="WS_DISCONNECT",e.WS_ERR="WS_ERR",e.EXTERNAL_SIGNAL_ABORT="EXTERNAL_SIGNAL_ABORT",e.LIVE_STREAMING_TASK_CONFLICT="LIVE_STREAMING_TASK_CONFLICT",e.LIVE_STREAMING_INVALID_ARGUMENT="LIVE_STREAMING_INVALID_ARGUMENT",e.LIVE_STREAMING_INTERNAL_SERVER_ERROR="LIVE_STREAMING_INTERNAL_SERVER_ERROR",e.LIVE_STREAMING_PUBLISH_STREAM_NOT_AUTHORIZED="LIVE_STREAMING_PUBLISH_STREAM_NOT_AUTHORIZED",e.LIVE_STREAMING_TRANSCODING_NOT_SUPPORTED="LIVE_STREAMING_TRANSCODING_NOT_SUPPORTED",e.LIVE_STREAMING_CDN_ERROR="LIVE_STREAMING_CDN_ERROR",e.LIVE_STREAMING_INVALID_RAW_STREAM="LIVE_STREAMING_INVALID_RAW_STREAM",e.LIVE_STREAMING_WARN_STREAM_NUM_REACH_LIMIT="LIVE_STREAMING_WARN_STREAM_NUM_REACH_LIMIT",e.LIVE_STREAMING_WARN_FAILED_LOAD_IMAGE="LIVE_STREAMING_WARN_FAILED_LOAD_IMAGE",e.LIVE_STREAMING_WARN_FREQUENT_REQUEST="LIVE_STREAMING_WARN_FREQUENT_REQUEST",e.WEBGL_INTERNAL_ERROR="WEBGL_INTERNAL_ERROR",e.BEAUTY_PROCESSOR_INTERNAL_ERROR="BEAUTY_PROCESSOR_INTERNAL_ERROR",e.CROSS_CHANNEL_WAIT_STATUS_ERROR="CROSS_CHANNEL_WAIT_STATUS_ERROR",e.CROSS_CHANNEL_FAILED_JOIN_SRC="CROSS_CHANNEL_FAILED_JOIN_SEC",e.CROSS_CHANNEL_FAILED_JOIN_DEST="CROSS_CHANNEL_FAILED_JOIN_DEST",e.CROSS_CHANNEL_FAILED_PACKET_SENT_TO_DEST="CROSS_CHANNEL_FAILED_PACKET_SENT_TO_DEST",e.CROSS_CHANNEL_SERVER_ERROR_RESPONSE="CROSS_CHANNEL_SERVER_ERROR_RESPONSE",e.METADATA_OUT_OF_RANGE="METADATA_OUT_OF_RANGE",e.LOCAL_AEC_ERROR="LOCAL_AEC_ERROR",e.INVALID_PLUGIN="INVALID_PLUGIN",e.DISCONNECT_P2P="DISCONNECT_P2P",e.CONVERTING_IMAGEDATA_TO_BLOB_FAILED="CONVERTING_IMAGEDATA_TO_BLOB_FAILED",e.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED="CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED",e.INIT_DATACHANNEL_TIMEOUT="INIT_DATACHANNEL_TIMEOUT",e.CREATE_DATACHANNEL_ERROR="CREATE_DATACHANNEL_ERROR",e.DATACHANNEL_CONNECTION_TIMEOUT="DATACHANNEL_CONNECTION_TIMEOUT",e.PROHIBITED_OPERATION="PROHIBITED_OPERATION",e.IMAGE_MODERATION_UPLOAD_FAILED="IMAGE_MODERATION_UPLOAD_FAILED",e.P2P_MESSAGE_FAILED="P2P_MESSAGE_FAILED",e}({}),mw=class extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2?arguments[2]:void 0;super(t),_w(this,"code",void 0),_w(this,"message",void 0),_w(this,"data",void 0),_w(this,"name","AgoraRTCException"),this.code=e,this.message="AgoraRTCError ".concat(this.code,": ").concat(t),this.data=i}toString(){return this.data?"".concat(this.message,"\ndata: ").concat(JSON.stringify(this.data)):this.message}print(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"error",t=arguments.length>1?arguments[1]:void 0;return"error"===e&&(t||console).error(this.toString()),"warning"===e&&(t||console).warn(this.toString()),this}throw(e){throw this.print("error",e),this}};function fw(e,t){if("boolean"!=typeof e)throw new mw(Ew.INVALID_PARAMS,"Invalid ".concat(t,": The value is of the boolean type."))}function Tw(e,t,i){if(!Dn(i).call(i,e))throw new mw(Ew.INVALID_PARAMS,"".concat(t," can only be set as ").concat(JSON.stringify(i)))}function Sw(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e4;if(e<i||e>n||(!(arguments.length>4&&void 0!==arguments[4])||arguments[4])&&!function(e){return"number"==typeof e&&e%1==0}(e))throw new mw(Ew.INVALID_PARAMS,"invalid ".concat(t,": the value range is [").concat(i,", ").concat(n,"]. integer only"))}function gw(e,t){if("number"!=typeof e){if(!(e.min||e.max||e.ideal||e.exact))throw new mw(Ew.INVALID_PARAMS,"".concat(t," is not a valid ConstrainLong"));void 0!==e.min&&Sw(e.min,"".concat(t,".min"),0,1/0),void 0!==e.max&&Sw(e.max,"".concat(t,".max"),1,1/0),void 0!==e.exact&&Sw(e.exact,"".concat(t,".exact"),1,1/0),void 0!==e.ideal&&Sw(e.ideal,"".concat(t,".ideal"),1,1/0)}else Sw(e,t,1,1/0)}function Rw(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:255,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];if(null==e)throw new mw(Ew.INVALID_PARAMS,"".concat(t||"param"," cannot be empty"));if(!Iw(e,i,n,r))throw new mw(Ew.INVALID_PARAMS,"Invalid ".concat(t||"string param",": Length of the string: [").concat(i,",").concat(n,"].").concat(r?" ASCII characters only.":""))}function vw(e,t){if(!Array.isArray(e))throw new mw(Ew.INVALID_PARAMS,"".concat(t," should be an array"))}function Cw(e){return null==e}function Iw(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:255,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];return"string"==typeof e&&e.length<=i&&e.length>=t&&(!n||function(e){if("string"!=typeof e)return!1;for(let t=0;t<e.length;t+=1){const i=e.charCodeAt(t);if(i<0||i>255)return!1}return!0}(e))}var yw=function(e){return e.COVERED="COVERED",e.POSITION="POSITION",e.SIZE="SIZE",e.STYLE="STYLE",e}(yw||{}),Aw=function(e){return e.UNMOUNTED="UNMOUNTED",e.INVALID_HTML_ELEMENT="INVALID_HTML_ELEMENT",e}(Aw||{});const bw=new class{constructor(){_w(this,"_clientSize",null),_w(this,"getClientWidth",(()=>document.documentElement?document.documentElement.clientWidth:document.body.clientWidth)),_w(this,"getClientHeight",(()=>document.documentElement?document.documentElement.clientHeight:document.body.clientHeight)),_w(this,"getStyle",(e=>window.getComputedStyle(e,null))),_w(this,"checkCssVisibleProperty",(e=>{var t;let i=!0;const n=this.getStyle(e),{display:r,visibility:o,opacity:s,filter:a}=n;return("none"===r||Dn(t=["hidden","collapse"]).call(t,o)||Number(s)<.1)&&(i=!1),!!i&&(a&&a.split(" ").filter((e=>{var t;const i=e.split("(")[0];return Dn(t=["brightness","blur","opacity"]).call(t,i)})).map((e=>{const[t,i]=e.split(/\(|\)/);return[t,Number(i.match(/^[0-9\.]+/))]})).forEach((e=>{const[t,n]=e;switch(t){case"brightness":(n<.1||n>3)&&(i=!1);break;case"blur":n>3&&(i=!1);break;case"opacity":n<.1&&(i=!1)}})),i)})),_w(this,"checkPropertyUpToAllParentNodes",((e,t)=>{let i=!0,n=!0;const r=e=>t(e);let o=e;for(;o&&n;)r(o)||(i=!1,n=!1),o=o.parentElement,o||(n=!1);return i})),_w(this,"checkActualCssVisibleIncludeInherit",(e=>this.checkPropertyUpToAllParentNodes(e,this.checkCssVisibleProperty))),_w(this,"getSizeAboutClient",(e=>{const{width:t,height:i,left:n,right:r,top:o,bottom:s}=e.getBoundingClientRect(),a=this.getClientWidth(),c=this.getClientHeight();return{width:t,height:i,left:n,right:r,top:o,bottom:s,clientWidth:a,clientHeight:c,clientMin:Math.min(a,c)}})),_w(this,"checkActualSize",(()=>{const{width:e,height:t,clientMin:i}=this._clientSize;return this.checkSizeIsVisible(e,t,i)})),_w(this,"elementFromPoint",((e,t)=>document.elementFromPoint?document.elementFromPoint(e,t):null)),_w(this,"checkCoverForAPoint",((e,t,i)=>{const n=this.elementFromPoint(e,t);return null!==n&&n!==i})),_w(this,"getPointPositionList",(()=>{const{width:e,height:t,left:i,top:n}=this._clientSize,r=e/6,o=t/6,s=[],a=10**6;for(let e=0;e<5;e++)for(let t=0;t<5;t++){const c=(i*a+(0===e?.1:4===e?(r*e*a-1e5)/a:r*e)*a)/a,d=(n*a+(0===t?.1:4===t?(o*t*a-1e5)/a:o*t)*a)/a;s.push({x:c,y:d})}return[...s]})),_w(this,"checkElementCover",(e=>this.getPointPositionList().map((t=>this.checkCoverForAPoint(t.x,t.y,e))).filter((e=>!!e)).length>6)),_w(this,"checkSizeIsVisible",((e,t,i)=>(e>50||i/e<=10)&&(t>50||i/t<=10))),_w(this,"checkSizeOfPartInClient",(()=>{const{left:e,right:t,top:i,bottom:n,clientHeight:r,clientWidth:o,clientMin:s}=this._clientSize;let a,c,d,l;if(e<0)a=0;else{if(!(e<o))return!1;a=e}if(t<0)return!1;if(c=t<o?t:o,i<0)d=0;else{if(!(i<r))return!1;d=i}if(n<0)return!1;l=n<r?n:r;const u=c-a,h=l-d;return this.checkSizeIsVisible(u,h,s)})),_w(this,"returnHiddenResult",(e=>(this._clientSize=null,{visible:!1,reason:e}))),_w(this,"checkOneElementVisible",(e=>{if(e instanceof HTMLElement){if(this.checkElementIsMountedOnDom(e)){if(this.checkActualCssVisibleIncludeInherit(e)){if(this._clientSize=this.getSizeAboutClient(e),this.checkElementCover(e))return this.returnHiddenResult(yw.COVERED);{const e=this.checkActualSize(),t=this.checkSizeOfPartInClient();return e&&!t?this.returnHiddenResult(yw.POSITION):e?(this._clientSize=null,{visible:!0}):this.returnHiddenResult(yw.SIZE)}}return this.returnHiddenResult(yw.STYLE)}return this.returnHiddenResult(Aw.UNMOUNTED)}return this.returnHiddenResult(Aw.INVALID_HTML_ELEMENT)})),_w(this,"checkElementIsMountedOnDom",(e=>this.checkPropertyUpToAllParentNodes(e,(e=>"HTML"!==e.nodeName.toUpperCase()?null!==e.parentElement:!!document.documentElement))))}};function ww(e){return(new TextEncoder).encode(e)}const Ow=function(e,t){const i=new Uint8Array(e.byteLength+t.byteLength);return i.set(new Uint8Array(e),0),i.set(new Uint8Array(t),e.byteLength),i};const Nw=async e=>function(e,t){let i="";return new Uint8Array(e).forEach((e=>{i+=e.toString(t).padStart(2,"0")})),i}(await crypto.subtle.digest("SHA-256",ww(e)),16);let Dw=class{constructor(){_w(this,"_events",{}),_w(this,"addListener",this.on)}getListeners(e){return this._events[e]?this._events[e].map((e=>e.listener)):[]}on(e,t){this._events[e]||(this._events[e]=[]);const i=this._events[e];-1===this._indexOfListener(i,t)&&i.push({listener:t,once:!1})}once(e,t){this._events[e]||(this._events[e]=[]);const i=this._events[e];-1===this._indexOfListener(i,t)&&i.push({listener:t,once:!0})}off(e,t){if(!this._events[e])return;const i=this._events[e],n=this._indexOfListener(i,t);-1!==n&&i.splice(n,1),0===this._events[e].length&&delete this._events[e]}removeAllListeners(e){e?delete this._events[e]:this._events={}}emit(e){this._events[e]||(this._events[e]=[]);const t=this._events[e].map((e=>e));for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];for(let i=0;i<t.length;i+=1){const r=t[i];r.once&&this.off(e,r.listener),r.listener.apply(this,n||[])}}safeEmit(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];[...this._events[e]||[]].forEach((t=>{t.once&&this.off(e,t.listener);try{t.listener.apply(this,i)}catch(t){console.error("safeEmit event:".concat(e," error ").concat(null==t?void 0:t.toString()))}}))}_indexOfListener(e,t){let i=e.length;for(;i--;)if(e[i].listener===t)return i;return-1}};let Pw=null;function Lw(){if(Pw)return Pw;if(window.electron)return Pw=window.electron;if(!window.require)return null;try{return Pw=window.require("electron"),Pw}catch(e){return null}}let kw=function(e){return e.CREATE_CLIENT="createClient",e.CHECK_SYSTEM_REQUIREMENTS="checkSystemRequirements",e.SET_AREA="setArea",e.PRELOAD="PRELOAD",e.CHECK_VIDEO_TRACK_IS_ACTIVE="checkVideoTrackIsActive",e.CHECK_AUDIO_TRACK_IS_ACTIVE="checkAudioTrackIsActive",e.CREATE_MIC_AUDIO_TRACK="createMicrophoneAudioTrack",e.CREATE_CUSTOM_AUDIO_TRACK="createCustomAudioTrack",e.CREATE_BUFFER_AUDIO_TRACK="createBufferSourceAudioTrack",e.CREATE_CAM_VIDEO_TRACK="createCameraVideoTrack",e.CREATE_CUSTOM_VIDEO_TRACK="createCustomVideoTrack",e.CREATE_MIC_AND_CAM_TRACKS="createMicrophoneAndCameraTracks",e.CREATE_SCREEN_VIDEO_TRACK="createScreenVideoTrack",e.SET_ENCRYPTION_CONFIG="Client.setEncryptionConfig",e.START_PROXY_SERVER="Client.startProxyServer",e.STOP_PROXY_SERVER="Client.stopProxyServer",e.SET_PROXY_SERVER="Client.setProxyServer",e.SET_TURN_SERVER="Client.setTurnServer",e.SET_CLIENT_ROLE="Client.setClientRole",e.SET_LOW_STREAM_PARAMETER="Client.setLowStreamParameter",e.ENABLE_DUAL_STREAM="Client.enableDualStream",e.DISABLE_DUAL_STREAM="Client.disableDualStream",e.JOIN="Client.join",e.LEAVE="Client.leave",e.PUBLISH="Client.publish",e.UNPUBLISH="Client.unpublish",e.SUBSCRIBE="Client.subscribe",e.MASS_SUBSCRIBE="Client.massSubscribe",e.MASS_UNSUBSCRIBE="Client.massUnsubscribe",e.UNSUBSCRIBE="Client.unsubscribe",e.RENEW_TOKEN="Client.renewToken",e.SET_REMOTE_VIDEO_STREAM_TYPE="Client.setRemoteVideoStreamType",e.SET_STREAM_FALLBACK_OPTION="Client.setStreamFallbackOption",e.ENABLE_AUDIO_VOLUME_INDICATOR="Client.enableAudioVolumeIndicator",e.SEND_CUSTOM_REPORT_MESSAGE="Client.sendCustomReportMessage",e.INSPECT_VIDEO_CONTENT="Client.inspectVideoContent",e.STOP_INSPECT_VIDEO_CONTENT="Client.stopInspectVideoContent",e.JOIN_FALLBACK_TO_PROXY="Client._joinFallbackToProxy",e.ON_LIVE_STREAM_WARNING="Client.onLiveStreamWarning",e.ON_LIVE_STREAM_ERROR="Client.onLiveStreamingError",e.START_LIVE_STREAMING="Client.startLiveStreaming",e.SET_LIVE_TRANSCODING="Client.setLiveTranscoding",e.STOP_LIVE_STREAMING="Client.stopLiveStreaming",e.START_CHANNEL_MEDIA_RELAY="Client.startChannelMediaRelay",e.UPDATE_CHANNEL_MEDIA_RELAY="Client.updateChannelMediaRelay",e.STOP_CHANNEL_MEDIA_RELAY="Client.stopChannelMediaRelay",e.REQUEST_CONFIG_DISTRIBUTE="_config-distribute-request",e.SET_CONFIG_DISTRIBUTE="_configDistribute",e.LOCAL_TRACK_SET_MUTED="LocalTrack.setMute",e.LOCAL_AUDIO_TRACK_PLAY="LocalAudioTrack.play",e.LOCAL_AUDIO_TRACK_PLAY_IN_ELEMENT="LocalAudioTrack.playInElement",e.LOCAL_AUDIO_TRACK_STOP="LocalAudioTrack.stop",e.LOCAL_AUDIO_TRACK_SET_VOLUME="LocalAudioTrack.setVolume",e.MIC_AUDIO_TRACK_SET_DEVICE="MicrophoneAudioTrack.setDevice",e.BUFFER_AUDIO_TRACK_START="BufferSourceAudioTrack.startProcessAudioBuffer",e.BUFFER_AUDIO_TRACK_STOP="BufferSourceAudioTrack.stopProcessAudioBuffer",e.BUFFER_AUDIO_TRACK_PAUSE="BufferSourceAudioTrack.pauseProcessAudioBuffer",e.BUFFER_AUDIO_TRACK_RESUME="BufferSourceAudioTrack.resumeProcessAudioBuffer",e.BUFFER_AUDIO_TRACK_SEEK="BufferSourceAudioTrack.seekAudioBuffer",e.LOCAL_VIDEO_TRACK_PLAY="LocalVideoTrack.play",e.LOCAL_VIDEO_TRACK_STOP="LocalVideoTrack.stop",e.LOCAL_VIDEO_TRACK_GET_VIDEO_VISIBLE="LocalVideoTrack.getVideoElementVisibleStatus",e.LOCAL_VIDEO_TRACK_BEAUTY="LocalVideoTrack.setBeautyEffect",e.LOCAL_VIDEO_SEND_SEI_DATA="LocalVideoTrack.sendSeiData",e.CAM_VIDEO_TRACK_SET_DEVICE="CameraVideoTrack.setDevice",e.CAM_VIDEO_TRACK_SET_ENCODER_CONFIG="CameraVideoTrack.setEncoderConfiguration",e.REMOTE_VIDEO_TRACK_PLAY="RemoteVideoTrack.play",e.REMOTE_VIDEO_TRACK_STOP="RemoteVideoTrack.stop",e.REMOTE_VIDEO_TRACK_GET_VIDEO_VISIBLE="RemoteVideoTrack.getVideoElementVisibleStatus",e.REMOTE_AUDIO_TRACK_PLAY="RemoteAudioTrack.play",e.REMOTE_AUDIO_TRACK_STOP="RemoteAudioTrack.stop",e.REMOTE_AUDIO_SET_VOLUME="RemoteAudioTrack.setVolume",e.REMOTE_AUDIO_SET_OUTPUT_DEVICE="RemoteAudioTrack.setOutputDevice",e.GET_MEDIA_STREAM_TRACK="Track.getMediaStreamTrack",e.STREAM_TYPE_CHANGE="streamTypeChange",e.CONNECTION_STATE_CHANGE="connectionStateChange",e.LOAD_CONFIG_FROM_LOCALSTORAGE="loadConfigFromLocalStorage",e.IMAGE_MODERATION_UPLOAD="imageModerationUpload",e.REPUB_AFTER_PC_CONNECTED="repubAfterPCConnected",e}({}),Mw=function(e){return e.TRACER="tracer",e}({});function Uw(e){return Sw(e.timeout,"config.timeout",0,1e5),Sw(e.timeoutFactor,"config.timeoutFactor",0,100,!1),Sw(e.maxRetryCount,"config.maxRetryConfig",0,1/0),Sw(e.maxRetryTimeout,"config.maxRetryTimeout",0,1/0),!0}let xw=function(e){return e[e.AUDIENCE_LEVEL_LOW_LATENCY=1]="AUDIENCE_LEVEL_LOW_LATENCY",e[e.AUDIENCE_LEVEL_ULTRA_LOW_LATENCY=2]="AUDIENCE_LEVEL_ULTRA_LOW_LATENCY",e[e.AUDIENCE_LEVEL_SYNC_LATENCY=3]="AUDIENCE_LEVEL_SYNC_LATENCY",e}({}),Vw=function(e){return e.LEAVE="LEAVE",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.UID_BANNED="UID_BANNED",e.FALLBACK="FALLBACK",e.IP_BANNED="IP_BANNED",e.CHANNEL_BANNED="CHANNEL_BANNED",e.LICENSE_MISSING="LICENSE_MISSING",e.LICENSE_EXPIRED="LICENSE_EXPIRED",e.LICENSE_MINUTES_EXCEEDED="LICENSE_MINUTES_EXCEEDED",e.LICENSE_PERIOD_INVALID="LICENSE_PERIOD_INVALID",e.LICENSE_MULTIPLE_SDK_SERVICE="LICENSE_MULTIPLE_SDK_SERVICE",e.LICENSE_ILLEGAL="LICENSE_ILLEGAL",e.TOKEN_EXPIRE="TOKEN_EXPIRE",e}({});function Fw(e){if(!Array.isArray(e)||e.length<1)return!1;try{e.forEach((e=>{if(!e.urls)throw Error()}))}catch(e){return!1}return!0}function Bw(e){return Rw(e.turnServerURL,"turnServerURL"),Rw(e.username,"username"),Rw(e.password,"password"),e.udpport&&Sw(e.udpport,"udpport",1,99999,!0),e.forceturn&&fw(e.forceturn,"forceturn"),e.security&&fw(e.security,"security"),e.tcpport&&Sw(e.tcpport,"tcpport",1,99999,!0),!0}function jw(e){return void 0!==e.level&&Tw(e.level,"level",[1,2,3]),void 0!==e.delay&&Sw(e.delay,"delay",0,3e3,!0),!0}let Gw=function(e){return e.PEERCONNECTION_STATE_CHANGE="peerconnection-state-change",e.AUDIO_METADATA="audio-metadata",e.CONNECTION_STATE_CHANGE="connection-state-change",e.MEDIA_RECONNECT_START="media-reconnect-start",e.MEDIA_RECONNECT_END="media-reconnect-end",e.IS_USING_CLOUD_PROXY="is-using-cloud-proxy",e.USER_JOINED="user-joined",e.USER_LEAVED="user-left",e.USER_PUBLISHED="user-published",e.USER_UNPUBLISHED="user-unpublished",e.USER_INFO_UPDATED="user-info-updated",e.CLIENT_BANNED="client-banned",e.CHANNEL_MEDIA_RELAY_STATE="channel-media-relay-state",e.CHANNEL_MEDIA_RELAY_EVENT="channel-media-relay-event",e.VOLUME_INDICATOR="volume-indicator",e.CRYPT_ERROR="crypt-error",e.ON_TOKEN_PRIVILEGE_WILL_EXPIRE="token-privilege-will-expire",e.ON_TOKEN_PRIVILEGE_DID_EXPIRE="token-privilege-did-expire",e.NETWORK_QUALITY="network-quality",e.STREAM_TYPE_CHANGED="stream-type-changed",e.STREAM_FALLBACK="stream-fallback",e.RECEIVE_METADATA="receive-metadata",e.STREAM_MESSAGE="stream-message",e.LIVE_STREAMING_ERROR="live-streaming-error",e.LIVE_STREAMING_WARNING="live-streaming-warning",e.EXCEPTION="exception",e.ERROR="error",e.P2P_LOST="p2p_lost",e.JOIN_FALLBACK_TO_PROXY="join-fallback-to-proxy",e.CHANNEL_FALLBACK_TO_WEBSOCKET="channel-fallback-to-websocket",e.MEDIA_CONNECTION_TYPE_CHANGE="media-connection-type-change",e.PUBLISHED_USER_LIST="published-user-list",e.CONTENT_INSPECT_CONNECTION_STATE_CHANGE="content-inspect-connection-state-change",e.CONTENT_INSPECT_ERROR="content-inspect-error",e.CONTENT_INSPECT_RESULT="content-inspect-result",e.IMAGE_MODERATION_CONNECTION_STATE_CHANGE="image-moderation-connection-state-change",e}({}),Ww=function(e){return e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.MULTI_IP="MULTI_IP",e.TIMEOUT="TIMEOUT",e.OFFLINE="OFFLINE",e.LEAVE="LEAVE",e.P2P_FAILED="P2P_FAILED",e.FALLBACK="FALLBACK",e.REGIONAL_DISTRIBUTION="REGIONAL_DISTRIBUTION",e}({}),Hw=function(e){return e.ONLINE="ONLINE",e.OFFLINE="OFFLINE",e}({}),Kw=function(e){return e.NETWORK_STATE_CHANGE="NETWORK_STATE_CHANGE",e.ONLINE="ONLINE",e.OFFLINE="OFFLINE",e}({});function Yw(e,t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return 0===e.getListeners(t).length?Wh.reject(new mw(Ew.UNEXPECTED_ERROR,"can not emit promise")):new Wh(((i,r)=>{e.emit(t,...n,i,r)}))}function qw(e,t){if(0===e.getListeners(t).length)return Wh.resolve();for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return Yw(e,t,...n)}function zw(e,t){if(0===e.getListeners(t).length)return null;for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return Xw(e,t,...n)}function Xw(e,t){let i=null,n=null;for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];if(e.emit(t,...o,(e=>{i=e}),(e=>{n=e})),null!==n)throw n;if(null===i)throw new mw(Ew.UNEXPECTED_ERROR,"handler is not sync");return i}const Jw=new class extends Dw{set networkState(e){this.emit(Kw.NETWORK_STATE_CHANGE,e,this._networkState),e===Hw.ONLINE?this.emit(Kw.ONLINE):e===Hw.OFFLINE&&(this.onlineWaiter=new Wh((e=>{this.once(Kw.ONLINE,(()=>{this.onlineWaiter=void 0,e(Hw.ONLINE)}))})),this.emit(Kw.OFFLINE)),this._networkState=e}get networkState(){return this._networkState}get isOnline(){return this._networkState===Hw.ONLINE}constructor(){super(),_w(this,"_moduleName","network-indicator"),_w(this,"_networkState",Hw.ONLINE),_w(this,"onlineWaiter",void 0),window.addEventListener("online",(()=>{this.networkState=Hw.ONLINE})),window.addEventListener("offline",(()=>{this.networkState=Hw.OFFLINE}))}};function Qw(e,t){const i=e.indexOf(t);-1!==i&&e.splice(i,1)}function Zw(e){const t=[];return e.forEach((e=>{-1===t.indexOf(e)&&t.push(e)})),t}function $w(e){void 0!==Wh?Wh.resolve().then(e):setTimeout(e,0)}function eO(e){return JSON.parse(JSON.stringify(e))}function tO(e){try{return eO(e)}catch(t){return e}}const iO={};function nO(e,t){iO[t]||(iO[t]=!0,e())}function rO(e){const t=window.atob(e),i=new Uint8Array(new ArrayBuffer(t.length));for(let e=0;e<t.length;e+=1)i[e]=t.charCodeAt(e);return i}function oO(e){let t="";for(let i=0;i<e.length;i+=1)t+=String.fromCharCode(e[i]);return window.btoa(t)}function sO(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,i=(new TextEncoder).encode(e);if(i.length>t)i=i.slice(0,t);else if(i.length<t){const e=new Uint8Array(t);e.set(i),i=e}return i}function aO(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const n=Xn(t).call(t,((e,t)=>e+t.length),0),r=new Uint8Array(new ArrayBuffer(n));let o=0;return t.forEach((e=>{r.set(e,o),o+=e.length})),r}function cO(e){return window.TextEncoder?(new TextEncoder).encode(e).length:e.length}function dO(e){let t=0;return(/DingTalk/i.test(navigator.userAgent)||/AliApp/i.test(navigator.userAgent))&&e.realFormData&&(e=e.realFormData),e.forEach((e=>{t+="string"==typeof e?cO(e):e.size})),t+138}function lO(e){const t=new mw(Ew.TIMEOUT,"timeout");return new Wh(((i,n)=>{window.setTimeout((()=>n(t)),e)}))}function uO(e){return new Wh((t=>{window.setTimeout(t,e)}))}function hO(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:7,t=arguments.length>1?arguments[1]:void 0;const i=Math.random().toString(16).substr(2,e).toLowerCase();return i.length===e?"".concat(t).concat(i):"".concat(t).concat(i)+hO(e-i.length,"")}function pO(){return hO(32,"").toUpperCase()}const _O=()=>{},EO=new class{constructor(){_w(this,"fnMap",new Map)}throttleByKey(e,t,i,n){for(var r=arguments.length,o=new Array(r>4?r-4:0),s=4;s<r;s++)o[s-4]=arguments[s];if(this.fnMap.has(t)){const r=this.fnMap.get(t);if(r.threshold!==i){r.fn(...r.args),clearTimeout(r.timer);const s=window.setTimeout((()=>{const e=this.fnMap.get(t);e&&e.fn(...e.args),this.fnMap.delete(t)}),i);this.fnMap.set(t,{fn:e,threshold:i,timer:s,args:o,skipFn:n})}else r.skipFn&&r.skipFn(...r.args),this.fnMap.set(t,pw(pw({},r),{},{fn:e,args:o,skipFn:n}))}else{const r=window.setTimeout((()=>{const e=this.fnMap.get(t);e&&e.fn(...e.args),this.fnMap.delete(t)}),i);this.fnMap.set(t,{fn:e,threshold:i,timer:r,args:o,skipFn:n})}}},mO=EO.throttleByKey.bind(EO);function fO(e){return"object"==typeof e&&null!==e&&!(e instanceof RegExp)}function TO(e,t){if(!fO(e)||!fO(t))return t;if(Array.isArray(e)&&!Array.isArray(t)||!Array.isArray(e)&&Array.isArray(t))return t;if(Array.isArray(t)&&Array.isArray(e)){const i=[...e];for(let n=0;n<t.length;n++)i[n]=TO(e[n],t[n]);return i}{const i=pw({},e);for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(Object.prototype.hasOwnProperty.call(e,n)?i[n]=TO(e[n],t[n]):i[n]=t[n]);return i}}function SO(e,t){let i=[0];if(t&&(i=new Array(t).fill(0)),0===e)return i;let n=0;for(;e>0&&(i[n]=255&e,e>>=8,n++,!t||n!==t););return i}function gO(e){return"number"==typeof e?e:e.exact||e.ideal||e.max||e.min||0}function RO(e){const t="0123456789abcdef";function i(e){let i,n="";for(i=0;i<=3;i++)n+=t.charAt(e>>8*i+4&15)+t.charAt(e>>8*i&15);return n}function n(e,t){const i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i}function r(e,t,i,r,o,s){return n(function(e,t){return e<<t|e>>>32-t}(n(n(t,e),n(r,s)),o),i)}function o(e,t,i,n,o,s,a){return r(t&i|~t&n,e,t,o,s,a)}function s(e,t,i,n,o,s,a){return r(t&n|i&~n,e,t,o,s,a)}function a(e,t,i,n,o,s,a){return r(t^i^n,e,t,o,s,a)}function c(e,t,i,n,o,s,a){return r(i^(t|~n),e,t,o,s,a)}const d=function(e){let t;const i=1+(e.length+8>>6),n=new Array(16*i);for(t=0;t<16*i;t++)n[t]=0;for(t=0;t<e.length;t++)n[t>>2]|=e.charCodeAt(t)<<t%4*8;return n[t>>2]|=128<<t%4*8,n[16*i-2]=8*e.length,n}(e);let l,u,h,p,_,E=1732584193,m=-271733879,f=-1732584194,T=271733878;for(l=0;l<d.length;l+=16)u=E,h=m,p=f,_=T,E=o(E,m,f,T,d[l+0],7,-680876936),T=o(T,E,m,f,d[l+1],12,-389564586),f=o(f,T,E,m,d[l+2],17,606105819),m=o(m,f,T,E,d[l+3],22,-1044525330),E=o(E,m,f,T,d[l+4],7,-176418897),T=o(T,E,m,f,d[l+5],12,1200080426),f=o(f,T,E,m,d[l+6],17,-1473231341),m=o(m,f,T,E,d[l+7],22,-45705983),E=o(E,m,f,T,d[l+8],7,1770035416),T=o(T,E,m,f,d[l+9],12,-1958414417),f=o(f,T,E,m,d[l+10],17,-42063),m=o(m,f,T,E,d[l+11],22,-1990404162),E=o(E,m,f,T,d[l+12],7,1804603682),T=o(T,E,m,f,d[l+13],12,-40341101),f=o(f,T,E,m,d[l+14],17,-1502002290),m=o(m,f,T,E,d[l+15],22,1236535329),E=s(E,m,f,T,d[l+1],5,-165796510),T=s(T,E,m,f,d[l+6],9,-1069501632),f=s(f,T,E,m,d[l+11],14,643717713),m=s(m,f,T,E,d[l+0],20,-373897302),E=s(E,m,f,T,d[l+5],5,-701558691),T=s(T,E,m,f,d[l+10],9,38016083),f=s(f,T,E,m,d[l+15],14,-660478335),m=s(m,f,T,E,d[l+4],20,-405537848),E=s(E,m,f,T,d[l+9],5,568446438),T=s(T,E,m,f,d[l+14],9,-1019803690),f=s(f,T,E,m,d[l+3],14,-187363961),m=s(m,f,T,E,d[l+8],20,1163531501),E=s(E,m,f,T,d[l+13],5,-1444681467),T=s(T,E,m,f,d[l+2],9,-51403784),f=s(f,T,E,m,d[l+7],14,1735328473),m=s(m,f,T,E,d[l+12],20,-1926607734),E=a(E,m,f,T,d[l+5],4,-378558),T=a(T,E,m,f,d[l+8],11,-2022574463),f=a(f,T,E,m,d[l+11],16,1839030562),m=a(m,f,T,E,d[l+14],23,-35309556),E=a(E,m,f,T,d[l+1],4,-1530992060),T=a(T,E,m,f,d[l+4],11,1272893353),f=a(f,T,E,m,d[l+7],16,-155497632),m=a(m,f,T,E,d[l+10],23,-1094730640),E=a(E,m,f,T,d[l+13],4,681279174),T=a(T,E,m,f,d[l+0],11,-358537222),f=a(f,T,E,m,d[l+3],16,-722521979),m=a(m,f,T,E,d[l+6],23,76029189),E=a(E,m,f,T,d[l+9],4,-640364487),T=a(T,E,m,f,d[l+12],11,-421815835),f=a(f,T,E,m,d[l+15],16,530742520),m=a(m,f,T,E,d[l+2],23,-995338651),E=c(E,m,f,T,d[l+0],6,-198630844),T=c(T,E,m,f,d[l+7],10,1126891415),f=c(f,T,E,m,d[l+14],15,-1416354905),m=c(m,f,T,E,d[l+5],21,-57434055),E=c(E,m,f,T,d[l+12],6,1700485571),T=c(T,E,m,f,d[l+3],10,-1894986606),f=c(f,T,E,m,d[l+10],15,-1051523),m=c(m,f,T,E,d[l+1],21,-2054922799),E=c(E,m,f,T,d[l+8],6,1873313359),T=c(T,E,m,f,d[l+15],10,-30611744),f=c(f,T,E,m,d[l+6],15,-1560198380),m=c(m,f,T,E,d[l+13],21,1309151649),E=c(E,m,f,T,d[l+4],6,-145523070),T=c(T,E,m,f,d[l+11],10,-1120210379),f=c(f,T,E,m,d[l+2],15,718787259),m=c(m,f,T,E,d[l+9],21,-343485551),E=n(E,u),m=n(m,h),f=n(f,p),T=n(T,_);return i(E)+i(m)+i(f)+i(T)}let vO=1,CO=console,IO=class{static setLogger(e){CO=e}constructor(e,t){_w(this,"id",void 0),_w(this,"lockingPromise",Wh.resolve()),_w(this,"locks",0),_w(this,"name",""),_w(this,"lockId",void 0),this.lockId=vO++,e&&(this.name=e),t&&(this.id=t),this.logger("created")}logger(e,t){const i=(this.id?"[".concat(this.id,"]"):"")+"[lock-".concat(this.name,"-").concat(this.lockId,"]"),n="created"===e?"is ".concat(e,"."):"is ".concat(e,", current queue ").concat(this.locks,". ").concat(null!=t?t:"");CO.debug("".concat(i," ").concat(n))}setId(e){this.id=e}get isLocked(){return this.locks>0}lock(e){let t;this.locks+=1,this.logger("locked",e);const i=new Wh((i=>{t=()=>{this.locks-=1,this.logger("unlocked",e),i()}})),n=this.lockingPromise.then((()=>t));return this.lockingPromise=this.lockingPromise.then((()=>i)),n}};function yO(e,t){return function(i,n,r){const o=r.value;if("function"!=typeof o)throw new Error("Cannot use mutex on object property.");return r.value=async function(){const i=this[t];if(!i)throw new Error("mutex property key ".concat(t," doesn't exist on ").concat(e));const r=await i.lock("From ".concat(e,".").concat(n));try{for(var s=arguments.length,a=new Array(s),c=0;c<s;c++)a[c]=arguments[c];return await o.apply(this,a)}finally{r()}},r}}const AO={timeout:500,timeoutFactor:1.5,maxRetryCount:1/0,maxRetryTimeout:1e4};function bO(e,t){const i=Math.floor(t.timeout*Math.pow(t.timeoutFactor,e));return Math.min(t.maxRetryTimeout,i)}function wO(e,t,i,n){const r=Object.assign({},AO,n);let o=r.timeout;const s=async()=>{await function(e){return new Wh((t=>{window.setTimeout(t,e)}))}(o),o*=r.timeoutFactor,o=Math.min(r.maxRetryTimeout,o)};let a=!1;const c=new Wh((async(n,o)=>{t=t||(()=>!1),i=i||(()=>!0);for(let c=0;c<r.maxRetryCount;c+=1){if(a)return o(new mw(Ew.OPERATION_ABORTED));try{const i=await e();if(!t(i,c))return n(i);if(c+1===r.maxRetryCount)return n(i);await s()}catch(e){if(!i(e,c))return o(e);if(c+1===r.maxRetryCount)return o(e);await s()}}}));return c.cancel=()=>a=!0,c}let OO,NO=class{constructor(e){_w(this,"input",[]),_w(this,"size",void 0),this.size=e}add(e){this.input.push(e),this.input.length>this.size&&this.input.splice(0,1)}mean(){var e;return 0===this.input.length?0:Xn(e=this.input).call(e,((e,t)=>e+t))/this.input.length}},DO=0,PO=0;function LO(e,t,i,n){return new Wh(((r,o)=>{t.responseType=t.responseType||"json",t.data&&!i?(t.data=JSON.stringify(t.data),DO+=cO(t.data)):i&&(t.data.size?DO+=t.data.size:t.data instanceof FormData?DO+=dO(t.data):DO+=cO(JSON.stringify(t.data))),t.headers=t.headers||{},t.headers["Content-Type"]=t.headers["Content-Type"]||"application/json",t.method="POST",t.url=e,Ab.request(t).then((e=>{"string"==typeof e.data?PO+=cO(e.data):e.data instanceof ArrayBuffer||e.data instanceof Uint8Array?PO+=e.data.byteLength:PO+=cO(JSON.stringify(e.data)),n&&r({data:e.data,headers:e.headers}),r(e.data)})).catch((e=>{Ab.isCancel(e)?o(new mw(Ew.OPERATION_ABORTED,"cancel token canceled")):"ECONNABORTED"===e.code?o(new mw(Ew.NETWORK_TIMEOUT,e.message)):e.response?o(new mw(Ew.NETWORK_RESPONSE_ERROR,e.response.status)):o(new mw(Ew.NETWORK_ERROR,e.message))}))}))}async function kO(e,t){const i=new Blob([t.data],{type:"buffer"});return await LO(e,pw(pw({},t),{},{data:i,headers:{"Content-Type":"application/octet-stream"}}),!0)}const MO=()=>void 0!==window.isSecureContext;function UO(e){if(Array.isArray(e))return e.map((e=>e));if(!xO(e))return e;const t={};for(const i in e){const n=e[i];xO(n)||Array.isArray(n)?t[i]=UO(n):t[i]=n}return t}function xO(e){return!("object"!=typeof e||Array.isArray(e)||!e)}let VO=class{constructor(e){_w(this,"input",[]),_w(this,"size",void 0),this.size=e}add(e){this.input.push(e),this.input.length>this.size&&this.input.splice(0,1)}diffMean(){return 0===this.input.length?0:(this.input[this.input.length-1]-this.input[0])/this.input.length}};const FO={address:"unknown",candidateType:"unknown",id:"unknown",port:0,priority:0,protocol:"unknown",type:"unknown"},BO={timestamp:0,bitrate:{actualEncoded:0,transmit:0},sendPacketLossRate:0,recvPacketLossRate:0,videoRecv:[],videoSend:[],audioRecv:[],audioSend:[],selectedCandidatePair:{id:"unknown",localCandidate:FO,remoteCandidate:FO},updateInterval:0},jO={firsCount:0,nacksCount:0,plisCount:0,framesDecodeCount:0,framesDecodeInterval:0,framesDecodeFreezeTime:0,decodeFrameRate:0,bytes:0,packetsLost:0,packetLostRate:0,packets:0,ssrc:0,qpSumPerFrame:0,framesDroppedCount:0,outputFrameRate:0,packetsDiscarded:0,framesAssembledFromMultiplePackets:0,totalProcessingDelay:0,avgDecodeMs:0,avgFramesAssembledFromMultiplePacketsMs:0,avgProcessingDelayMs:0,avgInterFrameDelayMs:0,totalAssemblyTime:0},GO={firsCount:0,nacksCount:0,plisCount:0,frameCount:0,bytes:0,packets:0,packetsLost:0,packetLostRate:0,ssrc:0,rttMs:0,jitterMs:0,qpSumPerFrame:0},WO={bytes:0,packets:0,packetsLost:0,packetLostRate:0,ssrc:0,rttMs:0,jitterMs:0},HO={jitterBufferMs:0,jitterMs:0,bytes:0,packetsLost:0,packetLostRate:0,packetsDiscarded:0,packets:0,ssrc:0,receivedFrames:0,droppedFrames:0,concealedSamples:0,totalSamplesReceived:0};let KO=class{constructor(e,t){_w(this,"onFirstVideoReceived",void 0),_w(this,"onFirstVideoDecoded",void 0),_w(this,"onFirstAudioReceived",void 0),_w(this,"onFirstVideoDecodedTimeout",void 0),_w(this,"onFirstAudioDecoded",void 0),_w(this,"onSelectedLocalCandidateChanged",void 0),_w(this,"onSelectedRemoteCandidateChanged",void 0),_w(this,"videoIsReady",!1),_w(this,"videoIsReady2",{}),_w(this,"pc",void 0),_w(this,"options",void 0),_w(this,"intervalTimer",void 0),_w(this,"stats",UO(BO)),_w(this,"isFirstVideoReceived",{}),_w(this,"isFirstVideoDecoded",{}),_w(this,"isFirstAudioReceived",{}),_w(this,"isFirstAudioDecoded",{}),_w(this,"isFirstVideoDecodedTimeout",{}),_w(this,"lossRateWindowStats",[]),this.pc=e,this.options=t,this.intervalTimer=window.setInterval((async()=>{this.updateStats()}),this.options.updateInterval)}getStats(){return this.stats}getSelectedCandidatePair(){return new Wh((e=>{e({local:pw({},FO),remote:pw({},FO)})}))}setVideoIsReady(e){this.videoIsReady=e}setVideoIsReady2(e,t){this.videoIsReady2[e]=t}getVideoIsReady(e){return this.videoIsReady2[e]||!1}setIsFirstAudioDecoded(e){}destroy(){window.clearInterval(this.intervalTimer),this.pc=void 0}calcLossRate(e){this.lossRateWindowStats.push(e),this.lossRateWindowStats.length>this.options.lossRateInterval&&this.lossRateWindowStats.splice(0,1);const t=this.lossRateWindowStats.length,i=["videoSend","audioSend","videoRecv","audioRecv"];let n=0,r=0,o=0,s=0;for(const a of i)e[a].forEach(((e,i)=>{if(!this.lossRateWindowStats[t-1][a][i]||!this.lossRateWindowStats[0][a][i])return;const c=this.lossRateWindowStats[t-1][a][i].packets-this.lossRateWindowStats[0][a][i].packets,d=this.lossRateWindowStats[t-1][a][i].packetsLost-this.lossRateWindowStats[0][a][i].packetsLost;"videoSend"===a||"audioSend"===a?(n+=c,o+=d):(r+=c,s+=d),Number.isNaN(c)||Number.isNaN(c)?e.packetLostRate=0:e.packetLostRate=c<=0||d<=0?0:d/(c+d)}));e.sendPacketLossRate=n<=0||o<=0?0:o/(n+o),e.recvPacketLossRate=r<=0||s<=0?0:s/(r+s)}},YO=class extends KO{constructor(){super(...arguments),_w(this,"_stats",BO),_w(this,"lastDecodeVideoReceiverStats",new Map)}async updateStats(){const e=await this._getStats(),t=this.statsResponsesToObjects(e);this._stats=UO(BO);const i=t.filter((e=>"ssrc"===e.type));this.processSSRCStats(i);const n=t.find((e=>"VideoBwe"===e.type));n&&this.processBandwidthStats(n),this._stats.timestamp=Date.now(),this.calcLossRate(this._stats),this.stats=this._stats}processBandwidthStats(e){this._stats.bitrate={actualEncoded:Number(e.googActualEncBitrate),targetEncoded:Number(e.googTargetEncBitrate),retransmit:Number(e.googRetransmitBitrate),transmit:Number(e.googTransmitBitrate)},this._stats.sendBandwidth=Number(e.googAvailableSendBandwidth)}processSSRCStats(e){e.forEach((e=>{var t;const i=Dn(t=e.id).call(t,"send");switch("".concat(e.mediaType,"_").concat(i?"send":"recv")){case"video_send":{const t=UO(GO);t.codec=e.googCodecName,t.adaptionChangeReason="none",e.googCpuLimitedResolution&&(t.adaptionChangeReason="cpu"),e.googBandwidthLimitedResolution&&(t.adaptionChangeReason="bandwidth"),t.avgEncodeMs=Number(e.googAvgEncodeMs),t.inputFrame={width:Number(e.googFrameWidthInput)||Number(e.googFrameWidthSent),height:Number(e.googFrameHeightInput)||Number(e.googFrameHeightSent),frameRate:Number(e.googFrameRateInput)},t.sentFrame={width:Number(e.googFrameWidthSent),height:Number(e.googFrameHeightSent),frameRate:Number(e.googFrameRateInput)},t.firsCount=Number(e.googFirReceived),t.nacksCount=Number(e.googNacksReceived),t.plisCount=Number(e.googPlisReceived),t.frameCount=Number(e.framesEncoded),t.bytes=Number(e.bytesSent),t.packets=Number(e.packetsSent),t.packetsLost=Number(e.packetsLost),t.ssrc=Number(e.ssrc),t.rttMs=Number(e.googRtt||0),this._stats.videoSend.push(t),this._stats.rtt=t.rttMs;break}case"video_recv":{const t=UO(jO),i=this.lastDecodeVideoReceiverStats.get(Number(e.ssrc));if(t.codec=e.googCodecName,t.targetDelayMs=Number(e.googTargetDelayMs),t.renderDelayMs=Number(e.googRenderDelayMs),t.currentDelayMs=Number(e.googCurrentDelayMs),t.minPlayoutDelayMs=Number(e.googMinPlayoutDelayMs),t.decodeMs=Number(e.googDecodeMs),t.maxDecodeMs=Number(e.googMaxDecodeMs),t.receivedFrame={width:Number(e.googFrameWidthReceived),height:Number(e.googFrameHeightReceived),frameRate:Number(e.googFrameRateReceived)},t.decodedFrame={width:Number(e.googFrameWidthReceived),height:Number(e.googFrameHeightReceived),frameRate:Number(e.googFrameRateDecoded)},t.decodeFrameRate=Number(e.googFrameRateDecoded),t.outputFrame={width:Number(e.googFrameWidthReceived),height:Number(e.googFrameHeightReceived),frameRate:Number(e.googFrameRateOutput)},t.jitterBufferMs=Number(e.googJitterBufferMs),t.firsCount=Number(e.googFirsSent),t.nacksCount=Number(e.googNacksSent),t.plisCount=Number(e.googPlisSent),t.framesDecodeCount=Number(e.framesDecoded),t.bytes=Number(e.bytesReceived),t.packets=Number(e.packetsReceived),t.packetsLost=Number(e.packetsLost),t.ssrc=Number(e.ssrc),t.packets>0&&!this.isFirstVideoReceived[t.ssrc]&&(this.onFirstVideoReceived&&this.onFirstVideoReceived(t.ssrc),this.isFirstVideoReceived[t.ssrc]=!0),t.framesDecodeCount>0&&!this.isFirstVideoDecoded[t.ssrc]&&(this.onFirstVideoDecoded&&this.onFirstVideoDecoded(t.ssrc,t.decodedFrame.width,t.decodedFrame.height),this.isFirstVideoDecoded[t.ssrc]=!0),i){const n=i.stats,r=Date.now()-i.lts;t.framesDecodeFreezeTime=n.framesDecodeFreezeTime,t.framesDecodeInterval=n.framesDecodeInterval,t.framesDecodeCount>n.framesDecodeCount&&this.isFirstVideoDecoded[t.ssrc]?(i.lts=Date.now(),t.framesDecodeInterval=r,t.framesDecodeInterval>=this.options.freezeRateLimit&&(this.getVideoIsReady(parseInt(e.ssrc,10))?t.framesDecodeFreezeTime+=t.framesDecodeInterval:this.setVideoIsReady2(parseInt(e.ssrc,10),!0))):t.framesDecodeCount<i.stats.framesDecodeCount&&(t.framesDecodeInterval=0)}this.lastDecodeVideoReceiverStats.set(t.ssrc,{stats:pw({},t),lts:Date.now()}),this._stats.videoRecv.push(t);break}case"audio_recv":{const t=UO(HO);t.codec=e.googCodecName,t.outputLevel=Math.abs(Number(e.audioOutputLevel))/32767,t.decodingCNG=Number(e.googDecodingCNG),t.decodingCTN=Number(e.googDecodingCTN),t.decodingCTSG=Number(e.googDecodingCTSG),t.decodingNormal=Number(e.googDecodingNormal),t.decodingPLC=Number(e.googDecodingPLC),t.decodingPLCCNG=Number(e.googDecodingPLCCNG),t.expandRate=Number(e.googExpandRate),t.accelerateRate=Number(e.googAccelerateRate),t.preemptiveExpandRate=Number(e.googPreemptiveExpandRate),t.secondaryDecodedRate=Number(e.googSecondaryDecodedRate),t.speechExpandRate=Number(e.googSpeechExpandRate),t.preferredJitterBufferMs=Number(e.googPreferredJitterBufferMs),t.jitterBufferMs=Number(e.googJitterBufferMs),t.jitterMs=Number(e.googJitterReceived),t.bytes=Number(e.bytesReceived),t.packets=Number(e.packetsReceived),t.packetsLost=Number(e.packetsLost),t.ssrc=Number(e.ssrc),t.receivedFrames=Number(e.googDecodingCTN)||Number(e.packetsReceived),t.droppedFrames=Number(e.googDecodingPLC)+Number(e.googDecodingPLCCNG)||Number(e.packetsLost),t.receivedFrames>0&&!this.isFirstAudioReceived[t.ssrc]&&(this.onFirstAudioReceived&&this.onFirstAudioReceived(t.ssrc),this.isFirstAudioReceived[t.ssrc]=!0),t.decodingNormal>0&&!this.isFirstAudioDecoded[t.ssrc]&&(this.onFirstAudioDecoded&&this.onFirstAudioDecoded(t.ssrc),this.isFirstAudioDecoded[t.ssrc]=!0),this._stats.audioRecv.push(t);break}case"audio_send":{const t=UO(WO);t.codec=e.googCodecName,t.inputLevel=Math.abs(Number(e.audioInputLevel))/32767,t.aecReturnLoss=Number(e.googEchoCancellationReturnLoss||0),t.aecReturnLossEnhancement=Number(e.googEchoCancellationReturnLossEnhancement||0),t.residualEchoLikelihood=Number(e.googResidualEchoLikelihood||0),t.residualEchoLikelihoodRecentMax=Number(e.googResidualEchoLikelihoodRecentMax||0),t.bytes=Number(e.bytesSent),t.packets=Number(e.packetsSent),t.packetsLost=Number(e.packetsLost),t.ssrc=Number(e.ssrc),t.rttMs=Number(e.googRtt||0),this._stats.rtt=t.rttMs,this._stats.audioSend.push(t);break}}}))}_getStats(){return new Wh(((e,t)=>{this.pc.getStats(e,t)}))}statsResponsesToObjects(e){const t=[];return e.result().forEach((e=>{const i={id:e.id,timestamp:e.timestamp.valueOf().toString(),type:e.type};e.names().forEach((t=>{i[t]=e.stat(t)})),t.push(i)})),t}},qO=function(e){return e.BANDWIDTH="bandwidth",e.CPU="cpu",e.NONE="none",e.OTHER="other",e}({}),zO=function(e){return e.L1T1="L1T1",e.L1T2="L1T2",e.L1T3="L1T3",e.L1T3_KEY="L1T3_KEY",e.L2T1_KEY="L2T1_KEY",e.L2T2_KEY="L2T2_KEY",e.L2T3_KEY="L2T3_KEY",e.L3T1_KEY="L3T1_KEY",e.L3T2_KEY="L3T2_KEY",e.L3T3_KEY="L3T3_KEY",e}({}),XO=function(e){return e[e.new=0]="new",e[e.connecting=1]="connecting",e[e.connected=2]="connected",e[e.disconnected=3]="disconnected",e[e.failed=4]="failed",e[e.closed=5]="closed",e}({}),JO=function(e){return e.CERTIFICATE="certificate",e.CODEC="codec",e.CANDIDATE_PAIR="candidate-pair",e.LOCAL_CANDIDATE="local-candidate",e.REMOTE_CANDIDATE="remote-candidate",e.INBOUND="inbound-rtp",e.TRACK="track",e.OUTBOUND="outbound-rtp",e.PC="peer-connection",e.REMOTE_INBOUND="remote-inbound-rtp",e.REMOTE_OUTBOUND="remote-outbound-rtp",e.TRANSPORT="transport",e.CSRC="csrc",e.DATA_CHANNEL="data-channel",e.STREAM="stream",e.SENDER="sender",e.RECEIVER="receiver",e}({});var QO=function(e){return e[e.kNone=1]="kNone",e[e.kMillisecondsFromSeconds=1e3]="kMillisecondsFromSeconds",e[e.kBytesToBits=8]="kBytesToBits",e}(QO||{});function ZO(e,t,i,n){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:QO.kNone;if(!t)return;const o=Number(t[i]);if("number"!=typeof o)return;const s=Number(t[n]);if("number"!=typeof s)return;if(!e)return s?o/s*r:void 0;const a=Number(e[i]);if("number"!=typeof a)return;const c=Number(e[n]);if("number"!=typeof c)return;const d=s-c;return d?(o-a)/d*r:void 0}let $O=class extends KO{constructor(){super(...arguments),_w(this,"_stats",BO),_w(this,"report",void 0),_w(this,"lastDecodeVideoReceiverStats",new Map),_w(this,"lastVideoFramesRecv",new Map),_w(this,"lastVideoFramesSent",new Map),_w(this,"lastVideoFramesDecode",new Map),_w(this,"lastVideoFramesOutput",new Map),_w(this,"lastVideoJBDelay",new Map),_w(this,"lastAudioJBDelay",new Map),_w(this,"mediaBytesSent",new Map),_w(this,"mediaBytesRetransmit",new Map),_w(this,"mediaBytesTargetEncode",new Map),_w(this,"lastDecodeAudioReceiverStats",new Map),_w(this,"lastEncoderMs",new Map)}async updateStats(){this.report=await this.pc.getStats(),this._stats=UO(BO),this.report.forEach((e=>{switch(e.type){case JO.OUTBOUND:case JO.INBOUND:{const t=e.mediaType||e.kind,i=!t&&"frameWidth"in e,n=!t&&!("frameWidth"in e);e.type===JO.OUTBOUND?"audio"===t||n?this.processAudioOutboundStats(e):("video"===t||i)&&this.processVideoOutboundStats(e):e.type===JO.INBOUND&&("audio"===t||n?this.processAudioInboundStats(e):("video"===t||i)&&this.processVideoInboundStats(e));break}case JO.TRANSPORT:{const t=this.report.get(e.selectedCandidatePairId);t&&this.processCandidatePairStats(t);break}case JO.CANDIDATE_PAIR:e.selected&&this.processCandidatePairStats(e)}})),this.updateSendBitrate(),this._stats.updateInterval=Date.now()-this.stats.timestamp,this._stats.timestamp=Date.now(),this.calcLossRate(this._stats),this.stats=this._stats}async getSelectedCandidatePair(){const e=await this.pc.getStats(),t={local:pw({},FO),remote:pw({},FO)};return e.forEach((i=>{let n;if(i.type===JO.TRANSPORT&&(n=e.get(i.selectedCandidatePairId)),i.type===JO.CANDIDATE_PAIR&&i.selected&&(n=i),n){const i=(e,t)=>{e.type=t.type,e.id=t.id,t.address&&(e.address=t.address),t.candidateType&&(e.candidateType=t.candidateType),t.port&&(e.port=t.port),t.priority&&(e.priority=t.priority),t.protocol&&(e.protocol=t.protocol),t.relayProtocol&&(e.relayProtocol=t.relayProtocol)};if(n.localCandidateId){const r=e.get(n.localCandidateId);r&&i(t.local,r)}if(n.remoteCandidateId){const r=e.get(n.remoteCandidateId);r&&i(t.remote,r)}}})),t}processCandidatePairStats(e){if(this._stats.sendBandwidth=e.availableOutgoingBitrate||0,e.currentRoundTripTime&&(this._stats.rtt=1e3*e.currentRoundTripTime),this._stats.videoSend.forEach((t=>{e.currentRoundTripTime&&(t.rttMs=1e3*e.currentRoundTripTime)})),this._stats.audioSend.forEach((t=>{e.currentRoundTripTime&&(t.rttMs=1e3*e.currentRoundTripTime)})),this._stats.selectedCandidatePair.id=e.id,e.localCandidateId){const t=this.report.get(e.localCandidateId);t&&this.processCandidateStats(t)}if(e.remoteCandidateId){const t=this.report.get(e.remoteCandidateId);t&&this.processCandidateStats(t)}}processCandidateStats(e){let t;e.type===JO.LOCAL_CANDIDATE&&(t=this._stats.selectedCandidatePair.localCandidate),e.type===JO.REMOTE_CANDIDATE&&(t=this._stats.selectedCandidatePair.remoteCandidate),t&&(t.type=e.type,t.id=e.id,e.address&&(t.address=e.address),e.candidateType&&(t.candidateType=e.candidateType),e.port&&(t.port=e.port),e.priority&&(t.priority=e.priority),e.protocol&&(t.protocol=e.protocol),e.relayProtocol&&(t.relayProtocol=e.relayProtocol),e.type===JO.LOCAL_CANDIDATE&&this.stats.selectedCandidatePair.localCandidate.id!==t.id&&this.onSelectedLocalCandidateChanged&&this.onSelectedLocalCandidateChanged(pw({},t),pw({},this.stats.selectedCandidatePair.localCandidate)),e.type===JO.REMOTE_CANDIDATE&&this.stats.selectedCandidatePair.remoteCandidate.id!==t.id&&this.onSelectedRemoteCandidateChanged&&this.onSelectedRemoteCandidateChanged(pw({},t),pw({},this.stats.selectedCandidatePair.remoteCandidate)))}processAudioInboundStats(e){let t=this._stats.audioRecv.find((t=>t.ssrc===e.ssrc));t||(t=UO(HO),this._stats.audioRecv.push(t)),t.ssrc=e.ssrc,t.packets=e.packetsReceived,t.packetsLost=e.packetsLost,t.packetsDiscarded=e.packetsDiscarded,t.bytes=e.bytesReceived,t.jitterMs=1e3*e.jitter,t.retransmittedBytesReceived=e.retransmittedBytesReceived,t.retransmittedPacketsReceived=e.retransmittedPacketsReceived,t.totalProcessingDelay=e.totalProcessingDelay,t.jitterBufferEmittedCount=e.jitterBufferEmittedCount;const i=this.lastDecodeAudioReceiverStats.get(t.ssrc);t.avgProcessingDelayMs=ZO(i,t,"totalProcessingDelay","jitterBufferEmittedCount",QO.kMillisecondsFromSeconds),this.processAudioTrackReceiverStats(e,e.trackId,t),e.codecId&&(t.codec=this.getCodecFromCodecStats(e.codecId)),t.receivedFrames||(t.receivedFrames=e.packetsReceived),t.droppedFrames||(t.droppedFrames=e.packetsLost),t.receivedFrames>0&&!this.isFirstAudioReceived[t.ssrc]&&(this.onFirstAudioReceived&&this.onFirstAudioReceived(t.ssrc),this.isFirstAudioReceived[t.ssrc]=!0),t.outputLevel&&t.outputLevel>0&&!this.isFirstAudioDecoded[t.ssrc]&&(this.onFirstAudioDecoded&&this.onFirstAudioDecoded(t.ssrc),this.isFirstAudioDecoded[t.ssrc]=!0),"number"==typeof e.concealedSamples&&(t.concealedSamples=e.concealedSamples),this.lastDecodeAudioReceiverStats.set(t.ssrc,pw({},t))}processVideoInboundStats(e){let t=this._stats.videoRecv.find((t=>t.ssrc===e.ssrc));t||(t=UO(jO),this._stats.videoRecv.push(t)),t.ssrc=e.ssrc,t.packets=e.packetsReceived,t.packetsLost=e.packetsLost,t.bytes=e.bytesReceived,t.firsCount=e.firCount,t.nacksCount=e.nackCount,t.plisCount=e.pliCount,t.framesDecodeCount=e.framesDecoded,t.framesDroppedCount=e.framesDropped,t.totalInterFrameDelay=e.totalInterFrameDelay,t.totalSquaredInterFrameDelay=e.totalSquaredInterFrameDelay,t.totalFreezesDuration=e.totalFreezesDuration,t.totalProcessingDelay=e.totalProcessingDelay,t.packetsDiscarded=e.packetsDiscarded,t.framesAssembledFromMultiplePackets=e.framesAssembledFromMultiplePackets,t.totalAssemblyTime=e.totalAssemblyTime,t.keyFramesDecoded=e.keyFramesDecoded,t.retransmittedBytesReceived=e.retransmittedBytesReceived,t.retransmittedPacketsReceived=e.retransmittedPacketsReceived;const i=this.lastDecodeVideoReceiverStats.get(t.ssrc),n=this.lastVideoFramesDecode.get(t.ssrc),r=this.lastVideoFramesOutput.get(t.ssrc),o=Date.now();if(t.framesDecodeCount>0&&!this.isFirstVideoDecoded[t.ssrc]){const e=t.decodedFrame?t.decodedFrame.width:0,i=t.decodedFrame?t.decodedFrame.height:0;this.onFirstVideoDecoded&&this.onFirstVideoDecoded(t.ssrc,e,i),this.isFirstVideoDecoded[t.ssrc]=!0}if(i){const n=i.stats,r=o-i.lts;t.framesDecodeFreezeTime=n.framesDecodeFreezeTime,t.framesDecodeInterval=n.framesDecodeInterval,!this.isFirstVideoDecoded[t.ssrc]&&r>this.options.firstVideoDecodedTimeout&&!this.isFirstVideoDecodedTimeout[t.ssrc]&&(this.onFirstVideoDecodedTimeout&&this.onFirstVideoDecodedTimeout(t.ssrc),this.isFirstVideoDecodedTimeout[t.ssrc]=!0),t.framesDecodeCount>n.framesDecodeCount&&this.isFirstVideoDecoded[t.ssrc]?(i.lts=Date.now(),t.framesDecodeInterval=r,t.framesDecodeInterval>=this.options.freezeRateLimit&&(this.getVideoIsReady(parseInt(e.ssrc))?t.framesDecodeFreezeTime+=t.framesDecodeInterval:this.setVideoIsReady2(parseInt(e.ssrc,10),!0))):t.framesDecodeCount<n.framesDecodeCount&&(t.framesDecodeInterval=0),e.framesDecoded&&e.qpSum&&(i.stats.framesDecodeCount>e.framesDecoded?t.qpSumPerFrame=e.qpSum/e.framesDecoded:t.qpSumPerFrame=(e.qpSum-i.qpSum)/(e.framesDecoded-i.stats.framesDecodeCount))}e.totalDecodeTime&&(t.decodeMs=1e3*e.totalDecodeTime,t.avgDecodeMs=ZO(null==i?void 0:i.stats,t,"decodeMs","framesDecodeCount")),t.avgProcessingDelayMs=ZO(null==i?void 0:i.stats,t,"totalProcessingDelay","framesDecodeCount",QO.kMillisecondsFromSeconds),t.avgFramesAssembledFromMultiplePacketsMs=ZO(null==i?void 0:i.stats,t,"totalAssemblyTime","framesAssembledFromMultiplePackets",QO.kMillisecondsFromSeconds),t.avgInterFrameDelayMs=ZO(null==i?void 0:i.stats,t,"totalInterFrameDelay","framesDecodeCount",QO.kMillisecondsFromSeconds),n&&o-n.lts>=800?(t.decodeFrameRate=Math.round((t.framesDecodeCount-n.count)/((o-n.lts)/1e3)),this.lastVideoFramesDecode.set(t.ssrc,{count:t.framesDecodeCount,lts:o,rate:t.decodeFrameRate})):n?t.decodeFrameRate=n.rate:this.lastVideoFramesDecode.set(t.ssrc,{count:t.framesDecodeCount,lts:o,rate:0}),t.framesDroppedCount&&e.framesReceived&&(r&&o-r.lts>=800?(t.outputFrameRate=Math.round((e.framesReceived-t.framesDroppedCount-r.count)/((o-r.lts)/1e3)),this.lastVideoFramesOutput.set(t.ssrc,{count:e.framesReceived-t.framesDroppedCount,lts:o,rate:Math.max(t.outputFrameRate,0)})):r?t.outputFrameRate=r.rate:this.lastVideoFramesOutput.set(t.ssrc,{count:e.framesReceived-t.framesDroppedCount,lts:o,rate:0})),this.processVideoTrackReceiverStats(e,e.trackId,t),e.codecId&&(t.codec=this.getCodecFromCodecStats(e.codecId)),e.framerateMean&&(t.framesRateFirefox=e.framerateMean),t.packets>0&&!this.isFirstVideoReceived[t.ssrc]&&(this.onFirstVideoReceived&&this.onFirstVideoReceived(t.ssrc),this.isFirstVideoReceived[t.ssrc]=!0),this.lastDecodeVideoReceiverStats.set(t.ssrc,{stats:pw({},t),lts:i?i.lts:Date.now(),qpSum:e.qpSum})}processVideoOutboundStats(e){let t=this._stats.videoSend.find((t=>t.ssrc===e.ssrc));t||(t=UO(GO),this._stats.videoSend.push(t));const i=this.mediaBytesSent.get(e.ssrc);if(i)i.add(e.bytesSent);else{const t=new VO(10);t.add(e.bytesSent),this.mediaBytesSent.set(e.ssrc,t)}if(void 0!==e.retransmittedBytesSent){const t=this.mediaBytesRetransmit.get(e.ssrc);if(t)t.add(e.retransmittedBytesSent);else{const t=new VO(10);t.add(e.retransmittedBytesSent),this.mediaBytesRetransmit.set(e.ssrc,t)}}if(e.totalEncodedBytesTarget){const t=this.mediaBytesTargetEncode.get(e.ssrc);if(t)t.add(e.totalEncodedBytesTarget);else{const t=new VO(10);t.add(e.totalEncodedBytesTarget),this.mediaBytesTargetEncode.set(e.ssrc,t)}}if(t.ssrc=e.ssrc,t.bytes=e.bytesSent,t.packets=e.packetsSent,t.firsCount=e.firCount,t.nacksCount=e.nackCount,t.plisCount=e.pliCount,t.frameCount=e.framesEncoded,t.adaptionChangeReason=e.qualityLimitationReason,t.scalabilityMode=e.scalabilityMode,t.retransmittedBytesSent=e.retransmittedBytesSent,t.retransmittedPacketsSent=e.retransmittedPacketsSent,t.hugeFramesSent=e.hugeFramesSent,t.keyFramesEncoded=e.keyFramesEncoded,e.totalEncodeTime&&e.framesEncoded){const i=this.lastEncoderMs.get(e.ssrc);if(!i||i.lastFrameCount>e.framesEncoded)t.avgEncodeMs=1e3*e.totalEncodeTime/e.framesEncoded;else{const n=e.framesEncoded-i.lastFrameCount,r=e.totalEncodeTime-i.lastEncoderTime;t.avgEncodeMs=1e3*r/n}}if(e.framesEncoded&&e.qpSum){const i=this.lastEncoderMs.get(e.ssrc);!i||i.lastFrameCount>e.framesEncoded?t.qpSumPerFrame=e.qpSum/e.framesEncoded:t.qpSumPerFrame=(e.qpSum-i.lastQpSum)/(e.framesEncoded-i.lastFrameCount)}if(this.lastEncoderMs.set(e.ssrc,{lastFrameCount:e.framesEncoded,lastEncoderTime:e.totalEncodeTime,lastQpSum:e.qpSum,lts:Date.now()}),e.codecId&&(t.codec=this.getCodecFromCodecStats(e.codecId)),e.mediaSourceId&&this.processVideoMediaSource(e.mediaSourceId,t),this.processVideoTrackSenderStats(e,e.trackId,t),e.remoteId)this.processRemoteInboundStats(e.remoteId,t);else{const i=this.findRemoteStatsId(e.ssrc,JO.REMOTE_INBOUND);i&&this.processRemoteInboundStats(i,t)}}processAudioOutboundStats(e){let t=this._stats.audioSend.find((t=>t.ssrc===e.ssrc));if(t||(t=UO(WO),this._stats.audioSend.push(t)),t.ssrc=e.ssrc,t.packets=e.packetsSent,t.bytes=e.bytesSent,t.retransmittedBytesSent=e.retransmittedBytesSent,t.retransmittedPacketsSent=e.retransmittedPacketsSent,e.mediaSourceId&&this.processAudioMediaSource(e.mediaSourceId,t),e.codecId&&(t.codec=this.getCodecFromCodecStats(e.codecId)),this.processAudioTrackSenderStats(e,e.trackId,t),e.remoteId)this.processRemoteInboundStats(e.remoteId,t);else{const i=this.findRemoteStatsId(e.ssrc,JO.REMOTE_INBOUND);i&&this.processRemoteInboundStats(i,t)}}findRemoteStatsId(e,t){var i;const n=Array.from(Zh(i=this.report).call(i)).find((i=>i.type===t&&i.ssrc===e));return n?n.id:null}processVideoMediaSource(e,t){const i=this.report.get(e);i&&i.width&&i.height&&i.framesPerSecond&&(t.inputFrame={width:i.width,height:i.height,frameRate:i.framesPerSecond})}processAudioMediaSource(e,t){const i=this.report.get(e);i&&(t.inputLevel=i.audioLevel)}processVideoTrackSenderStats(e,t,i){var n,r,o,s;const a=t?this.report.get(t):void 0,c=null!==(n=null==a?void 0:a.framesSent)&&void 0!==n?n:e.framesSent;if("number"!=typeof c)return;let d=null!==(r=null==a?void 0:a.frameWidth)&&void 0!==r?r:e.frameWidth,l=null!==(o=null==a?void 0:a.frameHeight)&&void 0!==o?o:e.frameHeight,u=null!==(s=null==a?void 0:a.framesPerSecond)&&void 0!==s?s:e.framesPerSecond;if("number"==typeof d&&"number"==typeof l||(d=0,l=0),null==u){const e=Date.now(),t=this.lastVideoFramesSent.get(i.ssrc);t&&e-t.lts>=800?(u=Math.round((c-t.count)/((e-t.lts)/1e3)),this.lastVideoFramesSent.set(i.ssrc,{count:c,lts:e,rate:u})):t?u=t.rate:this.lastVideoFramesSent.set(i.ssrc,{count:c,lts:e,rate:0})}i.sentFrame={width:d,height:l,frameRate:Math.max(0,u)}}processVideoTrackReceiverStats(e,t,i){var n,r,o,s,a;const c=t?this.report.get(t):void 0,d=null!==(n=null==c?void 0:c.framesReceived)&&void 0!==n?n:e.framesReceived,l=null!==(r=null==c?void 0:c.frameWidth)&&void 0!==r?r:e.frameWidth,u=null!==(o=null==c?void 0:c.frameHeight)&&void 0!==o?o:e.frameHeight,h=null!==(s=null==c?void 0:c.jitterBufferDelay)&&void 0!==s?s:e.jitterBufferDelay,p=null!==(a=null==c?void 0:c.jitterBufferEmittedCount)&&void 0!==a?a:e.jitterBufferEmittedCount;if("number"==typeof d){const e=this.lastVideoFramesRecv.get(i.ssrc),t=Date.now();i.framesReceivedCount=d;let n=0;e&&t-e.lts>=800?(n=Math.round((d-e.count)/((t-e.lts)/1e3)),this.lastVideoFramesRecv.set(i.ssrc,{count:d,lts:t,rate:n})):e?n=e.rate:this.lastVideoFramesRecv.set(i.ssrc,{count:d,lts:t,rate:0}),i.receivedFrame={width:l||0,height:u||0,frameRate:n||0},i.decodedFrame={width:l||0,height:u||0,frameRate:i.decodeFrameRate||0},i.outputFrame={width:l||0,height:u||0,frameRate:i.outputFrameRate||i.decodeFrameRate||0}}if(h&&p){const e=this.lastVideoJBDelay.get(i.ssrc)||{jitterBufferDelay:0,jitterBufferEmittedCount:0,jitterBufferMs:0};let t=e.jitterBufferMs;const n=p-e.jitterBufferEmittedCount;n>0&&(t=1e3*(h-e.jitterBufferDelay)/n),i.jitterBufferMs=t,i.currentDelayMs=Math.round(t),this.lastVideoJBDelay.set(i.ssrc,{jitterBufferDelay:h,jitterBufferEmittedCount:p,jitterBufferMs:i.currentDelayMs})}}processAudioTrackSenderStats(e,t,i){var n,r,o,s;const a=t?this.report.get(t):void 0,c=null!==(n=null!==(r=null==a?void 0:a.echoReturnLoss)&&void 0!==r?r:e.echoReturnLoss)&&void 0!==n?n:0,d=null!==(o=null!==(s=null==a?void 0:a.echoReturnLossEnhancement)&&void 0!==s?s:e.echoReturnLossEnhancement)&&void 0!==o?o:0;i.aecReturnLoss=c,i.aecReturnLossEnhancement=d}processAudioTrackReceiverStats(e,t,i){var n,r,o,s,a,c,d;const l=t?this.report.get(t):void 0,u=null!==(n=null==l?void 0:l.removedSamplesForAcceleration)&&void 0!==n?n:e.removedSamplesForAcceleration,h=null!==(r=null==l?void 0:l.totalSamplesReceived)&&void 0!==r?r:e.totalSamplesReceived,p=null!==(o=null==l?void 0:l.jitterBufferDelay)&&void 0!==o?o:e.jitterBufferDelay,_=null!==(s=null==l?void 0:l.jitterBufferEmittedCount)&&void 0!==s?s:e.jitterBufferEmittedCount,E=null!==(a=null==l?void 0:l.audioLevel)&&void 0!==a?a:null==e?void 0:e.audioLevel,m=null!==(c=null==l?void 0:l.totalSamplesDuration)&&void 0!==c?c:null==e?void 0:e.totalSamplesDuration,f=null!==(d=null==l?void 0:l.concealedSamples)&&void 0!==d?d:e.concealedSamples;if("number"==typeof h&&(i.totalSamplesReceived=h),u&&h&&(i.accelerateRate=u/h),p&&_){const e=this.lastAudioJBDelay.get(i.ssrc)||{jitterBufferDelay:0,jitterBufferEmittedCount:0,jitterBufferMs:0};let t=e.jitterBufferMs;const n=_-e.jitterBufferEmittedCount;n>0&&(t=1e3*(p-e.jitterBufferDelay)/n),i.jitterBufferMs=Math.round(t),this.lastAudioJBDelay.set(i.ssrc,{jitterBufferDelay:p,jitterBufferEmittedCount:_,jitterBufferMs:i.jitterBufferMs})}i.outputLevel=E;let T=1920;m&&h&&(T=h/m/50,i.receivedFrames=Math.round(h/T)),f&&(i.droppedFrames=Math.round(f/T))}processRemoteInboundStats(e,t){const i=this.report.get(e);i&&(t.packetsLost=i.packetsLost,i.roundTripTime&&(t.rttMs=1e3*i.roundTripTime),i.jitter&&(t.jitterMs=1e3*i.jitter),i.timestamp&&(t.timestamp=i.timestamp))}getCodecFromCodecStats(e){const t=this.report.get(e);if(!t)return"";const i=t.mimeType.match(/\/(.*)$/);return i&&i[1]?i[1]:""}updateSendBitrate(){let e=0,t=null,i=null;this.mediaBytesSent.forEach((t=>{e+=t.diffMean()})),this.mediaBytesRetransmit.forEach((e=>{t=null===t?e.diffMean():t+e.diffMean()})),this.mediaBytesTargetEncode.forEach((e=>{i=null===i?e.diffMean():i+e.diffMean()}));const n=null!==t?e-t:e;this._stats.bitrate={actualEncoded:8*n/(this.options.updateInterval/1e3),transmit:8*e/(this.options.updateInterval/1e3)},null!==t&&(this._stats.bitrate.retransmit=8*t/(this.options.updateInterval/1e3)),null!==i&&(this._stats.bitrate.targetEncoded=8*i/(this.options.updateInterval/1e3))}},eN=class extends KO{updateStats(){return Wh.resolve()}};function tN(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:500,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1e4;const o=function(){const e=navigator.userAgent.toLocaleLowerCase().match(/chrome\/[\d]*/i);return e&&e[0]?Number(e[0].split("/")[1]):null}();return o?o<76?new YO(e,{updateInterval:t,lossRateInterval:i,freezeRateLimit:n,firstVideoDecodedTimeout:r}):new $O(e,{updateInterval:t,lossRateInterval:i,freezeRateLimit:n,firstVideoDecodedTimeout:r}):function(e){if(!window.RTCStatsReport)return!1;const t=e.getStats();return!!(t instanceof Wh||function(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}(t))}(e)?new $O(e,{updateInterval:t,lossRateInterval:i,freezeRateLimit:n,firstVideoDecodedTimeout:r}):new eN(e,{updateInterval:t,lossRateInterval:i,freezeRateLimit:n,firstVideoDecodedTimeout:r})}const iN="websdk_ng_install_id";function nN(){try{if(_N("INSTALL_ID"))return _N("INSTALL_ID");let e=window.localStorage.getItem(iN);return e||(e=pO(),window.localStorage.setItem(iN,e)),pN("INSTALL_ID",e),e}catch(e){return}}const rN=function(e){if(e.match(/[0-9]+\.[0-9]+\.[0-9]+$/))return e;const t=e.match(/([0-9]+\.[0-9]+\.[0-9]+)\-([0-9]+)/);if(t&&t[1]&&t[2]){const e=t[1],i=t[2];return"".concat(e,".").concat(i)}return"4.0.0.999"}("4.23.2"),oN=function(){try{return!0===JSON.parse("true")}catch(e){return!0}}();let sN=function(e){return e.Default="default",e.Auto="auto",e.Relay="relay",e.SdRtn="sd-rtn",e}({});const aN=function(){const e="us".concat("erna","me"),t="pa".concat("sswo","rd"),i=["t","s","t"];i.splice(1,0,"e");const n=i.join(""),r=[];for(let e=0;e<6;e++)r.push("1");const o=r.join(""),s={};return s[e]=n,s[t]=o,Object.assign(s,{turnServerURL:"",tcpport:3433,udpport:3478,forceturn:!1})}();window.DEFAULT_TURN_CONFIG=aN;
12271const cN={ENABLE_PUBLISHED_USER_LIST:!0,MAX_SUBSCRIPTION:50,SUBSCRIBE_AUDIO_FILTER_TOPN:void 0,ENABLE_PUBLISH_AUDIO_FILTER:void 0,ENABLE_USER_LICENSE_CHECK:!0,DISABLE_FEC:void 0,ENABLE_NTP_REPORT:!1,ENABLE_INSTANT_VIDEO:!1,ENABLE_USER_AUTO_REBALANCE_CHECK:!0,ENABLE_LOSSBASED_BWE:!0,ENABLE_AUT_CC:!1,ENABLE_CC_FALLBACK:void 0,SUBSCRIBE_TWCC:!0,PUBLISH_TWCC:!1,ENABLE_SVC_DEFAULT_CODECS:["H264","VP8","VP9","AV1"],SVC:[],ENABLE_FULL_LINK_AV_SYNC:!1,SVC_MODE:null,PRE_SUB_NUM:2,ENABLE_AUT_FEEDBACK:!1,SVC_EXTENDED:["VP9"]},dN={MIN_FRAME_RATE:1,MAX_FRAME_RATE:30,MAX_THRESHOLD_FRAMERATE:30,BITRATE_MIN_THRESHOLD:100,BITRATE_MAX_THRESHOLD:100,MAX_SCALE:5,BWE_SCALE_UP_THRESHOLD:.6,BWE_SCALE_DOWN_THRESHOLD:.6,PERF_SCALE_UP_THRESHOLD:.7,PERF_SCALE_DOWN_THRESHOLD:.6,MOTION_RESOLUTION_FACTOR:.8,MOTION_BITRATE_FACTOR:.6,DETAIL_FRAMERATE_FACTOR:.8,DETAIL_BITRATE_FACTOR:.6,BALANCE_RESOLUTION_FACTOR:.9,BALANCE_FRAMERATE_FACTOR:.9,BALANCE_BITRATE_FACTOR:.6,OVERUSE_TIMES_THRESHOLD:10,UNDERUSE_TIMES_THRESHOLD:40},lN="v4.23.2-0-g1599fdac-dirty(3/4/2025, 5:13:36 PM)",uN={ENABLE_EVENT_REPORT:!0,UPLOAD_LOG:!1,ENABLE_AG_ADAPTATION:!0,FORCE_AG_HIGH_FRAMERATE:!1,FORCE_SUPPORT_AG_ADAPTATION:!1,ENCODER_CONFIG_LIMIT:{},CAMERA_CAPTURE_CONFIG:void 0,ENABLE_PRELOAD:!0,NEW_ICE_RESTART:!1,ICE_RESTART_INTERVAL:1e4,RESTART_SEQUENCE:["udp_tcp_relay","relay"],FIRST_TCP_CANDIDATE:!1,FIRST_TCP_CANDIDATE_INTERVAL:1e3,TURN_DOMAIN:"edge.agora.io",USE_TURN_IP:!1,NEW_TURN_MODE:void 0,NEW_FORCE_TURN:!1},hN=pw(pw(pw({},uN),{},{PROCESS_ID:"",ENCRYPT_AES:!0,AREAS:["CHINA","GLOBAL"],WEBCS_DOMAIN:["webrtc2-ap-web-1.agora.io","webrtc2-2.ap.sd-rtn.com"],WEBCS_DOMAIN_BACKUP_LIST:["webrtc2-ap-web-3.agora.io","webrtc2-4.ap.sd-rtn.com"],PROXY_CS:["ap-proxy-1.agora.io","ap-proxy-2.agora.io"],CDS_AP:["cds-ap-web-1.agora.io","cds-web-2.ap.sd-rtn.com","cds-ap-web-3.agora.io","cds-web-4.ap.sd-rtn.com"],ACCOUNT_REGISTER:["sua-ap-web-1.agora.io","sua-web-2.ap.sd-rtn.com","sua-ap-web-3.agora.io","sua-web-4.ap.sd-rtn.com"],UAP_AP:["uap-ap-web-1.agora.io","uap-web-2.ap.sd-rtn.com","uap-ap-web-3.agora.io","uap-web-4.ap.sd-rtn.com"],LOG_UPLOAD_SERVER:"logservice.agora.io",EVENT_REPORT_DOMAIN:"statscollector-1.agora.io",EVENT_REPORT_BACKUP_DOMAIN:"web-2.statscollector.sd-rtn.com",GATEWAY_ADDRESS:[],GATEWAY_WSS_ADDRESS:"",LIVE_STREAMING_ADDRESS:"",HTTP_CONNECT_TIMEOUT:5e3,SIGNAL_REQUEST_TIMEOUT:1e4,REPORT_STATS:!0,NOT_REPORT_EVENT:[],PING_PONG_TIME_OUT:10,WEBSOCKET_TIMEOUT_MIN:1e4,EVENT_REPORT_SEND_INTERVAL:3e3,CONFIG_DISTRIBUTE_INTERVAL:3e5,ENABLE_CONFIG_DISTRIBUTE:!0,CANDIDATE_TIMEOUT:5e3,SHOW_REPORT_INVOKER_LOG:!1,SHOW_REPORT_USER_INVOKER_LOG:!0,JOIN_EXTEND:"",PUB_EXTEND:"",SUB_EXTEND:"",FORCE_TURN:!1,TURN_ENABLE_TCP:!0,TURN_ENABLE_UDP:!0,MAX_UPLOAD_CACHE:50,UPLOAD_CACHE_INTERVAL:2e3,AJAX_REQUEST_CONCURRENT:3,REPORT_APP_SCENARIO:void 0,GATEWAY_DOMAINS:["edge.agora.io","edge.sd-rtn.com"],CONNECT_GATEWAY_WITHOUT_DOMAIN:!1,WORKER_DOMAIN:"edge.agora.io",EVENT_REPORT_RETRY:!0,CHROME_FORCE_PLAN_B:!1,AUDIO_SOURCE_VOLUME_UPDATE_INTERVAL:400,AUDIO_SOURCE_AVG_VOLUME_DURATION:3e3,AUDIO_VOLUME_INDICATION_INTERVAL:2e3,VOLUME_VOICE_WEIGHT:10,GET_VOLUME_OF_MUTED_AUDIO_TRACK:!1,STATS_UPDATE_INTERVAL:250,NORMAL_EVENT_QUEUE_CAPACITY:100,CUSTOM_REPORT:!0,CUSTOM_REPORT_LIMIT:20,PROXY_SERVER_TYPE2:"webnginx-proxy.agora.io",PROXY_SERVER_TYPE3:["webrtc-cloud-proxy.sd-rtn.com","webrtc-cloud-proxy.agora.io"],CUSTOM_PUB_ANSWER_MODIFIER:null,CUSTOM_SUB_ANSWER_MODIFIER:null,CUSTOM_PUB_OFFER_MODIFIER:null,CUSTOM_SUB_OFFER_MODIFIER:null,DSCP_TYPE:"high",REMOVE_NEW_CODECS:!0,FRAGEMENT_LENGTH:3,WEBSOCKET_COMPRESS:!1,SIMULCAST:!1,PRELOAD_MEDIA_COUNT:0,CHECK_VIDEO_VISIBLE_INTERVAL:3e4,CHECK_LOCAL_STATS_INTERVAL:250,PROFILE_SWITCH_INTERVAL:2e3,UNSUPPORTED_VIDEO_CODEC:[],ENUMERATE_DEVICES_INTERVAL:!1,ENUMERATE_DEVICES_INTERVAL_TIME:1e4,USE_NEW_TOKEN:!1,CLOSE_AFB_FOR_LOCAL_AP:!0,JOIN_MAX_CONCURRENCY:6,JOIN_WITH_FALLBACK_SIGNAL_PROXY:!0,JOIN_WITH_FALLBACK_MEDIA_PROXY:!0,JOIN_WITH_FALLBACK_MEDIA_PROXY_FORCE:!1,JOIN_GATEWAY_TRY_443PORT_DURATION:2e3,JOIN_GATEWAY_USE_443PORT_ONLY:!1,JOIN_GATEWAY_USE_DUAL_DOMAIN:!0,JOIN_GATEWAY_FALLBACK_PORT:443,USE_TURN_SERVER_OF_GATEWAY:!1,H264_PROFILE_LEVEL_ID:"",USE_NEW_LOG:!1,LOG_VERSION:3,MEDIA_DEVICE_CONSTRAINTS:null,ENCRYPT_PROXY_USERNAME_AND_PSW:!0,SDP_LOGGING:!1,CSP_DETECTED_HOSTNAME_LIST:["agora.io","sd-rtn.com"],REMOTE_AUDIO_TRACK_USES_WEB_AUDIO:!1,LOCAL_AUDIO_TRACK_USES_WEB_AUDIO:!1,BITRATE_ADAPTER_TYPE:"STANDARD_BITRATE",AI_DENOISER_PARAMETERS:{excludedLinks:[]},ADJUST_3A_FROM_PLUGINS:!0,RAISE_H264_BASELINE_PRIORITY:!0,FILTER_SEND_H264_BASELINE:!1,FIRST_H264_PROFILE_LEVEL_ID:"42001f",FIRST_PACKETIZATION_MODE:"",X_GOOGLE_START_BITRATE:void 0,NEW_REPORT_SERVER:!1,NEW_REPORT_SERVER_DOMAINS:["data-reporting.agora.io","data-reporting.agora.io"],VIDEO_INSPECT_WORKER_MESSAGE_LENGTH_LIMIT:3e5,VIDEO_INSPECT_INTERVAL_MINIMUM:1e3,VIDEO_INSPECT_QUALITY_RATIO:.9,V
vendor: 58,522 bytes, line 12271
12271IDEO_INSPECT_WORKER_MANAGER_HOST:"edge.agora.io",VIDEO_INSPECT_WORKER_MANAGER_PORT:"",VIDEO_INSPECT_WORKER_PORT:"",SHOW_VIDEO_INSPECT_WORKER_MESSAGE:!1,STATS_COLLECTOR_PORT:443,FORCE_TURN_TCP:!1,WEBAUDIO_INIT_OPTIONS:void 0,FILTER_VIDEO_FEC:!0,FILTER_AUDIO_FEC:!1,CHROME_DUAL_STREAM_USE_ENCODING:!0,DISABLE_DUAL_STREAM_USE_ENCODING:!1,EXTENSION_USAGE_UPLOAD_INTERVAL:1e4,ICE_RESTART:!0,FINGERPRINT:null,ENABLE_VIDEO_FRAME_CALLBACK:!0,VIDEO_FREEZE_DURATION:500,SPATIALIZER_PARAMETERS:{},UPLOAD_LOG_INTERVAL:3e3,UPLOAD_LOG_REQUEST_RETRY_INTERVAL:2e3,UPLOAD_LOG_REQUEST_MAX_RETRY_INTERVAL:2e4,UPLOAD_LOG_TRY_INTERVAL_WHILE_OFF:5e3,UPLOAD_LOG_RETRY_INTERVAL_V1:1e4,UPLOAD_LOG_TWICE_RETRY_INTERVAL_V1:200,UPLOAD_LOG_LENGTH_EACH_TIME:10,APP_TYPE:0,DISABLE_WEBAUDIO:!1,CHANNEL_MEDIA_RELAY_SERVERS:void 0,KEEP_LAST_FRAME:!0,FORWARD_P2P_CREATION:!0,SYNC_GROUP:!0,BLOCK_LOCAL_CLIENT:!1,ENABLE_AUDIO_TOPN:!1,ENABLE_AUDIO_METADATA:!1,ENABLE_AUDIO_PTS_METADATA:!1,TOPN_SMOOTH_LEVEL:void 0,TOPN_NEW_SPEAKER_DELAY:void 0,TOPN_SWITCH_HOLD_MS:void 0,TOPN_AUDIO_GAIN:void 0,TOPN_SILENCE_THRESHOLD:250,AP_AREA:!0,ENABLE_ENCODED_TRANSFORM:!1,ENABLE_VIDEO_SEI:!1,IMAGE_MODERATION_WORKER_HOST:"edge.agora.io",IMAGE_MODERATION_WORKER_MESSAGE_LENGTH_LIMIT:3e5,IMAGE_MODERATION_INTERVAL_MINIMUM:1e3,SHOW_IMAGE_MODERATION_WORKER_MESSAGE:!1,IMAGE_MODERATION_QUALITY_RATIO:.9,IMAGE_MODERATION_UPLOAD_REPORT_INTERVAL:5e3,SHOW_GLOBAL_CLIENT_LIST:!1,DATASTREAM_MAX_RETRANSMITS:10,TCP_CANDIDATE_ONLY:!1,EXTERNAL_SIGNAL_REQUEST_TIMEOUT:3e3,SHOW_P2P_LOG:!1,MAX_P2P_TIMEOUT:3e4,P2P_TOKEN_INTERVAL:1e3,SHOW_DATASTREAM2_LOG:!1,RESTRICTION_SET_PLAYBACK_DEVICE:!0,USE_PURE_ENCRYPTION_MASTER_KEY:!1,ACCOUNT_REGISTER_RETRY_TIMEOUT:1,ACCOUNT_REGISTER_RETRY_RATIO:2,ACCOUNT_REGISTER_RETRY_TIMEOUT_MAX:6e4,ACCOUNT_REGISTER_RETRY_COUNT_MAX:1e5,AUDIO_CONTEXT:null,WEBCS_BACKUP_CONNECT_TIMEOUT:6e3,PLAYER_STATE_DEFER:2e3,SIGNAL_REQUEST_WATCH_INTERVAL:1e3,FILEPATH_LENMAX:255,DUALSTREAM_OPERATION_CHECK:!0,MEDIA_ELEMENT_EXISTS_DEPTH:3,SHIM_CANDIDATE:!1,LEAVE_MSG_TIMEOUT:2e3,STATS_FILTER:{transportId:!0,googTrackId:!0},FILTER_VIDEO_CODEC:[],USE_NEW_NETWORK_CONFIG:!1,AUTO_RESET_AUDIO_ROUTE:!1,PLUGIN_INFO:[],OVERUSE_DETECTOR_PARAMS:dN,CUSTOM_ADAPTATION_DEFAULT_MODE:"",HIDE_NO_POSTER:!1,AP_CACHE_NUM:10,AP_UPDATE_INTERVAL:12e4,AP_CACHE_LIFETIME:12e4,MAX_PRELOAD_ASYNC_LENGTH:3,DISABLE_SCREEN_SHARE_REMB:!1},cN),{},{USE_CANDIDATE_FROM_AP_DETAIL:!1,AP_REQUEST_DETAIL:void 0,ENABLE_ROLE_SELECT_EDGE:!1,CLIENT_ROLE_OPTIONS:void 0,COMPATIBLE_SDP_EXTENSION:["gdpr_forbidden"],LIMIT_BITRATE:void 0,EXPERIMENTS:{},USE_PUB_RTX:!0,USE_SUB_RTX:!0,ENABLE_DATASTREAM_2:!1,USE_XR:!0,ENABLE_PREALLOC_PC:!1,ENABLE_PRE_SUB:!1,ENABLE_SVC:!1},{INSTALL_ID:""});function pN(e,t,i){var n,r,o;Dn(n=Object.keys(hN)).call(n,e)&&(!i&&Dn(r=Object.keys(mN)).call(r,e)||(hN[e]=t,"ENABLE_VIDEO_SEI"!==e&&"ENABLE_AUDIO_TOPN"!==e&&"ENABLE_AUDIO_METADATA"!==e&&"ENABLE_AUDIO_PTS_METADATA"!==e||!0!==t||(hN.ENABLE_ENCODED_TRANSFORM=!0,"ENABLE_AUDIO_PTS_METADATA"===e&&(hN.ENABLE_AUDIO_METADATA=!0)),"USE_NEW_NETWORK_CONFIG"===e&&t&&(o=!!t,hN.USE_NEW_NETWORK_CONFIG=o,o&&(hN.WEBCS_DOMAIN=["webrtc2-2.ap.sd-rtn.com"],hN.WEBCS_DOMAIN_BACKUP_LIST=["webrtc2-4.ap.sd-rtn.com"],hN.CDS_AP=["cds-web-2.ap.sd-rtn.com","cds-web-4.ap.sd-rtn.com"],hN.ACCOUNT_REGISTER=["sua-web-2.ap.sd-rtn.com","sua-web-4.ap.sd-rtn.com"],hN.EVENT_REPORT_DOMAIN="web-2.statscollector.sd-rtn.com",hN.EVENT_REPORT_BACKUP_DOMAIN="statscollector-1.agora.io",hN.GATEWAY_DOMAINS=["edge.sd-rtn.com"])),"ENABLE_PRE_SUB"===e&&t&&(hN.ENABLE_INSTANT_VIDEO=!0,hN.ENABLE_PREALLOC_PC=!0),"ENABLE_SVC"===e&&t&&(hN.ENABLE_AUT_CC=!0),"NEW_FORCE_TURN"===e&&t&&(hN.NEW_TURN_MODE||(hN.NEW_TURN_MODE=4))))}function _N(e){return hN[e]}oN||(hN.WEBCS_DOMAIN=["ap-web-1-oversea.agora.io","ap-web-1-north-america.agora.io"],hN.WEBCS_DOMAIN_BACKUP_LIST=["ap-web-2-oversea.agora.io","ap-web-2-north-america.agora.io"],hN.PROXY_CS=["proxy-ap-web-oversea.agora.io","proxy-ap-web-america.agora.io"],hN.CDS_AP=["cds-ap-web-oversea.agora.io","cds-ap-web-america.agora.io","cds-ap-web-america2.agora.io"],hN.ACCOUNT_REGISTER=["sua-ap-web-oversea.agora.io","sua-ap-web-america.agora.io","sua-ap-web-america2.agora.io"],hN.UAP_AP=["uap-ap-web-oversea.agora.io","uap-ap-web-america.agora.io","uap-ap-web-america2.agora.io"],hN.LOG_UPLOAD_SERVER="logservice-oversea.agora.io",hN.EVENT_REPORT_DOMAIN="statscollector-1-oversea.agora.io",hN.EVENT_REPORT_BACKUP_DOMAIN="statscollector-2-oversea.agora.io",hN.PROXY_SERVER_TYPE3="webrtc-cloud-proxy.agora.io",hN.AREAS=["NORTH_AMERICA","OVERSEA"]);let EN=function(e){return e[e.REALTIME=1]="REALTIME",e}({});const mN={};var fN=function(e){return e.SET_SESSION_ID="SET_SESSION_ID",e.SET_P2P_ID="SET_P2P_id",e.SET_DC_ID="SET_DC_id",e.SET_UID="SET_UID",e.SET_INT_UID="SET_INT_UID",e.SET_PUB_ID="SET_PUB_ID",e.SET_CLOUD_PROXY_SERVER_MODE="SET_CLOUD_PROXY_SERVER_MODE",e.KEY_METRIC_CLIENT_CREATED="KEY_METRIC_CLIENT_CREATED",e.KEY_METRIC_JOIN_START="KEY_METRIC_JOIN_START",e.AVOID_JOIN_START="AVOID_JOIN_START",e.KEY_METRIC_JOIN_END="KEY_METRIC_JOIN_END",e.KEY_METRIC_REQUEST_AP_START="KEY_METRIC_REQUEST_AP_START",e.KEY_METRIC_REQUEST_AP_END="KEY_METRIC_REQUEST_AP_END",e.KEY_METRIC_JOIN_GATEWAY_START="KEY_METRIC_JOIN_GATEWAY_START",e.KEY_METRIC_JOIN_GATEWAY_END="KEY_METRIC_JOIN_GATEWAY_END",e.KEY_METRIC_PEER_CONNECTION_START="KEY_METRIC_PEER_CONNECTION_START",e.KEY_METRIC_PEER_CONNECTION_END="KEY_METRIC_PEER_CONNECTION_END",e.KEY_METRIC_DESCRIPTION_START="KEY_METRIC_DESCRIPTION_START",e.KEY_METRIC_ICE_CONNECTION_END="KEY_METRIC_ICE_CONNECTION_END",e.KEY_METRIC_SIGNAL_CHANNEL_OPEN="KEY_METRIC_SIGNAL_CHANNEL_OPEN",e.KEY_METRIC_PUBLISH="KEY_METRIC_PUBLISH",e.KEY_METRIC_SUBSCRIBE="KEY_METRIC_SUBSCRIBE",e.RECORD_JOIN_CHANNEL_SERVICE="RECORD_JOIN_CHANNEL_SERVICE",e.RESET_JOIN_CHANNEL_SERVICE_RECORDS="RESET_JOIN_CHANNEL_SERVICE_RECORDS",e.RESET_KEY_METRICS="RESET_KEY_METRICS",e.SET_USE_P2P="SET_USE_P2P",e.SET_TRANSPORT_TYPE="SET_TRANSPORT_TYPE",e}(fN||{});let TN=function(e){return e.h264="h264",e.h265="h265",e.vp8="vp8",e.vp9="vp9",e.av1="av1",e}({});!function(e){e.opus="opus",e.pcma="pcma",e.pcmu="pcmu",e.g722="g722"}({});const SN=128,gN=96,RN=1e3,vN=10;let CN=0;var IN=(()=>{var e={8:(e,t,i)=>{i.r(t),i.d(t,{Parser:()=>v,Printer:()=>b,parse:()=>D,print:()=>P});const n="\n",r="".concat("\r").concat(n),o=" ";let s;function a(e){return e>="0"&&e<="9"}function c(e){return e>="!"&&e<="~"}function d(e){return c(e)||e>="Â"&&e<="ÿ"}function l(e){return"!"===e||e>="#"&&e<="'"||e>="*"&&e<="+"||e>="-"&&e<="."||e>="0"&&e<="9"||e>="A"&&e<="Z"||e>="^"&&e<="~"}function u(e){return e>="1"&&e<="9"}function h(e){return e>="A"&&e<="Z"||e>="a"&&e<="z"}function p(e){return"d"===e||"h"===e||"m"===e||"s"===e}function _(e){return e>"�"&&e<"\t"||e>"\v"&&e<"\f"||e>"�"&&e<"ÿ"}function E(e){return h(e)||a(e)||"+"===e||"/"===e}function m(e){return a(e)||h(e)||"+"===e||"/"===e||"-"===e||"_"===e}function f(e){return h(e)||a(e)||"+"===e||"/"===e}function T(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function S(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?T(Object(i),!0).forEach((function(t){g(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):T(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function g(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}!function(e){e.VERSION="v",e.ORIGIN="o",e.SESSION_NAME="s",e.INFORMATION="i",e.URI="u",e.EMAIL="e",e.PHONE="p",e.CONNECTION="c",e.BANDWIDTH="b",e.TIME="t",e.REPEAT="r",e.ZONE_ADJUSTMENTS="z",e.KEY="k",e.ATTRIBUTE="a",e.MEDIA="m"}(s||(s={}));class R{consumeText(e,t){let i=t;for(;i<e.length;){const t=e[i];if("\0"===t||"\r"===t||t===n)break;i+=1}if(i-t==0)throw new Error("Invalid text, at ".concat(e));return i}consumeUnicastAddress(e,t,i){return this.consumeTill(e,t,o)}consumeOneOrMore(e,t,i){let n=t;for(;i(e[n]);)n++;if(n-t==0)throw new Error("Invalid rule at ".concat(t,"."));return n}consumeSpace(e,t){if(e[t]===o)return t+1;throw new Error("Invalid space at ".concat(t,"."))}consumeIP4Address(e,t){let i=t;for(let t=0;t<4;t++)if(i=this.consumeDecimalUChar(e,i),3!==t){if("."!==e[i])throw new Error("Invalid IP4 address.");i++}return i}consumeDecimalUChar(e,t){let i=t;for(let t=0;t<3&&a(e[i]);t++,i++);if(i-t==0)throw new Error("Invalid decimal uchar.");const n=parseInt(e.slice(t,i));if(n>=0&&n<=255)return i;throw new Error("Invalid decimal uchar")}consumeIP6Address(e,t){let i=this.consumeHexpart(e,t);return":"===e[i]?(i+=1,i=this.consumeIP4Address(e,i),i):i}consumeHexpart(e,t){let i=t;if(":"===e[i]&&":"===e[i+1]){i+=2;try{i=this.consumeHexseq(e,i)}catch(e){}return i}if(i=this.consumeHexseq(e,i),":"===e[i]&&":"===e[i+1]){i+=2;try{i=this.consumeHexseq(e,i)}catch(e){}return i}return i}consumeHexseq(e,t){let i=t;for(;i=this.consumeHex4(e,i),":"===e[i]&&":"!==e[i+1];)i+=1;return i}consumeHex4(e,t){let i=0;for(;i<4;i++)if(!((n=e[t+i])>="0"&&n<="9"||n>="a"&&n<="f"||n>="A"&&n<="F")){if(0===i)throw new Error("Invalid hex 4");break}var n;return t+i}consumeFQDN(e,t){let i=t;for(;a(e[i])||h(e[i])||"-"===e[i]||"."===e[i];)i+=1;if(i-t<4)throw new Error("Invalid FQDN");return i}consumeExtnAddr(e,t){return this.consumeOneOrMore(e,t,d)}consumeMulticastAddress(e,t,i){switch(i){case"IP4":case"ip4":return this.consumeIP4MulticastAddress(e,t);case"IP6":case"ip6":return this.consumeIP6MulticastAddress(e,t);default:try{return this.consumeFQDN(e,t)}catch(i){return this.consumeExtnAddr(e,t)}}}consumeIP6MulticastAddress(e,t){const i=this.consumeHexpart(e,t);return"/"===e[i]?this.consumeInteger(e,i+1):i}consumeIP4MulticastAddress(e,t){let i=t+3;const n=e.slice(t,i),r=parseInt(n);if(r<224||r>239)throw new Error("Invalid IP4 multicast address, IPv4 multicast addresses may be in the range 224.0.0.0 to 239.255.255.255.");for(let t=0;t<3;t++){if("."!==e[i])throw new Error("Invalid IP4 multicast address.");i+=1,i=this.consumeDecimalUChar(e,i)}return"/"===e[i]&&(i+=1),i=this.consumeTTL(e,i),"/"===e[i]&&(i=this.consumeInteger(e,i)),i}consumeInteger(e,t){if(!u(e[t]))throw new Error("Invalid integer.");for(t+=1;a(e[t]);)t+=1;return t}consumeTTL(e,t){if("0"===e[t])return t+1;if(!u(e[t]))throw new Error("Invalid TTL.");t+=1;for(let i=0;i<2&&a(e[t]);i++)t+=1;return t}consumeToken(e,t){return this.consumeOneOrMore(e,t,l)}consumeTime(e,t){let i=t;if("0"===e[i])return i+1;for(u(e[i])&&(i+=1);a(e[i]);)i++;if(i-t<10)throw new Error("Invalid time");return i}consumeAddress(e,t){return this.consumeTill(e,t,o)}consumeTypedTime(e,t){let i=t;return i=this.consumeOneOrMore(e,i,a),p(e[i])?i+1:i}consumeRepeatInterval(e,t){if(!u(e[t]))throw new Error("Invalid repeat interval");for(t+=1;a(e[t]);)t+=1;return p(e[t])&&(t+=1),t}consumePort(e,t){return this.consumeOneOrMore(e,t,a)}consume(e,t,i){for(let n=0;n<i.length;n++){if(t+n>=e.length)throw new Error("consume exceeding value length");if(e[t+n]!==i[n])throw new Error("consume ".concat(i," failed at ").concat(n))}return t+i.length}consumeTill(e,t,i){let n=t;for(;n<e.length&&("string"!=typeof i||e[n]!==i)&&("function"!=typeof i||!i(e[n]));)n++;return n}}class v extends R{constructor(){super(),g(this,"records",[]),g(this,"currentLine",0)}parse(e){const t=this.probeEOL(e);this.records=e.split(t).filter((e=>!!OT(e).call(e))).map(this.parseLine),this.currentLine=0;const i=this.parseVersion(),n=this.parseOrigin(),r=this.parseSessionName(),o=this.parseInformation(),s=this.parseUri(),a=this.parseEmail(),c=this.parsePhone(),d=this.parseConnection(),l=this.parseBandWidth(),u=this.parseTimeFields(),h=this.parseKey(),p=this.parseSessionAttribute(),_=this.parseMediaDescription();if(this.currentLine!==this.records.length)throw new Error("parsing failed, non exhaustive sdp lines.");return{version:i,origin:n,sessionName:r,information:o,uri:s,emails:a,phones:c,connection:d,bandwidths:l,timeFields:u,key:h,attributes:p,mediaDescriptions:_}}getCurrentRecord(){const e=this.records[this.currentLine];if(!e)throw new Error("Record doesn't exit.");return e}probeEOL(e){for(let t=0;t<e.length;t++)if(e[t]===n)return"\r"===e[t-1]?r:n;throw new Error("Invalid newline character.")}parseLine(e,t){if(e.length<2)throw new Error("Invalid sdp line, sdp line should be of form <type>=<value>.");const i=e[0];if("="!==e[1])throw new Error('Invalid sdp line, <type> should be a single character followed by an "=" sign.');return{type:i,value:e.slice(2),line:t,cur:0}}parseSessionAttribute(){const e=new I;for(;this.currentLine<this.records.length;){const t=this.getCurrentRecord();if(t.type!==s.ATTRIBUTE)break;const i={attField:this.extractOneOrMore(t,(e=>l(e)&&":"!==e)),_cur:0};":"===t.value[t.cur]&&(t.cur+=1,i.attValue=this.extractOneOrMore(t,_)),e.parse(i),this.currentLine++}return e.digest()}parseMediaAttributes(e){const t=new y(e);for(;this.currentLine<this.records.length;){const e=this.getCurrentRecord();if(e.type!==s.ATTRIBUTE)break;const i={attField:this.extractOneOrMore(e,(e=>l(e)&&":"!==e)),_cur:0};":"===e.value[e.cur]&&(e.cur+=1,i.attValue=this.extractOneOrMore(e,_)),t.parse(i),this.currentLine++}return t.digest()}parseKey(){const e=this.getCurrentRecord();if(e.type===s.KEY){if("prompt"===e.value||"clear:"===e.value||"base64:"===e.value||"uri:"===e.value)return e.value;throw this.currentLine++,new Error("Invalid key.")}}parseZone(){const e=this.getCurrentRecord();if(e.type===s.ZONE_ADJUSTMENTS){const t=[];for(;;)try{const i=this.extract(e,this.consumeTime);this.consumeSpaceForRecord(e);let n=!1;"-"===e.value[e.cur]&&(n=!0,e.cur+=1);const r=this.extract(e,this.consumeTypedTime);t.push({time:i,typedTime:r,back:n})}catch(e){break}if(0===t.length)throw new Error("Invalid zone adjustments");return this.currentLine++,t}return[]}parseRepeat(){const e=[];for(;;){const t=this.getCurrentRecord();if(t.type!==s.REPEAT)break;{const i=this.extract(t,this.consumeRepeatInterval),n=this.parseTypedTime(t);e.push({repeatInterval:i,typedTimes:n}),this.currentLine++}}return e}parseTypedTime(e){const t=[];for(;;)try{this.consumeSpaceForRecord(e),t.push(this.extract(e,this.consumeTypedTime))}catch(e){break}if(0===t.length)throw new Error("Invalid typed time.");return t}parseTime(){const e=this.getCurrentRecord(),t=this.extract(e,this.consumeTime);this.consumeSpaceForRecord(e);const i=this.extract(e,this.consumeTime);return this.currentLine++,{startTime:t,stopTime:i}}parseBandWidth(){const e=[];for(;this.currentLine<this.records.length;){const t=this.getCurrentRecord();if(t.type!==s.BANDWIDTH)break;{const i=this.extractOneOrMore(t,l);if(":"!==t.value[t.cur])throw new Error("Invalid bandwidth field.");t.cur++;const n=this.extractOneOrMore(t,a);e.push({bwtype:i,bandwidth:n}),this.currentLine++}}return e}parseVersion(){const e=this.getCurrentRecord();if(e.type!==s.VERSION)throw new Error("first sdp record must be version");const t=e.value.slice(0,this.consumeOneOrMore(e.value,0,a));if(t.length!==e.value.length)throw new Error('invalid proto version, "v='.concat(e.value,'"'));return this.currentLine++,t}parseOrigin(){const e=this.getCurrentRecord();if(e.type!==s.ORIGIN)throw new Error("second line of sdp must be origin");const t=this.extractOneOrMore(e,d);this.consumeSpaceForRecord(e);const i=this.extractOneOrMore(e,a);this.consumeSpaceForRecord(e);const n=this.extractOneOrMore(e,a);this.consumeSpaceForRecord(e);const r=this.extractOneOrMore(e,l);this.consumeSpaceForRecord(e);const o=this.extractOneOrMore(e,l);this.consumeSpaceForRecord(e);const c=this.extract(e,this.consumeUnicastAddress);return this.currentLine++,{username:t,sessId:i,sessVersion:n,nettype:r,addrtype:o,unicastAddress:c}}parseSessionName(){const e=this.getCurrentRecord();if(e.type===s.SESSION_NAME){const t=this.extract(e,this.consumeText);return this.currentLine++,t}}parseInformation(){const e=this.getCurrentRecord();if(e.type!==s.INFORMATION)return;const t=this.extract(e,this.consumeText);return this.currentLine++,t}parseUri(){const e=this.getCurrentRecord();if(e.type===s.URI)return this.currentLine++,e.value}parseEmail(){const e=[];for(;;){const t=this.getCurrentRecord();if(t.type!==s.EMAIL)break;e.push(t.value),this.currentLine++}return e}parsePhone(){const e=[];for(;;){const t=this.getCurrentRecord();if(t.type!==s.PHONE)break;e.push(t.value),this.currentLine++}return e}parseConnection(){const e=this.getCurrentRecord();if(e.type===s.CONNECTION){const t=this.extractOneOrMore(e,l);this.consumeSpaceForRecord(e);const i=this.extractOneOrMore(e,l);this.consumeSpaceForRecord(e);const n=this.extract(e,this.consumeAddress);return this.currentLine++,{nettype:t,addrtype:i,address:n}}}parseMedia(){const e=this.getCurrentRecord(),t=this.extract(e,this.consumeToken);this.consumeSpaceForRecord(e);let i=this.extract(e,this.consumePort);"/"===e.value[e.cur]&&(e.cur+=1,i+=this.extract(e,this.consumeInteger)),this.consumeSpaceForRecord(e);const n=[];for(n.push(this.extract(e,this.consumeToken));"/"===e.value[e.cur];)e.cur+=1,n.push(this.extract(e,this.consumeToken));if(0===n.length)throw new Error("Invalid proto");const r=this.parseFmt(e);return this.currentLine++,{mediaType:t,port:i,protos:n,fmts:r}}parseTimeFields(){const e=[];for(;this.getCurrentRecord().type===s.TIME;){const t=this.parseTime(),i=this.parseRepeat(),n=this.parseZone();e.push({time:t,repeats:i,zones:n})}return e}parseMediaDescription(){const e=[];for(;this.currentLine<this.records.length&&this.getCurrentRecord().type===s.MEDIA;){const t=this.parseMedia(),i=this.parseInformation(),n=this.parseConnections(),r=this.parseBandWidth(),o=this.parseKey(),s=this.parseMediaAttributes(t);e.push({media:t,information:i,connections:n,bandwidths:r,key:o,attributes:s})}return e}parseConnections(){const e=[];for(;this.currentLine<this.records.length&&this.getCurrentRecord().type===s.CONNECTION;)e.push(this.parseConnection());return e}parseFmt(e){const t=[];for(;;)try{this.consumeSpaceForRecord(e),t.push(this.extract(e,this.consumeToken))}catch(e){break}if(0===t.length)throw new Error("Invalid fmts");return t}extract(e,t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];const o=t.call(this,e.value,e.cur,...n),s=e.value.slice(e.cur,o);return e.cur=o,s}extractOneOrMore(e,t){const i=this.consumeOneOrMore(e.value,e.cur,t),n=e.value.slice(e.cur,i);return e.cur=i,n}consumeSpaceForRecord(e){if(e.value[e.cur]!==o)throw new Error("Invalid space at ".concat(e.cur,"."));e.cur+=1}}class C extends R{constructor(){super(...arguments),g(this,"attributes",void 0),g(this,"digested",!1)}extractOneOrMore(e,t,i){const n=this.consumeOneOrMore(e.attValue,e._cur,t),r=e.attValue.slice(e._cur,n),[o,s]=i||[];if("number"==typeof o&&r.length<o)throw new Error("error in length, should be more or equal than ".concat(o," characters."));if("number"==typeof s&&r.length>s)throw new Error("error in length, should be less or equal than ".concat(s," characters."));return e._cur=n,r}consumeAttributeSpace(e){if(e.attValue[e._cur]!==o)throw new Error("Invalid space at ".concat(e._cur,"."));e._cur+=1}extract(e,t){if(!e.attValue)throw new Error("Nothing to extract from attValue.");for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];const o=t.call(this,e.attValue,e._cur,...n),s=e.attValue.slice(e._cur,o);return e._cur=o,s}atEnd(e){if(!e.attValue)throw new Error;return e._cur>=e.attValue.length}peekChar(e){if(!e.attValue)throw new Error;return e.attValue[e._cur]}peek(e,t){if(!e.attValue)throw new Error;for(let i=0;i<t.length;i++)if(t[i]!==e.attValue[e._cur+i])return!1;return!0}parseIceUfrag(e){if(this.attributes.iceUfrag)throw new Error("Invalid ice-ufrag, should be only a single line if 'a=ice-ufrag'");this.attributes.iceUfrag=this.extractOneOrMore(e,E,[4,256])}parseIcePwd(e){if(this.attributes.icePwd)throw new Error("Invalid ice-pwd, should be only a single line if 'a=ice-pwd'");this.attributes.icePwd=this.extractOneOrMore(e,E,[22,256])}parseIceOptions(e){if(this.attributes.iceOptions)throw new Error("Invalid ice-options, should be only one 'ice-options' line");const t=[];for(;!this.atEnd(e);){t.push(this.extractOneOrMore(e,E));try{this.consumeAttributeSpace(e)}catch(t){if(this.atEnd(e))break;throw t}}this.attributes.iceOptions=t}parseFingerprint(e){const t=this.extract(e,this.consumeToken);this.consumeAttributeSpace(e);const i=this.extract(e,this.consumeTill);this.attributes.fingerprints.push({hashFunction:t,fingerprint:i})}parseExtmap(e){const t=this.extractOneOrMore(e,a);let i;"/"===this.peekChar(e)&&(this.extract(e,this.consume,"/"),i=this.extract(e,this.consumeToken)),this.consumeAttributeSpace(e);const n=this.extract(e,this.consumeTill,o),r=S(S({entry:parseInt(t,10)},i&&{direction:i}),{},{extensionName:n});this.peekChar(e)===o&&(this.consumeAttributeSpace(e),r.extensionAttributes=this.extract(e,this.consumeTill)),this.attributes.extmaps.push(r)}parseSetup(e){if(this.attributes.setup)throw new Error("must only be one single 'a=setup' line.");const t=this.extract(e,this.consumeTill);if("active"!==t&&"passive"!==t&&"actpass"!==t&&"holdconn"!==t)throw new Error("role must be one of 'active', 'passive', 'actpass', 'holdconn'.");this.attributes.setup=t}}class I extends C{constructor(){super(...arguments),g(this,"attributes",{unrecognized:[],groups:[],extmaps:[],fingerprints:[],identities:[]})}parse(e){if(this.digested)throw new Error("already digested");try{switch(e.attField){case"group":this.parseGroup(e);break;case"ice-lite":this.parseIceLite();break;case"ice-ufrag":this.parseIceUfrag(e);break;case"ice-pwd":this.parseIcePwd(e);break;case"ice-options":this.parseIceOptions(e);break;case"fingerprint":this.parseFingerprint(e);break;case"setup":this.parseSetup(e);break;case"tls-id":this.parseTlsId(e);break;case"identity":this.parseIdentity(e);break;case"extmap":this.parseExtmap(e);break;case"msid-semantic":this.parseMsidSemantic(e);break;default:e.ignored=!0,this.attributes.unrecognized.push(e)}}catch(t){throw console.error("parsing session attribute ".concat(e.attField,' error, "a=').concat(e.attField,":").concat(e.attValue,'"')),t}if(!e.ignored&&e.attValue&&!this.atEnd(e))throw new Error("attribute parsing error")}digest(){return this.digested=!0,this.attributes}parseGroup(e){const t=this.extract(e,this.consumeToken),i=[];for(;!this.atEnd(e)&&this.peekChar(e)===o;)this.consumeAttributeSpace(e),i.push(this.extract(e,this.consumeToken));this.attributes.groups.push({semantic:t,identificationTag:i})}parseIceLite(){if(this.attributes.iceLite)throw new Error("Invalid ice-lite, should be only a single line of 'a=ice-lite'");this.attributes.iceLite=!0}parseTlsId(e){if(this.attributes.tlsId)throw new Error("must be only one tld-id line");this.attributes.tlsId=this.extractOneOrMore(e,m)}parseIdentity(e){const t=this.extractOneOrMore(e,f),i=[];for(;!this.atEnd(e)&&this.peekChar(e)===o;){this.consumeAttributeSpace(e);const t=this.extract(e,this.consumeToken);this.extract(e,this.consume,"=");const n=this.extractOneOrMore(e,(e=>e!==o&&_(e)));i.push({name:t,value:n})}this.attributes.identities.push({assertionValue:t,extensions:i})}parseMsidSemantic(e){this.peekChar(e)===o&&this.consumeAttributeSpace(e);const t={semantic:this.extract(e,this.consumeToken),identifierList:[]};for(;;){try{this.consumeAttributeSpace(e)}catch(e){break}if("*"===this.peekChar(e)){this.extract(e,this.consume,"*"),t.applyForAll=!0;break}{const i=this.extract(e,this.consumeTill,o);t.identifierList.push(i)}}this.attributes.msidSemantic=t}}class y extends C{constructor(e){super(),g(this,"attributes",void 0),-1!==e.protos.indexOf("RTP")||e.protos.indexOf("rtp"),this.attributes={unrecognized:[],candidates:[],extmaps:[],fingerprints:[],imageattr:[],msids:[],remoteCandidatesList:[],rids:[],ssrcs:[],ssrcGroups:[],rtcpFeedbackWildcards:[],payloads:[]}}parse(e){if(this.digested)throw new Error("already digested");try{switch(e.attField){case"extmap":this.parseExtmap(e);break;case"setup":this.parseSetup(e);break;case"ice-ufrag":this.parseIceUfrag(e);break;case"ice-pwd":this.parseIcePwd(e);break;case"ice-options":this.parseIceOptions(e);break;case"candidate":this.parseCandidate(e);break;case"remote-candidate":this.parseRemoteCandidate(e);break;case"end-of-candidates":this.parseEndOfCandidates();break;case"fingerprint":this.parseFingerprint(e);break;case"rtpmap":this.parseRtpmap(e);break;case"ptime":this.parsePtime(e);break;case"maxptime":this.parseMaxPtime(e);break;case"sendrecv":case"recvonly":case"sendonly":case"inactive":this.parseDirection(e);break;case"ssrc":this.parseSSRC(e);break;case"fmtp":this.parseFmtp(e);break;case"rtcp-fb":this.parseRtcpFb(e);break;case"rtcp-mux":this.parseRTCPMux();break;case"rtcp-mux-only":this.parseRTCPMuxOnly();break;case"rtcp-rsize":this.parseRTCPRsize();break;case"rtcp":this.parseRTCP(e);break;case"mid":this.parseMid(e);break;case"msid":this.parseMsid(e);break;case"imageattr":this.parseImageAttr(e);break;case"rid":this.parseRid(e);break;case"simulcast":this.parseSimulcast(e);break;case"sctp-port":this.parseSctpPort(e);break;case"max-message-size":this.parseMaxMessageSize(e);break;case"ssrc-group":this.parseSSRCGroup(e);break;default:e.ignored=!0,this.attributes.unrecognized.push(e)}}catch(t){throw console.error("parsing media attribute ".concat(e.attField,' error, "a=').concat(e.attField,":").concat(e.attValue,'"')),t}if(!e.ignored&&e.attValue&&!this.atEnd(e))throw new Error("attribute parsing error")}parseCandidate(e){const t=this.extractOneOrMore(e,E,[1,32]);this.consumeAttributeSpace(e);const i=this.extractOneOrMore(e,a,[1,5]);this.consumeAttributeSpace(e);const n=this.extract(e,this.consumeToken);this.consumeAttributeSpace(e);const r=this.extractOneOrMore(e,a,[1,10]);this.consumeAttributeSpace(e);const s=this.extract(e,this.consumeAddress);this.consumeAttributeSpace(e);const d=this.extract(e,this.consumePort);this.consumeAttributeSpace(e),this.extract(e,this.consume,"typ"),this.consumeAttributeSpace(e);const l={foundation:t,componentId:i,transport:n,priority:r,connectionAddress:s,port:d,type:this.extract(e,this.consumeToken),extension:{}};for(this.peek(e," raddr")&&(this.extract(e,this.consume," raddr"),this.consumeAttributeSpace(e),l.relAddr=this.extract(e,this.consumeAddress)),this.peek(e," rport")&&(this.extract(e,this.consume," rport"),this.consumeAttributeSpace(e),l.relPort=this.extract(e,this.consumePort));this.peekChar(e)===o;){this.consumeAttributeSpace(e);const t=this.extract(e,this.consumeToken);this.consumeAttributeSpace(e),l.extension[t]=this.extractOneOrMore(e,c)}this.attributes.candidates.push(l)}parseRemoteCandidate(e){const t=[];for(;;){const i=this.extractOneOrMore(e,a,[1,5]);this.consumeAttributeSpace(e);const n=this.extract(e,this.consumeAddress);this.consumeAttributeSpace(e);const r=this.extract(e,this.consumePort);t.push({componentId:i,connectionAddress:n,port:r});try{this.consumeAttributeSpace(e)}catch(e){break}}this.attributes.remoteCandidatesList.push(t)}parseEndOfCandidates(){if(this.attributes.endOfCandidates)throw new Error("must be only one line of end-of-candidates");this.attributes.endOfCandidates=!0}parseRtpmap(e){const t=this.extract(e,this.consumeToken);this.consumeAttributeSpace(e);const i=this.extract(e,this.consumeTill,"/");this.extract(e,this.consume,"/");const n={encodingName:i,clockRate:this.extractOneOrMore(e,a)};this.atEnd(e)||"/"!==this.peekChar(e)||(this.extract(e,this.consume,"/"),n.encodingParameters=parseInt(this.extract(e,this.consumeTill),10));const r=this.attributes.payloads.find((e=>e.payloadType===parseInt(t,10)));r?r.rtpMap=n:this.attributes.payloads.push({payloadType:parseInt(t,10),rtpMap:n,rtcpFeedbacks:[]})}parsePtime(e){if(this.attributes.ptime)throw new Error("must be only one line of ptime");this.attributes.ptime=this.extract(e,this.consumeTill)}parseMaxPtime(e){if(this.attributes.maxPtime)throw new Error("must be only one line of ptime");this.attributes.maxPtime=this.extract(e,this.consumeTill)}parseDirection(e){if(this.attributes.direction)throw new Error("must be only one line of direction info");this.attributes.direction=e.attField}parseSSRC(e){const t=this.extractOneOrMore(e,a);this.consumeAttributeSpace(e);const i=this.extract(e,this.consumeTill,":");let n;":"===this.peekChar(e)&&(this.extract(e,this.consume,":"),n=this.extract(e,this.consumeTill));const r=this.attributes.ssrcs.find((e=>e.ssrcId===parseInt(t,10)));r?r.attributes[i]=n:this.attributes.ssrcs.push({ssrcId:parseInt(t,10),attributes:{[i]:n}})}parseFmtp(e){const t=this.extract(e,this.consumeTill,o);this.consumeAttributeSpace(e);const i=this.extract(e,this.consumeTill),n={};i.split(";").forEach((e=>{let[t,i]=e.split("=");t=OT(t).call(t);const r="string"==typeof i?OT(i).call(i):null;"string"==typeof t&&t.length>0&&(n[t]=r)}));const r=this.attributes.payloads.find((e=>e.payloadType===parseInt(t,10)));r?r.fmtp={parameters:n}:this.attributes.payloads.push({payloadType:parseInt(t,10),rtcpFeedbacks:[],fmtp:{parameters:n}})}parseFmtParameters(e){const t={},i=this.extract(e,this.consumeTill,"=");e._cur++;const n=this.extract(e,this.consumeTill,";");for(t[i]=n;";"===e.attValue[e._cur];){const i=this.extract(e,this.consumeTill,"=");e._cur++;const n=this.extract(e,this.consumeTill,";");t[i]=n}return t}parseRtcpFb(e){let t="";t="*"===this.peekChar(e)?this.extract(e,this.consume,"*"):this.extract(e,this.consumeTill,o),this.consumeAttributeSpace(e);const i=this.extract(e,this.consumeTill,o);let n;if("trr-int"===i)n={type:i,interval:this.extract(e,this.consumeTill)};else{const t={type:i};this.peekChar(e)===o&&(this.consumeAttributeSpace(e),t.parameter=this.extract(e,this.consumeToken),this.peekChar(e)===o&&(t.additional=this.extract(e,this.consumeTill))),n=t}if("*"===t)this.attributes.rtcpFeedbackWildcards.push(n);else{const e=this.attributes.payloads.find((e=>e.payloadType===parseInt(t,10)));e?e.rtcpFeedbacks.push(n):this.attributes.payloads.push({payloadType:parseInt(t,10),rtcpFeedbacks:[n]})}}parseRTCPMux(){if(this.attributes.rtcpMux)throw new Error("must be single line of rtcp-mux");this.attributes.rtcpMux=!0}parseRTCPMuxOnly(){if(this.attributes.rtcpMuxOnly)throw new Error("must be single line of rtcp-only");this.attributes.rtcpMuxOnly=!0}parseRTCPRsize(){if(this.attributes.rtcpRsize)throw new Error("must be single line of rtcp-rsize");this.attributes.rtcpRsize=!0}parseRTCP(e){if(this.attributes.rtcp)throw new Error("must be single line of rtcp");const t={port:this.extract(e,this.consumePort)};this.peekChar(e)===o&&(this.consumeAttributeSpace(e),t.netType=this.extractOneOrMore(e,l),this.consumeAttributeSpace(e),t.addressType=this.extractOneOrMore(e,l),this.consumeAttributeSpace(e),t.address=this.extract(e,this.consumeAddress)),this.attributes.rtcp=t}parseMsid(e){const t={id:this.extractOneOrMore(e,l,[1,64])};this.peekChar(e)===o&&(this.consumeAttributeSpace(e),t.appdata=this.extractOneOrMore(e,l,[1,64])),this.attributes.msids.push(t)}parseImageAttr(e){this.attributes.imageattr.push(e.attValue)}parseRid(e){const t=this.extractOneOrMore(e,(e=>h(e)||a(e)||"_"===e||"-"===e));this.consumeAttributeSpace(e);const i={id:t,direction:this.extract(e,this.consumeToken),params:[]};if(this.peekChar(e)===o){if(this.consumeAttributeSpace(e),this.peek(e,"pt=")){this.extract(e,this.consume,"pt=");const t=[];for(;;){const i=this.extract(e,this.consumeToken);t.push(i);try{this.extract(e,this.consume,",")}catch(e){break}}i.payloads=t,this.peekChar(e)===o&&this.extract(e,this.consume,o)}for(;;){const t=this.extract(e,this.consumeToken);switch(t){case"depend":{const n={type:t,rids:this.extract(e,this.consume,"=").split(",")};i.params.push(n);break}default:{const n={type:t};"="===this.peekChar(e)&&(this.extract(e,this.consume,"="),n.val=this.extract(e,this.consumeTill,";")),i.params.push(n)}}try{this.extract(e,this.consume,";")}catch(e){break}}}this.attributes.rids.push(i)}parseSimulcast(e){if(this.attributes.simulcast)throw new Error("must be single line of simulcast");this.attributes.simulcast=e.attValue,this.extract(e,this.consumeTill)}parseSctpPort(e){this.attributes.sctpPort=this.extractOneOrMore(e,a,[1,5])}parseMaxMessageSize(e){this.attributes.maxMessageSize=this.extractOneOrMore(e,a,[1,void 0])}digest(){return this.digested=!0,this.attributes}parseMid(e){this.attributes.mid=this.extract(e,this.consumeToken)}parseSSRCGroup(e){const t=this.extract(e,this.consumeToken),i=[];for(;;)try{this.consumeAttributeSpace(e);const t=this.extract(e,this.consumeInteger);i.push(parseInt(t,10))}catch(e){break}this.attributes.ssrcGroups.push({semantic:t,ssrcIds:i})}}function A(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class b{constructor(){A(this,"eol",r)}print(e,t){let i="";return t&&(this.eol=t),i+=this.printVersion(e.version),i+=this.printOrigin(e.origin),i+=this.printSessionName(e.sessionName),i+=this.printInformation(e.information),i+=this.printUri(e.uri),i+=this.printEmail(e.emails),i+=this.printPhone(e.phones),i+=this.printConnection(e.connection),i+=this.printBandwidth(e.bandwidths),i+=this.printTimeFields(e.timeFields),i+=this.printKey(e.key),i+=this.printSessionAttributes(e.attributes),i+=this.printMediaDescription(e.mediaDescriptions),i}printVersion(e){return"v=".concat(e).concat(this.eol)}printOrigin(e){return"o=".concat(e.username," ").concat(e.sessId," ").concat(e.sessVersion," ").concat(e.nettype," ").concat(e.addrtype," ").concat(e.unicastAddress).concat(this.eol)}printSessionName(e){return e?"s=".concat(e).concat(this.eol):""}printInformation(e){return e?"i=".concat(e).concat(this.eol):""}printUri(e){return e?"u=".concat(e).concat(this.eol):""}printEmail(e){let t="";for(const i of e)t+="e=".concat(i).concat(this.eol);return t}printPhone(e){let t="";for(const i of e)t+="e=".concat(i).concat(this.eol);return t}printConnection(e){return e?"c=".concat(e.nettype," ").concat(e.addrtype," ").concat(e.address).concat(this.eol):""}printBandwidth(e){let t="";for(const i of e)t+="b=".concat(i.bwtype,":").concat(i.bandwidth).concat(this.eol);return t}printTimeFields(e){let t="";for(const i of e){t+="t=".concat(i.time.startTime," ").concat(i.time.startTime).concat(this.eol);for(const e of i.repeats)t+="r=".concat(e.repeatInterval," ").concat(e.typedTimes.join(" ")).concat(this.eol);i.zoneAdjustments&&(t+="z=",t+="z=".concat(i.zoneAdjustments.map((e=>"".concat(e.time," ").concat(e.back?"-":""," ").concat(e.typedTime))).join(" ")).concat(this.eol),t+=this.eol)}return t}printKey(e){return e?"k=".concat(e).concat(this.eol):""}printAttributes(e){let t="";for(const i of e)t+="a=".concat(i.attField).concat(i.attValue?":".concat(i.attValue):"").concat(this.eol);return t}printMediaDescription(e){let t="";for(const i of e)t+=this.printMedia(i.media),t+=this.printInformation(i.information),t+=this.printConnections(i.connections),t+=this.printBandwidth(i.bandwidths),t+=this.printKey(i.key),t+=this.printMediaAttributes(i);return t}printConnections(e){let t="";for(const i of e)t+=this.printConnection(i);return t}printMedia(e){return"m=".concat(e.mediaType," ").concat(e.port," ").concat(e.protos.join("/")," ").concat(e.fmts.join(" ")).concat(this.eol)}printSessionAttributes(e){return new O(this.eol).print(e)}printMediaAttributes(e){return new N(this.eol).print(e)}}class w{constructor(e){A(this,"eol",void 0),this.eol=e}printIceUfrag(e){return void 0===e?"":"a=ice-ufrag:".concat(e).concat(this.eol)}printIcePwd(e){return void 0===e?"":"a=ice-pwd:".concat(e).concat(this.eol)}printIceOptions(e){return void 0===e?"":"a=ice-options:".concat(e.join(o)).concat(this.eol)}printFingerprints(e){return e.length>0?e.map((e=>"a=fingerprint:".concat(e.hashFunction).concat(o).concat(e.fingerprint))).join(this.eol)+this.eol:""}printExtmap(e){return e.map((e=>"a=extmap:".concat(e.entry).concat(e.direction?"/".concat(e.direction):"").concat(o).concat(e.extensionName).concat(e.extensionAttributes?"".concat(o).concat(e.extensionAttributes):"").concat(this.eol))).join("")}printSetup(e){return void 0===e?"":"a=setup:".concat(e).concat(this.eol)}printUnrecognized(e){return e.map((e=>"a=".concat(e.attField).concat(e.attValue?":".concat(e.attValue):"").concat(this.eol))).join("")}}class O extends w{print(e){let t="";return t+=this.printGroups(e.groups),t+=this.printMsidSemantic(e.msidSemantic),t+=this.printIceLite(e.iceLite),t+=this.printIceUfrag(e.iceUfrag),t+=this.printIcePwd(e.icePwd),t+=this.printIceOptions(e.iceOptions),t+=this.printFingerprints(e.fingerprints),t+=this.printSetup(e.setup),t+=this.printTlsId(e.tlsId),t+=this.printIdentity(e.identities),t+=this.printExtmap(e.extmaps),t+=this.printUnrecognized(e.unrecognized),t}printGroups(e){let t="";return e.length>0&&(t+=e.map((e=>"a=group:".concat(e.semantic).concat(e.identificationTag.map((e=>"".concat(o).concat(e))).join("")).concat(this.eol))).join("")),t}printIceLite(e){return void 0===e?"":"a=ice-lite"+this.eol}printTlsId(e){return e?"a=tls-id:".concat(e).concat(this.eol):""}printIdentity(e){return 0===e.length?"":e.map((e=>"a=identity:".concat(e.assertionValue).concat(e.extensions.map((e=>"".concat(o).concat(e.name).concat(e.value?"=".concat(e.value):"")))))).join(this.eol)+this.eol}printMsidSemantic(e){if(!e)return"";let t="a=msid-semantic:".concat(e.semantic);return e.applyForAll?t+="".concat(o,"*"):e.identifierList.length>0&&(t+=e.identifierList.map((e=>"".concat(o).concat(e)))),t+this.eol}}class N extends w{print(e){const t=e.attributes;let i="";return i+=this.printRTCP(t.rtcp),i+=this.printIceUfrag(t.iceUfrag),i+=this.printIcePwd(t.icePwd),i+=this.printIceOptions(t.iceOptions),i+=this.printCandidates(t.candidates),i+=this.printRemoteCandidatesList(t.remoteCandidatesList),i+=this.printEndOfCandidates(t.endOfCandidates),i+=this.printFingerprints(t.fingerprints),i+=this.printSetup(t.setup),i+=this.printMid(t.mid),i+=this.printExtmap(t.extmaps),i+=this.printRTPRelated(t),i+=this.printPtime(t.ptime),i+=this.printMaxPtime(t.maxPtime),i+=this.printDirection(t.direction),i+=this.printSSRCGroups(t.ssrcGroups),i+=this.printSSRC(t.ssrcs),i+=this.printRTCPMux(t.rtcpMux),i+=this.printRTCPMuxOnly(t.rtcpMuxOnly),i+=this.printRTCPRsize(t.rtcpRsize),i+=this.printMSId(t.msids),i+=this.printImageattr(t.imageattr),i+=this.printRid(t.rids),i+=this.printSimulcast(t.simulcast),i+=this.printSCTPPort(t.sctpPort),i+=this.printMaxMessageSize(t.maxMessageSize),i+=this.printUnrecognized(t.unrecognized),i}printCandidates(e){return e.map((e=>"a=candidate:".concat(e.foundation).concat(o).concat(e.componentId).concat(o).concat(e.transport).concat(o).concat(e.priority).concat(o).concat(e.connectionAddress).concat(o).concat(e.port).concat(o,"typ").concat(o).concat(e.type).concat(e.relAddr?"".concat(o,"raddr").concat(o).concat(e.relAddr):"").concat(e.relPort?"".concat(o,"rport").concat(o).concat(e.relPort):"").concat(Object.keys(e.extension).map((t=>"".concat(o).concat(t).concat(o).concat(e.extension[t]))).join("")).concat(this.eol))).join("")}printRemoteCandidatesList(e){return e.map((e=>"a=remote-candidates:".concat(e.join(o)).concat(this.eol))).join("")}printEndOfCandidates(e){return void 0===e?"":"a=end-of-candidates"+this.eol}printRTPRelated(e){if(!e.payloads)return"";const t=e.payloads;let i="";i+=e.rtcpFeedbackWildcards.map((e=>this.printRTCPFeedback("*",e))).join("");for(const e of t)i+=this.printRtpMap(e.payloadType,e.rtpMap),i+=this.printFmtp(e.payloadType,e.fmtp),i+=e.rtcpFeedbacks.map((t=>this.printRTCPFeedback(e.payloadType,t))).join("");return i}printFmtp(e,t){if(!t)return"";const i=Object.keys(t.parameters);return 1===i.length&&null===t.parameters[i[0]]?"a=fmtp:".concat(e).concat(o).concat(i[0]).concat(this.eol):"a=fmtp:".concat(e).concat(o).concat(Object.keys(t.parameters).map((e=>"".concat(e,"=").concat(t.parameters[e]))).join(";")).concat(this.eol)}printRtpMap(e,t){return t?"a=rtpmap:".concat(e).concat(o).concat(t.encodingName,"/").concat(t.clockRate).concat(t.encodingParameters?"/".concat(t.encodingParameters):"").concat(this.eol):""}printRTCPFeedback(e,t){let i="a=rtcp-fb:".concat(e).concat(o),n=t;return"trr-int"===n.type?i+="ttr-int".concat(o).concat(n.interval):(i+="".concat(n.type),n.parameter&&(i+="".concat(o).concat(n.parameter),n.additional&&(i+="".concat(o).concat(n.additional)))),i+this.eol}printPtime(e){return void 0===e?"":"a=ptime:".concat(e).concat(this.eol)}printMaxPtime(e){return void 0===e?"":"a=maxptime:".concat(e).concat(this.eol)}printDirection(e){return void 0===e?"":"a=".concat(e).concat(this.eol)}printSSRC(e){return e.map((e=>Object.keys(e.attributes).map((t=>"a=ssrc:".concat(e.ssrcId.toString(10)).concat(o).concat(t).concat(e.attributes[t]?":".concat(e.attributes[t]):"").concat(this.eol))).join(""))).join("")}printRTCPMux(e){return void 0===e?"":"a=rtcp-mux".concat(this.eol)}printRTCPMuxOnly(e){return void 0===e?"":"a=rtcp-mux-only".concat(this.eol)}printRTCPRsize(e){return void 0===e?"":"a=rtcp-rsize".concat(this.eol)}printRTCP(e){if(void 0===e)return"";let t="a=rtcp:".concat(e.port);return e.netType&&(t+="".concat(o).concat(e.netType)),e.addressType&&(t+="".concat(o).concat(e.addressType)),e.address&&(t+="".concat(o).concat(e.address)),t+this.eol}printMSId(e){return e.map((e=>"a=msid:".concat(e.id).concat(e.appdata?"".concat(o).concat(e.appdata):"").concat(this.eol))).join("")}printImageattr(e){return e.map((e=>"a=imageattr:".concat(e).concat(this.eol))).join("")}printRid(e){return e.map((e=>{let t="a=rid:".concat(e.id).concat(o).concat(e.direction);return e.payloads&&(t+="".concat(o,"pt=").concat(e.payloads.join(","))),e.params.length>0&&(t+="".concat(o).concat(e.params.map((e=>"depend"===e.type?"depend=".concat(e.rids.join(",")):"".concat(e.type,"=").concat(e.val))).join(";"))),t+this.eol})).join("")}printSimulcast(e){return void 0===e?"":"a=simulcast:".concat(e).concat(this.eol)}printSCTPPort(e){return void 0===e?"":"a=sctp-port:".concat(e).concat(this.eol)}printMaxMessageSize(e){return void 0===e?"":"a=max-message-size:".concat(e).concat(this.eol)}printMid(e){return void 0===e?"":"a=mid:".concat(e).concat(this.eol)}printSSRCGroups(e){return e.map((e=>"a=ssrc-group:".concat(e.semantic).concat(e.ssrcIds.map((e=>"".concat(o).concat(e.toString(10)))).join("")).concat(this.eol))).join("")}}function D(e){return(new v).parse(e)}function P(e,t){return(new b).print(e,t)}}},t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={exports:{}};return e[n](r,r.exports,i),r.exports}return i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i(8)})();function yN(e){return IN.parse(e)}function AN(e,t){return IN.print(e,t)}var bN=Ji("Array").keys,wN=pn,ON=Ze,NN=l,DN=bN,PN=Array.prototype,LN={DOMTokenList:!0,NodeList:!0},kN=function(e){var t=e.keys;return e===PN||NN(PN,e)&&t===PN.keys||ON(LN,wN(e))?DN:t},MN=i(kN);function UN(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function xN(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?UN(Object(i),!0).forEach((function(t){VN(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):UN(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function VN(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const FN=new class extends Dw{constructor(){super(...arguments),VN(this,"currentUploadLogID",0)}reportLogUploadError(e){const{errorRange:t}=e;t[t.length-1]&&t[t.length-1]>this.currentUploadLogID&&(this.currentUploadLogID=t[t.length-1],this.emit("REPORT_LOG_UPLOAD",e))}};class BN{constructor(e){VN(this,"logger",void 0),VN(this,"prefixLists",[]),this.logger=e}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.logger.debug(...this.prefixLists,...t)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.logger.info(...this.prefixLists,...t)}warning(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.logger.warning(...this.prefixLists,...t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.logger.error(...this.prefixLists,...t)}prefix(e){return this.prefixLists.push(e),this}popPrefix(){return this.prefixLists.pop(),this}}function jN(){const e=new Date;return e.toTimeString().split(" ")[0]+":"+e.getMilliseconds()}function GN(){const e=new Date,t=/((\d+:){2}\d+)/.exec((new Date).toUTCString());return t?(null==t?void 0:t[0])+":"+e.getUTCMilliseconds():e.toTimeString().split(" ")[0]+":"+e.getMilliseconds()}const WN={DEBUG:0,INFO:1,WARNING:2,ERROR:3,NONE:4},HN=Date.now(),KN=e=>{for(const t in WN)if(Object.prototype.hasOwnProperty.call(WN,t)&&WN[t]===e)return t;return"DEFAULT"};const YN=new class{constructor(){VN(this,"proxyServerURL",void 0),VN(this,"logLevel",WN.DEBUG),VN(this,"uploadState","collecting"),VN(this,"uploadLogWaitingList",[]),VN(this,"uploadLogUploadingList",[]),VN(this,"uploadErrorCount",0),VN(this,"currentLogID",0),VN(this,"url",void 0),VN(this,"extLog",((e,t)=>{this.appendLogToWaitingList(e,...t)}))}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const n=[WN.DEBUG].concat(t);this.log.apply(this,n)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const n=[WN.INFO].concat(t);this.log.apply(this,n)}warning(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const n=[WN.WARNING].concat(t);this.log.apply(this,n)}warn(){this.warning(...arguments)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const n=[WN.ERROR].concat(t);this.log.apply(this,n)}upload(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const n=[WN.DEBUG].concat(t);this.uploadLog.apply(this,n)}setLogLevel(e){e=Math.min(Math.max(0,e),4),this.logLevel=e}enableLogUpload(){pN("UPLOAD_LOG",!0)}disableLogUpload(){pN("UPLOAD_LOG",!1),this.uploadLogUploadingList=[],this.uploadLogWaitingList=[]}setProxyServer(e){this.proxyServerURL=e}prefix(e){return new BN(this).prefix(e)}log(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(Date.now()-HN<100)return void setTimeout((()=>{this.log(...t)}),Date.now()-HN);const n=Math.max(0,Math.min(4,t[0]));if(t[0]=jN()+" Agora-SDK [".concat(KN(n),"]:"),this.appendLogToWaitingList(n,...t),n<this.logLevel)return;const r=jN()+" %cAgora-SDK [".concat(KN(n),"]:");let o=[];if(!_N("USE_NEW_LOG"))switch(n){case WN.DEBUG:o=[r,"color: #64B5F6;"].concat(t.slice(1)),console.log.apply(console,o);break;case WN.INFO:o=[r,"color: #1E88E5; font-weight: bold;"].concat(t.slice(1)),console.log.apply(console,o);break;case WN.WARNING:o=[r,"color: #FB8C00; font-weight: bold;"].concat(t.slice(1)),console.warn.apply(console,o);break;case WN.ERROR:o=[r,"color: #B00020; font-weight: bold;"].concat(t.slice(1)),console.error.apply(console,o)}}uploadLog(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];if(Date.now()-HN<100)return void setTimeout((()=>{this.uploadLog(...t)}),Date.now()-HN);const n=Math.max(0,Math.min(4,t[0]));t[0]=jN()+" Agora-SDK [".concat(KN(n),"]:"),this.appendLogToWaitingList(n,...t)}appendLogToWaitingList(e){if(!_N("UPLOAD_LOG"))return;for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];Array.isArray(i[0])?i[0][0]=GN()+" Agora-SDK [".concat(KN(e),"]:"):i[0]=GN()+" Agora-SDK [".concat(KN(e),"]:");let r="";i.forEach((e=>{"object"==typeof e&&(e=JSON.stringify(e)),r+="".concat(e," ")})),this.uploadLogWaitingList.push({payload_str:r,log_level:e,log_item_id:this.currentLogID++}),"uploading"===this.uploadState&&0===this.uploadLogUploadingList.length&&this.uploadLogInterval()}startUpload(){this.uploadState="uploading",0===this.uploadLogUploadingList.length&&this.uploadLogInterval()}async uploadLogs(){const e=this.uploadLogUploadingList,t={sdk_version:rN,process_id:_N("PROCESS_ID"),payload:JSON.stringify(e)};return wO((async()=>{const e=await Ab.post(this.url||(this.proxyServerURL?"https://".concat(this.proxyServerURL,"/ls/?h=").concat(_N("LOG_UPLOAD_SERVER"),"&p=443&d=upload/v1"):"https://".concat(_N("LOG_UPLOAD_SERVER"),"/upload/v1")),t,{responseType:"text"});if("OK"!==e.data){const t=new Error("unexpected upload log response");throw t.response=e,t}}),(()=>(this.uploadLogUploadingList=[],!1)),(t=>{const i={status:-1,message:t.message,errorRange:e.map((e=>e.log_item_id))};return t.response?(i.status=t.response.status,i.data=t.response.data,i.headers=t.response.headers):t.request&&(i.status=t.request.status),FN.reportLogUploadError(i),!0}),{timeout:_N("UPLOAD_LOG_REQUEST_RETRY_INTERVAL"),maxRetryTimeout:_N("UPLOAD_LOG_REQUEST_MAX_RETRY_INTERVAL")})}uploadLogInterval(){0===this.uploadLogUploadingList.length&&0===this.uploadLogWaitingList.length||(0===this.uploadLogUploadingList.length&&(this.uploadLogUploadingList=this.uploadLogWaitingList.splice(0,_N("UPLOAD_LOG_LENGTH_EACH_TIME"))),this.uploadLogs().then((()=>{this.uploadErrorCount=0,this.uploadLogWaitingList.length>0&&window.setTimeout((()=>this.uploadLogInterval()),_N("UPLOAD_LOG_INTERVAL"))})).catch((e=>{this.uploadErrorCount+=1,this.uploadErrorCount<2?window.setTimeout((()=>this.uploadLogInterval()),_N("UPLOAD_LOG_TWICE_RETRY_INTERVAL_V1")):window.setTimeout((()=>this.uploadLogInterval()),_N("UPLOAD_LOG_RETRY_INTERVAL_V1"))})))}};var qN;function zN(e){return Rw(e.reportId,"params.reportId",0,100,!1),Rw(e.category,"params.category",0,100,!1),Rw(e.event,"params.event",0,100,!1),Rw(e.label,"params.label",0,100,!1),Sw(e.value,"params.value",Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,!1),!0}(qN={}).FREE="free",qN.UPLOADING="uploading",function(e){e[e.MISC=0]="MISC",e[e.INTERNAL_EVENT=1]="INTERNAL_EVENT",e[e.PUBLIC_EVENT=2]="PUBLIC_EVENT",e[e.WEB_EVENT=3]="WEB_EVENT",e[e.INTERNAL_API=4]="INTERNAL_API",e[e.WEB_API=5]="WEB_API",e[e.PUBLIC_API=6]="PUBLIC_API"}({});const XN={sid:"",lts:0,success:null,cname:null,uid:null,peer:null,cid:null,elapse:null,extend:null,vid:0};let JN=function(e){return e.PUBLISH="publish",e.SUBSCRIBE="subscribe",e.WS_COMPRESSOR_INIT="ws_compressor_init",e.SESSION_INIT="session_init",e.JOIN_CHOOSE_SERVER="join_choose_server",e.REQ_USER_ACCOUNT="req_user_account",e.JOIN_GATEWAY="join_gateway",e.REJOIN_GATEWAY="rejoin_gateway",e.STREAM_SWITCH="stream_switch",e.REQUEST_PROXY_WORKER_MANAGER="request_proxy_worker_manager",e.REQUEST_PROXY_APPCENTER="request_proxy_appcenter",e.FIRST_VIDEO_RECEIVED="first_video_received",e.FIRST_AUDIO_RECEIVED="first_audio_received",e.FIRST_VIDEO_DECODE="first_video_decode",e.FIRST_AUDIO_DECODE="first_audio_decode",e.ON_ADD_AUDIO_STREAM="on_add_audio_stream",e.ON_ADD_VIDEO_STREAM="on_add_video_stream",e.ON_UPDATE_STREAM="on_update_stream",e.ON_REMOVE_STREAM="on_remove_stream",e.USER_ANALYTICS="req_user_analytics",e.PC_STATS="pc_stats",e.UPDATE_REMOTE_RTPCAPABILITIES="update_remote_rtpCapabilities",e.AB_TEST="ab_test",e}({}),QN=function(e){return e.SESSION="io.agora.pb.Wrtc.Session",e.JOIN_CHOOSE_SERVER="io.agora.pb.Wrtc.JoinChooseServer",e.REQ_USER_ACCOUNT="io.agora.pb.Wrtc.ReqUserAccount",e.JOIN_GATEWAY="io.agora.pb.Wrtc.JoinGateway",e.RE_JOIN_GATEWAY="io.agora.pb.Wrtc.ReJoinGateway",e.PUBLISH="io.agora.pb.Wrtc.Publish",e.SUBSCRIBE="io.agora.pb.Wrtc.Subscribe",e.WS_COMPRESSOR_INIT="io.agora.pb.Wrtc.WsCompressorInit",e.STREAM_SWITCH="io.agora.pb.Wrtc.StreamSwitch",e.AUDIO_SENDING_STOPPED="io.agora.pb.Wrtc.AudioSendingStopped",e.VIDEO_SENDING_STOPPED="io.agora.pb.Wrtc.VideoSendingStopped",e.REQUEST_PROXY_APPCENTER="io.agora.pb.Wrtc.RequestProxyAppCenter",e.REQUEST_PROXY_WORKER_MANAGER="io.agora.pb.Wrtc.RequestProxyWorkerManager",e.API_INVOKE="io.agora.pb.Wrtc.ApiInvoke",e.FIRST_VIDEO_RECEIVED="io.agora.pb.Wrtc.FirstVideoReceived",e.FIRST_AUDIO_RECEIVED="io.agora.pb.Wrtc.FirstAudioReceived",e.FIRST_VIDEO_DECODE="io.agora.pb.Wrtc.FirstVideoDecode",e.FIRST_AUDIO_DECODE="io.agora.pb.Wrtc.FirstAudioDecode",e.ON_ADD_AUDIO_STREAM="io.agora.pb.Wrtc.OnAddAudioStream",e.ON_ADD_VIDEO_STREAM="io.agora.pb.Wrtc.OnAddVideoStream",e.ON_UPDATE_STREAM="io.agora.pb.Wrtc.OnUpdateStream",e.ON_REMOVE_STREAM="io.agora.pb.Wrtc.OnRemoveStream",e.JOIN_CHANNEL_TIMEOUT="io.agora.pb.Wrtc.JoinChannelTimeout",e.PEER_PUBLISH_STATUS="io.agora.pb.Wrtc.PeerPublishStatus",e.WORKER_EVENT="io.agora.pb.Wrtc.WorkerEvent",e.AP_WORKER_EVENT="io.agora.pb.Wrtc.APWorkerEvent",e.JOIN_WEB_PROXY_AP="io.agora.pb.Wrtc.JoinWebProxyAP",e.WEBSOCKET_QUIT="io.agora.pb.Wrtc.WebSocketQuit",e.USER_ANALYTICS="io.agora.pb.Wrtc.UserAnalytics",e.AUTOPLAY_FAILED="io.agora.pb.Wrtc.AutoplayFailed",e.PC_STATS="io.agora.pb.Wrtc.PCStats",e.UPDATE_REMOTE_RTPCAPABILITIES="io.agora.pb.Wrtc.UpdateRemoteRTPCapabilities",e.AB_TEST="io.agora.pb.Wrtc.ABTest",e}({});!function(e){e[e.WORKER_EVENT=156]="WORKER_EVENT",e[e.AP_WORKER_EVENT=160]="AP_WORKER_EVENT"}({});let ZN=function(e){return e[e.SESSION=26]="SESSION",e[e.JOIN_CHOOSE_SERVER=27]="JOIN_CHOOSE_SERVER",e[e.REQ_USER_ACCOUNT=196]="REQ_USER_ACCOUNT",e[e.JOIN_GATEWAY=28]="JOIN_GATEWAY",e[e.PUBLISH=30]="PUBLISH",e[e.SUBSCRIBE=29]="SUBSCRIBE",e[e.WS_COMPRESSOR_INIT=9430]="WS_COMPRESSOR_INIT",e[e.STREAM_SWITCH=32]="STREAM_SWITCH",e[e.AUDIO_SENDING_STOPPED=33]="AUDIO_SENDING_STOPPED",e[e.VIDEO_SENDING_STOPPED=34]="VIDEO_SENDING_STOPPED",e[e.REQUEST_PROXY_APPCENTER=35]="REQUEST_PROXY_APPCENTER",e[e.REQUEST_PROXY_WORKER_MANAGER=36]="REQUEST_PROXY_WORKER_MANAGER",e[e.API_INVOKE=41]="API_INVOKE",e[e.FIRST_VIDEO_RECEIVED=348]="FIRST_VIDEO_RECEIVED",e[e.FIRST_AUDIO_RECEIVED=349]="FIRST_AUDIO_RECEIVED",e[e.FIRST_VIDEO_DECODE=350]="FIRST_VIDEO_DECODE",e[e.FIRST_AUDIO_DECODE=351]="FIRST_AUDIO_DECODE",e[e.ON_ADD_AUDIO_STREAM=352]="ON_ADD_AUDIO_STREAM",e[e.ON_ADD_VIDEO_STREAM=353]="ON_ADD_VIDEO_STREAM",e[e.ON_UPDATE_STREAM=356]="ON_UPDATE_STREAM",e[e.ON_REMOVE_STREAM=355]="ON_REMOVE_STREAM",e[e.JOIN_CHANNEL_TIMEOUT=407]="JOIN_CHANNEL_TIMEOUT",e[e.PEER_PUBLISH_STATUS=408]="PEER_PUBLISH_STATUS",e[e.WORKER_EVENT=156]="WORKER_EVENT",e[e.AP_WORKER_EVENT=160]="AP_WORKER_EVENT",e[e.JOIN_WEB_PROXY_AP=700]="JOIN_WEB_PROXY_AP",e[e.WEBSOCKET_QUIT=671]="WEBSOCKET_QUIT",e[e.USER_ANALYTICS=1e4]="USER_ANALYTICS",e[e.AUTOPLAY_FAILED=9178]="AUTOPLAY_FAILED",e}({});function $N(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t,i,n){const r=n.value;if("function"==typeof r){const o=e.className||t.__className__||("AgoraRTCClient"===t.constructor.name?"Client":t.constructor.name);n.value=function(){for(var t,n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];let c=s;if(e.argsMap)try{c=e.argsMap(this,...s)}catch(e){YN.warning(e),c=[]}try{JSON.stringify(c)}catch(e){YN.warning("arguments for method ".concat(o,".").concat(String(i)," not serializable for apiInvoke.")),c=[]}const d=(e.report||eD).reportApiInvoke(this._sessionId||null,{id:this._clientId||(null===(t=this.store)||void 0===t?void 0:t.clientId)||this._ID,name:"".concat(o,".").concat(String(i)),options:c,tag:Mw.TRACER,reportResult:e.reportResult},e.throttleTime);try{const t=r.apply(this,s);return t instanceof Wh?t.then((t=>(d.onSuccess(e.reportResult&&t),t))).catch((e=>{throw d.onError(e),e})):(d.onSuccess(e.reportResult&&t),t)}catch(e){throw d.onError(e),e}}}return n}}const eD=new class{constructor(){VN(this,"baseInfoMap",new Map),VN(this,"proxyServer",void 0),VN(this,"eventUploadTimer",void 0),VN(this,"setSessionIdTimer",void 0),VN(this,"url",void 0),VN(this,"sids",new Set),VN(this,"backupUrl",void 0),VN(this,"_appId",void 0),VN(this,"_aid",0),VN(this,"keyEventUploadPendingItems",[]),VN(this,"normalEventUploadPendingItems",[]),VN(this,"apiInvokeUploadPendingItems",[]),VN(this,"apiInvokeCount",0),VN(this,"apiInvokeLoggedCount",0),VN(this,"ltsList",[]),VN(this,"lastSendNormalEventTime",Date.now()),VN(this,"customReportCounterTimer",void 0),VN(this,"customReportCount",0),VN(this,"extApiInvoke",(async e=>{for(const t of e){const e=xN(xN({},t),{},{sid:null,invokeId:++this.apiInvokeCount,tag:Mw.TRACER});this.sendApiInvoke(e)}})),this.eventUploadTimer=window.setInterval(this.doSend.bind(this),_N("EVENT_REPORT_SEND_INTERVAL")),this.setSessionIdTimer=window.setInterval(this.appendSessionId.bind(this),_N("EVENT_REPORT_SEND_INTERVAL"))}getBaseInfoBySessionId(e){return this.baseInfoMap.get(e)}setAppId(e){this._appId=e,this._aid=parseInt(e.replace(/[a-fA-F0-9]{8}/g,(e=>{let[t,i]=e;return t+i})),16)||0}reportApiInvoke(e,t,i){t.timeout=t.timeout||6e4,t.reportResult=void 0===t.reportResult||t.reportResult;const n=Date.now();this.apiInvokeCount+=1;const r=this.apiInvokeCount,o=!!_N("SHOW_REPORT_INVOKER_LOG"),s=!!_N("SHOW_REPORT_USER_INVOKER_LOG"),a=o||s&&t.id;a&&(this.apiInvokeLoggedCount+=1);const c=this.apiInvokeLoggedCount;function d(e,i){if(a){let n="[apiInvoke-".concat(c,"]");t.id&&(n+="[".concat(t.id,"]")),t.name&&(n+="[".concat(t.name,"]")),YN.info("".concat(n," ").concat(e),"start"===e?t.options:i||"")}}const l=()=>({tag:t.tag,invokeId:r,sid:e,name:t.name,apiInvokeTime:n,options:t.options,states:t.states||null});d("start");let u=!1;uO(t.timeout).then((()=>{u||(this.sendApiInvoke(xN(xN({},l()),{},{error:Ew.API_INVOKE_TIMEOUT,success:!1})),d("timeout"))}));const h=new mw(Ew.UNEXPECTED_ERROR,"".concat(t.name,": this api invoke is end"));return{onSuccess:e=>{const n=()=>{if(u)throw h;return u=!0,this.sendApiInvoke(xN(xN({},l()),{},{success:!0},t.reportResult&&{result:e})),d("onSuccess"),e};return i?mO(n,t.name+"Success",i,(()=>u=!0)):n()},onError:e=>{const n=()=>{if(u)throw e;u=!0,this.sendApiInvoke(xN(xN({},l()),{},{success:!1,error:e})),d("onFailure",e.toString())};return i?mO(n,t.name+"Error",i,(()=>u=!0)):n()}}}sessionInit(e,t){if(this.baseInfoMap.has(e))return;const i=Date.now(),n=this.createBaseInfo(e,i);n.cname=t.cname;const r=Object.assign({},{willUploadConsoleLog:_N("UPLOAD_LOG"),maxTouchPoints:navigator.maxTouchPoints,areaVersion:oN?"global":"oversea",areas:_N("AREAS")&&_N("AREAS").join(",")}
12271,t.extend),{stringUid:o,channelProfile:s,channelMode:a,isABTestSuccess:c,lsid:d,clientRole:l}=t,u=Date.now(),h=xN(xN({},n),{},{eventType:JN.SESSION_INIT,appid:t.appid,browser:navigator.userAgent,buildFormat:t.buildFormat,build:lN,lts:u,elapse:u-i,extend:JSON.stringify(r),mode:t.mode,process:_N("PROCESS_ID"),appType:_N("APP_TYPE"),success:!0,version:rN,stringUid:o,channelProfile:s,channelMode:a,isABTestSuccess:c,lsid:d,clientType:Dn(p=window.navigator.userAgent).call(p,"AgoraWebView")?42:20,clientRole:l,serviceId:_N("PROCESS_ID"),extensionID:_N("PLUGIN_INFO").join(",")||""});var p;this.send({type:QN.SESSION,data:h},!0)}joinChooseServer(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN({},n),{},{role:t.role,eventType:JN.JOIN_CHOOSE_SERVER,lts:r,eventElapse:t.elapse||r-t.lts,chooseServerAddr:t.csAddr,errorCode:t.ec,elapse:r-i.startTime,success:t.succ,chooseServerAddrList:JSON.stringify(t.serverList),uid:t.uid?parseInt(t.uid):null,cid:t.cid?parseInt(t.cid):null,chooseServerIp:t.csIp||"",opid:t.opid,unilbsServerIds:t.unilbsServerIds,extend:t.extend||void 0,isHttp3:t.isHttp3,corssRegionTagReq:t.corssRegionTagReq||void 0,corssRegionTagRes:t.corssRegionTagRes||void 0});this.send({type:QN.JOIN_CHOOSE_SERVER,data:o},!0)}reqUserAccount(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN({},n),{},{eventType:JN.REQ_USER_ACCOUNT,lts:r,success:t.success,serverAddress:t.serverAddr,stringUid:t.stringUid,uid:t.uid,errorCode:t.errorCode,elapse:t.elapse||r-i.startTime,eventElapse:r-t.lts,extend:JSON.stringify(t.extend)});this.send({type:QN.REQ_USER_ACCOUNT,data:o},!0)}joinGateway(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info;t.vid&&(n.vid=t.vid),n.uid=t.uid,n.cid=t.cid;const r=Date.now(),{firstSuccess:o,avoidJoinStartTime:s,addr:a,isProxy:c}=t,d=r-(o&&s?s:i.startTime),l=xN(xN({},n),{},{eventType:JN.JOIN_GATEWAY,lts:r,gatewayAddr:t.addr,success:t.succ,errorCode:t.ec,errorMsg:t.errorMsg||"",elapse:d,eventElapse:r-t.lts,firstSuccess:o,signalChannel:t.signalChannel,preload:t.preload?1:0,installId:nN(),isABTestSuccess:t.isABTestSuccess?1:0}),u=l.success?1:0;if(t.succ&&(i.lastJoinSuccessTime=r),o)this.send({type:QN.JOIN_GATEWAY,data:l},!0);else{let e;if(a)if(c){const t=a.match(/h=(\d{1,3}-){3}\d{1,3}/g),i=a.match(/p=[0-9]{1,6}/g);e={isSuccess:u,gatewayIp:t&&t.length?t[0].split("=")[1].replace(/-/g,"."):"",port:i&&i.length?i[0].split("=")[1]:"",isProxy:c?1:0}}else{const t=a.match(/wss:\/\/(\d{1,3}-){3}\d{1,3}/g),i=a.match(/(:|p=)[0-9]{1,6}/g);e={isSuccess:u,gatewayIp:t&&t.length?t[0].split("//")[1].replace(/-/g,"."):"",port:i&&i.length?i[0].split(/:|p=/g)[1]:"",isProxy:c?1:0}}else e={isSuccess:u,gatewayIp:"",port:"",isProxy:c?1:0};delete l.success,delete l.eventType,delete l.firstSuccess,l.vid=Number(l.vid);const t=Object.assign({},l,e,{eventType:JN.REJOIN_GATEWAY});this.send({type:QN.RE_JOIN_GATEWAY,data:t},!0)}}joinChannelTimeout(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=Date.now(),r=xN(xN({},i.info),{},{lts:n,timeout:t,elapse:n-i.startTime});this.send({type:QN.JOIN_CHANNEL_TIMEOUT,data:r},!0)}publish(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN({},n),{},{eventType:JN.PUBLISH,lts:r,eventElapse:t.eventElapse,elapse:r-i.startTime,success:t.succ,errorCode:t.ec,videoName:t.videoName,audioName:t.audioName,screenName:t.screenName,screenshare:t.screenshare,audio:t.audio,video:t.video,p2pid:t.p2pid,publishRequestid:t.publishRequestid});this.send({type:QN.PUBLISH,data:o},!0)}subscribe(e,t,i){const n=this.baseInfoMap.get(e);if(!n)return;const r=n.info,o=Date.now(),s=xN(xN({},r),{},{eventType:JN.SUBSCRIBE,lts:o,eventElapse:t.eventElapse,elapse:o-n.startTime,success:t.succ,errorCode:t.ec,video:t.video,audio:t.audio,subscribeRequestid:t.subscribeRequestid,p2pid:t.p2pid,preSsrc:t.preSsrc?1:0},i&&{extend:JSON.stringify({isMassSubscribe:!0})});"string"==typeof t.peerid?s.peerSuid=t.peerid:s.peer=t.peerid,this.send({type:QN.SUBSCRIBE,data:s},!0)}wsCompressorInit(e){var t;const i=[...MN(t=this.baseInfoMap).call(t)],n=i.length?i[0]:"UnableToGetSid",r=this.baseInfoMap.get(n);if(!r)return;const o=r.info,s=Date.now(),a=xN(xN({},o),{},{eventType:JN.WS_COMPRESSOR_INIT,lts:s,eventElapse:e.eventElapse,elapse:s-r.startTime,status:e.status?1:2});this.send({type:QN.WS_COMPRESSOR_INIT,data:a},!0)}firstRemoteVideoDecode(e,t,i,n){const r=this.baseInfoMap.get(e);if(!r)return;const o=r.info,s=Date.now(),a=xN(xN(xN({},o),n),{},{elapse:s-r.startTime,eventType:t,lts:s,firstDecodeFrame:Math.max((n.firstFrame||s)-r.startTime,0),apEnd:Math.max(n.apEnd-r.startTime,0),apStart:Math.max(n.apStart-r.startTime,0),joinGwEnd:Math.max(n.joinGwEnd-r.startTime,0),joinGwStart:Math.max(n.joinGwStart-r.startTime,0),pcEnd:Math.max(n.pcEnd-r.startTime,0),pcStart:Math.max(n.pcStart-r.startTime,0),subscriberEnd:Math.max(n.subscriberEnd-r.startTime,0),subscriberStart:Math.max(n.subscriberStart-r.startTime,0),videoAddNotify:Math.max(n.videoAddNotify-r.startTime,0)});this.send({type:i,data:a},!0)}firstRemoteFrame(e,t,i,n){const r=this.baseInfoMap.get(e);if(!r)return;const o=r.info,s=Date.now(),a=xN(xN(xN({},o),n),{},{elapse:s-r.startTime,eventType:t,lts:s});this.send({type:i,data:a},!0)}abTest(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN(xN({},n),t),{},{vid:void 0===n.vid?0:Number(n.vid),elapse:r-i.startTime,eventType:JN.AB_TEST,lts:r});this.send({type:QN.AB_TEST,data:o},!0)}pcStats(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN(xN({},n),t),{},{vid:void 0===n.vid?0:Number(n.vid),elapse:r-i.startTime,eventType:JN.PC_STATS,lts:r,preallocation:t.preallocation?1:0});
vendor: 25,893 bytes, line 12271
12271this.send({type:QN.PC_STATS,data:o},!0)}updateRemoteRTPCapabilities(e,t){if(e){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN(xN({},n),t),{},{vid:void 0===n.vid?0:Number(n.vid),eventType:JN.UPDATE_REMOTE_RTPCAPABILITIES,lts:r});this.send({type:QN.UPDATE_REMOTE_RTPCAPABILITIES,data:o},!0)}}onGatewayStream(e,t,i,n){const r=this.baseInfoMap.get(e);if(!r)return;const o=r.info,s=Date.now(),a=xN(xN(xN({},o),n),{},{eventType:t,lts:s});this.send({type:i,data:a},!0)}streamSwitch(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN({},n),{},{eventType:JN.STREAM_SWITCH,lts:r,isDual:t.isdual,elapse:r-i.startTime,success:t.succ});this.send({type:QN.STREAM_SWITCH,data:o},!0)}requestProxyAppCenter(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN({},n),{},{eventType:JN.REQUEST_PROXY_APPCENTER,lts:r,eventElapse:r-t.lts,elapse:r-i.startTime,APAddr:t.APAddr,workerManagerList:t.workerManagerList,response:t.response,errorCode:t.ec,success:t.succ});this.send({type:QN.REQUEST_PROXY_APPCENTER,data:o},!0)}requestProxyWorkerManager(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN({},n),{},{eventType:JN.REQUEST_PROXY_WORKER_MANAGER,lts:r,eventElapse:r-t.lts,elapse:r-i.startTime,workerManagerAddr:t.workerManagerAddr,response:t.response,errorCode:t.ec,success:t.succ});this.send({type:QN.REQUEST_PROXY_WORKER_MANAGER,data:o},!0)}setProxyServer(e){this.proxyServer=e,e?YN.debug("reportProxyServerurl: ".concat(e)):YN.debug("disable reportProxyServerurl: ".concat(e))}peerPublishStatus(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN({},n),{},{subscribeElapse:t.subscribeElapse,peer:t.peer,peerPublishDuration:Math.max(t.audioPublishDuration,t.videoPublishDuration),audiotag:t.audioPublishDuration>0?1:-1,videotag:t.videoPublishDuration>0?1:-1,lts:r,elapse:r-i.startTime,joinChannelSuccessElapse:r-(i.lastJoinSuccessTime||r),peerPublishDurationVideo:t.videoPublishDuration,peerPublishDurationAudio:t.audioPublishDuration});this.send({type:QN.PEER_PUBLISH_STATUS,data:o},!0)}workerEvent(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now();(function(e,t,i){const n=e[t];if(!n||"string"!=typeof n)return[e];e[t]="";const r=cO(JSON.stringify(e));let o=0;const s=[];let a=0;for(let c=0;c<n.length;c++)a+=n.charCodeAt(c)<=127?1:3,a<=i-r||(s[s.length]=pw(pw({},e),{},{[t]:n.substring(o,c)}),o=c,a=n.charCodeAt(c)<=127?1:3);return o!==n.length-1&&(s[s.length]=pw(pw({},e),{},{[t]:n.substring(o)})),s})(xN(xN(xN({},n),t),{},{elapse:r-i.startTime,lts:r,productType:"WebRTC"}),"payload",1300).forEach((e=>this.send({type:QN.WORKER_EVENT,data:e},!0)))}apworkerEvent(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN(xN({},n),t),{},{elapse:r-i.startTime,lts:r});this.send({type:QN.AP_WORKER_EVENT,data:o},!0)}joinWebProxyAP(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN(xN({},n),t),{},{elapse:r-i.startTime,lts:r,extend:t.extend||void 0});this.send({type:QN.JOIN_WEB_PROXY_AP,data:o},!0)}WebSocketQuit(e,t){const i=this.baseInfoMap.get(e);if(!i)return;const n=i.info,r=Date.now(),o=xN(xN(xN({},n),t),{},{elapse:r-i.startTime,lts:r});this.send({type:QN.WEBSOCKET_QUIT,data:o},!0)}async sendCustomReportMessage(e,t){if(this.customReportCount+=t.length,this.customReportCount>_N("CUSTOM_REPORT_LIMIT"))throw new mw(Ew.CUSTOM_REPORT_FREQUENCY_TOO_HIGH);this.customReportCounterTimer||(this.customReportCounterTimer=window.setInterval((()=>{this.customReportCount=0}),5e3));const i=Date.now(),n=t.map((t=>({type:QN.USER_ANALYTICS,data:xN(xN({sid:e},t),{},{lts:i})})));try{_N("NEW_REPORT_SERVER")?await this.postDataToStatsCollector2(n):await this.postDataToStatsCollector(n)}catch(e){throw YN.error("send custom report message failed",e.toString()),new mw(Ew.CUSTOM_REPORT_SEND_FAILED,e.message)}}sendApiInvoke(e){const t=_N("NOT_REPORT_EVENT");if(e.tag&&Dn(t)&&Dn(t).call(t,e.tag))return!1;if(null===e.sid)return this.apiInvokeUploadPendingItems.push(e),!1;const i=this.baseInfoMap.get(e.sid);if(!i)return this.apiInvokeUploadPendingItems.push(e),!1;const{cname:n,uid:r,cid:o}=i.info;let s;if(e.lts=e.lts||Date.now(),e.error)if(e.error instanceof mw){const{code:t,message:i}=e.error;s=t||i||e.error.toString()}else s=e.error.toString();const a={invokeId:e.invokeId,sid:e.sid,cname:n,cid:o,uid:r,lts:e.lts,success:e.success,elapse:e.lts-i.startTime,execElapse:e.lts-e.apiInvokeTime,apiName:e.name,options:e.options?JSON.stringify(e.options):void 0,execStates:e.states?JSON.stringify(e.states):void 0,execResult:e.result?JSON.stringify(e.result):void 0,errorCode:e.error?s:void 0,errorMsg:e.error?JSON.stringify(e.error):void 0};return this.send({type:QN.API_INVOKE,data:a},!1),!0}addSid(e){this.sids.add(e)}removeSid(e){this.sids.delete(e)}appendSessionId(){const e=this.apiInvokeUploadPendingItems;if(0===e.length)return;const t=Array.from(this.sids).find((e=>null!==e));t&&e.forEach((e=>{e&&(e.sid=t,this.sendApiInvoke(Object.assign({},e)))})),e.length=0}send(e,t){if(t)return this.keyEventUploadPendingItems.push(e),void this.sendItems(this.keyEventUploadPendingItems,!0);this.normalEventUploadPendingItems.push(e),this.normalEventUploadPendingItems.length>_N("NORMAL_EVENT_QUEUE_CAPACITY")&&this.normalEventUploadPendingItems.splice(0,1),this.normalEventUploadPendingItems.length>=10&&this.sendItems(this.normalEventUploadPendingItems,!1)}doSend(){this.keyEventUploadPendingItems.length>0&&this.sendItems(this.keyEventUploadPendingItems,!0),this.normalEventUploadPendingItems.length>0&&Date.now()-this.lastSendNormalEventTime>=5e3&&this.sendItems(this.normalEventUploadPendingItems,!1)}sendItems(e,t){const i=[],n=[];for(;e.length;){const t=e.shift();i.length<20?i.push(t):n.push(t)}e.push(...n);for(const e of[...i]){var r;-1!==this.ltsList.indexOf(e.data.lts)?(e.data.lts=this.ltsList[this.ltsList.length-1]+1,this.ltsList.push(e.data.lts)):(this.ltsList.push(e.data.lts),vS(r=this.ltsList).call(r,((e,t)=>e-t)))}return t||(this.lastSendNormalEventTime=Date.now()),_N("ENABLE_EVENT_REPORT")?(i.length&&(_N("NEW_REPORT_SERVER")?this.postDataToStatsCollector2(i):this.postDataToStatsCollector(i)).catch((e=>i=>{_N("EVENT_REPORT_RETRY")&&(t?this.keyEventUploadPendingItems=this.keyEventUploadPendingItems.concat(e):(this.normalEventUploadPendingItems=this.normalEventUploadPendingItems.concat(e),this.normalEventUploadPendingItems.length>_N("NORMAL_EVENT_QUEUE_CAPACITY")&&(this.normalEventUploadPendingItems.splice(0,this.normalEventUploadPendingItems.length-_N("NORMAL_EVENT_QUEUE_CAPACITY")),YN.warning("report: drop normal events"))))})(i)),e):e}async postDataToStatsCollector2(e){Jw.networkState===Hw.OFFLINE&&await Wh.race([Jw.onlineWaiter,uO(2*AO.maxRetryTimeout)]);const t=e=>{let t=new Uint8Array;return e.forEach((e=>{const i=ww(JSON.stringify(e.data)),n=new ArrayBuffer(5),r=(e=>{let t=0;return Object.entries(QN).forEach((i=>{let[n,r]=i;r===e.type&&(t=ZN[n])})),t})(e),o=new DataView(n);o.setUint16(0,i.byteLength,!0),o.setUint8(2,255&r),o.setUint8(3,r>>>8&255),o.setUint8(4,r>>>16&255),t=Ow(t,new Uint8Array(n)),t=Ow(t,i)})),t},i="event";let n=this.proxyServer?"https://".concat(this.proxyServer,"/rs/?h=").concat(_N("NEW_REPORT_SERVER_DOMAINS")[0],"&p=443&d=").concat(i):"https://".concat(_N("NEW_REPORT_SERVER_DOMAINS")[0],"/").concat(i);for(let r=0;r<2;r+=1){1===r&&(n=this.proxyServer?"https://".concat(this.proxyServer,"/rs/?h=").concat(_N("NEW_REPORT_SERVER_DOMAINS")[1],"&p=443&d=").concat(i):"https://".concat(_N("NEW_REPORT_SERVER_DOMAINS")[1],"/").concat(i));try{await LO(n,{timeout:1e4,data:t(e),headers:xN(xN({biz:"webrtc",sendts:Math.round(Date.now()/1e3),debug:"false"},this._appId&&{appid:this._appId}),{},{"Content-Type":"application/octet-stream"})},!0)}catch(e){if(1===r)throw e;continue}return}}async postDataToStatsCollector(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=(e=>{const t=e&&e.data.sid&&this.baseInfoMap.get(e.data.sid);return t&&t.info.vid&&+t.info.vid||0})(e[0]),n=i?void 0:this._aid,r={msgType:"EventMessages",sentTs:Math.round(Date.now()/1e3),payloads:e.map((e=>JSON.stringify(e))),vid:i,aid:n};Jw.networkState===Hw.OFFLINE&&await Wh.race([Jw.onlineWaiter,uO(2*AO.maxRetryTimeout)]);const o=t?"/events/proto-raws":"/events/messages";let s=this.url||(this.proxyServer?"https://".concat(this.proxyServer,"/rs/?h=").concat(_N("EVENT_REPORT_DOMAIN"),"&p=").concat(_N("STATS_COLLECTOR_PORT"),"&d=").concat(o):"https://".concat(_N("EVENT_REPORT_DOMAIN"),":").concat(_N("STATS_COLLECTOR_PORT")).concat(o));for(let e=0;e<2;e+=1){1===e&&(s=this.backupUrl||(this.proxyServer?"https://".concat(this.proxyServer,"/rs/?h=").concat(_N("EVENT_REPORT_BACKUP_DOMAIN"),"&p=").concat(_N("STATS_COLLECTOR_PORT"),"&d=").concat(o):"https://".concat(_N("EVENT_REPORT_BACKUP_DOMAIN"),":").concat(_N("STATS_COLLECTOR_PORT")).concat(o)));try{t?await kO(s,{timeout:1e4,data:r}):await LO(s,{timeout:1e4,data:r})}catch(t){if(1===e)throw t;continue}return}}createBaseInfo(e,t){const i=Object.assign({},XN);return i.sid=e,this.baseInfoMap.set(e,{info:i,startTime:t}),i}reportResourceTiming(e,t){const i=performance.getEntriesByName(e),n=i[i.length-1];n&&this.reportApiInvoke(t,{name:"Client.resourceTiming",options:n,tag:Mw.TRACER}).onSuccess()}};FN.on("REPORT_LOG_UPLOAD",(e=>{e.networkState=Jw.networkState,eD.reportApiInvoke(null,{name:"logUploadError",options:e,tag:Mw.TRACER}).onSuccess("logUploadError")}));class tD extends mw{constructor(e){super(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",arguments.length>2?arguments[2]:void 0),VN(this,"name","AgoraRTCException")}print(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"error";return super.print(e,YN)}throw(){super.throw(YN)}}const iD={getDisplayMedia:!1,getStreamFromExtension:!1,supportUnifiedPlan:!1,supportMinBitrate:!1,supportSetRtpSenderParameters:!1,supportDualStream:!0,webAudioMediaStreamDest:!1,supportReplaceTrack:!1,supportWebGL:!1,webAudioWithAEC:!1,supportRequestFrame:!1,supportShareAudio:!1,supportDualStreamEncoding:!1,supportDataChannel:!1,supportPCSetConfiguration:!1,supportWebRTCEncodedTransform:!1,supportWebRTCInsertableStream:!1,supportRequestVideoFrameCallback:!1,supportWebCrypto:!1};function nD(){return iD}function rD(){return"setSinkId"in HTMLAudioElement.prototype&&(!_N("RESTRICTION_SET_PLAYBACK_DEVICE")||(Gb()||Hb())&&!cw())}function oD(){return!iD.supportUnifiedPlan||_N("CHROME_FORCE_PLAN_B")&&dw()}let sD=function(e){return e.IOS_15_16_INTERRUPTION_START="ios15_16-interruption-start",e.IOS_15_16_INTERRUPTION_END="ios15_16-interruption-end",e.IOS_INTERRUPTION_START="ios-interruption-start",e.IOS_INTERRUPTION_END="ios-interruption-end",e.STATE_CHANGE="state-change",e}({});function aD(e,t,i){return{sampleRate:e,stereo:t,bitrate:i}}function cD(e,t,i,n,r){return{width:e,height:t,frameRate:i,bitrateMin:n,bitrateMax:r}}function dD(e,t,i,n,r){return{width:{max:e},height:{max:t},frameRate:i,bitrateMin:n,bitrateMax:r}}function lD(e,t){return{numSpatialLayers:e,numTemporalLayers:t}}const uD={"90p":cD(160,90),"90p_1":cD(160,90),"120p":cD(160,120,15,30,65),"120p_1":cD(160,120,15,30,65),"120p_3":cD(120,120,15,30,50),"120p_4":cD(212,120),"180p":cD(320,180,15,30,140),"180p_1":cD(320,180,15,30,140),"180p_3":cD(180,180,15,30,100),"180p_4":cD(240,180,15,30,120),"240p":cD(320,240,15,40,200),"240p_1":cD(320,240,15,40,200),"240p_3":cD(240,240,15,40,140),"240p_4":cD(424,240,15,40,220),"360p":cD(640,360,15,80,400),"360p_1":cD(640,360,15,80,400),"360p_3":cD(360,360,15,80,260),"360p_4":cD(640,360,30,80,600),"360p_6":cD(360,360,30,80,400),"360p_7":cD(480,360,15,80,320),"360p_8":cD(480,360,30,80,490),"360p_9":cD(640,360,15,80,800),"360p_10":cD(640,360,24,80,800),"360p_11":cD(640,360,24,80,1e3),"480p":cD(640,480,15,100,500),"480p_1":cD(640,480,15,100,500),"480p_2":cD(640,480,30,100,1e3),"480p_3":cD(480,480,15,100,400),"480p_4":cD(640,480,30,100,750),"480p_6":cD(480,480,30,100,600),"480p_8":cD(848,480,15,100,610),"480p_9":cD(848,480,30,100,930),"480p_10":cD(640,480,10,100,400),"720p":cD(1280,720,15,120,1130),"720p_auto":cD(1280,720,30,900,3e3),"720p_1":cD(1280,720,15,120,1130),"720p_2":cD(1280,720,30,120,2e3),"720p_3":cD(1280,720,30,120,1710),"720p_5":cD(960,720,15,120,910),"720p_6":cD(960,720,30,120,1380),"1080p":cD(1920,1080,15,120,2080),"1080p_1":cD(1920,1080,15,120,2080),"1080p_2":cD(1920,1080,30,120,3e3),"1080p_3":cD(1920,1080,30,120,3150),"1080p_5":cD(1920,1080,60,120,4780),"1440p":cD(2560,1440,30,120,4850),"1440p_1":cD(2560,1440,30,120,4850),"1440p_2":cD(2560,1440,60,120,7350),"4k":cD(3840,2160,30,120,8910),"4k_1":cD(3840,2160,30,120,8910),"4k_3":cD(3840,2160,60,120,13500)},hD={"480p":dD(640,480,5),"480p_1":dD(640,480,5),"480p_2":dD(640,480,30),"480p_3":dD(640,480,15),"720p":dD(1280,720,5),"720p_auto":cD(1280,720,30,900,3e3),"720p_1":dD(1280,720,5),"720p_2":dD(1280,720,30),"720p_3":dD(1280,720,15),"1080p":dD(1920,1080,5),"1080p_1":dD(1920,1080,5),"1080p_2":dD(1920,1080,30),"1080p_3":dD(1920,1080,15)},pD={"1SL1TL":lD(1,1),"3SL3TL":lD(3,3),"2SL3TL":lD(2,3)};function _D(e){return e||(e="480p_1"),"string"==typeof e?Object.assign({},uD[e]):e}function ED(e){return"string"==typeof e?Object.assign({},hD[e]):e}function mD(e){return"string"==typeof e?Object.assign({},pD[e]):e}const fD={speech_low_quality:aD(16e3,!1),speech_standard:aD(32e3,!1,18),music_standard:aD(48e3,!1),standard_stereo:aD(48e3,!0,56),high_quality:aD(48e3,!1,128),high_quality_stereo:aD(48e3,!0,192)};function TD(e){return"string"==typeof e?Object.assign({},fD[e]):e}const SD=[];function gD(e){return Tw(e,"mediaSource",["screen","window","application"]),!0}let RD=function(e){return e.NEED_RENEGOTIATE="@need_renegotiate",e.NEED_REPLACE_TRACK="@need_replace_track",e.NEED_REPLACE_MIXING_TRACK="@need_replace_mixing_track",e.NEED_CLOSE="@need_close",e.NEED_ENABLE_TRACK="@need_enable_track",e.NEED_DISABLE_TRACK="@need_disable_track",e.NEED_SESSION_ID="@need_sid",e.SET_OPTIMIZATION_MODE="@set_optimization_mode",e.GET_STATS="@get_stats",e.GET_RTC_STATS="@get_rtc_stats",e.GET_LOW_VIDEO_TRACK="@get_low_video_track",e.NEED_RESET_REMOTE_SDP="@need_reset_remote_sdp",e.NEED_UPDATE_VIDEO_ENCODER="@need_update_video_encoder",e.NEED_UPDATE_VIDEO_SEND_PARAMETERS="@need_update_video_send_parameters",e.NEED_MUTE_TRACK="@need_mute_track",e.NEED_UNMUTE_TRACK="@need_unmute_track",e}({}),vD=function(e){return e.SCREEN_TRACK="screen_track",e.CUSTOM_TRACK="custome_track",e.LOW_STREAM="low_stream",e.SCREEN_LOW_TRACK="screen_low_track",e}({});let CD=function(e){return e[e.HIGH_STREAM=0]="HIGH_STREAM",e[e.LOW_STREAM=1]="LOW_STREAM",e}({}),ID=function(e){return e[e.HIGH_STREAM=0]="HIGH_STREAM",e[e.LOW_STREAM=1]="LOW_STREAM",e[e.HIGH_STREAM_LAYER1=4]="HIGH_STREAM_LAYER1",e[e.HIGH_STREAM_LAYER2=5]="HIGH_STREAM_LAYER2",e[e.HIGH_STREAM_LAYER3=6]="HIGH_STREAM_LAYER3",e[e.HIGH_STREAM_LAYER4=7]="HIGH_STREAM_LAYER4",e[e.HIGH_STREAM_LAYER5=8]="HIGH_STREAM_LAYER5",e[e.HIGH_STREAM_LAYER6=9]="HIGH_STREAM_LAYER6",e}({}),yD=function(e){return e[e.DISABLE=0]="DISABLE",e[e.LOW_STREAM=1]="LOW_STREAM",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e[e.HIGH_STREAM_LAYER1=3]="HIGH_STREAM_LAYER1",e[e.HIGH_STREAM_LAYER2=4]="HIGH_STREAM_LAYER2",e[e.HIGH_STREAM_LAYER3=5]="HIGH_STREAM_LAYER3",e[e.HIGH_STREAM_LAYER4=6]="HIGH_STREAM_LAYER4",e[e.HIGH_STREAM_LAYER5=7]="HIGH_STREAM_LAYER5",e[e.HIGH_STREAM_LAYER6=8]="HIGH_STREAM_LAYER6",e}({}),AD=function(e){return e.TRANSCEIVER_UPDATED="transceiver-updated",e.SEI_TO_SEND="sei-to-send",e.SEI_RECEIVED="sei-received",e.TRACK_UPDATED="track-updated",e}({}),bD=function(e){return e.SOURCE_STATE_CHANGE="source-state-change",e.TRACK_ENDED="track-ended",e.BEAUTY_EFFECT_OVERLOAD="beauty-effect-overload",e.VIDEO_ELEMENT_VISIBLE_STATUS="video-element-visible-status",e.CLOSED="closed",e}({}),wD=function(e){return e.FIRST_FRAME_DECODED="first-frame-decoded",e.VIDEO_ELEMENT_VISIBLE_STATUS="video-element-visible-status",e.VIDEO_STATE_CHANGED="video-state-changed",e}({}),OD=function(e){return e.AUDIO="audio",e.VIDEO="video",e.DATA="data",e}({}),ND=function(e){return e.AUDIO_SOURCE_STATE_CHANGE="audio_source_state_change",e.RECEIVE_TRACK_BUFFER="receive_track_buffer",e.ON_AUDIO_BUFFER="on_audio_buffer",e.UPDATE_SOURCE="update_source",e}({});!function(e){e.UPDATE_TRACK_SOURCE="update-track-source"}({});const DD={sendVolumeLevel:0,sendBitrate:0,sendBytes:0,sendPackets:0,sendPacketsLost:0,sendJitterMs:0,sendRttMs:0,currentPacketLossRate:0},PD={sendBytes:0,sendBitrate:0,sendPackets:0,sendPacketsLost:0,sendJitterMs:0,sendRttMs:0,sendResolutionHeight:0,sendResolutionWidth:0,captureResolutionHeight:0,captureResolutionWidth:0,targetSendBitrate:0,totalDuration:0,totalFreezeTime:0,currentPacketLossRate:0},LD={transportDelay:0,end2EndDelay:0,receiveBitrate:0,receiveLevel:0,receiveBytes:0,receiveDelay:0,receivePackets:0,receivePacketsLost:0,receivePacketsDiscarded:0,totalDuration:0,totalFreezeTime:0,freezeRate:0,packetLossRate:0,currentPacketLossRate:0,publishDuration:-1},kD={uplinkNetworkQuality:0,downlinkNetworkQuality:0},MD={transportDelay:0,end2EndDelay:0,receiveBitrate:0,receiveBytes:0,receiveDelay:0,receivePackets:0,receivePacketsLost:0,receiveResolutionHeight:0,receiveResolutionWidth:0,totalDuration:0,totalFreezeTime:0,freezeRate:0,packetLossRate:0,currentPacketLossRate:0,publishDuration:-1};let UD=function(e){return e.ON_TRACK="on_track",e.ON_NODE="on_node",e}({}),xD=function(e){return e.REQUEST_UPDATE_CONSTRAINTS="request_update_constraints",e.REQUEST_CONSTRAINTS="request_constraints",e}({}),VD=function(e){return e.IDLE="IDLE",e.INITING="INITING",e.INITEND="INITEND",e}({}),FD=function(e){return e.STATE_CHANGE="state_change",e.RECORDING_DEVICE_CHANGED="recordingDeviceChanged",e.PLAYOUT_DEVICE_CHANGED="playoutDeviceChanged",e.CAMERA_DEVICE_CHANGED="cameraDeviceChanged",e}({}),BD=function(e){return e.NONE="none",e.INIT="init",e.CANPLAY="canplay",e.PLAYING="playing",e.PAUSED="paused",e.SUSPEND="suspend",e.STALLED="stalled",e.WAITING="waiting",e.ERROR="error",e.DESTROYED="destroyed",e.ABORT="abort",e.ENDED="ended",e.EMPTIED="emptied",e.LOADEDDATA="loadeddata",e}({}),jD=function(e){return e[e.VideoStateStopped=0]="VideoStateStopped",e[e.VideoStateStarting=1]="VideoStateStarting",e[e.VideoStateDecoding=2]="VideoStateDecoding",e[e.VideoStateFrozen=3]="VideoStateFrozen",e}({});const GD={uninit:100,none:110,init:120,loadeddata:130,canplay:200,playing:210,paused:220,suspend:300,stalled:310,waiting:320,error:330,destroyed:340,abort:350,ended:360,emptied:370};let WD=function(e){return e.OPEN="open",e.MESSAGE="message",e.CLOSE="close",e.CLOSING="closing",e.ERROR="error",e}({});function HD(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function KD(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?HD(Object(i),!0).forEach((function(t){YD(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):HD(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function YD(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function qD(e,t,i,n,r){var o,s,a={};return Object.keys(n).forEach((function(e){a[e]=n[e]})),a.enumerable=!!a.enumerable,a.configurable=!!a.configurable,("value"in a||a.initializer)&&(a.writable=!0),a=Xn(o=cr(s=i.slice()).call(s)).call(o,(function(i,n){return n(e,t,i)||i}),a),r&&void 0!==a.initializer&&(a.value=a.initializer?a.initializer.call(r):void 0,a.initializer=void 0),void 0===a.initializer&&(Object.defineProperty(e,t,a),a=null),a}class zD extends Dw{set _mediaStreamTrack(e){e!==this.mediaStreamTrack&&(this.safeEmit(AD.TRACK_UPDATED,e),this.mediaStreamTrack=e)}get _mediaStreamTrack(){return this.mediaStreamTrack}constructor(e,t){super(),YD(this,"trackMediaType",void 0),YD(this,"_ID",void 0),YD(this,"_rtpTransceiver",void 0),YD(this,"_lowRtpTransceiver",void 0),YD(this,"_hints",[]),YD(this,"_isClosed",!1),YD(this,"_originMediaStreamTrack",void 0),YD(this,"mediaStreamTrack",void 0),YD(this,"_external",{}),this._ID=t||hO(8,"track-"),this._originMediaStreamTrack=e,this.mediaStreamTrack=e,function(e){Dn(SD).call(SD,e)||SD.push(e)}(this)}toString(){return this._ID}getTrackId(){return this._ID}getMediaStreamTrack(e){return e||nO((()=>{var e;eD.reportApiInvoke(null,{name:kw.GET_MEDIA_STREAM_TRACK,options:[],tag:Mw.TRACER}).onSuccess((null===(e=this._mediaStreamTrack)||void 0===e?void 0:e.label)||"")}),this.mediaStreamTrack.id||this.getTrackId()),this._mediaStreamTrack}getRTCRtpTransceiver(e){return e===CD.LOW_STREAM?this._lowRtpTransceiver:this._rtpTransceiver}getMediaStreamTrackSettings(){return this.getMediaStreamTrack(!0).getSettings()}close(){this._isClosed=!0,this._lowRtpTransceiver=void 0,this._rtpTransceiver=void 0,function(e){const t=SD.indexOf(e);-1!==t&&SD.splice(t,1)}(this),this.emit(bD.CLOSED),this.removeAllListeners(AD.SEI_RECEIVED)}_updateRtpTransceiver(e,t){if(t===CD.LOW_STREAM){if(this._lowRtpTransceiver===e)return;this._lowRtpTransceiver=e}else{if(this._rtpTransceiver===e)return;this._rtpTransceiver=e}this.emit(AD.TRANSCEIVER_UPDATED,e,t)}}class XD extends zD{get isExternalTrack(){return this._isExternalTrack}get muted(){return this._muted}get enabled(){return this._enabled}get processorContext(){return this._processorContext}constructor(e,t){super(e,t),YD(this,"_enabled",!0),YD(this,"_muted",!1),YD(this,"_isExternalTrack",!1),YD(this,"_isClosed",!1),YD(this,"_enabledMutex",void 0),YD(this,"processor",void 0),YD(this,"_processorContext",void 0),YD(this,"_handleTrackEnded",(()=>{this.onTrackEnded()})),this._enabledMutex=new IO("".concat(this.getTrackId())),e.addEventListener("ended",this._handleTrackEnded)}getTrackLabel(){var e,t;return null!==(e=null===(t=this._originMediaStreamTrack)||void 0===t?void 0:t.label)&&void 0!==e?e:""}close(){this._isClosed||(this.stop(),this._originMediaStreamTrack.stop(),this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack.stop(),this._mediaStreamTrack=null),this._originMediaStreamTrack=null,this._enabledMutex=null,YN.debug("[".concat(this.getTrackId(),"] close")),this.emit(RD.NEED_CLOSE),super.close())}async _updateOriginMediaStreamTrack(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this._isExternalTrack=i,e!==this._originMediaStreamTrack&&(this._originMediaStreamTrack&&(this._originMediaStreamTrack.removeEventListener("ended",this._handleTrackEnded),t&&this._originMediaStreamTrack.stop()),e.addEventListener("ended",this._handleTrackEnded),this._originMediaStreamTrack=e,this._muted&&(this._originMediaStreamTrack.enabled=!1),this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await qw(this,RD.NEED_REPLACE_TRACK,this),this.processor&&this._processorContext&&this.processor.updateInput({track:this._originMediaStreamTrack,context:this._processorContext}))}_getDefaultPlayerConfig(){return{}}onTrackEnded(){YN.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(bD.TRACK_ENDED)}stateCheck(e,t){if(YN.debug("check track state, [muted: ".concat(this._muted,", enabled: ").concat(this._enabled,"] to [").concat(e,": ").concat(t,"]")),fw(t,e),this._enabled&&this._muted&&"enabled"===e&&!1===t)throw new mw(Ew.TRACK_STATE_UNREACHABLE,"cannot set enabled while the track is muted").print("error",YN);if(!this._enabled&&!this._muted&&"muted"===e&&!0===t)throw new mw(Ew.TRACK_STATE_UNREACHABLE,"cannot set muted while the track is disabled").print("error",YN)}getProcessorStats(){return this._processorContext&&this._processorContext.gatherStats()||[]}getProcessorUsage(){return this._processorContext?this._processorContext.gatherUsage():Wh.resolve([])}}const JD=window.AudioContext||window.webkitAudioContext;let QD=null;const ZD=new class extends Dw{constructor(){super(...arguments),YD(this,"prevState",void 0),YD(this,"curState",void 0),YD(this,"currentTime",void 0),YD(this,"currentTimeStuckAt",void 0),YD(this,"interruptDetectorTrack",void 0),YD(this,"onLocalAudioTrackMute",(()=>{YN.info("ios15-interruption-start"),this.emit(sD.IOS_15_16_INTERRUPTION_START)})),YD(this,"onLocalAudioTrackUnmute",(async()=>{YN.info("ios15-interruption-end"),"running"!==this.curState||this.duringInterruption?YN.info("ios15-interruption-end-canceled"):(QD&&await QD.suspend(),this.emit(sD.IOS_15_16_INTERRUPTION_END))}))}get duringInterruption(){return"running"===this.prevState&&"interrupted"===this.curState}bindInterruptDetectorTrack(e){YN.debug("webaudio bindInterruptDetectorTrack ".concat(e.getTrackId())),this.interruptDetectorTrack||(this.interruptDetectorTrack=e,this.interruptDetectorTrack._mediaStreamTrack.onmute=this.onLocalAudioTrackMute,this.interruptDetectorTrack._mediaStreamTrack.onunmute=this.onLocalAudioTrackUnmute)}unbindInterruptDetectorTrack(e){YN.debug("webaudio unbindInterruptDetectorTrack ".concat(e.getTrackId())),this.interruptDetectorTrack&&this.interruptDetectorTrack===e&&(this.interruptDetectorTrack._mediaStreamTrack&&(this.interruptDetectorTrack._mediaStreamTrack.onmute=null,this.interruptDetectorTrack._mediaStreamTrack.onunmute=null),this.interruptDetectorTrack=void 0)}};function $D(){if(!QD){if(function(){if(!JD)return void YN.error("your browser is not support web audio");YN.info("create audio context");const e=KD({},_N("WEBAUDIO_INIT_OPTIONS"));YN.debug("audio context init option:",JSON.stringify(e)),QD=new JD(e),ZD.curState=Q
12271D.state,QD.onstatechange=()=>{ZD.prevState=ZD.curState,ZD.curState=QD?QD.state:void 0;const{prevState:e,curState:t}=ZD,i="running"===t,n="interrupted"===t,r="running"===e,o="suspended"===e,s="interrupted"===e,a=xb().osVersion;(Yb()||ow())&&r&&n&&(YN.info("ios".concat(a,"-interruption-start")),ZD.emit(sD.IOS_INTERRUPTION_START)),(Yb()||ow())&&(o||s)&&i&&(YN.info("ios".concat(a,"-interruption-end")),ZD.emit(sD.IOS_INTERRUPTION_END)),e!==t&&ZD.emit(sD.STATE_CHANGE,t,e)},setInterval((()=>{var e;const t=null===(e=QD)||void 0===e?void 0:e.currentTime;ZD.currentTime!==t?(ZD.currentTimeStuckAt&&(YN.debug("AudioContext current time resume at ".concat(t)),ZD.currentTimeStuckAt=void 0),ZD.currentTime=t):(t!==ZD.currentTimeStuckAt&&(eD.reportApiInvoke(null,{name:"WEB_AUDIO_CURRENT_TIME_STUCK",options:{currentTime:t},tag:Mw.TRACER}).onSuccess(),YN.warning("AudioContext current time stuck at ".concat(t))),ZD.currentTimeStuckAt=t)}),5e3),async function(e){const t=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","touchend","keydown","keyup"];let i,n=!1,r=!1,o=!1;function s(t){"running"===e.state?a(!1):Yb()||ow()?"suspended"===e.state&&(a(!0),t&&e.resume().then(c,c)):"closed"!==e.state&&(a(!0),t&&e.resume().then(c,c))}function a(e){if(n!==e){n=e;for(let i=0,n=t;i<n.length;i+=1){const t=n[i];e?window.addEventListener(t,d,{capture:!0,passive:!0}):window.removeEventListener(t,d,{capture:!0,passive:!0})}}}function c(){s(!1)}function d(){s(!0)}function l(e){if(!o)if(i.paused)if(e){let t;u(!1),o=!0;try{t=i.play(),t?t.then(h,h):(i.addEventListener("playing",h),i.addEventListener("abort",h),i.addEventListener("error",h))}catch(e){h()}}else u(!0);else u(!1)}function u(e){if(r!==e){r=e;for(let i=0,n=t;i<n.length;i++){const t=n[i];e?window.addEventListener(t,p,{capture:!0,passive:!0}):window.removeEventListener(t,p,{capture:!0,passive:!0})}}}function h(){i.removeEventListener("playing",h),i.removeEventListener("abort",h),i.removeEventListener("error",h),o=!1,l(!1)}function p(){l(!0)}if(Yb()){const t=e.createMediaStreamDestination(),n=document.createElement("div");n.innerHTML="<audio x-webkit-airplay='deny'></audio>",i=n.children.item(0),i.controls=!1,i.disableRemotePlayback=!0,i.preload="auto",i.srcObject=t.stream,l(!0)}ZD.on(sD.STATE_CHANGE,(function(){s(!0)})),s(!1)}(QD)}(),!QD)throw new mw(Ew.NOT_SUPPORTED,"can not create audio context");return QD}return QD}function eP(e){if(function(){if(null!==tP)return tP;const e=$D(),t=e.createBufferSource(),i=e.createGain(),n=e.createGain();t.connect(i),t.connect(n),t.disconnect(i);let r=!1;try{t.disconnect(i)}catch(e){r=!0}return t.disconnect(),tP=r,r}())return;const t=e.connect,i=e.disconnect;e.connect=(i,n,r)=>{var o;return e._inputNodes||(e._inputNodes=[]),Dn(o=e._inputNodes).call(o,i)||(i instanceof AudioNode?(e._inputNodes.push(i),t.call(e,i,n,r)):t.call(e,i,n)),e},e.disconnect=(n,r,o)=>{i.call(e),n?Qw(e._inputNodes,n):e._inputNodes=[];for(const i of e._inputNodes)t.call(e,i)}}let tP=null;function iP(e,t){let i=!1;const n=1/t;if(_N("DISABLE_WEBAUDIO")){const t=window.setInterval((()=>{i?window.clearInterval(t):e(performance.now()/1e3)}),1e3*n)}else{const t=$D();let r=t.createGain();r.gain.value=0,r.connect(t.destination);const o=()=>{if(i)return void(r=null);const s=t.createOscillator();s.onended=o,s.connect(r),s.start(0),s.stop(t.currentTime+n),e(t.currentTime)};o()}return()=>{i=!0}}class nP{constructor(){YD(this,"context",void 0),YD(this,"analyserNode",void 0),YD(this,"sourceNode",void 0),this.context=$D(),this.analyserNode=this.context.createAnalyser(),this.analyserNode.fftSize=2048,this.analyserNode.smoothingTimeConstant=.4}updateSource(e){if(e!==this.sourceNode){if(this.sourceNode)try{this.sourceNode.disconnect(this.analyserNode)}catch(e){}this.sourceNode=e,null==e||e.connect(this.analyserNode)}}getVolumeLevel(){if(!this.sourceNode)return 0;if(!this.context||Yb()||ow()||"running"!==this.context.state&&this.context.resume(),!this.analyserNode)return 0;const e=new Float32Array(this.analyserNode.fftSize);if(this.analyserNode.getFloatTimeDomainData)this.analyserNode.getFloatTimeDomainData(e);else{const t=new Uint8Array(this.analyserNode.fftSize);this.analyserNode.getByteTimeDomainData(t);for(let i=0;i<e.length;++i)e[i]=t[i]/128-1}const t=Xn(e).call(e,((e,t)=>
vendor: 9,081 bytes, line 12271
12271e+t*t),0)/e.length;return Math.max(10*Math.log10(t)+100,0)/100}getAnalyserNode(){return this.analyserNode}rebuildAnalyser(){try{var e,t;null===(e=this.sourceNode)||void 0===e||e.disconnect(this.analyserNode),this.analyserNode=this.context.createAnalyser(),this.analyserNode.fftSize=2048,this.analyserNode.smoothingTimeConstant=.4,null===(t=this.sourceNode)||void 0===t||t.connect(this.analyserNode)}catch(e){YN.warning("rebuild analyser node failed.")}}destroy(){this.updateSource(void 0)}}class rP extends Dw{get processSourceNode(){return this.sourceNode}set processedNode(e){var t;if(!this.isDestroyed&&this._processedNode!==e){try{var i;null===(i=this.sourceNode)||void 0===i||i.disconnect(this.outputNode)}catch(e){}null===(t=this._processedNode)||void 0===t||t.disconnect(),this._processedNode=e,this.connect()}}get processedNode(){return this._processedNode}constructor(){super(),YD(this,"outputNode",void 0),YD(this,"outputTrack",void 0),YD(this,"isPlayed",!1),YD(this,"sourceNode",void 0),YD(this,"context",void 0),YD(this,"audioBufferNode",void 0),YD(this,"destNode",void 0),YD(this,"audioOutputLevel",0),YD(this,"volumeLevelAnalyser",void 0),YD(this,"_processedNode",void 0),YD(this,"playNode",void 0),YD(this,"isDestroyed",!1),YD(this,"onNoAudioInput",void 0),YD(this,"isNoAudioInput",!1),YD(this,"_noAudioInputCount",0),this.context=$D(),this.playNode=this.context.destination,this.outputNode=this.context.createGain(),eP(this.outputNode),this.volumeLevelAnalyser=new nP}startGetAudioBuffer(e){this.audioBufferNode||(this.audioBufferNode=this.context.createScriptProcessor(e),this.outputNode.connect(this.audioBufferNode),this.audioBufferNode.connect(this.context.destination),this.audioBufferNode.onaudioprocess=e=>{this.emit(ND.ON_AUDIO_BUFFER,function(e){for(let t=0;t<e.outputBuffer.numberOfChannels;t+=1){const i=e.outputBuffer.getChannelData(t);for(let e=0;e<i.length;e+=1)i[e]=0}return e.inputBuffer}(e))})}stopGetAudioBuffer(){this.audioBufferNode&&(this.audioBufferNode.onaudioprocess=null,this.outputNode.disconnect(this.audioBufferNode),this.audioBufferNode=void 0)}createOutputTrack(){if(!nD().webAudioMediaStreamDest)throw new mw(Ew.NOT_SUPPORTED,"your browser is not support audio processor");return this.destNode&&this.outputTrack||(this.destNode=this.context.createMediaStreamDestination(),this.outputNode.connect(this.destNode),this.outputTrack=this.destNode.stream.getAudioTracks()[0]),this.outputTrack}play(e){"running"!==this.context.state&&$w((()=>{ZD.emit("autoplay-failed")})),this.isPlayed=!0,this.playNode=e||this.context.destination,this.outputNode.connect(this.playNode)}stop(){if(this.isPlayed)try{this.outputNode.disconnect(this.playNode)}catch(e){}this.isPlayed=!1}getAccurateVolumeLevel(){return this.volumeLevelAnalyser.getVolumeLevel()}async checkHasAudioInput(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(e>5)return this.isNoAudioInput=!0,this.onNoAudioInput&&this.onNoAudioInput(),!1;Yb()||ow()?"suspended"===this.context.state&&this.context.resume():"running"!==this.context.state&&this.context.resume();const t=this.volumeLevelAnalyser.getAnalyserNode();let i;t.getFloatTimeDomainData?(i=new Float32Array(t.fftSize),t.getFloatTimeDomainData(i)):(i=new Uint8Array(t.fftSize),t.getByteTimeDomainData(i));let n=!1;for(let e=0;e<i.length;e++)0!==i[e]&&(n=!0);return n?(this.isNoAudioInput=!1,!0):(await uO(200),await this.checkHasAudioInput(e?e+1:1)&&n)}getAudioVolume(){return this.outputNode.gain.value}setVolume(e){this.outputNode.gain.setValueAtTime(e,this.context.currentTime)}destroy(){this.disconnect(),this.stop(),this.isDestroyed=!0,this.onNoAudioInput=void 0}disconnect(){var e,t;null===(e=this.processedNode)||void 0===e||e.disconnect(),null===(t=this.sourceNode)||void 0===t||t.disconnect(),this.outputNode&&this.outputNode.disconnect()}connect(){var e;this.processedNode?null===(e=this.processedNode)||void 0===e||e.connect(this.outputNode):this.sourceNode&&this.sourceNode.connect(this.outputNode),this.volumeLevelAnalyser.updateSource(this.outputNode)}}class oP extends rP{get isFreeze(){return!1}constructor(e,t,i){var n;if(super(),YD(this,"sourceNode",void 0),YD(this,"track",void 0),YD(this,"clonedTrack",void 0),YD(this,"audioElement",void 0),YD(this,"isCurrentTrackCloned",!1),YD(this,"isRemoteTrack",!1),YD(this,"originVolumeLevelAnalyser",void 0),YD(this,"rebuildWebAudio",(async()=>{if(YN.debug("ready to rebuild web audio, state:",this.context.state),this.isNoAudioInput&&await this.checkHasAudioInput(),!this.isNoAudioInput||this.isDestroyed)return document.body.removeEventListener("click",this.rebuildWebAudio,!0),void YN.debug("rebuild web audio success, current volume status",this.getAccurateVolumeLevel());this.context.resume().then((()=>YN.info("resume success"))),YN.debug("rebuild web audio because of ios 12 bugs"),this.disconnect();const e=this.track;this.track=this.track.clone(),this.isCurrentTrackCloned?e.stop():this.isCurrentTrackCloned=!0;const t=new MediaStream([this.track]);this.sourceNode=this.context.createMediaStreamSource(t),eP(this.sourceNode),this.volumeLevelAnalyser.rebuildAnalyser();const i=this.outputNode.gain.value;this.outputNode=this.context.createGain(),this.outputNode.gain.setValueAtTime(i,this.context.currentTime),eP(this.outputNode),this.emit(ND.UPDATE_SOURCE),this.connect(),this.audioElement.srcObject=t,this.isPlayed&&this.play(this.playNode),this.checkHasAudioInput()})),"audio"!==e.kind)throw new mw(Ew.UNEXPECTED_ERROR);this.track=e;const r=new MediaStream([this.track]);if(this.isRemoteTrack=!!t,this.sourceNode=this.context.createMediaStreamSource(r),eP(this.sourceNode),i){const e=i.clone();e.enabled=!0,this.clonedTrack=e,YN.debug("create an unmuted track ".concat(e.id," from the original track ").concat(i.id," to get the volume"));const t=this.context.createMediaStreamSource(new MediaStream([e]));eP(t),this.originVolumeLevelAnalyser=new nP,this.originVolumeLevelAnalyser.updateSource(t)}this.connect(),this.audioElement=document.createElement("audio"),this.audioElement.srcObject=r;const o=xb();t&&o.os===Pb.IOS&&Number(null===(n=o.osVersion)||void 0===n?void 0:n.split(".")[0])<15&&(ZD.on(sD.STATE_CHANGE,(()=>{"suspended"===this.context.state?document.body.addEventListener("click",this.rebuildWebAudio,!0):"running"===this.context.state&&this.rebuildWebAudio()})),this.checkHasAudioInput().then((e=>{e||document.body.addEventListener("click",this.rebuildWebAudio,!0)})))}updateTrack(e){this.sourceNode.disconnect(),this.track=e,this.isCurrentTrackCloned=!1;const t=new MediaStream([e]);this.sourceNode=this.context.createMediaStreamSource(t),eP(this.sourceNode),this.processedNode||this.sourceNode.connect(this.outputNode),this.emit(ND.UPDATE_SOURCE),this.audioElement.srcObject=t}destroy(){var e;this.audioElement.srcObject=null,this.audioElement.remove(),ZD.off("state-change",this.rebuildWebAudio),null===(e=this.originVolumeLevelAnalyser)||void 0===e||e.destroy(),this.clonedTrack=void 0,super.destroy()}createMediaStreamSourceNode(e){return this.context.createMediaStreamSource(new MediaStream([e]))}updateOriginTrack(e){const t=e.clone();t.enabled=!0,this.clonedTrack&&(this.clonedTrack.stop(),this.clonedTrack=t),YN.debug("create an unmuted track ".concat(t.id," from the original track ").concat(e.id," to get the volume"));const i=this.context.createMediaStreamSource(new MediaStream([t]));eP(i),this.originVolumeLevelAnalyser&&this.originVolumeLevelAnalyser.updateSource(i)}getOriginVolumeLevel(){return this.originVolumeLevelAnalyser?this.originVolumeLevelAnalyser.getVolumeLevel():this.getAccurateVolumeLevel()}}async function sP(e,t,i){const n=(e,t)=>e?"number"!=typeof e?e.max||e.exact||e.ideal||e.min||t:e:t,r={audio:!!i&&{mandatory:{chromeMediaSource:"desktop"}},video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e,maxHeight:n(t.height,1080),maxWidth:n(t.width,1920)}}};return t.frameRate&&"number"!=typeof t.frameRate?(r.video.mandatory.maxFrameRate=t.frameRate.max,r.video.mandatory.minFrameRate=t.frameRate.min):"number"==typeof t.frameRate&&(r.video.mandatory.maxFrameRate=t.frameRate),await navigator.mediaDevices.getUserMedia(r)}async function aP(e,t){const i=await cP(e.mediaSource),{sourceId:n,audio:r}=await function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Wh(((i,n)=>{const r=document.createElement("div");r.innerText="share screen",r.setAttribute("style","text-align: center; height: 25px; line-height: 25px; border-radius: 4px 4px 0 0; background: #D4D2D4; border-bottom: solid 1px #B9B8B9;");const o=document.createElement("div");o.setAttribute("style","width: 100%; height: 500px; padding: 15px 25px ; box-sizing: border-box;");const s=document.createElement("div");s.innerText="Agora Web Screensharing wants to share the contents of your screen with webdemo.agorabeckon.com. Choose what you'd like to share.",s.setAttribute("style","height: 12%;");const a=document.createElement("div");a.setAttribute("style","width: 100%; height: 80%; background: #FFF; border: solid 1px #CBCBCB; display: flex; flex-wrap: wrap; justify-content: space-around;
12271 overflow-y: scroll; padding: 0 15px; box-sizing: border-box;");const c=document.createElement("div");c.setAttribute("style","display: flex; justify-content: space-between; padding: 16px 0;");const d=document.createElement("button");d.innerHTML="cancel",d.setAttribute("style","width: 85px;"),d.onclick=()=>{document.body.removeChild(h);const e=new Error("NotAllowedError");e.name="NotAllowedError",n(e)};let l=t;const u=document.createElement("div");if(t){const e=document.createElement("input");e.setAttribute("type","checkbox");const t=document.createElement("span");e.setAttribute("style","margin-right: 6px;"),t.innerText="Share audio",e.checked=l,e.onchange=()=>{l=e.checked},u.appendChild(e),u.appendChild(t)}c.appendChild(u),c.appendChild(d),o.appendChild(s),o.appendChild(a),o.appendChild(c);const h=document.createElement("div");h.setAttribute("style","position: fixed; z-index: 99999999; top: 50%; left: 50%; width: 620px; height: 525px; background: #ECECEC; border-radius: 4px; -webkit-transform: translate(-50%,-50%); transform: translate(-50%,-50%);"),h.appendChild(r),h.appendChild(o),document.body.appendChild(h),e.map((e=>{if(e.id){const t=document.createElement("div");t.setAttribute("style","width: 30%; height: 160px; padding: 20px 0; text-align: center;box-sizing: content-box;");let n=e.thumbnail;try{const{width:e}=n.getSize();e>1920&&(n=n.resize({width:1920}))}catch(e){throw e&&e.message.startsWith("Illegal invocation")&&console.error("Operate thumbnail error, please try to set contextIsolation: false. (https://github.com/electron/electron/issues/34953)"),e}t.innerHTML='<div style="height: 120px; display: table-cell; vertical-align: middle;"><img style="width: 100%; background: #333333; box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.2);" src='+n.toDataURL()+' /></div><span style="\theight: 40px; line-height: 40px; display: inline-block; width: 70%; word-break: keep-all; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">'+e.name.replace(/[\u00A0-\u9999<>\&]/g,(function(e){return"&#"+e.charCodeAt(0)+";"}))+"</span>",t.onclick=()=>{document.body.removeChild(h),i({sourceId:e.id,audio:l})},a.appendChild(t)}}))}))}(i,t);return await sP(n,e,r)}
vendor: 18,358 bytes, line 12271
12271async function cP(e){let t=["window","screen"];"application"!==e&&"window"!==e||(t=["window"]),"screen"===e&&(t=["screen"]);const i=Lw();if(!i)throw console.error("failed to fetch electron, please mount it to window"),new mw(Ew.ELECTRON_IS_NULL);let n=null;try{var r;n=(null===(r=i.desktopCapturer)||void 0===r?void 0:r.getSources({types:t}))||i.ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES",{types:t})}catch(e){n=null}n&&n.then||(n=new Wh(((e,n)=>{i.desktopCapturer.getSources({types:t},((t,i)=>{t?n(t):e(i)}))})));try{return await n}catch(e){throw new mw(Ew.ELECTRON_DESKTOP_CAPTURER_GET_SOURCES_ERROR,e.toString())}}const dP=new IO("safari");let lP=!1,uP=!1;async function hP(e,t){let i=0,n=null;for(;i<2;)try{n=await pP(e,t,i>0);break}catch(e){if(e instanceof mw)throw YN.error("[".concat(t,"] ").concat(e.toString())),e;const n=_P(e.name||e.code||e,e.message);if(n.code===Ew.MEDIA_OPTION_INVALID){YN.debug("[".concat(t,"] detect media option invalid, retry")),i+=1,await uO(500);continue}throw YN.error("[".concat(t,"] ").concat(n.toString())),n}if(!n)throw new mw(Ew.UNEXPECTED_ERROR,"can not find stream after getUserMedia");return n}async function pP(e,t,i){if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new mw(Ew.NOT_SUPPORTED,"can not find getUserMedia");i&&(e.video&&(delete e.video.width,delete e.video.height),e.screen&&(delete e.screen.width,delete e.screen.height));const n=nD(),r=new MediaStream;if(e.audioSource&&r.addTrack(e.audioSource),e.videoSource&&r.addTrack(e.videoSource),!e.audio&&!e.video&&!e.screen)return YN.debug("Using Video Source/ Audio Source"),r;if(e.screen)if(Lw())e.screen.sourceId?EP(r,await sP(e.screen.sourceId,e.screen,!!e.screenAudio)):EP(r,await aP(e.screen,!!e.screenAudio));else if(Gb()&&e.screen.extensionId&&e.screen.mandatory){if(!n.getStreamFromExtension)throw new mw(Ew.NOT_SUPPORTED,"This browser does not support screen sharing");YN.debug("[".concat(t,'] Screen access on chrome stable, looking for extension"'));const i=await(s=e.screen.extensionId,a=t,new Wh(((e,t)=>{try{chrome.runtime.sendMessage(s,{getStream:!0},(i=>{if(!i||!i.streamId)return YN.error("[".concat(a,"] No response from Chrome Plugin. Plugin not installed properly"),i),void t(new mw(Ew.CHROME_PLUGIN_NO_RESPONSE,"No response from Chrome Plugin. Plugin not installed properly"));e(i.streamId)}))}catch(e){YN.error("[".concat(a,"] AgoraRTC screensharing plugin is not accessible(").concat(s,")"),e.toString()),t(new mw(Ew.CHROME_PLUGIN_NOT_INSTALL))}})));e.screen.mandatory.chromeMediaSourceId=i,EP(r,await navigator.mediaDevices.getUserMedia({video:{mandatory:e.screen.mandatory}}))}else if(n.getDisplayMedia){var o;e.screen.mediaSource&&gD(e.screen.mediaSource);const i={width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate,displaySurface:null!==(o=e.screen.displaySurface)&&void 0!==o?o:"screen"===e.screen.mediaSource?"monitor":e.screen.mediaSource},{selfBrowserSurface:n,surfaceSwitching:s,systemAudio:a,preferCurrentTab:c}=e.screen,d={selfBrowserSurface:n,surfaceSwitching:s,systemAudio:a,preferCurrentTab:c};!n&&delete d.selfBrowserSurface,!s&&delete d.surfaceSwitching,!a&&delete d.systemAudio,!c&&delete d.preferCurrentTab,YN.debug("[".concat(t,"] getDisplayMedia:"),JSON.stringify({video:i,audio:e.screenAudio,controls:d})),EP(r,await navigator.mediaDevices.getDisplayMedia(KD({video:i,audio:e.screenAudio},d)))}else{if(!Kb())throw YN.error("[".concat(t,"] This browser does not support screenSharing")),new mw(Ew.NOT_SUPPORTED,"This browser does not support screen sharing");{e.screen.mediaSource&&gD(e.screen.mediaSource);const i={video:{mediaSource:e.screen.mediaSource,width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate}};YN.debug("[".concat(t,"] getUserMedia: ").concat(JSON.stringify(i))),EP(r,await navigator.mediaDevices.getUserMedia(i))}}var s,a;if(!e.video&&!e.audio)return r;let c={video:e.video,audio:e.audio},d=_N("MEDIA_DEVICE_CONSTRAINTS");if(d)try{"string"==typeof d&&(d=JSON.parse(d)),c=TO(c,d)}catch(e){}YN.debug("[".concat(t,"] GetUserMedia"),JSON.stringify(c)),xb();let l,u=null;(Wb()||Yb()||jb())&&(u=await dP.lock());try{l=await navigator.mediaDevices.getUserMedia(c)}catch(e){throw u&&u(),e}return c.audio&&(lP=!0),c.video&&(uP=!0),EP(r,l),u&&u(),r}function _P(e,t){switch(e){case"Starting video failed":case"OverconstrainedError":case"TrackStartError":return new mw(Ew.MEDIA_OPTION_INVALID,"".concat(e,": ").concat(t));case"NotFoundError":case"DevicesNotFoundError":return new mw(Ew.DEVICE_NOT_FOUND,"".concat(e,": ").concat(t));case"NotSupportedError":return new mw(Ew.NOT_SUPPORTED,"".concat(e,": ").concat(t));case"NotReadableError":return new mw(Ew.NOT_READABLE,"".concat(e,": ").concat(t));case"InvalidStateError":case"NotAllowedError":case"PERMISSION_DENIED":case"PermissionDeniedError":return new mw(Ew.PERMISSION_DENIED,"".concat(e,": ").concat(t));case"ConstraintNotSatisfiedError":return new mw(Ew.CONSTRAINT_NOT_SATISFIED,"".concat(e,": ").concat(t));default:return YN.error("getUserMedia unexpected error",e),new mw(Ew.UNEXPECTED_ERROR,"".concat(e,": ").concat(t))}}function EP(e,t){const i=e.getVideoTracks()[0],n=e.getAudioTracks()[0],r=t.getVideoTracks()[0],o=t.getAudioTracks()[0];o&&(n&&e.removeTrack(n),e.addTrack(o)),r&&(i&&e.removeTrack(i),e.addTrack(r))}const mP=new class extends Dw{get state(){return this._state}set state(e){e!==this._state&&(this.emit(FD.STATE_CHANGE,e),this._state=e)}constructor(){super(),YD(this,"_state",VD.IDLE),YD(this,"isAccessMicrophonePermission",!1),YD(this,"isAccessCameraPermission",!1),YD(this,"lastAccessMicrophonePermission",!1),YD(this,"lastAccessCameraPermission",!1),YD(this,"checkdeviceMatched",!1),YD(this,"deviceInfoMap",new Map),this.init().then((()=>{navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",this.updateDevicesInfo.bind(this)),window.setInterval((()=>{(_N("ENUMERATE_DEVICES_INTERVAL")||(lw()||Fb()===Pb.HARMONY_OS)&&dw())&&this.updateDevicesInfo()}),_N("ENUMERATE_DEVICES_INTERVAL_TIME"))})).catch((e=>YN.error(e.toString())))}async enumerateDevices(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices)return new mw(Ew.NOT_SUPPORTED,"enumerateDevices() not supported.").throw();const n=await navigator.mediaDevices.enumerateDevices(),r=this.checkMediaDeviceInfoIsOk(n);let o=!this.isAccessMicrophonePermission&&e,s=!this.isAccessCameraPermission&&t;r.audio&&(o=!1),r.video&&(s=!1);let a=null,c=null,d=null;if(!i&&(o||s)){if(dP.isLocked&&(YN.debug("[device manager] wait GUM lock"),(await dP.lock())(),YN.debug("[device manager] GUM unlock")),lP&&(o=!1,this.isAccessMicrophonePermission=!0),uP&&(s=!1,this.isAccessCameraPermission=!0),YN.debug("[device manager] check media device permissions",e,t,o,s),o&&s){try{d=await navigator.mediaDevices.getUserMedia({audio:!0,video:!0})}catch(e){const t=_P(e.name||e.code||e,e.message);if(t.code===Ew.PERMISSION_DENIED)throw t;YN.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0,this.isAccessMicrophonePermission=!0}else if(o){try{a=await navigator.mediaDevices.getUserMedia({audio:e})}catch(e){const t=_P(e.name||e.code||e,e.message);if(t.code===Ew.PERMISSION_DENIED)throw t;YN.warning("getUserMedia failed in getDevices",t)}this.isAccessMicrophonePermission=!0}else if(s){try{c=await navigator.mediaDevices.getUserMedia({video:t})}catch(e){const t=_P(e.name||e.code||e,e.message);if(t.code===Ew.PERMISSION_DENIED)throw t;YN.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0}YN.debug("[device manager] mic permission",e,"cam permission",t)}try{const e=await navigator.mediaDevices.enumerateDevices();return a&&a.getTracks().forEach((e=>e.stop())),c&&c.getTracks().forEach((e=>e.stop())),d&&d.getTracks().forEach((e=>e.stop())),a=null,c=null,d=null,e}catch(e){return a&&a.getTracks().forEach((e=>e.stop())),c&&c.getTracks().forEach((e=>e.stop())),d&&d.getTracks().forEach((e=>e.stop())),a=null,c=null,d=null,new mw(Ew.ENUMERATE_DEVICES_FAILED,e.toString()).throw()}}async getRecordingDevices(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(await this.enumerateDevices(!0,!1,e)).filter((e=>"audioinput"===e.kind))}async getCamerasDevices(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(await this.enumerateDevices(!1,!0,e)).filter((e=>"videoinput"===e.kind))}async getSpeakers(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(await this.enumerateDevices(!0,!1,e)).filter((e=>"audiooutput"===e.kind))}searchDeviceIdByName(e){let t=null;return this.deviceInfoMap.forEach((i=>{i.device.label===e&&(t=i.device.deviceId)})),t}async getDeviceById(e){const t=(await this.enumerateDevices(!0,!0,!0)).find((t=>t.deviceId===e));if(!t)throw new mw(Ew.DEVICE_NOT_FOUND,"deviceId: ".concat(e));return t}async init(){this.state=VD.INITING;try{await this.updateDevicesInfo(),this.state=VD.INITEND}catch(e){throw YN.warning("Device Detection functionality cannot start properly.",e.toString()),this.state=VD.IDLE,("boolean"==typeof isSecureContext?isSecureContext:"https:"===location.protocol||"file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname||"::1"===location.hostname)||new mw(Ew.WEB_SECURITY_RESTRICT,"Your context is limited by web security, please try using https protocol or localhost.").throw(),e}}async updateDevicesInfo(){const e=await this.enumerateDevices(!0,!0,!0),t=Date.now(),i=[];if(e[0]&&e[0].label&&!1===this.checkdeviceMatched){this.checkdeviceMatched=!0;const t=e.find((e=>"audioinput"===e.kind&&"default"===e.deviceId)),i=e.find((e=>"audiooutput"===e.kind&&"default"===e.deviceId));t&&i?i.groupId===t.groupId?YN.debug("[device-check] default input ".concat(t.label," and output ").concat(i.label," is the same group")):YN.debug("[device-check] default input ".concat(t.label," and output ").concat(i.label," is not the same group")):YN.debug("[device-check] default input or output not found")}const n=this.checkMediaDeviceInfoIsOk(e);if(e.forEach((e=>{if(!e.deviceId)return;const n=this.deviceInfoMap.get("".concat(e.kind,"_").concat(e.deviceId));if("ACTIVE"!==(n?n.state:"INACTIVE")){const n={initAt:t,updateAt:t,device:e,state:"ACTIVE"};this.deviceInfoMap.set("".concat(e.kind,"_").concat(e.deviceId),n),i.push(n)}n&&(n.updateAt=t)})),this.deviceInfoMap.forEach(((e,n)=>{"ACTIVE"===e.state&&e.updateAt!==t&&(e.state="INACTIVE",i.push(e))})),this.state!==VD.INITEND)return n.audio&&(this.lastAccessMicrophonePermission=!0,this.isAccessMicrophonePermission=!0),void(n.video&&(this.lastAccessCameraPermission=!0,this.isAccessCameraPermission=!0));i.forEach((e=>{switch(e.device.kind){case"audioinput":this.lastAccessMicrophonePermission&&this.isAccessMicrophonePermission&&this.emit(FD.RECORDING_DEVICE_CHANGED,e);break;case"videoinput":this.lastAccessCameraPermission&&this.isAccessCameraPermission&&this.emit(FD.CAMERA_DEVICE_CHANGED,e);break;case"audiooutput":this.lastAccessMicrophonePermission&&this.isAccessMicrophonePermission&&this.emit(FD.PLAYOUT_DEVICE_CHANGED,e)}})),n.audio&&(this.lastAccessMicrophonePermission=!0,this.isAccessMicrophonePermission=!0),n.video&&(this.lastAccessCameraPermission=!0,this.isAccessCameraPermission=!0)}checkMediaDeviceInfoIsOk(e){const t=e.filter((e=>"audioinput"===e.kind)),i=e.filter((e=>"videoinput"===e.kind)),n={audio:!1,video:!1};for(const e of t)if(e.label&&e.deviceId){n.audio=!0;break}for(const e of i)if(e.label&&e.deviceId){n.video=!0;break}return n}};let fP=!1;const TP=new class extends Dw{constructor(){super(...arguments),YD(this,"onAutoplayFailed",void 0),YD(this,"onAudioAutoplayFailed",void 0)}};function SP(){if(xb(),!fP){const e=t=>{t.preventDefault(),fP=!1,uw()?document.body.removeEventListener("click",e,!0):(document.body.removeEventListener("touchstart",e,!0),document.body.removeEventListener("mousedown",e,!0))};fP=!0,uw()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0)),YN.info("detect media autoplay failed, document: https://docs.agora.io/cn/Voice/autoplay_policy_web_ng?platform=Web"),TP.onAutoplayFailed?TP.onAutoplayFailed():TP.onAudioAutoplayFailed?YN.warning("AgoraRTC.onAudioAutoplayFailed has been deprecated in favor of AgoraRTC.onAutoplayFailed.\n\n Please refer to the Agora document to migrate the newer API, https://docs.agora.io/en/Voice/autoplay_policy_web_ng?platform=Web ."):YN.warning("We have detected a media autoplay failed event, and found out that you haven't implemented AgoraRTC.onAutoplayFailed callback yet.\n\n It will cause audio/video element not playing automatically on some browsers without user interaction, possibly hurting user experiences.\n\n Please refer to the Agora document to properly handle autoplay failed event, https://docs.agora.io/en/Voice/autoplay_policy_web_ng?platform=Web ."),TP.emit("autoplay-failed")}}function gP(e,t,i,n){if(!e)return;const r=eD.getBaseInfoBySessionId(e);if(!r)return;const o=r.info,s=Date.now(),a=KD(KD({},o),{},{vid:void 0===o.vid?0:Number(o.vid),lts:s,elapse:s-r.startTime,cbRegistered:TP.onAutoplayFailed||TP.onAudioAutoplayFailed?1:-1,errorMsg:i,mediaType:t,trackId:n,extend:void 0});eD.send({type:QN.AUTOPLAY_FAILED,data:a},!0)}const RP=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","error"],vP=new class{constructor(){YD(this,"onAutoplayFailed",void 0),YD(this,"elementMap",new Map),YD(this,"elementStateMap",new Map),YD(this,"elementsNeedToResume",[]),YD(this,"sinkIdMap",new Map),YD(this,"autoResumeAfterInterruption",(e=>{Array.from(this.elementMap.entries()).forEach((t=>{let[i,n]=t;const r=this.elementStateMap.get(i),o=n.srcObject.getAudioTracks()[0],s=o&&o.readyState;if(YN.debug("resume after interrupted, ele: ".concat(r," audio: ").concat(s," ").concat(e)),"live"===s){if(e)return n.pause(),void n.play();if("running"===ZD.curState)return iw()?(n.pause(),void n.play()):void(r&&"paused"===r&&n.play())}}))})),YD(this,"autoResumeAfterInterruptionOnIOS15_16",(()=>{Array.from(this.elementMap.entries()).forEach((e=>{let[t,i]=e;const n=i.srcObject.getAudioTracks()[0];n&&"live"===n.readyState&&(YN.debug("auto resume after interruption inside autoResumeAfterInterruptionOnIOS15"),i.pause(),i.play())}))})),this.autoResumeAudioElement(),ZD.on(sD.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),ZD.on(sD.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),ZD.on(sD.STATE_CHANGE,(()=>{Yb()&&"suspended"===ZD.prevState&&"running"===ZD.curState&&this.autoResumeAfterInterruption()}))}async setSinkID(e,t){const i=this.elementMap.get(e);if(this.sinkIdMap.set(e,t),i)try{await i.setSinkId(t)}catch(e){throw new mw(Ew.PERMISSION_DENIED,"can not set sink id: "+e.toString())}}play(e,t,i,n){if(this.elementMap.has(t))return;const r=document.createElement("audio");r.autoplay=!0,r.srcObject=new MediaStream([e]),this.bindAudioElementEvents(t,r),this.elementMap.set(t,r),this.elementStateMap.set(t,BD.INIT),this.setVolume(t,i);const o=this.sinkIdMap.get(t);if(o)try{r.setSinkId(o).catch((e=>{YN.warning("[".concat(t,"] set sink id failed"),e.toString())}))}catch(e){YN.warning("[".concat(t,"] set sink id failed"),e.toString())}const s=r.play();s&&s.then&&s.catch((e=>{n&&gP(n,"audio",e.message,t),YN.warning("audio element play warning",e.toString()),this.elementMap.has(t)&&"NotAllowedError"===e.name&&(YN.warning("detected audio element autoplay failed"),this.elementsNeedToResume.push(r),$w((()=>{this.onAutoplayFailed&&this.onAutoplayFailed(),SP()})))}))}updateTrack(e,t){const i=this.elementMap.get(e);i&&(i.srcObject=new MediaStream([t]))}isPlaying(e){return this.elementMap.has(e)&&"playing"===this.elementStateMap.get(e)}setVolume(e,t){const i=this.elementMap.get(e);i&&(t=Math.max(0,Math.min(100,t)),i.volume=t/100)}stop(e){const t=this.elementMap.get(e);if(this.sinkIdMap.delete(e),!t)return;const i=this.elementsNeedToResume.indexOf(t);this.elementsNeedToResume.splice(i,1),t.srcObject=null,t.remove(),this.elementMap.delete(e),this.elementStateMap.delete(e)}bindAudioElementEvents(e,t){RP.forEach((i=>{t.addEventListener(i,(i=>{const n=this.elementStateMap.get(e),r="pause"===i.type?"paused":i.type;if(YN.debug("[".concat(e,"] audio-element-status change ").concat(n," => ").concat(r)),"error"===i.type){const i=null==t?void 0:t.error;i&&YN.error("[".concat(e,"] media error, code: ").concat(i.code,", message: ").concat(i.message))}this.elementStateMap.set(e,r)}))}))}getPlayerState(e){return this.elementStateMap.get(e)||"uninit"}autoResumeAudioElement(){const e=()=>{this.elementsNeedToResume.forEach((e=>{e.play().then((e=>{YN.debug("Auto resume audio element success")})).catch((e=>{YN.warning("Auto resume audio element failed!",e)}))})),this.elementsNeedToResume=[]};new Wh((e=>{document.body?e():window.addEventListener("load",(()=>e()))})).then((()=>{uw()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0))}))}};function CP(){return function(e,t,i){const n=i.value;return"function"==typeof n&&(i.value=function(){this._isClosed&&new mw(Ew.INVALID_OPERATION,"[".concat(this.getTrackId(),"] cannot operate a closed track")).print("warning",YN);for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const r=n.apply(this,t);return r instanceof Wh?new Wh(((e,t)=>{r.then(e).catch(t)})):r}),i}}class IP extends Dw{constructor(e){super(),YD(this,"name","VideoProcessorDestination"),YD(this,"ID","0"),YD(this,"_source",void 0),YD(this,"videoContext",void 0),YD(this,"inputTrack",void 0),this.videoContext=e}get kind(){return"video"}get enabled(){return!0}pipe(){throw new mw(Ew.NOT_SUPPORTED,"VideoProcessor cannot pipe to any other Processor")}unpipe(){throw new mw(Ew.NOT_SUPPORTED,"VideoProcessor cannot unpipe to any other Processor")}enable(){}disable(){}updateInput(e){if(e.context!==this.videoContext)throw new Error("ProcessorContext passed to VideoTrack.processorDestination doesn't match it's belonging VideoTrack's context.\nProbably you are making pipeline like this:\nvideoTrack1.pipe(processor).pipe(videoTrack2.processorDestination).");e.track&&e.track!==this.inputTrack&&(this.videoContext.chained=!0,this.inputTrack=e.track,this.emit
12271(UD.ON_TRACK,e.track))}reset(){this.inputTrack=void 0,this.videoContext.chained=!1,this.emit(UD.ON_TRACK,void 0)}}class yP extends Dw{set chained(e){this._chained=e}get chained(){return this._chained}constructor(e,t){super(),YD(this,"constraintsMap",new Map),YD(this,"statsRegistry",[]),YD(this,"usageRegistry",[]),YD(this,"trackId",void 0),YD(this,"direction",void 0),YD(this,"_chained",!1),this.trackId=e,this.direction=t}async getConstraints(){return await Yw(this,xD.REQUEST_CONSTRAINTS)}async requestApplyConstraints(e,t){var i;return YN.info("processor ".concat(t.name," requestApplyConstraints for ").concat(this.trackId)),e&&this.constraintsMap.set(t,e),qw(this,xD.REQUEST_UPDATE_CONSTRAINTS,Array.from(Zh(i=this.constraintsMap).call(i)))}async requestRevertConstraints(e){var t;if(this.constraintsMap.has(e))return YN.info("processor ".concat(e.name," requestRevertConstraints for ").concat(this.trackId)),this.constraintsMap.delete(e),qw(this,xD.REQUEST_UPDATE_CONSTRAINTS,Array.from(Zh(t=this.constraintsMap).call(t)))}registerStats(e,t,i){this.statsRegistry.find((i=>i.processorID===e.ID&&i.processorName===e.name&&i.type===t))||this.statsRegistry.push({processorName:e.name,processorID:e.ID,type:t,cb:i})}unregisterStats(e,t){const i=this.statsRegistry.findIndex((i=>i.processorID===e.ID&&i.processorName===e.name&&i.type===t));-1!==i&&this.statsRegistry.splice(i,1)}gatherStats(){const e=[];for(const{processorID:t,processorName:i,type:n,cb:r}of this.statsRegistry)try{const o=r();e.push({processorID:t,processorName:i,type:n,stats:o})}catch(e){YN.error(new mw(Ew.UNEXPECTED_ERROR,e.message))}return e}registerUsage(e,t){this.usageRegistry.find((t=>t.processorID===e.ID&&t.processorName===e.name))||this.usageRegistry.push({processorID:e.ID,processorName:e.name,cb:t})}unregisterUsage(e){const t=this.usageRegistry.findIndex((t=>t.processorID===e.ID&&t.processorName===e.name));-1!==t&&this.usageRegistry.splice(t,1)}async gatherUsage(){const e=[];if(!this.chained)return[];for(const{cb:t}of this.usageRegistry)try{let i=t();i instanceof Wh&&(i=await i),e.push(KD(KD({},i),{},{direction:this.direction}))}catch(e){YN.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class AP extends Dw{constructor(e){super(),YD(this,"name","AudioProcessorDestination"),YD(this,"ID","0"),YD(this,"inputTrack",void 0),YD(this,"inputNode",void 0),YD(this,"audioProcessorContext",void 0),YD(this,"_source",void 0),this.audioProcessorContext=e}get kind(){return"audio"}get enabled(){return!0}pipe(){throw new mw(Ew.NOT_SUPPORTED,"AudioProcessorDestination cannot pipe to any other Processor")}unpipe(){throw new mw(Ew.NOT_SUPPORTED,"AudioProcessor cannot unpipe to any other Processor")}enable(){}disable(){}reset(){this.inputTrack=void 0,this.inputNode=void 0,this.audioProcessorContext.chained=!1,this.emit(UD.ON_TRACK,void 0),this.emit(UD.ON_NODE,void 0)}updateInput(e){if(e.context!==this.audioProcessorContext)throw new Error("ProcessorContext passed to AudioTrack.processorDestination doesn't match it's belonging AudioTrack's context.\n Probably you are making pipeline like this: audioTrack1.pipe(processor).pipe(audioTrack2.processorDestination).");e.track&&this.inputTrack!==e.track&&(this.audioProcessorContext.chained=!0,this.inputTrack=e.track,this.emit(UD.ON_TRACK,this.inputTrack)),e.node&&this.inputNode!==e.node&&(this.audioProcessorContext.chained=!0,this.inputNode=e.node,this.emit(UD.ON_NODE,this.inputNode))}}class bP extends Dw{set chained(e){this._chained=e}get chained(){return this._chained}constructor(e,t,i){super(),YD(this,"constraintsMap",new Map),YD(this,"statsRegistry",[]),YD(this,"audioContext",void 0),YD(this,"trackId",void 0),YD(this,"direction",void 0),YD(this,"usageRegistry",[]),YD(this,"_chained",!1),this.audioContext=e,this.trackId=t,this.direction=i}async getConstraints(){return Yw(this,xD.REQUEST_CONSTRAINTS)}getAudioContext(){return this.audioContext}async requestApplyConstraints(e,t){var i;return YN.info("processor ".concat(t.name," requestApplyConstraints for ").concat(this.trackId)),e&&this.constraintsMap.set(t,e),qw(this,xD.REQUEST_UPDATE_CONSTRAINTS,Array.from(Zh(i=this.constraintsMap).call(i)))}async requestRevertConstraints(e){var t;if(this.constraintsMap.has(e))return this.constraintsMap.delete(e),qw(this,xD.REQUEST_UPDATE_CONSTRAINTS,Array.from(Zh(t=this.constraintsMap).call(t)))}registerStats(e,t,i){this.statsRegistry.find((i=>i.processorID===e.ID&&i.processorName===e.name&&i.type===t))||this.statsRegistry.push({processorName:e.name,processorID:e.ID,type:t,cb:i})}unregisterStats(e,t){const i=this.statsRegistry.findIndex((i=>i.processorID===e.ID&&i.processorName===e.name&&i.type===t));-1!==i&&this.statsRegistry.splice(i,1)}gatherStats(){const e=[];for(const{processorID:t,processorName:i,type:n,cb:r}of this.statsRegistry)try{const o=r();e.push({processorID:t,processorName:i,type:n,stats:o})}catch(e){YN.error(new mw(Ew.UNEXPECTED_ERROR,e.message))}return e}registerUsage(e,t){this.usageRegistry.find((t=>t.processorID===e.ID&&t.processorName===e.name))||this.usageRegistry.push({processorID:e.ID,processorName:e.name,cb:t})}unregisterUsage(e){const t=this.usageRegistry.findIndex((t=>t.processorID===e.ID&&t.processorName===e.name));-1!==t&&this.usageRegistry.splice(t,1)}async gatherUsage(){const e=[];
12271if(!this.chained)return[];for(const{cb:t}of this.usageRegistry)try{let i=t();i instanceof Wh&&(i=await i),e.push(KD(KD({},i),{},{direction:this.direction}))}catch(e){YN.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class wP extends Dw{get isPlayed(){return!0}get isFreeze(){return!1}constructor(){super(),YD(this,"context",void 0),YD(this,"processSourceNode",void 0),YD(this,"outputTrack",void 0),YD(this,"processedNode",void 0),YD(this,"clonedTrack",void 0),YD(this,"outputNode",void 0),this.outputNode=new OP}setVolume(){}createOutputTrack(){throw new mw(Ew.NOT_SUPPORTED,"can not create output MediaStreamTrack when WebAudio disabled")}getOriginVolumeLevel(){return 0}getAccurateVolumeLevel(){return 0}stopGetAudioBuffer(){}startGetAudioBuffer(){}play(){}stop(){}destroy(){}updateTrack(){}updateOriginTrack(){}createMediaStreamSourceNode(){}}class OP{disconnect(){}connect(){}}function NP(e){return new Wh(((t,i)=>{let n=!1;const r=document.createElement("video");r.setAttribute("autoplay",""),r.setAttribute("muted",""),r.muted=!0,r.autoplay=!0,r.setAttribute("playsinline",""),r.setAttribute("style","position: fixed; top: 0; left: 0; width: 1px; height: 1px"),document.body.appendChild(r);const o=Yb()?"canplay":"playing";r.addEventListener(o,(()=>{const e=r.videoWidth,i=r.videoHeight;!e&&Kb()||(n=!0,r.srcObject=null,r.remove(),t([e,i]))})),r.srcObject=new MediaStream([e]),r.play().catch(_O),setTimeout((()=>{n||(r.srcObject=null,r.remove(),t([r.videoWidth,r.videoHeight]))}),4e3)}))}function DP(e){const t={};e.facingMode&&(t.facingMode=e.facingMode),e.cameraId&&(t.deviceId={exact:e.cameraId});const i=_D(e.encoderConfig);return null!=i.width&&(t.width=i.width),null!=i.height&&(t.height=i.height),!aw()&&i.frameRate&&(t.frameRate=i.frameRate),Hb()&&"object"==typeof t.frameRate&&(t.frameRate.max=60),Kb()&&(t.frameRate={ideal:30,max:30}),t}function PP(e){const t={};return aw()||(void 0!==e.AGC&&(t.autoGainControl=e.AGC),void 0!==e.AEC&&(t.echoCancellation=e.AEC),void 0!==e.ANS&&(t.noiseSuppression=e.ANS,Gb()&&e.ANS&&(t.googHighpassFilter=e.ANS))),t}function LP(e){const t=PP(e);if(e.encoderConfig){const i=TD(e.encoderConfig);t.channelCount=i.stereo?2:1,t.sampleRate=i.sampleRate,t.sampleSize=i.sampleSize}return e.microphoneId&&(t.deviceId={exact:e.microphoneId}),lw()&&(t.sampleRate=void 0),t}const kP=e=>{const t=e._encoderConfig;if(!t)return;const{frameRate:i,width:n,height:r}=e.getMediaStreamTrackSettings();let{frameRate:o=i,width:s=n,height:a=r}=t;if(!o||!s||!a)return;s=gO(s),a=gO(a),o=gO(o);const{max:c,min:d}=function(e,t,i){const n=200*Math.pow(i/15,.6)*Math.pow(e*t/640/360,.75);return{min:Math.floor(n),max:Math.floor(4*n)}}(s,a,o),{bitrateMax:l,bitrateMin:u}=t||{};l||YN.debug("calculate bitrate: [w: ".concat(s,", h: ").concat(a,", fps: ").concat(o,"] => [brMax: ").concat(l,", brMin: ").concat(u,"]"));const{maxFramerate:h}=_N("ENCODER_CONFIG_LIMIT");return h&&"number"==typeof h&&(o=Math.min(o,h)),{frameRate:o,bitrateMax:l||c,bitrateMin:u||d,scaleResolutionDownBy:1,scale:0}},MP=async(e,t,i)=>await(async(e,t,i)=>{const n=function(e){const t=[];for(let i=0;i<e.length;i+=2)t.push(parseInt(e.slice(i,i+2),16));return Uint8Array.from(t)}(RO(""+t+i)).slice(0,16),r=n.slice(0,12),o=await window.crypto.subtle.importKey("raw",n,"AES-GCM",!0,["encrypt"]);return new Uint8Array(await window.crypto.subtle.encrypt({name:"AES-GCM",iv:r},o,e))})(e.buffer,t,i),UP=e=>{const t=document.createElement("canvas");return t.width=2,t.height=2,new Wh(((i,n)=>{t.toBlob((async e=>{if(t.remove(),e){const n=await xP(e);i({buffer:n,width:t.width,height:t.height})}else n(new mw(Ew.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,1)}))},xP=async e=>{const t=await e.arrayBuffer();return new Uint8Array(t)};var VP,FP,BP,jP,GP,WP,HP,KP,YP,qP,zP,XP,JP,QP,ZP,$P,eL,tL,iL,nL,rL,oL,sL,aL,cL,dL,lL,uL,hL,pL,_L,EL,mL,fL,TL,SL,gL,RL,vL,CL;let IL=(VP=$N({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),FP=$N({argsMap:(e,t)=>[e.getTrackId(),t]}),BP=CP(),jP=yO("LocalAudioTrack","_enabledMutex"),GP=$N({argsMap:(e,t)=>[e.getTrackId(),t]}),WP=CP(),HP=yO("LocalAudioTrack","_enabledMutex"),KP=$N({argsMap:(e,t)=>[e.getTrackId(),t]}),YP=CP(),qP=CP(),zP=CP(),XP=$N({argsMap:e=>[e.getTrackId()]}),JP=CP(),QP=$N({argsMap:e=>[e.getTrackId()]}
vendor: 11,209 bytes, line 12271
12271),ZP=CP(),$P=$N({argsMap:e=>[e.getTrackId()]}),eL=$N({argsMap:(e,t)=>[e.getTrackId(),t.name]}),tL=$N({argsMap:e=>[e.getTrackId()]}),qD((iL=class extends XD{get _source(){return this.initWebAudio()}set _source(e){this._trackSource=e}get processorContext(){return this._processorContext||(this._processorContext=this.initProcessor().processorContext),this._processorContext}get processorDestination(){return this._processorDestination||(this._processorDestination=this.initProcessor().processorDestination),this._processorDestination}get isPlaying(){return this._useAudioElement?vP.isPlaying(this.getTrackId()):this._source.isPlayed}get __className__(){return"LocalAudioTrack"}constructor(e,t,i,n){super(e,i),YD(this,"trackMediaType",OD.AUDIO),YD(this,"_encoderConfig",void 0),YD(this,"_trackSource",void 0),YD(this,"metadata",[]),YD(this,"_enabled",!0),YD(this,"_volume",100),YD(this,"_useAudioElement",!0),YD(this,"_bypassWebAudio",!1),YD(this,"processor",void 0),YD(this,"_processorContext",void 0),YD(this,"_processorDestination",void 0),YD(this,"_getOriginVolumeLevel",void 0),this._encoderConfig=t,this._getOriginVolumeLevel=!!n,this._trackSource=new wP,_N("DISABLE_WEBAUDIO")&&(this._bypassWebAudio=!0),_N("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")&&(this._useAudioElement=!1),Wb()&&!QD?setTimeout((()=>this.initWebAudio())):this.initWebAudio()}setVolume(e){Sw(e,"volume",0,1e3),this._volume=e,this._source.setVolume(e/100),this._useAudioElement&&vP.setVolume(this.getTrackId(),e);try{if(this._bypassWebAudio)return void YN.debug("[".concat(this.getTrackId(),"] setVolume returned because no pass through WebAudio."));const e=this._source.createOutputTrack();this._mediaStreamTrack!==e&&(this._mediaStreamTrack=e,qw(this,RD.NEED_REPLACE_TRACK,this).then((()=>{YN.debug("[".concat(this.getTrackId(),"] replace web audio track success"))})).catch((e=>{YN.warning("[".concat(this.getTrackId(),"] replace web audio track failed"),e)})))}catch(e){}}getVolumeLevel(){return this._muted&&this.enabled&&this._getOriginVolumeLevel?this._source.getOriginVolumeLevel():this._source.getAccurateVolumeLevel()}async setPlaybackDevice(e){if(!this._useAudioElement||!rD())throw new mw(Ew.NOT_SUPPORTED,"your browser does not support setting the audio output device");await vP.setSinkID(this.getTrackId(),e)}async setEnabled(e,t,i){return this._setEnabled(e,t,i)}async _setEnabled(e,t,i){if(!i){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(YN.info("[".concat(this.getTrackId(),"] start setEnabled"),e),e){this._originMediaStreamTrack.enabled=!0;try{i||(this._enabled=!0),await qw(this,RD.NEED_ENABLE_TRACK,this),YN.info("[".concat(this.getTrackId(),"] setEnabled to ").concat(e," success"))}catch(e){throw i||(this._enabled=!1),YN.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}}else{this._originMediaStreamTrack.enabled=!1,i||(this._enabled=!1);try{await qw(this,RD.NEED_DISABLE_TRACK,this)}catch(e){throw i||(this._enabled=!0),YN.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}}}async setMuted(e){e!==this._muted&&(this.stateCheck("muted",e),this._muted=e,this._originMediaStreamTrack.enabled=!e,YN.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(e)),e?await qw(this,RD.NEED_MUTE_TRACK,this):await qw(this,RD.NEED_UNMUTE_TRACK,this))}getStats(){nO((()=>{YN.warning("[deprecated] LocalAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalAudioStats instead")}),"localAudioTrackGetStatsWarning");return zw(this,RD.GET_STATS)||KD({},DD)}setAudioFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4096;if(!e)return this._source.removeAllListeners(ND.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(t),this._source.removeAllListeners(ND.ON_AUDIO_BUFFER),this._source.on(ND.ON_AUDIO_BUFFER,(t=>e(t)))}play(){YN.debug("[".concat(this.getTrackId(),"] start audio playback")),this._useAudioElement?(YN.debug("[".concat(this.getTrackId(),"] start audio playback in element")),vP.play(this._mediaStreamTrack,this.getTrackId(),this._volume)):this._source.play()}stop(){YN.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._useAudioElement?vP.stop(this.getTrackId()):this._source.stop()}close(){super.close(),this._processorDestination&&this.unbindProcessorDestinationEvents(this._processorDestination),this._processorContext&&this.unbindProcessorContextEvents(this._processorContext),this.unpipe(),this._processorDestination&&this._processorDestination._source&&this._processorDestination._source.unpipe(),this._source.destroy()}_updatePlayerSource(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];YN.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&vP.updateTrack(this.getTrackId(),this._mediaStreamTrack)}async _updateOriginMediaStreamTrack(e,t){this._originMediaStreamTrack!==e&&(this._originMediaStreamTrack&&(this._originMediaStreamTrack.removeEventListener("ended",this._handleTrackEnded),t&&this._originMediaStreamTrack.stop()),e.addEventListener("ended",this._handleTrackEnded),this._originMediaStreamTrack=e,this._muted&&(this._originMediaStreamTrack.enabled=!1),this.processor&&this._processorContext&&this.processor.updateInput({track:e,context:this._processorContext}),this._mediaStreamTrack!==this._source.outputTrack?(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await qw(this,RD.NEED_REPLACE_TRACK,this)):this._source.updateTrack(this._originMediaStreamTrack),this._getOriginVolumeLevel&&this._source.updateOriginTrack(e))}renewMediaStreamTrack(e){return Wh.resolve(void 0)}pipe(e){if(this._bypassWebAudio)throw new mw(Ew.INVALID_OPERATION,"Can not process AudioTrack when bypassWebAudio set to true.");if(this.processor===e)return e;if(e._source)throw new mw(Ew.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,node:this._source.processSourceNode,context:this.processorContext}),e}unpipe(){var e;if(!this.processor)return;const t=this.processor;null===(e=this._source.processSourceNode)||void 0===e||e.disconnect(),this.processor._source=!1,this.processor=void 0,t.reset()}bindProcessorDestinationEvents(e){e.on(UD.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(!1),this._source.processedNode=this._source.createMediaStreamSourceNode(e),await qw(this,RD.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await qw(this,RD.NEED_REPLACE_TRACK,this))})),e.on(UD.ON_NODE,(e=>{this._source.processedNode=e}))}unbindProcessorDestinationEvents(e){e.removeAllListeners(UD.ON_TRACK),e.removeAllListeners(UD.ON_NODE)}bindProcessorContextEvents(e){e.on(xD.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}unbindProcessorContextEvents(e){e.removeAllListeners(xD.REQUEST_CONSTRAINTS)}initWebAudio(){return this._trackSource instanceof wP&&(this._trackSource=new oP(this._mediaStreamTrack,!1,this._getOriginVolumeLevel?this._mediaStreamTrack:void 0)),this._trackSource}initProcessor(){const e=new bP(this._source.context,this.getTrackId(),"local"),t=new AP(e);return this._processorContext=e,this._processorDestination=t,this.bindProcessorContextEvents(e),this.bindProcessorDestinationEvents(t),this._source.on(ND.UPDATE_SOURCE,(()=>{this.processor&&this.processor.updateInput({node:this._source.processSourceNode,context:e})})),this._useAudioElement&&(this._useAudioElement=!1,this.isPlaying&&(vP.stop(this.getTrackId()),this._source.play()),qw(this,RD.NEED_REPLACE_MIXING_TRACK,this).then((()=>{YN.debug("[".concat(this.getTrackId(),"] replace from origin track to web audio track success"))})).catch((e=>{YN.warning("[".concat(this.getTrackId(),"] replace from origin track to web audio track failed"),e)}))),{processorContext:e,processorDestination:t}}}).prototype,"setVolume",[VP],Object.getOwnPropertyDescriptor(iL.prototype,"setVolume"),iL.prototype),qD(iL.prototype,"setPlaybackDevice",[FP,BP],Object.getOwnPropertyDescriptor(iL.prototype,"setPlaybackDevice"),iL.prototype),qD(iL.prototype,"setEnabled",[jP,GP,WP],Object.getOwnPropertyDescriptor(iL.prototype,"setEnabled"),iL.prototype),qD(iL.prototype,"setMuted",[HP,KP,YP],Object.getOwnPropertyDescriptor(iL.prototype,"setMuted"),iL.prototype),qD(iL.prototype,"getStats",[qP],Object.getOwnPropertyDescriptor(iL.prototype,"getStats"),iL.prototype),qD(iL.prototype,"setAudioFrameCallback",[zP],Object.getOwnPropertyDescriptor(iL.prototype,"setAudioFrameCallback"),iL.prototype),qD(iL.prototype,"play",[XP,JP],Object.getOwnPropertyDescriptor(iL.prototype,"play"),iL.prototype),qD(iL.prototype,"stop",[QP,ZP],Object.getOwnPropertyDescriptor(iL.prototype,"stop"),iL.prototype),qD(iL.prototype,"close",[$P],Object.getOwnPropertyDescriptor(iL.prototype,"close"),iL.prototype),qD(iL.prototype,"pipe",[eL],Object.getOwnPropertyDescriptor(iL.prototype,"pipe"),iL.prototype),qD(iL.prototype,"unpipe",[tL],Object.getOwnPropertyDescriptor(iL.prototype,"unpipe"),iL.prototype),iL),yL=(nL=$N({argsMap:(e,t)=>[e.getTrackId(),t]}),rL=CP(),oL=yO("MicrophoneAudioTrack","_enabledMutex"),sL=$N({argsMap:(e,t,i)=>[e.getTrackId(),t,i]}),aL=CP(),cL=$N({argsMap:e=>[e.getTrackId()]}),qD((dL=class extends IL{get __className__(){return"MicrophoneAudioTrack"}constructor(e,t,i,n){super(e,t.encoderConfig?TD(t.encoderConfig):{},n,_N("GET_VOLUME_OF_MUTED_AUDIO_TRACK")),YD(this,"_config",void 0),YD(this,"_deviceName","default"),YD(this,"_constraints",void 0),YD(this,"_originalConstraints",void 0),YD(this,"_enabled",!0),this._config=t,this._constraints=i,this._originalConstraints=i,this._deviceName=e.label,"boolean"==typeof t.bypassWebAudio&&(this._bypassWebAudio=t.bypassWebAudio),(iw()||nw())&&ZD.bindInterruptDetectorTrack(this)}async setDevice(e){if(YN.info("[".concat(this.getTrackId(),"] start set device to ").concat(e)),this._enabled)try{const t=await mP.getDeviceById(e),i={};i.audio=KD({},this._constraints),i.audio.deviceId={exact:e},this._originMediaStreamTrack.stop();let n=null;try{n=await hP(i,this.getTrackId())}catch(e){throw YN.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),n=await hP({audio:this._constraints},this.getTrackId()),await this._updateOriginMediaStreamTrack(n.getAudioTracks()[0],!1),e}await this._updateOriginMediaStreamTrack(n.getAudioTracks()[0],!1),this._deviceName=t.label,this._config.microphoneId=e,this._constraints.deviceId={exact:e}}catch(e){throw YN.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await mP.getDeviceById(e);this._deviceName=t.label,this._config.microphoneId=e,this._constraints.deviceId={exact:e}}catch(e){throw YN.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}YN.info("[".concat(this.getTrackId(),"] set device to ").concat(e," success"))}async setEnabled(e,t,i){if(t)return YN.debug("[".concat(this.getTrackId(),"] setEnabled false (
12271do not close microphone)")),await super._setEnabled(e);if(!i){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(YN.info("[".concat(this.getTrackId(),"] start setEnabled"),e),_N("AUTO_RESET_AUDIO_ROUTE")&&(Yb()||ow())){const t=navigator.audioSession;t&&(e||(t.type="playback"),t.type="auto")}if(!e){var n;this._originMediaStreamTrack.onended=null,this._originMediaStreamTrack.stop(),null===(n=this._source.clonedTrack)||void 0===n||n.stop(),i||(this._enabled=!1);try{await qw(this,RD.NEED_DISABLE_TRACK,this)}catch(e){throw YN.error("[".concat(this.getTrackId(),"] setEnabled false failed"),e.toString()),e}return}const r=KD({},this._constraints),o=mP.searchDeviceIdByName(this._deviceName);o&&!r.deviceId&&(r.deviceId=o);try{i||(this._enabled=!0);const e=await hP({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getAudioTracks()[0],!1),await qw(this,RD.NEED_ENABLE_TRACK,this)}catch(e){throw i||(this._enabled=!1),YN.error("[".concat(this.getTrackId(),"] setEnabled true failed"),e.toString()),e}YN.info("[".concat(this.getTrackId(),"] setEnabled success"))}close(){super.close(),(iw()||nw())&&ZD.unbindInterruptDetectorTrack(this)}onTrackEnded(){if((Yb()||ow())&&this._enabled&&!this._isClosed&&ZD.duringInterruption){const e=async()=>{ZD.off(sD.IOS_INTERRUPTION_END,e),this._enabled&&!this._isClosed&&(YN.debug("[".concat(this.getTrackId(),"] try capture microphone media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};ZD.on(sD.IOS_INTERRUPTION_END,e)}else YN.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(bD.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,i=mP.searchDeviceIdByName(this._deviceName);if(i&&!t.deviceId&&(t.deviceId=i),this._constraints=t,this._enabled){this._originMediaStreamTrack.stop();const e=await hP({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getAudioTracks()[0],!0)}}bindProcessorContextEvents(e){super.bindProcessorContextEvents(e),e.on(xD.REQUEST_UPDATE_CONSTRAINTS,(async(e,t,i)=>{try{const i=Object.assign({},this._originalConstraints,...e);await this.renewMediaStreamTrack(i),t()}catch(e){i(e)}}))}unbindProcessorContextEvents(e){super.unbindProcessorContextEvents(e),e.removeAllListeners(xD.REQUEST_UPDATE_CONSTRAINTS)}}).prototype,"setDevice",[nL,rL],Object.getOwnPropertyDescriptor(dL.prototype,"setDevice"),dL.prototype),qD(dL.prototype,"setEnabled",[oL,sL,aL],Object.getOwnPropertyDescriptor(dL.prototype,"setEnabled"),dL.prototype),qD(dL.prototype,"close",[cL],Object.getOwnPropertyDescriptor(dL.prototype,"close"),dL.prototype),dL),AL=(lL=$N({argsMap:(e,t)=>[e.getTrackId(),t,e.duration]}),uL=CP(),hL=$N({argsMap:e=>[e.getTrackId()]}),pL=CP(),_L=$N({argsMap:e=>[e.getTrackId()]}),EL=CP(),mL=$N({argsMap:e=>[e.getTrackId()]}),fL=CP(),TL=$N({argsMap:e=>[e.getTrackId()]}),SL=CP(),gL=$N({argsMap:e=>[e.getTrackId()]}),RL=$N({argsMap:e=>[e.getTrackId()]}),vL=CP(),qD((CL=class extends IL{get __className__(){return"BufferSourceAudioTrack"}constructor(e,t,i,n){super(t.createOutputTrack(),i,n),YD(this,"source",void 0),YD(this,"_bufferSource",void 0),this._useAudioElement=!1,this.source=e,this._bufferSource=t,this._bufferSource.on(ND.AUDIO_SOURCE_STATE_CHANGE,(e=>{this.safeEmit(bD.SOURCE_STATE_CHANGE,e)}));try{this._mediaStreamTrack=this._source.createOutputTrack()}catch(e){}}get currentState(){return this._bufferSource.currentState}get duration(){return this._bufferSource.duration}get playbackSpeed(){return this._bufferSource.playbackSpeed}getCurrentTime(){return this._bufferSource.currentTime}startProcessAudioBuffer(e){e&&this._bufferSource.updateOptions(e),this._bufferSource.startProcessAudioBuffer()}pauseProcessAudioBuffer(){this._bufferSource.pauseProcessAudioBuffer()}seekAudioBuffer(e){this._bufferSource.seekAudioBuffer(e)}resumeProcessAudioBuffer(){this._bufferSource.resumeProcessAudioBuffer()}stopProcessAudioBuffer(){this._bufferSource.stopProcessAudioBuffer()}close(){this.source=null,this._bufferSource.destroy(),super.close()}
vendor: 7,229 bytes, line 12271
12271setAudioBufferPlaybackSpeed(e){Sw(e,"speed",0),this._bufferSource.setAudioBufferPlaybackSpeed(e)}}).prototype,"startProcessAudioBuffer",[lL,uL],Object.getOwnPropertyDescriptor(CL.prototype,"startProcessAudioBuffer"),CL.prototype),qD(CL.prototype,"pauseProcessAudioBuffer",[hL,pL],Object.getOwnPropertyDescriptor(CL.prototype,"pauseProcessAudioBuffer"),CL.prototype),qD(CL.prototype,"seekAudioBuffer",[_L,EL],Object.getOwnPropertyDescriptor(CL.prototype,"seekAudioBuffer"),CL.prototype),qD(CL.prototype,"resumeProcessAudioBuffer",[mL,fL],Object.getOwnPropertyDescriptor(CL.prototype,"resumeProcessAudioBuffer"),CL.prototype),qD(CL.prototype,"stopProcessAudioBuffer",[TL,SL],Object.getOwnPropertyDescriptor(CL.prototype,"stopProcessAudioBuffer"),CL.prototype),qD(CL.prototype,"close",[gL],Object.getOwnPropertyDescriptor(CL.prototype,"close"),CL.prototype),qD(CL.prototype,"setAudioBufferPlaybackSpeed",[RL,vL],Object.getOwnPropertyDescriptor(CL.prototype,"setAudioBufferPlaybackSpeed"),CL.prototype),CL);class bL extends IL{get __className__(){return"MixingAudioTrack"}get isActive(){for(const e of this.trackList)if(e._enabled&&!e._isClosed&&!e.muted)return!0;return!1}constructor(){const e=$D().createMediaStreamDestination();super(e.stream.getAudioTracks()[0],void 0,hO(8,"track-mix-")),YD(this,"trackList",void 0),YD(this,"destNode",void 0),this._useAudioElement=!1;try{this._mediaStreamTrack=this._source.createOutputTrack()}catch(e){}this.destNode=e,this.trackList=[]}hasAudioTrack(e){return-1!==this.trackList.indexOf(e)}addAudioTrack(e){-1===this.trackList.indexOf(e)?(YN.debug("add ".concat(e.getTrackId()," to mixing track")),e._source.outputNode.connect(this.destNode),this.trackList.push(e),this.updateEncoderConfig()):YN.debug("track ".concat(e.getTrackId()," is already added"))}removeAudioTrack(e){if(-1!==this.trackList.indexOf(e)){YN.debug("remove ".concat(e.getTrackId()," from mixing track"));try{e._source.outputNode.disconnect(this.destNode)}catch(e){}Qw(this.trackList,e),this.updateEncoderConfig()}}updateEncoderConfig(){const e={};this.trackList.forEach((t=>{t._encoderConfig&&((t._encoderConfig.bitrate||0)>(e.bitrate||0)&&(e.bitrate=t._encoderConfig.bitrate),(t._encoderConfig.sampleRate||0)>(e.sampleRate||0)&&(e.sampleRate=t._encoderConfig.sampleRate),(t._encoderConfig.sampleSize||0)>(e.sampleSize||0)&&(e.sampleSize=t._encoderConfig.sampleSize),t._encoderConfig.stereo&&(e.stereo=!0))})),this._encoderConfig=e}_updateRtpTransceiver(e){this._rtpTransceiver!==e&&(this._rtpTransceiver=e,this.trackList.forEach((t=>{t instanceof bL?t.emit(AD.TRANSCEIVER_UPDATED,e):t._updateRtpTransceiver(e)})))}}class wL extends rP{set currentState(e){e!==this._currentState&&(this._currentState=e,this.safeEmit(ND.AUDIO_SOURCE_STATE_CHANGE,this._currentState))}get currentState(){return this._currentState}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),YD(this,"audioBuffer",void 0),YD(this,"sourceNode",void 0),YD(this,"startPlayTime",0),YD(this,"startPlayOffset",0),YD(this,"pausePlayTime",0),YD(this,"options",void 0),YD(this,"currentLoopCount",0),YD(this,"currentPlaybackSpeed",100),YD(this,"_currentState","stopped"),this.audioBuffer=e,this.options=t,this.startPlayOffset=this.options.startPlayTime||0}createWebAudioDiagram(){return this.context.createGain()}get duration(){return this.audioBuffer?this.audioBuffer.duration:0}get playbackSpeed(){return this.currentPlaybackSpeed}get currentTime(){return this.audioBuffer?"stopped"===this.currentState?0:"paused"===this.currentState?this.pausePlayTime:((this.context.currentTime-this.startPlayTime)*(this.playbackSpeed/100)+this.startPlayOffset)%this.audioBuffer.duration:0}updateOptions(e){"stopped"===this.currentState?(this.options=e,this.startPlayOffset=this.options.startPlayTime||0):YN.warning("can not set audio source options")}startProcessAudioBuffer(){this.sourceNode&&this.stopProcessAudioBuffer(),this.sourceNode=this.createSourceNode(),this.startSourceNode(),this.currentState="playing"}pauseProcessAudioBuffer(){this.sourceNode&&"playing"===this.currentState&&(this.pausePlayTime=this.currentTime,this.sourceNode.onended=null,this.sourceNode.stop(),this.sourceNode.buffer=null,this.sourceNode=this.createSourceNode(),this.currentState="paused")}seekAudioBuffer(e){this.sourceNode&&(this.sourceNode.onended=null,"playing"===this.currentState&&this.sourceNode.stop(),this.sourceNode=this.createSourceNode(),"playing"===this.currentState?(this.startPlayOffset=e,this.startSourceNode()):"paused"===this.currentState&&(this.pausePlayTime=e))}resumeProcessAudioBuffer(){"paused"===this.currentState&&this.sourceNode&&(this.startPlayOffset=this.pausePlayTime,this.pausePlayTime=0,this.startSourceNode(),this.currentState="playing")}stopProcessAudioBuffer(){if(this.sourceNode){this.sourceNode.onended=null;try{this.sourceNode.stop()}catch(e){}this.reset()}}destroy(){this.audioBuffer=null,super.destroy()}setAudioBufferPlaybackSpeed(e){this.sourceNode&&("playing"===this.currentState&&(this.startPlayOffset=this.currentTime,this.startPlayTime=this.context.currentTime),this.sourceNode.playbackRate.value=e/100),this.currentPlaybackSpeed=e}startSourceNode(){this.sourceNode&&this.sourceNode.buffer&&(this.sourceNode.start(0,this.startPlayOffset),this.startPlayTime=this.context.currentTime,this.sourceNode.onended=this.handleSourceNodeEnded.bind(this))}createSourceNode(){const e=this.context.createBufferSource();return e.buffer=this.audioBuffer,e.loop=!!this.options.loop,e.connect(this.outputNode),e.playbackRate.value=this.currentPlaybackSpeed/100,e}handleSourceNodeEnded(){if(this.currentLoopCount+=1,this.options.cycle&&this.options.cycle>this.currentLoopCount)return this.startPlayOffset=0,this.sourceNode=void 0,void this.startProcessAudioBuffer();this.reset()}reset(){this.startPlayOffset=this.options.startPlayTime||0,this.currentState="stopped",this.sourceNode&&(this.sourceNode.disconnect(),this.sourceNode=void 0),this.currentLoopCount=0}}const OL=new Map;class NL{get rendFrameRate(){if(this.renderStats&&this.renderStats.curTs!==this.renderStats.lastTs){const e=this.renderStats.curTs-this.renderStats.lastTs,t=(this.renderStats.renderNum-this.renderStats.lastRenderNum)/e;return this.renderStats.lastRenderNum=this.renderStats.renderNum,this.renderStats.lastTs=this.renderStats.curTs,t}return 0}get videoElementStatus(){return this._videoElementStatus}set videoElementStatus(e){e!==this._videoElementStatus&&(YN.debug("[".concat(this.trackId,"] video-element-status change ").concat(this._videoElementStatus," => ").concat(e)),this._videoElementStatus=e)}get videoState(){return this._videoState}set videoState(e){var t;e!==this._videoState&&(this._videoState=e,null===(t=this.onVideoStateChanged)||void 0===t||t.call(this,this.videoState))}constructor(e){YD(this,"trackId",void 0),YD(this,"config",void 0),YD(this,"onFirstVideoFrameDecoded",void 0),YD(this,"onVideoStateChanged",void 0),YD(this,"freezeTimeCounterList",[]),YD(this,"renderFreezeAccTime",0),YD(this,"isKeepLastFrame",!1),YD(this,"timeUpdatedCount",0),YD(this,"freezeTime",0),YD(this,"playbackTime",0),YD(this,"lastTimeUpdatedTime",0),YD(this,"autoplayFailed",!1),YD(this,"videoTrack",void 0),YD(this,"videoElement",void 0),YD(this,"cac
12271heVideoElement",void 0),YD(this,"renderStats",void 0),YD(this,"_videoState",jD.VideoStateStopped),YD(this,"videoElementCheckInterval",void 0),YD(this,"videoElementFreezeTimeout",void 0),YD(this,"_videoElementStatus",BD.NONE),YD(this,"isGettingVideoDimensions",!1),YD(this,"startGetVideoDimensions",(()=>{const e=()=>{if(this.isGettingVideoDimensions=!0,this.videoElement.videoWidth*this.videoElement.videoHeight>4)return YN.debug("[".concat(this.trackId,"] current video dimensions:"),this.videoElement.videoWidth,this.videoElement.videoHeight),void(this.isGettingVideoDimensions=!1);setTimeout(e,500)};!this.isGettingVideoDimensions&&e()})),YD(this,"autoResumeAfterInterruption",(()=>{this.videoTrack&&"live"===this.videoTrack.readyState&&"running"===ZD.curState&&(YN.debug("[track-".concat(this.trackId,"] video element paused, auto resume for ").concat(Bb())),rw()?(this.videoElement.srcObject=null,this.videoElement.srcObject=new MediaStream([this.videoTrack]),this.videoElement.play()):(this.videoElement.pause(),this.videoElement.play()))})),YD(this,"handleVideoEvents",(e=>{switch(e.type){case"play":case"playing":this.startGetVideoDimensions(),this.videoElementStatus=BD.PLAYING;break;case"loadeddata":if(this.videoState=jD.VideoStateStarting,this.onFirstVideoFrameDecoded&&this.onFirstVideoFrameDecoded(),this.cacheVideoElement){try{this.cacheVideoElement.srcObject=null,this.cacheVideoElement.remove()}catch(e){}this.cacheVideoElement=void 0}break;case"canplay":this.videoElementStatus=BD.CANPLAY;break;case"stalled":this.videoElementStatus=BD.STALLED;break;case"suspend":this.videoElementStatus=BD.SUSPEND;break;case"pause":this.videoElementStatus=BD.PAUSED,Yb()||ow()||Wb()&&this.autoplayFailed||!this.videoTrack||"live"!==this.videoTrack.readyState||(YN.debug("[track-".concat(this.trackId,"] video element paused, auto resume")),this.videoElement.play());break;case"waiting":this.videoElementStatus=BD.WAITING;break;case"abort":this.videoElementStatus=BD.ABORT;break;case"ended":this.videoElementStatus=BD.ENDED;break;case"emptied":this.videoElementStatus=BD.EMPTIED;break;case"error":{const e=this.videoElement.error;e&&(this.videoElementStatus=BD.ERROR,YN.error("[".concat(this.trackId,"] media error: ").concat(e.message," (").concat(e.code,")")));break}case"timeupdate":{const e=performance.now();if(this.timeUpdatedCount+=1,this.timeUpdatedCount<10)return void(this.lastTimeUpdatedTime=e);const t=e-this.lastTimeUpdatedTime,i=this.lastTimeUpdatedTime;if(this.lastTimeUpdatedTime=e,Dk.lastVisibleTime<Dk.lastHiddenTime||i<Dk.lastHiddenTime||i<Dk.lastVisibleTime)return;for(t>_N("VIDEO_FREEZE_DURATION")&&(this.freezeTime+=t),this.playbackTime+=t;this.playbackTime>=6e3;){this.playbackTime-=6e3;const e=Math.min(6e3,this.freezeTime);this.freezeTimeCounterList.push(e),this.freezeTime=Math.max(0,this.freezeTime-6e3)}break}}})),YD(this,"autoResumeAfterInterruptionOnIOS15_16",(()=>{this.videoTrack&&"live"===this.videoTrack.readyState&&(YN.debug("[track-".concat(this.trackId,"] video element paused, auto resume for ").concat(Bb())),rw()?(this.videoElement.srcObject=null,this.videoElement.srcObject=new MediaStream([this.videoTrack]),this.videoElement.play()):(this.videoElement.pause(),this.videoElement.play()))})),this.trackId=e.trackId,this.config=e,e.element instanceof HTMLVideoElement?this.videoElement=e.element:this.videoElement=document.createElement("video"),ZD.on(sD.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),ZD.on(sD.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16)}getVideoElement(){return this.videoElement}getContainerElement(){var e;return null!==(e=this.videoElement.parentElement)&&void 0!==e?e:void 0}updateConfig(e){this.config=e,this.trackId=e.trackId,e.element!==this.videoElement&&(this.destroy(),this.videoElement=e.element),this.videoTrack&&this.initVideoElement()}updateVideoTrack(e){this.videoTrack!==e&&(this.videoTrack=e,this.initVideoElement())}play(e){const t=this.videoElement.play();t&&t.catch&&t.catch((t=>{e&&gP(e,"video",t.message,this.trackId),"NotAllowedError"===t.name?(YN.warning("detected video element autoplay failed",t),this.autoplayFailed=!0,this.handleAutoPlayFailed()):YN.warning("[".concat(this.trackId,"] play warning: "),t)}));const i=xb();if(("Safari"===i.name&&15===Number(i.version)||iw())&&t&&t.then){const e=()=>{this.config.mirror&&(this.videoElement.style.transform="rotateY(180deg)")};t.then(e).catch(e)}}getCurrentFrame(){const e=document.createElement("canvas");e.width=this.videoElement.videoWidth,e.height=this.videoElement.videoHeight;const t=e.getContext("2d");if(!t)return YN.error("create canvas context failed!"),new ImageData(2,2);t.drawImage(this.videoElement,0,0,e.width,e.height);const i=t.getImageData(0,0,e.width,e.height);return e.remove(),i}async getCurrentFrameToUint8Array(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const i=document.createElement("canvas");i.width=this.videoElement.videoWidth,i.height=this.videoElement.videoHeight;const n=i.getContext("2d");return n?(n.drawImage(this.videoElement,0,0,i.width,i.height),new Wh(((n,r)=>{i.toBlob((async e=>{if(i.remove(),e){const t=await xP(e);n({buffer:t,width:i.width,height:i.height})}else r(new mw(Ew.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,t<0?.1:t>1?1:t)}))):await UP(e)}destroy(){this.renderStats=void 0,ZD.off(sD.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),ZD.off(sD.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),this.videoElement.srcObject=null,this.resetVideoElement(),this.freezeTimeCounterList=[],this.videoState=jD.VideoStateStopped}initVideoElement(){if(this.videoElementStatus=BD.INIT,!this.videoElementCheckInterval&&(DL.forEach((e=>{this.videoElement.addEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval=window.setInterval((()=>{(function(e){return e!==document.body&&document.body.contains(e)})(this.videoElement)||(this.videoElementStatus=BD.DESTROYED)}),1e3),_N("ENABLE_VIDEO_FRAME_CALLBACK"))){var e,t;let i;const n=()=>{"visible"===document.visibilityState&&(document.removeEventListener("visibilitychange",n),this.videoElementFreezeTimeout=window.setTimeout(r,_N("VIDEO_FREEZE_DURATION")))},r=()=>{this.videoElementFreezeTimeout=void 0,this.videoState===jD.VideoStateDecoding&&("visible"===document.visibilityState?this.videoState=jD.VideoStateFrozen:document.addEventListener("visibilitychange",n))},o=(e,t)=>{if(this.videoElementStatus===BD.PLAYING){if(this.renderStats?(this.renderStats.renderNum++,this.renderStats.curTs=t.mediaTime):this.renderStats={lastTs:t.mediaTime,curTs:t.mediaTime,lastRenderNum:0,renderNum:0},i){const e=t.presentationTime-i.presentationTime;this.videoState===jD.VideoStateStarting&&(this.videoState=jD.VideoStateDecoding),this.videoState===jD.VideoStateDecoding&&this.onVideoStateChanged&&(this.videoElementFreezeTimeout&&window.clearTimeout(this.videoElementFreezeTimeout),this.videoElementFreezeTimeout=window.setTimeout(r,_N("VIDEO_FREEZE_DURATION"))),e<_N("VIDEO_FREEZE_DURATION")&&this.videoState===jD.VideoStateFrozen&&(this.videoState=jD.VideoStateDecoding),e>_N("VIDEO_FREEZE_DURATION")&&Dk.lastVisibleTime>=Dk.lastHiddenTime&&i.timestamp>Dk.lastVisibleTime&&i.timestamp>Dk.lastHiddenTime&&(this.renderFreezeAccTime+=e)}i=KD(KD({},t),{},{timestamp:e})}var n,s;_N("ENABLE_VIDEO_FRAME_CALLBACK")&&(null===(n=(s=this.videoElement).requestVideoFrameCallback)||void 0===n||n.call(s,o))};null===(e=(t=this.videoElement).requestVideoFrameCallback)||void 0===e||e.call(t,o)}this.videoElement.controls=!1,this.videoElement.setAttribute("playsinline",""),lw()&&!_N("HIDE_NO_POSTER")&&(this.videoElement.poster="noposter");const i=xb();"Safari"===i.name&&15===Number(i.version)||iw()||!this.config.mirror||(this.videoElement.style.transform="rotateY(180deg)"),this.config.fit?this.videoElement.style.objectFit=this.config.fit:this.videoElement.style.objectFit="cover",this.videoElement.setAttribute("muted",""),this.videoElement.muted=!0,this.videoElement.srcObject&&this.videoElement.srcObject instanceof MediaStream?this.videoElement.srcObject.getVideoTracks()[0]!==this.videoTrack&&(this.videoElement.srcObject=this.videoTrack?new MediaStream([this.videoTrack]):null,Kb()&&this.videoElement.load()):(this.videoElement.srcObject=this.videoTrack?new MediaStream([this.videoTrack]):null,Kb()&&this.videoElement.load());const n=this.videoElement.play();void 0!==n&&n.catch((e=>{YN.debug("[".concat(this.trackId,"] playback interrupted"),e.toString())}))}resetVideoElement(){DL.forEach((e=>{this.videoElement&&this.videoElement.removeEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval&&(window.clearInterval(this.videoElementCheckInterval),this.videoElementCheckInterval=void 0),this.videoElementStatus=BD.NONE}handleAutoPlayFailed(){const e=t=>{t.preventDefault(),this.videoElement.play().then((()=>{YN.debug("[".concat(this.trackId,"] Video element for trackId:").concat(this.trackId," autoplay resumed."))})).catch((e=>{YN.error(e)})),this.autoplayFailed=!1,uw()?document.body.removeEventListener("click",e,!0):(document.body.removeEventListener("touchstart",e,!0),document.body.removeEventListener("mousedown",e,!0))};uw()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0)),SP()}}const DL=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","timeupdate","error"];class PL extends NL{constructor(e){super(e),YD(this,"container",void 0),YD(this,"slot",void 0),this.slot=e.element,this.updateConfig(e)}updateConfig(e){this.config=e,this.trackId=e.trackId;const t=e.element;t!==this.slot&&(this.destroy(),this.slot=t),this.createElements()}updateVideoTrack(e){this.videoTrack!==e&&(this.videoTrack=e,this.createElements())}play(e){var t;null!==(t=this.container)&&void 0!==t&&t.contains(this.videoElement)&&super.play(e)}getCurrentFrame(){var e;return null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)?super.getCurrentFrame():new ImageData(2,2)}async getCurrentFrameToUint8Array(e){var t;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return null!==(t=this.container)&&void 0!==t&&t.contains(this.videoElement)?await super.getCurrentFrameToUint8Array(e,i):await UP(e)}destroy(){if(super.destroy(),this.videoElement.remove(),this.videoElement=document.createElement("video"),this.container){try{this.container.remove(),this.slot.removeChild(this.container)}catch(e){}this.container=void 0}}createElements(){this.container||(this.container=document.createElement("div")),this.container.id="agora-video-player-".concat(this.trackId),this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="relative",this.container.style.overflow="hidden",this.videoTrack?(this.container.style.backgroundColor="black",_N("KEEP_LAST_FRAME")&&this.isKeepLastFrame&&this.videoElement.paused&&this.resetVideoElement(),this.mountedVideoElement()):this.unmountedVideoElement(),this.slot.appendChild(this.container)}mountedVideoElement(){var e;!this.container||null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)||this.container.appendChild(this.videoElement),super.initVideoElement(),this.videoElement.id="video_".concat(this.trackId),this.videoElement.className="agora_video_player",this.videoElement.style.width="100%",this.videoElement.style.height="100%",this.videoElement.style.position="absolute",this.videoElement.style.left="0",this.videoElement.style.top="0"}unmountedVideoElement(){var e;if(null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)){super.resetVideoElement();try{this.container&&this.container.removeChild(this.videoElement)}catch(e){}this.videoElement=document.createElement("video")}}resetVideoElement(){var e;null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)&&(super.resetVideoElement(),this.cacheVideoElement=this.videoElement,this.videoElement=document.createElement("video"))}getContainerElement(){return this.container}}
vendor: 5,074 bytes, line 12271
12271var LL,kL,ML,UL,xL,VL,FL,BL,jL,GL,WL,HL,KL,YL,qL,zL,XL,JL,QL,ZL,$L,ek,tk,ik,nk,rk,ok,sk,ak,ck,dk,lk,uk,hk;let pk=(LL=$N({argsMap:(e,t,i)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",i]}),kL=CP(),ML=$N({argsMap:e=>[e.getTrackId()]}),UL=yO("LocalVideoTrack","_enabledMutex"),xL=$N({argsMap:(e,t)=>[e.getTrackId(),t]}),VL=CP(),FL=yO("LocalVideoTrack","_enabledMutex"),BL=$N({argsMap:(e,t)=>[e.getTrackId(),t]}),jL=CP(),GL=$N({argsMap:(e,t)=>[e.getTrackId(),t]}),WL=CP(),HL=CP(),KL=$N({argsMap:(e,t,i)=>[e.getTrackId(),t,i]}),YL=CP(),qL=CP(),zL=CP(),XL=CP(),JL=CP(),QL=CP(),ZL=CP(),$L=$N({argsMap:(e,t)=>[e.getTrackId(),t.name]}),ek=$N({argsMap:e=>[e.getTrackId()]}),tk=$N({argsMap:e=>[e.getTrackId()]}),ik=$N({argsMap:(e,t,i)=>[e.getTrackId(),t.label,i]}),nk=class e extends XD{get videoHeight(){if(Wb()){const{height:e}=this._mediaStreamTrack.getSettings();return this._videoHeight=e,this._videoHeight}return this._videoHeight}get videoWidth(){if(Wb()){const{width:e}=this._mediaStreamTrack.getSettings();return this._videoWidth=e,this._videoWidth}return this._videoWidth}get isPlaying(){return!(!this._player||this._player.videoElementStatus!==BD.PLAYING)}get processorDestination(){return this._processorDestination}get processorContext(){return this._processorContext}set processorContext(e){this._processorContext=e}get __className__(){return"LocalVideoTrack"}constructor(e,t,i,n,r,o){if(super(e,r),YD(this,"trackMediaType",OD.VIDEO),YD(this,"_player",void 0),YD(this,"isUseScaleResolutionDownBy",!1),YD(this,"_videoVisibleTimer",null),YD(this,"_previousVideoVisibleStatus",void 0),YD(this,"_clearPreviousVideoVisibleStatus",(()=>this._previousVideoVisibleStatus=void 0)),YD(this,"_encoderConfig",void 0),YD(this,"_scalabilityMode",{numSpatialLayers:1,numTemporalLayers:1}),YD(this,"_optimizationMode",void 0),YD(this,"_videoHeight",void 0),YD(this,"_videoWidth",void 0),YD(this,"_forceBitrateLimit",void 0),YD(this,"_enabled",!0),YD(this,"_processorDestination",void 0),YD(this,"_processorContext",void 0),Wb()){const{width:t,height:i}=e.getSettings();this._videoWidth=t,this._videoHeight=i}else this.updateMediaStreamTrackResolution();if(this._encoderConfig=t,this._scalabilityMode=i,this._optimizationMode=n,this._hints=o||[],-1===this._hints.indexOf(vD.SCREEN_TRACK))this.updateBitrateFromProfile();else if(Xb(Lb.CHROME,115)&&-1!==Fb().indexOf("Windows")){const t=function(e,t){if("VideoFrame"in window&&"TransformStream"in window&&nD().supportWebRTCInsertableStream){const i=new MediaStreamTrackProcessor(e),n=new MediaStreamTrackGenerator({kind:"video"});let r,o,s=Date.now();const a=()=>{c&&(clearInterval(c),c=void 0),r&&(r.close(),r=void 0),e.stop(),o=void 0,n.removeEventListener("ended",a)};let c=window.setInterval((()=>{if(o&&r&&Date.now()-s>(null!=t?t:1e3))try{"live"===n.readyState?o.enqueue(r.clone()):a()}catch(e){a()}}),null!=t?t:1e3);const d=new TransformStream({transform:(e,t)=>{"live"===n.readyState?(o=t,s=Date.now(),void 0===r?(r=e,t.enqueue(e.clone())):(t.enqueue(r),r=e)):e.close()}});return n.addEventListener("ended",a),i.readable.pipeThrough(d).pipeTo(n.writable),n}}(e);t&&(YN.info("local screen video track begin to inject frame"),this._mediaStreamTrack=t)}t&&-1!==this._hints.indexOf(vD.CUSTOM_TRACK)&&this.setEncoderConfiguration(t),this._processorContext=new yP(this.getTrackId(),"local"),this._processorDestination=new IP(this.processorContext),this.bindProcessorDestinationEvents()}play(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof e){const t=document.getElementById(e);t?e=t:(YN.warning("[".concat(this.getTrackId(),'] can not find "#').concat(e,'" element, use document.body')),e=document.body)}YN.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(e instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(t));const i=KD(KD(KD({},this._getDefaultPlayerConfig()),t),{},{trackId:this.getTrackId(),element:e});this._player?this._player.updateConfig(i):(e instanceof HTMLVideoElement?this._player=new NL(i):this._player=new PL(i),this._player.updateVideoTrack(this._mediaStreamTrack)),this._player.play(),this._videoVisibleTimer&&window.clearInterval(this._videoVisibleTimer),this._clearPreviousVideoVisibleStatus(),this._videoVisibleTimer=window.setInterval((()=>{try{const e=this.getVideoElementVisibleStatus();this.safeEmit(bD.VIDEO_ELEMENT_VISIBLE_STATUS,e)}catch(e){}}),_N("CHECK_VIDEO_VISIBLE_INTERVAL"))}stop(){this._player&&(this._videoVisibleTimer&&(window.clearInterval(this._videoVisibleTimer),this._videoVisibleTimer=null),this._clearPreviousVideoVisibleStatus(),this._player.destroy(),this._player=void 0,YN.debug("[".concat(this.getTrackId(),"] stop video playback")))}async setEnabled(e,t){if(!t){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(YN.info("[".concat(this.getTrackId(),"] start setEnabled"),e),!e){this._originMediaStreamTrack.enabled=!1;try{await qw(this,RD.NEED_DISABLE_TRACK,this)}catch(e){throw YN.error("[".concat(this.getTrackId(),"] setEnabled to fal
12271se error"),e.toString()),e}return t||(this._enabled=!1),void YN.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}this._originMediaStreamTrack.enabled=!0;try{await qw(this,RD.NEED_ENABLE_TRACK,this)}catch(e){throw YN.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}YN.info("[".concat(this.getTrackId(),"] setEnabled to true success")),t||(this._enabled=!0)}async setMuted(e){e!==this._muted&&(this.stateCheck("muted",e),this._muted=e,this._originMediaStreamTrack.enabled=!e,YN.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(e)),e?await qw(this,RD.NEED_MUTE_TRACK,this):await qw(this,RD.NEED_UNMUTE_TRACK,this))}async setEncoderConfiguration(e,t){if(!this._enabled)throw new mw(Ew.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");if(e=_D(e),this._forceBitrateLimit&&(e.bitrateMax=this._forceBitrateLimit.max_bitrate?this._forceBitrateLimit.max_bitrate:e.bitrateMax,e.bitrateMin=this._forceBitrateLimit.min_bitrate?this._forceBitrateLimit.min_bitrate:e.bitrateMin),e.width||e.height||e.frameRate){const t=DP({encoderConfig:e});(Wb()||Yb()||ow())&&(t.deviceId=void 0),YN.debug("[".concat(this.getTrackId(),"] setEncoderConfiguration applyConstraints"),JSON.stringify(e),JSON.stringify(t));try{await this._originMediaStreamTrack.applyConstraints(t),this.updateMediaStreamTrackResolution()}catch(e){const t=new mw(Ew.UNEXPECTED_ERROR,e.toString());throw YN.error("[".concat(this.getTrackId(),"] applyConstraints error"),t.toString()),t}}this._encoderConfig=e,-1===this._hints.indexOf(vD.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await qw(this,RD.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(YN)}}getStats(){nO((()=>{YN.warning("[deprecated] LocalVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalVideoStats instead")}),"localVideoTrackGetStatsWarning");return zw(this,RD.GET_STATS)||KD({},PD)}async setBeautyEffect(e){YN.error("LocalVideoTrack.setBeautyEffect was deprecated, please migrate to agora-extension-beauty-effect")}getCurrentFrameData(){return this._player?this._player.getCurrentFrame():new ImageData(2,2)}async getCurrentFrameImage(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._player?this._player.getCurrentFrameToUint8Array(e,t):await UP(e)}async setBitrateLimit(e){YN.debug("[".concat(this.getTrackId(),"] set bitrate limit, ").concat(JSON.stringify(e))),e&&(this._forceBitrateLimit=e,this._encoderConfig&&(this._encoderConfig.bitrateMax?this._encoderConfig.bitrateMax=this._encoderConfig.bitrateMax<e.max_bitrate?this._encoderConfig.bitrateMax:e.max_bitrate:this._encoderConfig.bitrateMax=e.max_bitrate,this._encoderConfig.bitrateMin,this._encoderConfig.bitrateMin=e.min_bitrate))}async setOptimizationMode(e){if("motion"!==e&&"detail"!==e&&"balanced"!==e)return void YN.error(Ew.INVALID_PARAMS,"optimization mode must be motion, detail or balanced");const t=this._optimizationMode;try{this._optimizationMode=e,await qw(this,RD.NEED_UPDATE_VIDEO_SEND_PARAMETERS,this)}catch(e){throw this._optimizationMode=t,YN.error("[".concat(this.getTrackId(),"] set optimization mode failed"),e.toString()),e}YN.info("[".concat(this.getTrackId(),"] set optimization mode success (").concat(e,")"))}setScalabiltyMode(e){if(1===e.numSpatialLayers&&1!==e.numTemporalLayers)return YN.error(Ew.INVALID_PARAMS,"scalability mode currently not supported, no SVC."),void(this._scalabilityMode={numSpatialLayers:1,numTemporalLayers:1});this._scalabilityMode=e,YN.info("[".concat(this.getTrackId(),"] set scalability mode success (").concat(e,")"))}updateMediaStreamTrackResolution(){NP(this._originMediaStreamTrack).then((e=>{let[t,i]=e;this._videoHeight=i,this._videoWidth=t})).catch(_O)}_updatePlayerSource(){this._player&&this._player.updateVideoTrack(this._mediaStreamTrack)}_getDefaultPlayerConfig(){return{fit:"contain"}}async setSenderConfiguration(e){if(!this._enabled)throw new mw(Ew.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");YN.debug("[".concat(this.getTrackId(),"] setSenderConfiguration applyConstraints"),JSON.stringify(e)),e=_D(e),this._forceBitrateLimit&&(e.bitrateMax=this._forceBitrateLimit.max_bitrate?this._forceBitrateLimit.max_bitrate:e.bitrateMax,e.bitrateMin=this._forceBitrateLimit.min_bitrate?this._forceBitrateLimit.min_bitrate:e.bitrateMin),this._encoderConfig=e,-1===this._hints.indexOf(vD.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await qw(this,RD.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(YN)}}updateBitrateFromProfile(){if(!this._encoderConfig)return;const{width:e,height:t,frameRate:i}=this.getMediaStreamTrackSettings();if(!e||!t||!i)return;const{bitrateMax:n,bitrateMin:r}=this._encoderConfig;if(null==r||null==n){const{max:o,min:s}=function(e,t,i,n,r){const o=_N("BITRATE_ADAPTER_TYPE");if("DEFAULT_BITRATE"===o)return{min:n,max:r};if(void 0===r){var s;const a=Math.floor(200*Math.pow(i/15,.6)*Math.pow(e*t/640/360,.75));r="STANDARD_BITRATE"===o?4*a:2*a,n=null!==(s=n)&&void 0!==s?s:a}else{var a;n=null!==(a=n)&&void 0!==a?a:Math.floor(r/10)}return{min:n,max:r}}(e,t,i,r,n);this._encoderConfig.bitrateMin=s,this._encoderConfig.bitrateMax=o,YN.debug("[".concat(this.getTrackId(),"] update bitrate from profile, [w: ").concat(e,", h: ").concat(t,", fps: ").concat(i,"] => [brMax: ").concat(o,", brMin: ").concat(s,"]"))}}getVideoElementVisibleStatus(){try{var e,t;const i=null==this||null===(e=this._player)||void 0===e?void 0:e.getContainerElement(),n={track:this,element:null==this||null===(t=this._player)||void 0===t?void 0:t.getVideoElement(),slot:null==i?void 0:i.parentElement},{element:r,slot:o}=n;
vendor: 9,640 bytes, line 12271
12271if(this.isPlaying&&r instanceof HTMLVideoElement&&o instanceof HTMLElement){const e=bw.checkOneElementVisible(r),t=Object.assign({},e);if(t.visible!==this._previousVideoVisibleStatus){this._previousVideoVisibleStatus=t.visible;const e=eD.reportApiInvoke(null,{tag:Mw.TRACER,name:kw.LOCAL_VIDEO_TRACK_GET_VIDEO_VISIBLE,options:[this.getTrackId()]});t.visible?e.onSuccess("Video is visible"):e.onSuccess("Invisible because of ".concat(t.reason))}return t}return}catch(e){throw new mw(Ew.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}async renewMediaStreamTrack(e){}pipe(e){if(this.processor===e)return e;if(e._source)throw new mw(Ew.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,context:this.processorContext}),e}unpipe(){if(!this.processor)return;const e=this.processor;this.processor._source=void 0,this.processor=void 0,e.reset()}close(){super.close(),this.unbindProcessorDestinationEvents(),this.unbindProcessorContextEvents(),this.unpipe(),this.processorDestination._source&&this.processorDestination._source.unpipe()}clone(t){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this._encoderConfig;t&&(n=KD(KD({},n),_D(t))),n=tO(n);const r=hO(8,"track-video-cloned-"),o=new e(i?this._mediaStreamTrack.clone():this._mediaStreamTrack,n,tO(this._scalabilityMode),this._optimizationMode,r,tO(this._hints));return t&&n&&o.setEncoderConfiguration(n),YN.debug("clone video track from ".concat(this.getTrackId()," to ").concat(r,", clone ").concat(i)),o}async replaceTrack(e,t){if(!(e instanceof MediaStreamTrack))throw new mw(Ew.INVALID_PARAMS,"track should be an instance of MediaStreamTrack");if("video"!==e.kind)throw new mw(Ew.INVALID_PARAMS,"track should be a video MediaStreamTrack");await this._updateOriginMediaStreamTrack(e,t,!0),this.updateMediaStreamTrackResolution()}sendSeiData(e){if(nO((()=>{eD.reportApiInvoke(null,{name:kw.LOCAL_VIDEO_SEND_SEI_DATA,options:[],tag:Mw.TRACER}).onSuccess("")}),this._mediaStreamTrack.id||this.getTrackId()),!_N("ENABLE_VIDEO_SEI")||!_N("ENABLE_ENCODED_TRANSFORM"))return void YN.warning('To send/receive SEI, please call AgoraRTC.setParameter("ENABLE_VIDEO_SEI", true) before instantiate IAgoraRtcClient');if(e instanceof Uint8Array==0)return new mw(Ew.INVALID_PARAMS,"Invalid argument type, ILocalVideoTrack.sendSeiData() only accept Uint8Array argument.").throw();const t=this.getRTCRtpTransceiver();if(!t)return void YN.warning("Video track is not published, SEI can not be send");const i=t.sender.getParameters();if(0===i.codecs.length)return;const n=i.codecs[0].mimeType.toLocaleLowerCase();"video/h264"===n?this.safeEmit("sei-to-send",e):YN.warning("SEI is not supported by ".concat(n))}bindProcessorDestinationEvents(){this.processorDestination.on(UD.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(),await qw(this,RD.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await qw(this,RD.NEED_REPLACE_TRACK,this))}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(UD.ON_TRACK)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(xD.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(xD.REQUEST_CONSTRAINTS)}},qD(nk.prototype,"play",[LL,kL],Object.getOwnPropertyDescriptor(nk.prototype,"play"),nk.prototype),qD(nk.prototype,"stop",[ML],Object.getOwnPropertyDescriptor(nk.prototype,"stop"),nk.prototype),qD(nk.prototype,"setEnabled",[UL,xL,VL],Object.getOwnPropertyDescriptor(nk.prototype,"setEnabled"),nk.prototype),qD(nk.prototype,"setMuted",[FL,BL,jL],Object.getOwnPropertyDescriptor(nk.prototype,"setMuted"),nk.prototype),qD(nk.prototype,"setEncoderConfiguration",[GL,WL],Object.getOwnPropertyDescriptor(nk.prototype,"setEncoderConfiguration"),nk.prototype),qD(nk.prototype,"getStats",[HL],Object.getOwnPropertyDescriptor(nk.prototype,"getStats"),nk.prototype),qD(nk.prototype,"setBeautyEffect",[KL,YL],Object.getOwnPropertyDescriptor(nk.prototype,"setBeautyEffect"),nk.prototype),qD(nk.prototype,"getCurrentFrameData",[qL],Object.getOwnPropertyDescriptor(nk.prototype,"getCurrentFrameData"),nk.prototype),qD(nk.prototype,"getCurrentFrameImage",[zL],Object.getOwnPropertyDescriptor(nk.prototype,"getCurrentFrameImage"),nk.prototype),qD(nk.prototype,"setBitrateLimit",[XL],Object.getOwnPropertyDescriptor(nk.prototype,"setBitrateLimit"),nk.prototype),qD(nk.prototype,"setOptimizationMode",[JL],Object.getOwnPropertyDescriptor(nk.prototype,"setOptimizationMode"),nk.prototype),qD(nk.prototype,"setScalabiltyMode",[QL],Object.getOwnPropertyDescriptor(nk.prototype,"setScalabiltyMode"),nk.prototype),qD(nk.prototype,"updateMediaStreamTrackResolution",[ZL],Object.getOwnPropertyDescriptor(nk.prototype,"updateMediaStreamTrackResolution"),nk.prototype),qD(nk.prototype,"pipe",[$L],Object.getOwnPropertyDescriptor(nk.prototype,"pipe"),nk.prototype),qD(nk.prototype,"unpipe",[ek],Object.getOwnPropertyDescriptor(nk.prototype,"unpipe"),nk.prototype),qD(nk.prototype,"close",[tk],Object.getOwnPropertyDescriptor(nk.prototype,"close"),nk.prototype),qD(nk.prototype,"replaceTrack",[ik],Object.getOwnPropertyDescriptor(nk.prototype,"replaceTrack"),nk.prototype),nk),_k=(rk=$N({argsMap:(e,t)=>[e.getTrackId(),t]}),ok=CP(),sk=yO("CameraVideoTrack","_enabledMutex"),ak=$N({argsMap:(e,t)=>[e.getTrackId(),t]}),ck=CP(),dk=$N({argsMap:(e,t)=>[e.getTrackId(),t]}),lk=CP(),uk=$N({argsMap:e=>[e.getTrackId()]}),hk=class e extends pk{get __className__(){return"CameraVideoTrack"}constructor(e,t,i,n,r,o){super(e,_D(t.encoderConfig),n,r,o),YD(this,"_config",void 0),YD(this,"_originalConstraints",void 0),YD(this,"_constraints",void 0),YD(this,"_enabled",!0),YD(this,"_deviceName","default"),YD(this,"tryResumeVideoForIOS15_16WeChat",(async()=>{(iw()||nw())&&!function(){const e=xb();if(e.os!==Pb.IOS||!e.osVersion)return!1;const t=e.osVersion.split(".");return 15===Number(t[0])&&Number(t[1])>=2}()&&sw()&&this._enabled&&!this._isClosed&&(YN.debug("[".concat(this.getTrackId(),"] try capture camera media device for interrupted iOS 15 device on WeChat.")),await this.renewMediaStreamTrack())})),this._config=t,this._originalConstraints=i,this._constraints=i,this._deviceName=e.label,this._encoderConfig=_D(this._config.encoderConfig),ZD.on(sD.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),ZD.on(sD.IOS_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),this.bindProcessorContextEvents()}async setDevice(e){return"string"==typeof e?this._setDeviceById(e):e.deviceId?this._setDeviceById(e.deviceId):e.facingMode?this._setDeviceByFacingModel(e.facingMode):void 0}async _setDeviceById(e){if(YN.info("[".concat(this.getTrackId(),"] set device to ").concat(e)),this._enabled)try{const t=await mP.getDeviceById(e),i={};i.video=KD({},this._constraints),i.video.deviceId={exact:e},i.video.facingMode=void 0,this._originMediaStreamTrack.stop();let n=null;try{n=await hP(i,this.getTrackId())}catch(e){throw YN.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),n=await hP({video:this._constraints},this.getTrackId()),await this._updateOriginMediaStreamTrack(n.getVideoTracks()[0],!1),e}await this._updateOriginMediaStreamTrack(n.getVideoTracks()[0],!1),this.updateMediaStreamTrackResolution(),this._deviceName=t.label,this._config.cameraId=e,this._constraints.deviceId={exact:e}}catch(e){throw YN.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await mP.getDeviceById(e);this._deviceName=t.label,this._config.cameraId=e,this._constraints.deviceId={exact:e}}catch(e){throw YN.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}YN.info("[".concat(this.getTrackId(),"] setDevice success"))}async _setDeviceByFacingModel(e){YN.info("[".concat(this.getTrackId(),"] set facingMode ").concat(e));const t={video:KD(KD({},this._constraints),{},{deviceId:void 0,facingMode:{exact:e}})};if(this._enabled){this._originMediaStreamTrack.stop();let e=null;try{e=await hP(t,this.getTrackId())}catch(t){throw YN.error("[".concat(this.getTrackId(),"] setDeviceByFacingModel failed"),t.toString()),e=await hP({video:this._constraints},this.getTrackId()),await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1),t}await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1),this.updateMediaStreamTrackResolution()}this._deviceName="",this._config.facingMode=e,this._config.cameraId=void 0,this._constraints=KD({},t.video),YN.info("[".concat(this.getTrackId(),"] setDeviceByFacingModel success"))}async setEnabled(e,t){if(!t){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(YN.info("[".concat(this.getTrackId(),"] start setEnabled"),e),e){try{if(this.isExternalTrack)this._originMediaStreamTrack.enabled=!0;else{const e=await hP({video:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1)}await qw(this,RD.NEED_ENABLE_TRACK,this)}catch(e){throw YN.error("[".concat(this.getTrackId(),"] setEnabled true error"),e.toString()),e}this.updateMediaStreamTrackResolution(),YN.info("[".concat(this.getTrackId(),"] setEnabled to true success")),t||(this._enabled=!0)}else{this.isExternalTrack?this._originMediaStreamTrack.enabled=!1:(this._originMediaStreamTrack.onended=null,this._originMediaStreamTrack.stop()),t||(this._enabled=!1);try{await qw(this,RD.NEED_DISABLE_TRACK,this)}catch(e){throw YN.error("[".concat(this.getTrackId(),"] setEnabled to fal
12271se error"),e.toString()),e}YN.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}}async setEncoderConfiguration(e,t){if(!this._enabled)throw new mw(Ew.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");e=_D(e),this._forceBitrateLimit&&(e.bitrateMax=this._forceBitrateLimit.max_bitrate||e.bitrateMax,e.bitrateMin=this._forceBitrateLimit.min_bitrate||e.bitrateMin);const i=eO(this._config);i.encoderConfig=e;const n=DP(i);(Wb()||Yb()||ow())&&(n.deviceId=void 0),YN.debug("[".concat(this.getTrackId(),"] setEncoderConfiguration applyConstraints"),JSON.stringify(e),JSON.stringify(n));try{await this._originMediaStreamTrack.applyConstraints(n),this.updateMediaStreamTrackResolution()}catch(e){const t=new mw(Ew.UNEXPECTED_ERROR,e.toString());throw YN.error("[".concat(this.getTrackId(),"] applyConstraints error"),t.toString()),t}this._config=i,this._constraints=n,this._originalConstraints=n,this._encoderConfig=e,-1===this._hints.indexOf(vD.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await qw(this,RD.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(YN)}}_getDefaultPlayerConfig(){return{mirror:!0,fit:"cover"}}onTrackEnded(){if((Yb()||ow())&&this._enabled&&!this._isClosed&&ZD.duringInterruption){const e=async()=>{ZD.off(sD.IOS_INTERRUPTION_END,e),this._enabled&&!this._isClosed&&(YN.debug("[".concat(this.getTrackId(),"] try capture camera media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};ZD.on(sD.IOS_INTERRUPTION_END,e)}else YN.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(bD.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,i=mP.searchDeviceIdByName(this._deviceName);if(i&&!t.deviceId&&(t.deviceId={exact:i}),this._enabled){const e=await hP({video:t},this.getTrackId());this._constraints=t,await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!0),this.updateMediaStreamTrackResolution()}}close(){super.close(),ZD.off(sD.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),ZD.off(sD.IOS_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat)}clone(t){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this._encoderConfig;t&&(n=KD(KD({},n),_D(t))),n=tO(n);const r=hO(8,"track-cam-cloned-"),o=new e(i?this._mediaStreamTrack.clone():this._mediaStreamTrack,tO(KD(KD({},this._config),{},{encoderConfig:n})),tO(this._constraints),tO(this._scalabilityMode),this._optimizationMode,r);return t&&n&&o.setEncoderConfiguration(n),YN.debug("clone track from ".concat(this.getTrackId()," to ").concat(r,", clone ").concat(i)),o}bindProcessorContextEvents(){this.processorContext.on(xD.REQUEST_UPDATE_CONSTRAINTS,(async(e,t,i)=>{try{const i=Object.assign({},this._originalConstraints,...e);await this.renewMediaStreamTrack(i),t()}catch(e){i(e)}})),this.processorContext.on(xD.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}},qD(hk.prototype,"setDevice",[rk,ok],Object.getOwnPropertyDescriptor(hk.prototype,"setDevice"),hk.prototype),qD(hk.prototype,"setEnabled",[sk,ak,ck],Object.getOwnPropertyDescriptor(hk.prototype,"setEnabled"),hk.prototype),qD(hk.prototype,"setEncoderConfiguration",[dk,lk],Object.getOwnPropertyDescriptor(hk.prototype,"setEncoderConfiguration"),hk.prototype),qD(hk.prototype,"close",[uk],Object.getOwnPropertyDescriptor(hk.prototype,"close"),hk.prototype),hk);function Ek(e,t,i,n){i.optimizationMode&&(n&&n.width&&n.height?(i.encoderConfig=KD(KD({},n),{},{bitrateMin:n.bitrateMin,bitrateMax:n.bitrateMax}),"motion"!==i.optimizationMode&&"detail"!==i.optimizationMode||(t.contentHint=i.optimizationMode,t.contentHint===i.optimizationMode?YN.debug("[".concat(e,"] set content hint to"),i.optimizationMode):YN.debug("[".concat(e,"] set content hint failed")))):YN.warning("[".concat(e,"] can not apply optimization mode bitrate config, no encoderConfig")))}var mk,fk,Tk,Sk,gk,Rk,vk,Ck,Ik,yk,Ak,bk;class wk extends zD{getUserId(){return this._userId}constructor(e,t,i,n){super(e,"track-".concat(e.kind,"-").concat(t,"-").concat(n.clientId,"_").concat(hO(5,""))),YD(this,"_userId",void 0),YD(this,"_uintId",void 0),YD(this,"_isDestroyed",!1),YD(this,"store",void 0),YD(this,"processor",void 0),YD(this,"processorContext",void 0),this._userId=t,this._uintId=i,this.store=n}_updateOriginMediaStreamTrack(e){this._originMediaStreamTrack=e,this._mediaStreamTrack=e,this._updatePlayerSource(),this.processor&&this.processor.updateInput({track:this._originMediaStreamTrack,context:this.processorContext})}_destroy(){this._isDestroyed=!0,YN.info("[".concat(this.getTrackId(),"] is destroyed")),this.stop(),super.close()}getProcessorStats(){return this.processorContext.gatherStats()}getProcessorUsage(){return this.processorContext.gatherUsage()}}let Ok=(mk=$N({argsMap:(e,t,i)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",i]}),fk=$N({argsMap:e=>[e.getTrackId()]}),Tk=$N({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Sk=$N({argsMap:e=>[e.getTrackId()]}),qD((gk=class extends wk{get isPlaying(){return!(!this._player||this._player.videoElementStatus!==BD.PLAYING)}get __className__(){return"RemoteVideoTrack"}constructor(e,t,i,n){super(e,t,i,n),YD(this,"_videoVisibleTimer",null),YD(this,"_previousVideoVisibleStatus",void 0),YD(this,"_clearPreviousVideoVisibleStatus",(()=>this._previousVideoVisibleStatus=void 0)),YD(this,"trackMediaType",OD.VIDEO),YD(this,"_videoWidth",void 0),YD(this,"_videoHeight",void 0),YD(this,"_player",void 0),YD(this,"processorDestination",void 0),YD(this,"processorContext",void 0),this.updateMediaStreamTrackResolution(),this.processorContext=new yP(this.getTrackId(),"remote"),this.processorDestination=new IP(this.processorContext),this.bindProcessorDestinationEvents()}getStats(){return nO((()=>{YN.warning("[deprecated] RemoteVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteVideoStats instead")}),"remoteVideoTrackGetStatsWarning"),zw(this,RD.GET_STATS)||KD({},MD)}play(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof e){const t=document.getElementById(e);t?e=t:(YN.warning("[".concat(this.getTrackId(),'] can not find "#').concat(e,'" element, use document.body')),e=document.body)}YN.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(e instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(t));
vendor: 14,868 bytes, line 12271
12271const i=KD(KD({fit:"cover"},t),{},{trackId:this.getTrackId(),element:e});this._player?this._player.updateConfig(i):(e instanceof HTMLVideoElement?this._player=new NL(i):this._player=new PL(i),this._player.updateVideoTrack(this._mediaStreamTrack),this._player.onFirstVideoFrameDecoded=()=>{this.store.subscribe(this.getUserId(),"video",void 0,void 0,Date.now()),this.safeEmit(wD.FIRST_FRAME_DECODED)},this._player.onVideoStateChanged=e=>{this.safeEmit(wD.VIDEO_STATE_CHANGED,e)}),this._player.play(this.store.sessionId||void 0),this._videoVisibleTimer&&window.clearInterval(this._videoVisibleTimer),this._clearPreviousVideoVisibleStatus(),this._videoVisibleTimer=window.setInterval((()=>{try{const e=this.getVideoElementVisibleStatus();this.safeEmit(wD.VIDEO_ELEMENT_VISIBLE_STATUS,e)}catch(e){}}),_N("CHECK_VIDEO_VISIBLE_INTERVAL"))}stop(){this._player&&(this._videoVisibleTimer&&(window.clearInterval(this._videoVisibleTimer),this._videoVisibleTimer=null),this._clearPreviousVideoVisibleStatus(),this._player.destroy(),this._player=void 0,YN.debug("[".concat(this.getTrackId(),"] stop video playback")))}getCurrentFrameData(){return this._player?this._player.getCurrentFrame():new ImageData(2,2)}updateMediaStreamTrackResolution(){NP(this._originMediaStreamTrack).then((e=>{let[t,i]=e;this._videoHeight=i,this._videoWidth=t})).catch(_O)}_updatePlayerSource(){YN.debug("[".concat(this.getTrackId(),"] update player source track")),this._player&&this._player.updateVideoTrack(this._mediaStreamTrack)}getVideoElementVisibleStatus(){try{var e,t;const i=null==this||null===(e=this._player)||void 0===e?void 0:e.getContainerElement(),n={track:this,element:null==this||null===(t=this._player)||void 0===t?void 0:t.getVideoElement(),slot:null==i?void 0:i.parentElement},{element:r,slot:o}=n;if(this.isPlaying&&r instanceof HTMLVideoElement&&o instanceof HTMLElement){const e=bw.checkOneElementVisible(r),t=Object.assign({},e);if(t.visible!==this._previousVideoVisibleStatus){this._previousVideoVisibleStatus=t.visible;const e=eD.reportApiInvoke(null,{tag:Mw.TRACER,name:kw.REMOTE_VIDEO_TRACK_GET_VIDEO_VISIBLE,options:[this.getTrackId()]});t.visible?e.onSuccess("Video is visible"):e.onSuccess("Invisible because of ".concat(t.reason))}return t}return}catch(e){throw new mw(Ew.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}pipe(e){if(this.processor===e)return e;if(e._source)throw new mw(Ew.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,context:this.processorContext}),e}unpipe(){if(!this.processor)return;const e=this.processor;this.processor._source=void 0,this.processor=void 0,e.reset()}bindProcessorDestinationEvents(){this.processorDestination.on(UD.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource()):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource())}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(UD.ON_TRACK)}_destroy(){super._destroy(),this.unbindProcessorDestinationEvents()}_onSei(e){this.emit(AD.SEI_RECEIVED,e)}}).prototype,"play",[mk],Object.getOwnPropertyDescriptor(gk.prototype,"play"),gk.prototype),qD(gk.prototype,"stop",[fk],Object.getOwnPropertyDescriptor(gk.prototype,"stop"),gk.prototype),qD(gk.prototype,"pipe",[Tk],Object.getOwnPropertyDescriptor(gk.prototype,"pipe"),gk.prototype),qD(gk.prototype,"unpipe",[Sk],Object.getOwnPropertyDescriptor(gk.prototype,"unpipe"),gk.prototype),gk),Nk=(Rk=$N({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),vk=$N({argsMap:(e,t)=>[e.getTrackId(),t]}),Ck=$N({argsMap:e=>[e.getTrackId()]}),Ik=$N({argsMap:e=>[e.getTrackId()]}),yk=$N({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Ak=$N({argsMap:e=>[e.getTrackId()]}),qD((bk=class extends wk{get isPlaying(){return this._useAudioElement?vP.isPlaying(this.getTrackId()):this._source.isPlayed}get __className__(){return"RemoteAudioTrack"}constructor(e,t,i,n){super(e,t,i,n),YD(this,"trackMediaType",OD.AUDIO),YD(this,"_source",void 0),YD(this,"_useAudioElement",!0),YD(this,"_volume",100),YD(this,"processorContext",void 0),YD(this,"processorDestination",void 0),YD(this,"_played",!1),YD(this,"_bypassWebAudio",!1),_N("DISABLE_WEBAUDIO")?(this._source=new wP,this._bypassWebAudio=!0,this._useAudioElement=!0):(this._source=new oP(e,!0),_N("REMOTE_AUDIO_TRACK_USES_WEB_AUDIO")&&(this._useAudioElement=!1)),this._source.once(ND.RECEIVE_TRACK_BUFFER,(()=>{this.safeEmit(wD.FIRST_FRAME_DECODED)})),this.processorContext=new bP(this._source.context,this.getTrackId(),"remote"),this.processorDestination=new AP(this.processorContext),this.bindProcessorDestinationEvents(),this._source.on(ND.UPDATE_SOURCE,(()=>{this.processor&&this.processor.updateInput({node:this._source.processSourceNode,context:this.processorContext})}))}setAudioFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4096;if(!e)return this._source.removeAllListeners(ND.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(t),this._source.removeAllListeners(ND.ON_AUDIO_BUFFER),this._source.on(ND.ON_AUDIO_BUFFER,(t=>e(t)))}setVolume(e){this._volume=e,this._useAudioElement?vP.setVolume(this.getTrackId(),e):this._source.setVolume(e/100)}async setPlaybackDevice(e){if(!this._useAudioElement||!rD())throw new mw(Ew.NOT_SUPPORTED,"your browser does not support setting the audio output device");await vP.setSinkID(this.getTrackId(),e)}getVolumeLevel(){return this._source.getAccurateVolumeLevel()}getStats(){return nO((()=>{YN.warning("[deprecated] RemoteAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteAudioStats instead")}),"remoteAudioTrackGetStatsWarning"),zw(this,RD.GET_STATS)||KD({},LD)}play(){YN.debug("[".concat(this.getTrackId(),"] start audio playback")),this._played=!0,this._useAudioElement?(YN.debug("[".concat(this.getTrackId(),"] use audio element to play")),vP.play(this._mediaStreamTrack,this.getTrackId(),this._volume,this.store.sessionId||void 0)):this._source.play()}stop(){YN.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._played=!1,this._useAudioElement?vP.stop(this.getTrackId()):this._source.stop()}_destroy(){super._destroy(),this._played=!1,this.unbindProcessorDestinationEvents(),this._source.destroy()}_isFreeze(){return this._source.isFreeze}_updatePlayerSource(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];YN.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&vP.updateTrack(this.getTrackId(),this._mediaStreamTrack)}pipe(e){if(this._bypassWebAudio)throw new mw(Ew.NOT_SUPPORTED,"can not pipe extension when WebAudio disabled");if(this.processor===e)return e;if(e._source)throw new mw(Ew.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,node:this._source.processSourceNode,context:this.processorContext}),e}unpipe(){var e;if(this._bypassWebAudio)throw new mw(Ew.NOT_SUPPORTED,"can not unpipe extension when WebAudio disabled");if(!this.processor)return;const t=this.processor;null===(e=this._source.processSourceNode)||void 0===e||e.disconnect(),this.processor._source=!1,this.processor=void 0,t.reset()}bindProcessorDestinationEvents(){this.processorDestination.on(UD.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(!1),this._source.processedNode=this._source.createMediaStreamSourceNode(e)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource())})),this.processorDestination.on(UD.ON_NODE,(e=>{this._source.processedNode=e;const t=!e;this._useAudioElement!==t&&(this._played?(this.stop(),this._useAudioElement=t,this.play()):this._useAudioElement=t)}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(UD.ON_TRACK),this.processorDestination.removeAllListeners(UD.ON_NODE)}}).prototype,"setVolume",[Rk],Object.getOwnPropertyDescriptor(bk.prototype,"setVolume"),bk.prototype),qD(bk.prototype,"setPlaybackDevice",[vk],Object.getOwnPropertyDescriptor(bk.prototype,"setPlaybackDevice"),bk.prototype),qD(bk.prototype,"play",[Ck],Object.getOwnPropertyDescriptor(bk.prototype,"play"),bk.prototype),qD(bk.prototype,"stop",[Ik],Object.getOwnPropertyDescriptor(bk.prototype,"stop"),bk.prototype),qD(bk.prototype,"pipe",[yk],Object.getOwnPropertyDescriptor(bk.prototype,"pipe"),bk.prototype),qD(bk.prototype,"unpipe",[Ak],Object.getOwnPropertyDescriptor(bk.prototype,"unpipe"),bk.prototype),bk);const Dk=new class extends Dw{get visibility(){return document.visibilityState}get lastHiddenTime(){return this._lastHiddenTime}get lastVisibleTime(){return this._lastVisibleTime}constructor(){super(),YD(this,"_lastHiddenTime",0),YD(this,"_lastVisibleTime",0),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState?this._lastHiddenTime=performance.now():this._lastVisibleTime=performance.now(),YN.debug("current web page is ".concat(document.visibilityState)),this.emit("VISIBILITY_CHANGE",document.visibilityState)}))}};class Pk extends Dw{constructor(e,t){super(),YD(this,"trackMediaType",OD.DATA),YD(this,"_version",1),YD(this,"_type",3),YD(this,"_config",void 0),YD(this,"_originDataChannel",void 0),YD(this,"_dataStreamPacketHeader",new ArrayBuffer(4)),YD(this,"_dataStreamPacketHandler",{serialize:e=>e,deserialize:e=>e}),YD(this,"_datachannelEventMap",new Map),this._config=e,t&&(this._originDataChannel=t,this._bandDataChannelEvents(t)),this._initPacketHeader()}useDataStream(e){this._dataStreamPacketHandler=e}get id(){return this._config.id}get ordered(){return this._config.ordered}get maxRetransmits(){return _N("DATASTREAM_MAX_RETRANSMITS")}get metadata(){return this._config.metadata}get readyState(){var e,t;return null!==(e=null===(t=this._originDataChannel)||void 0===t?void 0:t.readyState)&&void 0!==e?e:"connecting"}get _originDataChannelId(){var e,t;return null!==(e=null===(t=this._originDataChannel)||void 0===t?void 0:t.id)&&void 0!==e?e:null}getChannelId(){return this.id}getConfig(){return this._config}_close(){this._originDataChannel&&(this._unbindDataChannelEvents(this._originDataChannel),this._originDataChannel=void 0)}async _waitTillOpen(){return new Wh(((e,t)=>{if(this._originDataChannel){"open"===this._originDataChannel.readyState&&e();const i=setTimeout((()=>{var e;t(new mw(Ew.DATACHANNEL_CONNECTION_TIMEOUT,"Cannot create datachannel, id: ".concat(null===(e=this._originDataChannel)||void 0===e?void 0:e.id)))}),1e4);this._originDataChannel.onopen=()=>{clearTimeout(i),this._originDataChannel&&this._bandDataChannelEvents(this._originDataChannel),e()},this._originDataChannel.onerror=()=>{throw clearTimeout(i),new mw(Ew.DATACHANNEL_CONNECTION_TIMEOUT)}}else t(new mw(Ew.DATACHANNEL_CONNECTION_TIMEOUT,"cannot find dataChannel"))}))}_updateOriginDataChannel(e){this._originDataChannel=e,this._bandDataChannelEvents(e)}_initPacketHeader(){const e=new DataView(this._dataStreamPacketHeader);e.setUint16(0,this._version),e.setUint8(2,this._type),e.setUint8(3,this._config.id)}_bandDataChannelEvents(e){this._unbindDataChannelEvents(e),[WD.OPEN,WD.CLOSE,WD.ERROR].forEach((t=>{const i=()=>{this.emit(t)};this._datachannelEventMap.set(t,i),e.addEventListener(t,i)}))}_unbindDataChannelEvents(e){Array.from(this._datachannelEventMap.entries()).forEach((t=>{let[i,n]=t;e.removeEventListener(i,n)})),this._datachannelEventMap.clear()}}class Lk extends Pk{constructor(e){super(e),YD(this,"_messageListener",void 0),this._messageListener=e=>{if(e.data.byteLength<this._dataStreamPacketHeader.byteLength)throw Error("invalid byteLength: the byte length must exceed "+this._dataStreamPacketHeader.byteLength);const t=e.data.slice(0,this._dataStreamPacketHeader.byteLength),i=new DataView(t).getUint8(3);if(i!==this.id)return void(_N("SHOW_DATASTREAM2_LOG")&&YN.debug("invalid datachannel id: ".concat(i," !== ").concat(this.id)));let n=e.data.slice(this._dataStreamPacketHeader.byteLength);n=this._dataStreamPacketHandler.deserialize(n),this.emit(WD.MESSAGE,n)}}_updateOriginDataChannel(e){super._updateOriginDataChannel(e),this._bandRemoteDataChannelEvents()}_close(){this._originDataChannel&&(this._originDataChannel.removeEventListener("message",this._messageListener),super._close())}_bandRemoteDataChannelEvents(){this._originDataChannel&&this._originDataChannel.addEventListener("message",this._messageListener)}}class kk extends Pk{send(e){if(this._originDataChannel){let t=e;t=this._dataStreamPacketHandler.serialize(e);const i=new Uint8Array(this._dataStreamPacketHeader.byteLength+t.byteLength);i.set(new Uint8Array(this._dataStreamPacketHeader),0),i.set(new Uint8Array(t),this._dataStreamPacketHeader.byteLength),this._originDataChannel.send(i.buffer)}}}function Mk(){const e=new Blob([atob("ZnVuY3Rpb24gdCh0LGUsbil7bGV0IGE9bmV3IFVpbnQ4QXJyYXkodCxlLG4pLG89W10scj0wO2Zvcig7by5sZW5ndGg8bjspciszPG4mJjA9PT1hW3JdJiYwPT09YVtyKzFdJiYzPT09YVtyKzJdJiYoMD09PWFbciszXXx8MT09PWFbciszXXx8Mj09PWFbciszXXx8Mz09PWFbciszXSk/KG8ucHVzaChhW3JdLGFbcisxXSxhW3IrM10pLHIrPTQpOihvLnB1c2goYVtyXSkscisrKTtyZXR1cm4gbmV3IFVpbnQ4QXJyYXkobyl9ZnVuY3Rpb24gZSh0LGUpe2NvbnN0IG49ZnVuY3Rpb24odCl7Y29uc3QgZT10Lmxlbmd0aDtsZXQgbj1bXSxhPTA7Zm9yKDthPGU7KWErMjxlJiYwPT09dFthXSYmMD09PXRbYSsxXSYmKDA9PT10W2ErMl18fDE9PT10W2ErMl18fDI9PT10W2ErMl18fDM9PT10W2ErMl0pPyhuLnB1c2godFthXSx0W2ErMV0sMyx0W2ErMl0pLGErPTMpOihuLnB1c2godFthXSksYSsrKTtyZXR1cm4gbmV3IFVpbnQ4QXJyYXkobil9KGUpLGE9bi5sZW5ndGgsbz1NYXRoLmZsb29yKGEvMjU1KSxyPWElMjU1LHM9bmV3IFVpbnQ4QXJyYXkoNitvKzErYSt0LmJ5dGVMZW5ndGgpO3NbMF09MCxzWzFdPTAsc1syXT0wLHNbM109MSxzWzRdPTYsc1s1XT0xMDE7bGV0IGk9MDtmb3IoO2k8bzspc1s2K2ldPTI1NSxpKys7cmV0dXJuIHNbNitpXT1yLGkrKyxzLnNldChuLDYraSkscy5zZXQobmV3IFVpbnQ4QXJyYXkodCksNitpK2EpLHMuYnVmZmVyfWNvbnN0IG49NzEsYT0xLG89MixyPTEscz0yO3ZhciBpOyFmdW5jdGlvbih0KXt0W3QuQVVESU9fTEVWRUw9MV09IkFVRElPX0xFVkVMIix0W3QuTUVUQURBVEE9Ml09Ik1FVEFEQVRBIix0W3QuQVVESU9fNjRfQklUX1BUUz0zXT0iQVVESU9fNjRfQklUX1BUUyJ9KGl8fChpPXt9KSk7bmF2aWdhdG9yLnVzZXJBZ2VudC5pbmRleE9mKCJTYWZhcmkiKT4tMSYmLTE9PT1uYXZpZ2F0b3IudXNlckFnZW50LmluZGV4T2YoIkNocm9tZSIpJiYoc2VsZi5vbnJ0Y3RyYW5zZm9ybT1mPT57Y29uc3QgdT1mLnRyYW5zZm9ybWVyO2xldCBkPVtdLGw9W107dS5vcHRpb25zLnBvcnQub25tZXNzYWdlPXQ9Pnt0LmRhdGEuc2VpJiZkLnB1c2godC5kYXRhLnNlaSksdC5kYXRhLm1ldGFkYXRhJiZsLnB1c2godC5kYXRhLm1ldGFkYXRhKX0sc2VsZi5wb3N0TWVzc2FnZSgic3RhcnRlZCIpO2NvbnN0IGc9dS5yZWFkYWJsZS5nZXRSZWFkZXIoKSxjPXUud3JpdGFibGUuZ2V0V3JpdGVyKCk7InNlaS1yeCI9PT11Lm9wdGlvbnMubmFtZT9mdW5jdGlvbiBlKG4pe2cucmVhZCgpLnRoZW4oKGE9PntpZighYS5kb25lKXtpZihhLnZhbHVlIGluc3RhbmNlb2YgUlRDRW5jb2RlZ
12271FZpZGVvRnJhbWUpe2NvbnN0IGU9ZnVuY3Rpb24oZSl7Y29uc3Qgbj1uZXcgRGF0YVZpZXcoZS5kYXRhKTtsZXQgYT0wO2Zvcig7YSs0PGUuZGF0YS5ieXRlTGVuZ3RoOyl7aWYoMD09PW4uZ2V0VWludDgoYSswKSYmMD09PW4uZ2V0VWludDgoYSsxKSYmMD09PW4uZ2V0VWludDgoYSsyKSYmMT09PW4uZ2V0VWludDgoYSszKSYmNj09PW4uZ2V0VWludDgoYSs0KSl7bGV0IG89YSs2LHI9MCxzPTA7Zm9yKDsyNTU9PT0ocz1uLmdldFVpbnQ4KG8rKykpOylyKz0yNTU7cis9cztjb25zdCBpPXQoZS5kYXRhLG8scik7cmV0dXJuIG5ldyBVaW50OEFycmF5KGkpfWErK31yZXR1cm4gbnVsbH0oYS52YWx1ZSk7ZSYmbi5vcHRpb25zLnBvcnQucG9zdE1lc3NhZ2Uoe3NlaTplfSl9Yy53cml0ZShhLnZhbHVlKSxuLm9wdGlvbnMucG9ydC5wb3N0TWVzc2FnZSh7dHJhbnNmb3JtZWQ6ITB9KSxlKG4pfX0pKX0odSk6InNlaS10eCI9PT11Lm9wdGlvbnMubmFtZT9mdW5jdGlvbiB0KG4pe2cucmVhZCgpLnRoZW4oKGE9PntpZighYS5kb25lKXtpZihhLnZhbHVlIGluc3RhbmNlb2YgUlRDRW5jb2RlZFZpZGVvRnJhbWUpe2NvbnN0IHQ9ZC5zaGlmdCgpO3QmJihhLnZhbHVlLmRhdGE9ZShhLnZhbHVlLmRhdGEsdCkpfWMud3JpdGUoYS52YWx1ZSksbi5vcHRpb25zLnBvcnQucG9zdE1lc3NhZ2Uoe3RyYW5zZm9ybWVkOiEwfSksdChuKX19KSl9KHUpOiJhdWRpby1tZXRhZGF0YS1yeCI9PT11Lm9wdGlvbnMubmFtZT9mdW5jdGlvbiB0KGUpe2cucmVhZCgpLnRoZW4oKGY9PntpZighZi5kb25lKXtpZihmLnZhbHVlIGluc3RhbmNlb2YgUlRDRW5jb2RlZEF1ZGlvRnJhbWUpe2NvbnN0IHQ9ZnVuY3Rpb24odCxlPSExKXtjb25zdCBmPXQuZ2V0VWludDgoMCk7aWYoZiE9PW4pcmV0dXJuO2NvbnN0IHU9dC5nZXRVaW50MTYoMSksZD1hK28rdSxsPW5ldyBVaW50OEFycmF5KHQuYnl0ZUxlbmd0aC1kKTtsLnNldChuZXcgVWludDhBcnJheSh0LmJ1ZmZlcixkLHQuYnl0ZUxlbmd0aC1kKSk7Y29uc3QgZz17bTpmLHRsdkxlbjp1LHRsdjpbXSxmcmFtZTpsfTtsZXQgYz1hK287Zm9yKDtjPGQ7KXtjb25zdCBuPXQuZ2V0VWludDgoYyksYT10LmdldFVpbnQxNihjK3IpLG89citzO2lmKG49PT1pLkFVRElPX0xFVkVMKXtsZXQgcj10LmdldFVpbnQ4KGMrbyk7Zm9yKGxldCBlPTE7ZTxhO2UrKylyPXI8PDh8dC5nZXRVaW50OChjK28rZSk7Zy50bHYucHVzaCh7dGFnOm4sbGVuZ3RoOmEsdmFsdWU6ZT8xMjdecj4+MToxMjcmcn0pfWVsc2UgaWYobj09PWkuTUVUQURBVEF8fG49PT1pLkFVRElPXzY0X0JJVF9QVFMpe2NvbnN0IGU9bmV3IFVpbnQ4QXJyYXkoYSk7Zm9yKGxldCBuPTA7bjxhO24rKyllW25dPXQuZ2V0VWludDgoYytvK24pO2cudGx2LnB1c2goe3RhZzpuLGxlbmd0aDphLHZhbHVlOmV9KX1jKz1vK2F9cmV0dXJuIGd9KG5ldyBEYXRhVmlldyhmLnZhbHVlLmRhdGEpKTtpZih0KXtjb25zdCBuPXQudGx2LmZpbmQoKHQ9PnQudGFnPT09aS5NRVRBREFUQXx8dC50YWc9PT1pLkFVRElPXzY0X0JJVF9QVFMpKTtuJiZuLnZhbHVlIGluc3RhbmNlb2YgVWludDhBcnJheSYmZS5vcHRpb25zLnBvcnQucG9zdE1lc3NhZ2Uoe21ldGFkYXRhOm4udmFsdWV9KSxmLnZhbHVlLmRhdGE9dC5mcmFtZS5idWZmZXJ9fWMud3JpdGUoZi52YWx1ZSksZS5vcHRpb25zLnBvcnQucG9zdE1lc3NhZ2Uoe3RyYW5zZm9ybWVkOiEwfSksdChlKX19KSl9KHUpOiJhdWRpby1tZXRhZGF0YS10eCI9PT11Lm9wdGlvbnMubmFtZSYmZnVuY3Rpb24gdChlKXtnLnJlYWQoKS50aGVuKChmPT57aWYoIWYuZG9uZSl7aWYoZS5vcHRpb25zLnBvcnQucG9zdE1lc3NhZ2Uoe2dldE1ldGFkYXRhOiEwfSksZi52YWx1ZSBpbnN0YW5jZW9mIFJUQ0VuY29kZWRBdWRpb0ZyYW1lKXtjb25zdCB0PWwuc2hpZnQoKTt0JiYoZi52YWx1ZS5kYXRhPWZ1bmN0aW9uKHQsZSxpKXtjb25zdCBmPWkuYnl0ZUxlbmd0aCx1PWYrcitzLGQ9YStvK3UsbD1uZXcgQXJyYXlCdWZmZXIodC5ieXRlTGVuZ3RoK2QpLGc9bmV3IERhdGFWaWV3KGwpO2cuc2V0VWludDgoMCxuKSxnLnNldFVpbnQxNigxLHUpLGcuc2V0VWludDgoMyxlKSxnLnNldFVpbnQxNig0LGYpO2ZvcihsZXQgdD0wO3Q8Zjt0KyspZy5zZXRVaW50OCg2K3QsaVt0XSk7Y29uc3QgYz1uZXcgVWludDhBcnJheShnLmJ1ZmZlcik7cmV0dXJuIGMuc2V0KG5ldyBVaW50OEFycmF5KHQpLGQpLGMuYnVmZmVyfShmLnZhbHVlLmRhdGEsaS5BVURJT182NF9CSVRfUFRTLHQpKX1jLndyaXRlKGYudmFsdWUpLGUub3B0aW9ucy5wb3J0LnBvc3RNZXNzYWdlKHt0cmFuc2Zvcm1lZDohMH0pLHQoZSl9fSkpfSh1KX0sc2VsZi5wb3N0TWVzc2FnZSgicmVnaXN0ZXJlZCIpKTsK")],{type:"text/javascript"});return setTimeout((()=>Tf.revokeObjectURL(e)),0),new Worker(Tf.createObjectURL(e))}const Uk=71,xk=1,Vk=2,Fk=1,Bk=2;var jk=function(e){return e[e.AUDIO_LEVEL=1]="AUDIO_LEVEL",e[e.METADATA=2]="METADATA",e[e.AUDIO_64_BIT_PTS=3]="AUDIO_64_BIT_PTS",e}(jk||{});function Gk(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=e.getUint8(0);if(i!==Uk)return;const n=e.getUint16(1),r=xk+Vk+n,o=new Uint8Array(e.byteLength-r);o.set(new Uint8Array(e.buffer,r,e.byteLength-r));const s={m:i,tlvLen:n,tlv:[],frame:o};let a=xk+Vk;for(;a<r;){const i=e.getUint8(a),n=e.getUint16(a+Fk),r=Fk+Bk;if(i===jk.AUDIO_LEVEL){let o=e.getUint8(a+r);for(let t=1;t<n;t++)o=o<<8|e.getUint8(a+r+t);s.tlv.push({tag:i,length:n,value:t?127^o>>1:127&o})}else if(i===jk.METADATA||i===jk.AUDIO_64_BIT_PTS){const t=new Uint8Array(n);for(let i=0;i<n;i++)t[i]=e.getUint8(a+r+i);s.tlv.push({tag:i,length:n,value:t})}a+=r+n}return s}const Wk=new Map;const Hk=127,Kk=1e-10,Yk=139/13,qk=new Map;function zk(e,t,i){const n="".concat(e,"-").concat(t,"-").concat(i);let r=0;if(qk.has(n))r=qk.get(n);else{const o=.5;r=Math.log(function(e,t){const i=e-t;t<i&&(t=i);let n=1;for(let i=e,r=1;i>t;i--,r++)n=n*i/r;return n}(t,e))+e*Math.log(o)+(t-e)*Math.log(1-o)-Math.log(i)+i*e,qk.set(n,r)}return r<Kk&&(r=Kk),r}function Xk(e,t,i){const n=t.length,r=e.length/n;let o=!1;for(let s=0,a=0;s<n;s++){let n=0;for(let t=a+r;a<t;a++)e[a]>i&&n++;t[s]!==n&&(t[s]=n,o=!0)}return o}window.cache=qk;let Jk=0;class Qk{constructor(e){YD(this,"id",void 0),YD(this,"immediates",[]),YD(this,"lastNonSilence",-1),YD(this,"immediateSpeechActivityScore",Kk),YD(this,"lastLevelChangedTime",Date.now()),YD(this,"levels",[]),YD(this,"longs",[]),YD(this,"longSpeechActivityScore",Kk),YD(this,"mediums",[]),YD(this,"mediumSpeechActivityScore",Kk),YD(this,"minLevel",0),YD(this,"nextMinLevel",0),YD(this,"nextMinLevelWindowLength",0),YD(this,"energyScore",0),this.id=e||"".concat(Jk++),this.immediates.length=50,this.mediums.length=10,this.longs.length=1,this.levels.length=this.immediates.length}computeImmediates(){const e=this.immediates,t=this.levels,i=this.minLevel+Yk;let n=!1;for(let r=0;r<e.length;++r){let o=t[r];o<i&&(o=0);const s=Math.floor(o/Yk);e[r]!==s&&(e[r]=s,n=!0)}return n}computeLongs(){return Xk(this.mediums,this.longs,4)}computeMediums(){return Xk(this.immediates,this.mediums,7)}evaluateImmediateSpeechActivityScore(){this.immediateSpeechActivityScore=zk(this.immediates[0],13,.78)}evaluateLongSpeechActivityScore(e){this.longSpeechActivityScore=zk(this.longs[0],10,47),this.longSpeechActivityScore>Kk&&(this.lastNonSilence=e)}evaluateMediumSpeechActivityScore(){this.mediumSpeechActivityScore=zk(this.mediums[0],5,24)}evaluateSpeechActivityScores(e){this.computeImmediates()&&(this.evaluateImmediateSpeechActivityScore(),this.computeMediums()&&(this.evaluateMediumSpeechActivityScore(),this.computeLongs()&&this.evaluateLongSpeechActivityScore(e)))}getLastLevelChangedTime(){return this.lastLevelChangedTime}getLevels(){var e;return"[".concat(cr(e=[...this.levels]).call(e).join(),"]")}getSpeechActivityScore(e){switch(e){case 0:return this.immediateSpeechActivityScore;case 1:return this.mediumSpeechActivityScore;case 2:return this.longSpeechActivityScore;default:throw new Error("interval "+e)}}levelChanged(e,t){if(this.lastLevelChangedTime<=t){this.lastLevelChangedTime=t;let i=e;return e<0&&(i=0),e>Hk&&(i=Hk),this.levels.unshift(i),this.levels.length>this.immediates.length&&this.levels.pop(),this.updateMinLevel(i),i>=this.minLevel+Yk?i:i/2}return-1}levelTimedOut(){this.levelChanged(0,this.lastLevelChangedTime)}updateMinLevel(e){if(0!==e){if(0===this.minLevel||this.minLevel>e)return this.minLevel=e,this.nextMinLevel=0,void(this.nextMinLevelWindowLength=0);if(0===this.nextMinLevel)return this.nextMinLevel=e,void(this.nextMinLevelWindowLength=1);if(this.nextMinLevel>e&&(this.nextMinLevel=e),this.nextMinLevelWindowLength++,this.nextMinLevelWindowLength>=750){let e=Math.sqrt(this.minLevel*this.nextMinLevel);e<0?e=0:e>Hk&&(e=Hk),this.minLevel=e,this.nextMinLevel=0,this.nextMinLevelWindowLength=0}}}}class Zk{constructor(e){YD(this,"algorithm",void 0),this.algorithm=e}execute(){let e=!this.algorithm;if(!e)try{const t=this.algorithm.runInDecisionMaker(this);t<=0?e=!0:setTimeout(this.execute.bind(this),t)}catch(t){e=!0}e&&this.algorithm&&this.algorithm.decisionMakerExited(this)}}class $k{constructor(e,t,i){YD(this,"isDominant",void 0),YD(this,"energyRanking",void 0),YD(this,"energyScore",void 0),this.isDominant=e,this.energyRanking=t,this.energyScore=i}}class eM extends Dw{constructor(e){super(),YD(this,"dominantId",null),YD(this,"lastDecisionTime",0),YD(this,"lastLevelChangedTime",0),YD(this,"lastLevelIdleTime",0),YD(this,"relativeSpeechActivities",[]),YD(this,"speakers",new Map),YD(this,"enableSilence",!1),YD(this,"timeoutToSilenceInterval",0),YD(this,"decisionMaker",null),YD(this,"loudest",[]),YD(this,"numLoudestToTrack",3),YD(this,"energyExpireTimeMs",250),YD(this,"energyAlphaPct",50),this.timeoutToSilenceInterval=e,this.enableSilence=e>0,this.relativeSpeechActivities.length=3}setLoudestConfig(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3,t=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;this.numLoudestToTrack=e,null!=t&&(this.energyExpireTimeMs=t),null!=i&&(this.energyAlphaPct=i),this.loudest.length>e&&this.loudest.splice(e)}getDominantSpeaker(){return this.dominantId}isAmongLoudest(e){return this.loudest.some((t=>
vendor: 13,180 bytes, line 12271
12271t.id===e))}levelChanged(e,t){const i=Date.now(),n=this.getOrCreateSpeaker(e);this.lastLevelChangedTime<i&&(this.lastLevelChangedTime=i,this.maybeStartDecisionMaker());const r=n.levelChanged(t,i);return this.updateLoudestList(n,r,i)}runInDecisionMaker(e){return this.decisionMaker!==e||this.lastDecisionTime>0&&this.lastDecisionTime-this.lastLevelChangedTime>=15e3?-1:this._runInDecisionMaker()}decisionMakerExited(e){this.decisionMaker===e&&(this.decisionMaker=null)}destroy(){this.decisionMaker=null,this.loudest.length=0,this.speakers.clear(),this.removeAllListeners()}addSpeakers(e){e.forEach((e=>{this.speakers.has(e.id)||this.speakers.set(e.id,e)}))}removeSpeakers(e){e.forEach((e=>{this.speakers.delete(e.id)}))}getOrCreateSpeaker(e){let t=this.speakers.get(e);return t||(t=new Qk(e),this.speakers.set(e,t),this.maybeStartDecisionMaker()),t}updateLoudestList(e,t,i){const n=e.id===this.dominantId;if(t<0){let t=0;for(;t<this.loudest.length&&this.loudest[t]!==e;)++t;return new $k(n,t,e.energyScore)}if(e.energyScore=Math.floor((this.energyAlphaPct*t+(100-this.energyAlphaPct)*e.energyScore+50)/100),0===this.numLoudestToTrack)return new $k(n,0,e.energyScore);const r=i-this.energyExpireTimeMs;let o=0;for(;o<this.loudest.length;){const t=this.loudest[o];if(t.getLastLevelChangedTime()<r&&this.loudest.length>=this.numLoudestToTrack)this.loudest.splice(o,1);else if(t.id!==e.id)++o;else if(this.loudest.splice(o,1),this.loudest.length<this.numLoudestToTrack)break}let s=0;for(;s<this.loudest.length&&!(this.loudest[s].energyScore<e.energyScore);)++s;return s<this.numLoudestToTrack&&(this.loudest.splice(s,0,e),this.loudest.length>this.numLoudestToTrack&&this.loudest.splice(this.numLoudestToTrack,1)),new $k(n,s,e.energyScore)}maybeStartDecisionMaker(){!this.decisionMaker&&this.speakers.size>0&&(this.decisionMaker=new Zk(this),this.decisionMaker.execute())}makeDecision(e){let t=null,i=null;const n=this.speakers.size;let r=null;if(0===n)r=null;else if(1===n){var o;const t=Zh(o=this.speakers).call(o).next().value;this.enableSilence&&t&&(r=t.id,t.evaluateSpeechActivityScores(e),e-t.lastNonSilence>this.timeoutToSilenceInterval&&(r=null))}else{let t=null==this.dominantId?null:this.speakers.get(this.dominantId);if(null==t){const e=this.speakers.entries().next();e.value&&(r=e.value[0],t=e.value[1])}else r=t.id;null!=t&&t.evaluateSpeechActivityScores(e);const i=this.relativeSpeechActivities;let n=2;for(const o of this.speakers.entries()){const[s,a]=o;if(a===t)continue;a.evaluateSpeechActivityScores(e);for(let e=0;e<i.length;++e){const n=null==t?Kk:t.getSpeechActivityScore(e);i[e]=Math.log(a.getSpeechActivityScore(e)/n)}const c=i[0],d=i[1],l=i[2];c>3&&d>2&&l>0&&d>n&&(n=d,r=s)}this.enableSilence&&null!=t&&r===t.id&&e-t.lastNonSilence>this.timeoutToSilenceInterval&&(r=null)}null==r&&!this.enableSilence||r===this.dominantId||(t=this.dominantId,this.dominantId=r,i=this.dominantId),null==i&&!this.enableSilence||i===t||this.emit("ActiveSpeakerChanged",i)}_runInDecisionMaker(){const e=Date.now(),t=300-(e-this.lastLevelIdleTime);let i=0;t<=0?(0!==this.lastLevelIdleTime&&this.timeoutIdleLevels(e),this.lastLevelIdleTime=e):i=t;let n=300-(e-this.lastDecisionTime);return n<=0&&(this.lastDecisionTime=e,this.makeDecision(e),n=300-(Date.now()-e)),n>0&&i>n&&(i=n),i}timeoutIdleLevels(e){const t=[];for(const n of Zh(i=this.speakers).call(i)){var i;const r=e-n.getLastLevelChangedTime();36e5<r&&(null==this.dominantId||n.id!==this.dominantId)?t.push(n.id):300<r&&n.levelTimedOut()}t.forEach((e=>this.speakers.delete(e)))}}const tM=new Map;let iM=null,nM=null;const rM=3;let oM=[];const sM=new Map,aM=new Map;class cM{get samples(){return this.actives+this.inactives}get activeRate(){return this.actives/this.samples}constructor(e,t){YD(this,"id",void 0),YD(this,"track",void 0),YD(this,"score",0),YD(this,"active",!0),YD(this,"muted",!1),YD(this,"timer",0),YD(this,"actives",0),YD(this,"inactives",0),this.id=e,this.track=t,this.setActive(sM.size<3)}autoCheckActive(){this.autoSetActive(),this.autoAdjustActive(),this.resetTimer(),this.actives=0,this.inactives=0}autoSetActive(){const e=this.active;this.active=this.activeRate>=.8;const{actives:t,inactives:i}=function(){const e=[],t=[];return Array.from(Zh(sM).call(sM)).forEach((i=>{i.active?e.push(i):t.push(i)})),{actives:e,inactives:t}}();if(t.length>3){let e;t.forEach((t=>{(!e||e.score>t.score)&&(e=t)})),e&&e.setActive(!1)}if(t.length<3&&i.length>0){let t;i.forEach((e=>{(!t||t.score<e.score)&&e.id!==this.id&&(t=e)})),t&&e&&!this.active&&(t.samples>40&&t.activeRate-this.activeRate>.4?t.setActive(!0):this.active=!0)}this.setMuted(!this.active)}setActive(e){this.active=e,this.resetTimer(),this.setMuted(!e)}autoAdjustActive(){this.active?this.autoSwitchToInactive():this.autoSwitchToActive()}autoSwitchToActive(){const e=function(e){let t;return Array.from(Zh(sM).call(sM)).forEach((i=>{!i.active||i.id===e||i.samples<40||(!t||i.score<t.score)&&(t=i)})),t}(this.id);e&&this.activeRate-e.activeRate>.4&&(e.setActive(!1),this.setActive(!0))}autoSwitchToInactive(){const e=function(e){let t;return Array.from(Zh(sM).call(sM)).forEach((i=>{i.active||i.id===e||i.samples<40||(!t||i.score>t.score)&&(t=i)})),t}(this.id);e&&e.activeRate-this.activeRate>.4&&(e.setActive(!0),this.setActive(!1))}addSample(e){e?this.actives+=1:this.inactives+=1,this.samples>66.66666666666667&&this.autoCheckActive()}setMuted(e){this.track&&(this.track.enabled=!e,this.muted=e)}resetTimer(){this.clearTimer(),this.timer=window.setTimeout((()=>{if(0!==this.samples)return this.samples<50?this.resetTimer():void this.autoCheckActive()}),1e3)}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=0)}}let dM;function lM(e){const t=sM.get(e);t&&(sM.delete(e),t.clearTimer())}const uM=new Map,hM=new Map;function pM(e,t,i){let n=new Uint8Array(e,t,i),r=[],o=0;for(;r.length<i;)o+3<i&&0===n[o]&&0===n[o+1]&&3===n[o+2]&&(0===n[o+3]||1===n[o+3]||2===n[o+3]||3===n[o+3])?(r.push(n[o],n[o+1],n[o+3]),o+=4):(r.push(n[o]),o++);return new Uint8Array(r)}const _M=new Map;const EM=new Map;!function(){const e=xb();iD.getDisplayMedia=!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia),iD.getStreamFromExtension=e.name===Lb.CHROME&&Number(e.version)>34,iD.supportUnifiedPlan=function(){if(!window.RTCRtpTransceiver)return!1;if(!("currentDirection"in RTCRtpTransceiver.prototype))return!1;const e=new RTCPeerConnection;let t=!1;try{e.addTransceiver("audio"),t=!0}catch(e){}return e.close(),t}(),iD.supportMinBitrate=e.name===Lb.CHROME||e.name===Lb.EDGE,iD.supportSetRtpSenderParameters=function(){const e=xb();return!!(window.RTCRtpSender&&window.RTCRtpSender.prototype.setParameters&&window.RTCRtpSender.prototype.getParameters)&&(!!dw()||!(!Wb()&&!jb())||e.name===Lb.FIREFOX&&Number(e.version)>=64)}(),e.name===Lb.SAFARI&&(Number(e.version)>=14?iD.supportDualStream=!0:iD.supportDualStream=!1),iD.webAudioMediaStreamDest=function(){const e=xb();return!(e.name===Lb.SAFARI&&Number(e.version)<12)}(),iD.supportReplaceTrack=!!window.RTCRtpSender&&"function"==typeof RTCRtpSender.prototype.replaceTrack,iD.supportWebGL="undefined"!=typeof WebGLRenderingContext,iD.supportRequestFrame=!!window.CanvasCaptureMediaStreamTrack,dw()||(iD.webAudioWithAEC=!0),iD.supportShareAudio=function(){const e=xb();return(e.os===Pb.WIN_10||e.os===Pb.WIN_81||e.os===Pb.WIN_7||e.os===Pb.LINUX||e.os===Pb.MAC_OS||e.os===Pb.CHROMIUM_OS)&&e.name===Lb.CHROME&&Number(e.version)>=74}(),iD.supportDataChannel=!!(qb(76)||function(e){const t=xb();return!(t.name!==Lb.FIREFOX||!t.osVersion)&&Number(t.version)>=e}(68)||Qb(14)),iD.supportPCSetConfiguration=function(){const e=window.RTCPeerConnection;return!Kb()&&!!e&&e.prototype.setConfiguration instanceof Function}(),iD.supportWebRTCEncodedTransform=function(){const e=xb();return"Chrome"===e.name&&Number(e.version)>=87||"Safari"===e.name&&Number(e.version)>=15}(),iD.supportWebRTCInsertableStream=function(){const e=xb();return(e.name===Lb.CHROME||e.name===Lb.EDGE)&&Number(e.version)>=94&&"MediaStreamTrackGenerator"in window&&"MediaStreamTrackProcessor"in window}(),iD.supportRequestVideoFrameCallback="requestVideoFrameCallback"in HTMLVideoElement.prototype,iD.supportWebCrypto="undefined"!=typeof window&&void 0!==window.crypto&&void 0!==window.crypto.subtle,$w((()=>{iD.supportDualStreamEncoding=function(){const e=xb();return!!_N("DISABLE_WEBAUDIO")||("Safari"===e.name&&Number(e.version)>=14||!!("Chrome"===e.name&&/Windows/i.test(e.os||"")&&Number(e.version)>=100&&_N("CHROME_DUAL_STREAM_USE_ENCODING")))}(),YN.debug("browser ua: ",navigator.userAgent),YN.info("browser info: ",e),YN.info("browser compatibility: ",iD)}))}();const mM=["CHINA","GLOBAL"];const fM=[[0,1,2,3,4,5,5],[0,2,2,3,4,5,5],[0,3,3,3,4,5,5],[0,4,4,4,4,5,5],[0,5,5,5,5,5,5]],TM=[],SM=[];function gM(e,t){return!!t&&TM.some((i=>i.uid===e&&i.channelName===t))}function RM(){return SM.length>0}var vM=Ev.forEach,CM=Bn("forEach")?[].forEach:function(e){return vM(this,e,arguments.length>1?arguments[1]:void 0)};wi({target:"Array",proto:!0,forced:[].forEach!=CM},{forEach:CM});var IM=Ji("Array").forEach,yM=pn,AM=Ze,bM=l,wM=IM,OM=Array.prototype,NM={DOMTokenList:!0,NodeList:!0},DM=function(e){var t=e.forEach;return e===OM||bM(OM,e)&&t===OM.forEach||AM(NM,yM(e))?wM:t},PM=i(DM),LM=Xe,kM=to;wi({target:"Object",stat:!0,forced:n((function(){kM(1)}))},{keys:function(e){return kM(LM(e))}});var MM=i(ie.Object.keys),UM=i(zn),xM=i(ar),VM=wi,FM=Qn,BM=Gc,jM=te,GM=xi,WM=Gi,HM=Z,KM=sp,YM=ht,qM=Qc,zM=OR("slice"),XM=YM("species"),JM=Array,QM=Math.max;VM({target:"Array",proto:!0,forced:!zM},{slice:function(e,t){var i,n,r,o=HM(this),s=WM(o),a=GM(e,s),c=GM(void 0===t?s:t,s);if(FM(o)&&(i=o.constructor,(BM(i)&&(i===JM||FM(i.prototype))||jM(i)&&null===(i=i[XM]))&&(i=void 0),i===JM||void 0===i))return qM(o,a,c);for(n=new(void 0===i?JM:i)(QM(c-a,0)),r=0;a<c;a++,r++)a in o&&KM(n,r,o[a]);return n.length=r,n}});var ZM=Ji("Array").slice,$M=l,eU=ZM,tU=Array.prototype,iU=function(e){var t=e.slice;return e===tU||$M(tU,e)&&t===tU.slice?eU:t},nU=i(iU);function rU(e,t,i,n,r){var o,s,a,c={};return PM(o=MM(n)).call(o,(function(e){c[e]=n[e]})),c.enumerable=!!c.enumerable,c.configurable=!!c.configurable,("value"in c||c.initializer)&&(c.writable=!0),c=UM(s=xM(a=nU(i).call(i)).call(a)).call(s,(function(i,n){return n(e,t,i)||i}),c),r&&void 0!==c.initializer&&(c.value=c.initializer?c.initializer.call(r):void 0,c.initializer=void 0),void 0===c.initializer&&(fR(e,t,c),c=null),c}let oU=function(e){return e[e.ACCESS_POINT=101]="ACCESS_POINT",e[e.UNILBS=201]="UNILBS",e[e.STRING_UID_ALLOCATOR=901]="STRING_UID_ALLOCATOR",e}({}),sU=function(e){return e[e.IIIEGAL_APPID=1]="IIIEGAL_APPID",e[e.IIIEGAL_UID=2]="IIIEGAL_UID",e[e.INTERNAL_ERROR=3]="INTERNAL_ERROR",e}({}),aU=function(e){return e[e.INVALID_VENDOR_KEY=5]="INVALID_VENDOR_KEY",e[e.INVALID_CHANNEL_NAME=7]="INVALID_CHANNEL_NAME",e[e.INTERNAL_ERROR=8]="INTERNAL_ERROR",e[e.NO_AUTHORIZED=9]="NO_AUTHORIZED",e[e.DYNAMIC_KEY_TIMEOUT=10]="DYNAMIC_KEY_TIMEOUT",e[e.NO_ACTIVE_STATUS=11]="NO_ACTIVE_STATUS",e[e.DYNAMIC_KEY_EXPIRED=13]="DYNAMIC_KEY_EXPIRED",e[e.STATIC_USE_DYNAMIC_KEY=14]="STATIC_USE_DYNAMIC_KEY",e[e.DYNAMIC_USE_STATIC_KEY=15]="DYNAMIC_USE_STATIC_KEY",e[e.USER_OVERLOAD=16]="USER_OVERLOAD",e[e.FORBIDDEN_REGION=18]="FORBIDDEN_REGION",e[e.CANNOT_MEET_AREA_DEMAND=19]="CANNOT_MEET_AREA_DEMAND",e}({}),cU=function(e){return e[e.NO_FLAG_SET=100]="NO_FLAG_SET",e[e.FLAG_SET_BUT_EMPTY=101]="FLAG_SET_BUT_EMPTY",e[e.INVALID_FALG_SET=102]="INVALID_FALG_SET",e[e.FLAG_SET_BUT_NO_RE=103]="FLAG_SET_BUT_NO_RE",e[e.INVALID_SERVICE_ID=104]="INVALID_SERVICE_ID",e[e.NO_SERVICE_AVAILABLE=200]="NO_SERVICE_AVAILABLE",e[e.NO_SERVICE_AVAILABLE_P2P=201]="NO_SERVICE_AVAILABLE_P2P",e[e.NO_SERVICE_AVAILABLE_VOICE=202]="NO_SERVICE_AVAILABLE_VOICE",e[e.NO_SERVICE_AVAILABLE_WEBRTC=203]="NO_SERVICE_AVAILABLE_WEBRTC",e[e.NO_SERVICE_AVAILABLE_CDS=204]="NO_SERVICE_AVAILABLE_CDS",e[e.NO_SERVICE_AVAILABLE_CDN=205]="NO_SERVICE_AVAILABLE_CDN",e[e.NO_SERVICE_AVAILABLE_TDS=206]="NO_SERVICE_AVAILABLE_TDS",e[e.NO_SERVICE_AVAILABLE_REPORT=207]="NO_SERVICE_AVAILABLE_REPORT",e[e.NO_SERVICE_AVAILABLE_APP_CENTER=208]="NO_SERVICE_AVAILABLE_APP_CENTER",e[e.NO_SERVICE_AVAILABLE_ENV0=209]="NO_SERVICE_AVAILABLE_ENV0",e[e.NO_SERVICE_AVAILABLE_VOET=210]="NO_SERVICE_AVAILABLE_VOET",e[e.NO_SERVICE_AVAILABLE_STRING_UID=211]="NO_SERVICE_AVAILABLE_STRING_UID",e[e.NO_SERVICE_AVAILABLE_WEBRTC_UNILBS=212]="NO_SERVICE_AVAILABLE_WEBRTC_UNILBS",e[e.NO_SERVICE_AVAILABLE_UNILBS_FLV=213]="NO_SERVICE_AVAILABLE_UNILBS_FLV",e}({}),dU=function(e){return e[e.K_TIMESTAMP_EXPIRED=2]="K_TIMESTAMP_EXPIRED",e[e.K_CHANNEL_PERMISSION_INVALID=3]="K_CHANNEL_PERMISSION_INVALID",e[e.K_CERTIFICATE_INVALID=4]="K_CERTIFICATE_INVALID",e[e.K_CHANNEL_NAME_EMPTY=5]="K_CHANNEL_NAME_EMPTY",e[e.K_CHANNEL_NOT_FOUND=6]="K_CHANNEL_NOT_FOUND",e[e.K_TICKET_INVALID=7]="K_TICKET_INVALID",e[e.K_CHANNEL_CONFLICTED=8]="K_CHANNEL_CONFLICTED",e[e.K_SERVICE_NOT_READY=9]="K_SERVICE_NOT_READY",e[e.K_SERVICE_TOO_HEAVY=10]="K_SERVICE_TOO_HEAVY",e[e.K_UID_BANNED=14]="K_UID_BANNED",e[e.K_IP_BANNED=15]="K_IP_BANNED",e[e.K_CHANNEL_BANNED=16]="K_CHANNEL_BANNED",e[e.DATASTREAM2_NOT_AVAILABLE=27]="DATASTREAM2_NOT_AVAILABLE",e[e.K_AUTO_REBALANCE=28]="K_AUTO_REBALANCE
vendor: 2,568 bytes, line 12271
12271",e[e.WARN_NO_AVAILABLE_CHANNEL=103]="WARN_NO_AVAILABLE_CHANNEL",e[e.WARN_LOOKUP_CHANNEL_TIMEOUT=104]="WARN_LOOKUP_CHANNEL_TIMEOUT",e[e.WARN_LOOKUP_CHANNEL_REJECTED=105]="WARN_LOOKUP_CHANNEL_REJECTED",e[e.WARN_OPEN_CHANNEL_TIMEOUT=106]="WARN_OPEN_CHANNEL_TIMEOUT",e[e.WARN_OPEN_CHANNEL_REJECTED=107]="WARN_OPEN_CHANNEL_REJECTED",e[e.WARN_REQUEST_DEFERRED=108]="WARN_REQUEST_DEFERRED",e[e.ERR_DYNAMIC_KEY_TIMEOUT=109]="ERR_DYNAMIC_KEY_TIMEOUT",e[e.ERR_NO_AUTHORIZED=110]="ERR_NO_AUTHORIZED",e[e.ERR_VOM_SERVICE_UNAVAILABLE=111]="ERR_VOM_SERVICE_UNAVAILABLE",e[e.ERR_NO_CHANNEL_AVAILABLE_CODE=112]="ERR_NO_CHANNEL_AVAILABLE_CODE",e[e.ERR_MASTER_VOCS_UNAVAILABLE=114]="ERR_MASTER_VOCS_UNAVAILABLE",e[e.ERR_INTERNAL_ERROR=115]="ERR_INTERNAL_ERROR",e[e.ERR_NO_ACTIVE_STATUS=116]="ERR_NO_ACTIVE_STATUS",e[e.ERR_INVALID_UID=117]="ERR_INVALID_UID",e[e.ERR_DYNAMIC_KEY_EXPIRED=118]="ERR_DYNAMIC_KEY_EXPIRED",e[e.ERR_STATIC_USE_DYANMIC_KE=119]="ERR_STATIC_USE_DYANMIC_KE",e[e.ERR_DYNAMIC_USE_STATIC_KE=120]="ERR_DYNAMIC_USE_STATIC_KE",e[e.ERR_NO_VOCS_AVAILABLE=2e3]="ERR_NO_VOCS_AVAILABLE",e[e.ERR_NO_VOS_AVAILABLE=2001]="ERR_NO_VOS_AVAILABLE",e[e.ERR_JOIN_CHANNEL_TIMEOUT=2002]="ERR_JOIN_CHANNEL_TIMEOUT",e[e.ERR_REPEAT_JOIN_CHANNEL=2003]="ERR_REPEAT_JOIN_CHANNEL",e[e.ERR_JOIN_BY_MULTI_IP=2004]="ERR_JOIN_BY_MULTI_IP",e[e.ERR_NOT_JOINED=2011]="ERR_NOT_JOINED",e[e.ERR_REPEAT_JOIN_REQUEST=2012]="ERR_REPEAT_JOIN_REQUEST",e[e.ERR_INVALID_VENDOR_KEY=2013]="ERR_INVALID_VENDOR_KEY",e[e.ERR_INVALID_CHANNEL_NAME=2014]="ERR_INVALID_CHANNEL_NAME",e[e.ERR_INVALID_STRINGUID=2015]="ERR_INVALID_STRINGUID",e[e.ERR_TOO_MANY_USERS=2016]="ERR_TOO_MANY_USERS",e[e.ERR_SET_CLIENT_ROLE_TIMEOUT=2017]="ERR_SET_CLIENT_ROLE_TIMEOUT",e[e.ERR_SET_CLIENT_ROLE_NO_PERMISSION=2018]="ERR_SET_CLIENT_ROLE_NO_PERMISSION",e[e.ERR_SET_CLIENT_ROLE_ALREADY_IN_USE=2019]="ERR_SET_CLIENT_ROLE_ALREADY_IN_USE",e[e.ERR_PUBLISH_REQUEST_INVALID=2020]="ERR_PUBLISH_REQUEST_INVALID",e[e.ERR_SUBSCRIBE_REQUEST_INVALID=2021]="ERR_SUBSCRIBE_REQUEST_INVALID",e[e.ERR_NOT_SUPPORTED_MESSAGE=2022]="ERR_NOT_SUPPORTED_MESSAGE",e[e.ERR_ILLEAGAL_PLUGIN=2023]="ERR_ILLEAGAL_PLUGIN",e[e.ERR_REJOIN_TOKEN_INVALID=2024]="ERR_REJOIN_TOKEN_INVALID",e[e.ERR_REJOIN_USER_NOT_JOINED=2025]="ERR_REJOIN_USER_NOT_JOINED",e[e.ERR_INVALID_OPTIONAL_INFO=2027]="ERR_INVALID_OPTIONAL_INFO",e[e.ILLEGAL_AES_PASSWORD=2028]="ILLEGAL_AES_PASSWORD",e[e.ILLEGAL_CLIENT_ROLE_LEVEL=2029]="ILLEGAL_CLIENT_ROLE_LEVEL",e[e.ERR_TOO_MANY_BROADCASTERS=2031]="ERR_TOO_MANY_BROADCASTERS",e[e.ERR_TOO_MANY_SUBSCRIBERS=2032]="ERR_TOO_MANY_SUBSCRIBERS",e[e.ERR_
vendor: 15,459 bytes, line 12271
12271LICENSE_MISSING=32769]="ERR_LICENSE_MISSING",e[e.ERR_LICENSE_EXPIRED=32771]="ERR_LICENSE_EXPIRED",e[e.ERR_LICENSE_MINUTES_EXCEEDED=32773]="ERR_LICENSE_MINUTES_EXCEEDED",e[e.ERR_LICENSE_PERIOD_INVALID=32774]="ERR_LICENSE_PERIOD_INVALID",e[e.ERR_LICENSE_MULTIPLE_SDK_SERVICE=32778]="ERR_LICENSE_MULTIPLE_SDK_SERVICE",e[e.ERR_LICENSE_ILLEGAL=32783]="ERR_LICENSE_ILLEGAL",e[e.ERR_TEST_RECOVER=9e3]="ERR_TEST_RECOVER",e[e.ERR_TEST_TRYNEXT=9001]="ERR_TEST_TRYNEXT",e[e.ERR_TEST_RETRY=9002]="ERR_TEST_RETRY",e}({}),lU=function(e){return e.CONNECTING="connecting",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.CLOSED="closed",e}({}),uU=function(e){return e.WS_CONNECTED="ws_connected",e.WS_RECONNECTING="ws_reconnecting",e.WS_CLOSED="ws_closed",e.WS_RECONNECT_CREATE_CONNECTION="ws_reconnect_create_connection",e.ON_BINARY_DATA="on_binary_data",e.REQUEST_RECOVER="request_recover",e.REQUEST_JOIN_INFO="request_join_info",e.REQUEST_REJOIN_INFO="req_rejoin_info",e.IS_P2P_DISCONNECTED="is_p2p_dis",e.DISCONNECT_P2P="dis_p2p",e.ABORT_P2P_EXECUTION="abort_p2p_execution",e.NEED_RENEW_SESSION="need-sid",e.REPORT_JOIN_GATEWAY="report_join_gateway",e.REQUEST_TIMEOUT="request_timeout",e.REQUEST_SUCCESS="request_success",e.JOIN_RESPONSE="join_response",e.PRE_CONNECT_PC="pre_connect_pc",e.P2P_CONNECTION="p2p_connection",e.P2P_REMOTE_CANDIDATE_UPDATE="p2p_remote_candidate_update",e.P2P_SUBSCRIBE="p2p_subscribe",e.P2P_UNSUBSCRIBE="p2p_unsubscribe",e.P2P_EXCHANGE_SDP="p2p_exchange_sdp",e.P2P_ON_ADD_VIDEO_STREAM="p2p_on_add_video_stream",e.P2P_ON_ADD_AUDIO_STREAM="p2p_on_add_audio_stream",e.RECOVER_NOTIFICATION="recover_notification",e}({}),hU=function(e){return e.PING="ping",e.PING_BACK="ping_back",e.JOIN="join_v3",e.REJOIN="rejoin_v3",e.LEAVE="leave",e.SET_CLIENT_ROLE="set_client_role",e.PUBLISH="publish",e.PUBLISH_DATASTREAM="publish_datastream",e.UNPUBLISH="unpublish",e.UNPUBLISH_DATASTREAM="unpublish_datastream",e.SUBSCRIBE="subscribe",e.PRE_SUBSCRIBE="pre_subscribe",e.SUBSCRIBE_DATASTREAM="subscribe_datastream",e.SUBSCRIBE_STREAMS="subscribe_streams",e.UNSUBSCRIBE="unsubscribe",e.UNSUBSCRIBE_DATASTREAM="unsubscribe_datastream",e.UNSUBSCRIBE_STREAMS="unsubscribe_streams",e.SUBSCRIBE_CHANGE="subscribe_change",e.TRAFFIC_STATS="traffic_stats",e.RENEW_TOKEN="renew_token",e.SWITCH_VIDEO_STREAM="switch_video_stream",e.DEFAULT_VIDEO_STREAM="default_video_stream",e.SET_FALLBACK_OPTION="set_fallback_option",e.GATEWAY_INFO="gateway_info",e.CONTROL="control",e.SEND_METADATA="send_metadata",e.DATA_STREAM="data_stream",e.PICK_SVC_LAYER="pick_svc_layer",e.RESTART_ICE="restart_ice",e.CONNECT_PC="connect_pc",e.SET_VIDEO_PROFILE="set_video_profile",e.SET_PARAMETER="set_parameter",e.SET_RTM2_FLAG="set_rtm2_flag",e}({}),pU=function(e){return e.WRTC_STATS="wrtc_stats",e.WS_INFLATE_DATA_LENGTH="ws_inflate_data_length",e.DENOISER_STATS="denoiser_stats",e.EXTENSION_USAGE_STATS="extension_usage_stats",e}({}),_U=function(e){return e.ON_USER_ONLINE="on_user_online",e.ON_USER_OFFLINE="on_user_offline",e.ON_STREAM_FALLBACK_UPDATE="on_stream_fallback_update",e.ON_PUBLISH_STREAM="on_publish_stream",e.ON_UPLINK_STATS="on_uplink_stats",e.ON_P2P_LOST="on_p2p_lost",e.ON_REMOVE_STREAM="on_remove_stream",e.ON_ADD_AUDIO_STREAM="on_add_audio_stream",e.ON_ADD_VIDEO_STREAM="on_add_video_stream",e.ON_TOKEN_PRIVILEGE_WILL_EXPIRE="on_token_privilege_will_expire",e.ON_TOKEN_PRIVILEGE_DID_EXPIRE="on_token_privilege_did_expire",e.ON_USER_BANNED="on_user_banned",e.ON_USER_LICENSE_BANNED="on_user_license_banned",e.ON_NOTIFICATION="on_notification",e.ON_CRYPT_ERROR="on_crypt_error",e.MUTE_AUDIO="mute_audio",e.MUTE_VIDEO="mute_video",e.UNMUTE_AUDIO="unmute_audio",e.UNMUTE_VIDEO="unmute_video",e.ON_P2P_OK="on_p2p_ok",e.RECEIVE_METADATA="receive_metadata",e.ON_DATA_STREAM="on_data_stream",e.ON_RTP_CAPABILITY_CHANGE="on_rtp_capability_change",e.ON_REMOTE_DATASTREAM_UPDATE="on_remote_datastream_update",e.ON_REMOTE_FULL_DATASTREAM_INFO="on_remote_full_datastream_info",e.ENABLE_LOCAL_VIDEO="enable_local_video",e.DISABLE_LOCAL_VIDEO="disable_local_video",e.ENABLE_LOCAL_AUDIO="enable_local_audio",e.DISABLE_LOCAL_AUDIO="disable_local_audio",e.ON_PUBLISHED_USER_LIST="on_published_user_list",e}({}),EU=function(e){return e.SEND_ONLY="SEND_ONLY",e.RECEIVE_ONLY="RECEIVE_ONLY",e}({}),mU=function(e){return e.CONNECTED="websocket:connected",e.RECONNECTING="websocket:reconnecting",e.WILL_RECONNECT="websocket:will_reconnect",e.CLOSED="websocket:closed",e.FAILED="websocket:failed",e.ON_MESSAGE="websocket:on_message",e.REQUEST_NEW_URLS="websocket:request_new_urls",e.RECONNECT_CREATE_CONNECTION="websocket:reconnect_create_connection",e.ON_TOKEN_PRIVILEGE_DID_EXPIRE="websocket:on_token_privilege_did_expire",e}({});function fU(e){if("string"!=typeof e||!/^[a-zA-Z0-9 \!\#\$\%\&\(\)\+\-\:\;\<\=\.\>\?\@\[\]\^\_\{\}\|\~\,]{1,64}$/.test(e))throw YN.error("Invalid Channel Name ".concat(e)),new tD(Ew.INVALID_PARAMS,"The length must be within 64 bytes. The supported characters: a-z,A-Z,0-9,space,!, #, $, %, &, (, ), +, -, :, ;, <, =, ., >, ?, @, [, ], ^, _, {, }, |, ~, ,")}function TU(e){if(!(t=e,"number"==typeof t&&Math.floor(t)===t&&0<=t&&t<=4294967295||Iw(e,1,255)))throw new tD(Ew.INVALID_PARAMS,"[String uid] Length of the string: [1,255]. ASCII characters only. [Number uid] The value range is [0,10000]");var t;"string"==typeof e&&YN.warn("You input a string as the user ID, to ensure better end-user experience, Agora highly suggests not using a string as the user ID.")}let SU=function(e){return e.TRANSCODE="mix_streaming",e.RAW="raw_streaming",e}({});const gU={alpha:1,height:640,width:360,x:0,y:0,zOrder:0,audioChannel:0},RU={x:0,y:0,width:160,height:160,zOrder:255,alpha:1};function vU(e,t){Rw(e.url,"".concat(t,".url"),1,1e3,!1),Cw(e.x)||Sw(e.x,"".concat(t,".x"),0,1e4),Cw(e.y)||Sw(e.y,"".concat(t,".y"),0,1e4),Cw(e.width)||Sw(e.width,"".concat(t,".width"),0,1e4),Cw(e.height)||Sw(e.height,"".concat(t,".height"),0,1e4),Cw(e.zOrder)||Sw(e.zOrder,"".concat(t,".zOrder"),0,255),Cw(e.alpha)||Sw(e.alpha,"".concat(t,".alpha"),0,1,!1)}const CU={audioBitrate:48,audioChannels:1,audioSampleRate:48e3,backgroundColor:0,height:360,lowLatency:!1,videoBitrate:400,videoCodecProfile:100,videoCodecType:1,videoFrameRate:15,videoGop:30,width:640,images:[],userConfigs:[],userConfigExtraInfo:""};let IU=function(e){return e.WARNING="@live_uap-warning",e.ERROR="@line_uap-error",e.PUBLISH_STREAM_STATUS="@live_uap-publish-status",e.WORKER_STATUS="@live_uap-worker-status",e.REQUEST_NEW_ADDRESS="@live_uap-request-address",e}({}),yU=function(e){return e.REQUEST_WORKER_MANAGER_LIST="@live_req_worker_manager",e}({}),AU=function(e){return e[e.LIVE_STREAM_RESPONSE_SUCCEED=200]="LIVE_STREAM_RESPONSE_SUCCEED",e[e.LIVE_STREAM_RESPONSE_ALREADY_EXISTS_STREAM=454]="LIVE_STREAM_RESPONSE_ALREADY_EXISTS_STREAM",e[e.LIVE_STREAM_RESPONSE_TRANSCODING_PARAMETER_ERROR=450]="LIVE_STREAM_RESPONSE_TRANSCODING_PARAMETER_ERROR",e[e.LIVE_STREAM_RESPONSE_BAD_STREAM=451]="LIVE_STREAM_RESPONSE_BAD_STREAM",e[e.LIVE_STREAM_RESPONSE_WM_PARAMETER_ERROR=400]="LIVE_STREAM_RESPONSE_WM_PARAMETER_ERROR",e[e.LIVE_STREAM_RESPONSE_WM_WORKER_NOT_EXIST=404]="LIVE_STREAM_RESPONSE_WM_WORKER_NOT_EXIST",e[e.LIVE_STREAM_RESPONSE_NOT_AUTHORIZED=456]="LIVE_STREAM_RESPONSE_NOT_AUTHORIZED",e[e.LIVE_STREAM_RESPONSE_FAILED_LOAD_IMAGE=457]="LIVE_STREAM_RESPONSE_FAILED_LOAD_IMAGE",e[e.LIVE_STREAM_RESPONSE_REQUEST_TOO_OFTEN=429]="LIVE_STREAM_RESPONSE_REQUEST_TOO_OFTEN",e[e.LIVE_STREAM_RESPONSE_NOT_FOUND_PUBLISH=452]="LIVE_STREAM_RESPONSE_NOT_FOUND_PUBLISH",e[e.LIVE_STREAM_RESPONSE_NOT_SUPPORTED=453]="LIVE_STREAM_RESPONSE_NOT_SUPPORTED",e[e.LIVE_STREAM_RESPONSE_MAX_STREAM_NUM=455]="LIVE_STREAM_RESPONSE_MAX_STREAM_NUM",e[e.LIVE_STREAM_RESPONSE_INTERNAL_SERVER_ERROR=500]="LIVE_STREAM_RESPONSE_INTERNAL_SERVER_ERROR",e[e.LIVE_STREAM_RESPONSE_WORKER_LOST=501]="LIVE_STREAM_RESPONSE_WORKER_LOST",e[e.LIVE_STREAM_RESPONSE_RESOURCE_LIMIT=502]="LIVE_STREAM_RESPONSE_RESOURCE_LIMIT",e[e.LIVE_STREAM_RESPONSE_WORKER_QUIT=503]="LIVE_STREAM_RESPONSE_WORKER_QUIT",e[e.ERROR_FAIL_SEND_MESSAGE=504]="ERROR_FAIL_SEND_MESSAGE",e[e.PUBLISH_STREAM_STATUS_ERROR_RTMP_HANDSHAKE=30]="PUBLISH_STREAM_STATUS_ERROR_RTMP_HANDSHAKE",e[e.PUBLISH_STREAM_STATUS_ERROR_RTMP_CONNECT=31]="PUBLISH_STREAM_STATUS_ERROR_RTMP_CONNECT",e[e.PUBLISH_STREAM_STATUS_ERROR_RTMP_PUBLISH=32]="PUBLISH_STREAM_STATUS_ERROR_RTMP_PUBLISH",e[e.PUBLISH_STREAM_STATUS_ERROR_PUBLISH_BROKEN=33]="PUBLISH_STREAM_STATUS_ERROR_PUBLISH_BROKEN",e}({});function bU(e){if(!e.channelName)throw new tD(Ew.INVALID_PARAMS,"invalid channelName in info");if("number"!=typeof e.uid)throw new tD(Ew.INVALID_PARAMS,"invalid uid in info, uid must be a number");return e.token&&Rw(e.token,"info.token",1,2047),TU(e.uid),fU(e.channelName),!0}let wU=function(e){return e[e.SetSdkProfile=0]="SetSdkProfile",e[e.SetSourceChannel=1]="SetSourceChannel",e[e.SetSourceUserId=2]="SetSourceUserId",e[e.SetDestChannel=3]="SetDestChannel",e[e.StartPacketTransfer=4]="StartPacketTransfer",e[e.StopPacketTransfer=5]="StopPacketTransfer",e[e.UpdateDestChannel=6]="UpdateDestChannel",e[e.Reconnect=7]="Reconnect",e[e.SetVideoProfile=8]="SetVideoProfile",e}({}),OU=function(e){return e.NETWORK_DISCONNECTED="NETWORK_DISCONNECTED",e.NETWORK_CONNECTED="NETWORK_CONNECTED",e.PACKET_JOINED_SRC_CHANNEL="PACKET_JOINED_SRC_CHANNEL",e.PACKET_JOINED_DEST_CHANNEL="PACKET_JOINED_DEST_CHANNEL",e.PACKET_SENT_TO_DEST_CHANNEL="PACKET_SENT_TO_DEST_CHANNEL",e.PACKET_RECEIVED_VIDEO_FROM_SRC="PACKET_RECEIVED_VIDEO_FROM_SRC",e.PACKET_RECEIVED_AUDIO_FROM_SRC="PACKET_RECEIVED_AUDIO_FROM_SRC",e.PACKET_UPDATE_DEST_CHANNEL="PACKET_UPDATE_DEST_CHANNEL",e.PACKET_UPDATE_DEST_CHANNEL_REFUSED="PACKET_UPDATE_DEST_CHANNEL_REFUSED",e.PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE="PACKET_UPDATE_DEST_CHANNEL_NOT_CHANGE",e}({}),NU=function(e){return e.RELAY_STATE_IDLE="RELAY_STATE_IDLE",e.RELAY_STATE_CONNECTING="RELAY_STATE_CONNECTING",e.RELAY_STATE_RUNNING="RELAY_STATE_RUNNING",e.RELAY_STATE_FAILURE="RELAY_STATE_FAILURE",e}({}),DU=function(e){return e.RELAY_OK="RELAY_OK",e.SERVER_CONNECTION_LOST="SERVER_CONNECTION_LOST",e.SRC_TOKEN_EXPIRED="SRC_TOKEN_EXPIRED",e.DEST_TOKEN_EXPIRED="DEST_TOKEN_EXPIRED",e}({}),PU=function(e){return e.High="high",e.Low="low",e.Audio="audio",e.Screen="screen",e.ScreenLow="screen_low",e}({}),LU=function(e){return e.DISCONNECT="disconnect",e.CONNECTION_STATE_CHANGE="connection-state-change",e.NETWORK_QUALITY="network-quality",e.STREAM_TYPE_CHANGE="stream-type-change",e.IS_P2P_DISCONNECTED="is-p2p-dis",e.DISCONNECT_P2P="dis-p2p",e.REQUEST_NEW_GATEWAY_LIST="req-gate-url",e.NEED_RENEW_SESSION="need-sid",e.REQUEST_P2P_CONNECTION_PARAMS="request-p2p-connection-params",e.JOIN_RESPONSE="join-response",e.RESET_CONNECTION_EVENTS="reset-connection-events",e.PRE_CONNECT_PC="pre-connect_pc",e.UPDATE_GATEWAY_CONFIG="update-gateway-config",e}({}),kU=function(e){return e.P2P_DISCONNECTED="P2P_DISCONNECTED",e.A_ROUND_WS_FAILED="A_ROUND_WS_FAILED",e.TIMEOUT="TIMEOUT",e.UNKNOWN_REASON="UNKNOWN_REASON",e}({}),MU=function(e){return e[e.Nothing=0]="Nothing",e[e.Audio=1]="Audio",e[e.LwoVideo=2]="LwoVideo",e[e.Video=4]="Video",e[e.Data=8]="Data",e[e.DataStream0=256]="DataStream0",e[e.DataStream1=512]="DataStream1",e[e.DataStream2=1024]="DataStream2",e[e.DataStream3=2048]="DataStream3",e[e.DataStream4=4096]="DataStream4",e[e.DataStream5=8192]="DataStream5",e[e.DataStream6=16384]="DataStream6",e[e.DataStream7=32768]="DataStream7",e}({}),UU=function(e){return e.CHINA="CHINA",e.ASIA="ASIA",e.NORTH_AMERICA="NORTH_AMERICA",e.EUROPE="EUROPE",e.JAPAN="JAPAN",e.INDIA="INDIA",e.KOREA="KOREA",e.HKMC="HKMC",e.US="US",e.OCEANIA="OCEANIA",e.SOUTH_AMERICA="SOUTH_AMERICA",e.AFRICA="AFRICA",e.OVERSEA="OVERSEA",e.GLOBAL="GLOBAL",e.EXTENSIONS="EXTENSIONS",e}({});const xU=[UU.AFRICA,UU.ASIA,UU.CHINA,UU.EUROPE,UU.GLOBAL,UU.INDIA,UU.JAPAN,UU.NORTH_AMERICA,UU.OCEANIA,UU.OVERSEA,UU.SOUTH_AMERICA];let VU=function(e){return e.CHINA="CN",e.ASIA="AS",e.NORTH_AMERICA="NA",e.EUROPE="EU",e.JAPAN="JP",e.INDIA="IN",e.KOREA="KR",e.HKMC="HK",e.US="US",e.OCEANIA="OC",e.SOUTH_AMERICA="SA",e.AFRICA="AF",e.OVERSEA="OVERSEA",e.GLOBAL="GLOBAL",e.EXTENSIONS="GLOBAL",e}({});const FU={CHINA:{},ASIA:{CODE:VU.ASIA,WEBCS_DOMAIN:["ap-web-1-asia.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-asia.agora.io"],PROXY_CS:["proxy-ap-web-asia.agora.io"],CDS_AP:["cds-ap-web-asia.agora.io","cds-ap-web-asia2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-asia.agora.io","sua-ap-web-asia2.agora.io"],UAP_AP:["uap-ap-web-asia.agora.io","uap-ap-web-asia2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-asia.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-asia.agora.io"],LOG_UPLOAD_SERVER:["logservice-asia.agora.io"],PROXY_SERVER_TYPE3:["southeast-asia.webrtc-cloud-proxy.sd-rtn.com"]},NORTH_AMERICA:{CODE:VU.NORTH_AMERICA,WEBCS_DOMAIN:["ap-web-1-north-america.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-north-america.agora.io"],PROXY_CS:["proxy-ap-web-america.agora.io"],CDS_AP:["cds-ap-web-america.agora.io","cds-ap-web-america2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-america.agora.io","sua-ap-web-america2.agora.io"],UAP_AP:["uap-ap-web-america.agora.io","uap-ap-web-america2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-north-america.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-north-america.agora.io"],LOG_UPLOAD_SERVER:["logservice-north-america.agora.io"],PROXY_SERVER_TYPE3:["east-usa.webrtc-cloud-proxy.sd-rtn.com"]},EUROPE:{CODE:VU.EUROPE,WEBCS_DOMAIN:["ap-web-1-europe.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-europe.agora.io"],PROXY_CS:["proxy-ap-web-europe.agora.io"],CDS_AP:["cds-ap-web-europe.agora.io","cds-ap-web-europe2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-europe.agora.io","sua-ap-web-europe.agora.io"],UAP_AP:["uap-ap-web-europe.agora.io","uap-ap-web-europe2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-europe.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-europe.agora.io"],LOG_UPLOAD_SERVER:["logservice-europe.agora.io"],PROXY_SERVER_TYPE3:["europe.webrtc-cloud-proxy.sd-rtn.com"]},JAPAN:{CODE:VU.JAPAN,WEBCS_DOMAIN:["ap-web-1-japan.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-japan.agora.io"],PROXY_CS:["proxy-ap-web-japan.agora.io"],CDS_AP:["cds-ap-web-japan.agora.io","cds-ap-web-japan2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-japan.agora.io","sua-ap-web-japan2.agora.io"],UAP_AP:["uap-ap-web-japan.agora.io","uap-ap-web-japan2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-japan.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-japan.agora.io"],LOG_UPLOAD_SERVER:["logservice-japan.agora.io"],PROXY_SERVER_TYPE3:["japan.webrtc-cloud-proxy.sd-rtn.com"]},INDIA:{CODE:VU.INDIA,WEBCS_DOMAIN:["ap-web-1-india.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-india.agora.io"],PROXY_CS:["proxy-ap-web-india.agora.io"],CDS_AP:["cds-ap-web-india.agora.io","cds-ap-web-india2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-india.agora.io","sua-ap-web-india2.agora.io"],UAP_AP:["uap-ap-web-india.agora.io","uap-ap-web-india2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-india.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-india.agora.io"],LOG_UPLOAD_SERVER:["logservice-india.agora.io"],PROXY_SERVER_TYPE3:["india.webrtc-cloud-proxy.sd-rtn.com"]},KOREA:{CODE:VU.KOREA,WEBCS_DOMAIN:["ap-web-1-korea.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-korea.agora.io"],PROXY_CS:["proxy-ap-web-korea.agora.io"],CDS_AP:["cds-ap-web-korea.agora.io","cds-ap-web-korea2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-korea.agora.io","sua-ap-web-kor
12271ea2.agora.io"],UAP_AP:["uap-ap-web-korea.agora.io","uap-ap-web-korea2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-korea.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-korea.agora.io"],LOG_UPLOAD_SERVER:["logservice-korea.agora.io"],PROXY_SERVER_TYPE3:["korea.webrtc-cloud-proxy.sd-rtn.com"]},HKMC:{CODE:VU.HKMC,WEBCS_DOMAIN:["ap-web-1-hkmc.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-hkmc.agora.io"],PROXY_CS:["proxy-ap-web-hkmc.agora.io"],CDS_AP:["cds-ap-web-hkmc.agora.io","cds-ap-web-hkmc2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-hkmc.agora.io","sua-ap-web-hkmc2.agora.io"],UAP_AP:["uap-ap-web-hkmc.agora.io","uap-ap-web-hkmc2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-hkmc.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-hkmc.agora.io"],LOG_UPLOAD_SERVER:["logservice-hkmc.agora.io"],PROXY_SERVER_TYPE3:["hkmc.webrtc-cloud-proxy.sd-rtn.com"]},US:{CODE:VU.US,WEBCS_DOMAIN:["ap-web-1-us.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-us.agora.io"],PROXY_CS:["proxy-ap-web-us.agora.io"],CDS_AP:["cds-ap-web-us.agora.io","cds-ap-web-us2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-us.agora.io","sua-ap-web-us2.agora.io"],UAP_AP:["uap-ap-web-us.agora.io","uap-ap-web-us2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-us.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-us.agora.io"],LOG_UPLOAD_SERVER:["logservice-us.agora.io"],PROXY_SERVER_TYPE3:["us.webrtc-cloud-proxy.sd-rtn.com"]},OVERSEA:{CODE:VU.OVERSEA,WEBCS_DOMAIN:["ap-web-1-oversea.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-oversea.agora.io"],PROXY_CS:["proxy-ap-web-oversea.agora.io"],CDS_AP:["cds-ap-web-oversea.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-oversea.agora.io"],UAP_AP:["uap-ap-web-oversea.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-oversea.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-oversea.agora.io"],LOG_UPLOAD_SERVER:["logservice-oversea.agora.io"],PROXY_SERVER_TYPE3:["webrtc-cloud-proxy.agora.io"]},GLOBAL:{CODE:VU.GLOBAL,WEBCS_DOMAIN:["webrtc2-ap-web-1.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["webrtc2-ap-web-3.agora.io"],PROXY_CS:["ap-proxy-1.agora.io","ap-proxy-2.agora.io"],CDS_AP:["cds-ap-web-1.agora.io","cds-ap-web-3.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-1.agora.io","sua-ap-web-3.agora.io"],UAP_AP:["uap-ap-web-1.agora.io","uap-ap-web-3.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2.agora.io"],LOG_UPLOAD_SERVER:["logservice.agora.io"],PROXY_SERVER_TYPE3:["webrtc-cloud-proxy.sd-rtn.com"]},OCEANIA:{CODE:VU.OCEANIA,WEBCS_DOMAIN:["ap-web-1-oceania.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-oceania.agora.io"],PROXY_CS:["proxy-ap-web-oceania.agora.io"],CDS_AP:["cds-ap-web-oceania.agora.io","cds-ap-web-oceania2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-oceania.agora.io","sua-ap-web-oceania2.agora.io"],UAP_AP:["uap-ap-web-oceania.agora.io","uap-ap-web-oceania2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-oceania.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-oceania.agora.io"],LOG_UPLOAD_SERVER:["logservice-oceania.agora.io"],PROXY_SERVER_TYPE3:["oceania.webrtc-cloud-proxy.sd-rtn.com"]},SOUTH_AMERICA:{CODE:VU.SOUTH_AMERICA,WEBCS_DOMAIN:["ap-web-1-south-america.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-south-america.agora.io"],PROXY_CS:["proxy-ap-web-south-america.agora.io"],CDS_AP:["cds-ap-web-south-america.agora.io","cds-ap-web-south-america2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-south-america.agora.io","sua-ap-web-south-america2.agora.io"],UAP_AP:["uap-ap-web-south-america.agora.io","uap-ap-web-south-america2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-south-america.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-south-america.agora.io"],LOG_UPLOAD_SERVER:["logservice-south-america.agora.io"],PROXY_SERVER_TYPE3:["south-america.webrtc-cloud-proxy.sd-rtn.com"]},AFRICA:{CODE:VU.AFRICA,WEBCS_DOMAIN:["ap-web-1-africa.agora.io"],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-africa.agora.io"],PROXY_CS:["proxy-ap-web-africa.agora.io"],CDS_AP:["cds-ap-web-africa.agora.io","cds-ap-web-africa2.agora.io"],ACCOUNT_REGISTER:["sua-ap-web-africa.agora.io","sua-ap-web-africa2.agora.io"],UAP_AP:["uap-ap-web-africa.agora.io","uap-ap-web-africa2.agora.io"],EVENT_REPORT_DOMAIN:["statscollector-1-africa.agora.io"],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-africa.agora.io"],LOG_UPLOAD_SERVER:["logservice-south-africa.agora.io"],PROXY_SERVER_TYPE3:["africa.webrtc-cloud-proxy.sd-rtn.com"]},EXTENSIONS:{}};
vendor: 48,654 bytes, line 12271
12271oN&&(FU.CHINA={CODE:VU.CHINA,WEBCS_DOMAIN:["webrtc2-2.ap.sd-rtn.com"],WEBCS_DOMAIN_BACKUP_LIST:["webrtc2-4.ap.sd-rtn.com"],PROXY_CS:["proxy-web.ap.sd-rtn.com"],CDS_AP:["cds-web-2.ap.sd-rtn.com","cds-web-4.ap.sd-rtn.com"],ACCOUNT_REGISTER:["sua-web-2.ap.sd-rtn.com","sua-web-4.ap.sd-rtn.com"],UAP_AP:["uap-web-2.ap.sd-rtn.com","uap-web-4.ap.sd-rtn.com"],EVENT_REPORT_DOMAIN:["web-3.statscollector.sd-rtn.com"],EVENT_REPORT_BACKUP_DOMAIN:["web-4.statscollector.sd-rtn.com"],LOG_UPLOAD_SERVER:["logservice-china.agora.io"],PROXY_SERVER_TYPE3:["east-cn.webrtc-cloud-proxy.sd-rtn.com"]});let BU=function(e){return e.UPDATE_BITRATE_LIMIT="update_bitrate_limit",e.UPDATE_CLIENT_ROLE_OPTIONS="update_client_role_options",e}({});function jU(e){return!!e&&(!(!e.uplink||!e.id)&&(void 0!==e.uplink.max_bitrate&&void 0!==e.uplink.min_bitrate))}class GU extends Dw{constructor(e,t){super(),QI(this,"onICEConnectionStateChange",void 0),QI(this,"onConnectionStateChange",void 0),QI(this,"onDTLSTransportStateChange",void 0),QI(this,"onDTLSTransportError",void 0),QI(this,"onICETransportStateChange",void 0),QI(this,"onFirstAudioReceived",void 0),QI(this,"onFirstVideoReceived",void 0),QI(this,"onFirstAudioDecoded",void 0),QI(this,"onFirstVideoDecoded",void 0),QI(this,"onFirstVideoDecodedTimeout",void 0),QI(this,"onSelectedLocalCandidateChanged",void 0),QI(this,"onSelectedRemoteCandidateChanged",void 0),QI(this,"onICECandidateError",void 0),QI(this,"getLocalVideoStats",void 0)}}class WU extends GU{constructor(e,t){super(e,t),QI(this,"establishPromise",void 0)}}let HU=function(e){return e.VIDEO="video",e.AUDIO="audio",e}({}),KU=function(e){return e.UDP_RELAY="udp_relay",e.UDP_TCP_RELAY="udp_tcp_relay",e.TCP_RELAY="tcp_relay",e.RELAY="relay",e}({}),YU=function(e){return e[e.FIRST_CONNECTION=0]="FIRST_CONNECTION",e[e.UDP_TCP_RESTART=1]="UDP_TCP_RESTART",e[e.RELAY_RESTART=2]="RELAY_RESTART",e[e.TCP_RESTART=3]="TCP_RESTART",e[e.OLD_FIRST_CONNECTION=10]="OLD_FIRST_CONNECTION",e[e.OLD_RESTART=11]="OLD_RESTART",e[e.DISCONNECTED_OR_FAILED=20]="DISCONNECTED_OR_FAILED",e}({});const qU=["disconnected","failed"];let zU=function(e){return e.LocalVideoTrack="videoTrack",e.LocalAudioTrack="audioTrack",e.LocalVideoLowTrack="videoLowTrack",e}({}),XU=function(e){return e.New="new",e.Connected="connected",e.Reconnecting="reconnecting",e.Disconnected="disconnected",e}({}),JU=function(e){return e.AudioMetadata="audioMetadata",e.StateChange="stateChange",e.IceConnectionStateChange="iceConnectionStateChange",e.RequestMuteLocal="requestMuteLocal",e.RequestUnmuteLocal="requestUnmuteLocal",e.RequestRePublish="requestRePublish",e.RequestRePublishDataChannel="requestRePublishDataChannel",e.RequestReSubscribe="requestReSubscribe",e.RequestUploadStats="requestUploadStats",e.RequestUpload="requestUpload",e.MediaReconnectStart="MediaReconnectStart",e.MediaReconnectEnd="MediaReconnectEnd",e.NeedSignalRTT="NeedSignalRTT",e.RequestRestartICE="RequestRestartIce",e.PeerConnectionStateChange="PeerConnectionStateChange",e.RequestReconnect="RequestReconnect",e.RequestReconnectPC="RequestReconnectPC",e.RequestUnpublishForReconnectPC="RequestUnpublishForReconnectPC",e.P2PLost="P2PLost",e.UpdateVideoEncoder="UpdateVideoEncoder",e.ConnectionTypeChange="ConnectionTypeChange",e.RequestLowStreamParameter="RequestLowStreamParameter",e.QueryClientConnectionState="QueryClientConnectionState",e.LocalCandidate="LocalCandidate",e.RequestP2PMuteLocal="requestP2PMuteLocal",e.RequestP2PUnPublish="RequestP2PUnPublish",e.RequestP2PUnmuteRemote="RequestP2PUnmuteRemote",e.RequestP2PMuteRemote="RequestP2PMuteRemote",e.RequestP2PRestartICE="RequestP2PRestartICE",e}({}),QU=function(e){return e.CONNECTING="CONNECTING",e.RECONNECTING="RECONNECTING",e.CONNECTED="CONNECTED",e.CLOSED="CLOSED",e}({}),ZU=function(e){return e[e.CONNECT_AP=0]="CONNECT_AP",e[e.AP_CONNECTED=1]="AP_CONNECTED",e[e.CONNECT_WORKER_MANAGER=2]="CONNECT_WORKER_MANAGER",e[e.WORKER_MANAGER_CONNECTED=3]="WORKER_MANAGER_CONNECTED",e[e.GET_WORKER_MANAGER_RESPONSE=4]="GET_WORKER_MANAGER_RESPONSE",e[e.CONNECT_WORKER=5]="CONNECT_WORKER",e[e.WORKER_CONNECTED=6]="WORKER_CONNECTED",e[e.CLOSED=7]="CLOSED",e}({}),$U=function(e){return e.CONNECTION_STATE_CHANGE="connection-state-change",e.STATE_CHANGE="state-change",e.INSPECT_RESULT="inspect-result",e.CLIENT_LOCAL_VIDEO_TRACK="client-local-video-track",e.REQUEST_NEW_WORKER_URL="request-new-worker-url",e}({}),ex=function(e){return e.CONNECTED="transmitter:connected",e.RECONNECTING="transmitter:reconnecting",e.WILL_RECONNECT="transmitter:will_reconnect",e.CLOSED="transmitter:closed",e.FAILED="transmitter:failed",e.ON_MESSAGE="transmitter:on_message",e.REQUEST_NEW_URLS="transmitter:request_new_urls",e.RECONNECT_CREATE_CONNECTION="transmitter:reconnect_create_connection",e.ON_TOKEN_PRIVILEGE_DID_EXPIRE="transmitter:on_token_privilege_did_expire",e.TO_CONNECT_DATACHANNEL="transmitter:to_connect_datachannel",e.FAILBACK="transmitter:failback",e.PRE_CONNECT_PC="transmitter:pre_connect_pc",e}({}),tx=function(e){return e.CAMERA_CHANGED="camera-changed",e.MICROPHONE_CHANGED="microphone-changed",e.PLAYBACK_DEVICE_CHANGED="playback-device-changed",e.AUDIO_AUTOPLAY_FAILED="audio-autoplay-failed",e.AUTOPLAY_FAILED="autoplay-failed",e.AUDIO_CONTEXT_STATE_CHANGED="audio-context-state-changed",e.SECURITY_POLICY_VIOLATION="security-policy-violation",e}({}),ix=function(e){return e.CONNECTING="CONNECTING",e.RECONNECTING="RECONNECTING",e.CONNECTED="CONNECTED",e.CLOSED="CLOSED",e}({}),nx=function(e){return e.CONNECTION_STATE_CHANGE="connection-state-change",e.STATE_CHANGE="state-change",e.INSPECT_RESULT="inspect-result",e.CLIENT_LOCAL_VIDEO_TRACK="client-local-video-track",e.REQUEST_NEW_WORKER_URL="request-new-worker-url",e}({}),rx=function(e){return e[e.CONNECT_AP=0]="CONNECT_AP",e[e.AP_CONNECTED=1]="AP_CONNECTED",e[e.CONNECT_WORKER_MANAGER=2]="CONNECT_WORKER_MANAGER",e[e.WORKER_MANAGER_CONNECTED=3]="WORKER_MANAGER_CONNECTED",e[e.GET_WORKER_MANAGER_RESPONSE=4]="GET_WORKER_MANAGER_RESPONSE",e[e.CONNECT_WORKER=5]="CONNECT_WORKER",e[e.WORKER_CONNECTED=6]="WORKER_CONNECTED",e[e.CLOSED=7]="CLOSED",e}({}),ox=function(e){return e.CALL="call",e.CANDIDATE="candidate",e.PUBLISH="publish",e.UNPUBLISH="unpublish",e.CONTROL="control",e.RESTART_ICE="restart_ice",e.ACK="ack",e.RESPONSE="response",e.JOIN="join",e.CHECK="check",e}({}),sx=function(e){return e.ABORT="abort",e}({}),ax=function(e){return e.MUTE_LOCAL_AUDIO="mute_local_audio",e.MUTE_LOCAL_VIDEO="mute_local_video",e.UNMUTE_LOCAL_AUDIO="unmute_local_audio",e.UNMUTE_LOCAL_VIDEO="unmute_local_video",e}({}),cx=function(e){return e.P2P_TOKEN_TIMEOUT="p2p_token_timeout",e.P2P_TOKEN_CHANGED="p2p_token_changed",e}({});const dx={[oU.ACCESS_POINT]:{[cU.NO_FLAG_SET]:{desc:"flag is zero",retry:!1},[cU.FLAG_SET_BUT_EMPTY]:{desc:"flag is empty",retry:!1},[cU.INVALID_FALG_SET]:{desc:"invalid flag",retry:!1},[cU.FLAG_SET_BUT_NO_RE]:{desc:"flag set unilbs but no request",retry:!1},[cU.INVALID_SERVICE_ID]:{desc:"invalid service id",retry:!1},[cU.NO_SERVICE_AVAILABLE]:{desc:"no service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_P2P]:{desc:"no unilbs p2p service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_VOICE]:{desc:"no unilbs voice service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_WEBRTC]:{desc:"no unilbs webrtc service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_CDS]:{desc:"no cds service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_CDN]:{desc:"no cdn dispatcher service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_TDS]:{desc:"no tds service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_REPORT]:{desc:"no unilbs report service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_APP_CENTER]:{desc:"no app center service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_ENV0]:{desc:"no unilbs sig env0 service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_VOET]:{desc:"no unilbs voet service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_STRING_UID]:{desc:"no string uid service available",retry:!0},[cU.NO_SERVICE_AVAILABLE_WEBRTC_UNILBS]:{desc:"no webrtc unilbs service available",retry:!0}},[oU.UNILBS]:{[aU.INVALID_VENDOR_KEY]:{desc:"invalid vendor key, can not find appid",retry:!1},[aU.INVALID_CHANNEL_NAME]:{desc:"invalid channel name",retry:!1},[aU.INTERNAL_ERROR]:{desc:"unilbs internal error",retry:!1},[aU.NO_AUTHORIZED]:{desc:"invalid token, authorized failed",retry:!1},[aU.DYNAMIC_KEY_TIMEOUT]:{desc:"dynamic key or token timeout",retry:!1},[aU.NO_ACTIVE_STATUS]:{desc:"no active status",retry:!1},[aU.DYNAMIC_KEY_EXPIRED]:{desc:"dynamic key expired",retry:!1},[aU.STATIC_USE_DYNAMIC_KEY]:{desc:"static use dynamic key",retry:!1},[aU.DYNAMIC_USE_STATIC_KEY]:{desc:"dynamic use static key",retry:!1},[aU.USER_OVERLOAD]:{desc:"amount of users over load",retry:!1},[aU.FORBIDDEN_REGION]:{desc:"the request is forbidden in this area",retry:!1},[aU.CANNOT_MEET_AREA_DEMAND]:{desc:"unable to allocate services in this area",retry:!1}},[oU.STRING_UID_ALLOCATOR]:{[sU.IIIEGAL_APPID]:{desc:"invalid appid",retry:!1},[sU.IIIEGAL_UID]:{desc:"invalid string uid",retry:!1},[sU.INTERNAL_ERROR]:{desc:"string uid allocator internal error",retry:!0}}};function lx(e){const t=dx[Math.floor(e/1e4)];if(!t)return{desc:"unknown error",retry:!1};const i=t[e%1e4];if(!i){if(Math.floor(e/1e4)===oU.ACCESS_POINT){const t=e%1e4;if("1"===t.toString()[0])return{desc:e.toString(),retry:!1};if("2"===t.toString()[0])return{desc:e.toString(),retry:!0}}return{desc:"unknown error",retry:!1}}return i}const ux={[dU.K_TIMESTAMP_EXPIRED]:{desc:"K_TIMESTAMP_EXPIRED",action:"failed"},[dU.K_CHANNEL_PERMISSION_INVALID]:{desc:"K_CHANNEL_PERMISSION_INVALID",action:"failed"},[dU.K_CERTIFICATE_INVALID]:{desc:"K_CERTIFICATE_INVALID",action:"failed"},[dU.K_CHANNEL_NAME_EMPTY]:{desc:"K_CHANNEL_NAME_EMPTY",action:"failed"},[dU.K_CHANNEL_NOT_FOUND]:{desc:"K_CHANNEL_NOT_FOUND",action:"failed"},[dU.K_TICKET_INVALID]:{desc:"K_TICKET_INVALID",action:"failed"},[dU.K_CHANNEL_CONFLICTED]:{desc:"K_CHANNEL_CONFLICTED",action:"failed"},[dU.K_SERVICE_NOT_READY]:{desc:"K_SERVICE_NOT_READY",action:"tryNext"},[dU.K_SERVICE_TOO_HEAVY]:{desc:"K_SERVICE_TOO_HEAVY",action:"tryNext"},[dU.K_UID_BANNED]:{desc:"K_UID_BANNED",action:"failed"},[dU.K_IP_BANNED]:{desc:"K_IP_BANNED",action:"failed"},[dU.DATASTREAM2_NOT_AVAILABLE]:{desc:"DATASTREAM2_NOT_AVAILABLE",action:"quit"},[dU.K_AUTO_REBALANCE]:{desc:"k_AUTO_REBALANCE",action:"recover"},[dU.ERR_INVALID_VENDOR_KEY]:{desc:"ERR_INVALID_VENDOR_KEY",action:"failed"},[dU.ERR_INVALID_CHANNEL_NAME]:{desc:"ERR_INVALID_CHANNEL_NAME",action:"failed"},[dU.WARN_NO_AVAILABLE_CHANNEL]:{desc:"WARN_NO_AVAILABLE_CHANNEL",action:"failed"},[dU.WARN_LOOKUP_CHANNEL_TIMEOUT]:{desc:"WARN_LOOKUP_CHANNEL_TIMEOUT",action:"tryNext"},[dU.WARN_LOOKUP_CHANNEL_REJECTED]:{desc:"WARN_LOOKUP_CHANNEL_REJECTED",action:"failed"},[dU.WARN_OPEN_CHANNEL_TIMEOUT]:{desc:"WARN_OPEN_CHANNEL_TIMEOUT",action:"tryNext"},[dU.WARN_OPEN_CHANNEL_REJECTED]:{desc:"WARN_OPEN_CHANNEL_REJECTED",action:"failed"},[dU.WARN_REQUEST_DEFERRED]:{desc:"WARN_REQUEST_DEFERRED",action:"failed"},[dU.ERR_DYNAMIC_KEY_TIMEOUT]:{desc:"ERR_DYNAMIC_KEY_TIMEOUT",action:"failed"},[dU.ERR_NO_AUTHORIZED]:{desc:"ERR_NO_AUTHORIZED",action:"failed"},[dU.ERR_VOM_SERVICE_UNAVAILABLE]:{desc:"ERR_VOM_SERVICE_UNAVAILABLE",action:"tryNext"},[dU.ERR_NO_CHANNEL_AVAILABLE_CODE]:{desc:"ERR_NO_CHANNEL_AVAILABLE_CODE",action:"failed"},[dU.ERR_MASTER_VOCS_UNAVAILABLE]:{desc:"ERR_MASTER_VOCS_UNAVAILABLE",action:"tryNext"},[dU.ERR_INTERNAL_ERROR]:{desc:"ERR_INTERNAL_ERROR",action:"tryNext"},[dU.ERR_NO_ACTIVE_STATUS]:{desc:"ERR_NO_ACTIVE_STATUS",action:"failed"},[dU.ERR_INVALID_UID]:{desc:"ERR_INVALID_UID",action:"failed"},[dU.ERR_DYNAMIC_KEY_EXPIRED]:{desc:"ERR_DYNAMIC_KEY_EXPIRED",action:"failed"},[dU.ERR_STATIC_USE_DYANMIC_KE]:{desc:"ERR_STATIC_USE_DYANMIC_KE",action:"failed"},[dU.ERR_DYNAMIC_USE_STATIC_KE]:{desc:"ERR_DYNAMIC_USE_STATIC_KE",action:"failed"},[dU.ERR_NO_VOCS_AVAILABLE]:{desc:"ERR_NO_VOCS_AVAILABLE",action:"tryNext"},[dU.ERR_NO_VOS_AVAILABLE]:{desc:"ERR_NO_VOS_AVAILABLE",action:"tryNext"},[dU.ERR_JOIN_CHANNEL_TIMEOUT]:{desc:"ERR_JOIN_CHANNEL_TIMEOUT",action:"tryNext"},[dU.ERR_JOIN_BY_MULTI_IP]:{desc:"ERR_JOIN_BY_MULTI_IP",action:"recover"},[dU.ERR_NOT_JOINED]:{desc:"ERR_NOT_JOINED",action:"failed"},[dU.ERR_REPEAT_JOIN_REQUEST]:{desc:"ERR_REPEAT_JOIN_REQUEST",action:"quit"},[dU.ERR_REPEAT_JOIN_CHANNEL]:{desc:"ERR_REPEAT_JOIN_CHANNEL",action:"quit"},[dU.ERR_INVALID_STRINGUID]:{desc:"ERR_INVALID_STRINGUID",action:"failed"},[dU.ERR_TOO_MANY_USERS]:{desc:"ERR_TOO_MANY_USERS",action:"tryNext"},[dU.ERR_SET_CLIENT_ROLE_TIMEOUT]:{desc:"ERR_SET_CLIENT_ROLE_TIMEOUT",action:"failed"},[dU.ERR_SET_CLIENT_ROLE_NO_PERMISSION]:{desc:"ERR_SET_CLIENT_ROLE_TIMEOUT",action:"failed"},[dU.ERR_SET_CLIENT_ROLE_ALREADY_IN_USE]:{desc:"ERR_SET_CLIENT_ROLE_ALREADY_IN_USE",action:"success"},[dU.ERR_PUBLISH_REQUEST_INVALID]:{desc:"ERR_PUBLISH_REQUEST_INVALID",action:"failed"},[dU.ERR_SUBSCRIBE_REQUEST_INVALID]:{desc:"ERR_SUBSCRIBE_REQUEST_INVALID",action:"failed"},[dU.ERR_NOT_SUPPORTED_MESSAGE]:{desc:"ERR_NOT_SUPPORTED_MESSAGE",action:"failed"},[dU.ERR_ILLEAGAL_PLUGIN]:{desc:"ERR_ILLEAGAL_PLUGIN",action:"failed"},[dU.ILLEGAL_CLIENT_ROLE_LEVEL]:{desc:"ILLEGAL_CLIENT_ROLE_LEVEL",action:"failed"},[dU.ERR_REJOIN_TOKEN_INVALID]:{desc:"ERR_REJOIN_TOKEN_INVALID",action:"failed"},[dU.ERR_REJOIN_USER_NOT_JOINED]:{desc:"ERR_REJOIN_NOT_JOINED",action:"failed"},[dU.ERR_INVALID_OPTIONAL_INFO]:{desc:"ERR_INVALID_OPTIONAL_INFO",action:"quit"},[dU.ERR_TEST_RECOVER]:{desc:"ERR_TEST_RECOVER",action:"recover"},[dU.ERR_TEST_TRYNEXT]:{desc:"ERR_TEST_TRYNEXT",action:"recover"},[dU.ERR_TEST_RETRY]:{desc:"ERR_TEST_RETRY",action:"recover"},[dU.ILLEGAL_AES_PASSWORD]:{desc:"ERR_TEST_RETRY",action:"failed"},[dU.ERR_TOO_MANY_BROADCASTERS]:{desc:"ERR_TOO_MANY_BROADCASTERS",action:"failed"},[dU.ERR_TOO_MANY_SUBSCRIBERS]:{desc:"ERR_TOO_MANY_SUBSCRIBERS",action:"failed"},[dU.ERR_LICENSE_ILLEGAL]:{desc:"ERR_LICENSE_ILLEGAL",action:"quit"},[dU.ERR_LICENSE_MISSING]:{desc:"ERR_LICENSE_MISSING",action:"quit"},[dU.ERR_LICENSE_EXPIRED]:{desc:"ERR_LICENSE_EXPIRED",action:"quit"},[dU.ERR_LICENSE_MINUTES_EXCEEDED]:{desc:"ERR_LICENSE_MINUTES_EXCEEDED",action:"quit"},[dU.ERR_LICENSE_PERIOD_INVALID]:{desc:"ERR_LICENSE_PERIOD_INVALID",action:"quit"},[dU.ERR_LICENSE_MULTIPLE_SDK_SERVICE]:{desc:"ERR_LICENSE_MULTIPLE_SDK_SERVICE",action:"quit"}};function hx(e){const t=ux[e];return t||{desc:"UNKNOWN_ERROR_".concat(e),action:"failed"}}function px(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function _x(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?px(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):px(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Ex(e,t){if("string"==typeof e)return e;const{proxy:i,host:n,port:r}=e;if(t){const e=_N("JOIN_GATEWAY_FALLBACK_PORT")||443;return 443===e?"wss://".concat(n,"/ws/?p=").concat(Number(r)+150):"wss://".concat(n,":").concat(e,"/ws/?p=").concat(Number(r)+150)}return i?"wss://".concat(i,"/ws/?h=").concat(n,"&p=").concat(r):"wss://".concat(n,":").concat(r)}const mx=/wss:\/\/(.+)\/ws\/\?h=(.+)&p=([0-9]+)\/?/,fx=/wss:\/\/(.+)\/ws\/\?p=([0-9]+)\/?/,Tx=/wss:\/\/(.+):([0-9]+)\/?/,Sx=/wss:\/\/(.[^\/]+)\/?/;let gx=0;class Rx{constructor(e,t){QI(this,"id",0),QI(this,"store",void 0),QI(this,"recordIndex",void 0),QI(this,"websockets",[]),QI(this,"try443PortDuration",2e3),QI(this,"forceCloseWSDuration",5e3),QI(this,"try443PortTimeout",null),QI(this,"forceCloseTimeout",null),QI(this,"isTry443PortFailed",!1),QI(this,"isNormalPortFailed",!1),QI(this,"useDoubleDomain",!1),QI(this,"useProxy",!1),QI(this,"startTime",Date.now()),this.id=++gx,this.try443PortDuration=_N("JOIN_GATEWAY_TRY_443PORT_DURATION")||2e3,this.forceCloseWSDuration=e||5e3,this.store=t}closeAllWebsockets(){this.websockets.forEach((e=>{e.onopen=null,e.onclose=null,e.onmessage=null,e.close()})),this.websockets.length=0}clearTimeout(){this.forceCloseTimeout&&clearTimeout(this.forceCloseTimeout),this.try443PortTimeout&&clearTimeout(this.try443PortTimeout),this.forceCloseTimeout=null,this.try443PortTimeout=null}logger(){var e;const t=Date.now()-this.startTime;for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];YN.debug("[choose-best-ws ".concat(null===(e=this.store)||void 0===e?void 0:e.clientId," ").concat(this.id,"] ").concat(t,"ms:"),...n)}createWebSocket(e,t,i){this.logger("createWebSocket:",e,{isTry443Port:t,hasTimeoutDetection:i});const n=_N("GATEWAY_DOMAINS"),r=Date.now(),o=[],s=n.find((t=>{var i;return Dn(i=e.host).call(i,t)}));s||(this.useDoubleDomain=!1);const a=[];if(this.useDoubleDomain)n.forEach((i=>{a.push(Ex(_x(_x({},e),{},{host:e.host.replace(s,i)}),t))}));else{const i=_x({},e);if(t&&s){const e=n.find((e=>e!==s));e&&(i.host=i.host.replace(s,e))}a.push(Ex(i,t))}try{a.forEach((e=>{const t=new WebSocket(e);t.binaryType="arraybuffer",o.push(t),this.logger("ws is connecting:",t.url)}))}catch(n){if(this.logger("ws create failed"),o.forEach((e=>e.close())),o.length=0,this.useDoubleDomain)return this.useDoubleDomain=!1,this.createWebSocket(e,t,i);if(!t&&443!==Number(e.port))return this.createWebSocket(e,!0,i);throw new tD(Ew.WS_ERR,"init websocket failed! Error: ".concat(n.toString()))}const c=wb();this.store&&this.store.recordJoinChannelService({urls:o.map((e=>e.url)),service:"gateway"},this.recordIndex),o.forEach((e=>{e.onopen=()=>{this.logger("onopen: ws ".concat(e.url," open cost ").concat(Date.now()-r,"ms")),this.websockets.forEach((t=>{t!==e&&(t.onopen=null,t.onclose=null,t.onmessage=null,t.close(),this.logger("close backup websocket: ".concat(t.url)))})),this.websockets.length=0,c.resolve(e)},e.onclose=i=>{this.logger("onclose: ws ".concat(e.url," closed cost ").concat(Date.now()-r,"ms state: ").concat(e.readyState));const n=o.every((e=>e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING));this.logger("".concat(t?"443":"47xx"," websocket closed, all failed: ").concat(n)),n&&(t||this.isTry443PortFailed||this.useProxy)?(this.logger("onclose: all websocket is closed, ".concat(i.reason)),c.reject({code:i.code,reason:kU.A_ROUND_WS_FAILED})):!t&&n&&!this.isNormalPortFailed&&this.try443PortTimeout&&(this.logger("all 47xx websocket is closed, try 443 port"),this.clearTimeout(),l()),t?this.isTry443PortFailed=n:this.isNormalPortFailed=n},e.onmessage=t=>this.logger("".concat(e.url," onmessage: ").concat(t.data))})),this.websockets.push(...o);const d=()=>{this.websockets.forEach((e=>e.readyState!==WebSocket.OPEN&&e.close()))},l=()=>{if(c.isResolved)return d();xb().os===Pb.MAC_OS&&Kb()&&d(),this.createWebSocket(e,!0,!0).then((e=>{c.resolve(e)})).catch((e=>{this.isNormalPortFailed&&c.reject(e),this.logger("try 443 port to create ws failed")})),this.forceCloseTimeout=window.setTimeout((()=>{this.logger("5s timeout close un-opens, isWebsocket created: ",c.isResolved),this.forceCloseTimeout=null,d()}),this.forceCloseWSDuration)};return i||(()=>{if(t||this.useProxy)return this.logger("add 5s timeout at ".concat(t?"try-443":"proxy"," condition")),this.forceCloseTimeout=window.setTimeout((()=>{this.forceCloseTimeout=null,d()}),this.forceCloseWSDuration);this.try443PortTimeout=window.setTimeout((()=>{this.logger("2s timeout, isWebsocket created: ",c.isResolved),this.try443PortTimeout=null,l()}),this.try443PortDuration)})(),c.promise}chooseBestWebsocket(e,t,i,n){return this.useDoubleDomain=!!t,"string"==typeof e&&(e=function(e){let t,i,n;return[,t,i,n]=e.match(mx)||[],t||([,i,n]=e.match(fx)||[]),i&&n||([,i,n]=e.match(Tx)||[]),i&&n||([,i]=e.match(Sx)||[]),i||YN.warning("un-destructible url: ",e),{proxy:t,host:i,port:n||"443"}}(e)),this.recordIndex=n,this.useProxy=!!e.proxy,i&&this.useProxy&&(YN.warn("cannot use 443 only when use proxy"),i=!1),this.createWebSocket(e,!!i,!1).finally((()=>this.clearTimeout()))}}function vx(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}class Cx extends Dw{get url(){return this.websocket&&this.websocket.url||null}get reconnectMode(){return this._reconnectMode}set reconnectMode(e){var t;Dn(t=["tryNext","recover"]).call(t,e)&&this.resetReconnectCount(e),this._reconnectMode=e}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,"reconnecting"===this._state?this.emit(mU.RECONNECTING,this.reconnectReason):"connected"===this._state?this.emit(mU.CONNECTED):"closed"===this._state?this.emit(mU.CLOSED):"failed"===this._state&&this.emit(mU.FAILED))}resetReconnectCount(e){YN.debug("websocket reset reconnect count, reason: "+e),this.reconnectCount=0}constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=arguments.length>5?arguments[5]:void 0;super(),QI(this,"connectionID",0),QI(this,"currentURLIndex",0),QI(this,"urls",[]),QI(this,"_reconnectMode","tryNext"),QI(this,"reconnectReason",void 0),QI(this,"_initMutex",void 0),QI(this,"name",void 0),QI(this,"_state","closed"),QI(this,"reconnectInterrupter",void 0),QI(this,"websocket",void 0),QI(this,"retryConfig",void 0),QI(this,"reconnectCount",0),QI(this,"forceCloseTimeout",5e3),QI(this,"onlineReconnectListener",void 0),QI(this,"useCompress",void 0),QI(this,"tryDoubleDomain",!1),QI(this,"use443PortOnly",!1),QI(this,"wsInflateLength",0),QI(this,"wsDeflateLength",0),QI(this,"closeEstablishingWs",(()=>{})),QI(this,"store",void 0),QI(this,"joinGatewayRecordIndex",void 0),this.store=o,this.name=e,this.retryConfig=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?vx(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):vx(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({},t),this.useCompress=i,this.tryDoubleDomain=n,this.use443PortOnly=r,this._initMutex=new IO("websocket",o?o.clientId:void 0);const{timeout:s,timeoutFactor:a}=t,c=Math.max(300,Math.floor(3*s/5)),d=Math.max(1.2,Math.floor(8*a)/10);Hw.ONLINE&&(this.retryConfig.timeout=c,this.retryConfig.timeoutFactor=d),Jw.on(Kw.NETWORK_STATE_CHANGE,((e,t)=>{e!==t&&(this.resetReconnectCount("network state change: ".concat(t," -> ").concat(e)),e===Hw.ONLINE?(this.retryConfig.timeout=c,this.retryConfig.timeoutFactor=d):(this.retryConfig.timeout=s,this.retryConfig.timeoutFactor=a))}))}getConnection(){return this.websocket||void 0}async init(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3;const i=await this._initMutex.lock();this._reconnectMode="tryNext",this.forceCloseTimeout=t,this.urls=e,this.state="connecting";try{const e=wb(),t=this.urls[this.currentURLIndex];_N("ENABLE_PREALLOC_PC")&&this.emit(ex.PRE_CONNECT_PC),this.createWebSocketConnection(t).then(e.resolve).catch(e.reject),this.once(mU.CLOSED,(()=>{e.reject(new mw(Ew.WS_DISCONNECT))})),this.once(mU.CONNECTED,e.resolve),await e.promise}catch(e){}finally{i()}}close(e,t){if(this.currentURLIndex=0,this.resetReconnectCount("close"),this.reconnectInterrupter&&this.reconnectInterrupter(),this.websocket){this.websocket.onclose=null,this.websocket.onopen=null,this.websocket.onmessage=null;const e=this.websocket;t?setTimeout((()=>e.close()),500):e.close(),this.websocket=void 0}this.state=e?"failed":"closed",this.closeEstablishingWs&&this.closeEstablishingWs()}reconnect(e,t){if(!this.websocket)return void YN.warning("[".concat(this.name,"] can not reconnect, no websocket"));void 0!==e&&(this.reconnectMode=e),YN.debug("[".concat(this.name,"] reconnect is triggered initiative")),"number"==typeof this.joinGatewayRecordIndex&&this.store&&this.store.recordJoinChannelService({status:"error",errors:[new Error(t)]},this.joinGatewayRecordIndex);const i=this.websocket.onclose;this.websocket.onclose=null,this.websocket.close(),i&&i.bind(this.websocket)({code:9999,reason:t})}sendMessage(e){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!this.websocket||this.websocket.readyState!==WebSocket.OPEN)throw new mw(Ew.WS_ABORT,"websocket is not ready");try{t||(e=JSON.stringify(e)),this.websocket.send(e)}catch(e){throw new mw(Ew.WS_ERR,"send websocket message error"+e.toString())}}setWsInflateData(e){this.wsDeflateLength=this.wsDeflateLength+e.originLength,this.wsInflateLength=this.wsInflateLength+e.compressedLength}getWsInflateData(){const e=this.wsInflateLength,t=this.wsDeflateLength;return this.clearWsInflateData(),{wsInflateLength:e,wsDeflateLength:t}}clearWsInflateData(){this.wsInflateLength=0,this.wsDeflateLength=0}async createWebSocketConnection(e){var t;const i=wb();this.connectionID+=1,this.joinGatewayRecordIndex=void 0;const n=e=>{var t;null===(t=this.store)||void 0===t||t.signalChannelOpen(),YN.debug("[".concat(this.name,"] websocket opened:"),e),this.reconnectMode="retry",this.state="connected",this.resetReconnectCount("opened"),i.resolve()},r=async e=>{var t;if(YN.debug("[".concat(this.name,"] websocket close ").concat(null===(t=this.websocket)||void 0===t?void 0:t.url,", code: ").concat(e.code,", reason: ").concat(e.reason,", current mode: ").concat(this.reconnectMode)),this.reconnectCount>=this.retryConfig.maxRetryCount)i.reject(new mw(Ew.WS_DISCONNECT,"websocket close: ".concat(e.code))),this.close();else{"connected"===this.state&&(this.reconnectReason=e.reason,this.state="reconnecting");const t=zw(this,mU.WILL_RECONNECT,this.reconnectMode,e.reason)||this.reconnectMode,n=await this.reconnectWithAction(t);if("closed"===this.state)return void YN.debug("[".concat(this.connectionID,"] ws is closed, no need to reconnect"));if(!n)return i.reject(new mw(Ew.WS_DISCONNECT,"websocket reconnect failed: ".concat(e.code))),this.close(!0);i.resolve()}},o=e=>{this.emit(mU.ON_MESSAGE,e)},s=e=>{YN.warn("[".concat(this.connectionID,"] ws open error ").concat(e))};this.websocket&&(this.websocket.onclose=null,this.websocket.close()),_N("GATEWAY_WSS_ADDRESS")&&this.name.startsWith("gateway")&&(e=_N("GATEWAY_WSS_ADDRESS")),YN.debug("[".concat(this.name,"] start connect, url:"),e);const a=null===(t=this.store)||void 0===t?void 0:t.recordJoinChannelService({startTs:Date.now(),status:"pending",service:"gateway"});try{var c;const t=await this.chooseBestWebsocketConnection(e);this.websocket=t,n&&n(this.websocket.url),this.websocket.onclose=r,this.websocket.onmessage=o,this.websocket.onerror=s,null===(c=this.store)||void 0===c||c.recordJoinChannelService({endTs:Date.now(),status:"success"},a),this.joinGatewayRecordIndex=a}catch(e){const t="closed"===this.state,n=e instanceof mw,o=n&&e.code===Ew.WS_ABORT,s=n&&e.code===Ew.WS_ERR,c=n?e.message:e&&(e.reason||e.toString());YN.warning("[choose-best-ws] chooseBestWebsocket error: ".concat(c)),this.store&&this.store.recordJoinChannelService({endTs:Date.now(),status:o?"aborted":"error",errors:[e]},a),t||s?(i.reject(t?new mw(Ew.WS_DISCONNECT,"websocket is closed: ".concat(c)):new mw(Ew.WS_ERR,"init websocket failed: ".concat(c))),s&&YN.error("[".concat(this.name,"] init websocket failed: ").concat(c))):r&&r(e)}return i.promise}async reconnectWithAction(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.reconnectCount>=this.retryConfig.maxRetryCount)return!1;if(0===this.urls.length)return!1;if("closed"===this.state)return!1;YN.warning("[choose-best-ws] action: =>",e),this.onlineReconnectListener||Jw.isOnline||!Jw.onlineWaiter||(this.onlineReconnectListener=Jw.onlineWaiter.then((()=>{this.onlineReconnectListener=void 0})));let i=!0;if(this.reconnectInterrupter=()=>i=!1,t){const t=bO(this.reconnectCount,this.retryConfig);YN.debug("[".concat(this.name,"] wait ").concat(t,"ms to reconnect websocket, mode: ").concat(e)),await Wh.race([uO(t),this.onlineReconnectListener||new Wh((()=>{}))])}if("closed"===this._state||!i)return!1;this.reconnectCount+=1;const n=async(e,t)=>{this.emit(mU.RECONNECT_CREATE_CONNECTION,t),await this.createWebSocketConnection(e)};try{if("retry"===e)await n(this.urls[this.currentURLIndex],e);else if("tryNext"===e){if(this.currentURLIndex+=1,this.currentURLIndex>=this.urls.length)return this.reconnectWithAction("recover",!1);YN.debug("[".concat(this.name,"] websocket url length: ").concat(this.urls.length," current index: ").concat(this.currentURLIndex)),await n(this.urls[this.currentURLIndex],e)}else"recover"===e&&(YN.debug("[".concat(this.name,"] request new urls")),this.resetReconnectCount("recover mode"),this.urls=await Yw(this,mU.REQUEST_NEW_URLS),this.currentURLIndex=0,await n(this.urls[this.currentURLIndex],e))}catch(i){var r;YN.error("[".concat(this.name,"] reconnect failed ").concat(i&&i.toString()));const n=null==i||null===(r=i.data)||void 0===r?void 0:r.desc;return Array.isArray(n)&&Dn(n).call(n,"dynamic key expired")?(this.emit(mU.ON_TOKEN_PRIVILEGE_DID_EXPIRE),!1):this.reconnectWithAction(e,t)}return!0}}class Ix extends Cx{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3],arguments.length>4&&void 0!==arguments[4]&&arguments[4],arguments.length>5?arguments[5]:void 0)}async chooseBestWebsocketConnection(e,t){const i=wb(),n=function(e,t){return new Rx(e,t)}(this.forceCloseTimeout,this.store);this.closeEstablishingWs=()=>{YN.debug("[choose-best-ws] close establishing websockets"),n.closeAllWebsockets(),i.reject(new mw(Ew.WS_ABORT,"choose best websocket aborted"))};const r=_N("GATEWAY_DOMAINS");return YN.debug("[choose-best-ws] currentDomain: ",e,", domains: ",r,"total: ".concat(this.urls.length),"current: ".concat(this.currentURLIndex+1)),n.chooseBestWebsocket(e,this.tryDoubleDomain,this.use443PortOnly,t).then(i.resolve).catch(i.reject),i.promise.finally((()=>{this.closeEstablishingWs=void 0}))}}class yx extends Cx{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]&&arguments[3],arguments.length>4&&void 0!==arguments[4]&&arguments[4],arguments.length>5?arguments[5]:void 0)}async chooseBestWebsocketConnection(e,t){return new Wh(((i,n)=>{let r=!1;const o=[];this.closeEstablishingWs=()=>{YN.debug("[choose-best-ws] close establishing websockets"),o.forEach((e=>{e.onclose=null,e.onopen=null,e.onmessage=null,e.close()})),n(new mw(Ew.WS_ABORT,"choose best websocket aborted"))};const s=_N("GATEWAY_DOMAINS");let a;const c=e.indexOf("?h="),d=s.find((t=>-1!==c?Dn(e).call(e,t,c):Dn(e).call(e,t)));YN.debug("[choose-best-ws] currentDomain: ",d,", domains: ",s);let l=!this.tryDoubleDomain||!d;if(!l&&d){var u;const h=Date.now();try{s.forEach((t=>{const i=-1===c?e.replace(d,t):e.substr(0,c)+e.substr(c).replace(d,t),n=new WebSocket(i);n.binaryType="arraybuffer",o.push(n),YN.debug("[choose-best-ws] ws is connecting:",n.url)}))}catch(e){for(YN.debug("[choose-best-ws] ws create failed, fallback to single url"),o.forEach((e=>e.close()));o.length;)o.pop();l=!0}null===(u=this.store)||void 0===u||u.recordJoinChannelService({urls:o.map((e=>e.url)),service:"gateway"},t),o.forEach((e=>{e.onopen=()=>{if(r)return;const t=Date.now()-h;YN.debug("[choose-best-ws] ws open cost ".concat(t,"ms")),o.filter((t=>t!==e)).forEach((e=>{YN.debug("[choose-best-ws]close backup websocket: ".concat(e.url)),e.close()})),r=!0,i(e)},e.onclose=e=>{if(a=e,r)return;o.find((e=>!(e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING)))||(YN.debug("[choose-best-ws] all websocket is closed"),r=!0,n(a))},e.onmessage=t=>{YN.debug("[choose-best-ws]".concat(e.url," onmessage: ").concat(t.data))}})),uO(this.forceCloseTimeout).then((()=>{o.forEach((e=>{e.readyState!==WebSocket.OPEN&&e.close()}))}))}if(l){var h;let r;YN.debug("[choose-best-ws] use single url: ",e),null===(h=this.store)||void 0===h||h.recordJoinChannelService({urls:[e],service:"gateway"},t);try{r=new WebSocket(e),o.push(r),r.binaryType="arraybuffer"}catch(e){const t=new mw(Ew.WS_ERR,"init websocket failed! Error: ".concat(e.toString()));return YN.error("[".concat(this.name,"]").concat(t)),void n(t)}r.onopen=()=>{i(r)},r.onclose=e=>{n(e)},r.onmessage=e=>{YN.debug("[choose-best-ws]".concat(r.url," onmessage: ").concat(e.data))},uO(this.forceCloseTimeout).then((()=>{r&&r.readyState!==WebSocket.OPEN&&r.close()}))}})).then((e=>(this.closeEstablishingWs=void 0,e))).catch((e=>{throw this.closeEstablishingWs=void 0,e}))}}class Ax extends Dw{get connectionState(){return this._connectionState}set connectionState(e){e!==this._connectionState&&(this._connectionState=e,e===lU.CONNECTED?this.emit(uU.WS_CONNECTED):e===lU.RECONNECTING?this.emit(uU.WS_RECONNECTING,this._websocketReconnectReason):e===lU.CLOSED&&this.emit(uU.WS_CLOSED,this._disconnectedReason))}get currentURLIndex(){return this.websocket.currentURLIndex}get url(){return this.websocket&&this.websocket.url||null}get rtt(){return this.rttRolling.mean()}constructor(e,t){super(),QI(this,"_disconnectedReason",void 0),QI(this,"_websocketReconnectReason",void 0),QI(this,"_connectionState",lU.CLOSED),QI(this,"reconnectToken",void 0),QI(this,"websocket",void 0),QI(this,"openConnectionTime",void 0),QI(this,"clientId",void 0),QI(this,"lastMsgTime",Date.now()),QI(this,"uploadCache",[]),QI(this,"uploadCacheInterval",void 0),QI(this,"rttRolling",new NO(5)),QI(this,"pingpongTimer",void 0),QI(this,"wsInflateDataTimer",void 0),QI(this,"pingpongTimeoutCount",0),QI(this,"joinResponse",void 0),QI(this,"multiIpOption",void 0),QI(this,"initError",void 0),QI(this,"spec",void 0),QI(this,"store",void 0),QI(this,"onWebsocketMessage",(e=>{if(e.data instanceof ArrayBuffer)return void this.emit(uU.ON_BINARY_DATA,e.data);const t=JSON.parse(e.data);if(this.lastMsgTime=Date.now(),Object.prototype.hasOwnProperty.call(t,"_id")){const e="res-@".concat(t._id);this.emit(e,t._result,t._message)}else if(Object.prototype.hasOwnProperty.call(t,"_type")){if(this.emit(t._type,t._message),t._type===_U.ON_NOTIFICATION&&this.handleNotification(t._message),t._type===_U.ON_USER_BANNED)switch(t._message.error_code){case 14:this.close(Vw.UID_BANNED);break;case 15:this.close(Vw.IP_BANNED);break;case 16:this.close(Vw.CHANNEL_BANNED)}if(t._type===_U.ON_USER_LICENSE_BANNED)switch(t._message.error_code){case dU.ERR_LICENSE_MISSING:this.close(Vw.LICENSE_MISSING);break;case dU.ERR_LICENSE_EXPIRED:this.close(Vw.LICENSE_EXPIRED);break;case dU.ERR_LICENSE_MINUTES_EXCEEDED:this.close(Vw.LICENSE_MINUTES_EXCEEDED);break;case dU.ERR_LICENSE_PERIOD_INVALID:this.close(Vw.LICENSE_PERIOD_INVALID);break;case dU.ERR_LICENSE_MULTIPLE_SDK_SERVICE:this.close(Vw.LICENSE_MULTIPLE_SDK_SERVICE);break;case dU.ERR_LICENSE_ILLEGAL:this.close(Vw.LICENSE_ILLEGAL);break;default:this.close()}}})),this.clientId=e.clientId,this.spec=e,this.store=t,this.websocket=new Ix("gateway-".concat(this.clientId),this.spec.retryConfig,!0,_N("JOIN_GATEWAY_USE_DUAL_DOMAIN"),_N("JOIN_GATEWAY_USE_443PORT_ONLY"),t),this.handleWebsocketEvents(),window.addEventListener("offline",(()=>{this.connectionState===lU.CONNECTED&&this.reconnect("retry",Ww.OFFLINE)}))}async request(e,t,i,n){const r=hO(6,""),o={_id:r,_type:e,_message:t},s=this.websocket.connectionID,a=()=>new Wh(((t,i)=>{if(this.connectionState===lU.CONNECTED)return t();const n=()=>{this.off(uU.WS_CLOSED,r),t()},r=()=>{this.off(uU.WS_CONNECTED,n),i(new tD(Ew.WS_ABORT))};this.once(uU.WS_CONNECTED,n),this.once(uU.WS_CLOSED,r),e!==hU.PUBLISH&&e!==hU.PUBLISH_DATASTREAM&&e!==hU.SUBSCRIBE&&e!==hU.SUBSCRIBE_DATASTREAM&&e!==hU.UNSUBSCRIBE&&e!==hU.UNSUBSCRIBE_DATASTREAM&&e!==hU.UNPUBLISH&&e!==hU.UNPUBLISH_DATASTREAM&&e!==hU.CONTROL&&e!==hU.RESTART_ICE||this.once(uU.DISCONNECT_P2P,(()=>{i(new tD(Ew.DISCONNECT_P2P))})),e!==hU.PUBLISH&&e!==hU.RESTART_ICE||this.once(uU.ABORT_P2P_EXECUTION,(()=>{i(new tD(Ew.DISCONNECT_P2P))}))}));if(this.connectionState!==lU.CONNECTING&&this.connectionState!==lU.RECONNECTING||e===hU.JOIN||e===hU.REJOIN||await a(),this.websocket.sendMessage(o,!0),n)return;const c=new Wh(((i,n)=>{let o=!1;const a=(n,r)=>{o=!0,i({isSuccess:"success"===n,message:r||{}}),this.off(uU.WS_CLOSED,c),this.off(uU.WS_RECONNECTING,c),this.emit(uU.REQUEST_SUCCESS,e,t)};this.once("res-@".concat(r),a);const c=()=>{n(new tD(Ew.WS_ABORT,"type: ".concat(e))),this.off(uU.WS_CLOSED,c),this.off(uU.WS_RECONNECTING,c),this.off("res-@".concat(r),a)};this.once(uU.WS_CLOSED,c),this.once(uU.WS_RECONNECTING,c),uO(_N("SIGNAL_REQUEST_TIMEOUT")).then((()=>{this.websocket.connectionID!==s||o||(YN.warning("[".concat(this.clientId,"] ws request timeout, type: ").concat(e)),this.emit(uU.REQUEST_TIMEOUT,e,t))}))}));let d=null;try{d=await c}catch(n){if(this.connectionState===lU.CLOSED||e===hU.LEAVE)throw new tD(Ew.WS_ABORT);return!this.spec.forceWaitGatewayResponse||i?n.throw():e===hU.JOIN||e===hU.REJOIN?null:(await a(),await this.request(e,t))}if(d.isSuccess)return d.message;const l=Number(d.message.error_code||d.message.code),u=hx(l),h=new tD(Ew.UNEXPECTED_RESPONSE,"".concat(u.desc,": ").concat(d.message.error_str),{code:l,data:d.message,desc:u.desc});return"success"===u.action?d.message:(YN.warning("[".concat(this.clientId,"] [").concat(this.websocket.connectionID,"] unexpected response from type ").concat(e,", error_code: ").concat(l,", message: ").concat(u.desc,", action: ").concat(u.action)),l===dU.ERR_TOO_MANY_BROADCASTERS?e===hU.JOIN||e===hU.REJOIN?(this.initError=h,this.close(),h.throw()):h.throw():"failed"===u.action?h.throw():"quit"===u.action?(this.initError=h,this.close(),h.throw()):(l===dU.ERR_JOIN_BY_MULTI_IP?(this.multiIpOption=d.message.option,YN.warning("[".concat(this.clientId,"] detect multi ip, recover")),this.reconnect("recover",Ww.MULTI_IP)):this.reconnect(u.action,Ww.SERVER_ERROR),e===hU.JOIN||e===hU.REJOIN?null:await this.request(e,t)))}waitMessage(e,t){return new Wh((i=>{const n=r=>{(!t||t(r))&&(this.off(e,n),i(r))};this.on(e,n)}))}uploadWRTCStats(e){if(!this.store.sessionId)return void YN.warn("[".concat(this.clientId,"] no session id when upload wrtc stats"));const t={lts:Date.now(),sid:this.store.sessionId,uid:this.store.intUid,stats:e};this.upload(pU.WRTC_STATS,t)}upload(e,t){const i={_type:e,_message:t};try{this.websocket.sendMessage(i)}catch(e){const t=_N("MAX_UPLOAD_CACHE")||50;this.uploadCache.push(i),this.uploadCache.length>t&&this.uploadCache.splice(0,1),this.uploadCache.length>0&&!this.uploadCacheInterval&&(this.uploadCacheInterval=window.setInterval((()=>{if(this.connectionState!==lU.CONNECTED)return;const e=this.uploadCache.splice(0,1)[0];0===this.uploadCache.length&&(window.clearInterval(this.uploadCacheInterval),this.uploadCacheInterval=void 0),this.upload(e._type,e._message)}),_N("UPLOAD_CACHE_INTERVAL")||2e3))}}send(e,t){const i={_type:e,_message:t};this.websocket.sendMessage(i)}init(e){return this.initError=void 0,this.multiIpOption=void 0,this.joinResponse=void 0,this.reconnectToken=void 0,this.openConnectionTime=void 0,new Wh(((t,i)=>{this.once(uU.WS_CONNECTED,(()=>t(this.joinResponse))),this.once(uU.WS_CLOSED,(e=>i(this.initError||new tD(Ew.WS_ABORT,e)))),this.connectionState=lU.CONNECTING,this.websocket.init(e).catch(i),this.wsInflateDataTimer&&window.clearInterval(this.wsInflateDataTimer),this.wsInflateDataTimer=window.setInterval((()=>{this.handleWsInflateData()}),2e4)}))}close(e){this.pingpongTimer&&(this.pingpongTimeoutCount=0,window.clearInterval(this.pingpongTimer),this.pingpongTimer=void 0),this.wsInflateDataTimer&&(this.handleWsInflateData(),window.clearInterval(this.wsInflateDataTimer),this.wsInflateDataTimer=void 0),this.reconnectToken=void 0,this.joinResponse=void 0,this._disconnectedReason=e||Vw.LEAVE,this.connectionState=lU.CLOSED,YN.debug("[".concat(this.clientId,"] ")+"will close websocket in signal"),this.websocket.close()}async join(){if(!this.joinResponse){this.emit(uU.ABORT_P2P_EXECUTION);const e=await Yw(this,uU.REQUEST_JOIN_INFO),t=await this.request(hU.JOIN,e);if(!t)return this.emit(uU.REPORT_JOIN_GATEWAY,kU.TIMEOUT,this.url||""),!1;this.joinResponse=t,this.emit(uU.JOIN_RESPONSE,this.joinResponse),this.reconnectToken=this.joinResponse.rejoin_token}return this.connectionState=lU.CONNECTED,this.pingpongTimer&&window.clearInterval(this.pingpongTimer),this.pingpongTimer=window.setInterval(this.handlePingPong.bind(this),3e3),!0}async rejoin(){if(!this.reconnectToken)throw new tD(Ew.UNEXPECTED_ERROR,"can not rejoin, no rejoin token");const e=Xw(this,uU.REQUEST_REJOIN_INFO);e.token=this.reconnectToken;const t=await this.request(hU.REJOIN,e);return!!t&&(this.connectionState=lU.CONNECTED,this.pingpongTimer&&window.clearInterval(this.pingpongTimer),this.pingpongTimer=window.setInterval(this.handlePingPong.bind(this),3e3),t.peers&&t.peers.forEach((e=>{this.emit(_U.ON_USER_ONLINE,{uid:e.uid}),e.audio&&this.emit(_U.ON_ADD_AUDIO_STREAM,{uid:e.uid,uint_id:e.uint_id,audio:!0,ssrcId:e.audio_ssrc}),e.video&&this.emit(_U.ON_ADD_VIDEO_STREAM,{uid:e.uid,uint_id:e.uint_id,video:!0,ssrcId:e.video_ssrc}),e.audio_mute?this.emit(_U.MUTE_AUDIO,{uid:e.uid}):this.emit(_U.UNMUTE_AUDIO,{uid:e.uid}),e.video_mute?this.emit(_U.MUTE_VIDEO,{uid:e.uid}):this.emit(_U.UNMUTE_VIDEO,{uid:e.uid}),e.audio_enable_local?this.emit(_U.ENABLE_LOCAL_AUDIO,{uid:e.uid}):this.emit(_U.DISABLE_LOCAL_AUDIO,{uid:e.uid}),e.video_enable_local?this.emit(_U.ENABLE_LOCAL_VIDEO,{uid:e.uid}):this.emit(_U.DISABLE_LOCAL_VIDEO,{uid:e.uid}),e.audio||e.video||this.emit(_U.ON_REMOVE_STREAM,{uid:e.uid,uint_id:e.uint_id})})),!0)}reconnect(e,t){this.pingpongTimer&&(this.pingpongTimeoutCount=0,window.clearInterval(this.pingpongTimer),this.pingpongTimer=void 0),this.websocket.reconnect(e,t)}handleNotification(e){YN.debug("[".concat(this.clientId,"] receive notification: "),e);const t=hx(e.code);if(28===e.code&&"detail"in e&&(YN.info("[".concat(this.clientId,"] receive recover notification: "),e.detail),this.emit(uU.RECOVER_NOTIFICATION,e.detail)),"success"!==t.action){if("failed"!==t.action)return"quit"===t.action?("ERR_REPEAT_JOIN_CHANNEL"===t.desc&&this.close(Vw.UID_BANNED),void this.close()):void this.reconnect(t.action,Ww.SERVER_ERROR);YN.error("[".concat(this.clientId,"] ignore error: "),t.desc)}}handlePingPong(){if(!this.websocket||"connected"!==this.websocket.state)return;this.pingpongTimeoutCount>0&&this.rttRolling.add(3e3),this.pingpongTimeoutCount+=1;const e=_N("PING_PONG_TIME_OUT"),t=Date.now();this.pingpongTimeoutCount>=e&&(YN.warning("[".concat(this.clientId,"] PING-PONG Timeout. Last Socket Message: ").concat(t-this.lastMsgTime,"ms")),t-this.lastMsgTime>_N("WEBSOCKET_TIMEOUT_MIN"))?this.reconnect("retry",Ww.TIMEOUT):this.request(hU.PING,void 0,!0).then((()=>{this.pingpongTimeoutCount=0;const e=Date.now()-t;this.rttRolling.add(e),_N("REPORT_STATS")&&this.send(hU.PING_BACK,{pingpongElapse:e})})).catch((e=>{}))}handleWsInflateData(){const{wsInflateLength:e,wsDeflateLength:t}=this.websocket.getWsInflateData();0!==e&&0!==t&&this.upload(pU.WS_INFLATE_DATA_LENGTH,{ws_deflate_length:t,ws_inflate_length:e})}handleWebsocketEvents(){this.websocket.on(mU.RECONNECT_CREATE_CONNECTION,(e=>{this.emit(uU.WS_RECONNECT_CREATE_CONNECTION,e)})),this.websocket.on(mU.ON_MESSAGE,this.onWebsocketMessage),this.websocket.on(mU.CLOSED,(()=>{this.connectionState=lU.CLOSED})),this.websocket.on(mU.FAILED,(()=>{this._disconnectedReason=Vw.NETWORK_ERROR,this.connectionState=lU.CLOSED})),this.websocket.on(mU.RECONNECTING,(e=>{this._websocketReconnectReason=e,this.joinResponse=void 0,this.connectionState===lU.CONNECTED?this.connectionState=lU.RECONNECTING:this.connectionState=lU.CONNECTING})),this.websocket.on(mU.WILL_RECONNECT,((e,t,i)=>{const n=Xw(this,uU.IS_P2P_DISCONNECTED),r=n||"retry"!==e;n&&"retry"===e&&(YN.debug("".concat(this.clientId," reconnect mode is retry, but p2p lost, change to tryNext")),e="tryNext",t=kU.P2P_DISCONNECTED),r&&(YN.debug("".concat(this.clientId," will renewSession, reconnect mode: ").concat(e)),this.emit(uU.REPORT_JOIN_GATEWAY,t||kU.UNKNOWN_REASON,this.url||""),this.reconnectToken=void 0,this.emit(uU.DISCONNECT_P2P)),i(e)})),this.websocket.on(mU.CONNECTED,(()=>{this.openConnectionTime=Date.now(),this.reconnectToken?this.rejoin().catch((e=>{YN.warning("[".concat(this.clientId,"] rejoin failed ").concat(e)),this.reconnect("tryNext",Ww.SERVER_ERROR)})):this.join().catch((e=>{if(this.emit(uU.REPORT_JOIN_GATEWAY,e,this.url||""),e instanceof tD){if(e.code===Ew.UNEXPECTED_RESPONSE&&e.data.code===dU.ERR_NO_AUTHORIZED)return this.initError=new tD(Ew.TOKEN_EXPIRE,"dynamic key expired"),void this.close(Vw.TOKEN_EXPIRE);YN.error("[".concat(this.clientId,"] join gateway request failed"),e.toString()),this.spec.forceWaitGatewayResponse?this.reconnect("tryNext",Ww.SERVER_ERROR):(this.initError=e,this.close())}}))})),this.websocket.on(mU.REQUEST_NEW_URLS,((e,t)=>{Yw(this,uU.REQUEST_RECOVER,this.multiIpOption).then(e).catch(t)})),this.websocket.on(mU.ON_TOKEN_PRIVILEGE_DID_EXPIRE,(()=>{this.emit(_U.ON_TOKEN_PRIVILEGE_DID_EXPIRE)})),this.websocket.on(ex.PRE_CONNECT_PC,(()=>{this.emit(uU.PRE_CONNECT_PC)}))}}let bx=function(e){return e.NATIVE_RTC="native_rtc",e.NATIVE_RTM="native_rtm",e.WEB_RTC="web_rtc",e.WEB_RTM="web_rtm",e}({}),wx=function(e){return e[e.CHOOSE_SERVER=11]="CHOOSE_SERVER",e[e.CLOUD_PROXY=18]="CLOUD_PROXY",e[e.CLOUD_PROXY_5=20]="CLOUD_PROXY_5",e[e.CLOUD_PROXY_FALLBACK=26]="CLOUD_PROXY_FALLBACK",e}({});function Ox(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Nx(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Ox(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Ox(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Dx(e){return e.match(/^[\.\:\d]+$/)?"".concat(e.replace(/[^\d]/g,"-"),".").concat(_N("TURN_DOMAIN")):(YN.debug("Cannot recognized as ip address: ".concat(e,", use as host")),e)}function Px(e,t){e.addresses||(e.addresses=[]);const i=function(e,t){if(_N("CONNECT_GATEWAY_WITHOUT_DOMAIN"))return e.map((e=>{let{ip:t,port:i}=e;return{address:"".concat(t,":").concat(i)}}));const i=_N("GATEWAY_DOMAINS");let n=i[1]&&Dn(t).call(t,i[1])?1:0;return e.map((e=>{let{domain_prefix:t,port:r,ip:o}=e;if(t)return{address:"".concat(t,".").concat(i[n++%i.length],":").concat(r)};const s=/^[\.\:\d]+$/.test(o),a=s?"".concat(o.replace(/[^\d]/g,"-"),".").concat(i[n++%i.length],":").concat(r):"".concat(o,":").concat(r);return s||YN.debug("Cannot recognized as ip address: ".concat(o,", use as host")),{ip:o,port:r,address:a}}))}(e.addresses,t),n=Array.isArray(e.detail)&&e.detail[18];if(n&&"string"==typeof n){const e=n.split(";");for(let t=0;t<e.length;t++){var r;const n=OT(r=e[t]).call(r);i[t]&&n&&(i[t].ip6=n)}}const o=e.detail&&e.detail.candidate;let s;if(o){const[e,t]=o.split(":");e&&t&&(s={port:Number(t),ip:e,address:"".concat(e,":").concat(t)})}return{gatewayAddrs:i,apGatewayAddress:s,uid:e.uid,cid:e.cid,cert:e.cert,vid:e.detail&&e.detail[8],uni_lbs_ip:e.detail&&e.detail[1],res:e,csIp:e.detail&&e.detail[502]}}function Lx(e){return"number"==typeof e?e:e.exact||e.ideal||e.max||e.min||0}function kx(e){const t=e._encoderConfig;if(!t)return{};const i={resolution:t.width&&t.height?"".concat(Lx(t.width),"x").concat(Lx(t.height)):void 0,maxVideoBW:t.bitrateMax,minVideoBW:t.bitrateMin};return"number"==typeof t.frameRate?(i.maxFrameRate=t.frameRate,i.minFrameRate=t.frameRate):t.frameRate&&(i.maxFrameRate=t.frameRate.max||t.frameRate.ideal||t.frameRate.exact||t.frameRate.min,i.minFrameRate=t.frameRate.min||t.frameRate.ideal||t.frameRate.exact||t.frameRate.max),i}function Mx(e){return e>=0&&e<.17?1:e>=.17&&e<.36?2:e>=.36&&e<.59?3:e>=.59&&e<=1?4:e>1?5:0}function Ux(e,t){let i,n,r;switch(t){case wx.CHOOSE_SERVER:n=4096,r="choose server";break;case wx.CLOUD_PROXY:n=1048576,r="proxy";break;case wx.CLOUD_PROXY_5:n=4194304,r="proxy5";break;case wx.CLOUD_PROXY_FALLBACK:n=4194310,r="proxy fallback";break;default:throw new tD(Ew.UNEXPECTED_ERROR,"multi unlibs response transformer get unknown service id",{csIp:e.detail&&e.detail[502],retry:!1})}if(e.response_body.forEach((t=>{t.buffer&&t.buffer.flag===n&&(i={code:t.buffer.code,addresses:(t.buffer.edges_services||[]).map((e=>Nx(Nx({},e),{},{ticket:t.buffer.cert}))),server_ts:e.enter_ts,uid:t.buffer.uid,cid:t.buffer.cid,cname:t.buffer.cname,detail
12271:Nx(Nx({},t.buffer.detail),e.detail),flag:t.buffer.flag,opid:e.opid,cert:t.buffer.cert})})),!i)throw new tD(Ew.MULTI_UNILBS_RESPONSE_ERROR,"cannot parse response ".concat(r," from multi unilbs response"),{csIp:e.detail&&e.detail[502]});return i}async function xx(e,t){return await Wh.all(e.addresses.map((async e=>({address:_N("USE_TURN_IP")?e.ip:Dx(e.ip),tcpport:e.port,udpport:e.port,username:t&&_N("ENCRYPT_PROXY_USERNAME_AND_PSW")&&window.isSecureContext?t.toString():aN.username,password:t&&_N("ENCRYPT_PROXY_USERNAME_AND_PSW")&&window.isSecureContext?await Nw(t.toString()):aN.password}))))}function Vx(e,t){const i=t.getMediaStreamTrack(!0).getSettings(),n=t.videoHeight||i.height,r=t.videoWidth||i.width;return n&&r?Math.max(Math.min(n,r)/Math.min(Lx(e.height),Lx(e.width)),1):(YN.warning("can't get ori-track's height, default scale down 4 times for low stream"),4)}function Fx(e){let{candidateType:t,relayProtocol:i,type:n,address:r,port:o,protocol:s}=e;const a={candidateType:t,relayProtocol:i,protocol:s};if("local-candidate"!==n){const e=r.split(".");e.length>=4&&(e[1]="*",e[2]="*"),a.address=e.join("."),a.port=o}return a}function Bx(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:_N("SVC_MODE");if(_N("ENABLE_SVC"))return function(e){return e in zO}(e)?e:zO.L1T3}const jx={[HU.VIDEO]:[{key:"abs-send-time",extensionName:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"},{key:"video-orientation",extensionName:"urn:3gpp:video-orientation"},{key:"draft-holmer-rmcat-transport-wide-cc-extensions-01",extensionName:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"},{key:"playout-delay",extensionName:"http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"},{key:"video-content-type",extensionName:"http://www.webrtc.org/experiments/rtp-hdrext/video-content-type"},{key:"color-space",extensionName:"http://www.webrtc.org/experiments/rtp-hdrext/color-space"},{key:"video-timing",extensionName:"http://www.webrtc.org/experiments/rtp-hdrext/video-timing"}],[HU.AUDIO]:[{key:"ssrc-audio-level",extensionName:"urn:ietf:params:rtp-hdrext:ssrc-audio-level"},{key:"draft-holmer-rmcat-transport-wide-cc-extensions-01",extensionName:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"},{key:"abs-send-time",extensionName:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"}]};function Gx(e,t,i){t.forEach((t=>{var n;const r=jx[e].find((e=>{var i;let{key:n}=e;return Dn(i=t.extensionName).call(i,n)}));if(!r)return;const o=i.find((e=>{let{extensionName:t}=e;return Dn(t).call(t,r.key)}));o&&Dn(n=o.extensionName).call(n,"gdpr_forbidden")&&(t.extensionName=o.extensionName)}))}function Wx(e,t){t.forEach((t=>{var i;const n=jx[e].find((e=>{var i;let{key:n}=e;return Dn(i=t.extensionName).call(i,n)}));Dn(i=t.extensionName).call(i,"gdpr_forbidden")&&n&&(t.extensionName=n.extensionName)}))}function Hx(e){return"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"===e||Dn(e).call(e,"abs-send-time")}function Kx(e){return"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"===e||Dn(e).call(e,"draft-holmer-rmcat-transport-wide-cc-extensions-01")}function Yx(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function qx(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Yx(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Yx(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function zx(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3?arguments[3]:void 0;const{filterRTX:r,filterVideoFec:o,filterAudioFec:s,filterAudioCodec:a,filterVideoCodec:c}=t,{useXR:d}=i;let l=[],u=[],h=[],p=[],_=!1,E=!1;if(yN(e).mediaDescriptions.forEach((e=>{n&&n!==e.attributes.direction||("video"!==e.media.mediaType||_||(u=e.attributes.payloads,p=e.attributes.extmaps,_=!0),"audio"!==e.media.mediaType||E||(l=e.attributes.payloads,h=e.attributes.extmaps,E=!0))})),!p||0===u.length)throw new Error("Cannot get video capabilities from SDP.");if(!h||0===l.length)throw new Error("Cannot get audio capabilities from SDP.");if(u.forEach((e=>{var t;null!==(t=e.rtpMap)&&void 0!==t&&t.clockRate&&(e.rtpMap.clockRate=parseInt(e.rtpMap.clockRate)),d&&e.rtcpFeedbacks.push({type:"rrtr"})})),l.forEach((e=>{var t;null!==(t=e.rtpMap)&&void 0!==t&&t.clockRate&&(e.rtpMap.clockRate=parseInt(e.rtpMap.clockRate)),d&&e.rtcpFeedbacks.push({type:"rrtr"})})),r&&(l=l.filter((e=>{var t;return"rtx"!==(null===(t=e.rtpMap)||void 0===t?void 0:t.encodingName.toLowerCase())})),u=u.filter((e=>{var t;return"rtx"!==(null===(t=e.rtpMap)||void 0===t?void 0:t.encodingName.toLowerCase())}))),o&&(u=u.filter((e=>{var t;
vendor: 6,273 bytes, line 12271
12271return!/(red)|(ulpfec)|(flexfec)/i.test((null===(t=e.rtpMap)||void 0===t?void 0:t.encodingName)||"")}))),s&&(l=l.filter((e=>{var t;return!/(red)|(ulpfec)|(flexfec)/i.test((null===(t=e.rtpMap)||void 0===t?void 0:t.encodingName)||"")}))),a&&(null==a?void 0:a.length)>0&&(l=l.filter((e=>{var t;return Dn(a).call(a,(null===(t=e.rtpMap)||void 0===t?void 0:t.encodingName.toLowerCase())||"")}))),c&&(null==c?void 0:c.length)>0){const e=u.filter((e=>{var t;return Dn(c).call(c,(null===(t=e.rtpMap)||void 0===t?void 0:t.encodingName.toLowerCase())||"")}));u=e.concat(r?[]:hV(e,u))}const m=_N("UNSUPPORTED_VIDEO_CODEC");return m&&m.length>0&&(u=u.filter((e=>!(e.rtpMap&&Dn(m).call(m,e.rtpMap.encodingName.toLowerCase()))))),{audioCodecs:l,videoCodecs:u,audioExtensions:h,videoExtensions:p}}function Xx(e){const t=yN(e);let i,n;for(const e of t.mediaDescriptions){if(!i){const t=e.attributes.iceUfrag,n=e.attributes.icePwd;if(!t||!n)throw new Error("Cannot get iceUfrag or icePwd from SDP.");i={iceUfrag:t,icePwd:n}}if(!n){const t=e.attributes.fingerprints;t.length>0&&(n={fingerprints:t})}}if(!n&&t.attributes.fingerprints.length>0&&(n={fingerprints:t.attributes.fingerprints}),!n||!i)throw new Error("Cannot get iceParameters or dtlsParameters from SDP.");return{iceParameters:i,dtlsParameters:n}}function Jx(e,t){const i=[],n=e.attributes.ssrcGroups.filter((e=>"FID"===e.semantic)),r=e.attributes.ssrcGroups.find((e=>"SIM"===e.semantic)),o=e.attributes.ssrcs;if(r)r.ssrcIds.forEach((e=>{var r;const o=null===(r=n.find((t=>t.ssrcIds[0]===e)))||void 0===r?void 0:r.ssrcIds[1];i.push({ssrcId:e,rtx:t?o:void 0})}));else if(n.length>0){const e=n[0].ssrcIds[0],r=n[0].ssrcIds[1];i.push({ssrcId:e,rtx:t?r:void 0})}else{if(0===o.length)throw new Error("No ssrcs found on local media description.");i.push({ssrcId:o[0].ssrcId})}return i}function Qx(e,t,i){const{cname:n}=e;let r=[];t&&(r=Zx(t)),0===r.length&&(r=e.iceParameters.candidates.map((e=>({foundation:e.foundation,componentId:"1",transport:e.protocol,priority:e.priority.toString(),connectionAddress:e.ip,port:e.port.toString(),type:e.type,extension:{}}))),YN.debug("Using candidates from gateway."));const o={fingerprints:e.dtlsParameters.fingerprints.map((e=>({hashFunction:e.algorithm,fingerprint:e.fingerprint})))},s={iceUfrag:e.iceParameters.iceUfrag,icePwd:e.iceParameters.icePwd};let a;switch(e.dtlsParameters.role){case"server":a="passive";break;case"client":a="active";break;case"auto":a="actpass"}const c=dV(e.rtpCapabilities),d=[];return Array.isArray(i)&&i.length>0&&i.forEach((e=>{d.push({kind:HU.VIDEO,ssrcId:e.v,rtx:e.v_rtx,mslabel:"".concat(e.v,"_").concat(e.a)},{kind:HU.AUDIO,ssrcId:e.a,mslabel:"".concat(e.v,"_").concat(e.a)})})),{dtlsParameters:o,iceParameters:s,candidates:r,rtpCapabilities:c,setup:a,cname:n,preSSRCs:d}}function Zx(e){let t=[];return e.ip&&"number"==typeof e.port&&(t=[{foundation:"udpcandidate",componentId:"1",transport:"udp",priority:"2103266323",connectionAddress:e.ip,port:e.port.toString(),type:"host",extension:{}}],YN.debug("Using remote candidate from AP ".concat(e.ip,":").concat(e.port)),e.ip6&&(t.push({foundation:"udpcandidate",componentId:"1",transport:"udp",priority:"2103266323",connectionAddress:e.ip6,port:e.port.toString(),type:"host",extension:{}}),YN.debug("Using IPV6 remote candidate from AP ".concat(e.ip6,":").concat(e.port)))),t}function $x(e,t,i){const n=[],r=[];return e.forEach((e=>{let{ssrcId:o,rtx:s}=e;const a=hO(8,"track-"),c={ssrcId:o,attributes:qx({label:a,mslabel:i=i||hO(10,""),msid:"".concat(i," ").concat(a)},t&&{cname:t})};if(n.push(c),void 0!==s){const e={ssrcId:s,attributes:qx({label:a,mslabel:i,msid:"".concat(i," ").concat(a)},t&&{cname:t})};n.push(e),r.push({semantic:"FID",ssrcIds:[o,s]})}})),e.length>1&&r.push({semantic:"SIM",ssrcIds:e.map((e=>{let{ssrcId:t}=e;return t}))}),{ssrcs:n,ssrcGroups:r}}function eV(e,t){t instanceof IL&&e.attributes.payloads.forEach((e=>{var i;const n=null===(i=e.rtpMap)||void 0===i?void 0:i.encodingName.toLowerCase();if(!n||-1===["opus","pcmu","pcma","g722"].indexOf(n))return;e.fmtp||(e.fmtp={parameters:{}}),e.fmtp.parameters.minptime="10",e.fmtp.parameters.useinbandfec="1";const r=t._encoderConfig;r&&"pcmu"!==n&&"pcma"!==n&&"g722"!==n&&(r.bitrate&&!Kb()&&(e.fmtp.parameters.maxaveragebitrate="".concat(Math.floor(1e3*r.bitrate))),r.sampleRate&&(e.fmtp.parameters.maxplaybackrate="".concat(r.sampleRate),e.fmtp.parameters["sprop-maxcapturerate"]="".concat(r.sampleRate)),r.stereo&&(e.fmtp.parameters.stereo="1",e.fmtp.parameters["sprop-stereo"]="1"))}))}function tV(e){const t=e.attributes.unrecognized.findIndex((e=>"x-google-flag"===e.attField&&"conference"===e.attValue));-1!==t&&e.attributes.unrecognized.splice(t,1)}function iV(e,t){var i;if(!(t instanceof pk&&t._encoderConfig&&-1===t._hints.indexOf(vD.SCREEN_TRACK)))return;const n=t._encoderConfig;nD().supportMinBitrate&&n.bitrateMin&&e.attributes.payloads.forEach((e=>{var t,i;Dn(t=["h264","h265","vp8","vp9","av1"]).call(t,(null===(i=e.rtpMap)||void 0===i?void 0:i.encodingName.toLowerCase())||"")&&(e.fmtp||(e.fmtp={parameters:{}}),e.fmtp.parameters["x-google-min-bitrate"]="".concat(n.bitrateMin))})),nD().supportMinBitrate&&!Dn(i=t._hints).call(i,vD.LOW_STREAM)&&n.bitrateMax&&e.attributes.payloads.forEach((e=>{var t,i;Dn(t=["h264","h265","vp8","vp9","av1"]).call(t,(null===(i=e.rtpMap)||void 0===i?void 0:i.encodingName.toLowerCase())||"")&&(e.fmtp||(e.fmtp={parameters:{}}),e.fmtp.parameters["x-google-start-bitrate"]="".concat(_N("X_GOOGLE_START_BITRATE")||Math.floor(n.bitrateMax)))}))}function nV(e){if("video"!==e.media.mediaType)return;const t=xb();if(t.name!==Lb.SAFARI&&t.os!==Pb.IOS)return;const i=e.attributes.extmaps.findIndex((e=>/video-orientation/g.test(e.extensionName)));-1!==i&&e.attributes.extmaps.splice(i,1)}function rV(e,t,i){if(!t)return;let n,r;if("video"===e.media.mediaType?(n=i.videoExtensions,r=i.videoCodecs):(n=i.audioExtensions,r=i.audioCodecs),!0===t.twcc){const t=n.find((e=>Kx(e.extensionName)));if(t){const i=t.extensionName;e.attributes.extmaps.find((e=>Kx(e.extensionName)))||e.attributes.extmaps.push({entry:t.entry,extensionName:i});const n=function(e,t){return t.filter((t=>!!e.find((e=>e.payloadType===t.payloadType&&!!e.rtcpFeedbacks.find((e=>"transport-cc"===e.type))))))}(r,e.attributes.payloads);
vendor: 10,709 bytes, line 12271
12271n.forEach((e=>{e.rtcpFeedbacks.find((e=>"transport-cc"===e.type))||e.rtcpFeedbacks.push({type:"transport-cc"})}))}}else if(!1===t.twcc){const t=e.attributes.extmaps.findIndex((e=>Kx(e.extensionName)));-1!==t&&e.attributes.extmaps.splice(t,1),e.attributes.payloads.forEach((e=>{const t=e.rtcpFeedbacks.findIndex((e=>"transport-cc"===e.type));-1!==t&&e.rtcpFeedbacks.splice(t,1)}))}if(!0===t.remb){const t=n.find((e=>Hx(e.extensionName)));if(t){const i=t.extensionName;e.attributes.extmaps.find((e=>e.extensionName===i))||e.attributes.extmaps.push({entry:t.entry,extensionName:i});const n=function(e,t){return t.filter((t=>!!e.find((e=>e.payloadType===t.payloadType&&!!e.rtcpFeedbacks.find((e=>"goog-remb"===e.type))))))}(r,e.attributes.payloads);n.forEach((e=>{e.rtcpFeedbacks.find((e=>"goog-remb"===e.type))||e.rtcpFeedbacks.push({type:"goog-remb"})}))}}else if(!1===t.remb){const t=e.attributes.extmaps.findIndex((e=>Hx(e.extensionName)));-1!==t&&e.attributes.extmaps.splice(t,1),e.attributes.payloads.forEach((e=>{const t=e.rtcpFeedbacks.findIndex((e=>"goog-remb"===e.type));-1!==t&&e.rtcpFeedbacks.splice(t,1)}))}}function oV(e,t,i){if(Kb())return;if("video"!==e.media.mediaType)return;if(!(t instanceof pk))return;if("vp9"!==i&&"vp8"!==i)return;if("vp8"===i&&!_N("SIMULCAST"))return;if("vp9"===i&&_N("ENABLE_SVC"))return;if(void 0===t._scalabilityMode||t._scalabilityMode.numSpatialLayers<=1)return;const n="vp8"===i?2:t._scalabilityMode.numSpatialLayers,r=e.attributes.ssrcs[0],o=e.attributes.ssrcGroups.find((e=>"FID"===e.semantic&&e.ssrcIds[0]===r.ssrcId)),s={semantic:"SIM",ssrcIds:[r.ssrcId]};for(let t=1;t<n;t++)e.attributes.ssrcs.push({ssrcId:r.ssrcId+t,attributes:eO(r.attributes)}),s.ssrcIds.push(r.ssrcId+t),o&&(e.attributes.ssrcs.push({ssrcId:o.ssrcIds[1]+t,attributes:eO(r.attributes)}),e.attributes.ssrcGroups.push({semantic:"FID",ssrcIds:[r.ssrcId+t,o.ssrcIds[1]+t]}));e.attributes.ssrcGroups.unshift(s)}async function sV(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new RTCPeerConnection;i.addTransceiver("video",{direction:"sendonly"}),i.addTransceiver("audio",{direction:"sendonly"}),i.addTransceiver("video",{direction:"recvonly"}),i.addTransceiver("audio",{direction:"recvonly"});const n=(await i.createOffer()).sdp,{send:r,recv:o,sendrecv:s}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const n=zx(i,e,t,"sendonly"),r=zx(i,e,t,"recvonly"),o={audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]},s={audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]},a={audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]};if(cV(n,r,"videoExtensions",o,s,a),cV(n,r,"videoCodecs",o,s,a),cV(n,r,"audioExtensions",o,s,a),cV(n,r,"audioCodecs",o,s,a),_N("RAISE_H264_BASELINE_PRIORITY")){const e=[],t=[];a.videoCodecs.forEach(((i,n)=>{var r;if("h264"===(null===(r=i.rtpMap)||void 0===r?void 0:r.encodingName.toLocaleLowerCase())){var o,s;const r=a.videoCodecs[n+1],c=r&&fV(i,r),d=null===(o=i.fmtp)||void 0===o?void 0:o.parameters["profile-level-id"],l=null===(s=i.fmtp)||void 0===s?void 0:s.parameters["packetization-mode"];!d||d!==_N("FIRST_H264_PROFILE_LEVEL_ID")||_N("FIRST_PACKETIZATION_MODE")&&l!==_N("FIRST_PACKETIZATION_MODE")?c?t.push([i,r]):t.push([i]):c?e.push([i,r]):e.push([i])}})),e.length>0&&t.length>0&&(YN.debug("raising H264 baseline profile priority"),a.videoCodecs.forEach(((i,n)=>{var r;if("h264"===(null===(r=i.rtpMap)||void 0===r?void 0:r.encodingName.toLocaleLowerCase())){const r=fV(i,a.videoCodecs[n+1]),o=e.shift()||t.shift()||[];o.length>0&&(r?a.videoCodecs.splice(n,2,...o):a.videoCodecs.splice(n,1,...o))}})),s.videoCodecs=s.videoCodecs.filter((e=>{var t,i;return!("h264"===(null===(t=e.rtpMap)||void 0===t?void 0:t.encodingName.toLocaleLowerCase())&&(null===(i=e.fmtp)||void 0===i?void 0:i.parameters["profile-level-id"])!==_N("FIRST_H264_PROFILE_LEVEL_ID"))})),_N("FILTER_SEND_H264_BASELINE")&&(o.videoCodecs=o.videoCodecs.filter((e=>{var t,i;return!("h264"===(null===(t=e.rtpMap)||void 0===t?void 0:t.encodingName.toLocaleLowerCase())&&(null===(i=e.fmtp)||void 0===i?void 0:i.parameters["profile-level-id"])!==_N("FIRST_H264_PROFILE_LEVEL_ID"))}))))}return{send:o,recv:s,sendrecv:a}}(e,t,n);try{i.close()}catch(e){}return{send:r,recv:o,sendrecv:s}}function aV(){const e={audioCodecs:[],videoCodecs:[],audioExtensions:[],videoExtensions:[]},t=zx(arguments.length>2?arguments[2]:void 0,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},"recvonly"),i={audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]},n={audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]},r={audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]};if(cV(e,t,"videoExtensions",i,n,r),cV(e,t,"videoCodecs",i,n,r),cV(e,t,"audioExtensions",i,n,r),cV(e,t,"audioCodecs",i,n,r),_N("RAISE_H264_BASELINE_PRIORITY")){const e=r.videoCodecs.findIndex((e=>e.rtpMap&&"h264"===e.rtpMap.encodingName.toLocaleLowerCase()&&e.fmtp&&"42001f"===e.fmtp.parameters["profile-level-id"]));if(-1!==e){const t=r.videoCodecs.findIndex((e=>e.rtpMap&&"h264"===e.rtpMap.encodingName.toLocaleLowerCase()));if(t<e){YN.debug("raising H264 baseline profile priority");const i=r.videoCodecs[e];r.videoCodecs.splice(e,1),r.videoCodecs.splice(t,0,i)}-1!==t&&(n.videoCodecs=n.videoCodecs.filter((e=>!(e.rtpMap&&"h264"===e.rtpMap.encodingName.toLocaleLowerCase()&&e.fmtp&&"42001f"!==e.fmtp.parameters["profile-level-id"]))))}}return{send:i,recv:n,sendrecv:r}}function cV(e,t,i,n,r,o){if("videoExtensions"===i||"audioExtensions"===i){const s=[];return e[i].forEach((e=>{t[i].some(((t,i)=>{if(e.entry===t.entry&&e.extensionName===t.extensionName)return s.push(i),!0}))?o[i].push(e):n[i].push(e)})),void t[i].forEach(((e,t)=>{-1===s.indexOf(t)&&r[i].push(e)}))}if("videoCodecs"===i||"audioCodecs"===i){const s=[];return e[i].forEach((e=>{t[i].some(((t,i)=>{if(e.payloadType===t.payloadType&&JSON.stringify(e)===JSON.stringify(t))return s.push(i),!0}))?o[i].push(e):n[i].push(e)})),void t[i].forEach(((e,t)=>{-1===s.indexOf(t)&&r[i].push(e)}))}}function dV(e){const{send:t,recv:i,sendrecv:n}=e;if(!n){if(!t||!i)throw new Error("cannot merge rtp capabilities because one of send or recv is empty!");return{send:t,recv:i}}let r,o;return t?(r={audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]},r.audioCodecs=[...t.audioCodecs,...n.audioCodecs],r.videoCodecs=[...t.videoCodecs,...n.videoCodecs],r.audioExtensions=[...t.audioExtensions,...n.audioExtensions],r.videoExtensions=[...t.videoExtensions,...n.videoExtensions]):r=n,i?(o={audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]},o.audioCodecs=[...i.audioCodecs,...n.audioCodecs],o.videoCodecs=[...i.videoCodecs,...n.videoCodecs],o.audioExtensions=[...i.audioExtensions,...n.audioExtensions],o.videoExtensions=[...i.videoExtensions,...n.videoExtensions]):o=n,{send:r,recv:o}}function lV(e){if("audio"!==e.media.mediaType)return;e.attributes.payloads.filter((e=>{var t;return"opus"===(null===(t=e.rtpMap)||void 0===t?void 0:t.encodingName.toLowerCase())})).forEach((e=>{e.fmtp||(e.fmtp={parameters:{}}),e.fmtp.parameters.stereo="1",e.fmtp.parameters["sprop-stereo"]="1"}))}function uV(e,t,i,n){let r=[];if(e===HU.VIDEO){if(_N("H264_PROFILE_LEVEL_ID")&&"h264"===n&&(r=t.videoCodecs.filter((e=>{var t;return Dn(t=e.rtpMap&&e.rtpMap.encodingName.toLowerCase()||"").call(t,n)&&e&&e.fmtp&&e.fmtp.parameters["profile-level-id"]===_N("H264_PROFILE_LEVEL_ID")}))),!Array.isArray(r)||0===r.length){let e=[];const o=[],s=[],a=[];if(i.videoCodecs.forEach((t=>{const i=t.rtpMap&&t.rtpMap.encodingName.toLowerCase()||"";Dn(i).call(i,n)?e.push(t):Dn(i).call(i,"vp9")?o.push(t):Dn(i).call(i,"vp8")?s.push(t):Dn(i).call(i,"h264")&&a.push(t)})),0===e.length){let t="";0!==o.length?(e=o,t="vp9"):0!==s.length?(e=s,t="vp8"):0!==a.length&&(e=a,t="h264"),YN.warning("codec ".concat(n," not included in rtpCapabilities, fallback to default payloads: ").concat(t))}0!==e.length&&(r=t.videoCodecs.filter((t=>e.some((e=>e.payloadType===t.payloadType)))))}if(0===r.length&&(YN.warning("codec ".concat(n," not included in rtpCapabilities, fallback to default payloads: ").concat(t.videoCodecs[0].rtpMap&&t.videoCodecs[0].rtpMap.encodingName)),r=t.videoCodecs),_N("USE_PUB_RTX")||_N("USE_SUB_RTX")){const e=hV(r,t.videoCodecs);r=[...r,...e]}}else r=t.audioCodecs.filter((e=>{var t;return Dn(t=e.rtpMap&&e.rtpMap.encodingName.toLowerCase()||"").call(t,n)})),0===r.length&&(YN.warning("codec ".concat(n," not included in rtpCapabilities, fallback to opus")),r=t.audioCodecs.filter((e=>{var t;return Dn(t=e.rtpMap&&e.rtpMap.encodingName.toLowerCase()||"").call(t,"opus")})));return r}function hV(e,t){const i=e.map((e=>e.payloadType.toString()));return t.filter((e=>e.rtpMap&&"rtx"===e.rtpMap.encodingName&&e.fmtp&&e.fmtp.parameters.apt&&Dn(i).call(i,e.fmtp&&e.fmtp.parameters.apt)))}async function pV(e,t,i){const n=t.toString(),r=EV(n,"offer","remote","exchangeSDP");await e.setRemoteDescription({type:"offer",sdp:n});const o=await e.createAnswer();if(!o.sdp)throw new Error("cannot get answer sdp");let s=o.sdp;s=_V(s,i||{}),null==r||r(s||""),await e.setLocalDescription({type:"answer",sdp:s})}function _V(e,t,i){const n=yN(e),{useXR:r}=t;return n.mediaDescriptions.forEach((e=>{var t;e.attributes.mid&&(Array.isArray(i)&&!Dn(i).call(i,e.attributes.mid)||("audio"===e.media.mediaType&&lV(e),r&&Dn(t=["audio","video"]).call(t,e.media.mediaType)&&e.attributes.payloads.forEach((e=>{-1===e.rtcpFeedbacks.findIndex((e=>"rrtr"===e.type))&&e.rtcpFeedbacks.push({type:"rrtr"})}))))})),AN(n)}function EV(e,t,i,n){if(_N("SDP_LOGGING"))return YN.upload("exchanging ".concat(i," ").concat(t," SDP during P2PConnection.").concat(n,"\n"),e),"offer"===t?e=>{EV(e,"answer","local"===i?"remote":"local",n)}:void 0}function mV(e){const t=_N("COMPATIBLE_SDP_EXTENSION");return!!(Array.isArray(t)&&t.length>0)&&t.some((t=>Dn(e).call(e,t)))}function fV(e,t){try{var i;return(null===(i=e.fmtp)||void 0===i?void 0:i.parameters.apt)===t.payloadType.toString()}catch(e){return!1}}function TV(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function SV(e,t){return typeof _N(e)===t?_N(e):void 0}function gV(){try{const e=_N("EXPERIMENTS")||{};return"string"==typeof e||Array.isArray(e)?{}:function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};
12271t%2?TV(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):TV(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({},e)}catch(e){return YN.debug("handle gateway attributes failed: ",e),{}}}const RV={};function vV(e){(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&YN.debug("install service ".concat(e.name)),RV[e.name]=e}function CV(e){const t=RV[e];if(!t)throw new mw(Ew.INVALID_OPERATION,"".concat(e," not found, please use AgoraRTC.use(").concat(e,"Service) to load it first"));return t}function IV(e,t){return CV("DataStream").create(e,t)}function yV(){return CV("InterceptFrame").create()}function AV(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function bV(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?AV(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):AV(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}const wV=new Map;class OV extends Dw{get state(){return this._state}set state(e){if(e===this._state)return;const t=this._state;this._state=e,"DISCONNECTED"===e&&this._disconnectedReason?this.emit(LU.CONNECTION_STATE_CHANGE,e,t,this._disconnectedReason):this.emit(LU.CONNECTION_STATE_CHANGE,e,t)}get joinGatewayStartTime(){return this._joinGatewayStartTime}set joinGatewayStartTime(e){YN.debug("[".concat(this.store.clientId,"] set joinGatewayStartTime at ").concat(e)),this._joinGatewayStartTime=e}constructor(e,t){var i,n,r;super(),QI(this,"store",void 0),QI(this,"joinInfo",void 0),QI(this,"key",void 0),QI(this,"ntpOffset",0),QI(this,"signal",void 0),QI(this,"role",void 0),QI(this,"inChannelInfo",{joinAt:null,duration:0}),QI(this,"spec",void 0),QI(this,"_state","DISCONNECTED"),QI(this,"_statsCollector",void 0),QI(this,"_disconnectedReason",void 0),QI(this,"isSignalRecover",!1),QI(this,"hasChangeBGPAddress",!1),QI(this,"trafficStatsInterval",void 0),QI(this,"networkQualityInterval",void 0),QI(this,"_joinGatewayStartTime",0),QI(this,"_signalTimeout",!1),QI(this,"_clientRoleOptions",void 0),QI(this,"_isProactiveJoin",!1),this.store=e,this.spec=t,this.signal=this.store.useP2P?(i={spec:bV(bV({},t),{},{retryConfig:t.websocketRetryConfig}),store:e},null===(n=(r=CV("P2PChannel")).createSubmodule)||void 0===n?void 0:n.call(r,i)):new Ax(bV(bV({},t),{},{retryConfig:t.websocketRetryConfig}),e),this._statsCollector=t.statsCollector,this.role=t.role||"audience",this._clientRoleOptions=t.clientRoleOptions,this.handleSignalEvents()}async join(e,t,i){this.store.joinGatewayStart(),"disabled"!==e.cloudProxyServer&&(this.hasChangeBGPAddress=!0);const n=Date.now();let r=wV.get(e.cname);if(r||(r=new Map,wV.set(e.cname,r)),this._isProactiveJoin=!0,r.has(e.uid)){const t=new tD(Ew.UID_CONFLICT);throw eD.joinGateway(e.sid,{lts:n,succ:!1,ec:t.code,addr:null,uid:e.uid,cid:e.cid,firstSuccess:this._isProactiveJoin,avoidJoinStartTime:this.store.avoidJoinStart,isProxy:!!e.proxyServer,signalChannel:"0",preload:e.preload}),t}r.set(e.uid,!0),this.joinInfo=e,this.key=t;let o=0;this.joinGatewayStartTime=n;const s=e.proxyServer;try{YN.debug("[".concat(this.store.clientId,"] use websocket join uid ").concat(o));const t=e.gatewayAddrs.map((t=>{let{address:i}=t;const[n,r]=i.split(":"),o={host:n,port:r};return e.proxyServer&&(o.proxy=e.proxyServer),o}));o=(await this.signal.init(t)).uid,YN.debug("[".concat(this.store.clientId,"] websocket join uid ").concat(o," cost ").concat(Date.now()-this.joinGatewayStartTime))}catch(t){var a;throw YN.error("[".concat(this.store.clientId,"] User join failed"),t.toString()),eD.joinGateway(e.sid,{lts:n,succ:!1,ec:(null===(a=t.data)||void 0===a?void 0:a.desc)||t.code,errorMsg:t.message,addr:this.signal.url,uid:e.uid,cid:e.cid,firstSuccess:this._isProactiveJoin,avoidJoinStartTime:this.store.avoidJoinStart,isProxy:!!s,signalChannel:"0",preload:e.preload}),r.delete(e.uid),this.signal.close(),t}return this.state="CONNECTED",this.inChannelInfo.joinAt=Date.now(),YN.debug("[".concat(this.store.clientId,"] Connected to gateway server")),this.trafficStatsInterval=window.setInterval((()=>{this.updateTrafficStats().catch((e=>{YN.warning("[".concat(this.store.clientId,"] get traffic stats error"),e.toString())}))}),3e3),this.networkQualityInterval=window.setInterval((()=>{navigator&&void 0!==navigator.onLine&&!navigator.onLine?this.emit
vendor: 8,372 bytes, line 12271
12271(LU.NETWORK_QUALITY,{downlinkNetworkQuality:6,uplinkNetworkQuality:6}):this._signalTimeout?this.emit(LU.NETWORK_QUALITY,{downlinkNetworkQuality:5,uplinkNetworkQuality:5}):"CONNECTED"===this.state&&this._statsCollector.trafficStats?this.emit(LU.NETWORK_QUALITY,{uplinkNetworkQuality:Mx(this._statsCollector.trafficStats.B_unq),downlinkNetworkQuality:Mx(this._statsCollector.trafficStats.B_dnq)}):this.emit(LU.NETWORK_QUALITY,{uplinkNetworkQuality:0,downlinkNetworkQuality:0})}),2e3),this.store.joinGatewayEnd(),o}async leave(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0;if("DISCONNECTED"!==this.state){t!==Vw.FALLBACK&&(this.state="DISCONNECTING");try{e||this.signal.connectionState!==lU.CONNECTED||await function(e,t){return t===1/0?e:Wh.race([e,lO(t)])}(this.signal.request(hU.LEAVE,void 0,!0),3e3)}catch(e){YN.warning("[".concat(this.store.clientId,"] leave request failed, ignore"),e)}this.signal.close(t),t!==Vw.FALLBACK&&(this.state="DISCONNECTED"),this.reset()}}async publish(e,t,i){if("CONNECTED"!==this.state&&"RECONNECTING"!==this.state)throw new tD(Ew.INVALID_OPERATION,"can not publish when connection state is ".concat(this.state));const n={state:"offer",p2p_id:this.store.p2pId,ortc:t,mode:this.spec.mode,extend:_N("PUB_EXTEND"),twcc:!!_N("PUBLISH_TWCC"),rtx:!!_N("USE_PUB_RTX")};try{return(await this.signal.request(hU.PUBLISH,n,!0))._message}catch(n){if(i&&n.data&&n.data.code===dU.ERR_PUBLISH_REQUEST_INVALID)return YN.warning("[".concat(this.store.clientId,"] receive publish error code, retry"),n.toString()),await this.tryUnpubBeforeRepub(e,t),this.publish(e,t,!1);throw n}}async publishDataChannel(e,t,i){var n;if("CONNECTED"!==this.state&&"RECONNECTING"!==this.state)throw new tD(Ew.INVALID_OPERATION,"can not publish when connection state is ".concat(this.state));const r={stream_id:t.streamId,ordered:t.ordered?1:0,max_retrans_times:null!==(n=t.maxRetransmits)&&void 0!==n?n:10,channel_id:t.channelId,metadata:t.metadata};try{await this.signal.request(hU.PUBLISH_DATASTREAM,r,!0)}catch(n){if(i&&n.data&&n.data.code===dU.ERR_PUBLISH_REQUEST_INVALID)return YN.warning("[".concat(this.store.clientId,"] receive publish datachannels error code, retry"),n.toString()),await this.tryUnpubDataChannelBeforeRepub(e,t),this.publishDataChannel(e,t,!1);throw n}}async unpublish(e,t){try{if("CONNECTED"!==this.state&&"RECONNECTING"!==this.state)throw new tD(Ew.INVALID_OPERATION,"can not publish when connection state is ".concat(this.state));await this.signal.request(hU.UNPUBLISH,{stream_id:t,ortc:e},!0)}catch(e){YN.warning("[".concat(this.store.clientId,"] unpublish warning: "),e)}}async unpublishDataChannel(e){try{if("CONNECTED"!==this.state&&"RECONNECTING"!==this.state)throw new tD(Ew.INVALID_OPERATION,"can not publish when connection state is ".concat(this.state));await Wh.all(e.map((e=>this.signal.request(hU.UNPUBLISH_DATASTREAM,{channel_id:e},!0))))}catch(e){YN.warning("unpublish datachannels warning: ",e)}}async presubscribe(e,t,i){if("CONNECTED"!==this.state&&"RECONNECTING"!==this.state)throw new tD(Ew.INVALID_OPERATION,"can not presubscribe when connection state is ".concat(this.state));const n={stream_id:e,stream_type:t,mode:this.spec.mode,codec:this.spec.codec,p2p_id:this.store.p2pId,twcc:!!_N("SUBSCRIBE_TWCC"),rtx:!!_N("USE_SUB_RTX")||void 0,extend:_N("SUB_EXTEND"),svc:Array.isArray(_N("SVC"))&&0!==_N("SVC").length?_N("SVC"):void 0};try{return await this.signal.request(hU.PRE_SUBSCRIBE,n,!0)}catch(n){if(i&&n.data&&n.data.code===dU.ERR_SUBSCRIBE_REQUEST_INVALID)return YN.warning("[".concat(this.store.clientId,"] pre-subscribe error, retry"),n.toString()),this.presubscribe(e,t,!1);throw n}}async subscribe(e,t,i){if("CONNECTED"!==this.state&&"RECONNECTING"!==this.state)throw new tD(Ew.INVALID_OPERATION,"can not subscribe when connection state is ".concat(this.state));const n={stream_id:e,stream_type:t.stream_type,mode:this.spec.mode,codec:this.spec.codec,p2p_id:this.store.p2pId,twcc:!!_N("SUBSCRIBE_TWCC"),rtx:!!_N("USE_SUB_RTX"),extend:_N("SUB_EXTEND"),ssrcId:t.ssrcId,svc:Array.isArray(_N("SVC"))&&0!==_N("SVC").length?_N("SVC"):void 0};try{return(await this.signal.request(hU.SUBSCRIBE,n,!0))._message}catch(n){if(i&&n.data&&n.data.code===dU.ERR_SUBSCRIBE_REQUEST_INVALID)return YN.warning("[".concat(this.store.clientId,"] receiver subscribe error code, retry"),n.toString()),await this.tryUnsubBeforeResub(e,t),await this.subscribe(e,t,!1);throw n}}async subscribeDataChannel(e,t,i){if("CONNECTED"!==this.state&&"RECONNECTING"!==this.state)throw new tD(Ew.INVALID_OPERATION,"can not subscribe datachannel when connection state is ".concat(this.state));const n={uid:e,stream_id:t.id,channel_id:t.datachannelId};try{return void await this.signal.request(hU.SUBSCRIBE_DATASTREAM,n,!0)}catch(n){if(i&&n.data&&n.data.code===dU.ERR_SUBSCRIBE_REQUEST_INVALID)return YN.warning("[".concat(this.store.clientId,"] receiver subscribe datachannel error code, retry"),n.toString()),await this.tryUnsubDataChannelBeforeResub(e,t),await this.subscribeDataChannel(e,t,!1);throw n}}async subscribeAll(e,t){if("CONNECTED"!==this.state&&"RECONNECTING"!==this.state)throw new tD(Ew.INVALID_OPERATION,"can not massSubscribe when connection state is ".concat(this.state));const i={p2p_id:this.store.p2pId,users:e,dtx:!1,rtx:!!_N("USE_SUB_RTX"),twcc:!!_N("SUBSCRIBE_TWCC"),svc:Array.isArray(_N("SVC"))&&0!==_N("SVC").length?_N("SVC"):void 0};try{return await this.signal.request(hU.SUBSCRIBE_STREAMS,i,!0)}catch(i){if(t&&i.data&&i.data.code===dU.ERR_SUBSCRIBE_REQUEST_INVALID)return YN.warning("[".concat(this.store.clientId,"] receiver massSubscribe error code, retry"),i.toString()),await this.tryMassUnsubBeforeResub(e),await this.subscribeAll(e,!1);throw i}}async setVideoProfile(e){const t=function(e){if(!(e.bitrateMax&&e.bitrateMin&&e.frameRate&&e.height&&e.width))return;let t=e.frameRate,i=e.width,n=e.height,r=!0;return"number"!=typeof t&&(t=t.exact||t.ideal||t.max||t.min||0,t||(r=!1)),"number"!=typeof i&&(i=i.exact||i.ideal||i.max||i.min||0,i||(r=!1)),"number"!=typeof n&&(n=n.exact||n.ideal||n.max||n.min||0,t||(r=!1)),r?{stream_type:0,width:i,height:n,fps:t,start_bps:1e3*e.bitrateMax,min_bps:1e3*e.bitrateMin,target_bps:1e3*e.bitrateMax}:void 0}(e);if(t)return this.signal.request(hU.SET_VIDEO_PROFILE,t);YN.debug("[".concat(this.store.clientId,"] encoder config is not complete, do not report to gateway"))}async unsubscribe(e,t){try{await this.signal.request(hU.UNSUBSCRIBE,{p2p_id:this.store.p2pId,ortc:e,stream_id:t},!0)}catch(e){YN.warning("[".concat(this.store.clientId,"] unsubscribe warning: "),e)}}async unsubscribeDataChannel(e,t){try{if("CONNECTED"!==this.state&&"RECONNECTING"!==this.state)throw new tD(Ew.INVALID_OPERATION,"can not publish when connection state is ".concat(this.state));await Wh.all(e.map((e=>this.signal.request(hU.UNSUBSCRIBE_DATASTREAM,{stream_id:e,uid:t},!0))))}catch(e){YN.warning("unsubscribeDataChannel warning: ",e)}}async massUnsubscribe(e){try{await this.signal.request(hU.UNSUBSCRIBE_STREAMS,e,!0)}catch(e){YN.warning("[".concat(this.store.clientId,"] massUnsubscribeAll warning: "),e)}}async reconnectPC(e){const{iceParameters:t,dtlsParameters:i,rtpCapabilities:n}=e;return{gatewayEstablishParams:await this.signal.request(hU.CONNECT_PC,{p2p_id:this.store.p2pId,stream_id:this.store.uid,ortc:{iceParameters:t,dtlsParameters:i,rtpCapabilities:n}},!0),gatewayAddress:this.getCurrentGatewayAddress()}}getGatewayInfo(){return this.signal.request(hU.GATEWAY_INFO)}async renewToken(e){await this.signal.request(hU.RENEW_TOKEN,e),this.key=e.token}updateClientRole(e,t){t&&(this._clientRoleOptions=Object.assign({},t)),_N("CLIENT_ROLE_OPTIONS")&&(YN.debug("[".concat(this.store.clientId,"] Set roleOptions for ").concat(JSON.stringify(_N("CLIENT_ROLE_OPTIONS"))," instead of ").concat(JSON.stringify(this._clientRoleOptions)," ")),this._clientRoleOptions=Object.assign({},_N("CLIENT_ROLE_OPTIONS"))),this.role=e}async setClientRole(e,t){if(t&&(this._clientRoleOptions=Object.assign({},t)),_N("CLIENT_ROLE_OPTIONS")&&(this._clientRoleOptions=Object.assign({},_N("CLIENT_ROLE_OPTIONS")),YN.debug("[".concat(this.store.clientId,"] Set roleOptions for ").concat(JSON.stringify(_N("CLIENT_ROLE_OPTIONS"))," instead of ").concat(JSON.stringify(this._clientRoleOptions)," "))),"CONNECTED"!==this.state)return void(this.role=e);let i,n=0;
12271"audience"===e?this._clientRoleOptions&&this._clientRoleOptions.delay?(i=this._clientRoleOptions.delay,n=1):n=this._clientRoleOptions&&this._clientRoleOptions.level?this._clientRoleOptions.level:2:n=0,await this.signal.request(hU.SET_CLIENT_ROLE,{role:e,level:n,delay:i,client_ts:Date.now()}),this.role=e}async setRemoteVideoStreamType(e,t){await this.signal.request(hU.SWITCH_VIDEO_STREAM,{stream_id:e,stream_type:t})}async setDefaultRemoteVideoStreamType(e){await this.signal.request(hU.DEFAULT_VIDEO_STREAM,{stream_type:e})}async setStreamFallbackOption(e,t){await this.signal.request(hU.SET_FALLBACK_OPTION,{stream_id:e,fallback_type:t})}async pickSVCLayer(e,t){await this.signal.request(hU.PICK_SVC_LAYER,{stream_id:e,spatial_layer:t.spatialLayer,temporal_layer:t.temporalLayer})}async setRTM2Flag(e){await this.signal.request(hU.SET_RTM2_FLAG,{rtm2_flag:e})}async sendExtensionMessage(e,t,i){if(this.store.useP2P)return this.signal.sendExtensionMessage(e,t,i)}getInChannelInfo(){return this.inChannelInfo.joinAt&&(this.inChannelInfo.duration=Date.now()-this.inChannelInfo.joinAt),bV({},this.inChannelInfo)}async getGatewayVersion(){return(await this.signal.request(hU.GATEWAY_INFO)).version}reset(){if(this.inChannelInfo.joinAt&&(this.inChannelInfo.duration=Date.now()-this.inChannelInfo.joinAt,this.inChannelInfo.joinAt=null),this.trafficStatsInterval&&(window.clearInterval(this.trafficStatsInterval),this.trafficStatsInterval=void 0),this.joinInfo){const e=wV.get(this.joinInfo.cname);e&&e.delete(this.joinInfo.uid)}this.joinInfo=void 0,this.key=void 0,this.networkQualityInterval&&(window.clearInterval(this.networkQualityInterval),this.networkQualityInterval=void 0)}updateTurnConfigFromSignal(){if(!this.joinInfo)return;const e=function(e){let t;return t=e.startsWith("dc")?e.match(/(dc\:\/\/)?([^:]+):(\d+)/):e.match(/(wss\:\/\/)?([^:]+):(\d+)/),t?{username:aN.username,password:aN.password,turnServerURL:t[2],tcpport:parseInt(t[3])+30,udpport:parseInt(t[3])+30,forceturn:!1}:null}(("disabled"===this.joinInfo.cloudProxyServer?this.signal.url:this.joinInfo.gatewayAddrs[this.signal.currentURLIndex].address)||"");this.joinInfo.turnServer.serversFromGateway=[],e&&"off"!==this.joinInfo.turnServer.mode&&"disabled"===this.joinInfo.cloudProxyServer&&this.joinInfo.turnServer.serversFromGateway.push(bV(bV({},aN),{},{turnServerURL:e.turnServerURL,tcpport:e.tcpport,udpport:e.udpport,username:this.joinInfo.uid.toString(),password:this.joinInfo.token}))}async updateTrafficStats(){if("CONNECTED"!==this.state)return;const e=await this.signal.request(hU.TRAFFIC_STATS,void 0,!0);e.timestamp=Date.now(),null!=e.ntp_offset&&(this.ntpOffset=e.ntp_offset),e.peer_delay.forEach((e=>{const t=this._statsCollector.trafficStats&&this._statsCollector.trafficStats.peer_delay.find((t=>t.peer_uid===e.peer_uid));t&&t.B_st!==e.B_st&&$w((()=>{this.emit(LU.STREAM_TYPE_CHANGE,e.peer_uid,e.B_st)}))})),this._statsCollector.updateTrafficStats(e)}getJoinMessage(e){if(!this.joinInfo||!this.key)throw new tD(Ew.UNEXPECTED_ERROR,"can not generate join message, no join info");const t=Object.assign({},this.joinInfo.apResponse);let i=_N("REPORT_APP_SCENARIO");if("string"!=typeof i)try{i=JSON.stringify(i)}catch(e){i=void 0}var n;i&&i.length>128&&(i=void 0),this.store.hasStartJoinChannel=!0,this.store.isABTestSuccess||this.emit(LU.UPDATE_GATEWAY_CONFIG),n=this.store.clientId,Dn(SM).call(SM,n)||SM.push(n);const r=!(Kb()||zb(87)||oD())&&("boolean"==typeof _N("ENABLE_PRE_SUB")&&_N("ENABLE_PRE_SUB")),o=!oD()&&SV("ENABLE_PREALLOC_PC","boolean"),s=gV(),a=qb(87)||function(){const e=xb();if(e.name!==Lb.SAFARI||!e.browserVersion)return!1;const t=e.browserVersion.split(".");return Number(t[0])>15||15===Number(t[0])&&Number(t[1])>=4}(),c=bV({license:this.joinInfo.license,p2p_id:this.store.p2pId,session_id:this.joinInfo.sid,app_id:this.joinInfo.appId,channel_key:this.key,channel_name:this.joinInfo.cname,sdk_version:rN,browser:navigator.userAgent,process_id:_N("PROCESS_ID"),mode:this.store.useP2P?"p2p":this.spec.mode,codec:this.spec.codec,role:this.role,has_changed_gateway:this.hasChangeBGPAddress,ap_response:t,extend:_N("JOIN_EXTEND"),details:{6:this.joinInfo.stringUid,cservice_map:"proxy3"===this.joinInfo.cloudProxyServer?"1":"proxy5"===this.joinInfo.cloudProxyServer?"2":void 0},features:{rejoin:!0},optionalInfo:this.joinInfo.optionalInfo,appScenario:i,attributes:{userAttributes:bV({enableEncodedTransform:!!_N("ENABLE_AUDIO_METADATA")&&a||!!_N("ENABLE_AUDIO_TOPN")&&Xb(Lb.CHROME,87,116)||void 0,enableAudioMetadata:!!_N("ENABLE_AUDIO_METADATA")&&a,enableAudioPts:!!_N("ENABLE_AUDIO_PTS_METADATA")&&a,topnSmoothLevel:_N("TOPN_SMOOTH_LEVEL"),topnNewSpeakerDelay:_N("TOPN_NEW_SPEAKER_DELAY"),topnSwitchHoldMs:_N("TOPN_SWITCH_HOLD_MS"),topnAudioGain:_N("TOPN_AUDIO_GAIN"),enablePublishedUserList:_N("ENABLE_PUBLISHED_USER_LIST"),maxSubscription:_N("MAX_SUBSCRIPTION"),subscribeAudioFilterTopN:SV("SUBSCRIBE_AUDIO_FILTER_TOPN","number"),enablePublishAudioFilter:SV("ENABLE_PUBLISH_AUDIO_FILTER","boolean"),enableUserLicenseCheck:SV("ENABLE_USER_LICENSE_CHECK","boolean"),enableRTX:!0===_N("USE_PUB_RTX")||!0===_N("USE_SUB_RTX")||void 0,disableFEC:_N("DISABLE_FEC"),enableNTPReport:!!_N("ENABLE_NTP_REPORT")||void 0,enableInstantVideo:!!_N("ENABLE_INSTANT_VIDEO")||void 0,enableFulllinkAvSync:!!_N("ENABLE_FULL_LINK_AV_SYNC")||void 0,enableDataStream2:SV("ENABLE_DATASTREAM_2","boolean"),enableAutFeedback:!!_N("ENABLE_AUT_FEEDBACK")||void 0,rtm2Flag:"number"==typeof this.joinInfo.rtmFlag?this.joinInfo.rtmFlag:void 0,enableUserAutoRebalanceCheck:!!_N("ENABLE_USER_AUTO_REBALANCE_CHECK"),enableXR:SV("USE_XR","boolean"),enableLossbasedBwe:SV("ENABLE_LOSSBASED_BWE","boolean"),enableAutCC:!!_N("ENABLE_AUT_CC")||void 0,enableCCF
12271allback:SV("ENABLE_CC_FALLBACK","boolean"),enablePreallocPC:o,preSubNum:r?SV("PRE_SUB_NUM","number"):void 0,enablePubTWCC:SV("PUBLISH_TWCC","boolean"),enableSubTWCC:SV("SUBSCRIBE_TWCC","boolean"),enablePubRTX:SV("USE_PUB_RTX","boolean"),enableSubRTX:SV("USE_SUB_RTX","boolean"),enableSubSVC:_N("ENABLE_SVC")?_N("ENABLE_SVC_DEFAULT_CODECS"):Array.isArray(_N("SVC"))&&0!==_N("SVC").length?_N("SVC"):void 0,enableSvcExtended:_N("ENABLE_SVC")&&Array.isArray(_N("SVC_EXTENDED"))&&0!==_N("SVC_EXTENDED").length?_N("SVC_EXTENDED"):void 0},s)},join_ts:this.joinGatewayStartTime},e);return this.joinInfo.stringUid&&(c.string_uid=this.joinInfo.stringUid),this.joinInfo.aesmode&&this.joinInfo.aespassword&&(c.aes_mode=this.joinInfo.aesmode,_N("ENCRYPT_AES")?(c.aes_secret=this.joinInfo.aespassword,c.aes_encrypt=!0):c.aes_secret=this.joinInfo.aespassword,this.joinInfo.aessalt&&(c.aes_salt=this.joinInfo.aessalt)),t.addresses[this.signal.websocket.currentURLIndex]&&(c.ap_response.ticket=t.addresses[this.signal.websocket.currentURLIndex].ticket,delete t.addresses),void 0!==this.joinInfo.defaultVideoStream&&(c.default_video_stream=this.joinInfo.defaultVideoStream),c}getRejoinMessage(){if(!this.joinInfo)throw new tD(Ew.UNEXPECTED_ERROR,"can not generate rejoin message, no join info");return{session_id:this.joinInfo.sid,channel_name:this.joinInfo.cname,cid:this.joinInfo.cid,uid:this.joinInfo.uid,vid:Number(this.joinInfo.vid)}}handleSignalEvents(){this.signal.on(uU.WS_RECONNECT_CREATE_CONNECTION,(e=>{this.joinGatewayStartTime=Date.now()})),this.signal.on(uU.WS_RECONNECTING,(e=>{this.joinInfo&&eD.WebSocketQuit(this.joinInfo.sid,{lts:Date.now(),succ:-1,cname:this.joinInfo.cname,uid:this.joinInfo.uid,cid:this.joinInfo.cid,errorCode:e||Ww.NETWORK_ERROR}),this.joinInfo&&(this.state="RECONNECTING",eD.sessionInit(this.joinInfo.sid,{lts:(new Date).getTime(),extend:this.isSignalRecover?{recover:!0}:{rejoin:!0}
12271,cname:this.joinInfo.cname,appid:this.joinInfo.appId,mode:this.spec.mode,stringUid:this.joinInfo.stringUid,channelProfile:"live"===this.spec.mode?1:0,channelMode:0,lsid:this.joinInfo.sid,clientRole:"audience"===this.role?2:1,buildFormat:1}),this.isSignalRecover=!1,this.joinGatewayStartTime=Date.now())})),this.signal.on(uU.WS_CLOSED,(e=>{let t;switch(e){case Vw.LEAVE:t=Ww.LEAVE;break;case Vw.UID_BANNED:case Vw.IP_BANNED:case Vw.CHANNEL_BANNED:case Vw.SERVER_ERROR:t=Ww.SERVER_ERROR;break;case Vw.FALLBACK:t=Ww.FALLBACK;break;case Vw.LICENSE_MISSING:case Vw.LICENSE_EXPIRED:case Vw.LICENSE_MINUTES_EXCEEDED:case Vw.LICENSE_PERIOD_INVALID:case Vw.LICENSE_MULTIPLE_SDK_SERVICE:case Vw.LICENSE_ILLEGAL:case Vw.TOKEN_EXPIRE:t=e;break;default:t=Ww.NETWORK_ERROR}YN.debug("[".concat(this.store.clientId,"] [signal] websocket closed, reason: ").concat(t||"undefined -> "+Ww.NETWORK_ERROR)),this.joinInfo&&eD.WebSocketQuit(this.joinInfo.sid,{lts:Date.now(),succ:e===Vw.LEAVE?1:-1,cname:this.joinInfo.cname,uid:this.joinInfo.uid,cid:this.joinInfo.cid,errorCode:t}),this._disconnectedReason=e,e!==Vw.FALLBACK&&(this.state="DISCONNECTED"),this.reset()})),this.signal.on(uU.WS_CONNECTED,(()=>{if(this.updateTurnConfigFromSignal(),this.state="CONNECTED",this.joinInfo){if("audience"===this.role){const e=_N("CLIENT_ROLE_OPTIONS")||this._clientRoleOptions;e&&(e.level||e.delay)&&(YN.debug("[".concat(this.store.clientId,"] patch to send set client role, role: ").concat(this.role,", mode: ").concat(this.spec.mode,", level: ").concat(e.level,", delay: ").concat(e.delay)),this.setClientRole(this.role,e))}if(eD.joinGateway(this.joinInfo.sid,{lts:this.joinGatewayStartTime,succ:!0,ec:null,vid:this.joinInfo.vid,addr:this.signal.url,uid:this.joinInfo.uid,cid:this.joinInfo.cid,firstSuccess:this._isProactiveJoin,avoidJoinStartTime:this.store.avoidJoinStart,isProxy:!!this.joinInfo.proxyServer,signalChannel:"0",preload:this.joinInfo.preload,isABTestSuccess:this.store.isABTestSuccess}),this._isProactiveJoin=!1,this.joinInfo.useLocalAccessPoint&&1===this.joinInfo.setLocalAPVersion){const e=this.signal.url&&this.signal.url.match(/wss\:\/\/([^:]+):(\d+)/);if(!e)return void YN.error("[".concat(this.store.clientId,"] set local access point after joined failed: ").concat(e));pN("EVENT_REPORT_DOMAIN",e[1]),pN("EVENT_REPORT_BACKUP_DOMAIN",e[1]),pN("LOG_UPLOAD_SERVER","".concat(e[1],":6444"))}}})),this.signal.on(_U.ON_UPLINK_STATS,(e=>{this._statsCollector.updateUplinkStats(e)})),this.signal.on(uU.REQUEST_RECOVER,((e,t,i)=>{if(!this.joinInfo)return i(new tD(Ew.UNEXPECTED_ERROR,"gateway: can not recover, no join info"));e&&(this.joinInfo.multiIP=e,this.hasChangeBGPAddress=!0),this.isSignalRecover=!0,Yw(this,LU.REQUEST_NEW_GATEWAY_LIST).then(t).catch(i)})),this.signal.on(uU.REQUEST_JOIN_INFO,(async(e,t,i)=>{var n;if(this.updateTurnConfigFromSignal(),this.store.useP2P)return void e(this.getJoinMessage({ortc:{}}));const r=eO(null===(n=this.joinInfo)||void 0===n?void 0:n.turnServer);if(_N("NEW_TURN_MODE")&&r){let e=r.servers,t=r.serversFromGateway;const i=this.signal.currentURLIndex;if(e.length>0){e=[e[i%e.length]],r.servers=e}Array.isArray(t)&&t.length>0&&(t=[t[0]],r.serversFromGateway=t),YN.debug("[".concat(this.store.clientId,"] use single turn, use turn server index: ").concat(i))}const{iceParameters:o,dtlsParameters:s,rtpCapabilities:a}=await Yw(this,LU.REQUEST_P2P_CONNECTION_PARAMS,{turnServer:r});try{e(this.getJoinMessage({ortc:{iceParameters:o,dtlsParameters:s,rtpCapabilities:a,version:"2"}}))}catch(e){t(e)}})),this.signal.on(uU.REQUEST_REJOIN_INFO,(e=>{e(this.getRejoinMessage())})),this.signal.on(uU.REPORT_JOIN_GATEWAY,((e,t)=>{if(!this.joinInfo)return;let i,n="";var r;e instanceof tD?(i=(null===(r=e.data)||void 0===r?void 0:r.desc)||e.code,n=e.message):i=e;eD.joinGateway(this.joinInfo.sid,{lts:this.joinGatewayStartTime,succ:!1,ec:i,errorMsg:n,addr:t,uid:this.joinInfo.uid,cid:this.joinInfo.cid,firstSuccess:this._isProactiveJoin,avoidJoinStartTime:this.store.avoidJoinStart,isProxy:!!this.joinInfo.proxyServer,signalChannel:"0",preload:this.joinInfo.preload})})),this.signal.on(uU.IS_P2P_DISCONNECTED,(e=>{e(Xw(this,LU.IS_P2P_DISCONNECTED))})),this.signal.on(uU.DISCONNECT_P2P,(()=>
12271{this.emit(LU.DISCONNECT_P2P)})),this.signal.on(uU.REQUEST_SUCCESS,(()=>{this._signalTimeout=!1})),this.signal.on(uU.REQUEST_TIMEOUT,(()=>{this._signalTimeout=!0})),this.signal.on(uU.JOIN_RESPONSE,(e=>{const t=this.getCurrentGatewayAddress();this.emit(LU.JOIN_RESPONSE,e,t)})),this.signal.on(uU.PRE_CONNECT_PC,(async()=>{if(this.joinInfo){this.updateTurnConfigFromSignal();const e=this.getCurrentGatewayAddress(),t=_N("FINGERPRINT")||this.joinInfo.apResponse.addresses[this.signal.currentURLIndex].fingerprint;if(e&&t){const i=Zx(e);this.emit(LU.PRE_CONNECT_PC,{candidates:i,fingerprint:t})}}})),this.signal.on(uU.RECOVER_NOTIFICATION,(e=>{this.joinInfo&&"string"==typeof _N("AP_REQUEST_DETAIL")&&(this.joinInfo.apRequestDetail="".concat(_N("AP_REQUEST_DETAIL"),";").concat(e))}))}async tryUnsubBeforeResub(e,t){try{await this.signal.request(hU.UNSUBSCRIBE,{p2p_id:this.store.p2pId,stream_id:e,ortc:[t]},!0)}catch(e){throw YN.warning("[".concat(this.store.clientId,"] tryUnsubBeforeResub warning"),e),e}}async tryUnsubDataChannelBeforeResub(e,t){try{await this.signal.request(hU.UNSUBSCRIBE,{stream_id:t.id},!0)}catch(e){throw YN.warning("unsubscribe datachannel warning",e),e}}async tryUnpubBeforeRepub(e,t){try{await this.signal.request(hU.UNPUBLISH,{stream_id:e,ortc:t},!0)}catch(e){throw YN.warning("[".concat(this.store.clientId,"] tryUnpubBeforeRepub warning: "),e),e}}async tryUnpubDataChannelBeforeRepub(e,t){try{await this.signal.request(hU.UNPUBLISH_DATASTREAM,{channnel_id:t.channelId},!0)}catch(e){throw YN.warning("unpublish datastream warning: ",e),e}}async tryMassUnsubBeforeResub(e){const t={users:e.map((e=>({stream_id:e.stream_id,stream_type:e.stream_type})))};try{await this.signal.request(hU.UNSUBSCRIBE_STREAMS,t,!0)}catch(e){throw YN.warning("[".concat(this.store.clientId,"] tryMassUnsubBeforeResub warning"),e),e}}async muteLocal(e,t){const i={action:e.find((e=>e.stream_type===PU.Audio))?"mute_local_audio":"mute_local_video",p2p_id:this.store.p2pId,ortc:e,stream_id:t};try{await this.signal.request(hU.CONTROL,i,!0,!0)}catch(e){throw YN.warning("[".concat(this.store.clientId,"] gateway muteLocal warning: "),e),e}}async unmuteLocal(e,t){const i={action:e.find((e=>e.stream_type===PU.Audio))?"unmute_local_audio":"unmute_local_video",p2p_id:this.store.p2pId,ortc:e,stream_id:t};try{await this.signal.request(hU.CONTROL,i,!0,!0)}catch(e){throw YN.warning("[".concat(this.store.clientId,"] gateway unmuteLocal warning: "),e),e}}async muteRemote(e,t){const i={action:e===HU.AUDIO?"mute_remote_audio":"mute_remote_video",p2p_id:this.store.p2pId,stream_id:t};try{await this.signal.request(hU.CONTROL,i,!0,!0)}catch(e){throw YN.warning("[".concat(this.store.clientId,"] gateway muteRemote warning: "),e),e}}async unmuteRemote(e,t){const i={action:e===HU.AUDIO?"unmute_remote_audio":"unmute_remote_video",p2p_id:this.store.p2pId,stream_id:t};try{await this.signal.request(hU.CONTROL,i,!0,!0)}catch(e){throw YN.warning("[".concat(this.store.clientId,"] gateway unmuteRemote warning: "),e),e}}uploadWRTCStats(e){this.signal.uploadWRTCStats(e)}upload(e,t){this.signal.upload(e,t)}getSignalRTT(){return this.signal.rtt}async restartICE(e){const t={p2p_id:this.store.p2pId,stream_id:this.store.uid,ortc:e};try{return await this.signal.request(hU.RESTART_ICE,t,!0)}catch(e){throw YN.warning("[".concat(this.store.clientId,"] P2PChannel.restartICE warning: "),e),e}}reconnect(e,t){"CONNECTED"===this.state&&this.signal.reconnect(e||void 0,t||Ww.P2P_FAILED)}getCurrentGatewayAddress(){var e,t;if(!_N("GATEWAY_WSS_ADDRESS"))return _N("USE_CANDIDATE_FROM_AP_DETAIL")&&null!==(e=this.joinInfo)&&void 0!==e&&e.apGatewayAddress?(YN.debug("[".concat(this.store.clientId,"] use candidate from ap detail, ").concat(JSON.stringify(this.joinInfo.apGatewayAddress))),this.joinInfo.apGatewayAddress):null!==(t=this.joinInfo)&&void 0!==t&&t.gatewayAddrs?this.joinInfo.gatewayAddrs[this.signal.currentURLIndex]:void 0}async setPublishAudioFilterEnabled(e){await this.signal.request(hU.SET_PARAMETER,{enablePublishAudioFilter:e})}}let NV=0,DV=0;function PV(e,t,i,n){return new Wh(((r,o)=>{t.timeout=t.timeout||_N("HTTP_CONNECT_TIMEOUT"),t.responseType=t.responseType||"json",t.data&&!i?(t.data=JSON.stringify(t.data),NV+=cO(t.data)):i&&(t.data.size?NV+=t.data.size:t.data instanceof FormData?NV+=dO(t.data):NV+=cO(JSON.stringify(t.data))),t.headers=t.headers||{},t.headers["Content-Type"]=t.headers["Content-Type"]||"application/json",t.method="POST",t.url=e,Ab.request(t).then((e=>{"string"==typeof e.data?DV+=cO(e.data):e.data instanceof ArrayBuffer||e.data instanceof Uint8Array?DV+=e.data.byteLength:DV+=cO(JSON.stringify(e.data)),n&&r({data:e.data,headers:e.headers}),r(e.data)})).catch((e=>{Ab.isCancel(e)?o(new tD(Ew.OPERATION_ABORTED,"cancel token canceled")):"ECONNABORTED"===e.code?o(new tD(Ew.NETWORK_TIMEOUT,e.message)):e.response?o(new tD(Ew.NETWORK_RESPONSE_E
vendor: 9,958 bytes, lines 12271-12272
12271RROR,e.response.status)):o(new tD(Ew.NETWORK_ERROR,e.message))}))}))} 12272/*! formdata-polyfill. MIT License. Jimmy W?rting <https://jimmy.warting.se/opensource> */!function(){var e;function i(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}var n="function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,i){return e==Array.prototype||e==Object.prototype||(e[t]=i.value),e};var r,o=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof t&&t];for(var i=0;i<e.length;++i){var n=e[i];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")}(this);function s(e,t){if(t)e:{var i=o;e=e.split(".");for(var r=0;r<e.length-1;r++){var s=e[r];if(!(s in i))break e;i=i[s]}(t=t(r=i[e=e[e.length-1]]))!=r&&null!=t&&n(i,e,{configurable:!0,writable:!0,value:t})}}function a(e){return(e={next:e})[Symbol.iterator]=function(){return this},e}function c(e){var t="undefined"!=typeof Symbol&&Symbol.iterator&&e[Symbol.iterator];return t?t.call(e):{next:i(e)}}if(s("Symbol",(function(e){function t(e,t){this.A=e,n(this,"description",{configurable:!0,writable:!0,value:t})}if(e)return e;t.prototype.toString=function(){return this.A};var i="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",r=0;return function e(n){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new t(i+(n||"")+"_"+r++,n)}})),s("Symbol.iterator",(function(e){if(e)return e;e=Symbol("Symbol.iterator");for(var t="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),r=0;r<t.length;r++){var s=o[t[r]];"function"==typeof s&&"function"!=typeof s.prototype[e]&&n(s.prototype,e,{configurable:!0,writable:!0,value:function(){return a(i(this))}})}return e})),"function"==typeof Object.setPrototypeOf)r=Object.setPrototypeOf;else{var d;e:{var l={};try{l.__proto__={a:!0},d=l.a;break e}catch(e){}d=!1}r=d?function(e,t){if(e.__proto__=t,e.__proto__!==t)throw new TypeError(e+" is not extensible");return e}:null}var u=r;function h(){this.m=!1,this.j=null,this.v=void 0,this.h=1,this.u=this.C=0,this.l=null}function p(e){if(e.m)throw new TypeError("Generator is already running");e.m=!0}function _(e,t){return e.h=3,{value:t}}function E(e){this.g=new h,this.G=e}function m(e,t,i,n){try{var r=t.call(e.g.j,i);if(!(r instanceof Object))throw new TypeError("Iterator result "+r+" is not an object");if(!r.done)return e.g.m=!1,r;var o=r.value}catch(t){return e.g.j=null,e.g.s(t),f(e)}return e.g.j=null,n.call(e.g,o),f(e)}function f(e){for(;e.g.h;)try{var t=e.G(e.g);if(t)return e.g.m=!1,{value:t.value,done:!1}}catch(t){e.g.v=void 0,e.g.s(t)}if(e.g.m=!1,e.g.l){if(t=e.g.l,e.g.l=null,t.F)throw t.D;return{value:t.return,done:!0}}return{value:void 0,done:!0}}function T(e){this.next=function(t){return e.o(t)},this.throw=function(t){return e.s(t)},this.return=function(t){return function(e,t){p(e.g);var i=e.g.j;return i?m(e,"return"in i?i.return:function(e){return{value:e,done:!0}},t,e.g.return):(e.g.return(t),f(e))}(e,t)},this[Symbol.iterator]=function(){return this}}function S(e,t){return t=new T(new E(t)),u&&e.prototype&&u(t,e.prototype),t}if(h.prototype.o=function(e){this.v=e},h.prototype.s=function(e){this.l={D:e,F:!0},this.h=this.C||this.u},h.prototype.return=function(e){this.l={return:e},this.h=this.u},E.prototype.o=function(e){return p(this.g),this.g.j?m(this,this.g.j.next,e,this.g.o):(this.g.o(e),f(this))},E.prototype.s=function(e){return p(this.g),this.g.j?m(this,this.g.j.throw,e,this.g.o):(this.g.s(e),f(this))},s("Array.prototype.entries",(function(e){return e||function(){return function(e,t){e instanceof String&&(e+="");var i=0,n=!1,r={next:function(){if(!n&&i<e.length){var r=i++;return{value:t(r,e[r]),done:!1}}return n=!0,{done:!0,value:void 0}}};return r[Symbol.iterator]=function(){return r},r}(this,(function(e,t){return[e,t]}))}})),"undefined"!=typeof Blob&&("undefined"==typeof FormData||!FormData.prototype.keys)){var g=function(e,t){for(var i=0;i<e.length;i++)t(e[i])},R=function(e){return e.replace(/\r?\n|\r/g,"\r\n")},v=function(e,t,i){return t instanceof Blob?(i=void 0!==i?String(i+""):"string"==typeof t.name?t.name:"blob",t.name===i&&"[object Blob]"!==Object.prototype.toString.call(t)||(t=new File([t],i)),[String(e),t]):[String(e),String(t)]},C=function(e,t){if(e.length<t)throw new TypeError(t+" argument required, but only "+e.length+" present.")},I="object"==typeof globalThis?globalThis:"object"==typeof window?window:"object"==typeof self?self:this,y=I.FormData,A=I.XMLHttpRequest&&I.XMLHttpRequest.prototype.send,b=I.Request&&I.fetch,w=I.navigator&&I.navigator.sendBeacon,O=I.Element&&I.Element.prototype,N=I.Symbol&&Symbol.toStringTag;N&&(Blob.prototype[N]||(Blob.prototype[N]="Blob"),"File"in I&&!File.prototype[N]&&(File.prototype[N]="File"));try{new File([],"")}catch(e){I.File=function(e,t,i){return e=new Blob(e,i||{}),Object.defineProperties(e,{name:{value:t},lastModified:{value:+(i&&void 0!==i.lastModified?new Date(i.lastModified):new Date)},toString:{value:function(){return"[object File]"}}}),N&&Object.defineProperty(e,N,{value:"File"}),e}}var D=function(e){return e.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22")},P=function(e){this.i=[];var t=this;e&&g(e.elements,(function(e){if(e.name&&!e.disabled&&"submit"!==e.type&&"button"!==e.type&&!e.matches("form fieldset[disabled] *"))if("file"===e.type){var i=e.files&&e.files.length?e.files:[new File([],"",{type:"application/octet-stream"})];g(i,(function(i){t.append(e.name,i)}))}else"select-multiple"===e.type||"select-one"===e.type?g(e.options,(function(i){!i.disabled&&i.selected&&t.append(e.name,i.value)})):"checkbox"===e.type||"radio"===e.type?e.checked&&t.append(e.name,e.value):(i="textarea"===e.type?R(e.value):e.value,t.append(e.name,i))}))};if((e=P.prototype).append=function(e,t,i){C(arguments,2),this.i.push(v(e,t,i))},e.delete=function(e){C(arguments,1);var t=[];e=String(e),g(this.i,(function(i){i[0]!==e&&t.push(i)})),this.i=t},e.entries=function e(){var t,i=this;return S(e,(function(e){if(1==e.h&&(t=0),3!=e.h)return t<i.i.length?e=_(e,i.i[t]):(e.h=0,e=void 0),e;t++,e.h=2}))},e.forEach=function(e,t){C(arguments,1);for(var i=c(this),n=i.next();!n.done;n=i.next()){var r=c(n.value);n=r.next().value,r=r.next().value,e.call(t,r,n,this)}},e.get=function(e){C(arguments,1);var t=this.i;e=String(e);for(var i=0;i<t.length;i++)if(t[i][0]===e)return t[i][1];return null},e.getAll=function(e){C(arguments,1);var t=[];return e=String(e),g(this.i,(function(i){i[0]===e&&t.push(i[1])})),t},e.has=function(e){C(arguments,1),e=String(e);for(var t=0;t<this.i.length;t++)if(this.i[t][0]===e)return!0;return!1},e.keys=function e(){var t,i,n,r,o=this;return S(e,(function(e){if(1==e.h&&(t=c(o),i=t.next()),3!=e.h)return i.done?void(e.h=0):(n=i.value,r=c(n),_(e,r.next().value));i=t.next(),e.h=2}))},e.set=function(e,t,i){C(arguments,2),e=String(e);var n=[],r=v(e,t,i),o=!0;g(this.i,(function(t){t[0]===e?o&&(o=!n.push(r)):n.push(t)})),o&&n.push(r),this.i=n},e.values=function e(){var t,i,n,r,o=this;return S(e,(function(e){if(1==e.h&&(t=c(o),i=t.next()),3!=e.h)return i.done?void(e.h=0):(n=i.value,(r=c(n)).next(),_(e,r.next().value));i=t.next(),e.h=2}))},P.prototype._asNative=function(){for(var e=new y,t=c(this),i=t.next();!i.done;i=t.next()){var n=c(i.value);i=n.next().value,n=n.next().value,e.append(i,n)}return e},P.prototype._blob=function(){var e="----formdata-polyfill-"+Math.random(),t=[],i="--"+e+'\r\nContent-Disposition: form-data; name="';return this.forEach((function(e,n){return"string"==typeof e?t.push(i+D(R(n))+'"\r\n\r\n'+R(e)+"\r\n"):t.push(i+D(R(n))+'"; filename="'+D(e.name)+'"\r\nContent-Type: '+(e.type||"application/octet-stream")+"\r\n\r\n",e,"\r\n")})),t.push("--"+e+"--"),new Blob(t,{type:"multipart/form-data; boundary="+e})},P.prototype[Symbol.iterator]=function(){return this.entries()},P.prototype.toString=function(){return"[object FormData]"},O&&!O.matches&&(O.matches=O.matchesSelector||O.mozMatchesSelector||O.msMatchesSelector||O.oMatchesSelector||O.webkitMatchesSelector||function(e){for(var t=(e=(this.document||this.ownerDocument).querySelectorAll(e)).length;0<=--t&&e.item(t)!==this;);return-1<t}),N&&(P.prototype[N]="FormData"),A){var L=I.XMLHttpRequest.prototype.setRequestHeader;I.XMLHttpRequest.prototype.setRequestHeader=function(e,t){L.call(this,e,t),"content-type"===e.toLowerCase()&&(this.B=!0)},I.XMLHttpRequest.prototype.send=function(e){e instanceof P?(e=e._blob(),this.B||this.setRequestHeader("Content-Type",e.type),A.call(this,e)):A.call(this,e)}}b&&(I.fetch=function(e,t){return t&&t.body&&t.body instanceof P&&(t.body=t.body._blob()),b.call(this,e,t)}),w&&(I.navigator.sendBeacon=function(e,t){return t instanceof P&&(t=t._asNative()),w.call(this,e,t)}),I.FormData=P}}();const LV=()=>{const e=_N("AREAS");0===e.length&&e.push(UU.GLOBAL);return Xn(e).call(e,((e,t,i)=>{const n=kV(t);return n?0===i?n:"".concat(e,",").concat(n):e}),"")},kV=e=>e===UU.OVERSEA?"".concat(VU.ASIA,",").concat(VU.EUROPE,",").concat(VU.AFRICA,",").concat(VU.NORTH_AMERICA,",").concat(VU.SOUTH_AMERICA,",").concat(VU.OCEANIA):VU[e],MV=e=>{const t={CODE:"",WEBCS_DOMAIN:[],WEBCS_DOMAIN_BACKUP_LIST:[],PROXY_CS:[],CDS_AP:[],ACCOUNT_REGISTER:[],UAP_AP:[],EVENT_REPORT_DOMAIN:[],EVENT_REPORT_BACKUP_DOMAIN:[],LOG_UPLOAD_SERVER:[],PROXY_SERVER_TYPE3:[]};return e.map((e=>{const i=FU[e],n=Object.keys(i);n&&n.map((e=>{"CODE"!==e&&(t[e]=t[e].concat(i[e]))}))})),t},UV={GLOBAL:{ASIA:[UU.CHINA,UU.JAPAN,UU.INDIA,UU.KOREA,UU.HKMC],EUROPE:[],NORTH_AMERICA:[UU.US],SOUTH_AMERICA:[],OCEANIA:[],AFRICA:[]}},xV=Object.keys(UV[UU.GLOBAL]),VV=[UU.CHINA,UU.NORTH_AMERICA,UU.EUROPE,UU.ASIA,UU.JAPAN,UU.INDIA,UU.OCEANIA,UU.SOUTH_AMERICA,UU.AFRICA,UU.KOREA,UU.HKMC,UU.US],FV=function(e,t){let i=[];if(Dn(e).call(e,UU.GLOBAL)){const o=[UU.GLOBAL,UU.OVERSEA],s=Object.keys(FU);if(t===UU.GLOBAL)throw new tD(Ew.INVALID_PARAMS,"GLOBAL is an invali
12272d excludedArea value");if(t===UU.CHINA)i=[UU.OVERSEA];else if(r=t,Dn(xV).call(xV,r)){const e=(n=t,UV[UU.GLOBAL][n]||[]),r=[...o,t,...e];i=s.filter((e=>!Dn(r).call(r,e)))}else if(function(e){let t=!1;return xV.forEach((i=>{var n;Dn(n=UV[UU.GLOBAL][i]).call(n,e)&&(t=!0)})),t}(t)){const e=function(e){let t;return xV.forEach((i=>{var n;Dn(n=UV[UU.GLOBAL][i]).call(n,e)&&(t=i)})),t}(t),n=[...o,e,t];i=s.filter((e=>!Dn(n).call(n,e)))}else i=e;i=function(e){const t=[];return VV.forEach((i=>{Dn(e).call(e,i)&&t.push(i)})),t.concat(e.filter((e=>!Dn(VV).call(VV,e))))}(i)}else i=e;var n,r;return i};function BV(e){var t,i;if(!e&&Dn(t=_N("AREAS")).call(t,UU.EXTENSIONS))return YN.debug("update area from ap : reset"),void jV(mM,!0);if(!Dn(i=_N("AREAS")).call(i,UU.GLOBAL)||!e)return;let n=FU.EXTENSIONS;n&&(n={CODE:kV(UU.EXTENSIONS),WEBCS_DOMAIN:["ap-web-1-".concat(e,".agora.io")],WEBCS_DOMAIN_BACKUP_LIST:["ap-web-2-".concat(e,".ap.sd-rtn.com")],PROXY_CS:["proxy-ap-web-".concat(e,".agora.io")],CDS_AP:["cds-ap-web-1-".concat(e,".agora.io"),"cds-ap-web-2-".concat(e,".ap.sd-rtn.com")],ACCOUNT_REGISTER:["sua-ap-web-1-".concat(e,".agora.io"),"sua-ap-web-2-".concat(e,".ap.sd-rtn.com")],UAP_AP:["uap-ap-web-1-".concat(e,".agora.io"),"uap-ap-web-2-".concat(e,".ap.sd-rtn.com")],EVENT_REPORT_DOMAIN:["statscollector-1-".concat(e,".agora.io")],EVENT_REPORT_BACKUP_DOMAIN:["statscollector-2-".concat(e,".agora.io")],LOG_UPLOAD_SERVER:["logservice-".concat(e,".agora.io")],PROXY_SERVER_TYPE3:["webrtc-cloud-proxy-".concat(e,".agora.io")]},YN.debug("update area from ap success: ".concat(e,",config is "),n),pN("AREAS",[UU.EXTENSIONS],!0),Object.keys(n).map((e=>{if("LOG_UPLOAD_SERVER"===e||"EVENT_REPORT_DOMAIN"===e||"EVENT_REPORT_BACKUP_DOMAIN"===e||"PROXY_SERVER_TYPE3"===e){pN(e,n[e][0])}else pN(e,n[e])})))}function jV(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=eD.reportApiInvoke(null,{name:kw.SET_AREA,options:e,tag:Mw.TRACER});try{let n=[];if("string"==typeof e&&(n=[e]),Array.isArray(e)&&(e.forEach((e=>{if(!Dn(xU).call(xU,e))throw new tD(Ew.INVALID_PARAMS,"invalid area code")})),n=e),"[object Object]"===Object.prototype.toString.call(e)){const{areaCode:t,excludedArea:i}=e;if(!t)throw new tD(Ew.INVALID_PARAMS,"area code is needed");let r=t;"string"==typeof t&&(r=[t]),n=i?FV(r,i):r}if(!t){if(mN.AREAS){const e=new tD(Ew.PROHIBITED_OPERATION,"setArea is prohibited because of config-distribute");return i.onError(e),void YN.warning("setArea is prohibited because of config-distribute")}if(Dn(n).call(n,UU.GLOBAL)&&_N("AREAS")===UU.EXTENSIONS){const e=new tD(Ew.PROHIBITED_OPERATION,"setArea is prohibited because of ap extensions");return i.onError(e),void YN.warning("setArea is prohibited because of ap extensions")}}pN("AREAS",n,t);const r=MV(n);Object.keys(r).map((e=>{if("LOG_UPLOAD_SERVER"===e||"EVENT_REPORT_DOMAIN"===e||"EVENT_REPORT_BACKUP_DOMAIN"===e||"PROXY_SERVER_TYPE3"===e){pN(e,r[e][0])}else pN(e,r[e])})),YN.debug("set area success:",n.join(","))}catch(e){throw i.onError(e),e}i.onSuccess()}function GV(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function WV(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?GV(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):GV(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}let HV=1;function KV(e,t,i,n,r){HV+=1;const o={sid:i.sid,command:"convergeAllocateEdge",uid:"666",appId:i.appId,ts:Math.floor(Date.now()/1e3),seq:HV,requestId:HV,version:rN,cname:i.cname},s={service_name:t,json_body:JSON.stringify(o)};let a,c,d=e[0];return wO((async()=>{a=Date.now();const e=await PV(d,{data:s,cancelToken:n,headers:{"X-Packet-Service-Type":"0","X-Packet-URI":"61"}});if(c=Date.now()-a,0!==e.code){const t=new tD(Ew.UNEXPECTED_RESPONSE,"live streaming ap error, code"+e.code,{retry:!0,responseTime:c});throw YN.error(t.toString()),t}const i=JSON.parse(e.json_body);
12272if(200!==i.code){const e=new tD(Ew.UNEXPECTED_RESPONSE,"live streaming app center error, code: ".concat(i.code,", reason: ").concat(i.reason),{code:i.code,responseTime:c});throw YN.error(e.toString()),e}if(!i.servers||0===i.servers.length){const e=new tD(Ew.UNEXPECTED_RESPONSE,"live streaming app center empty server",{code:i.code,responseTime:c});throw YN.error(e.toString()),e}const r=function(e,t){return{addressList:e.servers.map((e=>"wss://".concat(e.address.replace(/\./g,"-"),".").concat(_N("WORKER_DOMAIN"),":").concat(e.wss,"?serviceName=").concat(encodeURIComponent(t)))),workerToken:e.workerToken,vid:e.vid}}(i,t);return _N("LIVE_STREAMING_ADDRESS")&&(r.addressList=_N("LIVE_STREAMING_ADDRESS")instanceof Array?_N("LIVE_STREAMING_ADDRESS"):[_N("LIVE_STREAMING_ADDRESS")]),WV(WV({},r),{},{responseTime:c})}),((n,r)=>(eD.apworkerEvent(i.sid,{success:!0,sc:200,serviceName:t,responseDetail:JSON.stringify(n.addressList),firstSuccess:0===r,responseTime:c,serverIp:e[r%e.length]}),!1)),((n,r)=>(eD.apworkerEvent(i.sid,{success:!1,sc:n.data&&n.data.code||200,serviceName:t,responseTime:c,serverIp:e[r%e.length]}),!!(n.code!==Ew.OPERATION_ABORTED&&n.code!==Ew.UNEXPECTED_RESPONSE||n.data&&n.data.retry)&&(d=e[(r+1)%e.length],!0))),r)}let YV=1;function qV(e,t,i,n){let{url:r,areaCode:o}=e;const{clientId:s,sid:a}=t,c=Date.now();let d;const l=t.role,[u,h]=ZV(t,o,[wx.CHOOSE_SERVER]);let p=Jw.networkState;return wO((async()=>{p&&Jw.networkState===Hw.OFFLINE&&Jw.onlineWaiter&&await Wh.race([Jw.onlineWaiter,uO(n&&n.maxRetryTimeout||AO.maxRetryTimeout)]),p=Jw.networkState;const{data:e,headers:o}=await PV(r,{data:u,cancelToken:i,headers:{"Content-Type":"multipart/form-data;"}},!0,!0);d="1"===o.http3?1:-1,eD.reportResourceTiming(r,a),XV(e,r,t,c,[wx.CHOOSE_SERVER],d);const s=Ux(e,wx.CHOOSE_SERVER);return JV(s),Px(s,r)}),(e=>(e&&eD.joinChooseServer(a,{role:l,lts:c,succ:!0,csAddr:r,opid:h,serverList:e.gatewayAddrs.map((e=>e.address)),ec:null,cid:e.cid.toString(),uid:e.uid.toString(),csIp:e.csIp,unilbsServerIds:[wx.CHOOSE_SERVER].toString(),isHttp3:d,corssRegionTagReq:t.apRequestDetail,corssRegionTagRes:e.res.detail&&e.res.detail[38]}),!1)),(e=>e.code!==Ew.OPERATION_ABORTED&&(e.code===Ew.CAN_NOT_GET_GATEWAY_SERVER?e.data.retry:(eD.joinChooseServer(a,{role:l,lts:c,succ:!1,csAddr:r,serverList:null,opid:h,ec:e.code,csIp:e.data&&e.data.csIp,unilbsServerIds:[wx.CHOOSE_SERVER].toString(),extend:JSON.stringify({networkState:p}),isHttp3:d,corssRegionTagReq:t.apRequestDetail}),YN.warning("[".concat(s||"sid-".concat(a.slice(0,6)),"] Choose server network error, retry"),e),!0))),n)}function zV(e,t,i,n){let r,{url:o,areaCode:s,serviceIds:a}=e;const c=Date.now(),d=t.role,[l,u]=ZV(t,s,a);let h;return wO((async()=>{h&&Jw.networkState===Hw.OFFLINE&&Jw.onlineWaiter&&await Wh.race([Jw.onlineWaiter,uO(n&&n.maxRetryTimeout||AO.maxRetryTimeout)]),h=Jw.networkState;const{data:e,headers:s}=await PV(o,{data:l,cancelToken:i,headers:{"Content-Type":"multipart/form-data;"}},!0,!0);r="1"===s.http3?1:-1,eD.reportResourceTiming(o,t.sid),XV(e,o,t,c,a,r);const d=Ux(e,wx.CHOOSE_SERVER),u=Ux(e,"proxy5"===t.cloudProxyServer?wx.CLOUD_PROXY_5:"proxy3"===t.cloudProxyServer||"proxy4"===t.cloudProxyServer?wx.CLOUD_PROXY:wx.CLOUD_PROXY_FALLBACK);return JV(d),{gatewayInfo:Px(d,o),proxyInfo:u,url:o}}),(e=>(e.gatewayInfo&&eD.joinChooseServer(t.sid,{role:d,lts:c,succ:!0,csAddr:o,serverList:e.gatewayInfo.gatewayAddrs.map((e=>e.address)),ec:null,opid:u,cid:e.gatewayInfo.cid.toString(),uid:e.gatewayInfo.uid.toString(),csIp:e.gatewayInfo.csIp,unilbsServerIds:a.toString(),isHttp3:r,corssRegionTagReq:t.apRequestDetail,corssRegionTagRes:e.gatewayInfo.res.detail&&e.gatewayInfo.res.detail[38]}),e.proxyInfo&&eD.joinWebProxyAP(t.sid,{lts:c,sucess:1,apServerAddr:o,turnServerAddrList:e.proxyInfo.addresses.map((e=>e.ip)).join(","),errorCode:null,eventType:t.cloudProxyServer,unilbsServerIds:a.toString()}),!1)),(e=>e.code!==Ew.OPERATION_ABORTED&&(e.code===Ew.CAN_NOT_GET_GATEWAY_SERVER?e.data.retry:(eD.joinWebProxyAP(t.sid,{lts:c,sucess:0,apServerAddr:o,turnServerAddrList:null,errorCode:e.code,eventType:t.cloudProxyServer,unilbsServerIds:a.toString(),extend:JSON.stringify({networkState:h})}),YN.warning("[".concat(t.clientId,"] multi unilbs network error, retry"),e),!0))),n)}const XV=(e,t,i,n,r,o)=>{const{sid:s,clientId:a,cloudProxyServer:c}=i,d=[],l=a=>{4096===a.flag?eD.joinChooseServer(s,{role:i.role,lts:n,succ:!1,csAddr:t,opid:e.opid,serverList:null,ec:a.error.message,csIp:a.error.data&&a.error.data.csIp,unilbsServerIds:r.toString(),isHttp3:o,corssRegionTagReq:i.apRequestDetail}
vendor: 11,882 bytes, line 12272
12272):1048576!==a.flag&&4194304!==a.flag&&4194310!==a.flag||eD.joinWebProxyAP(s,{lts:n,sucess:0,apServerAddr:t,turnServerAddrList:null,errorCode:a.error.code,eventType:c,unilbsServerIds:r.toString()})};if(e.response_body.forEach((t=>{const i=t.buffer.code;if(23===t.uri&&0===i&&!t.buffer.edges_services)if(4194310===t.buffer.flag)YN.warning("no edge services in ap response of proxy fallback, will not set proxy in iceServers"),t.buffer.edges_services=[];else{const i={error:new tD(Ew.CAN_NOT_GET_GATEWAY_SERVER,"no edge services in ap response",{retry:!0,csIp:e.detail[502]}),flag:t.buffer.flag};d.push(i),l(i)}if(0!==i){const n=lx(i),r={error:new tD(Ew.CAN_NOT_GET_GATEWAY_SERVER,n.desc,{desc:n.desc,retry:n.retry,csIp:e.detail[502]}),flag:t.buffer.flag};4194310===t.buffer.flag?YN.warning(r.error.toString()):d.push(r),l(r)}})),d.length)throw YN.warning("[".concat(a||"sid-".concat(s.slice(0,6)),"] multi unilbs ").concat(t," failed, ").concat(d.map((e=>"flag: ".concat(e.flag,", message: ").concat(e.error.message,", retry: ").concat(e.error.data.retry))).join(" | "))),new tD(Ew.CAN_NOT_GET_GATEWAY_SERVER,d.map((e=>"flag: ".concat(e.flag,", message: ").concat(e.error.message))).join(" | "),{retry:!!d.find((e=>e.error.data.retry)),csIp:e.detail[502],desc:[...new Set(d.map((e=>{var t;return null==e||null===(t=e.error)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.desc})).filter((e=>!!e)))]})},JV=e=>{var t,i,n,r;if(e.addresses&&0===e.addresses.length&&0===e.code)throw new tD(Ew.CAN_NOT_GET_GATEWAY_SERVER,"void gateway address",{retry:!0,csIp:e.detail&&e.detail[502]});_N("AP_AREA")&&(null!==(n=e.detail)&&void 0!==n&&n[23]&&"string"==typeof(null===(r=e.detail)||void 0===r?void 0:r[23])?BV(e.detail[23].toLowerCase()):BV());if(null!==(t=e.detail)&&void 0!==t&&t[19]&&"string"==typeof(null===(i=e.detail)||void 0===i?void 0:i[19])){const t=e.detail[19],i=null==t?void 0:t.split(";");for(let t=0;t<i.length;t++){var o;const n=OT(o=i[t]).call(o);e.addresses[t]&&i&&(e.addresses[t].fingerprint=n)}}if(_N("GATEWAY_ADDRESS")&&_N("GATEWAY_ADDRESS").length>0){YN.debug("assign gateway address to",_N("GATEWAY_ADDRESS"));const t=_N("GATEWAY_ADDRESS").map((t=>{var i,n;const r=null!==(i=null===(n=e.addresses.find((e=>e.ip===t.ip&&e.port===t.port)))||void 0===n?void 0:n.fingerprint)&&void 0!==i?i:"";return{ip:t.ip,port:t.port,ticket:e.addresses[0]&&e.addresses[0].ticket,fingerprint:r}}));e.addresses=t}},QV=(e,t)=>{if(e.response_body&&e.response_body.length){const t=e.response_body[0];if(0!==t.buffer.code){const e=lx(t.buffer.code);throw new tD(Ew.UPDATE_TICKET_FAILED,"[".concat(t.buffer.code,"]: ").concat(e.desc),{retry:e.retry})}return t.buffer.ticket}throw YN.debug("update ticket request received ap response without response body:",t),new tD(Ew.UPDATE_TICKET_FAILED,"cannot find response body from ap response",{retry:!1})},ZV=(e,t,i)=>{const n=Math.floor(Math.random()*10**12),r="host"===e.role?"1":"audience"===e.role?"2":void 0,o={appid:e.appId,client_ts:Date.now(),opid:n,sid:e.sid,request_bodies:[{uri:22,buffer:{cname:e.cname,detail:WV(WV(WV({6:e.stringUid,11:t,12:_N("USE_NEW_TOKEN")?"1":void 0},r?{17:r}:{}),{},{22:t},e.apRequestDetail?{33:e.apRequestDetail}:{}),e.apRTM?{26:"RTM2"}:{}),key:e.token,service_ids:i,uid:e.uid||0}}]};o.request_bodies.forEach((t=>{e.multiIP&&e.multiIP.gateway_ip&&(t.buffer.detail[5]=JSON.stringify({vocs_ip:[e.multiIP.uni_lbs_ip],vos_ip:[e.multiIP.gateway_ip]}))}));const s=new FormData;return s.append("request",JSON.stringify(o)),[s,n]},$V=(e,t)=>{const i=Math.floor(Math.random()*10**12),n={appid:e.appId,client_ts:Date.now(),opid:i,sid:e.sid,request_bodies:[{uri:28,buffer:{cname:e.cname,detail:{1:"",6:e.stringUid,12:"1"},token:e.token,service_ids:t,uid:e.uid||0,edges_services:e.apResponse.addresses.map((e=>({ip:e.ip,port:e.port})))}}]},r=new FormData;return r.append("request",JSON.stringify(n)),[r,i]};let eF=0;function tF(e){return Wh.all(e.map((e=>e.then((e=>{throw e}),(e=>e))))).then((e=>{throw e}),(e=>e))}const iF=async e=>{let{fragementLength:t,referenceList:i,asyncMapHandler:n,allFailedhandler:r,promisesCollector:o}=e,s=0;const a=t;let c,d=0;const l=async()=>{const e=(()=>{const e=s*a,t=e+a;return i.slice(e,t).map(n)})();o&&o.push(...e);try{c=await tF(e)}catch(e){if(d+=a,s++,!(d>=i.length))return void await l();r(e)}e.forEach((e=>e.cancel()))};return await l(),c},nF=async e=>{let{referenceList:t,asyncMapHandler:i,closeFn:n}=e;const r=t.length;let o=0;const s=async()=>{const e=i(t.shift());try{return await e}catch(e){if(o++,o>=r||null!=n&&n(e))throw e;return s()}};return s()};async function rF(e,t,i,n){const r=async function(e,t,i,n){let r=null;const o=[],s=async()=>{const r=_N("WEBCS_DOMAIN").slice(0,_N("AJAX_REQUEST_CONCURRENT")).map((t=>({url:e.proxyServer?"https://".concat(e.proxyServer,"/ap/?url=").concat(t+"/api/v2/transpond/webrtc?v=2"):"https://".concat(t,"/api/v2/transpond/webrtc?v=2"),areaCode:LV()}))),s=n.recordJoinChannelService({startTs:Date.now(),status:"pending",service:"chooseServer",urls:r.map((e=>e.url))}),a=await iF({fragementLength:_N("FRAGEMENT_LENGTH"),referenceList:r,asyncMapHandler:n=>(YN.debug("[".concat(e.clientId,"] Connect to choose_server:"),n.url),qV(n,e,t,i)),allFailedhandler:e=>{throw n.recordJoinChannelService({endTs:Date.now(),status:"error",errors:e},s),e[0]},promisesCollector:o});return n.recordJoinChannelService({endTs:Date.now(),status:"success"},s),a},a=async()=>{if(await uO(1e3),null!==r)return r;const s=_N("WEBCS_DOMAIN_BACKUP_LIST").map((t=>({url:e.proxyServer?"https://".concat(e.proxyServer,"/ap/?url=").concat(t+"/api/v2/transpond/webrtc?v=2"):"https://".concat(t,"/api/v2/transpond/webrtc?v=2"),areaCode:LV()}))),a=n.recordJoinChannelService({endTs:void 0,startTs:Date.now(),status:"pending",service:"chooseServer",urls:s.map((e=>e.url))}),c=await iF({fragementLength:_N("FRAGEMENT_LENGTH"),referenceList:s,asyncMapHandler:n=>(YN.debug("[".concat(e.clientId,"] Connect to backup choose_server:"),n.url),qV(n,e,t,i)),allFailedhandler:e=>{throw n.recordJoinChannelService({endTs:Date.now(),status:"error",errors:e},a),e[0]},promisesCollector:o});return n.recordJoinChannelService({endTs:Date.now(),status:"success"},a),c};try{return r=await tF([s(),a()]),o.length&&o.forEach((e=>e.cancel&&"function"==typeof e.cancel&&e.cancel())),r}catch(e){throw e[0]}}(e,t,i,n);return{gatewayInfo:await r}}async function oF(e,t,i,n,r){const o=e.cloudProxyServer;if("disabled"===o){if(!n)return;if(e.useLocalAccessPoint)return await rF(e,t,i,r);if(_N("JOIN_WITH_FALLBACK_MEDIA_PROXY")){const{gatewayInfo:n,proxyInfo:o}=await lF(e,t,i,r);if(e.turnServer&&"auto"!==e.turnServer.mode)return{gatewayInfo:n};const a=o.map((e=>({turnServerURL:e.address,tcpport:e.tcpport||aN.tcpport,udpport:e.udpport||aN.udpport,username:e.username||aN.username,password:e.password||aN.password,forceturn:!1,security:!0})));if(r.useP2P){var s;const t=null!==(s=e.uid)&&void 0!==s?s:n.uid,i="glb:".concat(t.toString()),r=await Nw(i),c=o.map((e=>({turnServerURL:e.address,tcpport:e.tcpport||aN.tcpport,udpport:e.udpport||aN.udpport,username:i,password:r,forceturn:!1,security:!0})));a.push(...c)}return e.turnServer={mode:"manual",servers:a},{gatewayInfo:n}}return await rF(e,t,i,r)}const{proxyInfo:a,gatewayInfo:c}=await lF(e,t,i,r),d={gatewayInfo:c},l=a.map((e=>({turnServerURL:e.address,tcpport:"proxy3"===o?void 0:e.tcpport?e.tcpport:aN.tcpport,udpport:"proxy4"===o?void 0:e.udpport?e.udpport:aN.udpport,username:e.username||aN.username,password:e.password||aN.password,forceturn:"proxy4"!==o,security:"proxy5"===o})));if(r.useP2P){var u;const t=null!==(u=e.uid)&&void 0!==u?u:c.uid,i="glb:".concat(t.toString()),n=await Nw(i),r=a.map((e=>({turnServerURL:e.address,tcpport:"proxy3"===o?void 0:e.tcpport||aN.tcpport,udpport:"proxy4"===o?void 0:e.udpport||aN.udpport,username:i,password:n,forceturn:"proxy4"!==o,security:"proxy5"===o})));l.push(...r)}return e.turnServer={mode:"manual",servers:l},YN.debug("[".concat(e.clientId,"] set proxy server: ").concat(e.proxyServer,", mode: ").concat(o)),d}async function sF(e,t,i,n,r){const o=_N("ACCOUNT_REGISTER").slice(0,_N("AJAX_REQUEST_CONCURRENT"));let s=[];s=t.proxyServer?o.map((e=>"https://".concat(t.proxyServer,"/ap/?url=").concat(e+"/api/v1"))):o.map((e=>"https://".concat(e,"/api/v1")));const a=null==r?void 0:r.recordJoinChannelService({startTs:Date.now(),status:"pending",service:"stringUID",urls:s});try{const o=await async function(e,t,i,n,r){const o=Date.now(),s={sid:i.sid,opid:10,appid:i.appId,string_uid:t};let a=e[0];const c=await wO((()=>PV(a+"".concat(-1===a.indexOf("?")?"?":"&","action=stringuid"),{data:s,cancelToken:n,headers:{"X-Packet-Service-Type":0,"X-Packet-URI":72}})),((i,n)=>{if(0===i.code){if(i.uid<=0||i.uid>=Math.pow(2,32))throw YN.error("Invalid Uint Uid ".concat(t," => ").concat(i.uid),i),eD.reqUserAccount(s.sid,{lts:o,success:!1,serverAddr:a,stringUid:s.string_uid,uid:i.uid,errorCode:Ew.INVALID_UINT_UID_FROM_STRING_UID,extend:s}),new tD(Ew.INVALID_UINT_UID_FROM_STRING_UID);return eD.reqUserAccount(s.sid,{lts:o,success:!0,serverAddr:a,stringUid:s.string_uid,uid:i.uid,errorCode:null,extend:s}),!1}const r=lx(i.code);return r.retry&&(a=e[(n+1)%e.length]),eD.reqUserAccount(s.sid,{lts:o,success:!1,serverAddr:a,stringUid:s.string_uid,uid:i.uid,errorCode:r.desc,extend:s}),r.retry}),((t,i)=>t.code!==Ew.OPERATION_ABORTED&&(eD.reqUserAccount(s.sid,{lts:o,success:!1,serverAddr:a,stringUid:s.string_uid,uid:null,errorCode:t.code,extend:s}),a=e[(i+1)%e.length],!0)),r);if(0!==c.code){const e=lx(c.code);throw new tD(Ew.UNEXPECTED_RESPONSE,e.desc)}return c}(s,e,t,i,n);return null==r||r.recordJoinChannelService({status:"success",endTs:Date.now()},a),o.uid}catch(e){throw null==r||r.recordJoinChannelService({status:"error",endTs:Date.now(),errors:[e]},a),e}}async function aF(e,t,i){const n=_N("ACCOUNT_REGISTER");let r=[];r=t.proxyServer?n.map((e=>"https://".concat(t.proxyServer,"/ap/?url=").concat(e+"/api/v1"))):n.map((e=>"https://".concat(e,"/api/v1")));try{const n=await nF({referenceList:r,asyncMapHandler:n=>async function(e,t,i,n){const r=Date.now(),o={sid:i.sid,opid:10,appid:i.appId,string_uid:t};try{const t=await PV(e+"".concat(-1===e.indexOf("?")?"?":"&","action=stringuid"),{data:o,cancelToken:n,headers:{"X-Packet-Service-Type":0,"X-Packet-URI":72}});if(0!==t.code){const e=lx(t.code);throw new tD(Ew.UNEXPECTED_RESPONSE,"preload sua error:".concat(e.desc),e)}if(t.uid<=0||t.uid>=Math.pow(2,32))throw new tD(Ew.INVALID_UINT_UID_FROM_STRING_UID);return{requestTime:r,url:e,req:o,uid:t.uid,elapse:Date.now()-r}}catch(e){throw e}}(n,e,t,i),closeFn:e=>e.code===Ew.OPERATION_ABORTED||e.code===Ew.UNEXPECTED_RESPONSE&&!e.data.retry});return n}catch(e){throw e}}async function cF(e,t,i){const n=_N("CDS_AP").slice(0,_N("AJAX_REQUEST_CONCURRENT")).map((t=>e.proxyServer?"https://".concat(e.proxyServer,"/ap/?url=").concat(t+"/api/v1"):"https://".concat(t,"/api/v1?action=config"))),r=n.map((n=>function(e,t,i,n){const r=xb(),o={flag:64,cipher_method:0,features:WV(WV(WV(WV(WV({install_id:nN(),device:r.name,system:r.os,system_general:navigator.userAgent,vendor:t.appId,version:rN,cname:t.cname,session_id:t.sid,proxyServer:t.proxyServer,sdk_type:bx.WEB_RTC,browser_name:r.name,browser_version:r.version,user_agent:navigator.userAgent,channel_name:t.cname},t.stringUid&&{string_uid:t.stringUid}),t.uid&&{uid:t.uid+""}),r.os&&{os_name:r.os}),r.osVersion&&{os_version:r.osVersion}),{},{detail:""})};return wO((()=>PV(e,{data:o,timeout:1e3,cancelToken:i,headers:{"X-Packet-Service-Type":0,"X-Packet-URI":54}})),void 0,(e=>e.code!==Ew.OPERATION_ABORTED),n)}(n,e,t,i)));let o=null,s=null,a={};try{o=await tF(r)}catch(e){if(e.code===Ew.OPERATION_ABORTED)throw e;s=e}r.forEach((e=>e.cancel()));if(eD.reportApiInvoke(e.sid,{name:kw.REQUEST_CONFIG_DISTRIBUTE,options:{error:s,res:o}}).onSuccess(),o&&o.test_tags)try{a=function(e){if(!e.test_tags)return{};const t=e.test_tags,i=Object.keys(t),n={};
12272return i.forEach((e=>{var i;const r=OT(i=e.slice(4)).call(i),o=JSON.parse(t[e]),s=o[1];n[r]={tag:o[0]||"",value:s}})),n}(o)}catch(e){}return a}async function dF(e,t){const i=_N("WEBCS_DOMAIN").concat(_N("WEBCS_DOMAIN_BACKUP_LIST")).map((e=>({url:"https://".concat(e,"/api/v2/transpond/webrtc?v=2"),areaCode:LV(),serviceIds:[wx.CHOOSE_SERVER,wx.CLOUD_PROXY_FALLBACK]})));try{const n=await nF({referenceList:i,asyncMapHandler:i=>async function(e,t,i){let n,{url:r,areaCode:o,serviceIds:s}=e;const a=Date.now(),[c,d]=ZV(t,o,s);let l=Jw.networkState;try{l&&Jw.networkState===Hw.OFFLINE&&Jw.onlineWaiter&&await Wh.race([Jw.onlineWaiter,uO(AO.maxRetryTimeout)]),l=Jw.networkState;const{data:e,headers:t}=await PV(r,{data:c,cancelToken:i,headers:{"Content-Type":"multipart/form-data;"}},!0,!0);n="1"===t.http3?1:-1;const o=e=>{const t=[];if(e.response_body.forEach((i=>{const n=i.buffer.code;if(23===i.uri&&0===n&&!i.buffer.edges_services)if(4194310===i.buffer.flag)i.buffer.edges_services=[];else{const n={error:new tD(Ew.CAN_NOT_GET_GATEWAY_SERVER,"no edge services in ap response",{retry:!0,csIp:e.detail[502]}),flag:i.buffer.flag};t.push(n)}if(0!==n){const r=lx(n),o={error:new tD(Ew.CAN_NOT_GET_GATEWAY_SERVER,r.desc,{desc:r.desc,retry:r.retry,csIp:e.detail[502]}),flag:i.buffer.flag};4194310===i.buffer.flag?YN.warning(o.error.toString()):t.push(o)}})),t.length)throw new tD(Ew.CAN_NOT_GET_GATEWAY_SERVER,t.map((e=>"flag: ".concat(e.flag,", message: ").concat(e.error.message))).join(" | "),{retry:!!t.find((e=>e.error.data.retry)),csIp:e.detail[502],desc:[...new Set(t.map((e=>{var t;return null==e||null===(t=e.error)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.desc})).filter((e=>!!e)))]})};o(e);const s=Ux(e,wx.CHOOSE_SERVER),u=Ux(e,wx.CLOUD_PROXY_FALLBACK);return JV(s),{gatewayInfo:Px(s,r),proxyInfo:u,opid:d,requestTime:a,url:r,isHttp3:n,elapse:Date.now()-a}}catch(e){throw e}}(i,e,t),closeFn:e=>e.code===Ew.OPERATION_ABORTED||e.code===Ew.CAN_NOT_GET_GATEWAY_SERVER&&!e.data.retry});return n}catch(e){throw e}}async function lF(e,t,i,n){const r=_N("PROXY_SERVER_TYPE3"),o=(e,t,i)=>{let n=i||r;return Array.isArray(n)&&(n=t%2==0?r[1]:r[0]),"https://".concat(n,"/ap/?url=").concat(e)};let s=null;const a=[],c=async()=>{const r=_N("WEBCS_DOMAIN").slice(0,_N("AJAX_REQUEST_CONCURRENT")).map(((t,i)=>{let n;return n="disabled"===e.cloudProxyServer&&e.proxyServer?o("".concat(t,"/api/v2/transpond/webrtc?v=2"),i,e.proxyServer):"disabled"===e.cloudProxyServer||"fallback"===e.cloudProxyServer?"https://".concat(t,"/api/v2/transpond/webrtc?v=2"):o("".concat(t,"/api/v2/transpond/webrtc?v=2"),i),{url:n,areaCode:LV(),serviceIds:[wx.CHOOSE_SERVER,"proxy5"===e.cloudProxyServer?wx.CLOUD_PROXY_5:"proxy3"===e.cloudProxyServer||"proxy4"===e.cloudProxyServer?wx.CLOUD_PROXY:wx.CLOUD_PROXY_FALLBACK]}})),s=n.recordJoinChannelService({startTs:Date.now(),status:"pending",service:"chooseServer",urls:r.map((e=>e.url))}),c=await iF({fragementLength:_N("FRAGEMENT_LENGTH"),referenceList:r,asyncMapHandler:n=>(YN.debug("[".concat(e.clientId,"] Connect to choose_server:"),n.url),zV(n,e,t,i)),allFailedhandler:e=>{throw n.recordJoinChannelService({endTs:Date.now(),status:"error",errors:e},s),e[0]},promisesCollector:a});return n.recordJoinChannelService({endTs:Date.now(),status:"success"},s),c},d=async()=>{if(await uO(1e3),null!==s)return s;const r=_N("WEBCS_DOMAIN_BACKUP_LIST").map(((t,i)=>{let n;return n="disabled"===e.cloudProxyServer&&e.proxyServer?o("".concat(t,"/api/v2/transpond/webrtc?v=2"),i,e.proxyServer):"disabled"===e.cloudProxyServer||"fallback"===e.cloudProxyServer?"https://".concat(t,"/api/v2/transpond/webrtc?v=2"):o("".concat(t,"/api/v2/transpond/webrtc?v=2"),i),{url:n,areaCode:LV(),serviceIds:[wx.CHOOSE_SERVER,"proxy5"===e.cloudProxyServer?wx.CLOUD_PROXY_5:"proxy3"===e.cloudProxyServer||"proxy4"===e.cloudProxyServer?wx.CLOUD_PROXY:wx.CLOUD_PROXY_FALLBACK]}})),c=n.recordJoinChannelService({startTs:Date.now(),status:"pending",service:"chooseServer",urls:r.map((e=>e.url))}),d=await iF({fragementLength:_N("FRAGEMENT_LENGTH"),referenceList:r,asyncMapHandler:n=>(YN.debug("[".concat(e.clientId,"] Connect to backup choose_server:"),n.url),zV(n,e,t,i)),allFailedhandler:e=>{throw n.recordJoinChannelService({endTs:Date.now(),status:"error",errors:e},c),e[0]},promisesCollector:a});return n.recordJoinChannelService({endTs:Date.now(),status:"success"},c),d};let l,u,h;try{({gatewayInfo:l,proxyInfo:u,url:h}=await tF([c(),d()]))}catch(e){throw e[0]}if(a.length&&a.forEach((e=>e.cancel&&"function"==typeof e.cancel&&e.cancel())),!l||!u)throw new tD(Ew.UNEXPECTED_ERROR,"missing gateway or proxy response").print();if(e.apUrl=h,"disabled"!==e.cloudProxyServer&&Array.isArray(r)&&h){const t=/^https?:\/\/(.+?)(\/.*)?$/.exec(h)[1];Dn(r).call(r,t)&&(e.proxyServer=t,YN.setProxyServer(t),eD.setProxyServer(t))}return s={gatewayInfo:l,proxyInfo:await xx(u,l.uid)},s}async function uF(e,t,i){const n=_N("UAP_AP").slice(0,_N("AJAX_REQUEST_CONCURRENT")).map((t=>e.proxyServer?"https://".concat(e.proxyServer,"/ap/?url=").concat(t+"/api/v1?action=uap"):"https://".concat(t,"/api/v1?action=uap"))),r
vendor: 4,995 bytes, line 12272
12272=n.map((n=>function(e,t,i,n){const r={command:"convergeAllocateEdge",sid:t.sid,appId:t.appId,token:t.token,ts:Date.now(),version:rN,cname:t.cname,uid:t.uid.toString(),requestId:YV,seq:YV};YV+=1;const o={service_name:"tele_channel",json_body:JSON.stringify(r)};return wO((async()=>{const t=await PV(e,{data:o,cancelToken:i,headers:{"X-Packet-Service-Type":0,"X-Packet-URI":61}});if(0!==t.code){const e=new tD(Ew.UNEXPECTED_RESPONSE,"cross channel ap error, code"+t.code,{retry:!0});throw YN.error(e.toString()),e}const n=JSON.parse(t.json_body);if(200!==n.code){const e=new tD(Ew.UNEXPECTED_RESPONSE,"cross channel app center error, code: ".concat(n.code,", reason: ").concat(n.reason));throw YN.error(e.toString()),e}if(!n.servers||0===n.servers.length){const e=new tD(Ew.UNEXPECTED_RESPONSE,"cross channel app center empty server");throw YN.error(e.toString()),e}return{vid:n.vid,workerToken:n.workerToken,addressList:(_N("CHANNEL_MEDIA_RELAY_SERVERS")||n.servers).map((e=>"wss://".concat(e.address.replace(/\./g,"-"),".").concat(_N("WORKER_DOMAIN"),":").concat(e.wss)))}}),void 0,(e=>!!(e.code!==Ew.OPERATION_ABORTED&&e.code!==Ew.UNEXPECTED_RESPONSE||e.data&&e.data.retry)),n)}(n,e,t,i)));try{const e=await tF(r);return r.forEach((e=>e.cancel())),e}catch(e){throw e[0]}}async function hF(e,t,i){let n=null;const r=[],o=async o=>{const s=_N(o?"WEBCS_DOMAIN_BACKUP_LIST":"WEBCS_DOMAIN").map((t=>e.proxyServer?"https://".concat(e.proxyServer,"/ap/?url=").concat(t+"/api/v2/transpond/webrtc?v=2"):"https://".concat(t,"/api/v2/transpond/webrtc?v=2")));return o&&(await uO(1e3),null!==n)?n:await iF({fragementLength:_N("FRAGEMENT_LENGTH"),referenceList:s,asyncMapHandler:n=>(YN.debug("[".concat(e.clientId,"] update ticket, Connect to ").concat(o?"backup":""," choose_server:"),n),function(e,t,i,n){const[r]=$V(t,[wx.CHOOSE_SERVER]);let o=Jw.networkState;return wO((async()=>{o&&Jw.networkState===Hw.OFFLINE&&Jw.onlineWaiter&&await Wh.race([Jw.onlineWaiter,uO(n&&n.maxRetryTimeout||AO.maxRetryTimeout)]),o=Jw.networkState;const t=await PV(e,{data:r,cancelToken:i,headers:{"Content-Type":"multipart/form-data;"}},!0);return QV(t,e)}),(()=>!1),(e=>e.code!==Ew.OPERATION_ABORTED&&(e.code===Ew.UPDATE_TICKET_FAILED?e.data.retry:(YN.warning("[".concat(t.clientId,"] update ticket network error, retry"),e),!0))),n)}(n,e,t,i)),allFailedhandler:e=>{throw e[0]},promisesCollector:r})};try{return n=await tF([o(!1),o(!0)]),r.length&&r.forEach((e=>e.cancel&&"function"==typeof e.cancel&&e.cancel())),n}catch(e){throw e[0]}}function pF(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function _F(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?pF(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):pF(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class EF extends Dw{get isSuccess(){return!!this.configs}constructor(e,t){super(),QI(this,"configs",void 0),QI(this,"store",void 0),QI(this,"joinInfo",void 0),QI(this,"cancelToken",void 0),QI(this,"retryConfig",{timeout:3e3,timeoutFactor:1.5,maxRetryCount:1,maxRetryTimeout:1e4}),QI(this,"interval",void 0),QI(this,"mutex",void 0),QI(this,"mutableParamsRead",!1),QI(this,"configCache",{}),QI(this,"limit_bitrate",void 0),this.mutex=new IO("config-distribute",e),this.store=t}startGetConfigDistribute(e,t){this.joinInfo=e,this.cancelToken=t,this.interval&&this.stopGetConfigDistribute(),_N("ENABLE_CONFIG_DISTRIBUTE")&&(this.updateConfigDistribute(),this.interval=window.setInterval((()=>{this.updateConfigDistribute()}),_N("CONFIG_DISTRIBUTE_INTERVAL")))}stopGetConfigDistribute(){this.interval&&clearInterval(this.interval),this.interval=void 0,this.joinInfo=void 0,this.cancelToken=void 0,this.configs=void 0,this.limit_bitrate=void 0}async awaitConfigDistributeComplete(){if(!this.mutex.isLocked)return;(await this.mutex.lock())()}async updateConfigDistribute(){if(!this.mutableParamsRead){this.mutableParamsRead=!0;eD.reportApiInvoke(null,{options:void 0,name:kw.LOAD_CONFIG_FROM_LOCALSTORAGE,tag:Mw.TRACER}).onSuccess(JSON.stringify(mN))}if(!this.joinInfo||!this.cancelToken||!this.retryConfig)return void YN.debug("[config-distribute] get config distribute interrupted have no joininfo");let e;const t=await this.mutex.lock();try{e=await cF(this.joinInfo,this.cancelToken,this.retryConfig),YN.debug("[config-distribute] get config distribute",JSON.stringify(e));const i=function(e){var t;const i=vS(t=Object.keys(e).filter((e=>/^webrtc_ng_global_parameter/.test(e)))).call(t);for(let t=0;t<i.length;t++)for(let n=i.length-1;n>t;n--){const t=i[n],r=e[t].value;if("number"==typeof r.__priority){const o=r.__priority,s=i[n-1],a=e[s].value;if("number"==typeof a.__priority){if(!(o>a.__priority))continue;
12272{const e=t;i[n]=i[n-1],i[n-1]=e}}else{const e=t;i[n]=i[n-1],i[n-1]=e}}}const n=Date.now();let r={};return i.forEach((t=>{const i=e[t].value.__expires;i&&i<=n||(r[t]=e[t])})),r}(e);this.cacheGlobalParameterConfig(i),this.store.hasStartJoinChannel||(this.store.isABTestSuccess=!0),this.configs=i}catch(e){const t=new tD(Ew.NETWORK_RESPONSE_ERROR,e);YN.warning("[config-distribute] ".concat(t.toString()))}finally{t()}}getBitrateLimit(){return this.limit_bitrate||void 0}handleBitrateLimit(e){jU(e)&&(this.limit_bitrate?this.limit_bitrate&&this.limit_bitrate.id!==e.id&&this.emit(BU.UPDATE_BITRATE_LIMIT,e):this.emit(BU.UPDATE_BITRATE_LIMIT,e))}getLowStreamConfigDistribute(){return this.limit_bitrate&&_F({},this.limit_bitrate.low_stream_uplink)}handleABTestConfigDistribute(e){try{const t={},i=Object.keys(e),n=[];i.forEach((i=>{const r=e[i].value;t[i]=r;const o=r.__id;if(o&&this.configCache[i]&&this.configCache[i].__id===o)return;const s=r.__type,a=e[i].value,c=e[i].tag;let d=0;s?s===EN.REALTIME&&(d=1):Object.keys(a).some((e=>Object.prototype.hasOwnProperty.call(uN,e)||!RM()&&Object.prototype.hasOwnProperty.call(cN,e)?(d=1,!0):void 0)),n.push({tag:c,isApplied:d,feature:i,params:JSON.stringify(r)})})),n.forEach((e=>{let{tag:t,feature:i,params:n,isApplied:r}=e;this.store.sessionId&&eD.abTest(this.store.sessionId,{intSucc:1,isApplied:r,tag:t,feature:i,params:n,cid:this.store.cid,uid:this.store.intUid})})),this.configCache=t}catch(e){YN.debug("handleABTestConfigDistribute error",e)}}cacheGlobalParameterConfig(e){const t=function(e){const t={};return Object.keys(e).forEach((i=>{const n=e[i].value,r=n.__expires,o=n.__type;Object.keys(n).forEach((e=>{"__id"===e||"__type"===e||"__priority"===e||"__expires"===e||Object.prototype.hasOwnProperty.call(t,e)||(t[e]=_F(_F({value:n[e]},r&&{expires:r}),o&&{type:o}))}))})),t}(e);try{var i;const n=null===(i=t.LIMIT_BITRATE)||void 0===i?void 0:i.value;delete t.LIMIT_BITRATE,n&&jU(n)&&this.handleBitrateLimit(n),this.limit_bitrate=n,this.handleGlobalParameterConfig(t),this.handleABTestConfigDistribute(e),function(e){try{const t=Date.now();Object.keys(e).forEach((i=>{const{value:n,type:r,expires:o}=e[i];o&&o<=t||((r===EN.REALTIME||Object.prototype.hasOwnProperty.call(uN,i))&&(mN[i]=n,hN[i]=n,YN.debug("Update realtime parameters from config distribute",i,n)),r||RM()||!Object.prototype.hasOwnProperty.call(cN,i)||(mN[i]=n,hN[i]=n,YN.debug("Update gateway parameters from config distribute",i,n)))}))}catch(t){YN.error("Error update config immediately: ".concat(e),t.message)}}(t);const r=JSON.stringify(t),o=window.btoa(r);window.localStorage.setItem("websdk_ng_global_parameter",o),YN.debug("Caching global parameters ".concat(r))}catch(e){YN.error("Error caching global parameters:",e.message)}}handleGlobalParameterConfig(e){try{const t=Date.now();Object.keys(e).forEach((i=>{if("CLIENT_ROLE_OPTIONS"===i)if(Object.prototype.hasOwnProperty.call(hN,i)){const{value:n,expires:r}=e[i];if(r&&r<=t)return;(function(e,t){try{return"object"==typeof e&&"object"==typeof t&&JSON.stringify(e)===JSON.stringify(t)}catch(e){return!1}})(hN[i],n)||(mN[i]=n,hN[i]=n,this.emit(BU.UPDATE_CLIENT_ROLE_OPTIONS,n),YN.debug("Updating client role options: ".concat(JSON.stringify(n))))}}))}catch(e){YN.error("Error handling global parameter config:",e.message)}}}class mF extends Dw{constructor(){super(...arguments),QI(this,"resultStorage",new Map)}setLocalAudioStats(e,t,i){this.record("AUDIO_INPUT_LEVEL_TOO_LOW",e,this.checkAudioInputLevel(i,t)),this.record("SEND_AUDIO_BITRATE_TOO_LOW",e,this.checkSendAudioBitrate(i,t))}setLocalVideoStats(e,t,i){this.record("SEND_VIDEO_BITRATE_TOO_LOW",e,this.checkSendVideoBitrate(i,t)),this.record("FRAMERATE_INPUT_TOO_LOW",e,this.checkFramerateInput(i,t)),this.record("FRAMERATE_SENT_TOO_LOW",e,this.checkFramerateSent(i))}setRemoteAudioStats(e,t){const i=e.getUserId();this.record("AUDIO_OUTPUT_LEVEL_TOO_LOW",i,this.checkAudioOutputLevel(t))}setRemoteVideoStats(e,t){const i=e.getUserId();this.record("RECV_VIDEO_DECODE_FAILED",i,this.checkVideoDecode(t))}record(e,t,i){if(_N("STATS_UPDATE_INTERVAL")>500)return;this.resultStorage.has(e)||this.resultStorage.set(e,{result:[],isPrevNormal:!0});const n=this.resultStorage.get(e);if(n&&(n.result.push(i),n.result.length>=5)){var r;const i=Dn(r=n.result).call(r,!0);
vendor: 15,136 bytes, line 12272
12272n.isPrevNormal&&!i&&this.emit("exception",fF[e],e,t),!n.isPrevNormal&&i&&this.emit("exception",fF[e]+2e3,e+"_RECOVER",t),n.isPrevNormal=i,n.result=[]}}checkAudioOutputLevel(e){return!(e.receiveBitrate>0&&0===e.receiveLevel)}checkAudioInputLevel(e,t){return t instanceof bL&&!t.isActive||(!!t.muted||0!==e.sendVolumeLevel)}checkFramerateInput(e,t){let i=null;t._encoderConfig&&t._encoderConfig.frameRate&&(i=Lx(t._encoderConfig.frameRate));const n=e.captureFrameRate;return!i||!n||!(i>10&&n<5||i<10&&i>=5&&n<=1)}checkFramerateSent(e){return!(e.captureFrameRate&&e.sendFrameRate&&e.captureFrameRate>5&&e.sendFrameRate<=1)}checkSendVideoBitrate(e,t){return!!t.muted||0!==e.sendBitrate}checkSendAudioBitrate(e,t){return t instanceof bL&&!t.isActive||(!!t.muted||0!==e.sendBitrate)}checkVideoDecode(e){return 0===e.receiveBitrate||0!==e.decodeFrameRate}}const fF={FRAMERATE_INPUT_TOO_LOW:1001,FRAMERATE_SENT_TOO_LOW:1002,SEND_VIDEO_BITRATE_TOO_LOW:1003,RECV_VIDEO_DECODE_FAILED:1005,AUDIO_INPUT_LEVEL_TOO_LOW:2001,AUDIO_OUTPUT_LEVEL_TOO_LOW:2002,SEND_AUDIO_BITRATE_TOO_LOW:2003};const TF=new class{markSubscribeStart(e,t){performance.mark("agora-web-sdk/".concat(e,"/subscribe-").concat(t))}markPublishStart(e,t){performance.mark("agora-web-sdk/".concat(e,"/publish-").concat(t))}measureFromSubscribeStart(e,t){const i=performance.getEntriesByName("agora-web-sdk/".concat(e,"/subscribe-").concat(t));if(i.length>0){const e=i[i.length-1];return Math.round(performance.now()-e.startTime)}return 0}measureFromPublishStart(e,t){const i=performance.getEntriesByName("agora-web-sdk/".concat(e,"/publish-").concat(t));if(i.length>0){const e=i[i.length-1];return Math.round(performance.now()-e.startTime)}return 0}};function SF(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function gF(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?SF(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):SF(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class RF{constructor(e){QI(this,"store",void 0),QI(this,"onStatsException",void 0),QI(this,"onUploadPublishDuration",void 0),QI(this,"onStatsChanged",void 0),QI(this,"localStats",new Map),QI(this,"remoteStats",new Map),QI(this,"updateStatsInterval",void 0),QI(this,"trafficStats",void 0),QI(this,"trafficStatsPeerList",[]),QI(this,"uplinkStats",void 0),QI(this,"exceptionMonitor",void 0),QI(this,"p2pChannel",void 0),QI(this,"scalabilityMode",zO.L1T1),QI(this,"updateStats",(()=>{this.p2pChannel&&(this.updateRemoteStats(this.p2pChannel),this.updateLocalStats(this.p2pChannel))})),this.store=e,this.exceptionMonitor=new mF,this.exceptionMonitor.on("exception",((e,t,i)=>{this.onStatsException&&this.onStatsException(e,t,i)}))}startUpdateStats(){this.updateStatsInterval||(this.updateStatsInterval=window.setInterval(this.updateStats,1e3))}stopUpdateStats(){this.updateStatsInterval&&(window.clearInterval(this.updateStatsInterval),this.updateStatsInterval=void 0)}reset(){this.localStats=new Map,this.remoteStats=new Map,this.trafficStats=void 0,this.trafficStatsPeerList=[],this.uplinkStats=void 0}getLocalAudioTrackStats(){return this.localStats.get(zU.LocalAudioTrack)||gF({},DD)}getLocalVideoTrackStats(){return this.localStats.get(zU.LocalVideoTrack)||gF({},PD)}getRemoteAudioTrackStats(e){const t=(e,t)=>{if(!this.trafficStats)return t;const i=this.trafficStats.peer_delay.find((t=>t.peer_uid===e));return i&&(t.publishDuration=i.B_ppad+(Date.now()-this.trafficStats.timestamp)),t},i={};if(e){var n;const r=null===(n=this.remoteStats.get(e))||void 0===n?void 0:n.audioStats;r&&(i[e]=t(e,r))}else Array.from(this.remoteStats.entries()).forEach((e=>{let[n,{audioStats:r}]=e;r&&(i[n]=t(n,r))}));return i}getRemoteNetworkQualityStats(e){const t={};if(e){var i;const n=null===(i=this.remoteStats.get(e))||void 0===i?void 0:i.networkStats;n&&(t[e]=n)}else Array.from(this.remoteStats.entries()).forEach((e=>{let[i,{networkStats:n}]=e;n&&(t[i]=n)}));return t}getRemoteVideoTrackStats(e){const t=(e,t)=>{if(!this.trafficStats)return t;const i=this.trafficStats.peer_delay.find((t=>t.peer_uid===e));return i&&(t.publishDuration=i.B_ppvd+(Date.now()-this.trafficStats.timestamp)),t},i={};if(e){var n;const r=null===(n=this.remoteStats.get(e))||void 0===n?void 0:n.videoStats;r&&(i[e]=t(e,r))}else Array.from(this.remoteStats.entries()).forEach((e=>{let[n,{videoStats:r}]=e;r&&(i[n]=t(n,r))}));return i}getRTCStats(){let e=0,t=0,i=0,n=0;const r=this.localStats.get(zU.LocalAudioTrack);r&&(e+=r.sendBytes,t+=r.sendBitrate);const o=this.localStats.get(zU.LocalVideoTrack);o&&(e+=o.sendBytes,t+=o.sendBitrate);const s=this.localStats.get(zU.LocalVideoLowTrack);s&&(e+=s.sendBytes,t+=s.sendBitrate),this.remoteStats.forEach((e=>{let{audioStats:t,videoStats:r}=e;t&&(i+=t.receiveBytes,n+=t.receiveBitrate),r&&(i+=r.receiveBytes,n+=r.receiveBitrate)}));let a=1;return this.trafficStats&&(a+=this.trafficStats.peer_delay.length),{Duration:0,UserCount:a,SendBitrate:t,SendBytes:e,RecvBytes:i,RecvBitrate:n,OutgoingAvailableBandwidth:this.uplinkStats?this.uplinkStats.B_uab/1e3:0,RTT:this.trafficStats?2*this.trafficStats.B_acd:0}}addLocalStats(e){this.localStats.set(e,void 0)}removeLocalStats(e){e?this.localStats.delete(e):this.localStats.clear()}addRemoteStats(e){this.remoteStats.set(e,{})}removeRemoteStats(e){e?this.remoteStats.delete(e):this.remoteStats.clear()}addP2PChannel(e){this.p2pChannel=e}updateTrafficStats(e){e.peer_delay=e.peer_delay.filter((e=>void 0!==e.B_ppad||void 0!==e.B_ppvd));e.peer_delay.filter((e=>-1===this.trafficStatsPeerList.indexOf(e.peer_uid))).forEach((e=>{var t;const i=null===(t=this.p2pChannel)||void 0===t?void 0:t.getRemoteMedia(e.peer_uid),n=null!=i&&i.videoSSRC?TF.measureFromSubscribeStart(this.store.clientId,i.videoSSRC):0,r=null!=i&&i.audioSSRC?TF.measureFromSubscribeStart(this.store.clientId,i.audioSSRC):0;void 0!==e.B_ppad&&void 0!==e.B_ppvd&&(this.onUploadPublishDuration&&this.onUploadPublishDuration(e.peer_uid,e.B_ppad,e.B_ppvd,n>r?n:r),this.trafficStatsPeerList.push(e.peer_uid))})),this.trafficStats=e}updateUplinkStats(e){this.uplinkStats&&this.uplinkStats.B_fir!==e.B_fir&&YN.debug("[".concat(this.store.clientId,"]: Period fir changes to ").concat(e.B_fir)),this.uplinkStats=e}static isRemoteVideoFreeze(e,t,i){if(!e)return!1;const n=!!i&&t.framesDecodeFreezeTime>i.framesDecodeFreezeTime,r=!i||t.framesDecodeCount>i.framesDecodeCount;return n||!r}static isRemoteAudioFreeze(e){return!!e&&e._isFreeze()}isLocalVideoFreeze(e){return!(!e.inputFrame||!e.sentFrame)&&(e.inputFrame.frameRate>5&&e.sentFrame.frameRate<3)}updateLocalStats(e){Array.from(this.localStats.entries()).forEach((t=>{let[i,n]=t;switch(i){case zU.LocalVideoTrack:case zU.LocalVideoLowTrack:{const t=n,o=gF({},PD),s=e.getStats(),a=e.getLocalMedia(i);if(s){const i=s.videoSend.find((e=>e.ssrc===(null==a?void 0:a.ssrcs[0].ssrcId)));if(i){const n=e.getLocalVideoSize(),r=e.getEncoderConfig(zU.LocalVideoTrack);"H264"!==i.codec&&"H265"!==i.codec&&"VP8"!==i.codec&&"VP9"!==i.codec&&"AV1X"!==i.codec&&"AV1"!==i.codec||(o.codecType=i.codec),o.sendBytes=i.bytes,o.sendBitrate=t?8*Math.max(0,o.sendBytes-t.sendBytes):0,i.inputFrame?(o.captureFrameRate=i.inputFrame.frameRate,o.captureResolutionHeight=i.inputFrame.height,o.captureResolutionWidth=i.inputFrame.width):n&&(o.captureResolutionWidth=n.width,o.captureResolutionHeight=n.height),i.sentFrame?(o.sendFrameRate=i.sentFrame.frameRate,o.sendResolutionHeight=i.sentFrame.height,o.sendResolutionWidth=i.sentFrame.width):n&&(o.sendResolutionWidth=n.width,o.sendResolutionHeight=n.height),i.avgEncodeMs&&(o.encodeDelay=i.avgEncodeMs),r&&r.bitrateMax&&(o.targetSendBitrate=1e3*r.bitrateMax),o.sendPackets=i.packets,o.sendPacketsLost=i.packetsLost,o.sendJitterMs=i.jitterMs,o.sendRttMs=i.rttMs,o.totalDuration=t?t.totalDuration+1:1,o.totalFreezeTime=t?t.totalFreezeTime:0,this.isLocalVideoFreeze(i)&&(o.totalFreezeTime+=1),i.scalabilityMode&&this.scalabilityMode!==i.scalabilityMode&&(YN.debug("[".concat(this.store.clientId,"]: The scalabilityMode of the video sending stream is ").concat(i.scalabilityMode)),this.scalabilityMode=i.scalabilityMode)}this.trafficStats&&(o.currentPacketLossRate=(this.trafficStats.B_pvlr4||0)/100)}var r;if(this.localStats.set(i,o),(null==t?void 0:t.sendResolutionWidth)!==o.sendResolutionWidth||(null==t?void 0:t.sendResolutionHeight)!==o.sendResolutionHeight)null===(r=this.onStatsChanged)||void 0===r||r.call(this,"resolution",{width:o.sendResolutionWidth,height:o.sendResolutionHeight});o&&a&&this.exceptionMonitor.setLocalVideoStats(this.store.uid,a.track,o);break}case zU.LocalAudioTrack:{const t=n,r=gF({},DD),o=e.getStats(),s=e.getLocalMedia(i);if(o){const i=o.audioSend.find((e=>e.ssrc===(null==s?void 0:s.ssrcs[0].ssrcId)));if(i){if("opus"!==i.codec&&"aac"!==i.codec&&"PCMU"!==i.codec&&"PCMA"!==i.codec&&"G722"!==i.codec||(r.codecType=i.codec),i.inputLevel)r.sendVolumeLevel=Math.round(32767*i.inputLevel);else{const t=e.getLocalAudioVolume();t&&(r.sendVolumeLevel=Math.round(32767*t))}r.sendBytes=i.bytes,r.sendPackets=i.packets,r.sendPacketsLost=i.packetsLost,r.sendJitterMs=i.jitterMs,r.sendRttMs=i.rttMs,r.sendBitrate=t?8*Math.max(0,r.sendBytes-t.sendBytes):0}}this.trafficStats&&(r.currentPacketLossRate=(this.trafficStats.B_palr4||0)/100),this.localStats.set(zU.LocalAudioTrack,r),r&&s&&this.exceptionMonitor.setLocalAudioStats(this.store.uid,s.track,r);break}}}))}updateRemoteStats(e){Array.from(this.remoteStats.entries()).forEach((t=>{var i,n;let[r,{videoStats:o,audioStats:s,videoPcStats:a}]=t;const c=s,d=o,l=a,u=gF({},LD),h=gF({},MD),p=gF({},kD),{audioTrack:_,videoTrack:E,audioSSRC:m,videoSSRC:f}=e.getRemoteMedia(r);let T;T=this.store.useP2P?e.getStats(!0):e.getStats();const S=null===(i=T)||void 0===i?void 0:i.audioRecv.find((e=>e.ssrc===m)),g=null===(n=T)||void 0===n?void 0:n.videoRecv.find((e=>e.ssrc===f)),R=this.trafficStats&&this.trafficStats.peer_delay.find((e=>e.peer_uid===r));if(S&&("opus"!==S.codec&&"aac"!==S.codec&&"PCMU"!==S.codec&&"PCMA"!==S.codec&&"G722"!==S.codec||(u.codecType=S.codec),S.outputLevel?u.receiveLevel=Math.round(32767*S.outputLevel):_&&(u.receiveLevel=Math.round(32767*_.getVolumeLevel())),u.receiveBytes=S.bytes,u.receivePackets=S.packets,u.receivePacketsLost=S.packetsLost,u.receivePacketsDiscarded=S.packetsDiscarded,u.packetLossRate=u.receivePacketsLost/(u.receivePackets+u.receivePacketsLost),u.receiveBitrate=c?8*Math.max(0,u.receiveBytes-c.receiveBytes):0,u.totalDuration=c?c.totalDuration+1:1,u.totalFreezeTime=c?c.totalFreezeTime:0,u.freezeRate=u.totalFreezeTime/u.totalDuration,u.receiveDelay=S.jitterBufferMs,u.totalDuration>10&&RF.isRemoteAudioFreeze(_)&&(u.totalFreezeTime+=1)),g){var v;"H264"!==g.codec&&"H265"!==g.codec&&"VP8"!==g.codec&&"VP9"!==g.codec&&"AV1X"!==g.codec&&"AV1"!==g.codec||(h.codecType=g.codec),h.receiveBytes=g.bytes,h.receiveBitrate=d?8*Math.max(0,h.receiveBytes-d.receiveBytes):0,h.decodeFrameRate=g.decodeFrameRate<0?0:g.decodeFrameRate,h.renderFrameRate=g.decodeFrameRate<0?0:g.decodeFrameRate,g.outputFrame&&(h.renderFrameRate=g.outputFrame.frameRate),g.receivedFrame?(h.receiveFrameRate=g.receivedFrame.frameRate,h.receiveResolutionHeight=g.receivedFrame.height,h.receiveResolutionWidth=g.receivedFrame.width):E&&(h.receiveResolutionHeight=E._videoHeight||0,h.receiveResolutionWidth=E._videoWidth||0),void 0!==g.framesRateFirefox&&(h.receiveFrameRate=Math.round(g.framesRateFirefox)),h.receivePackets=g.packets,h.receivePacketsLost=g.packetsLost,h.packetLossRate=h.receivePacketsLost/(h.receivePackets+h.receivePacketsLost);const t=d?d.totalFreezeTime:0,i=d?d.totalDuration:0;h.totalDuration=d?d.totalDuration+1:1,h.totalFreezeTime=null!==(v=g.totalFreezesDuration)&&void 0!==v?v:t||0,h.receiveDelay=g.jitterBufferMs||0;const n=!!f&&e.getRemoteVideoIsReady(f);void 0===g.totalFreezesDuration&&E&&n&&RF.isRemoteVideoFreeze(E,g,l)&&(h.totalFreezeTime+=1),h.freezeRate=Math.max(0,Math.min((h.totalFreezeTime-t)/(h.totalDuration-i),1))}R&&(u.end2EndDelay=R.B_ad,h.end2EndDelay=R.B_vd,u.transportDelay=R.B_ed,h.transportDelay=R.B_ed,u.currentPacketLossRate=R.B_ealr4/100,h.currentPacketLossRate=R.B_evlr4/100,p.uplinkNetworkQuality=R.B_punq?R.B_punq:0,p.downlinkNetworkQuality=R.B_pdnq?R.B_pdnq:0),this.remoteStats.set(r,{audioStats:u,videoStats:h,videoPcStats:g,networkStats:p}),_&&this.exceptionMonitor.setRemoteAudioStats(_,u),E&&this.exceptionMonitor.setRemoteVideoStats(E,h)}))}}class vF{constructor(){QI(this,"destChannelMediaInfos",new Map),QI(this,"srcChannelMediaInfo",void 0)}setSrcChannelInfo(e){bU(e),this.srcChannelMediaInfo=e}addDestChannelInfo(e){bU(e),this.destChannelMediaInfos.set(e.channelName,e)}removeDestChannelInfo(e){fU(e),this.destChannelMediaInfos.delete(e)}getSrcChannelMediaInfo(){return this.srcChannelMediaInfo}getDestChannelMediaInfo(){return this.destChannelMediaInfos}}function CF(e){if(!(e instanceof vF)){return new tD(Ew.INVALID_PARAMS,"Config should be instance of [ChannelMediaRelayConfiguration]").throw()}const t=e.getSrcChannelMediaInfo(),i=e.getDestChannelMediaInfo();if(!t){return new tD(Ew.INVALID_PARAMS,"srcChannelMediaInfo should not be empty").throw()}if(0===i.size){return new tD(Ew.INVALID_PARAMS,"destChannelMediaInfo should not be empty").throw()}}class IF{get hasVideo(){return this._video_enabled_&&!this._video_muted_&&this._video_added_}get hasAudio(){return this._audio_enabled_&&!this._audio_muted_&&this._audio_added_}get audioTrack(){if(this.hasAudio||this._audio_pre_subscribed)return this._audioTrack}get videoTrack(){if(this.hasVideo||this._video_pre_subscribed)return this._videoTrack}get dataChannels(){return this._dataChannels}constructor(e,t){QI(this,"uid",void 0),QI(this,"_uintid",void 0),QI(this,"_trust_in_room_",!0),QI(this,"_trust_audio_enabled_state_",!0),QI(this,"_trust_video_enabled_state_",!0),QI(this,"_trust_audio_mute_state_",!0),QI(this,"_trust_video_mute_state_",!0),QI(this,"_audio_muted_",!1),QI(this,"_video_muted_",!1),QI(this,"_audio_enabled_",!0),QI(this,"_video_enabled_",!0),QI(this,"_audio_added_",!1),QI(this,"_video_added_",!1),QI(this,"_is_pre_created",!1),QI(this,"_video_pre_subscribed",!1),QI(this,"_audio_pre_subscribed",!1),QI(this,"_trust_video_stream_added_state_",!0),QI(this,"_trust_audio_stream_added_state_",!0),QI(this,"_audioTrack",void 0),QI(this,"_videoTrack",void 0),QI(this,"_dataChannels",[]),QI(this,"_audioSSRC",void 0),QI(this,"_videoSSRC",void 0),QI(this,"_audioOrtc",void 0),QI(this,"_videoOrtc",void 0),QI(this,"_cname",void 0),QI(this,"_rtxSsrcId",void 0),QI(this,"_videoMid",void 0),QI(this,"_audioMid",void 0),this.uid=e,this._uintid=t}}function yF(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function AF(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};
12272t%2?yF(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):yF(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}const bF="9",wF=4e4;function OF(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function NF(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?OF(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):OF(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var DF=function(e){return e[e.DOWN=0]="DOWN",e[e.UP=1]="UP",e}(DF||{});const PF=new Map;function LF(e,t,i,n){let{scale:r}=e;if(0===r&&n===DF.UP||r>=t.length-1&&n===DF.DOWN)return e;let o=NF(NF({},e),{},{scale:n===DF.DOWN?++r:--r});switch(i){case"maintain-framerate":o=NF(NF({},o),t[r].motion);break;case"maintain-resolution":o=NF(NF({},o),t[r].detail);break;case"balanced":o=NF(NF({},o),t[r].balanced)}return o}function kF(e,t){if(t){const i={overUse:0,underUse:0,adaptationList:MF(t)};PF.set(e,i)}else PF.delete(e)}function MF(e){const t=NF({},e),{bitrateMax:i,frameRate:n,scaleResolutionDownBy:r,bitrateMin:o}=t,{MIN_FRAME_RATE:s,MAX_THRESHOLD_FRAMERATE:a,MAX_SCALE:c,BITRATE_MIN_THRESHOLD:d,BITRATE_MAX_THRESHOLD:l,BWE_SCALE_UP_THRESHOLD:u,BWE_SCALE_DOWN_THRESHOLD:h,PERF_SCALE_DOWN_THRESHOLD:p,PERF_SCALE_UP_THRESHOLD:_,BALANCE_BITRATE_FACTOR:E,BALANCE_FRAMERATE_FACTOR:m,BALANCE_RESOLUTION_FACTOR:f,MOTION_RESOLUTION_FACTOR:T,MOTION_BITRATE_FACTOR:S,DETAIL_FRAMERATE_FACTOR:g,DETAIL_BITRATE_FACTOR:R}=dN,v=Math.min(t.frameRate,a),C=[{scale:0,threshold:{bwe_down:Math.round(Math.pow(h,1)*i),bwe_up:i,fps_down:Math.round(Math.pow(p,1)*v),fps_up:n},balanced:{scaleResolutionDownBy:1,frameRate:n,bitrateMax:i,bitrateMin:o},motion:{scaleResolutionDownBy:1,frameRate:n,bitrateMax:i,bitrateMin:o},detail:{scaleResolutionDownBy:1,frameRate:n,bitrateMax:i,bitrateMin:o}}];for(let e=1;e<=c;e++){const t={bwe_up:Math.round(Math.pow(u,e)*i),bwe_down:Math.round(Math.pow(h,e+1)*i),fps_up:Math.round(Math.pow(_,e)*v),fps_down:Math.round(Math.pow(p,e+1)*v)},a={scaleResolutionDownBy:r/Math.pow(f,e),frameRate:Math.max(Math.round(Math.pow(m,e)*n),s),bitrateMax:Math.max(Math.round(Math.pow(E,e)*i),l),bitrateMin:Math.max(Math.round(Math.pow(E,e)*o),d)},c={scaleResolutionDownBy:r/Math.pow(T,e),frameRate:n,bitrateMax:Math.max(Math.round(Math.pow(S,e)*i),l),bitrateMin:Math.max(Math.round(Math.pow(S,e)*o),d)},I={scaleResolutionDownBy:1,frameRate:Math.max(Math.round(Math.pow(g,e)*n),s),bitrateMax:Math.max(Math.round(Math.pow(R,e)*i),l),bitrateMin:Math.max(Math.round(Math.pow(R,e)*o),d)};C.push({scale:e,threshold:t,balanced:a,motion:c,detail:I})}return C}function UF(e,t,i,n,r,o){const s=PF.get(e)||{overUse:0,underUse:0,adaptationList:MF(r)},{adaptationList:a}=s;PF.set(e,s);const{OVERUSE_TIMES_THRESHOLD:c,UNDERUSE_TIMES_THRESHOLD:d}=dN,{scale:l}=n;let u,h;return"number"==typeof t&&t>0&&function(e,t,i,n){if(t>=i.length)return!1;let{threshold:{fps_down:r}}=i[t];return _N("FORCE_AG_HIGH_FRAMERATE")&&"maintain-framerate"===n&&(r=i[0].threshold.fps_down),e<r}(t,l,a,o)&&(s.overUse++,h=qO.CPU,s.overUse>c)||"number"==typeof i&&i>0&&function(e,t,i){if(t>=i.length)return!1;const{threshold:{bwe_down:n}}=i[t];return e<n}(i,l,a)&&(s.overUse++,h=qO.BANDWIDTH,s.overUse>c)?(s.overUse=0,s.underUse=0,u=LF(n,a,o,DF.DOWN),[u,h]):("number"==typeof t&&t>0&&"number"==typeof i&&i>0&&function(e,t,i,n){if(0===t)return;let{threshold:{fps_up:r}}=i[t];return _N("FORCE_AG_HIGH_FRAMERATE")&&"maintain-framerate"===n&&(r=i[1].threshold.fps_up),e>r}(t,l,a,o)&&function(e,t,i){if(0===t)return;const{threshold:{bwe_up:n}}=i[t];return e>n}(i,l,a)&&(s.underUse++,s.underUse>d&&(s.overUse=0,s.underUse=0,u=LF(n,a,o,DF.UP),0===u.scale&&(h=qO.NONE))),[u,h])}function xF(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function VF(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};
12272t%2?xF(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):xF(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function FF(e){var t;return!!_N("ENABLE_AG_ADAPTATION")&&(!!(e instanceof _k||Dn(t=e._hints).call(t,vD.CUSTOM_TRACK))&&(!!_N("FORCE_SUPPORT_AG_ADAPTATION")||!!(function(e){const t=xb();if(t.os!==Pb.IOS||!t.osVersion)return!1;const i=t.osVersion.split(".");return Number(i[0])>=e}(14)&&Zb(17,4,!0)||Qb(14)&&$b(17,4,!0))))}const BF=new Map;function jF(e,t){const i=BF.get(e);if(i){const{timer:t}=i;window.clearTimeout(t),BF.delete(e)}t.qualityLimitationReason=qO.NONE,kF(e)}function GF(e,t){var i;let n;switch(t){case zU.LocalAudioTrack:n=PU.Audio;break;case zU.LocalVideoTrack:n=Dn(i=e._hints).call(i,vD.SCREEN_TRACK)?PU.Screen:PU.High;break;case zU.LocalVideoLowTrack:n=PU.Low}return n}function WF(e){const t=nD();if(e.some((e=>e._bypassWebAudio)))throw new mw(Ew.NOT_SUPPORTED,"cannot publish multiple tracks which one of them configured with bypassWebAudio");if(!t.webAudioMediaStreamDest)throw new mw(Ew.NOT_SUPPORTED,"cannot publish multiple tracks because your browser does not support audio mixing")}function HF(e,t){WF(e);const i=t||new bL;return e.forEach((e=>i.addAudioTrack(e))),i}const KF=!nD().supportUnifiedPlan||_N("CHROME_FORCE_PLAN_B")&&dw();function YF(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var i;return KF?(i={spec:t,store:e},CV("PlanBConnection").create(i)):new ZF(t,e)}function qF(e){return e&&("disconnected"===e.iceConnectionState||"checking"===e.iceConnectionState||"failed"===e.iceConnectionState)}function zF(e){try{if(e.iceServers)return!1;if(e.turnServer&&"off"!==e.turnServer.mode){if(Fw(e.turnServer.servers))return!1;if(_N("FORCE_TURN_TCP")||e.turnServer.servers.concat(e.turnServer.serversFromGateway||[]).some((e=>e.forceturn)))return!0}return!1}catch(e){return!1}}var XF;function JF(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function QF(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?JF(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):JF(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}let ZF=(XF=class e extends WU{get currentLocalDescription(){return this.peerConnection.currentLocalDescription}get currentRemoteDescription(){return this.peerConnection.currentRemoteDescription}get peerConnectionState(){return this.peerConnection.connectionState}get iceConnectionState(){return this.peerConnection.iceConnectionState}get dtlsTransportState(){var e,t;return null!==(e=null===(t=this.peerConnection.getReceivers()[0])||void 0===t||null===(t=t.transport)||void 0===t?void 0:t.state)&&void 0!==e?e:null}get localCodecs(){return[...new Set(this.localCapabilities&&this.localCapabilities.send.videoCodecs.map((e=>e.rtpMap&&e.rtpMap.encodingName.toLowerCase()||"")).filter((e=>{var t;return Dn(t=Object.keys(TN)).call(t,e)})))]}constructor(t,i){super(t,i),QI(this,"id",hO(5,"connection-")),QI(this,"store",void 0),QI(this,"peerConnection",void 0),QI(this,"forceTurn",!1),QI(this,"remoteSDP",void 0),QI(this,"initialOffer",void 0),QI(this,"transportEventReceiver",void 0),QI(this,"statsFilter",void 0),QI(this,"extension",{useXR:_N("USE_XR")}),QI(this,"localCapabilities",void 0),QI(this,"remoteCodecs",void 0),QI(this,"localCandidateCount",0),QI(this,"allCandidatesReceived",!1),QI(this,"isPreallocation",!1),QI(this,"preSSRCMap",new Map),QI(this,"dataStreamChannelMap",new Map),QI(this,"establishPromise",void 0),QI(this,"recoveredDataChannelIds",[]),QI(this,"currentDataChannelId",1),QI(this,"supportAV1RtpSpec",!1),QI(this,"mutex",void 0),QI(this,"qualityLimitationReason",qO.NONE),QI(this,"isFirstConnected",!1),this.store=i,this.forceTurn=zF(t),this.mutex=new IO("P2PConnection-mutex",i.clientId),this.peerConnection=new RTCPeerConnection(e.resolvePCConfiguration(t),{optional:[{googDscp:!0}]}),this.isFirstConnected=!1,this.statsFilter=tN(this.peerConnection,_N("STATS_UPDATE_INTERVAL"),void 0,Kb()?1200:void 0),this.bindPCEvents(),this.bindStatsEvents(),this.store.p2pId=this.store.p2pId+1,this.establishPromise=this.establish()}getPreMedia(e){const t=this.preSSRCMap.get(e);if(void 0!==t){const e=this.peerConnection.getTransceivers().find((e=>e.mid===t));if(e)return{transceiver:e,track:e.receiver.track,id:t}}}async updateRemoteRTPCapabilities(e,t){if(this.remoteCodecs=t,!this.remoteSDP)return void YN.debug("[P2PConnection] cannot updateRemoteRTPCapabilities before remote SDP created, local codecs: ".concat(this.localCodecs,", codecs: ").concat(t));if(this.remoteSDP.updateRemoteCodec(e,t,this.store.codec)){const e=await this.peerConnection.createOffer(),t=this.logSDPExchange(e.sdp||"","offer","local","muteLocal");await this.peerConnection.setLocalDescription(e);const i=this.remoteSDP.toString();null==t||t(i),await this.peerConnection.setRemoteDescription({type:"answer",sdp:i})}else YN.debug("[P2PConnection] updateRemoteRTPCapabilities no need to exchange SDP.")}async establish(){try{this.peerConnection.addTransceiver("video",{direction:"recvonly"}),this.peerConnection.addTransceiver("audio",{direction:"recvonly"});const i=await this.peerConnection.createOffer();if(!i.sdp)throw new Error("Cannot get initialOffer.sdp when trying to establish PeerConnection.");
12272const n=Xx(i.sdp),r=await sV({filterRTX:!_N("USE_PUB_RTX")&&!_N("USE_SUB_RTX"),filterVideoFec:_N("FILTER_VIDEO_FEC"),filterAudioFec:_N("FILTER_AUDIO_FEC"),filterVideoCodec:_N("FILTER_VIDEO_CODEC")},this.extension);if(this.localCapabilities=dV(r),this.initialOffer=i,_N("ENABLE_SVC")&&"av1"==this.store.codec){const t=await async function(){try{const e=new RTCPeerConnection;e.addTransceiver("video",{direction:"sendonly",sendEncodings:[{scalabilityMode:zO.L1T3}]});const t=await e.createOffer();if(!t.sdp)return void e.close();const i=yN(t.sdp).mediaDescriptions[0];if(!i)return;const n=i.attributes.extmaps.find((e=>"https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension"===e.extensionName));return e.close(),n}catch(e){return}}();var e;if(t)this.supportAV1RtpSpec=!0,null===(e=r.send)||void 0===e||e.videoExtensions.push(t)}let o;return i.sdp&&mV(i.sdp)&&(o=eO(r),(t=o).send&&(Wx(HU.VIDEO,t.send.videoExtensions),Wx(HU.AUDIO,t.send.audioExtensions)),t.recv&&(Wx(HU.VIDEO,t.recv.videoExtensions),Wx(HU.AUDIO,t.recv.audioExtensions)),t.sendrecv&&(Wx(HU.VIDEO,t.sendrecv.videoExtensions),Wx(HU.AUDIO,t.sendrecv.audioExtensions))),QF(QF({},n),{},{rtpCapabilities:o||r,offerSDP:i.sdp})}catch(e){throw new mw(Ew.GET_LOCAL_CONNECTION_PARAMS_FAILED,e.toString())}var t}async connect(e){try{if(!this.initialOffer)throw new Error("Cannot establish P2PConnection without initial offer.");this.initialOffer.sdp&&mV(this.initialOffer.sdp)&&(t=e.rtpCapabilities,i=this.localCapabilities,t.send&&(Gx(HU.VIDEO,t.send.videoExtensions,i.send.videoExtensions),Gx(HU.AUDIO,t.send.audioExtensions,i.send.audioExtensions)),t.recv&&(Gx(HU.VIDEO,t.recv.videoExtensions,i.recv.videoExtensions),Gx(HU.AUDIO,t.recv.audioExtensions,i.recv.audioExtensions))),this.remoteSDP=new class{get localCapabilities(){return eO(this._localCapabilities)}get rtpCapabilities(){return eO(this._rtpCapabilities)}get candidates(){return eO(this._candidates)}get iceParameters(){return eO(this._iceParameters)}get dtlsParameters(){return eO(this._dtlsParameters)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];QI(this,"sessionDesc",void 0),QI(this,"_localCapabilities",void 0),QI(this,"_rtpCapabilities",void 0),QI(this,"_candidates",void 0),QI(this,"_originCandidates",void 0),QI(this,"_iceParameters",void 0),QI(this,"_isUseExtmapAllowMixed",void 0),QI(this,"_dtlsParameters",void 0),QI(this,"setup",void 0),QI(this,"currentMidIndex",void 0),QI(this,"cname",void 0),QI(this,"firefoxSsrcMidMap",new Map),this._isUseExtmapAllowMixed=t,e=eO(e);const{iceParameters:i,dtlsParameters:n,candidates:r,rtpCapabilities:o,setup:s,localCapabilities:a,cname:c}=e;this._rtpCapabilities=o,this._candidates=r,this._originCandidates=eO(r),this._iceParameters=i,this._dtlsParameters=n,this._localCapabilities=a,this.setup=s,this.cname=c,this.sessionDesc=this.updateRemoteRTPCapabilities(o),this.currentMidIndex=this.sessionDesc.mediaDescriptions.length-1}preloadRemoteMedia(e){const t=this.candidates,i=this.dtlsParameters,n=this.iceParameters,r=this.rtpCapabilities.send;let o=this.sessionDesc.mediaDescriptions.length-1;for(let s=1;s<e;s++){const e=2*s+2e4,a=2*s+wF,{ssrcs:c,ssrcGroups:d}=$x([{ssrcId:e}],this.cname),{ssrcs:l,ssrcGroups:u}=$x([{ssrcId:a,rtx:_N("USE_SUB_RTX")?a+1:void 0}],this.cname);this.sessionDesc.mediaDescriptions.push({media:{mediaType:"video",port:bF,protos:["UDP","TLS","RTP","SAVPF"],fmts:r.videoCodecs.map((e=>e.payloadType.toString(10)))},connections:[{nettype:"IN",addrtype:"IP4",address:"127.0.0.1"}],bandwidths:[],attributes:{iceUfrag:n.iceUfrag,icePwd:n.icePwd,unrecognized:[],candidates:t,extmaps:r.videoExtensions,fingerprints:i.fingerprints,imageattr:[],msids:[],remoteCandidatesList:[],rids:[],ssrcs:l,ssrcGroups:u,rtcpFeedbackWildcards:[],payloads:r.videoCodecs,rtcp:{port:"9",netType:"IN",addressType:"IP4",address:"0.0.0.0"},setup:this.setup,direction:"sendonly",rtcpMux:!0,rtcpRsize:!0,mid:"".concat(++o)}}),this.sessionDesc.mediaDescriptions.push({media:{mediaType:"audio",port:bF,protos:["UDP","TLS","RTP","SAVPF"],fmts:r.audioCodecs.map((e=>e.payloadType.toString(10)))},connections:[{nettype:"IN",addrtype:"IP4",address:"127.0.0.1"}],bandwidths:[],attributes:{iceUfrag:n.iceUfrag,icePwd:n.icePwd,unrecognized:[],candidates:t,extmaps:r.audioExtensions,fingerprints:i.fingerprints,imageattr:[],msids:[],remoteCandidatesList:[],rids:[],ssrcs:c,ssrcGroups:d,rtcpFeedbackWildcards:[],payloads:r.audioCodecs,rtcp:{port:"9",netType:"IN",addressType:"IP4",address:"0.0.0.0"},setup:this.setup,direction:"sendonly",rtcpMux:!0,rtcpRsize:!0,mid:"".concat(++o)}}),this.currentMidIndex+=2}this.updateBundleMids()}toString(){return AN(this.sessionDesc)}send(e,t,i,n){const{ssrcs:r,ssrcGroups:o}=$x(t,this.cname,_N("SYNC_GROUP")?i:void 0),s=this.findPreloadMediaDesc(r);if(s){if(Kb()&&this.firefoxSsrcMidMap.set(r[0].ssrcId,s.attributes.mid),n&&(n.twcc||n.remb)){const e=this.sessionDesc.mediaDescriptions.indexOf(s);return this.sessionDesc.mediaDescriptions[e]=this.mungSendMediaDesc(s,n),{mid:s.attributes.mid,needExchangeSDP:!0}}return{mid:s.attributes.mid,needExchangeSDP:!1}}{const t=this.findAvailableMediaIndex(e,r);let i;return-1===t||1===t&&(Wb()||function(){const e=xb();return!(e.name!==Lb.CHROME||!e.osVersion)&&Number(e.version)<=90}()||_N("ENABLE_ENCODED_TRANSFORM")&&Gb())||0===t&&_N("USE_SUB_RTX")||tw()?(i=this.createOrRecycleSendMedia(e,r,o,"sendonly",n),this.updateBundleMids()):(i=eO(this.sessionDesc.mediaDescriptions[t]),i.attributes.direction="sendonly",i.attributes.ssrcs=r,i.attributes.ssrcGroups=o,this.sessionDesc.mediaDescriptions[t]=this.mungSendMediaDesc(i,n)),Kb()&&this.firefoxSsrcMidMap.set(r[0].ssrcId,i.attributes.mid),{mid:i.attributes.mid,needExchangeSDP:!0}}}
12272sendDataChannel(){const{mediaDesc:e,needExchangeSDP:t}=this.createOrRecycleDataChannel();return this.updateBundleMids(),{mid:e.attributes.mid,needExchangeSDP:t}}batchSend(e){const t=e.map((e=>{let{kind:t,ssrcMsg:i,mslabel:n}=e;return this.send(t,i,n)})),i=[];let n=!1;return t.forEach((e=>{let{mid:t,needExchangeSDP:r}=e;r&&(n=!0),i.push(t)})),{mids:i,needExchangeSDP:n}}stopSending(e){const t=this.sessionDesc.mediaDescriptions.filter((t=>t.attributes.mid&&-1!==e.indexOf(t.attributes.mid)));if(t.length!==e.length)throw new Error("mediaDescriptions' length doesn't match mids' length when calling RemoteSDP.stopSending.");t.forEach((e=>{"0"===e.attributes.mid||Kb()||tw()?e.attributes.ssrcs=[]:(e.attributes.ssrcs=[],e.attributes.direction="inactive",e.media.port="0")})),this.updateBundleMids()}mute(e){const t=this.sessionDesc.mediaDescriptions.find((t=>t.attributes.mid===e));if(!t)throw new Error("mediaDescription not found with ".concat(e," in remote SDP when calling RemoteSDP.mute."));t.attributes.direction="inactive"}unmute(e){const t=this.sessionDesc.mediaDescriptions.find((t=>t.attributes.mid===e));if(!t)throw new Error("mediaDescription not found with ".concat(e," in remote SDP when calling RemoteSDP.unmute."));t.attributes.direction="sendonly"}muteRemote(e){const t=this.sessionDesc.mediaDescriptions.filter((t=>Dn(e).call(e,t.attributes.mid||"")));if(t.length!==e.length)throw new Error("mediaDescriptions' length doesn't match mids' length when calling RemoteSDP.muteRemote.");t.forEach((e=>{e.attributes.direction="inactive"}))}unmuteRemote(e){const t=this.sessionDesc.mediaDescriptions.filter((t=>Dn(e).call(e,t.attributes.mid||"")));if(t.length!==e.length)throw new Error("mediaDescriptions' length doesn't match mids' length when calling RemoteSDP.muteRemote.");t.forEach((e=>{e.attributes.direction="recvonly"}))}receive(e,t,i,n){e.forEach(((e,r)=>{this.createOrRecycleRecvMedia(e,[],"recvonly",t,i,n[r])})),this.updateBundleMids()}stopReceiving(e){const t=this.sessionDesc.mediaDescriptions.filter((t=>-1!==e.indexOf(t.attributes.mid)));if(t.length!==e.length)throw new Error("MediaDescriptions' length doesn't match mids's length when calling RemoteSDP.receive.");t.forEach((e=>{e.media.port="0",e.attributes.direction="inactive"})),this.updateBundleMids()}updateRemoteRTPCapabilities(e){const t=this.sessionDesc||yN((i=this._isUseExtmapAllowMixed,"v=0\no=- 0 0 IN IP4 127.0.0.1\ns=AgoraGateway\nt=0 0\na=group:BUNDLE 0 1\na=msid-semantic: WMS\na=ice-lite".concat(i?"\na=extmap-allow-mixed":"","\nm=video 9 UDP/TLS/RTP/SAVPF 0\nc=IN IP4 127.0.0.1\na=rtcp:9 IN IP4 0.0.0.0\na=sendonly\na=rtcp-mux\na=rtcp-rsize\na=mid:0\nm=audio 9 UDP/TLS/RTP/SAVPF 0\nc=IN IP4 127.0.0.1\na=rtcp:9 IN IP4 0.0.0.0\na=sendonly\na=rtcp-mux\na=rtcp-rsize\na=mid:1\n")));var i;this._rtpCapabilities=e;const n=this.rtpCapabilities.send,r=this.localCapabilities.send;for(const e of t.mediaDescriptions){if(e.attributes.iceUfrag=this._iceParameters.iceUfrag,e.attributes.icePwd=this._iceParameters.icePwd,e.attributes.fingerprints=this._dtlsParameters.fingerprints,e.attributes.candidates=this._candidates,e.attributes.setup=this.setup,"application"===e.media.mediaType&&(e.attributes.sctpPort="5000"),"video"===e.media.mediaType)if(0===n.videoCodecs.length){const t=r.videoCodecs.filter((e=>{var t,i;return null===(t=e.rtpMap)||void 0===t?void 0:Dn(i=t.encodingName.toLowerCase()).call(i,"vp8")}))||[r.videoCodecs[0]];e.media.fmts=t.map((e=>e.payloadType.toString(10))),e.attributes.payloads=t,e.attributes.extmaps=[]}else if(e.media.fmts=n.videoCodecs.map((e=>e.payloadType.toString(10))),e.attributes.payloads=n.videoCodecs,e.attributes.extmaps=n.videoExtensions,_N("PRELOAD_MEDIA_COUNT")>0){const{ssrcs:t,ssrcGroups:i}=$x([{ssrcId:wF,rtx:_N("USE_SUB_RTX")?40001:void 0}],this.cname);e.attributes.ssrcs=t,e.attributes.ssrcGroups=i}if("audio"===e.media.mediaType)if(0===n.audioCodecs.length){const t=r.audioCodecs.filter((e=>{var t,i;return null===(t=e.rtpMap)||void 0===t?void 0:Dn(i=t.encodingName.toLowerCase()).call(i,"opus")}))||[r.audioCodecs[0]];e.media.fmts=t.map((e=>e.payloadType.toString(10))),e.attributes.payloads=t,e.attributes.extmaps=[]}else if(e.media.fmts=n.audioCodecs.map((e=>e.payloadType.toString(10))),e.attributes.payloads=n.audioCodecs,e.attributes.extmaps=n.audioExtensions,lV(e),_N("PRELOAD_MEDIA_COUNT")>0){const{ssrcs:t,ssrcGroups:i}=$x([{ssrcId:2e4}],this.cname);e.attributes.ssrcs=t,e.attributes.ssrcGroups=i}}return this.sessionDesc=t,this.currentMidIndex=t.mediaDescriptions.length-1,this.sessionDesc}updateCandidates(e){const t=this._originCandidates.filter((e=>"udp"===e.transport)),i=[];if(t.forEach((e=>{i.push(AF(AF({},e),{},{foundation:"tcpcandidate",priority:Number(e.priority)-1+"",transport:"tcp",port:Number(e.port)+90+""}))})),0!==t.length){switch(e){case KU.TCP_RELAY:this._candidates=i;break;case KU.UDP_TCP_RELAY:case KU.RELAY:this._candidates=[...t,...i];break;default:this._candidates=t}for(const e of this.sessionDesc.mediaDescriptions)e.attributes.candidates=this.candidates}}restartICE(e){e=eO(e),this._iceParameters=e,this.sessionDesc.mediaDescriptions.forEach((t=>
vendor: 11,979 bytes, line 12272
12272{t.attributes.iceUfrag=e.iceUfrag,t.attributes.icePwd=e.icePwd}))}predictReceivingMids(e){const t=[];for(let i=0;i<e;i++)t.push((this.currentMidIndex+i+1).toString(10));return t}findAvailableMediaIndex(e,t){return this.sessionDesc.mediaDescriptions.findIndex((i=>{const n=i.media.mediaType===e&&"0"!==i.media.port&&("sendonly"===i.attributes.direction||"sendrecv"===i.attributes.direction)&&0===i.attributes.ssrcs.length;if(Kb()){if(n){const e=this.firefoxSsrcMidMap.get(t[0].ssrcId);return!(e||"0"!==i.attributes.mid&&"1"!==i.attributes.mid)||!(!e||e!==i.attributes.mid)}return!1}return n}))}createOrRecycleDataChannel(){for(const e of this.sessionDesc.mediaDescriptions)if("application"===e.media.mediaType)return{mediaDesc:e,needExchangeSDP:!1};this.currentMidIndex+=1;const e="".concat(this.currentMidIndex),t={media:{mediaType:"application",port:bF,protos:["UDP","DTLS","SCTP"],fmts:["webrtc-datachannel"]},connections:[{nettype:"IN",addrtype:"IP4",address:"127.0.0.1"}],bandwidths:[],attributes:{iceUfrag:this.iceParameters.iceUfrag,icePwd:this.iceParameters.icePwd,unrecognized:[],candidates:this.candidates,extmaps:[],fingerprints:this.dtlsParameters.fingerprints,imageattr:[],msids:[],remoteCandidatesList:[],rids:[],ssrcs:[],ssrcGroups:[],rtcpFeedbackWildcards:[],payloads:[],rtcp:{port:"9",netType:"IN",addressType:"IP4",address:"0.0.0.0"},setup:this.setup,mid:"".concat(e),sctpPort:"5000"}};return this.sessionDesc.mediaDescriptions.push(t),{mediaDesc:t,needExchangeSDP:!0}}createOrRecycleRecvMedia(e,t,i,n,r,o){const s=e._mediaStreamTrack.kind,a=this.rtpCapabilities.recv,c=uV(s,a,this.localCapabilities.send,s===HU.VIDEO?n:r),d=s===HU.VIDEO?a.videoExtensions:a.audioExtensions;this.currentMidIndex+=1;const l="".concat(this.currentMidIndex);let u={media:{mediaType:s,port:bF,protos:["UDP","TLS","RTP","SAVPF"],fmts:c.map((e=>e.payloadType.toString(10)))},connections:[{nettype:"IN",addrtype:"IP4",address:"127.0.0.1"}],bandwidths:[],attributes:{iceUfrag:this.iceParameters.iceUfrag,icePwd:this.iceParameters.icePwd,unrecognized:[],candidates:this.candidates,extmaps:d,fingerprints:this.dtlsParameters.fingerprints,imageattr:[],msids:[],remoteCandidatesList:[],rids:[],ssrcs:t,ssrcGroups:[],rtcpFeedbackWildcards:[],payloads:c,rtcp:{port:"9",netType:"IN",addressType:"IP4",address:"0.0.0.0"},setup:this.setup,direction:i,rtcpMux:!0,rtcpRsize:!0,mid:"".concat(l)}};u=this.mungRecvMediaDsec(u,e,o);const h=this.findFirstClosedMedia(s);if(h){const e=this.sessionDesc.mediaDescriptions.indexOf(h);this.sessionDesc.mediaDescriptions[e]=u}else this.sessionDesc.mediaDescriptions.push(u);return u}updateRemoteCodec(e,t,i){const n=[...new Set(this._rtpCapabilities.recv.videoCodecs.map((e=>e.rtpMap&&e.rtpMap.encodingName.toLowerCase()||"")).filter((e=>{var t;return Dn(t=Object.keys(TN)).call(t,e)})))],r=new Set(t);if(n.every((e=>r.has(e))))return YN.debug("codecs has not changed, no need to updateRemoteCodec, codecs: ".concat(t)),!1;const o=this._rtpCapabilities.recv.videoCodecs.filter((e=>t.some((t=>{var i;return Dn(i=e.rtpMap&&e.rtpMap.encodingName.toLowerCase()||"").call(i,t)}))));if(0===o.length)return YN.debug("updateRemoteCodec failed, because cannot find matched codec, remoteCapabilities codecs: ".concat(n," codecs: ").concat(t)),!1;const s=[...new Set(o.map((e=>e.rtpMap&&e.rtpMap.encodingName.toLowerCase()||"")))];let a;if(YN.debug("updateRemoteCodec, from ".concat(n," to ").concat(s)),0===e.length)a=this.sessionDesc.mediaDescriptions.filter((e=>"video"===e.media.mediaType&&"recvonly"===e.attributes.direction));else if(a=this.sessionDesc.mediaDescriptions.filter((t=>t.attributes.mid&&Dn(e).call(e,t.attributes.mid)&&"recvonly"===t.attributes.direction)),a.length!==e.length)return YN.debug("updateRemoteCodec failed, because cannot find mids, mids: ".concat(e,", codecs: ").concat(t)),!1;if(_N("USE_PUB_RTX")||_N("USE_SUB_RTX")){const e=hV(o,this.rtpCapabilities.recv.videoCodecs);o.push(...e)}this._rtpCapabilities.recv.videoCodecs=o;const c=this.localCapabilities.send,d=this.rtpCapabilities.recv,l=uV(HU.VIDEO,d,c,i);return a.forEach((e=>{const t=l.map((e=>e.payloadType.toString(10)));YN.debug("updateRemoteCodec mid: ".concat(e.attributes.mid,", from"),e.attributes.payloads,"to",l),e.attributes.payloads=l,e.media.fmts=t})),!0}createOrRecycleSendMedia(e,t,i,n,r){const o=this.rtpCapabilities.send,s=e===HU.VIDEO?o.videoCodecs:o.audioCodecs,a=e===HU.VIDEO?o.videoExtensions:o.audioExtensions;this.currentMidIndex+=1;const c="".concat(this.currentMidIndex);let d={media:{mediaType:e,port:bF,protos:["UDP","TLS","RTP","SAVPF"],fmts:s.map((e=>e.payloadType.toString(10)))},connections:[{nettype:"IN",addrtype:"IP4",address:"127.0.0.1"}],bandwidths:[],attributes:{iceUfrag:this.iceParameters.iceUfrag,icePwd:this.iceParameters.icePwd,unrecognized:[],candidates:this.candidates,extmaps:a,fingerprints:this.dtlsParameters.fingerprints,imageattr:[],msids:[],remoteCandidatesList:[],rids:[],ssrcs:t,ssrcGroups:i,rtcpFeedbackWildcards:[],payloads:s,rtcp:{port:"9",netType:"IN",addressType:"IP4",address:"0.0.0.0"},setup:this.setup,direction:n,rtcpMux:!0,rtcpRsize:!0,mid:"".concat(c)}};d=this.mungSendMediaDesc(d,r);const l=this.findFirstClosedMedia(e);if(l){const e=this.sessionDesc.mediaDescriptions.indexOf(l);this.sessionDesc.mediaDescriptions[e]=d}else this.sessionDesc.mediaDescriptions.push(d);return d}updateBundleMids(){this.sessionDesc.attributes.groups[0].identificationTag=this.sessionDesc.mediaDescriptions.filter((e=>"0"!==e.media.port)).map((e=>e.attributes.mid))}mungRecvMediaDsec(e,t,i){const n=eO(e);return tV(n),eV(n,t),iV(n,t),nV(n),rV(n,i,this.localCapabilities.send),n}mungSendMediaDesc(e,t){const i=eO(e);return rV(i,t,this.localCapabilities.recv),lV(i),i}updateRecvMedia(e,t){const i=this.sessionDesc.mediaDescriptions.findIndex((t=>t.attributes.mid===e));if(-1!==i){const e=this.mungRecvMediaDsec(this.sessionDesc.mediaDescriptions[i],t);this.sessionDesc.mediaDescriptions[i]=e}}bumpMid(e){this.currentMidIndex+=e}findFirstClosedMedia(e){return this.sessionDesc.mediaDescriptions.find((t=>Kb()?"0"===t.media.port&&t.media.mediaType===e:"0"===t.media.port))}findPreloadMediaDesc(e){return this.sessionDesc.mediaDescriptions.find((t=>{var i;return(null===(i=t.attributes)||void 0===i||null===(i=i.ssrcs[0])||void 0===i?void 0:i.ssrcId)===e[0].ssrcId}))}getSSRC(e){var t;return null===(t=this.sessionDesc.mediaDescriptions.find((t=>t.attributes.mid===e)))||void 0===t?void 0:t.attributes.ssrcs}}(QF(QF({},e),{},{localCapabilities:this.localCapabilities}),this.supportAV1RtpSpec),e.preallocation&&(this.isPreallocation=!0),Array.isArray(this.remoteCodecs)&&this.remoteCodecs.length>0&&this.remoteSDP.updateRemoteCodec([],this.remoteCodecs,this.store.codec);const n=this.remoteSDP.toString(),r=_V(this.initialOffer.sdp,this.extension),o=this.logSDPExchange(r||"","offer","local","connect");this.store.descriptionStart(),await this.peerConnection.setLocalDescription({type:"offer",sdp:r}),null==o||o(n),await this.peerConnection.setRemoteDescription({type:"answer",sdp:n});const s=this.peerConnection.getTransceivers()[0];if(null!=s&&s.receiver&&this.tryBindTransportEvents(s.receiver),_N("PRELOAD_MEDIA_COUNT")>0){this.remoteSDP.preloadRemoteMedia(_N("PRELOAD_MEDIA_COUNT"));const e=this.remoteSDP.toString();await this.peerConnection.setRemoteDescription({type:"offer",sdp:e});const t=await this.peerConnection.createAnswer();await this.peerConnection.setLocalDescription(t)}const{preSSRCs:a}=e;if(Array.isArray(a)&&a.length>0){const{mids:e}=this.remoteSDP.batchSend(a.map((e=>({kind:e.kind,ssrcMsg:[{ssrcId:e.ssrcId,rtx:e.rtx}],mslabel:e.mslabel}))));e.forEach(((e,t)=>{this.preSSRCMap.set(a[t].ssrcId,e)})),await pV(this.peerConnection,this.remoteSDP,this.extension),YN.debug("[".concat(this.store.clientId,"] [P2PConnection] pre-batchReceive exchange SDP."))}}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.connect failed; ".concat(e.toString()))}var t,i}async updateRemoteConnect(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.updateRemoteConnect before remote SDP created");const{rtpCapabilities:t}=e;this.remoteSDP.updateRemoteRTPCapabilities(t),Array.isArray(this.remoteCodecs)&&this.remoteCodecs.length>0&&this.remoteSDP.updateRemoteCodec([],this.remoteCodecs,this.store.codec);const{preSSRCs:i}=e;if(Array.isArray(i)&&i.length>0){const{mids:e}=this.remoteSDP.batchSend(i.map((e=>Object.assign({},{kind:e.kind,ssrcMsg:[{ssrcId:e.ssrcId,rtx:e.rtx}],mslabel:e.mslabel}))));e.forEach(((e,t)=>{this.preSSRCMap.set(i[t].ssrcId,e)}))}await pV(this.peerConnection,this.remoteSDP,this.extension),YN.debug("[P2PConnection] updateRemoteRTPCapabilities by exchanging SDP.")}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.updateRemoteConnect failed; ".concat(e.toString()))}}send(e,t,i){var n=this;return FA((function*(){const r=yield BA(n.mutex.lock("From P2PConnection.send"));try{if(!n.remoteSDP)throw new Error("Cannot call P2PConnection.send before remote SDP created");const o=[],s=Bx();e.forEach((e=>{const t=n.peerConnection.addTransceiver(e._mediaStreamTrack,QF({direction:"sendonly"},"video"===e.trackMediaType&&n.supportAV1RtpSpec&&s?{sendEncodings:[{scalabilityMode:s}]}:{}));o.push(t),e._updateRtpTransceiver(t)})),Kb()&&!0===_N("SIMULCAST")&&(yield BA(n.applySimulcastForFirefox(o,e)));const a=yield BA(n.peerConnection.createOffer()),c=n.remoteSDP.predictReceivingMids(e.length),d=n.mungSendOfferSDP(a.sdp,e,c),l=yN(d),u=c.map((e=>{const t=l.mediaDescriptions.find((t=>t.attributes.mid===e));if(!t)throw new Error("Cannot extract ssrc from mediaDescription.");return Jx(t,_N("USE_PUB_RTX"))}));let h;try{h=yield u}catch(r){h=[],n.remoteSDP.receive(e,t,i,h);const o=n.remoteSDP.toString();throw yield BA(n.peerConnection.setLocalDescription({type:"offer",sdp:d})),yield BA(n.peerConnection.setRemoteDescription({type:"answer",sdp:o})),yield BA(n.stopSending(c,!0)),r}n.remoteSDP.receive(e,t,i,h);const p=n.remoteSDP.toString(),_=n.logSDPExchange(d,"offer","local","send");return yield BA(n.peerConnection.setLocalDescription({type:"offer",sdp:d})),yield BA(n.applySimulcastEncodings(o,e)),yield BA(n.applySendEncodings(o,e)),null==_||_(p),yield BA(n.peerConnection.setRemoteDescription({type:"answer",sdp:p})),o.map(((e,t)=>{const i=c[t];return{localSSRC:u[t],id:i,transceiver:e}}))}catch(e){throw e instanceof mw?e:new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.send failed; ".concat(e.toString()))}finally{r()}}))()}async createDataChannels(e,t){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.createDataChannels before remote SDP created");let i=this.dataStreamChannelMap.get(e);if(i&&"open"===i.readyState)YN.debug("[P2PConnection] Channels are already available and can be reused directly.");else{const t=this.currentDataChannelId<1023?this.currentDataChannelId++:this.recoveredDataChannelIds.shift();if("number"!=typeof t)throw new Error("create DataChannel error, because cannot get dc id");i=this.peerConnection.createDataChannel("datastream-channel",{id:t,negotiated:!0,ordered:!1,maxRetransmits:_N("DATASTREAM_MAX_RETRANSMITS")}),i.binaryType="arraybuffer",this.dataStreamChannelMap.set(e,i)}t.forEach((e=>{e._updateOriginDataChannel(i)}));const{needExchangeSDP:n}=this.remoteSDP.sendDataChannel();if(n){const e=this.remoteSDP.toString();await this.peerConnection.setRemoteDescription({type:"offer",sdp:e});const t=await this.peerConnection.createAnswer();await this.peerConnection.setLocalDescription(t),YN.debug("[P2PConnection] createDataChannels by exchanging SDP.")}else YN.debug("[P2PConnection] createDataChannels no need to exchange SDP.");return}catch(e){throw e instanceof mw?e:new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.createDataChannels failed; ".concat(e.toString()))}}async stopDataChannels(e){try{const t=this.dataStreamChannelMap.get(e);return t&&(t.id&&this.recoveredDataChannelIds.push(t.id),t.close()),void this.dataStreamChannelMap.delete(e)}catch(e){throw e instanceof mw?e:new mw(Ew.DATACHANNEL_FAILED,"P2PConnection.stopD
12272ataChannels failed; ".concat(e.toString()))}}async stopSending(e,t){const i=t?void 0:await this.mutex.lock("From P2PConnection.stopSending");try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.stopSending before remote SDP created");const t=this.peerConnection.getTransceivers().filter((t=>-1!==e.indexOf(t.mid)));if(t.length!==e.length)throw new Error("Transceivers' length doesn't match mids' length when trying to call P2PConnection.stopSending.");t.map((e=>{var t;jF(this.id+e.mid,this),e.direction="inactive",null===(t=e.stop)||void 0===t||t.call(e)}));const n=await this.peerConnection.createOffer(),r=this.logSDPExchange(n.sdp||"","offer","local","stopSending");await this.peerConnection.setLocalDescription(n),this.remoteSDP.stopReceiving(e);const o=this.remoteSDP.toString();null==r||r(o),await this.peerConnection.setRemoteDescription({type:"answer",sdp:o})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.stopSending failed; ".concat(e.toString()))}finally{i&&i()}}async receive(e,t,i,n){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.receive ".concat(e," before remoteSDP created."));const{mid:r,needExchangeSDP:o}=this.remoteSDP.send(e,t,i,n);o&&(await pV(this.peerConnection,this.remoteSDP,this.extension),YN.debug("[".concat(this.store.clientId,"] [P2PConnection] receive ").concat(e," by exchanging SDP.")));const s=this.peerConnection.getTransceivers().find((e=>e.mid===r));if(!s)throw new Error("Cannot get transceiver after setLocalDescription.");return{track:s.receiver.track,id:r,transceiver:s}}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.receive failed; ".concat(e.toString()))}}async batchReceive(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.batchReceive before remoteSDP created.");const{mids:t,needExchangeSDP:i}=this.remoteSDP.batchSend(e);return i&&(await pV(this.peerConnection,this.remoteSDP,this.extension),YN.debug("[".concat(this.store.clientId,"] [P2PConnection] batchReceive by exchanging SDP."))),t.map((e=>{const t=this.peerConnection.getTransceivers().find((t=>t.mid===e));if(!t)throw new Error("Cannot get transceiver after setLocalDescription.");return{track:t.receiver.track,id:e,transceiver:t}}))}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.receive failed; ".concat(e.toString()))}}async stopReceiving(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.stopReceiving before remote SDP created.");e.forEach((e=>{Array.from(this.preSSRCMap.entries()).some((t=>{let[i,n]=t;if(n===e)return this.preSSRCMap.delete(i),!0}))})),this.remoteSDP.stopSending(e);const t=this.remoteSDP.toString(),i=this.logSDPExchange(t,"offer","remote","stopReceiving");await this.peerConnection.setRemoteDescription({type:"offer",sdp:t});const n=await this.peerConnection.createAnswer();null==i||i(n.sdp||""),await this.peerConnection.setLocalDescription(n)}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection stopReceiving failed; ".concat(e.toString()))}}async muteRemote(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.muteRemote mid=".concat(e," before remote SDP created."));this.remoteSDP.mute(e);const t=this.remoteSDP.toString(),i=this.logSDPExchange(t,"offer","remote","muteRemote");await this.peerConnection.setRemoteDescription({type:"offer",sdp:t});const n=await this.peerConnection.createAnswer();null==i||i(n.sdp||""),await this.peerConnection.setLocalDescription(n)}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.muteRemote failed; ".concat(e.toString()))}}async unmuteRemote(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.unmuteRemote mid=".concat(e," before remote SDP created."));this.remoteSDP.unmute(e);const t=this.remoteSDP.toString(),i=this.logSDPExchange(t,"offer","remote","unmuteRemote");await this.peerConnection.setRemoteDescription({type:"offer",sdp:t});const n=await this.peerConnection.createAnswer();null==i||i(n.sdp||""),await this.peerConnection.setLocalDescription(n)}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.unmuteRemote failed; ".concat(e.toString()))}}async muteLocal(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.muteLocal before remote SDP created.");const t=this.peerConnection.getTransceivers().filter((t=>
vendor: 6,112 bytes, line 12272
12272t.mid&&-1!==e.indexOf(t.mid)));if(t.length!==e.length)throw new Error("Transceivers' length doesn't match mids' length.");t.map((e=>{e.direction="inactive"}));const i=await this.peerConnection.createOffer(),n=this.logSDPExchange(i.sdp||"","offer","local","muteLocal");await this.peerConnection.setLocalDescription(i),this.remoteSDP.muteRemote(e);const r=this.remoteSDP.toString();null==n||n(r),await this.peerConnection.setRemoteDescription({type:"answer",sdp:r})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.muteLocal failed; ".concat(e.toString()))}}async unmuteLocal(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.unmuteLocal before remote SDP created.");const t=this.peerConnection.getTransceivers().filter((t=>t.mid&&-1!==e.indexOf(t.mid)));if(t.length!==e.length)throw new Error("Transceivers' length doesn't match mids' length.");t.map((async(e,t)=>{e.direction="sendonly"}));const i=await this.peerConnection.createOffer(),n=this.logSDPExchange(i.sdp||"","offer","local","unmuteLocal");await this.peerConnection.setLocalDescription(i),this.remoteSDP.unmuteRemote(e),Array.isArray(this.remoteCodecs)&&this.remoteCodecs.length>0&&this.remoteSDP.updateRemoteCodec(e,this.remoteCodecs,this.store.codec);const r=this.remoteSDP.toString();null==n||n(r),await this.peerConnection.setRemoteDescription({type:"answer",sdp:r})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.unmuteLocal failed; ".concat(e.toString()))}}restartICE(e){var t=this;return FA((function*(){const i=yield BA(t.mutex.lock("From P2PConnection.restartICE"));try{if(!t.remoteSDP)throw new Error("Cannot restartICE before remoteSDP created.");const n=nD().supportPCSetConfiguration,r=_N("FORCE_TURN_TCP")||t.forceTurn;if(e===KU.RELAY&&!n)return;if(n&&!r){const i=e===KU.RELAY?"relay":"all",n=t.peerConnection.getConfiguration();n.iceTransportPolicy!==i&&(YN.debug("[".concat(t.store.clientId,"] restartICE change iceTransportPolicy from [").concat(n.iceTransportPolicy,"] to [").concat(i,"]")),n.iceTransportPolicy=i,t.peerConnection.setConfiguration(n))}t.remoteSDP.updateCandidates(e);const o=yield BA(t.peerConnection.createOffer({iceRestart:!0}));if(!o.sdp)throw new Error("Cannot restartICE because restart offer SDP does not exist.");const s=Xx(o.sdp),{remoteIceParameters:a}=yield s.iceParameters;t.remoteSDP.restartICE(a);const c=t.remoteSDP.toString(),d=t.logSDPExchange(o.sdp||"","offer","local","restartICE");t.store.descriptionStart(),yield BA(t.peerConnection.setLocalDescription(o)),null==d||d(c),yield BA(t.peerConnection.setRemoteDescription({type:"answer",sdp:c}))}catch(e){YN.warning("[".concat(t.store.clientId,"] restart ICE failed, abort operation"),e)}finally{i()}}))()}async extendCandidate(){if(!this.remoteSDP||this.isFirstConnected)return;const e=await this.mutex.lock("From P2PConnection.extendCandidate");try{this.remoteSDP.updateCandidates(KU.TCP_RELAY),await pV(this.peerConnection,this.remoteSDP,this.extension)}catch(e){YN.warning("[".concat(this.store.clientId,"] extend candidate failed, abort operation"),e)}finally{e()}}close(){var e;this.peerConnection.getTransceivers().forEach((e=>{jF(this.id+e.mid,this)})),this.preSSRCMap.clear(),this.peerConnection.close(),null===(e=this.onConnectionStateChange)||void 0===e||e.call(this,"closed"),this.tryUnbindTransportEvents(),this.unbindPCEvents(),this.unbindStatsEvents(),this.removeAllListeners(),this.transportEventReceiver=void 0,this.statsFilter.destroy(),this.dataStreamChannelMap.clear(),this.recoveredDataChannelIds=[],this.currentDataChannelId=1}getStats(){return QF(QF({},this.statsFilter.getStats()),{},{qualityLimitationReason:this.qualityLimitationReason})}getRemoteVideoIsReady(e){return this.statsFilter.getVideoIsReady(e)}async updateEncoderConfig(e,t){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.updateEncoderConfig before remote SDP created.");const i=await this.peerConnection.createOffer(),n=this.mungSendOfferSDP(i.sdp,[t],[e]);this.remoteSDP.updateRecvMedia(e,t);const r=this.remoteSDP.toString(),o=this.logSDPExchange(n,"offer","local","updateEncoderConfig");await this.peerConnection.setLocalDescription({type:"offer",sdp:n}),null==o||o(r),await this.peerConnection.setRemoteDescription({type:"answer",sdp:r})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,e.toString())}}async updateSendParameters(e,t){const i=this.peerConnection.getTransceivers().filter((t=>t.mid===e));1===i.length&&(this.isVP8Simulcast(t)?Kb()||await this.applySimulcastEncodings(i,[t]):await this.applySendEncodings(i,[t]))}setStatsRemoteVideoIsReady(e,t){this.statsFilter.setVideoIsReady2(e,t)}async replaceTrack(e,t){const i=this.peerConnection.getTransceivers().find((e=>e.mid===t));i&&await i.sender.replaceTrack(e._mediaStreamTrack)}async getSelectedCandidatePair(){const e=this.peerConnection.getReceivers();if(e.length>0&&e[0].transport&&e[0].transport.iceTransport&&e[0].transport.iceTransport.getSelectedCandidatePair&&e[0].transport.iceTransport.getSelectedCandidatePair()){const t=e[0].transport.iceTransport,{local:i,remote:n}=t.getSelectedCandidatePair();return{local:QF(QF({},FO),{},{candidateType:i.type,protocol:i.protocol,address:i.address,port:i.port}),remote:QF(QF({},FO),{},{candidateType:n.type,protocol:n.protocol,address:n.address,port:n.port})}}return this.statsFilter.getSelectedCandidatePair()}bindPCEvents(){this.peerConnection.oniceconnectionstatechange=()=>{var e;null===(e=this.onICEConnectionStateChange)||void 0===e||e.call(this,this.peerConnection.iceConnectionState)},this.peerConnection.onconnectionstatechange=()=>{var e;"connected"===this.peerConnection.connectionState&&(this.isFirstConnected=!0),null===(e=this.onConnectionStateChange)||void 0===e||e.call(this,this.peerConnection.connectionState)},this.peerConnection.onicecandidateerror=e=>{if(e&&(e.errorCode||e.errorText)){var t;const i="code: ".concat(e.errorCode,", message: ").concat(e.errorText),n=e.port?"local: ".concat(e.port):"";YN.debug("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.onICECandidateError(").concat(i,"), url: ").concat(e.url||"",", host_c
12272andidate:").concat(n)),null===(t=this.onICECandidateError)||void 0===t||t.call(this,i)}},this.peerConnection.onicegatheringstatechange=e=>{e&&e.target&&"iceGatheringState"in e.target&&YN.debug("[".concat(this.store.clientId,"] [pc-").concat(this.store.p2pId,"] RTCPeerConnection.onicegatheringstatechange(").concat(e.target.iceGatheringState,")"))},this.peerConnection.onicecandidate=e=>{e.candidate?this.localCandidateCount+=1:(this.peerConnection.onicecandidate=null,this.allCandidatesReceived=!0,YN.debug("[".concat(this.store.clientId,"] [pc-").concat(this.store.p2pId,"] local candidate count"),this.localCandidateCount))},setTimeout((()=>{this.allCandidatesReceived||(this.allCandidatesReceived=!0,YN.debug("[".concat(this.store.clientId,"] [pc-").concat(this.store.p2pId,"] onicecandidate timeout, local candidate count"),this.localCandidateCount))}),_N("CANDIDATE_TIMEOUT"))}unbindPCEvents(){this.peerConnection.oniceconnectionstatechange=null,this.peerConnection.onconnectionstatechange=null,this.peerConnection.onsignalingstatechange=null,this.peerConnection.onicecandidateerror=null,this.peerConnection.onicecandidate=null,this.peerConnection.ontrack=null}static resolvePCConfiguration(t){const i={iceServers:[]};return t.iceServers?i.iceServers=t.iceServers:t.turnServer&&(Fw(t.turnServer.servers)?i.iceServers=t.turnServer.servers:_N("NEW_TURN_MODE")&&i.iceServers?(_N("USE_TURN_SERVER_OF_GATEWAY")?t.turnServer.serversFromGateway&&i.iceServers.push(...e.newTurnServerConfigToIceServers(t.turnServer.serversFromGateway)):i.iceServers.push(...e.newTurnServerConfigToIceServers(t.turnServer.servers)),_N("NEW_FORCE_TURN")&&(i.iceTransportPolicy="relay")):"off"!==t.turnServer.mode&&(i.iceServers&&i.iceServers.push(...e.turnServerConfigToIceServers(t.turnServer.servers)),_N("USE_TURN_SERVER_OF_GATEWAY")&&i.iceServers&&t.turnServer.serversFromGateway&&i.iceServers.push(...e.turnServerConfigToIceServers(t.turnServer.serversFromGateway)),_N("FORCE_TURN_TCP")?i.iceTransportPolicy="relay":t.turnServer.servers.concat(t.turnServer.serversFromGateway||[]).forEach((e=>{e.forceturn&&(i.iceTransportPolicy="relay")})))),_N("ENABLE_ENCODED_TRANSFORM")&&nD().supportWebRTCEncodedTransform&&(i.encodedInsertableStreams=!0),i}static turnServerConfigToIceServers(e){const t=[];return e.forEach((e=>{e.security?e.tcpport&&t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turns:".concat(Dx(e.turnServerURL),":").concat(e.tcpport,"?transport=tcp")}):(e.udpport&&!_N("FORCE_TURN_TCP")&&t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turn:".concat(e.turnServerURL,":").concat(e.udpport,"?transport=udp")}),e.tcpport&&t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turn:".concat(e.turnServerURL,":").concat(e.tcpport,"?transport=tcp")}))})),t}static newTurnServerConfigToIceServers(e){const t=[];return e.forEach((e=>{const i=_N("NEW_TURN_MODE");1===i?t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turn:".concat(e.turnServerURL,":3478?transport=udp")}):2===i?t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turn:".concat(e.turnServerURL,":3478?transport=tcp")}):3===i?t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turns:".concat(Dx(e.turnServerURL),":443?transport=tcp")}):4===i&&(t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turn:".concat(e.turnServerURL,":3478?transport=udp")}),t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turn:".concat(e.turnServerURL,":3478?transport=tcp")}),t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turns:".concat(Dx(e.turnServerURL),":443?transport=tcp")}))})),t}tryBindTransportEvents(e){const t=e.transport;if(t){this.transportEventReceiver=e,t.onstatechange=()=>{var e;null!=t&&t.state&&(null===(e=this.onDTLSTransportStateChange)||void 0===e||e.call(this,t.state))},t.onerror=e=>{var t;null===(t=this.onDTLSTransportError)||void 0===t||t.call(this,"error"in e?e.error:e)};const i=t.iceTransport;i&&(i.onstatechange=()=>{const e=null==t?void 0:t.iceTransport.state;var i;e&&(null===(i=this.onICETransportStateChange)||void 0===i||i.call(this,e))},i.getSelectedCandidatePair&&(i.onselectedcandidatepairchange=()=>{if(i.getSelectedCandidatePair()){const{local:e,remote:t}
12272=i.getSelectedCandidatePair();YN.info("[".concat(this.store.clientId,"] [pc-").concat(this.store.p2pId,"] selectedcandidatepairchange: local ").concat(JSON.stringify({candidateType:e.type,protocol:e.protocol}),", remote ").concat(JSON.stringify({candidateType:t.type,protocol:t.protocol,address:t.address,port:t.port})," )"))}}))}}tryUnbindTransportEvents(){this.transportEventReceiver&&this.transportEventReceiver.transport&&(this.transportEventReceiver.transport.onstatechange=null,this.transportEventReceiver.transport.onerror=null,this.transportEventReceiver.transport.iceTransport&&(this.transportEventReceiver.transport.iceTransport.onstatechange=null))}async updateRtpSenderEncodings(e,t){var i,n;if(!t){const i=this.peerConnection.getSenders();t=i.find((t=>t.track===e._mediaStreamTrack))}if(!t)return YN.warn("[".concat(e.getTrackId(),"] no rtpSender found}"));if(this.isVP8Simulcast(e))return YN.warn("[updateRtpSenderEncodings] Track is VP8 simulcast, please apply simulcast encodings");if(!nD().supportSetRtpSenderParameters)return YN.warn("[updateRtpSenderEncodings] Browser not support set rtp-sender parameters");const r={},o={};switch(e._optimizationMode){case"motion":r.degradationPreference="maintain-framerate";break;case"detail":r.degradationPreference="maintain-resolution";break;case"balanced":r.degradationPreference="balanced"}const s=function(e,t){return e.getTransceivers().find((e=>e.sender.track===t||e.receiver.track===t))}(this.peerConnection,e._mediaStreamTrack),a=kP(e);if(FF(e)&&s&&t&&a&&this.getLocalVideoStats&&Dn(i=["vp8","vp9"]).call(i,this.store.codec)){var c;const i=r.degradationPreference||(Dn(c=e._hints).call(c,vD.CUSTOM_TRACK)?_N("CUSTOM_ADAPTATION_DEFAULT_MODE"):"maintain-framerate");!function(e,t,i,n,r,o){if(jF(e,i),r(t),"balanced"!==n&&"maintain-framerate"!==n&&"maintain-resolution"!==n)return;let s=-1;kF(e,t);const a=window.setInterval((()=>{const a=BF.get(e);if(!_N("ENABLE_AG_ADAPTATION")||!a)return jF(e,i),void r(t);const c=o();if(c.sendPackets>0&&c.OutgoingAvailableBandwidth>0){if(-1===s)return void(s=Date.now());if(Date.now()-s<1e3)return;const o=c.sendFrameRate,d=c.OutgoingAvailableBandwidth,[l,u]=UF(e,o,d,a.adaptationConfig,t,n);u&&(i.qualityLimitationReason=u),l&&a.adaptationConfig.scale!==l.scale&&(YN.debug("[".concat(e,"] applyAdaptation: ").concat(i.qualityLimitationReason,"\n sendFps ").concat(o,", bwe ").concat(d,", switch from ").concat(a.adaptationConfig.scale," to ").concat(l.scale," ")),a.adaptationConfig=VF(VF({},a.adaptationConfig),l),r(l))}}),_N("CHECK_LOCAL_STATS_INTERVAL")),c=VF({},t);BF.set(e,{timer:a,adaptationConfig:c,originConfig:t,adaptationFunc:r}),YN.debug("[".concat(e,"] start adaptation, originConfig: ").concat(JSON.stringify(t),", degradationPreference: ").concat(n))}(this.id+s.mid,a,this,i,(e=>{t&&this.updateAdaptation(t,e)}),this.getLocalVideoStats.bind(this))}if(e._encoderConfig){var d;const{bitrateMax:t,frameRate:i,scaleResolutionDownBy:n}=e._encoderConfig;t&&(o.maxBitrate=1e3*t),(Dn(d=e._hints).call(d,vD.LOW_STREAM)||e.isUseScaleResolutionDownBy)&&(i&&(o.maxFramerate=Lx(i)),n&&n>=1&&(o.scaleResolutionDownBy=n))}const{maxFramerate:l}=_N("ENCODER_CONFIG_LIMIT");if(l&&"number"==typeof l&&(o.maxFramerate=o.maxFramerate?Math.min(o.maxFramerate,l):l),_N("DSCP_TYPE")&&dw()){var u;const e=_N("DSCP_TYPE");Dn(u=["very-low","low","medium","high"]).call(u,e)&&(o.networkPriority=e)}const h=t.getParameters(),p=null===(n=h.encodings)||void 0===n?void 0:n[0];Kb()&&!p&&(r.encodings=[o]),p&&Object.assign(p,o),Object.assign(h,r),YN.debug("[".concat(e.getTrackId(),"] updateRtpSenderEncodings: ").concat(JSON.stringify(h.encodings))),await t.setParameters(h),await async function(e,t,i){try{var n;if(!nD().supportSetRtpSenderParameters)return;if(!function(e){return"vp9"===e||"av1"===e}(e)||!_N("ENABLE_SVC"))return;const r={},o={},s=t.getParameters(),a=null===(n=s.encodings)||void 0===n?void 0:n[0];o.scalabilityMode=Bx(i),a&&Object.assign(a,o),Object.assign(s,r),await t.setParameters(s),YN.debug("[updateAdaptation] updateRtpSenderEncodings scalabilityMode success: ".concat(JSON.stringify(s.encodings)))}catch(e){YN.debug("[updateAdaptation] updateRtpSenderEncodings scalabilityMode failed",e)}}(this.store.codec,t,_N("SVC_MODE"))}async updateAdaptation(e,t){var i,n;if(!e)return YN.debug("[updateAdaptation] no rtpSender found");if(!nD().supportSetRtpSenderParameters)return YN.debug("[updateAdaptation] Browser not support set rtp-sender parameters");const r={},{bitrateMax:o,frameRate:s,scaleResolutionDownBy:a}=t;o&&(r.maxBitrate=1e3*o),s&&(r.maxFramerate=Lx(s)),a&&a>=1&&Dn(i=["vp8","vp9"]).call(i,this.store.codec)&&(r.scaleResolutionDownBy=a);const c=e.getParameters(),d=null===(n=c.encodings)||void 0===n?void 0:n[0];d&&Object.assign(d,r),Object.assign(c,{});try{await e.setParameters(c),YN.debug("[updateAdaptation] updateRtpSenderEncodings: ".concat(JSON.stringify(c.encodings)))}catch(t){!("transport"in e)||e.transport&&"connected"===e.transport.state?"connected"!==this.peerConnectionState?YN.debug("[updateAdaptation] peerConnection not connected}"):YN.debug("[updateAdaptation] updateRtpSenderEncodings failed",t):YN.debug("[updateAdaptation] rtpSender transport not connected}")}}async applySendEncodings(e,t){try{if(!nD().supportSetRtpSenderParameters)return;if(e.length!==t.length)return;for(let i=0;i<e.length;i++){const n=e[i],r=t[i];r instanceof pk&&!this.isVP8Simulcast(r)&&await this.updateRtpSenderEncodings(r,n.sender)}}catch(e){YN.debug("[".concat(this.store.clientId,"] Apply RTPSendEncodings failed."))}}mungSendOfferSDP(e,t,i){const n=yN(e);return t.forEach(((e,t)=>{const r=i[t],o=n.mediaDescriptions.find((e=>e.attributes.mid===r));o&&(eV(o,e),oV(o,e,this.store.codec))})),AN(n)}bindStatsEvents(){this.statsFilter.onFirstAudioReceived=e=>{var t;null===(t=this.onFirstAudioReceived)||void 0===t||t.call(this,e)},this.statsFilter.onFirstVideoReceived=e=>{var t;null===(t=this.onFirstVideoReceived)||void 0===t||t.call(this,e)},this.statsFilter.onFirstAudioDecoded=e=>{var t;null===(t=this.onFirstAudioDecoded)||void 0===t||t.call(this,e)},this.statsFilter.onFirstVideoDecoded=(e,t,i)=>{var n;null===(n=this.onFirstVideoDecoded)||void 0===n||n.call(this,e,t,i)},this.statsFilter.onSelectedLocalCandidateChanged=(e,t)=>{var i;null===(i=this.onSelectedLocalCandidateChanged)||void 0===i||i.call(this,e,t)},this.statsFilter.onSelectedRemoteCandidateChanged=(e,t)=>{var i;null===(i=this.onSelectedRemoteCandidateChanged)||void 0===i||i.call(this,e,t)},this.statsFilter.onFirstVideoDecodedTimeout=e=>{var t;null===(t=this.onFirstVideoDecodedTimeout)||void 0===t||t.call(this,e)}}unbindStatsEvents(){this.statsFilter.onFirstAudioReceived=void 0,this.statsFilter.onFirstVideoReceived=void 0,this.statsFilter.onFirstAudioDecoded=void 0,this.statsFilter.onFirstVideoDecoded=void 0,this.statsFilter.onSelectedLocalCandidateChanged=void 0,this.statsFilter.onSelectedRemoteCandidateChanged=void 0,this.statsFilter.onFirstVideoDecodedTimeout=void 0}async applySimulcastForFirefox(e,t){if(e.length===t.length)for(let a=0;a<e.length;a++){var i,n,r,o,s;const c=e[a],d=t[a];if(d instanceof pk&&!Dn(i=d._hints).call(i,vD.LOW_STREAM)&&null!==(n=d._encoderConfig)&&void 0!==n&&n.bitrateMax&&(null===(r=d._encoderConfig)||void 0===r?void 0:r.bitrateMax)>
vendor: 8,139 bytes, line 12272
12272200&&null!==(o=d._scalabilityMode)&&void 0!==o&&o.numSpatialLayers&&(null===(s=d._scalabilityMode)||void 0===s?void 0:s.numSpatialLayers)>1&&"vp8"===this.store.codec){const e={},t={high:1e3*(d._encoderConfig.bitrateMax-50),medium:5e4};e.encodings=[{rid:"m",active:!0,maxBitrate:t.medium,scaleResolutionDownBy:4},{rid:"h",active:!0,maxBitrate:t.high}];const i=c.sender.getParameters();await c.sender.setParameters(Object.assign(i,e))}}}async applySimulcastEncodings(e,t){if(!Kb()&&e.length===t.length)for(let i=0;i<e.length;i++){const n=t[i];if(n instanceof pk&&this.isVP8Simulcast(n)){const t=e[i],r={},o={high:1e3*(n._encoderConfig.bitrateMax-50),medium:5e4};r.encodings=[{active:!0,adaptivePtime:!1,networkPriority:"high",priority:"high",maxBitrate:o.high},{active:!0,adaptivePtime:!1,networkPriority:"low",priority:"low",maxBitrate:o.medium,scaleResolutionDownBy:4}];const s=t.sender.getParameters();await t.sender.setParameters(Object.assign(s,r))}}}isVP8Simulcast(e){var t,i,n,r,o;return!!(e instanceof pk&&_N("SIMULCAST")&&"vp8"===this.store.codec&&!Dn(t=e._hints).call(t,vD.LOW_STREAM)&&null!==(i=e._encoderConfig)&&void 0!==i&&i.bitrateMax&&(null===(n=e._encoderConfig)||void 0===n?void 0:n.bitrateMax)>200&&null!==(r=e._scalabilityMode)&&void 0!==r&&r.numSpatialLayers&&(null===(o=e._scalabilityMode)||void 0===o?void 0:o.numSpatialLayers)>1)}logSDPExchange(e,t,i,n){if(_N("SDP_LOGGING"))return YN.upload("[".concat(this.store.clientId,"] exchanging ").concat(i," ").concat(t," SDP during P2PConnection.").concat(n,"\n"),e),"offer"===t?e=>{this.logSDPExchange(e,"answer","local"===i?"remote":"local",n)}:void 0}async getRemoteSSRC(e){if(!this.remoteSDP)return;const t=this.remoteSDP.getSSRC(e);return t&&0!==t.length?t[0].ssrcId:void 0}setConfiguration(t){if(nD().supportPCSetConfiguration){const i=e.resolvePCConfiguration(t);this.peerConnection.setConfiguration(i)}}},rU(XF.prototype,"updateRemoteRTPCapabilities",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"updateRemoteRTPCapabilities"),XF.prototype),rU(XF.prototype,"connect",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"connect"),XF.prototype),rU(XF.prototype,"updateRemoteConnect",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"updateRemoteConnect"),XF.prototype),rU(XF.prototype,"createDataChannels",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"createDataChannels"),XF.prototype),rU(XF.prototype,"receive",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"receive"),XF.prototype),rU(XF.prototype,"batchReceive",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"batchReceive"),XF.prototype),rU(XF.prototype,"stopReceiving",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"stopReceiving"),XF.prototype),rU(XF.prototype,"muteRemote",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"muteRemote"),XF.prototype),rU(XF.prototype,"unmuteRemote",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"unmuteRemote"),XF.prototype),rU(XF.prototype,"muteLocal",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"muteLocal"),XF.prototype),rU(XF.prototype,"unmuteLocal",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"unmuteLocal"),XF.prototype),rU(XF.prototype,"close",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"close"),XF.prototype),rU(XF.prototype,"updateEncoderConfig",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"updateEncoderConfig"),XF.prototype),rU(XF.prototype,"updateSendParameters",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"updateSendParameters"),XF.prototype),rU(XF.prototype,"replaceTrack",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"replaceTrack"),XF.prototype),rU(XF.prototype,"updateAdaptation",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"updateAdaptation"),XF.prototype),rU(XF.prototype,"getRemoteSSRC",[$F],Object.getOwnPropertyDescriptor(XF.prototype,"getRemoteSSRC"),XF.prototype),XF);function $F(e,t,i){const n=e[t];if("function"!=typeof n)throw new Error("Cannot use mutex on object property.");return i.value=async function(){const e=this.mutex,i=await e.lock("From P2PConnection.".concat(t));try{for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return await n.apply(this,o)}finally{i()}},i}function eB(e,t){let i=document.createElement("video"),n=document.createElement("canvas");i.setAttribute("style","display:none"),n.setAttribute("style","display:none"),i.setAttribute("muted",""),i.muted=!0,i.setAttribute("autoplay",""),i.autoplay=!0,i.setAttribute("playsinline",""),n.width=Lx(t.width),n.height=Lx(t.height);const r=Lx(t.framerate||15);document.body.append(i),document.body.append(n);let o=e._mediaStreamTrack;i.srcObject=new MediaStream([o]),i.play();const s=n.getContext("2d");if(!s)throw new tD(Ew.UNEXPECTED_ERROR,"can not get canvas context");const a=nD(),c=n.captureStream(a.supportRequestFrame?0:r).getVideoTracks()[0];c.canvas||(c.canvas=n),n.startCapture=()=>{if(!i)return n.stopCapture&&n.stopCapture();if(i.paused&&i.play(),i.videoHeight>2&&i.videoWidth>2){const e=i.videoWidth,t=i.videoHeight/e,r=n.width*t;Math.abs(r-n.height)>=2&&(YN.debug("adjust low stream resolution","".concat(n.width,"x").concat(n.height," -> ").concat(n.width,"x").concat(r)),n.height=r)}s.drawImage(i,0,0,n.width,n.height),c.requestFrame&&c.requestFrame(),o!==e._mediaStreamTrack&&(o=e._mediaStreamTrack,i.srcObject=new MediaStream([o]))},n.stopCapture=iP((()=>n.startCapture&&n.startCapture()),r);const d=c.stop;return c.stop=()=>{d.call(c),i&&(i.remove(),i.srcObject=null,i=null),n&&(n.width=0,n.remove(),n.stopCapture&&n.stopCapture(),n.startCapture=void 0,n.stopCapture=void 0,n=null),YN.debug("clean low stream renderer")},c}var tB=function(e){return e[e.HEIGHT=2033]="HEIGHT",e[e.FRAME_RATE=2034]="FRAME_RATE",e[e.WIDTH=2035]="WIDTH",e}(tB||{}),iB=function(e){return e[e.FRAME_RATE=2002]="FRAME_RATE",e[e.WIDTH=2003]="WIDTH",e[e.HEIGHT=2004]="HEIGHT",e[e.PACKAGE_LOST=2005]="PACKAGE_LOST",e[e.AVG_ENCODE=2007]="AVG_ENCODE",e[e.NACKS=2009]="NACKS",e[e.PLIS=2010]="PLIS",e[e.FIRS=2011]="FIRS",e[e.BITRATE=2012]="BITRATE",e[e.PACKAGE_RATE=2031]="PACKAGE_RATE",e[e.ADAPTATION=2032]="ADAPTATION",e[e.ACTUAL_ENCODED=2060]="ACTUAL_ENCODED",e[e.BANDWIDTH=2061]="BANDWIDTH",e[e.RETRANSMIT=2062]="RETRANSMIT",e[e.TARGET_ENCODED=2064]="TARGET_ENCODED",e[e.TRANSMIT=2066]="TRANSMIT",e[e.FREEZE=2082]="FREEZE",e[e.DISABLED=2095]="DISABLED",e[e.PLAYER_STATUS=2128]="PLAYER_STATUS",e[e.QP_SUM=2143]="QP_SUM",e[e.BYTES_RETRANSMIT=2173]="BYTES_RETRANSMIT",e[e.PACKAGES_RETRANSMIT=2172]="PACKAGES_RETRANSMIT",e[e.HUGE_FRAME_SENT=2174]="HUGE_FRAME_SENT",e[e.KEY_FRAMES_ENCODED=2207]="KEY_FRAMES_ENCODED",e}(iB||{}),nB=function(e){return e[e.BITRATE=2069]="BITRATE",e[e.PACKAGE_LOST=2070]="PACKAGE_LOST",e[e.PACKAGE_RATE=2071]="PACKAGE_RATE",e[e.HEIGHT=2073]="HEIGHT",e[e.FRAME_RATE=2075]="FRAME_RATE",e[e.WIDTH=2077]="WIDTH",e}(nB||{}),rB=function(e){return e[e.JITTER=-1]="JITTER",e[e.PACKAGE_LOST=2014]="PACKAGE_LOST",e[e.WIDTH=2018]="WIDTH",e[e.HEIGHT=2019]="HEIGHT",e[e.FRAME_RATE=2020]="FRAME_RATE",e[e.JITTER_BUFFER=2023]="JITTER_BUFFER",e[e.CURRENT_DELAY=2024]="CURRENT_DELAY",e[e.NACKS=2026]="NACKS",e[e.PLIS=2027]="PLIS",e[e.FIRS=2028]="FIRS",e[e.BITRATE=2029]="BITRATE",e[e.PACKAGE_RATE=2078]="PACKAGE_RATE",e[e.FREEZE=2084]="FREEZE",e[e.DISABLED=2101]="DISABLED",e[e.PLAYER_STATUS=2129]="PLAYER_STATUS",e[e.QP_SUM=2144]="QP_SUM",e[e.I_FRAME_DELAY=2149]="I_FRAME_DELAY",e[e.FRAMES_DROPPED=2181]="FRAMES_DROPPED",e[e.BYTES_RETRANSMIT=2175]="BYTES_RETRANSMIT",e[e.PACKAGES_RETRANSMIT=2176]="PACKAGES_RETRANSMIT",e[e.PACKAGES_DISCARDED=2198]="PACKAGES_DISCARDED",e[e.AVG_DECODE=2200]="AVG_DECODE",e[e.AVG_PROCESSING_DELAY=2202]="AVG_PROCESSING_DELAY",e[e.AVG_ASSEMBLY_TIME=2203]="AVG_ASSEMBLY_TIME",e[e.AVG_INTER_FRAME_DELAY=2204]="AVG_INTER_FRAME_DELAY",e[e.KEY_FRAMES_DECODED=2206]="KEY_FRAMES_DECODED",e}(rB||{}),oB=function(e){return e[e.FRAME_RATE_DECODE=2021]="FRAME_RATE_DECODE",e[e.FRAME_RATE_RENDER=2022]="FRAME_RATE_RENDER",e[e.FRAME_RATE_OUTPUT=2155]="FRAME_RATE_OUTPUT",e[e.FREEZE_TIME=2109]="FREEZE_TIME",e[e.FREEZE_TIME_RENDER=2147]="FREEZE_TIME_RENDER",e[e.FREEZE_DURATION=2156]="FREEZE_DURATION",e}(oB||{}),sB=function(e){return e[e.PCM_LEVEL=2104]="PCM_LEVEL",e}(sB||{}
12272),aB=function(e){return e[e.PACKAGE_LOST=-1]="PACKAGE_LOST",e[e.LEVEL=2038]="LEVEL",e[e.BITRATE=2039]="BITRATE",e[e.PACKAGE_RATE=2040]="PACKAGE_RATE",e[e.AEC_RETURN_LOSS=2041]="AEC_RETURN_LOSS",e[e.AEC_RETURN_LOSS_ENH=2042]="AEC_RETURN_LOSS_ENH",e[e.FREEZE=2081]="FREEZE",e[e.DISABLED=2096]="DISABLED",e[e.BYTES_RETRANSMIT=2179]="BYTES_RETRANSMIT",e[e.PACKAGES_RETRANSMIT=2180]="PACKAGES_RETRANSMIT",e}(aB||{}),cB=function(e){return e[e.BITRATE=2044]="BITRATE",e[e.PACKAGE_LOST=2045]="PACKAGE_LOST",e[e.PACKAGE_RATE=2046]="PACKAGE_RATE",e[e.CURRENT_DELAY=2047]="CURRENT_DELAY",e[e.JITTER_BUFFER=2054]="JITTER_BUFFER",e[e.JITTER=2055]="JITTER",e[e.FREEZE=2083]="FREEZE",e[e.DISABLED=2102]="DISABLED",e[e.PCM_LEVEL=2105]="PCM_LEVEL",e[e.PLAYER_STATUS=2130]="PLAYER_STATUS",e[e.CONCEALED_SAMPLES=2148]="CONCEALED_SAMPLES",e[e.BYTES_RETRANSMIT=2178]="BYTES_RETRANSMIT",e[e.PACKAGES_RETRANSMIT=2177]="PACKAGES_RETRANSMIT",e[e.PACKAGES_DISCARDED=2199]="PACKAGES_DISCARDED",e[e.AVG_PROCESSING_DELAY=2201]="AVG_PROCESSING_DELAY",e[e.TOTAL_SAMPLES_RECEIVED=2224]="TOTAL_SAMPLES_RECEIVED",e}(cB||{}),dB=function(e){return e[e.FREEZE_TIME=-1]="FREEZE_TIME",e[e.LEVEL=2043]="LEVEL",e}(dB||{}),lB=function(e){return e[e.RTT=2006]="RTT",e[e.CONN_TYPE=801]="CONN_TYPE",e[e.STATS_UPDATE_INTERVAL=2205]="STATS_UPDATE_INTERVAL",e}(lB||{}),uB=function(e){return e[e.RTC_PEER_CONNECTION_STATE=2219]="RTC_PEER_CONNECTION_STATE",e}(uB||{});const hB=1e3,pB=6,_B=3,EB=Math.max(pB,_B);function mB(e,t,i){null!=i&&Number.isFinite(i)&&(e[t]=Math.round(Math.max(0,i)))}function fB(e){const t={[lB.CONN_TYPE]:0,[lB.RTT]:e.rtt,[lB.STATS_UPDATE_INTERVAL]:e.updateInterval?Math.round(Math.max(0,e.updateInterval)):void 0};switch(e.selectedCandidatePair.localCandidate.candidateType){case"relay":{const i=e.selectedCandidatePair.localCandidate.relayProtocol;"udp"===i&&(t[lB.CONN_TYPE]=1),"tcp"===i&&(t[lB.CONN_TYPE]=3),"tls"===i&&(t[lB.CONN_TYPE]=4);break}case"srflx":t[lB.CONN_TYPE]=2;break;case"unknown":t[lB.CONN_TYPE]=5;break;default:t[lB.CONN_TYPE]=0}return t}function TB(e){let t=0;switch(e){case"none":t=0;break;case"cpu":t=1;break;case"bandwidth":t=2;break;case"other":t=3}return t}class SB extends Dw{constructor(e){super(),QI(this,"store",void 0),QI(this,"uploadWRTCStatsTimer",void 0),QI(this,"uploadOutboundDenoiserStatsTimer",void 0),QI(this,"uploadExtStatsTimer",void 0),QI(this,"uploadExtUsageStatsTimer",void 0),QI(this,"uploadInboundExtStatsTimer",void 0),QI(this,"requestStats",void 0),QI(this,"requestTransportStats",void 0),QI(this,"requestLocalMedia",void 0),QI(this,"requestRemoteMedia",void 0),QI(this,"requestAllTracks",void 0),QI(this,"requestVideoIsReady",void 0),QI(this,"requestUploadStats",void 0),QI(this,"requestUpload",void 0),QI(this,"uploadOutboundStarted",!1),QI(this,"uploadInboundStarted",!1),QI(this,"uploadTransportStarted",!1),QI(this,"uploadBaseStatsStarted",!1),QI(this,"uploadExtensionUsageStarted",!1),QI(this,"lastRecvStats",void 0),QI(this,"lastSendStats",void 0),QI(this,"lastRefRecvStats",void 0),QI(this,"lastRefSendStats",void 0),QI(this,"lastFullRecvStats",void 0),QI(this,"lastFullSendStats",void 0),QI(this,"needUploadRenderFreezeTime",!0),this.store=e}uploadWRTCStats(e){if(!this.requestStats||!this.requestUploadStats)return;const t=e%_B==0,i=e%pB==0;let n,r;if(this.uploadTransportStarted&&(n=this.requestStats(),this.store.useP2P&&(r=this.requestStats(!0))),!n&&this.uploadOutboundStarted&&(n=this.requestStats()),!r&&this.uploadInboundStarted&&(r=this.requestStats(!0)),n||r){var o;const e={};if(this.uploadTransportStarted&&n){const i=this.getTransportStats(n,r,t);i&&(e.misc=[i])}if(this.uploadOutboundStarted&&n){const r=this.getOutboundStats(n,i?this.lastFullSendStats:t?this.lastRefSendStats:this.lastSendStats,t,i);r&&(e.outbound=[r])}if(this.uploadInboundStarted&&r){const n=this.getInboundStats(r,i?this.lastFullRecvStats:t?this.lastRefRecvStats:this.lastRecvStats,t,i);n&&(e.inbound=n)}const s=null===(o=this.requestTransportStats)||void 0===o?void 0:o.call(this).connectState;s&&(Array.isArray(e.misc)?e.misc[0]&&e.misc[0].addition&&(e.misc[0].addition[uB.RTC_PEER_CONNECTION_STATE]=XO[s]):e.misc=[{addition:{[uB.RTC_PEER_CONNECTION_STATE]:XO[s]}}]),this.requestUploadStats(e)}this.lastRecvStats=r,this.lastSendStats=n,i&&(this.lastFullRecvStats=r,this.lastFullSendStats=n),t&&(this.lastRefRecvStats=r,this.lastRefSendStats=n)}startUploadWRTCStats(){if(this.uploadWRTCStatsTimer)return;this.uploadBaseStatsStarted=!0;let e=1;this.uploadWRTCStatsTimer=window.setInterval((()=>
12272{if(!this.uploadTransportStarted&&!this.uploadInboundStarted&&!this.uploadOutboundStarted){if(this.uploadBaseStatsStarted){var t,i;const e=null===(t=this.requestTransportStats)||void 0===t?void 0:t.call(this);return void(e&&(null===(i=this.requestUploadStats)||void 0===i||i.call(this,{misc:[{addition:{[uB.RTC_PEER_CONNECTION_STATE]:XO[e.connectState]}}]})))}return this.stopUploadWRTCStats()}this.uploadWRTCStats(e),++e===EB+1&&(e=1)}),hB)}stopUploadWRTCStats(){window.clearInterval(this.uploadWRTCStatsTimer),this.uploadWRTCStatsTimer=void 0,this.lastSendStats&&(this.lastSendStats.videoSend=[],this.lastSendStats.audioSend=[],this.lastSendStats=void 0),this.lastRecvStats&&(this.lastRecvStats.videoRecv=[],this.lastRecvStats.audioRecv=[],this.lastRecvStats=void 0)}getTransportStats(e,t,i){if(!this.requestStats)return;if(!i)return null==e.rtt?void 0:{addition:{[lB.RTT]:e.rtt,[lB.CONN_TYPE]:void 0,[lB.STATS_UPDATE_INTERVAL]:e.updateInterval||void 0}};const n=fB(e);if(this.store.useP2P){if(t){const e=fB(t);n[lB.CONN_TYPE]+=e[lB.CONN_TYPE]<<3}n[lB.CONN_TYPE]+=110}else n[lB.CONN_TYPE]+=100;return{addition:n}}getOutboundStats(e,t,i,n){if(!this.requestUploadStats||!this.requestLocalMedia)return;const r=this.requestLocalMedia();if(!r||0===r.length)return;let o,s,a;return r.forEach((r=>{let[c,{track:d,ssrcs:l}]=r;switch(c){case zU.LocalVideoLowTrack:case zU.LocalVideoTrack:if(c===zU.LocalVideoTrack){const r=function(e,t,i,n,r,o){const s=t.videoSend.find((t=>t.ssrc===e));if(!s)return;const a={},{sentFrame:c,inputFrame:d}=s;if(o&&(mB(a,iB.QP_SUM,s.qpSumPerFrame),d&&c)){const e=d.frameRate,t=c.frameRate;a[iB.FREEZE]=function(e,t){let i=!0;return i=!(e<=5)&&(e<=10?t<3:e<=20?t<4:t<5),i}(e,t)?1:0}if(r){switch(c&&(mB(a,iB.HEIGHT,c.height),mB(a,iB.WIDTH,c.width),mB(a,iB.FRAME_RATE,c.frameRate)),a[iB.DISABLED]=n._originMediaStreamTrack&&!n._originMediaStreamTrack.enabled||n._mediaStreamTrack&&!n._mediaStreamTrack.enabled?1:0,s.adaptionChangeReason){case"none":a[iB.ADAPTATION]=0;break;case"cpu":a[iB.ADAPTATION]=1;break;case"bandwidth":a[iB.ADAPTATION]=2;break;case"other":a[iB.ADAPTATION]=3}let o=0;s.adaptionChangeReason&&(o+=TB(s.adaptionChangeReason)),t.qualityLimitationReason&&(o+=TB(t.qualityLimitationReason)<<3),a[iB.ADAPTATION]=o,a[iB.PLAYER_STATUS]=GD[n._player?n._player.videoElementStatus:"uninit"],mB(a,iB.NACKS,s.nacksCount),mB(a,iB.PLIS,s.plisCount),mB(a,iB.FIRS,s.firsCount),mB(a,iB.AVG_ENCODE,s.avgEncodeMs),mB(a,iB.HUGE_FRAME_SENT,s.hugeFramesSent),mB(a,iB.BYTES_RETRANSMIT,s.retransmittedBytesSent),mB(a,iB.PACKAGES_RETRANSMIT,s.retransmittedPacketsSent),mB(a,iB.KEY_FRAMES_ENCODED,s.keyFramesEncoded);const d=i&&i.videoSend.find((t=>t.ssrc===e));if(d){let e=r?hB:hB*pB;d.timestamp&&s.timestamp&&(e=s.timestamp-d.timestamp),null!=d.packets&&null!=s.packets&&mB(a,iB.PACKAGE_RATE,1e3*(s.packets-d.packets)/e),null!=s.packetsLost&&null!=d.packetsLost&&mB(a,iB.PACKAGE_LOST,s.packetsLost-d.packetsLost),null!=d.bytes&&null!=s.bytes&&mB(a,iB.BITRATE,8*(s.bytes-d.bytes)/e)}}return a}(l[0].ssrcId,e,t,d,i,n),o=d&&function(e,t,i,n){const r=t.videoSend.find((t=>t.ssrc===e));if(!r)return null;const o={};if(n){const e=r.inputFrame,t=e&&e.height||i.videoHeight||0,n=e&&e.width||i.videoWidth||0,s=e&&e.frameRate||0;mB(o,tB.HEIGHT,t),mB(o,tB.WIDTH,n),mB(o,tB.FRAME_RATE,s)}return o}(l[0].ssrcId,e,d,i),a=function(e,t){const i={};return t&&(mB(i,iB.RETRANSMIT,e.bitrate.retransmit),mB(i,iB.TARGET_ENCODED,e.bitrate.targetEncoded),mB(i,iB.ACTUAL_ENCODED,e.bitrate.actualEncoded),mB(i,iB.TRANSMIT,e.bitrate.transmit),mB(i,iB.BANDWIDTH,e.sendBandwidth)),i}(e,i);s=Object.assign({},r,o,a)}else a=function(e,t,i,n){const r=t.videoSend.find((t=>t.ssrc===e));if(!r)return;const o={};if(n){const t=r.sentFrame;if(t&&(mB(o,nB.HEIGHT,t.height),mB(o,nB.WIDTH,t.width),mB(o,nB.FRAME_RATE,t.frameRate)),i){const t=i.videoSend.find((t=>t.ssrc===e));if(t){let e=hB*pB;t.timestamp&&r.timestamp&&(e=r.timestamp-t.timestamp),null!=t.packets&&null!=r.packets&&mB(o,nB.PACKAGE_RATE,1e3*(r.packets-t.packets)/e),null!=r.packetsLost&&null!=t.packetsLost&&mB(o,nB.PACKAGE_LOST,r.packetsLost-t.packetsLost),null!=t.bytes&&null!=r.bytes&&mB(o,nB.BITRATE,8*(r.bytes-t.bytes)/e)}}}return o}(l[0].ssrcId,e,t,i);break;case zU.LocalAudioTrack:o=d&&function(e,t,i,n,r){const o=t.audioSen
12272d.find((t=>t.ssrc===e));if(!o)return;const s={};if(r){s[aB.DISABLED]=n._originMediaStreamTrack&&!n._originMediaStreamTrack.enabled||n._mediaStreamTrack&&!n._mediaStreamTrack.enabled?1:0;const t=100*n._source.getAccurateVolumeLevel(),r=o.inputLevel;if(null!=r){const e=Math.ceil(50*Math.log10(100*r+1));mB(s,aB.LEVEL,e)}mB(s,sB.PCM_LEVEL,t),mB(s,aB.AEC_RETURN_LOSS,o.aecReturnLoss),mB(s,aB.AEC_RETURN_LOSS_ENH,o.aecReturnLossEnhancement),mB(s,aB.BYTES_RETRANSMIT,o.retransmittedBytesSent),mB(s,aB.PACKAGES_RETRANSMIT,o.retransmittedPacketsSent),s[aB.FREEZE]=0;const a=i&&i.audioSend.find((t=>t.ssrc===e));if(a){let e=hB*pB;a.timestamp&&o.timestamp&&(e=o.timestamp-a.timestamp),null!=a.bytes&&null!=o.bytes&&mB(s,aB.BITRATE,8*(o.bytes-a.bytes)/e),null!=a.packets&&null!=o.packets&&mB(s,aB.PACKAGE_RATE,1e3*(o.packets-a.packets)/e)}}return s}(l[0].ssrcId,e,t,d,i)}})),{high:s,low:a,audio:o}}getInboundStats(e,t,i,n){if(!this.requestRemoteMedia)return;const r=this.requestRemoteMedia()||[],o=[];return r.forEach((r=>{let[s,a]=r;const c={peer:s.uid};if(a.has(HU.VIDEO)&&s.videoTrack){const r=s._videoSSRC&&this.requestVideoIsReady&&this.requestVideoIsReady(s._videoSSRC)||!1,o=s.videoTrack?function(e,t,i,n,r,o,s,a){const c=t.videoRecv.find((t=>t.ssrc===e));if(!c)return;const d={},{receivedFrame:l,outputFrame:u,decodeFrameRate:h}=c,p=i&&i.videoRecv.find((t=>t.ssrc===e));if(mB(d,oB.FRAME_RATE_DECODE,h),c.framesRateFirefox&&mB(d,rB.FRAME_RATE,c.framesRateFirefox),l&&mB(d,rB.FRAME_RATE,l.frameRate),mB(d,rB.FRAMES_DROPPED,c.framesDroppedCount),mB(d,rB.BYTES_RETRANSMIT,c.retransmittedBytesReceived),mB(d,rB.PACKAGES_RETRANSMIT,c.retransmittedPacketsReceived),mB(d,rB.PACKAGES_DISCARDED,c.packetsDiscarded),mB(d,rB.AVG_DECODE,c.avgDecodeMs),mB(d,rB.AVG_PROCESSING_DELAY,c.avgProcessingDelayMs),mB(d,rB.AVG_ASSEMBLY_TIME,c.avgFramesAssembledFromMultiplePacketsMs),mB(d,rB.AVG_INTER_FRAME_DELAY,c.avgInterFrameDelayMs),mB(d,rB.KEY_FRAMES_DECODED,c.keyFramesDecoded),p){const e=t.timestamp-i.timestamp||hB*(a?pB:s?_B:1);null!=c.packetsLost&&null!=p.packetsLost&&mB(d,rB.PACKAGE_LOST,c.packetsLost-p.packetsLost),null!=p.bytes&&null!=c.bytes&&mB(d,rB.BITRATE,8*(c.bytes-p.bytes)/e),null!=p.packets&&null!=c.packets&&mB(d,rB.PACKAGE_RATE,1e3*(c.packets-p.packets)/e)}if(a&&(mB(d,rB.QP_SUM,c.qpSumPerFrame),d[rB.FREEZE]=r&&RF.isRemoteVideoFreeze(n,c,p)?1:0),s){var _;l?(mB(d,rB.HEIGHT,l.height),mB(d,rB.WIDTH,l.width)):n&&(mB(d,rB.HEIGHT,n._videoHeight||0),mB(d,rB.WIDTH,n._videoWidth||0)),u&&mB(d,oB.FRAME_RATE_OUTPUT,u.frameRate);const e=null===(_=n._player)||void 0===_?void 0:_.rendFrameRate.toFixed(0);if(e&&mB(d,oB.FRAME_RATE_RENDER,+e),mB(d,rB.JITTER_BUFFER,c.jitterBufferMs),mB(d,rB.CURRENT_DELAY,c.currentDelayMs),mB(d,rB.FIRS,c.firsCount),mB(d,rB.NACKS,c.nacksCount),mB(d,rB.PLIS,c.plisCount),n){d[rB.DISABLED]=n._originMediaStreamTrack.enabled&&n._mediaStreamTrack.enabled?0:1;const e=n._player;if(e){const{freezeTimeCounterList:t,renderFreezeAccTime:i,videoElementStatus:n}=e;if(t&&t.length>0&&mB(d,oB.FREEZE_TIME,t.splice(0,1)[0]),o&&"visible"===Dk.visibility&&n===BD.PLAYING&&nD().supportRequestVideoFrameCallback){const t=Math.min(6e3,i);e.renderFreezeAccTime=Math.max(0,i-t),mB(d,oB.FREEZE_TIME_RENDER,t)}if("number"==typeof c.totalFreezesDuration){const e=p&&p.totalFreezesDuration?c.totalFreezesDuration-p.totalFreezesDuration:c.totalFreezesDuration;mB(d,oB.FREEZE_DURATION,1e3*e)}}}if(d[rB.PLAYER_STATUS]=GD[n._player?n._player.videoElementStatus:"uninit"],p&&void 0!==c.totalInterFrameDelay&&void 0!==c.totalSquaredInterFrameDelay&&void 0!==p.totalInterFrameDelay&&void 0!==p.totalSquaredInterFrameDelay){const e=c.totalInterFrameDelay-p.totalInterFrameDelay,t=c.totalSquaredInterFrameDelay-p.totalSquaredInterFrameDelay,i=c.framesDecodeCount-p.framesDecodeCount,n=e/i*1e3,r=Math.round(1e3*Math.sqrt((t-Math.pow(e,2)/i)/i));!isNaN(r)&&n+r>Math.max(3*n,n+150)&&(d[rB.I_FRAME_DELAY]=r)}}return d}(s._videoSSRC,e,t,s.videoTrack,!0===r,this.needUploadRenderFreezeTime,i,n):void 0;o&&(c.video=o)}if(a.has(HU.AUDIO)&&s.audioTrack){const r=s.audioTrack?function(e,t,i,n,r,o){const s=t.audioRecv.find((t=>t.ssrc===e));if(!s)return;const a={},c=i&&i.audioRecv.find((t=>t.ssrc===e));if(mB(a,cB.JITTER,s.jitterMs),mB(a,cB.BYTES_RETRANSMIT,s.retransmittedBytesReceived),mB(a,cB.PACKAG
12272ES_RETRANSMIT,s.retransmittedPacketsReceived),mB(a,cB.PACKAGES_DISCARDED,s.packetsDiscarded),mB(a,cB.AVG_PROCESSING_DELAY,s.avgProcessingDelayMs),c){const e=t.timestamp-i.timestamp||hB*(o?pB:r?_B:1);null!=s.packets&&null!=c.packets&&mB(a,cB.PACKAGE_RATE,1e3*(s.packets-c.packets)/e),r&&null!=c.bytes&&null!=s.bytes&&mB(a,cB.BITRATE,8*(s.bytes-c.bytes)/e),null!=s.packetsLost&&null!=c.packetsLost&&mB(a,cB.PACKAGE_LOST,s.packetsLost-c.packetsLost)}if(o){const{receivedFrames:e,droppedFrames:t}=s;null!=e&&null!=t&&(a[cB.FREEZE]=0===(d=e)||100*t/d>20?1:0)}var d;if(r){const e=100*n._source.getAccurateVolumeLevel(),t=s.outputLevel;if(null!=t){const e=Math.ceil(50*Math.log10(100*t+1));mB(a,dB.LEVEL,e)}if(mB(a,cB.PCM_LEVEL,e),n&&(a[cB.DISABLED]=n._originMediaStreamTrack.enabled&&n._mediaStreamTrack.enabled?0:1),mB(a,cB.JITTER_BUFFER,s.jitterBufferMs),mB(a,cB.CURRENT_DELAY,s.jitterBufferMs),a[cB.PLAYER_STATUS]=GD[vP.getPlayerState(n.getTrackId())],c){const e=s.concealedSamples-c.concealedSamples;e>0&&mB(a,cB.CONCEALED_SAMPLES,e);const t=s.totalSamplesReceived-c.totalSamplesReceived;t>0&&mB(a,cB.TOTAL_SAMPLES_RECEIVED,t)}}return a}(s._audioSSRC,e,t,s.audioTrack,i,n):void 0;r&&(c.audio=r)}(c.video||c.audio)&&o.push(c)})),this.needUploadRenderFreezeTime=!this.needUploadRenderFreezeTime,o}startUploadTransportStats(){this.uploadTransportStarted=!0,this.uploadWRTCStatsTimer||this.startUploadWRTCStats()}stopUploadTransportStats(){this.uploadTransportStarted=!1}startUploadOutboundStats(){this.uploadOutboundStarted||(this.uploadOutboundStarted=!0,this.uploadWRTCStatsTimer||this.startUploadWRTCStats(),this.uploadOutboundDenoiserStatsTimer&&window.clearInterval(this.uploadOutboundDenoiserStatsTimer),this.uploadOutboundDenoiserStatsTimer=window.setInterval((()=>{if(!this.requestAllTracks||!this.requestUpload)return;const e=(this.requestAllTracks()||[]).find((e=>e instanceof yL));if(e&&e._external.getDenoiserStats){const t=e._external.getDenoiserStats();t&&this.requestUpload(pU.DENOISER_STATS,t)}}),2e3),this.uploadExtStatsTimer&&window.clearInterval(this.uploadExtStatsTimer),this.uploadExtStatsTimer=window.setInterval((()=>{if(!this.requestAllTracks||!this.requestUpload)return;this.requestAllTracks().forEach((e=>
12272{e.getProcessorStats().forEach((e=>{this.requestUpload&&this.requestUpload(e.type,e.stats)}))}))}),2e3))}stopUploadOutboundStats(){this.uploadOutboundStarted&&(this.uploadOutboundStarted=!1,this.lastSendStats&&(this.lastSendStats.videoSend=[],this.lastSendStats.audioSend=[],this.lastSendStats=void 0),this.uploadOutboundDenoiserStatsTimer&&window.clearInterval(this.uploadOutboundDenoiserStatsTimer),this.uploadOutboundDenoiserStatsTimer=void 0)}startUploadInboundStats(){this.uploadInboundStarted||(this.uploadInboundStarted=!0,this.uploadWRTCStatsTimer||this.startUploadWRTCStats(),this.uploadInboundExtStatsTimer&&window.clearInterval(this.uploadInboundExtStatsTimer),this.uploadInboundExtStatsTimer=window.setInterval((()=>{if(!this.requestUpload||!this.requestRemoteMedia)return;(this.requestRemoteMedia()||[]).forEach((e=>{let[t,i]=e;if(i.has(HU.VIDEO)&&t.videoTrack){t.videoTrack.getProcessorStats().forEach((e=>{this.requestUpload&&this.requestUpload(e.type,e.stats)}))}if(i.has(HU.AUDIO)&&t.audioTrack){t.audioTrack.getProcessorStats().forEac
12272h((e=>{this.requestUpload&&this.requestUpload(e.type,e.stats)}))}}))}),2e3))}stopUploadInboundStats(){this.uploadInboundStarted&&(this.uploadInboundStarted=!1,this.lastRecvStats&&(this.lastRecvStats.videoRecv=[],this.lastRecvStats.audioRecv=[],this.lastRecvStats=void 0))}startUploadExtensionUsageStats(){if(this.uploadExtensionUsageStarted)return;this.uploadExtensionUsageStarted=!0,this.uploadExtUsageStatsTimer&&window.clearInterval(this.uploadExtUsageStatsTimer);const e=new Map;this.uploadExtUsageStatsTimer=window.setInterval((async()=>{const t=Date.now(),i={connectionInterval:_N("EXTENSION_USAGE_UPLOAD_INTERVAL")/1e3,details:[],lts:t};let n=[];const r=this.requestAllTracks&&this.requestAllTracks()||[];for(const e of r)!e.muted&&e.enabled&&(n=n.concat(await e.getProcessorUsage()));const o=this.requestRemoteMedia&&this.requestRemoteMedia()||[];for(const[e,t]of o)t.has(HU.VIDEO)&&e.videoTrack&&(n=n.concat(await e.videoTrack.getProcessorUsage())),t.has(HU.AUDIO)&&e.audioTrack&&(n=n.concat(await e.audioTrack.getProcessorUsage()));if(0===n.length)return;i.details=function(e,t){const i={};for(const{id:s,value:a,level:c,direction:d}of e){var n;const e=null!==(n=t.get(s))&&void 0!==n?n:0,l=2===a?e+_N("EXTENSION_USAGE_UPLOAD_INTERVAL")/1e3:e;var r,o;t.set(s,l),i[s]?(2===a&&(i[s].value=a),c>i[s].level&&(i[s].level=c),"remote"===d&&(i[s].remoteUidCount+=1),i[s].totalTs=null!==(r=t.get(s))&&void 0!==r?r:0):i[s]={value:a,level:c,remoteUidCount:"local"===d?0:1,totalTs:null!==(o=t.get(s))&&void 0!==o?o:0}}return Object.keys(i).map((e=>{const{level:t,value:n,totalTs:r}=i[e];return{id:e,level:t,value:n,totalTs:r}}))}(n,e);const s=Date.now(),a=s>t?s:t+1;this.requestUpload&&this.requestUpload(pU.EXTENSION_USAGE_STATS,{usageStats:i,sendTs:a})}),_N("EXTENSION_USAGE_UPLOAD_INTERVAL"))}stopUploadExtensionUsageStats(){this.uploadExtensionUsageStarted&&(this.uploadExtensionUsageStarted=!1,this.uploadExtUsageStatsTimer&&window.clearInterval(this.uploadExtUsageStatsTimer),this.uploadExtUsageStatsTimer=void 0)}stopUploadBaseStats(){this.uploadBaseStatsStarted=!1}}const gB=_N("ICE_RESTART_INTERVAL");let RB=new Map,vB=new Map,CB=[KU.UDP_TCP_RELAY,KU.TCP_RELAY,KU.RELAY],IB=_N("JOIN_WITH_FALLBACK_MEDIA_PROXY_FORCE")&&nD().supportPCSetConfiguration;function yB(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=RB.get(e.id);i&&(window.clearTimeout(i),RB.delete(e.id));const n=vB.get(e.id);t&&n&&n.index===CB.length-1&&(YN.debug("[".concat(e.id,"] reset ICE restart policy")),vB.delete(e.id))}function AB(e,t,i){if(0===RB.size&&0===vB.size&&(Array.isArray(_N("RESTART_SEQUENCE"))&&_N("RESTART_SEQUENCE").length>0&&!function(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i+=1){const n=e[i];if(e.filter((e=>e===n)).length!==t.filter((e=>e===n)).length)return!1}return!0}(CB,_N("RESTART_SEQUENCE"))&&(CB=_N("RESTART_SEQUENCE").filter((e=>{var t;if(Dn(t=Object.values(KU)).call(t,e))return!0})),YN.debug("use reconnection policy from config distribution, queues: ".concat(CB.join(" => ")))),IB=_N("JOIN_WITH_FALLBACK_MEDIA_PROXY_FORCE")&&nD().supportPCSetConfiguration),0===CB.length)return void i();let n,{index:r=0,type:o}=vB.get(e.id)||{};if(IB&&o===KU.RELAY)return void i();let s=o&&r>=CB.length-1;if(IB)o=KU.RELAY;else{if(s)return void i();o?(r++,o=CB[r]):(o=CB[0],r=0)}YN.debug("[".concat(e.id,"] choose ICE restart policy: ").concat(o,", index: ").concat(r)),t(o),vB.set(e.id,{index:r,type:o}),n=window.setTimeout((()=>AB(e,t,i)),gB),RB.set(e.id,n)}var bB;function wB(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function OB(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?wB(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):wB(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function NB(e){var t,i,n,r=2;for("undefined"!=typeof Symbol&&(i=GA,n=Symbol.iterator);r--;){if(i&&null!=(t=e[i]))return t.call(e);
vendor: 6,651 bytes, line 12272
12272if(n&&null!=(t=e[n]))return new DB(t.call(e));i="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function DB(e){function t(e){if(Object(e)!==e)return Wh.reject(new TypeError(e+" is not an object."));var t=e.done;return Wh.resolve(e.value).then((function(e){return{value:e,done:t}}))}return DB=function(e){this.s=e,this.n=e.next},DB.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var i=this.s.return;return void 0===i?Wh.resolve({value:e,done:!0}):t(i.apply(this.s,arguments))},throw:function(e){var i=this.s.return;return void 0===i?Wh.reject(e):t(i.apply(this.s,arguments))}},new DB(e)}let PB=(bB=class extends Dw{get state(){return this._state}set state(e){const t=this._state;this._state=e,this.emit(JU.StateChange,t,this._state)}constructor(e,t){super(),QI(this,"isPlanB",void 0),QI(this,"store",void 0),QI(this,"statsUploader",void 0),QI(this,"connection",void 0),QI(this,"localTrackMap",new Map),QI(this,"remoteUserMap",new Map),QI(this,"localDataChannels",[]),QI(this,"remoteDataChannelMap",new Map),QI(this,"pendingLocalTracks",[]),QI(this,"pendingRemoteTracks",[]),QI(this,"pendingLocalDataChannels",[]),QI(this,"pendingRemoteDataChannels",[]),QI(this,"statsCollector",void 0),QI(this,"shouldForwardP2PCreation",void 0),QI(this,"iceFailedCount",0),QI(this,"dtlsFailedCount",0),QI(this,"mutex",void 0),QI(this,"_state",XU.Disconnected),QI(this,"_pcStatsUploadType",_N("NEW_ICE_RESTART")?YU.FIRST_CONNECTION:YU.OLD_FIRST_CONNECTION),QI(this,"_isStartRestartIce",!1),QI(this,"_restartTimer",void 0),QI(this,"_isTryConnecting",!1),QI(this,"_iceError",null),QI(this,"_forceTurn",!1),QI(this,"_isWaitPcToRePub",!1),QI(this,"handleMuteLocalTrack",(async(e,t,i)=>{const n=await this.mutex.lock("Locking from P2PChannel.handleMuteLocalTrack");try{if(!this.connection||this.state!==XU.Connected)return void i(new mw(Ew.INVALID_OPERATION,"Cannot call P2PChannel.handleMuteLocalTrack before connection established."));const r=this.filterTobeMutedTracks(e);if(0===r.length)return void t();const o=r.find((e=>"videoLowTrack"===e[0]));if(o){o[1].track._originMediaStreamTrack.stop()}await this.connection.muteLocal(r.map((e=>{let[,{id:t}]=e;return t})));const s=this.createMuteMessage(r);await qw(this,JU.RequestMuteLocal,s),t()}catch(e){i(e)}finally{n()}})),QI(this,"handleUnmuteLocalTrack",(async(e,t,i)=>{const n=await this.mutex.lock("Locking from P2PChannel.handleUnmuteLocalTrack");try{if(!this.connection||this.state!==XU.Connected)return void i(new mw(Ew.INVALID_OPERATION,"Cannot call P2PChannel.handleUnmuteLocalTrack before connection established."));const r=this.filterTobeUnmutedTracks(e);if(0===r.length)return void t();const o=r.find((e=>"videoLowTrack"===e[0]));if(o){const t=o[1];if(t.track._originMediaStreamTrack.stop(),!_N("DISABLE_DUAL_STREAM_USE_ENCODING")&&nD().supportDualStreamEncoding){const i=e._mediaStreamTrack.clone();t.track._mediaStreamTrack=i,t.track._originMediaStreamTrack=i}else{const i=eB(e,Xw(this,JU.RequestLowStreamParameter));t.track._mediaStreamTrack=i,t.track._originMediaStreamTrack=i}await new Wh(((e,i)=>{this.handleReplaceTrack(t.track,e,i,!0)}))}await this.connection.unmuteLocal(r.map((e=>{let[,{id:t}]=e;return t})));const s=this.createUnmuteMessage(r);await qw(this,JU.RequestUnmuteLocal,s),t()}catch(e){i(e)}finally{n()}})),QI(this,"handleUpdateVideoEncoder",(async(e,t,i,n)=>{let r;n||(r=await this.mutex.lock("Locking from P2PChannel.handleUpdateVideoEncoder"));try{const i=this.localTrackMap.get(zU.LocalVideoTrack);if(!this.connection||!i||i.track!==e||this.state!==XU.Connected)return void t();const{id:n,track:s}=i;await this.connection.updateSendParameters(n,s),await this.connection.updateEncoderConfig(n,s),this.emit(JU.UpdateVideoEncoder,s),t()}catch(e){i(e)}finally{var o;null===(o=r)||void 0===o||o()}})),QI(this,"handleUpdateVideoSendParameters",(async(e,t,i)=>{const n=await this.mutex.lock("Locking from P2PChannel.handleUpdateVideoSendParameters");try{const i=this.localTrackMap.get(zU.LocalVideoTrack);if(!this.connection||!i||i.track!==e||this.state!==XU.Connected)return void t();const{id:r,track:o}=i;await this.connection.updateSendParameters(r,o),t()}catch(e){i(e)}finally{n()}})),QI(this,"handleReplaceMixingTrack",(async(e,t,i,n)=>{if(!this.connection||this.state!==XU.Connected)return void t();const r=HF([e]);let o;YN.debug("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection will replace audioTrack [").concat(r.getTrackId(),"]")),"boolean"==typeof n&&n||(o=await this.mutex.lock("From P2PChannel.handleReplaceMixingTrack"));try{await this.replaceTrack(e,r),t()}catch(e){i(e)}finally{var s;null===(s=o)||void 0===s||s()}})),QI(this,"handleReplaceTrack",(async(e,t,i,n)=>{let r;YN.debug("[".concat(this.store.clientId,"] P2PChannel handleReplaceTrack for [track-id-").concat(e.getTrackId(),"]")),"boolean"==typeof n&&n||(r=await this.mutex.lock("From P2PChannel.handleReplaceTrack"));try{var o;const i=Array.from(this.localTrackMap.entries()).find((t=>{let[,{track:i}]=t;return e===i}));if(!this.connection||!i||this.state!==XU.Connected)return void t();if(await(null===(o=this.connection)||void 0===o?void 0:o.replaceTrack(e,i[1].id)),this.isPlanB){const t=i[1];t.id=e._mediaStreamTrack.id,this.localTrackMap.set(i[0],t)}if(i[0]===zU.LocalVideoTrack&&!_N("DISABLE_DUAL_STREAM_USE_ENCODING")&&nD().supportDualStreamEncoding){const t=this.localTrackMap.get(zU.LocalVideoLowTrack);if(t){const i=e._mediaStreamTrack.clone();t.track._originMediaStreamTrack.stop(),t.track._mediaStreamTrack=i,t.track._originMediaStreamTrack=i,await new Wh(((e,i)=>{this.handleReplaceTrack(t.track,e,i,!0)}))}}t()}catch(e){i(e)}finally{var s;null===(s=r)||void 0===s||s()}})),QI(this,"handleGetRTCStats",(e=>{e(this.statsCollector.getRTCStats())})),QI(this,"handleGetLocalVideoStats",(e=>{e(this.statsCollector.getLocalVideoTrackStats())})),QI(this,"handleGetLocalAudioStats",(e=>{e(this.statsCollector.getLocalAudioTrackStats())})),QI(this,"handleGetRemoteVideoStats",(e=>this.statsCollector.getRemoteVideoTrackStats(e.uid)[e.uid])),QI(this,"handleGetRemoteAudioStats",(e=>this.statsCollector.getRemoteAudioTrackStats(e.uid)[e.uid])),this.store=e,this.statsCollector=t,this.statsCollector.addP2PChannel(this),this.statsUploader=new SB(this.store),this.bindStatsUploaderEvents(),this.mutex=new IO("P2PChannel-mutex",this.store.clientId),this.isPlanB=!nD().supportUnifiedPlan||_N("CHROME_FORCE_PLAN_B")&&dw(),this.shouldForwardP2PCreation=_N("FORWARD_P2P_CREATION")&&nD().supportPCSetConfiguration&&cw(),this.shouldForwardP2PCreation&&(this.connection=YF(this.store),this.emit
12272(JU.PeerConnectionStateChange,this.connection.peerConnectionState),this.bindConnectionEvents(this.connection))}async startP2PConnection(e){var t;this.state=XU.New,this._forceTurn=zF(e),YN.debug("[".concat(this.store.clientId,"] [").concat(this.store.p2pId,"] forceTurn: ").concat(this._forceTurn));const i=this.shouldForwardP2PCreation&&"closed"===(null===(t=this.connection)||void 0===t?void 0:t.peerConnectionState);if(this.shouldForwardP2PCreation&&!i||(i&&this.connection&&(YN.warning("[".concat(this.store.clientId,"] P2PChannel.startP2PConnection ForwardP2P closed.")),this.resetConnection(this.connection)),this.connection=YF(this.store,e),this.emit(JU.PeerConnectionStateChange,this.connection.peerConnectionState),this.bindConnectionEvents(this.connection)),!this.connection)throw new mw(Ew.UNEXPECTED_ERROR,"Cannot P2PChannel.startConnection before P2PConnection initialization .");return this._pcStatsUploadType=_N("NEW_ICE_RESTART")?YU.FIRST_CONNECTION:YU.OLD_FIRST_CONNECTION,this._isTryConnecting=!0,this._isStartRestartIce=!1,this._iceError=null,this.connection.setConfiguration(e),this.connection.establishPromise}async connect(e){if(!this.connection)throw new mw(Ew.UNEXPECTED_ERROR,"Cannot P2PChannel.connect before P2PChannel.startP2PConnection .");_N("ENABLE_PREALLOC_PC")&&this.state===XU.Connected?await this.connection.updateRemoteConnect(e):(this.store.peerConnectionStart(),await this.connection.connect(e),this.statsUploader.startUploadTransportStats(),this.statsUploader.startUploadExtensionUsageStats(),this.state=XU.Connected)}updateRemoteRTPCapabilities(e){const t=Array.from(this.localTrackMap.entries()).filter((e=>{var t;let[i]=e;return Dn(t=[zU.LocalVideoLowTrack,zU.LocalVideoTrack]).call(t,i)})),i=t.map((e=>{let[,{id:t}]=e;return t})),n=t.map((e=>{let[t]=e;return t}));if(this.connection instanceof ZF){if(eD.updateRemoteRTPCapabilities(this.store.sessionId,{trackTypes:JSON.stringify(n),localCodecs:JSON.stringify(this.connection.localCodecs),remoteCodecs:JSON.stringify(e)}),!Dn(e).call(e,this.store.codec)){const t=["vp9","vp8","h264"].find((t=>Dn(e).call(e,t)));t&&(this.store.codec=t,YN.debug("[".concat(this.store.clientId,"] [").concat(this.store.p2pId," updateRemoteRTPCapabilities] default co
12272dec is not available, hence the fallback to ").concat(t,".")))}this.connection.updateRemoteRTPCapabilities(i,e)}}async getEstablishParams(){var e;if(this.connection instanceof ZF&&"closed"!==this.connection.peerConnectionState&&Dn(e=[XU.New,XU.Connected]).call(e,this.state))return this.connection.establishPromise}async publishDataChannel(e){if(!this.connection||this.state!==XU.Connected){if(this.state===XU.Disconnected)throw new mw(Ew.UNEXPECTED_ERROR,"PeerConnection already disconnected.");return e.forEach((e=>{var t;Dn(t=this.pendingLocalDataChannels).call(t,e)||this.pendingLocalDataChannels.push(e)})),[]}const t=this.filterTobePublishedDataChannels(e);return 0===t.length?[]:(t.forEach((e=>{const t=Date.now();this.store.publish(e.id.toString(),"datachannel",t)})),await this.connection.createDataChannels(this.store.uid,t),t.forEach((e=>{this.localDataChannels.push(e);const t=Date.now();this.store.publish(e.id+"","datachannel",void 0,t)})),e.map((e=>({streamId:e.id,ordered:e.ordered,maxRetransmits:e.maxRetransmits,metadata:e.metadata,channelId:e._originDataChannelId}))))}publish(e,t,i){var n=this;return FA((function*(){const r=yield BA(n.mutex.lock("From P2PChannel.publish"));try{var o;const s=n.connection&&Dn(o=["disconnected","failed"]).call(o,n.connection.peerConnectionState);if(!n.connection||n.state!==XU.Connected||s){if(n.state===XU.Disconnected)throw new mw(Ew.UNEXPECTED_ERROR,"PeerConnection already disconnected.");n.throwIfTrackTypeNotMatch(e);const t=e.filter((e=>-1===n.pendingLocalTracks.indexOf(e)));return n.pendingLocalTracks=n.pendingLocalTracks.concat(t),void(s&&(n._isWaitPcToRePub=!0))}n.store.pubId=n.store.pubId+1,TF.markPublishStart(n.store.clientId,n.store.pubId);const a=n.filterTobePublishedTracks(e,t,i);if(0===a.length)return void(yield BA(n.tryToUnmuteAudio(e)));yield*jA(NB(n.doPublish(n.connection,a)))}finally{r()}}))()}doPublish(e,t){var i=this;return FA((function*(){t.forEach((e=>{let{track:t,type:n}=e;const r=Date.now();i.store.publish(t.getTrackId(),n===zU.LocalAudioTrack?"audio":"video",r)})),i.bindLocalTrackEvents(t);const n=t.map((e=>{let{track:t}=e;return t})),r=yield BA(e.send(n,i.store.codec,i.store.audioCodec)),o=(yield BA(r.next())).value,s=i.createGatewayPublishMessage(t,o);let a;try{a=yield s}catch(e){throw r.throw(e),(null==e?void 0:e.code)===Ew.WS_ABORT&&t.forEach((e=>{let{track:t}=e;-1===i.pendingLocalTracks.indexOf(t)&&i.pendingLocalTracks.push(t)})),i.unbindLocalTrackEvents(t),e}const c=i.mapPubResToRemoteConfig(s,a,n),d=(yield BA(r.next(c))).value;if(i.state===XU.Disconnected)throw new mw(Ew.UNEXPECTED_ERROR,"PeerConnection already disconnected.");_N("ENABLE_VIDEO_SEI");const l=_N("ENABLE_ENCODED_TRANSFORM"),u=_N("ENABLE_AUDIO_METADATA");n.forEach((async e=>{const t=e.getRTCRtpTransceiver();if(!t||!l)return;const{interceptLocalVideoFrame:i,interceptLocalAudioFrame:n}=yV();e.trackMediaType===HU.VIDEO?await i(t.sender,e):e.trackMediaType===HU.AUDIO&&await n(t.sender,{metadata:u?()=>{const t=e.metadata.shift();return t&&t.value}:void 0})})),t.forEach((e=>{let{type:t}=e;i.statsCollector.addLocalStats(t)})),i.assignLocalTracks(t,d),i.statsUploader.startUploadOutboundStats(),t.forEach((e=>{let{track:t,type:n}=e;const r=Date.now();i.store.publish(t.getTrackId(),n===zU.LocalAudioTrack?"audio":"video",void 0,r)}))}))()}async updateVideoStreamParameter(e,t){const i=this.localTrackMap.get(t);if(!i||!this.connection)return;if(!(i.track instanceof pk))return YN.warn("[updateVideoStreamParameter]: track is not an instance of LocalVideoTrack");const{track:n}=i,r=function(e,t){const i={};return e.height&&e.width&&(i.scaleResolutionDownBy=Vx(e,t)),i.maxFramerate=e.framerate?Lx(e.framerate):void 0,i.maxBitrate=e.bitrate?1e3*e.bitrate:void 0,i}(e,n);if(n._encoderConfig||(n._encoderConfig={}),t!==zU.LocalVideoLowTrack||!_N("DISABLE_DUAL_STREAM_USE_ENCODING")&&nD().supportDualStreamEncoding)null!=r.scaleResolutionDownBy&&(n._encoderConfig.scaleResolutionDownBy=r.scaleResolutionDownBy);else{const t=n._originMediaStreamTrack;if(!t.canvas)return YN.warn("[".concat(n.getTrackId(),"] no canvas on track"));!function(e,t){const i=e.canvas;t.width&&(i.width=Lx(t.width)),t.height&&(i.height=Lx(t.height)),t.framerate&&(i.stopCapture&&i.stopCapture(),i.stopCapture=iP((()=>{!i.startCapture&&i.stopCapture&&i.stopCapture(),i.startCapture&&i.startCapture()}),Lx(t.framerate)))}(t,e)}null!=r.maxBitrate&&(n._encoderConfig.bitrateMax=r.maxBitrate/1e3),null!=r.maxFramerate&&(n._encoderConfig.frameRate&&"object"==typeof n._encoderConfig.frameRate?n._encoderConfig.frameRate.max=r.maxFramerate:n._encoderConfig.frameRate={max:r.maxFramerate}),YN.debug("[".concat(n.getTrackId(),"] LowStreamEncoderConfig: , ").concat(JSON.stringify(n._encoderConfig))),await this.connection.updateRtpSenderEncodings(n)}publishLowStream(e){var t=this;return FA((function*(){if(!t.connection||t.state!==XU.Connected)return;const i=yield BA(t.mutex.lock("Locking from P2PChannel.publishLowStream"));try{const r=t.localTrackMap.get(zU.LocalVideoTrack);if(!r)throw new mw(Ew.UNEXPECTED_ERROR,"Could not find high stream");if(t.localTrackMap.has(zU.LocalVideoLowTrack))throw new mw(Ew.UNEXPECTED_ERROR,"[".concat(t.store.clientId,"] Can't publish low stream when stream already publish"));const o=[{track:t.getLowVideoTrack(r.track,e),type:zU.LocalVideoLowTrack}];if(yield*jA(NB(t.doPublish(t.connection,o))),r.track.muted||!r.track.enabled){var n;const e=null===(n=t.localTrackMap.get(zU.LocalVideoLowTrack))||void 0===n?void 0:n.id;void 0!==e&&(yield BA(t.connection.muteLocal([e])))}}finally{i()}}))()}async republish(){this.pendingLocalTracks.length>0&&(YN.debug("[".concat(this.store.clientId,"] Emit P2PChannelEvents.RequestRePublish to republish tracks.")),await Yw(this,JU.RequestRePublish,this.pendingLocalTracks),this.emit
12272(JU.MediaReconnectEnd,this.store.uid),this.pendingLocalTracks=[]),this.pendingLocalDataChannels.length>0&&(YN.debug("Emit P2PChannelEvents.RequestRePublishDataChannel to republish datachannels."),await Yw(this,JU.RequestRePublishDataChannel,this.pendingLocalDataChannels),this.pendingLocalDataChannels=[]),this._isWaitPcToRePub=!1}async reSubscribe(e){for(let e=this.pendingRemoteTracks.length-1;e>=0;e--){const{user:t,kind:i}=this.pendingRemoteTracks[e];(i!==HU.AUDIO||t._audio_added_&&t._audioSSRC)&&(i!==HU.VIDEO||t._video_added_&&t._videoSSRC)||this.pendingRemoteTracks.splice(e,1)}if(e)await Yw(this,JU.RequestReSubscribe,this.pendingRemoteTracks);else for(const{user:e,kind:t}of this.pendingRemoteTracks)await this.subscribe(e,t,t===HU.VIDEO?e._videoSSRC:e._audioSSRC);this.pendingRemoteTracks.forEach((e=>{let{user:t}=e;this.emit(JU.MediaReconnectEnd,t.uid)})),this.pendingRemoteTracks=[]}async unpublish(e){if(!this.connection||this.state!==XU.Connected)return void e.forEach((e=>{const t=this.pendingLocalTracks.indexOf(e);-1!==t&&this.pendingLocalTracks.splice(t,1)}));const t=this.filterTobeUnpublishedTracks(e);if(0===t.length)return;const i=t.find((e=>"videoLowTrack"===e[0]));if(i){i[1].track.close()}return this.doUnpublish(this.connection,t)}async unpublishDataChannel(e){if(!this.connection||this.state!==XU.Connected)return void e.forEach((e=>{const t=this.pendingLocalDataChannels.indexOf(e);-1!==t&&this.pendingLocalDataChannels.splice(t,1)}));const t=this.filterTobeUnpublishedDataChannels(e);return 0!==t.length?(t.forEach((e=>{const t=this.localDataChannels.indexOf(e);-1!==t&&this.localDataChannels.splice(t,1)})),0===this.localDataChannels.length&&await this.connection.stopD
12272ataChannels(this.store.uid),t.map((e=>e.id))):void 0}async unpublishLowStream(){if(!this.connection||this.state!==XU.Connected)return;const e=this.localTrackMap.get(zU.LocalVideoLowTrack);if(!e)return;e.track.close();const t=[[zU.LocalVideoLowTrack,e]];return this.doUnpublish(this.connection,t)}async doUnpublish(e,t){const i=this.createGatewayUnpublishMessage(t);return await e.stopSending(t.map((e=>{let[,{id:t}]=e;return t}))),this.withdrawLocalTracks(t),this.unbindLocalTrackEvents(t.map((e=>{let[t,{track:i}]=e;return{type:t,track:i}}))),t.forEach((e=>{let[t]=e;this.statsCollector.removeLocalStats(t)})),0===this.localTrackMap.size&&this.statsUploader.stopUploadOutboundStats(),i}async subscribeDataChannel(e,t){if(!this.connection||this.state!==XU.Connected)throw new mw(Ew.INVALID_OPERATION,"Cannot subscribe remote user when peerConnection disconnected.");const i=t.filter((t=>{var i;return!(null!==(i=this.remoteDataChannelMap.get(e))&&void 0!==i&&i.get(t.id))}));if(0!==i.length)return await this.connection.createDataChannels(e.uid,i),i.forEac
12272h((t=>{var i;this.remoteDataChannelMap.has(e)?null===(i=this.remoteDataChannelMap.get(e))||void 0===i||i.set(t.id,t):this.remoteDataChannelMap.set(e,new Map([[t.id,t]]));const n=this.pendingRemoteDataChannels.findIndex((i=>{let{user:n,id:r}=i;return n.uid===e.uid&&r===t.id}));-1!==n&&this.pendingRemoteDataChannels.splice(n,1)})),i.map((e=>e.id))}async subscribe(e,t,i,n,r){var o;if(!this.connection||this.state!==XU.Connected)throw new mw(Ew.INVALID_OPERATION,"Cannot subscribe remote user when peerConnection disconnected.");if(null!==(o=this.remoteUserMap.get(e))&&void 0!==o&&o.has(t))return;let s,a,c;const d=this.connection.getPreMedia(i);if(d)YN.debug("[".concat(this.store.clientId,"] [").concat(this.store.p2pId,"] preSSRCMap has ssrcId: ").concat(i,", no need to send sub to gateway.")),c=d.transceiver,s=d.track,a=d.id;else if(r){const i=r.find((e=>{let{stream_type:i}=e;return i===t}));if(!i)throw new mw(Ew.UNEXPECTED_ERROR,"Cannot subscribe to remote ".concat(t," for user: ").concat(e.uid," because subscribe answer from gateway does not contain stream_type: ").concat(t,"."));
12272const n=await this.connection.receive(t,i.ssrcs,String(e._uintid),i.attributes);this.connection instanceof ZF&&(c=n.transceiver),s=n.track,a=n.id}else{const r=await this.connection.receive(t,[{ssrcId:i,rtx:n}],String(e._uintid),void 0);this.connection instanceof ZF&&(c=r.transceiver),s=r.track,a=r.id}if(t===HU.AUDIO?(e._audioTrack?e._audioTrack._updateOriginMediaStreamTrack(s):(e._audioTrack=new Nk(s,e.uid,e._uintid,this.store),YN.info("[".concat(this.store.clientId,"] [").concat(this.store.p2pId,"] create remote audio track: ").concat(e._audioTrack.getTrackId()))),c&&e._audioTrack._updateRtpTransceiver(c),this.bindRemoteTrackEvents(e,e._audioTrack)):(e._videoTrack?e._videoTrack._updateOriginMediaStreamTrack(s):(e._videoTrack=new Ok(s,e.uid,e._uintid,this.store),YN.info("[".concat(this.store.clientId,"] [").concat(this.store.p2pId,"] create remote video track: ").concat(e._videoTrack.getTrackId()))),c&&e._videoTrack._updateRtpTransceiver(c),this.bindRemoteTrackEvents(e,e._videoTrack)),c&&_N("ENABLE_ENCODED_TRANSFORM")){const{interceptRemoteVideoFrame:i,interceptRemoteAudioFrame:n}=yV();t==HU.VIDEO?await i(c.receiver,{onSei:_N("ENABLE_VIDEO_SEI")&&(t=>{var i;return null===(i=e._videoTrack)||void 0===i?void 0:i._onSei(t)})}):t==HU.AUDIO&&await n(c.receiver,{enableTopn:!!_N("ENABLE_AUDIO_TOPN"),enableMetadata:!!_N("ENABLE_AUDIO_METADATA"),onMetadata:e=>{this.safeEmit(JU.AudioMetadata,e)}})}const l=this.remoteUserMap.get(e);l?l.set(t,a):this.remoteUserMap.set(e,new Map([[t,a]])),this.statsCollector.addRemoteStats(e.uid),this.statsUploader.startUploadInboundStats();const u=this.pendingRemoteTracks.findIndex((i=>{let{user:n,kind:r}=i;return n.uid===e.uid&&t===r}));-1!==u&&(this.pendingRemoteTracks.splice(u,1),this.emit(JU.MediaReconnectEnd,e.uid))}async massSubscribe(e){return this.massSubscribeNoLock(e)}async massSubscribeNoLock(e){if(!this.connection||this.state!==XU.Connected)throw new mw(Ew.INVALID_OPERATION,"Cannot subscribeAll remote users when peerConnection disconnected.");e=e.filter((e=>{var t;let{user:i,mediaType:n}=e;return!(null!==(t=this.remoteUserMap.get(i))&&void 0!==t&&t.has(n))}));const t=[],i=new Map;e.forEach((e=>{if(!this.connection)return;const n=this.connection.getPreMedia(e.ssrcId);n?i.set(e.ssrcId,n):t.push(e)}));const n=await this.connection.batchReceive(t.map((e=>{let{user:t,mediaType:i,ssrcId:n,rtxSsrcId:r}=e;return{kind:i,ssrcMsg:[{ssrcId:n,rtx:r}],mslabel:String(t._uintid)}})));t.forEach(((e,t)=>{i.set(e.ssrcId,n[t])}));for(const{user:t,mediaType:n,ssrcId:r}of e){const e=i.get(r);if(!e)return void YN.debug("[".concat(this.store.clientId,"] [").concat(this.store.p2pId,"] cannot find ").concat(t.uid," subscribe data,").concat(n,", ").concat(r));const{track:o,id:s,transceiver:a}=e;if(a&&_N("ENABLE_ENCODED_TRANSFORM")){const{interceptRemoteVideoFrame:e,interceptRemoteAudioFrame:i}=yV();n==HU.VIDEO?await e(a.receiver,{onSei:_N("ENABLE_VIDEO_SEI")&&(e=>{var i;return null===(i=t._videoTrack)||void 0===i?void 0:i._onSei(e)})}):n==HU.AUDIO&&await i(a.receiver,{enableTopn:!!_N("ENABLE_AUDIO_TOPN"),enableMetadata:!!_N("ENABLE_AUDIO_METADATA"),onMetadata:e=>{this.safeEmit(JU.AudioMetadata,e)}})}if(n===HU.AUDIO?(t._audioTrack?t._audioTrack._updateOriginMediaStreamTrack(o):(t._audioTrack=new Nk(o,t.uid,t._uintid,this.store),YN.info("[".concat(this.store.clientId,"] [").concat(this.store.p2pId,"] create remote audio track: ").concat(t._audioTrack.getTrackId()))),a&&t._audioTrack._updateRtpTransceiver(a),this.bindRemoteTrackEvents(t,t._audioTrack)):(t._videoTrack?t._videoTrack._updateOriginMediaStreamTrack(o):(t._videoTrack=new Ok(o,t.uid,t._uintid,this.store),YN.info("[".concat(this.store.clientId,"] [").concat(this.store.p2pId,"] create remote video track: ").concat(t._videoTrack.getTrackId()))),a&&t._videoTrack._updateRtpTransceiver(a),this.bindRemoteTrackEvents(t,t._videoTrack)),_N("ENABLE_VIDEO_SEI")&&a){const{interceptRemoteVideoFrame:e,interceptRemoteAudioFrame:i}=yV();n==HU.VIDEO?await e(a.receiver,{onSei:e=>{var i;null===(i=t._videoTrack)||void 0===i||i._onSei(e)}}):n==HU.AUDIO&&await i(a.receiver)}const c=this.remoteUserMap.get(t);c?c.set(n,s):this.remoteUserMap.set(t,new Map([[n,s]])),this.statsCollector.addRemoteStats(t.uid),this.statsUploader.startUploadInboundStats();const d=this.pendingRemoteTracks.findIndex((e=>{let{user:i,kind:r}=e;return i.uid===t.uid&&n===r}));
12272-1!==d&&(this.pendingRemoteTracks.splice(d,1),this.emit(JU.MediaReconnectEnd,t.uid))}}async unsubscribe(e,t,i){const n=this.pendingRemoteTracks.filter((i=>{let{user:n,kind:r}=i;return void 0!==t?n.uid===e.uid&&t===r:n.uid===e.uid}));if(n.forEach((e=>{const t=this.pendingRemoteTracks.indexOf(e);this.pendingRemoteTracks.splice(t,1)})),this.connection&&this.state===XU.Connected||i||n.forEach((t=>{let{kind:i}=t;var n;if(i===HU.AUDIO)null===(n=e._audioTrack)||void 0===n||n._destroy(),e._audioTrack=void 0;else if(i===HU.VIDEO){var r;null===(r=e._videoTrack)||void 0===r||r._destroy(),e._videoTrack=void 0}})),!this.connection||this.state!==XU.Connected)return;const r=this.filterTobeUnSubscribedTracks(e,t);if(0===r.length)return;await this.connection.stopReceiving(r.map((e=>{let[,{id:t}]=e;return t})));const o=this.createUnsubscribeMessage(r);return this.withdrawRemoteTracks(r),0===this.remoteUserMap.size&&this.statsUploader.stopUploadInboundStats(),r.forEach((e=>{let[t,{kind:n}]=e;var r,o;n===HU.VIDEO&&t._videoSSRC&&(null===(r=this.connection)||void 0===r||r.setStatsRemoteVideoIsReady(t._videoSSRC,!1));if(n===HU.VIDEO)this.unbindRemoteTrackEvents(t._videoTrack),i||(null===(o=t._videoTrack)||void 0===o||o._destroy(),t._videoTrack=void 0);else if(n===HU.AUDIO){var s;if(this.unbindRemoteTrackEvents(t._audioTrack),!i)null===(s=t._audioTrack)||void 0===s||s._destroy(),t._audioTrack=void 0}})),o}async unsubscribeDataChannel(e,t){if(t.forEach((e=>{const t=this.pendingRemoteDataChannels.findIndex((t=>t.id===e.id));-1!==t&&this.pendingRemoteDataChannels.splice(t,1)})),!this.connection)return;const i=this.filterTobeUnSubscribedDataChannels(e,t);if(0===i.length)return;t.forEach((e=>{e._close()}));const n=this.remoteDataChannelMap.get(e);return i.forEach((e=>{n&&n.delete(e.id)})),n&&0===n.size&&(this.remoteDataChannelMap.delete(e),await this.connection.stopD
12272ataChannels(e.uid)),i.map((e=>e.id))}async massUnsubscribe(e){return this.massUnsubscribeNoLock(e)}async massUnsubscribeNoLock(e){let t=[];for(const{user:i,mediaType:n}of e){const e=this.pendingRemoteTracks.filter((e=>{let{user:t,kind:r}=e;return void 0!==n?t.uid===i.uid&&n===r:t.uid===i.uid}));e.forEach((e=>{const t=this.pendingRemoteTracks.indexOf(e);this.pendingRemoteTracks.splice(t,1)})),t=t.concat(e)}if(!this.connection||this.state!==XU.Connected)return void t.forEach((e=>{let{user:t,kind:i}=e;var n;if(i===HU.AUDIO)null===(n=t._audioTrack)||void 0===n||n._destroy(),t._audioTrack=void 0;else if(i===HU.VIDEO){var r;null===(r=t._videoTrack)||void 0===r||r._destroy(),t._videoTrack=void 0}}));const i=Xn(e).call(e,((e,t)=>{let{user:i,mediaType:n}=t;const r=this.filterTobeUnSubscribedTracks(i,n);return e.concat(r)}),[]);if(0===i.length)return;await this.connection.stopReceiving(i.map((e=>{let[,{id:t}]=e;return t})));const n=this.createUnsubscribeAllMessage(i);return this.withdrawRemoteTracks(i),0===this.remoteUserMap.size&&this.statsUploader.stopUploadInboundStats(),i.forEach((e=>{let[t,{kind:i}]=e;var n,r;i===HU.VIDEO&&t._videoSSRC&&(null===(n=this.connection)||void 0===n||n.setStatsRemoteVideoIsReady(t._videoSSRC,!1));if(i===HU.VIDEO)this.unbindRemoteTrackEvents(t._videoTrack),null===(r=t._videoTrack)||void 0===r||r._destroy(),t._videoTrack=void 0;else if(i===HU.AUDIO){var o;this.unbindRemoteTrackEvents(t._audioTrack),null===(o=t._audioTrack)||void 0===o||o._destroy(),t._audioTrack=void 0}})),n}isPreSubScribe(e){if(!this.connection||this.state!==XU.Connected)return!1;return!!this.connection.getPreMedia(e)}async muteRemote(e,t){if(!this.connection)return;const i=this.remoteUserMap.get(e);if(!i)return void YN.warning("[".concat(this.store.clientId,"] P2PChannel.muteRemote has no remote user ").concat(e.uid,"."));if(!i.get(t))return void YN.warning("[".concat(this.store.clientId,"] P2PChannel.muteRemote has no remote user ").concat(e.uid," media type ").concat(t,"."));const n=t===HU.VIDEO?e._videoSSRC:e._audioSSRC;void 0!==n&&this.connection.setStatsRemoteVideoIsReady(n,!1)}async unmuteRemote(e,t){return this.unmuteRemoteNoLock(e,t)}async unmuteRemoteNoLock(e,t){if(!this.connection)return;const i=this.remoteUserMap.get(e);if(!i)return void YN.warning("[".concat(this.store.clientId,"] P2PChannel.unmuteRemote has no remote user ").concat(e.uid,"."));i.get(t)||YN.warning("[".concat(this.store.clientId,"] P2PChannel.unmuteRemote has no remote user ").concat(e.uid," media type ").concat(t,"."))}addAudioMetadata(e){const t=this.localTrackMap.get(zU.LocalAudioTrack),i=t&&t.track;i&&i.metadata.push(e)}getAllTracks(e){const t=this.localTrackMap.get(zU.LocalAudioTrack);if((null==t?void 0:t.track)instanceof bL){const i=t.track;return Array.from(this.localTrackMap.entries()).filter((e=>{let[t]=e;return t!==zU.LocalAudioTrack})).filter((t=>{let[i]=t;return!(e&&i===zU.LocalVideoLowTrack)})).map((e=>{let[,{track:t}]=e;return t})).concat(i.trackList)}return Array.from(this.localTrackMap.entries()).filter((t=>{let[i]=t;return!(e&&i===zU.LocalVideoLowTrack)})).map((e=>{let[,{track:t}]=e;return t}))}getAllDataChannels(){return this.localDataChannels}reportPublishEvent(e,t,i,n,r){if(e){const i=this.localTrackMap.get(zU.LocalAudioTrack),o=n?this.localTrackMap.get(zU.LocalVideoLowTrack):this.localTrackMap.get(zU.LocalVideoTrack);eD.publish(this.store.sessionId,{eventElapse:TF.measureFromPublishStart(this.store.clientId,this.store.pubId),succ:e,ec:t,audioName:null==i?void 0:i.track.getTrackLabel(),videoName:null==o?void 0:o.track.getTrackLabel(),screenshare:-1!==(null==o?void 0:o.track._hints.indexOf(vD.SCREEN_TRACK)),audio:!!i,video:!!o,p2pid:this.store.p2pId,publishRequestid:this.store.pubId,extend:r})}else{var o;i||(i=[]);const s=i.find((e=>e instanceof IL)),a=n?null===(o=this.localTrackMap.get(zU.LocalVideoTrack))||void 0===o?void 0:o.track:i.find((e=>e instanceof pk));eD.publish(this.store.sessionId,{eventElapse:TF.measureFromPublishStart(this.store.clientId,this.store.pubId),succ:e,ec:t,audioName:null==s?void 0:s.getTrackLabel(),videoName:null==a?void 0:a.getTrackLabel(),screenshare:-1!==(null==a?void 0:a._hints.indexOf(vD.SCREEN_TRACK)),audio:!!s,video:!!a,p2pid:this.store.p2pId,publishRequestid:this.store.pubId,extend:r})}}reportSubscribeEvent(e,t,i,n){const r=n===HU.VIDEO?i._videoSSRC:i._audioSSRC;r&&eD.subscribe(this.store.sessionId,{succ:e,ec:t,video:n===HU.VIDEO,audio:n===HU.AU
vendor: 2,931 bytes, line 12272
12272DIO,peerid:i.uid,subscribeRequestid:r,p2pid:this.store.p2pId,eventElapse:TF.measureFromSubscribeStart(this.store.clientId,r),preSsrc:this.isPreSubScribe(r)})}reset(){YN.debug("[".concat(this.store.clientId,"] P2PChannel.reset")),this.mutex=new IO("P2PChannel-mutex",this.store.clientId),this.connection&&(this.resetConnection(this.connection),this.connection=void 0),this.shouldForwardP2PCreation&&(this.connection=YF(this.store),this.emit(JU.PeerConnectionStateChange,this.connection.peerConnectionState),this.bindConnectionEvents(this.connection)),this.statsUploader.stopUploadOutboundStats(),this.statsUploader.stopUploadInboundStats(),this.statsUploader.stopUploadTransportStats(),this.statsUploader.stopUploadExtensionUsageStats(),this.statsUploader.stopUploadBaseStats(),this.unbindLocalTrackEvents(),this.unbindAllRemoteTrackEvents(),this.unbindRtpTransceiver();const e=this.localTrackMap.get(zU.LocalAudioTrack);if((null==e?void 0:e.track)instanceof bL){if(e.track.trackList.length>0){const t=e.track;e.track.trackList.forEach((e=>{t.removeAudioTrack(e)}))}e.track.close()}this.localTrackMap.clear(),this.remoteUserMap.clear(),this.statsCollector.removeRemoteStats(),this.statsCollector.removeLocalStats(),this.iceFailedCount=0,this.dtlsFailedCount=0,this.pendingLocalTracks=[],this.pendingRemoteTracks=[],this.localDataChannels=[],this.remoteDataChannelMap.clear(),this.pendingLocalDataChannels=[],this.pendingRemoteDataChannels=[],this.state=XU.Disconnected}getStats(){var e;return null===(e=this.connection)||void 0===e?void 0:e.getStats()}getRemoteVideoIsReady(e){var t;return(null===(t=this.connection)||void 0===t?void 0:t.getRemoteVideoIsReady(e))||!1}getLocalAudioVolume(){const e=this.localTrackMap.get(zU.LocalAudioTrack);if(e)return e.track.getVolumeLevel()}getLocalVideoSize(){const e=this.localTrackMap.get(zU.LocalVideoTrack);if(e)return{width:e.track.videoWidth||0,height:e.track.videoHeight||0}}getEncoderConfig(e){const t=this.localTrackMap.get(e);return t&&t.track instanceof pk||t&&t.track instanceof IL?t.track._encoderConfig:void 0}getLocalMedia(e){return this.localTrackMap.get(e)}hasLocalMedia(){return this.localTrackMap.size>0}hasRemoteMedia(e,t){if(!e)return this.remoteUserMap.size>0;const i=this.remoteUserMap.get(e);return!!i&&(!t||i.has(t))}async hasRemoteMediaWithLock(e,t){if(!e)return this.remoteUserMap.size>0;const i=this.remoteUserMap.get(e);return!!i&&(!t||i.has(t))}getRemoteMedia(e){var t;const i=Array.from(MN(t=this.remoteUserMap).call(t)).find((t=>t.uid===e));return i?{audioTrack:i.audioTrack,audioSSRC:i._audioSSRC,videoTrack:i.videoTrack,videoSSRC:i._videoSSRC}:{}}getAudioLevels(){let e=Array.from(this.remoteUserMap.entries()).map((e=>{let[t]=e;return{uid:t.uid,level:t.audioTrack?100*t.audioTrack._source.getAccurateVolumeLevel():0}}));const t=this.localTrackMap.get(zU.LocalAudioTrack);return t&&e.push({level:100*t.track._source.getAccurateVolumeLevel(),uid:this.store.uid}
12272),e=vS(e).call(e,((e,t)=>e.level-t.level)),e}async disconnectForReconnect(){this.connection&&(YN.debug("[".concat(this.store.clientId,"] P2PChannel.disconnectForReconnect closing P2PConnection")),this.state=XU.Reconnecting,_N("KEEP_LAST_FRAME")&&0!==this.remoteUserMap.size&&Array.from(this.remoteUserMap.entries()).forEach((e=>{let[t]=e;var i;t._videoTrack&&t._videoTrack._player&&(null===(i=t._videoTrack._player.getVideoElement())||void 0===i||i.pause(),t._videoTrack._player.isKeepLastFrame=!0,t._videoTrack._originMediaStreamTrack.stop())})),this.resetConnection(this.connection),this.connection=void 0,this.shouldForwardP2PCreation&&(this.connection=YF(this.store),this.emit(JU.PeerConnectionStateChange,this.connection.peerConnectionState),this.bindConnectionEvents(this.connection)),0!==this.localTrackMap.size&&(Array.from(this.localTrackMap.entries()).forEach((e=>{var t;let[i,{track:n}]=e;switch(i){case zU.LocalVideoTrack:Dn(t=n._hints).call(t,vD.LOW_STREAM)?n.close():this.pendingLocalTracks.push(n);break;case zU.LocalAudioTrack:n instanceof bL?this.pendingLocalTracks=this.pendingLocalTracks.concat(n.trackList):this.pendingLocalTracks.push(n);case zU.LocalVideoLowTrack:}})),this.emit(JU.MediaReconnectStart,this.store.uid)),this.unbindLocalTrackEvents(),this.localTrackMap.clear(),0!==this.remoteUserMap.size&&Array.from(this.remoteUserMap.entries()).forEach((e=>{let[t,i]=e;Array.from(MN(i).call(i)).forEach((e=>{this.setPendingRemoteMedia(t,e)})),this.emit(JU.MediaReconnectStart,t.uid)})),this.unbindAllRemoteTrackEvents(),this.remoteUserMap.clear(),0!==this.localDataChannels.length&&(this.localDataChannels.forEach((e=>{this.pendingLocalDataChannels.push(e)})),this.localDataChannels.length=0),0!==this.remoteDataChannelMap.size&&(Array.from(this.remoteDataChannelMap.entries()).forEach((e=>{let[t,i]=e;Array.from(MN(i).call(i)).forEach((e=>{this.setPendingRemoteDataChannel(t,e)}))})),this.remoteDataChannelMap.clear()),this.statsUploader.stopUploadOutboundStats(),this.statsUploader.stopUploadInboundStats(),this.statsUploader.stopUploadTransportStats(),YN.debug("[".concat(this.store.clientId,"] P2PChannel disconnected, waiting to reconnect.")))}hasPendingRemoteDataChannel(e,t){for(const i of this.pendingRemoteDataChannels){const{user:n,id:r}=i;if((e instanceof IF?e.uid:e)===n.uid&&r===t)return!0}return!1}setPendingRemoteDataChannel(e,t){this.hasPendingRemoteDataChannel(e,t)||this.pendingRemoteDataChannels.push({user:e,id:t})}hasPendingRemoteMedia(e,t){for(const i of this.pendingRemoteTracks){const{user:n,kind:r}=i;if((e instanceof IF?e.uid:e)===n.uid&&t===r)return!0}return!1}setPendingRemoteMedia(e,t){this.hasPendingRemoteMedia(e,t)||this.pendingRemoteTracks.push({user:e,kind:t})}restartICE(e){var t=this;return FA((function*(){if(!t.connection||t.state!==XU.Connected)return;const i=yield BA(t.mutex.lock("From P2PChannel.restartICE"));let n;try{n=yield BA(t.connection.restartICE(e));const r=yield BA(n.next());if(r.done)return;const o=r.value,s=yield o;switch(qF(t.connection)&&t.reportPCStats(Date.now(),!1,t._pcStatsUploadType),e){case KU.UDP_TCP_RELAY:t._pcStatsUploadType=YU.UDP_TCP_RESTART;break;case KU.TCP_RELAY:t._pcStatsUploadType=YU.TCP_RESTART;break;case KU.RELAY:t._pcStatsUploadType=YU.RELAY_RESTART;break;default:t._pcStatsUploadType=YU.OLD_RESTART}t._isTryConnecting=!0,n.next(s)}catch(e){var r;null===(r=n)||void 0===r||r.throw(e)}finally{i()}}))()}getUplinkNetworkQuality(){if(!this.connection)return 0;const e=this.connection.getStats(),t=this.localTrackMap.get(zU.LocalVideoTrack),i=this.localTrackMap.get(zU.LocalAudioTrack),n=e.videoSend.find((e=>e.ssrc===(null==t?void 0:t.ssrcs[0].ssrcId))),r=e.audioSend.find((e=>e.ssrc===(null==i?void 0:i.ssrcs[0].ssrcId)));if(!n||!r)return 1;const o=zw(this,JU.NeedSignalRTT),s=n?n.rttMs:void 0,a=r?r.rttMs:void 0,c=s&&a?(s+a)/2:s||a,d=(c&&o?(c+o)/2:c||o)||0,l=100*e.sendPacketLossRate*.7/50+.3*d/1500,u=l<.17?1:l<.36?2:l<.59?3:l<.1?4:5,h=null==t?void 0:t.track;if(h&&h._encoderConfig&&-1===h._hints.indexOf(vD.SCREEN_TRACK)){const t=h._encoderConfig.bitrateMax,i=e.bitrate.actualEncoded;if(t&&i){const e=(1e3*t-i)/(1e3*t);return fM[e<.15?0:e<.3?1:e<.45?2:e<.6?3:4][u]}}return u}getDownlinkNetworkQuality(){if(!this.connection)return 0;const e=this.connection.getStats();let t=0;
vendor: 7,089 bytes, line 12272
12272return Array.from(this.remoteUserMap.entries()).forEach((i=>{let[n]=i;const r=n._audioSSRC,o=n._videoSSRC,s=e.audioRecv.find((e=>e.ssrc===r)),a=e.videoRecv.find((e=>e.ssrc===o));if(!s&&!a)return void(t+=1);const c=zw(this,JU.NeedSignalRTT),d=e.rtt,l=(d&&c?(d+c)/2:d||c)||0,u=s?s.jitterMs:void 0,h=e.recvPacketLossRate;let p=.7*h*100/50+.3*l/1500;u&&(p=.6*h*100/50+.2*l/1500+.2*u/400);t+=p<.1?1:p<.17?2:p<.36?3:p<.59?4:5})),this.remoteUserMap.size>0?Math.round(t/this.remoteUserMap.size):t}async muteLocalTrack(e){return new Wh(((t,i)=>{this.handleMuteLocalTrack(e,t,i)}))}async replaceTrack(e,t){var i;if(YN.debug("[".concat(this.store.clientId,"] P2PChannel replaceTrack from [").concat(e.getTrackId(),"] to [").concat(t.getTrackId(),"]")),!this.connection||this.state!==XU.Connected)return;const n=Array.from(this.localTrackMap.entries()).find((t=>{let[,{track:i}]=t;return e===i}));if(!n)return;const r=n[0];if(e!==t&&(this.unbindLocalTrackEvents([{track:e,type:r}]),this.bindLocalTrackEvents([{track:t,type:r}]),n[1].track=t),await(null===(i=this.connection)||void 0===i?void 0:i.replaceTrack(t,n[1].id)),this.isPlanB){const e=n[1];e.id=t._mediaStreamTrack.id,this.localTrackMap.set(r,e)}if(r===zU.LocalVideoTrack&&!_N("DISABLE_DUAL_STREAM_USE_ENCODING")&&nD().supportDualStreamEncoding){const t=this.localTrackMap.get(zU.LocalVideoLowTrack);if(t){const i=e._mediaStreamTrack.clone();t.track._originMediaStreamTrack.stop(),t.track._mediaStreamTrack=i,t.track._originMediaStreamTrack=i,await new Wh(((e,i)=>{this.handleReplaceTrack(t.track,e,i,!0)}))}}}filterTobePublishedTracks(e,t,i){const n=[],r=this.getAllTracks();e=Zw(e=e.filter((e=>-1===r.indexOf(e))));let o,s=!1;const a=this.localTrackMap.get(zU.LocalAudioTrack);for(const r of e){if(r instanceof pk&&(this.localTrackMap.has(zU.LocalVideoTrack)||s?new mw(Ew.CAN_NOT_PUBLISH_MULTIPLE_VIDEO_TRACKS).throw():(n.push({track:r,type:zU.LocalVideoTrack}),s=!0),t)){const e=this.getLowVideoTrack(r,i);n.push({track:e,type:zU.LocalVideoLowTrack})}if(r instanceof IL)if(a){const e=a.track;if(e instanceof bL)WF([r]),e.addAudioTrack(r),this.bindLocalAudioTrackEvents(r,!0);else{const t=HF([e,r]);YN.debug("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection will replace audioTrack [").concat(t.getTrackId(),"]")),this.replaceTrack(e,t)}}else if(o instanceof bL)WF([r]),o.addAudioTrack(r);else if(o||!r._useAudioElement&&nD().webAudioMediaStreamDest&&!r._bypassWebAudio){o=HF(o?[r,o]:[r])}else o=r}return o&&(YN.debug("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection will send audioTrack [").concat(o.getTrackId(),"]")),n.push({track:o,type:zU.LocalAudioTrack})),n}filterTobeUnpublishedTracks(e){const t=[],i=this.getAllTracks();e=Zw(e=e.filter((e=>-1!==i.indexOf(e))));for(const i of e){if(i instanceof IL){const e=this.localTrackMap.get(zU.LocalAudioTrack);if(!e)continue;e.track instanceof bL?(e.track.removeAudioTrack(i),this.unbindLocalAudioTrackEvents(i),0===e.track.trackList.length&&(t.push([zU.LocalAudioTrack,e]),e.track.close())):t.push([zU.LocalAudioTrack,e])}if(i instanceof pk){const e=this.localTrackMap.get(zU.LocalVideoTrack);if(!e)continue;t.push([zU.LocalVideoTrack,e]);const i=this.localTrackMap.get(zU.LocalVideoLowTrack);i&&t.push([zU.LocalVideoLowTrack,i])}}return t}filterTobePublishedDataChannels(e){return e=(e=Zw(e)).filter((e=>-1===this.localDataChannels.findIndex((t=>t.id===e.id))))}filterTobeUnpublishedDataChannels(e){return e=(e=(e=Zw(e)).filter((e=>-1!==this.localDataChannels.indexOf(e)))).filter((e=>e._originDataChannel))}bindLocalTrackEvents(e){e.forEach((e=>{let{track:t,type:i}=e;switch(i){case zU.LocalVideoTrack:t.addListener(RD.GET_STATS,this.handleGetLocalVideoStats),t.addListener(RD.GET_RTC_STATS,this.handleGetRTCStats),t.addListener(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),t.addListener(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),t.addListener(RD.NEED_UPDATE_VIDEO_ENCODER,this.handleUpdateVideoEncoder),t.addListener(RD.NEED_UPDATE_VIDEO_SEND_PARAMETERS,this.handleUpdateVideoSendParameters),t.addListener(RD.NEED_REPLACE_TRACK,this.handleReplaceTrack),t.addListener(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),t.addListener(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack);break;case zU.LocalAudioTrack:this.bindLocalAudioTrackEvents(t);case zU.LocalVideoLowTrack:}}))}bindLocalAudioTrackEvents(e,t){e instanceof bL?e.trackList.forEach((e=>{e.addListener(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),e.addListener(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),e.addListener(RD.GET_STATS,this.handleGetLocalAudioStats),e.addListener(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),e.addListener(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack)})):(e.addListener(RD.GET_STATS,this.handleGetLocalAudioStats),e.addListener(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),e.addListener(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),e.addListener(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),e.addListener(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack),t||(e.addListener(RD.NEED_REPLACE_TRACK,this.handleReplaceTrack),e.addListener(RD.NEED_REPLACE_MIXING_TRACK,this.handleReplaceMixingTrack)))}unbindLocalTrackEvents(e){e||(e=Array.from(this.localTrackMap.entries()).map((e=>{let[t,{track:i}]=e;return{track:i,type:t}}))),e.forEach((e=>{let{track:t,type:i}=e;switch(i){case zU.LocalVideoTrack:t.off(RD.GET_STATS,this.handleGetLocalVideoStats),t.off(RD.GET_RTC_STATS,this.handleGetRTCStats),t.off(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),t.off(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),t.off(RD.NEED_UPDATE_VIDEO_ENCODER,this.handleUpdateVideoEncoder),t.off(RD.NEED_UPDATE_VIDEO_SEND_PARAMETERS,this.handleUpdateVideoSendParameters),t.off(RD.NEED_REPLACE_TRACK,this.handleReplaceTrack),t.off(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),t.off(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack);break;case zU.LocalAudioTrack:this.unbindLocalAudioTrackEvents(t);case zU.LocalVideoLowTrack:}}))}unbindLocalAudioTrackEvents(e){e instanceof bL?e.trackList.forEach((e=>{e.off(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),e.off(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),e.off(RD.GET_STATS,this.handleGetLocalAudioStats),e.off(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),e.off(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack)})):(e.off(RD.GET_STATS,this.handleGetLocalAudioStats),e.off(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),e.off(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),e.off(RD.NEED_REPLACE_TRACK,this.handleReplaceTrack),e.off(RD.NEED_REPLACE_MIXING_TRACK,this.handleReplaceMixingTrack),e.off(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),e.off(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack))}bindRemoteTrackEvents(e,t){t instanceof Ok&&t.addListener(RD.GET_STATS,(t=>{t(this.handleGetRemoteVideoStats(e))})),t instanceof Nk&&t.addListener(RD.GET_STATS,(t=>{t(this.handleGetRemoteAudioStats(e))}))}unbindRemoteTrackEvents(e){e&&e.removeAllListeners(RD.GET_STATS)}unbindAllRemoteTrackEvents(){Array.from(this.remoteUserMap.entries()).forEac
12272h((e=>{let[t,i]=e;i.has(HU.AUDIO)&&this.unbindRemoteTrackEvents(t._audioTrack),i.has(HU.VIDEO)&&this.unbindRemoteTrackEvents(t._videoTrack)}))}createGatewayPublishMessage(e,t){return e.map(((e,i)=>{var n;let r,o,{track:s,type:a}=e;switch(a){case zU.LocalAudioTrack:r=PU.Audio,o={dtx:s instanceof yL&&s._config.DTX,hq:!1,lq:!1,stereo:!1,speech:!1};break;case zU.LocalVideoTrack:r=Dn(n=s._hints).call(n,vD.SCREEN_TRACK)?PU.Screen:PU.High,o=OB(OB({},kx(s)),{},{codec:this.store.codec,svc_mode:Bx()});break;case zU.LocalVideoLowTrack:r=PU.Low,o=OB(OB({},kx(s)),{},{codec:this.store.codec,svc_mode:Bx()})}return{stream_type:r,attributes:o,ssrcs:t[i]}}))}createGatewayUnpublishMessage(e){return e.map((e=>{var t;let i,[n,{track:r,ssrcs:o,id:s}]=e;switch(n){case zU.LocalVideoTrack:i=Dn(t=r._hints).call(t,vD.SCREEN_TRACK)?PU.Screen:PU.High;break;case zU.LocalAudioTrack:i=PU.Audio;break;case zU.LocalVideoLowTrack:i=PU.Low}return{stream_type:i,ssrcs:o,mid:s}}))}assignLocalTracks(e,t){e.forEach(((e,i)=>{let{track:n,type:r}=e;this.localTrackMap.set(r,{track:n,id:t[i].id,ssrcs:t[i].localSSRC})}))}withdrawLocalTracks(e){e.forEach((e=>{let[t]=e;this.localTrackMap.delete(t)}))}bindConnectionEvents(e){e.onConnectionStateChange=async t=>{if(YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.onConnectionStateChange(").concat(t,")")),this.emit(JU.PeerConnectionStateChange,t),"connecting"===t&&e instanceof ZF&&!Kb()&&_N("FIRST_TCP_CANDIDATE")&&window.setTimeout((()=>{"connecting"===t&&e.extendCandidate()}),_N("FIRST_TCP_CANDIDATE_INTERVAL")),"connected"!==t||this.store.keyMetrics.peerConnectionEnd||this.store.peerConnectionEnd(),"connected"===t){this._restartTimer&&(window.clearTimeout(this._restartTimer),this._restartTimer=void 0),e instanceof ZF&&yB(e,!0),this._isTryConnecting&&this.reportPCStats(Date.now(),!0,this._pcStatsUploadType),this._isTryConnecting=!1,this._isStartRestartIce=!1,this._pcStatsUploadType=YU.DISCONNECTED_OR_FAILED;if("CONNECTED"===zw(this,JU.QueryClientConnectionState)&&this._isWaitPcToRePub){const e=this.pendingLocalTracks.map((e=>e.getTrackId())),t=this.pendingLocalDataChannels.map((e=>"dc_".concat(e.id)));eD.reportApiInvoke(this.store.sessionId,{name:kw.REPUB_AFTER_PC_CONNECTED,options:e.concat(t),tag:Mw.TRACER}).onSuccess(),this.republish()}}if(_N("NEW_ICE_RESTART")&&e instanceof ZF&&!Kb()&&!this._forceTurn){if(Dn(qU).call(qU,t)){if(this._isStartRestartIce)return;this._isStartRestartIce=!0;const t=t=>{if(qF(e)){YN.debug("[".concat(this.store.clientId,"] [P2PChannel] try to restartICE, type is ").concat(t));"CONNECTED"===zw(this,JU.QueryClientConnectionState)&&this.emit(JU.RequestRestartICE,t)}},i=()=>{qF(e)&&(this.reportPCStats(Date.now(),!1,this._pcStatsUploadType),YN.debug("[".concat(this.store.clientId,"] P2PConnection disconnected timeout, force reconnect")),setTimeout((()=>
vendor: 4,190 bytes, line 12272
12272this.emit(JU.P2PLost)),0),this.iceFailedCount+=1,this.requestReconnect())};return void(this._restartTimer=window.setTimeout((()=>{AB(e,t,i)}),800))}}else{if("disconnected"===t&&"disconnected"===e.iceConnectionState)return setTimeout((()=>{if("disconnected"===e.iceConnectionState&&_N("ICE_RESTART")){"CONNECTED"===zw(this,JU.QueryClientConnectionState)&&this.emit(JU.RequestRestartICE)}}),800),void setTimeout((()=>{"disconnected"===e.peerConnectionState&&(YN.debug("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection disconnected timeout 4000ms, force reconnect")),this.reportPCStats(Date.now(),!1,this._pcStatsUploadType),this._isTryConnecting=!1,setTimeout((()=>this.emit(JU.P2PLost)),0),this.iceFailedCount+=1,this.requestReconnect())}),4e3);"failed"===t&&(YN.debug("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection state failed, force reconnect")),this.reportPCStats(Date.now(),!1,this._pcStatsUploadType),setTimeout((()=>this.emit(JU.P2PLost)),0),this.iceFailedCount+=1,await this.requestReconnect())}},e.onICEConnectionStateChange=e=>{"connected"!==e||this.store.keyMetrics.iceConnectionEnd||this.store.iceConnectionEnd(),YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.onICEConnectionStateChange(").concat(e,")")),eD.reportApiInvoke(this.store.sessionId,{name:"ICEConnectionStateChange",options:e,tag:Mw.TRACER}).onSuccess(),this.emit(JU.IceConnectionStateChange,e)},e.onICETransportStateChange=e=>{YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.onICETransportStateChange(").concat(e,")"))},e.onDTLSTransportStateChange=e=>{YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.onDTLSTransportStateChange(").concat(e,")"))},e.onDTLSTransportError=e=>{YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.onDTLSTransportError(").concat(e,")"))},e.onFirstAudioDecoded=e=>{var t;const i=Array.from(MN(t=this.remoteUserMap).call(t)).find((t=>t._audioSSRC===e));var n;i&&(this.store.subscribe(i.uid,"audio",void 0,void 0,void 0,Date.now()),null===(n=i.audioTrack)||void 0===n||n.emit(wD.FIRST_FRAME_DECODED),eD.firstRemoteFrame(this.store.sessionId,JN.FIRST_AUDIO_DECODE,QN.FIRST_AUDIO_DECODE,{peer:i._uintid,subscribeElapse:TF.measureFromSubscribeStart(this.store.clientId,e),subscribeRequestid:e,p2pid:this.store.p2pId}))},e.onFirstAudioReceived=e=>{var t;const i=Array.from(MN(t=this.remoteUserMap).call(t)).find((t=>t._audioSSRC===e));i&&eD.firstRemoteFrame(this.store.sessionId,JN.FIRST_AUDIO_RECEIVED,QN.FIRST_AUDIO_RECEIVED,{peer:i._uintid,subscribeElapse:TF.measureFromSubscribeStart(this.store.clientId,e),subscribeRequestid:e,p2pid:this.store.p2pId})},e.onFirstVideoDecoded=(e,t,i)=>{this.reportVideoFirstFrameDecoded(e,t,i)},e.onFirstVideoReceived=e=>{var t;const i=Array.from(MN(t=this.remoteUserMap).call(t)).find((t=>t._videoSSRC===e));i&&eD.firstRemoteFrame(this.store.sessionId,JN.FIRST_VIDEO_RECEIVED,QN.FIRST_VIDEO_RECEIVED,{peer:i._uintid,subscribeElapse:TF.measureFromSubscribeStart(this.store.clientId,e),subscribeRequestid:e,p2pid:this.store.p2pId})},e.onSelectedLocalCandidateChanged=(e,t)=>{const i="relay"===e.candidateType,n="relay"===t.candidateType;"unknown"!==t.candidateType&&i===n||this.emit(JU.ConnectionTypeChange,i),YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.SelectedLocalCandidateChanged(").concat(JSON.stringify(Fx(t))," -> ").concat(JSON.stringify(Fx(e)),")"))},e.onSelectedRemoteCandidateChanged=(e,t)=>{YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.SelectedRemoteCandidateChanged(").concat(JSON.stringify(Fx(t))," -> ").concat(JSON.stringify(Fx(e)),")"))},e.onFirstVideoDecodedTimeout=e=>{this.reportVideoFirstFrameDecoded(e,void 0,void 0,!0)},e.getLocalVideoStats=()=>{const e=this.statsCollector.getLocalVideoTrackStats(),t=this.statsCollector.getRTCStats();return OB(OB({},e),t)},e.onICECandidateError=e=>{this._iceError=e}}resetConnection(e){e instanceof ZF&&function(e){vB.delete(e.id),yB(e)}
12272(e),e.close(),this.emit(JU.PeerConnectionStateChange,"closed"),function(e){e.onConnectionStateChange=void 0,e.onICEConnectionStateChange=void 0,e.onICETransportStateChange=void 0,e.onDTLSTransportStateChange=void 0,e.onDTLSTransportError=void 0,e.onFirstAudioDecoded=void 0,e.onFirstAudioReceived=void 0,e.onFirstVideoDecoded=void 0,e.onFirstVideoReceived=void 0,e.onSelectedLocalCandidateChanged=void 0,e.onSelectedRemoteCandidateChanged=void 0,e.onFirstVideoDecodedTimeout=void 0,e.getLocalVideoStats=void 0}(e),this._isWaitPcToRePub=!1}filterTobeMutedTracks(e){const t=[];if(-1===this.getAllTracks().indexOf(e))return t;const i=this.localTrackMap.get(zU.LocalAudioTrack);if(e instanceof IL&&(null==i?void 0:i.track)instanceof bL)return i.track.isActive||t.push([zU.LocalAudioTrack,i]),t;const n=Array.from(this.localTrackMap.entries()).find((t=>{let[,{track:i}]=t;return e===i}));if(n&&(t.push(n),n[0]===zU.LocalVideoTrack)){const e=this.localTrackMap.get(zU.LocalVideoLowTrack);e&&t.push([zU.LocalVideoLowTrack,e])}return t}filterTobeUnmutedTracks(e){const t=[],i=this.localTrackMap.get(zU.LocalAudioTrack);if(e instanceof IL&&(null==i?void 0:i.track)instanceof bL)return i.track.isActive&&t.push([zU.LocalAudioTrack,i]),t;const n=Array.from(this.localTrackMap.entries()).find((t=>{let[,{track:i}]=t;return e===i}));if(n)if(n[0]===zU.LocalVideoTrack){t.push(n);const e=this.localTrackMap.get(zU.LocalVideoLowTrack);e&&t.push([zU.LocalVideoLowTrack,e])}else t.push(n);return t}createMuteMessage(e){return e.map((e=>{var t;let i,[n,{track:r,ssrcs:o,id:s}]=e;switch(n){case zU.LocalAudioTrack:i=PU.Audio;break;case zU.LocalVideoTrack:i=Dn(t=r._hints).call(t,vD.SCREEN_TRACK)?PU.Screen:PU.High;break;case zU.LocalVideoLowTrack:i=PU.Low}return{stream_type:i,ssrcs:o,mid:s}}))}createUnmuteMessage(e){return e.map((e=>{var t;let i,[n,{track:r,ssrcs:o,id:s}]=e;switch(n){case zU.LocalAudioTrack:i=PU.Audio;break;case zU.LocalVideoTrack:i=Dn(t=r._hints).call(t,vD.SCREEN_TRACK)?PU.Screen:PU.High;break;case zU.LocalVideoLowTrack:i=PU.Low}return{stream_type:i,ssrcs:o,mid:s}}))}filterTobeUnSubscribedTracks(e,t){const i=[],n=this.remoteUserMap.get(e);if(!n)return i;if(t){const r=n.get(t);if(!r)return i;i.push([e,{kind:t,id:r}])}else Array.from(n.entries()).forEach((t=>{let[n,r]=t;i.push([e,{kind:n,id:r}])}));return i}filterTobeUnSubscribedDataChannels(e,t){const i=[];return t.forEach((t=>{var n;null!==(n=this.remoteDataChannelMap.get(e))&&void 0!==n&&n.has(t.id)&&i.push(t)})),i}createUnsubscribeMessage(e){const t=[];return e.forEach((e=>{let[i,{kind:n,id:r}]=e;switch(n){case HU.VIDEO:return void(i._videoSSRC&&t.push({stream_type:HU.VIDEO,ssrcId:i._videoSSRC}));case HU.AUDIO:return void(i._audioSSRC&&t.push({stream_type:HU.AUDIO,ssrcId:i._audioSSRC}))}})),t}createUnsubscribeAllMessage(e){const t=new Map;return e.forEach((e=>{let[i,{kind:n}]=e;if(t.has(i)){let e=t.get(i);n===HU.VIDEO?e|=MU.Video:e|=MU.Audio,t.set(i,e)}else n===HU.VIDEO?t.set(i,MU.Video):t.set(i,MU.Audio)})),{users:Array.from(t.entries()).map((e=>{let[t,i]=e;return{stream_id:t.uid,stream_type:i}}))}}withdrawRemoteTracks(e){e.forEach((e=>{let[t,{kind:i}]=e;const n=this.remoteUserMap.get(t);n&&(n.delete(i),0===Array.from(n.entries()).length&&this.remoteUserMap.delete(t))}))}async updateBitrateLimit(e){const t=this.localTrackMap.get(zU.LocalVideoTrack),i=this.localTrackMap.get(zU.LocalVideoLowTrack);t&&(await t.track.setBitrateLimit(e.uplink),await new Wh(((e,i)=>{this.handleUpdateVideoEncoder(t.track,e,i,!0)}))),i&&e.low_stream_uplink&&(await i.track.setBitrateLimit({max_bitrate:e.low_stream_uplink.bitrate,min_bitrate:e.low_stream_uplink.bitrate||0}),await new Wh(((e,t)=>{this.handleUpdateVideoEncoder(i.track,e,t,!0)})))}isP2PDisconnected(){if(this.connection){return"connected"!==this.connection.peerConnectionState}return!0}mapPubResToRemoteConfig(e,t,i){return e.map(((e,n)=>{var r;let{stream_type:o}=e;const s=null===(r=t.find((e=>{let{stream_type:t}=e;return o===t})))||void 0===r?void 0:r.attributes;if(s&&_N("DISABLE_SCREEN_SHARE_REMB")){const e=i[n]._hints;(Dn(e).call(e,vD.SCREEN_TRACK)||Dn(e).call(e,vD.SCREEN_LOW_TRACK))&&(s.remb=!1,YN.debug("disable remb for screen share, hints:",e))}return s}))}async tryToUnmuteAudio(e){for(let i=0;i<e.length;i++)if(e[i]instanceof IL){var t;const n=this.filterTobeUnmutedTracks(e[i]);if(0===n.length)continue;await(null===(t=this.connection)||void 0===t?void 0:t.unmuteLocal(n.map((e=>{let[,{id:t}]=e;return t}))));const r=this.createUnmuteMessage(n);return void await qw(this,JU.RequestUnmuteLocal,r)}}bindStatsUploaderEvents(){this.statsUploader.requestStats=()=>this.getStats(),this.statsUploader.requestLocalMedia=()=>Array.from(this.localTrackMap.entries()),this.statsUploader.requestRemoteMedia=()=>Array.from(this.remoteUserMap.entries()),this.statsUploader.requestVideoIsReady=e=>{var t;return!(null===(t=this.connection)||void 0===t||!t.getRemoteVideoIsReady(e))},this.statsUploader.requestUpload=(e,t)=>
vendor: 34,470 bytes, line 12272
12272this.emit(JU.RequestUpload,e,t),this.statsUploader.requestUploadStats=e=>this.emit(JU.RequestUploadStats,e),this.statsUploader.requestAllTracks=()=>this.getAllTracks(),this.statsUploader.requestTransportStats=()=>{var e;return{connectState:(null===(e=this.connection)||void 0===e?void 0:e.peerConnectionState)||"closed"}}}unbindStatsUploaderEvents(){this.statsUploader.requestStats=void 0,this.statsUploader.requestLocalMedia=void 0,this.statsUploader.requestRemoteMedia=void 0,this.statsUploader.requestVideoIsReady=void 0}async requestReconnect(){this.dtlsFailedCount+=1,await uO(bO(this.dtlsFailedCount,AO)),this.emit(JU.RequestReconnect)}async reconnectP2P(){const e=Array.from(this.localTrackMap.entries()),t=this.createGatewayUnpublishMessage(e);Array.from(this.remoteUserMap.entries()),t.length>0&&await Yw(this,JU.RequestUnpublishForReconnectPC,t),this.disconnectForReconnect(),this.emit(JU.RequestReconnectPC)}canPublishLowStream(){return this.localTrackMap.has(zU.LocalVideoTrack)||this.pendingLocalTracks.some((e=>e instanceof pk))}throwIfTrackTypeNotMatch(e){if(e.filter((e=>e instanceof pk)).length>1)throw new mw(Ew.CAN_NOT_PUBLISH_MULTIPLE_VIDEO_TRACKS);if(e.filter((e=>e instanceof IL)).length>1&&(e.some((e=>e instanceof IL&&e._bypassWebAudio))||!nD().webAudioMediaStreamDest))throw new mw(Ew.NOT_SUPPORTED,"cannot publish multiple tracks which one of them configured with bypassWebAudio or your browser doesn't support MediaStreamDestNode");for(const t of e){if(t instanceof pk&&this.pendingLocalTracks.some((e=>e instanceof pk)))throw new mw(Ew.CAN_NOT_PUBLISH_MULTIPLE_VIDEO_TRACKS);if(t instanceof IL&&this.pendingLocalTracks.some((e=>e instanceof IL))&&(!nD().webAudioMediaStreamDest||t._bypassWebAudio||this.pendingLocalTracks.some((e=>e instanceof IL&&e._bypassWebAudio))))throw new mw(Ew.NOT_SUPPORTED,"cannot publish multiple tracks which one of them configured with bypassWebAudio or your browser doesn't support MediaStreamDestNode")}}getLowVideoTrack(e,t){var i;const n=!_N("DISABLE_DUAL_STREAM_USE_ENCODING")&&nD().supportDualStreamEncoding,r=OB(OB({},{width:160,height:120,framerate:15,bitrate:50}),t);let o;o=n?e._mediaStreamTrack.clone():eB(e,r);const s=hO(8,"track-low-"),a=new pk(o,OB(OB({},n&&{scaleResolutionDownBy:Vx(r,e)}),{},{frameRate:r.framerate,bitrateMax:r.bitrate,bitrateMin:r.bitrate}),void 0,void 0,s);return a.on(AD.TRANSCEIVER_UPDATED,(t=>{e._updateRtpTransceiver(t,CD.LOW_STREAM)})),a._hints.push(vD.LOW_STREAM),Dn(i=e._hints).call(i,vD.SCREEN_TRACK)&&a._hints.push(vD.SCREEN_LOW_TRACK),e.on("sei-to-send",(e=>{a.emit("sei-to-send",e)})),e.addListener(RD.NEED_CLOSE,(()=>{a.close()})),a}async globalLock(){return this.mutex.lock("From P2PChannel.globalLock")}async reportPCStats(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(this.connection&&this.connection instanceof ZF){var r,o,s,a;const c=this.store.keyMetrics.descriptionStart||0,{iceConnectionState:d,dtlsTransportState:l,peerConnectionState:u}=this.connection,{local:h,remote:p}=await this.connection.getSelectedCandidatePair();eD.pcStats(this.store.sessionId,{startTime:c,eventElapse:e-c||0,iceconnectionsate:d,dtlsstate:l,connectionstate:u,intSucc:t?1:2,error:this._iceError||n||"",selectedLocalCandidateProtocol:null!==(r=null==h?void 0:h.protocol)&&void 0!==r?r:"",selectedLocalCandidateType:null!==(o=h.candidateType)&&void 0!==o?o:"",selectedLocalCandidateAddress:"".concat(h.address,":").concat(h.port),selectedRemoteCandidateProtocol:null!==(s=p.protocol)&&void 0!==s?s:"",selectedRemoteCandidateType:null!==(a=p.candidateType)&&void 0!==a?a:"",selectedRemoteCandidateAddress:"".concat(p.address,":").concat(p.port),restartCnt:i,preallocation:this.connection.isPreallocation}),this._iceError=null}}reportVideoFirstFrameDecoded(e,t,i,n){var r;const o=Array.from(MN(r=this.remoteUserMap).call(r)).find((t=>t._videoSSRC===e));if(o){n||this.store.subscribe(o.uid,"video",void 0,void 0,void 0,void 0,Date.now());const r=this.store.keyMetrics,s=r.subscribe.find((e=>e.userId===o.uid&&"video"===e.type));eD.firstRemoteVideoDecode(this.store.sessionId,JN.FIRST_VIDEO_DECODE,QN.FIRST_VIDEO_DECODE,{peer:o._uintid,videowidth:t,videoheight:i,subscribeElapse:TF.measureFromSubscribeStart(this.store.clientId,e),subscribeRequestid:e,p2pid:this.store.p2pId,apEnd:r.requestAPEnd||0,apStart:r.requestAPStart||0,joinGwEnd:r.joinGatewayEnd||0,joinGwStart:r.joinGatewayStart||0,pcEnd:r.peerConnectionEnd||0,pcStart:r.peerConnectionStart||0,subscriberEnd:(null==s?void 0:s.subscribeEnd)||0,subscriberStart:(null==s?void 0:s.subscribeStart)||0,videoAddNotify:(null==s?void 0:s.streamAdded)||0,state:n?1:0,firstFrame:(null==s?void 0:s.firstFrame)||0})}}async remoteMediaSsrcChanged(e,t,i){if(!this.connection)return!1;const n=this.remoteUserMap.get(e);if(!n)return!1;const r=n.get(t);if(!r)return!1;const o=await this.connection.getRemoteSSRC(r);return void 0!==o&&o!==i}unbindRtpTransceiver(){0!==this.localTrackMap.size&&Array.from(this.localTrackMap.entries()).forEach((e=>{let[t,{track:i}]=e;t===zU.LocalVideoLowTrack?i._updateRtpTransceiver(void 0,CD.LOW_STREAM):i._updateRtpTransceiver(void 0)}))}},rU(bB.prototype,"startP2PConnection",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"startP2PConnection"),bB.prototype),rU(bB.prototype,"connect",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"connect"),bB.prototype),rU(bB.prototype,"updateRemoteRTPCapabilities",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"updateRemoteRTPCapabilities"),bB.prototype),rU(bB.prototype,"publishDataChannel",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"publishDataChannel"),bB.prototype),rU(bB.prototype,"unpublish",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"unpublish"),bB.prototype),rU(bB.prototype,"unpublishDataChannel",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"unpublishDataChannel"),bB.prototype),rU(bB.prototype,"unpublishLowStream",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"unpublishLowStream"),bB.prototype),rU(bB.prototype,"subscribeDataChannel",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"subscribeDataChannel"),bB.prototype),rU(bB.prototype,"subscribe",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"subscribe"),bB.prototype),rU(bB.prototype,"massSubscribe",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"massSubscribe"),bB.prototype),rU(bB.prototype,"unsubscribe",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"unsubscribe"),bB.prototype),rU(bB.prototype,"unsubscribeDataChannel",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"unsubscribeDataChannel"),bB.prototype),rU(bB.prototype,"massUnsubscribe",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"massUnsubscribe"),bB.prototype),rU(bB.prototype,"muteRemote",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"muteRemote"),bB.prototype),rU(bB.prototype,"unmuteRemote",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"unmuteRemote"),bB.prototype),rU(bB.prototype,"hasRemoteMediaWithLock",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"hasRemoteMediaWithLock"),bB.prototype),rU(bB.prototype,"disconnectForReconnect",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"disconnectForReconnect"),bB.prototype),rU(bB.prototype,"updateBitrateLimit",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"updateBitrateLimit"),bB.prototype),rU(bB.prototype,"remoteMediaSsrcChanged",[LB],Object.getOwnPropertyDescriptor(bB.prototype,"remoteMediaSsrcChanged"),bB.prototype),bB);function LB(e,t,i){const n=e[t];if("function"!=typeof n)throw new Error("Cannot use mutex on object property.");return i.value=async function(){const e=this.mutex,i=await e.lock("From P2PChannel.".concat(t));try{for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return await n.apply(this,o)}finally{i()}},i}function kB(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function MB(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?kB(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):kB(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}const UB=Date.now(),xB=20,VB=new Map,FB=new Map;async function BB(e){const t=VB.get(e),i=Array.isArray(t)&&t[t.length-1],n=FB.get(e);if(!i)return void(n.isSyncing=!1);const r={uid:i.uid,payload:i.payload};0===n.firstRecvTs&&(n.firstRecvTs=i.recvTs,n.firstSendTs=i.sendTs);const o=i.sendTs-n.firstSendTs,s=o-(Date.now()-n.firstRecvTs);s>0&&(n.firstRecvTs=Date.now()-o);let a=i.mediaDelay+s;a<=0?(t.pop(),jB(i.context,r),a=0):a=Math.min(a,xB),setTimeout((()=>t.length&&BB(e)),a)}function jB(e,t){e.safeEmit(Gw.STREAM_MESSAGE,t.uid,t.payload),e.onStreamMessage&&e.onStreamMessage(t)}function GB(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2?arguments[2]:void 0;if(!e.syncWithAudio)return jB(i,{uid:e.uid,payload:e.payload});const n="".concat(i.id,"-").concat(e.uid),r=VB.get(n)||[],o=r.findIndex((t=>e.sendTs>=t.sendTs)),s=MB(MB({},e),{},{context:i,mediaDelay:t,recvTs:Date.now()});-1===o?r.push(s):r.splice(o,0,s),VB.set(n,r);let a=!1;var c;FB.has(n)?a=!(null===(c=FB.get(n))||void 0===c||!c.isSyncing):FB.set(n,{isSyncing:a,firstRecvTs:0,firstSendTs:0});a||BB(n)}const WB=xb().name;function HB(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function KB(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?HB(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):HB(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}const YB="websdk_ng_cache_parameter",qB=_N("MAX_PRELOAD_ASYNC_LENGTH"),zB=1e4,XB=new Map,JB=[];let QB=null,ZB=0,$B=0;const ej=new Map,tj=function(e,t){const i=[];let n=0;const r=async()=>{const e=i.shift();e&&await e(),i.length>0&&n<t?r():n--};return async function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];return new Wh((async(o,a)=>{i.push((async()=>{try{const t=await e(...s);o(t)}catch(e){a(e)}})),n<t&&(n++,r())}))}}(nj,qB),ij=Ab.CancelToken.source();async function nj(e,t,i,n,r,o){try{if(!_N("ENABLE_PRELOAD"))return;if(!nD().supportWebCrypto)return void nO((()=>{YN.warn("Your browser does not support preloading, this feature be run in a secure environment")}),"preload_webcrypto_not_supported");if(!i&&null!==i)throw new mw(Ew.INVALID_PARAMS,"Invalid token: ".concat(i,". If you don not use token, set it to null"));i&&Rw(i,"token",1,2047),Rw(e,"appid",1,2047),fU(t),n&&TU(n);const s=pO();YN.debug("preload channel ".concat(t,", uid is ").concat(n));const a={appId:e,cname:t,token:i||e,uid:"string"!=typeof n?n:null,sid:s,proxyServer:r};let c,d;"string"==typeof n?(a.stringUid=n,[d,c]=await Wh.all([aF(n,{sid:s,appId:e},ij.token),dF(KB(KB({},a),{},{token:i||e,uid:0}),ij.token)]),a.uid=d.uid,c.gatewayInfo.uid=a.uid,c.gatewayInfo.res.uid=a.uid):(o&&(a.stringUid=o),c=await dF(a,ij.token));const l={sid:s,appId:e,cname:t,token:i||e,uid:a.stringUid||n,intUid:a.uid||c.gatewayInfo.uid,stringUid:a.stringUid,ts:Date.now(),sua:d,ap:c};await async function(e){let t;try{e.uid&&oj({appId:e.appId,cname:e.cname,token:e.token,uid:e.uid,stringUid:e.stringUid});const i=uj(e),n=await async function(e,t){try{const i=await window.crypto.subtle.importKey("raw",sO(t),"AES-GCM",!1,["encrypt"]),n=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:new Uint8Array(1)},i,rO(window.btoa(JSON.stringify(e))));return oO(new Uint8Array(n))}catch(e){return}}(e,e.token||e.appId);if(!n)return;t=dj(YB);const r=t?JSON.parse(t):[];r.push({[i]:n}),r.length>_N("AP_CACHE_NUM")&&r.shift(),lj(YB,JSON.stringify(r))}catch(e){YN.warn("Error caching server parameters:",e.message),lj(YB,"")}}(l),ZB++}catch(e){throw $B++,function(e){QB||(QB=window.setTimeout((()=>{let t="";ej.forEach(((e,i)=>{t+="".concat(i,": ").concat(e," ;")})),eD.reportApiInvoke(null,{name:kw.PRELOAD,options:{success:ZB,failed:$B,err:t}}).onError(e),ZB=0,$B=0,ej.clear(),QB=null}),zB));const t=ej.get(e.code)||0;ej.set(e.code,t+1)}(e),e}}async function rj(e){try{if(_N("AP_REQUEST_DETAIL")||_N("ENABLE_ROLE_SELECT_EDGE"))return;const t=oj(e);if(!t||"disabled"!==e.cloudProxyServer)return;const i=await async function(e,t){try{const i=await window.crypto.subtle.importKey("raw",sO(t),"AES-GCM",!1,["decrypt"]),n=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:new Uint8Array(1)},i,rO(e));return JSON.parse(window.atob(oO(new Uint8Array(n))))}catch(e){return}}(t,e.token||e.appId);if(!i)return;if(!function(e,t){const i=e.cname===t.cname&&e.appId===t.appId&&e.token===t.token;if(!i)return!1;return t.stringUid?e.stringUid===t.stringUid:"number"==typeof t.uid?e.uid===t.uid:e.uid==t.uid}(i,e))return;if(i&&Date.now()-i.ts<_N("AP_CACHE_LIFETIME"))return i}catch(e){YN.warn("Error get preloadInfo",e.message)}}function oj(e){let t;try{if(t=dj(YB),!t)return;const i=JSON.parse(t),n=uj(e),r=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1}(i,(e=>n in e));if(-1===r)return;const o=i.splice(r,1)[0];return lj(YB,JSON.stringify(i)),o[n]}catch(e){YN.warn("Error delete preload info: ".concat(t),e.message),lj(YB,"")}}function sj(e){if(e){let t=XB.get(e);t&&(window.clearTimeout(t),t=null,XB.delete(e)),Dn(JB).call(JB,e)||"disabled"!==e.cloudProxyServer||JB.push(e)}if(XB.size<_N("AP_CACHE_NUM")&&JB.length>0){const e=JB.shift();XB.set(e,window.setTimeout((async()=>{const{appId:t,cname:i,token:n,stringUid:r,uid:o,proxyServer:s}=e;try{await tj(t,i,n,o,s,r),XB.has(e)&&sj(e)}catch(t){YN.warn("update preload failed",t.message),aj(e)}}),_N("AP_UPDATE_INTERVAL")))}}function aj(e){const t=JB.indexOf(e);-1!==t&&JB.splice(t,1);let i=XB.get(e);i&&(window.clearTimeout(i),i=null,XB.delete(e),sj())}function cj(e,t){const i=e.sua,n=e.ap;t&&i&&eD.reqUserAccount(e.sid,{lts:i.requestTime,elapse:i.elapse,success:!0,serverAddr:i.url,stringUid:t,uid:e.intUid,errorCode:null,extend:i.req}),eD.reportResourceTiming(e.ap.url,e.sid),eD.joinWebProxyAP(e.sid,{lts:n.requestTime,elapse:n.elapse,sucess:1,apServerAddr:n.url,turnServerAddrList:n.proxyInfo.addresses.map((e=>e.ip)).join(","),eventType:"disabled",unilbsServerIds:[wx.CHOOSE_SERVER,wx.CLOUD_PROXY_FALLBACK].toString()}),eD.joinChooseServer(e.sid,{lts:n.requestTime,elapse:n.elapse,succ:!0,csAddr:n.url,opid:n.opid,serverList:n.gatewayInfo.gatewayAddrs.map((e=>e.address)),ec:null,cid:n.gatewayInfo.cid.toString(),uid:n.gatewayInfo.uid.toString(),csIp:n.gatewayInfo.csIp,unilbsServerIds:[wx.CHOOSE_SERVER].toString(),isHttp3:n.isHttp3})}function dj(e){return window.atob(window.localStorage.getItem(e)||"")}function lj(e,t){window.localStorage.setItem(e,window.btoa(t))}function uj(e){let t="".concat(e.appId,"_").concat(e.cname);return"string"==typeof e.uid&&(t+="_s_".concat(e.uid)),"number"==typeof e.uid&&(t+="_".concat(e.uid)),e.token&&(t+="_".concat(e.token)),RO(t)}function hj(e){let t=function(){const e=mj.pop();return e?(e.offset=e.limit=0,e):{bytes:new Uint8Array(64),offset:0,limit:0}}();return function(e,t){let i=e.appId;void 0!==i&&(bj(t,10),Cj(t,i));let n=e.cid;void 0!==n&&(bj(t,16),bj(t,n));let r=e.cname;void 0!==r&&(bj(t,26),Cj(t,r));let o=e.deviceId;void 0!==o&&(bj(t,34),Cj(t,o));let s=e.elapse;void 0!==s&&(bj(t,40),Oj(t,s));let a=e.fileSize;void 0!==a&&(bj(t,48),Oj(t,Ej(a)));let c=e.height;void 0!==c&&(bj(t,56),Oj(t,Ej(c)));let d=e.jpg;void 0!==d&&(bj(t,66),bj(t,d.length),Rj(t,d));let l=e.networkType;void 0!==l&&(bj(t,72),Oj(t,Ej(l)));let u=e.osType;void 0!==u&&(bj(t,80),Oj(t,Ej(u)));let h=e.requestId;void 0!==h&&(bj(t,90),Cj(t,h));let p=e.sdkVersion;void 0!==p&&(bj(t,98),Cj(t,p));let _=e.sequence;void 0!==_&&(bj(t,104),Oj(t,Ej(_)));let E=e.sid;void 0!==E&&(bj(t,114),Cj(t,E));let m=e.timestamp;void 0!==m&&(bj(t,120),Oj(t,m));let f=e.uid;void 0!==f&&(bj(t,128),bj(t,f));let T=e.vid;void 0!==T&&(bj(t,136),bj(t,T));let S=e.width;void 0!==S&&(bj(t,144),Oj(t,Ej(S)));let g=e.service;void 0!==g&&(bj(t,152),bj(t,g));let R=e.callbackData;void 0!==R&&(bj(t,162),bj(t,R.length),Rj(t,R));let v=e.ticket;void 0!==v&&(bj(t,170),Cj(t,v));let C=e.vendorConfigs;void 0!==C&&(bj(t,178),Cj(t,C))}(e,t),function(e){let t=e.bytes,i=e.limit;return t.length===i?t:t.subarray(0,i)}(t)}function pj(e){return function(e){let t={};e:for(;!Tj(e);){let i=Aj(e);switch(i>>>3){case 0:break e;case 1:t.code=Aj(e);break;case 2:t.msg=vj(e,Aj(e));break;case 3:t.requestId=vj(e,Aj(e));break;case 4:t.timestamp=wj(e,!1);break;default:_j(e,7&i)}}return t}({bytes:t=e,offset:0,limit:t.length});var t}function _j(e,t){switch(t){case 0:for(;128&Ij(e););break;case 2:fj(e,Aj(e));break;case 5:fj(e,4);break;case 1:fj(e,8);break;default:throw new Error("Unimplemented type: "+t)}}function Ej(e){return{low:e|=0,high:e>>31,unsigned:e>=0}}let mj=[];function fj(e,t){if(e.offset+t>e.limit)throw new Error("Skip past limit");e.offset+=t}function Tj(e){return e.offset>=e.limit}function Sj(e,t){let i=e.bytes,n=e.offset,r=e.limit,o=n+t;if(o>i.length){let t=new Uint8Array(2*o);t.set(i),e.bytes=t}return e.offset=o,o>r&&(e.limit=o),n}function gj(e,t){let i=e.offset;if(i+t>e.limit)throw new Error("Read past limit");return e.offset+=t,i}function Rj(e,t){let i=Sj(e,t.length);e.bytes.set(t,i)}function vj(e,t){let i=gj(e,t),n=String.fromCharCode,r=e.bytes,o="�",s="";for(let e=0;e<t;e++){let a,c,d,l,u=r[e+i];0==(128&u)?s+=n(u):192==(224&u)?e+1>=t?s+=o:(a=r[e+i+1],128!=(192&a)?s+=o:(l=(31&u)<<6|63&a,l<128?s+=o:(s+=n(l),e++))):224==(240&u)?e+2>=t?s+=o:(a=r[e+i+1],c=r[e+i+2],32896!=(49344&(a|c<<8))?s+=o:(l=(15&u)<<12|(63&a)<<6|63&c,l<2048||l>=55296&&l<=57343?s+=o:(s+=n(l),e+=2))):240==(248&u)?e+3>=t?s+=o:(a=r[e+i+1],c=r[e+i+2],d=r[e+i+3],8421504!=(12632256&(a|c<<8|d<<16))?s+=o:(l=(7&u)<<18|(63&a)<<12|(63&c)<<6|63&d,l<65536||l>1114111?s+=o:(l-=65536,s+=n(55296+(l>>10),56320+(1023&l)),e+=3))):s+=o}return s}function Cj(e,t){let i=t.length,n=0;for(let e=0;e<i;e++){let r=t.charCodeAt(e);r>=55296&&r<=56319&&e+1<i&&(r=(r<<10)+t.charCodeAt(++e)-56613888),n+=r<128?1:r<2048?2:r<65536?3:4}bj(e,n);let r=Sj(e,n),o=e.bytes;for(let e=0;e<i;e++){let n=t.charCodeAt(e);n>=55296&&n<=56319&&e+1<i&&(n=(n<<10)+t.charCodeAt(++e)-56613888),n<128?o[r++]=n:(n<2048?o[r++]=n>>6&31|192:(n<65536?o[r++]=n>>12&15|224:(o[r++]=n>>18&7|240,o[r++]=n>>12&63|128),o[r++]=n>>6&63|128),o[r++]=63&n|128)}}function Ij(e){return e.bytes[gj(e,1)]}function yj(e,t){let i=Sj(e,1);e.bytes[i]=t}function Aj(e){let t,i=0,n=0;do{t=Ij(e),i<32&&(n|=(127&t)<<i),i+=7}while(128&t);return n}function bj(e,t){for(t>>>=0;t>=128;)yj(e,127&t|128),t>>>=7;yj(e,t)}function wj(e,t){let i,n=0,r=0,o=0;return i=Ij(e),n=127&i,128&i&&(i=Ij(e),n|=(127&i)<<7,128&i&&(i=Ij(e),n|=(127&i)<<14,128&i&&(i=Ij(e),n|=(127&i)<<21,128&i&&(i=Ij(e),r=127&i,128&i&&(i=Ij(e),r|=(127&i)<<7,128&i&&(i=Ij(e),r|=(127&i)<<14,128&i&&(i=Ij(e),r|=(127&i)<<21,128&i&&(i=Ij(e),o=127&i,128&i&&(i=Ij(e),o|=(127&i)<<7))))))))),{low:n|r<<28,high:r>>>4|o<<24,unsigned:t}}function Oj(e,t){let i=t.low>>>0,n=(t.low>>>28|t.high<<4)>>>0,r=t.high>>>24,o=0===r?0===n?i<16384?i<128?1:2:i<1<<21?3:4:n<16384?n<128?5:6:n<1<<21?7:8:r<128?9:10,s=Sj(e,o),a=e.bytes;switch(o){case 10:a[s+9]=r>>>7&1;case 9:a[s+8]=9!==o?128|r:127&r;case 8:a[s+7]=8!==o?n>>>21|128:n>>>21&127;case 7:a[s+6]=7!==o?n>>>14|128:n>>>14&127;case 6:a[s+5]=6!==o?n>>>7|128:n>>>7&127;case 5:a[s+4]=5!==o?128|n:127&n;case 4:a[s+3]=4!==o?i>>>21|128:i>>>21&127;case 3:a[s+2]=3!==o?i>>>14|128:i>>>14&127;case 2:a[s+1]=2!==o?i>>>7|128:i>>>7&127;case 1:a[s]=1!==o?128|i:127&i}}const Nj={},Dj={},Pj=4294967296,Lj=Pj*Pj,kj=Lj/2,Mj=Bj(0,!0),Uj=Bj(0),xj=jj(0,-2147483648,!1),Vj=jj(-1,2147483647,!1),Fj=jj(-1,-1,!0);function Bj(e,t){let i,n,r;return t?(r=0<=(e>>>=0)&&e<256)&&(n=Dj[e],n)?n:(i=jj(e,0,!0),r&&(Dj[e]=i),i):(r=-128<=(e|=0)&&e<128)&&(n=Nj[e],n)?n:(i=jj(e,e<0?-1:0,!1),r&&(Nj[e]=i),i)}function jj(e,t,i){return{low:0|e,high:0|t,unsigned:!!i}}function Gj(e,t){if(isNaN(e))return t?Mj:Uj;if(t){if(e<0)return Mj;if(e>=Lj)return Fj}else{if(e<=-kj)return xj;if(e+1>=kj)return Vj}return e<0?t?Mj:Uj:jj(e%Pj|0,e/Pj|0,t)}function Wj(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}class Hj extends Dw{get connectionState(){return this._connectionState}set connectionState(e){if(this._connectionState===e)return;const t=this._connectionState;this._connectionState=e,this.emit(nx.CONNECTION_STATE_CHANGE,e,t)}get quality(){return this._quality}set quality(e){this._quality=e>1?1:e<.1?.1:e,this._qualityTimer&&(window.clearTimeout(this._qualityTimer),this._qualityTimer=null),this._quality>=1||(this._qualityTimer=window.setTimeout((()=>{this.quality=this._quality/this._qualityRatio}),6e4))}constructor(e){var t;super(),QI(this,"name","AgoraRTCImageModeration"),QI(this,"_connectionState",ix.CONNECTING),QI(this,"_sequence",0),QI(this,"_moderationStartTime",void 0),QI(this,"_workerConnection",void 0),QI(this,"_workerMessageLengthLimit",void 0),QI(this,"_qualityRatio",void 0),QI(this,"_connectInfo",void 0),QI(this,"_cancelTokenSource",Ab.CancelToken.source()),QI(this,"_retryConfig",void 0),QI(this,"_moderationInterval",void 0),QI(this,"_moderationTimer",null),QI(this,"_moderationMode",1),QI(this,"_quality",1),QI(this,"_qualityTimer",null),QI(this,"_ticket",void 0),QI(this,"_moderationIntervalMinimum",void 0),QI(this,"_uploadFailedNum",0),QI(this,"_uploadNum",0),QI(this,"_uploadTimer",null),QI(this,"_extraInfo",void 0),QI(this,"_vendor",""),QI(this,"_encoder",new TextEncoder),QI(this,"_moderationId",void 0),QI(this,"inspectImage",(()=>{if(this.connectionState!==ix.CONNECTED)throw new tD(Ew.OPERATION_ABORTED,"image moderation service connection status is ".concat(this.connectionState));this._moderationTimer&&(window.clearInterval(this._moderationTimer),this._moderationTimer=null),this._moderationTimer=window.setInterval((()=>{this.connectionState===ix.CONNECTED?this.requestToInspectImage():YN.debug("[".concat(this._moderationId,"] Moderation State is not connected , "),this.connectionState)}),this._moderationInterval<this._moderationIntervalMinimum?this._moderationIntervalMinimum:this._moderationInterval),this.requestToInspectImage()})),this._moderationId=hO(5,"image-moderation-"),this._workerMessageLengthLimit=_N("IMAGE_MODERATION_WORKER_MESSAGE_LENGTH_LIMIT"),this._moderationIntervalMinimum=_N("IMAGE_MODERATION_INTERVAL_MINIMUM"),this._moderationInterval=null!==(t=e.interval)&&void 0!==t?t:1e3,e.extraInfo&&(this._extraInfo=this._encoder.encode(e.extraInfo)),e.vendor&&(this._vendor=e.vendor),this._qualityRatio=_N("IMAGE_MODERATION_QUALITY_RATIO"),this._moderationStartTime=Number(Date.now()),this._workerConnection=new yx("worker-"+this._moderationId,AO),this.on(nx.STATE_CHANGE,((e,t)=>{YN.debug("[".concat(this._moderationId,"] Moderation operation :").concat(rx[e]," ").concat(t||""))})),this.handleWorkerEvents()}async init(e,t){this.emit(nx.STATE_CHANGE,rx.CONNECT_AP),this._connectInfo=e;const i=this._cancelTokenSource.token;return this._retryConfig=t,new Wh(((n,r)=>{this.on(nx.CONNECTION_STATE_CHANGE,((e,t)=>{e===ix.CONNECTED&&n()})),this.requestAP(e,i,t).then((e=>{this.connectWorker(e)})).catch((e=>{r(e)}))}))}updateConfig(e){var t;this._moderationInterval=null!==(t=e.interval)&&void 0!==t?t:1e3,e.extraInfo&&(this._extraInfo=this._encoder.encode(e.extraInfo)),e.vendor&&(this._vendor=e.vendor),YN.debug("[".concat(this._moderationId,"] updateConfig: ").concat(JSON.stringify(e))),this.connectionState===ix.CONNECTED&&this.inspectImage()}async requestAP(e,t,i){const n=_N("WEBCS_DOMAIN").map((e=>"https://".concat(e,"/api/v1"))),r=await function(e,t,i,n){let{appId:r,areaCode:o,cname:s,sid:a,token:c,uid:d}=t;eF++;const l="moderation_plugin",u={service_name:l,json_body:JSON.stringify({appId:r,areaCode:o,cname:s,command:"allocateEdge",requestId:eF,seq:eF,sid:a,appToken:c,ts:Date.now(),uid:d+""})};let h,p,_=e[0];return wO((async()=>{h=Date.now();const e=await PV(_,{data:u,cancelToken:i,headers:{"X-Packet-Service-Type":"0","X-Packet-URI":"61"},params:{action:"wrtc_gateway"}});if(p=Date.now()-h,0!==e.code){const t=new tD(Ew.UNEXPECTED_RESPONSE,"moderation plugin ap error, code"+e.code,{retry:!0,responseTime:p});throw YN.error(t.toString()),t}const t=JSON.parse(e.json_body);if(200!==t.code){const e=new tD(Ew.UNEXPECTED_RESPONSE,"moderation plugin ap error, code: ".concat(t.code,", reason: ").concat(t.reason),{code:t.code,responseTime:p});throw YN.error(e.toString()),e}if(!t.servers||!Array.isArray(t.servers)||0===t.servers.length){const e=new tD(Ew.UNEXPECTED_RESPONSE,"moderation plugin ap empty server",{code:t.code,responseTime:p});throw YN.error(e.toString()),e}if(!t.servers.some((e=>!!e.wss))){const e=new tD(Ew.UNEXPECTED_RESPONSE,"moderation plugin ap empty port",{code:t.code,responseTime:p});throw YN.error(e.toString()),e}const n=_N("IMAGE_MODERATION_WORKER_HOST");return{addressList:t.servers.map((e=>{let{address:t,wss:i}=e;if(t&&i)return"wss://".concat(t.replace(/\./g,"-"),".").concat(n,":").concat(i,"/moderation")})).filter((e=>!!e)),workerToken:t.workerToken,vid:t.vid,ticket:t.appTicket,responseTime:p}}),((t,i)=>(eD.apworkerEvent(a,{success:!0,sc:200,serviceName:l,responseDetail:JSON.stringify(t.addressList),firstSuccess:0===i,responseTime:p,serverIp:e[i%e.length]}),!1)),((t,i)=>(eD.apworkerEvent(a,{success:!1,sc:t.data&&t.data.code||200,serviceName:l,responseTime:p,serverIp:e[i%e.length]}),!!(t.code!==Ew.OPERATION_ABORTED&&t.code!==Ew.UNEXPECTED_RESPONSE||t.data&&t.data.retry)&&(_=e[(i+1)%e.length],!0))),n)}(n,e,t,i);this.emit(nx.STATE_CHANGE,rx.AP_CONNECTED);const{addressList:o,ticket:s}=r;return this._ticket=s,o}async connectWorker(e){this.emit(nx.STATE_CHANGE,rx.CONNECT_WORKER),await this._workerConnection.init(e,1e4)}handleWorkerEvents(){this._workerConnection.on(mU.CONNECTED,(async()=>{this.emit(nx.STATE_CHANGE,rx.WORKER_CONNECTED,this._workerConnection.url),this.connectionState=ix.CONNECTED})),this._workerConnection.on(mU.CLOSED,(()=>{this.connectionState=ix.CLOSED})),this._workerConnection.on(mU.FAILED,(()=>{this.connectionState=ix.CLOSED})),this._workerConnection.on(mU.RECONNECTING,(()=>{this.connectionState=this.connectionState===ix.CONNECTED?ix.RECONNECTING:ix.CONNECTING})),this._workerConnection.on(mU.ON_MESSAGE,(async e=>{if(e.data instanceof ArrayBuffer){const t=pj(new Uint8Array(e.data));_N("SHOW_IMAGE_MODERATION_WORKER_MESSAGE")&&YN.debug("[".concat(this._moderationId,"] Response message for worker of image moderation "),JSON.stringify(t)),this._uploadNum++,void 0===t.code||0===t.code||(this._uploadFailedNum++,YN.error("[".concat(this._moderationId,"] Error response from worke, code is ").concat(t.code,", msg is ").concat(t.msg)),this._uploadTimer||(this._uploadTimer=window.setTimeout((()=>{eD.reportApiInvoke(this._connectInfo.sid||null,{name:kw.IMAGE_MODERATION_UPLOAD,options:[this._uploadFailedNum,this._uploadNum,t.code],tag:Mw.TRACER}).onError(new tD(Ew.IMAGE_MODERATION_UPLOAD_FAILED,t.msg)),this._uploadTimer=null}),_N("IMAGE_MODERATION_UPLOAD_REPORT_INTERVAL"))))}else YN.error("[".concat(this._moderationId,"] Unexpected message type from worker"))})),this._workerConnection.on(mU.WILL_RECONNECT,((e,t,i)=>{"recover"===e&&i(e),i("tryNext")})),this._workerConnection.on(mU.REQUEST_NEW_URLS,((e,t)=>{this.requestAP(this._connectInfo,this._cancelTokenSource.token,this._retryConfig).then(e).catch(t)}))}static intToLong(e){return{low:e|=0,high:e>>31,unsigned:e>=0}}async requestToInspectImage(){const e=zw(this,nx.CLIENT_LOCAL_VIDEO_TRACK),t={appId:this._connectInfo.appId,cname:this._connectInfo.cname,cid:this._connectInfo.cid,sid:this._connectInfo.sid,uid:this._connectInfo.uid,vid:this._connectInfo.vid};if(e){if(!e.isPlaying)return void(_N("SHOW_IMAGE_MODERATION_WORKER_MESSAGE")&&YN.debug("Only the track being played can be inspected"));this._sequence++;const i=await this.generateRequestData(e,t);this._workerConnection.sendMessage(i,!0,!0)}else _N("SHOW_IMAGE_MODERATION_WORKER_MESSAGE")&&YN.debug("Only the track being published can be inspected")}async generateRequestData(e,t){let{appId:i,cname:n,cid:r,vid:o,sid:s,uid:a}=t;const c=Date.now(),d=await e.getCurrentFrameImage("image/jpeg",this.quality),l=await MP(d,i,n),u=this._sequence+"-"+r+"-"+a+"-"+c+"-"+hO(12,""),h={appId:i,cid:r,cname:n,deviceId:"",elapse:Hj.intToLong(Number(c-this._moderationStartTime)),fileSize:d.buffer.byteLength,height:d.height,width:d.width,jpg:l,networkType:6,osType:7,requestId:u,sdkVersion:"4.23.2",sequence:this._sequence,sid:s,timestamp:Gj(c),uid:a,vid:o,service:this._moderationMode,ticket:this._ticket,callbackData:this._extraInfo,vendorConfigs:this._vendor};void 0===this._extraInfo&&delete h.callbackData;const p=hj(h);if(p.byteLength<this._workerMessageLengthLimit){if(_N("SHOW_IMAGE_MODERATION_WORKER_MESSAGE")){const e=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Wj(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Wj(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({},h);delete e.jpg,YN.debug("[".concat(this._moderationId,"] Request message for worker of image moderation service: "),JSON.stringify(e))}return p}{const t=this.quality*this._qualityRatio;return this.quality=t,await this.generateRequestData(e,{appId:i,cname:n,cid:r,vid:o,sid:s,uid:a})}}close(){this._cancelTokenSource.cancel(),this._cancelTokenSource=Ab.CancelToken.source(),this._workerConnection&&this._workerConnection.close(),this._moderationTimer&&window.clearInterval(this._moderationTimer),this._moderationTimer=null,this._uploadTimer&&window.clearTimeout(this._uploadTimer),this._uploadTimer=null,this.connectionState=ix.CLOSED,this.emit(nx.STATE_CHANGE,rx.CLOSED)}}function Kj(e){if(Sw(e.interval,"interval",1e3,1/0),e&&e.extraInfo&&e.extraInfo.length>1024)throw new tD(Ew.INVALID_PARAMS,"config.extraInfo length cannot exceed 1024 bytes");if(e&&e.vendor&&e.vendor.length>1024)throw new tD(Ew.INVALID_PARAMS,"config.vendor length cannot exceed 1024 bytes")}const Yj={name:"ImageModeration",create:function(e){let{config:t}=e;return Kj(t),new Hj(t)}};var qj,zj,Xj,Jj,Qj,Zj,$j,eG,tG,iG,nG,rG,oG,sG,aG,cG,dG,lG,uG,hG,pG,_G,EG,mG,fG,TG,SG,gG,RG,vG,CG,IG,yG,AG,bG,wG,OG,NG,DG,PG,LG,kG;function MG(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function UG(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?MG(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):MG(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}IO.setLogger(YN);let xG=(qj=$N(),zj=$N({argsMap:(e,t)=>{if(!Array.isArray(t)){if(!(t instanceof XD))return[t];t=[t]}return t.map((e=>e?Object(e).toString():"null"))}}),Xj=$N({argsMap:(e,t)=>(t||(t=[]),Array.isArray(t)||t.trackMediaType!==OD.DATA?(Array.isArray(t)||(t=[t]),t.map((e=>e.getTrackId()))):[t.getChannelId()])}),Jj=$N({argsMap:(e,t,i,n)=>["object"==typeof t?t.uid:t,i,n]}),Qj=$N({argsMap:(e,t,i)=>[t,i]}),Zj=$N({argsMap:(e,t)=>t.map((e=>{let{user:t,mediaType:i}=e;return[null==t?void 0:t.uid,i]}))}),$j=$N({argsMap:(e,t,i,n)=>["object"==typeof t?t.uid:t,i,n]}),eG=$N({argsMap:(e,t)=>t.map((e=>{let{user:t,mediaType:i}=e;return{uid:null==t?void 0:t.uid,mediaType:i}}))}),tG=$N(),iG=$N(),nG=$N(),rG=$N(),oG=$N(),sG=$N(),aG=$N(),cG=$N(),dG=$N(),lG=$N(),uG=$N(),hG=$N(),pG=$N(),_G=$N(),EG=$N(),mG=$N({argsMap:(e,t)=>[t]}),fG=$N(),TG=$N(),SG=$N(),gG=$N(),RG=$N(),vG=$N(),CG=$N(),IG=$N(),yG=$N({argsMap:(e,t)=>(Array.isArray(t)||(t=[t]),[JSON.stringify(t)])}),AG=$N(),bG=$N(),wG=$N(),OG=$N(),NG=$N(),DG=$N(),PG=$N({reportResult:!0}),LG=$N(),kG=class extends Dw{get connectionState(){return this._gateway.state}get remoteUsers(){return this._users}get localTracks(){return this._p2pChannel.getAllTracks(!0)}get uid(){return this._uid}get channelName(){return this._channelName}get localDataChannels(){return this._p2pChannel.getAllDataChannels()}get mode(){return this._config.mode}get role(){var e;return(null===(e=this._config)||void 0===e?void 0:e.role)||"audience"}get codec(){return this._config.codec}get audioCodec(){return this._config.audioCodec||"opus"}get isStringUID(){return!!this._joinInfo&&!!this._joinInfo.stringUid}get __className__(){return"Client"}constructor(e,t){let i;if(super(),QI(this,"store",void 0),QI(this,"_uid",void 0),QI(this,"_channelName",void 0),QI(this,"_uintUid",void 0),QI(this,"_users",[]),QI(this,"_config",void 0),QI(this,"_clientId",void 0),QI(this,"_appId",void 0),QI(this,"_sessionId",null),QI(this,"_key",void 0),QI(this,"_rtmConfig",{}),QI(this,"_joinInfo",void 0),QI(this,"_gateway",void 0),QI(this,"_statsCollector",void 0),QI(this,"_configDistribute",void 0),QI(this,"_leaveMutex",void 0),QI(this,"_publishMutex",void 0),QI(this,"_renewTokenMutex",void 0),QI(this,"_subscribeMutex",void 0),QI(this,"_encryptionMode","none"),QI(this,"_encryptionSecret",null),QI(this,"_encryptionSalt",null),QI(this,"_encryptDataStream",!1),QI(this,"_encryptDataStreamKey",null),QI(this,"_encryptDataStreamIv",null),QI(this,"_proxyServer",void 0),QI(this,"_turnServer",{servers:[],mode:"auto"}),QI(this,"_cloudProxyServerMode","disabled"),QI(this,"_isDualStreamEnabled",!1),QI(this,"_defaultStreamFallbackType",void 0),QI(this,"_lowStreamParameter",void 0),QI(this,"_streamFallbackTypeCacheMap",new Map),QI(this,"_remoteStreamTypeCacheMap",new Map),QI(this,"_axiosCancelSource",Ab.CancelToken.source()),QI(this,"_audioVolumeIndicationInterval",void 0),QI(this,"_networkQualityInterval",void 0),QI(this,"_userOfflineTimeout",void 0),QI(this,"_streamRemovedTimeout",void 0),QI(this,"_liveTranscodeStreamingClient",void 0),QI(this,"_liveRawStreamingClient",void 0),QI(this,"_channelMediaRelayClient",void 0),QI(this,"_networkQualitySensitivity","normal"),QI(this,"_p2pCh
12272annel",void 0),QI(this,"_useLocalAccessPoint",!1),QI(this,"_setLocalAPVersion",void 0),QI(this,"_joinAndNotLeaveYet",!1),QI(this,"_numberOfJoinCount",0),QI(this,"_remoteDefaultVideoStreamType",void 0),QI(this,"_inspect",void 0),QI(this,"_moderation",void 0),QI(this,"_license",void 0),QI(this,"_pendingPublishedUsers",[]),QI(this,"ntpAlignErrorCount",0),QI(this,"remoteInboundOffset",0),QI(this,"_peerConnectionState",void 0),QI(this,"_handleLocalTrackEnable",((e,t,i)=>{this.publish(e,!1).then(t).catch(i)})),QI(this,"_handleLocalTrackDisable",((e,t,i)=>{this.unpublish(e).then(t).catch(i)})),QI(this,"_handleUserOnline",(e=>{if(_N("BLOCK_LOCAL_CLIENT")&&gM(e.uid,this.channelName))return void YN.debug("[".concat(e.uid,"] will be ignored in local"));this.isStringUID&&"string"!=typeof e.uid&&YN.error("[".concat(this._clientId,"] StringUID is Mixed with UintUID"));const t=this._users.find((t=>t.uid===e.uid));if(t)t._trust_in_room_=!0,t._is_pre_created&&(t._is_pre_created=!1,this.safeEmit(Gw.USER_JOINED,t));else{const t=new IF(e.uid,e.uint_id||e.uid);this._users.push(t),YN.debug("[".concat(this._clientId,"] user online"),e.uid),this.safeEmit(Gw.USER_JOINED,t)}})),QI(this,"_handleUserOffline",(e=>{if(_N("BLOCK_LOCAL_CLIENT")&&gM(e.uid,this.channelName))return;const t=this._users.find((t=>t.uid===e.uid));t&&(this._handleRemoveStream(e),this._handleRemoveDataChannels(e),t._audio_pre_subscribed||t._video_pre_subscribed?t._is_pre_created=!0:Qw(this._users,t),this._remoteStreamTypeCacheMap.delete(t.uid),this._streamFallbackTypeCacheMap.delete(t.uid),YN.debug("[".concat(this._clientId,"] user offline"),e.uid,"reason:",e.reason),this.safeEmit(Gw.USER_LEAVED,t,e.reason))})),QI(this,"_handleAddAudioOrVideoStream",((e,t,i,n,r,o,s)=>{if(_N("BLOCK_LOCAL_CLIENT")&&gM(t,this.channelName))return;const a=this._users.find((e=>e.uid===t));if(!a)return void YN.error("[".concat(this._clientId,"] can not find target user!(on_add_stream)"));YN.debug("[".concat(this._clientId,"] stream added with uid ").concat(t,", type ").concat(e)),this.store.subscribe(a.uid,e,void 0,void 0,void 0,Date.now());const c="audio"===e?a.hasAudio:a.hasVideo;a._uintid||(a._uintid=r||t),"audio"===e?a._trust_audio_stream_added_state_=!0:a._trust_video_stream_added_state_=!0,"audio"===e?(a._audio_added_=!0,void 0!==i&&(a._audioSSRC=i),void 0!==n&&(a._cname=n),o&&(a._audioOrtc=o)):(a._video_added_=!0,void 0!==i&&(a._videoSSRC=i),void 0!==n&&(a._cname=n),void 0!==s&&(a._rtxSsrcId=s),o&&(a._videoOrtc=o)),("audio"===e?a.hasAudio:a.hasVideo)&&!c&&(YN.info("[".concat(this._clientId,"] remote user ").concat(a.uid," published ").concat(e)),this.safeEmit(Gw.USER_PUBLISHED,a,e)),"video"===e?eD.onGatewayStream(this._sessionId,JN.ON_ADD_VIDEO_STREAM,QN.ON_ADD_VIDEO_STREAM,{peer:r||t,ssrc:a._videoSSRC}):eD.onGatewayStream(this._sessionId,JN.ON_ADD_AUDIO_STREAM,QN.ON_ADD_AUDIO_STREAM,{peer:r||t,ssrc:a._audioSSRC}),this._p2pChannel.remoteMediaSsrcChanged(a,e,i).then((t=>{if(t&&(YN.debug("[".concat(this._clientId,"] resubscribe ").concat(e," for user ").concat(a.uid," after rejoin because SSRC id changed.")),this._p2pChannel instanceof PB))return this._p2pChannel.unsubscribe(a,e,!0).then((()=>this._subscribe(a,e,!0).catch((e=>{YN.error("[".concat(this._clientId,"] resubscribe error"),e.toString())}))))})),this._p2pChannel.hasPendingRemoteMedia(a,e)&&(YN.debug("[".concat(this._clientId,"] resubscribe ").concat(e," for user ").concat(a.uid," after reconnect.")),this._subscribe(a,e,!0).catch((e=>{YN.error("[".concat(this._clientId,"] resubscribe error"),e.toString())})))})),QI(this,"_handleRemoveStream",(e=>{if(_N("BLOCK_LOCAL_CLIENT")&&gM(e.uid,this.channelName))return;const t=this._users.find((t=>t.uid===e.uid));if(!t)return void YN.warning("[".concat(this._clientId,"] can not find target user!(on_remove_stream)"));YN.debug("[".concat(this._clientId,"] stream removed with uid ").concat(e.uid));let i=()=>{};t.hasAudio&&t.hasVideo?i=()=>{YN.info("[".concat(this._clientId,"] remote user ").concat(t.uid," unpublished audio track")),this.safeEmit(Gw.USER_UNPUBLISHED,t,"audio"),YN.info("[".concat(this._clientId,"] remote user ").concat(t.uid," unpublished video track")),this.safeEmit(Gw.USER_UNPUBLISHED,t,"video")}:t.hasVideo?i=()=>{YN.info("[".concat(this._clientId,"] remote user ").concat(t.uid," unpublished video track")),this.safeEmit(Gw.USER_UNPUBLISHED,t,"video")}:t.hasAudio&&(i=()=>{YN.info("[".concat(this._clientId,"] remote user ").concat(t.uid," unpublished audio track")),this.safeEmit(Gw.USER_UNPUBLISHED,t,"audio")}),t._video_pre_subscribed||t._audio_pre_subscribed||(t._trust_audio_stream_added_state_=!0,t._trust_video_stream_added_state_=!0,t._audio_added_=!1,t._video_added_=!1,this._p2pChannel instanceof PB&&this._p2pChannel.unsubscribe(t).then((e=>{if(e)return this._gateway.unsubscribe(e,t.uid)})),t._audioSSRC=void 0,t._videoSSRC=void 0,t._audioOrtc=void 0,t._videoOrtc=void 0,t._rtxSsrcId=void 0),eD.onGatewayStream(this._sessionId,JN.ON_REMOVE_STREAM,QN.ON_REMOVE_STREAM,{peer:e.uint_id||e.uid}),i()})),QI(this,"_handleSetStreamLocalEnable",((e,t,i)=>{if(_N("BLOCK_LOCAL_CLIENT")&&gM(t,this.channelName))return;const n=this._users.find((e=>e.uid===t));if(!n)return void YN.error("[".concat(this._clientId,"] can not find target user!(disable_local)"));YN.debug("[".concat(this._clientId,"] local ").concat(e," ").concat(i?"enabled":"disabled"," with uid ").concat(t));const r="audio"===e?n.hasAudio:n.hasVideo;if("audio"===e){n._trust_audio_enabled_state_=!0;const e=n._audio_enabled_;if(n._audio_enabled_=i,n._audio_enabled_===e)return;{const e=n._audio_enabled_?"enable-local-audio":"disable-local-audio";YN.debug("[".concat(this._clientId,"] user-info-updated, uid: ").concat(t,", msg: ").concat(e)),this.safeEmit(Gw.USER_INFO_UPDATED,t,e)}}else{n._trust_video_enabled_state_=!0;const e=n._video_enabled_;if(n._video_enabled_=i,n._video_enabled_===e)return;{const e=n._video_enabled_?"enable-local-video":"disable-local-video";YN.debug("[".concat(this._clientId,"] user-info-update, uid: ").concat(t,", msg: ").concat(e)),this.safeEmit(Gw.USER_INFO_UPDATED,t,e)}}const o="audio"===e?n.hasAudio:n.hasVideo;return r!==o?!r&&o?(YN.info("[".concat(this._clientId,"] remote user ").concat(t," published ").concat(e)),void this.safeEmit(Gw.USER_PUBLISHED,n,e)):("video"===e&&n._videoTrack&&n._videoTrack._destroy(),"audio"===e&&n._audioTrack,this._p2pChannel.muteRemote(n,e),YN.info("[".concat(this._clientId,"] remote user ").concat(t," unpublished ").concat(e)),void this.safeEmit(Gw.USER_UNPUBLISHED,n,e)):void 0})),QI(this,"_handleMuteStream",((e,t,i)=>{if(_N("BLOCK_LOCAL_CLIENT")&&gM(e,this.channelName))return;YN.debug("[".concat(this._clientId,"] receive mute message"),e,t,i);const n=this._users.find((t=>t.uid===e));if(!n)return void YN.warning("[".concat(this._clientId,"] can not find remote user, ignore mute event, uid: ").concat(e));const r="audio"===t?n.hasAudio:n.hasVideo;if("audio"===t){n._trust_audio_mute_state_=!0;const t=n._audio_muted_;if(n._audio_muted_=i,n._audio_muted_===t)return;{const t=n._audio_muted_?"mute-audio":"unmute-audio";YN.debug("[".concat(this._clientId,"] user-info-update, uid: ").concat(e,", msg: ").concat(t)),this.safeEmit(Gw.USER_INFO_UPDATED,e,t)}}else{n._trust_video_mute_state_=!0;const t=n._video_muted_;if(n._video_muted_=i,n._video_muted_===t)return;{const t=n._video_muted_?"mute-video":"unmute-video";YN.debug("[".concat(this._clientId,"] user-info-update, uid: ").concat(e,", msg: ").concat(t)),this.safeEmit(Gw.USER_INFO_UPDATED,e,t)}}const o="audio"===t?n.hasAudio:n.hasVideo;if(r!==o){if(!r&&o){return("audio"===t?n._audioSSRC:n._videoSSRC)?(YN.info("[".concat(this._clientId,"] remote user ").concat(e," published ").concat(t)),void this.safeEmit(Gw.USER_PUBLISHED,n,t)):void YN.warning("[".concat(this._clientId,"] remote user ").concat(e," receive ").
vendor: 19,398 bytes, line 12272
12272concat(t," unmute message before add stream message, ").concat(t," SSRC doesn't exist yet."))}"video"===t&&n._videoTrack&&!n._video_pre_subscribed&&n._videoTrack._destroy(),"audio"===t&&n._audioTrack,this._p2pChannel.muteRemote(n,t),YN.info("[".concat(this._clientId,"] remote user ").concat(e," unpublished ").concat(t)),this.safeEmit(Gw.USER_UNPUBLISHED,n,t)}})),QI(this,"_handleP2PLost",(async e=>{YN.debug("[".concat(this._clientId,"] receive p2p lost"),e),parseInt(e.p2pid,10)===this.store.p2pId?await this._p2pChannel.requestReconnect():YN.warning("[".concat(this._clientId,"] P2PLost stream not found"),e)})),QI(this,"_handleTokenWillExpire",(()=>{YN.debug("[".concat(this._clientId,"] received message onTokenPrivilegeWillExpire")),this.safeEmit(Gw.ON_TOKEN_PRIVILEGE_WILL_EXPIRE)})),QI(this,"_handleBeforeUnload",(e=>{"beforeunload"===e.type&&void 0!==e.returnValue&&""!==e.returnValue||(this.leave(),YN.info("[".concat(this._clientId,"] auto leave onbeforeunload or pagehide")))})),QI(this,"_handleUpdateNetworkQuality",(()=>{if("normal"===this._networkQualitySensitivity)return;if(navigator&&void 0!==navigator.onLine&&!navigator.onLine)return void this.safeEmit(Gw.NETWORK_QUALITY,{downlinkNetworkQuality:6,uplinkNetworkQuality:6});const e={downlinkNetworkQuality:0,uplinkNetworkQuality:0};e.uplinkNetworkQuality=this._p2pChannel.getUplinkNetworkQuality(),e.downlinkNetworkQuality=this._p2pChannel.getDownlinkNetworkQuality(),this.safeEmit(Gw.NETWORK_QUALITY,e)})),QI(this,"_handleP2PAddAudioOrVideoStream",((e,t,i,n)=>{const r=this._users.find((e=>e.uid===t));if(!r)return void YN.error("[".concat(this._clientId,"] can not find target user!(on_add_stream)"));YN.debug("[".concat(this._clientId,"] stream added with uid ").concat(t,", type ").concat(e)),this.store.subscribe(r.uid,e,void 0,void 0,void 0,Date.now());const o="audio"===e?r.hasAudio:r.hasVideo;"audio"===e?r._trust_audio_stream_added_state_=!0:r._trust_video_stream_added_state_=!0,"audio"===e?(r._audio_added_=!0,void 0!==i&&(r._audioSSRC=i),void 0!==n&&(r._audioMid=n)):(r._video_added_=!0,void 0!==i&&(r._videoSSRC=i),void 0!==n&&(r._videoMid=n)),("audio"===e?r.hasAudio:r.hasVideo)&&!o&&(YN.info("[".concat(this._clientId,"] remote user ").concat(r.uid," published ").concat(e)),this.safeEmit(Gw.USER_PUBLISHED,r,e)),this._p2pChannel.hasPendingRemoteMedia(r,e)&&(YN.debug("[".concat(this._clientId,"] resubscribe ").concat(e," for user ").concat(r.uid," after reconnect.")),this._subscribe(r,e,!0).catch((e=>{YN.error("[".concat(this._clientId,"] resubscribe error"),e.toString())})))})),this._config=e,this._clientId=t||hO(5,"client-"),this.store=new class{constructor(e,t,i,n){_w(this,"state",void 0),this.state={codec:e,audioCodec:t,mode:i,clientId:n,sessionId:null,p2pId:0,dcId:0,pubId:0,subId:0,avoidJoinStart:0,keyMetrics:{publish:[],subscribe:[]},joinChannelServiceRecords:[],cloudProxyServerMode:"disabled",useP2P:!1,p2pTransport:sN.Default,hasStartJoinChannel:!1,isABTestSuccess:!1}}dispatch(e){this.state=function(e,t){switch(t.type){case fN.SET_SESSION_ID:return pw(pw({},e),{},{sessionId:t.sessionId});case fN.SET_P2P_ID:return pw(pw({},e),{},{p2pId:t.p2pId});case fN.SET_UID:return pw(pw({},e),{},{uid:t.uid});case fN.SET_INT_UID:return pw(pw({},e),{},{intUid:t.intUid});case fN.SET_PUB_ID:return pw(pw({},e),{},{pubId:t.pubId});case fN.KEY_METRIC_CLIENT_CREATED:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{clientCreated:t.metric})});case fN.KEY_METRIC_JOIN_START:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{joinStart:t.metric})});case fN.AVOID_JOIN_START:return pw(pw({},e),{},{avoidJoinStart:t.avoidJoinStart});case fN.KEY_METRIC_JOIN_END:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{joinEnd:t.metric})});case fN.KEY_METRIC_REQUEST_AP_START:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{requestAPStart:t.metric})});case fN.KEY_METRIC_REQUEST_AP_END:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{requestAPEnd:t.metric})});case fN.KEY_METRIC_JOIN_GATEWAY_START:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{joinGatewayStart:t.metric})});case fN.KEY_METRIC_JOIN_GATEWAY_END:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{joinGatewayEnd:t.metric})});case fN.KEY_METRIC_PEER_CONNECTION_START:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{peerConnectionStart:t.metric})});case fN.KEY_METRIC_PEER_CONNECTION_END:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{peerConnectionEnd:t.metric})});case fN.KEY_METRIC_DESCRIPTION_START:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{descriptionStart:t.metric})});case fN.KEY_METRIC_SIGNAL_CHANNEL_OPEN:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{signalChannelOpen:t.metric})});case fN.KEY_METRIC_ICE_CONNECTION_END:return pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{iceConnectionEnd:t.metric})});case fN.KEY_METRIC_PUBLISH:{const i=e.keyMetrics.publish,n=i.findIndex((e=>e.trackId===t.metric.trackId));return-1!==n?(i[n]=pw(pw({},i[n]),t.metric),pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{publish:[...i]})})):pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{publish:[...e.keyMetrics.publish,t.metric]})})}case fN.KEY_METRIC_SUBSCRIBE:{const i=e.keyMetrics.subscribe,n=i.findIndex((e=>e.userId===t.metric.userId&&e.type===t.metric.type));return-1!==n?(i[n]=pw(pw({},i[n]),t.metric),pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{subscribe:[...i]})})):pw(pw({},e),{},{keyMetrics:pw(pw({},e.keyMetrics),{},{subscribe:[...e.keyMetrics.subscribe,t.metric]})})}case fN.SET_CLOUD_PROXY_SERVER_MODE:return e.cloudProxyServerMode=t.mode,e;case fN.RECORD_JOIN_CHANNEL_SERVICE:return"number"!=typeof t.index?e.joinChannelServiceRecords=[...e.joinChannelServiceRecords,t.record]:(e.joinChannelServiceRecords[t.index]=pw(pw({},e.joinChannelServiceRecords[t.index]),t.record),e.joinChannelServiceRecords=[...e.joinChannelServiceRecords]),e;case fN.RESET_JOIN_CHANNEL_SERVICE_RECORDS:return e.joinChannelServiceRecords=[],e;case fN.RESET_KEY_METRICS:return e.keyMetrics={publish:[],subscribe:[]},e;case fN.SET_USE_P2P:return pw(pw({},e),{},{useP2P:t.val});case fN.SET_TRANSPORT_TYPE:return pw(pw({},e),{},{p2pTransport:t.val});default:return e}}(this.state,e)}set sessionId(e){this.dispatch({type:fN.SET_SESSION_ID,sessionId:e})}get sessionId(){return this.state.sessionId}set cid(e){this.state.cid=e}get cid(){return this.state.cid}set codec(e){this.state.codec=e}get codec(){return this.state.codec}get mode(){return this.state.mode}get audioCodec(){return this.state.audioCodec}get clientId(){return this.state.clientId}set p2pId(e){this.dispatch({type:fN.SET_P2P_ID,p2pId:e})}get p2pId(){return this.state.p2pId}set dcId(e){this.dispatch({type:fN.SET_DC_ID,dcId:e})}get dcId(){return this.state.dcId}set uid(e){this.dispatch({type:fN.SET_UID,uid:e})}get uid(){return this.state.uid}set intUid(e){this.dispatch({type:fN.SET_INT_UID,intUid:e})}get intUid(){return this.state.intUid}set pubId(e){this.dispatch({type:fN.SET_PUB_ID,pubId:e})}get pubId(){return this.state.pubId}set cloudProxyServerMode(e){this.dispatch({type:fN.SET_CLOUD_PROXY_SERVER_MODE,mode:e})}get cloudProxyServerMode(){return this.state.cloudProxyServerMode}set useP2P(e){this.dispatch({type:fN.SET_USE_P2P,val:e})}get useP2P(){return this.state.useP2P}set p2pTransport(e){this.dispatch({type:fN.SET_TRANSPORT_TYPE,val:e})}get p2pTransport(){return this.state.p2pTransport}set hasStartJoinChannel(e){this.state.hasStartJoinChannel=e}get hasStartJoinChannel(){return this.state.hasStartJoinChannel}set isABTestSuccess(e){this.state.isABTestSuccess=e}get isABTestSuccess(){return this.state.isABTestSuccess}clientCreated(){this.dispatch({type:fN.KEY_METRIC_CLIENT_CREATED,metric:Date.now()})}joinStart(){this.dispatch({type:fN.KEY_METRIC_JOIN_START,metric:Date.now()})}joinEnd(){this.dispatch({type:fN.KEY_METRIC_JOIN_END,metric:Date.now()})}requestAPStart(){this.dispatch({type:fN.KEY_METRIC_REQUEST_AP_START,metric:Date.now()})}requestAPEnd(){this.dispatch({type:fN.KEY_METRIC_REQUEST_AP_END,metric:Date.now()})}joinGatewayStart(){this.dispatch({type:fN.KEY_METRIC_JOIN_GATEWAY_START,metric:Date.now()})}joinGatewayEnd(){this.dispatch({type:fN.KEY_METRIC_JOIN_GATEWAY_END,metric:Date.now()})}peerConnectionStart(){this.dispatch({type:fN.KEY_METRIC_PEER_CONNECTION_START,metric:Date.now()})}peerConnectionEnd(){this.dispatch({type:fN.KEY_METRIC_PEER_CONNECTION_END,metric:Date.now()})}descriptionStart(){this.dispatch({type:fN.KEY_METRIC_DESCRIPTION_START,metric:Date.now()})}signalChannelOpen(){this.dispatch({type:fN.KEY_METRIC_SIGNAL_CHANNEL_OPEN,metric:Date.now()})}iceConnectionEnd(){this.dispatch({type:fN.KEY_METRIC_ICE_CONNECTION_END,metric:Date.now()})}publish(e,t,i,n){this.dispatch({type:fN.KEY_METRIC_PUBLISH,metric:pw(pw({trackId:e,type:t},i&&{publishStart:i}),n&&{publishEnd:n})})}subscribe(e,t,i,n,r,o,s){this.dispatch({type:fN.KEY_METRIC_SUBSCRIBE,metric:pw(pw(pw(pw(pw({userId:e,type:t},i&&{subscribeStart:i}),n&&{subscribeEnd:n}),r&&{firstFrame:r}),o&&{streamAdded:o}),s&&{firstDecoded:s})})}massSubscribe(e,t,i,n){e.forEach((e=>{this.dispatch({type:fN.KEY_METRIC_SUBSCRIBE,metric:pw(pw(pw({userId:e.userId,type:e.type},t&&{subscribeStart:t}),i&&{subscribeEnd:i}),n&&{firstFrame:n})})}))}get keyMetrics(){return this.state.keyMetrics}recordJoinChannelService(e,t){"gateway"===e.service&&Array.isArray(e.urls)&&(e.urls=e.urls.map((e=>e.replace(/(\d+)-\d+-\d+-(\d+)/,"$1-*-*-$2"))));try{return"number"!=typeof t?(this.dispatch({type:fN.RECORD_JOIN_CHANNEL_SERVICE,record:pw(pw({},e),{},{sessionId:this.sessionId,cloudProxyMode:this.cloudProxyServerMode,uid:this.uid})}),this.state.joinChannelServiceRecords.length-1):(t<0||t>=this.state.joinChannelServiceRecords.length||this.dispatch({type:fN.RECORD_JOIN_CHANNEL_SERVICE,record:e,index:t}),t)}catch(e){return 0}}resetJoinChannelServiceRecords(){this.dispatch({type:fN.RESET_JOIN_CHANNEL_SERVICE_RECORDS})}resetKeyMetrics(){this.dispatch({type:fN.RESET_KEY_METRICS})}get joinChannelServiceRecords(){try{return this.state.joinChannelServiceRecords}catch(e){return[]}}get avoidJoinStart(){return this.state.avoidJoinStart}set avoidJoinStart(e){this.dispatch({type:fN.AVOID_JOIN_START,avoidJoinStart:e})}}(e.codec,e.audioCodec,e.mode,this._clientId),this._leaveMutex=new IO("client-leave",this._clientId),this._publishMutex=new IO("client-publish",this._clientId),this._renewTokenMutex=new IO("client-renewtoken",this._clientId),this._subscribeMutex=new IO("client-subscribe",this._clientId),this.store.clientCreated(),e.proxyServer&&this.setProxyServer(e.proxyServer,!0),e.turnServer&&this.setTurnServer(e.turnServer,!0),YN.info("[".concat(this._clientId,"] Initializing AgoraRTC client v").concat(rN," build: ").concat(lN,", mode: ").concat(this.mode,", codec: ").concat(this.codec)),e.clientRoleOptions)try{jw(e.clientRoleOptions),i=Object.assign({},e.clientRoleOptions)}catch(e){YN.warning("[".concat(this._clientId,"] ").concat(e.toString()))}var n;this._statsCollector=new RF(this.store),this._statsCollector.onStatsException=(e,t,i)=>{YN.warn("[".concat(this._clientId,"] receive exception msg, code: ").concat(e,", msg: ").concat(t,", uid: ").concat(i)),this.safeEmit(Gw.EXCEPTION,{code:e,msg:t,uid:i})},this._statsCollector.onUploadPublishDuration=(e,t,i,n)=>{const r=this._users.find((t=>t.uid===e));r&&eD.peerPublishStatus(this._sessionId,{subscribeElapse:n,audioPublishDuration:t,videoPublishDuration:i,peer:r._uintid})},this.store.useP2P="p2p"===e.mode,this._gateway=new OV(this.store,{clientId:this._clientId,mode:this.mode,codec:this.codec,websocketRetryConfig:e.websocketRetryConfig||AO,httpRetryConfig:e.httpRetryConfig||AO,forceWaitGatewayResponse:void 0===e.forceWaitGatewayResponse||e.forceWaitGatewayResponse,statsCollector:this._statsCollector,role:e.role,clientRoleOptions:i}),this._configDistribute=new EF(this._clientId,this.store),this.store.useP2P?(this._p2pChannel=(n={store:this.store,statsCollector:this._statsCollector},CV("P2PChannel").create(n)),this._handleP2PEvents()):this._p2pChannel=new PB(this.store,this._statsCollector),this._handleP2PChannelEvents(),this._handleGatewayEvents(),this._handleGatewaySignalEvents()}async joinMeta(e,t,i,n,r){let o=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],s=arguments.length>6&&void 0!==arguments[6]&&arguments[6];pN("JOIN_GATEWAY_USE_443PORT_ONLY",o),pN("JOIN_GATEWAY_USE_DUAL_DOMAIN",s);const a=this._gateway.signal.websocket;return a instanceof Ix&&(a.use443PortOnly=o,a.tryDoubleDomain=s),async function(e,t,i){Ob.get(e)||Ob.set(e,[]),Nb.get(e)||Nb.set(e,t),Db.get(e)||Db.set(e,0);const n=Ob.get(e),r=Nb.get(e);if(!n||!r)throw new Error("concurrent: deferQueue or maxConcurrency is null");if(Db.get(e)===r){const e=wb();n.push(e),await e.promise}Db.set(e,Db.get(e)+1);for(var o=arguments.length,s=new Array(o>3?o-3:0),a=3;a<o;a++)s[a-3]=arguments[a];const c=await i(...s);return Db.set(e,Db.get(e)-1),Db.get(e)===r-1&&n.length>0&&(n[0].resolve(),n.shift()),0===Db.get(e)&&(Ob.set(e,[]),Nb.set(e,0),Db.set(e,0)),c}("client.join",_N("JOIN_MAX_CONCURRENCY"),this.join.bind(this),e,t,i,n,r)}async join(e,t,i,n,r){const o=++this._numberOfJoinCount;this.store.joinStart(),n&&(this.store.uid=n);const s="HTTPS"===(OO||OO||(OO=(window.location.protocol.split(":")[0]||"").toUpperCase(),OO)),a=MO()?window.isSecureContext:"Browser Not Support";if(!MO()&&!s||!window.isSecureContext){const e="The website must be running in a secure context (About secure context: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts ), otherwise the media collection will be restricted by the browser";YN.warning(e)}"DISCONNECTED"===this.connectionState&&(this.store.avoidJoinStart=Math.round(Date.now()),YN.debug("[".concat(this._clientId,"] set avoidJoinStart to ").concat(this.store.avoidJoinStart))),eD.setAppId(e);try{if(!i&&null!==i)throw new tD(Ew.INVALID_PARAMS,"Invalid token: ".concat(i,". If you don not use token, set it to null"));i&&Rw(i,"token",1,2047),Rw(e,"appid",1,2047),fU(t),n&&TU(n),r&&Rw(r,"optionalInfo",1,2047)}catch(r){throw eD.reportApiInvoke(pO(),{name:kw.JOIN,options:[e,t,i,n],states:{isHttps:s,isSecureContext:a},tag:Mw.TRACER}).onError(r),r}if(this._leaveMutex.isLocked){YN.debug("[".concat(this._clientId,"] join: waiting leave operation"));(await this._leaveMutex.lock())(),YN.debug("[".concat(this._clientId,"] join: continue"))}if(this._joinAndNotLeaveYet=!0,"DISCONNECTED"!==this.connectionState){const r=new tD(Ew.INVALID_OPERATION,"[".concat(this._clientId,"] Client already in connecting/connected state"));throw eD.reportApiInvoke(pO(),{name:kw.JOIN,options:[e,t,i,n],states:{isHttps:s,isSecureContext:a},tag:Mw.TRACER}).onError(r),r}this._gateway.state="CONNECTING";const c=await rj({appId:e,cname:t,uid:n,stringUid:"string"==typeof n?n:void 0,token:i||e,cloudProxyServer:this._cloudProxyServerMode});if(!this._joinAndNotLeaveYet)throw new tD(Ew.INVALID_OPERATION,"[".concat(this._clientId,"] Client already left"));const d=(null==c?void 0:c.sid)||pO();YN.info("[".concat(this._clientId,"] start join channel ").concat(t,", join number: ").concat(o)),this._sessionId||(this._sessionId=d,this.store.sessionId=this._sessionId);const l=eD.reportApiInvoke(d,{id:this._clientId,name:kw.JOIN,options:[e,t,i,n],states:{isHttps:s,isSecureContext:a},tag:Mw.TRACER}),u=UG(UG(UG({},this._rtmConfig),{},{role:this.role,clientId:this._clientId,appId:e,sid:this._sessionId,cname:t,uid:"string"!=typeof n?n:null,turnServer:this._turnServer,proxyServer:this._proxyServer,token:i||e,cloudProxyServer:this._cloudProxyServerMode,optionalInfo:r,license:this._license,useLocalAccessPoint:this._useLocalAccessPoint,preload:!!c},void 0!==this._remoteDefaultVideoStreamType&&{defaultVideoStream:this._remoteDefaultVideoStreamType}),{},{apRequestDetail:_N("AP_REQUEST_DETAIL")||void 0});if(this._useLocalAccessPoint&&(u.setLocalAPVersion=this._setLocalAPVersion),"string"==typeof n&&(u.stringUid=n,this._uintUid?(u.uid=this._uintUid,this._uintUid=void 0):u.uid=0),"none"!==this._encryptionMode&&this._encryptionSecret){if(u.aesmode=this._encryptionMode,u.aespassword=await(async e=>{const t=function(e){const t=window.atob("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCMnXAHkKIGAM+x4N22gCI+Wyu\nSTM9ztkT3uYslTT2PuKmZfPzhH6kVdO7PTjGCOZnAsyb3oTtWat0KcxQ4jxvqQV+\nHvYl3iI1Yd4vl2c3qRMJPLtRDfNxa2Mcxgq7e9aEUibzdd0st+OJAy3tOj/Y0aVy\nxQiYDz3vqa6bP29adwIDAQAB"),i=new Uint8Array(new ArrayBuffer(t.length));for(let e=0;e<t.length;e+=1)i[e]=t.charCodeAt(e);return i}(),i=await window.crypto.subtle.importKey("spki",t,{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),n=ww(e),r=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},i,n);return function(e){let t="";for(let i=0;i<e.length;i+=1)t+=String.fromCharCode(e[i]);return window.btoa(t)}(new Uint8Array(r))})(this._encryptionSecret),!this._joinAndNotLeaveYet)throw new tD(Ew.INVALID_OPERATION,"[".concat(this._clientId,"] Client already left"));this._encryptionSalt&&(u.aessalt=this._encryptionSalt)}if(this._encryptDataStream&&("aes-128-gcm2"===this._encryptionMode||"aes-256-gcm2"===this._encryptionMode))if(this._encryptionSalt&&this._encryptionSecret)if(window.crypto.subtle){const e=new TextEncoder,t=_N("USE_PURE_ENCRYPTION_MASTER_KEY")?e.encode(u.appId+this._encryptionSecret+this._encryptionSecret):e.encode(u.appId+u.cname+this._encryptionSecret);this._encryptDataStreamIv=await async function(e,t,i){const n=await window.crypto.subtle.importKey("raw",t,"PBKDF2",!1,["deriveBits","deriveKey"]),r="aes-128-gcm2"===e?128:256,o=await window.crypto.subtle.deriveBits({name:"PBKDF2",iterations:RN,hash:"SHA-256",salt:i},n,r+gN);return new Uint8Array(o).subarray(r/8)}(this._encryptionMode,t,rO(this._encryptionSalt)),this._encryptDataStreamKey=await async function(e,t,i){const n=await window.crypto.subtle.importKey("raw",t,"PBKDF2",!1,["deriveBits","deriveKey"]),r="aes-128-gcm2"===e?128:256;return await window.crypto.subtle.deriveKey({name:"PBKDF2",iterations:RN,hash:"SHA-256",salt:i},n,{name:"AES-GCM",length:r},!0,["encrypt","decrypt"])}(this._encryptionMode,t,rO(this._encryptionSalt))}else a?YN.warning("[".concat(this._clientId,"] encrypt datastream must be running in a secure context, fallback to plain data stream")):YN.warning("[".concat(this._clientId,"] current browser do not support WebCrypto ,fallback to plain data stream")),this._encryptDataStream=!1;else this._encryptDataStream=!1,YN.debug("[".concat(this._clientId,"] no salt / secret, cannot support encrypt data stream, fallback to plain data stream"));this._startSession(this._sessionId,{channel:t,appId:e,stringUid:u.stringUid});const h=this._sessionId;setTimeout((()=>{"CONNECTING"===this.connectionState&&h===this._sessionId&&eD.joinChannelTimeout(this._sessionId,5)}),5e3);try{var p;let n;const r=u.cloudProxyServer;if(Dn(p=["proxy3","proxy4","proxy5"]).call(p,r)){const e=_N("PROXY_SERVER_TYPE3");Array.isArray(e)?u.proxyServer=e[0]:u.proxyServer=e}if(eD.setProxyServer(u.proxyServer),YN.setProxyServer(u.proxyServer),this.store.requestAPStart(),c){if(YN.debug("[".concat(this._clientId,"] get serverInfo Success from Preload Cache ").concat(u.stringUid?", ".concat(u.stringUid," => ").concat(c.intUid):""," ")),u.stringUid&&!u.uid&&(u.uid=c.intUid),n={gatewayInfo:c.ap.gatewayInfo},_N("JOIN_WITH_FALLBACK_MEDIA_PROXY")&&"auto"===u.turnServer.mode)if(0===c.ap.proxyInfo.addresses.length)YN.warning("no edge services in a
12272p response of proxy fallback, will not set proxy in iceServers");else{const e=(await xx(c.ap.proxyInfo,c.ap.gatewayInfo.uid)).map((e=>({turnServerURL:e.address,tcpport:e.tcpport||aN.tcpport,udpport:e.udpport||aN.udpport,username:e.username||aN.username,password:e.password||aN.password,forceturn:!1,security:!0})));u.turnServer={mode:"manual",servers:e}}cj(c,u.stringUid)}else{if(u.stringUid&&!u.uid){let e;[e,n]=await Wh.all([sF(u.stringUid,u,this._axiosCancelSource.token,this._config.httpRetryConfig||AO,this.store),oF(u,this._axiosCancelSource.token,this._config.httpRetryConfig||AO,!0,this.store)]),YN.debug("[".concat(this._clientId,"] getUserAccount Success ").concat(u.stringUid," => ").concat(e)),u.uid=e,n.gatewayInfo.uid=e,n.gatewayInfo.res.uid=e}else n=await oF(u,this._axiosCancelSource.token,this._config.httpRetryConfig||AO,!0,this.store);if(!this._joinAndNotLeaveYet)throw new tD(Ew.INVALID_OPERATION,"[".concat(this._clientId,"] Client already left"))}this.store.requestAPEnd(),setTimeout((()=>{this._configDistribute.startGetConfigDistribute(u,this._axiosCancelSource.token),this._configDistribute.on(BU.UPDATE_BITRATE_LIMIT,(e=>{this._p2pChannel.updateBitrateLimit(e)})),this._configDistribute.on(BU.UPDATE_CLIENT_ROLE_OPTIONS,(e=>{this._setClientRoleOptions(e)}))}),0),this._key=i||e;const o=n.gatewayInfo,s=u.uid?u.uid:o.uid;this._joinInfo=UG(UG({},u),{},{cid:o.cid,uid:s,vid:o.vid,apResponse:o.res,apGatewayAddress:o.apGatewayAddress,uni_lbs_ip:o.uni_lbs_ip,gatewayAddrs:o.gatewayAddrs}),this.store.intUid=s,this.store.cid=o.cid;const a=await this._joinGateway();if(!this._joinAndNotLeaveYet)throw new tD(Ew.INVALID_OPERATION,"[".concat(this._clientId,"] Client already left"));l.onSuccess(a),this._appId=e,this._channelName=u.cname,this._uid=a,this.store.uid=a,setTimeout((()=>{this._networkQualityInterval&&window.clearInterval(this._networkQualityInterval),this._networkQualityInterval=window.setInterval(this._handleUpdateNetworkQuality,2e3),window.addEventListener(Wb()?"beforeunload":"pagehide",this._handleBeforeUnload),this._statsCollector.startUpdateStats()}),0);const d=u.stringUid?"string uid: ".concat(u.stringUid,",uid: ").concat(u.uid):"uid: ".concat(this._uid);return YN.info("[".concat(this._clientId,"] Joining channel success: channel: ").concat(t,",").concat(d)),setTimeout((()=>{YN.startUpload()}),5e3),this.store.joinEnd(),_=this,Dn(TM).call(TM,_)||TM.push(_),"disabled"===this._cloudProxyServerMode&&nD().supportWebCrypto&&_N("ENABLE_PRELOAD")&&sj(this._joinInfo),a}catch(e){const t=Array.isArray(e)?e[0]:e;throw t&&t.code===Ew.OPERATION_ABORTED?YN.warning("[".concat(this._clientId,"] join number: ").concat(o,", Joining channel failed, rollback"),t):YN.error("[".concat(this._clientId,"] join number: ").concat(o,", Joining channel failed, rollback"),t),t.code!==Ew.OPERATION_ABORTED&&this._numberOfJoinCount===o&&(this._gateway.state="DISCONNECTED",this._reset()),l.onError(t),t}var _}_joinGateway(){if(!this._joinInfo||!this._key)throw new tD(Ew.INVALID_OPERATION);return this._gateway.join(this._joinInfo,this._key,!("disabled"!==this._joinInfo.cloudProxyServer||this._joinInfo.proxyServer||!_N("JOIN_WITH_FALLBACK_SIGNAL_PROXY")))}async leave(){YN.info("[".concat(this._clientId,"] Leaving channel")),window.removeEventListener(Wb()?"beforeunload":"pagehide",this._handleBeforeUnload),this._reset(),function(e){const t=TM.indexOf(e);-1!==t&&TM.splice(t,1)}(this),this._statsCollector.stopUpdateStats();const e=await this._leaveMutex.lock();if("DISCONNECTED"===this.connectionState)return YN.info("[".concat(this._clientId,"] Leaving channel repeated, success")),void e();await this._gateway.leave("CONNECTED"!==this.connectionState,Vw.LEAVE),YN.info("[".concat(this._clientId,"] Leaving channel success")),this._joinAndNotLeaveYet=!1,this.store.resetJoinChannelServiceRecords(),e()}async publish(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!Array.isArray(e)){if(!(e instanceof XD))return this._publishDataChannel(e);e=[e]}if(0===e.length)throw new tD(Ew.INVALID_PARAMS,"param list is empty");const i=e;if("audience"===this._gateway.role)throw new tD(Ew.INVALID_OPERATION,"audience can not publish stream");for(const e of i){if(!(e instanceof XD))throw new tD(Ew.INVALID_PARAMS,"parameter is not local track");if(!e._enabled&&t)throw new tD(Ew.TRACK_IS_DISABLED,"can not publish a disabled track: ".concat(e.getTrackId()))}YN.info("[".concat(this._clientId,"] Publishing tracks, id ").concat(i.map((e=>"".concat(e.getTrackId()," ")))));const n=await this._publishMutex.lock();await this._configDistribute.awaitConfigDistributeComplete(),t&&i.forEac
vendor: 19,091 bytes, line 12272
12272h((e=>{const t=this._configDistribute.getBitrateLimit();e instanceof pk&&t&&e.setBitrateLimit(t.uplink)}));try{await this._publishHighStream(i),YN.info("[".concat(this._clientId,"] Publish success, id ").concat(i.map((e=>"".concat(e.getTrackId()," ")))))}catch(e){throw YN.error("[".concat(this._clientId,"] publish error"),e.toString()),e}finally{n()}}async _publishDataChannel(e){Sw(e.id,"id",0,65535,!0),fw(e.ordered,"ordered"),Rw(e.metadata,"metadata",0,512),YN.info("[".concat(this._clientId,"] Publishing datachannels, id ").concat(e.id));const t=await this._publishMutex.lock();try{if(-1!==this._p2pChannel.getAllDataChannels().findIndex((t=>t.id===e.id)))throw new tD(Ew.INVALID_PARAMS,"Invalid id: ".concat(e.id,". If you want to republish the datachannel, unpublish first"));if(!this._joinInfo||void 0===this._uid)throw new tD(Ew.INVALID_OPERATION,"Can't publish datachannel, haven't joined yet!");if("CONNECTED"!==this.connectionState&&"RECONNECTING"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"can not publish datachannel in ".concat(this.connectionState," state"));if("auto"===this._turnServer.mode&&_N("FORCE_TURN")&&!_N("TURN_ENABLE_TCP")&&!_N("TURN_ENABLE_UDP"))throw new tD(Ew.UNEXPECTED_ERROR,"force TURN With No TURN Configuration");const i=function(e){return IV(e,!1)}(e),n=await this._p2pChannel.publishDataChannel([i]);if(n.length>0){if("number"!=typeof i._originDataChannelId)throw YN.error("[".concat(this._clientId,"] can not publish with mediaType datachannel, cannot get RTCDatachannel id")),new tD(Ew.CREATE_DATACHANNEL_ERROR);try{await Wh.all(n.map((e=>this._uid&&this._gateway.publishDataChannel(this._uid,e,!0)))),await i._waitTillOpen()}catch(e){if(e.code!==Ew.DISCONNECT_P2P)throw e}}return YN.info("[".concat(this._clientId,"] Publish dataChannels success, id ").concat(i.id)),i}catch(e){throw YN.error("[".concat(this._clientId,"] publish datachannels error"),e.toString()),e}finally{t()}}async unpublish(e){if(!this._joinInfo||void 0===this._uid)throw new tD(Ew.INVALID_OPERATION,"Can't unpublish stream, haven't joined yet!");let t=[];if(e)if(Array.isArray(e))t=e;else{if(!(e instanceof XD))return this._unpublishDataChannel([e]);t=[e]}else this.store.useP2P||await this._unpublishDataChannel(),t=this._p2pChannel.getAllTracks(!0);YN.info("[".concat(this._clientId,"] Unpublish tracks, tracks ").concat(t.map((e=>"".concat(e.getTrackId()," ")))," "));const i=await this._publishMutex.lock();try{if(this.store.useP2P){const e=await this._p2pChannel.unpublish(t);e&&await this._gateway.sendExtensionMessage(ox.UNPUBLISH,{unpubMsg:e},!0)}else{const e=await this._p2pChannel.unpublish(t);e&&await this._gateway.unpublish(e,this._uid),YN.info("[".concat(this._clientId,"] Unpublish success,tracks ").concat(t.map((e=>"".concat(e.getTrackId())))))}}catch(e){throw YN.error("[".concat(this._clientId,"] unpublish error"),e.toString()),e}finally{i&&i()}}async _unpublishDataChannel(e){void 0!==e&&0!==e.length||(e=this._p2pChannel.getAllDataChannels()),YN.info("[".concat(this._clientId,"] Unpublish datachannels, datachannels ").concat(e.map((e=>"".concat(e.id," ")))," "));const t=await this._publishMutex.lock();try{const i=await this._p2pChannel.unpublishDataChannel(e);i&&await this._gateway.unpublishDataChannel(i),YN.info("[".concat(this._clientId,"] Unpublish dataChannel success,dataChannel ").concat(e.map((e=>"".concat(e.id)))))}catch(e){throw YN.error("[".concat(this._clientId,"] unpublish dataChannel error"),e.toString()),e}finally{t&&t()}}async subscribe(e,t,i){if(!(e instanceof IF)){const t=this.remoteUsers.find((t=>t.uid===e));if(!t)throw new tD(Ew.INVALID_REMOTE_USER,"user is not in the channel");e=t}return"datachannel"===t?this._subscribeDataChannel(e,i):this._subscribe(e,t)}async presubscribe(e,t){if(Tw(t,"mediaType",["audio","video"]),this.store.useP2P)throw new tD(Ew.INVALID_OPERATION,"can't presub at p2p mode");if(!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"can't presub when not join");if("CONNECTED"!==this.connectionState&&"RECONNECTING"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"can't presub in ".concat(this.connectionState," state"));const i=t===HU.AUDIO,n=t===HU.VIDEO,r=await this._subscribeMutex.lock();try{const{ssrcId:o,ortc:s,rtxSsrcId:a,cname:c,uint_id:d}=await this._gateway.presubscribe(e,t,!0);if(null==o)throw new tD(Ew.UNEXPECTED_RESPONSE,"no ssrc id");let l=this._users.find((t=>t.uid===e));l||(l=new IF(e,d||e),l._is_pre_created=!0,this._users.push(l)),c&&(l._cname=c),l._uintid||(l._uintid=d||e),i&&(l._audioSSRC=o,l._audio_pre_subscribed=!0,s&&(l._audioOrtc=s)),n&&(l._videoSSRC=o,l._video_pre_subscribed=!0,s&&(l._videoOrtc=s),null!=a&&(l._rtxSsrcId=a)),YN.info("[".concat(this._clientId,"] presub succeed ssrc: ").concat(o)),await this._p2pChannel.subscribe(l,t,o,a,s);const u=i?l._audioTrack:l._videoTrack;if(!u)throw new tD(Ew.UNEXPECTED_ERROR,"can not find remote track in user");return i&&(l._trust_audio_stream_added_state_=!0,l._audio_added_=!0),n&&(l._trust_video_stream_added_state_=!0,l._video_added_=!0),u}catch(t){throw YN.error("[".concat(this._clientId,"] presub user ").concat(e," error"),t),t}finally{r()}}async _subscribeDataChannel(e,t){var i;if(Sw(t,"channelId",0,65535,!0),!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"Can't subscribe datachannel, not joined");if("CONNECTED"!==this.connectionState&&"RECONNECTING"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"Can't subscribe datachannel in ".concat(this.connectionState," state"));const n=this._users.find((t=>t===e));if(!n)throw YN.error("[".concat(this._clientId,"] can not subscribe ").concat(e.uid,", this user is not in the channel")),new tD(Ew.INVALID_REMOTE_USER,"user is not in the channel");if(!e.hasAudio&&!e.hasVideo&&0===e._dataChannels.length)throw YN.error("[".concat(this._clientId,"] can not subscribe ").concat(e.uid,", user is not published")),new tD(Ew.INVALID_REMOTE_USER,"user is not published");const r=null===(i=e._dataChannels)||void 0===i?void 0:i.find((e=>e.id===t));if(!r)throw YN.error("[".concat(this._clientId,"] can not subscribe ").concat(e.uid," with mediaType datachannel, remote datachannel is not published")),new tD(Ew.REMOTE_USER_IS_NOT_PUBLISHED);const o=await this._subscribeMutex.lock();YN.info("[".concat(this._clientId,"] subscribe user ").concat(e.uid,", mediaType: datachannel"));try{const t=await this._p2pChannel.subscribeDataChannel(e,[r]);if(t&&Dn(t).call(t,r.id))try{var s;if("number"!=typeof r._originDataChannelId)throw YN.error("[".concat(this._clientId,"] can not subscribe ").concat(e.uid," with mediaType datachannel, cannot get RTCDatachannel")),new tD(Ew.CREATE_DATACHANNEL_ERROR);const t={id:r.id,datachannelId:r._originDataChannelId,ordered:r.ordered,maxRetransmits:r.maxRetransmits,metadata:null!==(s=r.metadata)&&void 0!==s?s:""};await this._gateway.subscribeDataChannel(e.uid,t,!0),await r._waitTillOpen()}catch(t){if((null==t?void 0:t.code)!==Ew.WS_ABORT)throw await this._p2pChannel.unsubscribeDataChannel(e,[r]),t;await this._p2pChannel.unsubscribeDataChannel(e,[r]),this._p2pChannel.setPendingRemoteDataChannel(e,r.id)}return YN.info("[".concat(this._clientId,"] subscribe success user ").concat(e.uid,", mediaType: datachannel")),r}finally{o()}}async _p2pSubscribe(e,t,i){if(Tw(t,"mediaType",["audio","video"]),!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"Can't subscribe stream, not joined");if("CONNECTED"!==this.connectionState&&"RECONNECTING"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"Can't subscribe stream in ".concat(this.connectionState," state"));const n=this._users.find((t=>t===e));if(!n){const t=new tD(Ew.INVALID_REMOTE_USER,"user is not in the channel");throw YN.error("[".concat(this._clientId,"] can not subscribe ").concat(e.uid,", this user is not in the channel")),t}if(!e.hasAudio&&!e.hasVideo){const t=new tD(Ew.INVALID_REMOTE_USER,"user is not published");throw YN.error("[".concat(this._clientId,"] can not subscribe ").concat(e.uid,", user is not published")),t}if(!i&&("audio"===t&&!e.hasAudio||"video"===t&&!e.hasVideo)){const i=new tD(Ew.REMOTE_USER_IS_NOT_PUBLISHED);throw YN.error("[".concat(this._clientId,"] can not subscribe ").concat(e.uid," with mediaType ").concat(t,", remote track is not published")),i}const r=await this._subscribeMutex.lock();YN.info("[".concat(this._clientId,"] subscribe user ").concat(e.uid,", mediaType: ").concat(t));try{if(await this._p2pChannel.hasRemoteMediaWithLock(e,t))await this._p2pChannel.unmuteRemote(e,t);else try{const i="audio"===t?e._audioSSRC:e._videoSSRC,n="audio"===t?e._audioMid:e._videoMid;this.store.subscribe(e.uid,t,Date.now()),this.store.useP2P&&await this._p2pChannel.subscribe(e,t,i,n)}catch(e){throw e}YN.info("[".concat(this._clientId,"] subscribe success user ").concat(e.uid,", mediaType: ").concat(t)),this._defaultStreamFallbackType&&this.setStreamFallbackOption(e.uid,this._defaultStreamFallbackType).catch((e=>{YN.warning("[".concat(this._clientId,"] auto set fallback failed"),e)}));const i="audio"===t?e._audioTrack:e._videoTrack;if(!i)throw new tD(Ew.UNEXPECTED_ERROR,"can not find remote track in user object");return i}catch(t){throw YN.error("[".concat(this._clientId,"] subscribe user ").concat(e.uid," error"),t),t}finally{r()}}async _subscribe(e,t,i){if(this.store.useP2P)return this._p2pSubscribe(e,t);if(Tw(t,"mediaType",["audio","video"]),!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"Can't subscribe stream, not joined");if("CONNECTED"!==this.connectionState&&"RECONNECTING"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"Can't subscribe stream in ".concat(this.connectionState," state"));const n=this._users.find((t=>t===e));if(!n){const t=new tD(Ew.INVALID_REMOTE_USER,"user is not in the channel");throw YN.error("[".concat(this._clientId,"] can not subscribe ").concat(e.uid,", this user is not in the channel")),t}if(!e.hasAudio&&!e.hasVideo){const t=new tD(Ew.INVALID_REMOTE_USER,"user is not published");throw YN.error("[".concat(this._clientId,"] can not subscribe ").concat(e.uid,", user is not published")),t}if(!(i||("audio"!==t||e.hasAudio&&void 0!==e._audioSSRC)&&("video"!==t||e.hasVideo&&void 0!==e._videoSSRC))){const i=new tD(Ew.REMOTE_USER_IS_NOT_PUBLISHED);throw YN.error("[".concat(this._clientId,"] can not subscribe ").concat(e.uid," with mediaType ").concat(t,", remote track is not published")),i}let r="audio"===t?e._audioSSRC:e._videoSSRC,o="audio"===t?e._audioOrtc:e._videoOrtc,s="video"===t?e._rtxSsrcId:void 0,a={stream_type:"audio"===t?HU.AUDIO:HU.VIDEO,ssrcId:r};const c=await this._subscribeMutex.lock();YN.info("[".concat(this._clientId,"] subscribe user ").concat(e.uid,", mediaType: ").concat(t));try{if(await this._p2pChannel.hasRemoteMediaWithLock(e,t))await this._p2pChannel.unmuteRemote(e,t);else try{const i="audio"===t?e._audioSSRC:e._videoSSRC;void 0!==i&&i!==r&&(r=i,o="audio"===t?e._audioOrtc:e._videoOrtc,s="video"===t?e._rtxSsrcId:void 0,a={stream_type:"audio"===t?HU.AUDIO:HU.VIDEO,ssrcId:r}),TF.markSubscribeStart(this.store.clientId,r),this.store.subscribe(e.uid,t,Date.now()),await this._p2pChannel.subscribe(e,t,r,s,o);try{this._p2pChannel.isPreSubScribe(r)||await this._gateway.subscribe(e.uid,a,!0)}catch(i){if((null==i?void 0:i.code)!==Ew.WS_ABORT)throw await this._p2pChannel.unsubscribe(e,t),i;await this._p2pChannel.unsubscribe(e,t,!0),this._p2pChannel.setPendingRemoteMedia(e,t)}this.store.subscribe(e.uid,t,void 0,Date.now()),this._p2pChannel.reportSubscribeEvent(!0,null,e,t)}catch(i){throw this._p2pChannel.reportSubscribeEvent(!1,null==i?void 0:i.code,e,t),i}YN.info("[".concat(this._clientId,"] subscribe success user ").concat(e.uid,", mediaType: ").concat(t)),this._defaultStreamFallbackType&&this.setStreamFallbackOption(e.uid,this._defaultStreamFallbackType).catch((e=>{YN.warning("[".concat(this._clientId,"] auto set fallback failed"),e)}));const i="audio"===t?e._audioTrack:e._videoTrack;if(!i)throw new tD(Ew.UNEXPECTED_ERROR,"can not find remote track in user object");return i}catch(t){throw YN.error("[".concat(this._clientId,"] subscribe user ").concat(e.uid," error"),t),t}finally{c()}}async massSubscribe(e){if(vw(e,"subscribeList"),!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"Can't subscribe stream, not joined");if("CONNECTED"!==this.connectionState&&"RECONNECTING"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"Can't subscribe stream in ".concat(this.connectionState," state"));const t=Date.now(),i=new Map,n=await this._subscribeMutex.lock();YN.info("[".concat(this._clientId,"]start massSubscribe user ").concat(e.map((e=>{let{user:t,mediaType:i}=e;return"user: ".concat(null==t?void 0:t.uid,", mediaType: ").concat(i)})).join("; ")));const r=(e=[...e]).map((e=>{let{user:t,mediaType:i}=e;return{user:t,mediaType:i}})),o=await this._p2pChannel.globalLock();try{var s;for(let t=e.length-1;t>=0;t--){const n=e[t],{user:o,mediaType:s}=n;if(Tw(s,"mediaType",["audio","video"]),!o){const e=new tD(Ew.INVALID_PARAMS,"user property does not exist in subscribeList item");throw YN.error("[".concat(this._clientId,"] user property does not exist in subscribeList item")),e}const a=this._users.find((e=>e===o));if(!a){const i=new tD(Ew.INVALID_REMOTE_USER,"user is not in the channel");YN.error("[".concat(this._clientId,"] can not massSubscribe ").concat(o.uid,", this user is not in the channel")),r[t].error=i,e.splice(t,1);continue}if("audio"===s&&(!o.hasAudio||void 0===o._audioSSRC)||"video"===s&&(!o.hasVideo||void 0===o._videoSSRC)){const i=new tD(Ew.REMOTE_USER_IS_NOT_PUBLISHED);YN.error("[".concat(this._clientId,"] can not subscribe ").concat(o.uid," with mediaType ").concat(s,", remote user is not published")),r[t].error=i,e.splice(t,1);continue}const c=MU.Video|MU.LwoVideo,d=i.get(o);if(d){if("video"===s?d&c:d&MU.Audio){e.splice(t,1),YN.warning("[".concat(this._clientId,"] repeat massSubscribe user:").concat(o.uid,", mediaType:").concat(s," twice"));continue}i.set(o,d|("video"===s?c:MU.Audio))}else i.set(o,"video"===s?c:MU.Audio)}for(let t=e.length-1;t>=0;t--){const n=e[t],{user:r,mediaType:o}=n,s=MU.Video|MU.LwoVideo;if(this._p2pChannel.hasRemoteMedia(r,o)){await this._p2pChannel.unmuteRemoteNoLock(r,o);const n=i.get(r);i.set(r,"video"===o?n^s:n^MU.Audio),e.splice(t,1)}}this.store.massSubscribe(e.map((e=>({userId:e.user.uid,type:e.mediaType}))),t);let a=Xn(s=Array.from(i.entries())).call(s,((e,t)=>{let[i,n]=t;if(0===n)return e;const r={stream_id:i.uid,stream_type:n};return n&MU.Audio&&(r.audio_ssrc=i._audioSSRC),n&MU.Video&&(r.video_ssrc=i._videoSSRC),e.push(r),e}),[]);try{e.length>0&&await this._p2pChannel.massSubscribeNoLock(e.map((e=>{let{user:t,mediaType:i}=e;return{user:t,mediaType:i,ssrcId:i===HU.VIDEO?t._videoSSRC:t._audioSSRC,rtxSsrcId:i===HU.VIDEO?t._rtxSsrcId:void 0}})));const i=new Map;if(a=a.filter((e=>e.video_ssrc&&!this._p2pChannel.isPreSubScribe(e.video_ssrc)||e.audio_ssrc&&!this._p2pChannel.isPreSubScribe(e.audio_ssrc)||!e.video_ssrc&&!e.audio_ssrc)),a.length>0){const e=await this._gateway.subscribeAll(a,!0);((null==e?void 0:e.users)||[]).forEach((e=>{let{stream_id:t,video_error_code:n,audio_error_code:r,error_code:o}=e;(n||r||o)&&i.set(t,{video_error_code:n,audio_error_code:r,error_code:o})}))}if(Array.from(i.entries()).length>0){const e=[];Array.from(i.entries()).forEach((t=>{let[i,n]=t;const r=this.remoteUsers.find((e=>e.uid===i));if(r){let t;n.error_code||n.video_error_code&&n.audio_error_code?t=void 0:n.video_error_code?t=HU.VIDEO:n.audio_error_code&&(t=HU.AUDIO),e.push({user:r,mediaType:t})}})),e.length>0&&await this._p2pChannel.massUnsubscribeNoLock(e)}for(const e of r){const t=i.get(e.user.uid);if(t){const i=t.error_code||"audio"===e.mediaType&&t.audio_error_code||"video"===e.mediaType&&t.video_error_code;if(i){const t=hx(i);YN.error("user:".concat(e.user.uid," mediaType:").concat(e.mediaType," has massSubscribe error ").concat(t.desc)),e.error=new tD(Ew.SUBSCRIBE_FAILED,"code ".concat(i,": ").concat(t.desc))}}e.error||("video"===e.mediaType?e.track=e.user.videoTrack:e.track=e.user.audioTrack)}return this.store.massSubscribe(r.filter((e=>!e.error)).map((e=>({userId:e.user.uid,type:e.mediaType}))),void 0,Date.now()),r.forEach((e=>{var i;eD.subscribe(this.store.sessionId,{succ:!!e.error,ec:(null===(i=e.error)||void 0===i?void 0:i.code)||null,video:e.mediaType===HU.VIDEO,audio:e.mediaType===HU.AUDIO,peerid:e.user.uid,subscribeRequestid:e.mediaType===HU.VIDEO?e.user._videoSSRC:e.user._audioSSRC,p2pid:this.store.p2pId,eventElapse:Math.floor(performance.now()-t),preSsrc:this._p2pChannel.isPreSubScribe(e.user._videoSSRC)},!0)})),YN.info("[".concat(this._clientId,"] massSubscribe success ").concat(e.map((e=>{let{user:t,mediaType:i}=e;return"user: ".concat(null==t?void 0:t.uid,", mediaType: ").concat(i)})).join("; "))),r}catch(t){throw await this._p2pChannel.massUnsubscribeNoLock(e),t}}finally{o(),n()}}async unsubscribe(e,t,i){if(!(e instanceof IF)){const t=this.remoteUsers.find((t=>t.uid===e));if(!t)throw new tD(Ew.INVALID_REMOTE_USER,"user is not in the channel");e=t}if(t||this.store.useP2P){if("datachannel"===t)return this._unsubscribeDataChannel(e,i)}else await this._unsubscribeDataChannel(e,i);if(t&&Tw(t,"mediaType",["audio","video"]),!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"Can't unsubscribe stream, haven't joined yet!");const n=this._users.find((t=>t===e));if(!n){const t=new tD(Ew.INVALID_REMOTE_USER,"user is not in the channel");throw YN.error("[".concat(this._clientId,"] can not unsubscribe ").concat(e.uid,", user is not in the channel")),t}YN.info("[".concat(this._clientId,"] unsubscribe uid: ").concat(e.uid,", mediaType: ").concat(t));const r=await this._subscribeMutex.lock();try{if(this.store.useP2P)await this._p2pChannel.unsubscribe(e,t);else{const i=await this._p2pChannel.unsubscribe(e,t);i&&await this._gateway.unsubscribe(i,e.uid),t&&"audio"!==t||(e._audio_pre_subscribed=!1),t&&"video"!==t||(e._video_pre_subscribed=!1),e._is_pre_created&&Qw(this._users,e),YN.info("[".concat(this._clientId,"] unsubscribe success uid: ").concat(e.uid,", mediaType: ").concat(t))}}catch(t){if(t.code===Ew.DISCONNECT_P2P)return void YN.warning("disconnecting p2p, abort unsubscribe request.");throw YN.error("[".concat(this._clientId,"] unsubscribe user ").concat(e.uid," error"),t.toString()),t}finally{r()}}async _unsubscribeDataChannel(e,t){if(t&&Sw(t,"id",0,65535,!0),!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"Can't unsubscribe datachannel, haven't joined yet!");const i=this._users.find((t=>t===e));if(!i){const t=new tD(Ew.INVALID_REMOTE_USER,"user is not in the channel");throw YN.error("[".concat(this._clientId,"] can not unsubscribe ").concat(e.uid,", user is not in the channel")),t}let n;if("number"==typeof t){const i=e._dataChannels.find((e=>e.id===t));i&&(n=[i])}else n=e._dataChannels;if(void 0===n){const i=new tD(Ew.REMOTE_USER_IS_NOT_PUBLISHED);throw YN.error("[".concat(this._clientId,"] can not unsubscribe ").concat(e.uid," with channelId ").concat(t,", remote datachannel is not published")),i}YN.info("[".concat(this._clientId,"] unsubscribe uid: ").concat(e.uid,", mediaType: datachannel, ids: ").concat(n.map((e=>e.id))));
vendor: 4,303 bytes, line 12272
12272try{const t=await this._p2pChannel.unsubscribeDataChannel(e,n);t&&await this._gateway.unsubscribeDataChannel(t,e.uid),YN.info("[".concat(this._clientId,"] unsubscribe datachannel success uid: ").concat(e.uid,", mediaType: datachannel, ids: ").concat(t))}catch(t){if(t.code===Ew.DISCONNECT_P2P)return void YN.warning("disconnecting p2p, abort unsubscribe request.");throw YN.error("[".concat(this._clientId,"] unsubscribe user ").concat(e.uid," error"),t.toString()),t}}async massUnsubscribe(e){if(vw(e,"unsubscribeList"),!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"Can't unsubscribeAll stream, haven't joined yet!");YN.info("[".concat(this._clientId,"] start massUnsubscribe ").concat(e.map((e=>{let{user:t,mediaType:i}=e;return"user: ".concat(null==t?void 0:t.uid,", mediaType: ").concat(i,";")})).join())),e=[...e];const t=new Map;for(let i=e.length-1;i>=0;i--){const{user:n,mediaType:r}=e[i];if(!n){const e=new tD(Ew.INVALID_PARAMS,"user property does not exist in unsubscribeList item");throw YN.error("[".concat(this._clientId,"] user property does not exist in unsubscribeList item")),e}Tw(r,"mediaType",["video","audio",void 0]);const o=this._users.find((e=>e===n));if(!o){YN.warning("[".concat(this._clientId,"] can not unsubscribe ").concat(n.uid,", user is not in the channel")),e.splice(i,1);continue}const s=MU.Video|MU.LwoVideo;if(t.has(n)){const o=t.get(n);let a;switch(r){case"video":a=o&s;break;case"audio":a=o&MU.Audio;break;default:a=o&(MU.Audio|s)}if(a){YN.warning("[".concat(this._clientId,"] repeat massUnsubscribe user:").concat(n.uid,",mediaType:").concat(r," twice.")),e.splice(i,1);continue}r?"audio"===r?t.set(n,o|MU.Audio):"video"===r&&t.set(n,o|s):t.set(n,o|MU.Audio|s)}else r?"audio"===r?t.set(n,MU.Audio):"video"===r&&t.set(n,s):t.set(n,MU.Audio|s)}try{const t=await this._p2pChannel.massUnsubscribe(e);t&&await this._gateway.massUnsubscribe(t),YN.info("[".concat(this._clientId,"] massUnsubscribe success ").concat(e.map((e=>{let{user:t,mediaType:i}=e;return"user: ".concat(null==t?void 0:t.uid,", mediaType: ").concat(i,";")})).join()))}catch(e){if(e.code===Ew.DISCONNECT_P2P)return void YN.warning("[".concat(this._clientId,"] disconnecting p2p, abort unsubscribe request."));throw YN.error("[".concat(this._clientId,"] massUnsubscribe error"),e.toString()),e}}async setLowStreamParameter(e){!function(e){if(!e)throw new mw(Ew.INVALID_PARAMS);Cw(e.width)||gw(e.width,"streamParameter.width"),Cw(e.height)||gw(e.height,"streamParameter.height"),Cw(e.framerate)||gw(e.framerate,"streamParameter.framerate"),Cw(e.bitrate)||Sw(e.bitrate,"streamParameter.bitrate")}(e),(!e.width&&e.height||e.width&&!e.height)&&YN.warning("[".concat(this._clientId,"] The width and height parameters take effect only when both are set")),YN.info("[".concat(this._clientId,"] set low stream parameter to"),JSON.stringify(e));const t=this._configDistribute.getLowStreamConfigDistribute();if(t&&t.bitrate&&e.bitrate&&t.bitrate<e.bitrate&&(e.bitrate=t.bitrate),this._lowStreamParameter=e,this._isDualStreamEnabled)return this._p2pChannel.updateVideoStreamParameter(e,zU.LocalVideoLowTrack)}async enableDualStream(){if(!nD().supportDualStream)throw eD.streamSwitch(this._sessionId,{lts:Date.now(),isdual:!0,succ:!1}),new tD(Ew.NOT_SUPPORTED,"Your browser is not support dual stream");if(this._isDualStreamEnabled)throw new tD(Ew.INVALID_OPERATION,"Dual stream is already enabled");if(this._p2pChannel.canPublishLowStream())try{await this._publishLowStream()}catch(e){throw eD.streamSwitch(this._sessionId,{lts:Date.now(),isdual:!0,succ:!1}),e}this._isDualStreamEnabled=!0,eD.streamSwitch(this._sessionId,{lts:Date.now(),isdual:!0,succ:!0}),YN.info("[".concat(this._clientId,"] enable dual stream"))}async disableDualStream(){if(this._isDualStreamEnabled){if(!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"Can't publish stream, haven't joined yet!");if(this._p2pChannel.getLocalMedia(zU.LocalVideoLowTrack))try{const e=await this._p2pChannel.unpublishLowStream();e&&await this._gateway.unpublish(e,this._joinInfo.stringUid||this._joinInfo.uid)}catch(e){throw eD.streamSwitch(this._sessionId,{lts:Date.now(),isdual:!1,succ:!1}),e}this._isDualStreamEnabled=!1,eD.streamSwitch(this._sessionId,{lts:Date.now(),isdual:!1,succ:!0}),YN.info("[".concat(this._clientId,"] disable dual stream"))}}
vendor: 21,971 bytes, line 12272
12272async setClientRole(e,t){if(function(e){Tw(e,"role",["audience","host"])}(e),t&&jw(t),"rtc"===this.mode||"p2p"===this.mode)throw YN.warning("[".concat(this._clientId,"]").concat(this.mode," mode can not use setClientRole")),new tD(Ew.INVALID_OPERATION,"".concat(this.mode," mode can not use setClientRole"));if(t&&t.level&&"host"===e)throw new tD(Ew.INVALID_OPERATION,"host mode can not set audience latency level");if("audience"===e&&this._p2pChannel.hasLocalMedia())throw new tD(Ew.INVALID_OPERATION,"can not set client role to audience when publishing stream");const i=this._config.role;this._joinInfo&&(this._joinInfo.role=e),e!==i&&_N("ENABLE_ROLE_SELECT_EDGE")?(this._gateway.updateClientRole(e,t),this._config.role=e,this._gateway.reconnect("recover",Ww.REGIONAL_DISTRIBUTION)):(await this._gateway.setClientRole(e,t),this._config.role=e),YN.info("[".concat(this._clientId,"] set client role to ").concat(e,", level: ").concat(t&&t.level))}async _setClientRoleOptions(e){if("rtc"===this.mode||"p2p"===this.mode)return;if("audience"!==this._config.role||this._p2pChannel.hasLocalMedia())return;let t=!1;try{e&&jw(e),await this._gateway.setClientRole(this._config.role,e),t=!0}catch(e){}finally{YN.info("[".concat(this._clientId,"] set client role options ").concat(t?"succeed":"failed",", options is ").concat(e))}}getRemoteInboundOffset(){var e;const t=null===(e=this._p2pChannel.getStats())||void 0===e?void 0:e.audioSend[0];if(!t||!t.timestamp)return 0;const i=t.timestamp-Date.now();return Math.abs(i)>1e3+t.rttMs+100?this.ntpAlignErrorCount+=1:this.ntpAlignErrorCount=0,this.ntpAlignErrorCount>=3?i:0}getNtpWallTimeInMs(){return"visible"===document.visibilityState&&(this.remoteInboundOffset=this.getRemoteInboundOffset()),this.remoteInboundOffset+Date.now()+this._gateway.ntpOffset}setProxyServer(e,t){if(Rw(e,"proxyServer"),!t){if("DISCONNECTED"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"Set proxy server before join channel");if("disabled"!==this._cloudProxyServerMode||this._useLocalAccessPoint)throw new tD(Ew.INVALID_OPERATION,"You have already set the proxy")}this._proxyServer=e,eD.setProxyServer(this._proxyServer),YN.setProxyServer(this._proxyServer),YN.info("[".concat(this._clientId,"] Set proxy server ").concat(t?"by initialize call":""," success."))}setTurnServer(e,t){if(Array.isArray(e)||(e=[e]),!t){if("DISCONNECTED"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"Set turn server before join channel");if("disabled"!==this._cloudProxyServerMode||this._useLocalAccessPoint)throw new tD(Ew.INVALID_OPERATION,"You have already set the proxy")}if(Fw(e))return this._turnServer={servers:e,mode:"original-manual"},void YN.info("[".concat(this._clientId,"] Set original turnserver ").concat(t?"by initialize call":""," success: ").concat(e.map((e=>e.urls)).join(","),"."));e.forEach((e=>Bw(e))),this._turnServer={servers:e,mode:"manual"},YN.info("[".concat(this._clientId,"] Set turnserver ").concat(t?"by initialize call":""," success."))}setLicense(e){if("DISCONNECTED"!==this.connectionState){throw new tD(Ew.INVALID_OPERATION,"you should set license before join channel")}if(Rw(e,"license",32,32),!/^[A-Za-z\d]+$/.test(e))throw new tD(Ew.INVALID_PARAMS,"license should only contains characters from A-Z a-z 0-9");this._license=e,YN.info("[".concat(this._clientId,"] set license success"),e)}startProxyServer(e){if("DISCONNECTED"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"Start proxy server before join channel");if(this._proxyServer||"manual"===this._turnServer.mode||this._useLocalAccessPoint)throw new tD(Ew.INVALID_OPERATION,"You have already set the proxy");const t=[3,4,5];let i;switch(void 0===e&&(e=3),e){case 1:case 2:throw new tD(Ew.NOT_SUPPORTED,"proxy mode 1/2 has been deprecated and not supported.");case 3:i="proxy3";break;case 4:i="proxy4";break;case 5:i="proxy5";break;default:throw new tD(Ew.INVALID_PARAMS,"proxy server mode must be ".concat(t.join("|")))}this._cloudProxyServerMode=i,this.store.cloudProxyServerMode=i,YN.info("[".concat(this._clientId,"] set cloud proxy server mode to"),this._cloudProxyServerMode)}stopProxyServer(){if("DISCONNECTED"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"Stop proxy server after leave channel");eD.setProxyServer(),YN.setProxyServer(),this._cloudProxyServerMode="disabled",this.store.cloudProxyServerMode="disabled",YN.info("[".concat(this._clientId,"] set cloud proxy server mode to"),this._cloudProxyServerMode),this._proxyServer=void 0,this._turnServer={mode:"auto",servers:[]}}setLocalAccessPointsV2(e){if(!e.accessPoints)throw new tD(Ew.INVALID_PARAMS,"accessPoints is required.");vw(e.accessPoints.serverList,"accessPoints.serverList"),Rw(e.accessPoints.domain,"accessPoints.domain");const t=(e,t)=>{Sw(e,t,0,65535,!0)};let i=443;if(e.accessPoints.port&&(t(e.accessPoints.port,"accessPoints.port"),i=e.accessPoints.port),this._proxyServer||"disabled"!==this._cloudProxyServerMode)throw new tD(Ew.INVALID_OPERATION,"set local access point failed, You have already set the cloud proxy");_N("CLOSE_AFB_FOR_LOCAL_AP")&&(pN("JOIN_WITH_FALLBACK_SIGNAL_PROXY",!1),pN("JOIN_WITH_FALLBACK_MEDIA_PROXY",!1));const n=/^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/,r=e.accessPoints.domain,o=e.accessPoints.serverList.map((e=>n.test(e)?"".concat(e.replace(/\./g,"-"),".").concat(r):e)),s=o.map((e=>"".concat(e,":").concat(i)));this._useLocalAccessPoint=!0,this._setLocalAPVersion=2,pN("WEBCS_DOMAIN",s),pN("WEBCS_DOMAIN_BACKUP_LIST",s),pN("GATEWAY_DOMAINS",[r]),e.report&&e.report.hostname&&Array.isArray(e.report.hostname)&&e.report.hostname.length?(vw(e.report.hostname,"report.hostname"),pN("EVENT_REPORT_DOMAIN",e.report.hostname[0]),pN("EVENT_REPORT_BACKUP_DOMAIN",e.report.hostname[1]||e.report.hostname[0])):(pN("EVENT_REPORT_DOMAIN",o[0]),pN("EVENT_REPORT_BACKUP_DOMAIN",o[1]||o[0]));let a=6443;e.report&&e.report.port&&(t(e.report.port,"report.port"),a=e.report.port),pN("STATS_COLLECTOR_PORT",a),e.report?pN("ENABLE_EVENT_REPORT",!0):pN("ENABLE_EVENT_REPORT",!1);let c="";e.log&&e.log.hostname&&Array.isArray(e.log.hostname)&&e.log.hostname.length?(vw(e.log.hostname,"log.hostname"),c=e.log.hostname[0]):c=o[0];let d=6444;e.log&&e.log.port&&(t(e.log.port,"log.port"),d=e.log.port),pN("LOG_UPLOAD_SERVER","".concat(c,":").concat(d));let l=[];e.cds&&e.cds.hostname&&Array.isArray(e.cds.hostname)&&e.cds.hostname.length?(vw(e.cds.hostname,"cds.hostname"),l=e.cds.hostname):l=o;let u=443;e.cds&&e.cds.port&&(t(e.cds.port,"cds.port"),u=e.cds.port),pN("CDS_AP",l.map((e=>"".concat(e,":").concat(u)))),e.cds?pN("ENABLE_CONFIG_DISTRIBUTE",!0):pN("ENABLE_CONFIG_DISTRIBUTE",!1),YN.info("set local access point v2 success")}setLocalAccessPoints(e,t){if(vw(e,"serverList"),Rw(t,"domain"),this._proxyServer||"disabled"!==this._cloudProxyServerMode)throw new tD(Ew.INVALID_OPERATION,"set local access point failed, You have already set the cloud proxy");const i=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;e=e.map((e=>i.test(e)?"".concat(e.replace(/\./g,"-"),".").concat(t):e)),this._useLocalAccessPoint=!0,this._setLocalAPVersion=1,pN("WEBCS_DOMAIN",e),pN("WEBCS_DOMAIN_BACKUP_LIST",e),pN("GATEWAY_DOMAINS",[t]),pN("EVENT_REPORT_DOMAIN",e[0]),pN("EVENT_REPORT_BACKUP_DOMAIN",e[1]||e[0]),pN("LOG_UPLOAD_SERVER","".concat(e[0],":6444")),YN.info("[".concat(this._clientId,"] set local access point success"))}async setRemoteDefaultVideoStreamType(e){if(Tw(e,"streamType",[0,1,4,5,6,7,8,9]),this._remoteDefaultVideoStreamType=e,this._joinInfo)try{await this._gateway.setDefaultRemoteVideoStreamType(e),this._joinInfo.defaultVideoStream=this._remoteDefaultVideoStreamType}catch(e){throw YN.error("[".concat(this._clientId,"] set default remote video stream type error"),e.toString()),e}else YN.debug("[".concat(this._clientId,"] haven't joined yet, cache remoteDefaultVideoStreamType ").concat(e))}async setRemoteVideoStreamType(e,t){Tw(t,"streamType",[0,1,4,5,6,7,8,9]);try{await this._gateway.setRemoteVideoStreamType(e,t),setTimeout((()=>{const t=this._users.find((t=>t.uid===e));t&&t.videoTrack&&t.videoTrack.updateMediaStreamTrackResolution()}),2e3)}catch(e){throw YN.error("[".concat(this._clientId,"] set remote video stream type error"),e.toString()),e}YN.info("[".concat(this._clientId,"] set remote ").concat(e," video stream type to ").concat(t)),this._remoteStreamTypeCacheMap.set(e,t)}async setStreamFallbackOption(e,t){Tw(t,"fallbackType",[0,1,2,3,4,5,6,7,8]);try{await this._gateway.setStreamFallbackOption(e,t)}catch(e){throw YN.error("[".concat(this._clientId,"] set stream fallback option"),e.toString()),e}YN.info("[".concat(this._clientId,"] set remote ").concat(e," stream fallback type to ").concat(t)),this._streamFallbackTypeCacheMap.set(e,t)}setEncryptionConfig(e,t,i,n){!function(e){Tw(e,"encryptionMode",["aes-128-xts","aes-256-xts","aes-128-ecb","sm4-128-ecb","aes-128-gcm","aes-256-gcm","aes-128-gcm2","aes-256-gcm2","none"])}(e),Rw(t,"secret");const r=["aes-128-gcm2","aes-256-gcm2"];if(Dn(r).call(r,e)){if(!i||!(i instanceof Uint8Array&&32===i.length))throw new tD(Ew.INVALID_PARAMS,"salt must be an Uint8Array and exactly equal to 32 bytes")}else if(i)throw new tD(Ew.INVALID_PARAMS,"current encrypt mode does not need salt");if(n){if(fw(n,"encryptDataStream"),!Dn(r).call(r,e))throw new tD(Ew.INVALID_PARAMS,"current encrypt mode does not support data stream");this._encryptDataStream=!0}new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*,.<>?/:;'\"|{}\\[\\]])(?=.{8,})").test(t)||YN.warning("The secret is not strong:\n The secret must contain at least 1 lowercase alphabetical character,\n The secret must contain at least 1 uppercase alphabetical character,\n The secret must contain at least 1 numeric character,\n The secret must contain at least one special character,\n The secret must be eight characters or longer.\n "),this._encryptionMode=e,this._encryptionSecret=t,i&&(this._encryptionSalt=oO(i))}async renewToken(e){if(Rw(e,"token",1,2047),!this._key||!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"renewToken should not be called before user join");const t=this._key;this._key=e,this._joinInfo&&(this._joinInfo.token=e);const i=await this._renewTokenMutex.lock();try{if(_N("USE_NEW_TOKEN")){YN.debug("[".concat(this._clientId,"] start renew token with ticket from unilbs"));const t=await hF(this._joinInfo,this._axiosCancelSource.token,this._config.httpRetryConfig||AO);YN.debug("[".concat(this._clientId,"] get ticket from unilbs success")),await this._gateway.renewToken({token:e,ticket:t})}else YN.debug("[".concat(this._clientId,"] start renew token without ticket")),await this._gateway.renewToken({token:e});YN.debug("[".concat(this._clientId,"] renewToken success"))}catch(e){throw this._key=t,this._joinInfo.token=t,YN.error("[".concat(this._clientId,"] renewToken failed"),e.toString()),e}finally{i()}}enableAudioVolumeIndicator(){this._audioVolumeIndicationInterval?YN.warning("you have already enabled audio volume indicator!"):this._audioVolumeIndicationInterval=window.setInterval((()=>{const e=this._p2pChannel.getAudioLevels();this.safeEmit(Gw.VOLUME_INDICATOR,e)}),_N("AUDIO_VOLUME_INDICATION_INTERVAL")||2e3)}getRTCStats(){const e=this._statsCollector.getRTCStats(),t=this._gateway.getInChannelInfo();return e.Duration=Math.round(t.duration/1e3),e}async startLiveStreaming(e,t){if(!t){if("h264"!==this.codec)throw new tD(Ew.LIVE_STREAMING_INVALID_RAW_STREAM,"raw streaming is only support h264");if(!this._p2pChannel.hasLocalMedia())throw new tD(Ew.LIVE_STREAMING_INVALID_RAW_STREAM,"can not find stream to raw streaming")}if(this._liveRawStreamingClient&&this._liveRawStreamingClient.hasUrl(e)||this._liveTranscodeStreamingClient&&this._liveTranscodeStreamingClient.hasUrl(e))throw new tD(Ew.LIVE_STREAMING_TASK_CONFLICT);const i=t?SU.TRANSCODE:SU.RAW;return this._createLiveStreamingClient(i).startLiveStreamingTask(e,i)}setLiveTranscoding(e){return this._createLiveStreamingClient(SU.TRANSCODE).setTranscodingConfig(e)}async stopLiveStreaming(e){const t=[this._liveRawStreamingClient,this._liveTranscodeStreamingClient].filter((t=>t&&t.hasUrl(e)));if(!t.length)throw new tD(Ew.INVALID_PARAMS,"can not find live streaming url to stop");await Wh.all(t.map((t=>t&&t.stopLiveStreamingTask(e))))}async startChannelMediaRelay(e){CF(e);const t=this._createChannelMediaRelayClient();await t.startChannelMediaRelay(e)}async updateChannelMediaRelay(e){CF(e);const t=this._createChannelMediaRelayClient();await t.updateChannelMediaRelay(e)}async stopChannelMediaRelay(){const e=this._createChannelMediaRelayClient();await e.stopChannelMediaRelay(),this._statsCollector.onStatsChanged&&(this._statsCollector.onStatsChanged=void 0)}sendAudioMetadata(e){this._p2pChannel instanceof PB&&this._p2pChannel.addAudioMetadata(e)}async sendStreamMessage(e){var t;let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"can not send data stream, not joined");if(("string"==typeof e||e instanceof Uint8Array)&&(e={payload:e}),"string"==typeof e.payload){const t=new TextEncoder;e.payload=t.encode(e.payload)}let n=!1;this._encryptDataStream&&this._encryptDataStreamIv&&this._encryptDataStreamKey&&window.crypto.subtle&&Dn(t=["aes-128-gcm2","aes-256-gcm2"]).call(t,this._encryptionMode)&&(n=!0,e.payload=await async function(e,t,i){var n;const r=Xn(n=Array.from(i)).call(n,((e,t)=>e+t),0),o={serverTs:0,seq:CN++,length:i.length,checkSum:r},s=new Uint8Array(SO(r,2)),a=new ArrayBuffer(vN),c=new DataView(a);c.setUint32(0,o.serverTs),c.setUint16(4,o.seq),c.setUint16(6,o.length),c.setUint16(8,o.checkSum);const d=16-i.length%16;i=aO(i,new Uint8Array(d));const l=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:e,tagLength:SN,additionalData:s},t,i);return aO(new Uint8Array(a),new Uint8Array(l))}(this._encryptDataStreamIv,this._encryptDataStreamKey,e.payload));if(new Blob([e.payload]).size>1024)throw new tD(Ew.INVALID_PARAMS,n?"encrypted stream message out of range.":"stream message out of range.");return this._gateway.signal.request(hU.DATA_STREAM,{payload:oO(e.payload),syncWithAudio:e.syncWithAudio,sendTs:Date.now()-UB},!i)}sendMetadata(e){if(!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"can not send metadata, not joined");if(new Blob([e]).size>1024)throw new tD(Ew.METADATA_OUT_OF_RANGE);return this._gateway.signal.request(hU.SEND_METADATA,{session_id:this._joinInfo.sid,metadata:oO(e)})}async sendCustomReportMessage(e){if(Array.isArray(e)||(e=[e]),e.forEach(zN),!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"can not send custom report, not joined");await eD.sendCustomReportMessage(this._joinInfo.sid,e)}getLocalAudioStats(){return this._statsCollector.getLocalAudioTrackStats()}getRemoteAudioStats(){return this._statsCollector.getRemoteAudioTrackStats()}getLocalVideoStats(){return this._statsCollector.getLocalVideoTrackStats()}getRemoteVideoStats(){return this._statsCollector.getRemoteVideoTrackStats()}getRemoteNetworkQuality(){return this._statsCollector.getRemoteNetworkQualityStats()}async pickSVCLayer(e,t){Tw(t.spatialLayer,"spatialLayer",[0,1,2,3]),Tw(t.temporalLayer,"temporalLayer",[0,1,2,3]);try{await this._gateway.pickSVCLayer(e,t)}catch(e){throw YN.error("[".concat(this._clientId,"] pick SVC layer failed"),e.toString()),e}}async setRTMConfig(e){const{apRTM:t=!1,rtmFlag:i}=e;if(fw(t,"apRTM"),Sw(i,"rtmFlag",0),this._rtmConfig.apRTM=t,this._rtmConfig.rtmFlag=i,YN.debug("[".concat(this._clientId,"] setRTMconfig ").concat(JSON.stringify(e)," in ").concat(this.connectionState," state")),("CONNECTED"===this.connectionState||"RECONNECTING"===this.connectionState)&&this._joinInfo)return this._joinInfo.apRTM=t,this._joinInfo.rtmFlag=i,this._gateway.setRTM2Flag(i)}_reset(){if(YN.debug("[".concat(this._clientId,"] reset client")),function(e){const t=SM.indexOf(e);-1!==t&&SM.splice(t,1)}(this._clientId),this.store.hasStartJoinChannel=!1,this.store.isABTestSuccess=!1,this._axiosCancelSource.cancel(),this._axiosCancelSource=Ab.CancelToken.source(),this._streamFallbackTypeCacheMap=new Map,this._remoteStreamTypeCacheMap=new Map,this._configDistribute.stopGetConfigDistribute(),this._joinInfo&&aj(this._joinInfo),this._joinInfo=void 0,this._proxyServer=void 0,this._defaultStreamFallbackType=void 0,this._sessionId&&eD.removeSid(this._sessionId),this._sessionId=null,this.store.sessionId=null,this._statsCollector.reset(),this._key=void 0,this._appId=void 0,this._uid=void 0,this.store.uid=void 0,this._channelName=void 0,this._encryptionMode="none",this._encryptionSecret=null,this._encryptionSalt=null,this._encryptDataStreamKey=null,this._encryptDataStreamIv=null,this._pendingPublishedUsers=[],this._users.forEach((e=>{e._audioTrack&&e._audioTrack._destroy(),e._videoTrack&&e._videoTrack._destroy(),e._dataChannels&&(e._dataChannels.forEach((e=>e._close())),e._dataChannels.length=0)})),this._users=[],this._audioVolumeIndicationInterval&&(window.clearInterval(this._audioVolumeIndicationInterval),this._audioVolumeIndicationInterval=void 0),"fallback"===this._cloudProxyServerMode&&(this._cloudProxyServerMode="disabled",this.store.cloudProxyServerMode="disabled"),this._p2pChannel.reset(),this._publishMutex=new IO("client-publish",this._clientId),this._subscribeMutex=new IO("client-subscribe",this._clientId),this._networkQualityInterval&&(window.clearInterval(this._networkQualityInterval),this._networkQualityInterval=void 0),this._liveRawStreamingClient&&(this._liveRawStreamingClient.terminate(),this._liveRawStreamingClient.removeAllListeners(),this._liveRawStreamingClient=void 0),this._liveTranscodeStreamingClient&&(this._liveTranscodeStreamingClient.terminate(),this._liveTranscodeStreamingClient.removeAllListeners(),this._liveTranscodeStreamingClient=void 0),this._channelMediaRelayClient&&(this._channelMediaRelayClient.dispose(),this._channelMediaRelayClient=void 0),this._inspect)try{this._inspect.close(),this._inspect=void 0}catch(e){}if(this._moderation)try{this.setImageModeration(!1)}catch(e){}}_startSession(e,t){var i;const n=e||pO();e?YN.debug("[".concat(this._clientId,"] new Session ").concat(n)):YN.debug("[".concat(this._clientId,"] renewSession ").concat(this._sessionId," => ").concat(n));const r=e?"":this._sessionId||"";this._sessionId=n,this.store.sessionId=n,eD.addSid(n);const o={lts:(new Date).getTime(),mode:this.mode,buildFormat:1,stringUid:(null==t?void 0:t.stringUid)||(null===(i=this._joinInfo)||void 0===i?void 0:i.stringUid),channelProfile:"live"===this.mode?1:0,channelMode:0,isABTestSuccess:Number(this._configDistribute.isSuccess),lsid:r,clientRole:"audience"===this.role?2:1};eD.sessionInit(this._sessionId,UG({cname:t.channel,appid:t.appId},o)),this._joinInfo&&(this._joinInfo.sid=n),this._gateway.joinInfo&&(this._gateway.joinInfo.sid=n)}async _publishHighStream(e){if(!this._joinInfo||void 0===this._uid)throw new tD(Ew.INVALID_OPERATION,"Can't publish stream, haven't joined yet!");if("CONNECTED"!==this.connectionState&&"RECONNECTING"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"can not publish stream in ".concat(this.connectionState," state"));if("auto"===this._turnServer.mode&&_N("FORCE_TURN")&&!_N("TURN_ENABLE_TCP")&&!_N("TURN_ENABLE_UDP"))throw new tD(Ew.UNEXPECTED_ERROR,"force TURN With No TURN Configuration");YN.debug("[".concat(this._clientId,"] publish high stream"));try{const i=await this._p2pChannel.publish(e,this._isDualStreamEnabled,this._lowStreamParameter);if(this.store.useP2P){const e=(await i.next()).value;if(e){try{await this._gateway.sendExtensionMessage(ox.PUBLISH,e,!0)}catch(e){throw i.throw(e),e}await i.next()}this._p2pChannel.reportPublishEvent(!0,null)}else{const n=(await i.next()).value;if(n){var t;let e;try{e=await this._gateway.publish(this._uid,n,!0)}catch(e){if(e.code!==Ew.DISCONNECT_P2P)throw i.throw(e),e}await i.next((null===(t=e)||void 0===t?void 0:t.ortc)||[])}this._p2pChannel.reportPublishEvent(!0,null);for(const t of e)t instanceof pk&&t._encoderConfig&&this._gateway.setVideoProfile(t._encoderConfig).catch((e=>{YN.debug("[".concat(this._clientId,"] stop setVideoProfile, because websocket is closed"))})),!t.muted&&t.enabled||await this._p2pChannel.muteLocalTrack(t)}}catch(t){if(this._p2pChannel.reportPublishEvent(!1,null==t?void 0:t.code,e),(null==t?void 0:t.code)===Ew.WS_ABORT)return;throw t}}async _publishLowStream(){if(!this._joinInfo||void 0===this._uid)throw new tD(Ew.INVALID_OPERATION,"Can't publish stream, haven't joined yet!");if("CONNECTED"!==this.connectionState&&"RECONNECTING"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"can not publish stream in ".concat(this.connectionState," state"));YN.debug("[".concat(this._clientId,"] publish low stream"));const e=this._configDistribute.getLowStreamConfigDistribute();e&&e.bitrate&&(this._lowStreamParameter||(this._lowStreamParameter={width:160,height:120,framerate:15,bitrate:50}),this._lowStreamParameter&&this._lowStreamParameter.bitrate&&e.bitrate<this._lowStreamParameter.bitrate&&(this._lowStreamParameter.bitrate=e.bitrate));try{const e=await this._p2pChannel.publishLowStream(this._lowStreamParameter),i=(await e.next()).value;if(i){var t;let n;try{n=await this._gateway.publish(this._uid,i,!0)}catch(t){if(t.code!==Ew.DISCONNECT_P2P)throw e.throw(t),t}e.next((null===(t=n)||void 0===t?void 0:t.ortc)||[]),this._p2pChannel.reportPublishEvent(!0,null,void 0,!0)}}catch(e){if(this._p2pChannel.reportPublishEvent(!1,null==e?void 0:e.code,void 0,!0),(null==e?void 0:e.code)===Ew.WS_ABORT)return;throw e}}_createLiveStreamingClient(e){const t=()=>{if(!this._joinInfo||!this._appId){return new tD(Ew.INVALID_OPERATION,"can not create live streaming client, please join channel first").throw()}const e=(t={joinInfo:this._joinInfo,appId:this._appId,websocketRetryConfig:this._config.websocketRetryConfig,httpRetryConfig:this._config.httpRetryConfig},CV("LiveStreaming").create(t));var t;return e.onLiveStreamError=(e,t)=>
12272{eD.reportApiInvoke(this._sessionId,{name:kw.ON_LIVE_STREAM_ERROR,options:[e,t],tag:Mw.TRACER}).onSuccess(),this.safeEmit(Gw.LIVE_STREAMING_ERROR,e,t)},e.onLiveStreamWarning=(e,t)=>{eD.reportApiInvoke(this._sessionId,{name:kw.ON_LIVE_STREAM_WARNING,options:[e,t],tag:Mw.TRACER}).onSuccess(),this.safeEmit(Gw.LIVE_STREAMING_WARNING,e,t)},e.on(yU.REQUEST_WORKER_MANAGER_LIST,((e,t,i)=>{if(!this._joinInfo)return i(new tD(Ew.INVALID_OPERATION,"can not find join info to get worker manager"));(async function(e,t,i,n){const r=_N("UAP_AP").slice(0,_N("AJAX_REQUEST_CONCURRENT")).map((e=>t.proxyServer?"https://".concat(t.proxyServer,"/ap/?url=").concat(e+"/api/v1?action=uap"):"https://".concat(e,"/api/v1?action=uap")));return await KV(r,e,t,i,n)})(e,this._joinInfo,this._axiosCancelSource.token,AO).then(t).catch(i)})),e};return e===SU.RAW?(this._liveRawStreamingClient=this._liveRawStreamingClient||t(),this._liveRawStreamingClient):(this._liveTranscodeStreamingClient=this._liveTranscodeStreamingClient||t(),this._liveTranscodeStreamingClient)}_createChannelMediaRelayClient(){if(!this._joinInfo){return new tD(Ew.INVALID_OPERATION,"can not create channel media relay client, please join channel first").throw()}if(!this._channelMediaRelayClient){const{sendResolutionWidth:t,sendResolutionHeight:i}=this.getLocalVideoStats(),n=(e={joinInfo:this._joinInfo,clientId:this._clientId,websocketRetryConfig:this._config.websocketRetryConfig,httpRetryConfig:this._config.httpRetryConfig,resolution:{width:t,height:i}},CV("ChannelMediaRelay").create(e));n.on("state",(e=>{e===NU.RELAY_STATE_FAILURE&&n&&n.dispose(),this.safeEmit(Gw.CHANNEL_MEDIA_RELAY_STATE,e)})),n.on("event",(e=>{this.safeEmit(Gw.CHANNEL_MEDIA_RELAY_EVENT,e)})),this._channelMediaRelayClient=n,this._statsCollector.onStatsChanged=(e,t)=>{var i;"resolution"===e&&(null===(i=this._channelMediaRelayClient)||void 0===i||i.setVideoProfile(t))}}var e;return this._channelMediaRelayClient}_handleUpdateDataChannel(e,t){const{added:i,deleted:n}=e,r=[];if(t){const e=[];this._users.forEach((t=>{t._dataChannels.forEach((n=>{i.every((e=>e.uid!==t._uintid||e.stream_id!==n.id))&&e.push({uid:t._uintid,stream_id:n.id,ordered:n.ordered,max_retrans_times:n.maxRetransmits,metadata:n.metadata})}))})),e.length>0&&this._handleUpdateDataChannel({added:[],deleted:e})}Array.isArray(i)&&i.length>0&&i.forEach((e=>{const{uid:i,stream_id:n,ordered:o,max_retrans_times:s,metadata:a}=e,c=this._users.find((e=>e._uintid===i));if(!c)return void YN.error("[".concat(this._clientId,"] can not find target user!(on_add_data_channel)"));YN.debug("[".concat(this._clientId,"] data_channel added with uid ").concat(i)),Dn(r).call(r,c)||r.push(c),c._uintid||(c._uintid=i);if(!(-1!==c._dataChannels.findIndex((t=>t.id===e.stream_id)))){const e={id:n,ordered:!!o,maxRetransmits:s,metadata:a},i=function(e){return IV(e,!0)}(e);c._dataChannels.push(i),YN.info("[".concat(this._clientId,"] remote user ").concat(c.uid," published datachannel")),t||this.safeEmit(Gw.USER_PUBLISHED,c,"datachannel",e)}this._p2pChannel.hasPendingRemoteDataChannel(c,e.stream_id)&&(YN.debug("[".concat(this._clientId,"] resubscribe datachannel for user ").concat(c.uid," after reconnect.")),this._subscribeDataChannel(c,e.stream_id).catch((e=>{YN.error("[".concat(this._clientId,"] resubscribe datachannel error"),e.toString())})))})),t&&(this.safeEmit(Gw.PUBLISHED_USER_LIST,this._pendingPublishedUsers),this._pendingPublishedUsers=[]),Array.isArray(n)&&n.length>0&&n.forEach((e=>{const{uid:t,stream_id:i}=e,n=this._users.find((e=>e._uintid===t));if(!n)return void YN.error("[".concat(this._clientId,"] can not find target user!(on_delete_data_channel)"));const r=n._dataChannels.find((t=>t.id===e.stream_id));r&&(YN.debug("[".concat(this._clientId,"] data_stream delete with uid ").concat(t)),this._p2pChannel.unsubscribeDataChannel(n,[r]).then((e=>{if(n._dataChannels=n._dataChannels.filter((e=>e!==r)),e)return this._gateway.unsubscribeDataChannel(e,n.uid)})),YN.info("[".concat(this._clientId,"] remote user ").concat(t," unpublished datachannel ,id:").concat(r.id)),this.safeEmit(Gw.USER_UNPUBLISHED,n,"datachannel",r._
vendor: 5,693 bytes, line 12272
12272config))}))}_handleRemoveDataChannels(e){const t=this._users.find((t=>t.uid===e.uid));if(t){if(void 0!==t._dataChannels&&t._dataChannels.length>0){YN.debug("[".concat(this._clientId,"] datachannel removed with uid ").concat(e.uid));const i=()=>{YN.info("[".concat(this._clientId,"] remote user ").concat(t.uid," unpublished datachannel")),t._dataChannels.forEach((e=>{this.safeEmit(Gw.USER_UNPUBLISHED,t,"datachannel",e._config)}))};this._p2pChannel.unsubscribeDataChannel(t,t._dataChannels).then((e=>{if(e)return this._gateway.unsubscribeDataChannel(e,t.uid)})),i()}}else YN.warning("[".concat(this._clientId,"] can not find target user!(on_remove_datachannel)"))}_handleGatewayEvents(){this._gateway.on(LU.UPDATE_GATEWAY_CONFIG,(()=>{!function(){let e;try{e=window.localStorage.getItem("websdk_ng_global_parameter")}catch(e){return void YN.error("Error loading sdk config",e.message)}if(e)try{const t=JSON.parse(window.atob(e)),i=Date.now();Object.keys(t).forEach((e=>{const{value:n,type:r,expires:o}=t[e];o&&o<=i||r||RM()||!Object.prototype.hasOwnProperty.call(cN,e)||(mN[e]=n,hN[e]=n,YN.debug("Update gateway parameters from config distribute",e,n))}))}catch(e){YN.error("Error update config from local cache",e.message)}}()})),this._gateway.on(LU.DISCONNECT_P2P,(async()=>{await this._p2pChannel.disconnectForReconnect()})),this._gateway.on(LU.CONNECTION_STATE_CHANGE,((e,t,i)=>{var n;if(i===Vw.FALLBACK)return;const r=()=>{this.safeEmit(Gw.CONNECTION_STATE_CHANGE,e,t,i)};if(eD.reportApiInvoke(this._sessionId||(null===(n=this._gateway.joinInfo)||void 0===n?void 0:n.sid)||null,{name:kw.CONNECTION_STATE_CHANGE,options:[e,t,i],tag:Mw.TRACER}).onSuccess(JSON.stringify({cur:e,prev:t,reason:i})),YN.info("[".concat(this._clientId,"] signal connection state change: ").concat(t," -> ").concat(e)),"DISCONNECTED"===e)return this._reset(),void r();if("RECONNECTING"===e)this._users.forEach((e=>{e._trust_in_room_=!1,e._trust_audio_enabled_state_=!1,e._trust_video_enabled_state_=!1,e._trust_audio_mute_state_=!1,e._trust_video_mute_state_=!1,e._trust_audio_stream_added_state_=!1,e._trust_video_stream_added_state_=!1,e._is_pre_created||(e._audio_pre_subscribed||(e._audioSSRC=void 0,e._audioOrtc=void 0),e._video_pre_subscribed||(e._videoSSRC=void 0,e._videoOrtc=void 0,e._rtxSsrcId=void 0),e._cname=void 0)})),this._userOfflineTimeout&&window.clearTimeout(this._userOfflineTimeout),this._streamRemovedTimeout&&window.clearTimeout(this._streamRemovedTimeout),this._userOfflineTimeout=void 0,this._streamRemovedTimeout=void 0;else if("CONNECTED"===e){var o;this._streamFallbackTypeCacheMap.forEach(((e,t)=>{this._gateway.setStreamFallbackOption(t,e).catch((e=>{YN.warning("[".concat(this._clientId,"] auto set stream fallback option failed"),e)}))})),this._remoteStreamTypeCacheMap.forEach(((e,t)=>{this._gateway.setRemoteVideoStreamType(t,e).catch((e=>{YN.warning("[".concat(this._clientId,"] auto set remote stream type failed"),e)}))})),void 0!==this._remoteDefaultVideoStreamType&&void 0===(null===(o=this._joinInfo)||void 0===o?void 0:o.defaultVideoStream)&&this.setRemoteDefaultVideoStreamType(this._remoteDefaultVideoStreamType).then((()=>{YN.debug("[".concat(this._clientId,"] setRemoteDefaultVideoStreamType after gateway connected"))})).catch((e=>{YN.error("[".concat(this._clientId,"] setRemoteDefaultVideoStreamType after gateway failed, ").concat(e))})),this.store.useP2P||(this._p2pChannel.republish(),this._userOfflineTimeout=window.setTimeout((()=>{if("CONNECTED"!==this.connectionState)return;this._userOfflineTimeout=void 0;this._users.filter((e=>!e._trust_in_room_)).forEach((e=>{YN.debug("[".concat(this._clientId,"] user offline timeout, emit user offline ").concat(e.uid)),this._handleUserOffline({uid:e.uid})}))}),3e3),this._streamRemovedTimeout=window.setTimeout((()=>{"CONNECTED"===this.connectionState&&(this._streamRemovedTimeout=void 0,this._users.forEach((e=>{e._trust_audio_mute_state_||(YN.debug("[".concat(this._clientId,"] auto dispatch audio unmute event ").concat(e.uid)),this._handleMuteStream(e.uid,HU.AUDIO,!1)),e._trust_video_mute_state_||(YN.debug("[".concat(this._clientId,"] auto dispatch video unmute event ").concat(e.uid)),this._handleMuteStream(e.uid,HU.VIDEO,!1)),e._trust_audio_enabled_state_||(YN.debug("[".concat(this._clientId,"] auto dispatch enable local audio ").concat(e.uid)),this._handleSetStreamLocalEnable("audio",e.uid,!0)),e._trust_video_enabled_state_||(YN.debug("[".concat(this._clientId,"] auto dispatch enable local video ").concat(e.uid)),this._handleSetStreamLocalEnable("video",e.uid,!0)),e._trust_video_stream_added_state_||(YN.debug("[".concat(this._clientId,"] auto dispatch reset video stream added ").concat(e.uid)),this._handleResetAddStream(e,"video")),e._trust_audio_stream_added_state_||(YN.debug("[".concat(this._clientId,"] auto dispatch reset audio stream added ").concat(e.uid)),this._handleResetAddStream(e,"audio")),e._video_added_||e._audio_added_||(YN.debug("[".concat(this._clientId,"] auto dispatch stream remove ").concat(e.uid)),this._handleRemoveStream({uid:e.uid,uint_id:e._uintid}))})))}),1e3))}r()})),this._gateway.on(LU.REQUEST_NEW_GATEWAY_LIST,(async(e,t)=>{if(!this._joinInfo)return t(new tD(Ew.UNEXPECTED_ERROR,"can not recover, no join info"));try{let t;const i=await rj(UG(UG({},this._joinInfo),{},{uid:this._joinInfo.uid,stringUid:void 0}));i?(t=i.ap,cj(i),this._joinInfo.preload=!0):(t=await rF(this._joinInfo,this._axiosCancelSource.token,this._config.httpRetryConfig||AO,this.store),this._joinInfo.preload=!1),this._joinInfo&&(this._joinInfo.apResponse=t.gatewayInfo.res,this._joinInfo.gatewayAddrs=t.gatewayInfo.gatewayAddrs,this._joinInfo.uni_lbs_ip=t.gatewayInfo.uni_lbs_ip);const n=[];
12272t.gatewayInfo.gatewayAddrs.forEach((e=>{let{address:t}=e;const[i,r]=t.split(":");this._joinInfo&&this._joinInfo.proxyServer?n.push({proxy:this._joinInfo.proxyServer,host:i,port:r}):n.push({host:i,port:r})})),e(n)}catch(e){t(e)}})),this._gateway.on(LU.NETWORK_QUALITY,(e=>{"normal"===this._networkQualitySensitivity&&this.safeEmit(Gw.NETWORK_QUALITY,e)})),this._gateway.on(LU.STREAM_TYPE_CHANGE,((e,t)=>{this.safeEmit(Gw.STREAM_TYPE_CHANGED,e,t);eD.reportApiInvoke(this._sessionId,{name:kw.STREAM_TYPE_CHANGE,options:[e,t],tag:Mw.TRACER}).onSuccess(JSON.stringify({uid:e,streamType:t}))})),this._gateway.on(LU.IS_P2P_DISCONNECTED,(e=>{this._p2pChannel.isP2PDisconnected()?e(!0):this._p2pChannel.hasLocalMedia()||this._p2pChannel.hasRemoteMedia()?e(!1):e(!0)})),this._gateway.on(LU.REQUEST_P2P_CONNECTION_PARAMS,(async(e,t,i)=>{try{let i=await this._p2pChannel.getEstablishParams();_N("ENABLE_PREALLOC_PC")&&i||(i=await this._p2pChannel.startP2PConnection(e)),t(i)}catch(e){i(e)}})),this._gateway.on(LU.JOIN_RESPONSE,((e,t)=>{if(this.store.useP2P)return;let i;e.attributes?i=e.attributes.userAttributes.preSubSsrcs:YN.debug("no attributes in joinResponse");const n=Qx(e.ortc,t,i);this._p2pChannel.connect(n)})),this._gateway.on(LU.PRE_CONNECT_PC,(async e=>{const{candidates:t,fingerprint:i}=e;if(this._joinInfo&&t.length>0&&!this._p2pChannel.isPlanB){var n;await this._p2pChannel.startP2PConnection({turnServer:this._joinInfo.turnServer});const{cert:e,cid:r}=this._joinInfo.apResponse;await this._p2pChannel.connect({iceParameters:{iceUfrag:"".concat(r,"_").concat(e),icePwd:"".concat(r,"_").concat(e)},dtlsParameters:{fingerprints:[{hashFunction:"sha-256",fingerprint:null!==(n=_N("FINGERPRINT"))&&void 0!==n?n:i}]},candidates:t,rtpCapabilities:{send:{audioCodecs:[],videoCodecs:[],audioExtensions:[],videoExtensions:[]},recv:{audioCodecs:[],videoCodecs:[],audioExtensions:[],videoExtensions:[]}},setup:"active",cname:"o/i14u9pJrxRKAsu",preallocation:!0})}}))}_handleGatewaySignalEvents(){this._gateway.signal.on(_U.ON_USER_ONLINE,this._handleUserOnline),this._gateway.signal.on(_U.ON_USER_OFFLINE,this._handleUserOffline),this._gateway.signal.on(_U.ON_ADD_AUDIO_STREAM,(e=>this._handleAddAudioOrVideoStream("audio",e.uid,e.ssrcId,e.cname,e.uint_id,e.ortc))),this._gateway.signal.on(_U.ON_ADD_VIDEO_STREAM,(e=>this._handleAddAudioOrVideoStream("video",e.uid,e.ssrcId,e.cname,e.uint_id,e.ortc,e.rtxSsrcId))),this._gateway.signal.on(_U.ON_REMOTE_DATASTREAM_UPDATE,(e=>{this._handleUpdateDataChannel(e)})),this._gateway.signal.on(_U.ON_REMOTE_FULL_DATASTREAM_INFO,(e=>{this._handleUpdateDataChannel({added:e.datastreams||[],deleted:[]},!0)})),this._gateway.signal.on(_U.ON_REMOVE_STREAM,this._handleRemoveStream),this._gateway.signal.on(_U.ON_P2P_LOST,this._handleP2PLost),this._gateway.signal.on(_U.MUTE_AUDIO,(e=>this._handleMuteStream(e.uid,HU.AUDIO,!0))),this._gateway.signal.on(_U.UNMUTE_AUDIO,(e=>this._handleMuteStream(e.uid,HU.AUDIO,!1))),this._gateway.signal.on(_U.MUTE_VIDEO,(e=>this._handleMuteStream(e.uid,HU.VIDEO,!0))),this._gateway.signal.on(_U.UNMUTE_VIDEO,(e=>this._handleMuteStream(e.uid,HU.VIDEO,!1))),this._gateway.signal.on(_U.RECEIVE_METADATA,(e=>{const t=rO(e.metadata);this.safeEmit(Gw.RECEIVE_METADATA,e.uid,t)})),this._gateway.signal.on(_U.ON_DATA_STREAM,(async e=>{var t;if(!e)return;let i=rO(e.payload);if(this._encryptDataStream&&this._encryptDataStreamIv&&this._encryptDataStreamKey&&window.crypto.subtle&&Dn(t=["aes-128-gcm2","aes-256-gcm2"]).call(t,this._encryptionMode)){if(e.payload.length<vN)throw new tD(Ew.UNEXPECTED_RESPONSE,"payload length ".concat(e.payload.length," is less than header length ").concat(vN));const t=await async function(e,t,i){const n=i.subarray(0,vN),r=n.slice(8,vN),o=(r[0]<<8)+r[1],s=(n[6]<<8)+n[7],a=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:e,tagLength:SN,additionalData:new Uint8Array(SO(o,2))},t,i.subarray(vN));return new Uint8Array(a).subarray(0,s)}(this._encryptDataStreamIv,this._encryptDataStreamKey,i);i=t}let n=0;if(e.ordered||e.syncWithAudio){const t=this._p2pChannel.getStats(),i=this.remoteUsers.find((t=>t.uid===e.uid)),r=null==t?void 0:t.audioRecv.find((e=>e.ssrc===(null==i?void 0:i._audioSSRC)));n=null==r?void 0:r.jitterBufferMs}(null==n||Number.isNaN(n))&&(n=0),GB(UG(UG({},e),{},{payload:i}),n,{id:this._clientId,onStreamMessage:"function"==typeof this.onStreamMessage?this.onStreamMessage.bind(this):void 0,safeEmit:this.safeEmit.bind(this)})})),this._gateway.signal.on(_U.ON_CRYPT_ERROR,(()=>{nO((()=>{YN.warning("[".concat(this._clientId,"] on crypt error")),this.safeEmit(Gw.CRYPT_ERROR)}),this._sessionId)})),this._gateway.signal.on(_U.ON_TOKEN_PRIVILEGE_WILL_EXPIRE,this._handleTokenWillExpire),this._gateway.signal.on(_U.ON_TOKEN_PRIVILEGE_DID_EXPIRE,(()=>{YN.warning("[".concat(this._clientId,"] received message onTokenPrivilegeDidExpire, please get new token and join again")),this._gateway.leave(!0,Vw.TOKEN_EXPIRE),this.safeEmit(Gw.ON_TOKEN_PRIVILEGE_DID_EXPIRE),this._reset()})),this._gateway.signal.on(_U.ON_STREAM_FALLBACK_UPDATE,(e=>{YN.debug("[".concat(this._clientId,"] stream fallback peerId: ").concat(e.stream_id,", attr: ").concat(e.stream_type)),this.safeEmit(Gw.STREAM_FALLBACK,e.stream_id,1===e.stream_type?"fallback":"recover")})),this._gateway.signal.on(_U.ON_PUBLISH_STREAM,(e=>{this.uid===this._uid&&(this._p2pChannel.reportPublishEvent(!0,null,void 0,!1,JSON.stringify({proxy:e.proxy})),YN.info("[".concat(this._clientId,"] on publish stream, ").concat(JSON.stringify(e))))})),this._gateway.signal.on(_U.ENABLE_LOCAL_VIDEO,(e=>{this._handleSetStreamLocalEnable("video",e.uid,!0)})),this._gateway.signal.on(_U.DISABLE_LOCAL_VIDEO,(e=>{this._handleSetStreamLocalEnable("video",e.uid,!1)})),this._gateway.signal.on(uU.REQUEST_TIMEOUT,((e,t)=>
12272{if(this._joinInfo)switch(e){case hU.PUBLISH:{if(!t)return;const e=t.ortc;if(e){var i,n;const r=e.some((e=>{let{stream_type:t}=e;return t===PU.Audio})),o=e.some((e=>{let{stream_type:t}=e;return t!==PU.Audio})),s=e.some((e=>{let{stream_type:t}=e;return t===PU.Screen||t===PU.ScreenLow}));"offer"===t.state&&eD.publish(this._joinInfo.sid,{eventElapse:TF.measureFromPublishStart(this.store.clientId,this.store.pubId),succ:!1,ec:Ew.TIMEOUT,audio:r,video:o,p2pid:t.p2p_id,publishRequestid:this.store.pubId,screenshare:s,audioName:r?null===(i=e.find((e=>{let{stream_type:t}=e;return t===PU.Audio})))||void 0===i||null===(i=i.ssrcs[0])||void 0===i?void 0:i.ssrcId.toString():void 0,videoName:o?null===(n=e.find((e=>{let{stream_type:t}=e;return t!==PU.Audio})))||void 0===n||null===(n=n.ssrcs[0])||void 0===n?void 0:n.ssrcId.toString():void 0})}break}case hU.SUBSCRIBE:t&&eD.subscribe(this._joinInfo.sid,{succ:!1,ec:Ew.TIMEOUT,audio:t.stream_type===HU.AUDIO,video:t.stream_type===HU.VIDEO,peerid:t.stream_id,subscribeRequestid:t.ssrcId,p2pid:this.store.p2pId,eventElapse:TF.measureFromSubscribeStart(this.store.clientId,t.ssrcId),preSsrc:this._p2pChannel.isPreSubScribe(t.ssrcId)})}})),this._gateway.signal.on(_U.ON_P2P_OK,(e=>{this.uid,this._uid})),this._gateway.signal.on(_U.ON_PUBLISHED_USER_LIST,(e=>{if(null==e||!e.users)return;_N("BLOCK_LOCAL_CLIENT")&&(e.users=e.users.filter((e=>!gM(e.string_id||e.stream_id,this.channelName))));const t=[],i=[];for(const n of e.users){let e=this._users.find((e=>e._uintid===n.stream_id));e?e._trust_in_room_=!0:(e=new IF(n.string_id||n.stream_id,n.stream_id),this._users.push(e),0===this.getListeners(Gw.PUBLISHED_USER_LIST).length&&(YN.debug("[".concat(this._clientId,"] user online"),n.stream_id),this.safeEmit(Gw.USER_JOINED,e)));const r=MU.Audio&n.stream_type,o=(MU.Video|MU.LwoVideo)&n.stream_type,s=0!=(65280&n.stream_type),a=r&&e.hasAudio,c=o&&e.hasVideo;o&&(e._trust_video_stream_added_state_=!0,e._video_added_=!0,e._videoSSRC=n.video_ssrc,e._rtxSsrcId=n.video_rtx),r&&(e._trust_audio_stream_added_state_=!0,e._audio_added_=!0,e._audioSSRC=n.audio_ssrc),r&&!a&&0===this.getListeners(Gw.PUBLISHED_USER_LIST).length&&(YN.info("[".concat(this._clientId,"] remote user ").concat(e.uid," published audio")),this.safeEmit(Gw.USER_PUBLISHED,e,"audio")),o&&!c&&0===this.getListeners(Gw.PUBLISHED_USER_LIST).length&&(YN.info("[".concat(this._clientId,"] remote user ").concat(e.uid," published video")),this.safeEmit(Gw.USER_PUBLISHED,e,"video")),(r&&!a||o&&!c||s)&&t.push(e),o&&this._p2pChannel.hasPendingRemoteMedia(e,"video")&&i.push({user:e,mediaType:"video"}),r&&this._p2pChannel.hasPendingRemoteMedia(e,"audio")&&i.push({user:e,mediaType:"audio"})}i.length>0&&(YN.debug("[".concat(this._clientId,"] RE massSubscribe after reconnect ").concat(i.map((e=>"user: ".concat(e.user.uid,", mediaType: ").concat(e.mediaType))).join("; ")," ")),this.massSubscribe(i).catch((e=>{YN.error("[".concat(this._clientId,"] mass resubscribe error"),e.toString())}))),this.getListeners(Gw.PUBLISHED_USER_LIST).length>0?_N("ENABLE_DATASTREAM_2")?this._pendingPublishedUsers=t:(YN.info("[".concat(this._clientId,"] client emit user-list event, users: ").concat(t.map((e=>e.uid)).join(", "))),this.safeEmit(Gw.PUBLISHED_USER_LIST,t)):YN.info("[".concat(this._clientId,"] client not emit user-list event case there is no user-list listener, users: ").concat(t.map((e=>e.uid)).join(", ")))})),this._gateway.signal.on(_U.ON_RTP_CAPABILITY_CHANGE,(e=>{const{video_codec:t}=e;this._p2pChannel instanceof PB&&this._p2pChannel.updateRemoteRTPCapabilities(t.map((e=>e.toLowerCase())).filter((e=>{var t;return Dn(t=Object.keys(TN)).call(t,e)})))}))}_handleP2PEvents(){this._gateway.signal.on(_U.ON_USER_OFFLINE,(()=>{this._p2pChannel.disconnectForReconnect()})),this._gateway.signal.on(ox.PUBLISH,((e,t,i)=>{const{uid:n}=e;e.forEach((e=>{const{kind:r,ssrcs:o,mid:s,isMuted:a}=e;this._handleP2PAddAudioOrVideoStream(r,n,o[0].ssrcId,s);const c=this._users.find((e=>e.uid===n));return c&&this.store.useP2P?this._p2pChannel.mockSubscribe(c,r,o[0].ssrcId,s).then((()=>{t()})).catch(i):t(),this._handleMuteStream(n,r,!!a)}))})),this._gateway.signal.on(ox.CALL,(async(e,t,i)=>{if(this.store.useP2P)try{var n;t(await this._p2pChannel.startP2P({turnServer:null===(n=this._joinInfo)||void 0===n?void 0:n.turnServer},e))}catch(e){i(e)}})),this._gateway.signal.on(uU.P2P_CONNECTION,(async e=>{this.store.useP2P&&(await this._p2pChannel).p2pConnect(e)})),this._gateway.signal.on(ox.UNPUBLISH,(async(e,t,i)=>{if(this.store.useP2P){const{unpubMsg:n,uid:r}=e,o=this._users.find((e=>e.uid===r));if(!o)return YN.warning("[".concat(this._clientId,"] can not find remote user, ignore mute event, uid: ").concat(r)),void t();
12272try{n.forEach((async e=>{let{stream_type:t}=e;const i=t===PU.Audio?HU.AUDIO:HU.VIDEO;await this._p2pChannel.unsubscribe(o,i),this._handleMuteStream(r,i,!0)})),t()}catch(e){i(e)}}})),this._gateway.signal.on(ox.CONTROL,(async(e,t)=>{const{action:i}=e;switch(i){case ax.MUTE_LOCAL_VIDEO:this._handleMuteStream(t,HU.VIDEO,!0);break;case ax.MUTE_LOCAL_AUDIO:this._handleMuteStream(t,HU.AUDIO,!0);break;case ax.UNMUTE_LOCAL_VIDEO:this._handleP2PAddAudioOrVideoStream("video",t),this._handleMuteStream(t,HU.VIDEO,!1);break;case ax.UNMUTE_LOCAL_AUDIO:this._handleP2PAddAudioOrVideoStream("audio",t),this._handleMuteStream(t,HU.AUDIO,!1)}})),this._gateway.signal.on(ox.RESTART_ICE,(async(e,t,i)=>{if(this.store.useP2P)try{const{direction:i,iceParameter:n}=e;if(i!==EU.SEND_ONLY||n){t(await this._p2pChannel.restartICE(i,n))}else this._p2pChannel.handleDisconnect(i),t()}catch(e){i(e)}})),this._gateway.signal.on(ox.CANDIDATE,(e=>{if(this.store.useP2P){const{candidate:t,direction:i}=e;this._p2pChannel.addRemoteCandidate(t,i)}})),this._p2pChannel.on(JU.RequestP2PRestartICE,(async(e,t,i)=>{try{const{direction:i}=e;t(await this._gateway.sendExtensionMessage(ox.RESTART_ICE,e,i===EU.SEND_ONLY))}catch(e){i(e)}})),this._p2pChannel.on(JU.LocalCandidate,(e=>{this._gateway.sendExtensionMessage(ox.CANDIDATE,JSON.stringify(e),!0)})),this._p2pChannel.on(JU.RequestP2PMuteLocal,(async(e,t,i)=>{try{await this._gateway.sendExtensionMessage(ox.CONTROL,e,!0),t()}catch(e){i(e)}})),this._p2pChannel.on(JU.RequestP2PUnmuteRemote,(async(e,t,i)=>{if(this._joinInfo)try{await this._gateway.unmuteRemote(e,this._joinInfo.stringUid||this._joinInfo.uid),t()}catch(e){e.code===Ew.DISCONNECT_P2P?t():i(e)}else t()})),this._p2pChannel.on(JU.RequestP2PMuteRemote,(async(e,t,i)=>{if(this._joinInfo)try{await this._gateway.muteRemote(e,this._joinInfo.stringUid||this._joinInfo.uid),t()}catch(e){e.code===Ew.DISCONNECT_P2P?t():i(e)}else t()})),this._p2pChannel.on(JU.StateChange,((e,t)=>
12272{t===XU.Connected&&this._p2pChannel.republish()}))}_handleP2PChannelEvents(){this._p2pChannel.on(JU.PeerConnectionStateChange,(e=>{const t=this._peerConnectionState;e!==t&&(this.safeEmit(Gw.PEERCONNECTION_STATE_CHANGE,e,t),this._peerConnectionState=e)})),this._p2pChannel.on(JU.RequestMuteLocal,(async(e,t,i)=>{if(this._joinInfo)try{await this._gateway.muteLocal(e,this._joinInfo.stringUid||this._joinInfo.uid),t()}catch(e){e.code===Ew.DISCONNECT_P2P?t():i(e)}else t()})),this._p2pChannel.on(JU.RequestUnmuteLocal,(async(e,t,i)=>{if(this._joinInfo)try{await this._gateway.unmuteLocal(e,this._joinInfo.stringUid||this._joinInfo.uid),t()}catch(e){e.code===Ew.DISCONNECT_P2P?t():i(e)}else t()})),this._p2pChannel.on(JU.RequestRePublish,((e,t,i)=>{this.publish(e,!1).then(t).catch(i)})),this._p2pChannel.on(JU.RequestRePublishDataChannel,((e,t,i)=>{Wh.all(e.map((async e=>{const t=await this._p2pChannel.publishDataChannel([e]);try{t.forEach((e=>{this._uid&&this._gateway.publishDataChannel(this._uid,e,!0)}))}catch(e){if(e.code!==Ew.DISCONNECT_P2P)throw e}}))).then(t).catch(i)})),this._p2pChannel.on(JU.RequestReSubscribe,(async(e,t,i)=>{try{for(const{user:t,kind:i}of e)i===HU.VIDEO?await this.subscribe(t,"video"):await this.subscribe(t,"audio");t()}catch(e){i(e)}})),this._p2pChannel.on(JU.RequestUpload,((e,t)=>{this._gateway.upload(e,t)})),this._p2pChannel.on(JU.RequestUploadStats,(e=>{this._gateway.uploadWRTCStats(e)})),this._p2pChannel.on(JU.MediaReconnectStart,(e=>{this.safeEmit(Gw.MEDIA_RECONNECT_START,e)})),this._p2pChannel.on(JU.MediaReconnectEnd,(e=>{this.safeEmit(Gw.MEDIA_RECONNECT_END,e)})),this._p2pChannel.on(JU.NeedSignalRTT,(e=>{e(this._gateway.getSignalRTT())})),this._p2pChannel.on(JU.RequestRestartICE,(async e=>{if(this.store.useP2P)return;const t=await this._p2pChannel.restartICE(e),i=await t.next();if(i.done)return;const n=i.value;let r;try{r=await this._gateway.restartICE({iceParameters:n})}catch(e){return void t.throw(e)}const{iceParameters:o}=function(e){const t=e.iceParameters;return{iceParameters:{iceUfrag:t.iceUfrag,icePwd:t.icePwd}}}(r);await t.next({remoteIceParameters:o})})),this._p2pChannel.on(JU.RequestReconnect,(async()=>{this._gateway.reconnect()})),this._p2pChannel.on(JU.RequestReconnectPC,(async()=>{var e;const{iceParameters:t,dtlsParameters:i,rtpCapabilities:n}=await this._p2pChannel.startP2PConnection({turnServer:null===(e=this._joinInfo)||void 0===e?void 0:e.turnServer}),{gatewayEstablishParams:r,gatewayAddress:o}=await this._gateway.reconnectPC({iceParameters:t,dtlsParameters:i,rtpCapabilities:n}),s=Qx(r,o);await this._p2pChannel.connect(s),await this._p2pChannel.republish(),await this._p2pChannel.reSubscribe()})),this._p2pChannel.on(JU.RequestUnpublishForReconnectPC,(async(e,t,i)=>{this._joinInfo&&void 0!==this._uid?(await this._gateway.unpublish(e,this._uid),t()):i()})),this._p2pChannel.on(JU.P2PLost,(()=>{this.safeEmit(Gw.P2P_LOST,this.store.uid)})),this._p2pChannel.on(JU.UpdateVideoEncoder,(e=>{e._encoderConfig&&this._gateway.setVideoProfile(e._encoderConfig)})),this._p2pChannel.on(JU.ConnectionTypeChange,(e=>{this.safeEmit(Gw.IS_USING_CLOUD_PROXY,e)})),this._p2pChannel.on(JU.RequestLowStreamParameter,(e=>{e(this._lowStreamParameter||{width:160,height:120,framerate:15,bitrate:50})})),this._p2pChannel.on(JU.QueryClientConnectionState,(e=>{e(this.connectionState)})),this._p2pChannel.on(JU.AudioMetadata,(e=>{this.safeEmit(Gw.AUDIO_METADATA,e)}))}getKeyMetrics(){return this.store.keyMetrics}async enableContentInspect(e){if(!this._joinInfo||"CONNECTED"!==this.connectionState)throw new tD(Ew.INVALID_OPERATION,"[".concat(this._clientId,"] can not create content inspect, please join channel first"));if(this._inspect)throw new tD(Ew.INVALID_OPERATION,"[".concat(this._clientId,"] Inspect content service already in connecting/connected state"));try{const i=(t={config:e},CV("ContentInspect").create(t));this._inspect=i,this.handleVideoInspectEvents(i);const{appId:n,cname:r,sid:o,token:s,uid:a,cid:c,vid:d}=this._joinInfo;await i.init({appId:n,areaCode:"",cname:r,sid:o,token:s,uid:a,cid:c,vid:d?Number(d):0},AO)}catch(e){throw Array.isArray(e)?e[0]:e}var t}handleVideoInspectEvents(e){e.on($U.CONNECTION_STATE_CHANGE,((t,i)=>{if(this.safeEmit(Gw.CONTENT_INSPECT_CONNECTION_STATE_CHANGE,t,i),i===QU.CONNECTED){if("CONNECTED"!==this.connectionState)return void this.safeEmit(Gw.CONTENT_INSPECT_ERROR,new tD(Ew.OPERATION_ABORTED,"Content inspect was cancelled because it left the channel"));e.inspectImage()}})),e.on($U.INSPECT_RESULT,((e,t)=>
vendor: 12,352 bytes, line 12272
12272{var i;if((null==t?void 0:t.code)===Ew.INVALID_OPERATION&&"DISCONNECTED"===this.connectionState)return YN.debug("Stop inspect content because that has left channel"),null==this||null===(i=this._inspect)||void 0===i||i.close(),void(this._inspect=void 0);this.safeEmit(Gw.CONTENT_INSPECT_RESULT,e,t)})),e.on($U.CLIENT_LOCAL_VIDEO_TRACK,(e=>{e(this.localTracks.filter((e=>"video"===e.trackMediaType))[0])}))}async disableContentInspect(){if(!this._inspect)throw new tD(Ew.INVALID_OPERATION,"[".concat(this._clientId,"] inspectVideoContent not started"));try{this._inspect.close(),this._inspect=void 0}catch(e){throw Array.isArray(e)?e[0]:e}}async setImageModeration(e,t){if(fw(e,"enabled"),e){if(!t)throw new tD(Ew.INVALID_PARAMS,"config is required");if(Kj(t),!this._joinInfo)throw new tD(Ew.INVALID_OPERATION,"can not create image moderation, please join channel first");try{if(this._moderation)this._moderation.updateConfig(t);else{const e=(i={config:t},CV("ImageModeration").create(i));this._moderation=e,this.handleImageModerationEvents(e);const{appId:n,cname:r,sid:o,token:s,uid:a,cid:c,vid:d}=this._joinInfo;await e.init({appId:n,areaCode:"",cname:r,sid:o,token:s,uid:a,cid:c,vid:d?Number(d):0},AO)}}catch(e){throw Array.isArray(e)?e[0]:e}}else{var i;if(!this._moderation)throw new tD(Ew.INVALID_OPERATION,"[".concat(this._clientId,"] image moderation not started"));try{this._moderation.close(),this._moderation.removeAllListeners(),this._moderation=void 0}catch(e){throw Array.isArray(e)?e[0]:e}}}handleImageModerationEvents(e){e.on(nx.CONNECTION_STATE_CHANGE,((t,i)=>{if(this.safeEmit(Gw.IMAGE_MODERATION_CONNECTION_STATE_CHANGE,t,i),t===ix.CONNECTED){if("CONNECTED"!==this.connectionState)throw this.setImageModeration(!1),new tD(Ew.OPERATION_ABORTED,"Image moderation was cancelled because it left the channel");e.inspectImage()}})),e.on(nx.CLIENT_LOCAL_VIDEO_TRACK,(e=>{e(this.localTracks.filter((e=>"video"===e.trackMediaType))[0])}))}setP2PTransport(e){if(function(e){Tw(e,"transport",["default","auto","relay","sd-rtn"])}(e),"p2p"!==this.mode)throw new tD(Ew.INVALID_OPERATION,"only p2p mode can set p2pTransport");this.store.p2pTransport=e,YN.info("[".concat(this._clientId,"] set client p2pTransport to ").concat(e))}getJoinChannelServiceRecords(){return YN.debug("getJoinChannelServiceRecords"),this.store.joinChannelServiceRecords}async setPublishAudioFilterEnabled(e){fw(e,"enabled"),pN("ENABLE_PUBLISH_AUDIO_FILTER",e),this._joinInfo&&await this._gateway.setPublishAudioFilterEnabled(e)}_handleResetAddStream(e,t){switch(t){case"audio":e._audio_added_=!1,e._trust_audio_stream_added_state_=!0;break;case"video":e._video_added_=!1,e._trust_video_stream_added_state_=!0}}},rU(kG.prototype,"leave",[qj],Object.getOwnPropertyDescriptor(kG.prototype,"leave"),kG.prototype),rU(kG.prototype,"publish",[zj],Object.getOwnPropertyDescriptor(kG.prototype,"publish"),kG.prototype),rU(kG.prototype,"unpublish",[Xj],Object.getOwnPropertyDescriptor(kG.prototype,"unpublish"),kG.prototype),rU(kG.prototype,"subscribe",[Jj],Object.getOwnPropertyDescriptor(kG.prototype,"subscribe"),kG.prototype),rU(kG.prototype,"presubscribe",[Qj],Object.getOwnPropertyDescriptor(kG.prototype,"presubscribe"),kG.prototype),rU(kG.prototype,"massSubscribe",[Zj],Object.getOwnPropertyDescriptor(kG.prototype,"massSubscribe"),kG.prototype),rU(kG.prototype,"unsubscribe",[$j],Object.getOwnPropertyDescriptor(kG.prototype,"unsubscribe"),kG.prototype),rU(kG.prototype,"massUnsubscribe",[eG],Object.getOwnPropertyDescriptor(kG.prototype,"massUnsubscribe"),kG.prototype),rU(kG.prototype,"setLowStreamParameter",[tG],Object.getOwnPropertyDescriptor(kG.prototype,"setLowStreamParameter"),kG.prototype),rU(kG.prototype,"enableDualStream",[iG],Object.getOwnPropertyDescriptor(kG.prototype,"enableDualStream"),kG.prototype),rU(kG.prototype,"disableDualStream",[nG],Object.getOwnPropertyDescriptor(kG.prototype,"disableDualStream"),kG.prototype),rU(kG.prototype,"setClientRole",[rG],Object.getOwnPropertyDescriptor(kG.prototype,"setClientRole"),kG.prototype),rU(kG.prototype,"_setClientRoleOptions",[oG],Object.getOwnPropertyDescriptor(kG.prototype,"_setClientRoleOptions"),kG.prototype),rU(kG.prototype,"setProxyServer",[sG],Object.getOwnPropertyDescriptor(kG.prototype,"setProxyServer"),kG.prototype),rU(kG.prototype,"setTurnServer",[aG],Object.getOwnPropertyDescriptor(kG.prototype,"setTurnServer"),kG.prototype),rU(kG.prototype,"setLicense",[cG],Object.getOwnPropertyDescriptor(kG.prototype,"setLicense"),kG.prototype),rU(kG.prototype,"startProxyServer",[dG],Object.getOwnPropertyDescriptor(kG.prototype,"startProxyServer"),kG.prototype),rU(kG.prototype,"stopProxyServer",[lG],Object.getOwnPropertyDescriptor(kG.prototype,"stopProxyServer"),kG.prototype),rU(kG.prototype,"setLocalAccessPointsV2",[uG],Object.getOwnPropertyDescriptor(kG.prototype,"setLocalAccessPointsV2"),kG.prototype),rU(kG.prototype,"setLocalAccessPoints",[hG],Object.getOwnPropertyDescriptor(kG.prototype,"setLocalAccessPoints"),kG.prototype),rU(kG.prototype,"setRemoteDefaultVideoStreamType",[pG],Object.getOwnPropertyDescriptor(kG.prototype,"setRemoteDefaultVideoStreamType"),kG.prototype),rU(kG.prototype,"setRemoteVideoStreamType",[_G],Object.getOwnPropertyDescriptor(kG.prototype,"setRemoteVideoStreamType"),kG.prototype),rU(kG.prototype,"setStreamFallbackOption",[EG],Object.getOwnPropertyDescriptor(kG.prototype,"setStreamFallbackOption"),kG.prototype),rU(kG.prototype,"setEncryptionConfig",[mG],Object.getOwnPropertyDescriptor(kG.prototype,"setEncryptionConfig"),kG.prototype),rU(kG.prototype,"renewToken",[fG],Object.getOwnPropertyDescriptor(kG.prototype,"renewToken"),kG.prototype),rU(kG.prototype,"enableAudioVolumeIndicator",[TG],Object.getOwnPropertyDescriptor(kG.prototype,"enableAudioVolumeIndicator"),kG.prototype),rU(kG.prototype,"startLiveStreaming",[SG],Object.getOwnPropertyDescriptor(kG.prototype,"startLiveStreaming"),kG.prototype),rU(kG.prototype,"setLiveTranscoding",[gG],Object.getOwnPropertyDescriptor(kG.prototype,"setLiveTranscoding"),kG.prototype),rU(kG.prototype,"stopLiveStreaming",[RG],Object.getOwnPropertyDescriptor(kG.prototype,"stopLiveStreaming"),kG.prototype),rU(kG.prototype,"startChannelMediaRelay",[vG],Object.getOwnPropertyDescriptor(kG.prototype,"startChannelMediaRelay"),kG.prototype),rU(kG.prototype,"updateChannelMediaRelay",[CG],Object.getOwnPropertyDescriptor(kG.prototype,"updateChannelMediaRelay"),kG.prototype),rU(kG.prototype,"stopChannelMediaRelay",[IG],Object.getOwnPropertyDescriptor(kG.prototype,"stopChannelMediaRelay"),kG.prototype),rU(kG.prototype,"sendCustomReportMessage",[yG],Object.getOwnPropertyDescriptor(kG.prototype,"sendCustomReportMessage"),kG.prototype),rU(kG.prototype,"pickSVCLayer",[AG],Object.getOwnPropertyDescriptor(kG.prototype,"pickSVCLayer"),kG.prototype),rU(kG.prototype,"setRTMConfig",[bG],Object.getOwnPropertyDescriptor(kG.prototype,"setRTMConfig"),kG.prototype),rU(kG.prototype,"enableContentInspect",[wG],Object.getOwnPropertyDescriptor(kG.prototype,"enableContentInspect"),kG.prototype),rU(kG.prototype,"disableContentInspect",[OG],Object.getOwnPropertyDescriptor(kG.prototype,"disableContentInspect"),kG.prototype),rU(kG.prototype,"setImageModeration",[NG],Object.getOwnPropertyDescriptor(kG.prototype,"setImageModeration"),kG.prototype),rU(kG.prototype,"setP2PTransport",[DG],Object.getOwnPropertyDescriptor(kG.prototype,"setP2PTransport"),kG.prototype),rU(kG.prototype,"getJoinChannelServiceRecords",[PG],Object.getOwnPropertyDescriptor(kG.prototype,"getJoinChannelServiceRecords"),kG.prototype),rU(kG.prototype,"setPublishAudioFilterEnabled",[LG],Object.getOwnPropertyDescriptor(kG.prototype,"setPublishAudioFilterEnabled"),kG.prototype),kG);class VG{constructor(e,t){QI(this,"id",0),QI(this,"element",void 0),QI(this,"peerPair",void 0),QI(this,"context",void 0),QI(this,"audioPlayerElement",void 0),QI(this,"audioTrack",void 0),VG.count+=1,this.id=VG.count,this.element=e,this.context=t}initPeers(){this.peerPair=[new RTCPeerConnection,new RTCPeerConnection],this.peerPair[1].ontrack=e=>{const t=document.createElement("audio");t.srcObject=new MediaStream([e.track]),t.play(),this.audioPlayerElement=t}}async switchSdp(){if(!this.peerPair)return;const e=async(e,t)=>{const i="offer"===t?await e.createOffer():await e.createAnswer();return await e.setLocalDescription(i),"complete"===e.iceGatheringState?e.localDescription:new Wh((t=>{e.onicegatheringstatechange=()=>{"complete"===e.iceGatheringState&&t(e.localDescription)}}))},t=async(e,t)=>await e.setRemoteDescription(t);try{const i=await e(this.peerPair[0],"offer");await t(this.peerPair[1],i);const n=await e(this.peerPair[1],"answer");await t(this.peerPair[0],n)}catch(e){throw new tD(Ew.LOCAL_AEC_ERROR,e.toString()).print()}}async getTracksFromMediaElement(e){if(this.audioTrack)return this.audioTrack;let t;try{e instanceof HTMLVideoElement&&(e.captureStream?e.captureStream():e.mozCaptureStream()),t=this.context.createMediaStreamDestination();this.context.createMediaElementSource(e).connect(t)}catch(e){throw new tD(Ew.LOCAL_AEC_ERROR,e.toString()).print()}if(!t){throw new tD(Ew.LOCAL_AEC_ERROR,"no dest node when local aec").print()}const i=t.stream.getAudioTracks()[0];return this.audioTrack=i,i}getElement(){return this.element}async startEchoCancellation(){this.context.resume(),this.peerPair&&this.close(),this.initPeers();const e=this.element,t=await this.getTracksFromMediaElement(e);this.peerPair&&this.peerPair[0].addTrack(t),await this.switchSdp()}close(){YN.debug("close echo cancellation unit, id is",this.id),this.audioPlayerElement&&this.audioPlayerElement.pause(),this.peerPair&&this.peerPair.forEach((e=>{e.close()})),this.peerPair=void 0,this.audioPlayerElement=void 0}}var FG,BG;QI(VG,"count",0);const jG=window.AudioContext||window.webkitAudioContext;const GG=new(FG=$N({report:eD}),rU((BG=class{constructor(){QI(this,"units",[]),QI(this,"context",void 0)}processExternalMediaAEC(e){if(!this._doesEnvironmentNeedAEC())return YN.debug("the system does not need to process local aec"),-1;this.context||(this.context=new jG);let t=this.units.find((t=>t&&t.getElement()===e));return t||(t=new VG(e,this.context),this.units.push(t)),t.startEchoCancellation(),YN.debug("start processing local audio echo cancellation, id is",t.id),t.id}_doesEnvironmentNeedAEC(){return xb().name!==Lb.SAFARI}}).prototype,"processExternalMediaAEC",[FG],Object.getOwnPropertyDescriptor(BG.prototype,"processExternalMediaAEC"),BG.prototype),BG);function WG(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function HG(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?WG(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):WG(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}const KG=window||document;function YG(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!KG)return;const i=hz._cspEventHandlerPointer;if(i&&t)return void console.error(i,t);const n=e=>{if(!(e&&e.blockedURI&&(hz.onSecurityPolicyViolation||hz.getListeners(tx.SECURITY_POLICY_VIOLATION).length>0)))return;const t=e.blockedURI;_N("CSP_DETECTED_HOSTNAME_LIST").some((e=>Dn(t).call(t,e)))&&(hz.onSecurityPolicyViolation&&"function"==typeof hz.onSecurityPolicyViolation&&hz.onSecurityPolicyViolation(e),hz.getListeners(tx.SECURITY_POLICY_VIOLATION).length>0&&hz.safeEmit(tx.SECURITY_POLICY_VIOLATION,e))};i&&KG.removeEventListener("securitypolicyviolation",i),(t||e&&"function"==typeof e||hz.getListeners(tx.SECURITY_POLICY_VIOLATION).length>0)&&KG.addEventListener("securitypolicyviolation",n),hz._cspEventHandlerPointer=n}var qG=l,zG=_y,XG=RegExp.prototype,JG=function(e){return e===XG||qG(XG,e)?zG(e):e.flags},QG=i(JG);function ZG(e){let t=e.length;for(;--t>=0;)e[t]=0}const $G=256,eW=286,tW=30,iW=15,nW=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),rW=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),oW=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),sW=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),aW=new Array(576);ZG(aW);
vendor: 1,504 bytes, line 12272
12272const cW=new Array(60);ZG(cW);const dW=new Array(512);ZG(dW);const lW=new Array(256);ZG(lW);const uW=new Array(29);ZG(uW);const hW=new Array(tW);function pW(e,t,i,n,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=e&&e.length}let _W,EW,mW;function fW(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ZG(hW);const TW=e=>e<256?dW[e]:dW[256+(e>>>7)],SW=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},gW=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<<e.bi_valid&65535,SW(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)},RW=(e,t,i)=>{gW(e,i[2*t],i[2*t+1])},vW=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},CW=(e,t,i)=>{const n=new Array(16);let r,o,s=0;for(r=1;r<=iW;r++)s=s+i[r-1]<<1,n[r]=s;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=vW(n[t]++,t))}},IW=e=>{let t;for(t=0;t<eW;t++)e.dyn_ltree[2*t]=0;for(t=0;t<tW;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},yW=e=>{e.bi_valid>8?SW(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},AW=(e,t,i,n)=>{const r=2*t,o=2*i;return e[r]<e[o]||e[r]===e[o]&&n[t]<=n[i]},bW=(e,t,i)=>{const n=e.heap[i];let r=i<<1;for(;r<=e.heap_len&&(r<e.heap_len&&AW(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!AW(t,n,e.heap[r],e.depth));)e.heap[i]=e.heap[r],i=r,r<<=1;e.heap[i]=n},wW=(e,t,i)=>{let n,r,o,s,a=0;
vendor: 4,225 bytes, line 12272
12272if(0!==e.sym_next)do{n=255&e.pending_buf[e.sym_buf+a++],n+=(255&e.pending_buf[e.sym_buf+a++])<<8,r=e.pending_buf[e.sym_buf+a++],0===n?RW(e,r,t):(o=lW[r],RW(e,o+$G+1,t),s=nW[o],0!==s&&(r-=uW[o],gW(e,r,s)),n--,o=TW(n),RW(e,o,i),s=rW[o],0!==s&&(n-=hW[o],gW(e,n,s)))}while(a<e.sym_next);RW(e,256,t)},OW=(e,t)=>{const i=t.dyn_tree,n=t.stat_desc.static_tree,r=t.stat_desc.has_stree,o=t.stat_desc.elems;let s,a,c,d=-1;for(e.heap_len=0,e.heap_max=573,s=0;s<o;s++)0!==i[2*s]?(e.heap[++e.heap_len]=d=s,e.depth[s]=0):i[2*s+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=d<2?++d:0,i[2*c]=1,e.depth[c]=0,e.opt_len--,r&&(e.static_len-=n[2*c+1]);for(t.max_code=d,s=e.heap_len>>1;s>=1;s--)bW(e,i,s);c=o;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],bW(e,i,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,i[2*c]=i[2*s]+i[2*a],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,i[2*s+1]=i[2*a+1]=c,e.heap[1]=c++,bW(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,n=t.max_code,r=t.stat_desc.static_tree,o=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let d,l,u,h,p,_,E=0;for(h=0;h<=iW;h++)e.bl_count[h]=0;for(i[2*e.heap[e.heap_max]+1]=0,d=e.heap_max+1;d<573;d++)l=e.heap[d],h=i[2*i[2*l+1]+1]+1,h>c&&(h=c,E++),i[2*l+1]=h,l>n||(e.bl_count[h]++,p=0,l>=a&&(p=s[l-a]),_=i[2*l],e.opt_len+=_*(h+p),o&&(e.static_len+=_*(r[2*l+1]+p)));if(0!==E){do{for(h=c-1;0===e.bl_count[h];)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[c]--,E-=2}while(E>0);for(h=c;0!==h;h--)for(l=e.bl_count[h];0!==l;)u=e.heap[--d],u>n||(i[2*u+1]!==h&&(e.opt_len+=(h-i[2*u+1])*i[2*u],i[2*u+1]=h),l--)}})(e,t),CW(i,d,e.bl_count)},NW=(e,t,i)=>{let n,r,o=-1,s=t[1],a=0,c=7,d=4;for(0===s&&(c=138,d=3),t[2*(i+1)+1]=65535,n=0;n<=i;n++)r=s,s=t[2*(n+1)+1],++a<c&&r===s||(a<d?e.bl_tree[2*r]+=a:0!==r?(r!==o&&e.bl_tree[2*r]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,o=r,0===s?(c=138,d=3):r===s?(c=6,d=3):(c=7,d=4))},DW=(e,t,i)=>{let n,r,o=-1,s=t[1],a=0,c=7,d=4;for(0===s&&(c=138,d=3),n=0;n<=i;n++)if(r=s,s=t[2*(n+1)+1],!(++a<c&&r===s)){if(a<d)do{RW(e,r,e.bl_tree)}while(0!=--a);else 0!==r?(r!==o&&(RW(e,r,e.bl_tree),a--),RW(e,16,e.bl_tree),gW(e,a-3,2)):a<=10?(RW(e,17,e.bl_tree),gW(e,a-3,3)):(RW(e,18,e.bl_tree),gW(e,a-11,7));a=0,o=r,0===s?(c=138,d=3):r===s?(c=6,d=3):(c=7,d=4)}};let PW=!1;const LW=(e,t,i,n)=>{gW(e,0+(n?1:0),3),yW(e),SW(e,i),SW(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var kW=e=>{PW||((()=>{let e,t,i,n,r;const o=new Array(16);for(i=0,n=0;n<28;n++)for(uW[n]=i,e=0;e<1<<nW[n];e++)lW[i++]=n;for(lW[i-1]=n,r=0,n=0;n<16;n++)for(hW[n]=r,e=0;e<1<<rW[n];e++)dW[r++]=n;for(r>>=7;n<tW;n++)for(hW[n]=r<<7,e=0;e<1<<rW[n]-7;e++)dW[256+r++]=n;for(t=0;t<=iW;t++)o[t]=0;for(e=0;e<=143;)aW[2*e+1]=8,e++,o[8]++;for(;e<=255;)aW[2*e+1]=9,e++,o[9]++;for(;e<=279;)aW[2*e+1]=7,e++,o[7]++;for(;e<=287;)aW[2*e+1]=8,e++,o[8]++;for(CW(aW,287,o),e=0;e<tW;e++)cW[2*e+1]=5,cW[2*e]=vW(e,5);_W=new pW(aW,nW,257,eW,iW),EW=new pW(cW,rW,0,tW,iW),mW=new pW(new Array(0),oW,0,19,7)})(),PW=!0),e.l_desc=new fW(e.dyn_ltree,_W),e.d_desc=new fW(e.dyn_dtree,EW),e.bl_desc=new fW(e.bl_tree,mW),e.bi_buf=0,e.bi_valid=0,IW(e)},MW=(e,t,i,n)=>{let r,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<$G;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),OW(e,e.l_desc),OW(e,e.d_desc),s=(e=>{let t;for(NW(e,e.dyn_ltree,e.l_desc.max_code),NW(e,e.dyn_dtree,e.d_desc.max_code),OW(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*sW[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=r&&(r=o)):r=o=i+5,i+4<=r&&-1!==t?LW(e,t,i,n):4===e.strategy||o===r?(gW(e,2+(n?1:0),3),wW(e,aW,cW)):(gW(e,4+(n?1:0),3),((e,t,i,n)=>{let r;for(gW(e,t-257,5),gW(e,i-1,5),gW(e,n-4,4),r=0;r<n;r++)gW(e,e.bl_tree[2*sW[r]+1],3);DW(e,e.dyn_ltree,t-1),DW(e,e.dyn_dtree,i-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),wW(e,e.dyn_ltree,e.dyn_dtree)),IW(e),n&&yW(e)},UW=(e,t,i)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>
vendor: 4,208 bytes, line 12272
122728,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(lW[i]+$G+1)]++,e.dyn_dtree[2*TW(t)]++),e.sym_next===e.sym_end),xW=e=>{gW(e,2,3),RW(e,256,aW),(e=>{16===e.bi_valid?(SW(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)},VW={_tr_init:kW,_tr_stored_block:LW,_tr_flush_block:MW,_tr_tally:UW,_tr_align:xW};var FW=(e,t,i,n)=>{let r=65535&e|0,o=e>>>16&65535|0,s=0;for(;0!==i;){s=i>2e3?2e3:i,i-=s;do{r=r+t[n++]|0,o=o+r|0}while(--s);r%=65521,o%=65521}return r|o<<16|0};const BW=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var jW=(e,t,i,n)=>{const r=BW,o=n+i;e^=-1;for(let i=n;i<o;i++)e=e>>>8^r[255&(e^t[i])];return-1^e},GW={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},WW={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:HW,_tr_stored_block:KW,_tr_flush_block:YW,_tr_tally:qW,_tr_align:zW}=VW,{Z_NO_FLUSH:XW,Z_PARTIAL_FLUSH:JW,Z_FULL_FLUSH:QW,Z_FINISH:ZW,Z_BLOCK:$W,Z_OK:eH,Z_STREAM_END:tH,Z_STREAM_ERROR:iH,Z_DATA_ERROR:nH,Z_BUF_ERROR:rH,Z_DEFAULT_COMPRESSION:oH,Z_FILTERED:sH,Z_HUFFMAN_ONLY:aH,Z_RLE:cH,Z_FIXED:dH,Z_DEFAULT_STRATEGY:lH,Z_UNKNOWN:uH,Z_DEFLATED:hH}=WW,pH=286,_H=30,EH=19,mH=2*pH+1,fH=15,TH=258,SH=262,gH=42,RH=113,vH=666,CH=(e,t)=>(e.msg=GW[t],t),IH=e=>2*e-(e>4?9:0),yH=e=>{let t=e.length;for(;--t>=0;)e[t]=0},AH=e=>{let t,i,n,r=e.w_size;t=e.hash_size,n=t;do{i=e.head[--n],e.head[n]=i>=r?i-r:0}while(--t);t=r,n=t;do{i=e.prev[--n],e.prev[n]=i>=r?i-r:0}while(--t)};let bH=(e,t,i)=>(t<<e.hash_shift^i)&e.hash_mask;const wH=e=>{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},OH=(e,t)=>{YW(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,wH(e.strm)},NH=(e,t)=>{e.pending_buf[e.pending++]=t},DH=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},PH=(e,t,i,n)=>{let r=e.avail_in;return r>n&&(r=n),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=FW(e.adler,t,r,i):2===e.state.wrap&&(e.adler=jW(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},LH=(e,t)=>{let i,n,r=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-SH?e.strstart-(e.w_size-SH):0,d=e.window,l=e.w_mask,u=e.prev,h=e.strstart+TH;let p=d[o+s-1],_=d[o+s];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(i=t,d[i+s]===_&&d[i+s-1]===p&&d[i]===d[o]&&d[++i]===d[o+1]){o+=2,i++;do{}while(d[++o]===d[++i]&&d[++o]===d[++i]&&d[++o]===d[++i]&&d[++o]===d[++i]&&d[++o]===d[++i]&&d[++o]===d[++i]&&d[++o]===d[++i]&&d[++o]===d[++i]&&o<h);if(n=TH-(h-o),o=h-TH,n>s){if(e.match_start=t,s=n,n>=a)break;p=d[o+s-1],_=d[o+s]}}}while((t=u[t&l])>c&&0!=--r);return s<=e.lookahead?s:e.lookahead},kH=e=>{const t=e.w_size;let i,n,r;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-SH)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),AH(e),n+=t),0===e.strm.avail_in)break;if(i=PH(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=i,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=bH(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=bH(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<SH&&0!==e.strm.avail_in)},MH=(e,t)=>{let i,n,r,o=e.pending_buf_size-5>
vendor: 4,811 bytes, line 12272
12272e.w_size?e.w_size:e.pending_buf_size-5,s=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_out<r)break;if(r=e.strm.avail_out-r,n=e.strstart-e.block_start,i>n+e.strm.avail_in&&(i=n+e.strm.avail_in),i>r&&(i=r),i<o&&(0===i&&t!==ZW||t===XW||i!==n+e.strm.avail_in))break;s=t===ZW&&i===n+e.strm.avail_in?1:0,KW(e,0,0,s),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,wH(e.strm),n&&(n>i&&(n=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+n),e.strm.next_out),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n,e.block_start+=n,i-=n),i&&(PH(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===s);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),s?4:t!==XW&&t!==ZW&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(r=e.window_size-e.strstart,e.strm.avail_in>r&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(PH(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water<e.strstart&&(e.high_water=e.strstart),r=e.bi_valid+42>>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,o=r>e.w_size?e.w_size:r,n=e.strstart-e.block_start,(n>=o||(n||t===ZW)&&t!==XW&&0===e.strm.avail_in&&n<=r)&&(i=n>r?r:n,s=t===ZW&&0===e.strm.avail_in&&i===n?1:0,KW(e,e.block_start,i,s),e.block_start+=i,wH(e.strm)),s?3:1)},UH=(e,t)=>{let i,n;for(;;){if(e.lookahead<SH){if(kH(e),e.lookahead<SH&&t===XW)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=bH(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-SH&&(e.match_length=LH(e,i)),e.match_length>=3)if(n=qW(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=bH(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=bH(e,e.ins_h,e.window[e.strstart+1]);else n=qW(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(OH(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===ZW?(OH(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(OH(e,!1),0===e.strm.avail_out)?1:2},xH=(e,t)=>{let i,n,r;for(;;){if(e.lookahead<SH){if(kH(e),e.lookahead<SH&&t===XW)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=bH(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-SH&&(e.match_length=LH(e,i),e.match_length<=5&&(e.strategy===sH||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,n=qW(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=bH(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(OH(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(n=qW(e,0,e.window[e.strstart-1]),n&&OH(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=qW(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===ZW?(OH(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(OH(e,!1),0===e.strm.avail_out)?1:2};function VH(e,t,i,n,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=n,this.func=r}const FH=[new VH(0,0,0,0,MH),new VH(4,4,8,4,UH),new VH(4,5,16,8,UH),new VH(4,6,32,32,UH),new VH(4,4,16,16,xH),new VH(8,16,32,32,xH),new VH(8,16,128,128,x
vendor: 4,682 bytes, line 12272
12272H),new VH(8,32,128,256,xH),new VH(32,128,258,1024,xH),new VH(32,258,258,4096,xH)];function BH(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=hH,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*mH),this.dyn_dtree=new Uint16Array(2*(2*_H+1)),this.bl_tree=new Uint16Array(2*(2*EH+1)),yH(this.dyn_ltree),yH(this.dyn_dtree),yH(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(fH+1),this.heap=new Uint16Array(2*pH+1),yH(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*pH+1),yH(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const jH=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==gH&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==RH&&t.status!==vH?1:0},GH=e=>{if(jH(e))return CH(e,iH);e.total_in=e.total_out=0,e.data_type=uH;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?gH:RH,e.adler=2===t.wrap?0:1,t.last_flush=-2,HW(t),eH},WH=e=>{const t=GH(e);return t===eH&&(e=>{e.window_size=2*e.w_size,yH(e.head),e.max_lazy_match=FH[e.level].max_lazy,e.good_match=FH[e.level].good_length,e.nice_match=FH[e.level].nice_length,e.max_chain_length=FH[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0})(e.state),t},HH=(e,t,i,n,r,o)=>{if(!e)return iH;let s=1;if(t===oH&&(t=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),r<1||r>9||i!==hH||n<8||n>15||t<0||t>9||o<0||o>dH||8===n&&1!==s)return CH(e,iH);8===n&&(n=9);const a=new BH;return e.state=a,a.strm=e,a.status=gH,a.wrap=s,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=r+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<r+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=t,a.strategy=o,a.method=i,WH(e)};var KH=(e,t)=>{if(jH(e)||t>$W||t<0)return e?CH(e,iH):iH;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===vH&&t!==ZW)return CH(e,0===e.avail_out?rH:iH);const n=i.last_flush;if(i.last_flush=t,0!==i.pending){if(wH(e),0===e.avail_out)return i.last_flush=-1,eH}else if(0===e.avail_in&&IH(t)<=IH(n)&&t!==ZW)return CH(e,rH);if(i.status===vH&&0!==e.avail_in)return CH(e,rH);if(i.status===gH&&0===i.wrap&&(i.status=RH),i.status===gH){let t=hH+(i.w_bits-8<<4)<<8,n=-1;if(n=i.strategy>=aH||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=n<<6,0!==i.strstart&&(t|=32),t+=31-t%31,DH(i,t),0!==i.strstart&&(DH(i,e.adler>>>16),DH(i,65535&e.adler)),e.adler=1,i.status=RH,wH(e),0!==i.pending)return i.last_flush=-1,eH}if(57===i.status)if(e.adler=0,NH(i,31),NH(i,139),NH(i,8),i.gzhead)NH(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),NH(i,255&i.gzhead.time),NH(i,i.gzhead.time>>8&255),NH(i,i.gzhead.time>>16&255),NH(i,i.gzhead.time>>24&255),NH(i,9===i.level?2:i.strategy>=aH||i.level<2?4:0),NH(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(NH(i,255&i.gzhead.extra.length),NH(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=jW(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(NH(i,0),NH(i,0),NH(i,0),NH(i,0),NH(i,0),NH(i,9===i.level?2:i.strategy>=aH||i.level<2?4:0),NH(i,3),i.status=RH,wH(e),0!==i.pending)return i.last_flush=-1,eH;if(69===i.status){if(i.gzhead.extra){let t=i.pending,n=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+n>i.pending_buf_size;){let r=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=jW(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=r,wH(e),0!==i.pending)return i.last_flush=-1,eH;t=0,n-=r}let r=new Uint8Array(i.gzhead.extra);
vendor: 9,077 bytes, line 12272
12272i.pending_buf.set(r.subarray(i.gzindex,i.gzindex+n),i.pending),i.pending+=n,i.gzhead.hcrc&&i.pending>t&&(e.adler=jW(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=jW(e.adler,i.pending_buf,i.pending-n,n)),wH(e),0!==i.pending)return i.last_flush=-1,eH;n=0}t=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,NH(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>n&&(e.adler=jW(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(e.adler=jW(e.adler,i.pending_buf,i.pending-n,n)),wH(e),0!==i.pending)return i.last_flush=-1,eH;n=0}t=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,NH(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>n&&(e.adler=jW(e.adler,i.pending_buf,i.pending-n,n))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(wH(e),0!==i.pending))return i.last_flush=-1,eH;NH(i,255&e.adler),NH(i,e.adler>>8&255),e.adler=0}if(i.status=RH,wH(e),0!==i.pending)return i.last_flush=-1,eH}if(0!==e.avail_in||0!==i.lookahead||t!==XW&&i.status!==vH){let n=0===i.level?MH(i,t):i.strategy===aH?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(kH(e),0===e.lookahead)){if(t===XW)return 1;break}if(e.match_length=0,i=qW(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(OH(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===ZW?(OH(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(OH(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===cH?((e,t)=>{let i,n,r,o;const s=e.window;for(;;){if(e.lookahead<=TH){if(kH(e),e.lookahead<=TH&&t===XW)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,n=s[r],n===s[++r]&&n===s[++r]&&n===s[++r])){o=e.strstart+TH;do{}while(n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&n===s[++r]&&r<o);e.match_length=TH-(o-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=qW(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=qW(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(OH(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===ZW?(OH(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(OH(e,!1),0===e.strm.avail_out)?1:2})(i,t):FH[i.level].func(i,t);if(3!==n&&4!==n||(i.status=vH),1===n||3===n)return 0===e.avail_out&&(i.last_flush=-1),eH;if(2===n&&(t===JW?zW(i):t!==$W&&(KW(i,0,0,!1),t===QW&&(yH(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),wH(e),0===e.avail_out))return i.last_flush=-1,eH}return t!==ZW?eH:i.wrap<=0?tH:(2===i.wrap?(NH(i,255&e.adler),NH(i,e.adler>>8&255),NH(i,e.adler>>16&255),NH(i,e.adler>>24&255),NH(i,255&e.total_in),NH(i,e.total_in>>8&255),NH(i,e.total_in>>16&255),NH(i,e.total_in>>24&255)):(DH(i,e.adler>>>16),DH(i,65535&e.adler)),wH(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?eH:tH)},YH=(e,t)=>{let i=t.length;if(jH(e))return iH;const n=e.state,r=n.wrap;if(2===r||1===r&&n.status!==gH||n.lookahead)return iH;if(1===r&&(e.adler=FW(e.adler,t,i,0)),n.wrap=0,i>=n.w_size){0===r&&(yH(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(i-n.w_size,i),0),t=e,i=n.w_size}const o=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,kH(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=bH(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,kH(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=s,e.input=a,e.avail_in=o,n.wrap=r,eH},qH={deflateInit:(e,t)=>HH(e,t,hH,15,8,lH),deflateInit2:HH,deflateReset:WH,deflateResetKeep:GH,deflateSetHeader:(e,t)=>jH(e)||2!==e.state.wrap?iH:(e.state.gzhead=t,eH),deflate:KH,deflateEnd:e=>{if(jH(e))return iH;const t=e.state.status;return e.state=null,t===RH?CH(e,nH):eH},deflateSetDictionary:YH,deflateInfo:"pako deflate (from Nodeca project)"};const zH=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var XH={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)zH(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,n=e.length;i<n;i++)t+=e[i].length;const i=new Uint8Array(t);for(let t=0,n=0,r=e.length;t<r;t++){let r=e[t];i.set(r,n),n+=r.length}return i}};let JH=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){JH=!1}const QH=new Uint8Array(256);for(let e=0;e<256;e++)QH[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;QH[254]=QH[254]=1;var ZH={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,r,o,s=e.length,a=0;for(r=0;r<s;r++)i=e.charCodeAt(r),55296==(64512&i)&&r+1<s&&(n=e.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),a+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(a),o=0,r=0;o<a;r++)i=e.charCodeAt(r),55296==(64512&i)&&r+1<s&&(n=e.charCodeAt(r+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),r++)),i<128?t[o++]=i:i<2048?(t[o++]=192|i>>>6,t[o++]=128|63&i):i<65536?(t[o++]=224|i>>>12,t[o++]=128|i>>>6&63,t[o++]=128|63&i):(t[o++]=240|i>>>18,t[o++]=128|i>>>12&63,t[o++]=128|i>>>6&63,t[o++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,r;const o=new Array(2*i);for(r=0,n=0;n<i;){let t=e[n++];if(t<128){o[r++]=t;continue}let s=QH[t];if(s>4)o[r++]=65533,n+=s-1;else{for(t&=2===s?31:3===s?15:7;s>1&&n<i;)t=t<<6|63&e[n++],s--;s>1?o[r++]=65533:t<65536?o[r++]=t:(t-=65536,o[r++]=55296|t>>10&1023,o[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&JH)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let n=0;n<t;n++)i+=String.fromCharCode(e[n]);return i})(o,r)},utf8border:(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+QH[e[i]]>t?i:t}};var $H=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const eK=Object.prototype.toString,{Z_NO_FLUSH:tK,Z_SYNC_FLUSH:iK,Z_FULL_FLUSH:nK,Z_FINISH:rK,Z_OK:oK,Z_STREAM_END:sK,Z_DEFAULT_COMPRESSION:aK,Z_DEFAULT_STRATEGY:cK,Z_DEFLATED:dK}=WW;function lK(e){this.options=XH.assign({level:aK,method:dK,chunkSize:16384,windowBits:15,memLevel:8,strategy:cK},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $H,this.strm.avail_out=0;let i=qH.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==oK)throw new Error(GW[i]);if(t.header&&qH.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?ZH.string2buf(t.dictionary):"[object ArrayBuffer]"===eK.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=qH.deflateSetDictionary(this.strm,e),i!==oK)throw new Error(GW[i]);this._dict_set=!0}}function uK(e,t){const i=new lK(t);if(i.push(e,!0),i.err)throw i.msg||GW[i.err];return i.result}lK.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize;let r,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?rK:tK,"string"==typeof e?i.input=ZH.string2buf(e):"[object ArrayBuffer]"===eK.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(o===iK||o===nK)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=qH.deflate(i,o),r===sK)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=qH.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===oK;if(0!==i.avail_out){if(o>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},lK.prototype.onData=function(e){this.chunks.push(e)},lK.prototype.onEnd=function(e){e===oK&&(this.result=XH.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var hK={Deflate:lK,deflate:uK,deflateRaw:function(e,t){return(t=t||{}).raw=!0,uK(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,uK(e,t)},constants:WW};const pK=16209;var _K=function(e,t){let i,n,r,o,s,a,c,d,l,u,h,p,_,E,m,f,T,S,g,R,v,C,I,y;const A=e.state;i=e.next_in,I=e.input,n=i+(e.avail_in-5),r=e.next_out,y=e.output,o=r-(t-e.avail_out),s=r+(e.avail_out-257),a=A.dmax,c=A.wsize,d=A.whave,l=A.wnext,u=A.window,h=A.hold,p=A.bits,_=A.lencode,E=A.distcode,m=(1<<A.lenbits)-1,f=(1<<A.distbits)-1;
vendor: 5,067 bytes, line 12272
12272e:do{p<15&&(h+=I[i++]<<p,p+=8,h+=I[i++]<<p,p+=8),T=_[h&m];t:for(;;){if(S=T>>>24,h>>>=S,p-=S,S=T>>>16&255,0===S)y[r++]=65535&T;else{if(!(16&S)){if(0==(64&S)){T=_[(65535&T)+(h&(1<<S)-1)];continue t}if(32&S){A.mode=16191;break e}e.msg="invalid literal/length code",A.mode=pK;break e}g=65535&T,S&=15,S&&(p<S&&(h+=I[i++]<<p,p+=8),g+=h&(1<<S)-1,h>>>=S,p-=S),p<15&&(h+=I[i++]<<p,p+=8,h+=I[i++]<<p,p+=8),T=E[h&f];i:for(;;){if(S=T>>>24,h>>>=S,p-=S,S=T>>>16&255,!(16&S)){if(0==(64&S)){T=E[(65535&T)+(h&(1<<S)-1)];continue i}e.msg="invalid distance code",A.mode=pK;break e}if(R=65535&T,S&=15,p<S&&(h+=I[i++]<<p,p+=8,p<S&&(h+=I[i++]<<p,p+=8)),R+=h&(1<<S)-1,R>a){e.msg="invalid distance too far back",A.mode=pK;break e}if(h>>>=S,p-=S,S=r-o,R>S){if(S=R-S,S>d&&A.sane){e.msg="invalid distance too far back",A.mode=pK;break e}if(v=0,C=u,0===l){if(v+=c-S,S<g){g-=S;do{y[r++]=u[v++]}while(--S);v=r-R,C=y}}else if(l<S){if(v+=c+l-S,S-=l,S<g){g-=S;do{y[r++]=u[v++]}while(--S);if(v=0,l<g){S=l,g-=S;do{y[r++]=u[v++]}while(--S);v=r-R,C=y}}}else if(v+=l-S,S<g){g-=S;do{y[r++]=u[v++]}while(--S);v=r-R,C=y}for(;g>2;)y[r++]=C[v++],y[r++]=C[v++],y[r++]=C[v++],g-=3;g&&(y[r++]=C[v++],g>1&&(y[r++]=C[v++]))}else{v=r-R;do{y[r++]=y[v++],y[r++]=y[v++],y[r++]=y[v++],g-=3}while(g>2);g&&(y[r++]=y[v++],g>1&&(y[r++]=y[v++]))}break}}break}}while(i<n&&r<s);g=p>>3,i-=g,p-=g<<3,h&=(1<<p)-1,e.next_in=i,e.next_out=r,e.avail_in=i<n?n-i+5:5-(i-n),e.avail_out=r<s?s-r+257:257-(r-s),A.hold=h,A.bits=p};const EK=15,mK=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),fK=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),TK=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),SK=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var gK=(e,t,i,n,r,o,s,a)=>{const c=a.bits;let d,l,u,h,p,_,E=0,m=0,f=0,T=0,S=0,g=0,R=0,v=0,C=0,I=0,y=null;const A=new Uint16Array(16),b=new Uint16Array(16);let w,O,N,D=null;for(E=0;E<=EK;E++)A[E]=0;for(m=0;m<n;m++)A[t[i+m]]++;for(S=c,T=EK;T>=1&&0===A[T];T--);if(S>T&&(S=T),0===T)return r[o++]=20971520,r[o++]=20971520,a.bits=1,0;for(f=1;f<T&&0===A[f];f++);for(S<f&&(S=f),v=1,E=1;E<=EK;E++)if(v<<=1,v-=A[E],v<0)return-1;if(v>0&&(0===e||1!==T))return-1;for(b[1]=0,E=1;E<EK;E++)b[E+1]=b[E]+A[E];for(m=0;m<n;m++)0!==t[i+m]&&(s[b[t[i+m]]++]=m);if(0===e?(y=D=s,_=20):1===e?(y=mK,D=fK,_=257):(y=TK,D=SK,_=0),I=0,m=0,E=f,p=o,g=S,R=0,u=-1,C=1<<S,h=C-1,1===e&&C>852||2===e&&C>592)return 1;for(;;){w=E-R,s[m]+1<_?(O=0,N=s[m]):s[m]>=_?(O=D[s[m]-_],N=y[s[m]-_]):(O=96,N=0),d=1<<E-R,l=1<<g,f=l;do{l-=d,r[p+(I>>R)+l]=w<<24|O<<16|N|0}while(0!==l);for(d=1<<E-1;I&d;)d>>=1;if(0!==d?(I&=d-1,I+=d):I=0,m++,0==--A[E]){if(E===T)break;E=t[i+s[m]]}if(E>S&&(I&h)!==u){for(0===R&&(R=S),p+=f,g=E-R,v=1<<g;g+R<T&&(v-=A[g+R],!(v<=0));)g++,v<<=1;if(C+=1<<g,1===e&&C>852||2===e&&C>592)return 1;u=I&h,r[u]=S<<24|g<<16|p-o|0}}return 0!==I&&(r[p+I]=E-R<<24|64<<16|0),a.bits=S,0};const{Z_FINISH:RK,Z_BLOCK:vK,Z_TREES:CK,Z_OK:IK,Z_STREAM_END:yK,Z_NEED_DICT:AK,Z_STREAM_ERROR:bK,Z_DATA_ERROR:wK,Z_MEM_ERROR:OK,Z_BUF_ERROR:NK,Z_DEFLATED:DK}=WW,PK=16180,LK=16190,kK=16191,MK=16192,UK=16194,xK=16199,VK=16200,FK=16206,BK=16209,jK=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function GK(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const WK=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<PK||t.mode>16211?1:0},HK=e=>{if(WK(e))return bK;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=PK,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,IK},KK=e=>{if(WK(e))return bK;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,HK(e)},YK=(e,t)=>{let i;if(WK(e))return bK;const n=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?bK:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,KK(e))},qK=(e,t)=>{if(!e)return bK;const i=new GK;e.state=i,i.strm=e,i.window=null,i.mode=PK;const n=YK(e,t);return n!==IK&&(e.state=null),n};let zK,XK,JK=!0;const QK=e=>{if(JK){zK=new Int32Array(512),XK=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(gK(1,e.lens,0,288,zK,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;gK(2,e.lens,0,32,XK,0,e.work,{bits:5}),JK=!1}
vendor: 35,177 bytes, line 12272
12272e.lencode=zK,e.lenbits=9,e.distcode=XK,e.distbits=5},ZK=(e,t,i,n)=>{let r;const o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),n>=o.wsize?(o.window.set(t.subarray(i-o.wsize,i),0),o.wnext=0,o.whave=o.wsize):(r=o.wsize-o.wnext,r>n&&(r=n),o.window.set(t.subarray(i-n,i-n+r),o.wnext),(n-=r)?(o.window.set(t.subarray(i-n,i),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=r,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=r))),0};var $K=(e,t)=>{let i,n,r,o,s,a,c,d,l,u,h,p,_,E,m,f,T,S,g,R,v,C,I=0;const y=new Uint8Array(4);let A,b;const w=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(WK(e)||!e.output||!e.input&&0!==e.avail_in)return bK;i=e.state,i.mode===kK&&(i.mode=MK),s=e.next_out,r=e.output,c=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,d=i.hold,l=i.bits,u=a,h=c,C=IK;e:for(;;)switch(i.mode){case PK:if(0===i.wrap){i.mode=MK;break}for(;l<16;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}if(2&i.wrap&&35615===d){0===i.wbits&&(i.wbits=15),i.check=0,y[0]=255&d,y[1]=d>>>8&255,i.check=jW(i.check,y,2,0),d=0,l=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",i.mode=BK;break}if((15&d)!==DK){e.msg="unknown compression method",i.mode=BK;break}if(d>>>=4,l-=4,v=8+(15&d),0===i.wbits&&(i.wbits=v),v>15||v>i.wbits){e.msg="invalid window size",i.mode=BK;break}i.dmax=1<<i.wbits,i.flags=0,e.adler=i.check=1,i.mode=512&d?16189:kK,d=0,l=0;break;case 16181:for(;l<16;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}if(i.flags=d,(255&QG(i))!==DK){e.msg="unknown compression method",i.mode=BK;break}if(57344&QG(i)){e.msg="unknown header flags set",i.mode=BK;break}i.head&&(i.head.text=d>>8&1),512&QG(i)&&4&i.wrap&&(y[0]=255&d,y[1]=d>>>8&255,i.check=jW(i.check,y,2,0)),d=0,l=0,i.mode=16182;case 16182:for(;l<32;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}i.head&&(i.head.time=d),512&QG(i)&&4&i.wrap&&(y[0]=255&d,y[1]=d>>>8&255,y[2]=d>>>16&255,y[3]=d>>>24&255,i.check=jW(i.check,y,4,0)),d=0,l=0,i.mode=16183;case 16183:for(;l<16;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}i.head&&(i.head.xflags=255&d,i.head.os=d>>8),512&QG(i)&&4&i.wrap&&(y[0]=255&d,y[1]=d>>>8&255,i.check=jW(i.check,y,2,0)),d=0,l=0,i.mode=16184;case 16184:if(1024&QG(i)){for(;l<16;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}i.length=d,i.head&&(i.head.extra_len=d),512&QG(i)&&4&i.wrap&&(y[0]=255&d,y[1]=d>>>8&255,i.check=jW(i.check,y,2,0)),d=0,l=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&QG(i)&&(p=i.length,p>a&&(p=a),p&&(i.head&&(v=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(o,o+p),v)),512&QG(i)&&4&i.wrap&&(i.check=jW(i.check,n,p,o)),a-=p,o+=p,i.length-=p),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&QG(i)){if(0===a)break e;p=0;do{v=n[o+p++],i.head&&v&&i.length<65536&&(i.head.name+=String.fromCharCode(v))}while(v&&p<a);if(512&QG(i)&&4&i.wrap&&(i.check=jW(i.check,n,p,o)),a-=p,o+=p,v)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=16187;case 16187:if(4096&QG(i)){if(0===a)break e;p=0;do{v=n[o+p++],i.head&&v&&i.length<65536&&(i.head.comment+=String.fromCharCode(v))}while(v&&p<a);if(512&QG(i)&&4&i.wrap&&(i.check=jW(i.check,n,p,o)),a-=p,o+=p,v)break e}else i.head&&(i.head.comment=null);i.mode=16188;case 16188:if(512&QG(i)){for(;l<16;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}if(4&i.wrap&&d!==(65535&i.check)){e.msg="header crc mismatch",i.mode=BK;break}d=0,l=0}i.head&&(i.head.hcrc=QG(i)>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=kK;break;case 16189:for(;l<32;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}e.adler=i.check=jK(d),d=0,l=0,i.mode=LK;case LK:if(0===i.havedict)return e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,i.hold=d,i.bits=l,AK;e.adler=i.check=1,i.mode=kK;case kK:if(t===vK||t===CK)break e;case MK:if(i.last){d>>>=7&l,l-=7&l,i.mode=FK;break}for(;l<3;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}switch(i.last=1&d,d>>>=1,l-=1,3&d){case 0:i.mode=16193;break;case 1:if(QK(i),i.mode=xK,t===CK){d>>>=2,l-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg="invalid block type",i.mode=BK}d>>>=2,l-=2;break;case 16193:for(d>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}if((65535&d)!=(d>>>16^65535)){e.msg="invalid stored block lengths",i.mode=BK;break}if(i.length=65535&d,d=0,l=0,i.mode=UK,t===CK)break e;case UK:i.mode=16195;case 16195:if(p=i.length,p){if(p>a&&(p=a),p>c&&(p=c),0===p)break e;r.set(n.subarray(o,o+p),s),a-=p,o+=p,c-=p,s+=p,i.length-=p;break}i.mode=kK;break;case 16196:for(;l<14;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}if(i.nlen=257+(31&d),d>>>=5,l-=5,i.ndist=1+(31&d),d>>>=5,l-=5,i.ncode=4+(15&d),d>>>=4,l-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=BK;break}i.have=0,i.mode=16197;case 16197:for(;i.have<i.ncode;){for(;l<3;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}i.lens[w[i.have++]]=7&d,d>>>=3,l-=3}for(;i.have<19;)i.lens[w[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},C=gK(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,C){e.msg="invalid code lengths set",i.mode=BK;break}i.have=0,i.mode=16198;case 16198:for(;i.have<i.nlen+i.ndist;){for(;I=i.lencode[d&(1<<i.lenbits)-1],m=I>>>24,f=I>>>16&255,T=65535&I,!(m<=l);){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}if(T<16)d>>>=m,l-=m,i.lens[i.have++]=T;else{if(16===T){for(b=m+2;l<b;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}if(d>>>=m,l-=m,0===i.have){e.msg="invalid bit length repeat",i.mode=BK;break}v=i.lens[i.have-1],p=3+(3&d),d>>>=2,l-=2}else if(17===T){for(b=m+3;l<b;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}d>>>=m,l-=m,v=0,p=3+(7&d),d>>>=3,l-=3}else{for(b=m+7;l<b;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}d>>>=m,l-=m,v=0,p=11+(127&d),d>>>=7,l-=7}if(i.have+p>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=BK;break}for(;p--;)i.lens[i.have++]=v}}if(i.mode===BK)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=BK;break}if(i.lenbits=9,A={bits:i.lenbits},C=gK(1,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,C){e.msg="invalid literal/lengths set",i.mode=BK;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},C=gK(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,C){e.msg="invalid distances set",i.mode=BK;break}if(i.mode=xK,t===CK)break e;case xK:i.mode=VK;case VK:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,i.hold=d,i.bits=l,_K(e,h),s=e.next_out,r=e.output,c=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,d=i.hold,l=i.bits,i.mode===kK&&(i.back=-1);break}for(i.back=0;I=i.lencode[d&(1<<i.lenbits)-1],m=I>>>24,f=I>>>16&255,T=65535&I,!(m<=l);){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}if(f&&0==(240&f)){for(S=m,g=f,R=T;I=i.lencode[R+((d&(1<<S+g)-1)>>S)],m=I>>>24,f=I>>>16&255,T=65535&I,!(S+m<=l);){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}d>>>=S,l-=S,i.back+=S}if(d>>>=m,l-=m,i.back+=m,i.length=T,0===f){i.mode=16205;break}if(32&f){i.back=-1,i.mode=kK;break}if(64&f){e.msg="invalid literal/length code",i.mode=BK;break}i.extra=15&f,i.mode=16201;case 16201:if(i.extra){for(b=i.extra;l<b;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}i.length+=d&(1<<i.extra)-1,d>>>=i.extra,l-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;I=i.distcode[d&(1<<i.distbits)-1],m=I>>>24,f=I>>>16&255,T=65535&I,!(m<=l);){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}if(0==(240&f)){for(S=m,g=f,R=T;I=i.distcode[R+((d&(1<<S+g)-1)>>S)],m=I>>>24,f=I>>>16&255,T=65535&I,!(S+m<=l);){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}d>>>=S,l-=S,i.back+=S}if(d>>>=m,l-=m,i.back+=m,64&f){e.msg="invalid distance code",i.mode=BK;break}i.offset=T,i.extra=15&f,i.mode=16203;case 16203:if(i.extra){for(b=i.extra;l<b;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}i.offset+=d&(1<<i.extra)-1,d>>>=i.extra,l-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=BK;break}i.mode=16204;case 16204:if(0===c)break e;if(p=h-c,i.offset>p){if(p=i.offset-p,p>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=BK;break}p>i.wnext?(p-=i.wnext,_=i.wsize-p):_=i.wnext-p,p>i.length&&(p=i.length),E=i.window}else E=r,_=s-i.offset,p=i.length;p>c&&(p=c),c-=p,i.length-=p;do{r[s++]=E[_++]}while(--p);0===i.length&&(i.mode=VK);break;case 16205:if(0===c)break e;r[s++]=i.length,c--,i.mode=VK;break;case FK:if(i.wrap){for(;l<32;){if(0===a)break e;a--,d|=n[o++]<<l,l+=8}if(h-=c,e.total_out+=h,i.total+=h,4&i.wrap&&h&&(e.adler=i.check=QG(i)?jW(i.check,r,h,s-h):FW(i.check,r,h,s-h)),h=c,4&i.wrap&&(QG(i)?d:jK(d))!==i.check){e.msg="incorrect data check",i.mode=BK;break}d=0,l=0}i.mode=16207;case 16207:if(i.wrap&&QG(i)){for(;l<32;){if(0===a)break e;a--,d+=n[o++]<<l,l+=8}if(4&i.wrap&&d!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=BK;break}d=0,l=0}i.mode=16208;case 16208:C=yK;break e;case BK:C=wK;break e;case 16210:return OK;default:return bK}return e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,i.hold=d,i.bits=l,(i.wsize||h!==e.avail_out&&i.mode<BK&&(i.mode<FK||t!==RK))&&ZK(e,e.output,e.next_out,h-e.avail_out),u-=e.avail_in,h-=e.avail_out,e.total_in+=u,e.total_out+=h,i.total+=h,4&i.wrap&&h&&(e.adler=i.check=QG(i)?jW(i.check,r,h,e.next_out-h):FW(i.check,r,h,e.next_out-h)),e.data_type=i.bits+(i.last?64:0)+(i.mode===kK?128:0)+(i.mode===xK||i.mode===UK?256:0),(0===u&&0===h||t===RK)&&C===IK&&(C=NK),C},eY={inflateReset:KK,inflateReset2:YK,inflateResetKeep:HK,inflateInit:e=>qK(e,15),inflateInit2:qK,inflate:$K,inflateEnd:e=>{if(WK(e))return bK;let t=e.state;return t.window&&(t.window=null),e.state=null,IK},inflateGetHeader:(e,t)=>{if(WK(e))return bK;const i=e.state;return 0==(2&i.wrap)?bK:(i.head=t,t.done=!1,IK)},inflateSetDictionary:(e,t)=>{const i=t.length;let n,r,o;return WK(e)?bK:(n=e.state,0!==n.wrap&&n.mode!==LK?bK:n.mode===LK&&(r=1,r=FW(r,t,i,0),r!==n.check)?wK:(o=ZK(e,t,i,i),o?(n.mode=16210,OK):(n.havedict=1,IK)))},inflateInfo:"pako inflate (from Nodeca project)"};var tY=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const iY=Object.prototype.toString,{Z_NO_FLUSH:nY,Z_FINISH:rY,Z_OK:oY,Z_STREAM_END:sY,Z_NEED_DICT:aY,Z_STREAM_ERROR:cY,Z_DATA_ERROR:dY,Z_MEM_ERROR:lY}=WW;function uY(e){this.options=XH.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $H,this.strm.avail_out=0;let i=eY.inflateInit2(this.strm,t.windowBits);if(i!==oY)throw new Error(GW[i]);if(this.header=new tY,eY.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=ZH.string2buf(t.dictionary):"[object ArrayBuffer]"===iY.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=eY.inflateSetDictionary(this.strm,t.dictionary),i!==oY)))throw new Error(GW[i])}function hY(e,t){const i=new uY(t);if(i.push(e),i.err)throw i.msg||GW[i.err];return i.result}uY.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=t===~~t?t:!0===t?rY:nY,"[object ArrayBuffer]"===iY.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),o=eY.inflate(i,s),o===aY&&r&&(o=eY.inflateSetDictionary(i,r),o===oY?o=eY.inflate(i,s):o===dY&&(o=aY));i.avail_in>0&&o===sY&&i.state.wrap>0&&0!==e[i.next_in];)eY.inflateReset(i),o=eY.inflate(i,s);switch(o){case cY:case dY:case aY:case lY:return this.onEnd(o),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||o===sY))if("string"===this.options.to){let e=ZH.utf8border(i.output,i.next_out),t=i.next_out-e,r=ZH.buf2string(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(o!==oY||0!==a){if(o===sY)return o=eY.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},uY.prototype.onData=function(e){this.chunks.push(e)},uY.prototype.onEnd=function(e){e===oY&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=XH.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var pY={Inflate:uY,inflate:hY,inflateRaw:function(e,t){return(t=t||{}).raw=!0,hY(e,t)},ungzip:hY,constants:WW};const{Deflate:_Y,deflate:EY,deflateRaw:mY,gzip:fY}=hK,{Inflate:TY,inflate:SY,inflateRaw:gY,ungzip:RY}=pY;var vY=EY,CY=SY,IY=function(e){return e[e.ONE_BYTE=0]="ONE_BYTE",e[e.TWO_BYTE=1]="TWO_BYTE",e}(IY||{});class yY{constructor(){QI(this,"_sequence",0),QI(this,"_startTime",Date.now()),QI(this,"isUseOneByte",!0)}get startTime(){const e=Date.now()-this._startTime;return e<Math.pow(2,16)?e:(this._startTime+=Math.pow(2,16),this.startTime)}get sequence(){return this._sequence<Math.pow(2,32)?this._sequence++:(this._sequence-=Math.pow(2,32),this.sequence)}serialize(e){const t={commonPacketHeader:{length:0,reserved:0,extension:0,sequence:this.sequence},commonStreamHeader:this.startTime,extension:void 0,payload:e};if(e.byteLength>128){const i=new Uint8Array(4);i.set([1,0,0,0]);const n={id:0,length:4,data:i.buffer},r={profile:this.isUseOneByte?0:1,length:this.isUseOneByte?5:6,datas:[n]};t.commonPacketHeader.extension=1,t.extension=r,t.payload=this.compress(e),t.commonPacketHeader.length=8+(t.extension.length+2)+t.payload.byteLength}else t.commonPacketHeader.length=8+t.payload.byteLength;_N("SHOW_DATASTREAM2_LOG")&&YN.debug("send data header: ".concat(JSON.stringify(t.commonPacketHeader)));const i=new ArrayBuffer(t.commonPacketHeader.length),n=new Uint8Array(i),r=new DataView(i);let o=0;if(r.setUint16(o,t.commonPacketHeader.extension<<15|t.commonPacketHeader.reserved<<14|t.commonPacketHeader.length,!0),o+=2,r.setUint32(o,t.commonPacketHeader.sequence,!0),o+=4,r.setUint16(o,t.commonStreamHeader,!0),o+=2,t.extension){const e=this.serializeExtension(t.extension);n.set(new Uint8Array(e),o),o+=e.byteLength}if(n.set(new Uint8Array(t.payload),o),o+=t.payload.byteLength,o!==t.commonPacketHeader.length)throw Error("serialize error!");return i}deserialize(e){if(e.byteLength<4)return new ArrayBuffer(0);const t=new DataView(e);let i=0;const n=t.getUint16(i,!0);i+=2;const r={length:16383&n,reserved:(16384&n)>>14,extension:(32768&n)>>15,sequence:t.getUint16(i+2,!0)<<16|t.getUint16(i,!0)};let o,s;if(i+=4,_N("SHOW_DATASTREAM2_LOG")&&YN.debug("receive data header: ".concat(JSON.stringify(r))),t.getUint16(i,!0),i+=2,r.extension){s=this.deserializeExtension(e.slice(i)),i+=2+s.length,o=e.slice(i);let t=!1;if(s.datas.length>0){const e=s.datas.find((e=>0===e.id));if(e){t=1==(1&new DataView(e.data).getUint32(0,!0))}}o=t?this.decompress(o):o}else o=e.slice(8);return o}serializeExtension(e){const{profile:t,length:i,datas:n}=e,r=new ArrayBuffer(i+2),o=new Uint8Array(r),s=new DataView(r);let a=0;if(s.setUint8(a++,t),s.setUint8(a++,i),n.forEach((e=>{t?(s.setUint8(a++,e.id),s.setUint8(a++,e.length),o.set(new Uint8Array(e.data),a),a+=e.data.byteLength):(s.setUint8(a++,e.id|e.length<<4),o.set(new Uint8Array(e.data),a),a+=e.data.byteLength)})),a!==i+2)throw Error("serialize extension error, is ".concat(a,"!==").concat(i+2));return r}deserializeExtension(e){const t=new DataView(e);let i=0;const n=t.getUint8(i);i++;const r=t.getUint8(i);i++;const o=n===IY.TWO_BYTE,s=[],a=new DataView(e,2);let c=0;for(;c<r;){let e=0,t=0,i=new ArrayBuffer(0);o?(e=a.getUint8(c),c++,t=a.getUint8(c),c++):(e=15&a.getUint8(c),t=a.getUint8(c)>>4,c++),t>0&&(i=a.buffer.slice(c+2,c+2+t),c+=i.byteLength),s.push({id:e,length:t,data:i})}if(c!==r)throw Error("parse error");return{profile:n,length:r,datas:s}}decompress(e){return CY(new Uint8Array(e))}compress(e){return vY(new Uint8Array(e))}}const AY={name:"DataStream",create:(e,t)=>{const i=t?new Lk(e):new kk(e);return i.useDataStream(new yY),i}};class bY extends Dw{constructor(e,t,i){super(),QI(this,"ws",void 0),QI(this,"requestId",1),QI(this,"heartBeatTimer",void 0),QI(this,"joinInfo",void 0),QI(this,"clientId",void 0),QI(this,"onOpen",(()=>{this.emit("open"),this.startHeartBeatCheck()})),QI(this,"onClose",(e=>{this.emit("close"),this.dispose()})),QI(this,"onMessage",(e=>{const t=JSON.parse(e.data);if(!t||"serverResponse"!==t.command||!t.requestId)return t&&"serverStatus"===t.command&&t.serverStatus&&t.serverStatus.command?(this.emit("status",t.serverStatus),void this.emit(t.serverStatus.command,t.serverStatus)):void 0;this.emit("req_".concat(t.requestId),t)})),this.joinInfo=e,this.clientId=t,this.ws=new yx("cross-channel-".concat(this.clientId),i),this.ws.on(mU.RECONNECTING,(()=>{this.ws.reconnectMode="retry",this.emit("reconnecting")})),this.ws.on(mU.CONNECTED,this.onOpen),this.ws.on(mU.ON_MESSAGE,this.onMessage),this.ws.on(mU.CLOSED,this.onClose)}isConnect(){return"connected"===this.ws.state}sendMessage(e){const t=this.requestId++;return e.requestId=t,e.seq=t,this.ws.sendMessage(e),t}waitStatus(e){return new Wh(((t,i)=>{const n=window.setTimeout((()=>{i(new tD(Ew.TIMEOUT,"wait status timeout, status: ".concat(e)))}),5e3);this.once(e,(r=>{window.clearTimeout(n),r.state&&0!==r.state?i(new tD(Ew.CROSS_CHANNEL_WAIT_STATUS_ERROR,"wait status error, status: ".concat(e))):t(void 0)})),this.once("dispose",(()=>{window.clearTimeout(n),i(new tD(Ew.WS_ABORT))}))}))}async request(e){if("closed"===this.ws.state)throw new tD(Ew.WS_DISCONNECT);const t=()=>new Wh(((e,t)=>{this.ws.once(mU.CLOSED,(()=>t(new tD(Ew.WS_ABORT)))),this.ws.once(mU.CONNECTED,e)}));"connected"!==this.ws.state&&await t();const i=this.sendMessage(e),n=new Wh(((e,t)=>{const n=()=>{t(new tD(Ew.WS_ABORT))};this.ws.once(mU.RECONNECTING,n),this.ws.once(mU.CLOSED,n),this.once("req_".concat(i),e),uO(3e3).then((()=>{this.removeAllListeners("req_".concat(i)),this.ws.off(mU.RECONNECTING,n),this.ws.off(mU.CLOSED,n),t(new tD(Ew.TIMEOUT,"cross channel ws request timeout"))}))})),r=await n;if(!r||200!==r.code)throw new tD(Ew.CROSS_CHANNEL_SERVER_ERROR_RESPONSE,"response: ".concat(JSON.stringify(r)));return r}async connect(e){this.ws.removeAllListeners(mU.REQUEST_NEW_URLS),this.ws.on(mU.REQUEST_NEW_URLS,(t=>{t(e)})),await this.ws.init(e)}dispose(){this.clearHeartBeatCheck(),this.emit("dispose"),this.removeAllListeners(),this.ws.close()}sendPing(e){const t=this.requestId++;return e.requestId=t,this.ws.sendMessage(e),t}startHeartBeatCheck(){this.heartBeatTimer&&window.clearInterval(this.heartBeatTimer),this.heartBeatTimer=window.setInterval((()=>{this.sendPing({command:"ping",appId:this.joinInfo.appId,cname:this.joinInfo.cname,uid:this.joinInfo.uid.toString(),sid:this.joinInfo.sid,ts:+new Date,requestId:0})}),3e3)}clearHeartBeatCheck(){window.clearInterval(this.heartBeatTimer),this.heartBeatTimer=void 0}}class wY extends Dw{set state(e){e!==this._state&&(e!==NU.RELAY_STATE_FAILURE&&(this.errorCode=DU.RELAY_OK),this.emit("state",e,this.errorCode),this._state=e)}get state(){return this._state}constructor(e,t,i,n,r){super(),QI(this,"joinInfo",void 0),QI(this,"sid",void 0),QI(this,"clientId",void 0),QI(this,"cancelToken",Ab.CancelToken.source()),QI(this,"workerToken",void 0),QI(this,"requestId",0),QI(this,"signal",void 0),QI(this,"prevChannelMediaConfig",void 0),QI(this,"httpRetryConfig",void 0),QI(this,"_resolution",void 0),QI(this,"_state",NU.RELAY_STATE_IDLE),QI(this,"errorCode",DU.RELAY_OK),QI(this,"onStatus",(e=>{YN.debug("[".concat(this.clientId,"] ChannelMediaStatus: ").concat(JSON.stringify(e))),e&&e.command&&("onAudioPacketReceived"===e.command&&this.emit("event",OU.PACKET_RECEIVED_AUDIO_FROM_SRC),"onVideoPacketReceived"===e.command&&this.emit("event",OU.PACKET_RECEIVED_VIDEO_FROM_SRC),"onSrcTokenPrivilegeDidExpire"===e.command&&(this.errorCode=DU.SRC_TOKEN_EXPIRED,this.state=NU.RELAY_STATE_FAILURE),"onDestTokenPrivilegeDidExpire"===e.command&&(this.errorCode=DU.DEST_TOKEN_EXPIRED,this.state=NU.RELAY_STATE_FAILURE))})),QI(this,"onReconnect",(async()=>{YN.debug("[".concat(this.clientId,"] ChannelMediaSocket disconnect, reconnecting")),this.emit("event",OU.NETWORK_DISCONNECTED),this.state=NU.RELAY_STATE_IDLE,this.prevChannelMediaConfig&&this.sendStartRelayMessage(this.prevChannelMediaConfig).catch((e=>{this.state!==NU.RELAY_STATE_IDLE&&(YN.error("auto restart channel media relay failed",e.toString()),this.errorCode=DU.SERVER_CONNECTION_LOST,this.state=NU.RELAY_STATE_FAILURE)}))})),this.joinInfo=e,this.clientId=t,this.sid=pO(),this.signal=new bY(this.joinInfo,this.clientId,i),this.httpRetryConfig=n,this._resolution=r}async startChannelMediaRelay(e){if(this.state!==NU.RELAY_STATE_IDLE)throw new tD(Ew.INVALID_OPERATION);this.state=NU.RELAY_STATE_CONNECTING,await this.connect(),YN.debug("[".concat(this.clientId,"] startChannelMediaRelay: connect success"));try{await this.sendStartRelayMessage(e)}catch(e){if(e.data&&e.data.serverResponse&&"SetSourceChannel"===e.data.serverResponse.command)throw new tD(Ew.CROSS_CHANNEL_FAILED_JOIN_SRC);if(e.data&&e.data.serverResponse&&"SetDestChannelStatus"===e.serverResponse.command)throw new tD(Ew.CROSS_CHANNEL_FAILED_JOIN_DEST);if(e.data&&e.data.serverResponse&&"StartPacketTransfer"===e.serverResponse.command)throw new tD(Ew.CROSS_CHANNEL_FAILED_PACKET_SENT_TO_DEST);throw e}this.prevChannelMediaConfig=e}async updateChannelMediaRelay(e){if(this.state!==NU.RELAY_STATE_RUNNING)throw new tD(Ew.INVALID_OPERATION);await this.sendUpdateMessage(e),this.prevChannelMediaConfig=e}async setVideoProfile(e){if(this._resolution=e,this.state!==NU.RELAY_STATE_RUNNING)throw new tD(Ew.INVALID_OPERATION);const t=this.genMessage(wU.SetVideoProfile);await this.signal.request(t),YN.debug("[".concat(this.clientId,"] startChannelMediaRelay: setVideoProfile success"))}async stopChannelMediaRelay(){await this.sendStopRelayMessage(),YN.debug("[".concat(this.clientId,"] stopChannelMediaRelay: send stop message success")),this.state=NU.RELAY_STATE_IDLE,this.dispose()}dispose(){YN.debug("[".concat(this.clientId,"] disposeChannelMediaRelay")),this.cancelToken.cancel(),this.cancelToken=Ab.CancelToken.source(),this.state=NU.RELAY_STATE_IDLE,this.emit("dispose"),this.signal.dispose(),this.prevChannelMediaConfig=void 0}async connect(){const e=await uF(this.joinInfo,this.cancelToken.token,this.httpRetryConfig);this.workerToken=e.workerToken,await this.signal.connect(e.addressList),this.emit("event",OU.NETWORK_CONNECTED),this.signal.on("status",this.onStatus),this.signal.on("reconnecting",this.onReconnect)}async sendStartRelayMessage(e){const t=this.genMessage(wU.StopPacketTransfer);await this.signal.request(t),await this.signal.waitStatus("Normal Quit"),YN.debug("[".concat(this.clientId,"] startChannelMediaRelay: StopPacketTransfer success"));const i=this.genMessage(wU.SetSdkProfile,e);await this.signal.request(i),YN.debug("[".concat(this.clientId,"] startChannelMediaRelay: SetSdkProfile success"));const n=this.genMessage(wU.SetSourceChannel,e);await this.signal.request(n),await this.signal.waitStatus("SetSourceChannelStatus"),this.emit("event",OU.PACKET_JOINED_SRC_CHANNEL),YN.debug("[".concat(this.clientId,"] startChannelMediaRelay: SetSourceChannel success"));const r=this.genMessage(wU.SetSourceUserId,e);await this.signal.request(r),YN.debug("[".concat(this.clientId,"] startChannelMediaRelay: SetSourceUserId success"));const o=this.genMessage(wU.SetDestChannel,e);await this.signal.request(o),await this.signal.waitStatus("SetDestChannelStatus"),this.emit("event",OU.PACKET_JOINED_DEST_CHANNEL),YN.debug("[".concat(this.clientId,"] startChannelMediaRelay: SetDestChannel success"));const s=this.genMessage(wU.StartPacketTransfer,e);await this.signal.request(s),this.emit("event",OU.PACKET_SENT_TO_DEST_CHANNEL),this.state=NU.RELAY_STATE_RUNNING,YN.debug("[".concat(this.clientId,"] startChannelMediaRelay: StartPacketTransfer success")),this.setVideoProfile(this._resolution)}async sendUpdateMessage(e){const t=this.genMessage(wU.UpdateDestChannel,e);await this.signal.request(t),this.emit("event",OU.PACKET_UPDATE_DEST_CHANNEL),YN.debug("[".concat(this.clientId,"] sendUpdateMessage: UpdateDestChannel success"))}async sendStopRelayMessage(){const e=this.genMessage(wU.StopPacketTransfer);await this.signal.request(e),YN.debug("[".concat(this.clientId,"] sendStopRelayMessage: StopPacketTransfer success"))}genMessage(e,t){const i=[],n=[],r=[];this.requestId+=1;const o={appId:this.joinInfo.appId,cname:this.joinInfo.cname,uid:this.joinInfo.uid.toString(),sdkVersion:rN,sid:this.sid,ts:Date.now(),requestId:this.requestId,seq:this.requestId,allocate:!0,clientRequest:{}};"4.23.2"===o.sdkVersion&&(o.sdkVersion="0.0.1");let s=null,a=null;switch(e){case wU.SetSdkProfile:return o.clientRequest={command:"SetSdkProfile",type:"multi_channel"},o;case wU.SetSourceChannel:if(a=t&&t.getSrcChannelMediaInfo(),!a)throw new tD(Ew.UNEXPECTED_ERROR,"can not find source config");return o.clientRequest={command:"SetSourceChannel",uid:"0",channelName:a.channelName,token:a.token||this.joinInfo.appId},o;case wU.SetSourceUserId:if(a=t&&t.getSrcChannelMediaInfo(),!a)throw new tD(Ew.UNEXPECTED_ERROR,"can not find source config");return o.clientRequest={command:"SetSourceUserId",uid:a.uid+""},o;case wU.SetDestChannel:if(s=t&&t.getDestChannelMediaInfo(),!s)throw new tD(Ew.UNEXPECTED_ERROR,"can not find dest config");return s.forEach((e=>{i.push(e.channelName),n.push(e.uid+""),r.push(e.token||this.joinInfo.appId)})),o.clientRequest={command:"SetDestChannel",channelName:i,uid:n,token:r},o;case wU.StartPacketTransfer:return o.clientRequest={command:"StartPacketTransfer"},o;case wU.Reconnect:return o.clientRequest={command:"Reconnect"},o;case wU.StopPacketTransfer:return o.clientRequest={command:"StopPacketTransfer"},o;case wU.UpdateDestChannel:if(s=t&&t.getDestChannelMediaInfo(),!s)throw new tD(Ew.UNEXPECTED_ERROR,"can not find dest config");return s.forEach((e=>{i.push(e.channelName),n.push(e.uid+""),r.push(e.token||this.joinInfo.appId)})),o.clientRequest={command:"UpdateDestChannel",channelName:i,uid:n,token:r},o;case wU.SetVideoProfile:o.clientRequest={command:"SetVideoProfile",width:this._resolution.width,height:this._resolution.height}}return o}}const OY={name:"ChannelMediaRelay",create:function(e){return new wY(e.joinInfo,e.clientId,e.websocketRetryConfig||AO,e.httpRetryConfig||AO,e.resolution)}};function NY(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function DY(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?NY(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):NY(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class PY extends Dw{constructor(e,t,i,n){super(),QI(this,"spec",void 0),QI(this,"token",void 0),QI(this,"websocket",void 0),QI(this,"pingpongTimer",void 0),QI(this,"reconnectMode","retry"),QI(this,"serviceMode",void 0),QI(this,"reqId",0),QI(this,"commandReqId",0),QI(this,"handleWebSocketOpen",(()=>{this.reconnectMode="retry",this.startPingPong()})),QI(this,"handleWebSocketMessage",(e=>{if(!e.data)return;const t=JSON.parse(e.data);t.requestId?this.emit("@".concat(t.requestId,"-").concat(t.sid),t):(eD.workerEvent(this.spec.sid,{actionType:"status",serverCode:t.code,workerType:this.serviceMode===SU.TRANSCODE?1:2}),this.emit(IU.PUBLISH_STREAM_STATUS,t))})),this.spec=t,this.token=e,this.serviceMode=n,this.websocket=new yx("live-streaming",i),this.websocket.on(mU.CONNECTED,this.handleWebSocketOpen),this.websocket.on(mU.ON_MESSAGE,this.handleWebSocketMessage),this.websocket.on(mU.REQUEST_NEW_URLS,((e,t)=>{Yw(this,IU.REQUEST_NEW_ADDRESS).then(e).catch(t)})),this.websocket.on(mU.RECONNECTING,(()=>{this.websocket.reconnectMode=this.reconnectMode}))}init(e){return this.websocket.init(e)}async request(e,t,i,n){this.reqId+=1,"request"===e&&(this.commandReqId+=1);const r=this.commandReqId,o=this.reqId;if(!o||!this.websocket)throw new tD(Ew.UNEXPECTED_ERROR);const s=DY({command:e,sdkVersion:"4.23.2"===rN?"0.0.1":rN,seq:o,requestId:o,allocate:i,cname:this.spec.cname,appId:this.spec.appId,sid:this.spec.sid,uid:this.spec.uid.toString(),ts:Math.floor(Date.now()/1e3)},t);if("closed"===this.websocket.state)throw new tD(Ew.WS_DISCONNECT);const a=()=>new Wh(((e,t)=>{this.websocket.once(mU.CLOSED,(()=>t(new tD(Ew.WS_ABORT)))),this.websocket.once(mU.CONNECTED,e)}));"connected"!==this.websocket.state&&await a(),s.clientRequest&&(s.clientRequest.workerToken=this.token);const c=new Wh(((e,t)=>{const i=()=>{t(new tD(Ew.WS_ABORT))};this.websocket.once(mU.RECONNECTING,i),this.websocket.once(mU.CLOSED,i),this.once("@".concat(o,"-").concat(this.spec.sid),(t=>{e(t)}))}));n&&eD.workerEvent(this.spec.sid,DY(DY({},n),{},{requestId:r,actionType:"request",payload:JSON.stringify(t.clientRequest),serverCode:0,code:0}));const d=Date.now();this.websocket.sendMessage(s);let l=null;try{l=await c}catch(n){if("closed"===this.websocket.state)throw n;return await a(),await this.request(e,t,i)}return n&&eD.workerEvent(this.spec.sid,DY(DY({},n),{},{requestId:r,actionType:"response",payload:JSON.stringify(l.serverResponse),serverCode:l.code,success:200===l.code,responseTime:Date.now()-d})),200!==l.code&&this.handleResponseError(l),l}tryNextAddress(){this.reconnectMode="tryNext",this.websocket.reconnect("tryNext")}close(){const e="4.23.2"===rN?"0.0.1":rN;this.reqId+=1,"connected"===this.websocket.state?(this.websocket.sendMessage({command:"request",appId:this.spec.appId,cname:this.spec.cname,uid:this.spec.uid.toString(),sdkVersion:e,sid:this.spec.sid,seq:this.reqId,ts:Math.floor(Date.now()/1e3),requestId:this.reqId,clientRequest:{command:"DestroyWorker"}}),this.websocket.close(!1,!0)):this.websocket.close(!1),this.pingpongTimer&&(window.clearInterval(this.pingpongTimer),this.pingpongTimer=void 0)}handleResponseError(e){switch(e.code){case AU.LIVE_STREAM_RESPONSE_ALREADY_EXISTS_STREAM:return void YN.warning("live stream response already exists stream");case AU.LIVE_STREAM_RESPONSE_TRANSCODING_PARAMETER_ERROR:case AU.LIVE_STREAM_RESPONSE_BAD_STREAM:case AU.LIVE_STREAM_RESPONSE_WM_PARAMETER_ERROR:return new tD(Ew.LIVE_STREAMING_INVALID_ARGUMENT,"",{code:e.code}).throw();case AU.LIVE_STREAM_RESPONSE_WM_WORKER_NOT_EXIST:if("UnpublishStream"===e.serverResponse.command)return;throw new tD(Ew.LIVE_STREAMING_INTERNAL_SERVER_ERROR,"live stream response wm worker not exist",{retry:!0});case AU.LIVE_STREAM_RESPONSE_NOT_AUTHORIZED:return new tD(Ew.LIVE_STREAMING_PUBLISH_STREAM_NOT_AUTHORIZED,"",{code:e.code}).throw();case AU.LIVE_STREAM_RESPONSE_FAILED_LOAD_IMAGE:{const t=new tD(Ew.LIVE_STREAMING_WARN_FAILED_LOAD_IMAGE);return this.emit(IU.WARNING,t,e.serverResponse.url)}case AU.LIVE_STREAM_RESPONSE_REQUEST_TOO_OFTEN:{const t=new tD(Ew.LIVE_STREAMING_WARN_FREQUENT_REQUEST);return this.emit(IU.WARNING,t,e.serverResponse.url)}case AU.LIVE_STREAM_RESPONSE_NOT_FOUND_PUBLISH:throw new tD(Ew.LIVE_STREAMING_INTERNAL_SERVER_ERROR,"live stream response wm worker not exist",{retry:!0});case AU.LIVE_STREAM_RESPONSE_NOT_SUPPORTED:return new tD(Ew.LIVE_STREAMING_TRANSCODING_NOT_SUPPORTED,"",{code:e.code}).throw();case AU.LIVE_STREAM_RESPONSE_MAX_STREAM_NUM:{const t=new tD(Ew.LIVE_STREAMING_WARN_STREAM_NUM_REACH_LIMIT);return this.emit(IU.WARNING,t,e.serverResponse.url)}case AU.LIVE_STREAM_RESPONSE_INTERNAL_SERVER_ERROR:return new tD(Ew.LIVE_STREAMING_INTERNAL_SERVER_ERROR,"",{code:e.code}).throw();case AU.LIVE_STREAM_RESPONSE_RESOURCE_LIMIT:throw new tD(Ew.LIVE_STREAMING_INTERNAL_SERVER_ERROR,"live stream resource limit",{retry:!0,changeAddress:!0});case AU.LIVE_STREAM_RESPONSE_WORKER_LOST:case AU.LIVE_STREAM_RESPONSE_WORKER_QUIT:if("UnpublishStream"===e.serverResponse.command)return;throw new tD(Ew.LIVE_STREAMING_INTERNAL_SERVER_ERROR,"error fail send message",{retry:!0,changeAddress:!0});case AU.ERROR_FAIL_SEND_MESSAGE:if("UnpublishStream"===e.serverResponse.command)return;if("UpdateTranscoding"===e.serverResponse.command||"ControlStream"===e.serverResponse.command)return new tD(Ew.LIVE_STREAMING_INTERNAL_SERVER_ERROR,"error fail send message",{code:e.code}).throw();throw new tD(Ew.LIVE_STREAMING_INTERNAL_SERVER_ERROR,"error fail send message",{retry:!0,changeAddress:!0});case AU.PUBLISH_STREAM_STATUS_ERROR_PUBLISH_BROKEN:case AU.PUBLISH_STREAM_STATUS_ERROR_RTMP_CONNECT:case AU.PUBLISH_STREAM_STATUS_ERROR_RTMP_HANDSHAKE:case AU.PUBLISH_STREAM_STATUS_ERROR_RTMP_PUBLISH:return new tD(Ew.LIVE_STREAMING_CDN_ERROR,"",{code:e.code}).throw()}}startPingPong(){this.pingpongTimer&&window.clearInterval(this.pingpongTimer),this.pingpongTimer=window.setInterval((()=>{"connected"===this.websocket.state&&this.request("ping",{}).catch(_O)}),6e3)}}function LY(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function kY(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?LY(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):LY(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class MY extends Dw{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:AO,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:AO;super(),QI(this,"onLiveStreamWarning",void 0),QI(this,"onLiveStreamError",void 0),QI(this,"spec",void 0),QI(this,"retryTimeout",1e4),QI(this,"connection",void 0),QI(this,"httpRetryConfig",void 0),QI(this,"wsRetryConfig",void 0),QI(this,"streamingTasks",new Map),QI(this,"isStartingStreamingTask",!1),QI(this,"taskMutex",new IO("live-streaming")),QI(this,"cancelToken",Ab.CancelToken.source()),QI(this,"transcodingConfig",void 0),QI(this,"uapResponse",void 0),QI(this,"lastTaskId",1),QI(this,"statusError",new Map),this.spec=e,this.httpRetryConfig=i,this.wsRetryConfig=t}async setTranscodingConfig(e){const t=kY(kY({},CU),e);66!==t.videoCodecProfile&&77!==t.videoCodecProfile&&100!==t.videoCodecProfile&&(YN.debug("[".concat(this.spec.clientId,"] set transcoding config, fix video codec profile: ").concat(t.videoCodecProfile," -> 100")),t.videoCodecProfile=100),t.transcodingUsers||(t.transcodingUsers=t.userConfigs),t.transcodingUsers&&(t.transcodingUsers=t.transcodingUsers.map((e=>kY(kY(kY({},gU),e),{},{zOrder:e.zOrder?e.zOrder+1:1})))),function(e){Cw(e.width)||Sw(e.width,"config.width",0,1e4),Cw(e.height)||Sw(e.height,"config.height",0,1e4),Cw(e.videoBitrate)||Sw(e.videoBitrate,"config.videoBitrate",1,1e6),Cw(e.videoFrameRate)||Sw(e.videoFrameRate,"config.videoFrameRate"),Cw(e.lowLatency)||fw(e.lowLatency,"config.lowLatency"),Cw(e.audioSampleRate)||Tw(e.audioSampleRate,"config.audioSampleRate",[32e3,44100,48e3]),Cw(e.audioBitrate)||Sw(e.audioBitrate,"config.audio
12272Bitrate",1,128),Cw(e.audioChannels)||Tw(e.audioChannels,"config.audioChannels",[1,2,3,4,5]),Cw(e.videoGop)||Sw(e.videoGop,"config.videoGop"),Cw(e.videoCodecProfile)||Tw(e.videoCodecProfile,"config.videoCodecProfile",[66,77,100]),Cw(e.userCount)||Sw(e.userCount,"config.userCount",0,17),Cw(e.backgroundColor)||Sw(e.backgroundColor,"config.backgroundColor",0,16777215),Cw(e.userConfigExtraInfo)||Rw(e.userConfigExtraInfo,"config.userConfigExtraInfo",0,4096,!1),e.transcodingUsers&&!Cw(e.transcodingUsers)&&(vw(e.transcodingUsers,"config.transcodingUsers"),e.transcodingUsers.forEach(((e,t)=>{TU(e.uid),Cw(e.x)||Sw(e.x,"transcodingUser[".concat(t,"].x"),0,1e4),Cw(e.y)||Sw(e.y,"transcodingUser[".concat(t,"].y"),0,1e4),Cw(e.width)||Sw(e.width,"transcodingUser[".concat(t,"].width"),0,1e4),Cw(e.height)||Sw(e.height,"transcodingUser[".concat(t,"].height"),0,1e4),Cw(e.zOrder)||Sw(e.zOrder-1,"transcodingUser[".concat(t,"].zOrder"),0,100),Cw(e.alpha)||Sw(e.alpha,"transcodingUser[".concat(t,"].alpha"),0,1,!1)}))),Cw(e.watermark)||vU(e.watermark,"watermark"),Cw(e.backgroundImage)||vU(e.backgroundImage,"backgroundImage"),e.images&&!Cw(e.images)&&(vw(e.images,"config.images"),e.images.forEach(((e,t)=>{vU(e,"images[".concat(t,"]"))})))}(t);const i=[];t.images&&i.push(...t.images.map((e=>kY(kY(kY({},RU),e),{},{zOrder:255})))),t.backgroundImage&&(i.push(kY(kY(kY({},RU),t.backgroundImage),{},{zOrder:0})),delete t.backgroundImage),t.watermark&&(i.push(kY(kY(kY({},RU),t.watermark),{},{zOrder:255})),delete t.watermark),t.images=i,t.transcodingUsers&&(t.userConfigs=t.transcodingUsers.map((e=>kY({},e))),t.userCount=t.transcodingUsers.length,delete t.transcodingUsers);const n=(t.userConfigs||[]).map((e=>"number"==typeof e.uid?Wh.resolve(e.uid):sF(e.uid,this.spec,this.cancelToken.token,this.httpRetryConfig)));if((await Wh.all(n)).forEach(((e,i)=>{t.userConfigs&&t.userConfigs[i]&&(t.userConfigs[i].uid=e)})),this.transcodingConfig=t,this.connection)try{var r;const e=await this.connection.request("request",{clientRequest:{command:"UpdateTranscoding",transcodingConfig:this.transcodingConfig}},!1,{command:"UpdateTranscoding",workerType:1,requestByUser:!0,tid:Array.from(Zh(r=this.streamingTasks).call(r)).map((e=>e.taskId)).join("#")});YN.debug("[".concat(this.spec.clientId,"] update live transcoding config success, code: ").concat(e.code,", config:"),JSON.stringify(this.transcodingConfig))}catch(e){if(!e.data||!e.data.retry)throw e;e.data.changeAddress&&this.connection.tryNextAddress(),this.streamingTasks.forEach((t=>{YN.warning("[".concat(this.spec.clientId,"] live streaming receive error"),e.toString(),"try to republish",t.url),this.startLiveStreamingTask(t.url,t.mode,e).then((()=>{YN.debug("[".concat(this.spec.clientId,"] live streaming republish ").concat(t.url," success"))})).catch((e=>{YN.error("[".concat(this.spec.clientId,"] live streaming republish failed"),t.url,e.toString()),this.onLiveStreamError&&this.onLiveStreamError(t.url,e)}))}
vendor: 29,208 bytes, line 12272
12272))}}async startLiveStreamingTask(e,t,i){if(!this.transcodingConfig&&t===SU.TRANSCODE)throw new tD(Ew.INVALID_OPERATION,"[LiveStreaming] no transcoding config found, can not start transcoding streaming task");const n={command:"PublishStream",ts:Date.now(),url:e,uid:this.spec.uid.toString(),autoDestroyTime:100,acceptImageTimeout:!0};YN.debug("[".concat(this.spec.clientId,"] start live streaming ").concat(e,", mode: ").concat(t));const r=await this.taskMutex.lock();if(!this.connection&&i)return void r();if(this.streamingTasks.get(e)&&!i)return r(),new tD(Ew.LIVE_STREAMING_TASK_CONFLICT).throw();try{this.connection||(this.connection=await this.connect(t))}catch(e){throw r(),e}switch(t){case SU.TRANSCODE:n.transcodingConfig=kY({},this.transcodingConfig);case SU.RAW:}this.uapResponse&&this.uapResponse.vid&&(n.vid=this.uapResponse.vid),this.isStartingStreamingTask=!0;const o=this.lastTaskId++;try{const s=new Wh(((t,n)=>{uO(this.retryTimeout).then((()=>{if(i)return n(i);const t=this.statusError.get(e);return t?(this.statusError.delete(e),n(t)):void 0}))})),a=await Wh.race([this.connection.request("request",{clientRequest:n},!0,{url:e,command:"PublishStream",workerType:t===SU.TRANSCODE?1:2,requestByUser:!i,tid:o.toString()}),s]);this.isStartingStreamingTask=!1,YN.debug("[".concat(this.spec.clientId,"] live streaming started, code: ").concat(a.code)),this.streamingTasks.set(e,{clientRequest:n,mode:t,url:e,taskId:o}),r()}catch(n){if(r(),this.isStartingStreamingTask=!1,!n.data||!n.data.retry||i)throw n;return n.data.changeAddress?(this.connection.tryNextAddress(),await this.startLiveStreamingTask(e,t,n)):await this.startLiveStreamingTask(e,t,n)}}stopLiveStreamingTask(e){return new Wh(((t,i)=>{const n=this.streamingTasks.get(e);if(!n||!this.connection)return new tD(Ew.UNEXPECTED_ERROR,"can not find streaming task to stop").throw();const r=n.mode;n.abortTask=()=>{YN.debug("[".concat(this.spec.clientId,"] stop live streaming success(worker exception)")),this.streamingTasks.delete(e),t()},this.connection.request("request",{clientRequest:{command:"UnpublishStream",url:n.url}},!1,{url:e,command:"UnPublishStream",workerType:r===SU.TRANSCODE?1:2,requestByUser:!0,tid:(this.lastTaskId++).toString()}).then((i=>{YN.debug("[".concat(this.spec.clientId,"] stop live streaming success, code: ").concat(i.code)),this.streamingTasks.delete(e),0===this.streamingTasks.size&&(this.connection&&this.connection.close(),this.connection=void 0),t()})).catch(i)}))}resetAllTask(){var e;const t=Array.from(Zh(e=this.streamingTasks).call(e));this.terminate();for(const e of t)this.startLiveStreamingTask(e.url,e.mode).catch((t=>{this.onLiveStreamError&&this.onLiveStreamError(e.url,t)}))}terminate(){this.cancelToken&&this.cancelToken.cancel(),this.streamingTasks=new Map,this.isStartingStreamingTask=!1,this.statusError=new Map,this.cancelToken=Ab.CancelToken.source(),this.uapResponse=void 0,this.connection&&this.connection.close(),this.connection=void 0}async connect(e){if(this.connection)throw new tD(Ew.UNEXPECTED_ERROR,"live streaming connection has already connected");const t=await Yw(this,yU.REQUEST_WORKER_MANAGER_LIST,e);return this.uapResponse=t,this.connection=new PY(t.workerToken,this.spec,this.wsRetryConfig,e),this.connection.on(IU.WARNING,((e,t)=>this.onLiveStreamWarning&&this.onLiveStreamWarning(t,e))),this.connection.on(IU.PUBLISH_STREAM_STATUS,(e=>this.handlePublishStreamServer(e))),this.connection.on(IU.REQUEST_NEW_ADDRESS,((t,i)=>{if(!this.connection)return i(new tD(Ew.UNEXPECTED_ERROR,"can not get new live streaming address list"));Yw(this,yU.REQUEST_WORKER_MANAGER_LIST,e).then((e=>{this.uapResponse=e,t(e.addressList)})).catch(i)})),await this.connection.init(t.addressList),this.connection}handlePublishStreamServer(e){const t=e.serverStatus&&e.serverStatus.url||"empty_url",i=this.streamingTasks.get(t),n=e.reason;switch(e.code){case AU.PUBLISH_STREAM_STATUS_ERROR_PUBLISH_BROKEN:case AU.PUBLISH_STREAM_STATUS_ERROR_RTMP_CONNECT:case AU.PUBLISH_STREAM_STATUS_ERROR_RTMP_HANDSHAKE:case AU.PUBLISH_STREAM_STATUS_ERROR_RTMP_PUBLISH:{const n=new tD(Ew.LIVE_STREAMING_CDN_ERROR,"",{code:e.code});if(i)return YN.error(n.toString()),this.onLiveStreamError&&this.onLiveStreamError(t,n);if(!this.isStartingStreamingTask)return;this.statusError.set(t,n)}case AU.LIVE_STREAM_RESPONSE_FAILED_LOAD_IMAGE:{const e=new tD(Ew.LIVE_STREAMING_WARN_FAILED_LOAD_IMAGE,n);return this.onLiveStreamWarning&&this.onLiveStreamWarning(t,e)}case AU.LIVE_STREAM_RESPONSE_WORKER_LOST:case AU.LIVE_STREAM_RESPONSE_WORKER_QUIT:{var r;if(!this.connection)return;this.connection.tryNextAddress();const t=Array.from(Zh(r=this.streamingTasks).call(r));for(const i of t)i.abortTask?i.abortTask():(YN.warning("[".concat(this.spec.clientId,"] publish stream status code"),e.code,"try to republish",i.url),this.startLiveStreamingTask(i.url,i.mode,new tD(Ew.LIVE_STREAMING_INTERNAL_SERVER_ERROR,"",{code:e.code})).then((()=>{YN.debug("[".concat(this.spec.clientId,"] republish live stream success"),i.url)})).catch((e=>{YN.error(e.toString()),this.onLiveStreamError&&this.onLiveStreamError(i.url,e)})));return}}}hasUrl(e){return this.streamingTasks.has(e)}}const UY={name:"LiveStreaming",create:function(e){return new MY(e.joinInfo,e.websocketRetryConfig||AO,e.httpRetryConfig||AO)}};function xY(e){let t=zY();return function(e,t){let i=e.appId;void 0!==i&&(cq(t,10),tq(t,i));let n=e.cid;void 0!==n&&(cq(t,16),cq(t,n));let r=e.cname;void 0!==r&&(cq(t,26),tq(t,r));let o=e.deviceId;void 0!==o&&(cq(t,34),tq(t,o));let s=e.elapse;void 0!==s&&(cq(t,40),dq(t,s));let a=e.fileSize;void 0!==a&&(cq(t,48),dq(t,YY(a)));let c=e.height;void 0!==c&&(cq(t,56),dq(t,YY(c)));let d=e.jpg;void 0!==d&&(cq(t,66),cq(t,d.length),function(e,t){let i=ZY(e,t.length);e.bytes.set(t,i)}(t,d));let l=e.networkType;void 0!==l&&(cq(t,72),dq(t,YY(l)));let u=e.osType;void 0!==u&&(cq(t,80),dq(t,YY(u)));let h=e.requestId;void 0!==h&&(cq(t,90),tq(t,h));let p=e.sdkVersion;void 0!==p&&(cq(t,98),tq(t,p));let _=e.sequence;void 0!==_&&(cq(t,104),dq(t,YY(_)));let E=e.sid;void 0!==E&&(cq(t,114),tq(t,E));let m=e.timestamp;void 0!==m&&(cq(t,120),dq(t,m));let f=e.uid;void 0!==f&&(cq(t,128),cq(t,f));let T=e.vid;void 0!==T&&(cq(t,136),cq(t,T));let S=e.width;void 0!==S&&(cq(t,144),dq(t,YY(S)));let g=e.service;void 0!==g&&(cq(t,152),cq(t,g));let R=e.callbackData;void 0!==R&&(cq(t,162),tq(t,R));let v=e.jpgEncryption;void 0!==v&&(cq(t,168),cq(t,v));let C=e.requestType;void 0!==C&&(cq(t,176),cq(t,C));let I=e.scorePorn;void 0!==I&&(cq(t,185),sq(t,I));let y=e.scoreSexy;void 0!==y&&(cq(t,193),sq(t,y));let A=e.scoreNeutral;void 0!==A&&(cq(t,201),sq(t,A));let b=e.scene;void 0!==b&&(cq(t,208),cq(t,b));let w=e.ossFilePrefix;void 0!==w&&(cq(t,218),tq(t,w));let O=e.serviceVendor;if(void 0!==O)for(let e of O){cq(t,226);let i=zY();BY(e,i),cq(t,i.limit),iq(t,i),XY(i)}}(e,t),function(e){let t=e.bytes,i=e.limit;return t.length===i?t:t.subarray(0,i)}(t)}function VY(e){return function(e){let t={};e:for(;!QY(e);){let i=aq(e);switch(i>>>3){case 0:break e;case 1:t.code=aq(e);break;case 2:t.msg=eq(e,aq(e));break;case 3:{let i=jY(e);t.data=FY(e),e.limit=i;break}default:GY(e,7&i)}}return t}({bytes:t=e,offset:0,limit:t.length});var t}function FY(e){let t={};e:for(;!QY(e);){let i=aq(e);switch(i>>>3){case 0:break e;case 1:t.requestId=eq(e,aq(e));break;case 2:t.requestType=aq(e)>>>0;break;case 3:t.scorePorn=oq(e);break;case 4:t.scoreSexy=oq(e);break;case 5:t.scoreNeutral=oq(e);break;case 6:t.requestScene=aq(e)>>>0;break;case 7:t.scene=aq(e)>>>0;break;default:GY(e,7&i)}}return t}function BY(e,t){let i=e.service;void 0!==i&&(cq(t,8),cq(t,i));let n=e.vendor;void 0!==n&&(cq(t,16),cq(t,n));let r=e.token;void 0!==r&&(cq(t,26),tq(t,r));let o=e.callbackUrl;void 0!==o&&(cq(t,34),tq(t,o))}function jY(e){let t=aq(e),i=e.limit;return e.limit=e.offset+t,i}function GY(e,t){switch(t){case 0:for(;128&nq(e););break;case 2:JY(e,aq(e));break;case 5:JY(e,4);break;case 1:JY(e,8);break;default:throw new Error("Unimplemented type: "+t)}}let WY=new Float32Array(1);new Uint8Array(WY.buffer);let HY=new Float64Array(1),KY=new Uint8Array(HY.buffer);function YY(e){return{low:e|=0,high:e>>31,unsigned:e>=0}}let qY=[];function zY(){const e=qY.pop();return e?(e.offset=e.limit=0,e):{bytes:new Uint8Array(64),offset:0,limit:0}}function XY(e){qY.push(e)}function JY(e,t){if(e.offset+t>e.limit)throw new Error("Skip past limit");e.offset+=t}function QY(e){return e.offset>=e.limit}function ZY(e,t){let i=e.bytes,n=e.offset,r=e.limit,o=n+t;if(o>i.length){let t=new Uint8Array(2*o);t.set(i),e.bytes=t}return e.offset=o,o>r&&(e.limit=o),n}function $Y(e,t){let i=e.offset;if(i+t>e.limit)throw new Error("Read past limit");return e.offset+=t,i}function eq(e,t){let i=$Y(e,t),n=String.fromCharCode,r=e.bytes,o="�",s="";for(let e=0;e<t;e++){let a,c,d,l,u=r[e+i];0==(128&u)?s+=n(u):192==(224&u)?e+1>=t?s+=o:(a=r[e+i+1],128!=(192&a)?s+=o:(l=(31&u)<<6|63&a,l<128?s+=o:(s+=n(l),e++))):224==(240&u)?e+2>=t?s+=o:(a=r[e+i+1],c=r[e+i+2],32896!=(49344&(a|c<<8))?s+=o:(l=(15&u)<<12|(63&a)<<6|63&c,l<2048||l>=55296&&l<=57343?s+=o:(s+=n(l),e+=2))):240==(248&u)?e+3>=t?s+=o:(a=r[e+i+1],c=r[e+i+2],d=r[e+i+3],8421504!=(12632256&(a|c<<8|d<<16))?s+=o:(l=(7&u)<<18|(63&a)<<12|(63&c)<<6|63&d,l<65536||l>1114111?s+=o:(l-=65536,s+=n(55296+(l>>10),56320+(1023&l)),e+=3))):s+=o}return s}function tq(e,t){let i=t.length,n=0;for(let e=0;e<i;e++){let r=t.charCodeAt(e);r>=55296&&r<=56319&&e+1<i&&(r=(r<<10)+t.charCodeAt(++e)-56613888),n+=r<128?1:r<2048?2:r<65536?3:4}cq(e,n);let r=ZY(e,n),o=e.bytes;for(let e=0;e<i;e++){let n=t.charCodeAt(e);n>=55296&&n<=56319&&e+1<i&&(n=(n<<10)+t.charCodeAt(++e)-56613888),n<128?o[r++]=n:(n<2048?o[r++]=n>>6&31|192:(n<65536?o[r++]=n>>12&15|224:(o[r++]=n>>18&7|240,o[r++]=n>>12&63|128),o[r++]=n>>6&63|128),o[r++]=63&n|128)}}function iq(e,t){let i=ZY(e,t.limit),n=e.bytes,r=t.bytes;for(let e=0,o=t.limit;e<o;e++)n[e+i]=r[e]}function nq(e){return e.bytes[$Y(e,1)]}function rq(e,t){let i=ZY(e,1);e.bytes[i]=t}function oq(e){let t=$Y(e,8),i=e.bytes;return KY[0]=i[t++],KY[1]=i[t++],KY[2]=i[t++],KY[3]=i[t++],KY[4]=i[t++],KY[5]=i[t++],KY[6]=i[t++],KY[7]=i[t++],HY[0]}function sq(e,t){let i=ZY(e,8),n=e.bytes;HY[0]=t,n[i++]=KY[0],n[i++]=KY[1],n[i++]=KY[2],n[i++]=KY[3],n[i++]=KY[4],n[i++]=KY[5],n[i++]=KY[6],n[i++]=KY[7]}function aq(e){let t,i=0,n=0;do{t=nq(e),i<32&&(n|=(127&t)<<i),i+=7}while(128&t);return n}function cq(e,t){for(t>>>=0;t>=128;)rq(e,127&t|128),t>>>=7;rq(e,t)}function dq(e,t){let i=t.low>>>0,n=(t.low>>>28|t.high<<4)>>>0,r=t.high>>>24,o=0===r?0===n?i<16384?i<128?1:2:i<1<<21?3:4:n<16384?n<128?5:6:n<1<<21?7:8:r<128?9:10,s=ZY(e,o),a=e.bytes;switch(o){case 10:a[s+9]=r>>>7&1;case 9:a[s+8]=9!==o?128|r:127&r;case 8:a[s+7]=8!==o?n>>>21|128:n>>>21&127;case 7:a[s+6]=7!==o?n>>>14|128:n>>>14&127;case 6:a[s+5]=6!==o?n>>>7|128:n>>>7&127;case 5:a[s+4]=5!==o?128|n:127&n;case 4:a[s+3]=4!==o?i>>>21|128:i>>>21&127;case 3:a[s+2]=3!==o?i>>>14|128:i>>>14&127;case 2:a[s+1]=2!==o?i>>>7|128:i>>>7&127;case 1:a[s]=1!==o?128|i:127&i}}function lq(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}const uq=new Map([["moderation",1],["supervise",2]]);class hq extends Dw{get connectionState(){return this._connectionState}set connectionState(e){if(this._connectionState===e)return;const t=this._connectionState;this._connectionState=e,this.emit($U.CONNECTION_STATE_CHANGE,t,e)}get inspectType(){return this._inspectType}set inspectType(e){var t;this._inspectMode=Xn(t=e.map((e=>uq.get(e)||0))).call(t,((e,t)=>e+t)),this._inspectType=e}get quality(){return this._quality}set quality(e){this._quality=e>1?1:e<.1?.1:e,this.qualityTimer&&(window.clearTimeout(this.qualityTimer),this.qualityTimer=null),this._quality>=1||(this.qualityTimer=window.setTimeout((()=>{this.quality=this._quality/this.qualityRatio}),6e4))}constructor(e){super(),QI(this,"name","AgoraRTCVideoContentInspect"),QI(this,"_connectionState",QU.CONNECTING),QI(this,"_innerConnectionState",void 0),QI(this,"sequence",0),QI(this,"inspectStartTime",void 0),QI(this,"workerManagerConnection",void 0),QI(this,"workerConnection",void 0),QI(this,"workerMessageLengthLimit",void 0),QI(this,"inspectIntervalMinimum",void 0),QI(this,"qualityRatio",void 0),QI(this,"_connectInfo",void 0),QI(this,"_cancelTokenSource",Ab.CancelToken.source()),QI(this,"_retryConfig",void 0),QI(this,"wmSequence",0),QI(this,"inspectInterval",void 0),QI(this,"inspectTimer",null),QI(this,"ossFilePrefix",void 0),QI(this,"extraInfo",void 0),QI(this,"_inspectType",void 0),QI(this,"_inspectMode",void 0),QI(this,"_quality",1),QI(this,"qualityTimer",null),QI(this,"_inspectId",void 0),QI(this,"_needWorkUrlOnly",!1),QI(this,"inspectImage",(()=>{if(this.connectionState!==QU.CONNECTED)throw new tD(Ew.OPERATION_ABORTED,"content inspect service connection status is ".concat(this.connectionState));this.inspectTimer&&(window.clearInterval(this.inspectTimer),this.inspectTimer=null),this.inspectTimer=window.setInterval((()=>{this.connectionState===QU.CONNECTED?this.requestToInspectImage():YN.debug("[".concat(this._inspectId,"] Inspect State is not connected , "),this.connectionState)}),this.inspectInterval<this.inspectIntervalMinimum?this.inspectIntervalMinimum:this.inspectInterval),this.requestToInspectImage()})),this._inspectId=hO(5,"inspect-"),this.workerMessageLengthLimit=_N("VIDEO_INSPECT_WORKER_MESSAGE_LENGTH_LIMIT"),this.inspectIntervalMinimum=_N("VIDEO_INSPECT_INTERVAL_MINIMUM"),this.qualityRatio=_N("VIDEO_INSPECT_QUALITY_RATIO"),this.inspectInterval=e.interval,this.ossFilePrefix=e.ossFilePrefix,this.extraInfo=e.extraInfo,this.inspectType=e.inspectType,this.inspectStartTime=Number(Date.now()),this.workerManagerConnection=new yx("worker-manager-"+this._inspectId,AO),this.on($U.STATE_CHANGE,((e,t)=>{this._innerConnectionState=e,YN.debug("[".concat(this._inspectId,"] Inspect operation :").concat(ZU[e]," ").concat(t||""))})),this.handleWorkerManagerEvents(),this.workerConnection=new yx("worker-"+this._inspectId,AO),this.handleWorkerEvents()}async init(e,t){this.emit($U.STATE_CHANGE,ZU.CONNECT_AP),this._connectInfo=e;const i=this._cancelTokenSource.token;return this._retryConfig=t,new Wh(((n,r)=>{this.on($U.CONNECTION_STATE_CHANGE,((e,t)=>{t===QU.CONNECTED&&n()})),this.requestAP(e,i,t).then((e=>{this.connectWorkerManager(e)})).catch((e=>{r(e)}))}))}async requestAP(e,t,i){const n=_N("WEBCS_DOMAIN").map((e=>"https://".concat(e,"/api/v1"))),r=await function(e,t,i,n){let{appId:r,areaCode:o,cname:s,sid:a,token:c,uid:d}=t;eF++;const l="image_moderation_api",u={service_name:l,json_body:JSON.stringify({appId:r,areaCode:o,cname:s,command:"allocateEdge",requestId:eF,seq:eF,sid:a,token:c,ts:Date.now(),uid:d+""})};let h,p,_=e[0];return wO((async()=>{h=Date.now();const e=await PV(_,{data:u,cancelToken:i,headers:{"X-Packet-Service-Type":"0","X-Packet-URI":"61"},params:{action:"wrtc_gateway"}});if(p=Date.now()-h,0!==e.code){const t=new tD(Ew.UNEXPECTED_RESPONSE,"image inspect ap error, code"+e.code,{retry:!0,responseTime:p});throw YN.error(t.toString()),t}const t=JSON.parse(e.json_body);if(200!==t.code){const e=new tD(Ew.UNEXPECTED_RESPONSE,"image inspect ap error, code: ".concat(t.code,", reason: ").concat(t.reason),{code:t.code,responseTime:p});throw YN.error(e.toString()),e}if(!t.servers||!Array.isArray(t.servers)||0===t.servers.length){const e=new tD(Ew.UNEXPECTED_RESPONSE,"image inspect ap empty server",{code:t.code,responseTime:p});throw YN.error(e.toString()),e}const n=_N("VIDEO_INSPECT_WORKER_MANAGER_HOST"),r=_N("VIDEO_INSPECT_WORKER_MANAGER_PORT");return{addressList:t.servers.map((e=>{let{address:t,wss:i}=e;if(t&&i)return"wss://".concat(t.replace(/\./g,"-"),".").concat(n,":").concat(r||i)})).filter((e=>!!e)),workerToken:t.workerToken,vid:t.vid,responseTime:p}}),((t,i)=>(eD.apworkerEvent(a,{success:!0,sc:200,serviceName:l,responseDetail:JSON.stringify(t.addressList),firstSuccess:0===i,responseTime:p,serverIp:e[i%e.length]}),!1)),((t,i)=>(eD.apworkerEvent(a,{success:!1,sc:t.data&&t.data.code||200,serviceName:l,responseTime:p,serverIp:e[i%e.length]}),!!(t.code!==Ew.OPERATION_ABORTED&&t.code!==Ew.UNEXPECTED_RESPONSE||t.data&&t.data.retry)&&(_=e[(i+1)%e.length],!0))),n)}(n,e,t,i);this.emit($U.STATE_CHANGE,ZU.AP_CONNECTED);const{addressList:o}=r;return this.wmSequence++,o}async connectWorkerManager(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._needWorkUrlOnly=t,this.emit($U.STATE_CHANGE,ZU.CONNECT_WORKER_MANAGER),await this.workerManagerConnection.init(e,1e4)}async connectWorker(e){await this.workerConnection.init([e])}handleWorkerManagerEvents(){this.workerManagerConnection.on(mU.CONNECTED,(async()=>{this.emit($U.STATE_CHANGE,ZU.WORKER_MANAGER_CONNECTED,this.workerManagerConnection.url),this.workerManagerConnection.sendMessage({appId:this._connectInfo.appId,cname:this._connectInfo.cname,uid:this._connectInfo.uid+"",sdkVersion:"4.23.2",sid:this._connectInfo.sid,seq:this.wmSequence,ts:Number(Date.now()),requestId:Math.floor(1e12*Math.random()),allocate:!0,clientRequest:{command:"join"}},!0)})),this.workerManagerConnection.on(mU.CLOSED,(()=>{this._innerConnectionState<ZU.GET_WORKER_MANAGER_RESPONSE&&YN.debug("[".concat(this._inspectId,"] Inspect worker manager is closed before connecting worker"))})),this.workerManagerConnection.on(mU.FAILED,(()=>{this._innerConnectionState<ZU.GET_WORKER_MANAGER_RESPONSE&&YN.debug("[".concat(this._inspectId,"] Connecting inspect worker manager is failed before connecting worker"))})),this.workerManagerConnection.on(mU.RECONNECTING,(()=>{this._innerConnectionState<ZU.GET_WORKER_MANAGER_RESPONSE&&YN.debug("[".concat(this._inspectId,"] Inspect worker manager is reconnecting before connecting worker"))})),this.workerManagerConnection.on(mU.ON_MESSAGE,(async e=>{this.emit($U.STATE_CHANGE,ZU.GET_WORKER_MANAGER_RESPONSE);const t=this.workerManagerConnection.url;this.workerManagerConnection.close();const i=JSON.parse(e.data);if(200!==i.code)throw YN.error("[".concat(this._inspectId,"] Unexpected code ").concat(i.code," from worker manager")),new tD(Ew.UNEXPECTED_RESPONSE,"response code of worker is unexpected",i);if(!(i.serverResponse&&i.serverResponse.portWss&&t))throw YN.error("[".concat(this._inspectId,"] Unexpected content from worker manager : ").concat(JSON.stringify(i))),new tD(Ew.UNEXPECTED_RESPONSE,"response content of worker is unexpected",i);{const e=_N("VIDEO_INSPECT_WORKER_PORT")||i.serverResponse.portWss,n=t.replace(/:\d+\/?$/,":".concat(e));this.emit($U.STATE_CHANGE,ZU.CONNECT_WORKER,n),this._needWorkUrlOnly?this.emit($U.REQUEST_NEW_WORKER_URL,n):await this.connectWorker(n)}})),this.workerManagerConnection.on(mU.WILL_RECONNECT,((e,t,i)=>{i(e)})),this.workerManagerConnection.on(mU.REQUEST_NEW_URLS,((e,t)=>{this.requestAP(this._connectInfo,this._cancelTokenSource.token,this._retryConfig).then(e).catch(t)}))}handleWorkerEvents(){this.workerConnection.on(mU.CONNECTED,(async()=>{this.emit($U.STATE_CHANGE,ZU.WORKER_CONNECTED,this.workerConnection.url),this.connectionState=QU.CONNECTED})),this.workerConnection.on(mU.ON_MESSAGE,(async e=>{if(e.data instanceof ArrayBuffer){const i=VY(new Uint8Array(e.data));if(_N("SHOW_VIDEO_INSPECT_WORKER_MESSAGE")&&YN.debug("[".concat(this._inspectId,"] Response message for worker of inspect content "),JSON.stringify(i)),200===i.code){if(Array.isArray(this.inspectType)&&1===this.inspectType.length&&"supervise"===this.inspectType[0])return void this.emit($U.INSPECT_RESULT,void 0,void 0);if(i.data&&i.data.scorePorn&&i.data.scoreSexy&&i.data.scoreNeutral){var t;const e={porn:i.data.scorePorn,sexy:i.data.scoreSexy,neutral:i.data.scoreNeutral},n=Xn(t=Object.keys(e)).call(t,((t,i)=>e[t]>e[i]?t:i),"porn"),r=Object.keys(e).find((e=>e===n));this.emit($U.INSPECT_RESULT,r)}else this.emit($U.INSPECT_RESULT,void 0,new tD(Ew.UNEXPECTED_RESPONSE,i.code+"","There is an unexpected data on message"))}else this.emit($U.INSPECT_RESULT,void 0,new tD(Ew.UNEXPECTED_RESPONSE,i.code+"",i.msg))}else YN.error("[".concat(this._inspectId,"] Unexpected message type from worker")),this.emit($U.INSPECT_RESULT,void 0,new tD(Ew.UNEXPECTED_RESPONSE,"invalid worker message type"))})),this.workerConnection.on(mU.CLOSED,(()=>{this.connectionState=QU.CLOSED})),this.workerConnection.on(mU.FAILED,(()=>{this.connectionState=QU.CLOSED})),this.workerConnection.on(mU.RECONNECTING,(()=>{this.connectionState=this.connectionState===QU.CONNECTED?QU.RECONNECTING:QU.CONNECTING})),this.workerConnection.on(mU.WILL_RECONNECT,((e,t,i)=>{"recover"===e&&i(e),i("tryNext")})),this.workerConnection.on(mU.REQUEST_NEW_URLS,((e,t)=>{this.workerManagerConnection.close(),this.once($U.REQUEST_NEW_WORKER_URL,(t=>{e([t])})),this.requestAP(this._connectInfo,this._cancelTokenSource.token,this._retryConfig).then((e=>{this.connectWorkerManager(e,!0)})).catch((e=>{t(e)}))}))}async requestToInspectImage(){this.sequence++;const e=zw(this,$U.CLIENT_LOCAL_VIDEO_TRACK),t={appId:this._connectInfo.appId,cname:this._connectInfo.cname,cid:this._connectInfo.cid,sid:this._connectInfo.sid,uid:this._connectInfo.uid,vid:this._connectInfo.vid};if(e){if(!e.isPlaying)return void this.emit($U.INSPECT_RESULT,void 0,new tD(Ew.INVALID_OPERATION,"Only the track being played can be inspected"));const i=await this.generateRequestData(e,t);this.workerConnection.sendMessage(i,!0,!0)}else this.emit($U.INSPECT_RESULT,void 0,new tD(Ew.INVALID_OPERATION,"Only the track being published can be inspected"))}async generateRequestData(e,t){let{appId:i,cname:n,cid:r,vid:o,sid:s,uid:a}=t;const c=Date.now(),d=await e.getCurrentFrameImage("image/jpeg",this.quality),l=await MP(d,i,n),u=this.sequence+"-"+r+"-"+a+"-"+c+"-"+hO(12,""),h={appId:i,cid:r,cname:n,deviceId:"",elapse:(p=Number(c-this.inspectStartTime),{low:p|=0,high:p>>31,unsigned:p>=0}),fileSize:l.byteLength,jpgEncryption:2,height:d.height,width:d.width,jpg:l,networkType:6,osType:7,requestId:u,sdkVersion:"4.23.2",sequence:this.sequence,sid:s,timestamp:Gj(c),uid:a,vid:o,service:this._inspectMode,callbackData:this.extraInfo,ossFilePrefix:this.ossFilePrefix};var p;void 0===this.extraInfo&&delete h.callbackData,void 0===this.ossFilePrefix&&delete h.ossFilePrefix;const _=xY(h);if(_.byteLength<this.workerMessageLengthLimit){if(_N("SHOW_VIDEO_INSPECT_WORKER_MESSAGE")){const e=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?lq(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):lq(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({},h);delete e.jpg,YN.debug("[".concat(this._inspectId,"] Request message for worker of inspect content "),JSON.stringify(e))}return _}{const t=this.quality*this.qualityRatio;return this.quality=t,await this.generateRequestData(e,{appId:i,cname:n,cid:r,vid:o,sid:s,uid:a})}}close(){this._cancelTokenSource.cancel(),this._cancelTokenSource=Ab.CancelToken.source(),this.workerManagerConnection&&this.workerManagerConnection.close(),this.workerConnection&&this.workerConnection.close(),this.inspectTimer&&window.clearInterval(this.inspectTimer),this.inspectTimer=null,this.connectionState=QU.CLOSED,this.emit($U.STATE_CHANGE,ZU.CLOSED)}}const pq={name:"ContentInspect",create:function(e){let{config:t}=e;return function(e){if(!e)throw new tD(Ew.INVALID_PARAMS,"inspectConfig is necessary.");if(!e.inspectType||!Array.isArray(e.inspectType))throw new tD(Ew.INVALID_PARAMS,"inspectConfig.inspectType is necessary and is an instance of Array.");{const t=[...new Set(e.inspectType)];t.forEach((e=>{var t;if(!Dn(t=["supervise","moderation"]).call(t,e))throw new tD(Ew.INVALID_PARAMS,"".concat(e," is not a valid inspect type."))})),e.inspectType=t}if(e&&e.extraInfo&&e.extraInfo.length>1024)throw new tD(Ew.INVALID_PARAMS,"inspectConfig.extraInfo length cannot exceed 1024 bytes")}(t),new hq(t)}};var _q=i(ie.Object.getOwnPropertySymbols),Eq=wi,mq=qi.indexOf,fq=Bn,Tq=I([].indexOf),Sq=!!Tq&&1/Tq([1],1,-0)<0;Eq({target:"Array",proto:!0,forced:Sq||!fq("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return Sq?Tq(this,e,t)||0:mq(this,e,t)}});var gq=Ji("Array").indexOf,Rq=l,vq=gq,Cq=Array.prototype,Iq=function(e){var t=e.indexOf;return e===Cq||Rq(Cq,e)&&t===Cq.indexOf?vq:t},yq=i(Iq);function Aq(e,t){if(null==e)return{};var i,n,r=function(e,t){if(null==e)return{};var i,n,r={},o=MM(e);for(n=0;n<o.length;n++)i=o[n],yq(t).call(t,i)>=0||(r[i]=e[i]);return r}(e,t);if(_q){var o=_q(e);for(n=0;n<o.length;n++)i=o[n],yq(t).call(t,i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}let bq=class{get localCapabilities(){return eO(this._localCapabilities)}get rtpCapabilities(){return eO(this._rtpCapabilities)}get candidates(){return eO(this._candidates)}get iceParameters(){return eO(this._iceParameters)}get dtlsParameters(){return eO(this._dtlsParameters)}constructor(e){QI(this,"sessionDesc",void 0),QI(this,"_localCapabilities",void 0),QI(this,"_rtpCapabilities",void 0),QI(this,"_candidates",void 0),QI(this,"_iceParameters",void 0),QI(this,"_dtlsParameters",void 0),QI(this,"setup",void 0),QI(this,"currentMidIndex",void 0),QI(this,"cname","o/i14u9pJrxRKAsu"),QI(this,"firefoxSsrcMidMap",new Map),e=eO(e);const{remoteIceParameters:t,remoteDtlsParameters:i,candidates:n,remoteRTPCapabilities:r,localCapabilities:o,direction:s,setup:a,videoCodec:c,audioCodec:d}=e;let l;this.setup=a,l=s===EU.RECEIVE_ONLY?yN("v=0\no=- 0 0 IN IP4 127.0.0.1\ns=AgoraGateway\nt=0 0\na=group:BUNDLE 0 1\na=msid-semantic: WMS\na=extmap-allow-mixed\nm=video 9 UDP/TLS/RTP/SAVPF 0\nc=IN IP4 127.0.0.1\na=rtcp:9 IN IP4 0.0.0.0\na=sendonly\na=rtcp-mux\na=rtcp-rsize\na=mid:0\nm=audio 9 UDP/TLS/RTP/SAVPF 0\nc=IN IP4 127.0.0.1\na=rtcp:9 IN IP4 0.0.0.0\na=sendonly\na=rtcp-mux\na=rtcp-rsize\na=mid:1\n"):yN("v=0\no=- 0 0 IN IP4 127.0.0.1\ns=AgoraGateway\nt=0 0\na=group:BUNDLE 0 1\na=msid-semantic: WMS\na=extmap-allow-mixed\nm=video 9 UDP/TLS/RTP/SAVPF 0\nc=IN IP4 127.0.0.1\na=rtcp:9 IN IP4 0.0.0.0\na=recvonly\na=rtcp-mux\na=rtcp-rsize\na=mid:0\nm=audio 9 UDP/TLS/RTP/SAVPF 0\nc=IN IP4 127.0.0.1\na=rtcp:9 IN IP4 0.0.0.0\na=recvonly\na=rtcp-mux\na=rtcp-rsize\na=mid:1\n"),this._rtpCapabilities=r,this._candidates=n,this._iceParameters=t,this._dtlsParameters=i,this._localCapabilities=o;const u=s===EU.RECEIVE_ONLY?this.rtpCapabilities.send:this.rtpCapabilities.recv,h=s===EU.RECEIVE_ONLY?this._localCapabilities.recv:this._localCapabilities.send,p=s===EU.RECEIVE_ONLY?r.send.videoCodecs:uV(HU.VIDEO,u,h,c),_=s===EU.RECEIVE_ONLY?r.send.audioCodecs:uV(HU.AUDIO,u,h,d);for(const e of l.mediaDescriptions)e.attributes.iceUfrag=t.iceUfrag,e.attributes.icePwd=t.icePwd,e.attributes.fingerprints=i.fingerprints,e.attributes.candidates=n,e.attributes.setup=this.setup,"application"===e.media.mediaType&&(e.attributes.sctpPort="5000"),"video"===e.media.mediaType&&(e.media.fmts=p.map((e=>e.payloadType.toString(10))),e.attributes.payloads=p,e.attributes.extmaps=u.videoExtensions),"audio"===e.media.mediaType&&(e.media.fmts=_.map((e=>e.payloadType.toString(10))),e.attributes.payloads=_,e.attributes.extmaps=u.audioExtensions,lV(e));this.sessionDesc=l,this.currentMidIndex=l.mediaDescriptions.length-1}toString(){return AN(this.sessionDesc)}hasMid(e){return Array.isArray(e)?e.every((e=>this.hasMid(e))):this.sessionDesc.mediaDescriptions.some((t=>t.attributes.mid===e))}send(e,t,i,n,r){i=i.replace(/ /g,"-");const{ssrcs:o,ssrcGroups:s}=$x(t,this.cname,_N("SYNC_GROUP")?i:void 0),a=this.findPreloadMediaDesc(o);if(a){if(Kb()&&this.firefoxSsrcMidMap.set(o[0].ssrcId,a.attributes.mid),r&&(r.twcc||r.remb)){const e=this.sessionDesc.mediaDescriptions.indexOf(a);return this.sessionDesc.mediaDescriptions[e]=this.mungSendMediaDesc(a,r),{mid:a.attributes.mid,needExchangeSDP:!0}}return{mid:a.attributes.mid,needExchangeSDP:!1}}{const t=this.findAvailableMediaIndex(e,o,n);let i;return-1===t?(i=this.createOrRecycleSendMedia(e,o,s,"sendonly",n,r),this.updateBundleMids()):(i=eO(this.sessionDesc.mediaDescriptions[t]),i.attributes.direction="sendonly",i.attributes.ssrcs=o,i.attributes.ssrcGroups=s,this.sessionDesc.mediaDescriptions[t]=this.mungSendMediaDesc(i,r)),Kb()&&this.firefoxSsrcMidMap.set(o[0].ssrcId,i.attributes.mid),{needExchangeSDP:!0,mid:i.attributes.mid}}}stopSending(e){const t=this.sessionDesc.mediaDescriptions.filter((t=>t.attributes.mid&&-1!==e.indexOf(t.attributes.mid)));if(t.length!==e.length)throw new Error("mediaDescriptions' length doesn't match mids' length when calling RemoteSDP.stopSending.");t.forEach((e=>{e.attributes.ssrcs=[]})),this.updateBundleMids()}receive(e,t,i){const n=[];return e.forEach((e=>{const r=e._mediaStreamTrack.kind,o=this.findAvailableRecvMediaIndex(r);let s,a=!1;-1===o?(a=!0,s=this.createOrRecycleRecvMedia(e,[],"recvonly",t,i),this.updateBundleMids()):(s=eO(this.sessionDesc.mediaDescriptions[o]),s.attributes.direction="recvonly"),n.push({mid:s.attributes.mid,needCreateTransceiver:a})})),n}stopReceiving(e){const t=this.sessionDesc.mediaDescriptions.filter((t=>-1!==e.indexOf(t.attributes.mid)));if(t.length!==e.length)throw new Error("MediaDescriptions' length doesn't match mids's length
12272when calling RemoteSDP.receive.");t.forEach((e=>{e.media.port="0",e.attributes.direction="inactive"})),this.updateBundleMids()}addRemoteCandidate(e){const{foundation:t,protocol:i,address:n,port:r,type:o,relatedAddress:s,relatedPort:a,priority:c}=new RTCIceCandidate(e),d={foundation:null!=t?t:"",componentId:"1",transport:null!=i?i:"",priority:c?c+"":"",connectionAddress:null!=n?n:"",port:r?r+"":"",type:o?o+"":"",relAddr:null!=s?s:"",relPort:a?a+"":"",extension:{}};this.candidates.some((e=>e.priority===d.priority&&e.connectionAddress===d.connectionAddress&&e.port===d.port))||(this._candidates.push(d),this.sessionDesc.mediaDescriptions.forEach((e=>{e.attributes.candidates=this.candidates})))}clearRemoteCandidate(){this._candidates=[],this.sessionDesc.mediaDescriptions[0].attributes.candidates=this._candidates}createOrRecycleRecvMedia(e,t,i,n,r){const o=e._mediaStreamTrack.kind,s=this.rtpCapabilities.recv,a=uV(o,s,this.localCapabilities.send,o===HU.AUDIO?r:n),c=o===HU.VIDEO?s.videoExtensions:s.audioExtensions,d="".concat(++this.currentMidIndex);let l={media:{mediaType:o,port:"9",protos:["UDP","TLS","RTP","SAVPF"],fmts:a.map((e=>e.payloadType.toString(10)))},connections:[{nettype:"IN",addrtype:"IP4",address:"127.0.0.1"}],bandwidths:[],attributes:{iceUfrag:this.iceParameters.iceUfrag,icePwd:this.iceParameters.icePwd,unrecognized:[],candidates:[],extmaps:c,fingerprints:this.dtlsParameters.fingerprints,imageattr:[],msids:[],remoteCandidatesList:[],rids:[],ssrcs:t,ssrcGroups:[],rtcpFeedbackWildcards:[],payloads:a,rtcp:{port:"9",netType:"IN",addressType:"IP4",address:"0.0.0.0"},setup:this.setup,direction:i,rtcpMux:!0,rtcpRsize:!0,mid:"".concat(d)}};l=this.mungRecvMediaDsec(l,e);const u=this.findFirstClosedMedia(o);if(u){const e=this.sessionDesc.mediaDescriptions.indexOf(u);this.sessionDesc.mediaDescriptions[e]=l}else this.sessionDesc.mediaDescriptions.push(l);return l}muteRemote(e){const t=this.sessionDesc.mediaDescriptions.filter((t=>Dn(e).call(e,t.attributes.mid||"")));if(t.length!==e.length)throw new Error("mediaDescriptions' length doesn't match mids' length when calling RemoteSDP.muteRemote.");t.forEach((e=>{e.attributes.direction="inactive"}))}unmuteRemote(e){const t=this.sessionDesc.mediaDescriptions.filter((t=>Dn(e).call(e,t.attributes.mid||"")));if(t.length!==e.length)throw new Error("mediaDescriptions' length doesn't match mids' length when calling RemoteSDP.muteRemote.");t.forEach((e=>{e.attributes.direction="recvonly"}))}findAvailableMediaIndex(e,t,i){return this.sessionDesc.mediaDescriptions.findIndex((n=>{const r=n.media.mediaType===e&&"0"!==n.media.port&&("sendonly"===n.attributes.direction||"sendrecv"===n.attributes.direction)&&0===n.attributes.ssrcs.length;if(Kb()){if(r){const e=this.firefoxSsrcMidMap.get(t[0].ssrcId);return!(e||"0"!==n.attributes.mid&&"1"!==n.attributes.mid)||!(!e||e!==n.attributes.mid)}return!1}return r&&n.attributes.mid===i}))}findAvailableRecvMediaIndex(e){return this.sessionDesc.mediaDescriptions.findIndex((t=>{const i=t.media.mediaType===e&&"0"!==t.media.port&&("recvonly"===t.attributes.direction||"sendrecv"===t.attributes.direction);return"0"!==t.attributes.mid&&"1"!==t.attributes.mid&&i}))}predictReceivingMids(e){const t=[];for(let i=0;i<e;i++)t.push((this.currentMidIndex+i+1).toString(10));return t}restartICE(e){e=eO(e),this._iceParameters=e,this.sessionDesc.mediaDescriptions.forEach((t=>{t.attributes.iceUfrag=e.iceUfrag,t.attributes.icePwd=e.icePwd}))}createOrRecycleSendMedia(e,t,i,n,r,o){const s=this.rtpCapabilities.send,a=e===HU.VIDEO?s.videoCodecs:s.audioCodecs,c=e===HU.VIDEO?s.videoExtensions:s.audioExtensions;Kb()&&(r="".concat(++this.currentMidIndex));let d={media:{mediaType:e,port:"9",protos:["UDP","TLS","RTP","SAVPF"],fmts:a.map((e=>e.payloadType.toString(10)))},connections:[{nettype:"IN",addrtype:"IP4",address:"127.0.0.1"}],bandwidths:[],attributes:{iceUfrag:this.iceParameters.iceUfrag,icePwd:this.iceParameters.icePwd,unrecognized:[],candidates:[],extmaps:c,fingerprints:this.dtlsParameters.fingerprints,imageattr:[],msids:[],remoteCandidatesList:[],rids:[],ssrcs:t,ssrcGroups:i,rtcpFeedbackWildcards:[],payloads:a,rtcp:{port:"9",netType:"IN",addressType:"IP4",address:"0.0.0.0"},setup:this.setup,direction:n,rtcpMux:!0,rtcpRsize:!0,mid:r}};d=this.mungSendMediaDesc(d,o);const l=this.findFirstClosedMedia(e);if(l){const e=this.sessionDesc.mediaDescriptions.indexOf(l);this.sessionDesc.mediaDescriptions[e]=d}else this.sessionDesc.mediaDescriptions.push(d);return d}mungRecvMediaDsec(e,t,i){const n=eO(e);return tV(n),eV(n,t),iV(n,t),nV(n),rV(n,i,this.localCapabilities.send),n}mungSendMediaDesc(e,t){const i=eO(e);return rV(i,t,this.localCapabilities.recv),lV(i),i}updateRecvMedia(e,t){const i=this.sessionDesc.mediaDescriptions.findIndex((t=>t.attributes.mid===e));if(-1!==i){const e=this.mungRecvMediaDsec(this.sessionDesc.mediaDescriptions[i],t);this.sessionDesc.mediaDescriptions[i]=e}}updateBundleMids(){this.sessionDesc.attributes.groups[0].identificationTag=this.sessionDesc.mediaDescriptions.filter((e=>"0"!==e.media.port)).map((e=>e.attributes.mid))}findPreloadMediaDesc(e){return this.sessionDesc.mediaDescriptions.find((t=>{var i;return(null===(i=t.attributes)||void 0===i||null===(i=i.ssrcs[0])||void 0===i?void 0:i.ssrcId)===e[0].ssrcId}))}findFirstClosedMedia(e){return this.sessionDesc.mediaDescriptions.find((t=>Kb()?"0"===t.media.port&&t.media.mediaType===e:"0"===t.media.port))}};const wq=["sdp"];var Oq;function Nq(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Dq(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};
vendor: 38,722 bytes, line 12272
12272t%2?Nq(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Nq(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}let Pq=(Oq=class e extends GU{get currentLocalDescription(){return this.peerConnection.currentLocalDescription}get currentRemoteDescription(){return this.peerConnection.currentRemoteDescription}get peerConnectionState(){return this.peerConnection.connectionState}get iceConnectionState(){return this.peerConnection.iceConnectionState}get dtlsTransportState(){var e,t;return null!==(e=null===(t=this.peerConnection.getReceivers()[0])||void 0===t||null===(t=t.transport)||void 0===t?void 0:t.state)&&void 0!==e?e:null}get localCodecs(){return[]}set isInRestartIce(e){this._isInRestartIce=e}get isInRestartIce(){return this._isInRestartIce}constructor(t,i,n){super(t,i),QI(this,"direction",void 0),QI(this,"name",void 0),QI(this,"store",void 0),QI(this,"spec",void 0),QI(this,"peerConnection",void 0),QI(this,"initialOffer",void 0),QI(this,"transport",void 0),QI(this,"statsFilter",void 0),QI(this,"localCandidateCount",0),QI(this,"_isInRestartIce",!1),QI(this,"mutex",void 0),QI(this,"onLocalCandidate",void 0),QI(this,"remoteSDP",void 0),QI(this,"pendingCandidates",[]),QI(this,"localCapabilities",void 0),QI(this,"isReady",!1),QI(this,"restartCnt",0),QI(this,"curTurnServerIndex",0),this.store=i,this.spec=t,this.mutex=new IO("P2PConnection-mutex",i.clientId),this.peerConnection=new RTCPeerConnection(e.resolvePCConfiguration(t,i.p2pTransport),{optional:[{googDscp:!0}]}),this.direction=null!=n?n:EU.SEND_ONLY,this.name=this.direction===EU.SEND_ONLY?"sendP2PConnection":"recvP2PConnection",this.statsFilter=tN(this.peerConnection,_N("STATS_UPDATE_INTERVAL"),void 0,Kb()?1200:void 0),this.bindPCEvents(),this.bindStatsEvents(),this.store.p2pId=this.store.p2pId+1}async establish(e){try{const t=await sV();if(this.localCapabilities=dV(t),e){const{sdp:t}=e,i=Aq(e,wq),n=function(){const e={audioCodecs:[],videoCodecs:[],audioExtensions:[],videoExtensions:[]},t=zx(arguments.length>2?arguments[2]:void 0,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},"sendonly"),i={audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]},n={audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]},r={audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]};if(cV(t,e,"videoExtensions",i,n,r),cV(t,e,"videoCodecs",i,n,r),cV(t,e,"audioExtensions",i,n,r),cV(t,e,"audioCodecs",i,n,r),_N("RAISE_H264_BASELINE_PRIORITY")){const e=r.videoCodecs.findIndex((e=>e.rtpMap&&"h264"===e.rtpMap.encodingName.toLocaleLowerCase()&&e.fmtp&&"42001f"===e.fmtp.parameters["profile-level-id"]));if(-1!==e){const t=r.videoCodecs.findIndex((e=>e.rtpMap&&"h264"===e.rtpMap.encodingName.toLocaleLowerCase()));if(t<e){YN.debug("raising H264 baseline profile priority");const i=r.videoCodecs[e];r.videoCodecs.splice(e,1),r.videoCodecs.splice(t,0,i)}-1!==t&&_N("FILTER_SEND_H264_BASELINE")&&(i.videoCodecs=i.videoCodecs.filter((e=>!(e.rtpMap&&"h264"===e.rtpMap.encodingName.toLocaleLowerCase()&&e.fmtp&&"42001f"!==e.fmtp.parameters["profile-level-id"]))))}}return{send:i,recv:n,sendrecv:r}}({},{},t);this.remoteSDP=new bq({remoteIceParameters:i.iceParameters,remoteDtlsParameters:i.dtlsParameters,candidates:[],remoteRTPCapabilities:n,localCapabilities:this.localCapabilities,direction:this.direction,setup:"actpass",videoCodec:this.store.codec,audioCodec:this.store.audioCodec}),await this.setRemoteDescription({type:"offer",sdp:this.remoteSDP.toString()}),this.isReady=!0;const r=await this.peerConnection.createAnswer();if(!r.sdp)throw new Error("Cannot get answer sdp when trying to establish PeerConnection.");const o=Xx(r.sdp);await this.peerConnection.setLocalDescription(r);const s=await aV({},{},r.sdp);this.localCapabilities=dV(s);const a=this.peerConnection.getTransceivers()[0];return null!=a&&a.receiver&&a.receiver.transport&&this.tryBindTransportEvents(a.receiver.transport),Dq(Dq({},o),{},{sdp:r.sdp})}{this.peerConnection.addTransceiver("video",{direction:"sendonly"}),this.peerConnection.addTransceiver("audio",{direction:"sendonly"});const e=await this.peerConnection.createOffer();if(!e.sdp)throw new Error("Cannot get initialOffer.sdp when trying to establish PeerConnection.");const t=Xx(e.sdp);return this.initialOffer=e,Dq(Dq({},t),{},{sdp:e.sdp})}}catch(e){throw new mw(Ew.GET_LOCAL_CONNECTION_PARAMS_FAILED,e.toString())}}async connect(e){try{if(!this.initialOffer)throw new Error("Cannot establish P2PConnection without initial offer.");await this.peerConnection.setLocalDescription(this.initialOffer);const{sdp:t,iceParameters:i,dtlsParameters:n}=e,r=await aV({},{},t);this.remoteSDP=new bq({remoteIceParameters:i,remoteDtlsParameters:n,candidates:[],remoteRTPCapabilities:r,localCapabilities:this.localCapabilities,direction:this.direction,setup:"active",videoCodec:this.store.codec,audioCodec:this.store.audioCodec}),await this.setRemoteDescription({type:"answer",sdp:this.remoteSDP.toString()});const o=this.peerConnection.getTransceivers()[0];null!=o&&o.sender&&o.sender.transport&&this.tryBindTransportEvents(o.sender.transport)}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.connect failed; ".concat(e.toString()))}}async addRemoteCandidate(e){try{e&&this.pendingCandidates.push(e),this.peerConnection.remoteDescription&&this.isReady&&(this.pendingCandidates.forEach((e=>{this.peerConnection.addIceCandidate(e)})),this.pendingCandidates=[])}catch(e){throw new mw(Ew.ADD_CANDIDATE_FAILED,"P2PConnection.addRemoteCandidate failed; ".concat(e.toString()))}}send(e,t,i){var n=this;return FA((function*(){const r=yield BA(n.mutex.lock("From P2PConnection.send"));try{if(!n.remoteSDP)throw new Error("Cannot call P2PConnection.send before remote SDP created");const o=[],s=n.remoteSDP.receive(e,t,i);e.forEach(((e,t)=>{if(s[t].needCreateTransceiver){const t=n.peerConnection.addTransceiver(e._mediaStreamTrack,{direction:"sendonly"});o.push(t),e._updateRtpTransceiver(t)}else{const i=n.peerConnection.getTransceivers().find((e=>e.mid===s[t].mid));if(!i)throw new Error("cannot find transceiver when sendPeerconnection send, mid is ".concat(s[t].mid));o.push(i),e._updateRtpTransceiver(i)}})),Kb()&&!0===_N("SIMULCAST")&&(yield BA(n.applySimulcastForFirefox(o,e)));const a=s.map((e=>e.mid)),c=yield BA(n.peerConnection.createOffer()),d=n.mungSendOfferSDP(c.sdp,e,a),l=yN(d),u=a.map((e=>{const t=l.mediaDescriptions.find((t=>t.attributes.mid===e));if(!t)throw new Error("Cannot extract ssrc from mediaDescription.");return Jx(t,_N("USE_PUB_RTX"))})),h=o.map(((e,t)=>{const i=a[t];return{localSSRC:u[t],id:i}}));yield BA(n.peerConnection.setLocalDescription({type:"offer",sdp:d}));try{yield h}catch(e){const t=n.remoteSDP.toString();throw yield BA(n.peerConnection.setLocalDescription({type:"offer",sdp:d})),yield BA(n.peerConnection.setRemoteDescription({type:"answer",sdp:t})),yield BA(n.stopSending(a,!0)),e}yield BA(n.applySimulcastEncodings(o,e)),yield BA(n.applySendEncodings(o,e));const p=n.remoteSDP.toString(),_=n.logSDPExchange(d,"offer","local","send");return null==_||_(p),yield BA(n.setRemoteDescription({type:"answer",sdp:p})),o.map(((e,t)=>{const i=a[t];return{localSSRC:u[t],id:i}}))}catch(e){throw e instanceof mw?e:new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.send failed; ".concat(e.toString()))}finally{r()}}))()}async stopSending(e,t){const i=t?void 0:await this.mutex.lock("From P2PConnection.stopSending");try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.stopSending before remote SDP created");const t=this.peerConnection.getTransceivers().filter((t=>-1!==e.indexOf(t.mid)));if(t.length!==e.length)throw new Error("Transceivers' length (".concat(t.length,") doesn't match mids' length (").concat(e.length,") when trying to call P2PConnection.stopSending."));t.map((e=>{var t;e.direction="inactive",null===(t=e.stop)||void 0===t||t.call(e)}));const n=await this.peerConnection.createOffer(),r=this.logSDPExchange(n.sdp||"","offer","local","stopSending");await this.peerConnection.setLocalDescription(n),this.remoteSDP.stopReceiving(e);const o=this.remoteSDP.toString();null==r||r(o),await this.setRemoteDescription({type:"answer",sdp:o})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.stopSending failed; ".concat(e.toString()))}finally{i&&i()}}async receive(e,t,i,n){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.receive ".concat(e," before remoteSDP created."));const{mid:r,needExchangeSDP:o}=this.remoteSDP.send(e,t,i,n);if(o){const t=this.remoteSDP.toString(),i=this.logSDPExchange(t,"offer","remote","receive");await this.setRemoteDescription({type:"offer",sdp:t});const n=await this.peerConnection.createAnswer(),o=this.mungReceiveAnswerSDP(n.sdp,r,e);null==i||i(o||""),await this.peerConnection.setLocalDescription({type:"answer",sdp:o}),YN.debug("[".concat(this.store.clientId,"] [P2PConnection] receive ").concat(e," by exchanging SDP."))}else YN.debug("[".concat(this.store.clientId,"] [P2PConnection] receive ").concat(e," no need to exchange SDP."));const s=this.peerConnection.getTransceivers().find((e=>e.mid===r));if(!s||null===s.mid)throw new Error("Cannot get transceiver after setLocalDescription.");return{track:s.receiver.track,mid:s.mid,transceiver:s}}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.receive failed; ".concat(e.toString()))}}async mockReceive(e,t,i,n){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.receive ".concat(e," before remoteSDP created."));const{mid:r,needExchangeSDP:o}=this.remoteSDP.send(e,t,i,n);if(o){const t=this.remoteSDP.toString(),i=this.logSDPExchange(t,"offer","remote","receive");await this.setRemoteDescription({type:"offer",sdp:t});const n=await this.peerConnection.createAnswer(),o=this.mungReceiveAnswerSDP(n.sdp,r,e);null==i||i(o||""),await this.peerConnection.setLocalDescription({type:"answer",sdp:o}),YN.debug("[".concat(this.store.clientId,"] [P2PConnection] receive ").concat(e," by exchanging SDP."))}else YN.debug("[".concat(this.store.clientId,"] [P2PConnection] receive ").concat(e," no need to exchange SDP."))}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.receive failed; ".concat(e.toString()))}}async stopReceiving(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.stopReceiving before remote SDP created.");this.remoteSDP.stopSending(e);const t=this.remoteSDP.toString(),i=this.logSDPExchange(t,"offer","remote","stopReceiving");await this.setRemoteDescription({type:"offer",sdp:t});const n=await this.peerConnection.createAnswer();null==i||i(n.sdp||""),await this.peerConnection.setLocalDescription(n)}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection stopReceiving failed; ".concat(e.toString()))}}async restartICE(t){try{if(this.store.p2pTransport===sN.Auto&&(this.store.p2pTransport=sN.SdRtn,nD().supportPCSetConfiguration&&this.peerConnection.setConfiguration(e.resolvePCConfiguration(this.spec,this.store.p2pTransport))),this.restartCnt>3&&(this.restartCnt=0,nD().supportPCSetConfiguration&&this.peerConnection.setConfiguration(e.resolvePCConfiguration(this.spec,this.store.p2pTransport,++this.curTurnServerIndex))),!t){this.restartCnt++,this.isReady=!1;const e=await this.peerConnection.createOffer({iceRestart:!0});if(!e.sdp)throw new Error("Cannot restartICE because restart offer SDP does not exist.");const{iceParameters:t}=Xx(e.sdp);return this.store.descriptionStart(),this.direction===EU.SEND_ONLY&&await this.peerConnection.setLocalDescription(e),t}if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.stopReceiving before remote SDP created.");if(this.remoteSDP.restartICE(t),this.store.descriptionStart(),this.direction===EU.RECEIVE_ONLY){this.restartCnt++,await this.setRemoteDescription({type:"offer",sdp:this.remoteSDP.toString()});const e=await this.peerConnection.createAnswer();if(!e.sdp)throw new Error("Cannot get answer sdp when trying to iceRestart.");const{iceParameters:t}=Xx(e.sdp);return await this.peerConnection.setLocalDescription(e),t}await this.setRemoteDescription({type:"answer",sdp:this.remoteSDP.toString()}),this.isReady=!0}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection stopReceiving failed; ".concat(e.toString()))}}close(){var e;this.peerConnection.close(),this.peerConnection.onicecandidate=null,null===(e=this.onConnectionStateChange)||void 0===e||e.call(this,"closed"),this.tryUnbindTransportEvents(),this.unbindPCEvents(),this.unbindStatsEvents(),this.transport=void 0,this.statsFilter.destroy()}getStats(){return this.statsFilter.getStats()}getRemoteVideoIsReady(e){return this.statsFilter.getVideoIsReady(e)}async updateEncoderConfig(e,t){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.updateEncoderConfig before remote SDP created.");const i=await this.peerConnection.createOffer(),n=this.mungSendOfferSDP(i.sdp,[t],[e]);this.remoteSDP.updateRecvMedia(e,t);const r=this.remoteSDP.toString(),o=this.logSDPExchange(n,"offer","local","updateEncoderConfig");await this.peerConnection.setLocalDescription({type:"offer",sdp:n}),null==o||o(r),await this.peerConnection.setRemoteDescription({type:"answer",sdp:r})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,e.toString())}}async updateSendParameters(e,t){const i=this.peerConnection.getTransceivers().filter((t=>t.mid===e));1===i.length&&(this.isVP8Simulcast(t)?Kb()||await this.applySimulcastEncodings(i,[t]):await this.applySendEncodings(i,[t]))}setStatsRemoteVideoIsReady(e,t){this.statsFilter.setVideoIsReady2(e,t)}async replaceTrack(e,t){const i=this.peerConnection.getTransceivers().find((e=>e.mid===t));i&&await i.sender.replaceTrack(e._mediaStreamTrack)}async getSelectedCandidatePair(){const e=this.peerConnection.getReceivers();if(e.length>0&&e[0].transport&&e[0].transport.iceTransport&&e[0].transport.iceTransport.getSelectedCandidatePair&&e[0].transport.iceTransport.getSelectedCandidatePair()){const t=e[0].transport.iceTransport,{local:i,remote:n}=t.getSelectedCandidatePair();return{local:Dq(Dq({},FO),{},{candidateType:i.type,protocol:i.protocol,address:i.address,port:i.port}),remote:Dq(Dq({},FO),{},{candidateType:n.type,protocol:n.protocol,address:n.address,port:n.port})}}return this.statsFilter.getSelectedCandidatePair()}bindPCEvents(){this.peerConnection.oniceconnectionstatechange=()=>{var e,t;Dn(e=["connected","completed"]).call(e,this.peerConnection.iceConnectionState)&&(this.isReady=!1),null===(t=this.onICEConnectionStateChange)||void 0===t||t.call(this,this.peerConnection.iceConnectionState)},this.peerConnection.onconnectionstatechange=()=>{var e;"connected"===this.peerConnection.connectionState&&(this.restartCnt=0),null===(e=this.onConnectionStateChange)||void 0===e||e.call(this,this.peerConnection.connectionState)},this.startICECandidate()}startICECandidate(){this.peerConnection.onicecandidate||(this.localCandidateCount=0,this.peerConnection.onicecandidate=e=>{if(e.candidate){var t;if(e.candidate.candidate)null===(t=this.onLocalCandidate)||void 0===t||t.call(this,e.candidate.toJSON());this.localCandidateCount+=1}else YN.debug("[".concat(this.store.clientId,"] [pc-").concat(this.store.p2pId,"] local candidate count"),this.localCandidateCount)})}unbindPCEvents(){this.peerConnection.oniceconnectionstatechange=null,this.peerConnection.onconnectionstatechange=null,this.peerConnection.onsignalingstatechange=null,this.peerConnection.onicecandidateerror=null,this.peerConnection.onicecandidate=null,this.peerConnection.ontrack=null}static resolvePCConfiguration(t,i){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const r={iceServers:[]};var o;t.iceServers?r.iceServers=t.iceServers:t.turnServer&&"off"!==t.turnServer.mode&&(Fw(t.turnServer.servers)?r.iceServers=t.turnServer.servers:(r.iceServers&&r.iceServers.push(...e.turnServerConfigToIceServers(t.turnServer.servers,i,n)),_N("USE_TURN_SERVER_OF_GATEWAY")&&r.iceServers&&t.turnServer.serversFromGateway&&r.iceServers.push(...e.turnServerConfigToIceServers(t.turnServer.serversFromGateway,i,n)),Dn(o=[sN.Relay,sN.SdRtn]).call(o,i)&&(r.iceTransportPolicy="relay"),_N("FORCE_TURN_TCP")?r.iceTransportPolicy="relay":t.turnServer.servers.concat(t.turnServer.serversFromGateway||[]).forEach((e=>{e.forceturn&&(r.iceTransportPolicy="relay")}))));return _N("ENABLE_ENCODED_TRANSFORM")&&nD().supportWebRTCEncodedTransform&&(r.encodedInsertableStreams=!0),YN.debug("P2PConnection p2pTransport is ".concat(i)),r}static turnServerConfigToIceServers(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const n=[],r=e.filter((e=>e.tcpport));YN.debug("P2PConnection turnServers is ".concat(r,", current index is ").concat(i));const o=r.length>i?r[i]:r[0];switch(t){case sN.SdRtn:const t=e.filter((e=>{var t;return Dn(t=e.username).call(t,"glb:")&&e.turnServerURL==e.turnServerURL})),r=t.length>i?t[i]:t[0];r&&(n.push({username:r.username,credential:r.password,credentialType:"password",urls:"turn:".concat(Dx(r.turnServerURL),":").concat(r.tcpport,"?transport=udp")}),n.push({username:r.username,credential:r.password,credentialType:"password",urls:"turns:".concat(Dx(r.turnServerURL),":").concat(r.tcpport,"?transport=tcp")}));break;case sN.Relay:o&&(n.push({username:o.username,credential:o.password,credentialType:"password",urls:"turn:".concat(o.turnServerURL,":").concat(o.tcpport,"?transport=udp")}),n.push({username:o.username,credential:o.password,credentialType:"password",urls:"turns:".concat(Dx(o.turnServerURL),":").concat(o.tcpport,"?transport=tcp")}));break;default:o&&(n.push({username:o.username,credential:o.password,credentialType:"password",urls:"turn:".concat(o.turnServerURL,":").concat(o.tcpport,"?transport=udp")}),n.push({username:o.username,credential:o.password,credentialType:"password",urls:"turns:".concat(Dx(o.turnServerURL),":").concat(o.tcpport,"?transport=tcp")}),n.push({username:o.username,credential:o.password,credentialType:"password",urls:"stun:".concat(o.turnServerURL,":").concat(o.tcpport)}))}return n}tryBindTransportEvents(e){if(e){this.transport=e,e.onstatechange=()=>{var t;null!=e&&e.state&&(null===(t=this.onDTLSTransportStateChange)||void 0===t||t.call(this,e.state))},e.onerror=e=>{var t;null===(t=this.onDTLSTransportError)||void 0===t||t.call(this,"error"in e?e.error:e)};const t=e.iceTransport;t&&(t.onstatechange=()=>{const t=null==e?void 0:e.iceTransport.state;var i;t&&(null===(i=this.onICETransportStateChange)||void 0===i||i.call(this,t))},t.getSelectedCandidatePair&&(t.onselectedcandidatepairchange=()=>{if(t.getSelectedCandidatePair()){const{local:e,remote:i}=t.getSelectedCandidatePair();YN.info("[".concat(this.store.clientId,"] [pc-").concat(this.store.p2pId,"] selectedcandidatepairchange: local ").concat(JSON.stringify({candidateType:e.type,protocol:e.protocol}),", remote ").concat(JSON.stringify({candidateType:i.type,protocol:i.protocol,address:i.address,port:i.port})," )"))}}))}}tryUnbindTransportEvents(){this.transport&&(this.transport.onstatechange=null,this.transport.onerror=null,this.transport.iceTransport&&(this.transport.iceTransport.onstatechange=null))}async updateRtpSenderEncodings(e,t){var i;if(!t){t=this.peerConnection.getSenders().find((t=>t.track===e._mediaStreamTrack))}if(!t)return YN.warn("[".concat(e.getTrackId(),"] no rtpSender found}"));if(this.isVP8Simulcast(e))return YN.warn("[updateRtpSenderEncodings] Track is VP8 simulcast, please apply simulcast encodings");if(!nD().supportSetRtpSenderParameters)return YN.warn("[updateRtpSenderEncodings] Browser not support set rtp-sender parameters");const n={},r={};switch(e._optimizationMode){case"motion":n.degradationPreference="maintain-framerate";break;case"detail":n.degradationPreference="maintain-resolution";break;default:n.degradationPreference="balanced"}if(e._encoderConfig){var o;const{bitrateMax:t,frameRate:i,scaleResolutionDownBy:n}=e._encoderConfig;t&&(r.maxBitrate=1e3*t),Dn(o=e._hints).call(o,vD.LOW_STREAM)&&(i&&(r.maxFramerate=Lx(i)),n&&n>=1&&(r.scaleResolutionDownBy=n))}if(_N("DSCP_TYPE")&&dw()){var s;const e=_N("DSCP_TYPE");Dn(s=["very-low","low","medium","high"]).call(s,e)&&(r.networkPriority=e)}const a=t.getParameters(),c=null===(i=a.encodings)||void 0===i?void 0:i[0];Kb()&&!c&&(n.encodings=[r]),c&&Object.assign(c,r),Object.assign(a,n),YN.debug("[".concat(e.getTrackId(),"] updateRtpSenderEncodings: ").concat(JSON.stringify(a.encodings))),await t.setParameters(a)}async applySendEncodings(e,t){try{if(!nD().supportSetRtpSenderParameters)return;if(e.length!==t.length)return;for(let i=0;i<e.length;i++){const n=e[i],r=t[i];r instanceof pk&&!this.isVP8Simulcast(r)&&await this.updateRtpSenderEncodings(r,n.sender)}}catch(e){YN.debug("[".concat(this.store.clientId,"] Apply RTPSendEncodings failed."))}}mungSendOfferSDP(e,t,i){const n=yN(e);return t.forEach(((e,t)=>{const r=i[t],o=n.mediaDescriptions.find((e=>e.attributes.mid===r));o&&(eV(o,e),oV(o,e,this.store.codec))})),AN(n)}bindStatsEvents(){this.statsFilter.onFirstAudioReceived=e=>{var t;null===(t=this.onFirstAudioReceived)||void 0===t||t.call(this,e)},this.statsFilter.onFirstVideoReceived=e=>{var t;null===(t=this.onFirstVideoReceived)||void 0===t||t.call(this,e)},this.statsFilter.onFirstAudioDecoded=e=>{var t;null===(t=this.onFirstAudioDecoded)||void 0===t||t.call(this,e)},this.statsFilter.onFirstVideoDecoded=(e,t,i)=>{var n;null===(n=this.onFirstVideoDecoded)||void 0===n||n.call(this,e,t,i)},this.statsFilter.onSelectedLocalCandidateChanged=(e,t)=>{var i;null===(i=this.onSelectedLocalCandidateChanged)||void 0===i||i.call(this,e,t)},this.statsFilter.onSelectedRemoteCandidateChanged=(e,t)=>{var i;null===(i=this.onSelectedRemoteCandidateChanged)||void 0===i||i.call(this,e,t)},this.statsFilter.onFirstVideoDecodedTimeout=e=>{var t;null===(t=this.onFirstVideoDecodedTimeout)||void 0===t||t.call(this,e)}}unbindStatsEvents(){this.statsFilter.onFirstAudioReceived=void 0,this.statsFilter.onFirstVideoReceived=void 0,this.statsFilter.onFirstAudioDecoded=void 0,this.statsFilter.onFirstVideoDecoded=void 0,this.statsFilter.onSelectedLocalCandidateChanged=void 0,this.statsFilter.onSelectedRemoteCandidateChanged=void 0,this.statsFilter.onFirstVideoDecodedTimeout=void 0}async applySimulcastForFirefox(e,t){if(e.length===t.length)for(let a=0;a<e.length;a++){var i,n,r,o,s;const c=e[a],d=t[a];if(d instanceof pk&&!Dn(i=d._hints).call(i,vD.LOW_STREAM)&&null!==(n=d._encoderConfig)&&void 0!==n&&n.bitrateMax&&(null===(r=d._encoderConfig)||void 0===r?void 0:r.bitrateMax)>200&&null!==(o=d._scalabilityMode)&&void 0!==o&&o.numSpatialLayers&&(null===(s=d._scalabilityMode)||void 0===s?void 0:s.numSpatialLayers)>1&&"vp8"===this.store.codec){const e={},t={high:1e3*(d._encoderConfig.bitrateMax-50),medium:5e4};e.encodings=[{rid:"m",active:!0,maxBitrate:t.medium,scaleResolutionDownBy:4},{rid:"h",active:!0,maxBitrate:t.high}];const i=c.sender.getParameters();await c.sender.setParameters(Object.assign(i,e))}}}async applySimulcastEncodings(e,t){if(!Kb()&&e.length===t.length)for(let i=0;i<e.length;i++){const n=t[i];if(n instanceof pk&&this.isVP8Simulcast(n)){const t=e[i],r={},o={high:1e3*(n._encoderConfig.bitrateMax-50),medium:5e4};r.encodings=[{active:!0,adaptivePtime:!1,networkPriority:"high",priority:"high",maxBitrate:o.high},{active:!0,adaptivePtime:!1,networkPriority:"low",priority:"low",maxBitrate:o.medium,scaleResolutionDownBy:4}];const s=t.sender.getParameters();await t.sender.setParameters(Object.assign(s,r))}}}isVP8Simulcast(e){var t,i,n,r,o;return!!(e instanceof pk&&_N("SIMULCAST")&&"vp8"===this.store.codec&&!Dn(t=e._hints).call(t,vD.LOW_STREAM)&&null!==(i=e._encoderConfig)&&void 0!==i&&i.bitrateMax&&(null===(n=e._encoderConfig)||void 0===n?void 0:n.bitrateMax)>200&&null!==(r=e._scalabilityMode)&&void 0!==r&&r.numSpatialLayers&&(null===(o=e._scalabilityMode)||void 0===o?void 0:o.numSpatialLayers)>1)}logSDPExchange(e,t,i,n){if(_N("SDP_LOGGING"))return YN.upload("[".concat(this.store.clientId,"] exchanging ").concat(i," ").concat(t," SDP during P2PConnection.").concat(n,"\n"),e),"offer"===t?e=>{this.logSDPExchange(e,"answer","local"===i?"remote":"local",n)}:void 0}async muteLocal(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.muteLocal before remote SDP created.");const t=this.peerConnection.getTransceivers().filter((t=>t.mid&&-1!==e.indexOf(t.mid)));if(t.length!==e.length)throw new Error("Transceivers' length doesn't match mids' length.");t.map((e=>{e.direction="inactive"}));const i=await this.peerConnection.createOffer(),n=this.logSDPExchange(i.sdp||"","offer","local","muteLocal");await this.peerConnection.setLocalDescription(i),this.remoteSDP.muteRemote(e);const r=this.remoteSDP.toString();null==n||n(r),await this.setRemoteDescription({type:"answer",sdp:r})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.muteLocal failed; ".concat(e.toString()))}}async unmuteLocal(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.unmuteLocal before remote SDP created.");const t=this.peerConnection.getTransceivers().filter((t=>t.mid&&-1!==e.indexOf(t.mid)));if(t.length!==e.length)throw new Error("Transceivers' length doesn't match mids' length.");t.map((async e=>{e.direction="sendonly"}));const i=await this.peerConnection.createOffer(),n=this.logSDPExchange(i.sdp||"","offer","local","unmuteLocal");await this.peerConnection.setLocalDescription(i),this.remoteSDP.unmuteRemote(e);const r=this.remoteSDP.toString();null==n||n(r),await this.setRemoteDescription({type:"answer",sdp:r})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.unmuteLocal failed; ".concat(e.toString()))}}async getRemoteSSRC(e,t){var i,n;if(t=null!==(i=t)&&void 0!==i?i:null===(n=this.currentRemoteDescription)||void 0===n?void 0:n.sdp){var r;const i=null===(r=yN(t).mediaDescriptions.find((t=>t.attributes.mid===e)))||void 0===r?void 0:r.attributes.ssrcs;return null==i?void 0:i[0].ssrcId}}async setRemoteDescription(e){var t;await this.peerConnection.setRemoteDescription(e),Dn(t=["connected","completed"]).call(t,this.peerConnection.iceConnectionState)||(this.isReady=!0,this.addRemoteCandidate())}mungReceiveAnswerSDP(e,t,i){const n=yN(e),r=n.mediaDescriptions.find((e=>e.attributes.mid===t));return r&&i===HU.AUDIO&&"audio"===r.media.mediaType&&lV(r),AN(n)}},rU(Oq.prototype,"establish",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"establish"),Oq.prototype),rU(Oq.prototype,"connect",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"connect"),Oq.prototype),rU(Oq.prototype,"receive",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"receive"),Oq.prototype),rU(Oq.prototype,"mockReceive",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"mockReceive"),Oq.prototype),rU(Oq.prototype,"stopReceiving",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"stopReceiving"),Oq.prototype),rU(Oq.prototype,"restartICE",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"restartICE"),Oq.prototype),rU(Oq.prototype,"close",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"close"),Oq.prototype),rU(Oq.prototype,"updateEncoderConfig",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"updateEncoderConfig"),Oq.prototype),rU(Oq.prototype,"updateSendParameters",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"updateSendParameters"),Oq.prototype),rU(Oq.prototype,"replaceTrack",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"replaceTrack"),Oq.prototype),rU(Oq.prototype,"muteLocal",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"muteLocal"),Oq.prototype),rU(Oq.prototype,"unmuteLocal",[Lq],Object.getOwnPropertyDescriptor(Oq.prototype,"unmuteLocal"),Oq.prototype),Oq);function Lq(e,t,i){const n=e[t];if("function"!=typeof n)throw new Error("Cannot use mutex on object property.");return i.value=async function(){const e=this.mutex,i=await e.lock("From P2PConnection.".concat(t));try{for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return await n.apply(this,o)}finally{i()}},i}let kq=function(e){return e.SEND_ONLY="SEND_ONLY",e.RECEIVE_ONLY="RECEIVE_ONLY",e}({});var Mq,Uq,xq,Vq,Fq,Bq,jq,Gq,Wq,Hq,Kq,Yq;function qq(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function zq(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?qq(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):qq(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}let Xq=(Mq=Jq(kq.SEND_ONLY),Uq=Jq(kq.SEND_ONLY),xq=Jq(),Vq=Jq(kq.RECEIVE_ONLY),Fq=Jq(kq.RECEIVE_ONLY),Bq=Jq(kq.RECEIVE_ONLY),jq=Jq(kq.RECEIVE_ONLY),Gq=Jq(kq.RECEIVE_ONLY),Wq=Jq(kq.RECEIVE_ONLY),Hq=Jq(),Kq=Jq(kq.RECEIVE_ONLY),Yq=class extends Dw{get state(){return this._state}set state(e){const t=this._state;this._state=e,this.emit(JU.StateChange,t,this._state)}constructor(e,t){super(),QI(this,"isPlanB",!1),QI(this,"store",void 0),QI(this,"statsUploader",void 0),QI(this,"sendConnection",void 0),QI(this,"recvConnection",void 0),QI(this,"localTrackMap",new Map),QI(this,"remoteUserMap",new Map),QI(this,"localDataChannels",[]),QI(this,"pendingLocalTracks",[]),QI(this,"pendingRemoteTracks",[]),QI(this,"statsCollector",void 0),QI(this,"dtlsFailedCount",0),QI(this,"sendMutex",void 0),QI(this,"recvMutex",void 0),QI(this,"_state",XU.Disconnected),QI(this,"_restartStates",["disconnected","failed"]),QI(this,"reconnectInterval",void 0),QI(this,"uploadUnplinkStarted",!1),QI(this,"uploadDownlinkStarted",!1),QI(this,"uplinkStateUploadInterval",void 0),QI(this,"downlinkStatsUploadInterval",void 0),QI(this,"handleMuteLocalTrack",(async(e,t,i)=>{const n=await this.sendMutex.lock("Locking from P2PChannel2.handleMuteLocalTrack");try{if(!this.sendConnection||this.state!==XU.Connected)return void i(new mw(Ew.INVALID_OPERATION,"Cannot call P2PChannel2.handleMuteLocalTrack before sendConnection established."));const s=this.filterTobeMutedTracks(e);if(0===s.length)return void t();const a=s.find((e=>"videoLowTrack"===e[0]));if(a){a[1].track._originMediaStreamTrack.stop()}await this.sendConnection.muteLocal(s.map((e=>{let[,{id:t}]=e;return t})));let c=!1;var r,o;if("video"===e.trackMediaType)c=!(null===(r=this.localTrackMap.get(zU.LocalAudioTrack))||void 0===r||!r.track._muted);else c=void 0===(null===(o=this.localTrackMap.get(zU.LocalVideoTrack))||void 0===o?void 0:o.id);const d=this.createMuteMessage(s);await qw(this,JU.RequestMuteLocal,d);const l="video"===e.trackMediaType?ax.MUTE_LOCAL_VIDEO:ax.MUTE_LOCAL_AUDIO;await qw(this,JU.RequestP2PMuteLocal,{action:l,message:d,isMuteAll:c}),t()}catch(e){i(e)}finally{n()}})),QI(this,"handleUnmuteLocalTrack",(async(e,t,i)=>{const n=await this.sendMutex.lock("Locking from P2PChannel2.handleUnmuteLocalTrack");try{if(!this.sendConnection||this.state!==XU.Connected)return void i(new mw(Ew.INVALID_OPERATION,"Cannot call P2PChannel2.handleUnmuteLocalTrack before sendConnection established."));const r=this.filterTobeUnmutedTracks(e);if(0===r.length)return void t();await this.sendConnection.unmuteLocal(r.map((e=>{let[,{id:t}]=e;return t})));const o=this.createUnmuteMessage(r),s="video"===e.trackMediaType?ax.UNMUTE_LOCAL_VIDEO:ax.UNMUTE_LOCAL_AUDIO;await qw(this,JU.RequestP2PMuteLocal,{action:s,message:o}),t()}catch(e){i(e)}finally{n()}})),QI(this,"handleUpdateVideoEncoder",(async(e,t,i,n)=>{let r;"boolean"==typeof n&&n||(r=await this.sendMutex.lock("Locking from P2PChannel2.handleUpdateVideoEncoder"));try{const i=this.localTrackMap.get(zU.LocalVideoTrack);if(!this.sendConnection||!i||i.track!==e||this.state!==XU.Connected)return void t();const{id:n,track:s}=i;n&&(await this.sendConnection.updateSendParameters(n,s),await this.sendConnection.updateEncoderConfig(n,s),this.emit(JU.UpdateVideoEncoder,s)),t()}catch(e){i(e)}finally{var o;null===(o=r)||void 0===o||o()}})),QI(this,"handleUpdateVideoSendParameters",(async(e,t,i)=>{const n=await this.sendMutex.lock("Locking from P2PChannel2.handleUpdateVideoSendParameters");try{const i=this.localTrackMap.get(zU.LocalVideoTrack);if(!this.sendConnection||!i||i.track!==e||this.state!==XU.Connected)return void t();const{id:r,track:o}=i;r&&await this.sendConnection.updateSendParameters(r,o),t()}catch(e){i(e)}finally{n()}})),QI(this,"handleReplaceTrack",(async(e,t,i,n)=>{let r;YN.debug("[".concat(this.store.clientId,"] P2PChannel2 handleReplaceTrack for [track-id-").concat(e.getTrackId(),"]")),"boolean"==typeof n&&n||(r=await this.sendMutex.lock("From P2PChannel2.handleReplaceTrack"));try{var o;const i=Array.from(this.localTrackMap.entries()).find((t=>{let[,{track:i}]=t;return e===i}));if(!this.sendConnection||!i||void 0===i[1].id||this.state!==XU.Connected)return void t();if(await(null===(o=this.sendConnection)||void 0===o?void 0:o.replaceTrack(e,i[1].id)),i[0]===zU.LocalVideoTrack&&nD().supportDualStreamEncoding){const t=this.localTrackMap.get(zU.LocalVideoLowTrack);if(t){const i=e._mediaStreamTrack.clone();t.track._originMediaStreamTrack.stop(),t.track._mediaStreamTrack=i,t.track._originMediaStreamTrack=i,await new Wh(((e,i)=>{this.handleReplaceTrack(t.track,e,i,!0)}))}}t()}catch(e){i(e)}finally{var s;null===(s=r)||void 0===s||s()}})),QI(this,"handleGetLocalVideoStats",(e=>{e(this.statsCollector.getLocalVideoTrackStats())})),QI(this,"handleGetLocalAudioStats",(e=>{e(this.statsCollector.getLocalAudioTrackStats())})),QI(this,"handleGetRemoteVideoStats",(e=>this.statsCollector.getRemoteVideoTrackStats(e.uid)[e.uid])),QI(this,"handleGetRemoteAudioStats",(e=>this.statsCollector.getRemoteAudioTrackStats(e.uid)[e.uid])),this.store=e,this.statsCollector=t,this.statsCollector.addP2PChannel(this),this.statsUploader=new SB(e),this.bindStatsUploaderEvents(),this.sendMutex=new IO("P2PChannel2-send-mutex",e.clientId),this.recvMutex=new IO("P2PChannel2-recv-mutex",e.clientId),this.reconnectInterval=window.setInterval((()=>{[this.sendConnection,this.recvConnection].forEach((e=>{e&&("disconnected"!==e.iceConnectionState&&"failed"!==e.iceConnectionState||this.handleDisconnect(e.direction))}))}),_N("ICE_RESTART_INTERVAL"))}async startP2PConnection(e,t){throw new mw(Ew.NOT_SUPPORTED,"p2p mode does not support startP2PConnection.")}async connect(e){throw new mw(Ew.NOT_SUPPORTED,"p2p mode does not support connect.")}async startP2P(e,t){let i;try{if(t){this.recvConnection&&(YN.warning("[".concat(this.store.clientId,"] P2PChannel.startP2P reset recvConnection.")),this.recvConnection.close(),this.unbindConnectionEvents(this.recvConnection)),i=await this.recvMutex.lock("From P2PChannel.startP2P"),this.recvConnection=new Pq(e,this.store,EU.RECEIVE_ONLY),this.bindConnectionEvents(this.recvConnection);const n=await this.recvConnection.establish(t);return{iceParameters:n.iceParameters,dtlsParameters:n.dtlsParameters,sdp:n.sdp}}{this.state=XU.New,this.sendConnection&&(YN.warning("[".concat(this.store.clientId,"] P2PChannel.startP2P reset sendConnection.")),this.sendConnection.close(),this.unbindConnectionEvents(this.sendConnection)),i=await this.sendMutex.lock("From P2PChannel.startP2P"),this.sendConnection=new Pq(e,this.store),this.store.peerConnectionStart(),this.bindConnectionEvents(this.sendConnection);const t=await this.sendConnection.establish();return{iceParameters:t.iceParameters,dtlsParameters:t.dtlsParameters,sdp:t.sdp}}}finally{i&&i()}}async p2pConnect(e){if(!this.sendConnection)throw new mw(Ew.UNEXPECTED_ERROR,"Cannot P2PChannel2.p2pConnect before P2PChannel2.startP2PConnection .");this.store.peerConnectionStart(),await this.sendConnection.connect(e),this.statsUploader.startUploadTransportStats(),this.statsUploader.startUploadExtensionUsageStats(),this.state=XU.Connected}async addRemoteCandidate(e,t){if(t===EU.RECEIVE_ONLY){if(!this.sendConnection)throw new mw(Ew.UNEXPECTED_ERROR,"Cannot P2PChannel2.connect before P2PChannel2.addRemoteCandidate .");await this.sendConnection.addRemoteCandidate(e)}else{if(!this.recvConnection)throw new mw(Ew.UNEXPECTED_ERROR,"Cannot P2PChannel2.connect before P2PChannel2.addRemoteCandidate .");await this.recvConnection.addRemoteCandidate(e)}}publish(e,t,i){var n=this;return FA((function*(){const r=yield BA(n.sendMutex.lock("From P2PChannel.publish"));try{if(!n.sendConnection||n.state!==XU.Connected){n.throwIfTrackTypeNotMatch(e);const t=e.filter((e=>-1===n.pendingLocalTracks.indexOf(e)));return void(n.pendingLocalTracks=n.pendingLocalTracks.concat(t))}n.store.pubId=n.store.pubId+1,TF.markPublishStart(n.store.clientId,n.store.pubId);const o=n.filterTobePublishedTracks(e,t,i);if(0===o.length)return void(yield BA(n.tryToUnmuteAudio(e)));o.forEach((e=>{let{track:t,type:i}=e;const r=Date.now();n.store.publish(t.getTrackId(),i===zU.LocalAudioTrack?"audio":"video",r)})),n.bindLocalTrackEvents(o);const s=yield BA(n.sendConnection.send(o.map((e=>{let{track:t}=e;return t})),n.store.codec,n.store.audioCodec)),a=(yield BA(s.next())).value,c=n.createGatewayPublishMessage(o,a);try{yield c}catch(e){throw s.throw(e),(null==e?void 0:e.code)===Ew.WS_ABORT&&o.forEach((e=>{let{track:t}=e;-1===n.pendingLocalTracks.indexOf(t)&&n.pendingLocalTracks.push(t)})),n.unbindLocalTrackEvents(o),e}yield BA(s.next()),o.forEach((e=>{let{type:t}=e;n.statsCollector.addLocalStats(t)})),n.statsUploader.startUploadOutboundStats(),n.assignLocalTracks(o,a),o.forEach((e=>{let{track:t,type:i}=e;const r=Date.now();n.store.publish(t.getTrackId(),i===zU.LocalAudioTrack?"audio":"video",void 0,r)})),n.startUploadUplinkState()}finally{r()}}))()}async unpublish(e){if(!this.sendConnection||this.state!==XU.Connected)return void(0===e.length?this.pendingLocalTracks.length=0:this.pendingLocalTracks=this.pendingLocalTracks.filter((t=>!Dn(e).call(e,t))));const t=this.filterTobeUnpublishedTracks(e);if(0===t.length)return;const i=t.find((e=>"videoLowTrack"===e[0]));if(i){i[1].track.close()}const n=this.createGatewayUnpublishMessage(t);if(await this.sendConnection.stopSending(t.map((e=>{let[,{id:t}]=e;return t}))),this.withdrawLocalTracks(t),this.unbindLocalTrackEvents(t.map((e=>{let[t,{track:i}]=e;return{type:t,track:i}}))),t.forEach((e=>{let[t]=e;this.statsCollector.removeLocalStats(t)})),0===this.localTrackMap.size&&(this.statsUploader.stopUploadOutboundStats(),this.stopUploadUplinkState()),this.sendConnection&&this.state===XU.Connected){if(i){i[1].track.close()}return n}e.forEach((e=>{const t=this.pendingLocalTracks.indexOf(e);-1!==t&&this.pendingLocalTracks.splice(t,1)}))}startUploadUplinkState(){if(this.uploadUnplinkStarted)return;this.uploadUnplinkStarted=!0,this.uplinkStateUploadInterval&&window.clearInterval(this.uplinkStateUploadInterval);const e=()=>{const e=[],t=[];
12272Array.from(this.localTrackMap.entries()).forEach((i=>{let[n,{track:r,ssrcs:o}]=i;const s={stream_type:GF(r,n),ssrcs:o};r._muted||!r._enabled?e.push(s):t.push(s)})),e.length>0&&e.forEach((e=>{qw(this,JU.RequestMuteLocal,[e])})),t.length>0&&t.forEach((e=>{qw(this,JU.RequestUnmuteLocal,[e])}))};e(),this.uplinkStateUploadInterval=window.setInterval((()=>{e()}),3e3)}stopUploadUplinkState(){this.uploadUnplinkStarted&&(this.uploadUnplinkStarted=!1,this.uplinkStateUploadInterval&&window.clearInterval(this.uplinkStateUploadInterval))}publishLowStream(e){return FA((function*(){throw new mw(Ew.NOT_SUPPORTED,"p2p mode does not support publishLowStream.")}))()}async republish(){this.pendingLocalTracks.length>0&&(YN.debug("[".concat(this.store.clientId,"] Emit P2PChannelEvents.RequestRePublish to republish tracks.")),await Yw(this,JU.RequestRePublish,this.pendingLocalTracks),this.emit(JU.MediaReconnectEnd,this.store.uid),this.pendingLocalTracks=[])}async unpublishLowStream(){throw new mw(Ew.NOT_SUPPORTED,"p2p mode does not support unpublishLowStream.")}async subscribe(e,t,i,n){var r;if(!this.recvConnection)throw new mw(Ew.INVALID_OPERATION,"Cannot subscribe remote user when recvConnection disconnected.");if(null!==(r=this.remoteUserMap.get(e))&&void 0!==r&&r.has(t))return;const{track:o,mid:s,transceiver:a}=await this.recvConnection.receive(t,[{ssrcId:i}],String(e.uid),n);t===HU.AUDIO?(e._audioTrack?e._audioTrack._updateOriginMediaStreamTrack(o):(e._audioTrack=new Nk(o,e.uid,e._uintid,this.store),YN.info("[".concat(this.store.clientId,"] [").concat(this.store.p2pId,"] create remote audio track: ").concat(e._audioTrack.getTrackId()))),a&&e._audioTrack._updateRtpTransceiver(a),this.bindRemoteTrackEvents(e,e._audioTrack)):(e._videoSSRC=i,e._videoTrack?e._videoTrack._updateOriginMediaStreamTrack(o):(e._videoTrack=new Ok(o,e.uid,e._uintid,this.store),YN.info("[".concat(this.store.clientId,"] [").concat(this.store.p2pId,"] create remote video track: ").concat(e._videoTrack.getTrackId()))),a&&e._videoTrack._updateRtpTransceiver(a),this.bindRemoteTrackEvents(e,e._videoTrack));const c=this.remoteUserMap.get(e);c?c.set(t,s):this.remoteUserMap.set(e,new Map([[t,s]])),this.statsCollector.addRemoteStats(e.uid),this.statsUploader.startUploadInboundStats(),this.startUploadDownlinkState();const d=this.pendingRemoteTracks.findIndex((i=>{let{user:n,kind:r}=i;return n.uid===e.uid&&t===r}));-1!==d&&(this.pendingRemoteTracks.splice(d,1),this.emit(JU.MediaReconnectEnd,e.uid))}async mockSubscribe(e,t,i,n){if(!this.recvConnection)throw new mw(Ew.INVALID_OPERATION,"Cannot subscribe remote user when recvConnection disconnected.");await this.recvConnection.mockReceive(t,[{ssrcId:i}],String(e.uid),n)}async unsubscribe(e,t,i){const n=this.pendingRemoteTracks.filter((i=>{let{user:n,kind:r}=i;return void 0!==t?n.uid===e.uid&&t===r:n.uid===e.uid}));if(n.forEach((e=>{const t=this.pendingRemoteTracks.indexOf(e);this.pendingRemoteTracks.splice(t,1)})),this.recvConnection||i||n.forEach((t=>{let{kind:i}=t;var n;if(i===HU.AUDIO)null===(n=e._audioTrack)||void 0===n||n._destroy(),e._audioTrack=void 0;else if(i===HU.VIDEO){var r;null===(r=e._videoTrack)||void 0===r||r._destroy(),e._videoTrack=void 0}})),!this.recvConnection)return;const r=this.filterTobeUnSubscribedTracks(e,t);0!==r.length&&(await this.recvConnection.stopReceiving(r.map((e=>{let[,{id:t}]=e;return t}))),this.withdrawRemoteTracks(r),0===this.remoteUserMap.size&&(this.statsUploader.stopUploadInboundStats(),this.stopUploadDownlinkState()),r.forEach((e=>{let[t,{kind:n}]=e;var r,o;n===HU.VIDEO&&t._videoSSRC&&(null===(r=this.recvConnection)||void 0===r||r.setStatsRemoteVideoIsReady(t._videoSSRC,!1));if(n===HU.VIDEO)this.unbindRemoteTrackEvents(t._videoTrack),i||(null===(o=t._videoTrack)||void 0===o||o._destroy(),t._videoTrack=void 0);else if(n===HU.AUDIO){var s;if(this.unbindRemoteTrackEvents(t._audioTrack),!i)null===(s=t._audioTrack)||void 0===s||s._destroy(),t._audioTrack=void 0}})),r.forEach((e=>{let[,{kind:t}]=e;qw(this,JU.RequestP2PMuteRemote,t)})))}startUploadDownlinkState(){if(this.uploadDownlinkStarted)return;this.uploadDownlinkStarted=!0,this.downlinkStatsUploadInterval&&window.clearInterval(this.downlinkStatsUploadInterval);const e=()=>
vendor: 13,108 bytes, line 12272
12272Array.from(this.remoteUserMap.entries()).forEach((e=>{let[,t]=e;[HU.VIDEO,HU.AUDIO].forEach((e=>{t.has(e)?qw(this,JU.RequestP2PUnmuteRemote,e):qw(this,JU.RequestP2PMuteRemote,e)}))}));e(),this.downlinkStatsUploadInterval=window.setInterval((()=>{e()}),3e3)}stopUploadDownlinkState(){this.uploadDownlinkStarted&&(this.uploadDownlinkStarted=!1,this.downlinkStatsUploadInterval&&window.clearInterval(this.downlinkStatsUploadInterval))}getAllDataChannels(){return this.localDataChannels}async massSubscribe(e){throw new mw(Ew.NOT_SUPPORTED,"p2p mode does not support massSubscribe.")}async massSubscribeNoLock(e){throw new mw(Ew.NOT_SUPPORTED,"p2p mode does not support massSubscribeNoLock.")}async massUnsubscribe(e){throw new mw(Ew.NOT_SUPPORTED,"p2p mode does not support massUnsubscribe.")}async massUnsubscribeNoLock(e){throw new mw(Ew.NOT_SUPPORTED,"p2p mode does not support massUnsubscribeNoLock.")}async muteRemote(e,t){if(!this.recvConnection)return;const i=this.remoteUserMap.get(e);if(!i)return void YN.warning("[".concat(this.store.clientId,"] P2PChannel2.muteRemote has no remote user ").concat(e.uid,"."));if(!i.get(t))return void YN.warning("[".concat(this.store.clientId,"] P2PChannel2.muteRemote has no remote user ").concat(e.uid," media type ").concat(t,"."));const n=t===HU.VIDEO?e._videoSSRC:e._audioSSRC;void 0!==n&&this.recvConnection.setStatsRemoteVideoIsReady(n,!1)}async unmuteRemote(e,t){return this.unmuteRemoteNoLock(e,t)}async unmuteRemoteNoLock(e,t){if(!this.recvConnection)return;const i=this.remoteUserMap.get(e);if(!i)return void YN.warning("[".concat(this.store.clientId,"] P2PChannel2.unmuteRemote has no remote user ").concat(e.uid,"."));i.get(t)||YN.warning("[".concat(this.store.clientId,"] P2PChannel2.unmuteRemote has no remote user ").concat(e.uid," media type ").concat(t,"."))}getAllTracks(e){const t=this.localTrackMap.get(zU.LocalAudioTrack);if((null==t?void 0:t.track)instanceof bL){const i=t.track;return Array.from(this.localTrackMap.entries()).filter((e=>{let[t]=e;return t!==zU.LocalAudioTrack})).filter((t=>{let[i]=t;return!(e&&i===zU.LocalVideoLowTrack)})).map((e=>{let[,{track:t}]=e;return t})).concat(i.trackList)}return Array.from(this.localTrackMap.entries()).filter((t=>{let[i]=t;return!(e&&i===zU.LocalVideoLowTrack)})).map((e=>{let[,{track:t}]=e;return t}))}reportPublishEvent(e,t,i,n,r){if(e){const i=this.localTrackMap.get(zU.LocalAudioTrack),o=n?this.localTrackMap.get(zU.LocalVideoLowTrack):this.localTrackMap.get(zU.LocalVideoTrack);eD.publish(this.store.sessionId,{eventElapse:TF.measureFromPublishStart(this.store.clientId,this.store.pubId),succ:e,ec:t,audioName:null==i?void 0:i.track.getTrackLabel(),videoName:null==o?void 0:o.track.getTrackLabel(),screenshare:-1!==(null==o?void 0:o.track._hints.indexOf(vD.SCREEN_TRACK)),audio:!!i,video:!!o,p2pid:this.store.p2pId,publishRequestid:this.store.pubId,extend:r})}else{var o;i||(i=[]);const s=i.find((e=>e instanceof IL)),a=n?null===(o=this.localTrackMap.get(zU.LocalVideoTrack))||void 0===o?void 0:o.track:i.find((e=>e instanceof pk));eD.publish(this.store.sessionId,{eventElapse:TF.measureFromPublishStart(this.store.clientId,this.store.pubId),succ:e,ec:t,audioName:null==s?void 0:s.getTrackLabel(),videoName:null==a?void 0:a.getTrackLabel(),screenshare:-1!==(null==a?void 0:a._hints.indexOf(vD.SCREEN_TRACK)),audio:!!s,video:!!a,p2pid:this.store.p2pId,publishRequestid:this.store.pubId,extend:r})}}reportSubscribeEvent(e,t,i,n){const r=n===HU.VIDEO?i._videoSSRC:i._audioSSRC;r&&eD.subscribe(this.store.sessionId,{succ:e,ec:t,video:n===HU.VIDEO,audio:n===HU.AUDIO,peerid:i.uid,subscribeRequestid:n===HU.VIDEO?i._videoSSRC:i._audioSSRC,p2pid:this.store.p2pId,eventElapse:TF.measureFromSubscribeStart(this.store.clientId,r)})}reset(){YN.debug("[".concat(this.store.clientId,"] P2PChannel2.reset")),this.sendMutex=new IO("P2PChannel2-send-mutex",this.store.clientId),this.sendMutex=new IO("P2PChannel2-recv-mutex",this.store.clientId),this.sendConnection&&(this.sendConnection.close(),this.unbindConnectionEvents(this.sendConnection),this.sendConnection=void 0),this.recvConnection&&(this.recvConnection.close(),this.unbindConnectionEvents(this.recvConnection),this.recvConnection=void 0),this.statsUploader.stopUploadOutboundStats(),this.statsUploader.stopUploadInboundStats(),this.statsUploader.stopUploadTransportStats(),this.statsUploader.stopUploadExtensionUsageStats(),this.stopUploadUplinkState(),this.stopUploadDownlinkState(),this.unbindLocalTrackEvents(),this.unbindAllRemoteTrackEvents(),this.unbindRtpTransceiver();const e=this.localTrackMap.get(zU.LocalAudioTrack);if((null==e?void 0:e.track)instanceof bL){if(e.track.trackList.length>0){const t=e.track;e.track.trackList.forEach((e=>{t.removeAudioTrack(e)}))}e.track.close()}this.localTrackMap.clear(),this.remoteUserMap.clear(),this.statsCollector.removeRemoteStats(),this.statsCollector.removeLocalStats(),this.dtlsFailedCount=0,this.pendingLocalTracks=[],this.pendingRemoteTracks=[],this.reconnectInterval&&(window.clearInterval(this.reconnectInterval),this.reconnectInterval=void 0),this.state=XU.Disconnected}getStats(e){var t,i;return e?null===(i=this.recvConnection)||void 0===i?void 0:i.getStats():null===(t=this.sendConnection)||void 0===t?void 0:t.getStats()}getRemoteVideoIsReady(e){var t;return(null===(t=this.recvConnection)||void 0===t?void 0:t.getRemoteVideoIsReady(e))||!1}getLocalAudioVolume(){const e=this.localTrackMap.get(zU.LocalAudioTrack);if(e)return e.track.getVolumeLevel()}getLocalVideoSize(){const e=this.localTrackMap.get(zU.LocalVideoTrack);if(e)return{width:e.track.videoWidth||0,height:e.track.videoHeight||0}}getEncoderConfig(e){const t=this.localTrackMap.get(e);return t&&t.track instanceof pk||t&&t.track instanceof IL?t.track._encoderConfig:void 0}getLocalMedia(e){return this.localTrackMap.get(e)}hasLocalMedia(){return this.localTrackMap.size>0}hasRemoteMedia(e,t){if(!e)return this.remoteUserMap.size>0;const i=this.remoteUserMap.get(e);return!!i&&(!t||i.has(t))}async hasRemoteMediaWithLock(e,t){if(!e)return this.remoteUserMap.size>0;const i=this.remoteUserMap.get(e);return!!i&&(!t||i.has(t))}getRemoteMedia(e){var t;const i=Array.from(MN(t=this.remoteUserMap).call(t)).find((t=>t.uid===e));return i?{audioTrack:i.audioTrack,audioSSRC:i._audioSSRC,videoTrack:i.videoTrack,videoSSRC:i._videoSSRC}:{}}getAudioLevels(){let e=Array.from(this.remoteUserMap.entries()).map((e=>{let[t]=e;return{uid:t.uid,level:t.audioTrack?100*t.audioTrack._source.getAccurateVolumeLevel():0}}));const t=this.localTrackMap.get(zU.LocalAudioTrack);return t&&e.push({level:100*t.track._source.getAccurateVolumeLevel(),uid:this.store.uid}),e=vS(e).call(e,((e,t)=>e.level-t.level)),e}async disconnectForReconnect(){this.sendConnection&&this.recvConnection&&(YN.debug("[".concat(this.store.clientId,"] P2PChannel2.disconnectForReconnect closing P2PConnection")),this.state=XU.Reconnecting,_N("KEEP_LAST_FRAME")&&0!==this.remoteUserMap.size&&Array.from(this.remoteUserMap.entries()).forEach((e=>{let[t]=e;var i;t._videoTrack&&t._videoTrack._player&&(null===(i=t._videoTrack._player.getVideoElement())||void 0===i||i.pause(),t._videoTrack._player.isKeepLastFrame=!0,t._videoTrack._originMediaStreamTrack.stop())})),this.sendConnection.close(),this.unbindConnectionEvents(this.sendConnection),this.sendConnection=void 0,this.recvConnection.close(),this.unbindConnectionEvents(this.recvConnection),this.recvConnection=void 0,0!==this.localTrackMap.size&&(Array.from(this.localTrackMap.entries()).forEach((e=>{var t;let[i,{track:n}]=e;switch(i){case zU.LocalVideoTrack:Dn(t=n._hints).call(t,vD.LOW_STREAM)?n.close():this.pendingLocalTracks.push(n);break;case zU.LocalAudioTrack:n instanceof bL?this.pendingLocalTracks=this.pendingLocalTracks.concat(n.trackList):this.pendingLocalTracks.push(n);case zU.LocalVideoLowTrack:}})),this.emit(JU.MediaReconnectStart,this.store.uid)),this.unbindLocalTrackEvents(),this.localTrackMap.clear(),0!==this.remoteUserMap.size&&Array.from(this.remoteUserMap.entries()).forEach((e=>{let[t,i]=e;Array.from(MN(i).call(i)).forEach((e=>{this.setPendingRemoteMedia(t,e)})),this.emit(JU.MediaReconnectStart,t.uid)})),this.unbindAllRemoteTrackEvents(),this.remoteUserMap.clear(),this.stopUploadUplinkState(),this.stopUploadDownlinkState(),this.statsUploader.stopUploadOutboundStats(),this.statsUploader.stopUploadInboundStats(),this.statsUploader.stopUploadTransportStats(),YN.debug("[".concat(this.store.clientId,"] P2PChannel2 disconnected, waiting to reconnect.")))}hasPendingRemoteMedia(e,t){for(const i of this.pendingRemoteTracks){const{user:n,kind:r}=i;if((e instanceof IF?e.uid:e)===n.uid&&t===r)return!0}return!1}setPendingRemoteMedia(e,t){this.hasPendingRemoteMedia(e,t)||this.pendingRemoteTracks.push({user:e,kind:t})}async restartICE(e,t){let i,n;if(e===EU.SEND_ONLY){if(!this.sendConnection)throw new mw(Ew.INVALID_OPERATION,"Cannot call P2PChannel2.handleMuteLocalTrack before sendConnection established.");i=await this.sendMutex.lock("From P2PChannel.restartICE"),n=this.sendConnection}else{if(!this.recvConnection)throw new mw(Ew.INVALID_OPERATION,"Cannot call P2PChannel2.handleMuteLocalTrack before recvConnection established.");i=await this.recvMutex.lock("From P2PChannel.restartICE"),n=this.recvConnection}try{if(t){const e=await n.restartICE(t);return n.isInRestartIce=!1,e}{const e=await n.restartICE();if(e){const t=await Yw(this,JU.RequestP2PRestartICE,{direction:EU.RECEIVE_ONLY,iceParameter:e});await n.restartICE(t),n.isInRestartIce=!1}}}finally{i()}}getUplinkNetworkQuality(){if(!this.sendConnection)return 0;const e=this.sendConnection.getStats(),t=this.localTrackMap.get(zU.LocalVideoTrack),i=this.localTrackMap.get(zU.LocalAudioTrack),n=e.videoSend.find((e=>{var i;return e.ssrc===(null==t||null===(i=t.ssrcs)||void 0===i?void 0:i[0].ssrcId)})),r=e.audioSend.find((e=>{var t;return e.ssrc===(null==i||null===(t=i.ssrcs)||void 0===t?void 0:t[0].ssrcId)}));if(!n||!r)return 1;const o=zw(this,JU.NeedSignalRTT),s=n?n.rttMs:void 0,a=r?r.rttMs:void 0,c=s&&a?(s+a)/2:s||a,d=(c&&o?(c+o)/2:c||o)||0,l=100*e.sendPacketLossRate*.7/50+.3*d/1500,u=l<.17?1:l<.36?2:l<.59?3:l<.1?4:5,h=null==t?void 0:t.track;if(h&&h._encoderConfig&&-1===h._hints.indexOf(vD.SCREEN_TRACK)){const t=h._encoderConfig.bitrateMax,i=e.bitrate.actualEncoded;if(t&&i){const e=(1e3*t-i)/(1e3*t);return fM[e<.15?0:e<.3?1:e<.45?2:e<.6?3:4][u]}}return u}getDownlinkNetworkQuality(){if(!this.recvConnection)return 0;const e=this.recvConnection.getStats();let t=0;return Array.from(this.remoteUserMap.entries()).forEach((i=>{let[n]=i;const r=n._audioSSRC,o=n._videoSSRC,s=e.audioRecv.find((e=>e.ssrc===r)),a=e.videoRecv.find((e=>e.ssrc===o));if(!s&&!a)return void(t+=1);const c=zw(this,JU.NeedSignalRTT),d=e.rtt,l=(d&&c?(d+c)/2:d||c)||0,u=s?s.jitterMs:void 0,h=e.recvPacketLossRate;let p=.7*h*100/50+.3*l/1500;u&&(p=.6*h*100/50+.2*l/1500+.2*u/400);t+=p<.1?1:p<.17?2:p<.36?3:p<.59?4:5})),this.remoteUserMap.size>0?Math.round(t/this.remoteUserMap.size):t}async muteLocalTrack(e){return new Wh(((t,i)=>{this.handleMuteLocalTrack(e,t,i)}))}filterTobePublishedTracks(e,t,i){const n=[],r=nD(),o=this.getAllTracks();e=Zw(e=e.filter((e=>-1===o.indexOf(e))));let s=!1,a=!1;for(const o of e){if(o instanceof pk&&(this.localTrackMap.has(zU.LocalVideoTrack)||s?new mw(Ew.CAN_NOT_PUBLISH_MULTIPLE_VIDEO_TRACKS).throw():(n.push({track:o,type:zU.LocalVideoTrack}),s=!0),t)){const e=this.getLowVideoTrack(o,i);n.push({track:e,type:zU.LocalVideoLowTrack})}if(o instanceof IL){const e=this.localTrackMap.get(zU.LocalAudioTrack);if(e){if(!(e.track instanceof bL))throw new mw(Ew.NOT_SUPPORTED,"cannot publish multiple tracks which one of them configured with bypassWebAudio or your browser does not support audio mixing");if(o._bypassWebAudio)throw new mw(Ew.NOT_SUPPORTED,"cannot publish multiple tracks which one of them configured with bypassWebAudio");e.track.addAudioTrack(o),this.bindLocalAudioTrackEvents(o,!0)}else if(a){const e=n.find((e=>{let{type:t}=e;return t===zU.LocalAudioTrack}));if(!(e.track instanceof bL))throw new mw(Ew.NOT_SUPPORTED,"cannot publish multiple tracks which one of them configured with bypassWebAudio or your browser does not support audio mixing");if(o._bypassWebAudio)throw new mw(Ew.NOT_SUPPORTED,"cannot publish multiple tracks which one of them configured with bypassWebAudio");e.track.addAudioTrack(o)}else{if(!r.webAudioMediaStreamDest||o instanceof bL||o._bypassWebAudio)n.push({track:o,type:zU.LocalAudioTrack});else{const e=new bL;e.addAudioTrack(o),n.push({track:e,type:zU.LocalAudioTrack})}a=!0}}}return n}filterTobeUnpublishedTracks(e){const t=[],i=this.getAllTracks();e=Zw(e=e.filter((e=>-1!==i.indexOf(e))));for(const i of e){if(i instanceof IL){const e=this.localTrackMap.get(zU.LocalAudioTrack);if(!e)continue;e.track instanceof bL?(e.track.removeAudioTrack(i),this.unbindLocalAudioTrackEvents(i),0===e.track.trackList.length&&(t.push([zU.LocalAudioTrack,e]),e.track.close())):t.push([zU.LocalAudioTrack,e])}if(i instanceof pk){const e=this.localTrackMap.get(zU.LocalVideoTrack);if(!e)continue;t.push([zU.LocalVideoTrack,e]);const i=this.localTrackMap.get(zU.LocalVideoLowTrack);
12272i&&t.push([zU.LocalVideoLowTrack,i])}}return t}bindLocalTrackEvents(e){e.forEach((e=>{let{track:t,type:i}=e;switch(i){case zU.LocalVideoTrack:t.addListener(RD.GET_STATS,this.handleGetLocalVideoStats),t.addListener(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),t.addListener(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),t.addListener(RD.NEED_UPDATE_VIDEO_ENCODER,this.handleUpdateVideoEncoder),t.addListener(RD.NEED_UPDATE_VIDEO_SEND_PARAMETERS,this.handleUpdateVideoSendParameters),t.addListener(RD.NEED_REPLACE_TRACK,this.handleReplaceTrack),t.addListener(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),t.addListener(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack);break;case zU.LocalAudioTrack:this.bindLocalAudioTrackEvents(t);case zU.LocalVideoLowTrack:}}))}bindLocalAudioTrackEvents(e,t){e instanceof bL?e.trackList.forEach((e=>{e.addListener(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),e.addListener(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),e.addListener(RD.GET_STATS,this.handleGetLocalAudioStats),e.addListener(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),e.addListener(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack)})):(e.addListener(RD.GET_STATS,this.handleGetLocalAudioStats),e.addListener(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),e.addListener(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),e.addListener(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),e.addListener(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack),t||e.addListener(RD.NEED_REPLACE_TRACK,this.handleReplaceTrack))}unbindLocalTrackEvents(e){e||(e=Array.from(this.localTrackMap.entries()).map((e=>{let[t,{track:i}]=e;return{track:i,type:t}}))),e.forEach((e=>{let{track:t,type:i}=e;switch(i){case zU.LocalVideoTrack:t.off(RD.GET_STATS,this.handleGetLocalVideoStats),t.off(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),t.off(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),t.off(RD.NEED_UPDATE_VIDEO_ENCODER,this.handleUpdateVideoEncoder),t.off(RD.NEED_UPDATE_VIDEO_SEND_PARAMETERS,this.handleUpdateVideoSendParameters),t.off(RD.NEED_REPLACE_TRACK,this.handleReplaceTrack),t.off(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),t.off(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack);break;case zU.LocalAudioTrack:this.unbindLocalAudioTrackEvents(t);case zU.LocalVideoLowTrack:}}))}unbindLocalAudioTrackEvents(e){e instanceof bL?e.trackList.forEach((e=>{e.off(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),e.off(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),e.off(RD.GET_STATS,this.handleGetLocalAudioStats),e.off(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),e.off(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack)})):(e.off(RD.GET_STATS,this.handleGetLocalAudioStats),e.off(RD.NEED_DISABLE_TRACK,this.handleMuteLocalTrack),e.off(RD.NEED_ENABLE_TRACK,this.handleUnmuteLocalTrack),e.off(RD.NEED_REPLACE_TRACK,this.handleReplaceTrack),e.off(RD.NEED_MUTE_TRACK,this.handleMuteLocalTrack),e.off(RD.NEED_UNMUTE_TRACK,this.handleUnmuteLocalTrack))}bindRemoteTrackEvents(e,t){t instanceof Ok&&t.addListener(RD.GET_STATS,(t=>{t(this.handleGetRemoteVideoStats(e))})),t instanceof Nk&&t.addListener(RD.GET_STATS,(t=>{t(this.handleGetRemoteAudioStats(e))}))}unbindRemoteTrackEvents(e){e&&e.removeAllListeners(RD.GET_STATS)}unbindAllRemoteTrackEvents(){Array.from(this.remoteUserMap.entries()).forEach((e=>{let[t,i]=e;i.has(HU.AUDIO)&&this.unbindRemoteTrackEvents(t._audioTrack),i.has(HU.VIDEO)&&this.unbindRemoteTrackEvents(t._videoTrack)}))}createGatewayPublishMessage(e,t){return e.map(((e,i)=>{var n;let r,{track:o,type:s}=e;switch(s){case zU.LocalAudioTrack:r=PU.Audio;break;case zU.LocalVideoTrack:r=Dn(n=o._hints).call(n,vD.SCREEN_TRACK)?PU.Screen:PU.High;break;case zU.LocalVideoLowTrack:r=PU.Low}return{kind:s===zU.LocalAudioTrack?HU.AUDIO:HU.VIDEO,stream_type:r,mid:t[i].id,ssrcs:t[i].localSSRC,isMuted:o.muted||!o.enabled}}))}createGatewayUnpublishMessage(e){return e.map((e=>{var t;let i,[n,{track:r,ssrcs:o,id:s}]=e;switch(n){case zU.LocalVideoTrack:i=Dn(t=r._hints).call(t,vD.SCREEN_TRACK)?PU.Screen:PU.High;break;case zU.LocalAudioTrack:i=PU.Audio;break;case zU.LocalVideoLowTrack:i=PU.Low}return{stream_type:i,ssrcs:o,mid:s}}))}assignLocalTracks(e,t){e.forEach(((e,i)=>{let{track:n,type:r}=e;this.localTrackMap.set(r,{track:n,id:t[i].id,ssrcs:t[i].localSSRC})}))}withdrawLocalTracks(e){e.forEach((e=>{let[t]=e;this.localTrackMap.delete(t)}))}bindConnectionEvents(e){e.onConnectionStateChange=async t=>{var i;YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: ").concat(e.name,".onConnectionStateChange(").concat(t,")")),this.emit
vendor: 15,874 bytes, line 12272
12272(JU.PeerConnectionStateChange,t),"connected"!==t||this.store.keyMetrics.peerConnectionEnd||this.store.peerConnectionEnd(),"connected"===t&&(e.isInRestartIce=!1),Dn(i=this._restartStates).call(i,t)&&!e.isInRestartIce&&("disconnected"===t&&await uO(800),"disconnected"!==e.iceConnectionState&&"failed"!==e.iceConnectionState||this.handleDisconnect(e.direction))},e.onICEConnectionStateChange=e=>{"connected"!==e||this.store.keyMetrics.iceConnectionEnd||this.store.iceConnectionEnd(),YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.onICEConnectionStateChange(").concat(e,")")),eD.reportApiInvoke(this.store.sessionId,{name:"ICEConnectionStateChange",options:e,tag:Mw.TRACER}).onSuccess(),this.emit(JU.IceConnectionStateChange,e)},e.onICETransportStateChange=e=>{YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.onICETransportStateChange(").concat(e,")"))},e.onDTLSTransportStateChange=e=>{YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.onDTLSTransportStateChange(").concat(e,")"))},e.onDTLSTransportError=e=>{YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.onDTLSTransportError(").concat(e,")"))},e.onFirstAudioDecoded=e=>{var t;const i=Array.from(MN(t=this.remoteUserMap).call(t)).find((t=>t._audioSSRC===e));var n;i&&(this.store.subscribe(i.uid,"audio",void 0,void 0,void 0,Date.now()),null===(n=i.audioTrack)||void 0===n||n.emit(wD.FIRST_FRAME_DECODED),eD.firstRemoteFrame(this.store.sessionId,JN.FIRST_AUDIO_DECODE,QN.FIRST_AUDIO_DECODE,{peer:i._uintid,subscribeElapse:TF.measureFromSubscribeStart(this.store.clientId,e),subscribeRequestid:e,p2pid:this.store.p2pId}))},e.onFirstAudioReceived=e=>{var t;const i=Array.from(MN(t=this.remoteUserMap).call(t)).find((t=>t._audioSSRC===e));i&&eD.firstRemoteFrame(this.store.sessionId,JN.FIRST_AUDIO_RECEIVED,QN.FIRST_AUDIO_RECEIVED,{peer:i._uintid,subscribeElapse:TF.measureFromSubscribeStart(this.store.clientId,e),subscribeRequestid:e,p2pid:this.store.p2pId})},e.onFirstVideoDecoded=(e,t,i)=>{this.reportVideoFirstFrameDecoded(e,t,i)},e.onFirstVideoReceived=e=>{var t;const i=Array.from(MN(t=this.remoteUserMap).call(t)).find((t=>t._videoSSRC===e));i&&eD.firstRemoteFrame(this.store.sessionId,JN.FIRST_VIDEO_RECEIVED,QN.FIRST_VIDEO_RECEIVED,{peer:i._uintid,subscribeElapse:TF.measureFromSubscribeStart(this.store.clientId,e),subscribeRequestid:e,p2pid:this.store.p2pId})},e.onSelectedLocalCandidateChanged=(e,t)=>{const i="relay"===e.candidateType,n="relay"===t.candidateType;"unknown"!==t.candidateType&&i===n||this.emit(JU.ConnectionTypeChange,i),YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.SelectedLocalCandidateChanged(").concat(JSON.stringify(Fx(t))," -> ").concat(JSON.stringify(Fx(e)),")"))},e.onSelectedRemoteCandidateChanged=(e,t)=>{YN.info("[".concat(this.store.clientId,"] [p2pId: ").concat(this.store.p2pId,"]: P2PConnection.SelectedRemoteCandidateChanged(").concat(JSON.stringify(Fx(t))," -> ").concat(JSON.stringify(Fx(e)),")"))},e.onFirstVideoDecodedTimeout=e=>{this.reportVideoFirstFrameDecoded(e,void 0,void 0,!0)},e.onLocalCandidate=t=>{this.emit(JU.LocalCandidate,{candidate:t,direction:e.direction})}}unbindConnectionEvents(e){e.onConnectionStateChange=void 0,e.onICEConnectionStateChange=void 0,e.onICETransportStateChange=void 0,e.onDTLSTransportStateChange=void 0,e.onDTLSTransportError=void 0,e.onFirstAudioDecoded=void 0,e.onFirstAudioReceived=void 0,e.onFirstVideoDecoded=void 0,e.onFirstVideoReceived=void 0,e.onSelectedLocalCandidateChanged=void 0,e.onSelectedRemoteCandidateChanged=void 0,e.onFirstVideoDecodedTimeout=void 0,e.onLocalCandidate=void 0}async handleDisconnect(e){const t=e===EU.SEND_ONLY?this.sendConnection:this.recvConnection;t&&!t.isInRestartIce&&(t.isInRestartIce=!0,YN.debug("[".concat(this.store.clientId,"] [P2PChannel-").concat(t.name,"] start use restartICE")),e===EU.SEND_ONLY?this.restartICE(e):Yw(this,JU.RequestP2PRestartICE,{direction:EU.SEND_ONLY}))}filterTobeMutedTracks(e){const t=[];if(-1===this.getAllTracks().indexOf(e))return t;const i=this.localTrackMap.get(zU.LocalAudioTrack);if(e instanceof IL&&(null==i?void 0:i.track)instanceof bL)return i.track.isActive||t.push([zU.LocalAudioTrack,i]),t;const n=Array.from(this.localTrackMap.entries()).find((t=>{let[,{track:i}]=t;return e===i}));if(n&&(t.push(n),n[0]===zU.LocalVideoTrack)){const e=this.localTrackMap.get(zU.LocalVideoLowTrack);e&&t.push([zU.LocalVideoLowTrack,e])}return t}filterTobeUnmutedTracks(e){const t=[],i=this.localTrackMap.get(zU.LocalAudioTrack);if(e instanceof IL&&(null==i?void 0:i.track)instanceof bL)return i.track.isActive&&t.push([zU.LocalAudioTrack,i]),t;const n=Array.from(this.localTrackMap.entries()).find((t=>{let[,{track:i}]=t;return e===i}));if(n)if(n[0]===zU.LocalVideoTrack){t.push(n);const e=this.localTrackMap.get(zU.LocalVideoLowTrack);e&&t.push([zU.LocalVideoLowTrack,e])}else t.push(n);return t}createMuteMessage(e){return e.map((e=>{var t;let i,[n,{track:r,ssrcs:o,id:s}]=e;switch(n){case zU.LocalAudioTrack:i=PU.Audio;break;case zU.LocalVideoTrack:i=Dn(t=r._hints).call(t,vD.SCREEN_TRACK)?PU.Screen:PU.High;break;case zU.LocalVideoLowTrack:i=PU.Low}return{stream_type:i,ssrcs:o,mid:s}}))}createUnmuteMessage(e){return e.map((e=>{var t;let i,[n,{track:r,ssrcs:o,id:s}]=e;switch(n){case zU.LocalAudioTrack:i=PU.Audio;break;case zU.LocalVideoTrack:i=Dn(t=r._hints).call(t,vD.SCREEN_TRACK)?PU.Screen:PU.High;break;case zU.LocalVideoLowTrack:i=PU.Low}return{stream_type:i,ssrcs:o,mid:s}}))}filterTobeUnSubscribedTracks(e,t){const i=[],n=this.remoteUserMap.get(e);if(!n)return i;if(t){const r=n.get(t);if(!r)return i;i.push([e,{kind:t,id:r}])}else Array.from(n.entries()).forEach((t=>{let[n,r]=t;i.push([e,{kind:n,id:r}])}));return i}createUnsubscribeMessage(e){const t=[];return e.forEach((e=>{let[i,{kind:n,id:r}]=e;switch(n){case HU.VIDEO:return void(i._videoSSRC&&t.push({stream_type:HU.VIDEO,ssrcId:i._videoSSRC}));case HU.AUDIO:return void(i._audioSSRC&&t.push({stream_type:HU.AUDIO,ssrcId:i._audioSSRC}))}})),t}withdrawRemoteTracks(e){e.forEach((e=>{let[t,{kind:i}]=e;const n=this.remoteUserMap.get(t);n&&(n.delete(i),0===Array.from(n.entries()).length&&this.remoteUserMap.delete(t))}))}async updateBitrateLimit(e){const t=this.localTrackMap.get(zU.LocalVideoTrack),i=this.localTrackMap.get(zU.LocalVideoLowTrack);t&&(await t.track.setBitrateLimit(e.uplink),await new Wh(((e,i)=>{this.handleUpdateVideoEncoder(t.track,e,i,!0)}))),i&&e.low_stream_uplink&&(await i.track.setBitrateLimit({max_bitrate:e.low_stream_uplink.bitrate,min_bitrate:e.low_stream_uplink.bitrate||0}),await new Wh(((e,t)=>{this.handleUpdateVideoEncoder(i.track,e,t,!0)})))}isP2PDisconnected(){if(this.sendConnection&&this.recvConnection){const e=this.sendConnection.peerConnectionState,t=this.recvConnection.peerConnectionState;return"connected"!==e&&"connected"!==t}return!0}async tryToUnmuteAudio(e){for(let t=0;t<e.length;t++)if(e[t]instanceof IL){const i=this.filterTobeUnmutedTracks(e[t]);if(0===i.length)continue;const n=this.createUnmuteMessage(i);return void await qw(this,JU.RequestUnmuteLocal,n)}}bindStatsUploaderEvents(){this.statsUploader.requestStats=e=>this.getStats(e),this.statsUploader.requestLocalMedia=()=>Array.from(this.localTrackMap.entries()).filter((e=>{let[,{ssrcs:t}]=e;return!!t})),this.statsUploader.requestRemoteMedia=()=>Array.from(this.remoteUserMap.entries()),this.statsUploader.requestVideoIsReady=e=>{var t;return!(null===(t=this.recvConnection)||void 0===t||!t.getRemoteVideoIsReady(e))},this.statsUploader.requestUpload=(e,t)=>this.emit(JU.RequestUpload,e,t),this.statsUploader.requestUploadStats=e=>this.emit(JU.RequestUploadStats,e),this.statsUploader.requestAllTracks=()=>this.getAllTracks()}unbindStatsUploaderEvents(){this.statsUploader.requestStats=void 0,this.statsUploader.requestLocalMedia=void 0,this.statsUploader.requestRemoteMedia=void 0,this.statsUploader.requestVideoIsReady=void 0}async requestReconnect(){this.dtlsFailedCount+=1,await uO(bO(this.dtlsFailedCount,AO)),this.emit(JU.RequestReconnect)}async reconnectP2P(){}canPublishLowStream(){return this.localTrackMap.has(zU.LocalVideoTrack)||this.pendingLocalTracks.some((e=>e instanceof pk))}throwIfTrackTypeNotMatch(e){if(e.filter((e=>e instanceof pk)).length>1)throw new mw(Ew.CAN_NOT_PUBLISH_MULTIPLE_VIDEO_TRACKS);if(e.filter((e=>e instanceof IL)).length>1&&(e.some((e=>e instanceof IL&&e._bypassWebAudio))||!nD().webAudioMediaStreamDest))throw new mw(Ew.NOT_SUPPORTED,"cannot publish multiple tracks which one of them configured with bypassWebAudio or your browser doesn't support MediaStreamDestNode");for(const t of e){if(t instanceof pk&&this.pendingLocalTracks.some((e=>e instanceof pk)))throw new mw(Ew.CAN_NOT_PUBLISH_MULTIPLE_VIDEO_TRACKS);if(t instanceof IL&&this.pendingLocalTracks.some((e=>e instanceof IL))&&(!nD().webAudioMediaStreamDest||t._bypassWebAudio||this.pendingLocalTracks.some((e=>e instanceof IL&&e._bypassWebAudio))))throw new mw(Ew.NOT_SUPPORTED,"cannot publish multiple tracks which one of them configured with bypassWebAudio or your browser doesn't support MediaStreamDestNode")}}getLowVideoTrack(e,t){const i=!_N("DISABLE_DUAL_STREAM_USE_ENCODING")&&nD().supportDualStreamEncoding,n=zq(zq({},{width:160,height:120,framerate:15,bitrate:50}),t);let r;r=i?e._mediaStreamTrack.clone():eB(e,n);const o=hO(8,"track-low-"),s=new pk(r,zq(zq({},i&&{scaleResolutionDownBy:Vx(n,e)}),{},{frameRate:n.framerate,bitrateMax:n.bitrate,bitrateMin:n.bitrate}),void 0,void 0,o);return s.on(AD.TRANSCEIVER_UPDATED,(t=>{e._updateRtpTransceiver(t,CD.LOW_STREAM)})),s._hints.push(vD.LOW_STREAM),e.addListener(RD.NEED_CLOSE,(()=>{s.close()})),s}async globalLock(){return this.recvMutex.lock("From P2PChannel2.globalLock")}reportVideoFirstFrameDecoded(e,t,i,n){var r;const o=Array.from(MN(r=this.remoteUserMap).call(r)).find((t=>t._videoSSRC===e));if(o){n||this.store.subscribe(o.uid,"video",void 0,void 0,void 0,void 0,Date.now());const r=this.store.keyMetrics,s=r.subscribe.find((e=>e.userId===o.uid&&"video"===e.type));eD.firstRemoteVideoDecode(this.store.sessionId,JN.FIRST_VIDEO_DECODE,QN.FIRST_VIDEO_DECODE,{peer:o._uintid,videowidth:t,videoheight:i,subscribeElapse:TF.measureFromSubscribeStart(this.store.clientId,e),subscribeRequestid:e,p2pid:this.store.p2pId,apEnd:r.requestAPEnd||0,apStart:r.requestAPStart||0,joinGwEnd:r.joinGatewayEnd||0,joinGwStart:r.joinGatewayStart||0,pcEnd:r.peerConnectionEnd||0,pcStart:r.peerConnectionStart||0,subscriberEnd:(null==s?void 0:s.subscribeEnd)||0,subscriberStart:(null==s?void 0:s.subscribeStart)||0,videoAddNotify:(null==s?void 0:s.streamAdded)||0,state:n?1:0})}}async remoteMediaSsrcChanged(e,t,i){if(!this.recvConnection)return!1;const n=this.remoteUserMap.get(e);if(!n)return!1;const r=n.get(t);if(!r)return!1;const o=await this.recvConnection.getRemoteSSRC(r);return void 0!==o&&o!==i}isPreSubScribe(e){return!1}async publishDataChannel(e){throw new mw(Ew.NOT_SUPPORTED)}async unpublishDataChannel(e){throw new mw(Ew.NOT_SUPPORTED)}async subscribeDataChannel(e,t){throw new mw(Ew.NOT_SUPPORTED)}async unsubscribeDataChannel(e,t){throw new mw(Ew.NOT_SUPPORTED)}hasPendingRemoteDataChannel(e,t){throw new mw(Ew.NOT_SUPPORTED)}setPendingRemoteDataChannel(e,t){throw new mw(Ew.NOT_SUPPORTED)}async preConnect(e){throw new mw(Ew.NOT_SUPPORTED)}getEstablishParams(){throw new mw(Ew.NOT_SUPPORTED)}async reSubscribe(e){throw new mw(Ew.NOT_SUPPORTED)}async updateVideoStreamParameter(e,t){throw new mw(Ew.NOT_SUPPORTED)}unbindRtpTransceiver(){0!==this.localTrackMap.size&&Array.from(this.localTrackMap.entries()).forEach((e=>{let[t,{track:i}]=e;t===zU.LocalVideoLowTrack?i._updateRtpTransceiver(void 0,CD.LOW_STREAM):i._updateRtpTransceiver(void 0)}))}},rU(Yq.prototype,"p2pConnect",[Mq],Object.getOwnPropertyDescriptor(Yq.prototype,"p2pConnect"),Yq.prototype),rU(Yq.prototype,"unpublish",[Uq],Object.getOwnPropertyDescriptor(Yq.prototype,"unpublish"),Yq.prototype),rU(Yq.prototype,"unpublishLowStream",[xq],Object.getOwnPropertyDescriptor(Yq.prototype,"unpublishLowStream"),Yq.prototype),rU(Yq.prototype,"subscribe",[Vq],Object.getOwnPropertyDescriptor(Yq.prototype,"subscribe"),Yq.prototype),rU(Yq.prototype,"mockSubscribe",[Fq],Object.getOwnPropertyDescriptor(Yq.prototype,"mockSubscribe"),Yq.prototype),rU(Yq.prototype,"unsubscribe",[Bq],Object.getOwnPropertyDescriptor(Yq.prototype,"unsubscribe"),Yq.prototype),rU(Yq.prototype,"muteRemote",[jq],Object.getOwnPropertyDescriptor(Yq.prototype,"muteRemote"),Yq.prototype),rU(Yq.prototype,"unmuteRemote",[Gq],Object.getOwnPropertyDescriptor(Yq.prototype,"unmuteRemote"),Yq.prototype),rU(Yq.prototype,"hasRemoteMediaWithLock",[Wq],Object.getOwnPropertyDescriptor(Yq.prototype,"hasRemoteMediaWithLock"),Yq.prototype),rU(Yq.prototype,"disconnectForReconnect",[Hq],Object.getOwnPropertyDescriptor(Yq.prototype,"disconnectForReconnect"),Yq.prototype),rU(Yq.prototype,"remoteMediaSsrcChanged",[Kq],Object.getOwnPropertyDescriptor(Yq.prototype,"remoteMediaSsrcChanged"),Yq.prototype),Yq);function Jq(e){return function(t,i,n){const r=t[i];if("function"!=typeof r)throw new Error("Cannot use mutex on object property.");return n.value=async function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];switch(e){case kq.SEND_ONLY:{const e=await this.sendMutex.lock("From P2PChannel2.".concat(i));try{return await r.apply(this,n)}finally{e()}}case kq.RECEIVE_ONLY:{const e=await this.recvMutex.lock("From P2PChannel2.".concat(i));try{return await r.apply(this,n)}finally{e()}}default:{const e=await this.sendMutex.lock("From P2PChannel2.".concat(i)),t=await this.recvMutex.lock("From P2PChannel2.".concat(i));try{return await r.apply(this,n)}finally{e(),t()}}}},n}}class Qq extends Dw{constructor(e,t){super(),QI(this,"signal",void 0),QI(this,"token",void 0),QI(this,"tokenTimeout",void 0),QI(this,"tokenInterval",void 0),QI(this,"_sequence",0),QI(this,"userMap",new Map),QI(this,"encoder",new TextEncoder),this.signal=e,this.token=t;const i=()=>{this.signal.connectionState===lU.CONNECTED&&this.check(),0===this.userMap.size?this.tokenInterval=window.setTimeout(i,1e3):this.tokenInterval=window.setTimeout(i,3*_N("P2P_TOKEN_INTERVAL"))};i()}async send(e,t,i,n,r){var o,s,a;if(0===this.userMap.size)return;const c=Array.from(Zh(o=this.userMap).call(o))[0].token;"string"!=typeof t&&(t=JSON.stringify(t)),n=null!==(s=n)&&void 0!==s?s:hO(6,""),r=null!==(a=r)&&void 0!==a?a:this._sequence++;const d={_id:n,_type:e,_seq:r,_message:t,token:"".concat(this.token,"_").concat(c)};_N("SHOW_P2P_LOG")&&YN.debug("send message",d,"noNeedResponse : ".concat(i));this.splitMessage(JSON.stringify(d)).forEach((e=>{this.signal.request(hU.DATA_STREAM,{payload:oO(this.encoder.encode(e))})}));const l=new Wh(((t,r)=>{const o=window.setTimeout((()=>{this.off("res-@".concat(n,"_ack"),s),this.off("res-@".concat(n),c),this.off(sx.ABORT,a),YN.debug("[external-signal] request timeout, type: ".concat(e,", requestId: ").concat(n)),0===this.userMap.size?r(new mw(Ew.INVALID_REMOTE_USER)):r(new mw(Ew.TIMEOUT))}),_N("EXTERNAL_SIGNAL_REQUEST_TIMEOUT")),s=()=>{o&&window.clearTimeout(o),this.off(sx.ABORT,a),i&&t()},a=()=>{o&&window.clearTimeout(o),this.off("res-@".concat(n,"_ack"),s),this.off("res-@".concat(n),c),r(new mw(Ew.EXTERNAL_SIGNAL_ABORT,"type: ".concat(e,", requestId: ").concat(n)))};this.once(sx.ABORT,a),this.once("res-@".concat(n,"_ack"),s);const c=(i,c)=>{l=!0,o&&window.clearTimeout(o),this.off("res-@".concat(n,"_ack"),s),this.off(sx.ABORT,a),"success"===i?t(c):r(new mw(Ew.P2P_MESSAGE_FAILED,"request ".concat(e," failed, requestId: ").concat(n)))};let l=!1;i||(this.once("res-@".concat(n),c),uO(_N("SIGNAL_REQUEST_TIMEOUT")).then((()=>{l||YN.warning("external_signal request timeout, type: ".concat(e,", requestId: ").concat(n,", ").concat(d))}
12272)))}));try{return await l}catch(o){if(o.code===Ew.TIMEOUT)return await this.send(e,t,i,n,r);throw o}}onMessage(e){var t;const{_uid:i}=e;let n,r=this.userMap.get(i);if(r)n=r.splitMessageMap;else{if(this.userMap.size>0||!("_type"in e)||e._type!==ox.CHECK)return;const{token:t}=e;n=new Map,r={uid:i,isStart:!0,token:t,splitMessageMap:n,nextExpectedSequenceNumber:0,receivedMessagesMap:new Map},this.userMap.set(i,r),this.signal.emit(_U.ON_USER_ONLINE,{uid:i}),this.handleUserOnline()}if("id"in e&&"total"in e){var o;const{id:t,total:r}=e,s=null!==(o=n.get(t))&&void 0!==o?o:[];if(s.push(e),n.has(t)||n.set(t,s),s.length!==r)return;{const r=vS(s).call(s,((e,t)=>e.index-t.index)).map((e=>e.payload)).join("");n.delete(t),(e=JSON.parse(r))._uid=i}}const{_type:s,token:a}=e;if(Dn(t=[ox.ACK,ox.CHECK]).call(t,s))return s===ox.CHECK&&this.handleCheckToken(r,a),void this.receiveMessage(e);a==="".concat(r.token,"_").concat(this.token)?this.handleReceivedMessage(e):YN.debug('Receive unexpected message", '.concat(a,", cur_token: ").concat(r.token,"_").concat(this.token),e)}check(){const e={_id:hO(6,""),token:this.token,_type:ox.CHECK};_N("SHOW_P2P_LOG")&&YN.debug("send message",e),this.signal.request(hU.DATA_STREAM,{payload:oO(this.encoder.encode(JSON.stringify(e)))})}ack(e){const t={_id:e,_type:ox.ACK,token:this.token};_N("SHOW_P2P_LOG")&&YN.debug("send message",t),this.signal.request(hU.DATA_STREAM,{payload:oO(this.encoder.encode(JSON.stringify(t)))})}response(e,t,i){this.send(ox.RESPONSE,JSON.stringify({success:!i,message:t}),!0,e)}handleReceivedMessage(e){const t=()=>
vendor: 64,558 bytes, line 12272
12272{this.userMap.forEach((e=>{const{receivedMessagesMap:t,nextExpectedSequenceNumber:i}=e;for(;t.has(i);){const n=t.get(i);t.delete(i),this.receiveMessage(n),e.nextExpectedSequenceNumber++}}))};if(!e)return void t();const{_uid:i,_seq:n}=e,r=this.userMap.get(i),{receivedMessagesMap:o,isStart:s,nextExpectedSequenceNumber:a}=r;if(n<a)return this.ack(e._id),void YN.debug("[external-signal] receive old message, seq: ".concat(n,", ").concat(e._message));o.set(n,e),s&&n===a&&(this.receiveMessage(e),o.delete(a),r.nextExpectedSequenceNumber++,t())}receiveMessage(e){const{_id:t,_type:i,_message:n,_uid:r}=e;if(_N("SHOW_P2P_LOG")&&YN.debug("receive message",e),t){let o;switch(e._type!==ox.ACK&&(n&&(o=JSON.parse(n)),this.ack(e._id)),e._type){case ox.CANDIDATE:case ox.CONTROL:this.signal.emit(i,o,r);break;case ox.PUBLISH:case ox.UNPUBLISH:case ox.RESTART_ICE:case ox.CALL:o.uid=r,Yw(this.signal,i,o).then((t=>{this.response(e._id,t)})).catch((()=>{this.response(e._id,void 0,!0)}));break;case ox.ACK:this.getListeners("res-@".concat(t,"_ack")).length>0&&this.emit("res-@".concat(t,"_ack"));break;case ox.RESPONSE:{const{success:e,message:i}=o;this.emit("res-@".concat(t),e?"success":"failed",i);break}}}}splitMessage(e){if(e.length<Qq.MAX_MESSAGE_SIZE)return[e];const t=[],{remoteToken:i}=JSON.parse(e),n=hO(6,"");let r=0,o=800;const s=Math.ceil(e.length/o);for(;e.length>0;){r++;const a={id:n,index:r,total:s,payload:e.slice(0,o),token:"".concat(this.token,"_").concat(i)};JSON.stringify(a).length>Qq.MAX_MESSAGE_SIZE?o-=50:(t.push(a),e=e.slice(o))}return t.map((e=>JSON.stringify(e)))}handleCheckToken(e,t){return e.token!==t?(YN.debug("token changed, from ".concat(e.token," to ").concat(t)),this.reset(e.uid,t),!1):(this.tokenTimeout&&(window.clearTimeout(this.tokenTimeout),this.tokenTimeout=void 0),this.tokenTimeout=window.setTimeout((()=>{YN.debug("token timeout, ".concat(t)),this.reset(e.uid)}),_N("MAX_P2P_TIMEOUT")),!0)}async handleUserOnline(){const e=await Yw(this.signal,ox.CALL,void 0),t=await this.send(ox.CALL,e);this.signal.emit(uU.P2P_CONNECTION,t,!0)}async reset(e,t){const i=this.userMap.get(e);i&&(this.emit(sx.ABORT),this.signal.emit(_U.ON_USER_OFFLINE,{uid:i.uid,reason:cx.P2P_TOKEN_CHANGED}),this._sequence=0,this.userMap.clear(),t||(YN.debug("change local token from ".concat(t," to ").concat(t)),this.token=hO(6,"")))}clear(){this._sequence=0,this.userMap.clear(),this.tokenInterval&&window.clearTimeout(this.tokenInterval),this.tokenInterval=void 0,this.tokenTimeout&&window.clearTimeout(this.tokenTimeout),this.tokenTimeout=void 0,this.emit(sx.ABORT)}}QI(Qq,"MAX_SIZE",1),QI(Qq,"MAX_MESSAGE_SIZE",1024);class Zq extends Dw{get connectionState(){return this._connectionState}set connectionState(e){e!==this._connectionState&&(this._connectionState=e,e===lU.CONNECTED?this.emit(uU.WS_CONNECTED):e===lU.RECONNECTING?this.emit(uU.WS_RECONNECTING,this._websocketReconnectReason):e===lU.CLOSED&&this.emit(uU.WS_CLOSED,this._disconnectedReason))}get currentURLIndex(){return this.websocket.currentURLIndex}get url(){return this.websocket&&this.websocket.url||null}get rtt(){return this.rttRolling.mean()}constructor(e,t){super(),QI(this,"_disconnectedReason",void 0),QI(this,"_websocketReconnectReason",void 0),QI(this,"_connectionState",lU.CLOSED),QI(this,"reconnectToken",void 0),QI(this,"p2pToken",void 0),QI(this,"websocket",void 0),QI(this,"openConnectionTime",void 0),QI(this,"clientId",void 0),QI(this,"lastMsgTime",Date.now()),QI(this,"uploadCache",[]),QI(this,"uploadCacheInterval",void 0),QI(this,"rttRolling",new NO(5)),QI(this,"pingpongTimer",void 0),QI(this,"pingpongTimeoutCount",0),QI(this,"joinResponse",void 0),QI(this,"multiIpOption",void 0),QI(this,"initError",void 0),QI(this,"spec",void 0),QI(this,"store",void 0),QI(this,"_external_signal",void 0),QI(this,"onWebsocketMessage",(e=>{if(e.data instanceof ArrayBuffer)return void this.emit(uU.ON_BINARY_DATA,e.data);const t=JSON.parse(e.data);if(this.lastMsgTime=Date.now(),Object.prototype.hasOwnProperty.call(t,"_id")){const e="res-@".concat(t._id);this.emit(e,t._result,t._message)}else if(Object.prototype.hasOwnProperty.call(t,"_type")){switch(t._type){case _U.ON_DATA_STREAM:return void this.handleDataStream(t._message);case _U.MUTE_AUDIO:case _U.MUTE_VIDEO:case _U.ON_P2P_LOST:case _U.ON_USER_ONLINE:return;case _U.ON_USER_OFFLINE:const{uid:e}=t._message;return YN.debug("[".concat(this.clientId,"] user-offline uid: ").concat(e)),void this._external_signal.reset(e)}if(this.emit(t._type,t._message),t._type===_U.ON_NOTIFICATION&&this.handleNotification(t._message),t._type===_U.ON_USER_BANNED)switch(t._message.error_code){case 14:this.close(Vw.UID_BANNED);break;case 15:this.close(Vw.IP_BANNED);break;case 16:this.close(Vw.CHANNEL_BANNED)}if(t._type===_U.ON_USER_LICENSE_BANNED)switch(t._message.error_code){case dU.ERR_LICENSE_MISSING:this.close(Vw.LICENSE_MISSING);break;case dU.ERR_LICENSE_EXPIRED:this.close(Vw.LICENSE_EXPIRED);break;case dU.ERR_LICENSE_MINUTES_EXCEEDED:this.close(Vw.LICENSE_MINUTES_EXCEEDED);break;case dU.ERR_LICENSE_PERIOD_INVALID:this.close(Vw.LICENSE_PERIOD_INVALID);break;case dU.ERR_LICENSE_MULTIPLE_SDK_SERVICE:this.close(Vw.LICENSE_MULTIPLE_SDK_SERVICE);break;case dU.ERR_LICENSE_ILLEGAL:this.close(Vw.LICENSE_ILLEGAL);break;default:this.close()}}})),this.clientId=e.clientId,this.spec=e,this.store=t,this.websocket=new Ix("gateway-".concat(this.clientId),this.spec.retryConfig,!0,_N("JOIN_GATEWAY_USE_DUAL_DOMAIN"),_N("JOIN_GATEWAY_USE_443PORT_ONLY"),t),this.handleWebsocketEvents(),window.addEventListener("offline",(()=>{this.connectionState===lU.CONNECTED&&this.reconnect("retry",Ww.OFFLINE)})),this.p2pToken=hO(6,""),this._external_signal=new Qq(this,this.p2pToken)}async request(e,t,i,n){const r=hO(6,""),o={_id:r,_type:e,_message:t},s=this.websocket.connectionID,a=()=>new Wh(((e,t)=>{if(this.connectionState===lU.CONNECTED)return e();const i=()=>{this.off(uU.WS_CLOSED,n),e()},n=()=>{this.off(uU.WS_CONNECTED,i),t(new mw(Ew.WS_ABORT))};this.once(uU.WS_CONNECTED,i),this.once(uU.WS_CLOSED,n)}));if(this.connectionState!==lU.CONNECTING&&this.connectionState!==lU.RECONNECTING||e===hU.JOIN||e===hU.REJOIN||await a(),this.websocket.sendMessage(o,!0),n)return;const c=new Wh(((i,n)=>{let o=!1;const a=(n,r)=>{o=!0,i({isSuccess:"success"===n,message:r||{}}),this.off(uU.WS_CLOSED,c),this.off(uU.WS_RECONNECTING,c),this.emit(uU.REQUEST_SUCCESS,e,t)};this.once("res-@".concat(r),a);const c=()=>{n(new mw(Ew.WS_ABORT,"type: ".concat(e))),this.off(uU.WS_CLOSED,c),this.off(uU.WS_RECONNECTING,c),this.off("res-@".concat(r),a)};this.once(uU.WS_CLOSED,c),this.once(uU.WS_RECONNECTING,c),uO(_N("SIGNAL_REQUEST_TIMEOUT")).then((()=>{this.websocket.connectionID!==s||o||(YN.warning("[".concat(this.clientId,"] ws request timeout, type: ").concat(e)),this.emit(uU.REQUEST_TIMEOUT,e,t))}))}));let d=null;try{d=await c}catch(n){if(this.connectionState===lU.CLOSED||e===hU.LEAVE)throw new mw(Ew.WS_ABORT);return!this.spec.forceWaitGatewayResponse||i?n.throw():e===hU.JOIN||e===hU.REJOIN?null:(await a(),await this.request(e,t))}if(d.isSuccess)return d.message;const l=Number(d.message.error_code||d.message.code),u=hx(l),h=new mw(Ew.UNEXPECTED_RESPONSE,"".concat(u.desc,": ").concat(d.message.error_str),{code:l,data:d.message,desc:u.desc});return"success"===u.action?d.message:(YN.warning("[".concat(this.clientId,"] [").concat(this.websocket.connectionID,"] unexpected response from type ").concat(e,", error_code: ").concat(l,", message: ").concat(u.desc,", action: ").concat(u.action)),l===dU.ERR_TOO_MANY_BROADCASTERS?e===hU.JOIN||e===hU.REJOIN?(this.initError=h,this.close(),h.throw()):h.throw():"failed"===u.action?h.throw():"quit"===u.action?(this.initError=h,this.close(),h.throw()):(l===dU.ERR_JOIN_BY_MULTI_IP?(this.multiIpOption=d.message.option,YN.warning("[".concat(this.clientId,"] detect multi ip, recover")),this.reconnect("recover",Ww.MULTI_IP)):this.reconnect(u.action,Ww.SERVER_ERROR),e===hU.JOIN||e===hU.REJOIN?null:await this.request(e,t)))}waitMessage(e,t){return new Wh((i=>{const n=r=>{(!t||t(r))&&(this.off(e,n),i(r))};this.on(e,n)}))}uploadWRTCStats(e){if(!this.store.sessionId)return void YN.warn("[".concat(this.clientId,"] no session id when upload wrtc stats"));const t={lts:Date.now(),sid:this.store.sessionId,uid:this.store.intUid,stats:e};this.upload(pU.WRTC_STATS,t)}upload(e,t){const i={_type:e,_message:t};try{this.websocket.sendMessage(i)}catch(e){const t=_N("MAX_UPLOAD_CACHE")||50;this.uploadCache.push(i),this.uploadCache.length>t&&this.uploadCache.splice(0,1),this.uploadCache.length>0&&!this.uploadCacheInterval&&(this.uploadCacheInterval=window.setInterval((()=>{if(this.connectionState!==lU.CONNECTED)return;const e=this.uploadCache.splice(0,1)[0];0===this.uploadCache.length&&(window.clearInterval(this.uploadCacheInterval),this.uploadCacheInterval=void 0),this.upload(e._type,e._message)}),_N("UPLOAD_CACHE_INTERVAL")||2e3))}}send(e,t){const i={_type:e,_message:t};this.websocket.sendMessage(i)}async sendExtensionMessage(e,t,i){return await this._external_signal.send(e,t,i)}init(e){return this.initError=void 0,this.multiIpOption=void 0,this.joinResponse=void 0,this.reconnectToken=void 0,this.openConnectionTime=void 0,new Wh(((t,i)=>{this.once(uU.WS_CONNECTED,(()=>t(this.joinResponse))),this.once(uU.WS_CLOSED,(()=>i(this.initError||new mw(Ew.WS_ABORT)))),this.connectionState=lU.CONNECTING,this.websocket.init(e).catch(i)}))}close(e){this.pingpongTimer&&(this.pingpongTimeoutCount=0,window.clearInterval(this.pingpongTimer),this.pingpongTimer=void 0),this.reconnectToken=void 0,this.joinResponse=void 0,this._external_signal.clear(),this._disconnectedReason=e||Vw.LEAVE,this.connectionState=lU.CLOSED,YN.debug("[".concat(this.clientId,"] ")+"will close websocket in signal"),this.websocket.close(),this.p2pToken=hO(6,""),this._external_signal.clear(),this._external_signal=new Qq(this,this.p2pToken)}async join(){if(!this.joinResponse){this.emit(uU.ABORT_P2P_EXECUTION);const e=await Yw(this,uU.REQUEST_JOIN_INFO),t=await this.request(hU.JOIN,e);if(!t)return this.emit(uU.REPORT_JOIN_GATEWAY,Ew.TIMEOUT,this.url||""),!1;this.joinResponse=t,this.emit(uU.JOIN_RESPONSE,this.joinResponse),this.reconnectToken=this.joinResponse.rejoin_token}return this.connectionState=lU.CONNECTED,this.pingpongTimer&&window.clearInterval(this.pingpongTimer),this.pingpongTimer=window.setInterval(this.handlePingPong.bind(this),3e3),!0}reconnect(e,t){this.pingpongTimer&&(this.pingpongTimeoutCount=0,window.clearInterval(this.pingpongTimer),this.pingpongTimer=void 0),this.websocket.reconnect(e,t)}handleDataStream(e){try{var t;const i=rO(e.payload),n=(new TextDecoder).decode(i),r=JSON.parse(n);"total"in r&&"id"in r||Dn(t=Object.values(ox)).call(t,r._type)?(r._uid=e.uid,this._external_signal.onMessage(r)):this.emit(_U.ON_DATA_STREAM,e)}catch(t){this.emit(_U.ON_DATA_STREAM,e)}}handleNotification(e){YN.debug("[".concat(this.clientId,"] receive notification: "),e);const t=hx(e.code);if("success"!==t.action){if("failed"!==t.action)return"quit"===t.action?("ERR_REPEAT_JOIN_CHANNEL"===t.desc&&this.close(Vw.UID_BANNED),void this.close()):void this.reconnect(t.action,Ww.SERVER_ERROR);YN.error("[".concat(this.clientId,"] ignore error: "),t.desc)}}handlePingPong(){if(!this.websocket||"connected"!==this.websocket.state)return;this.pingpongTimeoutCount>0&&this.rttRolling.add(3e3),this.pingpongTimeoutCount+=1;const e=_N("PING_PONG_TIME_OUT"),t=Date.now();this.pingpongTimeoutCount>=e&&(YN.warning("[".concat(this.clientId,"] PINGPONG Timeout. Last Socket Message: ").concat(t-this.lastMsgTime,"ms")),t-this.lastMsgTime>_N("WEBSOCKET_TIMEOUT_MIN"))?this.reconnect("retry",Ww.TIMEOUT):this.request(hU.PING,void 0,!0).then((()=>{this.pingpongTimeoutCount=0;const e=Date.now()-t;this.rttRolling.add(e),_N("REPORT_STATS")&&this.send(hU.PING_BACK,{pingpongElapse:e})})).catch((e=>{}))}handleWebsocketEvents(){this.websocket.on(mU.RECONNECT_CREATE_CONNECTION,(e=>{this.emit(uU.WS_RECONNECT_CREATE_CONNECTION,e)})),this.websocket.on(mU.ON_MESSAGE,this.onWebsocketMessage),this.websocket.on(mU.CLOSED,(()=>{this.connectionState=lU.CLOSED})),this.websocket.on(mU.FAILED,(()=>{this._disconnectedReason=Vw.NETWORK_ERROR,this.connectionState=lU.CLOSED})),this.websocket.on(mU.RECONNECTING,(e=>{this._websocketReconnectReason=e,this.joinResponse=void 0,this.connectionState===lU.CONNECTED?this.connectionState=lU.RECONNECTING:this.connectionState=lU.CONNECTING})),this.websocket.on(mU.WILL_RECONNECT,((e,t,i)=>{"retry"!==e?(YN.debug("".concat(this.clientId," websocket will_connect event, renewSession reconnectMode is ").concat(e)),this.reconnectToken=void 0):YN.debug("".concat(this.clientId," reconnect mode is retry, no need to renew session")),i(e)})),this.websocket.on(mU.CONNECTED,(()=>{this.openConnectionTime=Date.now(),this.join().catch((e=>{if(this.emit(uU.REPORT_JOIN_GATEWAY,e,this.url||""),e instanceof mw&&e.code===Ew.UNEXPECTED_RESPONSE&&e.data.code===dU.ERR_NO_AUTHORIZED)return YN.warning("[".concat(this.clientId,"] reconnect no authorized, recover")),void this.reconnect("recover",Ww.SERVER_ERROR);YN.error("[".concat(this.clientId,"] join gateway request failed"),e.toString()),this.spec.forceWaitGatewayResponse?this.reconnect("tryNext",Ww.SERVER_ERROR):(this.initError=e,this.close())}))})),this.websocket.on(mU.REQUEST_NEW_URLS,((e,t)=>{Yw(this,uU.REQUEST_RECOVER,this.multiIpOption).then(e).catch(t)})),this.websocket.on(mU.ON_TOKEN_PRIVILEGE_DID_EXPIRE,(()=>{this.emit(_U.ON_TOKEN_PRIVILEGE_DID_EXPIRE)}))}}const $q={name:"P2PChannel",create:function(e){let{store:t,statsCollector:i}=e;return new Xq(t,i)},createSubmodule:function(e){let{store:t,spec:i}=e;return new Zq(i,t)}};function ez(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function tz(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ez(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ez(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class iz{constructor(e){QI(this,"sessionDesc",void 0),QI(this,"localCapabilities",void 0),QI(this,"rtpCapabilities",void 0),QI(this,"candidates",void 0),QI(this,"_originCandidates",void 0),QI(this,"iceParameters",void 0),QI(this,"dtlsParameters",void 0),QI(this,"setup",void 0),QI(this,"currentMidIndex",void 0),QI(this,"cname",void 0),e=eO(e);const{iceParameters:t,dtlsParameters:i,candidates:n,rtpCapabilities:r,setup:o,localCapabilities:s,sdkCodec:a,cname:c}=e,d=yN("v=0\no=- 0 0 IN IP4 127.0.0.1\ns=AgoraGateway\nt=0 0\na=group:BUNDLE audio video\na=msid-semantic: WMS\na=ice-lite\nm=audio 9 UDP/TLS/RTP/SAVPF 0\nc=IN IP4 127.0.0.1\na=rtcp:9 IN IP4 0.0.0.0\na=sendrecv\na=rtcp-mux\na=rtcp-rsize\na=mid:audio\nm=video 9 UDP/TLS/RTP/SAVPF 0\nc=IN IP4 127.0.0.1\na=rtcp:9 IN IP4 0.0.0.0\na=sendrecv\na=rtcp-mux\na=rtcp-rsize\na=mid:video\n");this.rtpCapabilities=r,this.candidates=n,this._originCandidates=eO(n),this.iceParameters=t,this.dtlsParameters=i,this.setup=o,this.localCapabilities=s,this.cname=c;for(let e=0;e<d.mediaDescriptions.length;e++){const s=d.mediaDescriptions[e];if(s.attributes.iceUfrag=t.iceUfrag,s.attributes.icePwd=t.icePwd,s.attributes.fingerprints=i.fingerprints,s.attributes.candidates=n,s.attributes.setup=o,"video"===s.media.mediaType){s.media.fmts=r.videoCodecs.map((e=>e.payloadType.toString(10)));let e=r.videoCodecs.filter((e=>{var t,i;return null===(t=e.rtpMap)||void 0===t?void 0:Dn(i=t.encodingName.toLowerCase()).call(i,a)}));0===e.length&&(e=r.videoCodecs),s.attributes.payloads=e,s.attributes.extmaps=r.videoExtensions}"audio"===s.media.mediaType&&(s.media.fmts=r.audioCodecs.map((e=>e.payloadType.toString(10))),s.attributes.payloads=r.audioCodecs,s.attributes.extmaps=r.audioExtensions),d.mediaDescriptions[e]=this.mungMediaDesc(s)}this.sessionDesc=d,this.currentMidIndex=d.mediaDescriptions.length-1}toString(){return AN(this.sessionDesc)}send(e,t,i){const{ssrcs:n,ssrcGroups:r}=$x(t,this.cname),o=this.sessionDesc.mediaDescriptions.find((t=>e===HU.VIDEO?"video"===t.media.mediaType:"audio"===t.media.mediaType)),s=n[0].attributes.label,a=n[0].attributes.mslabel;return o.attributes.ssrcs=o.attributes.ssrcs.concat(n),o.attributes.ssrcGroups=o.attributes.ssrcGroups.concat(r),{id:s,mslabel:a}}batchSend(e){return e.map((e=>{let{kind:t,ssrcMsg:i}=e;return this.send(t,i,void 0)}))}stopSending(e){this.sessionDesc.mediaDescriptions.forEach((t=>{const i=[],n=[],r=[];t.attributes.ssrcs.forEach((t=>{Dn(e).call(e,t.attributes.label||"")?r.push(t):i.push(t)})),t.attributes.ssrcGroups.forEach((e=>{var t;Dn(t=r.map((e=>e.ssrcId))).call(t,e.ssrcIds[0])||n.push(e)})),t.attributes.ssrcs=i,t.attributes.ssrcGroups=n}))}mute(e){const t=this.sessionDesc.mediaDescriptions.find((t=>t.attributes.mid===e));if(!t)throw new Error("mediaDescription not found with ".concat(e," in remote SDP when calling RemoteSDP.mute."));t.attributes.direction="inactive"}unmute(e){const t=this.sessionDesc.mediaDescriptions.find((t=>t.attributes.mid===e));if(!t)throw new Error("mediaDescription not found with ".concat(e," in remote SDP when calling RemoteSDP.unmute."));t.attributes.direction="sendonly"}receive(e,t,i){e.forEach(((e,t)=>{const i=e._mediaStreamTrack,n=this.sessionDesc.mediaDescriptions.findIndex((e=>e.attributes.mid===i.kind)),r=this.mungRecvMediaDsec(this.sessionDesc.mediaDescriptions[n],e);this.sessionDesc.mediaDescriptions[n]=r}))}stopReceiving(e){}updateCandidates(e){const t=this._originCandidates.filter((e=>"udp"===e.transport)),i=[];if(t.forEach((e=>{i.push(tz(tz({},e),{},{foundation:"tcpcandidate",priority:Number(e.priority)-1+"",transport:"tcp",port:Number(e.port)+90+""}))})),0!==t.length){switch(e){case KU.TCP_RELAY:this.candidates=i;break;case KU.UDP_TCP_RELAY:case KU.RELAY:this.candidates=[...t,...i];break;default:this.candidates=t}for(const e of this.sessionDesc.mediaDescriptions)e.attributes.candidates=this.candidates}}restartICE(e){e=eO(e),this.iceParameters=e,this.sessionDesc.mediaDescriptions.forEach((t=>{t.attributes.iceUfrag=e.iceUfrag,t.attributes.icePwd=e.icePwd}))}predictReceivingMids(e){const t=[];for(let i=0;i<e;i++)t.push((this.currentMidIndex+i+1).toString(10));return t}mungRecvMediaDsec(e,t){const i=eO(e);return eV(i,t),iV(i,t),i}updateRecvMedia(e,t){const i=this.sessionDesc.mediaDescriptions.findIndex((t=>t.attributes.mid===e));if(-1!==i){const e=this.mungRecvMediaDsec(this.sessionDesc.mediaDescriptions[i],t);this.sessionDesc.mediaDescriptions[i]=e}}bumpMid(e){this.currentMidIndex+=e}updateTrackLabel(e,t,i){const n=this.sessionDesc.mediaDescriptions.find((t=>e===HU.VIDEO?"video"===t.attributes.mid:"audio"===t.attributes.mid));if(n){const e=n.attributes.ssrcs.find((e=>e.attributes.label===t));var r;if(e)e.attributes.label=i,null===(r=e.attributes.msid)||void 0===r||r.replace(t,i)}}mungMediaDesc(e){const t=eO(e);return tV(t),function(e){const t=e.attributes.extmaps.find((e=>Kx(e.extensionName)));t&&e.attributes.extmaps.splice(e.attributes.extmaps.indexOf(t),1),e.attributes.payloads.forEach((e=>{const t=e.rtcpFeedbacks.findIndex((e=>"transport-cc"===e.type));-1!==t&&e.rtcpFeedbacks.splice(t,1)}))}(t),t}getSSRC(e){for(const t of this.sessionDesc.mediaDescriptions)for(const i of t.attributes.ssrcs)if(i.attributes.label===e)return[i]}}var nz;function rz(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function oz(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?rz(Object(i),!0).forEach((function(t){QI(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):rz(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}let sz=(nz=class e extends WU{get peerConnectionState(){return this.peerConnection.connectionState}get iceConnectionState(){return this.peerConnection.iceConnectionState}get currentLocalDescription(){return this.peerConnection.currentLocalDescription}get currentRemoteDescription(){return this.peerConnection.currentRemoteDescription}get localCodecs(){return[...new Set(this.localCapabilities&&this.localCapabilities.videoCodecs.map((e=>e.rtpMap&&e.rtpMap.encodingName.toLowerCase()||"")).filter((e=>{var t;return Dn(t=Object.keys(TN)).call(t,e)})))]}constructor(t,i){super(t,i),QI(this,"store",void 0),QI(this,"peerConnection",void 0),QI(this,"remoteSDP",void 0),QI(this,"initialOffer",void 0),QI(this,"statsFilter",void 0),QI(this,"useRTX",!1),QI(this,"localCapabilities",void 0),QI(this,"localCandidateCount",0),QI(this,"allCandidatesReceived",!1),QI(this,"establishPromise",void 0),QI(this,"mutex",void 0),this.store=i,this.mutex=new IO("P2PConnection-mutex",i.clientId),this.peerConnection=new RTCPeerConnection(e.resolvePCConfiguration(t),{optional:[{googDscp:!0}]}),this.statsFilter=tN(this.peerConnection,_N("STATS_UPDATE_INTERVAL"),void 0,Kb()?1200:void 0),this.bindPCEvents(),this.bindStatsEvents(),this.store.p2pId=this.store.p2pId+1,this.establishPromise=this.establish()}async establish(){try{const e=await this.peerConnection.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});if(!e.sdp)throw new Error("Cannot get initialOffer.sdp when trying to establish PeerConnection.");const t=Xx(e.sdp),i=zx(e.sdp,{filterRTX:!this.useRTX,filterVideoFec:_N("FILTER_VIDEO_FEC"),filterAudioFec:_N("FILTER_AUDIO_FEC"),filterAudioCodec:["opus"]});return this.localCapabilities=i,this.initialOffer=e,oz(oz({},t),{},{rtpCapabilities:{send:{audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]},recv:{audioCodecs:[],audioExtensions:[],videoCodecs:[],videoExtensions:[]},sendrecv:i},offerSDP:e.sdp})}catch(e){throw new mw(Ew.GET_LOCAL_CONNECTION_PARAMS_FAILED,e.toString())}}async updateRemoteConnect(){}async connect(e){try{if(!this.initialOffer)throw new Error("Cannot establish P2PConnection without initial offer.");this.remoteSDP=new iz(oz(oz({},e),{},{rtpCapabilities:e.rtpCapabilities.send,localCapabilities:this.localCapabilities,sdkCodec:this.store.codec}));const t=this.remoteSDP.toString();await this.peerConnection.setLocalDescription(this.initialOffer),await this.peerConnection.setRemoteDescription({type:"answer",sdp:t})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.connect failed; ".concat(e.toString()))}}async updateRemoteRTPCapabilities(e,t){throw new mw(Ew.NOT_SUPPORTED,"Planb mode does not support createDataChannels.")}getPreMedia(e){}send(e,t){var i=this;return FA((function*(){const n=yield BA(i.mutex.lock());try{if(!i.remoteSDP)throw new Error("Cannot call P2PConnection.send before remote SDP created");const r=e.map((e=>i.peerConnection.addTrack(e._mediaStreamTrack))),o=yield BA(i.peerConnection.createOffer()),s=yN(o.sdp),a=e.map((e=>{const t=e._mediaStreamTrack,n=s.mediaDescriptions.find((e=>e.attributes.mid===t.kind));if(!n)throw new Error("Cannot extract ssrc from mediaDescription.");return function(e,t,i){const n=e.attributes.ssrcs.filter((e=>e.attributes.label===t)),r=e.attributes.ssrcGroups;if(0===n.length)throw new Error("Cannot extract ssrc from plan-b SDP.");if(r&&n.length>1){const e=r.find((e=>-1!==e.ssrcIds.indexOf(n[0].ssrcId)));return e?[{ssrcId:e.ssrcIds[0],rtx:i?e.ssrcIds[1]:void 0}]:[{ssrcId:n[0].ssrcId}]}return[{ssrcId:n[0].ssrcId}]}(n,t.id,i.useRTX)}));let c;try{c=yield a}catch(e){throw r.forEach((e=>{Wb()&&e.replaceTrack(null),i.peerConnection.removeTrack(e)})),e}const d=i.mungSendOfferSDP(o.sdp,e);i.remoteSDP.receive(e,t,c);const l=i.remoteSDP.toString();return yield BA(i.peerConnection.setLocalDescription({type:"offer",sdp:d})),yield BA(i.applySendEncodings(r,e)),yield BA(i.peerConnection.setRemoteDescription({type:"answer",sdp:l})),e.map(((e,t)=>{const i=e._mediaStreamTrack.id;return{localSSRC:a[t],id:i}}))}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.send failed; ".concat(e.toString()))}finally{n()}}))()}async stopSending(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.stopSending before remote SDP created");const t=this.peerConnection.getSenders().filter((t=>{var i;return-1!==e.indexOf((null===(i=t.track)||void 0===i?void 0:i.id)||"")}));if(t.length!==e.length)throw new Error("Transceivers' length doesn't match mids' length when trying to call P2PConnection.stopSending.");t.map((e=>{Wb()&&e.replaceTrack(null),this.peerConnection.removeTrack(e)}));const i=await this.peerConnection.createOffer();await this.peerConnection.setLocalDescription(i),this.remoteSDP.stopReceiving(e);const n=this.remoteSDP.toString();await this.peerConnection.setRemoteDescription({type:"answer",sdp:n})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.stopSending failed; ".concat(e.toString()))}}async receive(e,t,i,n){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.receive ".concat(e," before remoteSDP created."));const{id:i,mslabel:r}=this.remoteSDP.send(e,t,n),o=new Wh(((t,n)=>{const o=setTimeout((()=>{n(new Error("Cannot receive track, id: ".concat(i)))}),1e4),s=n=>{const a=xb();if(("Safari"===a.name&&11===Number(a.version)||Yb())&&n.track.id!==i&&n.streams[0].id===r){var c;const r=n.streams[0].getTracks()[0];return null===(c=this.remoteSDP)||void 0===c||c.updateTrackLabel(e,i,n.track.id),this.peerConnection.removeEventListener("track",s),clearTimeout(o),void t(r)}if(n.track.id===i)return this.peerConnection.removeEventListener("track",s),clearTimeout(o),void t(n.track)};this.peerConnection.addEventListener("track",s)})),s=this.remoteSDP.toString();await this.peerConnection.setRemoteDescription({type:"offer",sdp:s});const a=await this.peerConnection.createAnswer();await this.peerConnection.setLocalDescription(a);return{track:await o,id:i}}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.receive failed; ".concat(e.toString()))}}async stopReceiving(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.stopReceiving before remote SDP created.");this.remoteSDP.stopSending(e);const t=this.remoteSDP.toString();await this.peerConnection.setRemoteDescription({type:"offer",sdp:t});const i=await this.peerConnection.createAnswer();await this.peerConnection.setLocalDescription(i)}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection stopReceiving failed; ".concat(e.toString()))}}async muteRemote(e){}async unmuteRemote(e){}async muteLocal(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.muteLocal before remote SDP created.");const t=this.peerConnection.getSenders().filter((t=>{var i;return-1!==e.indexOf((null===(i=t.track)||void 0===i?void 0:i.id)||"")}));if(t.length!==e.length)throw new Error("sender' length doesn't match mids' length.");t.map((e=>{if(Wb()&&e.track)e.track.enabled=!1;else{const t=e.getParameters();t.encodings.forEach((e=>e.active=!1)),e.setParameters(t)}}))}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.muteLocal failed; ".concat(e.toString()))}}async unmuteLocal(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.unmuteLocal before remote SDP created.");const t=this.peerConnection.getSenders().filter((t=>{var i;return-1!==e.indexOf((null===(i=t.track)||void 0===i?void 0:i.id)||"")}));if(t.length!==e.length)throw new Error("Senders' length doesn't match mids' length.");t.map((async e=>{if(Wb()&&e.track)e.track.enabled=!0;else{const t=e.getParameters();t.encodings.forEach((e=>e.active=!0)),await e.setParameters(t)}}));const i=await this.peerConnection.createOffer();await this.peerConnection.setLocalDescription(i);const n=this.remoteSDP.toString();await this.peerConnection.setRemoteDescription({type:"answer",sdp:n})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.unmuteLocal failed; ".concat(e.toString()))}}restartICE(e){var t=this;return FA((function*(){const i=yield BA(t.mutex.lock("From P2PConnection.restartICE"));try{if(!t.remoteSDP)throw new Error("Cannot restartICE before remoteSDP created.");const n=nD().supportPCSetConfiguration;if(e===KU.RELAY&&!n)return;if(n){const i=t.peerConnection.getConfiguration(),n=e===KU.RELAY?"relay":"all";i.iceTransportPolicy!==n&&(YN.debug("[".concat(t.store.clientId,"] restartICE change iceTransportPolicy from [").concat(i.iceTransportPolicy,"] to [").concat(n,"]")),i.iceTransportPolicy=n,t.peerConnection.setConfiguration(i))}e!==KU.RELAY&&t.remoteSDP.updateCandidates(e);const r=yield BA(t.peerConnection.createOffer({iceRestart:!0}));if(!r.sdp)throw new Error("Cannot restartICE because restart offer SDP does not exist.");const o=Xx(r.sdp),{remoteIceParameters:s}=yield o.iceParameters;t.remoteSDP.restartICE(s);const a=t.remoteSDP.toString();yield BA(t.peerConnection.setLocalDescription(r)),yield BA(t.peerConnection.setRemoteDescription({type:"answer",sdp:a}))}catch(e){YN.warning("[".concat(t.store.clientId,"] restart ICE failed, abort operation"),e)}finally{i()}}))()}close(){var e;this.peerConnection.close(),null===(e=this.onConnectionStateChange)||void 0===e||e.call(this,"closed"),this.unbindPCEvents(),this.unbindStatsEvents(),this.removeAllListeners(),this.statsFilter.destroy()}getStats(){return this.statsFilter.getStats()}getRemoteVideoIsReady(e){return this.statsFilter.getVideoIsReady(e)}async updateEncoderConfig(e,t){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.updateEncoderConfig before remote SDP created.");const e=await this.peerConnection.createOffer(),i=this.mungSendOfferSDP(e.sdp,[t]);this.remoteSDP.updateRecvMedia(t._mediaStreamTrack.kind,t);const n=this.remoteSDP.toString();await this.peerConnection.setLocalDescription({type:"offer",sdp:i}),await this.peerConnection.setRemoteDescription({type:"answer",sdp:n})}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,e.toString())}}async updateSendParameters(e,t){const i=this.peerConnection.getSenders().filter((t=>{var i;return(null===(i=t.track)||void 0===i?void 0:i.id)===e}));1===i.length&&await this.applySendEncodings(i,[t])}setStatsRemoteVideoIsReady(e,t){this.statsFilter.setVideoIsReady2(e,t)}async replaceTrack(e,t){const i=this.peerConnection.getSenders().find((e=>{var i;return(null===(i=e.track)||void 0===i?void 0:i.id)===t}));i&&await i.replaceTrack(e._mediaStreamTrack)}createDataChannels(e,t){throw new mw(Ew.NOT_SUPPORTED,"Planb mode does not support createDataChannels.")}stopDataChannels(e){throw new mw(Ew.NOT_SUPPORTED,"Planb mode does not support stopDataChannels.")}bindPCEvents(){this.peerConnection.oniceconnectionstatechange=()=>{var e;null===(e=this.onICEConnectionStateChange)||void 0===e||e.call(this,this.peerConnection.iceConnectionState)},this.peerConnection.onconnectionstatechange=()=>{var e;null===(e=this.onConnectionStateChange)||void 0===e||e.call(this,this.peerConnection.connectionState)},this.peerConnection.onicecandidate=e=>{e.candidate?this.localCandidateCount+=1:(this.peerConnection.onicecandidate=null,this.allCandidatesReceived=!0,YN.debug("[".concat(this.store.clientId,"] [pc-").concat(this.store.p2pId,"] local candidate count"),this.localCandidateCount))},setTimeout((()=>{this.allCandidatesReceived||(this.allCandidatesReceived=!0,YN.debug("[".concat(this.store.clientId,"] [pc-").concat(this.store.p2pId,"] onicecandidate timeout, local candidate count"),this.localCandidateCount))}),_N("CANDIDATE_TIMEOUT"))}unbindPCEvents(){this.peerConnection.oniceconnectionstatechange=null,this.peerConnection.onconnectionstatechange=null,this.peerConnection.onsignalingstatechange=null,this.peerConnection.onicecandidateerror=null,this.peerConnection.onicecandidate=null,this.peerConnection.ontrack=null}static resolvePCConfiguration(t){const i={iceServers:[],sdpSemantics:"plan-b"};return t.iceServers?i.iceServers=t.iceServers:t.turnServer&&"off"!==t.turnServer.mode&&(Fw(t.turnServer.servers)?i.iceServers=t.turnServer.servers:(i.iceServers&&i.iceServers.push(...e.turnServerConfigToIceServers(t.turnServer.servers)),_N("USE_TURN_SERVER_OF_GATEWAY")&&i.iceServers&&t.turnServer.serversFromGateway&&i.iceServers.push(...e.turnServerConfigToIceServers(t.turnServer.serversFromGateway)),t.turnServer.servers.concat(t.turnServer.serversFromGateway||[]).forEach((e=>{e.forceturn&&(i.iceTransportPolicy="relay")})))),i}static turnServerConfigToIceServers(e){const t=[];return e.forEach((e=>{e.security?e.tcpport&&t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turns:".concat(e.turnServerURL,":").concat(e.tcpport,"?transport=tcp")}):(e.udpport&&t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turn:".concat(e.turnServerURL,":").concat(e.udpport,"?transport=udp")}),e.tcpport&&t.push({username:e.username,credential:e.password,credentialType:"password",urls:"turn:".concat(e.turnServerURL,":").concat(e.tcpport,"?transport=tcp")}))})),t}async updateRtpSenderEncodings(e,t){var i;if(!t){t=this.peerConnection.getSenders().find((t=>{var i;return(null===(i=t.track)||void 0===i?void 0:i.id)===e._mediaStreamTrack.id}))}if(!t)return YN.warn("[".concat(e.getTrackId(),"] no rtpSender found}"));if(!nD().supportSetRtpSenderParameters)return YN.warn("Browser not support set rtp-sender parameters");const n={},r={};if(e instanceof pk)switch(e._optimizationMode){case"motion":n.degradationPreference="maintain-framerate";break;case"detail":n.degradationPreference="maintain-resolution";break;default:n.degradationPreference="balanced"}if(_N("DSCP_TYPE")&&dw()){var o;const e=_N("DSCP_TYPE");Dn(o=["very-low","low","medium","high"]).call(o,e)&&(r.networkPriority=e)}const s=t.getParameters(),a=null===(i=s.encodings)||void 0===i?void 0:i[0];a&&Object.assign(a,r),Object.assign(s,n),YN.debug("[".concat(e.getTrackId(),"] updateRtpSenderEncodings: ").concat(JSON.stringify(s.encodings))),await t.setParameters(s)}async applySendEncodings(e,t){try{if(!nD().supportSetRtpSenderParameters)return;if(e.length!==t.length)return;for(let i=0;i<e.length;i++){const n=e[i],r=t[i];n&&r&&await this.updateRtpSenderEncodings(r,n)}}catch(e){YN.debug("[".concat(this.store.clientId,"] Apply RTPSendEncodings failed."))}}mungSendOfferSDP(e,t){const i=yN(e);return t.forEach(((e,t)=>{const n=e._mediaStreamTrack,r=i.mediaDescriptions.find((e=>e.attributes.mid===n.kind));r&&eV(r,e)})),AN(i)}bindStatsEvents(){this.statsFilter.onFirstAudioReceived=e=>{var t;null===(t=this.onFirstAudioReceived)||void 0===t||t.call(this,e)},this.statsFilter.onFirstVideoReceived=e=>{var t;null===(t=this.onFirstVideoReceived)||void 0===t||t.call(this,e)},this.statsFilter.onFirstAudioDecoded=e=>{var t;null===(t=this.onFirstAudioDecoded)||void 0===t||t.call(this,e)},this.statsFilter.onFirstVideoDecoded=(e,t,i)=>{var n;null===(n=this.onFirstVideoDecoded)||void 0===n||n.call(this,e,t,i)},this.statsFilter.onSelectedLocalCandidateChanged=(e,t)=>{var i;null===(i=this.onSelectedLocalCandidateChanged)||void 0===i||i.call(this,e,t)},this.statsFilter.onSelectedRemoteCandidateChanged=(e,t)=>{var i;null===(i=this.onSelectedRemoteCandidateChanged)||void 0===i||i.call(this,e,t)}}unbindStatsEvents(){this.statsFilter.onFirstAudioReceived=void 0,this.statsFilter.onFirstVideoReceived=void 0,this.statsFilter.onFirstAudioDecoded=void 0,this.statsFilter.onFirstVideoDecoded=void 0,this.statsFilter.onSelectedLocalCandidateChanged=void 0,this.statsFilter.onSelectedRemoteCandidateChanged=void 0}async batchReceive(e){try{if(!this.remoteSDP)throw new Error("Cannot call P2PConnection.batchReceive before remoteSDP created.");const t=this.remoteSDP.batchSend(e).map(((t,i)=>{let{id:n,mslabel:r}=t;const{kind:o}=e[i];return new Wh(((e,t)=>{const i=setTimeout((()=>{t(new Error("Cannot receive track, id: ".concat(n)))}),1e4),s=t=>{const a=xb();if("Safari"===a.name&&11===Number(a.version)&&t.track.id!==n&&t.streams[0].id===r){var c;const r=t.streams[0].getTracks()[0];return null===(c=this.remoteSDP)||void 0===c||c.updateTrackLabel(o,n,t.track.id),this.peerConnection.removeEventListener("track",s),clearTimeout(i),void e({track:r,id:n})}if(t.track.id===n)return this.peerConnection.removeEventListener("track",s),clearTimeout(i),void e({track:t.track,id:n})};this.peerConnection.addEventListener("track",s)}))})),i=this.remoteSDP.toString();await this.peerConnection.setRemoteDescription({type:"offer",sdp:i});const n=await this.peerConnection.createAnswer();return await this.peerConnection.setLocalDescription(n),await Wh.all(t)}catch(e){throw new mw(Ew.EXCHANGE_SDP_FAILED,"P2PConnection.receive failed; ".concat(e.toString()))}}async getRemoteSSRC(e){if(!this.remoteSDP)return;const t=this.remoteSDP.getSSRC(e);return null==t?void 0:t[0].ssrcId}setConfiguration(t){if(nD().supportPCSetConfiguration){const i=e.resolvePCConfiguration(t);this.peerConnection.setConfiguration(i)}}},rU(nz.prototype,"connect",[az],Object.getOwnPropertyDescriptor(nz.prototype,"connect"),nz.prototype),rU(nz.prototype,"stopSending",[az],Object.getOwnPropertyDescriptor(nz.prototype,"stopSending"),nz.prototype),rU(nz.prototype,"receive",[az],Object.getOwnPropertyDescriptor(nz.prototype,"receive"),nz.prototype),rU(nz.prototype,"stopReceiving",[az],Object.getOwnPropertyDescriptor(nz.prototype,"stopReceiving"),nz.prototype),rU(nz.prototype,"muteRemote",[az],Object.getOwnPropertyDescriptor(nz.prototype,"muteRemote"),nz.prototype),rU(nz.prototype,"unmuteRemote",[az],Object.getOwnPropertyDescriptor(nz.prototype,"unmuteRemote"),nz.prototype),rU(nz.prototype,"muteLocal",[az],Object.getOwnPropertyDescriptor(nz.prototype,"muteLocal"),nz.prototype),rU(nz.prototype,"unmuteLocal",[az],Object.getOwnPropertyDescriptor(nz.prototype,"unmuteLocal"),nz.prototype),rU(nz.prototype,"close",[az],Object.getOwnPropertyDescriptor(nz.prototype,"close"),nz.prototype),rU(nz.prototype,"updateEncoderConfig",[az],Object.getOwnPropertyDescriptor(nz.prototype,"updateEncoderConfig"),nz.prototype),rU(nz.prototype,"updateSendParameters",[az],Object.getOwnPropertyDescriptor(nz.prototype,"updateSendParameters"),nz.prototype),rU(nz.prototype,"replaceTrack",[az],Object.getOwnPropertyDescriptor(nz.prototype,"replaceTrack"),nz.prototype),rU(nz.prototype,"getRemoteSSRC",[az],Object.getOwnPropertyDescriptor(nz.prototype,"getRemoteSSRC"),nz.prototype),nz);function az(e,t,i){const n=e[t];if("function"!=typeof n)throw new Error("Cannot use mutex on object property.");return i.value=async function(){const e=this.mutex,i=await e.lock("Locking from P2PConnection.".concat(t));try{for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return await n.apply(this,o)}finally{i()}},i}const cz={name:"PlanBConnection",create:function(e){let{store:t,spec:i}=e;return new sz(i,t)}},dz={interceptLocalAudioFrame:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nD().supportWebRTCEncodedTransform)return void YN.warning("browser not support audio encoded transform");if(Wk.has(e))return;if(!e.track)return;const i={track:e.track};if(Gb()){if(!e.createEncodedStreams)return void YN.warning("browser not support createEncodedStreams() API");let r=null;try{r=e.createEncodedStreams()}catch(e){return void YN.error("create audio-encoded-streams error",e&&e.message)}const o=new TransformStream({transform(r,o){i.controller||(i.controller=o),e.track&&e.track.id!==i.track.id&&(YN.debug("audio track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",n),i.track=e.track,i.track.addEventListener("ended",n));const s=t.metadata&&t.metadata();s?function(e,t){const{chunk:i,controller:n}=t,r=_N("ENABLE_AUDIO_PTS_METADATA")?jk.AUDIO_64_BIT_PTS:jk.METADATA;i.data=function(e,t,i){const n=i.byteLength,r=n+Fk+Bk,o=xk+Vk+r,s=new ArrayBuffer(e.byteLength+o),a=new DataView(s);a.setUint8(0,Uk),a.setUint16(1,r),a.setUint8(3,t),a.setUint16(4,n);for(let e=0;e<n;e++)a.setUint8(6+e,i[e]);const c=new Uint8Array(a.buffer);return c.set(new Uint8Array(e),o),c.buffer}(i.data,r,e),n.enqueue(i)}(s,{sender:e,chunk:r,controller:o}):o.enqueue(r)}});r.readable.pipeThrough(o).pipeTo(r.writable)}else if(Wb()){if("undefined"==typeof RTCRtpScriptTransform)return void YN.warning("browser not support RTCRtpScriptTransform");const r=Mk(),o=new MessageChannel;await new Wh((e=>r.onmessage=t=>{"registered"===t.data&&e(void 0)}));const s=new RTCRtpScriptTransform(r,{name:"audio-metadata-tx",port:o.port2},[o.port2]);e.transform=s,await new Wh((e=>r.onmessage=t=>{"started"===t.data&&e(void 0)})),o.port1.onmessage=r=>{var s;if(r.data.transformed&&e.track&&(null===(s=e.track)||void 0===s?void 0:s.id)!==i.track.id)YN.debug("audio track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",n),i.track=e.track,i.track.addEventListener("ended",n);else if(r.data.getMetadata){const e=t.metadata&&t.metadata();e&&o.port1.postMessage({metadata:e})}},i.worker=r}function n(){if(e.track){if(this.id!==e.track.id)return;e.track.removeEventListener("ended",n)}const t=Wk.get(e);if(t){Wk.delete(e);try{var i,r;null===(i=t.controller)||void 0===i||i.terminate(),null===(r=t.worker)||void 0===r||r.terminate()}catch(e){YN.warning(e&&e.message)}}}Wk.set(e,i),e.track.addEventListener("ended",n)},interceptRemoteAudioFrame:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nD().supportWebRTCEncodedTransform)return void YN.warning("browser not support audio encoded transform");if(uM.has(e))return;const i={track:e.track,onMetadata:t.onMetadata};if(Gb()){if(!e.createEncodedStreams)return void YN.warning("browser not support createEncodedStreams() API");Xb(Lb.CHROME,87,116)||(t.enableTopn=!1);let r=null;try{r=e.createEncodedStreams()}catch(e){return void YN.error("create audio-encoded-streams error",e&&e.message)}const o=new TransformStream({transform(r,o){i.controller||(i.controller=o),e.track&&e.track.id!==i.track.id&&(YN.debug("audio track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",n),i.track=e.track,i.track.addEventListener("ended",n)),t.enableTopn?function(e,t,i){var n;const r=Gk(new DataView(t.data));if(!r)return i.enqueue(t);const o=e.track.id;hM.set(o,e.track);const s=null===(n=r.tlv.find((e=>e.tag===jk.AUDIO_LEVEL)))||void 0===n?void 0:n.value;let a=0;"number"==typeof s&&(a=127-s);const c=Math.round(Math.pow(10,a/60)-1),{selected:d,speaker:l}=function(e,t){let i=tM.get(e);if(i||(i=function(e){const t=new Qk;return tM.set(e,t),iM||(iM=new eM(_N("TOPN_SILENCE_THRESHOLD")||500),iM.on("ActiveSpeakerChanged",(e=>{null!=e&&(nM=e)}))),iM.addSpeakers([t]),t}(e)),tM.size<=rM)return{selected:!0,speaker:i};if(!iM)throw new Error("no active speaker detector");return iM.levelChanged(i.id,t),oM=iM.loudest.map((e=>e.id)),nM&&!Dn(oM).call(oM,nM)&&oM.length>=rM&&oM.pop(),{selected:Dn(oM).call(oM,i.id)||i.id===nM,speaker:i}}(e,c),u=function(e,t,i){const n=sM.get(e)||new cM(e,t);return n.score=i,sM.set(e,n),function(e){if(aM.set(e,!0),!dM)return void(dM=Date.now());const t=Date.now();t-dM>1e3&&(aM.get(e)?aM.set(e,!1):(lM(e),aM.delete(e)),dM=t)}(e),n}(o,e.track,l.energyScore);u.addSample(d),u.active&&(t.data=r.frame.buffer,i.enqueue(t))}(e,r,o):t.enableMetadata?function(e,t,i){const n=Gk(new DataView(e.data));if(!n)return t.enqueue(e);const r=n.tlv.find((e=>e.tag===jk.METADATA||e.tag===jk.AUDIO_64_BIT_PTS));r&&i&&r.value instanceof Uint8Array&&i(r.value),e.data=n.frame.buffer,t.enqueue(e)}(r,o,t.onMetadata):o.enqueue(r)}});r.readable.pipeThrough(o).pipeTo(r.writable)}else if(Wb()){if("undefined"==typeof RTCRtpScriptTransform)return void YN.warning("browser not support RTCRtpScriptTransform");const t=Mk(),r=new MessageChannel;await new Wh((e=>t.onmessage=t=>{"registered"===t.data&&e(void 0)}));const o=new RTCRtpScriptTransform(t,{name:"audio-metadata-rx",port:r.port2},[r.port2]);e.transform=o,await new Wh((e=>t.onmessage=t=>{"started"===t.data&&e(void 0)})),r.port1.onmessage=t=>{var r;t.data.transformed&&e.track&&(null===(r=e.track)||void 0===r?void 0:r.id)!==i.track.id?(YN.debug("audio track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",n),i.track=e.track,i.track.addEventListener("ended",n)):t.data.metadata&&i.onMetadata&&i.onMetadata(t.data.metadata)},i.worker=t}function n(){e.track.removeEventListener("ended",n),function(e){const t=uM.get(e);if(t){!function(e){const t=tM.get(e);t&&(tM.delete(e),iM&&(iM.removeSpeakers([t]),0===tM.size&&(iM.destroy(),iM=null)))}(e),lM(e.track.id),uM.delete(e);try{var i,n;null===(i=t.controller)||void 0===i||i.terminate(),null===(n=t.worker)||void 0===n||n.terminate()}catch(e){YN.warning(e&&e.message)}}}(e)}uM.set(e,i),e.track.addEventListener("ended",n)},interceptLocalVideoFrame:async function(e,t){if(!nD().supportWebRTCEncodedTransform)return void YN.warning("browser not support video encoded transform");if(_M.has(e))return;if(!e.track)return;const i={track:e.track};if(Gb()){if(!e.createEncodedStreams)return void YN.warning("browser not support createEncodedStreams() API");let r=null;try{r=e.createEncodedStreams()}catch(e){return void YN.error("create video-encoded-streams error",e&&e.message)}const o=[];t.on("sei-to-send",(e=>{o.push(e)}));const s=new TransformStream({transform(t,r){i.controller||(i.controller=r),e.track&&e.track.id!==i.track.id&&(YN.debug("video track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",n),i.track=e.track,i.track.addEventListener("ended",n));const s=o.shift();s&&(t.data=function(e,t){const i=function(e){const t=e.length;let i=[],n=0;for(;n<t;)n+2<t&&0===e[n]&&0===e[n+1]&&(0===e[n+2]||1===e[n+2]||2===e[n+2]||3===e[n+2])?(i.push(e[n],e[n+1],3,e[n+2]),n+=3):(i.push(e[n]),n++);return new Uint8Array(i)}(t),n=i.length,r=Math.floor(n/255),o=n%255,s=new Uint8Array(6+r+1+n+e.byteLength);s[0]=0,s[1]=0,s[2]=0,s[3]=1,s[4]=6,s[5]=101;let a=0;for(;a<r;)s[6+a]=255,a++;return s[6+a]=o,a++,s.set(i,6+a),s.set(new Uint8Array(e),6+a+n),s.buffer}(t.data,s)),r.enqueue(t)}});r.readable.pipeThrough(s).pipeTo(r.writable)}else{if(!Wb())return;{if("undefined"==typeof RTCRtpScriptTransform)return void YN.warning("browser not support RTCRtpScriptTransform");const r=Mk(),o=new MessageChannel;await new Wh((e=>r.onmessage=t=>{"registered"===t.data&&e(void 0)}));const s=new RTCRtpScriptTransform(r,{name:"sei-tx",port:o.port2},[o.port2]);e.transform=s,await new Wh((e=>r.onmessage=t=>{"started"===t.data&&e(void 0)})),t.on("sei-to-send",(e=>{o.port1.postMessage({sei:e})})),o.port1.onmessage=t=>{var r;t.data.transformed&&e.track&&(null===(r=e.track)||void 0===r?void 0:r.id)!==i.track.id&&(YN.debug("video track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",n),i.track=e.track,i.track.addEventListener("ended",n))},i.worker=r}}function n(){if(e.track){if(this.id!==e.track.id)return;e.track.removeEventListener("ended",n)}const t=_M.get(e);if(t){_M.delete(e);try{var i,r;null===(i=t.controller)||void 0===i||i.terminate(),null===(r=t.worker)||void 0===r||r.terminate()}catch(e){YN.warning(e&&e.message)}}}_M.set(e,i),e.track.addEventListener("ended",n)},interceptRemoteVideoFrame:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nD().supportWebRTCEncodedTransform)return void YN.warning("browser not support video encoded transform");if(!e.track)return;if(EM.has(e)){const i=EM.get(e);return void(i&&(i.onSei=t.onSei))}const i={track:e.track,onSei:t.onSei};if(Gb()){if(!e.createEncodedStreams)return void YN.warning("browser not support createEncodedStreams() API");let t=null;try{t=e.createEncodedStreams()}catch(e){return void YN.error("create video-encoded-streams error",e&&e.message)}const r=new TransformStream({transform(t,r){i.controller||(i.controller=r),e.track&&e.track.id!==i.track.id&&(YN.debug("video track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",n),i.track=e.track,i.track.addEventListener("ended",n));const o=function(e){const t=new DataView(e.data);let i=0;for(;i+4<e.data.byteLength;){if(0===t.getUint8(i+0)&&0===t.getUint8(i+1)&&0===t.getUint8(i+2)&&1===t.getUint8(i+3)&&6===t.getUint8(i+4)){let n=i+6,r=0,o=0;for(;255===(o=t.getUint8(n++));)r+=255;r+=o;const s=pM(e.data,n,r);return new Uint8Array(s)}i++}return null}(t);o&&i.onSei&&i.onSei(o),r.enqueue(t)}});t.readable.pipeThrough(r).pipeTo(t.writable)}else if(Wb()){if("undefined"==typeof RTCRtpScriptTransform)return void YN.warning("browser not support RTCRtpScriptTransform");const t=Mk(),r=new MessageChannel;await new Wh((e=>t.onmessage=t=>{"registered"===t.data&&e(void 0)}));const o=new RTCRtpScriptTransform(t,{name:"sei-rx",port:r.port2},[r.port2]);e.transform=o,await new Wh((e=>t.onmessage=t=>{"started"===t.data&&e(void 0)})),r.port1.onmessage=t=>{var r;t.data.transformed&&e.track&&(null===(r=e.track)||void 0===r?void 0:r.id)!==i.track.id?(YN.debug("video track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",n),i.track=e.track,i.track.addEventListener("ended",n)):t.data.sei&&i.onSei&&i.onSei(t.data.sei)},i.worker=t}function n(){if(e.track){if(this.id!==e.track.id)return;e.track.removeEventListener("ended",n)}!function(e){const t=EM.get(e);if(t){EM.delete(e);try{var i,n;null===(i=t.controller)||void 0===i||i.terminate(),null===(n=t.worker)||void 0===n||n.terminate()}catch(e){YN.warning(e&&e.message)}}}(e)}EM.set(e,i),e.track.addEventListener("ended",n)}},lz={name:"InterceptFrame",create:()=>dz};nN(),pN("PROCESS_ID","process-".concat(hO(8,""),"-").concat(hO(4,""),"-").concat(hO(4,""),"-").concat(hO(4,""),"-").concat(hO(12,""))),function(){let e;try{e=window.localStorage.getItem("websdk_ng_global_parameter")}catch(e){return void YN.error("Error loading sdk config",e.message)}if(e)try{const t=JSON.parse(window.atob(e)),i=Date.now();YN.debug("Loading global parameters from cache",t),Object.keys(t).forEach((e=>{if(Object.prototype.hasOwnProperty.call(hN,e)){const{value:n,expires:r}=t[e];if(r&&r<=i)return;mN[e]=n,hN[e]=n}}))}catch(t){YN.error("Error loading mutableParamsCache: ".concat(e),t.message)}}(),Array.isArray(mN.AREAS)&&mN.AREAS.length>0&&jV(mN.AREAS,!0);const uz=(e,t,i)=>{YN.debug("setParameter key:".concat(e,", value:").concat(JSON.stringify(t))),pN(e,t,i)};vV(OY,!1),vV(UY,!1),vV(Yj,!1),vV(pq,!1),vV(AY,!1),vV($q,!1),vV(cz,!1),vV(lz,!1);const hz=function(e){const t=new Dw,i=e,n={getListeners:t.getListeners.bind(t),on:(e,i)=>(function(e,t){e===tx.SECURITY_POLICY_VIOLATION&&YG(t,!0)}(e,i),t.on.bind(t)(e,i)),addListener:t.addListener.bind(t),once:t.once.bind(t),off:t.off.bind(t),removeAllListeners:t.removeAllListeners.bind(t),emit:t.emit.bind(t),safeEmit:t.safeEmit.bind(t)};return HG(HG({},i),n)}({__TRACK_LIST__:SD,VERSION:rN,BUILD:lN,ESM_BUNDLER:!1,ESM:!1,UMD:!0,DEV:!1,setParameter:uz,getParameter:_N,getSupportedCodec:async function(){let e={audio:[],video:[]};try{let t=new RTCPeerConnection;const i=await async function(e){let t;return nD().supportUnifiedPlan?(e.addTransceiver("video",{direction:"recvonly"}),e.addTransceiver("audio",{direction:"recvonly"}),t=(await e.createOffer()).sdp):t=(await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})).sdp,t}(t);if(!i)return e;t.close(),t=null,e=function(e){const t={video:[],audio:[]};return e.match(/ VP8/i)&&t.video.push("VP8"),e.match(/ VP9/i)&&t.video.push("VP9"),e.match(/ AV1/i)&&t.video.push("AV1"),e.match(/ H264/i)&&t.video.push("H264"),e.match(/ H265/i)&&t.video.push("H265"),e.match(/ opus/i)&&t.audio.push("OPUS"),e.match(/ PCMU/i)&&t.audio.push("PCMU"),e.match(/ PCMA/i)&&t.audio.push("PCMA"),e.match(/ G722/i)&&t.audio.push("G722"),t}(i)}catch(e){throw new tD(Ew.CREATE_OFFER_FAILED,e.toString&&e.toString()).print()}return e},checkSystemRequirements:function(){const e=eD.reportApiInvoke(null,{name:kw.CHECK_SYSTEM_REQUIREMENTS,options:[],tag:Mw.TRACER});let t=!1;try{const e=window.RTCPeerConnection,i=navigator.mediaDevices&&navigator.mediaDevices.getUserMedia,n=window.WebSocket;t=!!(e&&i&&n),t&&cw()&&zb(75)&&(new e).close()}catch(e){return YN.error("check system requirement failed: ",e),!1}let i=!1;const n=xb();n.name===Lb.CHROME&&Number(n.version)>=58&&("WebKit"!==Mb.engine.name||function(){const e=xb();if(jb()){if(e.os===Pb.MAC_OS)return!0;if(e.os===Pb.IOS){const e=Mb.os.version&&Mb.os.version.split(".");if(e&&14===Number(e[0])&&e[1]&&Number(e[1])>=3)return!0;if(e&&Number(e[0])>14)return!0}}return!1}())&&(i=!0),(n.name===Lb.FIREFOX&&Number(n.version)>=56||n.name===Lb.OPERA&&Number(n.version)>=45||n.name===Lb.SAFARI&&Number(n.version)>=11||"WebKit"===n.name&&(Yb()||ow())&&n.osVersion&&Number(n.osVersion.split(".")[0])>=11||sw()||xb().name===Lb.QQ)&&(i=!0),YN.debug("checkSystemRequirements, api:",t,"browser",i);const r=t&&i;return e.onSuccess(r),r},getDevices:function(e){return mP.enumerateDevices(!0,!0,e)},getMicrophones:function(e){return mP.getRecordingDevices(e)},getCameras:function(e){return mP.getCamerasDevices(e)},getElectronScreenSources:cP,getPlaybackDevices:function(e){return mP.getSpeakers(e)},createClient:function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{codec:"vp8",audioCodec:"opus",mode:"rtc"};const i=hO(5,"client-"),n=eD.reportApiInvoke(null,{id:i,name:kw.CREATE_CLIENT,options:[t],tag:Mw.TRACER});try{!function(e){Tw(e.codec,"config.codec",["vp8","vp9","av1","h264","h265"]),Tw(e.mode,"config.mode",["rtc","live","p2p"]),void 0!==e.audioCodec&&Tw(e.audioCodec,"config.audioCodec",["opus","pcmu","pcma","g722"]),void 0!==e.proxyServer&&Rw(e.proxyServer,"config.proxyServer",1,1e4),void 0!==e.turnServer&&Bw(e.turnServer),void 0!==e.httpRetryConfig&&Uw(e.httpRetryConfig),void 0!==e.websocketRetryConfig&&Uw(e.websocketRetryConfig)}(t)}catch(e){throw n.onError(e),e}return(Zb(16,0,!0)||$b(16,0,!0))&&("vp9"===t.codec&&(t.codec="vp8",YN.debug("browser not support vp9, force use vp8")),pN("UNSUPPORTED_VIDEO_CODEC",["vp9"])),void 0===t.audioCodec&&(t.audioCodec="opus"),n.onSuccess(),new xG(UG(UG({forceWaitGatewayResponse:!0},t),{},{role:Dn(e=["rtc","p2p"]).call(e,t.mode)?"host":t.role||"audience"}),i)},createCameraVideoTrack:async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=_N("CAMERA_CAPTURE_CONFIG"),i=hO(8,"track-cam-"),n=eD.reportApiInvoke(null,{id:i,tag:Mw.TRACER,name:kw.CREATE_CAM_VIDEO_TRACK,options:[KD({},e),t]});t&&(e.encoderConfig=t);const r=DP(e);let o=null;YN.info("start create camera video track with config",JSON.stringify(e),"trackId",i);try{o=(await hP({video:r},i)).getVideoTracks()[0]||null}catch(e){throw n.onError(e),e}if(!o){const e=new mw(Ew.UNEXPECTED_ERROR,"can not find track in media stream");return n.onError(e),e.throw(YN)}e.optimizationMode&&Ek(i,o,e,_D(e.encoderConfig));const s=new _k(o,e,r,e.scalabiltyMode?mD(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,i);return n.onSuccess(s.getTrackId()),YN.info("create camera video success, trackId:",i),s},createCustomVideoTrack:function(e){const t=hO(8,"track-cus-"),i=eD.reportApiInvoke(null,{id:t,tag:Mw.TRACER,name:kw.CREATE_CUSTOM_VIDEO_TRACK,options:[e]}),n=new pk(e.mediaStreamTrack,{width:e.width,height:e.height,frameRate:e.frameRate,bitrateMax:e.bitrateMax,bitrateMin:e.bitrateMin},e.scalabiltyMode?mD(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,t,[vD.CUSTOM_TRACK]);return i.onSuccess(n.getTrackId()),YN.info("create custom video track success with config",e,"trackId",n.getTrackId()),n},createScreenVideoTrack:async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"disable";const i="object"==typeof t?function(e){return PP(e)}(t):void 0;i&&(t="auto");const n=hO(8,"track-scr-v-"),r=eD.reportApiInvoke(null,{id:n,tag:Mw.TRACER,name:kw.CREATE_SCREEN_VIDEO_TRACK,options:[KD({},e),t]});e.encoderConfig?"string"==typeof e.encoderConfig||e.encoderConfig.width&&e.encoderConfig.height||(e.encoderConfig.width={max:1920},e.encoderConfig.height={max:1080}):e.encoderConfig="1080p_2";const o=function(e){const t={};e.screenSourceType&&(t.mediaSource=e.screenSourceType),e.extensionId&&Gb()&&(t.extensionId=e.extensionId);const{displaySurface:i,selfBrowserSurface:n,surfaceSwitching:r,systemAudio:o,preferCurrentTab:s}=e;(qb(107)||Jb(107)||ew(93))&&(i&&(Tw(i,"displaySurface",["browser","window","monitor"]),t.displaySurface=i),n?(Tw(n,"selfBrowserSurface",["exclude","include"]),t.selfBrowserSurface=n):t.selfBrowserSurface="include",r&&(Tw(r,"surfaceSwitching",["exclude","include"]),t.surfaceSwitching=r)),(qb(105)||Jb(105)||ew(91))&&o&&(Tw(o,"systemAudio",["exclude","include"]),t.systemAudio=o),(qb(94)||Jb(94)||ew(80))&&s&&(t.preferCurrentTab=!0),e.electronScreenSourceId&&(t.sourceId=e.electronScreenSourceId);const a=e.encoderConfig?ED(e.encoderConfig):null;return t.mandatory={chromeMediaSource:"desktop",maxWidth:a?a.width:void 0,maxHeight:a?a.height:void 0},a&&(a.frameRate&&("number"==typeof a.frameRate?(t.mandatory.maxFrameRate=a.frameRate,t.mandatory.minFrameRate=a.frameRate):(t.mandatory.maxFrameRate=a.frameRate.max||a.frameRate.ideal||a.frameRate.exact||void 0,t.mandatory.minFrameRate=a.frameRate.min||a.frameRate.ideal||a.frameRate.exact||void 0),t.frameRate=a.frameRate),a.width&&(t.width=a.width),a.height&&(t.height=a.height)),t}(e);let s=null,a=null;const c=nD();if(!c.supportShareAudio&&"enable"===t){const e=new mw(Ew.NOT_SUPPORTED,"your browser or platform is not support share-screen with audio");return r.onError(e),e.throw(YN)}YN.info("start create screen video track with config",e,"withAudio",t,"trackId",n);const d=c.supportShareAudio&&"disable"!==t;try{const e=await hP({screen:o,screenAudio:d?i||!0:void 0},n);s=e.getVideoTracks()[0]||null,a=e.getAudioTracks()[0]||null}catch(e){throw r.onError(e),e}if(!s){const e=new mw(Ew.UNEXPECTED_ERROR,"can not find track in media stream");return r.onError(e),e.throw(YN)}if(!a&&"enable"===t){s&&s.stop();const e=new mw(Ew.SHARE_AUDIO_NOT_ALLOWED);return r.onError(e),e.throw(YN)}e.optimizationMode||(e.optimizationMode="detail"),e.optimizationMode&&(Ek(n,s,e,e.encoderConfig&&ED(e.encoderConfig)||void 0),e.encoderConfig&&"string"!=typeof e.encoderConfig&&(e.encoderConfig.bitrateMin=e.encoderConfig.bitrateMax));const l=new pk(s,e.encoderConfig?ED(e.encoderConfig):{},e.scalabiltyMode?mD(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,n,[vD.SCREEN_TRACK]);if(!a)return r.onSuccess(l.getTrackId()),YN.info("create screen video track success","video:",l.getTrackId()),l;const u=new IL(a,void 0,hO(8,"track-scr-a-"),!1);return r.onSuccess([l.getTrackId(),u.getTrackId()]),YN.info("create screen video track success","video:",l.getTrackId(),"audio:",u.getTrackId()),[l,u]},createMicrophoneAndCameraTracks:async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=_N("CAMERA_CAPTURE_CONFIG"),n=hO(8,"track-mic-"),r=hO(8,"track-cam-"),o=eD.reportApiInvoke(null,{id:"".concat(n,"-").concat(r),tag:Mw.TRACER,name:kw.CREATE_MIC_AND_CAM_TRACKS,options:[e,t,i]});i&&(t.encoderConfig=i);const s=DP(t),a=LP(e);let c=null,d=null;YN.info("start create camera video track(".concat(r,") and microphone audio track(").concat(n,") with config, audio: ").concat(JSON.stringify(e),", video: ").concat(JSON.stringify(t)));try{const e=await hP({audio:a,video:s},"".concat(n,"-").concat(r));c=e.getAudioTracks()[0],d=e.getVideoTracks()[0]}catch(e){throw o.onError(e),e}if(!c||!d){const e=new mw(Ew.UNEXPECTED_ERROR,"can not find tracks in media stream");return o.onError(e),e.throw(YN)}t.optimizationMode&&Ek(r,d,t,_D(t.encoderConfig));const l=new yL(c,e,a,n),u=new _k(d,t,s,t.scalabiltyMode?mD(t.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},t.optimizationMode,r);return o.onSuccess([l.getTrackId(),u.getTrackId()]),YN.info("create camera video track(".concat(r,") and microphone audio track(").concat(n,") success")),[l,u]},createMicrophoneAudioTrack:async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=hO(8,"track-mic-"),i=eD.reportApiInvoke(null,{id:t,tag:Mw.TRACER,name:kw.CREATE_MIC_AUDIO_TRACK,options:[e]}),n=LP(e);let r=null;YN.info("start create microphone audio track with config",JSON.stringify(e),"trackId",t);try{r=(await hP({audio:n},t)).getAudioTracks()[0]||null}catch(e){throw i.onError(e),e}if(!r){const e=new mw(Ew.UNEXPECTED_ERROR,"can not find track in media stream");return i.onError(e),e.throw(YN)}const o=new yL(r,e,n,t);return i.onSuccess(o.getTrackId()),YN.info("create microphone audio track success, trackId:",t),o},createCustomAudioTrack:function(e){const t=hO(8,"track-cus-"),i=eD.reportApiInvoke(null,{id:t,tag:Mw.TRACER,name:kw.CREATE_CUSTOM_AUDIO_TRACK,options:[e]}),n=new IL(e.mediaStreamTrack,e.encoderConfig?TD(e.encoderConfig):{},t,!1);return YN.info("create custom audio track success with config",e,"trackId",n.getTrackId()),i.onSuccess(n.getTrackId()),n},createBufferSourceAudioTrack:async function(e){var t;const{cacheOnlineFile:i,encoderConfig:n}=e;let{source:r}=e;const o={source:r instanceof AudioBuffer?"AudioBuffer":r instanceof File?null!==(t=File.name)&&void 0!==t?t:"File":r,cacheOnlineFile:i,encoderConfig:n},s=hO(8,"track-buf-"),a=eD.reportApiInvoke(null,{id:s,tag:Mw.TRACER,name:kw.CREATE_BUFFER_AUDIO_TRACK,options:[o]});if(_N("DISABLE_WEBAUDIO"))throw new mw(Ew.NOT_SUPPORTED,"can not create BufferSourceAudioTrack when WebAudio disabled");YN.info("start create buffer source audio track with config",JSON.stringify(o),"trackId",s);const c=r;if(!(r instanceof AudioBuffer))try{r=await async function(e,t){let i=null;if("string"==typeof e){const t=OL.get(e);if(t)return YN.debug("use cached audio resource: ",e),t;try{i=(await wO((()=>Ab.get(e,{responseType:"arraybuffer"})),void 0,void 0,{maxRetryCount:3})).data}catch(e){throw new mw(Ew.FETCH_AUDIO_FILE_FAILED,e.toString())}}else{const t=new Wh(((t,i)=>{const n=new FileReader;n.onload=e=>{e.target?t(e.target.result):i(new mw(Ew.READ_LOCAL_AUDIO_FILE_ERROR))},n.onerror=()=>{i(new mw(Ew.READ_LOCAL_AUDIO_FILE_ERROR))},n.readAsArrayBuffer(e)}));i=await t}const n=await function(e){const t=$D();return new Wh(((i,n)=>{t.decodeAudioData(e,(e=>{i(e)}),(e=>{n(new mw(Ew.DECODE_AUDIO_FILE_FAILED,e.toString()))}))}))}(i);return"string"==typeof e&&t&&OL.set(e,n),n}(r,i)}catch(e){return a.onError(e),e.throw(YN)}const d=new wL(r),l=new AL(c,d,n?TD(n):{},s);return YN.info("create buffer source audio track success, trackId:",s),a.onSuccess(l.getTrackId()),l},setAppType:function(e){if(YN.debug("setAppType: ".concat(e)),!(Number.isInteger(e)&&e>=0))throw YN.debug("Invalid appType"),new tD(Ew.INVALID_PARAMS,"invalid app type",e);pN("APP_TYPE",Math.floor(e))},setLogLevel:function(e){YN.setLogLevel(e)},enableLogUpload:function(){_N("USE_NEW_LOG")?pN("UPLOAD_LOG",!0):YN.enableLogUpload()},disableLogUpload:function(){_N("USE_NEW_LOG")?pN("UPLOAD_LOG",!1):YN.disableLogUpload()},createChannelMediaRelayConfiguration:function(){return new vF},checkAudioTrackIsActive:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3;const i=eD.reportApiInvoke(null,{tag:Mw.TRACER,name:kw.CHECK_AUDIO_TRACK_IS_ACTIVE,options:[t]});if(!(e instanceof IL||e instanceof Nk)){const e=new tD(Ew.INVALID_TRACK,"the parameter is not a audio track");return i.onError(e),e.throw()}t&&t<1e3&&(t=1e3);const n=e instanceof IL?e.getTrackLabel():"remote_track",r=e.getVolumeLevel();let o=r,s=r;const a=Date.now();return new Wh((r=>{const c=setInterval((()=>{const d=e.getVolumeLevel();o=d>o?d:o,s=d<s?d:s;const l=o-s>1e-4,u=Date.now()-a;if(l||u>t){clearInterval(c);const t=l,s={duration:u,deviceLabel:n,maxVolumeLevel:o,result:t};YN.info("[track-".concat(e.getTrackId(),"] check audio track active completed. ").concat(JSON.stringify(s))),i.onSuccess(s),r(t)}}),200)}))},checkVideoTrackIsActive:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3;const i=eD.reportApiInvoke(null,{tag:Mw.TRACER,name:kw.CHECK_VIDEO_TRACK_IS_ACTIVE,options:[t]});if(!(e instanceof pk||e instanceof Ok)){const e=new tD(Ew.INVALID_TRACK,"the parameter is not a video track");return i.onError(e),e.throw()}t&&t<1e3&&(t=1e3);const n=e instanceof pk?e.getTrackLabel():"remote_track",r=e.getMediaStreamTrack(!0),o=document.createElement("video");o.style.width="1px",o.style.height="1px",o.setAttribute("muted",""),o.muted=!0,o.setAttribute("playsinline",""),o.controls=!1,(Wb()||jb())&&(o.style.opacity="0.01",o.style.position="fixed",o.style.left="0",o.style.top="0",document.body.appendChild(o)),o.srcObject=ne
12272w MediaStream([r]),o.play();const s=document.createElement("canvas");s.width=160,s.height=120;let a=0,c=0;try{const e=Date.now();a=await function(e,t,i,n){let r,o=0,s=null;return new Wh(((a,c)=>{function d(){o>n&&r&&(r(),a(o));const t=i.getContext("2d");if(!t){const e=new tD(Ew.UNEXPECTED_ERROR,"can not get canvas 2d context.");return YN.error(e.toString()),void c(e)}t.drawImage(e,0,0,160,120);const d=t.getImageData(0,0,i.width,i.height),l=Math.floor(d.data.length/3);if(s){for(let e=0;e<l;e+=3)if(d.data[e]!==s[e])return o+=1,void(s=d.data);s=d.data}else s=d.data}setTimeout((()=>{r&&(r(),a(o))}),t),r=iP((()=>{d()}),30)}))}(o,t,s,4),c=Date.now()-e}catch(e){throw i.onError(e),e}WB===Lb.SAFARI&&(o.pause(),o.remove()),o.srcObject=null;const d=a>4,l={duration:c,changedPicNum:a,deviceLabel:n,result:d};return YN.info("[track-".concat(e.getTrackId(),"] check video track active completed. ").concat(JSON.stringify(l))),i.onSuccess(l),d},setArea:jV,audioElementPlayCenter:vP,resumeAudioContext:function(){vP.autoResumeAfterInterruption(!0)},processExternalMediaAEC:function(e){GG.processExternalMediaAEC(e)},registerExtensions:function(e){const t=_N("PLUGIN_INFO")||[];e.forEach((e=>{"name"in e&&!Dn(t).call(t,e.name)&&t.push(e.name);const i=e;i.__registered__=!0,i.logger.hookLog=YN.extLog,i.reporter.hookApiInvoke=eD.extApiInvoke,i.parameters&&Object.keys(i.parameters).forEach((e=>{i.parameters[e]=_N(e)}))})),uz("PLUGIN_INFO",t)},ChannelMediaRelayError:DU,ChannelMediaRelayEvent:OU,ChannelMediaRelayState:NU,RemoteStreamFallbackType:yD,RemoteStreamType:ID,ConnectionDisconnectedReason:Vw,AudienceLatencyLevelType:xw,AREAS:UU,preload:async function(e,t,i,n){return nj(e,t,i,n)}});return Object.defineProperties(hz,{onAudioAutoplayFailed:{get:()=>TP.onAudioAutoplayFailed,set:e=>{TP.onAudioAutoplayFailed=e}},onAutoplayFailed:{get:()=>TP.onAutoplayFailed,set:e=>{TP.onAutoplayFailed=e}},_onSecurityPolicyViolation:{value:void 0,writable:!0},_cspEventHandlerPointer:{value:void 0,writable:!0},onSecurityPolicyViolation:{get:()=>hz._onSecurityPolicyViolation,set(e){hz._onSecurityPolicyViolation=e,YG(e)}},__CLIENT_LIST__:{get:()=>_N("SHOW_GLOBAL_CLIENT_LIST")?TM:[]}}),mP.on(FD.CAMERA_DEVICE_CHANGED,(e=>{YN.info("camera device changed",JSON.stringify(e)),hz.onCameraChanged&&hz.onCameraChanged(e),hz.safeEmit(tx.CAMERA_CHANGED,e)})),mP.on(FD.RECORDING_DEVICE_CHANGED,(e=>{YN.info("microphone device changed",JSON.stringify(e)),hz.onMicrophoneChanged&&hz.onMicrophoneChanged(e),hz.safeEmit(tx.MICROPHONE_CHANGED,e)})),mP.on(FD.PLAYOUT_DEVICE_CHANGED,(e=>{YN.debug("playout device changed",JSON.stringify(e)),hz.onPlaybackDeviceChanged&&hz.onPlaybackDeviceChanged(e),hz.safeEmit(tx.PLAYBACK_DEVICE_CHANGED,e)})),vP.onAutoplayFailed=()=>{YN.info("detect audio element autoplay failed"),TP.onAudioAutoplayFailed&&TP.onAudioAutoplayFailed()},ZD.on("autoplay-failed",(()=>{YN.info("detect webaudio autoplay failed"),TP.onAudioAutoplayFailed&&TP.onAudioAutoplayFailed(),hz.safeEmit(tx.AUTOPLAY_FAILED)})),ZD.on(sD.STATE_CHANGE,((e,t)=>{YN.info("audio context state changed: ".concat(t," => ").concat(e)),hz.onAudioContextStateChanged&&hz.onAudioContextStateChanged(e,t),hz.safeEmit(tx.AUDIO_CONTEXT_STATE_CHANGED,e,t)})),Jw.on(Kw.NETWORK_STATE_CHANGE,((e,t)=>{YN.info("[network-indicator] network state changed, ".concat(t," => ").concat(e))})),window&&(window.__ARTC__=hz),hz})); 12273; 12274 12275 //feed change user tabs work 12276function getStoreSwitchData(obj,imageTab){ 12277 (scriptJquery.ajax({ 12278 url : en4.core.baseUrl + 'estore/ajax/get-user-stores', 12279 data : { 12280 format : 'html', 12281 }, 12282 success: function(responseHTML) { 12283 imageTab.attr('src',scriptJquery(obj).attr('data-src')); 12284 scriptJquery('#estore_switch_cnt').html(responseHTML); 12285 scriptJquery('#estore_switch_cnt').show(); 12286 changeSwittcherPositionStore(obj); 12287 } 12288 })); 12289} 12290function changeSwittcherPositionStore(obj){ 12291 var position = scriptJquery(currentClickElem).offset(); 12292 scriptJquery('#estore_switch_cnt').css('left',position.left); 12293 scriptJquery('#estore_switch_cnt').css('top',position.top+24); 12294 markSwitcherCheckedStore(obj); 12295} 12296function markSwitcherCheckedStore(obj){ 12297 var dataRel = scriptJquery(obj).attr('data-rel'); 12298 scriptJquery('._selected').removeClass('_selected'); 12299 scriptJquery('.estore_switcher_li[data-rel="'+dataRel+'"]').addClass('_selected'); 12300} 12301AttachEventListerSE('click','.estore_switcher_li',function(e){
12302 scriptJquery('#estore_switch_cnt').hide(); 12303 changeUserImagesInCommentStore(this); 12304 closeSwitcherDivStore(); 12305 getCommentDataForChangeUserStore(this); 12306}) 12307function changeUserImagesInCommentStore(obj){ 12308 var data = scriptJquery(obj).attr('data-rel'); 12309 scriptJquery(currentClickElem).attr('data-rel',data); 12310 scriptJquery(currentClickElem).find('img').attr('src',scriptJquery(obj).find('div').find('img').attr('src')); 12311 scriptJquery(currentClickElem).attr('data-src',scriptJquery(obj).find('div').find('img').attr('src')); 12312 if(scriptJquery(currentClickElem).closest('#activity_post_box_status').length){ 12313 scriptJquery(currentClickElem).closest('#activity_post_box_status').find('.activity_post_box_img').find('a').find('img').attr('src',scriptJquery(obj).find('div').find('img').attr('src')); 12314 return; 12315 } 12316 scriptJquery(currentClickElem).closest('.comment-feed').find('.sesadvcmt_comments').find('form').find('.comments_author_photo').find('img').attr('src',scriptJquery(obj).find('div').find('img').attr('src')); 12317} 12318function getCommentDataForChangeUserStore(obj){ 12319 var action_id = scriptJquery(currentClickElem).attr('data-actionid'); 12320 var dataGuid = scriptJquery(currentClickElem).attr('data-rel'); 12321 var subject = scriptJquery(currentClickElem).attr('data-subject'); 12322 scriptJquery.ajax({ 12323 url : en4.core.baseUrl + 'comment/index/get-comment', 12324 data : { 12325 format : 'html', 12326 dataGuid:dataGuid, 12327 action_id:action_id, 12328 subject:subject, 12329 }, 12330 success: function(responseHTML) { 12331 var dataJson = scriptJquery.parseJSON(responseHTML); 12332 scriptJquery(currentClickElem).closest('.activity_comments').html(dataJson.body); 12333 //changeUserImagesInCommentStore(obj); 12334 } 12335 }); 12336} 12337function closeSwitcherDivStore(){ 12338 if(scriptJquery(currentClickElem).hasClass('active')){ 12339 scriptJquery(currentClickElem).removeClass('active'); 12340 scriptJquery('#estore_switch_cnt').hide(); 12341 } 12342} 12343var currentClickElem = ""; 12344AttachEventListerSE('click','.estore_feed_change_option',function(){ 12345 currentClickElem = scriptJquery(this).parent().find('.estore_feed_change_option_a'); 12346 if(scriptJquery(currentClickElem).hasClass('active')){ 12347 closeSwitcherDivStore(); 12348 return; 12349 } 12350 scriptJquery(currentClickElem).addClass('active'); 12351 var storeContentData = true; 12352 if(!scriptJquery('#estore_switch_cnt').length) 12353 storeContentData = false; 12354 var imageTab = scriptJquery(currentClickElem).find('img'); 12355 imageTab.attr('src','application/modules/Core/externals/images/loading.gif'); 12356 12357 if(!storeContentData){ 12358 //create container div 12359 scriptJquery('<div id="estore_switch_cnt" class="activity_owner_selector_pulldown sesbasic_bxs"></div>').appendTo('body'); 12360 getStoreSwitchData(currentClickElem,imageTab); 12361 }else{ 12362 imageTab.attr('src',scriptJquery(currentClickElem).attr('data-src')); 12363 scriptJquery('#estore_switch_cnt').show(); 12364 changeSwittcherPositionStore(currentClickElem); 12365 } 12366}); 12367AttachEventListerSE('click','.estore_elem_cnt',function(){ 12368 scriptJquery(this).parent().trigger('click'); 12369}) 12370AttachEventListerSE('click',function (e){ 12371 var elem = scriptJquery('#estore_switch_cnt'); 12372 if(!elem.has(e.target).length && !scriptJquery(e.target).hasClass('estore_feed_change_option')){ 12373 closeSwitcherDivStore(); 12374 } 12375}) 12376//end feed switcher work 12377; 12378 12379 /* $Id: composer_photo.js 9930 2013-02-18 21:02:11Z jung $ */ 12380(function() { // START NAMESPACE 12381 var $ = 'id' in document ? document.id : window.$; 12382 Composer.Plugin.Estorephoto = function(options){ 12383 12384 this.__proto__ = new Composer.Plugin.Interface(options); 12385 12386 this.name = 'estore_photo' 12387 12388 this.options = { 12389 title : 'Add Photo', 12390 lang : {}, 12391 requestOptions : false, 12392 fancyUploadEnabled : true, 12393 fancyUploadOptions : {}, 12394 } 12395 12396 this.initialize = function(options) { 12397 this.elements = new Hash(this.elements); 12398 this.params = new Hash(this.params); 12399 this.__proto__.initialize.call(this,options); 12400 this.uploadedPhotos = []; 12401 } 12402 12403 this.attach = function() { 12404 this.__proto__.activate.call(this); 12405 this.makeActivator(); 12406 return this; 12407 } 12408 12409 this.detach = function() { 12410 this.__proto__.deactivate.call(this); 12411 return this; 12412 } 12413 12414 this.activate = function() { 12415 if( this.active && scriptJquery("#compose-photo-body").length > 0) return; 12416 this.__proto__.activate.call(this); 12417 12418 this.makeMenu(); 12419 this.makeBody(); 12420 12421 // Generate form 12422 var fullUrl = this.options.requestOptions.url; 12423 if(typeof sesAdvancedActivity == 'undefined'){ 12424 var fullUrl = this.options.requestOptions.url; 12425 var hasFlash = false;
12426 12427 this.elements.formFancyContainer = scriptJquery.crtEle('div', { 12428 }) 12429 .css({ 12430 'display' : 'none', 12431 'visibility' : 'hidden' 12432 }) 12433 .appendTo(this.elements.body); 12434 12435 this.elements.scrollContainer = scriptJquery.crtEle('div', { 12436 'class': 'scrollbars', 12437 }) 12438 .css({ 12439 'width' : this.elements.body.width() + 'px', 12440 }) 12441 .appendTo(this.elements.formFancyContainer); 12442 12443 // This is the list 12444 this.elements.formFancyList = scriptJquery.crtEle('ul', { 12445 'class': 'compose-photos-fancy-list', 12446 }).appendTo(this.elements.scrollContainer); 12447 12448 // This is the browse button 12449 this.elements.formFancyFile = scriptJquery.crtEle('div', { 12450 'id' : 'compose-photo-form-fancy-file', 12451 'class' : '', 12452 }).appendTo(this.elements.scrollContainer); 12453 12454 this.elements.selectFileLink = scriptJquery.crtEle('a', { 12455 'class' : 'buttonlink', 12456 }) 12457 .html(this._lang('Select File')) 12458 .css({ 12459 'cursor' : 'pointer' 12460 }) 12461 .appendTo(this.elements.formFancyFile); 12462 12463 // this.elements.scrollContainer.scrollbars({ 12464 // scrollBarSize: 5, 12465 // fade: true 12466 // }); 12467 12468 // Ajax Upload Work 12469 this.elements.formInput = scriptJquery.crtEle('input', { 12470 'id' : 'compose-photo-form-input', 12471 'class' : 'compose-form-input', 12472 'type' : 'file', 12473 'value': '', 12474 'accepts': 'images/*', 12475 }) 12476 .change(this.onFileSelectAfter.bind(this)) 12477 .appendTo(this.elements.scrollContainer); 12478 12479 bindEvent = window.matchMedia("(min-width: 400px)").matches ? 'click' : 'touchend'; 12480 this.elements.selectFileLink.on(bindEvent, this.onSelectFileClick.bind(this)); 12481 this.showForm(); 12482 if (en4.isMobile) { 12483 this.elements.scrollContainer.find("ul.scrollbar.vertical").addClass('inactive'); 12484 this.elements.scrollContainer.find("ul.scrollbar.horizontal").addClass('inactive'); 12485 } 12486 }else{ 12487 12488 scriptJquery(this.elements.body).html('<input type="file" accept="image/x-png,image/jpeg" onchange="readImageUrlEstore(this)" multiple="multiple" id="file_multi" name="file_multi" style="display:none"><div class="advact_compose_photo_container sesbasic_custom_horizontal_scroll sesbasic_clearfix"><div id="advact_compose_photo_container_inner" class="sesbasic_clearfix"><div id="show_photo"></div><div id="dragandrophandler" class="advact_compose_photo_uploader" title="Choose a file to upload"><i class="fa fa-plus"></i></div></div></div>'); 12489 12490// scriptJquery(".sesbasic_custom_horizontal_scroll").mCustomScrollbar({ 12491// axis:"x", 12492// theme:"light-3", 12493// advanced:{autoExpandHorizontalScroll:true} 12494// }) 12495 } 12496 if(scriptJquery('#toValues-wrapper').length > 0 || scriptJquery('#submit-wrapper').length > 0){ 12497 //scriptJquery('#file_multi').removeAttr('multiple'); 12498 } 12499 if(scriptJquery('#toValues-wrapper').length > 0){ 12500 scriptJquery('#toValues-wrapper').append('<div><input type="hidden" value="1" id="messageAttachment" name="attachment[messageAttachment]"><input type="hidden" value="" id="fancyalbumuploadfileids" name="attachment[photo_id]"><input type="hidden" value="photo" id="photosesalbum" name="attachment[type]"></div>'); 12501 }else if(scriptJquery('#submit-wrapper').length > 0){ 12502 scriptJquery('#body-wrapper').append('<div><input type="hidden" value="1" id="messageAttachment" name="attachment[messageAttachment]"><input type="hidden" value="photo" id="photosesalbum" name="attachment[type]"><input type="hidden" value="" id="fancyalbumuploadfileids" name="attachment[photo_id]"></div>'); 12503 } 12504 12505 /* 12506 * this.elements.formSubmit = scriptJquery.crtEle('button', { 12507 * 'id' : 'compose-photo-form-submit', 12508 * 'class' : 'compose-form-submit', 12509 * 'html' : 'Attach', 12510 * 'events' : { 12511 * 'click' : function(e) { 12512 * e.stop(); 12513 * this.doAttach(); 12514 }.bind(this) 12515 } 12516 }).appendTo(this.elements.body); 12517*/ 12518 } 12519 12520 this.deactivate = function() { 12521 if( !this.active ) return; 12522 this.__proto__.deactivate.call(this); 12523 this.uploadedPhotos = []; 12524 scriptJquery('#fancyalbumuploadfileids').remove(); 12525 scriptJquery('#photosesalbum').remove(); 12526 scriptJquery('#messageAttachment').remove(); 12527 } 12528 12529 this.onSelectFileClick = function () { 12530 this.elements.formInput.click(); 12531 } 12532 12533 this.onFileSelectAfter = function() { 12534 this.elements.formFancyList.css("display",'inline-block'); 12535 this.getComposer().getMenu().css('display', 'none'); 12536 if (this.elements.formInput[0].files.length === 0) { 12537 return; 12538 } 12539 12540 var FileSize;
12541 var valid = true; 12542 this.elements.fileElement = []; 12543 this.elements.filePreview = []; 12544 this.elements.fileRemoveLink = []; 12545 for (var i = 0; i < this.elements.formInput[0].files.length; i++) { 12546 FileSize = this.elements.formInput[0].files[i].size / 1024 / 1024; // in MB 12547 if(FileSize > post_max_size) { 12548 valid = false; 12549 continue; 12550 } 12551 12552 if (!this.canUploadPhoto(this.elements.formInput[0].files[i])) { 12553 this.getComposer().getMenu().css('display', ''); 12554 continue; 12555 } 12556 this.elements.fileElement[i] = scriptJquery.crtEle('li', { 12557 'class' : 'file compose-photo-preview', 12558 }).appendTo(this.elements.formFancyList); 12559 12560 this.elements.filePreview[i] = scriptJquery.crtEle('span', { 12561 'class' : 'compose-photo-preview-image compose-photo-preview-loading', 12562 }).appendTo(this.elements.fileElement[i]); 12563 12564 var overlay = scriptJquery.crtEle('span', { 12565 'class' : 'compose-photo-preview-overlay', 12566 }).appendTo(this.elements.filePreview[i], 'after'); 12567 12568 this.elements.fileRemoveLink[i] = scriptJquery.crtEle('a', { 12569 'class': 'file-remove', 12570 title: 'Click to remove this entry.', 12571 }) 12572 .html('X') 12573 .appendTo(overlay); 12574 this.uploadFile(this.elements.formInput[0].files[i], i); 12575 12576 if (this.canUploadPhoto(null) !== true) { 12577 this.elements.formFancyFile.css('display', 'none'); 12578 break; 12579 } 12580 } 12581 12582 if(!valid) alert("The size of the file exceeds the limits set on the server."); 12583 12584 this.elements.formInput.val(''); 12585 this.updateScrollBar(); 12586 var scrollbarContent = this.elements.formFancyList.closest('.scrollbars'); 12587 scrollbarContent.scrollLeft(this.elements.formFancyFile.offset().left, scrollbarContent.scrollTop()); 12588 scrollbarContent.scrollTop(scrollbarContent.scrollTop()); 12589 } 12590 12591 this.uploadFile = function (file, iteration) { 12592 var xhr = new XMLHttpRequest(); 12593 var fd = new FormData(); 12594 xhr.open("POST", this.options.requestOptions.url, true); 12595 var composerInstance = this; 12596 xhr.onreadystatechange = function() { 12597 if (xhr.readyState === 4 && xhr.status === 200) { 12598 var res = JSON.parse(xhr.responseText); 12599 if (res['error'] !== undefined) { 12600 //return false; 12601 }else{ 12602 res['iteration'] = iteration; 12603 composerInstance.uploadedPhotos[res.photo_id] = res.fileName; 12604 } 12605 composerInstance.doProcessResponse(res); 12606 } 12607 }; 12608 fd.append('ajax-upload', 'true'); 12609 fd.append('Filedata', file); 12610 xhr.send(fd); 12611 } 12612 this.doProcessResponse = function(responseJSON, file) { 12613 if( typeof responseJSON == 'object' && typeof responseJSON.error != 'undefined' ) { 12614 if( this.elements.loading ) { 12615 this.elements.loading.remove(); 12616 } 12617 this.elements.body.empty(); 12618 return this.makeError(responseJSON.error, 'empty'); 12619 } 12620 12621 // An error occurred 12622 if( ($type(responseJSON) != 'hash' && $type(responseJSON) != 'object') || $type(responseJSON.src) != 'string' || $type(parseInt(responseJSON.photo_id)) != 'number' ) { 12623 this.elements.loading ? this.elements.loading.remove() : ''; 12624 this.elements.body.empty(); 12625 if( responseJSON.error == 'Invalid data' ) { 12626 this.makeError(this._lang('The image you tried to upload exceeds the maximum file size.'), 'empty'); 12627 } else { 12628 this.makeError(this._lang(responseJSON.error), 'empty'); 12629 } 12630 return; 12631 //throw "unable to upload image"; 12632 } 12633 12634 // Success 12635 if (file) { 12636 file = file || {}; 12637 file.rawParams = responseJSON; 12638 this.setPhotoId(responseJSON.photo_id); 12639 this.elements.preview = scriptJquery('img', { 12640 'id' : 'compose-photo-preview-image', 12641 'class' : 'compose-preview-image', 12642 'src' : responseJSON.src, 12643 }).load(function() { 12644 this.doImageLoaded(file); 12645 }.bind(this)); 12646 return; 12647 } 12648 // In case of ajax upload 12649 this.elements.filePreview[responseJSON['iteration']].removeClass('compose-photo-preview-loading'); 12650 this.elements.filePreview[responseJSON['iteration']].css( 12651 'backgroundImage', 12652 'url(' + responseJSON.src + ')' 12653 ); 12654 this.elements.fileRemoveLink[responseJSON['iteration']].attr('id', 'file_remove-' + responseJSON.photo_id); 12655 this.elements.fileRemoveLink[responseJSON['iteration']].on('click',this.removeFile.bind(this, responseJSON.photo_id)); 12656 12657 this.setPhotoId(responseJSON.photo_id); 12658 this.makeFormInputs(); 12659 } 12660 12661 this.removeFile = function(photo_id) { 12662 var composerInstance = this; 12663 scriptJquery('#file_remove-' + photo_id).parent().parent().parent().remove(); 12664 composerInstance.removePhoto(photo_id); 12665 delete composerInstance.uploadedPhotos[photo_id]; 12666 if (this.canUploadPhoto(null)) { 12667 this.elements.formFancyFile.css('display', ''); 12668 } 12669 setTimeout(function() {composerInstance.updateScrollBar();},1000); 12670 } 12671 this.doImageLoaded = function(file) { 12672 //compose-photo-error 12673 if(scriptJquery('#compose-photo-error').length){ 12674 scriptJquery('#compose-photo-error').remove(); 12675 } 12676 12677 if( this.elements.loading ) this.elements.loading.remove(); 12678 if( this.elements.formFancyContainer ) { 12679 file.preview.removeClass('compose-photo-preview-loading'); 12680 file.preview.css('backgroundImage', 'url(' + this.elements.preview.src + ')' ); 12681 } else { 12682 this.elements.preview.attr('width',''); 12683 this.elements.preview.attr('height',''); 12684 this.elements.preview.appendTo(this.elements.body); 12685 } 12686 if(this.allowToSetInInput) { 12687 this.makeFormInputs(); 12688 } 12689 } 12690 12691 this.removePhoto = function(removePhotoId) { 12692 this.setPhotoId(removePhotoId, 'remove'); 12693 var photo_id = this.setPhotoId(removePhotoId, 'remove'); 12694 const index = photo_id.indexOf(removePhotoId); 12695 if (index > -1) { 12696 photo_id.splice(index, 1); 12697 } 12698 if (photo_id.length === 0) { 12699 this.getComposer().deactivate(); 12700 this.activate(); 12701 return; 12702 } 12703 this.makeFormInputs(); 12704 } 12705 this.getPhotoIdsString = function() { 12706 var photo_id_str = '';
12707 this.params.photo_id.forEach(function(value) { 12708 photo_id_str += value + ','; 12709 }); 12710 return photo_id_str.substr(0, photo_id_str.length-1); 12711 } 12712 this.setPhotoId = function (photoId, action) { 12713 var photo_id = this.params.get('photo_id') || []; 12714 if (action === 'remove') { 12715 var index = photo_id.indexOf(photoId); 12716 if (index > -1) { 12717 photo_id.splice(index, 1); 12718 } 12719 } else { 12720 photo_id.push(photoId); 12721 } 12722 this.params.set('photo_id', photo_id); 12723 return photo_id; 12724 } 12725 this.showForm = function () { 12726 this.elements.formFancyContainer.css('display', ''); 12727 this.elements.formInput.css('display', 'none'); 12728 this.elements.formFancyContainer.css('visibility', 'visible'); 12729 } 12730 12731 this.canUploadPhoto = function (photo) { 12732 if (photo === null) { 12733 return this.options.fancyUploadOptions.limitFiles === 0 || 12734 scriptJquery('ul.compose-photos-fancy-list li').length < this.options.fancyUploadOptions.limitFiles; 12735 } 12736 if (this.uploadedPhotos.length === 0) { 12737 return true; 12738 } 12739 return this.uploadedPhotos.every(function (uploadedPhoto) { 12740 return uploadedPhoto !== photo.name; 12741 }); 12742 } 12743 12744 this.updateScrollBar = function () { 12745 var height = this.elements.formFancyFile.offsetHeight; 12746 if( height == 0 ) { 12747 height = 106; 12748 } 12749 var scrollbarContent = this.elements.formFancyList.parent(); 12750 scrollbarContent.css('height', height + 20); 12751 var li = this.elements.formFancyList.find('li'); 12752 scrollbarContent.css('width', ((li.width() + 11) * li.length) + this.elements.formFancyFile.height() + 10); 12753 //this.elements.scrollContainer.data('scrollbars').updateScrollBars(); 12754 scrollbarContent.parent().css('overflow', 'hidden'); 12755 } 12756 12757 // this.makeFormInputs = function() { 12758 // this.ready(); 12759 // this.__proto__.makeFormInputs.call(this,{ 12760 // 'photo_id' : this.params.photo_id, 12761 12762 // }); 12763 12764 // } 12765 this.makeFormInputs = function() { 12766 this.ready(); 12767 if( this.elements.has('attachmentFormPhoto_id') ) { 12768 return this.setFormInputValue('photo_id', this.getPhotoIdsString()); 12769 } 12770 12771 this.__proto__.makeFormInputs.call(this,{ 12772 'photo_id': this.getPhotoIdsString() 12773 }); 12774 } 12775 this.initialize(options); 12776 12777 }; 12778})(); // END NAMESPACE 12779; 12780 12781 /* 12782 * Toastr 12783 * Copyright 2012-2015 12784 * Authors: John Papa, Hans Fjällemark, and Tim Ferrell. 12785 * All Rights Reserved. 12786 * Use, reproduction, distribution, and modification of this code is subject to the terms and 12787 * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php 12788 * 12789 * ARIA Support: Greta Krafsig 12790 * 12791 * Project: https://github.com/CodeSeven/toastr 12792 */ 12793/* global define */ 12794(function (define) { 12795 define(['jquery'], function ($) { 12796 return (function () { 12797 var $container; 12798 var listener; 12799 var toastId = 0; 12800 var toastType = { 12801 success: 'success', 12802 }; 12803 var toastr = { 12804 clear: clear, 12805 remove: remove, 12806 getContainer: getContainer, 12807 options: {}, 12808 subscribe: subscribe, 12809 success: success, 12810 version: '2.1.3', 12811 }; 12812 var previousToast; 12813 return toastr; 12814 function getContainer(options, create) { 12815 if (!options) { options = getOptions(); } 12816 $container = $('#' + options.containerId); 12817 if ($container.length) { 12818 return $container; 12819 } 12820 if (create) { 12821 $container = createContainer(options); 12822 } 12823 return $container; 12824 } 12825 function subscribe(callback) { 12826 listener = callback; 12827 } 12828 function success(message, title, icon,iconImage,firstTitle) { 12829 return notify({ 12830 type: toastType.success, 12831 iconClass: icon, 12832 message: message, 12833 iconImage: iconImage, 12834 firstTitle: firstTitle, 12835 // optionsOverride: optionsOverride, 12836 title: title 12837 }); 12838 } 12839 function clear($toastElement, clearOptions) { 12840 var options = getOptions(); 12841 if (!$container) { getContainer(options); } 12842 if (!clearToast($toastElement, options, clearOptions)) { 12843 clearContainer(options); 12844 } 12845 } 12846 function remove($toastElement) { 12847 var options = getOptions(); 12848 if (!$container) { getContainer(options); } 12849 if ($toastElement && $(':focus', $toastElement).length === 0) { 12850 removeToast($toastElement); 12851 return; 12852 } 12853 if ($container.children().length) { 12854 $container.remove(); 12855 } 12856 } 12857 // internal functions 12858 function clearContainer (options) { 12859 var toastsToClear = $container.children();
vendor: 13,868 bytes, lines 12860-13160
12860 for (var i = toastsToClear.length - 1; i >= 0; i--) { 12861 clearToast($(toastsToClear[i]), options); 12862 } 12863 } 12864 function clearToast ($toastElement, options, clearOptions) { 12865 var force = clearOptions && clearOptions.force ? clearOptions.force : false; 12866 if ($toastElement && (force || $(':focus', $toastElement).length === 0)) { 12867 $toastElement[options.hideMethod]({ 12868 duration: options.hideDuration, 12869 easing: options.hideEasing, 12870 complete: function () { removeToast($toastElement); } 12871 }); 12872 return true; 12873 } 12874 return false; 12875 } 12876 function createContainer(options) { 12877 $container = $('<div/>') 12878 .attr('id', options.containerId) 12879 .addClass(options.positionClass); 12880 12881 $container.appendTo($(options.target)); 12882 return $container; 12883 } 12884 function getDefaults() { 12885 return { 12886 tapToDismiss: true, 12887 toastClass: 'sesadvnotification', 12888 containerId: 'sesadvnotification-container', 12889 debug: false, 12890 showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery 12891 showDuration: 300, 12892 showEasing: 'swing', //swing and linear are built into jQuery 12893 onShown: undefined, 12894 hideMethod: 'fadeOut', 12895 hideDuration: 1000, 12896 hideEasing: 'swing', 12897 onHidden: undefined, 12898 closeMethod: false, 12899 closeDuration: false, 12900 closeEasing: false, 12901 closeOnHover: false, 12902 extendedTimeOut: 1000, 12903 iconClasses: { 12904 success: 'sesadvnotification-success', 12905 }, 12906 iconClass: 'sesadvnotification-info', 12907 positionClass: 'sesadvnotification-top-right', 12908 timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky 12909 titleClass: 'sesadvnotification-title', 12910 messageClass: 'sesadvnotification-message', 12911 escapeHtml: false, 12912 target: 'body', 12913 closeHtml: '<button type="button"></button>', 12914 closeClass: 'sesadvnotification-close-button fas fa-times', 12915 newestOnTop: true, 12916 preventDuplicates: false, 12917 progressBar: false, 12918 progressClass: 'sesadvnotification-progress', 12919 rtl: false 12920 }; 12921 } 12922 function publish(args) { 12923 if (!listener) { return; } 12924 listener(args); 12925 } 12926 function notify(map) { 12927 var options = getOptions(); 12928 var iconClass = 'success'; 12929 toastId++; 12930 $container = getContainer(options, true); 12931 var intervalId = null; 12932 var $toastElement = $('<div/>'); 12933 var $titleElement = $('<div/>'); 12934 var $messageElement = $('<div/>'); 12935 var $progressElement = $('<div/>'); 12936 var $closeElement = $(options.closeHtml); 12937 var progressBar = { 12938 intervalId: null, 12939 hideEta: null, 12940 maxHideTime: null 12941 }; 12942 var response = { 12943 toastId: toastId, 12944 state: 'visible', 12945 startTime: new Date(), 12946 options: options, 12947 map: map 12948 }; 12949 personalizeToast(); 12950 displayToast(); 12951 handleEvents(); 12952 publish(response); 12953 if (options.debug && console) { 12954 console.log(response); 12955 } 12956 return $toastElement; 12957 function escapeHtml(source) { 12958 if (source == null) { 12959 source = ''; 12960 } 12961 return source 12962 .replace(/&/g, '&') 12963 .replace(/"/g, '"') 12964 .replace(/'/g, ''') 12965 .replace(/</g, '<') 12966 .replace(/>/g, '>'); 12967 } 12968 function personalizeToast() { 12969 setIcon(); 12970 setTitle(); 12971 setMessage(); 12972 setCloseButton(); 12973 setProgressBar(); 12974 setRTL(); 12975 setSequence(); 12976 setAria(); 12977 } 12978 function setAria() { 12979 var ariaValue = ''; 12980 switch (map.iconClass) { 12981 case 'toast-success': 12982 case 'toast-info': 12983 ariaValue = 'polite'; 12984 break; 12985 default: 12986 ariaValue = 'assertive'; 12987 } 12988 $toastElement.attr('aria-live', ariaValue); 12989 } 12990 function handleEvents() { 12991 if (options.closeOnHover) { 12992 $toastElement.hover(stickAround, delayedHideToast); 12993 } 12994 if (!options.onclick && options.tapToDismiss) { 12995 $toastElement.click(hideToast); 12996 } 12997 if (options.closeButton && $closeElement) { 12998 $closeElement.click(function (event) { 12999 if (event.stopPropagation) { 13000 event.stopPropagation(); 13001 } else if (event.cancelBubble !== undefined && event.cancelBubble !== true) { 13002 event.cancelBubble = true; 13003 } 13004 13005 if (options.onCloseClick) { 13006 options.onCloseClick(event); 13007 } 13008 13009 hideToast(true); 13010 }); 13011 } 13012 if (options.onclick) { 13013 $toastElement.click(function (event) { 13014 options.onclick(event); 13015 hideToast(); 13016 }); 13017 } 13018 } 13019 function displayToast() { 13020 $toastElement.hide(); 13021 $toastElement[options.showMethod]( 13022 {duration: options.showDuration, easing: options.showEasing, complete: options.onShown} 13023 ); 13024 if (options.timeOut > 0) { 13025 intervalId = setTimeout(hideToast, options.timeOut); 13026 progressBar.maxHideTime = parseFloat(options.timeOut); 13027 progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime; 13028 if (options.progressBar) { 13029 progressBar.intervalId = setInterval(updateProgress, 10); 13030 } 13031 } 13032 } 13033 function setIcon() { 13034 if (map.iconClass) { 13035 $toastElement.addClass(options.toastClass); 13036 } 13037 } 13038 function setSequence() { 13039 if (options.newestOnTop) { 13040 $container.prepend($toastElement); 13041 } else { 13042 $container.append($toastElement); 13043 } 13044 } 13045 function setTitle() { 13046 if (map.iconClass) { 13047 $toastElement.append('<div class="sesadvnotification-img"><img src="'+map.iconClass+'" /></div>') 13048 } 13049 if (map.title) { 13050 var suffix = map.title; 13051 if (options.escapeHtml) { 13052 suffix = escapeHtml(map.title); 13053 } 13054 $titleElement.append('<div class="'+options.titleClass+'"><span>'+suffix+'</span></div><div class="sesadvnotification-time '+map.iconImage+'">a few seconds ago.</div>').addClass('sesadvnotification-content'); 13055 $toastElement.append($titleElement); 13056 } 13057 } 13058 function setMessage() { 13059 if (map.message) { 13060 var suffix = map.message; 13061 if (options.escapeHtml) { 13062 suffix = escapeHtml(map.message); 13063 } 13064 $messageElement.append(suffix).addClass(options.messageClass); 13065 $toastElement.append($messageElement); 13066 } 13067 } 13068 function setCloseButton() { 13069 if (options.closeButton) { 13070 $closeElement.addClass(options.closeClass).attr('role', 'button'); 13071 $toastElement.prepend($closeElement); 13072 } 13073 } 13074 function setProgressBar() { 13075 if (options.progressBar) { 13076 $progressElement.addClass(options.progressClass); 13077 $toastElement.prepend($progressElement); 13078 } 13079 } 13080 function setRTL() { 13081 if (options.rtl) { 13082 $toastElement.addClass('rtl'); 13083 } 13084 } 13085 function shouldExit(options, map) { 13086 console.log(map); 13087 if (options.preventDuplicates) { 13088 console.log(map.message,previousToast); 13089 if (map.message === previousToast) { 13090 return true; 13091 } else { 13092 previousToast = map.message; 13093 } 13094 } 13095 return false; 13096 } 13097 function hideToast(override) { 13098 var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod; 13099 var duration = override && options.closeDuration !== false ? 13100 options.closeDuration : options.hideDuration; 13101 var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing; 13102 if ($(':focus', $toastElement).length && !override) { 13103 return; 13104 } 13105 clearTimeout(progressBar.intervalId); 13106 return $toastElement[method]({ 13107 duration: duration, 13108 easing: easing, 13109 complete: function () { 13110 removeToast($toastElement); 13111 clearTimeout(intervalId); 13112 if (options.onHidden && response.state !== 'hidden') { 13113 options.onHidden(); 13114 } 13115 response.state = 'hidden'; 13116 response.endTime = new Date(); 13117 publish(response); 13118 } 13119 }); 13120 } 13121 function delayedHideToast() { 13122 if (options.timeOut > 0 || options.extendedTimeOut > 0) { 13123 intervalId = setTimeout(hideToast, options.extendedTimeOut); 13124 progressBar.maxHideTime = parseFloat(options.extendedTimeOut); 13125 progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime; 13126 } 13127 } 13128 function stickAround() { 13129 clearTimeout(intervalId); 13130 progressBar.hideEta = 0; 13131 $toastElement.stop(true, true)[options.showMethod]( 13132 {duration: options.showDuration, easing: options.showEasing} 13133 ); 13134 } 13135 function updateProgress() { 13136 var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100; 13137 $progressElement.width(percentage + '%'); 13138 } 13139 } 13140 function getOptions() { 13141 return $.extend({}, getDefaults(), toastr.options); 13142 } 13143 function removeToast($toastElement) { 13144 if (!$container) { $container = getContainer(); } 13145 if ($toastElement.is(':visible')) { 13146 return; 13147 } 13148 $toastElement.remove(); 13149 $toastElement = null; 13150 if ($container.children().length === 0) { 13151 $container.remove(); 13152 previousToast = undefined; 13153 } 13154 } 13155 })(); 13156 }); 13157}(typeof define === 'function' && define.amd ? define : function (deps, factory) { 13158 if (typeof module !== 'undefined' && module.exports) { //Node 13159 module.exports = factory(require('jquery')); 13160 } else {
13161 window.toastr = factory(window.scriptJquery); 13162 } 13163}));; 13164 13165 /* $Id: composer_photo.js 9930 2013-02-18 21:02:11Z jung $ */ 13166(function() { // START NAMESPACE 13167var $ = 'id' in document ? document.id : window.$; 13168Composer.Plugin.Photo = function(options){ 13169 13170 this.__proto__ = new Composer.Plugin.Interface(options); 13171 13172 this.name = 'photo' 13173 13174 this.options = { 13175 title : 'Add Photo', 13176 lang : {}, 13177 requestOptions : false, 13178 fancyUploadEnabled : true, 13179 fancyUploadOptions : {}, 13180 } 13181 13182 this.initialize = function(options) { 13183 this.elements = new Hash(this.elements); 13184 this.params = new Hash(this.params); 13185 this.__proto__.initialize.call(this,options); 13186 this.uploadedPhotos = []; 13187 } 13188 13189 this.attach = function() { 13190 //this.__proto__.activate.call(this); 13191 this.makeActivator(); 13192 return this; 13193 } 13194 13195 this.detach = function() { 13196 this.__proto__.deactivate.call(this); 13197 return this; 13198 } 13199 13200 this.activate = function() { 13201 if( this.active && scriptJquery("#compose-photo-body").length > 0) return; 13202 this.__proto__.activate.call(this); 13203 13204 this.makeMenu(); 13205 this.makeBody(); 13206 13207 // Generate form 13208 var fullUrl = this.options.requestOptions.url; 13209 if(!true){ 13210 var fullUrl = this.options.requestOptions.url; 13211 var hasFlash = false; 13212 13213 this.elements.formFancyContainer = scriptJquery.crtEle('div', { 13214 }) 13215 .css({ 13216 'display' : 'none', 13217 'visibility' : 'hidden' 13218 }) 13219 .appendTo(this.elements.body); 13220 13221 this.elements.scrollContainer = scriptJquery.crtEle('div', { 13222 'class': 'scrollbars', 13223 }) 13224 .css({ 13225 'width' : this.elements.body.width() + 'px', 13226 }) 13227 .appendTo(this.elements.formFancyContainer); 13228 13229 // This is the list 13230 this.elements.formFancyList = scriptJquery.crtEle('ul', { 13231 'class': 'compose-photos-fancy-list', 13232 }).appendTo(this.elements.scrollContainer); 13233 13234 // This is the browse button 13235 this.elements.formFancyFile = scriptJquery.crtEle('div', { 13236 'id' : 'compose-photo-form-fancy-file', 13237 'class' : '', 13238 }).appendTo(this.elements.scrollContainer); 13239 13240 this.elements.selectFileLink = scriptJquery.crtEle('a', { 13241 'class' : 'buttonlink', 13242 }) 13243 .html(this._lang('Select File')) 13244 .css({ 13245 'cursor' : 'pointer' 13246 }) 13247 .appendTo(this.elements.formFancyFile); 13248 13249 // this.elements.scrollContainer.scrollbars({ 13250 // scrollBarSize: 5, 13251 // fade: true 13252 // }); 13253 13254 // Ajax Upload Work 13255 this.elements.formInput = scriptJquery.crtEle('input', { 13256 'id' : 'compose-photo-form-input', 13257 'class' : 'compose-form-input', 13258 'type' : 'file', 13259 'multiple': this.options.fancyUploadOptions.limitFiles != 1, 13260 'value': '', 13261 'accepts': 'images/*', 13262 }) 13263 .change(this.onFileSelectAfter.bind(this)) 13264 .appendTo(this.elements.scrollContainer); 13265 13266 bindEvent = window.matchMedia("(min-width: 400px)").matches ? 'click' : 'touchend'; 13267 this.elements.selectFileLink.on(bindEvent, this.onSelectFileClick.bind(this)); 13268 this.showForm(); 13269 if (en4.isMobile) { 13270 this.elements.scrollContainer.find("ul.scrollbar.vertical").addClass('inactive'); 13271 this.elements.scrollContainer.find("ul.scrollbar.horizontal").addClass('inactive'); 13272 } 13273 13274 // var self = this; 13275 // var opts = $merge({ 13276 // policyFile : ('https:' == document.location.protocol ? 'https://' : 'http://') 13277 // + document.location.host 13278 // + en4.core.baseUrl + 'cross-domain', 13279 // url : fullUrl, 13280 // appendCookieData: true, 13281 // multiple : false, 13282 // typeFilter: { 13283 // 'Images (*.jpg, *.jpeg, *.gif, *.png)': '*.jpg; *.jpeg; *.gif; *.png' 13284 // }, 13285 // target : this.elements.formFancyFile, 13286 // container : self.elements.body, 13287 // // Events 13288 // onLoad : function() { 13289 // self.elements.formFancyContainer.setStyle('display', ''); 13290 // self.elements.formFancyContainer.setStyle('visibility', 'visible'); 13291 // //self.elements.form.setStyle('display', 'none'); 13292 // self.elements.form.destroy(); 13293 // this.target.addEvents({ 13294 // click: function() { 13295 // return false;
13296 // }, 13297 // mouseenter: function() { 13298 // this.addClass('hover'); 13299 // }, 13300 // mouseleave: function() { 13301 // this.removeClass('hover'); 13302 // this.blur(); 13303 // }, 13304 // mousedown: function() { 13305 // this.focus(); 13306 // } 13307 // }); 13308 // }, 13309 // onSelectSuccess : function() { 13310 // self.makeLoading('invisible'); 13311 // //$('demo-status-overall').setStyle('display', ''); 13312 // this.start(); 13313 // }, 13314 // onFileSuccess : function(file, response) { 13315 // var json = new Hash(JSON.decode(response, true) || {}); 13316 // self.doProcessResponse(json); 13317 // } 13318 // }, this.options.fancyUploadOptions); 13319 13320 13321 // } 13322 }else{ 13323 scriptJquery(this.elements.body).html('<input type="file" accept="image/x-png,image/jpeg" onchange="readImageUrlSesalbum(this)" multiple="multiple" id="file_multi" name="file_multi" style="display:none"><div class="activity_compose_photo_container"><div id="advact_compose_photo_container_inner" class="sesbasic_clearfix"><div id="show_photo"></div><div id="dragandrophandler" class="activity_compose_photo_uploader center_item" title="Choose a file to upload"><i class="fa fa-plus"></i></div></div></div>'); 13324 // scriptJquery(".sesbasic_custom_horizontal_scroll").mCustomScrollbar({ 13325 // axis:"x", 13326 // theme:"light-3", 13327 // advanced:{autoExpandHorizontalScroll:true} 13328 // }) 13329 } 13330 if(isMessagePage) { 13331 scriptJquery('#file_multi').removeAttr('multiple'); 13332 } 13333 if(scriptJquery('#toValues-wrapper').length > 0 || scriptJquery('#submit-wrapper').length > 0){ 13334 //scriptJquery('#file_multi').removeAttr('multiple'); 13335 } 13336 if(scriptJquery('#toValues-wrapper').length > 0){ 13337 scriptJquery('#toValues-wrapper').append('<div><input type="hidden" value="1" id="messageAttachment" name="attachment[messageAttachment]"><input type="hidden" value="" id="fancyalbumuploadfileids" name="attachment[photo_id]"><input type="hidden" value="photo" id="photosesalbum" name="attachment[type]"></div>'); 13338 }else if(scriptJquery('#submit-wrapper').length > 0){ 13339 scriptJquery('#body-wrapper').append('<div><input type="hidden" value="1" id="messageAttachment" name="attachment[messageAttachment]"><input type="hidden" value="photo" id="photosesalbum" name="attachment[type]"><input type="hidden" value="" id="fancyalbumuploadfileids" name="attachment[photo_id]"></div>'); 13340 } else if(isMessagePage) { 13341 scriptJquery('#body-wrapper').append('<div><input type="hidden" value="1" id="messageAttachment" name="attachment[messageAttachment]"><input type="hidden" value="photo" id="photosesalbum" name="attachment[type]"><input type="hidden" value="" id="fancyalbumuploadfileids" name="attachment[photo_id]"></div>'); 13342 } 13343 13344 /* 13345 this.elements.formSubmit = scriptJquery.crtEle('button', { 13346 'id' : 'compose-photo-form-submit', 13347 'class' : 'compose-form-submit', 13348 'html' : 'Attach', 13349 'events' : { 13350 'click' : function(e) { 13351 e.stop(); 13352 this.doAttach(); 13353 }.bind(this) 13354 } 13355 }).appendTo(this.elements.body); 13356 */ 13357 } 13358 13359 this.deactivate = function() { 13360 if( !this.active ) return; 13361 this.__proto__.deactivate.call(this); 13362 this.uploadedPhotos = []; 13363 scriptJquery('#fancyalbumuploadfileids').remove(); 13364 scriptJquery('#photosesalbum').remove(); 13365 scriptJquery('#messageAttachment').remove(); 13366 } 13367 13368 this.onSelectFileClick = function () { 13369 this.elements.formInput.click(); 13370 } 13371 13372 this.onFileSelectAfter = function() { 13373 this.elements.formFancyList.css("display",'inline-block'); 13374 this.getComposer().getMenu().css('display', 'none'); 13375 if (this.elements.formInput[0].files.length === 0) { 13376 return; 13377 } 13378 13379 var FileSize; 13380 var valid = true; 13381 this.elements.fileElement = []; 13382 this.elements.filePreview = []; 13383 this.elements.fileRemoveLink = []; 13384 for (var i = 0; i < this.elements.formInput[0].files.length; i++) { 13385 FileSize = this.elements.formInput[0].files[i].size / 1024 / 1024; // in MB 13386 if(FileSize > post_max_size) { 13387 valid = false;
13388 continue; 13389 } 13390 13391 if (!this.canUploadPhoto(this.elements.formInput[0].files[i])) { 13392 this.getComposer().getMenu().css('display', ''); 13393 continue; 13394 } 13395 this.elements.fileElement[i] = scriptJquery.crtEle('li', { 13396 'class' : 'file compose-photo-preview', 13397 }).appendTo(this.elements.formFancyList); 13398 13399 this.elements.filePreview[i] = scriptJquery.crtEle('span', { 13400 'class' : 'compose-photo-preview-image compose-photo-preview-loading', 13401 }).appendTo(this.elements.fileElement[i]); 13402 13403 var overlay = scriptJquery.crtEle('span', { 13404 'class' : 'compose-photo-preview-overlay', 13405 }).appendTo(this.elements.filePreview[i], 'after'); 13406 13407 this.elements.fileRemoveLink[i] = scriptJquery.crtEle('a', { 13408 'class': 'file-remove', 13409 title: 'Click to remove this entry.', 13410 }) 13411 .html('X') 13412 .appendTo(overlay); 13413 this.uploadFile(this.elements.formInput[0].files[i], i); 13414 13415 if (this.canUploadPhoto(null) !== true) { 13416 this.elements.formFancyFile.css('display', 'none'); 13417 break; 13418 } 13419 } 13420 13421 if(!valid) alert("The size of the file exceeds the limits set on the server."); 13422 13423 this.elements.formInput.val(''); 13424 this.updateScrollBar(); 13425 var scrollbarContent = this.elements.formFancyList.closest('.scrollbars'); 13426 scrollbarContent.scrollLeft(this.elements.formFancyFile.offset().left, scrollbarContent.scrollTop()); 13427 scrollbarContent.scrollTop(scrollbarContent.scrollTop()); 13428 } 13429 13430 this.uploadFile = function (file, iteration) { 13431 var xhr = new XMLHttpRequest(); 13432 var fd = new FormData(); 13433 xhr.open("POST", this.options.requestOptions.url, true); 13434 var composerInstance = this; 13435 xhr.onreadystatechange = function() { 13436 if (xhr.readyState === 4 && xhr.status === 200) { 13437 var res = JSON.parse(xhr.responseText); 13438 if (res['error'] !== undefined) { 13439 //return false; 13440 }else{ 13441 res['iteration'] = iteration; 13442 composerInstance.uploadedPhotos[res.photo_id] = res.fileName; 13443 } 13444 composerInstance.doProcessResponse(res); 13445 } 13446 }; 13447 fd.append('ajax-upload', 'true'); 13448 fd.append('Filedata', file); 13449 xhr.send(fd); 13450 } 13451 this.doProcessResponse = function(responseJSON, file) { 13452 if( typeof responseJSON == 'object' && typeof responseJSON.error != 'undefined' ) { 13453 if( this.elements.loading ) { 13454 this.elements.loading.remove(); 13455 } 13456 this.elements.body.empty(); 13457 return this.makeError(responseJSON.error, 'empty'); 13458 } 13459 13460 // An error occurred 13461 if( ($type(responseJSON) != 'hash' && $type(responseJSON) != 'object') || $type(responseJSON.src) != 'string' || $type(parseInt(responseJSON.photo_id)) != 'number' ) { 13462 this.elements.loading ? this.elements.loading.remove() : ''; 13463 this.elements.body.empty(); 13464 if( responseJSON.error == 'Invalid data' ) { 13465 this.makeError(this._lang('The image you tried to upload exceeds the maximum file size.'), 'empty'); 13466 } else { 13467 this.makeError(this._lang(responseJSON.error), 'empty'); 13468 } 13469 return; 13470 //throw "unable to upload image"; 13471 } 13472 13473 // Success 13474 if (file) { 13475 file = file || {}; 13476 file.rawParams = responseJSON; 13477 this.setPhotoId(responseJSON.photo_id); 13478 this.elements.preview = scriptJquery('img', { 13479 'id' : 'compose-photo-preview-image', 13480 'class' : 'compose-preview-image', 13481 'src' : responseJSON.src, 13482 }).load(function() { 13483 this.doImageLoaded(file); 13484 }.bind(this)); 13485 return; 13486 } 13487 // In case of ajax upload 13488 this.elements.filePreview[responseJSON['iteration']].removeClass('compose-photo-preview-loading'); 13489 this.elements.filePreview[responseJSON['iteration']].css( 13490 'backgroundImage', 13491 'url(' + responseJSON.src + ')' 13492 ); 13493 this.elements.fileRemoveLink[responseJSON['iteration']].attr('id', 'file_remove-' + responseJSON.photo_id); 13494 this.elements.fileRemoveLink[responseJSON['iteration']].on('click',this.removeFile.bind(this, responseJSON.photo_id)); 13495 13496 this.setPhotoId(responseJSON.photo_id); 13497 this.makeFormInputs(); 13498 } 13499 13500 this.removeFile = function(photo_id) { 13501 var composerInstance = this; 13502 scriptJquery('#file_remove-' + photo_id).parent().parent().parent().remove(); 13503 composerInstance.removePhoto(photo_id); 13504 delete composerInstance.uploadedPhotos[photo_id]; 13505 if (this.canUploadPhoto(null)) { 13506 this.elements.formFancyFile.css('display', ''); 13507 } 13508 setTimeout(function() {composerInstance.updateScrollBar();},1000); 13509 } 13510 this.doImageLoaded = function(file) { 13511 //compose-photo-error 13512 if(scriptJquery('#compose-photo-error').length){ 13513 scriptJquery('#compose-photo-error').remove(); 13514 } 13515 13516 if( this.elements.loading ) this.elements.loading.remove(); 13517 if( this.elements.formFancyContainer ) { 13518 file.preview.removeClass('compose-photo-preview-loading'); 13519 file.preview.css('backgroundImage', 'url(' + this.elements.preview.src + ')' ); 13520 } else { 13521 this.elements.preview.attr('width',''); 13522 this.elements.preview.attr('height',''); 13523 this.elements.preview.appendTo(this.elements.body); 13524 } 13525 if(this.allowToSetInInput) { 13526 this.makeFormInputs(); 13527 } 13528 } 13529 13530 this.removePhoto = function(removePhotoId) { 13531 this.setPhotoId(removePhotoId, 'remove'); 13532 var photo_id = this.setPhotoId(removePhotoId, 'remove'); 13533 const index = photo_id.indexOf(removePhotoId); 13534 if (index > -1) { 13535 photo_id.splice(index, 1); 13536 } 13537 if (photo_id.length === 0) { 13538 this.getComposer().deactivate(); 13539 this.activate(); 13540 return; 13541 } 13542 this.makeFormInputs(); 13543 } 13544 this.getPhotoIdsString = function() { 13545 var photo_id_str = '';
13546 this.params.photo_id.forEach(function(value) { 13547 photo_id_str += value + ','; 13548 }); 13549 return photo_id_str.substr(0, photo_id_str.length-1); 13550 } 13551 this.setPhotoId = function (photoId, action) { 13552 var photo_id = this.params.get('photo_id') || []; 13553 if (action === 'remove') { 13554 var index = photo_id.indexOf(photoId); 13555 if (index > -1) { 13556 photo_id.splice(index, 1); 13557 } 13558 } else { 13559 photo_id.push(photoId); 13560 } 13561 this.params.set('photo_id', photo_id); 13562 return photo_id; 13563 } 13564 this.showForm = function () { 13565 this.elements.formFancyContainer.css('display', ''); 13566 this.elements.formInput.css('display', 'none'); 13567 this.elements.formFancyContainer.css('visibility', 'visible'); 13568 } 13569 13570 this.canUploadPhoto = function (photo) { 13571 if (photo === null) { 13572 return this.options.fancyUploadOptions.limitFiles === 0 || 13573 scriptJquery('ul.compose-photos-fancy-list li').length < this.options.fancyUploadOptions.limitFiles; 13574 } 13575 if (this.uploadedPhotos.length === 0) { 13576 return true; 13577 } 13578 return this.uploadedPhotos.every(function (uploadedPhoto) { 13579 return uploadedPhoto !== photo.name; 13580 }); 13581 } 13582 13583 this.updateScrollBar = function () { 13584 var height = this.elements.formFancyFile.offsetHeight; 13585 if( height == 0 ) { 13586 height = 106; 13587 } 13588 var scrollbarContent = this.elements.formFancyList.parent(); 13589 scrollbarContent.css('height', height + 20); 13590 var li = this.elements.formFancyList.find('li'); 13591 scrollbarContent.css('width', ((li.width() + 11) * li.length) + this.elements.formFancyFile.height() + 10); 13592 //this.elements.scrollContainer.data('scrollbars').updateScrollBars(); 13593 scrollbarContent.parent().css('overflow', 'hidden'); 13594 } 13595 13596 // this.makeFormInputs = function() { 13597 // this.ready(); 13598 // this.__proto__.makeFormInputs.call(this,{ 13599 // 'photo_id' : this.params.photo_id, 13600 13601 // }); 13602 13603 // } 13604 this.makeFormInputs = function() { 13605 this.ready(); 13606 if( this.elements.has('attachmentFormPhoto_id') ) { 13607 return this.setFormInputValue('photo_id', this.getPhotoIdsString()); 13608 } 13609 13610 this.__proto__.makeFormInputs.call(this,{ 13611 'photo_id': this.getPhotoIdsString() 13612 }); 13613 } 13614 this.initialize(options); 13615 13616}; 13617 13618 13619 13620})(); // END NAMESPACE 13621; 13622 13623 /** 13624 * BxSlider v4.1.2 - Fully loaded, responsive content slider 13625 * http://bxslider.com 13626 * 13627 * Copyright 2014, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com 13628 * Written while drinking Belgian ales and listening to jazz 13629 * 13630 * Released under the MIT license - http://opensource.org/licenses/MIT 13631 */ 13632!function(t){var e={},s={mode:"horizontal",slideSelector:"",infiniteLoop:!0,hideControlOnEnd:!1,speed:500,easing:null,slideMargin:0,startSlide:0,randomStart:!1,captions:!1,ticker:!1,tickerHover:!1,adaptiveHeight:!1,adaptiveHeightSpeed:500,video:!1,useCSS:!0,preloadImages:"visible",responsive:!0,slideZIndex:50,touchEnabled:!0,swipeThreshold:50,oneToOneTouch:!0,preventDefaultSwipeX:!0,preventDefaultSwipeY:!1,pager:!0,pagerType:"full",pagerShortSeparator:" / ",pagerSelector:null,buildPager:null,pagerCustom:null,controls:!0,nextText:"Next",prevText:"Prev",nextSelector:null,prevSelector:null,autoControls:!1,startText:"Start",stopText:"Stop",autoControlsCombine:!1,autoControlsSelector:null,auto:!1,pause:4e3,autoStart:!0,autoDirection:"next",autoHover:!1,autoDelay:0,minSlides:1,maxSlides:1,moveSlides:0,slideWidth:0,onSliderLoad:function(){},onSlideBefore:function(){},onSlideAfter:function(){},onSlideNext:function(){},onSlidePrev:function(){},onSliderResize:function(){}};t.fn.bxSlider=function(n){if(0==this.length)return this;if(this.length>1)return this.each(function(){t(this).bxSlider(n)}),this;var o={},r=this;e.el=this;var a=t(window).width(),l=t(window).height(),d=function(){o.settings=t.extend({},s,n),o.settings.slideWidth=parseInt(o.settings.slideWidth),o.children=r.children(o.settings.slideSelector),o.children.length<o.settings.minSlides&&(o.settings.minSlides=o.children.length),o.children.length<o.settings.maxSlides&&(o.settings.maxSlides=o.children.length),o.settings.randomStart&&(o.settings.startSlide=Math.floor(Math.random()*o.children.length)),o.active={index:o.settings.startSlide},o.carousel=o.settings.minSlides>1||o.settings.maxSlides>1,o.carousel&&(o.settings.preloadImages="all"),o.minThreshold=o.settings.minSlides*o.settings.slideWidth+(o.settings.minSlides-1)*o.settings.slideMargin,o.maxThreshold=o.settings.maxSlides*o.settings.slideWidth+(o.settings.maxSlides-1)*o.settings.slideMargin,o.working=!1,o.controls={},o.interval=null,o.animProp="vertical"==o.settings.mode?"top":"left",o.usingCSS=o.settings.useCSS&&"fade"!=o.settings.mode&&function(){var t=document.createElement("div"),e=["WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var i in e)if(void 0!==t.style[e[i]])return o.cssPrefix=e[i].replace("Perspective","").toLowerCase(),o.animProp="-"+o.cssPrefix+"-transform",!0;return!1}(),"vertical"==o.settings.mode&&(o.settings.maxSlides=o.settings.minSlides),r.data("origStyle",r.attr("style")),r.children(o.settings.slideSelector).each(function(){t(this).data("origStyle",t(this).attr("style"))}),c()},c=function(){r.wrap('<div class="bx-wrapper"><div class="bx-viewport"></div></div>'),o.viewport=r.parent(),o.loader=t('<div class="bx-loading" />'),o.viewport.prepend(o.loader),r.css({width:"horizontal"==o.settings.mode?100*o.children.length+215+"%":"auto",position:"relative"}),o.usingCSS&&o.settings.easing?r.css("-"+o.cssPrefix+"-transition-timing-function",o.settings.easing):o.settings.easing||(o.settings.easing="swing"),f(),o.viewport.css({width:"100%",overflow:"hidden",position:"relative"}),o.viewport.parent().css({maxWidth:p()}),o.settings.pager||o.viewport.parent().css({margin:"0 auto 0px"}
13632),o.children.css({"float":"horizontal"==o.settings.mode?"left":"none",listStyle:"none",position:"relative"}),o.children.css("width",u()),"horizontal"==o.settings.mode&&o.settings.slideMargin>0&&o.children.css("marginRight",o.settings.slideMargin),"vertical"==o.settings.mode&&o.settings.slideMargin>0&&o.children.css("marginBottom",o.settings.slideMargin),"fade"==o.settings.mode&&(o.children.css({position:"absolute",zIndex:0,display:"none"}),o.children.eq(o.settings.startSlide).css({zIndex:o.settings.slideZIndex,display:"block"})),o.controls.el=t('<div class="bx-controls" />'),o.settings.captions&&P(),o.active.last=o.settings.startSlide==x()-1,o.settings.video&&r.fitVids();var e=o.children.eq(o.settings.startSlide);"all"==o.settings.preloadImages&&(e=o.children),o.settings.ticker?o.settings.pager=!1:(o.settings.pager&&T(),o.settings.controls&&C(),o.settings.auto&&o.settings.autoControls&&E(),(o.settings.controls||o.settings.autoControls||o.settings.pager)&&o.viewport.after(o.controls.el)),g(e,h)},g=function(e,i){var s=e.find("img, iframe").length;if(0==s)return i(),void 0;var n=0;e.find("img, iframe").each(function(){t(this).one("load",function(){++n==s&&i()}).each(function(){this.complete&&t(this).load()})})},h=function(){if(o.settings.infiniteLoop&&"fade"!=o.settings.mode&&!o.settings.ticker){var e="vertical"==o.settings.mode?o.settings.minSlides:o.settings.maxSlides,i=o.children.slice(0,e).clone().addClass("bx-clone"),s=o.children.slice(-e).clone().addClass("bx-clone");r.append(i).prepend(s)}o.loader.remove(),S(),"vertical"==o.settings.mode&&(o.settings.adaptiveHeight=!0),o.viewport.height(v()),r.redrawSlider(),o.settings.onSliderLoad(o.active.index),o.initialized=!0,o.settings.responsive&&t(window).bind("resize",Z),o.settings.auto&&o.settings.autoStart&&H(),o.settings.ticker&&L(),o.settings.pager&&q(o.settings.startSlide),o.settings.controls&&W(),o.settings.touchEnabled&&!o.settings.ticker&&O()},v=function(){var e=0,s=t();if("vertical"==o.settings.mode||o.settings.adaptiveHeight)if(o.carousel){var n=1==o.settings.moveSlides?o.active.index:o.active.index*m();for(s=o.children.eq(n),i=1;i<=o.settings.maxSlides-1;i++)s=n+i>=o.children.length?s.add(o.children.eq(i-1)):s.add(o.children.eq(n+i))}else s=o.children.eq(o.active.index);else s=o.children;return"vertical"==o.settings.mode?(s.each(function(){e+=t(this).outerHeight()}),o.settings.slideMargin>0&&(e+=o.settings.slideMargin*(o.settings.minSlides-1))):e=Math.max.apply(Math,s.map(function(){return t(this).outerHeight(!1)}).get()),e},p=function(){var t="100%";return o.settings.slideWidth>0&&(t="horizontal"==o.settings.mode?o.settings.maxSlides*o.settings.slideWidth+(o.settings.maxSlides-1)*o.settings.slideMargin:o.settings.slideWidth),t},u=function(){var t=o.settings.slideWidth,e=o.viewport.width();return 0==o.settings.slideWidth||o.settings.slideWidth>e&&!o.carousel||"vertical"==o.settings.mode?t=e:o.settings.maxSlides>1&&"horizontal"==o.settings.mode&&(e>o.maxThreshold||e<o.minThreshold&&(t=(e-o.settings.slideMargin*(o.settings.minSlides-1))/o.settings.minSlides)),t},f=function(){var t=1;if("horizontal"==o.settings.mode&&o.settings.slideWidth>0)if(o.viewport.width()<o.minThreshold)t=o.settings.minSlides;else if(o.viewport.width()>o.maxThreshold)t=o.settings.maxSlides;else{var e=o.children.first().width();t=Math.floor(o.viewport.width()/e)}else"vertical"==o.settings.mode&&(t=o.settings.minSlides);return t},x=function(){var t=0;if(o.settings.moveSlides>0)if(o.settings.infiniteLoop)t=o.children.length/m();else for(var e=0,i=0;e<o.children.length;)++t,e=i+f(),i+=o.settings.moveSlides<=f()?o.settings.moveSlides:f();else t=Math.ceil(o.children.length/f());return t},m=function(){return o.settings.moveSlides>0&&o.settings.moveSlides<=f()?o.settings.moveSlides:f()},S=function(){if(o.children.length>o.settings.maxSlides&&o.active.last&&!o.settings.infiniteLoop){if("horizontal"==o.settings.mode){var t=o.children.last(),e=t.position();b(-(e.left-(o.viewport.width()-t.width())),"reset",0)}else if("vertical"==o.settings.mode){var i=o.children.length-o.settings.minSlides,e=o.children.eq(i).position();b(-e.top,"reset",0)}}else{var e=o.children.eq(o.active.index*m()).position();o.active.index==x()-1&&(o.active.last=!0),void 0!=e&&("horizontal"==o.settings.mode?b(-e.left,"reset",0):"vertical"==o.settings.mode&&b(-e.top,"reset",0))}}
13632,b=function(t,e,i,s){if(o.usingCSS){var n="vertical"==o.settings.mode?"translate3d(0, "+t+"px, 0)":"translate3d("+t+"px, 0, 0)";r.css("-"+o.cssPrefix+"-transition-duration",i/1e3+"s"),"slide"==e?(r.css(o.animProp,n),r.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){r.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),D()})):"reset"==e?r.css(o.animProp,n):"ticker"==e&&(r.css("-"+o.cssPrefix+"-transition-timing-function","linear"),r.css(o.animProp,n),r.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){r.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),b(s.resetValue,"reset",0),N()}))}else{var a={};a[o.animProp]=t,"slide"==e?r.animate(a,i,o.settings.easing,function(){D()}):"reset"==e?r.css(o.animProp,t):"ticker"==e&&r.animate(a,speed,"linear",function(){b(s.resetValue,"reset",0),N()})}},w=function(){for(var e="",i=x(),s=0;i>s;s++){var n="";o.settings.buildPager&&t.isFunction(o.settings.buildPager)?(n=o.settings.buildPager(s),o.pagerEl.addClass("bx-custom-pager")):(n=s+1,o.pagerEl.addClass("bx-default-pager")),e+='<div class="bx-pager-item"><a href="" data-slide-index="'+s+'" class="bx-pager-link">'+n+"</a></div>"}o.pagerEl.html(e)},T=function(){o.settings.pagerCustom?o.pagerEl=t(o.settings.pagerCustom):(o.pagerEl=t('<div class="bx-pager" />'),o.settings.pagerSelector?t(o.settings.pagerSelector).html(o.pagerEl):o.controls.el.addClass("bx-has-pager").append(o.pagerEl),w()),o.pagerEl.on("click","a",I)},C=function(){o.controls.next=t('<a class="bx-next" href="">'+o.settings.nextText+"</a>"),o.controls.prev=t('<a class="bx-prev" href="">'+o.settings.prevText+"</a>"),o.controls.next.bind("click",y),o.controls.prev.bind("click",z),o.settings.nextSelector&&t(o.settings.nextSelector).append(o.controls.next),o.settings.prevSelector&&t(o.settings.prevSelector).append(o.controls.prev),o.settings.nextSelector||o.settings.prevSelector||(o.controls.directionEl=t('<div class="bx-controls-direction" />'),o.controls.directionEl.append(o.controls.prev).append(o.controls.next),o.controls.el.addClass("bx-has-controls-direction").append(o.controls.directionEl))},E=function(){o.controls.start=t('<div class="bx-controls-auto-item"><a class="bx-start" href="">'+o.settings.startText+"</a></div>"),o.controls.stop=t('<div class="bx-controls-auto-item"><a class="bx-stop" href="">'+o.settings.stopText+"</a></div>"),o.controls.autoEl=t('<div class="bx-controls-auto" />'),o.controls.autoEl.on("click",".bx-start",k),o.controls.autoEl.on("click",".bx-stop",M),o.settings.autoControlsCombine?o.controls.autoEl.append(o.controls.start):o.controls.autoEl.append(o.controls.start).append(o.controls.stop),o.settings.autoControlsSelector?t(o.settings.autoControlsSelector).html(o.controls.autoEl):o.controls.el.addClass("bx-has-controls-auto").append(o.controls.autoEl),A(o.settings.autoStart?"stop":"start")},P=function(){o.children.each(function(){var e=t(this).find("img:first").attr("title");void 0!=e&&(""+e).length&&t(this).append('<div class="bx-caption"><span>'+e+"</span></div>")})},y=function(t){o.settings.auto&&r.stopAuto(),r.goToNextSlide(),t.preventDefault()},z=function(t){o.settings.auto&&r.stopAuto(),r.goToPrevSlide(),t.preventDefault()},k=function(t){r.startAuto(),t.preventDefault()},M=function(t){r.stopAuto(),t.preventDefault()},I=function(e){o.settings.auto&&r.stopAuto();var i=t(e.currentTarget),s=parseInt(i.attr("data-slide-index"));s!=o.active.index&&r.goToSlide(s),e.preventDefault()},q=function(e){var i=o.children.length;return"short"==o.settings.pagerType?(o.settings.maxSlides>1&&(i=Math.ceil(o.children.length/o.settings.maxSlides)),o.pagerEl.html(e+1+o.settings.pagerShortSeparator+i),void 0):(o.pagerEl.find("a").removeClass("active"),o.pagerEl.each(function(i,s){t(s).find("a").eq(e).addClass("active")}),void 0)},D=function(){if(o.settings.infiniteLoop){var t="";0==o.active.index?t=o.children.eq(0).position():o.active.index==x()-1&&o.carousel?t=o.children.eq((x()-1)*m()).position():o.active.index==o.children.length-1&&(t=o.children.eq(o.children.length-1).position()),t&&("horizontal"==o.settings.mode?b(-t.left,"reset",0):"vertical"==o.settings.mode&&b(-t.top,"reset",0))}o.working=!1,o.settings.onSlideAfter(o.children.eq(o.active.index),o.oldIndex,o.active.index)},A=function(t){o.settings.autoControlsCombine?o.controls.autoEl.html(o.controls[t]):(o.controls.autoEl.find("a").removeClass("active"),o.controls.autoEl.find("a:not(.bx-"+t+")").addClass("active"))},W=function(){1==x()?(o.controls.prev.addClass("disabled"),o.controls.next.addClass("disabled")):!o.settings.infiniteLoop&&o.settings.hideControlOnEnd&&(0==o.active.index?(o.controls.prev.addClass("disabled"),o.controls.next.removeClass("disabled")):o.active.index==x()-1?(o.controls.next.addClass("disabled"),o.controls.prev.removeClass("disabled")):(o.controls.prev.removeClass("disabled"),o.controls.next.removeClass("disabled")))},H=function(){o.settings.autoDelay>0?setTimeout(r.startAuto,o.settings.autoDelay):r.startAuto(),o.settings.autoHover&&r.hover(function(){o.interval&&(r.stopAuto(!0),o.autoPaused=!0)},function(){o.autoPaused&&(r.startAuto(!0),o.autoPaused=null)})},L=function(){var e=0;if("next"==o.settings.autoDirection)r.append(o.children.clone().addClass("bx-clone"));else{r.prepend(o.children.clone().addClass("bx-clone"));var i=o.children.first().position();e="horizontal"==o.settings.mode?-i.left:-i.top}b(e,"reset",0),o.settings.pager=!1,o.settings.controls=!1,o.settings.autoControls=!1,o.settings.tickerHover&&!o.usingCSS&&o.viewport.hover(function(){r.stop()},function(){var e=0;o.children.each(function(){e+="horizontal"==o.settings.mode?t(this).outerWidth(!0):t(this).outerHeight(!0)});
13632var i=o.settings.speed/e,s="horizontal"==o.settings.mode?"left":"top",n=i*(e-Math.abs(parseInt(r.css(s))));N(n)}),N()},N=function(t){speed=t?t:o.settings.speed;var e={left:0,top:0},i={left:0,top:0};"next"==o.settings.autoDirection?e=r.find(".bx-clone").first().position():i=o.children.first().position();var s="horizontal"==o.settings.mode?-e.left:-e.top,n="horizontal"==o.settings.mode?-i.left:-i.top,a={resetValue:n};b(s,"ticker",speed,a)},O=function(){o.touch={start:{x:0,y:0},end:{x:0,y:0}},o.viewport.bind("touchstart",X)},X=function(t){if(o.working)t.preventDefault();else{o.touch.originalPos=r.position();var e=t.originalEvent;o.touch.start.x=e.changedTouches[0].pageX,o.touch.start.y=e.changedTouches[0].pageY,o.viewport.bind("touchmove",Y),o.viewport.bind("touchend",V)}},Y=function(t){var e=t.originalEvent,i=Math.abs(e.changedTouches[0].pageX-o.touch.start.x),s=Math.abs(e.changedTouches[0].pageY-o.touch.start.y);if(3*i>s&&o.settings.preventDefaultSwipeX?t.preventDefault():3*s>i&&o.settings.preventDefaultSwipeY&&t.preventDefault(),"fade"!=o.settings.mode&&o.settings.oneToOneTouch){var n=0;if("horizontal"==o.settings.mode){var r=e.changedTouches[0].pageX-o.touch.start.x;n=o.touch.originalPos.left+r}else{var r=e.changedTouches[0].pageY-o.touch.start.y;n=o.touch.originalPos.top+r}b(n,"reset",0)}},V=function(t){o.viewport.unbind("touchmove",Y);var e=t.originalEvent,i=0;if(o.touch.end.x=e.changedTouches[0].pageX,o.touch.end.y=e.changedTouches[0].pageY,"fade"==o.settings.mode){var s=Math.abs(o.touch.start.x-o.touch.end.x);s>=o.settings.swipeThreshold&&(o.touch.start.x>o.touch.end.x?r.goToNextSlide():r.goToPrevSlide(),r.stopAuto())}else{var s=0;"horizontal"==o.settings.mode?(s=o.touch.end.x-o.touch.start.x,i=o.touch.originalPos.left):(s=o.touch.end.y-o.touch.start.y,i=o.touch.originalPos.top),!o.settings.infiniteLoop&&(0==o.active.index&&s>0||o.active.last&&0>s)?b(i,"reset",200):Math.abs(s)>=o.settings.swipeThreshold?(0>s?r.goToNextSlide():r.goToPrevSlide(),r.stopAuto()):b(i,"reset",200)}o.viewport.unbind("touchend",V)},Z=function(){var e=t(window).width(),i=t(window).height();(a!=e||l!=i)&&(a=e,l=i,r.redrawSlider(),o.settings.onSliderResize.call(r,o.active.index))};return r.goToSlide=function(e,i){if(!o.working&&o.active.index!=e)if(o.working=!0,o.oldIndex=o.active.index,o.active.index=0>e?x()-1:e>=x()?0:e,o.settings.onSlideBefore(o.children.eq(o.active.index),o.oldIndex,o.active.index),"next"==i?o.settings.onSlideNext(o.children.eq(o.active.index),o.oldIndex,o.active.index):"prev"==i&&o.settings.onSlidePrev(o.children.eq(o.active.index),o.oldIndex,o.active.index),o.active.last=o.active.index>=x()-1,o.settings.pager&&q(o.active.index),o.settings.controls&&W(),"fade"==o.settings.mode)o.settings.adaptiveHeight&&o.viewport.height()!=v()&&o.viewport.animate({height:v()},o.settings.adaptiveHeightSpeed),o.children.filter(":visible").fadeOut(o.settings.speed).css({zIndex:0}),o.children.eq(o.active.index).css("zIndex",o.settings.slideZIndex+1).fadeIn(o.settings.speed,function(){t(this).css("zIndex",o.settings.slideZIndex),D()});else{o.settings.adaptiveHeight&&o.viewport.height()!=v()&&o.viewport.animate({height:v()},o.settings.adaptiveHeightSpeed);var s=0,n={left:0,top:0};if(!o.settings.infiniteLoop&&o.carousel&&o.active.last)if("horizontal"==o.settings.mode){var a=o.children.eq(o.children.length-1);n=a.position(),s=o.viewport.width()-a.outerWidth()}else{var l=o.children.length-o.settings.minSlides;n=o.children.eq(l).position()}else if(o.carousel&&o.active.last&&"prev"==i){var d=1==o.settings.moveSlides?o.settings.maxSlides-m():(x()-1)*m()-(o.children.length-o.settings.maxSlides),a=r.children(".bx-clone").eq(d);n=a.position()}else if("next"==i&&0==o.active.index)n=r.find("> .bx-clone").eq(o.settings.maxSlides).position(),o.active.last=!1;else if(e>=0){var c=e*m();n=o.children.eq(c).position()}if("undefined"!=typeof n){var g="horizontal"==o.settings.mode?-(n.left-s):-n.top;b(g,"slide",o.settings.speed)}}},r.goToNextSlide=function(){if(o.settings.infiniteLoop||!o.active.last){var t=parseInt(o.active.index)+1;r.goToSlide(t,"next")}},r.goToPrevSlide=function(){if(o.settings.infiniteLoop||0!=o.active.index){var t=parseInt(o.active.index)-1;r.goToSlide(t,"prev")}},r.startAuto=function(t){o.interval||(o.interval=setInterval(function(){"next"==o.settings.autoDirection?r.goToNextSlide():r.goToPrevSlide()},o.settings.pause),o.settings.autoControls&&1!=t&&A("stop"))},r.stopAuto=function(t){o.interval&&(clearInterval(o.interval),o.interval=null,o.settings.autoControls&&1!=t&&A("start"))},r.getCurrentSlide=function(){return o.active.index},r.getCurrentSlideElement=function(){return o.children.eq(o.active.index)},r.getSlideCount=function(){return o.children.length},r.redrawSlider=function(){o.children.add(r.find(".bx-clone")).outerWidth(u()),o.viewport.css("height",v()),o.settings.ticker||S(),o.active.last&&(o.active.index=x()-1),o.active.index>=x()&&(o.active.last=!0),o.settings.pager&&!o.settings.pagerCustom&&(w(),q(o.active.index))},r.destroySlider=function(){o.initialized&&(o.initialized=!1,t(".bx-clone",this).remove(),o.children.each(function(){void 0!=t(this).data("origStyle")?t(this).attr("style",t(this).data("origStyle")):t(this).removeAttr("style")}),void 0!=t(this).data("origStyle")?this.attr("style",t(this).data("origStyle")):t(this).removeAttr("style"),t(this).unwrap().unwrap(),o.controls.el&&o.controls.el.remove(),o.controls.next&&o.controls.next.remove(),o.controls.prev&&o.controls.prev.remove(),o.pagerEl&&o.settings.controls&&o.pagerEl.remove(),t(".bx-caption",this).remove(),o.controls.autoEl&&o.controls.autoEl.remove(),clearInterval(o.interval),o.settings.responsive&&t(window).unbind("resize",Z))},r.reloadSlider=function(t){void 0!=t&&(n=t),r.destroySlider(),d()},d(),this}}(jQuery);; 13633 13634
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.