var S=Object.defineProperty;var f=(t,e,s)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var h=(t,e,s)=>f(t,typeof e!="symbol"?e+"":e,s);import{$ as c,bm as y,B as G,d as L,p as o,g,e as l}from"./DThBoNQI.js";const T=t=>{var r,n;const{props:e}=t,s=new G(e==null?void 0:e.start,e==null?void 0:e.count);return{params:{$pageIndex:s.pageIndex,$pageSize:s.pageSize,sportId:e.sport_id,featured:"extra"in e&&((r=e==null?void 0:e.extra)!=null&&r.featured)?e.extra.featured:void 0,writerId:"extra"in e&&((n=e==null?void 0:e.extra)!=null&&n.writer_id)?e.extra.writer_id:void 0},paginationHandler:s}},p=t=>t.storyId?`/api/v2/stories/${t.storyId}/next?sportId=${t.sportId}`:t.hidden?`/api/v2/Hidden/stories/${t.date}/${t.storySlug}?t=${Date.now()}`:`/api/v2/stories/${t.date}/${t.storySlug}`;class C{constructor(){h(this,"resource","/api/v2/stories")}async get(e){const{params:s,paginationHandler:r}=T(e),n=(e==null?void 0:e.customCdnIdentifier)??"",i=e.bucket??"",m=await c(this.resource,{params:s});if(!m)return[];try{const a=m.items.map(d=>y(d,n,i));return a!=null&&a.length?r.getData(a):[]}catch(a){return console.error("[StoryRepo] get() Mapping Failed",a),[]}}async getStoryContent({payload:e,fetch:s}){const r=p(e);return s(r,{onResponse:({response:n})=>{n.status===204&&(n._data=null)}}).then(n=>n||null).catch(n=>(console.error("[StoryRepo] getStoryContent() Request Failed",n),null))}async getStoryGames(e){try{const s=await c(`${this.resource}/${e.storyId}/games`);return s&&(s!=null&&s.length)?s:[]}catch(s){return console.error("Request Failed",s),[]}}async getStoryNextGame({payload:e,fetch:s}){return s(`${this.resource}/${e}/next-game`).then(r=>r).catch(r=>(console.error("[StoryRepo] getStoryNextGame() Request Failed",r),null))}async getSettings({fetch:e}){return e(`${this.resource}/settings`).then(s=>s).catch(s=>(console.error("[StoryRepo] getSettings() Request Failed",s),null))}}class x{constructor(){h(this,"url","/api/v2/Stats");h(this,"allowedSports",["baseball","basketball","field-hockey","football","hockey","lacrosse","softball","soccer","volleyball","wpolo"])}async get({payload:e,fetch:s}){return this.allowedSports.includes(e.sportShortName)?s(`${this.url}/${e.sportShortName}/game-leaders`,{params:{storyId:e.storyId}}).then(r=>r??[]).catch(r=>(console.error("[GameLeadersRepo] get() error",r),[])):(console.warn(`There is not endpoint for the sport's shortname given: ${e.sportShortName}`),[])}}class I{constructor(){h(this,"url","/api/v2/Stats")}async getGamesTeamsStats({payload:e,fetch:s}){return s(`${this.url}/${e.sport}/game-teams`,{params:{storyId:e.storyId,gameId:e.gameId}}).then(r=>r&&r.length?r:[]).catch(r=>(console.error("[GamesTeamsStatsRepo] getGamesTeamsStats() error",r),null))}}const u=()=>new C,w=()=>new x,$=()=>new I,F=L("story",{state:()=>({stories:{},isLoadingMore:{},isLoading:{},moreToLoad:{},storyContent:{},storyGames:{},isLoadingStoryGames:!1,storyGameLeaders:{},isLoadingStoryGameLeaders:!1,storyGamesTeamsStats:{},isLoadingStoryGamesTeamsStats:{},isStoryContentUnsafeHtml:{},storyNextGame:{},isLoadingStoryNextGame:!0,storyContentLoading:{},nextStory:null,storySettings:null,defaultSportTemplate:null,preloadedTemplates:{}}),actions:{async fetchStories(t){var e;if(!(t.hash in this.stories)){this.isLoading[t.hash]=!0;const s=g().bucket,r=((e=l().getGoogle360Settings)==null?void 0:e.customCdnIdentifier)??"",n={...t,customCdnIdentifier:r,bucket:s},i=await u().get(n);this.stories[t.hash]=i,t.hash in this.isLoading&&this.isLoading[t.hash]&&(this.isLoading[t.hash]=!1);const{props:m}=t;(!i||!i.length||m.count&&i.length{this.setPreloadedTemplate({url:a.url,type:a.type,contentTemplate:a.content_template})})}},async fetchMoreStories(t){var m;const e=g().bucket,s=((m=l().getGoogle360Settings)==null?void 0:m.customCdnIdentifier)??"",r={...t,customCdnIdentifier:s,bucket:e};this.isLoadingMore[t.hash]=!0;const n=await u().get(r);this.stories[t.hash]=[...this.stories[t.hash]??[],...n],this.isLoadingMore[t.hash]=!1;const{props:i}=t;(!n||!n.length||i.count&&n.length{this.setPreloadedTemplate({url:a.url,type:a.type,contentTemplate:a.content_template})})},async fetchStoryContent({payload:t,fetch:e}){const s=o(t);if(!(s in this.storyContent)){this.storyContentLoading[s]=!0;const r=await u().getStoryContent({payload:t,fetch:e});this.storyContent[s]=r,this.storyContentLoading[s]=!1}},async fetchStoryGames(t){const e=o(t);if(!(e in this.storyGames)){this.isLoadingStoryGames=!0;const s=await u().getStoryGames(t);this.storyGames[e]=s,this.isLoadingStoryGames=!1}},async fetchStoryGameLeaders({payload:t,fetch:e}){const s=o(t);if(!(s in this.storyGameLeaders)){this.isLoadingStoryGameLeaders=!0;const r=await w().get({payload:t,fetch:e});this.storyGameLeaders[s]=r,this.isLoadingStoryGameLeaders=!1}},async fetchStoryGamesTeamsStats({payload:t,fetch:e}){const s=o(t);if(!(s in this.storyGamesTeamsStats)){this.isLoadingStoryGamesTeamsStats[s]=!0;const r=await $().getGamesTeamsStats({payload:t,fetch:e});this.storyGamesTeamsStats[s]=r,this.isLoadingStoryGamesTeamsStats[s]=!1}},async fetchStoryNextGame({payload:t,fetch:e}){const s=o(t);if(!(s in this.storyNextGame)){this.isLoadingStoryNextGame=!0;const r=await u().getStoryNextGame({payload:t,fetch:e});this.storyNextGame[s]=r,this.isLoadingStoryNextGame=!1}},async fetchSettings({fetch:t}){if(!this.storySettings){const e=await u().getSettings({fetch:t});this.storySettings=e}},setNextStory(t){this.nextStory=t},setStoryBodyContent(t,e){var r;const s=o(t);s in this.storyContent&&((r=this.storyContent[s])!=null&&r.content)&&e&&(e!=null&&e.length)&&(this.storyContent[s].content=e)},setStoryIsUnsafeHtml(t,e){const s=o(t);this.isStoryContentUnsafeHtml[s]=e},setDefaultSportTemplate(t){(!this.defaultSportTemplate&&t||this.defaultSportTemplate&&!t||this.defaultSportTemplate!==t)&&(this.defaultSportTemplate=t)},setPreloadedTemplate(t){!(t.url in this.preloadedTemplates)&&t.contentTemplate&&(this.preloadedTemplates[t.url]={type:t.type,contentTemplate:t.contentTemplate})}},getters:{getStories:t=>e=>{const s=e;return s in t.stories&&t.stories[s]?t.stories[s]:[]},getLoadingMoreFlag:t=>e=>e in t.isLoadingMore?t.isLoadingMore[e]??!1:!1,getLoadingFlag:t=>e=>e in t.isLoading?t.isLoading[e]??!1:!1,getMoreToLoad:t=>e=>e in t.moreToLoad?t.moreToLoad[e]??!0:!0,getStoryContent:t=>e=>{const s=o(e);return s in t.storyContent?t.storyContent[s]??null:null},getContentLoadingFlag:t=>e=>{const s=o(e);return s in t.storyContentLoading?t.storyContentLoading[s]??!1:!1},getIsStoryContentUnsafeHtml:t=>e=>{const s=o(e);return s in t.isStoryContentUnsafeHtml?t.isStoryContentUnsafeHtml[s]??!1:!1},getStoryGames:t=>e=>{const s=o(e);return s in t.storyGames?t.storyGames[s]:[]},getLoadingFlagForStoryGameLeaders:t=>t.isLoadingStoryGameLeaders,getStoryGameLeaders:t=>e=>{const s=o(e);return s in t.storyGameLeaders?t.storyGameLeaders[s]:[]},getLoadingFlagForStoryGamesTeamsStats:t=>e=>{const s=o(e);return s in t.isLoadingStoryGamesTeamsStats?t.isLoadingStoryGamesTeamsStats[s]??!1:!1},getStoryGamesTeamsStats:t=>e=>{const s=o(e);return s in t.storyGamesTeamsStats?t.storyGamesTeamsStats[s]??null:null},getLoadingFlagForStoryNextGame:t=>t.isLoadingStoryNextGame,getStoryNextGame:t=>e=>{const s=o(e);return s in t.storyNextGame?t.storyNextGame[s]:null},getSettings(t){return t.storySettings},getNextStory(t){return t.nextStory},getDefaultSportTemplate(t){return t.defaultSportTemplate},getPreloadedTemplateByUrl:t=>e=>e in t.preloadedTemplates?t.preloadedTemplates[e]:null}});export{F as u};

AltStyle によって変換されたページ (->オリジナル) /