(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{151:function(e,t,n){"use strict";n.r(t);var c=n(0),o=n(5),s=n(4),i=n(12),a=n(6),r=n(9),l=n(15);function b(e){Object(c.e)(e,"svelte-vgthxo",'.container.svelte-vgthxo.svelte-vgthxo{background:transparent;color:#555;width:100%;box-sizing:border-box;border:3px dashed currentColor;transition:.2s border-color, .2s color;border-radius:20px;min-height:90px;font:inherit;display:flex;align-items:center;justify-content:center;text-align:center;overflow:hidden;position:relative;cursor:pointer;padding:4px}[theme="dark"] .container.svelte-vgthxo.svelte-vgthxo{color:#aaa}.dropping.svelte-vgthxo.svelte-vgthxo,.container.svelte-vgthxo.svelte-vgthxo:focus-visible,.container.svelte-vgthxo.svelte-vgthxo:active{color:rgb(79, 123, 211)}[theme="dark"] .dropping.svelte-vgthxo.svelte-vgthxo,[theme="dark"] .container.svelte-vgthxo.svelte-vgthxo:focus-visible,[theme="dark"] .container.svelte-vgthxo.svelte-vgthxo:active{color:rgb(178, 195, 228)}.placeholder.svelte-vgthxo.svelte-vgthxo{font-size:1.5em}.selected.svelte-vgthxo.svelte-vgthxo{display:flex;align-items:center;justify-content:center;flex-wrap:wrap}.selected.svelte-vgthxo>.svelte-vgthxo:not(:last-child){margin-right:12px}')}function d(e,t,n){const c=e.slice();return c[10]=t[n],c}function p(e){let t,n,o=e[4]("fileInput.select")+"";return{c(){t=Object(c.v)("div"),n=Object(c.Y)(o),Object(c.g)(t,"class","placeholder svelte-vgthxo")},m(e,o){Object(c.E)(e,t,o),Object(c.d)(t,n)},p(e,t){16&t&&o!==(o=e[4]("fileInput.select")+"")&&Object(c.Q)(n,o)},d(e){e&&Object(c.u)(t)}}}function O(e){let t,n,o,s,i,a,r,l,b,p=e[4]("fileInput.selected").replace("{file}",e[0].name)+"",O=e[4]("fileInput.clear")+"",u=e[1],g=[];for(let t=0;tObject(c.h)(t,"dropping",s)),t.$on("drop",e[7]),{c(){Object(c.o)(t.$$.fragment)},m(e,n){Object(c.H)(t,e,n),o=!0},p(e,[o]){const s={};8223&o&&(s.$$scope={dirty:o,ctx:e}),!n&&8&o&&(n=!0,s.dropping=e[3],Object(c.b)(()=>n=!1)),t.$set(s)},i(e){o||(Object(c.cb)(t.$$.fragment,e),o=!0)},o(e){Object(c.db)(t.$$.fragment,e),o=!1},d(e){Object(c.s)(t,e)}}}function m(e,t,n){let o;Object(c.l)(e,s.a,e=>n(4,o=e));const i=[".png",".jpg",".jpeg",".bmp",".svg",".ico",".gif"];let a,r,{file:l}=t,{previewSizes:b}=t;return e.$$set=e=>{"file"in e&&n(0,l=e.file),"previewSizes"in e&&n(1,b=e.previewSizes)},e.$$.update=()=>{5&e.$$.dirty&&(l?(r&&URL.revokeObjectURL(r),n(2,r=URL.createObjectURL(l))):r&&(URL.revokeObjectURL(r),n(2,r=null)))},[l,b,r,a,o,e=>{e.stopPropagation(),n(0,l=null)},()=>{const e=document.createElement("input");e.type="file",e.accept=i.join(","),e.addEventListener("change",e=>{const t=e.target.files;t.length?n(0,l=t[0]):n(0,l=null)}),document.body.appendChild(e),e.click(),e.remove()},({detail:e})=>{const t=e.files[0];i.some(e=>t.name.endsWith(e))&&n(0,l=t)},function(e){a=e,n(3,a)}]}class h extends c.a{constructor(e){super(),Object(c.C)(this,e,m,g,c.M,{file:0,previewSizes:1},b)}}var v=h;function f(e){Object(c.e)(e,"svelte-1vgg5z0","textarea.svelte-1vgg5z0{box-sizing:border-box;width:100%;min-width:100%;height:100px}")}function w(e){let t,n,o,s;return{c(){t=Object(c.v)("textarea"),t.value=n=e[0].join("\n"),Object(c.g)(t,"class","svelte-1vgg5z0")},m(n,i){Object(c.E)(n,t,i),o||(s=Object(c.G)(t,"change",e[1]),o=!0)},p(e,[c]){1&c&&n!==(n=e[0].join("\n"))&&(t.value=n)},i:c.I,o:c.I,d(e){e&&Object(c.u)(t),o=!1,s()}}}function x(e,t,n){let{extensions:c}=t;return e.$$set=e=>{"extensions"in e&&n(0,c=e.extensions)},[c,e=>{n(0,c=e.target.value.split("\n").filter(e=>e))}]}class k extends c.a{constructor(e){super(),Object(c.C)(this,e,x,w,c.M,{extensions:0},f)}}var y=k;function $(e){Object(c.e)(e,"svelte-fiwpjx","a.svelte-fiwpjx{text-decoration:none}a.svelte-fiwpjx:hover{text-decoration:underline}")}function E(e){let t,n,o;return{c(){t=Object(c.v)("a"),n=Object(c.Y)("(?)"),Object(c.g)(t,"href",e[1]),Object(c.g)(t,"title",o=e[0]("options.learnMore")),Object(c.g)(t,"target","_blank"),Object(c.g)(t,"rel","noopener noreferrer"),Object(c.g)(t,"class","svelte-fiwpjx")},m(e,o){Object(c.E)(e,t,o),Object(c.d)(t,n)},p(e,[n]){1&n&&o!==(o=e[0]("options.learnMore"))&&Object(c.g)(t,"title",o)},i:c.I,o:c.I,d(e){e&&Object(c.u)(t)}}}function S(e,t,n){let o;Object(c.l)(e,s.a,e=>n(0,o=e));let{slug:i}=t,{href:a}=t;const r=i?"https://docs.turbowarp.org/"+i:a;return e.$$set=e=>{"slug"in e&&n(2,i=e.slug),"href"in e&&n(3,a=e.href)},[o,r,i,a]}class U extends c.a{constructor(e){super(),Object(c.C)(this,e,S,E,c.M,{slug:2,href:3},$)}}var _=U;function C(e){let t,n,o;return{c(){t=Object(c.v)("input"),Object(c.g)(t,"type","color")},m(s,i){Object(c.E)(s,t,i),Object(c.R)(t,e[0]),n||(o=Object(c.G)(t,"input",e[1]),n=!0)},p(e,[n]){1&n&&Object(c.R)(t,e[0])},i:c.I,o:c.I,d(e){e&&Object(c.u)(t),n=!1,o()}}}function q(e,t,n){let{value:c}=t;return e.$$set=e=>{"value"in e&&n(0,c=e.value)},[c,function(){c=this.value,n(0,c)}]}class R extends c.a{constructor(e){super(),Object(c.C)(this,e,q,C,c.M,{value:0})}}var T=R,I=n(19);var A=async e=>{if("object"==typeof crypto&&crypto.subtle&&crypto.subtle.digest){const t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,"0")).join("")}const t=new(0,(await Promise.all([n.e(0),n.e(5)]).then(n.t.bind(null,149,7))).default);return t.update(new Uint8Array(e)),t.digest("hex")};var L=e=>e.replace(/["'<>&]/g,e=>{switch(e){case'"':return""";case"'":return"'";case"<":return"<";case">":return">";case"&":return"&"}});const N=e=>["https://packagerdata.turbowarp.org/"+e,"https://blobs.turbowarp.xyz/"+e],P=e=>"scaffolding/"+e;var M={"nwjs-win64":{src:N("nwjs-v0.68.1-win-x64.zip"),sha256:"82527d29f060bad7ec041f7c0536b1376f8bad5e5584adf7e3cf7205755a106c",estimatedSize:119821598},"nwjs-win32":{src:N("nwjs-v0.68.1-win-ia32.zip"),sha256:"7dd3104c2726082a8acd8973af2b2b223bc97960b722ec141b9bf07d84a0281b",estimatedSize:112613344},"nwjs-mac":{src:N("nwjs-v0.68.1-osx-x64.zip"),sha256:"4b1356302738a45f7ee212f6ecb997eb5d31403bfc45a7dd58429c968a1f581a",estimatedSize:119091132},"nwjs-linux-x64":{src:N("nwjs-v0.68.1-linux-x64.zip"),sha256:"5f597add1a2b6f13592117cc955111cea8211c13b21165e29c6616f385df5b94",estimatedSize:135854818},"electron-win32":{src:N("electron-v22.3.27-win32-ia32.zip"),sha256:"47bd498e5513529c5e141394fc9fd610cba1dcdea9e6dbb165edf929cbfd9af2",estimatedSize:90856612},"electron-win64":{src:N("electron-v22.3.27-win32-x64.zip"),sha256:"1a02c0f7af9664696f790dcce05948f0458a2f4f2d48c685f911d2eb99a4c9da",estimatedSize:96605498},"electron-win-arm":{src:N("electron-v22.3.27-win32-arm64.zip"),sha256:"0e4ad218018c0881ef4de363107a94dd2ced40367a0e18ca7d0dde1f40da0531",estimatedSize:94065344},"electron-mac":{src:N("electron-v22.3.27-macos-universal.zip"),sha256:"598b35f9030fe30f81b4041be048cd0374f675bd1bc0f172c26cf2808e80a3d9",estimatedSize:160882083},"electron-linux64":{src:N("electron-v22.3.27-linux-x64.zip"),sha256:"631d8eb08098c48ce2b29421e74c69ac0312b1e42f445d8a805414ba1242bf3a",estimatedSize:93426892},"electron-linux-arm32":{src:N("electron-v22.3.27-linux-armv7l.zip"),sha256:"9f8372606e5ede83cf1c73a3d8ff07047e4e3ef614aa89a76cd497dc06cf119d",estimatedSize:82722572},"electron-linux-arm64":{src:N("electron-v22.3.27-linux-arm64.zip"),sha256:"60279395a5ce4eaf3c08f1e717771b203830902d3fe3a7c311bc37deb1a0e15e",estimatedSize:93932512},"webview-mac":{src:N("WebView-macos-5.zip"),sha256:"b5636571cd9be2aae2f6dac1ab090fdf829c8fdfe91f462cc2feb2d324705f9f",estimatedSize:3425601},scaffolding:{src:P("scaffolding-full.js"),estimatedSize:4564032,useBuildId:!0},"scaffolding-min":{src:P("scaffolding-min.js"),estimatedSize:2530463,useBuildId:!0},addons:{src:P("addons.js"),estimatedSize:19931,useBuildId:!0}},z=n(11),B=n(14);const H=e=>new Promise((t,n)=>{e.toBlob(e=>{e?t(e):n(new Error("Could not read as blob"))})});var F=async e=>{const{Icns:t,Buffer:c}=await Promise.all([n.e(0),n.e(1)]).then(n.bind(null,150)),o=new Blob([e],{type:"image/png"}),s=URL.createObjectURL(o),i=await(a=s,new Promise((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=()=>t(new Error("Could not load image: "+a)),n.src=a}));var a;const r=[{type:"ic04",size:16},{type:"ic07",size:128},{type:"ic08",size:256},{type:"ic09",size:512},{type:"ic10",size:1024},{type:"ic11",size:32},{type:"ic12",size:64},{type:"ic13",size:256},{type:"ic14",size:512}].filter(e=>16===e.size||i.width>=e.size&&i.height>=e.size),l=document.createElement("canvas"),b=l.getContext("2d");if(!b)throw new Error("cannot get canvas rendering context");const d=new t.Icns;for(const e of r){const n=e.size;l.width=n,l.height=n,b.drawImage(i,0,0,n,n);const o=await H(l),s=await Object(B.a)(o),a=await t.IcnsImage.fromPNG(c.from(s),e.type);d.append(a)}return d.data};const Y="f0cabceedcb37aba953c1da70c848bcfbc74d5632c674716e4df2e96492d8d44",W=e=>{const t=e=>(40===e&&(e=60),41===e&&(e=62),e-42),n=e.indexOf(","),c=+e.substring(0,n).split("").map(e=>String.fromCharCode(e.charCodeAt(0)-49)).join(""),o=new ArrayBuffer((s=c)%4==0?s:s+(4-s%4));var s;const i=new Uint32Array(o);for(let c=n+1,o=0;c{if("dict"===e.tagName){const t={};for(const n of e.children)"key"===n.tagName&&(t[n.textContent]=Q(n.nextElementSibling));return t}return"array"===e.tagName?Array.from(e.children).map(Q):"string"===e.tagName?e.textContent:"true"===e.tagName||"false"!==e.tagName&&(console.warn("unknown plist xml",e),null)},D=(e,t)=>{if(Array.isArray(t)){const n=e.createElement("array");for(const c of t)n.appendChild(D(e,c));return n}if("object"==typeof t){const n=e.createElement("dict");for(const[c,o]of Object.entries(t)){const t=e.createElement("key");t.textContent=c;const s=D(e,o);n.appendChild(t),n.appendChild(s)}return n}if("string"==typeof t){const n=e.createElement("string");return n.textContent=t,n}if("boolean"==typeof t){return e.createElement(t.toString())}return console.warn("unknown plist value",t),D(e,""+t)};var G=n(1),V=n(3);const J=e=>{const t=(e=>{const t=e.red/255,n=e.green/255,c=e.blue/255,o=Math.min(Math.min(t,n),c),s=Math.max(Math.max(t,n),c);let i=0,a=0;if(o!==s){i=60*((t===o?3:n===o?5:1)-(t===o?n-c:n===o?c-t:t-n)/(s-o))%360,a=(s-o)/s}return{hue:i,saturation:a,value:s}})((e=>{const t=parseInt(e.substring(1),16);return{red:t>>16&255,green:t>>8&255,blue:255&t}})(e));t.value-=.1;return(e=>{const t=e=>e.toString(16).padStart(2,"0");return`#${t(e.red)}${t(e.green)}${t(e.blue)}`})((e=>{let t=e.hue%360;t<0&&(t+=360);const n=Math.max(0,Math.min(e.saturation,1)),c=Math.max(0,Math.min(e.value,1)),o=Math.floor(t/60),s=t/60-o,i=c*(1-n),a=c*(1-n*s),r=c*(1-n*(1-s));let l,b,d;switch(o){default:case 0:l=c,b=r,d=i;break;case 1:l=a,b=c,d=i;break;case 2:l=i,b=c,d=r;break;case 3:l=i,b=a,d=c;break;case 4:l=r,b=i,d=c;break;case 5:l=c,b=i,d=a}return{red:Math.floor(255*l),green:Math.floor(255*b),blue:Math.floor(255*d)}})(t))};let Z=null;const K=async()=>(await Promise.all([n.e(0),n.e(2)]).then(n.t.bind(null,148,7))).default,X=(e,t,n)=>{e.files[t]=n},ee={title:G.APP_NAME,homepage:G.WEBSITE,license:G.COPYRIGHT_NOTICE},te={title:"Scratch",homepage:"https://scratch.mit.edu/",license:'Copyright (c) 2016, Massachusetts Institute of Technology\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.'},ne={title:"Electron",homepage:"https://www.electronjs.org/",license:'Copyright (c) Electron contributors\nCopyright (c) 2013-2020 GitHub Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n"Software"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.'},ce=`/*!\nParts of this script are from the ${G.APP_NAME} <${G.WEBSITE}>, licensed as follows:\n${ee.license}\n\nParts of this script are from Scratch , licensed as follows:\n${te.license}\n*/\n`,oe=e=>`${`

The following entries were added by the ${G.APP_NAME}

`}${e.map(({title:e,license:t,homepage:n},c)=>`\n
\n${L(e)}\nhomepage\n\n\n
\n
${L(t)}
\n
\n
\n`).join("\n")}`,se=e=>`When you try to double click on the app to run it, you will probably see this warning:\n"${e.app.packageName} cannot be opened because the developer cannot be verified."\nThis is normal. Press cancel.\n\nTo run the app:\n1) Control+click on the app file (${e.app.packageName} in the same folder as this document) and select "Open".\n2) If a warning appears, select "Open" if it's an option.\n3) If a warning appears but "Open" isn't an option, press "Cancel" and repeat from step 1.\n The open button will appear the second time the warning appears.\n\nAfter completing these steps, the app should run without any further warnings.\n\nFeel free to drag the app into your Applications folder.\n`,ie=e=>{const t=["/","\\",":","*","?","<",">","|"];if(t.some(t=>e.includes(t)))throw new Error(`Invalid package name: ${e}. It must not use the characters: ${t.join(" ")}`)};class ae extends I.b{constructor(){super(),this.project=null,this.options=ae.DEFAULT_OPTIONS(),this.aborted=!1,this.used=!1}abort(){this.aborted||(this.aborted=!0,this.dispatchEvent(new Event("abort")))}ensureNotAborted(){if(this.aborted)throw new Error("Aborted")}async fetchLargeAsset(e,t){this.ensureNotAborted();const n=M[e];if(!n)throw new Error("Invalid asset: "+e);if("undefined"!=typeof __ASSETS__&&__ASSETS__[n.src])return __ASSETS__[n.src];const c=t=>this.dispatchEvent(new I.a("large-asset-fetch",{detail:{asset:e,progress:t}}));let o;c(0);let s=!1;try{const e=await Z.getCachedAsset(n);e&&(o=e,s=!0,c(.5))}catch(e){console.warn(e)}if(!o){let e=n.src;n.useBuildId&&(e+="?"+Y),o=await Object(z.a)({url:e,type:t,estimatedSize:n.estimatedSize,progressCallback:e=>{c(e)},abortTarget:this})}if(n.useBuildId&&(i=Y,(a=o).endsWith("=^..^=")&&!a.endsWith(i+" =^..^=")))throw new V.d("Build ID does not match.");var i,a;if(n.sha256){const t=await A(o);if(t!==n.sha256)throw new Error(`Hash mismatch for ${e}, found ${t} but expected ${n.sha256}`)}if(!s)try{await Z.cacheAsset(n,o)}catch(e){console.warn(e)}return c(1),o}getAddonOptions(){return{...this.options.chunks,specialCloudBehaviors:this.options.cloudVariables.specialCloudBehaviors,unsafeCloudBehaviors:this.options.cloudVariables.unsafeCloudBehaviors,pause:this.options.controls.pause.enabled}}async loadResources(){const e=[ce];this.project.analysis.usesMusic?e.push(await this.fetchLargeAsset("scaffolding","text")):e.push(await this.fetchLargeAsset("scaffolding-min","text")),Object.values(this.getAddonOptions()).some(e=>e)&&e.push(await this.fetchLargeAsset("addons","text")),this.script=e.join("\n").replace(/<\/script>/g,"")}computeWindowSize(){let e=this.options.stageWidth,t=this.options.stageHeight;return(this.options.controls.greenFlag.enabled||this.options.controls.stopAll.enabled||this.options.controls.pause.enabled)&&(t+=48),{width:e,height:t}}getPlistPropertiesForPrimaryExecutable(){return{CFBundleIdentifier:"org.turbowarp.packager.userland."+this.options.app.packageName,CFBundleName:this.options.app.windowTitle,CFBundleDisplayName:this.options.app.windowTitle,CFBundleExecutable:this.options.app.packageName,CFBundleVersion:this.options.app.version,CFBundleShortVersionString:this.options.app.version,LSApplicationCategoryType:"public.app-category.games"}}async updatePlist(e,t,n){const c=(e=>{const t=(new DOMParser).parseFromString(e,"text/xml").children[0].children[0];return Q(t)})(await e.file(t).async("string"));Object.assign(c,n),e.file(t,(e=>{const t=document.implementation.createDocument(null,"plist"),n=t.documentElement;n.setAttribute("version","1.0"),n.appendChild(D(t,e));return'\n\n'+(new XMLSerializer).serializeToString(t)})(c))}async addNwJS(e){const t=this.options.app.packageName;ie(t);const n=await this.fetchLargeAsset(this.options.target,"arraybuffer"),c=await(await K()).loadAsync(n),o=this.options.target.startsWith("nwjs-win"),s="nwjs-mac"===this.options.target,i=this.options.target.startsWith("nwjs-linux"),a=Object.keys(c.files)[0].split("/")[0],r=new(await K());for(const e of Object.keys(c.files)){const n=c.files[e];let l=e.replace(a,t);o?l=l.replace("nw.exe",t+".exe"):s?l=l.replace("nwjs.app",t+".app"):i&&(l=l.replace(/nw$/,t)),X(r,l,n)}const l=await Z.getAppIcon(this.options.app.icon),b={name:t,main:"main.js",version:this.options.app.version,window:{width:this.computeWindowSize().width,height:this.computeWindowSize().height,icon:"icon.png"}};let d;if(o)d=t+"/";else if(s){r.file(`${t}/How to run ${t}.txt`,se(this.options));const e=await F(l);r.file(`${t}/${t}.app/Contents/Resources/app.icns`,e),d=`${t}/${t}.app/Contents/Resources/app.nw/`}else if(i){const e='#!/bin/bash\ncd "$(dirname "$0")"\n./'+t;r.file(t+"/start.sh",e,{unixPermissions:33261}),d=t+"/"}for(const t of Object.keys(e.files))X(r,d+t,e.files[t]);r.file(d+"icon.png",l),r.file(d+"package.json",JSON.stringify(b,null,4)),r.file(d+"main.js","\n const start = () => nw.Window.open('index.html', {\n position: 'center',\n new_instance: true\n });\n nw.App.on('open', start);\n start();");const p=t+"/credits.html",O=await r.file(p).async("string");return r.file(p,O+oe([ee,te])),r}async addElectron(e){const t=this.options.app.packageName;ie(t);const n=await this.fetchLargeAsset(this.options.target,"arraybuffer"),c=await(await K()).loadAsync(n),o=this.options.target.includes("win"),s=this.options.target.includes("mac"),i=this.options.target.includes("linux"),a=new(await K());for(const e of Object.keys(c.files)){const n=c.files[e];let r;r=s?e:`${t}/${e}`,o?r=r.replace("electron.exe",t+".exe"):s?(r=r.replace("Electron.app",t+".app"),r=r.replace(/Electron$/,t)):i&&(r=r.replace(/electron$/,t)),X(a,r,n)}const r=s?"":t+"/",l=await a.file(r+"LICENSES.chromium.html").async("string");a.file(r+"licenses.html",l+oe([ee,te,ne])),a.remove(r+"LICENSE.txt"),a.remove(r+"LICENSES.chromium.html"),a.remove(r+"LICENSE"),a.remove(r+"version"),a.remove(r+"resources/default_app.asar");const b=s?`${r}${t}.app/Contents/`:r,d=s?b+"Resources/app/":b+"resources/app/",p=await Z.getAppIcon(this.options.app.icon);a.file(d+"icon.png",p);const O={name:t,main:"electron-main.js",version:this.options.app.version};a.file(d+"package.json",JSON.stringify(O,null,4));const j=`'use strict';\nconst {app, BrowserWindow, Menu, shell, screen, dialog} = require('electron');\nconst path = require('path');\n\nconst isWindows = process.platform === 'win32';\nconst isMac = process.platform === 'darwin';\nconst isLinux = process.platform === 'linux';\n\nif (isMac) {\n Menu.setApplicationMenu(Menu.buildFromTemplate([\n { role: 'appMenu' },\n { role: 'fileMenu' },\n { role: 'editMenu' },\n { role: 'windowMenu' },\n { role: 'help' }\n ]));\n} else {\n Menu.setApplicationMenu(null);\n}\n\nconst resourcesURL = Object.assign(new URL('file://'), {\n pathname: path.join(__dirname, '/')\n}).href;\nconst defaultProjectURL = new URL('./index.html', resourcesURL).href;\n\nconst createWindow = (windowOptions) => {\n const options = {\n title: ${JSON.stringify(this.options.app.windowTitle)},\n icon: path.resolve(__dirname, ${JSON.stringify("icon.png")}),\n useContentSize: true,\n webPreferences: {\n sandbox: true,\n contextIsolation: true,\n nodeIntegration: false,\n },\n show: true,\n width: 480,\n height: 360,\n ...windowOptions,\n };\n\n const activeScreen = screen.getDisplayNearestPoint(screen.getCursorScreenPoint());\n const bounds = activeScreen.workArea;\n options.x = bounds.x + ((bounds.width - options.width) / 2);\n options.y = bounds.y + ((bounds.height - options.height) / 2);\n\n const window = new BrowserWindow(options);\n return window;\n};\n\nconst createProjectWindow = (url) => {\n const windowMode = ${JSON.stringify(this.options.app.windowMode)};\n const options = {\n show: false,\n backgroundColor: ${JSON.stringify(this.options.appearance.background)},\n width: ${this.computeWindowSize().width},\n height: ${this.computeWindowSize().height},\n minWidth: 50,\n minHeight: 50,\n };\n // fullscreen === false disables fullscreen on macOS so only set this property when it's true\n if (windowMode === 'fullscreen') {\n options.fullscreen = true;\n }\n const window = createWindow(options);\n if (windowMode === 'maximize') {\n window.maximize();\n }\n window.loadURL(url);\n window.show();\n};\n\nconst createDataWindow = (dataURI) => {\n const window = createWindow({});\n window.loadURL(dataURI);\n};\n\nconst isResourceURL = (url) => {\n try {\n const parsedUrl = new URL(url);\n return parsedUrl.protocol === 'file:' && parsedUrl.href.startsWith(resourcesURL);\n } catch (e) {\n // ignore\n }\n return false;\n};\n\nconst SAFE_PROTOCOLS = [\n 'https:',\n 'http:',\n 'mailto:',\n];\n\nconst isSafeOpenExternal = (url) => {\n try {\n const parsedUrl = new URL(url);\n return SAFE_PROTOCOLS.includes(parsedUrl.protocol);\n } catch (e) {\n // ignore\n }\n return false;\n};\n\nconst isDataURL = (url) => {\n try {\n const parsedUrl = new URL(url);\n return parsedUrl.protocol === 'data:';\n } catch (e) {\n // ignore\n }\n return false;\n};\n\nconst openLink = (url) => {\n if (isDataURL(url)) {\n createDataWindow(url);\n } else if (isResourceURL(url)) {\n createProjectWindow(url);\n } else if (isSafeOpenExternal(url)) {\n shell.openExternal(url);\n }\n};\n\napp.on('render-process-gone', (event, webContents, details) => {\n const window = BrowserWindow.fromWebContents(webContents);\n dialog.showMessageBoxSync(window, {\n type: 'error',\n title: 'Error',\n message: 'Renderer process crashed: ' + details.reason + ' (' + details.exitCode + ')'\n });\n});\n\napp.on('child-process-gone', (event, details) => {\n dialog.showMessageBoxSync({\n type: 'error',\n title: 'Error',\n message: details.type + ' child process crashed: ' + details.reason + ' (' + details.exitCode + ')'\n });\n});\n\napp.on('web-contents-created', (event, contents) => {\n contents.setWindowOpenHandler((details) => {\n setImmediate(() => {\n openLink(details.url);\n });\n return {action: 'deny'};\n });\n contents.on('will-navigate', (e, url) => {\n if (!isResourceURL(url)) {\n e.preventDefault();\n openLink(url);\n }\n });\n contents.on('before-input-event', (e, input) => {\n const window = BrowserWindow.fromWebContents(contents);\n if (!window || input.type !== "keyDown") return;\n if (input.key === 'F11' || (input.key === 'Enter' && input.alt)) {\n window.setFullScreen(!window.isFullScreen());\n } else if (input.key === 'Escape' && window.isFullScreen()) {\n window.setFullScreen(false);\n }\n });\n});\n\napp.on('session-created', (session) => {\n session.webRequest.onBeforeRequest({\n urls: ["file://*"]\n }, (details, callback) => {\n callback({\n cancel: !details.url.startsWith(resourcesURL)\n });\n });\n});\n\napp.on('window-all-closed', () => {\n app.quit();\n});\n\napp.whenReady().then(() => {\n createProjectWindow(defaultProjectURL);\n});\n`;a.file(d+"electron-main.js",j);for(const[t,n]of Object.entries(e.files))X(a,`${d}${t}`,n);if(o){const e=["1) Extract the whole zip",`2) Open "${t}.exe" to start the app.`,'Open "licenses.html" for information regarding open source software used by the app.'].join("\n\n");a.file(r+"README.txt",e)}else if(s){a.file(`How to run ${this.options.app.packageName}.txt`,se(this.options));const e=this.getPlistPropertiesForPrimaryExecutable();await this.updatePlist(a,b+"Info.plist",e);const t=["Electron Helper","Electron Helper (GPU)","Electron Helper (Renderer)","Electron Helper (Plugin)"];for(const n of t)await this.updatePlist(a,`${b}Frameworks/${n}.app/Contents/Info.plist`,{CFBundleIdentifier:e.CFBundleIdentifier+".helper",CFBundleDisplayName:n.replace("Electron",this.options.app.packageName),CFBundleVersion:this.options.app.version,CFBundleShortVersionString:this.options.app.version});const n=await F(p);a.file(b+"Resources/electron.icns",n)}else if(i){const e='#!/bin/bash\ncd "$(dirname "$0")"\n./'+t;a.file(r+"start.sh",e,{unixPermissions:33261})}return a}async addWebViewMac(e){ie(this.options.app.packageName);const t=await this.fetchLargeAsset(this.options.target,"arraybuffer"),n=await(await K()).loadAsync(t),c=this.options.app.packageName+".app",o=c+"/Contents/",s=c+"/Contents/Resources/",i=new(await K());for(const[e,t]of Object.entries(n.files)){const n=e.replace("WebView.app",c).replace(/WebView$/,this.options.app.packageName);X(i,n,t)}for(const[t,n]of Object.entries(e.files))X(i,`${s}${t}`,n);const a=await Z.getAppIcon(this.options.app.icon),r=await F(a);i.file(s+"AppIcon.icns",r),i.remove(s+"Assets.car");const l=parseInt(this.options.appearance.background.substr(1),16),b={title:this.options.app.windowTitle,background:[l>>16&255,l>>8&255,255&l,1],width:this.computeWindowSize().width,height:this.computeWindowSize().height};return i.file(s+"application_config.json",JSON.stringify(b)),await this.updatePlist(i,o+"Info.plist",this.getPlistPropertiesForPrimaryExecutable()),i.file(`How to run ${this.options.app.packageName}.txt`,se(this.options)),i}makeWebSocketProvider(){const e="wss://clouddata.turbowarp.org"===this.options.cloudVariables.cloudHost?["wss://clouddata.turbowarp.org","wss://clouddata.turbowarp.xyz"]:this.options.cloudVariables.cloudHost;return`new Scaffolding.Cloud.WebSocketProvider(${JSON.stringify(e)}, ${JSON.stringify(this.options.projectId)})`}makeLocalStorageProvider(){return`new Scaffolding.Cloud.LocalStorageProvider(${JSON.stringify("cloudvariables:"+this.options.projectId)})`}makeCustomProvider(){const e=this.options.cloudVariables.custom;let t="{const providers = {};\n";for(const n of new Set(Object.values(e)))"ws"===n?t+=`providers.ws = ${this.makeWebSocketProvider()};\n`:"local"===n&&(t+=`providers.local = ${this.makeLocalStorageProvider()};\n`);t+="for (const provider of Object.values(providers)) scaffolding.addCloudProvider(provider);\n";for(const n of Object.keys(e)){const c=e[n];t+=`scaffolding.addCloudProviderOverride(${JSON.stringify(n)}, providers[${JSON.stringify(c)}] || null);\n`}return t+="}",t}generateFilename(e){return`${this.options.app.windowTitle}.${e}`}async generateGetProjectData(){let e,t,n="",c="",o=!1;if("html"===this.options.target){o="blob"!==this.project.type,e=.75,t=.98;const r=1e5,l=(e=>{const t=e.byteLength;let n;if(t%4!=0){const c=new ArrayBuffer(t+(4-t%4)),o=new Uint8Array(e),s=new Uint8Array(c);for(let e=0;e60===(e+=42)?40:62===e?41:e;for(let e=0;e${l.substr(e,r)}<\/script>