"use strict";var _liveMenuIcon=require("../../../utils/icons/live-menu-icon");Component({properties:{module:{type:String,value:"toolbar"},sdkInstance:{type:Object,value:null},iconList:{type:Array,value:[]},useExternalDrawer:{type:Boolean,value:!1},hasExternalDrawerItems:{type:Boolean,value:!1}},data:{outerIconList:[],innerIconList:[],showMoreEntry:!1},observers:{"sdkInstance, module":function(){this.bindIconSourceSync()},"module, iconList, useExternalDrawer, hasExternalDrawerItems":function(){this.syncIconList()}},lifetimes:{detached:function(){this.unbindIconSourceSync()}},methods:{bindIconSourceSync:function(){var n=this;this.unbindIconSourceSync();var t=this.data.sdkInstance;if(t&&"player"===this.data.module){var e=t.store,o=function(){return n.syncIconSources()};this._unsubIconSources=e.get({liveInfo:o,"reportInfo.videoType":o,"notification.isNotificationOpen":o,"notification.isShowNotificationButton":o}),this.syncIconSources()}},unbindIconSourceSync:function(){"function"==typeof this._unsubIconSources&&this._unsubIconSources(),this._unsubIconSources=null},syncIconSources:function(){(0,_liveMenuIcon.syncLiveRoomBottomIconSourcesFromStore)(this.data.sdkInstance)},syncIconList:function(){var n=Array.isArray(this.data.iconList)?this.data.iconList:[];if("player"===this.data.module)return this.data.useExternalDrawer?void this.setData({outerIconList:n,innerIconList:[],showMoreEntry:this.data.useExternalDrawer&&this.data.hasExternalDrawerItems}):void this.setData({outerIconList:n.slice(0,1),innerIconList:n.slice(1),showMoreEntry:!1});this.setData({outerIconList:n,innerIconList:[],showMoreEntry:!1})},openDrawer:function(){var n,t;this.data.useExternalDrawer?this.triggerEvent("openmore",{module:this.data.module}):null===(n=this.selectComponent("#volc-landscape-more-button-drawer"))||void 0===n||null===(t=n.showFrame)||void 0===t||t.call(n)},onOuterIconTap:function(n){var t=this.findIconByKey(this.data.outerIconList,n.currentTarget.dataset.key);this.emitIconTap(t)},onInnerIconTap:function(n){this.tapInnerIconByKey(n.currentTarget.dataset.key)},tapInnerIconByKey:function(n){var t,e,o=this.findIconByKey(this.data.innerIconList,n);this.emitIconTap(o),this.data.useExternalDrawer||null===(t=this.selectComponent("#volc-landscape-more-button-drawer"))||void 0===t||null===(e=t.hideFrame)||void 0===e||e.call(t)},findIconByKey:function(n,t){return(Array.isArray(n)?n:[]).find(function(n){return n.key===t})},emitIconTap:function(n){null!=n&&n.key&&this.triggerEvent("tapicon",{icon:n,module:this.data.module})}}});