1import{_ as T,S as I,h as M,t as R,r as P,E as O,j as v,o as A,P as w,k as V,l as N,m as B,b as Y,d as F,u as j,e as U,s as K,F as $,a as J,g as z}from"./vze0IUE7.js";import{S as G}from"./CDsd8vOW.js";import{S as q}from"./BQc_klOp.js";import{d as y}from"./P0XhUxu4.js";import{ai as b,B as p,C as u,a2 as i,$ as h,a3 as d,K as g,W as m,I as L,J as k,a7 as E,M as H,X as D,H as x,S as W,Y as X}from"./C0zDc0yF.js";import"./CzApALvg.js";import"./Bxjs9Jb2.js";import"./DYhlJ-Pq.js";import"./C7j_Gpi4.js";import"./BSxJh2EE.js";import"./r1KXDZnt.js";const f=["match_for","match_not","match_abnormal","match_complete"],C="YYYY-MM-DD",Q=["week_1","week_2","week_3","week_4","week_5","week_6","week_7"],S=()=>Object.fromEntries(f.map(e=>[e,new Map])),Z=e=>{const t=Number(e?.match_time||0);return t<=0?"unknown":y(t*1e3).format(C)},ee=(e,t)=>{if(!e||e==="unknown")return"";const l=y(e,C);if(!l.isValid())return"";const n=Q[l.day()];return`${t(n)}, ${l.format("DD/MM/YYYY")}`},te=(e,t)=>{const l=new Map;return f.forEach(n=>{const o=e?.[n];o instanceof Map&&o.forEach((s,a)=>{const c=Z(s);l.has(c)||l.set(c,{key:c,label:ee(c,t),sortValue:c==="unknown"?Number.MAX_SAFE_INTEGER:y(c,C).valueOf(),matchListMap:S()}),l.get(c).matchListMap[n].set(a,s)})}),Array.from(l.values()).sort((n,o)=>n.sortValue-o.sortValue)},oe=(e,t,l)=>{const n=String(e?.event_id||"").trim();if(n)return n;const o=String(e?.event_name||"").trim();return o?`${o}_${String(e?.country_id||"").trim()}`:`${t}_${String(e?.match_id||l)}`},le=(e,t)=>{if(!Array.isArray(e)||e.length===0)return[];if(e.every(n=>Array.isArray(n?.list)))return e;const l=new Map;return e.forEach((n,o)=>{if(!n||typeof n!="object")return;const s=oe(n,t,o);l.has(s)||l.set(s,{country_logo:n.country_logo||"",country_id:n.country_id||"",country_name:n.country_name||"",event_id:n.event_id||"",event_logo:n.event_logo||"",event_name:n.event_name||"",list:[]}),l.get(s).list.push(n)}),Array.from(l.values())},se=e=>{const t={};return f.forEach(l=>{t[l]=le(e?.[l],l)}),t},ie=e=>{const t=[];return f.forEach(l=>{const n=e?.[l];Array.isArray(n)&&n.forEach(o=>{if(Array.isArray(o?.list)){t.push(...o.list);return}o&&typeof o=="object"&&t.push(o)})}),t},ne={name:"Collection",components:{ScheduleList:I,SportSelect:G,SortSelect:q},setup(){const e=j(),t=U();return{headRoute:e,...K(t)}},head(){const e=this.headRoute?.path||"",t=Y({fullPath:e}),l=F(e);return{title:l.title,meta:[{key:"description",name:"description",content:l.description},{key:"og:description",property:"og:description",content:l.description},{key:"og:title",property:"og:title",content:l.title},{key:"og:type",property:"og:type",content:"website"},{key:"og:url",property:"og:url",content:t},{key:"robots",name:"robots",content:"noindex, nofollow"}],link:[{rel:"canonical",href:t}]}},data(){return{deletePopupShow:!1,isDeletingCompletedCollect:!1,blockRouteLeaveUntil:0,sportType:1,showMobileSportSelect:!1,loading:!0,activeJumpId:null,initialScrollDone:!1,matchListMap:S(),sortSelectValue:1,runtimeEffects:B()}},watch:{sportType:{handler(e,t){this.initialScrollDone=!1,this.matchListMap=S(),this.syncRealtimeBrowseCountChannel(),this.getCollectList()},immediate:!0},sortSelectValue:{handler(e,t){this.getCollectList()}},searchPopupVisible(){this.searchPopupVisible||this.getCollectList()}},computed:{sportOptions(){return[{value:1,label:this.$t("community_group_tag_football"),icon:`${this.$cdnImg}schedule_football_icon.png`},{value:2,label:this.$t("community_group_tag_basketball"),icon:`${this.$cdnImg}schedule_basketball_icon.png`}]},currentSportOption(){return this.sportOptions.find(e=>e.value===this.sportType)||this.sportOptions[0]},currentSportLabel(){return this.currentSportOption.label},currentSportIcon(){return this.currentSportOption.icon},mobilePageTitle(){return this.$t("home_page_collect")},mobileCollectionDateGroups(){return!this.isMobile||this.loading?[]:te(this.matchListMap,this.$t.bind(this))},deletePopupIconSrc(){return this.isMobile?`${this.$mobileCdnImg||this.$cdnImg}collect_alert.png`:`${this.$cdnImg}collection_delete_popup_icon.png`}},methods:{clearCompletedCollectedMatches(){const e={};for(const[t,l]of Object.entries(this.matchListMap||{})){if(!(l instanceof Map)){e[t]=l;continue}const n=new Map;l.forEach((o,s)=>{Number(o?.match_status)!==3&&n.set(s,o)}),e[t]=n}this.matchListMap=e},getCollectList(e=!0){return this.getCollectListInternal(e)},getCollectListInternal(e=!0){return e&&(this.loading=!0),this.activeJumpId=null,this.$api.matchAPI.collectList({sport_id:this.sportType,sort:this.sortSelectValue}).then(t=>{const{code:l,data:n}=t;if(l===200){const o=se(n||{});let s=null,a=null,c=null;const _=ie(o);_?.length>0&&_.forEach(r=>{!a&&Number(r.match_status)===1&&(a=r.match_id),!c&&[2,5,6].includes(Number(r.match_status))&&(c=r.match_id)}),s=c||a,s&&(this.activeJumpId=s),this.matchListMap=N(o)}}).finally(()=>{this.loading=!1,this.handleScrollToMatch()})},handleScrollToMatch(){if(!this.initialScrollDone){if(!this.activeJumpId
1){window.scrollTo({top:0,behavior:"auto"});return}this.$nextTick(()=>{const e=this.$refs.collectionMain;if(!e){this.initialScrollDone=!0;return}const t=e.getBoundingClientRect().top+window.pageYOffset,l=window.innerHeight-t;if(e.scrollHeight<=l){window.scrollTo({top:0,behavior:"auto"}),this.initialScrollDone=!0;return}const n=document.getElementById(`schedule-item-${this.activeJumpId}`);if(n){const a=n.getBoundingClientRect().top+window.pageYOffset-64-36;window.scrollTo({top:a,behavior:"auto"}),this.initialScrollDone=!0}else this.initialScrollDone=!0})}},handleDeletePopup(){this.isDeletingCompletedCollect||(this.deletePopupShow=!0)},syncRealtimeBrowseCountChannel(){M.joinLeaveScore(`${this.sportType===2?2:1}`)},handleRealtimeOnlineCount(e){const{changed:t,nextMatchListMap:l}=V({matchListMap:this.matchListMap,socketData:e});t&&(this.matchListMap=l)},toggleMobileSportSelect(){this.showMobileSportSelect=!this.showMobileSportSelect},handleMobileSportChange(e){this.showMobileSportSelect=!1,e!==this.sportType&&(this.sportType=e)},handleBack(){if(!(this.deletePopupShow||this.isDeletingCompletedCollect)){if(window.history.length>1){this.$router.back();return}this.$router.push({path:"/"})}},handleClickOutside(e){if(!this.showMobileSportSelect)return;const t=this.$refs.mobileSportSelectRoot;t&&!t.contains(e.target)&&(this.showMobileSportSelect=!1)},async handleDelete(){if(!this.isDeletingCompletedCollect){this.isDeletingCompletedCollect=!0,this.blockRouteLeaveUntil=Date.now()+1500;try{const e=await this.$api.matchAPI.cancelCompleteCollect({sport_id:this.sportType});if(Number(e?.code)===200){this.deletePopupShow=!1,this.clearCompletedCollectedMatches(),await this.getCollectList(!1);return}v({message:e?.message||this.$t("reaction_action_failed"),type:"error"})}catch(e){const t=Number(e?.response?.data?.code||e?.code||0);if(t===401||t===403){this.deletePopupShow=!1,A({redirectParams:{path:(this._.provides[w]||this.$route).path,query:{...(this._.provides[w]||this.$route).query}},isOpenNew:!1});return}v({message:e?.response?.data?.message||e?.message||this.$t("reaction_action_failed"),type:"error"})}finally{this.isDeletingCompletedCollect=!1}}},handleCollect(e){const{currentKey:t,match_id:l}=e||{},n=this.matchListMap?.[t];if(!(n instanceof Map)||l==null)return;if(Number(e.is_collected)===0){if(!n.has(l))return;const s=new Map(n);s.delete(l),this.matchListMap={...this.matchListMap,[t]:s};return}const o=new Map(n);o.set(l,{...e,is_collected:1}),this.matchListMap={...this.matchListMap,[t]:o}}},beforeRouteLeave(){return!(this.deletePopupShow||this.isDeletingCompletedCollect||Date.now()<this.blockRouteLeaveUntil)},created(){this.runtimeEffects?.subscribe(P,"refreshRequest",this.getCollectList),this.runtimeEffects?.subscribe(O,"room.online.payload",this.handleRealtimeOnlineCount)},mounted(){R($.FAVORITE_SCREEN,{[J.SRC_SCREEN_ID]:z()}),this.runtimeEffects?.listen(document,"click",this.handleClickOutside),this.syncRealtimeBrowseCountChannel()},beforeUnmount(){M.joinLeaveScore(null),this.runtimeEffects?.dispose(),this.runtimeEffects=null}},re={key:0,class:"collection-mobile-shell"},ce={class:"collection-mobile-header"},ae={class:"collection-mobile-header__top"},pe={class:"collection-mobile-header__title"},he={class:"collection-mobile-sport-select",ref:"mobileSportSelectRoot"},ue=["aria-expanded"],de={class:"collection-mobile-sport-select__icon"},me=["src","alt"],_e={class:"collection-mobile-sport-select__label"},fe=["src"],be={key:0,class:"collection-mobile-sport-select__menu",role:"menu"},ge=["aria-checked","onClick"],Se=["src","alt"],ye={class:"collection-mobile-header__section"},Ce={class:"collection-mobile-header__section-title is-active"},Me=["aria-label"],ve=["src"],we={class:"collection-mobile-content"},Le={ref:"collectionMain",class:"collection-mobile-list"},ke={class:"date_type"},Ee={class:"collection-mobile-date-card"},De={key:1,class:"container"},Te={class:"select-type-sidebar"},Ie={class:"select-wrap"},Re={class:"sidebar-wrap"},Pe={class:"sidebar-item"},Oe={class:"collection-main"},Ae={class:"sort-delete-wrap"},Ve=["disabled","aria-label"],Ne=["src"],Be={ref:"collectionMain"}
1,Ye=["src"],Fe={class:"delete-popup-title"},je={class:"delete-popup-btn-wrap"};function Ue(e,t,l,n,o,s){const a=b("ScheduleList"),c=b("SportSelect"),_=b("SortSelect");return p(),u("div",{class:g(["collection-page",{"collection-page--mobile":e.isMobile}])},[e.isMobile?(p(),u("div",re,[i("div",ce,[i("div",ae,[i("button",{type:"button",class:"collection-mobile-header__back","aria-label":"Quay lại",onClick:t[0]||(t[0]=(...r)=>s.handleBack&&s.handleBack(...r))},[...t[10]||(t[10]=[i("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[i("path",{d:"M14.5 6L8.5 12L14.5 18",stroke:"currentColor","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),i("div",pe,h(s.mobilePageTitle),1),i("div",he,[i("button",{type:"button",class:"collection-mobile-sport-select__trigger","aria-expanded":o.showMobileSportSelect?"true":"false",onClick:t[1]||(t[1]=d((...r)=>s.toggleMobileSportSelect&&s.toggleMobileSportSelect(...r),["stop"]))},[i("span",de,[i("img",{src:s.currentSportIcon,alt:s.currentSportLabel},null,8,me)]),i("span",_e,h(s.currentSportLabel),1),i("img",{class:g(["collection-mobile-sport-select__arrow",{"is-open":o.showMobileSportSelect}]),src:`${e.$cdnImg}schedule_select_arrow_icon.png`,alt:""},null,10,fe)],8,ue),m(D,{name:"fade"},{default:L(()=>[o.showMobileSportSelect?(p(),u("div",be,[(p(!0),u(k,null,E(s.sportOptions,r=>(p(),u("button",{key:r.value,type:"button",class:g(["collection-mobile-sport-select__option",{active:r.value===o.sportType}]),role:"menuitemradio","aria-checked":r.value===o.sportType?"true":"false",onClick:d(Ke=>s.handleMobileSportChange(r.value),["stop"])},[i("img",{src:r.icon,alt:r.label},null,8,Se),i("span",null,h(r.label),1)],10,ge))),128))])):H("",!0)]),_:1})],512)]),i("div",ye,[i("div",Ce,[i("span",null,h(e.$t("collect_tab_name")),1),t[11]||(t[11]=i("div",{class:"borderLine"},null,-1))]),i("button",{type:"button",class:"collection-mobile-header__delete","aria-label":e.$t("dialog_favorite_show"),onClick:t[2]||(t[2]=d((...r)=>s.handleDeletePopup&&s.handleDeletePopup(...r),["stop","prevent"]))},[i("img",{class:"delete-icon",src:`${e.$cdnImg}collection_delete_icon.png`,alt:""},null,8,ve)],8,Me)])]),i("div",we,[i("div",Le,[s.mobileCollectionDateGroups.length>0?(p(!0),u(k,{key:0},E(s.mobileCollectionDateGroups,r=>(p(),u("section",{key:r.key,class:"collection-mobile-date-group"},[i("div",ke,[i("span",null,h(r.label),1)]),i("div",Ee,[m(a,{matchListMap:r.matchListMap,loading:o.loading,sportType:o.sportType,type:"collection","collect-handler":s.handleCollect,onCollect:s.handleCollect},null,8,["matchListMap","loading","sportType","collect-handler","onCollect"])])]))),128)):(p(),x(a,{key:1,matchListMap:o.matchListMap,loading:o.loading,sportType:o.sportType,type:"collection","collect-handler":s.handleCollect,onCollect:s.handleCollect},null,8,["matchListMap","loading","sportType","collect-handler","onCollect"]))],512)])])):(p(),u("div",De,[i("div",Te,[i("div",Ie,[m(c,{modelValue:o.sportType,"onUpdate:modelValue":t[3]||(t[3]=r=>o.sportType=r)},null,8,["modelValue"])]),i("div",Re,[i("div",Pe,h(e.$t("collect_tab_name")),1)])]),i("div",Oe,[i("div",Ae,[m(_,{modelValue:o.sortSelectValue,"onUpdate:modelValue":t[4]||(t[4]=r=>o.sortSelectValue=r)},null,8,["modelValue"]),i("button",{type:"button",class:"delete-icon-wrap",disabled:o.isDeletingCompletedCollect,"aria-label":e.$t("dialog_favorite_show"),onClick:t[5]||(t[5]=d((...r)=>s.handleDeletePopup&&s.handleDeletePopup(...r),["stop","prevent"]))},[i("img",{class:"delete-icon",src:`${e.$cdnImg}collection_delete_icon.png`,alt:""},null,8,Ne)],8,Ve)]),i("div",Be,[m(a,{matchListMap:o.matchListMap,loading:o.loading,sportType:o.sportType,type:"collection","collect-handler":s.handleCollect,onCollect:s.handleCollect},null,8,["matchListMap","loading","sportType","collect-handler","onCollect"])],512)])])),m(D,{name:"fade"},{default:L(()=>[W(i("div",{class:"delete-popup",onClick:t[9]||(t[9]=d(r=>o.deletePopupShow=!1,["self"]))},[i("div",{class:"delete-popup-content",onClick:t[8]||(t[8]=d(()=>{},["stop"]))},[i("img",{class:"delete-popup-icon",src:s.deletePopupIconSrc,alt:""},null,8,Ye),i("div",Fe,h(e.$t("dialog_favorite_show")),1),i("div",je,[i("button",{type:"button",class:"delete-popup-btn delete-popup-btn--cancel",onClick:t[6]||(t[6]=d(r=>o.deletePopupShow=!1,["stop","prevent"]))},h(e.$t("dialog_cancel")),1),i("button",{type:"button",class:"delete-popup-btn delete-popup-btn--confirm",onClick:t[7]||(t[7]=d((...r)=>s.handleDelete&&s.handleDelete(...r),["stop","prevent"]))},h(e.$t("common_confirm")),1)])])],512),[[X,o.deletePopupShow]])]),_:1})],2)}const et=T(ne,[["render",Ue],["__scopeId","data-v-344efc27"]]);export{et as default};
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.