var OfficialShopLandingView=function(){var l,d,s,c,f,p,h,g,u=_.template("OFFICAL_SHOP_<%= catid %>_RECOMMEND<% if (catid==-2 || using_v2_recommendation_for_official_shop_cat){ %>_<%= userid %><% } %>"),w=_.template("OFFICAL_SHOP_BANNER_DATA_<%= catid %>_<%= userid %>");function A(e){f&&f.destroy(),p&&p.destroy(),s&&s.destroy(),c&&c.abort(),h&&h.destroy();var i,t,a,n,o=$(".page-tab[tabindex="+e+"]"),r=window.catid||o.attr("catid");r==Constants.OFFICAL_SHOP_POPULAR_CATID&&($(".official-shop-selling-points-wrapper").removeClass("hidden"),$(".official-shop-selling-points-wrapper").off("tap").on("tap",function(e){e.stopPropagation(),e.preventDefault(),bridgeInit(function(){bridgeCallHandler("navigate",{url:location.origin+"/user_selling_points/"},function(){})})})),o.find(".banner-section"),a=r,n=new BannersController,i="/api/banner/get_list?type=official_shop&category_id="+a,t=w({catid:a,userid:window.USERID}),n.init({clientRender:!0,api:i,CACHE_KEY:t,$container:$(".page-tab[catid="+a+"] .banner-container"),afterRenderCallback:function(e){}}),f=n,i=o.find(".official-shop-section"),t=r,a=new OfficialShopController,n=(parse_hash_general(location.href)||{}).init_position||0,t={display_type:"compact",callbackFunc:null,maxNumberOfRow:2,searchParams:{cat_id:t,limit:25,offset:0},$container:i.find(".official-shop-container"),$section:i,seeAllCallback:function(e,i){var t=window.APPVER||window.VERSION,a=null;(isIOS()&&21116<=t||isAndroid()&&21100<=t)&&(a={navbar:{title:toTitleCase(i18n.t("label_trending_shops")),navbarStyle:1,navbarBackgroundColor:"#D0011B",statusBarStyle:1}}),window.CONFIG_BRAND_LIST?((t=i.cat_id)==Constants.OFFICAL_SHOP_POPULAR_CATID&&(t=Constants.OFFICAL_SHOP_ALL_CATID),BJUtil.jumpToBrandlist(t,catname,0)):BJUtil.navigate("/trending-shops/?catid="+i.cat_id,null,null,a)},initPosition:n,trackingDfd:g},a.init(t),p=a,s=function(n,o,r){var l=u({catid:o,userid:window.USERID});o==Constants.OFFICAL_SHOP_POPULAR_CATID&&n.find(".shopee-section-header__title").text(i18n.t("label_just_for_you"));bridgeCallHandler("load",{key:l},function(e){var t=null;if(e.data)try{var i=JSON.parse(Base64.decode(e.data)),a=i.items?i:null,t=i.md5;s&&s.destroy(),s=m(n,o,a)}catch(e){t=null,console.error(e)}c=getJSON("/api/recommend/by_category",{catid:o,limit:60,offset:0,source:"home"},function(e){var i;e.md5!=t&&(i=e.items?e:null,bridgeCallHandler("save",{key:l,data:Base64.encode(JSON.stringify(e)),persist:1}),r==d&&(s&&s.destroy(),n.find(".item-list").empty(),s=m(n,o,i)))})})}(o.find(".recommend-section"),r,e)}function i(e){var i,t,a,n=e.data("gtab-index"),o=e.data("catid"),r=(window.need_web_header&&(r=e,i=Math.min(600,$(document).width()),$(".page-header").find(".header-items").animate({scrollLeft:r[0].offsetLeft+r.outerWidth()/2-i/2},500)),$(".header-items .header-item[data-gtab-index="+d+"]").removeClass("active"),$(".page-tab").replaceWith(l.clone()),$(".page-tab"));r.attr("catid",o),r.attr("tabindex",n),r.find(".item-list-container .item-list").removeClass(function(e,i){return(i.match(/(^|\s)recommend-section__item-list__\S+/g)||[]).join(" ")}).addClass("recommend-section__item-list__"+o),$(".page-tab[catid="+o+"] .loading-text").show(),e.addClass("active"),setTimeout(function(){A(n)},40),d=n,window.tabIndexForBI=n,window.catid=o,isShopeeApp()||window.using_mall_domain||(i=e.text().trim(),e=SeoUtil.getOfficialShopCategoryUrlSeo(i,o),t=parse_hash_general(location.href)||{},a=location.href.split("#")[0],delete(a=parse_get_params(a)||{}).catid,a.browser=1,o!=Constants.OFFICAL_SHOP_POPULAR_CATID&&delete t.init_position,history.replaceState({},"",generateHashUri(generateGetUri(e,a),t)),window.BJBridgeReceiver.triggerBridgeEvent("tabShow",{}))}function m(i,t,e){var a=new BatchItem;return runAfterDomReady(function(){a.options({apiUrl:"/",initialBatchLimit:60,displayBatchOverride:60,retryOnNetworkError:!0,skipAnimation:!0,onLoadCallback:function(e){$(".page-tab[catid="+t+"] .loading-text").hide(),a.markNoMore(),e.length%2&&e.splice(e.length-1,1)},root:"recommend-section__item-list__"+t,initialBatch:e,ROOT_BASIC_HEIGHT:0,hideOfficialShopLabel:window.OFFICIAL_SHOP_LANDING_PAGE_HIDE_OFFICIAL_SHOP_LABEL,funcOnTapItemCard:n}),a.loadData(null,function(e){(e=e||{}).total&&60<e.total&&(i.find(".shopee-section-header .label-see-all-wrapper").removeClass("hide").off("tap").on("tap",o(t,"link")),i.find(".recommend-section__btn-see-all").removeClass("hide").off("tap").on("tap",o(t,"button"))),0<e.total?i.removeClass("visibility-hidden ghost-hidden"):i.addClass("visibility-hidden ghost-hidden")})},isShopeeApp()&&isAndroid()?50:0),(h=new TrackScrollController).init(function(e,i,t){window.BI_ANALYTICS&&BI_ANALYTICS.trackGenericScroll(t,window.USERID,SEARCH_ENUM.PAGE_TYPE_ENUM.OFFICAL_SHOP_LANDING),ADS_TRACKING.collectAdsTracking(AdsTrackingOperationType.IMPRESSION,{items:i,list_type:SEARCH_ENUM.PAGE_TYPE_ENUM.OFFICAL_SHOP_LANDING})}),g.then(function(){h.addBatchItem(a)}),a}function n(e,i){e&&window.BI_ANALYTICS&&BI_ANALYTICS.trackGenericClick(convertItemDataForTracking(e),window.USERID,SEARCH_ENUM.PAGE_TYPE_ENUM.OFFICAL_SHOP_LANDING,null,null,null,i)}function o(t,a){return function(e){e.stopPropagation(),e.preventDefault();var e=window.APPVER||window.VERSION,i=null;(isIOS()&&21116<=e||isAndroid()&&21100<=e)&&(i={navbar:{navbarStyle:1,navbarBackgroundColor:"#D0011B",statusBarStyle:1}}),BJUtil.navigate(location.origin+window.CONFIG_OFFICIAL_SHOP_ROOT_URL+"/recommend/?catid="+t,null,null,i),window.BI_ANALYTICS&&BI_ANALYTICS.clickOfficialSeeMore(window.USERID,a)}}return{init:function(){h=c=d=l=null,g=$.Deferred(),function(){if(isShopeeApp()){var e=parse_all_params(location.href);if(e.search&&e.search.browser)return delete e.search.browser,e=generateUrlWithParams(location.origin+location.pathname,e),e=wrapUrlWithBridgeCMDNavigate(e),alert_message_with_loader(),BJUtil.navigate(e,!0,null,null,!0)}else bridgeCallHandler("configurePage",{navbar:getOfficialShopNavBar()},null);iOSRemoveBottomInset(),bridgeCallHandler("configureSearch",{searchConfig:{isGlobalSearch:!0}}),bridgeRegisterHandler("search",function(e,i){e&&""!=e.keyword&&null!=e.keyword&&""!=e.keyword.trim()&&(e={keyword:e.keyword,inPageReload:!1,nextPageInPageReload:!0,isOfficialShop:!0,source:e.source},BJUtil.jumpToSearch(e))}),bridgeRegisterHandler("onEventCallback",function(e,i){switch(e.key){case"nav_cart":bridgeCallHandler("login",{},function(e){1==e.status&&BJUtil.navigate(location.origin+"/buyer/cart/",null,null,{navbar:{title:i18n.t("title_shopping_cart"),rightItemsConfig:{items:[{type:"chat"}]}}})});break;case"nav_chat":bridgeCallHandler("navigateAppPath",{path:"chatList"})}}),function(i){{var e,t;!(isShopeeApp()&&isIOS()&&21400<getAppVersion())||(e=parse_hash_general(location.href)||{}).loaded?i.resolve():(BI_ANALYTICS.pauseSend(),e.loaded=!0,t=location.href.split("#")[0],t=generateHashUri(t,e),history.replaceState({},"",t))}bridgeRegisterHandler("tabShow",function(e){BI_ANALYTICS.resumeSend(),i.resolve(),BI_ANALYTICS.officialShopTabShow({tab_index:window.tabIndexForBI})}),bridgeRegisterHandler("tabHide",function(e){BI_ANALYTICS.pauseSend()})}(g),l=$(".page-tab").clone()}(),d=0,__ios_didAddOverflow__();var e=$(".header-items");__android_markNodeAsSwipeable__(e),window.need_web_header?(e=window.initial_tab_index,i($(".header-items .header-item[data-gtab-index="+e+"]")),$(".header-items .header-item").on("tap",function(e){i($(this))})):(A(0),window.catid=window.initial_catid),ADS_TRACKING.initAdsTracking(),window.using_mall_domain&&$(".header .ic_logo").on("tap",function(e){BJUtil.navigate(location.protocol+"//"+window.ROOT_DOMAIN,!0),e.stopPropagation(),e.preventDefault()})}}}();$(function(){bridgeInit(function(){OfficialShopLandingView.init()})}),window.brandListTabs=[];
//# sourceMappingURL=../../../source_maps/home/category/official_shop_landing.js.map
