const queryString=window.location.search,parameters=new URLSearchParams(queryString),app_id=parameters.get("game"),GetRequest=e=>new Promise(((t,n)=>{fetch(e,{method:"GET",mode:"cors"}).then((e=>{e.status>=200&&e.status<=299?e.text().then((e=>{t(e)})):n(new Error)})).catch((e=>n(e)))})),JSONPostRequest=(e,t)=>new Promise(((n,i)=>{fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:t,mode:"cors"}).then((e=>{e.status>=200&&e.status<=299?e.json().then((e=>{n(e)})):i(new Error)})).catch((e=>i(e)))}));class Action{_subs=[];constructor(...e){this._subs=e}AddCallback(e){if("function"!=typeof e)throw new Error("Invalid parameter type for 'callback': "+typeof e+". Expected 'function'.");this._subs.push(e)}RemoveCallback(e){this._subs.splice(this._subs.findIndex((t=>t==e)))}Invoke(e){for(let t=0;t{ShowPopupModal("App not found!",e)};e(),location.replace("https://isotopic.io/game-store")}let firstLoad=!0;const APIBaseURL="https://dapp.isotopic.io",API={GetGameDetails:()=>new Promise(((e,t)=>{GetRequest(`https://dapp.isotopic.io/api/v1/store/details/${app_id}`).then((t=>{e(JSON.parse(t))})).catch((e=>{t(e)}))})),GetGameImageSrcURL:e=>`https://dapp.isotopic.io/api/v1/store/files/${app_id}/page_images/?index=${e}`,GetGameMainImageSrcURL:()=>`https://dapp.isotopic.io/api/v1/store/files/${app_id}/page_main_image`,GetGameWeb3Details:()=>new Promise(((e,t)=>{GetRequest(`https://dapp.isotopic.io/api/v1/store/web3/${app_id}`).then((t=>{e(JSON.parse(t))})).catch((e=>{t(e)}))})),GetUserWallets:()=>JSONPostRequest("https://dapp.isotopic.io/api/v1/wallet/get",JSON.stringify({session_id:User.GetSessionID()})),GetUserRating:()=>new Promise(((e,t)=>{GetRequest(`https://dapp.isotopic.io/api/v1/store/rating/?user_id=${User.GetUserID()}&app_id=${app_id}`).then((t=>{e(JSON.parse(t))})).catch((e=>{t(e)}))})),SetUserRating:e=>JSONPostRequest("https://dapp.isotopic.io/api/v1/store/rate",JSON.stringify({session_id:User.GetSessionID(),app_id:app_id,rating:e})),GetAppCategories:()=>new Promise(((e,t)=>{GetRequest("https://dapp.isotopic.io/api/v1/store/categories").then((t=>{e(JSON.parse(t))})).catch((e=>t(e)))})),GetComments:()=>new Promise(((e,t)=>{GetRequest(`https://dapp.isotopic.io/api/v1/store/comments/${app_id}`).then((t=>{e(JSON.parse(t))})).catch((e=>{t(e)}))})),AddNewComment:(e,t=null)=>JSONPostRequest(`https://dapp.isotopic.io/api/v1/store/comments/${app_id}/post`,JSON.stringify({session_id:User.GetSessionID(),content:e,parent_id:t})),Analytics:()=>{JSONPostRequest("https://dapp.isotopic.io/api/v1/analytics/entry",JSON.stringify({session_id:MyAccount.session_id,action:1==firstLoad?"visit":"stay",app_id:app_id,data:{userAgent:navigator?.userAgent}})),firstLoad=!1},GetICPUploads:e=>new Promise(((t,n)=>{GetRequest(`https://dapp.isotopic.io/api/v1/icp/get-app-downloads/?app_id=${e}`).then((e=>{t(JSON.parse(e))})).catch((e=>n(e)))})),GetShortByID:e=>new Promise(((t,n)=>{GetRequest(`https://dapp.isotopic.io/api/v1/shorts/${e}/details`).then((e=>{t(JSON.parse(e))})).catch((e=>n(e)))})),GetShortsByApp:e=>JSONPostRequest("https://dapp.isotopic.io/api/v1/shorts/get_app_shorts",JSON.stringify({app_id:e}))},OpenAndWaitForLogin=()=>new Promise(((e,t)=>{$("body").addClass("edgtf-right-side-menu-opened"),$(".edgtf-side-menu-button-opener, .edgtf-icon-has-hover, .edgtf-side-menu-button-opener-svg-path").addClass("opened");const n=t=>{e(t),MyAccount.OnAccountSet.RemoveCallback(n)};MyAccount.OnAccountSet.AddCallback(n)}));let details,web3details,icpUploads,storesidebarRes=GetRequest("https://dapp.isotopic.io/games-page/sidebar").catch((e=>{throw e})),OnAppReady=new Action,icpUploadsProm=API.GetICPUploads(app_id).then((e=>{icpUploads=e,window.icpUploads=e})).catch((e=>{console.log(e)}));const gamePagePromises=[API.GetGameDetails().then((e=>{details=e,window.details=e,document.title=details.title})).catch((e=>{console.log(e)})),API.GetGameWeb3Details().then((e=>{web3details=e,window.web3details=e})).catch((e=>{console.log(e)}))],getAppCategoriesPromise=API.GetAppCategories();$("head").append(''),$(document).ready((async()=>{const e=$("#store-sidebar");let t=await storesidebarRes;e.html(t);try{$("#nav-menu-item-8859").addClass("edgtf-active-item"),$("#mobile-store-btn").addClass("red-underline")}catch{}const n=API.GetShortsByApp(app_id),i=import("https://dapp.isotopic.io/modules/video.min.js");await Promise.all(gamePagePromises),OnAppReady.Invoke(details);let a=!0;if(null==details||"fail"==details.result)return setTimeout((()=>{window.history.back(),setTimeout((()=>{window.location.href="https://isotopic.io/game-store/"}),200)}),2e3);MyAccount.OnReady.then((()=>{API.Analytics(),setInterval((()=>{API.Analytics()}),6e4)})),null!=web3details.web3_enabled&&0!=web3details.web3_enabled||(a=!1);const s=e=>new Promise(((t,n)=>{setTimeout(t,e)})),l=$("#single-game"),o='\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ';const c=async()=>{if(navigator?.userAgent?.indexOf("Electron")>=0)return;const e=$("#game-buttons-container"),t=$("#myDropdown");e.html(""),t.html("");const n=(e,t,n,i=null,a=null)=>`\n ${null!=i?``:""}\n
\n \n ${t}\n \n
\n ${null!=i?"
":""}`,i=(t,i,a,s=null,l=null)=>{console.log("GetAndInjectButton: "+i);let o=n(t,i,a,s,l);return $(o).appendTo(e),$(`#${t}`)},l=(e,t)=>{t?(e.removeClass("single-game-btn-disabled"),e.addClass("single-game-btn"),e.addClass("glow-lite"),e.removeClass("remove-animations")):(e.addClass("single-game-btn-disabled"),e.removeClass("single-game-btn"),e.removeClass("glow-lite"),e.addClass("remove-animations")),e.active=t};((e,n,i,a=null,s=null)=>{console.log("GetAndInjectButtonToDotMenu: "+n);let l=((e,t,n,i=null,a=null)=>`\n ${null!=i?``:""}\n
\n \n ${t}\n \n
\n ${null!=i?"
":""}`)(e,n,i,a,s);$(l).appendTo(t),$(`#${e}`)})("game-download-button-2","VIEW IN CLIENT",!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),"isotopic-client://game?game="+app_id,"dot-menu-entry");let r="",d=!1,p=null;if("string"==typeof details?.app_links){let e={};try{e=JSON.parse(details.app_links),"string"==typeof e.playstore&&(r+=`\n \n `,d=!0),"string"==typeof e.appstore&&(r+=`\n \n `,d=!0),"string"==typeof e.requires_asset&&(p=e.requires_asset)}catch{}}if(details.available_to_play||d)if(a)try{if(!MyAccount.IsLoggedIn){if(1==MyAccount.IsReady){i("game-buy-button","LOGIN TO BUY",!0,null,"single-game-btn-desc").click((()=>{MyAccount.OpenMyAccount(),MyAccount.OnAccountSet.AddCallbackOneOff((()=>{MyAccount.CloseMyAccount()}))}));let t="";t="0"==details.price?"FREE":details.price+"$";const n=`

${t}

`;return void $(n).appendTo(e)}i("game-buy-button","BUY GAME",!1,null,"single-game-btn-desc");await MyAccount.OnReady,c();return}let t=i("game-buy-button","BUY GAME",!1,null,"single-game-btn-desc"),a=!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),r=i("game-download-button","DOWNLOAD",a,null,"single-game-btn-desc");l(r,a);let d="";d="0"==details.price?"FREE":details.price+"$";let p="";null!=details.discount&&0!=details.discount&&(p=details.price/(details.discount/100),p=`

${p}$

`);const m=`

${d}

`;$("#original-price").text(p),$(m).appendTo(e),r.click((()=>{r.active&&ShowPopupModal(`\n
DOWNLOAD THROUGH ISOTOPIC CLIENT
\n

You must download the Isotopic Client application to install this game.


\n \n \n \n

\n \n \n \n `)})),await Web3Bundle.OnReady;let g=Web3Bundle.Web3Client,u=Web3Bundle.Sequence,h=new g.Web3AppContractInterface(web3details.contract_address,web3details.contract_abi,web3details.payment_contract_address,web3details.payment_contract_abi),v=await h.GetCost(),w=await h.GetPaymentTokenDecimals(),y=(parseInt(v)/10**parseInt(w)).toFixed(2);try{let e=await MyAccount.GetLinkedWallets(),t=!1;for(let n=0;n0){t=!0;break}}catch{}}catch{}let b='\x3c!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --\x3e\n ',x='\x3c!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --\x3e\n ';l(t,!0),t.click((()=>{t.active&&function e(){let t=`\n

${details.title}

\n
\n
\n \n
\n
\n \n
\n
\n
\n
Total:
\n
${y} USD
\n
\n
\n

Payment options:

\n
\n
\n\n ${n("buy-with-sequence",x+"CREDIT CARD",!1,null,"single-game-btn-buy")}\n ${n("buy-with-injected",b+"WEB3 WALLET",!1,null,"single-game-btn-buy")}\n \n

By buying this game, you accept our Terms And Conditions.
Payment in Polygon USDC. View License on PolygonScan.

\n\n \n
\n
\n
\n `;ShowPopupModal(`
${t}
`);let i=$("#buy-with-injected"),a=$("#buy-with-sequence");i.click((async()=>{if(!i.active)return;$("#popup-modal-close").css("color","unset"),$("#popup-modal-close").off("click"),l(i,!1),l(a,!1),$("#mint-checks-container").css("display","unset");const t=$("#connect-acc-p"),n=$("#connect-bal-p"),r=$("#approve-con-p"),d=$("#mint-p");t.html(`Connect Account ${o}`),n.html(`Balance Available ${o}`),r.html(`Approve Contract ${o}`),d.html(`Mint NFT ${o}`);let p=await g.ConnectWallet();if(null==p)return t.text("Connect Account ❌"),n.text("Balance Available ❌"),r.text("Approve Contract ❌"),d.text("Mint NFT ❌"),await s(2e3),e();t.text("Connect Account ✅");let m=await h.GetCost(),u=await h.PaymentBalanceOf(p);if(BigInt(u)Please add funds to your wallet first, or use a different option.",e);if(n.text("Balance Available ✅"),!await h.IsApprovedFor(m)){if(!await h.Approve(m))return r.text("Approve Contract ❌"),d.text("Mint NFT ❌"),await s(2e3),e()}if(r.text("Approve Contract ✅"),!await h.Buy(1))return d.text("Mint NFT ❌"),await s(2e3),e();await s(1500),d.text("Mint NFT ✅"),1==(await MyAccount.GetLinkedWallets()).filter((e=>e.address==p)).length?(ClosePopupModal(),c()):ShowPopupModal("You can download this game after linking the wallet to your account.",(()=>{MyAccount.OpenWallets()})),ShowNotification(`Succesfully bought:
${details.title}`)})),a.click((async()=>{if(!a.active)return;$("#popup-modal-close").css("color","unset"),$("#popup-modal-close").off("click"),$("#mint-checks-container").css("display","unset");const t=$("#connect-acc-p"),n=$("#connect-bal-p"),r=$("#approve-con-p"),d=$("#mint-p");if(t.html(`Connect to Sequence ${o}`),n.html(`Balance Available ${o}`),n.css("display","unset"),r.html(`Approve Buying ${o}`),d.html(`Buy Game ${o}`),l(i,!1),l(a,!1),null==u?.connectDetails?.connected){await u.ConnectAndAuthWallet();if(1!=u?.connectDetails?.connected)return t.text("Connect to Sequence ❌"),n.text("Balance Available ❌"),r.text("Approve Buying ❌"),d.text("Buy Game ❌"),await s(2e3),e()}let p=await u.Wallet.getAddress();t.text("Connect to Sequence ✅");let m=u.GetAppContractInterface(web3details.contract_address,web3details.contract_abi,web3details.payment_contract_address,web3details.payment_contract_abi),g=await m.GetCost();if(await m.PaymentBalanceOf(p)Please add funds to your wallet first.",e),void u.AskForFunds();if(n.text("Balance Available ✅"),!await m.IsApprovedFor(p,g)){if(!await m.Approve(g))return r.text("Approve Buying ❌"),d.text("Buy Game ❌"),await s(2e3),e()}r.text("Approve Contract ✅");let h=!0;if(h=await m.Buy(p,1).catch((e=>h=!1)),!h)return d.text("Buy Game ❌"),await s(2e3),e();await s(1500),d.text("Buy Game ✅"),1==(await MyAccount.GetLinkedWallets()).filter((e=>e.address==p)).length?(ClosePopupModal(),c()):ShowPopupModal("You can download this game after linking Sequence to your account.",(()=>{MyAccount.OpenWallets(),c()})),ShowNotification(`Succesfully bought:
${details.title}`)})),g.IsWeb3BrowserCompatible&&l(i,!0),l(a,!0)}()}))}catch(e){console.log(e),ShowNotification("An error occured while getting game's info.
Some data or functionalities might be missing from this page.","error-web3-retrieval",null,1e4)}else{if(0!=details.platform.split("-").filter((e=>["pc","mobile","vr"].includes(e))).length||d){let e=i("game-buy-button","DOWNLOAD GAME",!0,null,"single-game-btn-desc"),t=MyAccount.session_id??"isotopic-tester";e.click((async()=>{if(await icpUploadsProm,DownloadsHTML="
SELECT PLATFORM TO DOWNLOAD
",details.platform.includes("pc")){let e=`https://dapp.isotopic.io/games/${app_id}/download.zip?user=${t}`,n=`https://dapp.isotopic.io/api/v1/icp/downloads/${icpUploads?.data?.pc??""}`,i=null!=icpUploads?.data?.pc,a=details.downloads_available.includes("pc");DownloadsHTML+=`\n
\n ${a?``:""}${a?"":""}\n ${i?'':""}\n
`}if((details.platform.includes("mobile")||details.platform.includes("android"))&&0==d){let e=`https://dapp.isotopic.io/games/${app_id}/download.apk?user=${t}`,n=`https://dapp.isotopic.io/api/v1/icp/downloads/${icpUploads?.data?.mobile??""}`,i=null!=icpUploads?.data?.mobile,a=details.downloads_available.includes("mobile");DownloadsHTML+=`\n
\n ${a?``:""}${a?"":""}\n ${i?'':""}\n
`}if(details.platform.includes("vr")){let e=`https://dapp.isotopic.io/games/${app_id}/download-vr.apk?user=${t}`,n=`https://dapp.isotopic.io/api/v1/icp/downloads/${icpUploads?.data?.vr??""}`,i=null!=icpUploads?.data?.vr,a=details.downloads_available.includes("vr");DownloadsHTML+=`\n
\n ${a?``:""}${a?"":""}\n ${i?'':""}\n
`}if(details.platform.includes("mac")){let e=`https://dapp.isotopic.io/games/${app_id}/download-mac.zip?user=${t}`,n=`https://dapp.isotopic.io/api/v1/icp/downloads/${icpUploads?.data?.mac??""}`,i=null!=icpUploads?.data?.mac,a=details.downloads_available.includes("mac");DownloadsHTML+=`\n
\n ${a?``:""}${a?"":""}\n ${i?'':""}\n
`}if(details.platform.includes("linux")){let e=`https://dapp.isotopic.io/games/${app_id}/download-linux.zip?user=${t}`,n=`https://dapp.isotopic.io/api/v1/icp/downloads/${icpUploads?.data?.linux??""}`,i=null!=icpUploads?.data?.linux,a=details.downloads_available.includes("linux");DownloadsHTML+=`\n
\n ${a?``:""}${a?"":""}\n ${i?'':""}\n
`}if(DownloadsHTML+=`\n
\n ${r}\n
\n `,null!=p)return ShowPopupModalConfirm("
Notice

This download is free, but the game requires the purchace of assets for access.

","Learn More","View Downloads",(()=>{ShowPopupModal(DownloadsHTML)}),(()=>{window.open(p,"_blank")}));ShowPopupModal(DownloadsHTML)}))}details.platform.includes("web")&&(i("game-play-web","PLAY ON BROWSER",!0,`https://dapp.isotopic.io/games/${app_id}/web/index.html?user=isotopic-tester`,"single-game-btn-desc"),details.downloads_available.includes("web")||l($("#game-play-web"),!1));let t="";null!=details.discount&&0!=details.discount&&(t=details.price/(details.discount/100),t=`${t}$`);let n="";n="0"==details.price?"FREE":details.price+"$";const a=`

${n}

`;$("#original-price").text(t),$(a).appendTo(e)}else{i("game-unavailable-button",details.special_tags?.includes("coming_soon")?"COMING SOON":"NOT AVAILABLE",!1,null,"single-game-btn-desc")}};MyAccount.OnAccountSet.AddCallback(c);const r=()=>{const e=$("#comment-section-div"),t=(e,t,n,i,a,s)=>{let l=$(`
\n
\n
\n
\n \n
\n
\n

\n
\n
\n
\n
`);l.find(`#comment-username-${n}`).html(`${t} - ${s}`),l.find(`#comment-content-${n}`).text(a);let o=l.html();$(o).insertAfter($(`#comment-id-${i}`))};API.GetComments().then((n=>{if("fail"==n)return e.append("

An issue occured while loading comments.

");n.comments.forEach((t=>{null==t.parent_id&&e.append(((e,t,n,i,a)=>{let s=$(`
\n
\n \n
\n
\n

\n
\n
Reply
\n
\n
\n
\n
`);return s.find(`#comment-username-${n}`).html(`${t} - ${a}`),s.find(`#comment-content-${n}`).text(i),s.html()})(t.user_id,t.username,t.comment_id,t.content,t.created_at))})),n.comments.forEach((e=>{null!=e.parent_id&&null!=n.comments.find((t=>t.comment_id==e.parent_id))&&t(e.user_id,e.username,e.comment_id,e.parent_id,e.content,e.created_at)})),$(".reply-comment-button").click((function(){$(".replying-comment-container").remove();let i=$(this).attr("comment_id"),a=n.comments.find((e=>e.comment_id==i))?.username,s=$(`
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n POST\n \n
\n
\n
\n
\n
\n
`);s.find(`#comment-username-reply-${i}`).html(`Replying to ${a}:`);let l=s.html(),o=$(`#comment-id-${i}`).next(":not(.indented-comment-container)");0==o.length?e.append($(l)):$(l).insertBefore(o);$("#post-reply-button").click((()=>{let e=$("#new-reply-content").val();$("#new-reply-content").attr("disabled",!0),API.AddNewComment(e,i).then((n=>{if("fail"==n.result)return $(".replying-comment-container").remove(),void ShowNotification(`Reply Failed: ${n.error}`,"reply-sent",null,4e3,!1);((e,n,i,a)=>{$(".replying-comment-container").remove(),t(MyAccount.user_id,MyAccount.username,i,n,e,a)})(e,i,n.comment_id,"Just now")})).catch((e=>{ShowNotification("Reply failed, try again later!","reply-sent",null,3e3,!1),$(".replying-comment-container").remove()}))}))}))}));MyAccount.OnAccountSet.AddCallback((()=>{$("#new-comment-profile-img").attr("src",`https://dapp.isotopic.io/api/v1/user/profile/pic/get?user_id=${MyAccount.user_id}`)})),$("#post-comment-button").click((()=>{if(null==MyAccount.session_id)return ShowPopupModal("You must be logged in to comment!",OpenAndWaitForLogin);API.AddNewComment($("#new-comment-content").val()).then((e=>{if("fail"==e.result)return ShowPopupModal(e.error);$(".other-game-comment").remove(),r()})),$("#new-comment-content").val("")}))};(async()=>{const e=(e=1)=>1===e?'':0===e?'':void 0;l.append(`\n

\n ${details.title}\n

\n \n\n
\n\n
\n \n
\n
\n \x3c!--MAIN DISCRIPTION--\x3e\n
\n
\n
\n \x3c!--MAIN DESCRIPTION IMAGE--\x3e\n
\n
\n
\n \n \x3c!--

-10%

--\x3e\n
\n
\n
\n\n \x3c!--SMALL IMAGES--\x3e\n
\n
\n
\n \n
\n
\n\n\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n \n
\n \x3c!--SINGLE GAME SUB DESCRIPTION--\x3e\n
\n \x3c!--MAIN DESCRIPTION TEXT--\x3e\n
\n
\n
${details.title}
\n \x3c!-- three dot menu --\x3e\n \n
\n \n Publisher: ${details.publisher_name}\n
\n
${e(0)}
\n
${e(0)}
\n
${e(0)}
\n
${e(0)}
\n
${e(0)}
\n

\n
\n

${details.short_description}

\n
\n\n
\n \n Categories: \n \n \n Tags: \n \n

\n
\n
\n
\n
\n
\n
\n \n \x3c!--SINGLE GAME DETAILS--\x3e\n
\n \n \x3c!--HEADER--\x3e\n
\n
\n Description\n
\n
\n\n \x3c!--RELEASE DATE--\x3e\n
\n \n
\n\n \x3c!--LONG DESCRIPTION--\x3e\n
${details.details_html}\n
\n
\n\n \x3c!--RATING PANEL--\x3e\n \x3c!--
\n \n
\n Pegi Rating:\n

Suitable for people aged 12 and over.

\n
\n \n
\n\n
\n Genre:\n

TBD

\n
\n\n
\n\n
\n Customer Rating:\n
\n
--\x3e\n\n
\n
\n\n \n \n \n \n\n\n
\n \x3c!--SHORTS--\x3e\n
\n \n \n\n \x3c!--COMMENTS--\x3e\n
\n
\n
\n Game Comments\n
\n
\n
\n \n
\n
POST A COMMENT
\n \n
\n
\n \n POST\n \n
\n
\n
\n
\n
\n
\n\n \x3c!-- ___________________________RELATED GAMES____________________________________ --\x3e\n\n
\n
\n
\n MoreGames\n
\n
\n\n \n
\n \n
\n
\n \n\n `),$("body").append('\n \x3c!--MODAL TO VIEW IMAGES FULLSCREEN--\x3e\n ');const t=$("#special-tags-container"),n=(e,t)=>`\n \n
\n

${e}

\n
\n
\n `;t.append(n(details.platform.toUpperCase(),`https://isotopic.io/game-store-search/?platform=${details.platform}`)),details.special_tags.split("-").forEach((e=>{""==e||e.includes("requires_asset")||t.append(n(e.toUpperCase().replace(/_/g," "),`https://isotopic.io/game-store-search/?special=${e}`))}));const i=$("#rating-text");let a;API.GetUserRating().then((e=>{a=e?.rating})).catch((e=>{})),MyAccount.OnAccountSet.AddCallback((async e=>{a=(await API.GetUserRating().catch((e=>{})))?.rating}));const s=()=>{if(null==details.rating.rating||0==details.rating.rating_count){for(let t=1;t<=5;t++)$(`#rating-star-${t}`).html(e(0));i.text("(Not enough ratings)")}else{let t=details.rating.rating,n=Math.round(t),a=1;for(;a<=n;a++)$(`#rating-star-${a}`).html(e(1));(t-n>=.5||n<5)&&$(`#rating-star-${a}`).html(e(0));for(let t=1;t<6-a;t++)$(`#rating-star-${a+t}`).html(e(0));i.text(`${Number.parseFloat(details.rating.rating).toFixed(1)}/5.0 (${details.rating.rating_count} ratings)`)}};s();let o=!1;$("div .rating-star").on("click touchstart",(function(e){if(1==o)return;let t=MyAccount.session_id??getCookie("session_id");if([void 0,null,""].includes(t))return ShowPopupModal("You must be logged in to rate this!",(()=>{OpenAndWaitForLogin()}));let n=$(e.target),i=Number.parseInt(n.attr("id").slice(-1));null!=i&&(o=!0,n.removeClass("clickable"),API.SetUserRating(i).then((e=>{n.addClass("clickable"),"success"==e.result?(ShowPopupModal("Rating success!"),o=!1,a=i,API.GetGameDetails().then((e=>{details=e,s()}))):(ShowPopupModal(e.error),o=!1)})).catch((e=>{console.log(e),o=!1})))}));const c=()=>{0==$("#rating-panel-parent:hover").length&&(s(),clearInterval(r),r=null)};let r=setInterval(c,250);$(".rating-star").mouseenter((function(){let t=Number.parseInt($(this).attr("id").slice(-1)),n=1;for(;n<=t;n++)$(`#rating-star-${n}`).html(e(1));for(let i=0;i<5-t;i++)$(`#rating-star-${n+i}`).html(e(0));if(null===r&&(r=setInterval(c,250)),"number"==typeof a)i.text(`Your rating: ${a}/5`);else{let e=MyAccount.session_id??getCookie("session_id");[void 0,null,""].includes(e)?i.text("Login to rate this!"):i.text("Rate this!")}})),$("#rating-panel-parent").mouseleave((()=>{s()}));var d=0,p=[API.GetGameMainImageSrcURL(),API.GetGameImageSrcURL(0),API.GetGameImageSrcURL(1),API.GetGameImageSrcURL(2)];console.log("imageURLS: "+p.length),$(".myImg").click((function(){document.getElementById("myModal").style.visibility="visible";this.src;let e=document.getElementById("img01"),t=this.getAttribute("imageurl");d=this.getAttribute("image-index"),e.src=t})),$("#modal-next-btn").click((function(){d0?d--:d=p.length-1,console.log("Prev button clicked Image index: "+d),document.getElementById("img01").src=p[d]})),$("#close-modal").click((()=>{document.getElementById("myModal").style.visibility="hidden"}));let m=(await(g={orderby:"RAND()",limit:5},JSONPostRequest("https://dapp.isotopic.io/api/v1/store/search",JSON.stringify(g))).catch((e=>{throw e}))).results;var g;let u=$("#related-games-panel"),h=4;for(let e=0;e\n \n
\n \n \n
\n
\n\n \n \n `)).appendTo(u):h=5;var v;$("#dropdown-dots").click((function(){$(".dropdown-content").slideToggle(300,"linear"),$(".icons").toggleClass("active")})),window.addEventListener("click",(function(e){if(!e.target.matches(".dropbtn")){var t,n=document.getElementsByClassName("dropdown-content");for(t=0;t{const e=$("#single-game-categories"),t=JSON.parse(details.genres);let n=await getAppCategoriesPromise;t.forEach((t=>{let i="";var a,s;n.forEach((e=>{e.id==t&&(i=e.title)})),$((a=i,s=t,` ${a}, `)).appendTo(e)}))})(),(()=>{const e=$("#single-game-keywords");JSON.parse(details.keywords).forEach((t=>{$((e=>` ${e}, `)(t)).appendTo(e)}))})(),r(),(()=>{if("string"!=typeof details?.app_links)return;let e={};try{e=JSON.parse(details.app_links)}catch{return}let t="";if("string"==typeof e.demo&&(t+=`\n \n \n `),"string"==typeof e.full_version&&(t+=`\n \n \n `),null!=e.socials&&(t+='\n \n '),""==t)return;let n=`\n
\n ${t}\n
\n `;if($("#single-game-sub").append(n),null!=e.socials){let t=[],n="

|

";e.socials.forEach((e=>{t.push(`

${e.title}

`)})),$("#view-links-button").click((()=>{ShowPopupModal(`\n
\n
Socials/Links:
\n
\n ${t.join(n)}\n
\n
\n `)}))}})(),(async()=>{let e=await n;if("fail"==e.result||0==e.shorts?.length)return;await i;const t=videojs("shorts-player-1"),a=videojs("shorts-player-2");let s,l,o=new Promise(((e,t)=>{s=e})),c=new Promise(((e,t)=>{l=e}));t.ready(s),a.ready(l),await Promise.all([o,c]),t.on("volumechange",(()=>{a.volume(t.volume()),a.muted(t.muted())})),a.on("volumechange",(()=>{t.volume(a.volume()),t.muted(a.muted())})),$("#shorts-section-div").css("display","unset");const r=$("#short-1-parent"),d=$("#short-2-parent"),p=$("#short-description"),m=$("#short-title");let g=e.shorts.sort(((e,t)=>e.created_at-t.created_at)),u=e.session_id,h=!1;function v(e){let t=JSON.parse(e.metadata).extension;return{src:`https://dapp.isotopic.io/api/v1/shorts/${e.short_id}${t}?session_id=${u}`,mime:`video/${t.substr(1)}`}}let w=0;async function y(){return w{$("#pause-short-button").click((()=>{e(!1),$("#pause-button-text").text("PAUSE"),$("#next-short-button").off("click"),$("#pause-short-button").off("click"),r.off("click")})),r.click((()=>{e(!1),$("#pause-button-text").text("PAUSE"),$("#next-short-button").off("click"),$("#pause-short-button").off("click"),r.off("click")})),$("#next-short-button").click((async()=>{e(!0),$("#next-short-button").off("click"),$("#pause-short-button").off("click"),r.off("click"),$("#pause-button-text").text("PAUSE")}))}));await t.play();let f=1;a.src(v(await y())),t.on("ended",(async()=>{t.hide(),a.show(),await b(g[w]),await a.play(),f=2,t.src(v(await y())),h||(a.on("ended",(async()=>{a.hide(),t.show(),await b(g[w]),await t.play(),f=1,a.src(v(await y()))})),h=!0)}));let _=e=>1==e?t:a,A=!1;function S(){A?(_(f).play(),$("#pause-button-text").text("PAUSE")):(_(f).pause(),$("#pause-button-text").text("PLAY")),A=!A}$("#pause-short-button").click((()=>{S()})),r.click(S),d.click(S);let I=!1;$("#next-short-button").click((async()=>{if(I)return;I=!0;let e=_(f),t=_(1==f?2:1);e.pause(),e.hide(),t.show(),await b(g[w]),await t.play(),f=1==f?2:1,e.src(v(await y())),I=!1,A=!1,$("#pause-button-text").text("PAUSE")})),x&&$("#next-short-button").click()})()}));