$("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,n="",a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=new Uint8Array(e),s=i.byteLength,o=s%3,r=s-o,l=0;l>18]+a[(258048&t)>>12]+a[(4032&t)>>6]+a[63&t];return 1==o?n+=a[(252&(t=i[r]))>>2]+a[(3&t)<<4]+"==":2==o&&(n+=a[(64512&(t=i[r]<<8|i[r+1]))>>10]+a[(1008&t)>>4]+a[(15&t)<<2]+"="),n}$(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 n=()=>MyAccount?.session_id;let a=n();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/game-store"}),200)}),2e3)}const i=window.location.search,s=new URLSearchParams(i),o=s.get("asset"),r=s.get("message"),l=(s.get("beta"),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)))}))),d=(e,t)=>new Promise(((n,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=>{n(e)})):a(new Error)})).catch((e=>a(e)))})),p="https://dapp.isotopic.io/api/v1/",c=e=>new Promise(((t,a)=>{l(p+"assets/details/priv/"+e+"/?user="+n()).then((e=>{t(JSON.parse(e))})).catch((e=>{a(e)}))})),m=(e,t,a)=>d(p+"assets/asset/upload/init",JSON.stringify({asset_id:e,session_id:n(),file_size:t,platform:a})),g=(e,t,a)=>d(p+"assets/asset/upload/chunk",JSON.stringify({upload_id:e,session_id:n(),asset_id:t,chunk_data:a})),u=()=>new Promise(((e,t)=>{l(`${p}assets/categories`).then((t=>{e(JSON.parse(t))})).catch((e=>t(e)))})),h=await c(o).catch((e=>{const t=()=>{ShowPopupModal("Asset not found.",t)};t()}));if("fail"==h.result){const e=()=>{ShowPopupModal("Asset not found.",e)};e()}window.onbeforeunload=()=>"Are you sure you want to exit this page?\nUnsaved progress will be lost.";const f=await u();let y='\n \n ';f.forEach((e=>{y+=``}));const w=(e,t,n="")=>`\n \n `,v=(e,t)=>{e.children().first().children().first().text(t)};null!=r&&ShowPopupModal("Changes saved!"),(async()=>{e.append(`\n

\n MANAGE ASSET PAGE\n

\n
ASSET STATUS:

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

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

- To update asset files, upload your files (.zip only) below.

\n

- Changes on asset's images are uploaded imediately.

\n

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

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

\n FILES\n

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

\n EDIT ASSET 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 ${w("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 ${w("preview-details-button","PREVIEW DESCRIPTION")}\n ${w("preview-styles-button","PREVIEW HTML TAGS")}\n ${w("save-asset-details-button","SAVE DESCRIPTION")}\n
\n
\n
\n
\n \n `),$("#page-loading-svg").remove(),$("#page-loading-parent").remove(),v($("#publish-button"),h.is_ready?"HIDE PAGE":"SUBMIT FOR REVIEW"),$("#publish-button").click((()=>{let e=()=>{ShowPopupModal("Changing asset status...",e)};e(),d(p+"assets/asset/deploy",JSON.stringify({asset_id:o,is_ready:!h.is_ready,session_id:n()})).then((e=>{"success"==e.result?(ShowPopupModal(h.is_ready?"Success.":"Success. Pending moderator review..."),h.is_ready=!h.is_ready,v($("#publish-button"),h.is_ready?"HIDE PAGE":"SUBMIT FOR REVIEW")):ShowPopupModal("Fail, please refresh and try again.")}))})),$("#html_details_textarea").val(h.details_html.replace(/(?:
)/g,"\n")),$("#tags_input").val(JSON.parse(h.keywords).join(", ")),$("#text_description").val(h.short_description),$("#title_input").val(h.title);try{let e=JSON.parse(h.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{}})(),(async()=>{const e=(e,t,n)=>()=>{let a=new XMLHttpRequest;a.open("POST",$(`#game-image-${n}-form`).attr("action")),a.onload=function(n){let a=new FileReader;a.onloadend=function(){t.attr("src",a.result)},a.readAsDataURL(e.files[0])};let i=new FormData(document.getElementById(`game-image-${n}-form`));a.send(i)};$("#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 n=!1;function a(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})($("#upload-button-pc"),e),$("#build-pc-file-input").prop("disabled",!e)}function i(e){if(e<6e4)return"< 1 minute";var t=(e/1e3).toFixed(0),n=Math.floor(t/60),a="";return n>59&&(n=(n-=60*(a=(a=Math.floor(n/60))>=10?a:"0"+a))>=10?n:"0"+n),t=(t=Math.floor(t%60))>=10?t:"0"+t,""!=a?a+" hour(s), "+n+" minute(s)":n+" minute(s)"}$("#preview-details-button").click((()=>{var e;n=!n,e=n,$("#html_details_textarea").css("display",e?"none":"block"),$("#html_preview_details").css("display",e?"block":"none"),$("#preview-details-button-text").text(n?"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 i=a.find("iframe");for(let e=0;e\n `):$(i[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 n=$("#"+t).val();null!=n&&""!=n||(e=!0)})),e)return ShowPopupModal("Not all input fields are set.");t();let n=new XMLHttpRequest;n.open("POST",$("#edit-form").attr("action")),n.onload=function(e){let t=JSON.parse(n.responseText);if("fail"==t.result)return ShowPopupModal("Error: "+t.error);t.new_id!=o?(window.onbeforeunload=null,ShowPopupModal("Refreshing page..."),window.location.replace("https://isotopic.io/asset-page-edit/?asset="+t.new_id+"&message=saved")):ShowPopupModal("Details saved successfully!")};let a=new FormData(document.getElementById("edit-form"));n.send(a)})),$("#save-asset-details-button").click((()=>{let e=!1;if(["html_details_textarea"].forEach((t=>{let n=$("#"+t).val();null!=n&&""!=n||(e=!0)})),e)return ShowPopupModal("Not all input fields are set.");t();let n=new XMLHttpRequest;n.open("POST",$("#edit-description-form").attr("action")),n.onload=function(e){ShowPopupModal("Details Saved!")};let a=new FormData(document.getElementById("edit-description-form"));n.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 n=!1,s=(e,t)=>{0==n?(ShowNotification(`
Upload in progress

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

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

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

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

Check your Internet Connection!

","upload-network-issue",void 0,5e3,!0),f>20))return e(t);await y().then((t=>{e(t)}))}else e(t)})).catch((async t=>{if(f++,f>3)return e(chunkRes);await y().then((t=>{e(t)}))}))}));await y().then((e=>"fail"===e.result?(m=!0,RemoveNotification("upload-progress"),a(!0),ShowPopupModal("A fatal error occured. Please try again.")):"done"===e.status?(RemoveNotification("upload-progress"),a(!0),ShowPopupModal(`Upload complete for platform ${t}!`,(()=>{}))):(c=n/d,void s(c,0==c?0:(1/c-1)*(Date.now()-r)))))}}))}))})()}));