/*! - @omni-frontend/favourite-integrator : 1.0.2 */
import e from'/.js-modules/en_NZ/@omni-frontend/webcomponent-register.cf01c842599a2580.js';import{h as t,hooks as i,Fragment as o}from'/.js-modules/en_NZ/@lottoland/core/preact.2f252e2bd093fcd3.js';import{subscribe as r,unsubscribe as a,publish as n}from'/.js-modules/en_NZ/@lottoland/client-side-message-bus.38e33416b1525af0.js';import{resources as s,messages as m}from'/.js-modules/en_NZ/@lottoland/lsl.c0eeded8dcfe07af.js';import l from'/.js-modules/en_NZ/@omni-data/game-config.175f71c95444d6e3.js';import c from'/.js-modules/en_NZ/@omni-data/category.a46e85338af8f8a3.js';import d from'/.js-modules/en_NZ/@omni-data/overview-categories.5af6f77877b44f74.js';import g from'/.translations/en_NZ/games_gameName.d91810b98ef6f186.js';var h;!function(e){e.LOGIN='LOGIN',e.LOGOUT='LOGOUT'}(h||(h={}));const{useState:E,useEffect:u}=i;const p={logger:{error:console.log,warn:console.log},authentication:{open:e=>console.log(e),close:()=>{}},games:{getGameUrl:e=>console.log(e)},helper:{cookie:{get:()=>{}}}},I=window.dla||p;var f,G,A,_,D,O,C,T,R,y,S,F,v,N,w,P,U,k;!function(e){e[e.Ok=200]='Ok',e[e.NoContent=204]='NoContent',e[e.NotFound=404]='NotFound',e[e.Error=500]='Error'}(f||(f={})),function(e){e.True='true',e.False='false'}(G||(G={})),function(e){e.loaded='loaded'}(A||(A={})),function(e){e.REGISTERED='registered',e.NOPROMOTION='nopromotion',e.SESSION_EXPIRED='session_expired',e.PROBLEM='problem',e.EXPIRED='expired'}(_||(_={})),function(e){e.INIT='init',e.ROUTE_CHANGED='routeChanged',e.CLEAR='clear',e.SAVE='save',e.QUICKIE='quickie',e.JACKPOT_CHANGED='jackpotChanged',e.BET_AGAIN='betAgain',e.TOP_UP='topUp',e.AUTHENTICATE='authenticate',e.LOGOUT='logout',e.REFRESH_PLAYER='refreshPlayer',e.CHANGE_ROUTE='changeRoute',e.RECOVER_FROM_ERROR='recoverFromError',e.RESIZED='resized',e.TRACKING='tracking',e.LOGIN='login',e.DO_LOGOUT='doLogout',e.BACK_TO_SELECTION='backToSelection',e.CONTINUE_PURCHASING='continuePurchasing',e.PURCHASE_TICKET='purchaseTicket',e.PLAY_TICKET_AGAIN='playTicketAgain',e.NAVIGATE='navigate'}(D||(D={})),function(e){e.LIVE_DRAW='liveDraw',e.CLASSIC='classic',e.JACKPOT='jackpot',e.SIDE_BET='sideBet',e.RESULTS='results',e.MY_BETS='myBets'}(O||(O={})),function(e){e.QUICK_DEPOSIT_REQUIRED='QuickDepositRequired',e.DEPOSIT_SUCCESSFUL='DepositSuccessful',e.QUICK_DEPOSIT_DISMISSED='QuickDepositDismissed'}(C||(C={})),function(e){e.AUTH_REQUESTED='AuthRequested',e.LOGOUT_REQUESTED='LogoutRequested',e.LOGGED_IN='LoggedIn'}(T||(T={})),function(e){e.GAME_END='scratchcard.gameEnd',e.GO_TO_OVERVIEW='scratchcard.goToOverview',e.GO_TO_SHOPPING_CAR='scratchcard.goToShoppingCart',e.TRACK='scratchcard.track'}(R||(R={})),function(e){e.RESIZE='scratchcard.resize'}(y||(y={})),function(e){e.DID_INIT='GamesKenoGoDidInit',e.DID_BET_AGAIN='GamesKenoGoDidBetAgain',e.DID_CHANGE_ROUTE='GamesKenoGoDidChangeRoute',e.DID_CLEAR='GamesKenoGoDidClear',e.DID_JACKPOT_CHANGED='GamesKenoGoDidJackpotChanged',e.DID_QUICKIE='GamesKenoGoDidQuickie',e.DID_REFRESH_PLAYER='GamesKenoGoDidRefreshPlayer',e.DID_ROUTE_CHANGED='GamesKenoGoDidRouteChanged',e.DID_SAVE='GamesKenoGoDidSave',e.DID_RECOVER_FROM_ERROR='GamesKenoGoDidRecoverFromError',e.DID_RESIZED='GamesKenoGoDidResized',e.DID_PLAY_TICKET_AGAIN='GamesKenoGoDidPlayTicketAgain',e.DID_NAVIGATE='GamesDidNavigate',e.DID_PURCHASE_TICKET='GamesDidClickPurchaseTicketButton',e.DID_CONTINUE_PURCHASING='GamesDidClickContinuePurchasing'}(S||(S={})),function(e){e.TRACKING_CLICK='TrackingClick'}(F||(F={})),function(e){e.ADD='add',e.REMOVE='remove'}(v||(v={})),function(e){e.SHOW_FAVOURITE_TOAST='omniShowFavToast',e.FAVOURITE_DATA='omniFavData',e.FAVOURITE_GAME_WAS_ADDED='omniFavAdd_',e.FAVOURITE_GAME_WAS_REMOVED='omniFavRemove_',e.UNDO_FAVOURITE='omniUndoFavToast',e.FAVOURITE_GAMES_UPDATE='omniFavGamesUpdate',e.GAME_PAGE_REMOVAL_IOS_APP='omniGamePageRemovalForIOSApp'}(N||(N={})),function(e){e.DID_INIT='GamesDidInit',e.DID_CHANGE_ROUTE='GamesDidChangeRoute',e.DID_REFRESH_PLAYER='GamesDidRefreshPlayer',e.DID_ROUTE_CHANGED='GamesDidRouteChanged',e.DID_RECOVER_FROM_ERROR='GamesDidRecoverFromError',e.DID_RESIZED='GamesDidResized',e.DID_PLAY_TICKET_AGAIN='GamesDidPlayTicketAgain',e.DID_NAVIGATE='GamesDidNavigate'}(w||(w={})),function(e){e.INIT='init',e.ROUTE_CHANGED='routeChanged',e.AUTHENTICATE='authenticate',e.LOGOUT='logout',e.REFRESH_PLAYER='refreshPlayer',e.CHANGE_ROUTE='changeRoute',e.RECOVER_FROM_ERROR='recoverFromError',e.RESIZED='resized',e.TRACKING='tracking',e.LOGIN='login',e.DO_LOGOUT='doLogout',e.PURCHASE_TICKET='purchaseTicket',e.PLAY_TICKET_AGAIN='playTicketAgain',e.NAVIGATE='navigate'}(P||(P={})),function(e){e.OSS_POST_MESSAGE='OSS_POST_MESSAGE',e.PLAYNGO_POST_MESSAGE='PLAYNGO_POST_MESSAGE'}(U||(U={})),function(e){e.freeBetReload='freeBetReload'}(k||(k={}));const L={method:'GET',headers:{Accept:'application/json','Content-Type':'application/json'}},M=(e,t,i)=>fetch(e,{...L,...t}).then((e=>((e,t)=>{if(!e.ok)throw I.logger.error(`OMNI FE - MakeRequest error: ${e.statusText}`),Error(e.statusText);return t?e.text():e.json()})(e,i))).catch((e=>e)),V=768,K=()=>!!window.screen.orientation&&!!screen.orientation.angle,H=()=>window.Cypress?!K()&&window.innerWidth<V||K()&&window.innerHeight<V:!K()&&window.screen.width<V||K()&&window.screen.height<V,b=()=>!!s.playerNr,B=e=>{if(e&&(e=>!e.hideForLoggedOutUsers||b())(e)){const t=x(e);if(t&&(e=>H()?!e.noMob:!e.noDesk)(t))return!0}return!1},x=e=>e.currencyData[s.currency]||null;var $;!function(e){e.KENO_OPERATOR_TOKEN='kenoOpToken'}($||($={}));const Y='omniFavourite',W=e=>{const t=(e=>{try{return window.sessionStorage.getItem(e)}catch(e){return null}})(z(Y,e));try{return t?JSON.parse(t):[]}catch(e){return console.warn('Error while parsing favourite games cache: ',e),[]}},Q=(e,t)=>{((e,t)=>{try{const i='string'==typeof t?t:JSON.stringify(t);window.sessionStorage.setItem(e,i)}catch(e){}})(z(Y,t),e)},z=(e=Y,t)=>`${e}-${t||'default'}`;var j,J,q,Z,X;!function(e){e.Eager='eager',e.Lazy='lazy',e.Observer='observer'}(j||(j={})),function(e){e.Grid='grid',e.List='list'}(J||(J={})),function(e){e.Show='show',e.Hide='hide'}(q||(q={})),function(e){e.ShownAndFiltered='shown-and-filtered',e.ShownAndToFilter='shown-and-to-filter',e.HiddenAndFiltered='hidden-and-filtered',e.HiddenAndToFilter='hidden-and-to-filter'}(Z||(Z={})),function(e){e.Popularity='POPULARITY',e.Name='NAME',e.NameDescending='NAME_DESCENDING',e.StakeMinToMax='STAKE_MIN_TO_MAX',e.StakeMaxToMin='STAKE_MAX_TO_MIN',e.Favourite='FAVOURITE'}(X||(X={}));class ee{constructor(e,t){this.filter=e=>{for(let t=0;t<e.length;t++)if(e[t].categoryId===this.categoryId)return e[t].games;return[]},this.getCategoryId=()=>this.categoryId,this.getOverwrittenCatGames=()=>this.overwrittenCatGames,this.categoryId=e,this.overwrittenCatGames=t}}class te{constructor(){this.filter=e=>{const t=[];for(let i=0;i<e.length;i++)for(let o=0;o<e[i].games.length;o++)t.push(e[i].games[o]);return t},this.getCategoryId=()=>'',this.getOverwrittenCatGames=()=>{}}}const ie=(e,t)=>{const i=oe(e,t);return 0===i?0:-i},oe=(e,t)=>(e.minimumStake||0)<(t.minimumStake||0)?-1:(e.minimumStake||0)>(t.minimumStake||0)?1:0,re=(e,t)=>{const i=(e.translatedName||e.gameConfig.name).toUpperCase(),o=(t.translatedName||t.gameConfig.name).toUpperCase();return i<o?-1:i>o?1:0},ae=(e,t)=>e.popularityIndex<t.popularityIndex?-1:e.popularityIndex>t.popularityIndex?1:0,ne=(e,t)=>e.timestamp<t.timestamp?-1:e.timestamp>t.timestamp?1:0,se=e=>((e,t,i,...o)=>m.hasMessageKey(e,t)&&''!==m.getMessage(e,t)?m.getMessage(e,t,...o):'!'+i+t+'!')(g,e,'games_gameName_');class me{constructor(e,t){this.filters=[],this.games=[],this.parsedGames={},this.filterAndParseByCurrencyData=e=>e.reduce(((e,t,i)=>{if(B(t)){const o=x(t);e.push({gameConfig:t,minimumStake:o&&o.minimumStake?o.minimumStake:0,translatedName:se(t.name),popularityIndex:i})}return e}),[]),this.getCurrentCategoryParsedGames=()=>this.categoryFilter?this.parsedGames[this.categoryFilter.getCategoryId()]:[],this.filterCategories=e=>(this.applyCategoryFilter(e),this.removeFilters()),this.filterGames=e=>{let t=!1;for(let i=0;i<this.filters.length;i++)if(this.filters[i].typeName()===e.typeName()){this.filters[i]=e,t=!0;break}return t||this.filters.push(e),this.applyFilters()},this.removeFilter=e=>{const t=[];for(let i=0;i<this.filters.length;i++)this.filters[i].typeName()!==e.typeName()&&t.push(this.filters[i]);return this.filters=t,this.applyFilters()},this.removeFilters=()=>(this.filters=[],this.applyFilters()),this.removeCategoryFilter=()=>(this.categoryFilter=new te,this.filterCategories(this.categoryFilter)),this.resetFilters=()=>(this.removeCategoryFilter(),this.removeFilters()),this.sort=e=>{if(!this.categoryFilter||0===this.games.length)return[];this.normaliseGamesData();const t=this.categoryFilter.getCategoryId(),i=this.parsedGames[t];return e===X.Popularity?this.parsedGames[t]=i.sort(ae):e===X.Name?this.parsedGames[t]=i.sort(re):e===X.NameDescending?this.parsedGames[t]=i.sort(re).reverse():e===X.StakeMaxToMin?this.parsedGames[t]=i.sort(ie):e===X.Favourite?this.parsedGames[t]=i.sort(ne):this.parsedGames[t]=i.sort(oe),this.applyFilters()},this.extractProviders=()=>{const e=this.getCurrentCategoryParsedGames().map((e=>e.gameConfig.provider||[]));return new Set(e.reduce(((e,t)=>e.concat(t)),[]))},this.getGamesFromGamesConfigs=e=>this.filterAndParseByCurrencyData(e),this.addGamesToCategory=(e,t)=>{if(!this.categoryFilter)return;this.parsedGames[e]=t;if(this.categoryFilter.getCategoryId()===e){this.games=t;const i=this.categories.findIndex((t=>t.categoryId===e));if(i>-1){const e=t.map((e=>e.gameConfig.name));this.categories[i].games=e}}},this.changeGamesPosition=(e,t)=>{if(!this.categoryFilter||0===this.games.length)return;const i=this.categoryFilter.getCategoryId(),o=[...this.parsedGames[i]],r=o.findIndex((t=>t.gameConfig.name===e)),a=o.splice(r,1)[0];a&&o.splice(t,0,a);const n=Date.now();o.forEach(((e,t)=>e.timestamp=n+t)),this.games=o,this.parsedGames[i]=o},this.normaliseGamesData=()=>{0===this.games.length&&this.categoryFilter&&this.applyCategoryFilter(this.categoryFilter)},this.applyFilters=()=>{this.games=this.getCurrentCategoryParsedGames();for(let e=0;e<this.filters.length;e++)this.games=this.filters[e].filter(this.games);return this.games},this.applyCategoryFilter=e=>{const t=this.filterAndParseByCurrencyData(this.getCategoryGames(e));return this.parsedGames[e.getCategoryId()]=t,this.categoryFilter=e,this.games=t,t},this.getCategoryGames=e=>this.mapGameConfigs(e.getOverwrittenCatGames()||e.filter(this.categories)),this.mapGameConfigs=e=>e.map((e=>this.gameConfigs[e])).filter((e=>!!e)),this.checkIfGameIncludedInCategory=(e,t)=>{const i=new ee(e);return this.getCategoryGames(i).map((e=>e.name)).includes(t)},this.categories=e,this.gameConfigs=t}}var le;!function(e){e.ViewSwitched='omni.view.switched',e.FilterSwitched='omni.filter.switched',e.SortFilter='omni.sortFilter',e.NoFilteredGames='omni.noFilteredGames',e.ProviderFilter='omni.providerFilter',e.MinStakeFilter='omni.minStakeFilter',e.VolatilityFilter='omni.volatilityFilter',e.VolatilityFilterDeferred='omni.volatilityFilter.deferred',e.FilterApplied='omni.filter.applied',e.ApplyFilter='omni.applyFilter.button',e.FilterPanelInnerEvent='omni.filterPanelInner.event',e.LocalVersionsChecked='local.versions.checked',e.RemoteServerChecked='remote.server.checked',e.RemoteServerUnchecked='remote.server.unchecked',e.RemoteDeploymentComplete='remote.deployment.complete',e.RemoteDeploymentIncomplete='remote.deployment.incomplete',e.SmokeTestIncomplete='smoke.test.incomplete',e.SmokeTestComplete='smoke.test.complete',e.RenderCompleted='omni.render.complete',e.Load='load',e.FilterReset='omni.filter.reset',e.ContinuePlayingGamesLoad='omni.continueplaying.games.load',e.CategoryUpdated='omni.category.updated',e.PodPlayNavigation='OmniPodPlayNavigation',e.OpenGameInfoModal='OmniOpenGameInfoModal',e.CloseGameInfoModal='OmniCloseGameInfoModal',e.GameInfoModalEnabled='OmniGameInfoModalEnabled',e.GameInfoModalShadow='OmniGameInfoModalShadow',e.OmniRefreshBalance='OmniRefreshBalance',e.OmniSportsBookNavEvent='OmniSportsBookNavEvent'}(le||(le={}));const ce=(e,t,i)=>{const o=new CustomEvent(e,t);i?i.dispatchEvent(o):window.dispatchEvent(o)},de=(e,t)=>{window.addEventListener(e,t)},ge=(e,t)=>{window.removeEventListener(e,t)};var he;window&&(window.omni=window.omni||{},window.omni.events={publish:ce,subscribe:de,unsubscribe:ge}),function(e){e.FULL='FULL',e.OVERVIEW='OVERVIEW'}(he||(he={}));const Ee={[he.FULL]:c,[he.OVERVIEW]:d};let ue;const pe=e=>{const t=new me(Ee[e],l);return ue[e]=t,t},Ie=(e,t)=>e.reduce(((e,i)=>{const o=t?t(i):(e=>{const t=l[e];return B(t)?t:null})(i);return o&&e.push(o),e}),[]),fe=e=>{const t=Ie(e);return((e=he.FULL)=>{const t=b();return ue&&ue.loggedIn===t||(ue={loggedIn:t}),ue[e]||pe(e)})().getGamesFromGamesConfigs(t)},Ge=(e,t)=>{const i=((e,t)=>{if(e.includes('?'))return e.split('?').join(`?_=${t}&`);return`${e}?_=${t}`})(`${e}/${t}`,Date.now());return((e,t)=>M(e,{...t,method:'GET'}))(i).then((e=>{const{favourites:i}=e,o=i&&Array.isArray(i)?i:[];return Q(o,t),o})).catch((e=>(console.warn('Favourite games problem:'+e),[])))},Ae=(e,t)=>{const i=new Promise((e=>{setTimeout((()=>e('timeout of 3000 ms')),3e3)}));return Promise.race([Ge(e,t),i]).then((e=>t=>{if('string'==typeof t){const i=`OMNI FE - getFavouriteGamesOrCache: Show default category after ${t}. \n        For playerId=${e}. Using cached games`;return I.logger.warn(i),W(e)}return t})(t)).then((e=>e&&e.length?fe(e):[]))},{useEffect:_e}=i;var De=function(e){const i=e;let o,n;const s=e=>{o=r('LoggedIn',e),n=r('PlayerLoggedIn',e)},m=()=>{o&&a(o),n&&a(n)};return e=>{const[o,r]=E(null),[a,n]=E(!1),l=(e,t)=>{const{payload:i}=t;r({userData:i,authEventType:i.playerId?h.LOGIN:h.LOGOUT})};return u((()=>{a&&!o&&(s(l),n(!1))}),[a,o]),u((()=>(s(l),()=>{m()})),[]),t(i,{...e,...o,reloadAuthSubscriptions:()=>{m(),r(null),n(!0)}},e.children)}}((({favouritepageurl:e,favouritesurl:i,userData:r})=>(_e((()=>{n(N.FAVOURITE_DATA,{payload:{favouritePageUrl:e,favouritesUrl:i}},{sticky:!0})}),[]),_e((()=>{r?.playerId&&((e,t)=>{const i=W(t);Ae(e,t).then((e=>{const o=W(t),r=o.filter((e=>!i.includes(e))),a=i.filter((e=>!o.includes(e)));for(const e of r)n(`${N.FAVOURITE_GAME_WAS_ADDED}${e}`,{payload:{gameId:e}});for(const e of a)n(`${N.FAVOURITE_GAME_WAS_REMOVED}${e}`,{payload:{gameId:e}});const s=o.every(((e,t)=>e===i[t]));(r.length||a.length||!s)&&n(N.FAVOURITE_GAMES_UPDATE,{payload:{games:e}})}))})(i,r.playerId)}),[r]),t(o,null))));var Oe,Ce;Oe='FavouriteIntegrator',Ce='1.0.2',window.omni=window.omni||{},window.omni.packages||(window.omni.packages=[]),window.omni.packages.push({package:Oe,version:Ce});var Te;Te='omni-favourite-integrator',void 0===customElements.get(Te)&&e(De,'omni-favourite-integrator',!1,{shadow:!De.noShadowRoot},'')
/*! https://www.lottolandcorporate.com/careers */;
//# sourceMappingURL=index.js.map
