"use strict";var _constant=require("../../utils/constant");function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function ownKeys(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),e.push.apply(e,o)}return e}function _objectSpread(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?ownKeys(Object(e),!0).forEach(function(n){_defineProperty(t,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):ownKeys(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}return t}function _defineProperty(t,n,e){return(n=_toPropertyKey(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function _toPropertyKey(t){var n=_toPrimitive(t,"string");return"symbol"===_typeof(n)?n:String(n)}function _toPrimitive(t,n){if("object"!==_typeof(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var o=e.call(t,n||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}Component({properties:{sdkInstance:{type:Object,value:null},isPortrait:{type:Boolean,value:!1},themeColor:{type:Object,value:null}},data:{productMenus:[],activeTab:0,renderedProductTabMap:{0:!0},productDrawerReady:!1,drawerLightThemeColor:{FontColor:"#1D2129",BackFontColor:"#86909C",Fill_7:"#FFFFFF"}},observers:{activeTab:function(t){t<0||this.data.renderedProductTabMap[t]||this.setData(_defineProperty({},"renderedProductTabMap.".concat(t),!0))},sdkInstance:function(t){if(t){this.sdkInstance=t,this.store=t.store;var n=this;this.bindIconClick(),"function"==typeof this._unsub&&this._unsub(),this._unsub=null,this._unsub=this.store.get({liveInfo:function(t){if(null!=t&&t.Menus){var e=t.Menus,o=e.Menus,r=e.ProductV2,i=null==o?void 0:o.filter(function(t){if(t.Type===_constant.MENU_TYPE.ProductCard){var n=null==r?void 0:r[t.Index];if(n&&2!==n.DisplayEnable)return!0}return!1}).map(function(t){return _objectSpread(_objectSpread({},t),{},{title:t.Name})});if(JSON.stringify(n.data.productMenus)!==JSON.stringify(i)){var c={productMenus:i};i[n.data.activeTab]||(c.activeTab=0),n.setData(c),0===i.length&&n.hidePortraitProductCard()}}}})}}},lifetimes:{detached:function(){"function"==typeof this._unsub&&this._unsub(),this._unsub=null,this.unbindIconClick()}},methods:{showProductCardDrawer:function(){var t=this,n=function(){var n,e;return null===(n=t.selectComponent("#volc-dirawer-product-card-portrait"))||void 0===n||null===(e=n.showFrame)||void 0===e?void 0:e.call(n)};this.data.productDrawerReady?n():this.setData({productDrawerReady:!0},n)},hidePortraitProductCard:function(){var t,n;null===(t=this.selectComponent("#volc-dirawer-product-card-portrait"))||void 0===t||null===(n=t.hideFrame)||void 0===n||n.call(t,{silent:!0})},openShoppingCart:function(){var t;null===(t=this.sdkInstance)||void 0===t||t.emitEvent(this.sdkInstance.EVENTS.shopCart.click),this.showProductCardDrawer()},bindIconClick:function(){var t=this;this.sdkInstance&&this._iconClickSdk!==this.sdkInstance&&(this.unbindIconClick(),this._iconClickSdk=this.sdkInstance,this._onProductIconClick=function(n){var e;"SHOPPING"===(null==n||null===(e=n.icon)||void 0===e?void 0:e.key)&&t.openShoppingCart()},this.sdkInstance.on(_constant.EVENTS.PUBLIC.bottomIcon.click,this._onProductIconClick))},unbindIconClick:function(){this._iconClickSdk&&this._onProductIconClick&&this._iconClickSdk.off(_constant.EVENTS.PUBLIC.bottomIcon.click,this._onProductIconClick),this._iconClickSdk=null,this._onProductIconClick=null},onTabClick:function(t){var n=t.detail.index;this.setData({activeTab:n})},onChange:function(t){var n=t.detail.index;this.setData({activeTab:n})}}});