import{o as e}from"./chunk-mlkTr37E.js";import{t}from"./_plugin-vue2_normalizer-BHc2Ljhs.js";import{t as n}from"./slugify-CO19mam7.js";import{n as r}from"./category-8OJXPMDc.js";var i=e(n()),a=t({name:`TiktokCategoryTree`,data(){return{flatData:[],fullTreeData:[],displayedTreeData:[],searchText:``,checkedKeys:[],matchedKeys:[]}},methods:{buildTree(e){let t={};e.forEach(e=>{t[e.id]={key:e.id,category_id:e.id,title:e.local_display_name,name:e.local_display_name,slug:(0,i.default)(e.local_display_name,{lower:!0,trim:!0,locale:`vi`}),isLeaf:e.is_leaf,image:e.image||null,children:[]}});let n=[];return e.forEach(e=>{let r=t[e.id];if(e.parent_id===`0`||e.parent_id===0||e.parent_id===null)n.push(r);else{let n=t[e.parent_id];n&&n.children.push(r)}}),n},searchTreeForHighlight(e,t,n=[]){return e.forEach(e=>{e.title.toLowerCase().includes(t.toLowerCase())&&n.push(e.category_id),e.children&&e.children.length&&this.searchTreeForHighlight(e.children,t,n)}),n},filterTree(e,t){let n=[];return e.forEach(e=>{let r=e.title.toLowerCase().includes(t.toLowerCase()),i=[];e.children&&e.children.length&&(i=this.filterTree(e.children,t)),r?n.push({...e,children:e.children}):i.length&&n.push({...e,children:i})}),n},onSearch(){let e=this.searchText.trim();e?(this.matchedKeys=this.searchTreeForHighlight(this.fullTreeData,e,[]),this.displayedTreeData=this.filterTree(this.fullTreeData,e)):(this.matchedKeys=[],this.displayedTreeData=this.fullTreeData)},renderContent(e,{data:t}){let{category_id:n,slug:r}=t,i=this.matchedKeys.includes(n),a=t.image,o=this.getRouterUrl(`/tiktok/spy/category/${n}`),s=`https://shop-vn.tiktok.com/c/${r}/${n}`,c=i?{color:`#f90`,fontWeight:`bold`}:{};return e(`div`,{style:{display:`flex`,alignItems:`center`}},[a&&e(`img`,{attrs:{src:a},style:{width:`24px`,height:`24px`,marginRight:`8px`,borderRadius:`4px`,objectFit:`cover`}}),e(`a`,{attrs:{href:s,target:`_blank`},style:{textDecoration:`none`,color:`#515a6e`,...c}},t.title),e(`a`,{attrs:{href:o,target:`_blank`},style:{marginLeft:`5px`}},this.$t(`SPY_BTN`))])}},created(){this.flatData=r(),this.fullTreeData=this.buildTree(this.flatData),this.displayedTreeData=this.fullTreeData}},function(){var e=this,t=e._self._c;return t(`div`,[t(`Input`,{staticStyle:{"margin-bottom":`16px`},attrs:{placeholder:e.$t(`SEARCH_CATEOGRY_NAME`),clearable:``},on:{"on-change":e.onSearch},model:{value:e.searchText,callback:function(t){e.searchText=t},expression:`searchText`}}),t(`Tree`,{attrs:{data:e.displayedTreeData,"show-checkbox":!1,"highlight-current":!1,render:e.renderContent,"default-expand-all":!0,"checked-keys":e.checkedKeys},on:{"update:checkedKeys":function(t){e.checkedKeys=t},"update:checked-keys":function(t){e.checkedKeys=t}}})],1)},[],!1,null,`75534c69`,null,null).exports,o=t({name:`ShopeeSpyMarket`,components:{"category-tree":a}},function(){var e=this._self._c;return e(`div`,[e(`Row`,[e(`Col`,{attrs:{span:12,offset:6}},[e(`category-tree`)],1)],1)],1)},[],!1,null,null,null,null).exports;export{o as default};