';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 `},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
","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(`