$("head").append('');const SVGLoadingHTML='
\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
Loading Page...
';function ArrayBufferToBase64(e){for(var t,i="",a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(e),o=n.byteLength,l=o%3,s=o-l,r=0;r>18]+a[(258048&t)>>12]+a[(4032&t)>>6]+a[63&t];return 1==l?i+=a[(252&(t=n[s]))>>2]+a[(3&t)<<4]+"==":2==l&&(i+=a[(64512&(t=n[s]<<8|n[s+1]))>>10]+a[(1008&t)>>4]+a[(15&t)<<2]+"="),i}$(document).ready((async()=>{const e=$("#single-game");e.append(SVGLoadingHTML);const t=()=>{ShowPopupModal("Please wait...",t)};await new Promise(((e,t)=>{MyAccount.OnMyAccountReady.AddCallback(e)}));const i=()=>MyAccount?.session_id;let a=i();if(!![void 0,null,""].includes(a)){const e=()=>{ShowPopupModal("You must be logged in to view this page.",e)};return e(),setTimeout((()=>{window.history.back(),setTimeout((()=>{window.location.href="https://isotopic.io"}),200)}),2e3)}const n=window.location.search,o=new URLSearchParams(n),l=o.get("game"),s=o.get("message"),r=(o.get("beta"),e=>new Promise(((t,i)=>{fetch(e,{method:"GET",mode:"cors"}).then((e=>{e.status>=200&&e.status<=299?e.text().then((e=>{t(e)})):i(new Error)})).catch((e=>i(e)))}))),p=(e,t)=>new Promise(((i,a)=>{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=>{i(e)})):a(new Error)})).catch((e=>a(e)))})),d="https://dapp.isotopic.io/api/v1/",c=e=>new Promise(((t,a)=>{r(d+"store/details/priv/"+e+"/?user="+i()).then((e=>{t(JSON.parse(e))})).catch((e=>{a(e)}))})),u=(e,t,a)=>p(d+"store/game/upload/init",JSON.stringify({app_id:e,session_id:i(),file_size:t,platform:a})),m=(e,t,a)=>p(d+"store/game/upload/chunk",JSON.stringify({upload_id:e,session_id:i(),app_id:t,chunk_data:a})),h=()=>new Promise(((e,t)=>{r(`${d}store/categories`).then((t=>{e(JSON.parse(t))})).catch((e=>t(e)))})),g=(e,t)=>p(d+"store/game/platform/set",JSON.stringify({app_id:e,platform:t,session_id:i()})),f=(e,t)=>p(d+"store/game/upload-to-icp",JSON.stringify({app_id:e,platform:t,session_id:i()})),b=e=>p(d+"store/game/icp-uploads",JSON.stringify({app_id:e,session_id:i()})),w=e=>p(d+"shorts/get_app_shorts",JSON.stringify({app_id:e,session_id:i()})),y=(e,t,a,n,o)=>p(d+"shorts/init_upload",JSON.stringify({app_id:e,session_id:i(),file_size:t,short_title:a,short_desc:n,video_extension:o})),v=(e,t,a,n)=>p(d+"shorts/upload_chunk",JSON.stringify({app_id:e,session_id:i(),upload_id:t,short_id:n,chunk_data:a})),x=(e,t)=>p(d+"shorts/delete",JSON.stringify({app_id:e,session_id:i(),short_id:t})),k=await c(l).catch((e=>{const t=()=>{ShowPopupModal("App not found.",t)};return t(),setTimeout((()=>{window.history.back(),setTimeout((()=>{window.location.href="https://isotopic.io"}),200)}),2e3)}));if("fail"==k.result){const e=()=>{ShowPopupModal("App not found.",e)};return e(),setTimeout((()=>{window.history.back(),setTimeout((()=>{window.location.href="https://isotopic.io"}),200)}),2e3)}window.onbeforeunload=()=>"Are you sure you want to exit this page?\nUnsaved progress will be lost.";const _=await w(l),S=await h();let P='\n \n ';S.forEach((e=>{P+=``}));const I=(e,t,i="")=>`\n \n `,E=(e,t)=>{t?(e.removeClass("single-game-btn-disabled"),e.addClass("single-game-btn"),e.addClass("glow-lite"),e.removeClass("remove-animations"),e.css("pointer-events","auto")):(e.addClass("single-game-btn-disabled"),e.removeClass("single-game-btn"),e.removeClass("glow-lite"),e.addClass("remove-animations"),e.css("pointer-events","none")),e.active=t},N=(e,t)=>{e.children().first().children().first().text(t)},M=(e,t,i,a,n,o,l)=>{e=$("
").text(e).html(),t=$("
").text(t).html();let s=i.substr(i.lastIndexOf(".")+1,i.length);return`\n
\n
${a} - ${e} - (${n?o?"LIVE":"PENDING REVIEW":"HIDDEN"})
\n
\n \n
\n
Description:
\n

${t}

\n ${I(`delete-short-${l}`,"Delete",`short_id=${l}`)}\n
\n \n
\n
\n `},A=()=>{$('div[id^="delete-short-"]').unbind("click"),$('div[id^="delete-short-"]').click((function(){let e=$(this).attr("short_id");ShowPopupModalConfirm("Are you sure you want to delete this short?","Yes, I am sure","Cancel",(()=>{}),(()=>{E($(this),!1),x(l,e),$(this).parent().closest(".upload-short-panel").remove()}))}))};null!=s&&ShowPopupModal("Changes saved!"),(async()=>{e.append(`\n

\n MANAGE GAME PAGE\n

\n
\n
APP STATUS:

${k.is_ready?k.is_public?"Deployed ":"Pending":"Private"}

${k.is_public?`[View Page]`:""}
\n

- To update game build, upload your build (.zip only) below.

\n

- Changes on game's images are uploaded imediately.

\n

- Select competition submission if applicable: \n \n

\n

- If your game is not free-to-play, contact info@isotopic.io for listing, so we can support you in the best way possible.

\n
\n ${I("publish-button","")}\n \n

\n BUILDS\n

\n
\n \n \n \n \n

ICP Backup: None

\n
\n
\n \n \n \n \n

ICP Backup: None

\n
\n
\n \n \n \n \n

ICP Backup: None

\n
\n
\n \n \n \n \n

ICP Backup: None

\n
\n
\n \n \n \n \n

ICP Backup: None

\n
\n
\n \n \n \n \n

ICP Backup: None

\n
\n

\n EDIT GAME PAGE\n

\n \n \n
\n \x3c!--MAIN DISCRIPTION--\x3e\n
\n \x3c!--MAIN DESCRIPTION IMAGE--\x3e\n
\n
\n
\n
\n \n \n \n \n
\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
\n
\n
\n \n \n \n \n
\n
\n
\n \n
\n\n \n
\n
\n \n \x3c!--SINGLE GAME SUB DESCRIPTION--\x3e\n \x3c!--
--\x3e\n \n \x3c!--MAIN DESCRIPTION TEXT--\x3e\n
\n \n \n \n Short Description: \n \n \n \n \n
\n\n
\n \n Categories: \n
\n \n \n \n \n
\n
\n \n Comma-Separated Tags: \n \n \n ${I("submit-details","SAVE DETAILS")}\n
\n \x3c!--
--\x3e\n
\n\n\n \x3c!--SINGLE GAME DETAILS--\x3e\n
\n \n
\n \n \x3c!--HEADER--\x3e\n
\n
\n Description\n
\n
\n\n \x3c!--LONG DESCRIPTION--\x3e\n \n \n
\n ${I("preview-details-button","PREVIEW DESCRIPTION")}\n ${I("preview-styles-button","PREVIEW HTML TAGS")}\n ${I("save-game-details-button","SAVE DESCRIPTION")}\n
\n
\n
\n
\n
\n
\n Video Shorts\n\n
\n
\n\n
\n
UPLOAD NEW SHORT
\n \n \n
\n \n \n

File Selected: none

\n

\n \n

\n
\n\n
\n\n
\n
\n
\n
\n `);$("#upload-new-short-input");const t=$("#post-new-short-input");let n=$("#video-shorts-list");if("success"==_.result){let e="";_.shorts.forEach((t=>{try{let i=JSON.parse(t.metadata).extension;e+=M(t.title,t.description,`https://dapp.isotopic.io/api/v1/shorts/${t.short_id}${i}`,t.formatted_date,t.is_ready,t.is_public,t.short_id)}catch{}})),n.html(e),A()}E(t,!1);const o=async()=>{let e=await b(l);"fail"!=e.result&&e.uploads.forEach((e=>{$(`#icp-backup-status-${e.platform}`).text("ICP Backup: "+("error"==e.status?"None":"ready"==e.status?"Backed-up":`In Progress: ${Math.floor(100*e.progress)}%`))}))};o(),setInterval(o,8e3),k.platform.includes("pc")&&$("#upload-pc-check").prop("checked",!0),k.platform.includes("mobile")&&$("#upload-mobile-check").prop("checked",!0),k.platform.includes("web")&&$("#upload-web-check").prop("checked",!0),k.platform.includes("vr")&&$("#upload-vr-check").prop("checked",!0),k.platform.includes("mac")&&$("#upload-mac-check").prop("checked",!0),k.platform.includes("linux")&&$("#upload-linux-check").prop("checked",!0),$(".upload-build-platform-check").change((()=>{let e=[];$("#upload-pc-check").prop("checked")&&e.push("pc"),$("#upload-mobile-check").prop("checked")&&e.push("mobile"),$("#upload-web-check").prop("checked")&&e.push("web"),$("#upload-vr-check").prop("checked")&&e.push("vr"),$("#upload-mac-check").prop("checked")&&e.push("mac"),$("#upload-linux-check").prop("checked")&&e.push("linux"),g(l,e.join("-")).then((e=>{RemoveNotification("change-platform"),ShowNotification("Updated Platforms: "+e.result,"change-platform",null,1e3)}))})),$("#page-loading-svg").remove(),$("#page-loading-parent").remove(),N($("#publish-button"),k.is_ready?"HIDE PAGE":"SUBMIT FOR REVIEW"),$("#publish-button").click((()=>{let e=()=>{ShowPopupModal("Changing app status...",e)};e();let t=$("#special_tags").val();p(d+"store/game/deploy",JSON.stringify({app_id:l,is_ready:!k.is_ready,session_id:i(),special_tags:t})).then((e=>{"success"==e.result?(ShowPopupModal(k.is_ready?"Success.":"Success. Pending moderator review..."),k.is_ready=!k.is_ready,N($("#publish-button"),k.is_ready?"HIDE PAGE":"SUBMIT FOR REVIEW")):ShowPopupModal("Fail, please refresh and try again.")}))})),$("#html_details_textarea").val(k.details_html.replace(/(?:
)/g,"\n")),$("#tags_input").val(JSON.parse(k.keywords).join(", ")),$("#text_description").val(k.short_description),$("#title_input").val(k.title);try{let e=JSON.parse(k.genres);null!=e[0]&&$(`#category_1 option[value="${e[0]}"]`).attr("selected","selected"),null!=e[1]&&$(`#category_2 option[value="${e[1]}"]`).attr("selected","selected"),null!=e[2]&&$(`#category_3 option[value="${e[2]}"]`).attr("selected","selected"),null!=e[3]&&$(`#category_4 option[value="${e[3]}"]`).attr("selected","selected")}catch{}try{k.special_tags.split("-").forEach((e=>{$(`#special_tags option[value="${e}"]`).attr("selected","selected")}))}catch{}})(),(async()=>{const e=(e,t,i)=>()=>{let a=new XMLHttpRequest;a.open("POST",$(`#game-image-${i}-form`).attr("action")),a.onload=function(i){let a=new FileReader;a.onloadend=function(){t.attr("src",a.result)},a.readAsDataURL(e.files[0])};let n=new FormData(document.getElementById(`game-image-${i}-form`));a.send(n)};$("#image-0").on("change",e($("#image-0")[0],$("#image-0-preview"),0)),$("#image-1").on("change",e($("#image-1")[0],$("#image-1-preview"),1)),$("#image-2").on("change",e($("#image-2")[0],$("#image-2-preview"),2)),$("#image-3").on("change",e($("#image-3")[0],$("#image-3-preview"),3));let i=!1;function a(e){let t=$("#upload-button-pc"),i=$("#upload-button-web"),a=$("#upload-button-mobile"),n=$("#upload-button-vr"),o=$("#upload-button-mac"),l=$("#upload-button-linux");E(t,e),E(i,e),E(a,e),E(n,e),E(o,e),E(l,e),$("#build-pc-file-input").prop("disabled",!e),$("#build-web-file-input").prop("disabled",!e),$("#build-mobile-file-input").prop("disabled",!e),$("#build-vr-file-input").prop("disabled",!e),$("#build-mac-file-input").prop("disabled",!e),$("#build-linux-file-input").prop("disabled",!e),$("#upload-vr-check").prop("disabled",!e),$("#upload-web-check").prop("disabled",!e),$("#upload-pc-check").prop("disabled",!e),$("#upload-mobile-check").prop("disabled",!e),$("#upload-mac-check").prop("disabled",!e),$("#upload-linux-check").prop("disabled",!e)}function n(e){if(e<6e4)return"< 1 minute";var t=(e/1e3).toFixed(0),i=Math.floor(t/60),a="";return i>59&&(i=(i-=60*(a=(a=Math.floor(i/60))>=10?a:"0"+a))>=10?i:"0"+i),t=(t=Math.floor(t%60))>=10?t:"0"+t,""!=a?a+" hour(s), "+i+" minute(s)":i+" minute(s)"}$("#preview-details-button").click((()=>{var e;i=!i,e=i,$("#html_details_textarea").css("display",e?"none":"block"),$("#html_preview_details").css("display",e?"block":"none"),$("#preview-details-button-text").text(i?"EDIT DESCRIPTION":"PREVIEW DESCRIPTION");let t=$("#html_details_textarea").val().replace(/(?:\r\n|\r|\n)/g,"
"),a=$("
",{html:t});a.find(":not(a, iframe, img, video, source, h1, h2, h3, h4, h5, h6, p, strong, link, br, b, i, em, mark, small, del, ins, sub, sup, table, tr, th, td, ol, ul, li, dl, dt, dd, pre)").remove(),a.children().attr("style",""),a.children().attr("class",""),a.children().attr("id","");let n=a.find("iframe");for(let e=0;e\n `):$(n[e].remove());$("#html_preview_details").html(a.html())})),$("#preview-styles-button").click((()=>{ShowPopupModal("\n
Allowed HTML tags:

a, img, video, source, h1-6, p, strong, link, br, b, i, em, mark, small, del, ins, sub, sup, table, tr, th, td, ol, ul, li, dl, dt, dd, pre

\n ")})),$("#submit-details").click((()=>{let e=!1;if(["text_description","category_1","category_2","category_3","tags_input","text_description"].forEach((t=>{let i=$("#"+t).val();null!=i&&""!=i||(e=!0)})),e)return ShowPopupModal("Not all input fields are set.");t();let i=new XMLHttpRequest;i.open("POST",$("#edit-form").attr("action")),i.onload=function(e){let t=JSON.parse(i.responseText);if("fail"==t.result)return ShowPopupModal("Error: "+t.error);t.new_id!=l?(window.onbeforeunload=null,ShowPopupModal("Refreshing page..."),window.location.replace("https://isotopic.io/game-edit-page/?game="+t.new_id+"&message=saved")):ShowPopupModal("Details saved successfully!")};let a=new FormData(document.getElementById("edit-form"));i.send(a)})),$("#save-game-details-button").click((()=>{let e=!1;if(["html_details_textarea"].forEach((t=>{let i=$("#"+t).val();null!=i&&""!=i||(e=!0)})),e)return ShowPopupModal("Not all input fields are set.");t();let i=new XMLHttpRequest;i.open("POST",$("#edit-description-form").attr("action")),i.onload=function(e){ShowPopupModal("Details Saved!")};let a=new FormData(document.getElementById("edit-description-form"));i.send(a)})),$(".edit-page-build-file-input").on("change",(function(){let e=$(this)[0].files[0],t=$(this).attr("platform");a(!1),ShowNotification("Initiating Upload...","upload-init",void 0,5e3);let i=!1,o=(e,t)=>{0==i?(ShowNotification(`
Upload in progress

${Math.floor(100*e)}% - ${n(t)} left.

`,"upload-progress",void 0,-1,!0),i=!0):SetNotification("upload-progress",`
Upload in progress

${Math.floor(100*e)}% | ${n(t)} left.

`)},s=Date.now();u(l,e.size,t).then((async i=>{let{result:n,upload_id:r,total_chunks:p,chunk_size:d}=i;if(s=Date.now(),"fail"===n)return RemoveNotification("upload-progress"),a(!0),ShowPopupModal("An error occured.");let c=0,u=!1;for(let i=0;i{g.onloadend=function(e){n=ArrayBufferToBase64(g.result),t()},g.onerror=function(e){u=!0,t()},g.readAsArrayBuffer(e.slice(i*d,h>e.size?e.size:h))})),u)return RemoveNotification("upload-progress"),a(!0),ShowPopupModal("A fatal error occured. Please try again.");let b=0,w=()=>new Promise((async(e,t)=>{await m(r,l,n).then((async t=>{if("fail"===t.result){if(b++,b>3&&(RemoveNotification("upload-network-issue"),ShowNotification("
Uploading Warning

Check your Internet Connection!

","upload-network-issue",void 0,5e3,!0),b>20))return e(t);await w().then((t=>{e(t)}))}else e(t)})).catch((async t=>{if(b++,b>3)return e(chunkRes);await w().then((t=>{e(t)}))}))}));await w().then((n=>"fail"===n.result?(u=!0,RemoveNotification("upload-progress"),a(!0),ShowPopupModal("A fatal error occured. Please try again.")):"done"===n.status?(RemoveNotification("upload-progress"),a(!0),ShowPopupModal(`Upload complete for platform ${t}!`,(()=>{e.size<75e6&&ShowPopupModalConfirm("Build is eligible to be backed up to the Interet Computer for free.

","Yes! Backup my build!","Do not backup.",(()=>{}),(async()=>{await f(l,t)}))}))):(c=i/p,void o(c,0==c?0:(1/c-1)*(Date.now()-s)))))}}))}));const o=$("#upload-new-short-input"),s=$("#post-new-short-input");let r=null,p=$("#new-short-title-input"),d=$("#new-short-desc-input"),c=($("#new-short-file-input"),$("#short-file-selected")),h=$("#new-short-preview-link");const g=e=>{p.prop("disabled",!e),d.prop("disabled",!e),E(o,e)};$("#new-short-file-input").on("change",(function(){let e=$(this)[0].files[0];if(e.size>21e6&&1!=window.development_mode)return void ShowPopupModal("File too large. Maximum size allowed: 20MB.");r=e,c.html(`File Selected: ${e.name}`);let t=URL.createObjectURL(e);h.html(`Preview File`),E(s,!0)})),s.click((()=>{let e=null;if(""==d.val()&&(e="Please write a description for the short first."),""==p.val()&&(e="Please choose a title for the short first."),null==r&&(e="Please choose a video file to upload first."),null!=e)return ShowPopupModal("Error:"+e);let t=p.val(),i=d.val();if(t.length>31&&1!=window.development_mode)return ShowPopupModal("Error: Short's title is too large.");if(i.length>255&&1!=window.development_mode)return ShowPopupModal("Error: Short's description is too large.");g(!1),E(s,!1),ShowNotification("Initiating Upload...","short-upload-init",void 0,5e3);let a=!1,o=(e,t)=>{0==a?(ShowNotification(`
Short Upload in progress

${Math.floor(100*e)}% - ${n(t)} left.

`,"short-upload-progress",void 0,-1,!0),a=!0):SetNotification("short-upload-progress",`
Short Upload in progress

${Math.floor(100*e)}% | ${n(t)} left.

`)},u=r.name.substr(r.name.lastIndexOf(".")+1,r.name.length),m=Date.now();y(l,r.size,t,i,u).then((async e=>{let{result:a,upload_id:n,total_chunks:f,chunk_size:b,short_id:w,error:y}=e;if(m=Date.now(),"fail"===a)return RemoveNotification("short-upload-progress"),g(!0),E(s,!0),ShowPopupModal("An error occured: "+y);let x=0,k=!1;for(let e=0;e{_.onloadend=function(e){a=ArrayBufferToBase64(_.result),t()},_.onerror=function(e){k=!0,t()},_.readAsArrayBuffer(r.slice(e*b,y>r.size?r.size:y))})),k)return RemoveNotification("short-upload-progress"),g(!0),E(s,!0),ShowPopupModal("A fatal error occured. Please try again.");let S=0,P=()=>new Promise((async(e,t)=>{await v(l,n,a,w).then((async t=>{if("fail"===t.result){if(S++,S>3&&(RemoveNotification("short-upload-network-issue"),ShowNotification("
Uploading Warning

Check your Internet Connection!

","short-upload-network-issue",void 0,5e3,!0),S>20))return e(t);await P().then((t=>{e(t)}))}else e(t)})).catch((async t=>{if(S++,S>3)return e(chunkRes);await P().then((t=>{e(t)}))}))}));await P().then((a=>{if("fail"===a.result)return k=!0,RemoveNotification("short-upload-progress"),g(!0),E(s,!0),ShowPopupModal("A fatal error occured. Please try again.");if("done"===a.status){RemoveNotification("short-upload-progress"),g(!0),E(s,!0),r=null,p.val(""),d.val(""),c.html("File Selected: none"),h.html(""),E(s,!1);let e=$("#video-shorts-list").html();return $("#video-shorts-list").html(M(t,i,`https://dapp.isotopic.io/api/v1/shorts/${w}.${u}`,function(e){let t=e.getDate(),i=e.getMonth();return`${t<10?"0"+t:t}-${i<10?"0"+i:i}-${e.getFullYear()}`}(new Date),!0,!1,w)+e),A(),ShowPopupModal("Upload complete for new short!")}x=e/f,o(x,0==x?0:(1/x-1)*(Date.now()-m))}))}}))}))})()}));