diff --git a/README.md b/README.md index 16eb57f..7263f6f 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ To use this add-on you must uncheck "Project/Advanced/Use worker" option: ## Download -[Add-on](https://github.com/gritsenko/c3_spine_plugin/releases/download/v1/Spine-v1.3.0.c3addon) +[Add-on](https://github.com/gritsenko/c3_spine_plugin/releases/download/v1/Spine-v1.4.0.c3addon) -[Sample project](https://github.com/gritsenko/c3_spine_plugin/releases/download/v1/SpinePluginTest.c3p) +[Sample project](https://github.com/gritsenko/c3_spine_plugin/releases/download/v1.4.0/SpinePluginTest.c3p) ## LIVE DEMO [https://gritsenko.github.io/c3_spine_plugin/docs/LiveDemo/index.html](https://gritsenko.github.io/c3_spine_plugin/docs/LiveDemo/index.html) diff --git a/dist/Spine-v1.4.0..c3addon b/dist/Spine-v1.4.0..c3addon new file mode 100644 index 0000000..106d37a Binary files /dev/null and b/dist/Spine-v1.4.0..c3addon differ diff --git a/docs/LiveDemo/data.json b/docs/LiveDemo/data.json index a1d6758..4b41775 100644 --- a/docs/LiveDemo/data.json +++ b/docs/LiveDemo/data.json @@ -1 +1 @@ -{"project":["SpinePluginTest",null,[[0,false,true,true,false,true,true,true,true,true],[2,true,false,false,false,false,false,false,false,false],[3,false,true,true,true,true,true,true,true,false],[4,true,false,false,false,false,false,false,false,false],[5,false,true,true,true,true,true,true,true,false],[6,true,false,false,false,false,false,false,false,false]],[["SpineCharacter",0,false,[],1,0,["images/shared-0-sheet0.png",3322,0,0,0,250,250],null,[["8Direction",1,971849326318143]],false,false,708886617025756,[],null,0],["Keyboard",2,false,[],0,0,null,null,[],false,false,448378265906156,[],null,1,[]],["Sprite",3,false,[],0,0,null,[["Animation 1",5,false,1,0,false,741410374589640,[["images/shared-0-sheet2.png",6695,0,0,168,248,1,0.5,0.5,[],[-0.49404761904761907,-0.4959677419354839,0,-0.5,0.48809523809523814,-0.4959677419354839,0.48809523809523814,0,0.29761904761904767,0.3629032258064516,0,0.3629032258064516,-0.3035714285714286,0.3629032258064516,-0.49404761904761907,0],0]]]],[],false,false,886700548662699,[],null,2],["Sprite2",3,false,[],0,0,null,[["Animation 1",5,false,1,0,false,717641720423608,[["images/shared-0-sheet1.png",14996,0,0,237,237,1,0.5,0.5,[],[-0.3270042194092827,-0.3270042194092827,0,-0.3396624472573839,0.2721518987341772,-0.27637130801687765,0.4620253164556962,0,0.26793248945147674,0.26793248945147674,0,0.36919831223628696,-0.2805907172995781,0.2763713080168776,-0.5,0],0]]]],[],false,false,108703857865790,[],null,3],["Browser",4,false,[],0,0,null,null,[],false,false,778747613166461,[],null,4,[]],["Text",5,false,[],0,0,null,null,[],false,false,650905651038003,[],null,5],["Mouse",6,false,[],0,0,null,null,[],false,false,258289131195630,[],null,6,[]]],[],[["Layout 1",1708,960,false,"Event sheet 1",314783196911307,[["Layer 0",0,201656680313375,true,[201,188,165],false,1,1,1,false,false,1,0,0,[[[57,82,0,107.53079078915925,158.73592926018748,0,0,[1,1,1,1],0.5,0.5,0,0,[]],2,3,[],[],[true,"Animation 1",0,true]],[[200.64038681256912,207.64038681256912,0,238.56472277260414,238.56472277260414,0,0,[1,1,1,1],0.5,0.5,0,0,[]],0,10,[],[[200,1200,800,3,0,true,true]],["character.json","character.atlas","character.png","skin_1","01_idle"]],[[370,523,0,107.53079078915925,158.73592926018748,0,0,[1,1,1,1],0.5,0.5,0,0,[]],2,2,[],[],[true,"Animation 1",0,true]],[[413,766,0,107.53079078915925,158.73592926018748,0,0,[1,1,1,1],0.5,0.5,0,0,[]],2,4,[],[],[true,"Animation 1",0,true]],[[42,810,0,56.568542494923804,56.568542494923804,0,0,[1,1,1,0.5],0.5,0.5,0,0,[]],3,5,[],[],[true,"Animation 1",0,true]],[[79,792,0,264,41,0,0,[1,1,1,0.5],0,0,0,0,[]],5,7,[],[],["Get more assets",true,"Arial",22,0,true,false,[0.47058823529411764,0.47058823529411764,0.47058823529411764],0,0,0,true,0]]],[],0]],[],[]]],[["Event sheet 1",[[0,0,false,null,554690986948981,1,[[0,7,null,1,false,false,false,694463840700527,null]],[[-1,8,null,381813849675962,0,null,[[1,[0]],[3,1]]]]],[3,[false,"Main"],false,null,823723420148170,2,[[-1,9,null,0,false,false,false,0,false,[[1,[0]]]]],[],[[0,0,false,null,727071623645836,3,[[1,10,null,1,false,false,false,609606150967207,null,[[9,39]]]],[[0,11,null,288951721364919,0,null,[[16,false]]],[-2,"SetRunState",null,247184081469331,0,null]]],[0,0,false,null,530794082250574,4,[[1,12,null,0,false,true,false,460765857961525,null,[[9,39]]],[1,12,null,0,false,true,false,192265172835824,null,[[9,37]]],[1,12,null,0,false,true,false,679205180471502,null,[[9,38]]],[1,12,null,0,false,true,false,661767758020543,null,[[9,40]]],[-1,13,null,0,false,false,false,772655505680224,null]],[[-2,"SetIdleState",null,481431259685139,0,null]]],[0,0,false,null,336433050100178,5,[[1,10,null,1,false,false,false,782064121935287,null,[[9,37]]]],[[0,11,null,295920835649818,0,null,[[16,true]]],[-2,"SetRunState",null,787243115434873,0,null]]],[0,0,false,null,209014263658449,6,[[1,10,null,1,false,false,false,185905863038369,null,[[9,38]]]],[[-2,"SetRunState",null,482068393692473,0,null]]],[0,0,false,null,362044810182279,7,[[1,10,null,1,false,false,false,934502453496615,null,[[9,40]]]],[[-2,"SetRunState",null,827681765315319,0,null]]]]],[0,0,false,null,547411667985614,8,[[1,10,null,1,false,false,false,307511299237439,null,[[9,13]]]],[[-3,14,[false,false,0]]]],[4,["SetRunState",0,[],true],false,null,931697301972769,9,[[-1,15,null,0,false,false,false,775890013400469,null,[[7,[1,[1,0,16,true]]],[8,1],[7,[2]]]]],[[0,17,null,498623385655640,0,null,[[1,[3]],[16,true]]]]],[4,["SetIdleState",0,[],true],false,null,560252219812848,10,[[-1,15,null,0,false,false,false,141817586674388,null,[[7,[1,[1,0,16,true]]],[8,1],[7,[4]]]]],[[0,17,null,256267695449666,0,null,[[1,[5]],[16,true]]]]],[0,0,false,null,866905531542252,11,[[1,10,null,1,false,false,false,592601471479746,null,[[9,32]]]],[[0,17,null,463327720279473,0,null,[[1,[6]],[16,false]]]]],[0,0,true,null,797855408100176,12,[[6,18,null,0,false,false,false,205337430933907,null,[[4,5]]]],[],[[0,0,false,null,942185305962403,13,[],[[3,19,null,978230362166950,0,null,[[0,[7]]]],[5,20,null,919575884074656,0,null,[[0,[7]]]],[6,21,null,669947818700663,0,null,[[3,1]]]]]]],[0,0,false,null,797514448039221,14,[[-1,22,null,0,false,false,false,935567796966527,null]],[[6,21,null,135537856545416,0,null,[[3,0]]],[5,20,null,664032193958737,0,null,[[0,[8]]]],[3,19,null,472546355712867,0,null,[[0,[8]]]]]],[0,0,false,null,228524583106898,15,[[6,23,null,1,false,false,false,162769926503585,null,[[3,0],[3,0],[4,5]]]],[[4,24,null,526314307523535,0,null,[[1,[9]],[3,0]]]]]]]],[],"media/",false,480,854,3,true,"trilinear",true,"1.0.0.0",true,false,3,2,11,false,true,1,true,false,[],"icons/",[],true,"680j78qw5qc","fonts/",[],"high-performance",[],"standard"]} \ No newline at end of file +{"project":["SpinePluginTest",null,[[0,false,true,true,true,true,true,true,true,true],[2,true,false,false,false,false,false,false,false,false],[3,false,true,true,true,true,true,true,true,false],[4,true,false,false,false,false,false,false,false,false],[5,false,true,true,true,true,true,true,true,false],[6,true,false,false,false,false,false,false,false,false]],[["SpineCharacter",0,false,[],1,0,["images/shared-0-sheet0.png",3322,0,0,0,250,250],null,[["8Direction",1,971849326318143,0]],false,false,708886617025756,[],null,1],["Keyboard",2,false,[],0,0,null,null,[],false,false,448378265906156,[],null,2,[]],["Sprite",3,false,[],0,0,null,[["Animation 1",5,false,1,0,false,741410374589640,[["images/shared-0-sheet2.png",6695,0,0,168,248,1,0.5,0.5,[],[-0.49404761904761907,-0.4959677419354839,0,-0.5,0.48809523809523814,-0.4959677419354839,0.48809523809523814,0,0.29761904761904767,0.3629032258064516,0,0.3629032258064516,-0.3035714285714286,0.3629032258064516,-0.49404761904761907,0],0]]]],[],false,false,886700548662699,[],null,3],["Sprite2",3,false,[],0,0,null,[["Animation 1",5,false,1,0,false,717641720423608,[["images/shared-0-sheet1.png",14996,0,0,237,237,1,0.5,0.5,[],[-0.3270042194092827,-0.3270042194092827,0,-0.3396624472573839,0.2721518987341772,-0.27637130801687765,0.4620253164556962,0,0.26793248945147674,0.26793248945147674,0,0.36919831223628696,-0.2805907172995781,0.2763713080168776,-0.5,0],0]]]],[],false,false,108703857865790,[],null,4],["Browser",4,false,[],0,0,null,null,[],false,false,778747613166461,[],null,5,[]],["Text",5,false,[],0,0,null,null,[],false,false,650905651038003,[],null,6],["Mouse",6,false,[],0,0,null,null,[],false,false,258289131195630,[],null,7,[]],["AnimationText",5,false,[],0,0,null,null,[],false,false,638163697302026,[],null,8],["AnimationText2",5,false,[[229104675276951,1,"Value",9]],0,0,null,null,[],false,false,279098545763967,[],null,10],["AnimationText3",5,false,[[953542609703342,1,"Value",9]],0,0,null,null,[],false,false,906826237856803,[],null,11]],[],[["Layout 1",1708,960,false,"Event sheet 1",314783196911307,[["Layer 0",0,201656680313375,true,[201,188,165],false,1,1,1,false,false,1,0,0,[[[57,82,0,107.53079078915925,158.73592926018748,0,0,[1,1,1,1],0.5,0.5,0,0,[]],2,3,[],[],[true,"Animation 1",0,true]],[[200.64038681256912,207.64038681256912,0,238.56472277260414,238.56472277260414,0,0,[1,1,1,1],0.5,0.5,0,0,[]],0,10,[],[[200,1200,800,3,0,true,true]],["character.json","character.atlas","character.png","skin_1","01_idle","",0.7,true]],[[370,523,0,107.53079078915925,158.73592926018748,0,0,[1,1,1,1],0.5,0.5,0,0,[]],2,2,[],[],[true,"Animation 1",0,true]],[[413,766,0,107.53079078915925,158.73592926018748,0,0,[1,1,1,1],0.5,0.5,0,0,[]],2,4,[],[],[true,"Animation 1",0,true]],[[42,810,0,56.568542494923804,56.568542494923804,0,0,[1,1,1,0.5],0.5,0.5,0,0,[]],3,5,[],[],[true,"Animation 1",0,true]],[[79,792,0,264,41,0,0,[1,1,1,0.5],0,0,0,0,[]],5,7,[],[],["Assets from Murlykla",true,"Arial",17,0,true,false,[0.47058823529411764,0.47058823529411764,0.47058823529411764],0,0,0,true,0]],[[122,11,0,200,30,0,0,[1,1,1,1],0,0,0,0,[]],7,11,[],[],["Is Running ",true,"Arial",12,0,false,false,[0,0,0],0,0,0,true,0]],[[120,37,0,200,30,0,0,[1,1,1,1],0,0,0,0,[]],8,12,[0],[],["Any animation finished: 0",true,"Arial",12,0,false,false,[0,0,0],0,0,0,true,0]],[[120,63,0,200,30,0,0,[1,1,1,1],0,0,0,0,[]],9,13,[0],[],["Run animation finished: 0",true,"Arial",12,0,false,false,[0,0,0],0,0,0,true,0]]],[],0]],[],[]]],[["Event sheet 1",[[0,0,false,null,554690986948981,1,[[0,7,null,1,false,false,false,694463840700527,null]],[[-1,8,null,381813849675962,0,null,[[1,[0]],[3,1]]],[-2,"SetIdleState",null,612765897866696,0,null]]],[3,[false,"Main"],false,null,823723420148170,2,[[-1,9,null,0,false,false,false,0,false,[[1,[0]]]]],[],[[0,0,false,null,727071623645836,3,[[1,10,null,1,false,false,false,609606150967207,null,[[9,39]]]],[[0,11,null,288951721364919,0,null,[[16,false]]],[-2,"SetRunState",null,247184081469331,0,null]]],[0,0,false,null,530794082250574,4,[[1,12,null,0,false,true,false,460765857961525,null,[[9,39]]],[1,12,null,0,false,true,false,192265172835824,null,[[9,37]]],[1,12,null,0,false,true,false,679205180471502,null,[[9,38]]],[1,12,null,0,false,true,false,661767758020543,null,[[9,40]]],[-1,13,null,0,false,false,false,772655505680224,null]],[[-2,"SetIdleState",null,481431259685139,0,null]]],[0,0,false,null,336433050100178,5,[[1,10,null,1,false,false,false,782064121935287,null,[[9,37]]]],[[0,11,null,295920835649818,0,null,[[16,true]]],[-2,"SetRunState",null,787243115434873,0,null]]],[0,0,false,null,209014263658449,6,[[1,10,null,1,false,false,false,185905863038369,null,[[9,38]]]],[[-2,"SetRunState",null,482068393692473,0,null]]],[0,0,false,null,362044810182279,7,[[1,10,null,1,false,false,false,934502453496615,null,[[9,40]]]],[[-2,"SetRunState",null,827681765315319,0,null]]],[0,0,false,null,800428280887307,8,[[1,10,null,1,false,false,false,322609340410504,null,[[9,32]]]],[[0,14,null,248937731429421,0,null,[[1,[1]],[16,false]]]]],[0,0,false,null,961725521940944,9,[[0,15,null,1,false,false,false,709578475553517,null,[[1,[1]]]]],[[-2,"SetIdleState",null,415678932468507,0,null]]],[0,0,false,null,895148395534211,10,[[0,16,null,0,false,false,false,800554269029530,null,[[1,[2]]]]],[[7,17,null,422552093747724,0,null,[[7,[3]]]]]],[0,0,false,null,225137277339801,11,[[-1,18,null,0,false,false,false,970798890562933,null]],[[7,17,null,827322242916333,0,null,[[7,[4]]]]]],[4,["SetRunState",0,[],true],false,null,370032876731922,12,[[0,16,null,0,false,true,false,864968706504566,null,[[1,[2]]]]],[[0,14,null,425762001805630,0,null,[[1,[2]],[16,true]]]]],[4,["SetIdleState",0,[],true],false,null,688603524438358,13,[[0,16,null,0,false,true,false,312872308844273,null,[[1,[5]]]]],[[0,14,null,125777890775043,0,null,[[1,[6]],[16,true]]]]],[0,0,false,null,875931413505219,14,[[0,19,null,1,false,false,false,101075410889083,null]],[[8,20,null,738657914171619,0,null,[[10,0],[7,[7]]]],[8,17,null,641691253206969,0,null,[[7,[8,[2,8,false,0]]]]]]],[0,0,false,null,900400060664537,15,[[0,15,null,1,false,false,false,359173059817829,null,[[1,[2]]]]],[[9,20,null,490942428526294,0,null,[[10,0],[7,[7]]]],[9,17,null,824593299215093,0,null,[[7,[9,[2,9,false,0]]]]]]]]]]]],[],"media/",false,480,854,3,true,"trilinear",true,"1.0.0.0",true,false,3,2,14,false,true,1,true,false,[],"icons/",[],true,"680j78qw5qc","fonts/",[],"high-performance",[],"standard"]} \ No newline at end of file diff --git a/docs/LiveDemo/index.html b/docs/LiveDemo/index.html index 0070600..1499d17 100644 --- a/docs/LiveDemo/index.html +++ b/docs/LiveDemo/index.html @@ -22,7 +22,7 @@

This content requires JavaScript

JavaScript appears to be disabled. Please enable it to view this content.

-

This game was made in Construct. Make your own games

+

This game was built in Construct - a free online game maker.

diff --git a/docs/LiveDemo/offline.json b/docs/LiveDemo/offline.json index f6771c7..305cb10 100644 --- a/docs/LiveDemo/offline.json +++ b/docs/LiveDemo/offline.json @@ -1 +1 @@ -{"version":1568623391801,"fileList":["scripts/c3runtime.js","data.json","style.css","scripts/offlineclient.js","images/shared-0-sheet0.png","images/shared-0-sheet1.png","images/shared-0-sheet2.png","scripts/main.js","scripts/dispatchworker.js","scripts/jobworker.js","scripts/workermain.js","scripts/supportcheck.js","icons/loading-logo.png","icons/icon-16.png","icons/icon-32.png","icons/icon-64.png","icons/icon-128.png","icons/icon-256.png","icons/icon-512.png","character.png","character.atlas","character.json","scripts/register-sw.js"]} \ No newline at end of file +{"version":1572343095362,"fileList":["scripts/c3runtime.js","data.json","style.css","scripts/offlineclient.js","images/shared-0-sheet0.png","images/shared-0-sheet1.png","images/shared-0-sheet2.png","scripts/main.js","scripts/dispatchworker.js","scripts/jobworker.js","scripts/workermain.js","scripts/supportcheck.js","icons/loading-logo.png","icons/icon-16.png","icons/icon-32.png","icons/icon-64.png","icons/icon-128.png","icons/icon-256.png","icons/icon-512.png","character.png","character.atlas","character.json","scripts/register-sw.js"]} \ No newline at end of file diff --git a/docs/LiveDemo/scripts/c3runtime.js b/docs/LiveDemo/scripts/c3runtime.js index 4bbb275..e63e9e8 100644 --- a/docs/LiveDemo/scripts/c3runtime.js +++ b/docs/LiveDemo/scripts/c3runtime.js @@ -16,10 +16,10 @@ "use strict";{function a(a,b,c){if(!0===b){c();o.set(a,!0)}else if(b&&b.length){c(b[0]);o.set(a,!0)}else;}const b=navigator.userAgent;let c={linux:/linux|openbsd|freebsd|netbsd/i.test(b),chromeOS:/CrOS/.test(b),windowsTizen:/trident|iemobile|msie|tizen/i.test(b),genericMS:/trident|iemobile|msie|edge\//i.test(b),opera:/OPR\//.test(b),blackberry:/bb10/i.test(b),edge:/edge\//i.test(b),trident:/trident/i.test(b),webkit:/webkit/i.test(b),safari:/safari\//i.test(b),chrome:/chrome\//i.test(b),chromium:/chromium\//i.test(b),crosswalk:/crosswalk|xwalk/i.test(b),nwjs:/nwjs/i.test(b),amazonwebapp:/amazonwebappplatform/i.test(b),webview:/wv\)/.test(b),android:/android/i.test(b),nokia:/nokiabrowser\/[0-9.]+/i.test(b)},d={windows:/windows\s+nt\s+\d+\.\d+/i.exec(b),OSX:/mac\s+os\s+x\s+[0-9_]+/i.exec(b),android:/android\s+[0-9.]+/i.exec(b),opera:/OPR\/[0-9.]+/.exec(b),tizen:/tizen\s+[0-9.]+/i.exec(b),iphone:/iphone\s+os\s+[0-9_]+/i.exec(b),ipad:/ipad[^)]*os\s+[0-9_]+/i.exec(b),winPhone:/windows\s+phone\s+[0-9.]+/i.exec(b),winPhoneOS:/windows\s+phone\s+os\s+[0-9.]+/i.exec(b),chrome:/chrome\/[0-9.]+/i.exec(b),chromium:/chromium\/[0-9.]+/i.exec(b),nwjs:/nwjs\/[0-9.]+/i.exec(b),firefox:/firefox\/[0-9.]+/i.exec(b),ie:/msie\s+[0-9.]+/i.exec(b),edge:/edge\/[0-9.]+/i.exec(b),edgeChromium:/edg\/[0-9.]+/i.exec(b),silk:/silk\/[0-9.]+/i.exec(b)},e="(unknown)",f="(unknown)",g="(unknown)",h="(unknown)",i="(unknown)",j="(unknown)",k="(unknown)",l="browser",m=!1,n=!1,o=new Map;a("isWindows",d.windows,(a)=>{e="Windows";const b=a.split(" ")[2];b&&("5.0"===b?f="2000":"5.1"===b?f="XP":"5.2"===b?f="XP":"6.0"===b?f="Vista":"6.1"===b?f="7":"6.2"===b?f="8":"6.3"===b?f="8.1":"10.0"===b?f="10":void 0)}),a("isOSX",d.OSX,(a)=>{e="Mac OS X";const b=a.split(" ")[3];b&&(f=b.replace("_","."))}),a("isLinux",c.linux,()=>{e="Linux"}),a("isChromeOS",c.chromeOS,()=>{e="Chrome OS"}),a("isAndroid",!c.windowsTizen&&d.android,(a)=>{e="Android";const b=a.split(" ")[1];b&&(f=b)}),a("isTizen",d.tizen,(a)=>{e="Tizen";const b=a.split(" ")[1];b&&(f=b)}),a("isIPhone",!c.windowsTizen&&d.iphone,(a)=>{e="iOS";const b=a.split(" ")[2];b&&(f=b.replace("_","."))}),a("isIPad",!c.windowsTizen&&d.ipad,(a)=>{e="iOS";const b=a.split(" ")[3];b&&(f=b.replace("_","."))}),a("isWindowsPhone",d.winPhone,(a)=>{e="Windows Phone";const b=a.split(" ")[2];b&&(f=b)}),a("isWindowsPhoneOS",d.winPhoneOS,(a)=>{e="Windows Phone";const b=a.split(" ")[3];b&&(f=b)}),a("isBlackberry",c.blackberry,()=>{e="Blackberry",f="10",h="stock",k="webkit"}),a("isChrome",!c.edge&&!c.opera&&d.chrome,(a)=>{h="Chrome",k="Chromium";const b=a.split("/")[1];b&&(i=b)}),a("isOpera",d.opera,(a)=>{h="Opera",k="Chromium";const b=a.split("/")[1];b&&(i=b)}),a("isChromium",d.chromium,(a)=>{h="Chromium",k="Chromium";const b=a.split("/")[1];b&&(i=b)}),a("isFirefox",d.firefox,(a)=>{h="Firefox",k="Gecko";const b=a.split("/")[1];b&&(i=b)}),a("isInternetExplorer",d.ie,(a)=>{h="Internet Explorer",k="Trident";const b=a.split(" ")[1];b&&(i=b)}),a("isTrident","Internet Explorer"!=h&&c.trident,()=>{k="Trident";const a=/rv:[0-9.]+/i.exec(b);if(a&&a.length){h="Internet Explorer";const b=a[0].split(":")[1];b&&(i=b)}}),a("isEdge",d.edge,(a)=>{h="Edge",k="Edge";const b=a.split("/")[1];b&&(i=b)}),a("isEdgeChromium",d.edgeChromium,(a)=>{h="Edge",k="Chromium";const b=a.split("/")[1];b&&(i=b)}),a("isSafari",c.safari&&!c.nokia&&!c.chrome&&!c.chromium&&!c.genericIE&&!c.blackberry,()=>{h="Safari",k="WebKit";const a=/version\/[0-9.]+/i.exec(b),c=/crios\/[0-9.]+/i.exec(b),d=/fxios\/[0-9.]+/i.exec(b);if(a&&a.length){const b=a[0].split("/")[1];b&&(i=b)}if(c&&c.length){h="Chrome for iOS";const a=c[0].split("/")[1];a&&(i=a)}if(d&&d.length){h="Firefox for iOS";const a=d[0].split("/")[1];a&&(i=a)}}),a("isSilk",d.silk,(a)=>{h="Silk";const b=a.split("/")[1];b&&(i=b)}),a("isCrosswalk",c.crosswalk,()=>l="crosswalk"),a("isCordova",self["device"]&&(self["device"]["cordova"]||self["device"]["phonegap"]),()=>l="cordova"),a("isNWJS",d.nwjs,(a)=>{l="nwjs",h="NW.js",k="Chromium";const b=a.split("/")[1];b&&(i=b)}),a("isAmazonWebApp",c.amazonwebapp,()=>l="webapp"),a("isHomeScreenWebApp","nwjs"!=l&&"undefined"!=typeof window&&(window.matchMedia&&window.matchMedia("(display-mode: standalone)").matches||navigator["standalone"]),()=>l="webapp"),a("isFalseSafari","Safari"==h&&("Android"==e||"Tizen"==e||"Blackberry"==e),()=>h="stock"),a("isAndroidWebview","Chrome"==h&&"browser"==l&&c.webview,()=>l="webview"),a("isFirefoxOS","Firefox"==h&&e=="(unknown)",()=>e="Firefox OS"),a("isAndroidFallback",e=="(unknown)"&&!c.windowsTizen&&c.android,()=>e="Android"),a("isTridentFallback",e=="(unknown)"&&c.trident,()=>k="Trident"),a("isWebkitFallback",e=="(unknown)"&&c.webkit,()=>k="WebKit"),a("is64Bit",((a)=>a.test(b)||a.test(navigator.platform)||"x64"===navigator.cpuClass)(/x86_64|x86-64|win64|x64;|x64\)|x64_|amd64|wow64|ia64|arm64|arch64|sparc64|ppc64|irix64/i),()=>g="64-bit"),a("is32Bit",((a)=>a.test(b)||a.test(navigator.platform)||"x86"===navigator.cpuClass)(/x86;|x86\)|i86|i386|i486|i586|i686|armv1|armv2|armv3|armv4|armv5|armv6|armv7/i),()=>g="32-bit"),a("is64BitFallback",g=="(unknown)"&&"Mac OS X"==e&&10.7<=parseFloat(f),()=>g="64-bit"),a("is32BitFallback",g=="(unknown)"&&"Windows"==e||"Android"==e&&5>parseFloat(f),()=>g="32-bit"),a("is32BitBrowser","32-bit"==g||/wow64/i.test(b),()=>j="32-bit"),a("is64BitBrowser",/win64/i.test(b),()=>j="64-bit"),a("isDesktop",(()=>"Windows"==e||"Mac OS X"==e||"Linux"==e||"Chrome OS"==e||"nwjs"==l)(),()=>m=!0),"Edge"==k&&"undefined"!=typeof Windows&&"undefined"!=typeof Windows["System"]&&(l="windows-store"),n="nwjs"==l||"windows-store"==l,C3.Platform={OS:e,OSVersion:f,OSArchitecture:g,Browser:h,BrowserVersion:i,BrowserVersionNumber:parseFloat(i),BrowserArchitecture:j,BrowserEngine:k,Context:l,IsDesktop:m,IsMobile:!m,IsDesktopApp:n,IsChromeWebStore:!!(self["chrome"]&&self["chrome"]["runtime"]&&self["chrome"]["runtime"]["id"]),IsAppleOS:"Mac OS X"==e||"iOS"==e}} // ../lib/storage/kvStorage.js -"use strict";{function a(a){return new Promise((b,c)=>{a.onsuccess=()=>b(a.result),a.onerror=()=>c(a.error)})}function b(a){return new Promise((b,c)=>{a.oncomplete=()=>b(),a.onerror=()=>c(a.error),a.onabort=()=>c(a.error)})}function c(a,b){return e(a,b)}function d(a,b){return e(a,b,!0)}async function e(a,b,c=!1,d=!0){const g=await f(a);try{const a=g.transaction([j],c?"readwrite":"readonly");return b(a)}catch(f){if(d&&"InvalidStateError"===f["name"])return k.delete(a),e(a,b,c,!1);throw f}}function f(a){h(a);let b=k.get(a);return b instanceof Promise||(b=g(a),k.set(a,b),b.catch(()=>k.delete(a))),b}async function g(b){h(b);const c=indexedDB.open(b,i);return c.addEventListener("upgradeneeded",(a)=>{try{const b=a.target.result;b.createObjectStore(j)}catch(a){console.error(`Failed to create objectstore for database ${b}`,a)}}),a(c)}function h(a){if("string"!=typeof a)throw new TypeError("expected string")}const i=2,j="keyvaluepairs",k=new Map;self.KVStorageContainer=class{constructor(a){h(a),this.name=a}async ready(){await f(this.name)}set(c,e){return h(c),d(this.name,async(d)=>{const f=d.objectStore("keyvaluepairs").put(e,c),g=a(f),h=b(d);await Promise.all([h,g])})}get(d){return h(d),c(this.name,async(c)=>{const e=c.objectStore("keyvaluepairs").get(d),f=a(e),g=b(c),[h,i]=await Promise.all([g,f]);return i})}delete(c){return h(c),d(this.name,async(d)=>{const e=d.objectStore("keyvaluepairs").delete(c),f=a(e),g=b(d);await Promise.all([g,f])})}clear(){return d(this.name,async(c)=>{const d=c.objectStore("keyvaluepairs").clear(),e=a(d),f=b(c);await Promise.all([f,e])})}keys(){return c(this.name,async(c)=>{const d=c.objectStore("keyvaluepairs").getAllKeys(),e=a(d),f=b(c),[g,h]=await Promise.all([f,e]);return h})}values(){return c(this.name,async(c)=>{const d=c.objectStore("keyvaluepairs").getAll(),e=a(d),f=b(c),[g,h]=await Promise.all([f,e]);return h})}entries(){return c(this.name,async(c)=>{const d=c.objectStore("keyvaluepairs").getAllKeys(),e=a(d),f=c.objectStore("keyvaluepairs").getAll(),g=a(f),h=b(c),[i,j,k]=await Promise.all([h,e,g]),m=Math.min(j.length,k.length),l=[];for(let a=0;a{a.onsuccess=()=>b(a.result),a.onerror=()=>c(a.error)})}function b(a){return new Promise((b,c)=>{a.oncomplete=()=>b(),a.onerror=()=>c(a.error),a.onabort=()=>c(a.error)})}function c(a,b){return e(a,b)}function d(a,b){return e(a,b,!0)}async function e(a,b,c=!1,d=!0){const g=await f(a);try{const a=g.transaction([k],c?"readwrite":"readonly");return b(a)}catch(f){if(d&&"InvalidStateError"===f["name"])return l.delete(a),e(a,b,c,!1);throw f}}function f(a){h(a);let b=l.get(a);return b instanceof Promise||(b=g(a),l.set(a,b),b.catch(()=>l.delete(a))),b}async function g(b){h(b);const c=indexedDB.open(b,j);return c.addEventListener("upgradeneeded",(a)=>{try{const b=a.target.result;b.createObjectStore(k)}catch(a){console.error(`Failed to create objectstore for database ${b}`,a)}}),a(c)}function h(a){if("string"!=typeof a)throw new TypeError("expected string")}function i(a,b){const c=a.objectStore(k).openCursor();return new Promise((a)=>{const d=[];c.onsuccess=(c)=>{const e=c.target.result;e?("entries"===b?d.push([e.key,e.value]):"keys"===b?d.push(e.key):"values"===b?d.push(e.value):void 0,e.continue()):a(d)}})}const j=2,k="keyvaluepairs",l=new Map,m="function"==typeof IDBObjectStore.prototype.getAll,n="function"==typeof IDBObjectStore.prototype.getAllKeys;self.KVStorageContainer=class{constructor(a){h(a),this.name=a}async ready(){await f(this.name)}set(c,e){return h(c),d(this.name,async(d)=>{const f=d.objectStore("keyvaluepairs").put(e,c),g=a(f),h=b(d);await Promise.all([h,g])})}get(d){return h(d),c(this.name,async(c)=>{const e=c.objectStore("keyvaluepairs").get(d),f=a(e),g=b(c),[h,i]=await Promise.all([g,f]);return i})}delete(c){return h(c),d(this.name,async(d)=>{const e=d.objectStore("keyvaluepairs").delete(c),f=a(e),g=b(d);await Promise.all([g,f])})}clear(){return d(this.name,async(c)=>{const d=c.objectStore("keyvaluepairs").clear(),e=a(d),f=b(c);await Promise.all([f,e])})}keys(){return c(this.name,async(c)=>{let d;if(n){const b=c.objectStore("keyvaluepairs").getAllKeys();d=a(b)}else d=i(c,"keys");const e=b(c),[f,g]=await Promise.all([e,d]);return g})}values(){return c(this.name,async(c)=>{let d;if(m){const b=c.objectStore("keyvaluepairs").getAll();d=a(b)}else d=i(c,"values");const e=b(c),[f,g]=await Promise.all([e,d]);return g})}entries(){return c(this.name,async(a)=>{const c=i(a,"entries"),d=b(a),[e,f]=await Promise.all([d,c]);return f})}}} // ../lib/storage/localForageAdaptor.js -"use strict";{function a(a){throw new Error(`"${a}" is not implemented`)}function b(a){if("function"==typeof a)throw new Error(`localforage callback API is not implemented; please use the promise API instead`)}function c(a){return"object"==typeof a?new Promise((b)=>{const{port1:c,port2:d}=new MessageChannel;d.onmessage=(a)=>b(a.data),c.postMessage(a)}):Promise.resolve(a)}const d=[/no available storage method found/i,/an attempt was made to break through the security policy of the user agent/i,/the user denied permission to access the database/i,/a mutation operation was attempted on a database that did not allow mutations/i,/idbfactory\.open\(\) called in an invalid security context/i],e=new WeakMap;let f=!1;"undefined"==typeof indexedDB&&(f=!0,console.warn("Unable to use local storage because indexedDB is not defined"));class g{constructor(a){this._inst=a,e.set(this,new Map)}_MaybeSwitchToMemoryFallback(a){if(!f)for(const b of d)if(b.test(a.message)){console.error("Unable to use local storage, reverting to in-memory store: ",a,a.message),f=!0;break}}async _getItemFallback(a){const b=e.get(this).get(a),d=await c(b);return"undefined"==typeof d?null:d}async _setItemFallback(a,b){b=await c(b),e.get(this).set(a,b)}_removeItemFallback(a){e.get(this).delete(a)}_clearFallback(){e.get(this).clear()}_keysFallback(){return Array.from(e.get(this).keys())}IsUsingFallback(){return f}async getItem(a,c){if(b(c),f)return await this._getItemFallback(a);let d;try{d=await this._inst.get(a)}catch(b){return this._MaybeSwitchToMemoryFallback(b),f?await this._getItemFallback(a):(console.error(`Error reading '${a}' from storage, returning null: `,b),null)}return"undefined"==typeof d?null:d}async setItem(a,c,d){if(b(d),"undefined"==typeof c&&(c=null),f)return void(await this._setItemFallback(a,c));try{await this._inst.set(a,c)}catch(b){if(this._MaybeSwitchToMemoryFallback(b),f)await this._setItemFallback(a,c);else throw b}}async removeItem(a,c){if(b(c),f)return void this._removeItemFallback(a);try{await this._inst.delete(a)}catch(b){this._MaybeSwitchToMemoryFallback(b),f?this._removeItemFallback(a):console.error(`Error removing '${a}' from storage: `,b)}}async clear(a){if(b(a),f)return void this._clearFallback();try{await this._inst.clear()}catch(a){this._MaybeSwitchToMemoryFallback(a),f?this._clearFallback():console.error(`Error clearing storage: `,a)}}async keys(a){if(b(a),f)return this._keysFallback();let c=[];try{c=await this._inst.keys()}catch(a){if(this._MaybeSwitchToMemoryFallback(a),f)return this._keysFallback();console.error(`Error getting storage keys: `,a)}return c}ready(a){return b(a),f?Promise.resolve(!0):this._inst.ready()}createInstance(a){if("object"!=typeof a)throw new TypeError("invalid options object");const b=a["name"];if("string"!=typeof b)throw new TypeError("invalid store name");const c=new KVStorageContainer(b);return new g(c)}length(){a("localforage.length()")}key(){a("localforage.key()")}iterate(){a("localforage.iterate()")}setDriver(){a("localforage.setDriver()")}config(){a("localforage.config()")}defineDriver(){a("localforage.defineDriver()")}driver(){a("localforage.driver()")}supports(){a("localforage.supports()")}dropInstance(){a("localforage.dropInstance()")}}self.localforage=new g(new KVStorageContainer("localforage"))} +"use strict";{function a(a){throw new Error(`"${a}" is not implemented`)}function b(a){if("function"==typeof a)throw new Error(`localforage callback API is not implemented; please use the promise API instead`)}function c(a){return"object"==typeof a?new Promise((b)=>{const{port1:c,port2:d}=new MessageChannel;d.onmessage=(a)=>b(a.data),c.postMessage(a)}):Promise.resolve(a)}const d=[/no available storage method found/i,/an attempt was made to break through the security policy of the user agent/i,/the user denied permission to access the database/i,/a mutation operation was attempted on a database that did not allow mutations/i,/idbfactory\.open\(\) called in an invalid security context/i],e=new WeakMap;let f=!1;"undefined"==typeof indexedDB&&(f=!0,console.warn("Unable to use local storage because indexedDB is not defined"));class g{constructor(a){this._inst=a,e.set(this,new Map)}_MaybeSwitchToMemoryFallback(a){if(!f)for(const b of d)if(b.test(a.message)){console.error("Unable to use local storage, reverting to in-memory store: ",a,a.message),f=!0;break}}async _getItemFallback(a){const b=e.get(this).get(a),d=await c(b);return"undefined"==typeof d?null:d}async _setItemFallback(a,b){b=await c(b),e.get(this).set(a,b)}_removeItemFallback(a){e.get(this).delete(a)}_clearFallback(){e.get(this).clear()}_keysFallback(){return Array.from(e.get(this).keys())}IsUsingFallback(){return f}async getItem(a,c){if(b(c),f)return await this._getItemFallback(a);let d;try{d=await this._inst.get(a)}catch(b){return this._MaybeSwitchToMemoryFallback(b),f?await this._getItemFallback(a):(console.error(`Error reading '${a}' from storage, returning null: `,b),null)}return"undefined"==typeof d?null:d}async setItem(a,c,d){if(b(d),"undefined"==typeof c&&(c=null),f)return void(await this._setItemFallback(a,c));try{await this._inst.set(a,c)}catch(b){if(this._MaybeSwitchToMemoryFallback(b),f)await this._setItemFallback(a,c);else throw b}}async removeItem(a,c){if(b(c),f)return void this._removeItemFallback(a);try{await this._inst.delete(a)}catch(b){this._MaybeSwitchToMemoryFallback(b),f?this._removeItemFallback(a):console.error(`Error removing '${a}' from storage: `,b)}}async clear(a){if(b(a),f)return void this._clearFallback();try{await this._inst.clear()}catch(a){this._MaybeSwitchToMemoryFallback(a),f?this._clearFallback():console.error(`Error clearing storage: `,a)}}async keys(a){if(b(a),f)return this._keysFallback();let c=[];try{c=await this._inst.keys()}catch(a){if(this._MaybeSwitchToMemoryFallback(a),f)return this._keysFallback();console.error(`Error getting storage keys: `,a)}return c}ready(a){return b(a),f?Promise.resolve(!0):this._inst.ready()}createInstance(a){if("object"!=typeof a)throw new TypeError("invalid options object");const b=a["name"];if("string"!=typeof b)throw new TypeError("invalid store name");const c=new KVStorageContainer(b);return new g(c)}length(){a("localforage.length()")}key(){a("localforage.key()")}iterate(){a("localforage.iterate()")}setDriver(){a("localforage.setDriver()")}config(){a("localforage.config()")}defineDriver(){a("localforage.defineDriver()")}driver(){a("localforage.driver()")}supports(){a("localforage.supports()")}dropInstance(){a("localforage.dropInstance()")}disableMemoryMode(){f=!1}}self.localforage=new g(new KVStorageContainer("localforage"))} // ../lib/misc/supports.js "use strict";{if(C3.Supports={},C3.Supports.WebAnimations=(()=>{try{if("undefined"==typeof document)return!1;const a=document.createElement("div");if("undefined"==typeof a.animate)return!1;const b=a.animate([{opacity:"0"},{opacity:"1"}],1e3);return"undefined"!=typeof b.reverse}catch(a){return!1}})(),C3.Supports.DialogElement="undefined"!=typeof HTMLDialogElement,C3.Supports.RequestIdleCallback=!!self.requestIdleCallback,C3.Supports.ImageBitmap=!!self.createImageBitmap,C3.Supports.ImageBitmapOptions=!1,C3.Supports.ImageBitmap)try{self.createImageBitmap(new ImageData(32,32),{premultiplyAlpha:"none"}).then(()=>{C3.Supports.ImageBitmapOptions=!0}).catch(()=>{C3.Supports.ImageBitmapOptions=!1})}catch(a){C3.Supports.ImageBitmapOptions=!1}C3.Supports.ClipboardReadText=!!(navigator["clipboard"]&&navigator["clipboard"]["readText"]&&"Firefox"!==C3.Platform.Browser),C3.Supports.Proxies="undefined"!=typeof Proxy,C3.Supports.DownloadAttribute=(()=>{if("undefined"==typeof document)return!1;const b=document.createElement("a");return"undefined"!=typeof b.download})(),C3.Supports.CanvasToBlob=(()=>"undefined"!=typeof HTMLCanvasElement&&HTMLCanvasElement.prototype.toBlob)(),C3.Supports.CSSElement="undefined"!=typeof CSS&&CSS.supports("background","element(#test)"),C3.Supports.Fetch="function"==typeof fetch,C3.Supports.PersistentStorage=!!(self.isSecureContext&&"Opera"!==C3.Platform.Browser&&navigator["storage"]&&navigator["storage"]["persist"]),C3.Supports.StorageQuotaEstimate=!!(self.isSecureContext&&navigator["storage"]&&navigator["storage"]["estimate"]),C3.Supports.Fullscreen=(()=>{if("undefined"==typeof document)return!1;if("iOS"===C3.Platform.OS)return!1;const a=document.documentElement;return!!(a.requestFullscreen||a.msRequestFullscreen||a.mozRequestFullScreen||a.webkitRequestFullscreen)})();const a=[{name:"A",value:12},{name:"B",value:13},{name:"C",value:13},{name:"D",value:13},{name:"E",value:13},{name:"F",value:13},{name:"G",value:14},{name:"H",value:12},{name:"I",value:12},{name:"J",value:13},{name:"K",value:14}],b=Math.ceil(496/a.length),c=(b+"").length,d=[];for(const e of a)for(let a=0;a<=b;a++)d.push({name:e.name+(a+"")["padStart"](c,"0"),value:e.value});d.sort((c,a)=>a.value-c.value);const e=d.reduce((a,b)=>{const c=b.name.slice(0,1),d=a.slice(-1);return d===c?a:a+c},"");C3.Supports.ArraySortProbablyStable="GKBCDEFJAHI"===e} @@ -46,7 +46,7 @@ "use strict";C3.IsAbsoluteURL=function(a){return /^(?:[a-z]+:)?\/\//.test(a)||"data:"===a.substr(0,5)||"blob:"===a.substr(0,5)},C3.IsRelativeURL=function(a){return!C3.IsAbsoluteURL(a)},C3.ThrowIfNotOk=function(a){if(!a.ok)throw new Error(`fetch '${a.url}' response returned ${a.status} ${a.statusText}`)},C3.FetchOk=function(a,b){return fetch(a,b).then((a)=>(C3.ThrowIfNotOk(a),a))},C3.FetchText=function(a){return C3.FetchOk(a).then((a)=>a.text())},C3.FetchJson=function(a){return C3.FetchOk(a).then((a)=>a.json())},C3.FetchBlob=function(a){return C3.FetchOk(a).then((a)=>a.blob())},C3.FetchArrayBuffer=function(a){return C3.FetchOk(a).then((a)=>a.arrayBuffer())},C3.FetchImage=function(a){return new Promise((b,c)=>{const d=new Image;d.onload=()=>b(d),d.onerror=(a)=>c(a),d.src=a})},C3.BlobToArrayBuffer=function(a){return new Promise((b,c)=>{const d=new FileReader;d.onload=()=>b(d.result),d.onerror=()=>c(d.error),d.readAsArrayBuffer(a)})},C3.BlobToString=function(a){return new Promise((b,c)=>{const d=new FileReader;d.onload=()=>b(d.result),d.onerror=()=>c(d.error),d.readAsText(a)})},C3.BlobToJson=function(a){return C3.BlobToString(a).then((a)=>JSON.parse(a))},C3.BlobToImage=async function(a,b){let c=URL.createObjectURL(a);try{const a=await C3.FetchImage(c);return URL.revokeObjectURL(c),c="",b&&"function"==typeof a["decode"]&&(await a["decode"]()),a}finally{c&&URL.revokeObjectURL(c)}},C3.CreateCanvas=function(a,b){if("undefined"!=typeof document&&"function"==typeof document.createElement){const c=document.createElement("canvas");return c.width=a,c.height=b,c}return new OffscreenCanvas(a,b)},C3.CanvasToBlob=function(a,b,c){return"number"!=typeof c&&(c=1),b=b||"image/png",c=C3.clamp(c,0,1),a.toBlob?new Promise((d)=>a.toBlob(d,b,c)):a["convertToBlob"]?a["convertToBlob"]({"type":b,"quality":c}):C3.Asyncify(()=>C3.CanvasToBlobSync(a,b,c))},C3.CanvasToBlobSync=function(a,b,c){return"number"!=typeof c&&(c=1),b=b||"image/png",c=C3.clamp(c,0,1),C3.DataURIToBinaryBlob(a.toDataURL(b,c))},C3.DataURIToBinaryBlob=function(a){const b=C3.ParseDataURI(a);return C3.BinaryStringToBlob(b.data,b.mime_type)},C3.ParseDataURI=function(a){if("data:"!==a.substr(0,5))throw new URIError("expected data: uri");let b=a.indexOf(",");if(0>b)throw new URIError("expected comma in data: uri");let c,d=a.substring(5,b),e=a.substring(b+1),f=d.split(";"),g=f[0]||"",h=f[1],i=f[2];return c="base64"===h||"base64"===i?atob(e):decodeURIComponent(e),{mime_type:g,data:c}},C3.BinaryStringToBlob=function(a,b){let c,d,e=a.length,f=e>>2,g=new Uint8Array(e),h=new Uint32Array(g.buffer,0,f);for(c=0,d=0;cC3.DrawableToBlob(a,b,c));if(C3.Supports.ImageBitmap)return createImageBitmap(a).then((a)=>C3.DrawableToBlob(a,b,c));else{const d=C3.CreateCanvas(a.width,a.height),e=d.getContext("2d");return e.putImageData(a,0,0),C3.CanvasToBlob(d,b,c)}},C3.CopySet=function(a,b){a.clear();for(const c of b)a.add(c)},C3.MapToObject=function(a){const b=Object.create(null);for(const[c,d]of a.entries())b[c]=d;return b},C3.ObjectToMap=function(a,b){b.clear();for(const[c,d]of Object.entries(a))b.set(c,d)},C3.ToSuperJSON=function a(b){if("object"==typeof b&&null!==b){if(b instanceof Set)return{"_c3type_":"set","data":[...b].map((b)=>a(b))};if(b instanceof Map)return{"_c3type_":"map","data":[...b].map((b)=>[b[0],a(b[1])])};else{const c=Object.create(null);for(const[d,e]of Object.entries(b))c[d]=a(e);return c}}return b},C3.FromSuperJSON=function a(b){if("object"==typeof b&null!==b){if("set"===b["_c3type_"])return new Set(b["data"].map((b)=>a(b)));if("map"===b["_c3type_"])return new Map(b["data"].map((b)=>[b[0],a(b[1])]));else{const c=Object.create(null);for(const[d,e]of Object.entries(b))c[d]=a(e);return c}}return b},C3.CSSToCamelCase=function(a){let b="",c=!1;for(const d of a)"-"===d?c=!0:c?(b+=d.toUpperCase(),c=!1):b+=d;return b},C3.IsIterator=function(a){return"object"==typeof a&&"function"==typeof a.next}; // ../lib/misc/color.js -"use strict";{function a(a){return 0===a.length?"00":1===a.length?"0"+a:a}function c(a,b,c){return 0>c&&(c+=1),1b.length)return!1;const c=parseInt(b[0].trim(),10)/255,d=parseInt(b[1].trim(),10)/255,e=parseInt(b[2].trim(),10)/255;return isFinite(c)&&this.setR(c),isFinite(d)&&this.setG(d),isFinite(e)&&this.setB(e),this.setA(1),!0}parseCommaSeparatedPercentageRgb(a){if("string"!=typeof a)return!1;a=a.replace(/^rgb\(|\)|%/,"");const b=a.split(",");if(3>b.length)return!1;const c=parseInt(b[0].trim(),10)/100,d=parseInt(b[1].trim(),10)/100,e=parseInt(b[2].trim(),10)/100;return isFinite(c)&&this.setR(c),isFinite(d)&&this.setG(d),isFinite(e)&&this.setB(e),this.setA(1),!0}parseCommaSeparatedRgba(a){if("string"!=typeof a)return!1;a=a.replace(/^rgba\(|\)|%/,"");const b=a.split(",");if(4>b.length)return!1;const c=parseInt(b[0].trim(),10)/255,d=parseInt(b[1].trim(),10)/255,e=parseInt(b[2].trim(),10)/255,f=parseFloat(b[3].trim());return isFinite(c)&&this.setR(c),isFinite(d)&&this.setG(d),isFinite(e)&&this.setB(e),isFinite(f)&&this.setA(f),!0}parseCommaSeparatedPercentageRgba(a){if("string"!=typeof a)return!1;a=a.replace(/^rgba\(|\)|%/,"");const b=a.split(",");if(4>b.length)return!1;const c=parseInt(b[0].trim(),10)/100,d=parseInt(b[1].trim(),10)/100,e=parseInt(b[2].trim(),10)/100,f=parseFloat(b[3].trim());return isFinite(c)&&this.setR(c),isFinite(d)&&this.setG(d),isFinite(e)&&this.setB(e),isFinite(f)&&this.setA(f),!0}parseString(a){if("string"!=typeof a)return!1;if(a=a.replace(/\s+/,""),a.includes(",")){if(a.startsWith("rgb("))return a.includes("%")?this.parseCommaSeparatedPercentageRgb(a):this.parseCommaSeparatedRgb(a);if(a.startsWith("rgba("))return a.includes("%")?this.parseCommaSeparatedPercentageRgba(a):this.parseCommaSeparatedRgba(a);if(a.startsWith("hsl(")||a.startsWith("hsla("))return this.parseHSLString(a);else{const b=a.split(",");return a.includes("%")?3===b.length?this.parseCommaSeparatedPercentageRgb(a):4===b.length&&this.parseCommaSeparatedPercentageRgba(a):3===b.length?this.parseCommaSeparatedRgb(a):4===b.length&&this.parseCommaSeparatedRgba(a)}}else return this.parseHexString(a)}toJSON(){return[this._r,this._g,this._b,this._a]}setFromHSLA(d,e,f,h){let a,i,g;if(d%=360,e=C3.clamp(e,0,100),f=C3.clamp(f,0,100),h=C3.clamp(h,0,1),d/=360,e/=100,f/=100,0===e)a=i=g=f;else{const b=.5>f?f*(1+e):f+e-f*e,h=2*f-b;a=c(h,b,d+1/3),i=c(h,b,d),g=c(h,b,d-1/3)}return this.setR(a),this.setG(i),this.setB(g),this.setA(h),this}parseHSLString(a){const c=a.replace(/ |hsl|hsla|\(|\)|;/gi,""),e=b.exec(c),f=d.exec(c);return e&&4===e.length?(this.setFromHSLA(+e[1],+e[2],+e[3],1),!0):!!(f&&5===f.length)&&(this.setFromHSLA(+e[1],+e[2],+e[3],+e[4]),!0)}toHSLAString(){var c=Math.round;const e=this._r,f=this._g,g=this._b,b=this._a,a=Math.max(e,f,g),i=Math.min(e,f,g);let j,h,k=(a+i)/2;if(a===i)j=h=0;else{const b=a-i;h=.5a.length||(this._r=a[0],this._g=a[1],this._b=a[2],this._a=4<=a.length?a[3]:1)}set r(a){this.setR(a)}get r(){return this.getR()}set g(a){this.setG(a)}get g(){return this.getG()}set b(a){this.setB(a)}get b(){return this.getB()}set a(b){this.setA(b)}get a(){return this.getA()}setAtIndex(a,b){switch(a){case 0:this.setR(b);break;case 1:this.setG(b);break;case 2:this.setB(b);break;case 3:this.setA(b);break;default:throw new RangeError("invalid color index");}}getAtIndex(a){switch(a){case 0:return this.getR();case 1:return this.getG();case 2:return this.getB();case 3:return this.getA();default:throw new RangeError("invalid color index");}}static Diff(a,b){var c=Math.min,d=Math.max;const e=new C3.Color;return e.setR(d(a._r,b._r)-c(a._r,b._r)),e.setG(d(a._g,b._g)-c(a._g,b._g)),e.setB(d(a._b,b._b)-c(a._b,b._b)),e.setA(d(a._a,b._a)-c(a._a,b._a)),e}},C3.Color.White=Object.freeze(C3.New(C3.Color,1,1,1,1)),C3.Color.Black=Object.freeze(C3.New(C3.Color,0,0,0,1)),C3.Color.TransparentBlack=Object.freeze(C3.New(C3.Color,0,0,0,0))} +"use strict";{function a(a){return 0===a.length?"00":1===a.length?"0"+a:a}function c(a,b,c){return 0>c&&(c+=1),1b.length)return!1;const c=parseInt(b[0].trim(),10)/255,d=parseInt(b[1].trim(),10)/255,e=parseInt(b[2].trim(),10)/255;return isFinite(c)&&this.setR(c),isFinite(d)&&this.setG(d),isFinite(e)&&this.setB(e),this.setA(1),!0}parseCommaSeparatedPercentageRgb(a){if("string"!=typeof a)return!1;a=a.replace(/^rgb\(|\)|%/,"");const b=a.split(",");if(3>b.length)return!1;const c=parseInt(b[0].trim(),10)/100,d=parseInt(b[1].trim(),10)/100,e=parseInt(b[2].trim(),10)/100;return isFinite(c)&&this.setR(c),isFinite(d)&&this.setG(d),isFinite(e)&&this.setB(e),this.setA(1),!0}parseCommaSeparatedRgba(a){if("string"!=typeof a)return!1;a=a.replace(/^rgba\(|\)|%/,"");const b=a.split(",");if(4>b.length)return!1;const c=parseInt(b[0].trim(),10)/255,d=parseInt(b[1].trim(),10)/255,e=parseInt(b[2].trim(),10)/255,f=parseFloat(b[3].trim());return isFinite(c)&&this.setR(c),isFinite(d)&&this.setG(d),isFinite(e)&&this.setB(e),isFinite(f)&&this.setA(f),!0}parseCommaSeparatedPercentageRgba(a){if("string"!=typeof a)return!1;a=a.replace(/^rgba\(|\)|%/,"");const b=a.split(",");if(4>b.length)return!1;const c=parseInt(b[0].trim(),10)/100,d=parseInt(b[1].trim(),10)/100,e=parseInt(b[2].trim(),10)/100,f=parseFloat(b[3].trim());return isFinite(c)&&this.setR(c),isFinite(d)&&this.setG(d),isFinite(e)&&this.setB(e),isFinite(f)&&this.setA(f),!0}parseString(a){if("string"!=typeof a)return!1;if(a=a.replace(/\s+/,""),a.includes(",")){if(a.startsWith("rgb("))return a.includes("%")?this.parseCommaSeparatedPercentageRgb(a):this.parseCommaSeparatedRgb(a);if(a.startsWith("rgba("))return a.includes("%")?this.parseCommaSeparatedPercentageRgba(a):this.parseCommaSeparatedRgba(a);if(a.startsWith("hsl(")||a.startsWith("hsla("))return this.parseHSLString(a);else{const b=a.split(",");return a.includes("%")?3===b.length?this.parseCommaSeparatedPercentageRgb(a):4===b.length&&this.parseCommaSeparatedPercentageRgba(a):3===b.length?this.parseCommaSeparatedRgb(a):4===b.length&&this.parseCommaSeparatedRgba(a)}}else return this.parseHexString(a)}toJSON(){return[this._r,this._g,this._b,this._a]}setFromHSLA(d,e,f,h){let a,i,g;if(d%=360,e=C3.clamp(e,0,100),f=C3.clamp(f,0,100),h=C3.clamp(h,0,1),d/=360,e/=100,f/=100,0===e)a=i=g=f;else{const b=.5>f?f*(1+e):f+e-f*e,h=2*f-b;a=c(h,b,d+1/3),i=c(h,b,d),g=c(h,b,d-1/3)}return this.setR(a),this.setG(i),this.setB(g),this.setA(h),this}parseHSLString(a){const c=a.replace(/ |hsl|hsla|\(|\)|;/gi,""),e=b.exec(c),f=d.exec(c);return e&&4===e.length?(this.setFromHSLA(+e[1],+e[2],+e[3],1),!0):!!(f&&5===f.length)&&(this.setFromHSLA(+e[1],+e[2],+e[3],+e[4]),!0)}toHSLAString(){const c=this._r,d=this._g,e=this._b,b=this._a,a=C3.Color.GetHue(c,d,e),f=C3.Color.GetSaturation(c,d,e),g=C3.Color.GetLuminosity(c,d,e);return`hsla(${a}, ${f}%, ${g}%, ${b})`}toHSLAArray(){const a=this._r,c=this._g,d=this._b;return[C3.Color.GetHue(a,c,d),C3.Color.GetSaturation(a,c,d),C3.Color.GetLuminosity(a,c,d),this._a]}setFromJSON(a){!Array.isArray(a)||3>a.length||(this._r=a[0],this._g=a[1],this._b=a[2],this._a=4<=a.length?a[3]:1)}set r(a){this.setR(a)}get r(){return this.getR()}set g(a){this.setG(a)}get g(){return this.getG()}set b(a){this.setB(a)}get b(){return this.getB()}set a(b){this.setA(b)}get a(){return this.getA()}setAtIndex(a,b){switch(a){case 0:this.setR(b);break;case 1:this.setG(b);break;case 2:this.setB(b);break;case 3:this.setA(b);break;default:throw new RangeError("invalid color index");}}getAtIndex(a){switch(a){case 0:return this.getR();case 1:return this.getG();case 2:return this.getB();case 3:return this.getA();default:throw new RangeError("invalid color index");}}static Diff(a,b){var c=Math.min,d=Math.max;const e=new C3.Color;return e.setR(d(a._r,b._r)-c(a._r,b._r)),e.setG(d(a._g,b._g)-c(a._g,b._g)),e.setB(d(a._b,b._b)-c(a._b,b._b)),e.setA(d(a._a,b._a)-c(a._a,b._a)),e}static GetHue(a,c,d){const b=Math.max(a,c,d),e=Math.min(a,c,d);if(b===e)return 0;let f=0;return b===a?f=(c-d)/(b-e)+(c(a/=f/2)?b/2*a*a+e:-b/2*(--a*(a-2)-1)+e}static EaseInCubic(a,e,b,c){return b*(a/=c)*a*a+e}static EaseOutCubic(a,e,b,c){return b*((a=a/c-1)*a*a+1)+e}static EaseInOutCubic(a,e,b,c){return 1>(a/=c/2)?b/2*a*a*a+e:b/2*((a-=2)*a*a+2)+e}static EaseInQuart(a,e,b,c){return b*(a/=c)*a*a*a+e}static EaseOutQuart(a,e,b,f){return-b*((a=a/f-1)*a*a*a-1)+e}static EaseInOutQuart(a,e,b,f){return 1>(a/=f/2)?b/2*a*a*a*a+e:-b/2*((a-=2)*a*a*a-2)+e}static EaseInQuint(a,e,b,c){return b*(a/=c)*a*a*a*a+e}static EaseOutQuint(a,e,b,c){return b*((a=a/c-1)*a*a*a*a+1)+e}static EaseInOutQuint(a,e,b,c){return 1>(a/=c/2)?b/2*a*a*a*a*a+e:b/2*((a-=2)*a*a*a*a+2)+e}static EaseInSine(a,e,b,f){return-b*j(a/f*(k/2))+b+e}static EaseOutSine(a,e,b,c){return b*i(a/c*(k/2))+e}static EaseInOutSine(a,e,b,f){return-b/2*(j(k*a/f)-1)+e}static EaseInExpo(a,e,b,c){return 0===a?e:b*h(2,10*(a/c-1))+e}static EaseOutExpo(a,e,b,c){return a===c?e+b:b*(-h(2,-10*a/c)+1)+e}static EaseInOutExpo(a,e,b,c){return 0===a?e:a===c?e+b:1>(a/=c/2)?b/2*h(2,10*(a-1))+e:b/2*(-h(2,-10*--a)+2)+e}static EaseInCirc(a,e,b,f){return-b*(g(1-(a/=f)*a)-1)+e}static EaseOutCirc(a,e,b,c){return b*g(1-(a=a/c-1)*a)+e}static EaseInOutCirc(a,e,b,f){return 1>(a/=f/2)?-b/2*(g(1-a*a)-1)+e:b/2*(g(1-(a-=2)*a)+1)+e}static EaseInElastic(g,j,b,c){let d=1.70158,l=0,m=b;return 0===g?j:1===(g/=c)?j+b:(l||(l=.3*c),mg?-.5*(m*h(2,10*(g-=1))*i((g*c-d)*(2*k)/l))+j:.5*(m*h(2,-10*(g-=1))*i((g*c-d)*(2*k)/l))+b+j)}static EaseInBack(a,e,b,c,d){return void 0===d&&(d=1.70158),b*(a/=c)*a*((d+1)*a-d)+e}static EaseOutBack(a,e,b,c,d){return void 0===d&&(d=1.70158),b*((a=a/c-1)*a*((d+1)*a+d)+1)+e}static EaseInOutBack(a,e,b,c,d){return void 0===d&&(d=1.70158),1>(a/=c/2)?b/2*(a*a*(((d*=1.525)+1)*a-d))+e:b/2*((a-=2)*a*(((d*=1.525)+1)*a+d)+2)+e}static EaseInBounce(a,e,b,c){return b-s.EaseOutBounce(c-a,0,b,c)+e}static EaseOutBounce(a,e,b,c){return(a/=c)<1/2.75?b*(7.5625*a*a)+e:a<2/2.75?b*(7.5625*(a-=1.5/2.75)*a+.75)+e:a<2.5/2.75?b*(7.5625*(a-=2.25/2.75)*a+.9375)+e:b*(7.5625*(a-=2.625/2.75)*a+.984375)+e}static EaseInOutBounce(a,e,b,c){return ad-3*c+3*b-a,a=(a,b,c)=>3*c-6*b+3*a,b=(a,b)=>3*(b-a),c=(d,e,a,b)=>((e*d+a)*d+b)*d,s=(d,e,a,b)=>3*e*d*d+2*a*d+b,u=(d,e,g,h,i,j)=>{if(1==d)return 1;let k=0,l=1,m=j[l],n=j[10];for(;l!=10&&m<=d;)l++,m=j[l],k+=q;l--,m=j[l];const o=(d-m)/(j[l+1]-m);let p=k+o*q;const t=r(e,g,h,i),u=a(e,g,h,i),v=b(e,g,h,i),w=s(p,t,u,v);if(0===w)return p;if(w>=.02){for(let a=0;4>a;++a){const a=c(p,t,u,v)-d,b=s(p,t,u,v);p-=a/b}return p}else{let a,b,e=k,g=k+q,h=0;do{p=e+(g-e)/2;let i=c(p,t,u,v)-d;01e-7,b=10>++h}while(a&&b);return p}}})(); +// ../lib/misc/probability.js +"use strict";{function a(a){if(!C3.IsString(a));}C3.ProbabilityTable=class{constructor(){this._items=[],this._totalWeight=0}Release(){this.Clear(),this._items=null}Clear(){C3.clear2DArray(this._items),this._totalWeight=0}GetTotalWeight(){return this._totalWeight}Sample(a=Math.random()*this.GetTotalWeight()){let b=0;for(const[c,d]of this._items)if(b+=c,ac(a)));for(let c,d=0,e=this._listeners.length;dc(a)));return Promise.all(b).then(()=>!a.defaultPrevented)}async _FireAndWaitAsync(a){const b=[];this._IncreaseFireDepth();for(let c=0,d=this._captureListeners.length;cc(a)));for(let c,d=0,e=this._listeners.length;dc(a)));return Promise.all(b).then(()=>!a.defaultPrevented)}_FireAndWait_AsyncOptional(a){const b=[];this._IncreaseFireDepth();for(let c=0,d=this._captureListeners.length;c!a.defaultPrevented):!a.defaultPrevented}async _FireAndWaitAsync(a){return await this._FireAndWait_AsyncOptional(a)}async _FireAndWaitAsyncSequential(a){this._IncreaseFireDepth();for(let b=0,c=this._captureListeners.length;b(h.push({func:b,resolve:e,reject:f,stack:d}),k?void c(h.pop()):void(-1===i&&a(16))))},C3.Asyncify.SetHighThroughputMode=function(a){if(a)++j;else if(--j,0>j)throw new Error("already turned off high throughput mode")}} @@ -112,13 +115,13 @@ "use strict";C3.Gfx={}; // ../lib/gfx/texture.js -"use strict";{function a(a,b){let c,d,e,f;switch(a){case"rgba8":c=b.RGBA8,d=b.RGBA,e=b.RGBA,f=b.UNSIGNED_BYTE;break;case"rgb8":c=b.RGB8,d=b.RGB,e=b.RGB,f=b.UNSIGNED_BYTE;break;case"rgba4":c=b.RGBA4,d=b.RGBA,e=b.RGBA,f=b.UNSIGNED_SHORT_4_4_4_4;break;case"rgb5_a1":c=b.RGB5_A1,d=b.RGBA,e=b.RGBA,f=b.UNSIGNED_SHORT_5_5_5_1;break;case"rgb565":c=b.RGB565,d=b.RGB,e=b.RGB,f=b.UNSIGNED_SHORT_5_6_5;break;default:throw new Error("invalid pixel format");}return{sizedinternalformat:c,internalformat:d,format:e,type:f}}const b=new Set(["rgba8","rgb8","rgba4","rgb5_a1","rgb565"]),c=new Set(["nearest","bilinear","trilinear"]),d=new Set(["default","low","high"]);const e={isTiled:!1,tileType:"repeat",sampling:"trilinear",pixelFormat:"rgba8",mipMap:!0,mipMapQuality:"default",premultiplyAlpha:!0,isSvg:!1,width:-1,height:-1},f={premultiplyAlpha:!0},g=new Set;C3.Gfx.WebGLRendererTexture=class{constructor(a){this._renderer=a,this._texture=null,this._width=0,this._height=0,this._isStatic=!0,this._isTiled=!1,this._tileType="repeat",this._sampling="trilinear",this._pixelFormat="rgba8",this._isMipMapped=!1,this._mipMapQuality="default",this._refCount=0}_CreateStatic(f,h){if(("undefined"==typeof HTMLImageElement||!(f instanceof HTMLImageElement))&&("undefined"==typeof HTMLCanvasElement||!(f instanceof HTMLCanvasElement))&&("undefined"==typeof ImageBitmap||!(f instanceof ImageBitmap))&&("undefined"==typeof OffscreenCanvas||!(f instanceof OffscreenCanvas))&&!(f instanceof ImageData)&&!(f instanceof ArrayBuffer)&&null!==f)throw new Error("invalid texture source");if(h=Object.assign({},e,h),this._texture)throw new Error("already created texture");if(this._isTiled=!!h.isTiled,this._tileType=h.tileType,this._sampling=h.sampling,this._pixelFormat=h.pixelFormat,this._isMipMapped=!!h.mipMap,this._mipMapQuality=h.mipMapQuality,!c.has(this._sampling))throw new Error("invalid sampling");if(!b.has(this._pixelFormat))throw new Error("invalid pixel format");if(!d.has(this._mipMapQuality))throw new Error("invalid mipmap quality");if(this._isStatic=!0,!(f instanceof ArrayBuffer||null===f||h.isSvg))this._width=f.width,this._height=f.height;else if(this._width=h.width,this._height=h.height,f instanceof ArrayBuffer&&f.byteLength!==4*(this._width*this._height))throw new Error("ArrayBuffer wrong size");if(0>=this._width||0>=this._height)throw new Error("invalid texture data size");if(h.isSvg){const a=document.createElement("canvas");a.width=this._width,a.height=this._height;const b=a.getContext("2d");b.drawImage(f,0,0,this._width,this._height),f=a}const i=C3.isPOT(this._width)&&C3.isPOT(this._height),j=this._renderer.GetMaxTextureSize();if(this._width>j||this._height>j)throw new Error("texture data exceeds maximum texture size");const k=this._renderer.GetContext(),l=this._renderer.GetWebGLVersionNumber();this._texture=k.createTexture(),k.bindTexture(k.TEXTURE_2D,this._texture),k.pixelStorei(k["UNPACK_PREMULTIPLY_ALPHA_WEBGL"],h.premultiplyAlpha);const m=a(this._pixelFormat,k);if(!this._renderer.SupportsNPOTTextures()&&!i&&this._isTiled){if(null===f)throw new Error("cannot pass null data when creating a NPOT tiled texture without NPOT support");if(f instanceof ArrayBuffer&&(f=new ImageData(new Uint8ClampedArray(f),this._width,this._height)),f instanceof ImageData){const a=document.createElement("canvas");a.width=this._width,a.height=this._height;const b=a.getContext("2d");b.putImageData(f,0,0),f=a}const a=document.createElement("canvas");a.width=C3.nextHighestPowerOfTwo(this._width),a.height=C3.nextHighestPowerOfTwo(this._height);const b=a.getContext("2d");b.imageSmoothingEnabled="nearest"!==this._sampling,b.drawImage(f,0,0,this._width,this._height,0,0,a.width,a.height),k.texImage2D(k.TEXTURE_2D,0,m.internalformat,m.format,m.type,a)}else if(2<=l){let a;a=this._isMipMapped?Math.floor(Math.log2(Math.max(this._width,this._height))+1):1,k.texStorage2D(k.TEXTURE_2D,a,m.sizedinternalformat,this._width,this._height),f instanceof ArrayBuffer?k.texSubImage2D(k.TEXTURE_2D,0,0,0,this._width,this._height,m.format,m.type,new Uint8Array(f)):null!==f&&k.texSubImage2D(k.TEXTURE_2D,0,0,0,m.format,m.type,f)}else f instanceof ArrayBuffer?k.texImage2D(k.TEXTURE_2D,0,m.internalformat,this._width,this._height,0,m.format,m.type,new Uint8Array(f)):null===f?k.texImage2D(k.TEXTURE_2D,0,m.internalformat,this._width,this._height,0,m.format,m.type,null):k.texImage2D(k.TEXTURE_2D,0,m.internalformat,m.format,m.type,f);null!==f&&this._SetTextureParameters(k),k.bindTexture(k.TEXTURE_2D,null),this._renderer._ResetLastTexture(),this._refCount=1,g.add(this)}_CreateDynamic(f,h,i){var j=Math.floor;if(i=Object.assign({},e,i),this._texture)throw new Error("already created texture");if(this._isTiled=!!i.isTiled,this._tileType=i.tileType,this._sampling=i.sampling,this._pixelFormat=i.pixelFormat,this._isMipMapped=!!i.mipMap,this._mipMapQuality=i.mipMapQuality,!c.has(this._sampling))throw new Error("invalid sampling");if(!b.has(this._pixelFormat))throw new Error("invalid pixel format");if(!d.has(this._mipMapQuality))throw new Error("invalid mipmap quality");this._isStatic=!1,this._width=j(f),this._height=j(h);const k=C3.isPOT(this._width)&&C3.isPOT(this._height),l=this._renderer.GetMaxTextureSize();if(0>=this._width||0>=this._height)throw new Error("invalid texture size");if(this._width>l||this._height>l)throw new Error("texture exceeds maximum texture size");if(!this._renderer.SupportsNPOTTextures()&&this._isTiled&&!k)throw new Error("non-power-of-two tiled textures not supported");const m=this._renderer.GetContext(),n=this._renderer.GetWebGLVersionNumber();this._texture=m.createTexture(),m.bindTexture(m.TEXTURE_2D,this._texture),m.pixelStorei(m["UNPACK_PREMULTIPLY_ALPHA_WEBGL"],i.premultiplyAlpha);const o=a(this._pixelFormat,m),p=2<=n?o.sizedinternalformat:o.internalformat;m.texImage2D(m.TEXTURE_2D,0,p,this._width,this._height,0,o.format,o.type,null),this._SetTextureParameters(m),m.bindTexture(m.TEXTURE_2D,null),this._renderer._ResetLastTexture(),this._refCount=1,g.add(this)}_GetMipMapHint(a){if("default"===this._mipMapQuality)return this._isStatic?a.NICEST:a.FASTEST;if("low"===this._mipMapQuality)return a.FASTEST;if("high"===this._mipMapQuality)return a.NICEST;throw new Error("invalid mipmap quality")}_SetTextureParameters(a){const b=C3.isPOT(this._width)&&C3.isPOT(this._height);if(!this._isTiled)a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);else if("repeat-x"===this._tileType)a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.REPEAT),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);else if("repeat-y"===this._tileType)a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.REPEAT);else if("repeat"===this._tileType)a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.REPEAT),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.REPEAT);else throw new Error("invalid tile type");if("nearest"===this._sampling)a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),this._isMipMapped=!1;else if(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),(b||this._renderer.SupportsNPOTTextures())&&this._isMipMapped){a.hint(a.GENERATE_MIPMAP_HINT,this._GetMipMapHint(a)),a.generateMipmap(a.TEXTURE_2D);const b="trilinear"===this._sampling&&!this._renderer.HasMajorPerformanceCaveat();a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,b?a.LINEAR_MIPMAP_LINEAR:a.LINEAR_MIPMAP_NEAREST)}else a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),this._isMipMapped=!1}_Update(b,c){if(("undefined"==typeof HTMLImageElement||!(b instanceof HTMLImageElement))&&("undefined"==typeof HTMLVideoElement||!(b instanceof HTMLVideoElement))&&("undefined"==typeof HTMLCanvasElement||!(b instanceof HTMLCanvasElement))&&("undefined"==typeof ImageBitmap||!(b instanceof ImageBitmap))&&("undefined"==typeof OffscreenCanvas||!(b instanceof OffscreenCanvas))&&!(b instanceof ImageData))throw new Error("invalid texture source");if(!this._texture||0>=this._refCount)throw new Error("texture not created");if(this._isStatic)throw new Error("cannot update static texture");c=Object.assign({},f,c);const d=b.width||b.videoWidth,e=b.height||b.videoHeight,g=this._renderer.GetWebGLVersionNumber(),h=this._renderer.GetContext();h.bindTexture(h.TEXTURE_2D,this._texture),h.pixelStorei(h["UNPACK_PREMULTIPLY_ALPHA_WEBGL"],c.premultiplyAlpha);const i=a(this._pixelFormat,h),j=2<=g?i.sizedinternalformat:i.internalformat;try{if(this._width===d&&this._height===e){const a=C3.isPOT(this._width)&&C3.isPOT(this._height);h.texSubImage2D(h.TEXTURE_2D,0,0,0,i.format,i.type,b),(a||this._renderer.SupportsNPOTTextures())&&this._isMipMapped&&(h.hint(h.GENERATE_MIPMAP_HINT,this._GetMipMapHint(h)),h.generateMipmap(h.TEXTURE_2D))}else{this._width=d,this._height=e;const a=C3.isPOT(this._width)&&C3.isPOT(this._height);if(!this._renderer.SupportsNPOTTextures()&&this._isTiled&&!a)throw new Error("non-power-of-two tiled textures not supported");h.texImage2D(h.TEXTURE_2D,0,j,i.format,i.type,b),(a||this._renderer.SupportsNPOTTextures())&&this._isMipMapped&&(h.hint(h.GENERATE_MIPMAP_HINT,this._GetMipMapHint(h)),h.generateMipmap(h.TEXTURE_2D))}}catch(a){console.error("Error updating WebGL texture: ",a)}h.bindTexture(h.TEXTURE_2D,null),this._renderer._ResetLastTexture()}_Delete(){if(0=this._refCount)throw new Error("no more references");this._refCount--}GetReferenceCount(){return this._refCount}GetWidth(){return this._width}GetHeight(){return this._height}IsStatic(){return this._isStatic}GetEstimatedMemoryUsage(){let a=this._width*this._height;switch(this._pixelFormat){case"rgba8":a*=4;break;case"rgb8":a*=3;break;case"rgba4":case"rgb5_a1":case"rgb565":a*=2;}return this._isMipMapped&&(a+=Math.floor(a/3)),a}static OnContextLost(){g.clear()}static allTextures(){return g.values()}}} +"use strict";{function a(a,b){let c,d,e,f;switch(a){case"rgba8":c=b.RGBA8,d=b.RGBA,e=b.RGBA,f=b.UNSIGNED_BYTE;break;case"rgb8":c=b.RGB8,d=b.RGB,e=b.RGB,f=b.UNSIGNED_BYTE;break;case"rgba4":c=b.RGBA4,d=b.RGBA,e=b.RGBA,f=b.UNSIGNED_SHORT_4_4_4_4;break;case"rgb5_a1":c=b.RGB5_A1,d=b.RGBA,e=b.RGBA,f=b.UNSIGNED_SHORT_5_5_5_1;break;case"rgb565":c=b.RGB565,d=b.RGB,e=b.RGB,f=b.UNSIGNED_SHORT_5_6_5;break;default:throw new Error("invalid pixel format");}return{sizedinternalformat:c,internalformat:d,format:e,type:f}}const b=new Set(["rgba8","rgb8","rgba4","rgb5_a1","rgb565"]),c=new Set(["nearest","bilinear","trilinear"]),d=new Set(["default","low","high"]);const e={isTiled:!1,tileType:"repeat",sampling:"trilinear",pixelFormat:"rgba8",mipMap:!0,mipMapQuality:"default",premultiplyAlpha:!0,isSvg:!1,width:-1,height:-1},f={premultiplyAlpha:!0},g=new Set;C3.Gfx.WebGLRendererTexture=class{constructor(a){this._renderer=a,this._texture=null,this._width=0,this._height=0,this._isStatic=!0,this._isTiled=!1,this._tileType="repeat",this._sampling="trilinear",this._pixelFormat="rgba8",this._isMipMapped=!1,this._mipMapQuality="default",this._refCount=0}_CreateStatic(f,h){if(("undefined"==typeof HTMLImageElement||!(f instanceof HTMLImageElement))&&("undefined"==typeof HTMLCanvasElement||!(f instanceof HTMLCanvasElement))&&("undefined"==typeof ImageBitmap||!(f instanceof ImageBitmap))&&("undefined"==typeof OffscreenCanvas||!(f instanceof OffscreenCanvas))&&!(f instanceof ImageData)&&!(f instanceof ArrayBuffer)&&null!==f)throw new Error("invalid texture source");if(h=Object.assign({},e,h),this._texture)throw new Error("already created texture");if(this._isTiled=!!h.isTiled,this._tileType=h.tileType,this._sampling=h.sampling,this._pixelFormat=h.pixelFormat,this._isMipMapped=!!h.mipMap,this._mipMapQuality=h.mipMapQuality,!c.has(this._sampling))throw new Error("invalid sampling");if(!b.has(this._pixelFormat))throw new Error("invalid pixel format");if(!d.has(this._mipMapQuality))throw new Error("invalid mipmap quality");if(this._isStatic=!0,!(f instanceof ArrayBuffer||null===f||h.isSvg))this._width=f.width,this._height=f.height;else if(this._width=h.width,this._height=h.height,f instanceof ArrayBuffer&&f.byteLength!==4*(this._width*this._height))throw new Error("ArrayBuffer wrong size");if(0>=this._width||0>=this._height)throw new Error("invalid texture data size");if(h.isSvg){const a=C3.CreateCanvas(this._width,this._height),b=a.getContext("2d");b.drawImage(f,0,0,this._width,this._height),f=a}const i=C3.isPOT(this._width)&&C3.isPOT(this._height),j=this._renderer.GetMaxTextureSize();if(this._width>j||this._height>j)throw new Error("texture data exceeds maximum texture size");const k=this._renderer.GetContext(),l=this._renderer.GetWebGLVersionNumber();this._texture=k.createTexture(),k.bindTexture(k.TEXTURE_2D,this._texture),k.pixelStorei(k["UNPACK_PREMULTIPLY_ALPHA_WEBGL"],h.premultiplyAlpha);const m=a(this._pixelFormat,k);if(!this._renderer.SupportsNPOTTextures()&&!i&&this._isTiled){if(null===f)throw new Error("cannot pass null data when creating a NPOT tiled texture without NPOT support");if(f instanceof ArrayBuffer&&(f=new ImageData(new Uint8ClampedArray(f),this._width,this._height)),f instanceof ImageData){const a=C3.CreateCanvas(this._width,this._height),b=a.getContext("2d");b.putImageData(f,0,0),f=a}const a=C3.CreateCanvas(C3.nextHighestPowerOfTwo(this._width),C3.nextHighestPowerOfTwo(this._height)),b=a.getContext("2d");b.imageSmoothingEnabled="nearest"!==this._sampling,b.drawImage(f,0,0,this._width,this._height,0,0,a.width,a.height),k.texImage2D(k.TEXTURE_2D,0,m.internalformat,m.format,m.type,a)}else if(2<=l){let a;a=this._isMipMapped?Math.floor(Math.log2(Math.max(this._width,this._height))+1):1,k.texStorage2D(k.TEXTURE_2D,a,m.sizedinternalformat,this._width,this._height),f instanceof ArrayBuffer?k.texSubImage2D(k.TEXTURE_2D,0,0,0,this._width,this._height,m.format,m.type,new Uint8Array(f)):null!==f&&k.texSubImage2D(k.TEXTURE_2D,0,0,0,m.format,m.type,f)}else f instanceof ArrayBuffer?k.texImage2D(k.TEXTURE_2D,0,m.internalformat,this._width,this._height,0,m.format,m.type,new Uint8Array(f)):null===f?k.texImage2D(k.TEXTURE_2D,0,m.internalformat,this._width,this._height,0,m.format,m.type,null):k.texImage2D(k.TEXTURE_2D,0,m.internalformat,m.format,m.type,f);null!==f&&this._SetTextureParameters(k),k.bindTexture(k.TEXTURE_2D,null),this._renderer._ResetLastTexture(),this._refCount=1,g.add(this)}_CreateDynamic(f,h,i){var j=Math.floor;if(i=Object.assign({},e,i),this._texture)throw new Error("already created texture");if(this._isTiled=!!i.isTiled,this._tileType=i.tileType,this._sampling=i.sampling,this._pixelFormat=i.pixelFormat,this._isMipMapped=!!i.mipMap,this._mipMapQuality=i.mipMapQuality,!c.has(this._sampling))throw new Error("invalid sampling");if(!b.has(this._pixelFormat))throw new Error("invalid pixel format");if(!d.has(this._mipMapQuality))throw new Error("invalid mipmap quality");this._isStatic=!1,this._width=j(f),this._height=j(h);const k=C3.isPOT(this._width)&&C3.isPOT(this._height),l=this._renderer.GetMaxTextureSize();if(0>=this._width||0>=this._height)throw new Error("invalid texture size");if(this._width>l||this._height>l)throw new Error("texture exceeds maximum texture size");if(!this._renderer.SupportsNPOTTextures()&&this._isTiled&&!k)throw new Error("non-power-of-two tiled textures not supported");const m=this._renderer.GetContext(),n=this._renderer.GetWebGLVersionNumber();this._texture=m.createTexture(),m.bindTexture(m.TEXTURE_2D,this._texture),m.pixelStorei(m["UNPACK_PREMULTIPLY_ALPHA_WEBGL"],i.premultiplyAlpha);const o=a(this._pixelFormat,m),p=2<=n?o.sizedinternalformat:o.internalformat;m.texImage2D(m.TEXTURE_2D,0,p,this._width,this._height,0,o.format,o.type,null),this._SetTextureParameters(m),m.bindTexture(m.TEXTURE_2D,null),this._renderer._ResetLastTexture(),this._refCount=1,g.add(this)}_GetMipMapHint(a){if("default"===this._mipMapQuality)return this._isStatic?a.NICEST:a.FASTEST;if("low"===this._mipMapQuality)return a.FASTEST;if("high"===this._mipMapQuality)return a.NICEST;throw new Error("invalid mipmap quality")}_SetTextureParameters(a){const b=C3.isPOT(this._width)&&C3.isPOT(this._height);if(!this._isTiled)a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);else if("repeat-x"===this._tileType)a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.REPEAT),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);else if("repeat-y"===this._tileType)a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.REPEAT);else if("repeat"===this._tileType)a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.REPEAT),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.REPEAT);else throw new Error("invalid tile type");if("nearest"===this._sampling)a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),this._isMipMapped=!1;else if(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),(b||this._renderer.SupportsNPOTTextures())&&this._isMipMapped){a.hint(a.GENERATE_MIPMAP_HINT,this._GetMipMapHint(a)),a.generateMipmap(a.TEXTURE_2D);const b="trilinear"===this._sampling&&!this._renderer.HasMajorPerformanceCaveat();a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,b?a.LINEAR_MIPMAP_LINEAR:a.LINEAR_MIPMAP_NEAREST)}else a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),this._isMipMapped=!1}_Update(b,c){if(("undefined"==typeof HTMLImageElement||!(b instanceof HTMLImageElement))&&("undefined"==typeof HTMLVideoElement||!(b instanceof HTMLVideoElement))&&("undefined"==typeof HTMLCanvasElement||!(b instanceof HTMLCanvasElement))&&("undefined"==typeof ImageBitmap||!(b instanceof ImageBitmap))&&("undefined"==typeof OffscreenCanvas||!(b instanceof OffscreenCanvas))&&!(b instanceof ImageData))throw new Error("invalid texture source");if(!this._texture||0>=this._refCount)throw new Error("texture not created");if(this._isStatic)throw new Error("cannot update static texture");c=Object.assign({},f,c);const d=b.width||b.videoWidth,e=b.height||b.videoHeight,g=this._renderer.GetWebGLVersionNumber(),h=this._renderer.GetContext();h.bindTexture(h.TEXTURE_2D,this._texture),h.pixelStorei(h["UNPACK_PREMULTIPLY_ALPHA_WEBGL"],c.premultiplyAlpha);const i=a(this._pixelFormat,h),j=2<=g?i.sizedinternalformat:i.internalformat;try{if(this._width===d&&this._height===e){const a=C3.isPOT(this._width)&&C3.isPOT(this._height);h.texSubImage2D(h.TEXTURE_2D,0,0,0,i.format,i.type,b),(a||this._renderer.SupportsNPOTTextures())&&this._isMipMapped&&(h.hint(h.GENERATE_MIPMAP_HINT,this._GetMipMapHint(h)),h.generateMipmap(h.TEXTURE_2D))}else{this._width=d,this._height=e;const a=C3.isPOT(this._width)&&C3.isPOT(this._height);if(!this._renderer.SupportsNPOTTextures()&&this._isTiled&&!a)throw new Error("non-power-of-two tiled textures not supported");h.texImage2D(h.TEXTURE_2D,0,j,i.format,i.type,b),(a||this._renderer.SupportsNPOTTextures())&&this._isMipMapped&&(h.hint(h.GENERATE_MIPMAP_HINT,this._GetMipMapHint(h)),h.generateMipmap(h.TEXTURE_2D))}}catch(a){console.error("Error updating WebGL texture: ",a)}h.bindTexture(h.TEXTURE_2D,null),this._renderer._ResetLastTexture()}_Delete(){if(0=this._refCount)throw new Error("no more references");this._refCount--}GetReferenceCount(){return this._refCount}GetWidth(){return this._width}GetHeight(){return this._height}IsStatic(){return this._isStatic}GetEstimatedMemoryUsage(){let a=this._width*this._height;switch(this._pixelFormat){case"rgba8":a*=4;break;case"rgb8":a*=3;break;case"rgba4":case"rgb5_a1":case"rgb565":a*=2;}return this._isMipMapped&&(a+=Math.floor(a/3)),a}static OnContextLost(){g.clear()}static allTextures(){return g.values()}}} // ../lib/gfx/renderTarget.js "use strict";{const a=new Set(["nearest","bilinear","trilinear"]),b={sampling:"trilinear",alpha:!0,readback:!0,isDefaultSize:!0,multisampling:0},c=new Set;C3.Gfx.WebGLRenderTarget=class{constructor(a){this._renderer=a,this._frameBuffer=null,this._texture=null,this._renderBuffer=null,this._width=0,this._height=0,this._isDefaultSize=!0,this._sampling="trilinear",this._alpha=!0,this._readback=!0,this._multisampling=0}_Create(d,e,f){f=Object.assign({},b,f);const g=this._renderer.GetWebGLVersionNumber();if(this._texture||this._renderBuffer)throw new Error("already created render target");if(this._sampling=f.sampling,this._alpha=!!f.alpha,this._readback=!!f.readback,this._isDefaultSize=!!f.isDefaultSize,this._multisampling=f.multisampling,!a.has(this._sampling))throw new Error("invalid sampling");if(0g||this._readback))throw new Error("invalid use of multisampling");if(2>g&&(this._readback=!0),this._width=d,this._height=e,0>=this._width||0>=this._height)throw new Error("invalid render target size");const h=this._renderer.GetContext();if(this._frameBuffer=h.createFramebuffer(),h.bindFramebuffer(h.FRAMEBUFFER,this._frameBuffer),this._readback){this._texture=this._renderer.CreateDynamicTexture(this._width,this._height,{sampling:this._sampling,pixelFormat:this._alpha?"rgba8":"rgb8",mipMap:!1});const a=this._texture._GetTexture();h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,a,0)}else{this._renderBuffer=h.createRenderbuffer(),h.bindRenderbuffer(h.RENDERBUFFER,this._renderBuffer);const a=this._alpha?h.RGBA8:h.RGB8;if(0a&&(this._multisampling=a)}else this._multisampling=0}0===this._multisampling?h.renderbufferStorage(h.RENDERBUFFER,a,this._width,this._height):h.renderbufferStorageMultisample(h.RENDERBUFFER,this._multisampling,a,this._width,this._height),h.framebufferRenderbuffer(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.RENDERBUFFER,this._renderBuffer),h.bindRenderbuffer(h.RENDERBUFFER,null)}h.bindFramebuffer(h.FRAMEBUFFER,null),c.add(this)}_Resize(a,b){if(this._width!==a||this._height!==b){this._width=a,this._height=b;const c=this._renderer.GetContext();c.bindFramebuffer(c.FRAMEBUFFER,this._frameBuffer),this._texture?this._texture._Update(new ImageData(this._width,this._height)):(c.bindRenderbuffer(c.RENDERBUFFER,this._renderBuffer),c.renderbufferStorage(c.RENDERBUFFER,this._alpha?c.RGBA8:c.RGB8,this._width,this._height),c.bindRenderbuffer(c.RENDERBUFFER,null)),c.bindFramebuffer(c.FRAMEBUFFER,null)}}_Delete(){if(!this._texture&&!this._renderBuffer)throw new Error("already deleted render target");c.delete(this);const a=this._renderer.GetContext();a.bindFramebuffer(a.FRAMEBUFFER,this._frameBuffer),this._texture?(a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,null,0),this._renderer.DeleteTexture(this._texture),this._texture=null):this._renderBuffer&&(a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.RENDERBUFFER,null),a.deleteRenderbuffer(this._renderBuffer),this._renderBuffer=null),a.bindFramebuffer(a.FRAMEBUFFER,null),2<=this._renderer.GetWebGLVersionNumber()&&(a.bindFramebuffer(a.READ_FRAMEBUFFER,null),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,null)),a.deleteFramebuffer(this._frameBuffer),this._renderer.GetBatchState().currentFramebuffer=null,this._frameBuffer=null}_GetFramebuffer(){return this._frameBuffer}GetWebGLRenderer(){return this._renderer}GetTexture(){return this._texture}IsLinearSampling(){return"nearest"!==this._sampling}HasAlpha(){return this._alpha}IsReadback(){return this._readback}GetWidth(){return this._width}GetHeight(){return this._height}IsDefaultSize(){return this._isDefaultSize}GetMultisampling(){return this._multisampling}GetOptions(){const a={sampling:this._sampling,alpha:this._alpha,readback:this._readback};return this._isDefaultSize||(a.width=this._width,a.height=this._height),a}IsCompatibleWithOptions(a){return a=Object.assign({},b,a),"nearest"!==a.sampling===this.IsLinearSampling()&&!!a.alpha===this.HasAlpha()&&!(2<=this._renderer.GetWebGLVersionNumber()&&!!a.readback!==this.IsReadback())&&("number"==typeof a.width||"number"==typeof a.height?!this.IsDefaultSize()&&this.GetWidth()===a.width&&this.GetHeight()===a.height:this.IsDefaultSize())}_GetWebGLTexture(){return this._texture?this._texture._GetTexture():null}GetEstimatedMemoryUsage(){return this._texture?this._texture.GetEstimatedMemoryUsage():this._width*this._height*(this._alpha?4:3)}static async DebugReadPixelsToBlob(a,b){const c=await a.ReadBackRenderTargetToImageData(b,!0);return await C3.ImageDataToBlob(c)}static OnContextLost(){c.clear()}static allRenderTargets(){return c.values()}static ResizeAll(a,b){for(const d of c)d.IsDefaultSize()&&d._Resize(a,b)}}} // ../lib/gfx/shaderProgram.js -"use strict";C3.Gfx.WebGLShaderProgram=class{static async Compile(a,b,c,d){const e=a.GetContext(),f=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(f,b),e.compileShader(f);const g=e.createShader(e.VERTEX_SHADER);e.shaderSource(g,c),e.compileShader(g);const h=e.createProgram();e.attachShader(h,f),e.attachShader(h,g),e.bindAttribLocation(h,0,"aPos"),e.bindAttribLocation(h,1,"aTex"),e.bindAttribLocation(h,2,"aPoints"),e.linkProgram(h);const i=a._GetParallelShaderCompileExtension();if(i?await a._WaitForObjectReady(()=>e.getProgramParameter(h,i["COMPLETION_STATUS_KHR"])):await C3.Wait(5),!e.getShaderParameter(f,e.COMPILE_STATUS)){const a=e.getShaderInfoLog(f);throw e.deleteShader(f),e.deleteShader(g),e.deleteProgram(h),new Error("Error compiling fragment shader: "+a)}if(!e.getShaderParameter(g,e.COMPILE_STATUS)){const a=e.getShaderInfoLog(g);throw e.deleteShader(f),e.deleteShader(g),e.deleteProgram(h),new Error("Error compiling vertex shader: "+a)}if(!e.getProgramParameter(h,e.LINK_STATUS)){const a=e.getProgramInfoLog(h);throw e.deleteShader(f),e.deleteShader(g),e.deleteProgram(h),new Error("Error linking shader program: "+a)}const j=C3.FilterUnprintableChars(e.getProgramInfoLog(h)||"").trim();return j&&!C3.IsStringAllWhitespace(j)&&console.info(`[WebGL] Shader program '${d}' compilation log: `,j),e.deleteShader(f),e.deleteShader(g),h}static async Create(a,b,c,d){const e=await C3.Gfx.WebGLShaderProgram.Compile(a,b.src,c,d);return new C3.Gfx.WebGLShaderProgram(a,e,b,d)}constructor(a,b,c,d){const e=a.GetContext(),f=a.GetBatchState();a.EndBatch(),e.useProgram(b),this._gl=e,this._renderer=a,this._name=d,this._shaderProgram=b,this._isDeviceTransform=""===d;const g=e.getAttribLocation(b,"aPos"),h=e.getAttribLocation(b,"aTex"),i=e.getAttribLocation(b,"aPoints");-1!==g&&(e.bindBuffer(e.ARRAY_BUFFER,a._vertexBuffer),e.vertexAttribPointer(g,a.GetNumVertexComponents(),e.FLOAT,!1,0,0),e.enableVertexAttribArray(g)),-1!==h&&(e.bindBuffer(e.ARRAY_BUFFER,a._texcoordBuffer),e.vertexAttribPointer(h,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(h)),-1!==i&&(e.bindBuffer(e.ARRAY_BUFFER,a._pointBuffer),e.vertexAttribPointer(i,4,e.FLOAT,!1,0,0),e.enableVertexAttribArray(i)),e.bindBuffer(e.ARRAY_BUFFER,null),this._uMatP=new C3.Gfx.WebGLShaderUniform(this,"matP","mat4"),this._uMatMV=new C3.Gfx.WebGLShaderUniform(this,"matMV","mat4"),this._uColor=new C3.Gfx.WebGLShaderUniform(this,"color","vec4"),this._uSamplerFront=new C3.Gfx.WebGLShaderUniform(this,"samplerFront","sampler"),this._uPointTexStart=new C3.Gfx.WebGLShaderUniform(this,"pointTexStart","vec2"),this._uPointTexEnd=new C3.Gfx.WebGLShaderUniform(this,"pointTexEnd","vec2"),this._uZElevation=new C3.Gfx.WebGLShaderUniform(this,"zElevation","float"),this._uTileSize=new C3.Gfx.WebGLShaderUniform(this,"tileSize","vec2"),this._uTileSpacing=new C3.Gfx.WebGLShaderUniform(this,"tileSpacing","vec2"),this._uColor2=new C3.Gfx.WebGLShaderUniform(this,"color2","vec4"),this._uOutlineThickness=new C3.Gfx.WebGLShaderUniform(this,"outlineThickness","float"),this._uSamplerBack=new C3.Gfx.WebGLShaderUniform(this,"samplerBack","sampler"),this._uDestStart=new C3.Gfx.WebGLShaderUniform(this,"destStart","vec2"),this._uDestEnd=new C3.Gfx.WebGLShaderUniform(this,"destEnd","vec2"),this._uSrcStart=new C3.Gfx.WebGLShaderUniform(this,"srcStart","vec2"),this._uSrcEnd=new C3.Gfx.WebGLShaderUniform(this,"srcEnd","vec2"),this._uSrcOriginStart=new C3.Gfx.WebGLShaderUniform(this,"srcOriginStart","vec2"),this._uSrcOriginEnd=new C3.Gfx.WebGLShaderUniform(this,"srcOriginEnd","vec2"),this._uPixelSize=new C3.Gfx.WebGLShaderUniform(this,"pixelSize","vec2"),this._uSeconds=new C3.Gfx.WebGLShaderUniform(this,"seconds","float"),this._uLayerScale=new C3.Gfx.WebGLShaderUniform(this,"layerScale","float"),this._uLayerAngle=new C3.Gfx.WebGLShaderUniform(this,"layerAngle","float"),this._uLayoutStart=new C3.Gfx.WebGLShaderUniform(this,"layoutStart","vec2"),this._uLayoutEnd=new C3.Gfx.WebGLShaderUniform(this,"layoutEnd","vec2"),this._hasAnyOptionalUniforms=!!(this._uPixelSize.IsUsed()||this._uSeconds.IsUsed()||this._uSamplerBack.IsUsed()||this._uDestStart.IsUsed()||this._uDestEnd.IsUsed()||this._uSrcStart.IsUsed()||this._uSrcEnd.IsUsed()||this._uSrcOriginStart.IsUsed()||this._uSrcOriginEnd.IsUsed()||this._uLayerScale.IsUsed()||this._uLayerAngle.IsUsed()||this._uLayoutStart.IsUsed()||this._uLayoutEnd.IsUsed()),this._extendBoxHorizontal=c.extendBoxHorizontal||0,this._extendBoxVertical=c.extendBoxVertical||0,this._crossSampling=!!c.crossSampling,this._mustPreDraw=!!c.mustPreDraw,this._preservesOpaqueness=!!c.preservesOpaqueness,this._animated=!!c.animated;const j=c.parameters||[];this._uCustomParameters=[],this._usesDest=this._uDestStart.IsUsed()||this._uDestEnd.IsUsed(),this._usesAnySrcRectOrPixelSize=this._uPixelSize.IsUsed()||this._uSrcStart.IsUsed()||this._uSrcEnd.IsUsed()||this._uSrcOriginStart.IsUsed()||this._uSrcOriginEnd.IsUsed(),this._needsPostDrawOrExtendBox=this._crossSampling||this._usesDest||0!==this._extendBoxHorizontal||0!==this._extendBoxVertical,this._hasCurrentMatP=!1,this._hasCurrentMatMV=!1,this._uColor.Init4f(1,1,1,1),this._uColor2.Init4f(1,1,1,1),this._uSamplerFront.Init1i(0),this._uSamplerBack.Init1i(1),this._uPointTexStart.Init2f(0,0),this._uPointTexEnd.Init2f(1,1),this._uZElevation.Init1f(0),this._uTileSize.Init2f(0,0),this._uTileSpacing.Init2f(0,0),this._uDestStart.Init2f(0,0),this._uDestEnd.Init2f(1,1),this._uSrcStart.Init2f(0,0),this._uSrcEnd.Init2f(0,0),this._uSrcOriginStart.Init2f(0,0),this._uSrcOriginEnd.Init2f(0,0),this._uPixelSize.Init2f(0,0),this._uLayerScale.Init1f(1),this._uLayerAngle.Init1f(0),this._uSeconds.Init1f(0),this._uLayoutStart.Init2f(0,0),this._uLayoutEnd.Init2f(0,0),this._uOutlineThickness.Init1f(1);for(const e of j){const a=e[0],b=e[2],c=new C3.Gfx.WebGLShaderUniform(this,a,b);"color"===b?c.Init3f(0,0,0):c.Init1f(0),this._uCustomParameters.push(c)}this._isDeviceTransform?this._UpdateDeviceTransformUniforms(f.currentMatP):(this.UpdateMatP(f.currentMatP,!0),this.UpdateMatMV(f.currentMV,!0));const k=f.currentShader;e.useProgram(k?k._shaderProgram:null)}Release(){this._gl.deleteProgram(this._shaderProgram),this._shaderProgram=null,this._renderer._RemoveShaderProgram(this),this._gl=null,this._renderer=null}GetName(){return this._name}GetWebGLContext(){return this._gl}GetShaderProgram(){return this._shaderProgram}UsesDest(){return this._usesDest}UsesCrossSampling(){return this._crossSampling}MustPreDraw(){return this._mustPreDraw}PreservesOpaqueness(){return this._preservesOpaqueness}ExtendsBox(){return 0!==this._extendBoxHorizontal||0!==this._extendBoxVertical}GetBoxExtendHorizontal(){return this._extendBoxHorizontal}GetBoxExtendVertical(){return this._extendBoxVertical}UsesAnySrcRectOrPixelSize(){return this._usesAnySrcRectOrPixelSize}NeedsPostDrawOrExtendsBox(){return this._needsPostDrawOrExtendBox}GetParameterCount(){return this._uCustomParameters.length}GetParameterType(a){return this._uCustomParameters[a].GetType()}AreCustomParametersAlreadySetInBatch(a){for(let b=0,c=a.length;be.getProgramParameter(h,i["COMPLETION_STATUS_KHR"])):await C3.Wait(5),!e.getShaderParameter(f,e.COMPILE_STATUS)){const a=e.getShaderInfoLog(f);throw e.deleteShader(f),e.deleteShader(g),e.deleteProgram(h),new Error("Error compiling fragment shader: "+a)}if(!e.getShaderParameter(g,e.COMPILE_STATUS)){const a=e.getShaderInfoLog(g);throw e.deleteShader(f),e.deleteShader(g),e.deleteProgram(h),new Error("Error compiling vertex shader: "+a)}if(!e.getProgramParameter(h,e.LINK_STATUS)){const a=e.getProgramInfoLog(h);throw e.deleteShader(f),e.deleteShader(g),e.deleteProgram(h),new Error("Error linking shader program: "+a)}const j=C3.FilterUnprintableChars(e.getProgramInfoLog(h)||"").trim();return j&&!C3.IsStringAllWhitespace(j)&&console.info(`[WebGL] Shader program '${d}' compilation log: `,j),e.deleteShader(f),e.deleteShader(g),h}static async Create(a,b,c,d){const e=await C3.Gfx.WebGLShaderProgram.Compile(a,b.src,c,d);return new C3.Gfx.WebGLShaderProgram(a,e,b,d)}constructor(a,b,c,d){const e=a.GetContext(),f=a.GetBatchState();a.EndBatch(),e.useProgram(b),this._gl=e,this._renderer=a,this._name=d,this._shaderProgram=b,this._isDeviceTransform=""===d;const g=e.getAttribLocation(b,"aPos"),h=e.getAttribLocation(b,"aTex"),i=e.getAttribLocation(b,"aPoints");-1!==g&&(e.bindBuffer(e.ARRAY_BUFFER,a._vertexBuffer),e.vertexAttribPointer(g,a.GetNumVertexComponents(),e.FLOAT,!1,0,0),e.enableVertexAttribArray(g)),-1!==h&&(e.bindBuffer(e.ARRAY_BUFFER,a._texcoordBuffer),e.vertexAttribPointer(h,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(h)),-1!==i&&(e.bindBuffer(e.ARRAY_BUFFER,a._pointBuffer),e.vertexAttribPointer(i,4,e.FLOAT,!1,0,0),e.enableVertexAttribArray(i)),e.bindBuffer(e.ARRAY_BUFFER,null),this._uMatP=new C3.Gfx.WebGLShaderUniform(this,"matP","mat4"),this._uMatMV=new C3.Gfx.WebGLShaderUniform(this,"matMV","mat4"),this._uColor=new C3.Gfx.WebGLShaderUniform(this,"color","vec4"),this._uSamplerFront=new C3.Gfx.WebGLShaderUniform(this,"samplerFront","sampler"),this._uPointTexStart=new C3.Gfx.WebGLShaderUniform(this,"pointTexStart","vec2"),this._uPointTexEnd=new C3.Gfx.WebGLShaderUniform(this,"pointTexEnd","vec2"),this._uZElevation=new C3.Gfx.WebGLShaderUniform(this,"zElevation","float"),this._uTileSize=new C3.Gfx.WebGLShaderUniform(this,"tileSize","vec2"),this._uTileSpacing=new C3.Gfx.WebGLShaderUniform(this,"tileSpacing","vec2"),this._uColor2=new C3.Gfx.WebGLShaderUniform(this,"color2","vec4"),this._uOutlineThickness=new C3.Gfx.WebGLShaderUniform(this,"outlineThickness","float"),this._uSamplerBack=new C3.Gfx.WebGLShaderUniform(this,"samplerBack","sampler"),this._uDestStart=new C3.Gfx.WebGLShaderUniform(this,"destStart","vec2"),this._uDestEnd=new C3.Gfx.WebGLShaderUniform(this,"destEnd","vec2"),this._uSrcStart=new C3.Gfx.WebGLShaderUniform(this,"srcStart","vec2"),this._uSrcEnd=new C3.Gfx.WebGLShaderUniform(this,"srcEnd","vec2"),this._uSrcOriginStart=new C3.Gfx.WebGLShaderUniform(this,"srcOriginStart","vec2"),this._uSrcOriginEnd=new C3.Gfx.WebGLShaderUniform(this,"srcOriginEnd","vec2"),this._uPixelSize=new C3.Gfx.WebGLShaderUniform(this,"pixelSize","vec2"),this._uSeconds=new C3.Gfx.WebGLShaderUniform(this,"seconds","float"),this._uLayerScale=new C3.Gfx.WebGLShaderUniform(this,"layerScale","float"),this._uLayerAngle=new C3.Gfx.WebGLShaderUniform(this,"layerAngle","float"),this._uLayoutStart=new C3.Gfx.WebGLShaderUniform(this,"layoutStart","vec2"),this._uLayoutEnd=new C3.Gfx.WebGLShaderUniform(this,"layoutEnd","vec2"),this._hasAnyOptionalUniforms=!!(this._uPixelSize.IsUsed()||this._uSeconds.IsUsed()||this._uSamplerBack.IsUsed()||this._uDestStart.IsUsed()||this._uDestEnd.IsUsed()||this._uSrcStart.IsUsed()||this._uSrcEnd.IsUsed()||this._uSrcOriginStart.IsUsed()||this._uSrcOriginEnd.IsUsed()||this._uLayerScale.IsUsed()||this._uLayerAngle.IsUsed()||this._uLayoutStart.IsUsed()||this._uLayoutEnd.IsUsed()),this._extendBoxHorizontal=c.extendBoxHorizontal||0,this._extendBoxVertical=c.extendBoxVertical||0,this._crossSampling=!!c.crossSampling,this._mustPreDraw=!!c.mustPreDraw,this._preservesOpaqueness=!!c.preservesOpaqueness,this._animated=!!c.animated;const j=c.parameters||[];this._uCustomParameters=[],this._usesDest=this._uDestStart.IsUsed()||this._uDestEnd.IsUsed(),this._usesAnySrcRectOrPixelSize=this._uPixelSize.IsUsed()||this._uSrcStart.IsUsed()||this._uSrcEnd.IsUsed()||this._uSrcOriginStart.IsUsed()||this._uSrcOriginEnd.IsUsed(),this._needsPostDrawOrExtendBox=this._crossSampling||this._usesDest||0!==this._extendBoxHorizontal||0!==this._extendBoxVertical,this._hasCurrentMatP=!1,this._hasCurrentMatMV=!1,this._uColor.Init4f(1,1,1,1),this._uColor2.Init4f(1,1,1,1),this._uSamplerFront.Init1i(0),this._uSamplerBack.Init1i(1),this._uPointTexStart.Init2f(0,0),this._uPointTexEnd.Init2f(1,1),this._uZElevation.Init1f(0),this._uTileSize.Init2f(0,0),this._uTileSpacing.Init2f(0,0),this._uDestStart.Init2f(0,0),this._uDestEnd.Init2f(1,1),this._uSrcStart.Init2f(0,0),this._uSrcEnd.Init2f(0,0),this._uSrcOriginStart.Init2f(0,0),this._uSrcOriginEnd.Init2f(0,0),this._uPixelSize.Init2f(0,0),this._uLayerScale.Init1f(1),this._uLayerAngle.Init1f(0),this._uSeconds.Init1f(0),this._uLayoutStart.Init2f(0,0),this._uLayoutEnd.Init2f(0,0),this._uOutlineThickness.Init1f(1);for(const e of j){const a=e[0],b=e[2],c=new C3.Gfx.WebGLShaderUniform(this,a,b);"color"===b?c.Init3f(0,0,0):c.Init1f(0),this._uCustomParameters.push(c)}this._isDeviceTransform?this._UpdateDeviceTransformUniforms(f.currentMatP):(this.UpdateMatP(f.currentMatP,!0),this.UpdateMatMV(f.currentMV,!0));const k=f.currentShader;e.useProgram(k?k._shaderProgram:null)}Release(){this._gl.deleteProgram(this._shaderProgram),this._shaderProgram=null,this._renderer._RemoveShaderProgram(this),this._gl=null,this._renderer=null}GetName(){return this._name}GetWebGLContext(){return this._gl}GetShaderProgram(){return this._shaderProgram}UsesDest(){return this._usesDest}UsesCrossSampling(){return this._crossSampling}MustPreDraw(){return this._mustPreDraw}PreservesOpaqueness(){return this._preservesOpaqueness}ExtendsBox(){return 0!==this._extendBoxHorizontal||0!==this._extendBoxVertical}GetBoxExtendHorizontal(){return this._extendBoxHorizontal}GetBoxExtendVertical(){return this._extendBoxVertical}UsesAnySrcRectOrPixelSize(){return this._usesAnySrcRectOrPixelSize}NeedsPostDrawOrExtendsBox(){return this._needsPostDrawOrExtendBox}GetParameterCount(){return this._uCustomParameters.length}GetParameterType(a){return this._uCustomParameters[a].GetType()}AreCustomParametersAlreadySetInBatch(a){for(let b=0,c=a.length;b{const b=a.font.GetName();for(const c of i)(c.IsBBCodeEnabled()||C3.equalsNoCase(c.GetFontName(),b))&&c._SetTextChanged()}),C3.Gfx.WebGLText=class{constructor(a,b){b=Object.assign({},d,b),this._renderer=a,this._fontName="Arial",this._fontSize=16,this._lineHeight=0,this._isBold=!1,this._isItalic=!1,this._colorStr="black",this._isBBcodeEnabled=!1,this.onloadfont=null,this._alreadyLoadedFonts=new Set,this._horizontalAlign="left",this._verticalAlign="top",this._text="",this._bbString=null,this._wrappedText=C3.New(C3.WordWrap),this._wrapMode="word",this._textChanged=!1,this._isUpdating=!1,this._isAsync=!0,this._drawMaxCharCount=-1,this._drawCharCount=0,this._cssWidth=0,this._cssHeight=0,this._width=0,this._height=0,this._zoom=1,this._changed=!1,this._textCanvas=null,this._textContext=null,this._measureContext=null,this._lastCanvasWidth=-1,this._lastCanvasHeight=-1,this._lastTextCanvasFont="",this._lastMeasureCanvasFont="",this._lastTextCanvasFillStyle="",this._lastTextCanvasOpacity=1,this._lastTextCanvasLineWidth=1,this._measureTextCallback=(a,b)=>this._MeasureText(a,b),this._texture=null,this._textureWidth=0,this._textureHeight=0,this._rcTex=new C3.Rect,this._scaleFactor=1,this._needToRecreateTexture=!1,this._textureTimeout=new C3.IdleTimeout(()=>{this.ReleaseTexture(),this._SetTextCanvasSize(8,8)},b.timeout),this.ontextureupdate=null,this._wasReleased=!1,i.add(this)}Release(){this.onloadfont=null,this._alreadyLoadedFonts.clear(),this._bbString=null,this._textCanvas=null,this._textContext=null,this._measureContext=null,this._measureTextCallback=null,this._textureTimeout.Release(),this.ontextureupdate=null,this.ReleaseTexture(),this._wrappedText.Clear(),this._wrappedText=null,this._renderer=null,this._wasReleased=!0,i.delete(this)}_SetChanged(){this._changed=!0}_SetTextChanged(){this._SetChanged(),this._wrappedText.Clear(),this._textChanged=!0}SetIsAsync(b){this._isAsync=!!b}IsAsync(){return this._isAsync}SetBBCodeEnabled(a){a=!!a;this._isBBcodeEnabled===a||(this._isBBcodeEnabled=a,this._textContext&&(this._textContext.textBaseline=this._isBBcodeEnabled?"alphabetic":"top"),this._SetTextChanged())}IsBBCodeEnabled(){return this._isBBcodeEnabled}SetFontName(a){a||(a="serif");this._fontName===a||(this._fontName=a,this._SetTextChanged())}GetFontName(){return this._fontName}SetFontSize(a){.1>a&&(a=.1);this._fontSize===a||(this._fontSize=a,this._SetTextChanged())}SetLineHeight(a){this._lineHeight===a||(this._lineHeight=a,this._SetChanged())}SetBold(a){a=!!a;this._isBold===a||(this._isBold=a,this._SetTextChanged())}SetItalic(a){a=!!a;this._isItalic===a||(this._isItalic=a,this._SetTextChanged())}SetDrawMaxCharacterCount(a){a=Math.floor(a);this._drawMaxCharCount===a||(this._drawMaxCharCount=a,this._SetChanged())}GetDrawMaxCharacterCount(){return this._drawMaxCharCount}_GetStyleTag(a,b){for(let c=a.length-1;0<=c;--c){const d=a[c];if(d.tag===b)return d}return null}_HasStyleTag(a,b){return!!this._GetStyleTag(a,b)}_GetFontString(a,b){let c="";(this._isBold||this._HasStyleTag(b,"b"))&&(c+="bold"),(this._isItalic||this._HasStyleTag(b,"i"))&&(c+=" italic");const d=this._GetStyleTag(b,"size"),e=d?parseFloat(d.param):this._fontSize;c+=a?" "+e+"pt":" "+e*this._scaleFactor*this._zoom*self.devicePixelRatio+"pt";let f=this._fontName;const g=this._GetStyleTag(b,"font");return g&&g.param&&(f=g.param,this.onloadfont&&!this._alreadyLoadedFonts.has(f)&&(this.onloadfont(f),this._alreadyLoadedFonts.add(f))),f&&(c+=" \""+f+"\""),c}SetColor(a){a instanceof C3.Color&&(a=a.getCssRgb());this._colorStr===a||(this._colorStr=a,this._SetChanged())}SetColorRgb(a,c,d){e.setRgb(a,c,d),this.SetColor(e)}SetHorizontalAlignment(a){if(!f.has(a))throw new Error("invalid horizontal alignment");this._horizontalAlign===a||(this._horizontalAlign=a,this._SetChanged())}SetVerticalAlignment(a){if(!g.has(a))throw new Error("invalid vertical alignment");this._verticalAlign===a||(this._verticalAlign=a,this._SetChanged())}SetWordWrapMode(a){if(!h.has(a))throw new Error("invalid word wrap mode");this._wrapMode===a||(this._wrapMode=a,this._SetTextChanged())}SetText(a){this._text===a||(this._text=a,this._SetTextChanged())}SetSize(a,b,c){var d=Math.min;if("undefined"==typeof c&&(c=1),0>=a||0>=a)return;if(this._cssWidth===a&&this._cssHeight===b&&this._zoom===c)return;1===this._zoom!=(1===c)&&(this._needToRecreateTexture=!0);const e=this._cssWidth,f=this._zoom;this._cssWidth=a,this._cssHeight=b,this._zoom=c;const g=self.devicePixelRatio;this._width=this._cssWidth*this._zoom*g,this._height=this._cssHeight*this._zoom*g;const h=Math.max(this._width,this._height),i=d(this._renderer.GetMaxTextureSize(),2048);let j=1;h>i&&(j=i/h,this._width=d(this._width*j,i),this._height=d(this._height*j,i)),this._scaleFactor=j,0=this._width||0>=this._height||(this._changed=!1,this._isUpdating=!0,this._isAsync?C3.Asyncify(()=>this._DoUpdate()):this._DoUpdate())}_DoUpdate(){var a=Math.ceil;this._wasReleased||(this._SetTextCanvasSize(a(this._width),a(this._height)),this._MaybeWrapText(),this._DrawTextToCanvas(),this._UpdateTexture(),this._textureTimeout.Reset(),this._isUpdating=!1)}_SetTextCanvasSize(a,b){this._textCanvas||(this._textCanvas=C3.CreateCanvas(16,16));let c=!1;(this._lastCanvasWidth!==a||this._lastCanvasHeight!==b)&&(this._lastCanvasWidth=a,this._lastCanvasHeight=b,this._textCanvas.width=a,this._textCanvas.height=b,c=!0),this._textContext||(this._textContext=this._textCanvas.getContext("2d"),c=!0),c?(this._textContext.textBaseline=this._isBBcodeEnabled?"alphabetic":"top",this._textContext.font=this._lastTextCanvasFont,this._textContext.fillStyle=this._lastTextCanvasFillStyle,this._textContext.strokeStyle=this._lastTextCanvasFillStyle):this._textContext.clearRect(0,0,a,b)}_MaybeCreateMeasureContext(){this._measureContext||(this._measureContext=C3.CreateCanvas(16,16).getContext("2d"))}_SetMeasureFontString(a){this._lastMeasureCanvasFont===a||(this._lastMeasureCanvasFont=a,this._measureContext.font=a)}_MaybeWrapText(){this._textChanged&&(this._MaybeCreateMeasureContext(),this._isBBcodeEnabled&&(!this._bbString||this._bbString.toString()!==this._text)&&(this._bbString=new C3.BBString(this._text,{noEscape:!0})),this._wrappedText.WordWrap(this._isBBcodeEnabled?this._bbString.toFragmentList():this._text,this._measureTextCallback,this._cssWidth,this._wrapMode,0),this._textChanged=!1)}_MeasureText(a,b){this._SetMeasureFontString(this._GetFontString(!0,b));const d=this._GetStyleTag(b,"size"),e=d?parseFloat(d.param):this._fontSize;return{width:this._measureContext.measureText(a).width,height:c(e)}}_SetDrawFontString(a){this._lastTextCanvasFont===a||(this._lastTextCanvasFont=a,this._textContext.font=a)}_SetDrawCanvasColor(a){this._lastTextCanvasFillStyle===a||(this._lastTextCanvasFillStyle=a,this._textContext.fillStyle=a,this._textContext.strokeStyle=a)}_SetDrawCanvasOpacity(a){this._lastTextCanvasOpacity===a||(this._lastTextCanvasOpacity=a,this._textContext.globalAlpha=a)}_SetDrawCanvasLineWith(a){this._lastTextCanvasLineWidth===a||(this._lastTextCanvasLineWidth=a,this._textContext.lineWidth=a)}_DrawTextToCanvas(){var a=Math.max;this._drawCharCount=0;const b=this._scaleFactor*this._zoom*self.devicePixelRatio,d=c(this._fontSize)*b,e=(4+this._lineHeight)*b,f=d+e;let g=0;const h=this._wrappedText.GetLines();"center"===this._verticalAlign?g=a(this._height/2-h.length*f/2,0):"bottom"===this._verticalAlign&&(g=a(this._height-h.length*f-2,0));for(let a=0,c=h.length;athis._height-4*b)break;}else if(0=this._height-d)break;let f=0;"center"===this._horizontalAlign?f=(this._width-c.width*b)/2:"right"===this._horizontalAlign&&(f=this._width-c.width*b),this._DrawTextLine(c,f,g,b),this._isBBcodeEnabled||(g+=d),g+=e}}_DrawTextLine(a,b,c,d){for(const e of a.fragments)this._DrawTextFragment(e,b,c,d,a.height),b+=e.width*d}_DrawTextFragment(c,d,e,f,g){const h=this._textContext,i=g/16;let j=c.width*f;const k=c.height*f,l=c.height/16,m=(4+this._lineHeight)*f,n=c.styles;let o=c.text;if(-1!==this._drawMaxCharCount){if(this._drawCharCount>=this._drawMaxCharCount)return;this._drawCharCount+o.length>this._drawMaxCharCount&&(o=o.substr(0,this._drawMaxCharCount-this._drawCharCount),j=this._MeasureText(o,n).width*f),this._drawCharCount+=o.length}const p=this._GetStyleTag(n,"background"),q=this._HasStyleTag(n,"u"),r=this._HasStyleTag(n,"s");if((!C3.IsStringAllWhitespace(o)||p||q||r)&&!this._HasStyleTag(n,"hide")){const c=this._GetStyleTag(n,"offsetx");d+=c?parseFloat(c.param)*f:0;const g=this._GetStyleTag(n,"offsety");e+=g?parseFloat(g.param)*f:0,p&&(this._SetDrawCanvasColor(p.param),h.fillRect(d,e-k,j,k+m));const s=this._GetStyleTag(n,"color");this._SetDrawCanvasColor(s?s.param:this._colorStr);const t=this._GetStyleTag(n,"opacity");this._SetDrawCanvasOpacity(t?parseFloat(t.param)/100:1);const u=this._HasStyleTag(n,"stroke");if(u&&this._SetDrawCanvasLineWith(l*this._scaleFactor*this._zoom),q&&b(h,u,d,e+f*i,j,f*i),r&&b(h,u,d,e-k/4,j,f*l),this._SetDrawFontString(this._GetFontString(!1,n)),a(h,u,o,d,e,j),!u){this._SetDrawCanvasLineWith(l*this._scaleFactor*this._zoom);const b=this._GetStyleTag(n,"outline");b&&(this._SetDrawCanvasColor(b.param),a(h,!0,o,d,e,j))}}}_UpdateTexture(){var a=Math.ceil;this._renderer.IsContextLost()||(this._textureWidth=a(this._width),this._textureHeight=a(this._height),this._rcTex.set(0,0,this._width/this._textureWidth,this._height/this._textureHeight),this._needToRecreateTexture&&(this.ReleaseTexture(),this._needToRecreateTexture=!1),!this._texture&&(this._texture=this._renderer.CreateDynamicTexture(this._textureWidth,this._textureHeight,{mipMap:1===this._zoom,mipMapQuality:"high"})),this._renderer.UpdateTexture(this._textCanvas,this._texture),this.ontextureupdate&&this.ontextureupdate())}GetTexRect(){return this._rcTex}ReleaseTexture(){this._texture&&(!this._renderer.IsContextLost()&&this._renderer.DeleteTexture(this._texture),this._texture=null)}static OnContextLost(){for(const a of i)a.ReleaseTexture()}static GetAll(){return i.values()}}} +"use strict";{function a(a,b,c,d,e,f){b?"Gecko"===C3.Platform.BrowserEngine?a.strokeText(c,d,e,f):a.strokeText(c,d,e):"Gecko"===C3.Platform.BrowserEngine?a.fillText(c,d,e,f):a.fillText(c,d,e)}function b(a,b,c,d,e,f){b?a.strokeRect(c,d,e,f):a.fillRect(c,d,e,f)}function c(a){return a*(4/3)}const d={timeout:60},e=new C3.Color(0,0,0,1),f=new Set(["left","center","right"]),g=new Set(["top","center","bottom"]),h=new Set(["word","character"]),i=new Set;C3.FontManager&&C3.FontManager.addEventListener("fontload",(a)=>{const b=a.font.GetName();for(const c of i)(c.IsBBCodeEnabled()||C3.equalsNoCase(c.GetFontName(),b))&&c._SetTextChanged()}),C3.Gfx.WebGLText=class{constructor(a,b){b=Object.assign({},d,b),this._renderer=a,this._fontName="Arial",this._fontSize=16,this._lineHeight=0,this._isBold=!1,this._isItalic=!1,this._colorStr="black",this._isBBcodeEnabled=!1,this.onloadfont=null,this._alreadyLoadedFonts=new Set,this._horizontalAlign="left",this._verticalAlign="top",this._text="",this._bbString=null,this._wrappedText=C3.New(C3.WordWrap),this._wrapMode="word",this._textChanged=!1,this._isUpdating=!1,this._isAsync=!0,this._drawMaxCharCount=-1,this._drawCharCount=0,this._cssWidth=0,this._cssHeight=0,this._width=0,this._height=0,this._zoom=1,this._changed=!1,this._textCanvas=null,this._textContext=null,this._measureContext=null,this._lastCanvasWidth=-1,this._lastCanvasHeight=-1,this._lastTextCanvasFont="",this._lastMeasureCanvasFont="",this._lastTextCanvasFillStyle="",this._lastTextCanvasOpacity=1,this._lastTextCanvasLineWidth=1,this._measureTextCallback=(a,b)=>this._MeasureText(a,b),this._texture=null,this._textureWidth=0,this._textureHeight=0,this._rcTex=new C3.Rect,this._scaleFactor=1,this._needToRecreateTexture=!1,this._textureTimeout=new C3.IdleTimeout(()=>{this.ReleaseTexture(),this._SetTextCanvasSize(8,8)},b.timeout),this.ontextureupdate=null,this._wasReleased=!1,i.add(this)}Release(){this.onloadfont=null,this._alreadyLoadedFonts.clear(),this._bbString=null,this._textCanvas=null,this._textContext=null,this._measureContext=null,this._measureTextCallback=null,this._textureTimeout.Release(),this.ontextureupdate=null,this.ReleaseTexture(),this._wrappedText.Clear(),this._wrappedText=null,this._renderer=null,this._wasReleased=!0,i.delete(this)}_SetChanged(){this._changed=!0}_SetTextChanged(){this._SetChanged(),this._wrappedText.Clear(),this._textChanged=!0}SetIsAsync(b){this._isAsync=!!b}IsAsync(){return this._isAsync}SetBBCodeEnabled(a){a=!!a;this._isBBcodeEnabled===a||(this._isBBcodeEnabled=a,this._textContext&&(this._textContext.textBaseline=this._isBBcodeEnabled?"alphabetic":"top"),this._SetTextChanged())}IsBBCodeEnabled(){return this._isBBcodeEnabled}SetFontName(a){a||(a="serif");this._fontName===a||(this._fontName=a,this._SetTextChanged())}GetFontName(){return this._fontName}SetFontSize(a){.1>a&&(a=.1);this._fontSize===a||(this._fontSize=a,this._SetTextChanged())}SetLineHeight(a){this._lineHeight===a||(this._lineHeight=a,this._SetChanged())}SetBold(a){a=!!a;this._isBold===a||(this._isBold=a,this._SetTextChanged())}SetItalic(a){a=!!a;this._isItalic===a||(this._isItalic=a,this._SetTextChanged())}SetDrawMaxCharacterCount(a){a=Math.floor(a);this._drawMaxCharCount===a||(this._drawMaxCharCount=a,this._SetChanged())}GetDrawMaxCharacterCount(){return this._drawMaxCharCount}_GetStyleTag(a,b){for(let c=a.length-1;0<=c;--c){const d=a[c];if(d.tag===b)return d}return null}_HasStyleTag(a,b){return!!this._GetStyleTag(a,b)}_GetFontString(a,b){let c="";(this._isBold||this._HasStyleTag(b,"b"))&&(c+="bold"),(this._isItalic||this._HasStyleTag(b,"i"))&&(c+=" italic");const d=this._GetStyleTag(b,"size"),e=d?parseFloat(d.param):this._fontSize;c+=a?" "+e+"pt":" "+e*this._scaleFactor*this._zoom*self.devicePixelRatio+"pt";let f=this._fontName;const g=this._GetStyleTag(b,"font");return g&&g.param&&(f=g.param,this.onloadfont&&!this._alreadyLoadedFonts.has(f)&&(this.onloadfont(f),this._alreadyLoadedFonts.add(f))),f&&(c+=" \""+f+"\""),c}SetColor(a){a instanceof C3.Color&&(a=a.getCssRgb());this._colorStr===a||(this._colorStr=a,this._SetChanged())}SetColorRgb(a,c,d){e.setRgb(a,c,d),this.SetColor(e)}SetHorizontalAlignment(a){if(!f.has(a))throw new Error("invalid horizontal alignment");this._horizontalAlign===a||(this._horizontalAlign=a,this._SetChanged())}SetVerticalAlignment(a){if(!g.has(a))throw new Error("invalid vertical alignment");this._verticalAlign===a||(this._verticalAlign=a,this._SetChanged())}SetWordWrapMode(a){if(!h.has(a))throw new Error("invalid word wrap mode");this._wrapMode===a||(this._wrapMode=a,this._SetTextChanged())}SetText(a){this._text===a||(this._text=a,this._SetTextChanged())}SetSize(a,b,c){var d=Math.min;if("undefined"==typeof c&&(c=1),0>=a||0>=a)return;if(this._cssWidth===a&&this._cssHeight===b&&this._zoom===c)return;1===this._zoom!=(1===c)&&(this._needToRecreateTexture=!0);const e=this._cssWidth,f=this._zoom;this._cssWidth=a,this._cssHeight=b,this._zoom=c;const g=self.devicePixelRatio;this._width=this._cssWidth*this._zoom*g,this._height=this._cssHeight*this._zoom*g;const h=Math.max(this._width,this._height),i=d(this._renderer.GetMaxTextureSize(),2048);let j=1;h>i&&(j=i/h,this._width=d(this._width*j,i),this._height=d(this._height*j,i)),this._scaleFactor=j,0=this._width||0>=this._height||(this._changed=!1,this._isUpdating=!0,this._isAsync?C3.Asyncify(()=>this._DoUpdate()):this._DoUpdate())}_DoUpdate(){var a=Math.ceil;this._wasReleased||(this._SetTextCanvasSize(a(this._width),a(this._height)),this._MaybeWrapText(),this._DrawTextToCanvas(),this._UpdateTexture(),this._textureTimeout.Reset(),this._isUpdating=!1)}_SetTextCanvasSize(a,b){this._textCanvas||(this._textCanvas=C3.CreateCanvas(16,16));let c=!1;(this._lastCanvasWidth!==a||this._lastCanvasHeight!==b)&&(this._lastCanvasWidth=a,this._lastCanvasHeight=b,this._textCanvas.width=a,this._textCanvas.height=b,c=!0),this._textContext||(this._textContext=this._textCanvas.getContext("2d"),c=!0),c?(this._textContext.textBaseline=this._isBBcodeEnabled?"alphabetic":"top",this._textContext.font=this._lastTextCanvasFont,this._textContext.fillStyle=this._lastTextCanvasFillStyle,this._textContext.strokeStyle=this._lastTextCanvasFillStyle,this._textContext.globalAlpha=this._lastTextCanvasOpacity,this._textContext.lineWidth=this._lastTextCanvasLineWidth):this._textContext.clearRect(0,0,a,b)}_MaybeCreateMeasureContext(){this._measureContext||(this._measureContext=C3.CreateCanvas(16,16).getContext("2d"))}_SetMeasureFontString(a){this._lastMeasureCanvasFont===a||(this._lastMeasureCanvasFont=a,this._measureContext.font=a)}_MaybeWrapText(){this._textChanged&&(this._MaybeCreateMeasureContext(),this._isBBcodeEnabled&&(!this._bbString||this._bbString.toString()!==this._text)&&(this._bbString=new C3.BBString(this._text,{noEscape:!0})),this._wrappedText.WordWrap(this._isBBcodeEnabled?this._bbString.toFragmentList():this._text,this._measureTextCallback,this._cssWidth,this._wrapMode,0),this._textChanged=!1)}_MeasureText(a,b){this._SetMeasureFontString(this._GetFontString(!0,b));const d=this._GetStyleTag(b,"size"),e=d?parseFloat(d.param):this._fontSize;return{width:this._measureContext.measureText(a).width,height:c(e)}}_SetDrawFontString(a){this._lastTextCanvasFont===a||(this._lastTextCanvasFont=a,this._textContext.font=a)}_SetDrawCanvasColor(a){this._lastTextCanvasFillStyle===a||(this._lastTextCanvasFillStyle=a,this._textContext.fillStyle=a,this._textContext.strokeStyle=a)}_SetDrawCanvasOpacity(a){this._lastTextCanvasOpacity===a||(this._lastTextCanvasOpacity=a,this._textContext.globalAlpha=a)}_SetDrawCanvasLineWith(a){this._lastTextCanvasLineWidth===a||(this._lastTextCanvasLineWidth=a,this._textContext.lineWidth=a)}_DrawTextToCanvas(){this._drawCharCount=0;const b=this._scaleFactor*this._zoom*self.devicePixelRatio,c=(4+this._lineHeight)*b;let a=0;const d=this._wrappedText.GetLines(),e=d.reduce((d,a)=>d+a.height*b+c,0)-this._lineHeight*b;"center"===this._verticalAlign?a=Math.max(this._height/2-e/2,0):"bottom"===this._verticalAlign&&(a=this._height-e-2);for(let e=0,f=d.length;ethis._height-4*b)break;}else if(0=this._height-g)break;0<=h&&this._DrawTextLine(f,a,b),this._isBBcodeEnabled||(a+=g),a+=c}}_DrawTextLine(a,b,c){let d=0;"center"===this._horizontalAlign?d=(this._width-a.width*c)/2:"right"===this._horizontalAlign&&(d=this._width-a.width*c);for(const e of a.fragments)this._DrawTextFragment(e,d,b,c,a.height),d+=e.width*c}_DrawTextFragment(c,d,e,f,g){const h=this._textContext,i=g/16;let j=c.width*f;const k=c.height*f,l=c.height/16,m=(4+this._lineHeight)*f,n=c.styles;let o=c.text;if(-1!==this._drawMaxCharCount){if(this._drawCharCount>=this._drawMaxCharCount)return;this._drawCharCount+o.length>this._drawMaxCharCount&&(o=o.substr(0,this._drawMaxCharCount-this._drawCharCount),j=this._MeasureText(o,n).width*f),this._drawCharCount+=o.length}const p=this._GetStyleTag(n,"background"),q=this._HasStyleTag(n,"u"),r=this._HasStyleTag(n,"s");if((!C3.IsStringAllWhitespace(o)||p||q||r)&&!this._HasStyleTag(n,"hide")){const c=this._GetStyleTag(n,"offsetx");d+=c?parseFloat(c.param)*f:0;const g=this._GetStyleTag(n,"offsety");e+=g?parseFloat(g.param)*f:0,p&&(this._SetDrawCanvasColor(p.param),h.fillRect(d,e-k,j,k+m));const s=this._GetStyleTag(n,"color");this._SetDrawCanvasColor(s?s.param:this._colorStr);const t=this._GetStyleTag(n,"opacity");this._SetDrawCanvasOpacity(t?parseFloat(t.param)/100:1);const u=this._HasStyleTag(n,"stroke");if(u&&this._SetDrawCanvasLineWith(l*this._scaleFactor*this._zoom),q&&b(h,u,d,e+f*i,j,f*i),r&&b(h,u,d,e-k/4,j,f*l),this._SetDrawFontString(this._GetFontString(!1,n)),a(h,u,o,d,e,j),!u){this._SetDrawCanvasLineWith(l*this._scaleFactor*this._zoom);const b=this._GetStyleTag(n,"outline");b&&(this._SetDrawCanvasColor(b.param),a(h,!0,o,d,e,j))}}}_UpdateTexture(){var a=Math.ceil;this._renderer.IsContextLost()||(this._textureWidth=a(this._width),this._textureHeight=a(this._height),this._rcTex.set(0,0,this._width/this._textureWidth,this._height/this._textureHeight),this._needToRecreateTexture&&(this.ReleaseTexture(),this._needToRecreateTexture=!1),!this._texture&&(this._texture=this._renderer.CreateDynamicTexture(this._textureWidth,this._textureHeight,{mipMap:1===this._zoom,mipMapQuality:"high"})),this._renderer.UpdateTexture(this._textCanvas,this._texture),this.ontextureupdate&&this.ontextureupdate())}GetTexRect(){return this._rcTex}ReleaseTexture(){this._texture&&(!this._renderer.IsContextLost()&&this._renderer.DeleteTexture(this._texture),this._texture=null)}static OnContextLost(){for(const a of i)a.ReleaseTexture()}static GetAll(){return i.values()}}} // ../lib/gfx/query.js "use strict";{class a{constructor(a){this._gl=a.GetContext(),this._version=a.GetWebGLVersionNumber(),this._timerExt=a._GetDisjointTimerQueryExtension(),this._query=null,this._isActive=!1,this._hasResult=!1,this._result=0,this._query=1===this._version?this._timerExt["createQueryEXT"]():this._gl["createQuery"]()}Release(){this._DeleteQueryObject(),this._gl=null,this._timerExt=null,this._hasResult=!1}_DeleteQueryObject(){this._query&&(1===this._version?this._timerExt["deleteQueryEXT"](this._query):this._gl["deleteQuery"](this._query),this._query=null)}BeginTimeElapsed(){if(this._isActive)throw new Error("query already active");1===this._version?this._timerExt["beginQueryEXT"](this._timerExt["TIME_ELAPSED_EXT"],this._query):this._gl["beginQuery"](this._timerExt["TIME_ELAPSED_EXT"],this._query),this._isActive=!0}EndTimeElapsed(){if(!this._isActive)throw new Error("query not active");1===this._version?this._timerExt["endQueryEXT"](this._timerExt["TIME_ELAPSED_EXT"]):this._gl["endQuery"](this._timerExt["TIME_ELAPSED_EXT"]),this._isActive=!1}CheckForResult(){if(!this._query||this._hasResult||this._isActive)return;let a=!1;a=1===this._version?this._timerExt["getQueryObjectEXT"](this._query,this._timerExt["QUERY_RESULT_AVAILABLE_EXT"]):this._gl["getQueryParameter"](this._query,this._gl["QUERY_RESULT_AVAILABLE"]);const b=this._gl.getParameter(this._timerExt["GPU_DISJOINT_EXT"]);a&&!b&&(this._result=1===this._version?this._timerExt["getQueryObjectEXT"](this._query,this._timerExt["QUERY_RESULT_EXT"]):this._gl["getQueryParameter"](this._query,this._gl["QUERY_RESULT"]),this._result/=1e9,this._hasResult=!0),(a||b)&&this._DeleteQueryObject()}HasResult(){return this._hasResult}GetResult(){if(!this._hasResult)throw new Error("no result available");return this._result}}C3.Gfx.WebGLTimeElapsedQuery=class{constructor(a){this._renderer=a,this._frameNumber=a.GetFrameNumber(),this._isActive=!1,this._parentQuery=null,this._isNested=!1,this._realQuery=null,this._queries=[]}Release(){for(const b of this._queries)b instanceof a&&b.Release();C3.clearArray(this._queries),this._parentQuery=null,this._realQuery=null,this._renderer=null}BeginTimeElapsed(){if(this._isActive)throw new Error("query already active");const a=this._renderer._GetTimeQueryStack();0a.HasResult())}GetResult(){return this._queries.reduce((b,a)=>b+a.GetResult(),0)}GetFrameNumber(){return this._frameNumber}}} @@ -139,7 +142,7 @@ "use strict";C3.Gfx.StateGroup=class{constructor(a,b,c,d,e,f){this._renderer=a,this._refCount=0,this._shaderProgram=null,this._shaderProgramName="",this._srcBlend=c,this._destBlend=d,this._color=C3.New(C3.Color),this._color.set(e),this._zElevation=f,"string"==typeof b?this._shaderProgramName=b:(this._shaderProgram=b,this._shaderProgramName=this._shaderProgram.GetName())}Release(){if(0"],[l.GetTextureFillFragmentShaderSource(),o,""],[l.GetPointFragmentShaderSource(),l.GetPointVertexShaderSource(),""],[l.GetColorFillFragmentShaderSource(),o,""],[l.GetLinearGradientFillFragmentShaderSource(),o,""],[l.GetHardEllipseFillFragmentShaderSource(),o,""],[l.GetHardEllipseOutlineFragmentShaderSource(),o,""],[l.GetSmoothEllipseFillFragmentShaderSource(),o,""],[l.GetSmoothEllipseOutlineFragmentShaderSource(),o,""],[l.GetSmoothLineFillFragmentShaderSource(),o,""],[l.GetTilemapFragmentShaderSource(),l.GetDefaultVertexShaderSource(this._is3d,!0),""]],d=await Promise.all(s.map((e)=>this.CreateShaderProgram({src:e[0]},e[1],e[2])));this._spTextureFill=d[0],this._spDeviceTransformTextureFill=d[1],this._spPoints=d[2],this._spColorFill=d[3],this._spLinearGradientFill=d[4],this._spHardEllipseFill=d[5],this._spHardEllipseOutline=d[6],this._spSmoothEllipseFill=d[7],this._spSmoothEllipseOutline=d[8],this._spSmoothLineFill=d[9],this._spTilemapFill=d[10],this._currentStateGroup=null,this.SetTextureFillMode()}FillIndexBufferData(){const e=this._indexData;for(let t=0,r=0;t<12000;)e[t++]=r,e[t++]=r+1,e[t++]=r+2,e[t++]=r,e[t++]=r+2,e[t++]=r+3,r+=4}Is3D(){return this._is3d}GetNumVertexComponents(){return this._is3d?3:2}SetBaseZ(e){this._baseZ=e}GetBaseZ(){return this._baseZ}SetCurrentZ(e){this._currentZ=e,this._currentStateGroup=null}GetCurrentZ(){return this._currentZ}async CreateShaderProgram(e,t,r){const a=await C3.Gfx.WebGLShaderProgram.Create(this,e,t,r);return this._shaderPrograms.push(a),this._shaderProgramsByName.set(a.GetName(),a),a}GetShaderProgramByName(e){return this._shaderProgramsByName.get(e)||null}GetTextureFillShaderProgram(){return this._spTextureFill}ResetLastProgram(){this._lastProgram=null}_RemoveShaderProgram(e){const t=this._shaderPrograms.indexOf(e);-1!==t&&this._shaderPrograms.splice(t,1),this._shaderProgramsByName.delete(e.GetName())}Project(e,t,r,a,i){const n=this._matMV,l=this._matP;for(let n=0,l=_.length;n=this._lastVertexPtr&&(this.EndBatch(),e=0),1===this._topOfBatch)this._batch[this._batchPtr-1]._indexCount+=6;else{const t=this.PushBatch();t.InitQuad(this._is3d?e:3*(e/2),6),this._topOfBatch=1}}_WriteQuadToVertexBuffer(e){e.writeToTypedArray3D(this._vertexData,this._vertexPtr,this._baseZ+this._currentZ),this._vertexPtr+=12}Quad(e){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),n.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad2(e,t,r,a,i,_,l,o){this._ExtendQuadBatch();const s=this._vertexData;let d=this._vertexPtr;const u=this._baseZ+this._currentZ;this._is3d?(s[d++]=e,s[d++]=t,s[d++]=u,s[d++]=r,s[d++]=a,s[d++]=u,s[d++]=i,s[d++]=_,s[d++]=u,s[d++]=l,s[d++]=o,s[d++]=u):(s[d++]=e,s[d++]=t,s[d++]=r,s[d++]=a,s[d++]=i,s[d++]=_,s[d++]=l,s[d++]=o),this._vertexPtr=d,n.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad3(e,t){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),t.writeAsQuadToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad4(e,t){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),t.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}FullscreenQuad(e,t){var r=Math.max,a=Math.min;if(mat4.copy(s,this._lastMV),vec3.copy(l,this._cam),vec3.copy(o,this._look),this._cam[0]=0,this._cam[1]=0,this._cam[2]=100*self.devicePixelRatio,this._look[0]=0,this._look[1]=0,this._look[2]=0,this.ResetModelView(),this.UpdateModelView(),this._isScissorViewport){const e=this._viewportScissorWidth/2,t=this._viewportScissorHeight/2;c.set(-e,t,-e+this._viewportScissorWidth,t-this._viewportScissorHeight),d.setFromRect(c),c.set(0,0,this._viewportScissorWidth/this._width,this._viewportScissorHeight/this._height),this.Quad3(d,c)}else if("crop"===e&&this._currentRenderTarget&&t){const e=this._width/2,i=this._height/2,n=t.GetWidth(),_=t.GetHeight(),l=this._currentRenderTarget.GetWidth(),o=this._currentRenderTarget.GetHeight(),s=a(l,n),u=a(o,_),p=r(_-o,0),f=r(o-_,0);c.set(-e,i-f,-e+s,i-u-f),d.setFromRect(c),c.set(0,p,s,u+p),c.divide(n,_),this.Quad3(d,c)}else{let[e,t]=this.GetRenderTargetSize(this._currentRenderTarget);const r=e/2,a=t/2;this.Rect2(-r,a,r,-a)}mat4.copy(this._matMV,s),vec3.copy(this._cam,l),vec3.copy(this._look,o),this.UpdateModelView()}ConvexPoly(e){const t=e.length/2;if(3>t)throw new Error("need at least 3 points");const r=t-2,a=e[0],n=e[1];for(let t=0;t=this._lineWidthStack.length)throw new Error("cannot pop last line width - check push/pop pairs");this._lineWidthStack.pop(),this._lineWidth=this._lineWidthStack[this._lineWidthStack.length-1]}SetLineCapButt(){this._lineCap=0,this._lineCapStack[this._lineCapStack.length-1]=0}SetLineCapSquare(){this._lineCap=1,this._lineCapStack[this._lineCapStack.length-1]=0}SetLineCapZag(){this._lineCap=2,this._lineCapStack[this._lineCapStack.length-1]=0}PushLineCap(e){if("butt"===e)this.PushLineCapButt();else if("square"===e)this.PushLineCapSquare();else if("zag"===e)this.PushLineCapZag();else throw new Error("invalid line cap")}PushLineCapButt(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(0),this._lineCap=0}PushLineCapSquare(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(1),this._lineCap=1}PushLineCapZag(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(2),this._lineCap=2}PopLineCap(){if(1>=this._lineCapStack.length)throw new Error("cannot pop last line cap - check push/pop pairs");this._lineCapStack.pop(),this._lineCap=this._lineCapStack[this._lineCapStack.length-1]}SetLineOffset(e){this._lineOffset=e,this._lineOffsetStack[this._lineOffsetStack.length-1]=e}GetLineOffset(){return this._lineOffset}PushLineOffset(e){if(100<=this._lineOffsetStack.length)throw new Error("pushed too many line offsets - check push/pop pairs");this._lineOffsetStack.push(e),this._lineOffset=e}PopLineOffset(){if(1>=this._lineOffsetStack.length)throw new Error("cannot pop last line offset - check push/pop pairs");this._lineOffsetStack.pop(),this._lineOffset=this._lineOffsetStack[this._lineOffsetStack.length-1]}SetPointTextureCoords(e){if(!this._lastPointTexCoords.equals(e)){this._lastPointTexCoords.copy(e);const t=this.PushBatch();t.InitSetPointTexCoords(e),this._topOfBatch=0}}Point(e,t,r,a){this._pointPtr>=7996&&this.EndBatch();let i=this._pointPtr;const n=this._baseZ+this._currentZ;if(2===this._topOfBatch&&this._lastPointZ===n)this._batch[this._batchPtr-1]._indexCount++;else{const e=this.PushBatch();e.InitPoints(i,n),this._topOfBatch=2,this._lastPointZ=n}const _=this._pointData;_[i++]=e,_[i++]=t,_[i++]=r,_[i++]=a,this._pointPtr=i}SetProgram(e){if(this._lastProgram!==e){const t=this.PushBatch();t.InitSetProgram(e),this._lastProgram=e,this._topOfBatch=0,this._currentStateGroup=null}}SetTextureFillMode(){this.SetProgram(this._spTextureFill)}SetDeviceTransformTextureFillMode(){this.SetProgram(this._spDeviceTransformTextureFill)}SetColorFillMode(){this.SetProgram(this._spColorFill)}SetLinearGradientFillMode(){this.SetProgram(this._spLinearGradientFill)}SetGradientColor(e){const t=this.PushBatch();t.InitSetGradientColor(e),this._topOfBatch=0}SetHardEllipseFillMode(){this.SetProgram(this._spHardEllipseFill)}SetHardEllipseOutlineMode(){this.SetProgram(this._spHardEllipseOutline)}SetSmoothEllipseFillMode(){this.SetProgram(this._spSmoothEllipseFill)}SetSmoothEllipseOutlineMode(){this.SetProgram(this._spSmoothEllipseOutline)}SetEllipseParams(e,t,r=1){const a=this.PushBatch();a.InitSetEllipseParams(e,t,r),this._topOfBatch=0}SetSmoothLineFillMode(){this.SetProgram(this._spSmoothLineFill)}SetTilemapFillMode(){this.SetProgram(this._spTilemapFill)}SetTilemapInfo(e,t,r,a,i,n,_){if(this._lastProgram!==this._spTilemapFill)throw new Error("must set tilemap fill mode first");const l=this.PushBatch();l.InitSetTilemapInfo(e,t,r,a,i,n,_),this._topOfBatch=0}SetProgramParameters(e,t,r,a,i,n,_,l,o,d,u){const c=this._lastProgram,s=c._hasAnyOptionalUniforms,p=!!u.length;if(s&&!c.AreOptionalUniformsAlreadySetInBatch(t,r,a,i,n,_,l,o,d)||p&&!c.AreCustomParametersAlreadySetInBatch(u)){const f=this.PushBatch();if(f.InitSetProgramParameters(),s){c.SetOptionalUniformsInBatch(t,r,a,i,n,_,l,o,d);const s=f._mat4param;s[0]=n,s[1]=_,t.writeToTypedArray(s,2),s[6]=l,s[7]=o,r.writeToTypedArray(s,12);const u=f._colorParam;i.writeToTypedArray(u,0);const p=u[1];u[1]=u[3],u[3]=p,a.writeToTypedArray(f._srcOriginRect,0),f._startIndex=d,f._texParam=c._uSamplerBack.IsUsed()?e?e.GetTexture():null:null}p&&(c.SetCustomParametersInBatch(u),C3.shallowAssignArray(f._shaderParams,u)),this._topOfBatch=0}}ClearRgba(e,t,r,i){const a=this.PushBatch();a.InitClearSurface2(e,t,r,i),this._topOfBatch=0}Clear(e){const t=this.PushBatch();t.InitClearSurface(e),this._topOfBatch=0}ClearRect(e,t,r,a){this.ClearRect4(e,t,r,a,0,0,0,0)}ClearRect2(e){this.ClearRect4(e.getLeft(),e.getTop(),e.width(),e.height(),0,0,0,0)}ClearRect3(e,t){this.ClearRect4(e.getLeft(),e.getTop(),e.width(),e.height(),t.getR(),t.getG(),t.getB(),t.getA())}ClearRect4(e,t,i,n,_,r,l,o){if(!(0>i||0>n)){const a=this.PushBatch();a.InitClearRect(e,t,i,n,_,r,l,o),this._topOfBatch=0}}Start(){}Finish(){this.EndBatch(),this._gl.flush(),this._frameNumber++}CheckForQueryResults(){for(const e of this._allQueryResultBuffers)e.CheckForResults(this._frameNumber)}IsContextLost(){return!this._gl||this._gl.isContextLost()||this._isInitialisingAfterContextRestored}OnContextLost(){C3.Gfx.WebGLRendererTexture.OnContextLost(),C3.Gfx.WebGLRenderTarget.OnContextLost(),C3.Gfx.WebGLText.OnContextLost();for(const e of this._allQueryResultBuffers)e.Clear();this._extensions=[],this._timerExt=null,this._parallelShaderCompileExt=null,this._unmaskedVendor="(unavailable)",this._unmaskedRenderer="(unavailable)",this._lastProgram=null,this._spTextureFill=null,this._spDeviceTransformTextureFill=null,this._spColorFill=null,this._spLinearGradientFill=null,this._spHardEllipseFill=null,this._spHardEllipseOutline=null,this._spSmoothEllipseFill=null,this._spSmoothEllipseOutline=null,this._spSmoothLineFill=null,this._spPoints=null,this._spTilemapFill=null;for(const e of this._stateGroups.values())e.OnContextLost();for(const e of this._shaderPrograms)e.Release();C3.clearArray(this._shaderPrograms),this._shaderProgramsByName.clear()}async OnContextRestored(){this._isInitialisingAfterContextRestored=!0,await this.InitState(),this._isInitialisingAfterContextRestored=!1;for(const e of this._stateGroups.values())e.OnContextRestored(this);this.SetSize(this._width,this._height,!0)}CreateStaticTexture(e,t){if(this.IsContextLost())throw new Error("context lost");this.EndBatch();const r=C3.New(C3.Gfx.WebGLRendererTexture,this);return r._CreateStatic(e,t),r}CreateStaticTextureAsync(e,t){return this.IsContextLost()?Promise.reject("context lost"):(t=Object.assign({},t),C3.Supports.ImageBitmapOptions&&(this.SupportsNPOTTextures()||!t.isTiled)?(t.premultiplyAlpha=!1,createImageBitmap(e,{"premultiplyAlpha":"premultiply"}).then((e)=>C3.Asyncify(()=>this.CreateStaticTexture(e,t)))):C3.Supports.ImageBitmap?createImageBitmap(e).then((e)=>C3.Asyncify(()=>this.CreateStaticTexture(e,t))):e instanceof Blob?C3.BlobToImage(e,!0).then((e)=>this.CreateStaticTextureAsync(e,t)):"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement&&"function"==typeof e["decode"]?e["decode"]().then(()=>C3.Asyncify(()=>this.CreateStaticTexture(e,t))):C3.Asyncify(()=>this.CreateStaticTexture(e,t)))}CreateDynamicTexture(e,t,r){this.EndBatch();const a=C3.New(C3.Gfx.WebGLRendererTexture,this);return a._CreateDynamic(e,t,r),a}UpdateTexture(e,t,r){this.EndBatch(),t._Update(e,r)}DeleteTexture(e){e&&(e.SubtractReference(),0=t||0>=r)throw new Error("invalid size");this.EndBatch();const i=C3.New(C3.Gfx.WebGLRenderTarget,this);return i._Create(t,r,Object.assign({isDefaultSize:a},e)),this._currentRenderTarget=null,this._batchState.currentFramebuffer=null,i}SetRenderTarget(e){if(e===this._currentRenderTarget)return;let t,r,a,i;e?(e.IsDefaultSize()&&e._Resize(this._width,this._height),a=e.GetWidth(),i=e.GetHeight(),t=a,r=i):(a=this._width,i=this._height,t=this.GetScissoredViewportWidth(),r=this.GetScissoredViewportHeight());const n=this._lastBackbufferWidth!==a||this._lastBackbufferHeight!==i;n&&this._UpdateViewportRenderer(t,r,a,i);const _=this.PushBatch();_.InitSetRenderTarget(e,n,this._matP),this._currentRenderTarget=e,this._topOfBatch=0}GetRenderTarget(){return this._currentRenderTarget}GetRenderTargetSize(e){return e?[e.GetWidth(),e.GetHeight()]:[this._width,this._height]}CopyRenderTarget(e,t="stretch"){if(2>this._version||this._currentRenderTarget&&0this._version)){const t=this.PushBatch();t.InitInvalidateFramebuffer(e._GetFramebuffer()),this._topOfBatch=0}}DeleteRenderTarget(e){this.SetRenderTarget(null),this.EndBatch();const t=e.GetTexture();t===this._lastTexture0&&(this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._lastTexture0=null),t===this._lastTexture1&&(this._gl.activeTexture(this._gl.TEXTURE1),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.activeTexture(this._gl.TEXTURE0),this._lastTexture1=null),e._Delete()}async ReadBackRenderTargetToImageData(e,t){this.EndBatch();const r=this._currentRenderTarget;let a,i,n;e?(a=e.GetWidth(),i=e.GetHeight(),n=e._GetFramebuffer()):(a=this.GetWidth(),i=this.GetHeight(),n=null);const _=this._gl;_.bindFramebuffer(_.FRAMEBUFFER,n);const l=()=>{_.bindFramebuffer(_.FRAMEBUFFER,null),this._currentRenderTarget=null,this._batchState.currentFramebuffer=null,this.SetRenderTarget(r)};let o;if(!t&&2<=this.GetWebGLVersionNumber()){_.bindFramebuffer(_.READ_FRAMEBUFFER,n);const e=_.createBuffer(),t=4*(a*i),r=_["PIXEL_PACK_BUFFER"];_.bindBuffer(r,e),_.bufferData(r,t,_["STREAM_READ"]),_.readPixels(0,0,a,i,_.RGBA,_.UNSIGNED_BYTE,0),_.bindFramebuffer(_.READ_FRAMEBUFFER,null),_.bindBuffer(r,null),l();const s=_["fenceSync"](_["SYNC_GPU_COMMANDS_COMPLETE"],0);await this._WaitForObjectReady(()=>_["getSyncParameter"](s,_["SYNC_STATUS"])===_["SIGNALED"]),_["deleteSync"](s),o=new ImageData(a,i),_.bindBuffer(r,e),_["getBufferSubData"](r,0,new Uint8Array(o.data.buffer),0,t),_.bindBuffer(r,null),_.deleteBuffer(e)}else o=new ImageData(a,i),_.readPixels(0,0,a,i,_.RGBA,_.UNSIGNED_BYTE,new Uint8Array(o.data.buffer)),l();return o}StartQuery(e){if(this.SupportsGPUProfiling()){const t=this.PushBatch();t.InitStartQuery(e),this._topOfBatch=0}}EndQuery(e){if(this.SupportsGPUProfiling()){const t=this.PushBatch();t.InitEndQuery(e),this._topOfBatch=0}}_WaitForObjectReady(e){const r=new Promise((t)=>p.add({resolve:t,checkFunc:e}));return-1===f&&(f=self.requestAnimationFrame(t)),r}IsDesynchronized(){return!!this._attribs["desynchronized"]}GetEstimatedBackBufferMemoryUsage(){return this._width*this._height*(this._attribs["alpha"]?4:3)}GetEstimatedRenderBufferMemoryUsage(){let e=0;for(const r of C3.Gfx.WebGLRenderTarget.allRenderTargets())r.GetTexture()||(e+=r.GetEstimatedMemoryUsage());return e}GetEstimatedTextureMemoryUsage(){let e=0;for(const r of C3.Gfx.WebGLRendererTexture.allTextures())e+=r.GetEstimatedMemoryUsage();return e}GetEstimatedTotalMemoryUsage(){return this.GetEstimatedBackBufferMemoryUsage()+this.GetEstimatedRenderBufferMemoryUsage()+this.GetEstimatedTextureMemoryUsage()}GetWebGLVersionString(){return this._versionString}GetWebGLVersionNumber(){return this._version}SupportsNPOTTextures(){return 2<=this.GetWebGLVersionNumber()}GetMaxTextureSize(){return this._maxTextureSize}GetMinPointSize(){return this._minPointSize}GetMaxPointSize(){return this._maxPointSize}SupportsHighP(){return 0!==this._highpPrecision}GetHighPPrecision(){return this._highpPrecision}GetUnmaskedVendor(){return this._unmaskedVendor}GetUnmaskedRenderer(){return this._unmaskedRenderer}GetExtensions(){return this._extensions}HasMajorPerformanceCaveat(){return this._hasMajorPerformanceCaveat}SupportsGPUProfiling(){return!!this._timerExt}_GetDisjointTimerQueryExtension(){return this._timerExt}_GetParallelShaderCompileExtension(){return this._parallelShaderCompileExt}_AddQueryResultBuffer(e){this._allQueryResultBuffers.add(e)}_RemoveQueryResultBuffer(e){this._allQueryResultBuffers.delete(e)}_GetTimeQueryStack(){return this._timeQueryStack}GetFrameNumber(){return this._frameNumber}IncrementFrameNumber(){this._frameNumber++}GetContext(){return this._gl}GetNamedBlend(e){const t=this._gl;let r=t.ONE,a=t.ONE_MINUS_SRC_ALPHA;switch(e){case"normal":r=t.ONE,a=t.ONE_MINUS_SRC_ALPHA;break;case"additive":r=t.ONE,a=t.ONE;break;case"copy":r=t.ONE,a=t.ZERO;break;case"destination-over":r=t.ONE_MINUS_DST_ALPHA,a=t.ONE;break;case"source-in":r=t.DST_ALPHA,a=t.ZERO;break;case"destination-in":r=t.ZERO,a=t.SRC_ALPHA;break;case"source-out":r=t.ONE_MINUS_DST_ALPHA,a=t.ZERO;break;case"destination-out":r=t.ZERO,a=t.ONE_MINUS_SRC_ALPHA;break;case"source-atop":r=t.DST_ALPHA,a=t.ONE_MINUS_SRC_ALPHA;break;case"destination-atop":r=t.ONE_MINUS_DST_ALPHA,a=t.SRC_ALPHA;break;default:throw new Error("invalid blend name");}return{srcBlend:r,destBlend:a}}_InitBlendModeTable(e){this._blendModeTable=[[e.ONE,e.ONE_MINUS_SRC_ALPHA],[e.ONE,e.ONE],[e.ONE,e.ONE_MINUS_SRC_ALPHA],[e.ONE,e.ZERO],[e.ONE_MINUS_DST_ALPHA,e.ONE],[e.DST_ALPHA,e.ZERO],[e.ZERO,e.SRC_ALPHA],[e.ONE_MINUS_DST_ALPHA,e.ZERO],[e.ZERO,e.ONE_MINUS_SRC_ALPHA],[e.DST_ALPHA,e.ONE_MINUS_SRC_ALPHA],[e.ONE_MINUS_DST_ALPHA,e.SRC_ALPHA]]}_GetBlendByIndex(e){const t=this._blendModeTable;if(0>e||e>=t.length)throw new RangeError("invalid blend index");return t[e]}GetSrcBlendByIndex(e){return this._GetBlendByIndex(e)[0]}GetDestBlendByIndex(e){return this._GetBlendByIndex(e)[1]}CreateWebGLText(){return C3.New(C3.Gfx.WebGLText,this)}}} +"use strict";{function e(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function t(){f=-1;for(const e of p)e.checkFunc()&&(e.resolve(),p.delete(e));0"],[l.GetTextureFillFragmentShaderSource(),o,""],[l.GetPointFragmentShaderSource(),l.GetPointVertexShaderSource(),""],[l.GetColorFillFragmentShaderSource(),o,""],[l.GetLinearGradientFillFragmentShaderSource(),o,""],[l.GetHardEllipseFillFragmentShaderSource(),o,""],[l.GetHardEllipseOutlineFragmentShaderSource(),o,""],[l.GetSmoothEllipseFillFragmentShaderSource(),o,""],[l.GetSmoothEllipseOutlineFragmentShaderSource(),o,""],[l.GetSmoothLineFillFragmentShaderSource(),o,""],[l.GetTilemapFragmentShaderSource(),l.GetDefaultVertexShaderSource(this._is3d,!0),""]],d=await Promise.all(s.map((e)=>this.CreateShaderProgram({src:e[0]},e[1],e[2])));this._spTextureFill=d[0],this._spDeviceTransformTextureFill=d[1],this._spPoints=d[2],this._spColorFill=d[3],this._spLinearGradientFill=d[4],this._spHardEllipseFill=d[5],this._spHardEllipseOutline=d[6],this._spSmoothEllipseFill=d[7],this._spSmoothEllipseOutline=d[8],this._spSmoothLineFill=d[9],this._spTilemapFill=d[10],this._currentStateGroup=null,this.SetTextureFillMode()}FillIndexBufferData(){const e=this._indexData;for(let t=0,r=0;t<12000;)e[t++]=r,e[t++]=r+1,e[t++]=r+2,e[t++]=r,e[t++]=r+2,e[t++]=r+3,r+=4}Is3D(){return this._is3d}GetNumVertexComponents(){return this._is3d?3:2}SetBaseZ(e){this._baseZ=e}GetBaseZ(){return this._baseZ}SetCurrentZ(e){this._currentZ=e,this._currentStateGroup=null}GetCurrentZ(){return this._currentZ}async CreateShaderProgram(e,t,r){const a=await C3.Gfx.WebGLShaderProgram.Create(this,e,t,r);return this._shaderPrograms.push(a),this._shaderProgramsByName.set(a.GetName(),a),a}GetShaderProgramByName(e){return this._shaderProgramsByName.get(e)||null}GetTextureFillShaderProgram(){return this._spTextureFill}ResetLastProgram(){this._lastProgram=null}_RemoveShaderProgram(e){const t=this._shaderPrograms.indexOf(e);-1!==t&&this._shaderPrograms.splice(t,1),this._shaderProgramsByName.delete(e.GetName())}Project(e,t,r,a,i){const n=this._matMV,l=this._matP;for(let n=0,l=_.length;n=this._lastVertexPtr&&(this.EndBatch(),e=0),1===this._topOfBatch)this._batch[this._batchPtr-1]._indexCount+=6;else{const t=this.PushBatch();t.InitQuad(this._is3d?e:3*(e/2),6),this._topOfBatch=1}}_WriteQuadToVertexBuffer(e){e.writeToTypedArray3D(this._vertexData,this._vertexPtr,this._baseZ+this._currentZ),this._vertexPtr+=12}Quad(e){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),n.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad2(e,t,r,a,i,_,l,o){this._ExtendQuadBatch();const s=this._vertexData;let d=this._vertexPtr;const u=this._baseZ+this._currentZ;this._is3d?(s[d++]=e,s[d++]=t,s[d++]=u,s[d++]=r,s[d++]=a,s[d++]=u,s[d++]=i,s[d++]=_,s[d++]=u,s[d++]=l,s[d++]=o,s[d++]=u):(s[d++]=e,s[d++]=t,s[d++]=r,s[d++]=a,s[d++]=i,s[d++]=_,s[d++]=l,s[d++]=o),this._vertexPtr=d,n.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad3(e,t){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),t.writeAsQuadToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}Quad4(e,t){this._ExtendQuadBatch(),this._WriteQuadToVertexBuffer(e),t.writeToTypedArray(this._texcoordData,this._texPtr),this._texPtr+=8}FullscreenQuad(e,t){var r=Math.max,a=Math.min;if(mat4.copy(s,this._lastMV),vec3.copy(l,this._cam),vec3.copy(o,this._look),this._cam[0]=0,this._cam[1]=0,this._cam[2]=100*self.devicePixelRatio,this._look[0]=0,this._look[1]=0,this._look[2]=0,this.ResetModelView(),this.UpdateModelView(),this._isScissorViewport){const e=this._viewportScissorWidth/2,t=this._viewportScissorHeight/2;c.set(-e,t,-e+this._viewportScissorWidth,t-this._viewportScissorHeight),d.setFromRect(c),c.set(0,0,this._viewportScissorWidth/this._width,this._viewportScissorHeight/this._height),this.Quad3(d,c)}else if("crop"===e&&this._currentRenderTarget&&t){const e=this._width/2,i=this._height/2,n=t.GetWidth(),_=t.GetHeight(),l=this._currentRenderTarget.GetWidth(),o=this._currentRenderTarget.GetHeight(),s=a(l,n),u=a(o,_),p=r(_-o,0),f=r(o-_,0);c.set(-e,i-f,-e+s,i-u-f),d.setFromRect(c),c.set(0,p,s,u+p),c.divide(n,_),this.Quad3(d,c)}else{let[e,t]=this.GetRenderTargetSize(this._currentRenderTarget);const r=e/2,a=t/2;this.Rect2(-r,a,r,-a)}mat4.copy(this._matMV,s),vec3.copy(this._cam,l),vec3.copy(this._look,o),this.UpdateModelView()}ConvexPoly(e){const t=e.length/2;if(3>t)throw new Error("need at least 3 points");const r=t-2,a=e[0],n=e[1];for(let t=0;t=this._lineWidthStack.length)throw new Error("cannot pop last line width - check push/pop pairs");this._lineWidthStack.pop(),this._lineWidth=this._lineWidthStack[this._lineWidthStack.length-1]}SetLineCapButt(){this._lineCap=0,this._lineCapStack[this._lineCapStack.length-1]=0}SetLineCapSquare(){this._lineCap=1,this._lineCapStack[this._lineCapStack.length-1]=0}SetLineCapZag(){this._lineCap=2,this._lineCapStack[this._lineCapStack.length-1]=0}PushLineCap(e){if("butt"===e)this.PushLineCapButt();else if("square"===e)this.PushLineCapSquare();else if("zag"===e)this.PushLineCapZag();else throw new Error("invalid line cap")}PushLineCapButt(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(0),this._lineCap=0}PushLineCapSquare(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(1),this._lineCap=1}PushLineCapZag(){if(100<=this._lineCapStack.length)throw new Error("pushed too many line caps - check push/pop pairs");this._lineCapStack.push(2),this._lineCap=2}PopLineCap(){if(1>=this._lineCapStack.length)throw new Error("cannot pop last line cap - check push/pop pairs");this._lineCapStack.pop(),this._lineCap=this._lineCapStack[this._lineCapStack.length-1]}SetLineOffset(e){this._lineOffset=e,this._lineOffsetStack[this._lineOffsetStack.length-1]=e}GetLineOffset(){return this._lineOffset}PushLineOffset(e){if(100<=this._lineOffsetStack.length)throw new Error("pushed too many line offsets - check push/pop pairs");this._lineOffsetStack.push(e),this._lineOffset=e}PopLineOffset(){if(1>=this._lineOffsetStack.length)throw new Error("cannot pop last line offset - check push/pop pairs");this._lineOffsetStack.pop(),this._lineOffset=this._lineOffsetStack[this._lineOffsetStack.length-1]}SetPointTextureCoords(e){if(!this._lastPointTexCoords.equals(e)){this._lastPointTexCoords.copy(e);const t=this.PushBatch();t.InitSetPointTexCoords(e),this._topOfBatch=0}}Point(e,t,r,a){this._pointPtr>=7996&&this.EndBatch();let i=this._pointPtr;const n=this._baseZ+this._currentZ;if(2===this._topOfBatch&&this._lastPointZ===n)this._batch[this._batchPtr-1]._indexCount++;else{const e=this.PushBatch();e.InitPoints(i,n),this._topOfBatch=2,this._lastPointZ=n}const _=this._pointData;_[i++]=e,_[i++]=t,_[i++]=r,_[i++]=a,this._pointPtr=i}SetProgram(e){if(this._lastProgram!==e){const t=this.PushBatch();t.InitSetProgram(e),this._lastProgram=e,this._topOfBatch=0,this._currentStateGroup=null}}SetTextureFillMode(){this.SetProgram(this._spTextureFill)}SetDeviceTransformTextureFillMode(){this.SetProgram(this._spDeviceTransformTextureFill)}SetColorFillMode(){this.SetProgram(this._spColorFill)}SetLinearGradientFillMode(){this.SetProgram(this._spLinearGradientFill)}SetGradientColor(e){const t=this.PushBatch();t.InitSetGradientColor(e),this._topOfBatch=0}SetHardEllipseFillMode(){this.SetProgram(this._spHardEllipseFill)}SetHardEllipseOutlineMode(){this.SetProgram(this._spHardEllipseOutline)}SetSmoothEllipseFillMode(){this.SetProgram(this._spSmoothEllipseFill)}SetSmoothEllipseOutlineMode(){this.SetProgram(this._spSmoothEllipseOutline)}SetEllipseParams(e,t,r=1){const a=this.PushBatch();a.InitSetEllipseParams(e,t,r),this._topOfBatch=0}SetSmoothLineFillMode(){this.SetProgram(this._spSmoothLineFill)}SetTilemapFillMode(){this.SetProgram(this._spTilemapFill)}SetTilemapInfo(e,t,r,a,i,n,_){if(this._lastProgram!==this._spTilemapFill)throw new Error("must set tilemap fill mode first");const l=this.PushBatch();l.InitSetTilemapInfo(e,t,r,a,i,n,_),this._topOfBatch=0}SetProgramParameters(e,t,r,a,i,n,_,l,o,d,u){const c=this._lastProgram,s=c._hasAnyOptionalUniforms,p=!!u.length;if(s&&!c.AreOptionalUniformsAlreadySetInBatch(t,r,a,i,n,_,l,o,d)||p&&!c.AreCustomParametersAlreadySetInBatch(u)){const f=this.PushBatch();if(f.InitSetProgramParameters(),s){c.SetOptionalUniformsInBatch(t,r,a,i,n,_,l,o,d);const s=f._mat4param;s[0]=n,s[1]=_,t.writeToTypedArray(s,2),s[6]=l,s[7]=o,r.writeToTypedArray(s,12);const u=f._colorParam;i.writeToTypedArray(u,0);const p=u[1];u[1]=u[3],u[3]=p,a.writeToTypedArray(f._srcOriginRect,0),f._startIndex=d,f._texParam=c._uSamplerBack.IsUsed()?e?e.GetTexture():null:null}p&&(c.SetCustomParametersInBatch(u),C3.shallowAssignArray(f._shaderParams,u)),this._topOfBatch=0}}ClearRgba(e,t,r,i){const a=this.PushBatch();a.InitClearSurface2(e,t,r,i),this._topOfBatch=0}Clear(e){const t=this.PushBatch();t.InitClearSurface(e),this._topOfBatch=0}ClearRect(e,t,r,a){this.ClearRect4(e,t,r,a,0,0,0,0)}ClearRect2(e){this.ClearRect4(e.getLeft(),e.getTop(),e.width(),e.height(),0,0,0,0)}ClearRect3(e,t){this.ClearRect4(e.getLeft(),e.getTop(),e.width(),e.height(),t.getR(),t.getG(),t.getB(),t.getA())}ClearRect4(e,t,i,n,_,r,l,o){if(!(0>i||0>n)){const a=this.PushBatch();a.InitClearRect(e,t,i,n,_,r,l,o),this._topOfBatch=0}}Start(){}Finish(){this.EndBatch(),this._gl.flush(),this._frameNumber++}CheckForQueryResults(){for(const e of this._allQueryResultBuffers)e.CheckForResults(this._frameNumber)}IsContextLost(){return!this._gl||this._gl.isContextLost()||this._isInitialisingAfterContextRestored}OnContextLost(){C3.Gfx.WebGLRendererTexture.OnContextLost(),C3.Gfx.WebGLRenderTarget.OnContextLost(),C3.Gfx.WebGLText.OnContextLost();for(const e of this._allQueryResultBuffers)e.Clear();this._extensions=[],this._timerExt=null,this._parallelShaderCompileExt=null,this._unmaskedVendor="(unavailable)",this._unmaskedRenderer="(unavailable)",this._lastProgram=null,this._spTextureFill=null,this._spDeviceTransformTextureFill=null,this._spColorFill=null,this._spLinearGradientFill=null,this._spHardEllipseFill=null,this._spHardEllipseOutline=null,this._spSmoothEllipseFill=null,this._spSmoothEllipseOutline=null,this._spSmoothLineFill=null,this._spPoints=null,this._spTilemapFill=null;for(const e of this._stateGroups.values())e.OnContextLost();for(const e of this._shaderPrograms)e.Release();C3.clearArray(this._shaderPrograms),this._shaderProgramsByName.clear()}async OnContextRestored(){this._isInitialisingAfterContextRestored=!0,await this.InitState(),this._isInitialisingAfterContextRestored=!1;for(const e of this._stateGroups.values())e.OnContextRestored(this);this.SetSize(this._width,this._height,!0)}CreateStaticTexture(e,t){if(this.IsContextLost())throw new Error("context lost");this.EndBatch();const r=C3.New(C3.Gfx.WebGLRendererTexture,this);return r._CreateStatic(e,t),r}CreateStaticTextureAsync(e,t){return this.IsContextLost()?Promise.reject("context lost"):(t=Object.assign({},t),C3.Supports.ImageBitmapOptions&&(this.SupportsNPOTTextures()||!t.isTiled)?(t.premultiplyAlpha=!1,createImageBitmap(e,{"premultiplyAlpha":"premultiply"}).then((e)=>C3.Asyncify(()=>this.CreateStaticTexture(e,t)))):C3.Supports.ImageBitmap?createImageBitmap(e).then((e)=>C3.Asyncify(()=>this.CreateStaticTexture(e,t))):e instanceof Blob?C3.BlobToImage(e,!0).then((e)=>this.CreateStaticTextureAsync(e,t)):"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement&&"function"==typeof e["decode"]?e["decode"]().then(()=>C3.Asyncify(()=>this.CreateStaticTexture(e,t))):C3.Asyncify(()=>this.CreateStaticTexture(e,t)))}CreateDynamicTexture(e,t,r){this.EndBatch();const a=C3.New(C3.Gfx.WebGLRendererTexture,this);return a._CreateDynamic(e,t,r),a}UpdateTexture(e,t,r){this.EndBatch(),t._Update(e,r)}DeleteTexture(e){e&&(e.SubtractReference(),0=t||0>=r)throw new Error("invalid size");this.EndBatch();const i=C3.New(C3.Gfx.WebGLRenderTarget,this);return i._Create(t,r,Object.assign({isDefaultSize:a},e)),this._currentRenderTarget=null,this._batchState.currentFramebuffer=null,i}SetRenderTarget(e){if(e===this._currentRenderTarget)return;let t,r,a,i;e?(e.IsDefaultSize()&&e._Resize(this._width,this._height),a=e.GetWidth(),i=e.GetHeight(),t=a,r=i):(a=this._width,i=this._height,t=this.GetScissoredViewportWidth(),r=this.GetScissoredViewportHeight());const n=this._lastBackbufferWidth!==a||this._lastBackbufferHeight!==i;n&&this._UpdateViewportRenderer(t,r,a,i);const _=this.PushBatch();_.InitSetRenderTarget(e,n,this._matP),this._currentRenderTarget=e,this._topOfBatch=0}GetRenderTarget(){return this._currentRenderTarget}GetRenderTargetSize(e){return e?[e.GetWidth(),e.GetHeight()]:[this._width,this._height]}CopyRenderTarget(e,t="stretch"){if(2>this._version||this._currentRenderTarget&&0this._version)){const t=this.PushBatch();t.InitInvalidateFramebuffer(e._GetFramebuffer()),this._topOfBatch=0}}DeleteRenderTarget(e){this.SetRenderTarget(null),this.EndBatch();const t=e.GetTexture();t===this._lastTexture0&&(this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._lastTexture0=null),t===this._lastTexture1&&(this._gl.activeTexture(this._gl.TEXTURE1),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.activeTexture(this._gl.TEXTURE0),this._lastTexture1=null),e._Delete()}async ReadBackRenderTargetToImageData(e,t){this.EndBatch();const r=this._currentRenderTarget;let a,i,n;e?(a=e.GetWidth(),i=e.GetHeight(),n=e._GetFramebuffer()):(a=this.GetWidth(),i=this.GetHeight(),n=null);const _=this._gl;_.bindFramebuffer(_.FRAMEBUFFER,n);const l=()=>{_.bindFramebuffer(_.FRAMEBUFFER,null),this._currentRenderTarget=null,this._batchState.currentFramebuffer=null,this.SetRenderTarget(r)};let o;if(!t&&2<=this.GetWebGLVersionNumber()){_.bindFramebuffer(_.READ_FRAMEBUFFER,n);const e=_.createBuffer(),t=4*(a*i),r=_["PIXEL_PACK_BUFFER"];_.bindBuffer(r,e),_.bufferData(r,t,_["STREAM_READ"]),_.readPixels(0,0,a,i,_.RGBA,_.UNSIGNED_BYTE,0),_.bindFramebuffer(_.READ_FRAMEBUFFER,null),_.bindBuffer(r,null),l();const s=_["fenceSync"](_["SYNC_GPU_COMMANDS_COMPLETE"],0);await this._WaitForObjectReady(()=>_["getSyncParameter"](s,_["SYNC_STATUS"])===_["SIGNALED"]),_["deleteSync"](s),o=new ImageData(a,i),_.bindBuffer(r,e),_["getBufferSubData"](r,0,new Uint8Array(o.data.buffer),0,t),_.bindBuffer(r,null),_.deleteBuffer(e)}else o=new ImageData(a,i),_.readPixels(0,0,a,i,_.RGBA,_.UNSIGNED_BYTE,new Uint8Array(o.data.buffer)),l();return o}StartQuery(e){if(this.SupportsGPUProfiling()){const t=this.PushBatch();t.InitStartQuery(e),this._topOfBatch=0}}EndQuery(e){if(this.SupportsGPUProfiling()){const t=this.PushBatch();t.InitEndQuery(e),this._topOfBatch=0}}_WaitForObjectReady(e){const r=new Promise((t)=>p.add({resolve:t,checkFunc:e}));return-1===f&&(f=self.requestAnimationFrame(t)),r}IsDesynchronized(){return!!this._attribs["desynchronized"]}GetEstimatedBackBufferMemoryUsage(){return this._width*this._height*(this._attribs["alpha"]?4:3)}GetEstimatedRenderBufferMemoryUsage(){let e=0;for(const r of C3.Gfx.WebGLRenderTarget.allRenderTargets())r.GetTexture()||(e+=r.GetEstimatedMemoryUsage());return e}GetEstimatedTextureMemoryUsage(){let e=0;for(const r of C3.Gfx.WebGLRendererTexture.allTextures())e+=r.GetEstimatedMemoryUsage();return e}GetEstimatedTotalMemoryUsage(){return this.GetEstimatedBackBufferMemoryUsage()+this.GetEstimatedRenderBufferMemoryUsage()+this.GetEstimatedTextureMemoryUsage()}GetWebGLVersionString(){return this._versionString}GetWebGLVersionNumber(){return this._version}SupportsNPOTTextures(){return 2<=this.GetWebGLVersionNumber()}GetMaxTextureSize(){return this._maxTextureSize}GetMinPointSize(){return this._minPointSize}GetMaxPointSize(){return this._maxPointSize}SupportsHighP(){return 0!==this._highpPrecision}GetHighPPrecision(){return this._highpPrecision}GetUnmaskedVendor(){return this._unmaskedVendor}GetUnmaskedRenderer(){return this._unmaskedRenderer}GetExtensions(){return this._extensions}HasMajorPerformanceCaveat(){return this._hasMajorPerformanceCaveat}SupportsGPUProfiling(){return!!this._timerExt}_GetDisjointTimerQueryExtension(){return this._timerExt}_GetParallelShaderCompileExtension(){return this._parallelShaderCompileExt}_AddQueryResultBuffer(e){this._allQueryResultBuffers.add(e)}_RemoveQueryResultBuffer(e){this._allQueryResultBuffers.delete(e)}_GetTimeQueryStack(){return this._timeQueryStack}GetFrameNumber(){return this._frameNumber}IncrementFrameNumber(){this._frameNumber++}GetContext(){return this._gl}GetNamedBlend(e){const t=this._gl;let r=t.ONE,a=t.ONE_MINUS_SRC_ALPHA;switch(e){case"normal":r=t.ONE,a=t.ONE_MINUS_SRC_ALPHA;break;case"additive":r=t.ONE,a=t.ONE;break;case"copy":r=t.ONE,a=t.ZERO;break;case"destination-over":r=t.ONE_MINUS_DST_ALPHA,a=t.ONE;break;case"source-in":r=t.DST_ALPHA,a=t.ZERO;break;case"destination-in":r=t.ZERO,a=t.SRC_ALPHA;break;case"source-out":r=t.ONE_MINUS_DST_ALPHA,a=t.ZERO;break;case"destination-out":r=t.ZERO,a=t.ONE_MINUS_SRC_ALPHA;break;case"source-atop":r=t.DST_ALPHA,a=t.ONE_MINUS_SRC_ALPHA;break;case"destination-atop":r=t.ONE_MINUS_DST_ALPHA,a=t.SRC_ALPHA;break;default:throw new Error("invalid blend name");}return{srcBlend:r,destBlend:a}}_InitBlendModeTable(e){this._blendModeTable=[[e.ONE,e.ONE_MINUS_SRC_ALPHA],[e.ONE,e.ONE],[e.ONE,e.ONE_MINUS_SRC_ALPHA],[e.ONE,e.ZERO],[e.ONE_MINUS_DST_ALPHA,e.ONE],[e.DST_ALPHA,e.ZERO],[e.ZERO,e.SRC_ALPHA],[e.ONE_MINUS_DST_ALPHA,e.ZERO],[e.ZERO,e.ONE_MINUS_SRC_ALPHA],[e.DST_ALPHA,e.ONE_MINUS_SRC_ALPHA],[e.ONE_MINUS_DST_ALPHA,e.SRC_ALPHA]]}_GetBlendByIndex(e){const t=this._blendModeTable;if(0>e||e>=t.length)throw new RangeError("invalid blend index");return t[e]}GetSrcBlendByIndex(e){return this._GetBlendByIndex(e)[0]}GetDestBlendByIndex(e){return this._GetBlendByIndex(e)[1]}CreateWebGLText(){return C3.New(C3.Gfx.WebGLText,this)}}} // c3/assets/assetManager.js "use strict";{function a(a){if(!a)return"";const b=a.split(".");if(2>b.length)return"";const c=b[b.length-1].toLowerCase();return d.get(c)||""}function b(a){return new Promise((b,c)=>{const d=document.createElement("script");d.onload=b,d.onerror=c,d.async=!1,d.src=a,document.head.appendChild(d)})}const c=new Set(["local","remote"]),d=new Map([["mp4","video/mp4"],["webm","video/webm"],["m4a","audio/mp4"],["mp3","audio/mpeg"],["js","application/javascript"],["wasm","application/wasm"]]);C3.AssetManager=class extends C3.DefendedBase{constructor(a,b){if(super(),!c.has(b.defaultLoadPolicy))throw new Error("invalid load policy");if(this._runtime=a,this._localUrlBlobs=new Map,this._localBlobUrlCache=new Map,this._isCordova=!!b.isCordova,this._isWKWebView=!!b.isWKWebView,this._supportedAudioFormats=b.supportedAudioFormats||{},this._audioFiles=new Map,this._preloadSounds=!1,this._mediaSubfolder="",this._fontsSubfolder="",this._iconsSubfolder="",this._defaultLoadPolicy=b.defaultLoadPolicy,this._allAssets=[],this._assetsByUrl=new Map,this._webFonts=[],this._loadPromises=[],this._hasFinishedInitialLoad=!1,this._totalAssetSizeToLoad=0,this._assetSizeLoaded=0,this._lastLoadProgress=0,this._hasHadErrorLoading=!1,this._loadingRateLimiter=C3.New(C3.RateLimiter,()=>this._FireLoadingProgressEvent(),50),this._promiseThrottle=new C3.PromiseThrottle(Math.max(C3.hardwareConcurrency,8)),b.localUrlBlobs)for(const[a,c]of Object.entries(b.localUrlBlobs))this._localUrlBlobs.set(a.toLowerCase(),c);this._iAssetManager=new IAssetManager(this)}Release(){this._localUrlBlobs.clear();for(const a of this._localBlobUrlCache.values())URL.revokeObjectURL(a);this._localBlobUrlCache.clear();for(const a of this._allAssets)a.Release();C3.clearArray(this._allAssets),this._assetsByUrl.clear(),C3.clearArray(this._loadPromises),this._runtime=null}GetRuntime(){return this._runtime}_SetMediaSubfolder(a){this._mediaSubfolder=a}GetMediaSubfolder(){return this._mediaSubfolder}_SetFontsSubfolder(a){this._fontsSubfolder=a}GetFontsSubfolder(){return this._fontsSubfolder}_SetIconsSubfolder(a){this._iconsSubfolder=a}GetIconsSubfolder(){return this._iconsSubfolder}_HasLocalUrlBlob(a){return this._localUrlBlobs.has(a.toLowerCase())}_GetLocalUrlBlob(a){return this._localUrlBlobs.get(a.toLowerCase())||null}GetLocalUrlAsBlobUrl(a){const b=this._GetLocalUrlBlob(a);if(!b)return a;let c=this._localBlobUrlCache.get(b);return c||(c=URL.createObjectURL(b),this._localBlobUrlCache.set(b,c)),c}FetchBlob(a,b){b=b||this._defaultLoadPolicy;const c=this._GetLocalUrlBlob(a);if(c)return Promise.resolve(c);if(C3.IsRelativeURL(a)){const c=a.toLowerCase();return this._isCordova?this.CordovaFetchLocalFileAsBlob(c):"local"===b?this._promiseThrottle.Add(()=>C3.FetchBlob(c)):C3.FetchBlob(c)}return C3.FetchBlob(a)}FetchArrayBuffer(a){const b=this._GetLocalUrlBlob(a);if(b)return C3.BlobToArrayBuffer(b);if(C3.IsRelativeURL(a)){const b=a.toLowerCase();return this._isCordova?this.CordovaFetchLocalFileAsArrayBuffer(b):"local"===this._defaultLoadPolicy?this._promiseThrottle.Add(()=>C3.FetchArrayBuffer(b)):C3.FetchArrayBuffer(b)}return C3.FetchArrayBuffer(a)}FetchText(a){const b=this._GetLocalUrlBlob(a);if(b)return C3.BlobToString(b);if(C3.IsRelativeURL(a)){const b=a.toLowerCase();return this._isCordova?this.CordovaFetchLocalFileAsText(b):"local"===this._defaultLoadPolicy?this._promiseThrottle.Add(()=>C3.FetchText(b)):C3.FetchText(b)}return C3.FetchText(a)}async FetchJson(a){const b=await this.FetchText(a);return JSON.parse(b)}_CordovaFetchLocalFileAs(a,b){return this._runtime.PostComponentMessageToDOMAsync("runtime","cordova-fetch-local-file",{"filename":a,"as":b})}CordovaFetchLocalFileAsText(a){return this._CordovaFetchLocalFileAs(a,"text")}async CordovaFetchLocalFileAsBlob(b){const c=await this._CordovaFetchLocalFileAs(b,"buffer"),d=a(b);return new Blob([c],{"type":d})}async CordovaFetchLocalFileAsBlobURL(a){a=a.toLowerCase();let b=this._localBlobUrlCache.get(a);if(b)return b;const c=await this.CordovaFetchLocalFileAsBlob(a);return b=URL.createObjectURL(c),this._localBlobUrlCache.set(a,b),b}CordovaFetchLocalFileAsArrayBuffer(a){return this._CordovaFetchLocalFileAs(a,"buffer")}GetMediaFileUrl(a){return this._HasLocalUrlBlob(a)?this.GetLocalUrlAsBlobUrl(a):this._mediaSubfolder+a.toLowerCase()}GetProjectFileUrl(a,b=""){if(C3.IsAbsoluteURL(a)){if(b)throw new Error("cannot specify subfolder with remote URL");return Promise.resolve(a)}return this._HasLocalUrlBlob(a)?Promise.resolve(this.GetLocalUrlAsBlobUrl(a)):this._isCordova?this.CordovaFetchLocalFileAsBlobURL(b+a):Promise.resolve(b+a.toLowerCase())}LoadProjectFileUrl(a){return this.GetProjectFileUrl(a)}LoadImage(a){if(a.loadPolicy&&!c.has(a.loadPolicy))throw new Error("invalid load policy");let b=this._assetsByUrl.get(a.url);return b?b:(b=C3.New(C3.ImageAsset,this,{url:a.url,size:a.size||0,loadPolicy:a.loadPolicy||this._defaultLoadPolicy}),this._allAssets.push(b),this._assetsByUrl.set(b.GetURL(),b),this._hasFinishedInitialLoad||(this._totalAssetSizeToLoad+=b.GetSize(),this._loadPromises.push(b.Load().then(()=>this._AddLoadedSize(b.GetSize())))),b)}async WaitForAllToLoad(){try{await Promise.all(this._loadPromises),this._lastLoadProgress=1}catch(a){console.error("Error loading: ",a),this._hasHadErrorLoading=!0,this._FireLoadingProgressEvent()}}SetInitialLoadFinished(){this._hasFinishedInitialLoad=!0}HasHadErrorLoading(){return this._hasHadErrorLoading}_AddLoadedSize(a){this._assetSizeLoaded+=a,this._loadingRateLimiter.Call()}_FireLoadingProgressEvent(){const a=C3.New(C3.Event,"loadingprogress");this._lastLoadProgress=C3.clamp(this._assetSizeLoaded/this._totalAssetSizeToLoad,0,1),a.progress=this._lastLoadProgress,this._runtime.Dispatcher().dispatchEvent(a)}GetLoadProgress(){return this._lastLoadProgress}_SetWebFonts(a){C3.shallowAssignArray(this._webFonts,a),this._webFonts.length&&this._loadPromises.push(this._LoadWebFonts())}_LoadWebFonts(){if("undefined"==typeof FontFace)return Promise.resolve();const a=[];for(const[b,c,d]of this._webFonts)this._totalAssetSizeToLoad+=d,a.push(this._LoadWebFont(b,c).then(()=>this._AddLoadedSize(d)));return Promise.all(a)}async _LoadWebFont(a,b){try{const c=await this.GetProjectFileUrl(b,this._fontsSubfolder),d=new FontFace(a,`url('${c}')`);this._runtime.IsInWorker()?self.fonts.add(d):document.fonts.add(d),await d.load()}catch(b){console.warn(`[C3 runtime] Failed to load web font '${a}': `,b)}}IsAudioFormatSupported(a){return!!this._supportedAudioFormats[a]}_SetAudioFiles(a,b){this._preloadSounds=!!b;for(const[c,d,e]of a)this._audioFiles.set(c,{fileName:c,formats:d.map((a)=>({type:a[0],fileExtension:a[1],fullName:c+a[1],fileSize:a[2]})),isMusic:e})}GetPreferredAudioFile(a){const b=this._audioFiles.get(a.toLowerCase());if(!b)return null;let c=null;for(const d of b.formats)if(c||"audio/webm; codecs=opus"!==d.type||(c=d),this.IsAudioFormatSupported(d.type))return d;return c}GetProjectAudioFileUrl(a){const b=this.GetPreferredAudioFile(a);return b?{url:this.GetMediaFileUrl(b.fullName),type:b.type}:null}GetAudioToPreload(){if(this._preloadSounds){const a=[];for(const b of this._audioFiles.values()){if(b.isMusic)continue;const c=this.GetPreferredAudioFile(b.fileName);c&&a.push({originalUrl:b.fileName,url:this.GetMediaFileUrl(c.fullName),type:c.type,fileSize:c.fileSize})}return a}return[]}GetIAssetManager(){return this._iAssetManager}async LoadScripts(...a){const c=await Promise.all(a.map((a)=>this.GetProjectFileUrl(a)));this._runtime.IsInWorker()?importScripts(...c):await Promise.all(c.map((a)=>b(a)))}async CompileWebAssembly(a){if(WebAssembly.compileStreaming){const b=await this.GetProjectFileUrl(a);return await WebAssembly.compileStreaming(fetch(b))}else{const b=await C3.FetchArrayBuffer(a);return await WebAssembly.compile(b)}}async LoadStyleSheet(a){const b=await this.GetProjectFileUrl(a);return await this._runtime.PostComponentMessageToDOMAsync("runtime","add-stylesheet",{"url":b})}}} @@ -169,16 +172,16 @@ "use strict";{function a(){return k===j.length&&j.push(new i),j[k++]}function b(a){a.ReleaseEffectRenderTargets(),a.Clear(),k--}async function c(a,b,c){const d=await C3.Gfx.WebGLRenderTarget.DebugReadPixelsToBlob(b,c),e=URL.createObjectURL(d);console.log("[FX] "+a+" "+(c?"":" [to display]")+": ",e)}function d(a,b){var c=Math.max,d=Math.min;for(let c=0,d=b.length;c/g;C3.TimelineManager=class extends C3.DefendedBase{constructor(a){super(),this._runtime=a,this._timelineDataManager=C3.New(C3.TimelineDataManager),this._pluginInstance=null,this._timelines=[],this._timelinesByName=new Map,this._objectClassToTimelineMap=new Map,this._timelinesCreatedByTemplate=new Map,this._scheduledTimelines=[],this._playingTimelines=[],this._hasRuntimeListeners=!1,this._changingLayout=!1,this._isTickingTimelines=!1,this._tickFunc=()=>this._OnTick(),this._tick2Func=()=>this._OnTick2(),this._beforeLayoutChange=()=>this._OnBeforeChangeLayout(),this._layoutChange=()=>this._OnAfterChangeLayout(),this._instanceDestroy=(a)=>this._OnInstanceDestroy(a.instance)}Release(){const a=this._runtime.Dispatcher();a.removeEventListener("tick",this._tickFunc),this._tickFunc=null,a.removeEventListener("tick2",this._tick2Func),this._tick2Func=null,a.removeEventListener("beforelayoutchange",this._beforeLayoutChange),this._beforeLayoutChange=null,a.removeEventListener("layoutchange",this._layoutChange),this._layoutChange=null,a.removeEventListener("instancedestroy",this._instanceDestroy),this._instanceDestroy=null;for(const a of this._timelines)a.Stop(),a.Release();C3.clearArray(this._timelines),this._timelines=null,this._timelineDataManager.Release(),this._timelineDataManager=null,C3.clearArray(this._scheduledTimelines),this._scheduledTimelines=null,C3.clearArray(this._playingTimelines),this._playingTimelines=null,this._timelinesByName.clear(),this._timelinesByName=null,this._objectClassToTimelineMap.clear(),this._objectClassToTimelineMap=null,this._timelinesCreatedByTemplate.clear(),this._timelinesCreatedByTemplate=null,this._runtime=null}AddRuntimeListeners(){const a=this._runtime.Dispatcher();a.addEventListener("beforelayoutchange",this._beforeLayoutChange),a.addEventListener("layoutchange",this._layoutChange),a.addEventListener("instancedestroy",this._instanceDestroy)}Create(a){this._timelineDataManager.Add(a);const b=C3.TimelineState.CreateInitial(a,this);this.Add(b),this.SetTimelineObjectClassesToMap(b),this._timelinesCreatedByTemplate.set(b.GetName(),0)}CreateFromTemplate(a){const b=this.GetTimelineDataManager(),c=a.GetTemplateName(),d=b.Get(c),e=`${c}:${this._timelinesCreatedByTemplate.get(c)}`,f=C3.TimelineState.CreateFromTemplate(e,d,this);return this._timelinesCreatedByTemplate.set(c,this._timelinesCreatedByTemplate.get(c)+1),this.Add(f),f}Add(a){this._timelines.push(a),this._timelinesByName.set(a.GetName().toLowerCase(),a)}Remove(a){if(!a.IsTemplate()){const b=this._timelines.indexOf(a);-1!==b&&this._timelines.splice(b,1),this._timelinesByName.delete(a.GetName().toLowerCase()),this.RemoveTimelineFromObjectClassMap(a),a.Release()}}Trigger(a){this._runtime.Trigger(a,this._pluginInstance)}GetRuntime(){return this._runtime}GetTimelineDataManager(){return this._timelineDataManager}SetPluginInstance(a){this._pluginInstance=a}GetPluginInstance(){return this._pluginInstance}*GetTimelines(){for(const a of this._timelines)yield a}SetTimelineObjectClassToMap(a,b){this._objectClassToTimelineMap.has(a)||this._objectClassToTimelineMap.set(a,new Set),this._objectClassToTimelineMap.get(a).add(b)}SetTimelineObjectClassesToMap(a){for(const b of a.GetObjectClasses())this.SetTimelineObjectClassToMap(b,a)}RemoveTimelineFromObjectClassMap(a){for(const[b,c]of this._objectClassToTimelineMap.entries())c.has(a)&&(c.delete(a),0===c.size&&this._objectClassToTimelineMap.delete(b))}GetTimelinesForObjectClass(a){return this._objectClassToTimelineMap.has(a)?this._objectClassToTimelineMap.get(a):void 0}GetTimelineOfTemplateForInstances(a,b){if(b)for(const c of this._timelines){const d=b.every((a)=>c.HasTrackInstance(a.instance,a.trackId));if(d&&c.GetName().includes(a.GetName()))return c}}GetTimelineByName(a){return this._timelinesByName.get(a.toLowerCase())||null}*GetTimelinesByName(b){if(a.test(b)){a.lastIndex=0;let c;const d=new Set;do if(c=a.exec(b),c){const a=c[1].split(",");for(const b of a)d.add(b)}while(c);for(const a of d.values()){const b=this.GetTimelineByName(a);b&&(yield b)}d.clear()}else{const a=this.GetTimelineByName(b);a&&(yield a)}}*GetTimelinesByTags(a){for(const b of this._timelines)b.HasTags(a)&&(yield b)}ScheduleTimeline(a){a.SetPlaying(!1),a.SetScheduled(!0),a.SetMarkedForRemoval(!1),this._scheduledTimelines.push(a),this._MaybeAddRuntimeListeners()}DeScheduleTimeline(a){const b=this._scheduledTimelines.indexOf(a);a.SetPlaying(!1),a.SetScheduled(!1),a.ResolvePlayPromise();-1===b||(this._scheduledTimelines.splice(b,1),this._MaybeRemoveRuntimeListeners())}CompleteTimeline(a){a.SetPlaying(!1),a.SetScheduled(!1),a.SetMarkedForRemoval(!0)}CompleteTimelineAndResolve(a){this.CompleteTimeline(a),a.ResolvePlayPromise()}_OnTick(){if(this._changingLayout)return;let a=!1;for(this._isTickingTimelines=!0;this._scheduledTimelines.length;){const a=this._scheduledTimelines.pop();a.SetInitialState(),this._playingTimelines.push(a)}const b=this._runtime.GetDt(),c=this._runtime.GetTimeScale();for(const d of this._playingTimelines){if(d.IsMarkedForRemoval())continue;const e=d.Tick(b,c);!a&&e&&(a=!0)}this._isTickingTimelines=!1,a&&this.GetRuntime().UpdateRender()}_OnTick2(){for(const a of this._playingTimelines){if(!a.IsMarkedForRemoval())continue;const b=this._playingTimelines.indexOf(a);-1===b||this._playingTimelines.splice(b,1)}this._MaybeRemoveRuntimeListeners()}_MaybeAddRuntimeListeners(){if(!this._hasRuntimeListeners){const a=this._runtime.Dispatcher();a.addEventListener("tick",this._tickFunc),a.addEventListener("tick2",this._tick2Func),this._hasRuntimeListeners=!0}}_MaybeRemoveRuntimeListeners(){if(!this._playingTimelines.length&&!this._scheduledTimelines.length&&!this._isTickingTimelines){const a=this._runtime.Dispatcher();a.removeEventListener("tick",this._tickFunc),a.removeEventListener("tick2",this._tick2Func),this._hasRuntimeListeners=!1}}_OnBeforeChangeLayout(){for(this._changingLayout=!0;this._scheduledTimelines.length;)this.DeScheduleTimeline(this._scheduledTimelines.pop());for(;this._playingTimelines.length;){const a=this._playingTimelines.pop();this.CompleteTimeline(a),a.Reset(!1)}this._MaybeRemoveRuntimeListeners();for(const a of this._timelines)a.CleanCaches()}_OnAfterChangeLayout(){this._changingLayout=!1}_OnInstanceDestroy(a){const b=a.GetObjectClass(),c=this.GetTimelinesForObjectClass(b);if(c)for(const a of c)a.IsTemplate()||a.HasValidTracks()||this.Remove(a)}}} +"use strict";{const a=/<(.+?)>/g;C3.TimelineManager=class extends C3.DefendedBase{constructor(a){super(),this._runtime=a,this._timelineDataManager=C3.New(C3.TimelineDataManager),this._pluginInstance=null,this._timelines=[],this._timelinesByName=new Map,this._objectClassToTimelineMap=new Map,this._timelinesCreatedByTemplate=new Map,this._scheduledTimelines=[],this._playingTimelines=[],this._hasRuntimeListeners=!1,this._changingLayout=!1,this._isTickingTimelines=!1,this._tickFunc=()=>this._OnTick(),this._tick2Func=()=>this._OnTick2(),this._beforeLayoutChange=()=>this._OnBeforeChangeLayout(),this._layoutChange=()=>this._OnAfterChangeLayout(),this._instanceDestroy=(a)=>this._OnInstanceDestroy(a.instance)}Release(){const a=this._runtime.Dispatcher();a.removeEventListener("pretick",this._tickFunc),this._tickFunc=null,a.removeEventListener("tick2",this._tick2Func),this._tick2Func=null,a.removeEventListener("beforelayoutchange",this._beforeLayoutChange),this._beforeLayoutChange=null,a.removeEventListener("layoutchange",this._layoutChange),this._layoutChange=null,a.removeEventListener("instancedestroy",this._instanceDestroy),this._instanceDestroy=null;for(const a of this._timelines)a.Stop(),a.Release();C3.clearArray(this._timelines),this._timelines=null,this._timelineDataManager.Release(),this._timelineDataManager=null,C3.clearArray(this._scheduledTimelines),this._scheduledTimelines=null,C3.clearArray(this._playingTimelines),this._playingTimelines=null,this._timelinesByName.clear(),this._timelinesByName=null,this._objectClassToTimelineMap.clear(),this._objectClassToTimelineMap=null,this._timelinesCreatedByTemplate.clear(),this._timelinesCreatedByTemplate=null,this._runtime=null}AddRuntimeListeners(){const a=this._runtime.Dispatcher();a.addEventListener("beforelayoutchange",this._beforeLayoutChange),a.addEventListener("layoutchange",this._layoutChange),a.addEventListener("instancedestroy",this._instanceDestroy)}Create(a){this._timelineDataManager.Add(a);const b=C3.TimelineState.CreateInitial(a,this);this.Add(b),this.SetTimelineObjectClassesToMap(b),this._timelinesCreatedByTemplate.set(b.GetName(),0)}CreateFromTemplate(a){const b=this.GetTimelineDataManager(),c=a.GetTemplateName(),d=b.Get(c),e=`${c}:${this._timelinesCreatedByTemplate.get(c)}`,f=C3.TimelineState.CreateFromTemplate(e,d,this);return this._timelinesCreatedByTemplate.set(c,this._timelinesCreatedByTemplate.get(c)+1),this.Add(f),f}Add(a){this._timelines.push(a),this._timelinesByName.set(a.GetName().toLowerCase(),a)}Remove(a){if(!a.IsTemplate()){const b=this._timelines.indexOf(a);-1!==b&&this._timelines.splice(b,1),this._timelinesByName.delete(a.GetName().toLowerCase()),this.RemoveTimelineFromObjectClassMap(a),a.Release()}}Trigger(a){this._runtime.Trigger(a,this._pluginInstance)}GetRuntime(){return this._runtime}GetTimelineDataManager(){return this._timelineDataManager}SetPluginInstance(a){this._pluginInstance=a}GetPluginInstance(){return this._pluginInstance}*GetTimelines(){for(const a of this._timelines)yield a}SetTimelineObjectClassToMap(a,b){this._objectClassToTimelineMap.has(a)||this._objectClassToTimelineMap.set(a,new Set),this._objectClassToTimelineMap.get(a).add(b)}SetTimelineObjectClassesToMap(a){for(const b of a.GetObjectClasses())this.SetTimelineObjectClassToMap(b,a)}RemoveTimelineFromObjectClassMap(a){for(const[b,c]of this._objectClassToTimelineMap.entries())c.has(a)&&(c.delete(a),0===c.size&&this._objectClassToTimelineMap.delete(b))}GetTimelinesForObjectClass(a){return this._objectClassToTimelineMap.has(a)?this._objectClassToTimelineMap.get(a):void 0}GetTimelineOfTemplateForInstances(a,b){if(b)for(const c of this._timelines){const d=b.every((a)=>c.HasTrackInstance(a.instance,a.trackId));if(d&&c.GetName().includes(a.GetName()))return c}}GetTimelineByName(a){return this._timelinesByName.get(a.toLowerCase())||null}*GetTimelinesByName(b){if(a.test(b)){a.lastIndex=0;let c;const d=new Set;do if(c=a.exec(b),c){const a=c[1].split(",");for(const b of a)d.add(b)}while(c);for(const a of d.values()){const b=this.GetTimelineByName(a);b&&(yield b)}d.clear()}else{const a=this.GetTimelineByName(b);a&&(yield a)}}*GetTimelinesByTags(a){for(const b of this._timelines)b.HasTags(a)&&(yield b)}ScheduleTimeline(a){a.SetPlaying(!1),a.SetScheduled(!0),a.SetMarkedForRemoval(!1),this._scheduledTimelines.push(a),this._MaybeAddRuntimeListeners()}DeScheduleTimeline(a){const b=this._scheduledTimelines.indexOf(a);a.SetPlaying(!1),a.SetScheduled(!1),a.ResolvePlayPromise();-1===b||(this._scheduledTimelines.splice(b,1),this._MaybeRemoveRuntimeListeners())}CompleteTimeline(a){a.SetPlaying(!1),a.SetScheduled(!1),a.SetMarkedForRemoval(!0)}CompleteTimelineAndResolve(a){this.CompleteTimeline(a),a.ResolvePlayPromise()}_OnTick(){if(this._changingLayout)return;let a=!1;for(this._isTickingTimelines=!0;this._scheduledTimelines.length;){const a=this._scheduledTimelines.pop();a.SetInitialState(),this._playingTimelines.push(a)}const b=this._runtime.GetDt(),c=this._runtime.GetTimeScale();for(const d of this._playingTimelines){if(d.IsMarkedForRemoval())continue;const e=d.Tick(b,c);!a&&e&&(a=!0)}this._isTickingTimelines=!1,a&&this.GetRuntime().UpdateRender()}_OnTick2(){for(const a of this._playingTimelines){if(!a.IsMarkedForRemoval())continue;const b=this._playingTimelines.indexOf(a);-1===b||this._playingTimelines.splice(b,1)}this._MaybeRemoveRuntimeListeners()}_MaybeAddRuntimeListeners(){if(!this._hasRuntimeListeners){const a=this._runtime.Dispatcher();a.addEventListener("pretick",this._tickFunc),a.addEventListener("tick2",this._tick2Func),this._hasRuntimeListeners=!0}}_MaybeRemoveRuntimeListeners(){if(!this._playingTimelines.length&&!this._scheduledTimelines.length&&!this._isTickingTimelines){const a=this._runtime.Dispatcher();a.removeEventListener("pretick",this._tickFunc),a.removeEventListener("tick2",this._tick2Func),this._hasRuntimeListeners=!1}}_OnBeforeChangeLayout(){for(this._changingLayout=!0;this._scheduledTimelines.length;)this.DeScheduleTimeline(this._scheduledTimelines.pop());for(;this._playingTimelines.length;){const a=this._playingTimelines.pop();a.IsReleased()||(this.CompleteTimeline(a),a.Reset(!1))}this._MaybeRemoveRuntimeListeners();for(const a of this._timelines)a.CleanCaches()}_OnAfterChangeLayout(){this._changingLayout=!1}_OnInstanceDestroy(a){const b=a.GetObjectClass(),c=this.GetTimelinesForObjectClass(b);if(c)for(const a of c)a.IsTemplate()||a.HasValidTracks()||this.Remove(a)}}} // c3/timelines/state/timelineState.js -"use strict";{const a=0;C3.TimelineState=class extends C3.DefendedBase{constructor(b,c,d){super(),this._runtime=d.GetRuntime(),this._timelineManager=d,this._timelineDataItem=c,this._name=b,this._tracks=[];for(const a of this._timelineDataItem.GetTrackData().trackDataItems())this._tracks.push(C3.TrackState.Create(this,a));this._playPromise=null,this._playResolve=null,this._playheadTime=C3.New(C3.KahanSum),this._playheadTime.Set(0),this._playbackRate=1,this._pingPongState=a,this._currentRepeatCount=1,this._isPlaying=!1,this._isScheduled=!1,this._initialStateSet=!1,this._complete=!0,this._released=!1,this._markedForRemoval=!1,this._completedTick=-1,this._implicitPause=!1,this._isTemplate=!1,this._tags=[""],this._stringTags="",this._tagsChanged=!1}static CreateInitial(a,b){const c=b.GetTimelineDataManager(),d=c.GetNameId(),e=c.Get(a[d]),f=C3.New(C3.TimelineState,a[d],e,b);return f.SetIsTemplate(!0),f}static CreateFromTemplate(a,b,c){return C3.New(C3.TimelineState,a,b,c)}static get WORLD_INSTANCE_BOX_CHANGE(){return 1}static get LAYOUT_RENDER_CHANGE(){return C3.nextHighestPowerOfTwo(1)}Release(){if(!this.IsReleased()){this._timelineManager.DeScheduleTimeline(this),this._timelineManager.CompleteTimelineAndResolve(this);for(const a of this._tracks)a.Release();C3.clearArray(this._tracks),this._tracks=null,this._playheadTime.Release(),this._playheadTime=null,this._runtime=null,this._timelineManager=null,this._timelineDataItem=null,this._released=!0,this._playPromise=null,this._playResolve=null}}GetTimelineManager(){return this._timelineManager}GetRuntime(){return this._runtime}GetTracks(){return this._tracks}SetName(a){this._name=a}GetName(){return this._name}GetTemplateName(){return this._timelineDataItem.GetName()}GetTotalTime(){return this._timelineDataItem.GetTotalTime()}SetTotalTime(a){this._timelineDataItem.SetTotalTime(a)}GetStep(){return this._timelineDataItem.GetStep()}SetStep(a){this._timelineDataItem.SetStep(a)}GetInterpolationMode(){return this._timelineDataItem.GetInterpolationMode()}SetInterpolationMode(a){this._timelineDataItem.SetInterpolationMode(a)}GetResultMode(){return this._timelineDataItem.GetResultMode()}SetResultMode(a){this._timelineDataItem.GetResultMode(a)}SetEase(a){for(const b of this.GetTracks())b.SetEase(a)}GetLoop(){return this._timelineDataItem.GetLoop()}GetPingPong(){return this._timelineDataItem.GetPingPong()}GetRepeatCount(){return this._timelineDataItem.GetRepeatCount()}SetPlaybackRate(a){return this._playbackRate=a}GetPlaybackRate(){return this._playbackRate}IsForwardPlayBack(){return!this.IsPlaying()||0{this._playResolve=a}),this._playPromise)}ResolvePlayPromise(){this._playPromise&&(this._playResolve(),this._playPromise=null,this._playResolve=null)}SetTags(a){this._tags=C3.TimelineState._GetTagArray(a),this._tagsChanged=!0}GetTags(){return this._tags}GetStringTags(){return this._tagsChanged&&(this._stringTags=this._tags.join(" ")),this._tagsChanged=!1,this._stringTags}HasTags(a){if(!this._tags)return!1;if(!this._tags.length)return!1;const b=C3.TimelineState._GetTagArray(a);return!!b&&!!b.length&&b.every(C3.TimelineState._HasTag,this)}OnStarted(){C3.Plugins.Timeline.Cnds.SetTriggerTimeline(this),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineStarted),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineStartedByName),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineStartedByTags),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnAnyTimelineStarted),C3.Plugins.Timeline.Cnds.SetTriggerTimeline(null)}OnCompleted(){this._completedTick=this._runtime.GetTickCount(),C3.Plugins.Timeline.Cnds.SetTriggerTimeline(this),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineFinished),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineFinishedByName),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineFinishedByTags),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnAnyTimelineFinished),C3.Plugins.Timeline.Cnds.SetTriggerTimeline(null)}SetPlaying(a){this._isPlaying=a}IsPlaying(){return!(this._completedTick!==this._runtime.GetTickCount())||this._isPlaying}SetScheduled(a){this._isScheduled=a}IsScheduled(){return this._isScheduled}SetComplete(a){this._complete=a;const b=this.GetTime();(0>=b||b>=this.GetTotalTime())&&(this._complete=!0)}IsComplete(){return this._complete}IsReleased(){return this._released}SetMarkedForRemoval(a){this._markedForRemoval=a}IsMarkedForRemoval(){return this._markedForRemoval}SetImplicitPause(a){this._implicitPause=a}IsImplicitPause(){return this._implicitPause}SetIsTemplate(a){this._isTemplate=!!a}IsTemplate(){return this._isTemplate}InitialStateSet(){return this._initialStateSet}GetTime(){return this._playheadTime.Get()}SetTime(a){this._SetTime(a),this.SetComplete(!1),this.IsComplete()||this.SetImplicitPause(!0),(this.IsPlaying()||this.IsScheduled()||!this._initialStateSet)&&(this.IsPlaying()||this.IsScheduled()||this._initialStateSet?this.IsPlaying()?this.Stop():this.IsScheduled()&&(this._timelineManager.DeScheduleTimeline(this),this.SetInitialStateFromSetTime()):this.SetInitialStateFromSetTime());let b=!1;for(const c of this._tracks){c.SetResumeState();const a=c.Interpolate(this._playheadTime.Get(),!1,!0);!b&&a&&(b=!0)}b&&this.GetRuntime().UpdateRender(),this._OnSetTime()}_SetTime(a){0>a?this._playheadTime.Set(0):a>=this.GetTotalTime()?this._playheadTime.Set(this.GetTotalTime()):this._playheadTime.Set(a)}_OnSetTime(){C3.Plugins.Timeline&&this.constructor===C3.TimelineState&&(C3.Plugins.Timeline.Cnds.SetTriggerTimeline(this),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimeSet),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimeSetByName),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimeSetByTags),C3.Plugins.Timeline.Cnds.SetTriggerTimeline(null))}Resume(){if(!this.IsReleased()){if(this.IsForwardPlayBack()){if(this._playheadTime.Get()>=this.GetTotalTime())return;}else if(0>=this._playheadTime.Get())return;this.Play(!0)}}Play(a=!1){return!this.IsReleased()&&!this.IsScheduled()&&!this.IsPlaying()&&!!(this.IsComplete()||a||this.IsImplicitPause())&&(this.SetImplicitPause(!1),this._timelineManager.ScheduleTimeline(this),this.GetPlayPromise(),!0)}Stop(a=!1){this.IsReleased()||(this.SetComplete(a),this._timelineManager.CompleteTimeline(this),this.IsComplete()&&this.ResolvePlayPromise())}Reset(a=!0){if(this.IsReleased())return;if(!this.IsPlaying()&&this.IsScheduled())return this._timelineManager.DeScheduleTimeline(this);if(this.IsComplete())return;this.Stop(!0),this.IsForwardPlayBack()?this._SetTime(0):this._SetTime(this.GetTotalTime());let b=!1;for(const c of this._tracks){const a=c.Interpolate(this._playheadTime.Get());!b&&a&&(b=!0)}a&&this._OnSetTime(),b&&a&&this.GetRuntime().UpdateRender()}SetInitialStateFromSetTime(){this.SetInitialState(!0)}SetInitialState(b){if(b){this._initialStateSet=!0;for(const a of this._tracks)a.SetInitialState()}else if(this.SetPlaying(!0),this.SetScheduled(!1),this.OnStarted(),this.IsComplete()){this._completedTick=-1,this._pingPongState=a,this._currentRepeatCount=1,this._complete=!1,this._initialStateSet=!0,this.IsForwardPlayBack()?this._SetTime(0):this._SetTime(this.GetTotalTime());for(const a of this._tracks)a.SetInitialState()}else for(const a of this._tracks)a.SetResumeState()}Tick(a,b){this._playheadTime.Add(a*b*this._playbackRate);let c;if(this.GetLoop()||this.GetPingPong()?this.GetLoop()&&!this.GetPingPong()?c=this._LoopCompleteCheck():!this.GetLoop()&&this.GetPingPong()?c=this._PingPongCompleteCheck():this.GetLoop()&&this.GetPingPong()&&(c=this._LoopPingPongCompleteCheck()):c=this._SimpleCompleteCheck(),c){for(const a of this._tracks)a.SetEndState();return this.Stop(!0),this.OnCompleted(),!0}else{let a=!1;for(const b of this._tracks){const c=b.Interpolate(this._playheadTime.Get(),!0);!a&&c&&(a=!0)}return a}}_SimpleCompleteCheck(){if(this.IsForwardPlayBack()){if(this._playheadTime.Get()>=this.GetTotalTime())if(this._currentRepeatCount=this._playheadTime.Get())if(this._currentRepeatCount=this.GetTotalTime()&&this._SetTime(0):0>=this._playheadTime.Get()&&this._SetTime(this.GetTotalTime()),!1}_PingPongCompleteCheck(){if(this.IsForwardPlayBack()){if(this._playheadTime.Get()>=this.GetTotalTime())if(this._SetTime(this.GetTotalTime()),this.SetPlaybackRate(-1*this.GetPlaybackRate()),1!==this._pingPongState)this._pingPongState===a&&(this._pingPongState=1);else if(this._currentRepeatCount=this._playheadTime.Get())if(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),1!==this._pingPongState)this._pingPongState===a&&(this._pingPongState=1);else if(this._currentRepeatCount=this.GetTotalTime()&&(this._SetTime(this.GetTotalTime()),this.SetPlaybackRate(-1*this.GetPlaybackRate())):0>=this._playheadTime.Get()&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate())),!1}AddTrack(){const a=this._timelineDataItem.GetTrackData().AddEmptyTrackDataItem(),b=C3.TrackState.Create(this,a);return this._tracks.push(b),b}CleanCaches(){for(const a of this._tracks)a.CleanCaches()}ClearTrackInstances(){for(const a of this._tracks)a.ClearInstance()}SetTrackInstance(a,b){if(b)for(const c of this._tracks)c.GetId()&&c.GetId()===a&&(c.SetInstance(b),this._timelineManager.SetTimelineObjectClassToMap(b.GetObjectClass(),this))}HasTrackInstance(a,b){for(const c of this._tracks)if(b){if(b===c.GetId()&&a===c.GetInstance())return!0;}else if(a===c.GetInstance())return!0;return!1}HasValidTracks(){return this._tracks.some((a)=>a.CanInstanceBeValid())}GetPropertyTrack(a){for(const b of this.GetTracks())for(const c of b.GetPropertyTracks())if(c.GetPropertyName()===a)return c}GetKeyframeWithTags(a){let b=a?a.split(" "):[];const c=new Set(b.map((a)=>a.toLowerCase().trim()));b=[...c.values()];for(const c of this.GetTracks())for(const a of c.GetKeyframeDataItems()){const c=b.every((b)=>a.HasTag(b));if(c)return a}}GetObjectClasses(){const a=[];for(const b of this.GetTracks())a.push(b.GetObjectClass());return a.filter((a)=>a)}static _HasTag(a){const b=this.GetTags();return""===a?1===b.length&&""===b[0]:b.includes(a)}static _GetTagArray(a){return C3.IsArray(a)?a.slice(0):C3.IsString(a)?a.split(" "):void 0}}} +"use strict";{const a=0;C3.TimelineState=class extends C3.DefendedBase{constructor(b,c,d){super(),this._runtime=d.GetRuntime(),this._timelineManager=d,this._timelineDataItem=c,this._name=b,this._tracks=[];for(const a of this._timelineDataItem.GetTrackData().trackDataItems())this._tracks.push(C3.TrackState.Create(this,a));this._playPromise=null,this._playResolve=null,this._playheadTime=C3.New(C3.KahanSum),this._playheadTime.Set(0),this._playbackRate=1,this._pingPongState=a,this._currentRepeatCount=1,this._isPlaying=!1,this._isScheduled=!1,this._initialStateSet=!1,this._complete=!0,this._released=!1,this._markedForRemoval=!1,this._completedTick=-1,this._implicitPause=!1,this._isTemplate=!1,this._tags=[""],this._stringTags="",this._tagsChanged=!1}static CreateInitial(a,b){const c=b.GetTimelineDataManager(),d=c.GetNameId(),e=c.Get(a[d]),f=C3.New(C3.TimelineState,a[d],e,b);return f.SetIsTemplate(!0),f}static CreateFromTemplate(a,b,c){return C3.New(C3.TimelineState,a,b,c)}static get WORLD_INSTANCE_BOX_CHANGE(){return 1}static get LAYOUT_RENDER_CHANGE(){return C3.nextHighestPowerOfTwo(1)}Release(){if(!this.IsReleased()){this._timelineManager.DeScheduleTimeline(this),this._timelineManager.CompleteTimelineAndResolve(this);for(const a of this._tracks)a.Release();C3.clearArray(this._tracks),this._tracks=null,this._playheadTime.Release(),this._playheadTime=null,this._runtime=null,this._timelineManager=null,this._timelineDataItem=null,this._released=!0,this._playPromise=null,this._playResolve=null}}GetTimelineManager(){return this._timelineManager}GetRuntime(){return this._runtime}GetTracks(){return this._tracks}GetTrackById(a){for(const b of this._tracks)if(C3.equalsNoCase(b.GetId(),a))return b;return null}SetName(a){this._name=a}GetName(){return this._name}GetTemplateName(){return this._timelineDataItem.GetName()}GetTotalTime(){return this._timelineDataItem.GetTotalTime()}SetTotalTime(a){this._timelineDataItem.SetTotalTime(a)}GetStep(){return this._timelineDataItem.GetStep()}SetStep(a){this._timelineDataItem.SetStep(a)}GetInterpolationMode(){return this._timelineDataItem.GetInterpolationMode()}SetInterpolationMode(a){this._timelineDataItem.SetInterpolationMode(a)}GetResultMode(){return this._timelineDataItem.GetResultMode()}SetResultMode(a){this._timelineDataItem.GetResultMode(a)}SetEase(a){for(const b of this.GetTracks())b.SetEase(a)}GetLoop(){return this._timelineDataItem.GetLoop()}GetPingPong(){return this._timelineDataItem.GetPingPong()}GetRepeatCount(){return this._timelineDataItem.GetRepeatCount()}SetPlaybackRate(a){return this._playbackRate=a}GetPlaybackRate(){return this._playbackRate}IsForwardPlayBack(){return!this.IsPlaying()||0{this._playResolve=a}),this._playPromise)}ResolvePlayPromise(){this._playPromise&&(this._playResolve(),this._playPromise=null,this._playResolve=null)}SetTags(a){this._tags=C3.TimelineState._GetTagArray(a),this._tagsChanged=!0}GetTags(){return this._tags}GetStringTags(){return this._tagsChanged&&(this._stringTags=this._tags.join(" ")),this._tagsChanged=!1,this._stringTags}HasTags(a){if(!this._tags)return!1;if(!this._tags.length)return!1;const b=C3.TimelineState._GetTagArray(a);return!!b&&!!b.length&&b.every(C3.TimelineState._HasTag,this)}OnStarted(){C3.Plugins.Timeline.Cnds.SetTriggerTimeline(this),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineStarted),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineStartedByName),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineStartedByTags),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnAnyTimelineStarted),C3.Plugins.Timeline.Cnds.SetTriggerTimeline(null)}OnCompleted(){this._completedTick=this._runtime.GetTickCount(),C3.Plugins.Timeline.Cnds.SetTriggerTimeline(this),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineFinished),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineFinishedByName),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimelineFinishedByTags),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnAnyTimelineFinished),C3.Plugins.Timeline.Cnds.SetTriggerTimeline(null)}SetPlaying(a){this._isPlaying=a}IsPlaying(){return!(this._completedTick!==this._runtime.GetTickCount())||this._isPlaying}SetScheduled(a){this._isScheduled=a}IsScheduled(){return this._isScheduled}SetComplete(a){this._complete=a;const b=this.GetTime();(0>=b||b>=this.GetTotalTime())&&(this._complete=!0)}IsComplete(){return this._complete}IsReleased(){return this._released}SetMarkedForRemoval(a){this._markedForRemoval=a}IsMarkedForRemoval(){return this._markedForRemoval}SetImplicitPause(a){this._implicitPause=a}IsImplicitPause(){return this._implicitPause}SetIsTemplate(a){this._isTemplate=!!a}IsTemplate(){return this._isTemplate}InitialStateSet(){return this._initialStateSet}GetTime(){return this._playheadTime.Get()}SetTime(a){this._SetTime(a),this.SetComplete(!1),this.IsComplete()||this.SetImplicitPause(!0),(this.IsPlaying()||this.IsScheduled()||!this._initialStateSet)&&(this.IsPlaying()||this.IsScheduled()||this._initialStateSet?this.IsPlaying()?this.Stop():this.IsScheduled()&&(this._timelineManager.DeScheduleTimeline(this),this.SetInitialStateFromSetTime()):this.SetInitialStateFromSetTime());let b=!1;for(const c of this._tracks){c.SetResumeState();const a=c.Interpolate(this._playheadTime.Get(),!1,!0);!b&&a&&(b=!0)}b&&this.GetRuntime().UpdateRender(),this._OnSetTime()}_SetTime(a){0>a?this._playheadTime.Set(0):a>=this.GetTotalTime()?this._playheadTime.Set(this.GetTotalTime()):this._playheadTime.Set(a)}_OnSetTime(){C3.Plugins.Timeline&&this.constructor===C3.TimelineState&&(C3.Plugins.Timeline.Cnds.SetTriggerTimeline(this),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimeSet),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimeSetByName),this._timelineManager.Trigger(C3.Plugins.Timeline.Cnds.OnTimeSetByTags),C3.Plugins.Timeline.Cnds.SetTriggerTimeline(null))}Resume(){if(!this.IsReleased()){if(this.IsForwardPlayBack()){if(this._playheadTime.Get()>=this.GetTotalTime())return;}else if(0>=this._playheadTime.Get())return;this.Play(!0)}}Play(a=!1){return!this.IsReleased()&&!this.IsScheduled()&&!this.IsPlaying()&&!!(this.IsComplete()||a||this.IsImplicitPause())&&(this.SetImplicitPause(!1),this._timelineManager.ScheduleTimeline(this),this.GetPlayPromise(),!0)}Stop(a=!1){this.IsReleased()||(this.SetComplete(a),this._timelineManager.CompleteTimeline(this),this.IsComplete()&&this.ResolvePlayPromise())}Reset(a=!0){if(this.IsReleased())return;if(!this.IsPlaying()&&this.IsScheduled())return this._timelineManager.DeScheduleTimeline(this);if(this.IsComplete())return;this.Stop(!0),this.IsForwardPlayBack()?this._SetTime(0):this._SetTime(this.GetTotalTime());let b=!1;for(const c of this._tracks){const a=c.Interpolate(this._playheadTime.Get());!b&&a&&(b=!0)}a&&this._OnSetTime(),b&&a&&this.GetRuntime().UpdateRender()}SetInitialStateFromSetTime(){this.SetInitialState(!0)}SetInitialState(b){if(b){this._initialStateSet=!0;for(const a of this._tracks)a.SetInitialState()}else if(this.SetPlaying(!0),this.SetScheduled(!1),this.OnStarted(),this.IsComplete()){this._completedTick=-1,this._pingPongState=a,this._currentRepeatCount=1,this._complete=!1,this._initialStateSet=!0,this.IsForwardPlayBack()?this._SetTime(0):this._SetTime(this.GetTotalTime());for(const a of this._tracks)a.SetInitialState()}else for(const a of this._tracks)a.SetResumeState()}Tick(a,b){this._playheadTime.Add(a*b*this._playbackRate);let c;if(this.GetLoop()||this.GetPingPong()?this.GetLoop()&&!this.GetPingPong()?c=this._LoopCompleteCheck():!this.GetLoop()&&this.GetPingPong()?c=this._PingPongCompleteCheck():this.GetLoop()&&this.GetPingPong()&&(c=this._LoopPingPongCompleteCheck()):c=this._SimpleCompleteCheck(),c){for(const a of this._tracks)a.SetEndState();return this.Stop(!0),this.OnCompleted(),!0}else{let a=!1;for(const b of this._tracks){const c=b.Interpolate(this._playheadTime.Get(),!0);!a&&c&&(a=!0)}return a}}_SimpleCompleteCheck(){if(this.IsForwardPlayBack()){if(this._playheadTime.Get()>=this.GetTotalTime())if(this._currentRepeatCount=this._playheadTime.Get())if(this._currentRepeatCount=this.GetTotalTime()&&this._SetTime(0):0>=this._playheadTime.Get()&&this._SetTime(this.GetTotalTime()),!1}_PingPongCompleteCheck(){if(this.IsForwardPlayBack()){if(this._playheadTime.Get()>=this.GetTotalTime())if(this._SetTime(this.GetTotalTime()),this.SetPlaybackRate(-1*this.GetPlaybackRate()),1!==this._pingPongState)this._pingPongState===a&&(this._pingPongState=1);else if(this._currentRepeatCount=this._playheadTime.Get())if(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate()),1!==this._pingPongState)this._pingPongState===a&&(this._pingPongState=1);else if(this._currentRepeatCount=this.GetTotalTime()&&(this._SetTime(this.GetTotalTime()),this.SetPlaybackRate(-1*this.GetPlaybackRate())):0>=this._playheadTime.Get()&&(this._SetTime(0),this.SetPlaybackRate(-1*this.GetPlaybackRate())),!1}AddTrack(){const a=this._timelineDataItem.GetTrackData().AddEmptyTrackDataItem(),b=C3.TrackState.Create(this,a);return this._tracks.push(b),b}CleanCaches(){for(const a of this._tracks)a.CleanCaches()}ClearTrackInstances(){for(const a of this._tracks)a.ClearInstance()}SetTrackInstance(a,b){if(b)for(const c of this._tracks)if(a){if(c.GetId()!==a)continue;c.SetInstance(b),this._timelineManager.SetTimelineObjectClassToMap(b.GetObjectClass(),this);break}else{if(c.HasInstance())continue;c.SetInstance(b),this._timelineManager.SetTimelineObjectClassToMap(b.GetObjectClass(),this);break}}HasTrackInstance(a,b){for(const c of this._tracks)if(b){if(b===c.GetId()&&a===c.GetInstance())return!0;}else if(a===c.GetInstance())return!0;return!1}HasValidTracks(){return this._tracks.some((a)=>a.CanInstanceBeValid())}GetPropertyTrack(a){for(const b of this.GetTracks())for(const c of b.GetPropertyTracks())if(c.GetPropertyName()===a)return c}GetKeyframeWithTags(a){let b=a?a.split(" "):[];const c=new Set(b.map((a)=>a.toLowerCase().trim()));b=[...c.values()];for(const c of this.GetTracks())for(const a of c.GetKeyframeDataItems()){const c=b.every((b)=>a.HasTag(b));if(c)return a}}GetObjectClasses(){const a=[];for(const b of this.GetTracks())a.push(b.GetObjectClass());return a.filter((a)=>a)}static _HasTag(a){const b=this.GetTags();return""===a?1===b.length&&""===b[0]:b.includes(a)}static _GetTagArray(a){return C3.IsArray(a)?a.slice(0):C3.IsString(a)?a.split(" "):void 0}}} // c3/timelines/state/trackState.js -"use strict";C3.TrackState=class extends C3.DefendedBase{constructor(a,b){super(),this._timeline=a,this._trackDataItem=b,this._trackData=b.GetTrackData(),this._instanceUid=NaN,this._objectClassIndex=NaN,this._instance=null,this._worldInfo=null,this._lastKeyframeDataItem=null,this._keyframeDataItems=this._trackDataItem.GetKeyframeData().GetKeyframeDataItemArray(),this._propertyTracks=[];for(const c of this._trackDataItem.GetPropertyTrackData().propertyTrackDataItems())this._propertyTracks.push(C3.PropertyTrackState.Create(this,c))}static Create(a,b){return C3.New(C3.TrackState,a,b)}Release(){this._keyframeDataItems=null;for(const a of this._propertyTracks)a.Release();C3.clearArray(this._propertyTracks),this._propertyTracks=null,this._timeline=null,this._instance=null,this._worldInfo=null,this._trackDataItem=null,this._lastKeyframeDataItem=null}CleanCaches(){for(const a of this._propertyTracks)a.CleanCaches();this._instance=null,this._worldInfo=null}GetTimeline(){return this._timeline}GetRuntime(){return this._timeline.GetRuntime()}GetKeyframeDataItems(){return this._keyframeDataItems?this._keyframeDataItems:(this._keyframeDataItems=this._trackDataItem.GetKeyframeData().GetKeyframeDataItemArray(),this._keyframeDataItems)}GetPropertyTracks(){return this._propertyTracks}MaybeGetInstance(){this._instance||this.GetInstance()}IsInstanceValid(){return!!this._instance&&!this._instance.IsDestroyed()}CanInstanceBeValid(){const a=this.GetInstanceUID(),b=this.GetRuntime().GetInstanceByUID(a);return!!b&&!b.IsDestroyed()}GetObjectClass(){const a=this.GetObjectClassIndex();return-1===a?void 0:this.GetRuntime().GetObjectClassByIndex(a)}ClearInstance(){this._instance=null,this._instanceUid=-1,this._worldInfo=null,this._objectClassIndex=-1}GetInstance(){if(this._instance&&this.IsInstanceValid())return this._instance;const a=this.GetInstanceUID();return this._instance=this.GetRuntime().GetInstanceByUID(a),this._instance}SetInstance(a){if(this._instance!==a){this._instance=a,this._objectClassIndex=a.GetObjectClass().GetIndex(),this._instanceUid=a.GetUID(),this._worldInfo=a.GetWorldInfo();for(const a of this.propertyTrackItems()){const b=a.propertyTrack,c=a.sourceAdapter,d=b.GetSourceAdapterId();switch(d){case"instance-variable":{const b=c.GetEditorIndex(),d=inst.GetObjectClass(),e=d.GetInstanceVariableIndexByName(a.name),f=d.GetInstanceVariableName(e),g=d.GetInstanceVariableType(e);f===a.name&&g===a.type&&c.UpdateInstanceVariableIndex(e);break}case"behavior":{const b=a.behaviorType,d=this.GetObjectClass(),e=inst.GetObjectClass(),f=c.GetBehaviorType(e);if(b&&f){const a=b.GetName(),g=d.GetBehaviorIndexByName(a),h=e.GetBehaviorIndexByName(a),i=c.GetEditorIndex();c.UpdateBehaviorTypeSid(f.GetSID())}break}}}}}*propertyTrackItems(){for(const a of this._propertyTracks){const b=a.GetSourceAdapter(),c=this.GetObjectClass(),d={propertyTrack:a,sourceAdapter:b};switch(a.GetSourceAdapterId()){case"world-instance":{d.property=a.GetPropertyName();break}case"instance-variable":{const a=b.GetEditorIndex();d.name=c.GetInstanceVariableName(a),d.type=c.GetInstanceVariableType(a);break}case"effect":{const a=c.GetEffectList(),e=b.GetEffectType(a);d.effectType=e;break}case"behavior":{const a=b.GetBehaviorType(c);d.behaviorType=a;break}case"plugin":{d.plugin=c.GetPlugin();break}}yield d}}GetWorldInfo(){if(this._worldInfo&&this.IsInstanceValid())return this._worldInfo;const a=this.GetInstance();return a&&(this._worldInfo=a.GetWorldInfo()),this._worldInfo}GetTrackDataItem(){return this._trackDataItem}GetInstanceUID(){return this._instanceUid?this._instanceUid:this._trackDataItem.GetInstanceUID()}SetInstanceUID(a){this._trackDataItem.SetInstanceUID(a)}GetInterpolationMode(){return this._trackDataItem.GetInterpolationMode()}SetInterpolationMode(a){this._trackDataItem.SetInterpolationMode(a)}GetResultMode(){return this._trackDataItem.GetResultMode()}GetId(){return this._trackDataItem.GetId()}SetResultMode(a){this._trackDataItem.SetResultMode(a)}SetEase(a){for(const b of this.GetKeyframeDataItems())b.SetEase(a);for(const b of this.GetPropertyTracks())b.SetEase(a)}GetEnable(){return this._trackDataItem.GetEnable()}SetEnable(a){this._trackDataItem.SetEnable(a)}GetObjectClassIndex(){return isNaN(this._objectClassIndex)?this._trackDataItem.GetObjectClassIndex():this._objectClassIndex}SetObjectClassIndex(a){this._trackDataItem.SetObjectClassIndex(a)}SetInitialState(){if(this.MaybeGetInstance(),!!this.IsInstanceValid()){for(const a of this._propertyTracks)a.SetInitialState();const a=this.GetTimeline(),b=a.IsForwardPlayBack(),c=a.GetTotalTime(),d=b?0:c;this._lastKeyframeDataItem=this._trackData.GetKeyFrameDataItemAtTime(d,this._trackDataItem),this.Interpolate(d)}}SetResumeState(){if(this.MaybeGetInstance(),!!this.IsInstanceValid()){const a=this._timeline.IsForwardPlayBack(),b=this._timeline.GetTime();this._timeline.IsForwardPlayBack()?this._lastKeyframeDataItem=this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(b,this._trackDataItem):(this._lastKeyframeDataItem=this._trackData.GetFirstKeyFrameDataItemHigherOrEqualThan(b,this._trackDataItem),!this._lastKeyframeDataItem&&(this._lastKeyframeDataItem=this._trackData.GetLastKeyframeDataItem(this._trackDataItem)));for(const a of this._propertyTracks)a.SetResumeState()}}SetEndState(){if(!this.GetTimeline().IsComplete()&&(this.MaybeGetInstance(),!!this.IsInstanceValid())){const a=this._timeline.GetTime(),b=this._timeline.GetTotalTime();a>=b?this.Interpolate(b,!0):0>=a&&this.Interpolate(0,!0)}}Interpolate(a,b=!1,c=!1){if(this.MaybeGetInstance(),!this.IsInstanceValid())return!1;this._lastKeyframeDataItem=this.MaybeTriggerKeyframeReachedConditions(a,b);let d=!1,e=!1;for(const f of this._propertyTracks){const b=f.Interpolate(a,c);d||0==(b&C3.TimelineState.WORLD_INSTANCE_BOX_CHANGE)||(d=!0),e||0==(b&C3.TimelineState.LAYOUT_RENDER_CHANGE)||(e=!0)}if(d){const a=this.GetWorldInfo();a&&a.SetBboxChanged()}return e}MaybeTriggerKeyframeReachedConditions(a,b){if(!b)return;const c=this.GetTimeline();let d=this._trackData.GetKeyFrameDataItemAtTime(a,this._trackDataItem);return d?this.OnKeyframeReached(d):(d=c.IsForwardPlayBack()?this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(a,this._trackDataItem):this._trackData.GetFirstKeyFrameDataItemHigherOrEqualThan(a,this._trackDataItem),d!==this._lastKeyframeDataItem&&this.OnKeyframeReached(d)),d}OnKeyframeReached(a){if(C3.Plugins.Timeline&&this.GetTimeline().constructor===C3.TimelineState){const b=this.GetTimeline();C3.Plugins.Timeline.Cnds.SetTriggerTimeline(b),C3.Plugins.Timeline.Cnds.SetTriggerKeyframe(a);const c=b.GetTimelineManager();c.Trigger(C3.Plugins.Timeline.Cnds.OnAnyKeyframeReached),c.Trigger(C3.Plugins.Timeline.Cnds.OnKeyframeReached),C3.Plugins.Timeline.Cnds.SetTriggerTimeline(null),C3.Plugins.Timeline.Cnds.SetTriggerKeyframe(null)}}AddKeyframe(){const a=this._trackDataItem.GetKeyframeData(),b=a.AddEmptyKeyframeDataItem();return b}AddPropertyTrack(){const a=this._trackDataItem.GetPropertyTrackData(),b=a.AddEmptyPropertyTrackDataItem(),c=C3.PropertyTrackState.Create(this,b);return this._propertyTracks.push(c),c}DeleteKeyframes(a){const b=this._trackDataItem.GetKeyframeData();b.DeleteKeyframeDataItems(a)}DeletePropertyKeyframes(a){for(const b of this._propertyTracks)b.DeletePropertyKeyframes(a)}SaveState(){for(const a of this._propertyTracks)a.SaveState()}CompareInitialStateWithCurrent(){if(this.MaybeGetInstance(),!!this.IsInstanceValid())for(const a of this._propertyTracks)a.CompareInitialStateWithCurrent()}CompareSaveStateWithCurrent(){if(this.MaybeGetInstance(),!this.IsInstanceValid())return;let a=!1;for(const b of this._propertyTracks){const c=b.CompareSaveStateWithCurrent();!a&&c&&(a=!0)}if(a){const a=this.AddKeyframe();a.SetTime(this.GetTimeline().GetTime()),a.SetEase("noease"),a.SetEnable(!0),a.SetTags("")}}}; +"use strict";C3.TrackState=class extends C3.DefendedBase{constructor(a,b){super(),this._timeline=a,this._trackDataItem=b,this._trackData=b.GetTrackData(),this._instanceUid=NaN,this._objectClassIndex=NaN,this._instance=null,this._worldInfo=null,this._lastKeyframeDataItem=null,this._keyframeDataItems=this._trackDataItem.GetKeyframeData().GetKeyframeDataItemArray(),this._propertyTracks=[];for(const c of this._trackDataItem.GetPropertyTrackData().propertyTrackDataItems())this._propertyTracks.push(C3.PropertyTrackState.Create(this,c))}static Create(a,b){return C3.New(C3.TrackState,a,b)}Release(){this._keyframeDataItems=null;for(const a of this._propertyTracks)a.Release();C3.clearArray(this._propertyTracks),this._propertyTracks=null,this._timeline=null,this._instance=null,this._worldInfo=null,this._trackDataItem=null,this._lastKeyframeDataItem=null}CleanCaches(){for(const a of this._propertyTracks)a.CleanCaches();this._instance=null,this._worldInfo=null}GetTimeline(){return this._timeline}GetRuntime(){return this._timeline.GetRuntime()}GetKeyframeDataItems(){return this._keyframeDataItems?this._keyframeDataItems:(this._keyframeDataItems=this._trackDataItem.GetKeyframeData().GetKeyframeDataItemArray(),this._keyframeDataItems)}GetPropertyTracks(){return this._propertyTracks}GetPropertyTrack(a){for(const b of this._propertyTracks)if(b.GetPropertyName()===a)return b}MaybeGetInstance(){this._instance||this.GetInstance()}IsInstanceValid(){return!!this._instance&&!this._instance.IsDestroyed()}CanInstanceBeValid(){const a=this.GetInstanceUID(),b=this.GetRuntime().GetInstanceByUID(a);return!!b&&!b.IsDestroyed()}GetObjectClass(){const a=this.GetObjectClassIndex();return-1===a?void 0:this.GetRuntime().GetObjectClassByIndex(a)}ClearInstance(){this._instance=null,this._instanceUid=-1,this._worldInfo=null,this._objectClassIndex=-1}HasInstance(){return!!this._instance}GetInstance(){if(this._instance&&this.IsInstanceValid())return this._instance;const a=this.GetInstanceUID();return this._instance=this.GetRuntime().GetInstanceByUID(a),this._instance}SetInstance(a){if(this._instance!==a){this._instance=a,this._objectClassIndex=a.GetObjectClass().GetIndex(),this._instanceUid=a.GetUID(),this._worldInfo=a.GetWorldInfo();for(const a of this.propertyTrackItems()){const b=a.propertyTrack,c=a.sourceAdapter,d=b.GetSourceAdapterId();switch(d){case"instance-variable":{const b=c.GetEditorIndex(),d=inst.GetObjectClass(),e=d.GetInstanceVariableIndexByName(a.name),f=d.GetInstanceVariableName(e),g=d.GetInstanceVariableType(e);f===a.name&&g===a.type&&c.UpdateInstanceVariableIndex(e);break}case"behavior":{const b=a.behaviorType,d=this.GetObjectClass(),e=inst.GetObjectClass(),f=c.GetBehaviorType(e);if(b&&f){const a=b.GetName(),g=d.GetBehaviorIndexByName(a),h=e.GetBehaviorIndexByName(a),i=c.GetEditorIndex();c.UpdateBehaviorTypeSid(f.GetSID())}break}}}}}*propertyTrackItems(){for(const a of this._propertyTracks){const b=a.GetSourceAdapter(),c=this.GetObjectClass(),d={propertyTrack:a,sourceAdapter:b};switch(a.GetSourceAdapterId()){case"world-instance":{d.property=a.GetPropertyName();break}case"instance-variable":{const a=b.GetEditorIndex();d.name=c.GetInstanceVariableName(a),d.type=c.GetInstanceVariableType(a);break}case"effect":{const a=c.GetEffectList(),e=b.GetEffectType(a);d.effectType=e;break}case"behavior":{const a=b.GetBehaviorType(c);d.behaviorType=a;break}case"plugin":{d.plugin=c.GetPlugin();break}}yield d}}GetWorldInfo(){if(this._worldInfo&&this.IsInstanceValid())return this._worldInfo;const a=this.GetInstance();return a&&(this._worldInfo=a.GetWorldInfo()),this._worldInfo}GetTrackDataItem(){return this._trackDataItem}GetInstanceUID(){return this._instanceUid?this._instanceUid:this._trackDataItem.GetInstanceUID()}SetInstanceUID(a){this._trackDataItem.SetInstanceUID(a)}GetInterpolationMode(){return this._trackDataItem.GetInterpolationMode()}SetInterpolationMode(a){this._trackDataItem.SetInterpolationMode(a)}GetResultMode(){return this._trackDataItem.GetResultMode()}GetId(){return this._trackDataItem.GetId()}SetResultMode(a){this._trackDataItem.SetResultMode(a)}SetEase(a){for(const b of this.GetKeyframeDataItems())b.SetEase(a);for(const b of this.GetPropertyTracks())b.SetEase(a)}GetEnable(){return this._trackDataItem.GetEnable()}SetEnable(a){this._trackDataItem.SetEnable(a)}GetObjectClassIndex(){return isNaN(this._objectClassIndex)?this._trackDataItem.GetObjectClassIndex():this._objectClassIndex}SetObjectClassIndex(a){this._trackDataItem.SetObjectClassIndex(a)}SetInitialState(){if(this.MaybeGetInstance(),!!this.IsInstanceValid()){for(const a of this._propertyTracks)a.SetInitialState();const a=this.GetTimeline(),b=a.IsForwardPlayBack(),c=a.GetTotalTime(),d=b?0:c;this._lastKeyframeDataItem=this._trackData.GetKeyFrameDataItemAtTime(d,this._trackDataItem),this.Interpolate(d)}}SetResumeState(){if(this.MaybeGetInstance(),!!this.IsInstanceValid()){const a=this._timeline.IsForwardPlayBack(),b=this._timeline.GetTime();this._timeline.IsForwardPlayBack()?this._lastKeyframeDataItem=this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(b,this._trackDataItem):(this._lastKeyframeDataItem=this._trackData.GetFirstKeyFrameDataItemHigherOrEqualThan(b,this._trackDataItem),!this._lastKeyframeDataItem&&(this._lastKeyframeDataItem=this._trackData.GetLastKeyframeDataItem(this._trackDataItem)));for(const a of this._propertyTracks)a.SetResumeState()}}SetEndState(){if(!this.GetTimeline().IsComplete()&&(this.MaybeGetInstance(),!!this.IsInstanceValid())){const a=this._timeline.GetTime(),b=this._timeline.GetTotalTime();a>=b?this.Interpolate(b,!0):0>=a&&this.Interpolate(0,!0)}}Interpolate(a,b=!1,c=!1){if(this.MaybeGetInstance(),!this.IsInstanceValid())return!1;this._lastKeyframeDataItem=this.MaybeTriggerKeyframeReachedConditions(a,b);let d=!1,e=!1;for(const f of this._propertyTracks){const b=f.Interpolate(a,c);d||0==(b&C3.TimelineState.WORLD_INSTANCE_BOX_CHANGE)||(d=!0),e||0==(b&C3.TimelineState.LAYOUT_RENDER_CHANGE)||(e=!0)}if(d){const a=this.GetWorldInfo();a&&a.SetBboxChanged()}return e}MaybeTriggerKeyframeReachedConditions(a,b){if(!b)return;const c=this.GetTimeline();let d=this._trackData.GetKeyFrameDataItemAtTime(a,this._trackDataItem);return d?this.OnKeyframeReached(d):(d=c.IsForwardPlayBack()?this._trackData.GetFirstKeyFrameDataItemLowerOrEqualThan(a,this._trackDataItem):this._trackData.GetFirstKeyFrameDataItemHigherOrEqualThan(a,this._trackDataItem),d!==this._lastKeyframeDataItem&&this.OnKeyframeReached(d)),d}OnKeyframeReached(a){if(C3.Plugins.Timeline&&this.GetTimeline().constructor===C3.TimelineState){const b=this.GetTimeline();C3.Plugins.Timeline.Cnds.SetTriggerTimeline(b),C3.Plugins.Timeline.Cnds.SetTriggerKeyframe(a);const c=b.GetTimelineManager();c.Trigger(C3.Plugins.Timeline.Cnds.OnAnyKeyframeReached),c.Trigger(C3.Plugins.Timeline.Cnds.OnKeyframeReached),C3.Plugins.Timeline.Cnds.SetTriggerTimeline(null),C3.Plugins.Timeline.Cnds.SetTriggerKeyframe(null)}}AddKeyframe(){const a=this._trackDataItem.GetKeyframeData(),b=a.AddEmptyKeyframeDataItem();return b}AddPropertyTrack(){const a=this._trackDataItem.GetPropertyTrackData(),b=a.AddEmptyPropertyTrackDataItem(),c=C3.PropertyTrackState.Create(this,b);return this._propertyTracks.push(c),c}DeleteKeyframes(a){const b=this._trackDataItem.GetKeyframeData();b.DeleteKeyframeDataItems(a)}DeletePropertyKeyframes(a){for(const b of this._propertyTracks)b.DeletePropertyKeyframes(a)}SaveState(){for(const a of this._propertyTracks)a.SaveState()}CompareInitialStateWithCurrent(){if(this.MaybeGetInstance(),!!this.IsInstanceValid())for(const a of this._propertyTracks)a.CompareInitialStateWithCurrent()}CompareSaveStateWithCurrent(){if(this.MaybeGetInstance(),!this.IsInstanceValid())return;let a=!1;for(const b of this._propertyTracks){const c=b.CompareSaveStateWithCurrent();!a&&c&&(a=!0)}if(a){const a=this.AddKeyframe();a.SetTime(this.GetTimeline().GetTime()),a.SetEase("noease"),a.SetEnable(!0),a.SetTags("")}}}; // c3/timelines/state/propertyTrackState.js -"use strict";C3.PropertyTrackState=class extends C3.DefendedBase{constructor(a,b){super(),this._track=a,this._propertyTrackDataItem=b,this._propertyTrackData=b.GetPropertyTrackData(),this._sourceAdapter=this.GetSourceAdapter(),this._propertyKeyframeDataItems=this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray()}static Create(a,b){return C3.New(C3.PropertyTrackState,a,b)}Release(){this._track=null,this._sourceAdapter&&(this._sourceAdapter.Release(),this._sourceAdapter=null),this._propertyKeyframeDataItems=null,this._propertyTrackDataItem=null,this._propertyTrackData=null}GetTrack(){return this._track}GetPropertyTrackDataItem(){return this._propertyTrackDataItem}GetPropertyTrackData(){return this._propertyTrackData}GetTimeline(){return this._track.GetTimeline()}GetRuntime(){return this._track.GetRuntime()}GetSourceAdapter(){if(this._sourceAdapter)return this._sourceAdapter;const a=this._propertyTrackDataItem.GetSourceAdapterId();let b;return"behavior"===a?b=new C3.PropertyTrackState.BehaviorSourceAdapter(this):"effect"===a?b=new C3.PropertyTrackState.EffectSourceAdapter(this):"instance-variable"===a?b=new C3.PropertyTrackState.InstanceVariableSourceAdapter(this):"plugin"===a?b=new C3.PropertyTrackState.PluginSourceAdapter(this):"world-instance"===a?b=new C3.PropertyTrackState.WorldInstanceSourceAdapter(this):"value"===a?b=new C3.PropertyTrackState.ValueSourceAdapter(this):void 0,this._sourceAdapter=b,this._sourceAdapter}GetSourceAdapterId(){return this._propertyTrackDataItem.GetSourceAdapterId()}SetSourceAdapterId(a){this._propertyTrackDataItem.SetSourceAdapterId(a)}GetSourceAdapterArgs(){return this._propertyTrackDataItem.GetSourceAdapterArguments()}SetSourceAdapterArgs(a){this._propertyTrackDataItem.SetSourceAdapterArguments(a)}GetSourceAdapterValue(){return this.GetSourceAdapter().GetValue()}GetPropertyName(){return this._propertyTrackDataItem.GetProperty()}SetPropertyName(a){this._propertyTrackDataItem.SetProperty(a)}GetPropertyType(){return this._propertyTrackDataItem.GetType()}SetPropertyType(a){this._propertyTrackDataItem.SetType(a)}GetPropertyKeyframeType(){return this.GetPropertyTrackData().GetFirstPropertyKeyframeDataItem(this._propertyTrackDataItem).GetType()}GetMin(){return this._propertyTrackDataItem.GetMin()}SetMin(a){this._propertyTrackDataItem.SetMin(a)}GetMax(){return this._propertyTrackDataItem.GetMax()}SetMax(a){this._propertyTrackDataItem.SetMax(a)}GetEnable(){return this._propertyTrackDataItem.GetEnable()}SetEnable(a){this._propertyTrackDataItem.SetEnable(a)}GetInterpolationMode(){return this._propertyTrackDataItem.GetInterpolationMode()}SetInterpolationMode(a){this._propertyTrackDataItem.SetInterpolationMode(a)}GetResultMode(){return this._propertyTrackDataItem.GetResultMode()}SetResultMode(a){this._propertyTrackDataItem.SetResultMode(a)}SetEase(a){for(const b of this.GetPropertyKeyframeDataItems())b.SetEase(a)}GetPropertyKeyframeDataItems(){return this._propertyKeyframeDataItems?this._propertyKeyframeDataItems:(this._propertyKeyframeDataItems=this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray(),this._propertyKeyframeDataItems)}CleanCaches(){this.GetSourceAdapter().CleanCaches()}SetInitialState(){this.GetSourceAdapter().SetInitialState()}SetResumeState(){this.GetSourceAdapter().SetResumeState()}Interpolate(a,b=!1){const c=this._propertyTrackDataItem;let d,e=this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(a,c);return e?d=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherThan(a,c):(e=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(a,c),d=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(a,c)),this.GetSourceAdapter().Interpolate(a,e,d,b)}static GetStartPropertyKeyframeForTime(a,b){const c=b.GetPropertyTrackDataItem(),d=b._propertyTrackData;let e=d.GetPropertyKeyFrameDataItemAtTime(a,c);return e||(e=d.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(a,c)),e}static GetEndPropertyKeyframeForTime(a,b){const c=b.GetPropertyTrackDataItem(),d=b._propertyTrackData;let e=d.GetPropertyKeyFrameDataItemAtTime(a,c);return e?d.GetFirstPropertyKeyFrameDataItemHigherThan(a,c):d.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(a,c)}AddPropertyKeyframe(){const a=this._propertyTrackDataItem.GetPropertyKeyframeData(),b=a.AddEmptyPropertyKeyframeDataItem();return b}DeletePropertyKeyframes(a){const b=this._propertyTrackDataItem.GetPropertyKeyframeData();b.DeletePropertyKeyframeDataItems(a)}SaveState(){this.GetSourceAdapter().SaveState()}CompareInitialStateWithCurrent(){const a=this.GetSourceAdapter().CompareInitialStateWithCurrent();if(a){const a=this._propertyTrackData.GetFirstPropertyKeyframeDataItem(this._propertyTrackDataItem),b=this.GetSourceAdapter().GetCurrentState();a.SetAbsoluteValue(b)}}CompareSaveStateWithCurrent(){const a=this.GetSourceAdapter().CompareSaveStateWithCurrent();return a&&this.AddPropertyKeyframeAtCurrentTime(),this.GetSourceAdapter().ClearSaveState(),a}AddPropertyKeyframeAtCurrentTime(){const a=this.GetTimeline().GetTime(),b=this.GetSourceAdapter(),c=C3.PropertyTrackState.GetStartPropertyKeyframeForTime(a,this),d=this.AddPropertyKeyframe();d.SetType(c.GetType()),d.SetTime(a),d.SetEase(c.GetEase()),d.SetEnable(!0),d.SetValue(b.GetValueAtTime()),d.SetAbsoluteValue(b.GetCurrentState())}}; +"use strict";C3.PropertyTrackState=class extends C3.DefendedBase{constructor(a,b){super(),this._track=a,this._propertyTrackDataItem=b,this._propertyTrackData=b.GetPropertyTrackData(),this._sourceAdapter=this.GetSourceAdapter(),this._propertyKeyframeDataItems=this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray()}static Create(a,b){return C3.New(C3.PropertyTrackState,a,b)}Release(){this._track=null,this._sourceAdapter&&(this._sourceAdapter.Release(),this._sourceAdapter=null),this._propertyKeyframeDataItems=null,this._propertyTrackDataItem=null,this._propertyTrackData=null}GetTrack(){return this._track}GetPropertyTrackDataItem(){return this._propertyTrackDataItem}GetPropertyTrackData(){return this._propertyTrackData}GetTimeline(){return this._track.GetTimeline()}GetRuntime(){return this._track.GetRuntime()}GetSourceAdapter(){if(this._sourceAdapter)return this._sourceAdapter;const a=this._propertyTrackDataItem.GetSourceAdapterId();let b;return"behavior"===a?b=new C3.PropertyTrackState.BehaviorSourceAdapter(this):"effect"===a?b=new C3.PropertyTrackState.EffectSourceAdapter(this):"instance-variable"===a?b=new C3.PropertyTrackState.InstanceVariableSourceAdapter(this):"plugin"===a?b=new C3.PropertyTrackState.PluginSourceAdapter(this):"world-instance"===a?b=new C3.PropertyTrackState.WorldInstanceSourceAdapter(this):"value"===a?b=new C3.PropertyTrackState.ValueSourceAdapter(this):void 0,this._sourceAdapter=b,this._sourceAdapter}GetSourceAdapterId(){return this._propertyTrackDataItem.GetSourceAdapterId()}SetSourceAdapterId(a){this._propertyTrackDataItem.SetSourceAdapterId(a)}GetSourceAdapterArgs(){return this._propertyTrackDataItem.GetSourceAdapterArguments()}SetSourceAdapterArgs(a){this._propertyTrackDataItem.SetSourceAdapterArguments(a)}GetSourceAdapterValue(){return this.GetSourceAdapter().GetValue()}GetPropertyName(){return this._propertyTrackDataItem.GetProperty()}SetPropertyName(a){this._propertyTrackDataItem.SetProperty(a)}GetPropertyType(){return this._propertyTrackDataItem.GetType()}SetPropertyType(a){this._propertyTrackDataItem.SetType(a)}GetPropertyKeyframeType(){return this.GetPropertyTrackData().GetFirstPropertyKeyframeDataItem(this._propertyTrackDataItem).GetType()}GetMin(){return this._propertyTrackDataItem.GetMin()}SetMin(a){this._propertyTrackDataItem.SetMin(a)}GetMax(){return this._propertyTrackDataItem.GetMax()}SetMax(a){this._propertyTrackDataItem.SetMax(a)}GetEnable(){return this._propertyTrackDataItem.GetEnable()}SetEnable(a){this._propertyTrackDataItem.SetEnable(a)}GetInterpolationMode(){return this._propertyTrackDataItem.GetInterpolationMode()}SetInterpolationMode(a){this._propertyTrackDataItem.SetInterpolationMode(a)}GetResultMode(){return this._propertyTrackDataItem.GetResultMode()}SetResultMode(a){this._propertyTrackDataItem.SetResultMode(a)}SetEase(a){for(const b of this.GetPropertyKeyframeDataItems())b.SetEase(a)}GetPropertyKeyframeDataItems(){return this._propertyKeyframeDataItems?this._propertyKeyframeDataItems:(this._propertyKeyframeDataItems=this._propertyTrackDataItem.GetPropertyKeyframeData().GetPropertyKeyframeDataItemArray(),this._propertyKeyframeDataItems)}*GetPropertyKeyframeValues(){for(const a of this.GetPropertyKeyframeDataItems())yield a.GetValueWithResultMode()}CleanCaches(){this.GetSourceAdapter().CleanCaches()}SetInitialState(){this.GetSourceAdapter().SetInitialState()}SetResumeState(){this.GetSourceAdapter().SetResumeState()}Interpolate(a,b=!1){const c=this._propertyTrackDataItem;let d,e=this._propertyTrackData.GetPropertyKeyFrameDataItemAtTime(a,c);return e?d=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherThan(a,c):(e=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(a,c),d=this._propertyTrackData.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(a,c)),this.GetSourceAdapter().Interpolate(a,e,d,b)}static GetStartPropertyKeyframeForTime(a,b){const c=b.GetPropertyTrackDataItem(),d=b._propertyTrackData;let e=d.GetPropertyKeyFrameDataItemAtTime(a,c);return e||(e=d.GetFirstPropertyKeyFrameDataItemLowerOrEqualThan(a,c)),e}static GetEndPropertyKeyframeForTime(a,b){const c=b.GetPropertyTrackDataItem(),d=b._propertyTrackData;let e=d.GetPropertyKeyFrameDataItemAtTime(a,c);return e?d.GetFirstPropertyKeyFrameDataItemHigherThan(a,c):d.GetFirstPropertyKeyFrameDataItemHigherOrEqualThan(a,c)}AddPropertyKeyframe(){const a=this._propertyTrackDataItem.GetPropertyKeyframeData(),b=a.AddEmptyPropertyKeyframeDataItem();return b}DeletePropertyKeyframes(a){const b=this._propertyTrackDataItem.GetPropertyKeyframeData();b.DeletePropertyKeyframeDataItems(a)}SaveState(){this.GetSourceAdapter().SaveState()}CompareInitialStateWithCurrent(){const a=this.GetSourceAdapter().CompareInitialStateWithCurrent();if(a){const a=this._propertyTrackData.GetFirstPropertyKeyframeDataItem(this._propertyTrackDataItem),b=this.GetSourceAdapter().GetCurrentState();a.SetAbsoluteValue(b)}}CompareSaveStateWithCurrent(){const a=this.GetSourceAdapter().CompareSaveStateWithCurrent();return a&&this.AddPropertyKeyframeAtCurrentTime(),this.GetSourceAdapter().ClearSaveState(),a}AddPropertyKeyframeAtCurrentTime(){const a=this.GetTimeline().GetTime(),b=this.GetSourceAdapter(),c=C3.PropertyTrackState.GetStartPropertyKeyframeForTime(a,this),d=this.AddPropertyKeyframe();d.SetType(c.GetType()),d.SetTime(a),d.SetEase(c.GetEase()),d.SetEnable(!0),d.SetValue(b.GetValueAtTime()),d.SetAbsoluteValue(b.GetCurrentState())}}; // c3/timelines/state/propertySourceAdapters/propertySourceAdapter.js "use strict";{const a=C3.PropertyTrackState;a.PropertySourceAdapter=class{constructor(a){this._propertyTrack=a,this._propertyAdapter=null}Release(){this._propertyAdapter&&(this._propertyAdapter.Release(),this._propertyAdapter=null),this._propertyTrack=null}GetPropertyTrack(){return this._propertyTrack}CleanCaches(){this._propertyAdapter&&this._propertyAdapter.CleanCaches()}GetPropertyAdapter(){return this._propertyAdapter?this._propertyAdapter:(this._propertyAdapter=this._CreatePropertyAdapter(),this._propertyAdapter)}GetEditorIndex(){}GetIndex(){return this.GetEditorIndex()}GetTarget(){}SetInitialState(){this.GetPropertyAdapter().SetInitialState()}SetResumeState(){this.GetPropertyAdapter().SetResumeState()}Interpolate(b,c,d,e){const f=a.PropertySourceAdapter.GetInterpolateFunc(this._propertyTrack),g=f(b,c,d,this._propertyTrack);return this.GetPropertyAdapter().ChangeProperty(b,g,c,d,e)}SaveState(){this.GetPropertyAdapter().SetSaveState()}ClearSaveState(){this.GetPropertyAdapter().ClearSaveState()}GetCurrentState(){return this.GetPropertyAdapter().GetCurrentState()}CompareInitialStateWithCurrent(){return this.GetPropertyAdapter().CompareInitialStateWithCurrent()}CompareSaveStateWithCurrent(){return this.GetPropertyAdapter().CompareSaveStateWithCurrent()}GetValueAtTime(){return a.PropertySourceAdapter.GetValueAtTime(this._propertyTrack)}_CreatePropertyAdapter(){const b=this._propertyTrack.GetPropertyType(),c=this._propertyTrack.GetPropertyKeyframeType();return"combo"===c||"boolean"===c||"text"===c||"string"===c?new a.PropertyInterpolationAdapter.NoInterpolationAdapter(this):"numeric"===c||"number"===c||"angle"===c?"combo"===b?new a.PropertyInterpolationAdapter.NoInterpolationAdapter(this):new a.PropertyInterpolationAdapter.NumericInterpolationAdapter(this):"color"===c||"offsetColor"===c?new a.PropertyInterpolationAdapter.ColorInterpolationAdapter(this):void 0}static GetValueAtTime(b){const c=b.GetTrack(),d=c.GetTimeline().GetTime(),e=a.GetStartPropertyKeyframeForTime(d,b),f=a.GetEndPropertyKeyframeForTime(d,b),g=a.PropertySourceAdapter.GetInterpolateFunc(b);return g(d,e,f,b)}static GetValue(a,b,c){let d=a.GetResultMode();return"combo"===a.GetPropertyType()&&(d="absolute"),"relative"===d?b+c:"absolute"===d?c:void 0}static GetInterpolateFunc(b){const c=b.GetPropertyKeyframeType();return"numeric"===c?a.NumericTypeAdapter.Interpolate:"angle"===c?a.AngleTypeAdapter.Interpolate:"boolean"===c?a.BooleanTypeAdapter.Interpolate:"color"===c?a.ColorTypeAdapter.Interpolate:"text"===c?a.TextTypeAdapter.Interpolate:void 0}static GetWillChangeFunc(b){const c=b.GetPropertyKeyframeType();return"numeric"===c?a.NumericTypeAdapter.WillChange:"angle"===c?a.AngleTypeAdapter.WillChange:"boolean"===c?a.BooleanTypeAdapter.WillChange:"color"===c?a.ColorTypeAdapter.WillChange:"text"===c?a.TextTypeAdapter.WillChange:void 0}}} @@ -211,7 +214,7 @@ "use strict";{class a extends C3.PropertyTrackState.PropertyInterpolationAdapter{constructor(a){super(a)}SetInitialState(){}SetResumeState(){}GetCurrentState(){return this._Getter()}CompareInitialStateWithCurrent(){const a=this._FirstKeyframeGetter();return a!==this.GetCurrentState()}CompareSaveStateWithCurrent(){return!C3.IsNullOrUndefined(this._saveState)&&this._saveState!==this.GetCurrentState()}ChangeProperty(a,b){const c=C3.PropertyTrackState.PropertySourceAdapter.GetWillChangeFunc(this._propertyTrack),d=this._propertyTrack.GetSourceAdapterId(),e=c(this._GetIndex(),this._GetTarget(),b,d);if(e)return this._Setter(b),"behavior"===d||"effect"===d||"instance-variable"===d?void 0:"plugin"===d?C3.TimelineState.LAYOUT_RENDER_CHANGE:void 0}_Getter(){const a=this._propertyTrack.GetSourceAdapterId(),b=this._GetTarget(),c=this._GetIndex();switch(a){case"behavior":return b.GetPropertyValueByIndex(c);case"effect":return b[c];case"instance-variable":return b.GetInstanceVariableValue(c);case"plugin":return b.GetPropertyValueByIndex(c);;}}_Setter(a){const b=this._propertyTrack.GetSourceAdapterId(),c=this._GetTarget(),d=this._GetIndex();"behavior"===b?c.SetPropertyValueByIndex(d,a):"effect"===b?c[d]=a:"instance-variable"===b?c.SetInstanceVariableValue(d,a):"plugin"===b?c.SetPropertyValueByIndex(d,a):void 0}}C3.PropertyTrackState.PropertyInterpolationAdapter.NoInterpolationAdapter=a} // c3/timelines/state/propertyInterpolationAdapters/numericInterpolationAdapter.js -"use strict";{const a=new Map,b=(b,c,d)=>a.set(b,{setter:c,getter:d});b("offsetX",(a,b)=>a.OffsetX(b),(a)=>a.GetX()),b("offsetY",(a,b)=>a.OffsetY(b),(a)=>a.GetY()),b("offsetWidth",(a,b)=>a.OffsetWidth(b),(a)=>a.GetWidth()),b("offsetHeight",(a,b)=>a.OffsetHeight(b),(a)=>a.GetHeight()),b("offsetAngle",(a,b)=>a.OffsetAngle(b),(a)=>a.GetAngle()),b("offsetOpacity",(a,b)=>a.OffsetOpacity(b),(a)=>a.GetOpacity()),b("offsetOriginX",(a,b)=>a.OffsetOriginX(b),(a)=>a.GetOriginX()),b("offsetOriginY",(a,b)=>a.OffsetOriginY(b),(a)=>a.GetOriginY()),b("offsetZElevation",(a,b)=>a.OffsetZElevation(b),(a)=>a.GetZElevation());class c extends C3.PropertyTrackState.PropertyInterpolationAdapter{constructor(b){super(b),this._lastValue=0,this._instance_getter=null,this._instance_setter=null;const c=this._propertyTrack.GetPropertyName();"world-instance"===this._propertyTrack.GetSourceAdapterId()&&(this._instance_getter=a.get(c).getter,this._instance_setter=a.get(c).setter)}Release(){this._instance_getter=null,this._instance_setter=null,super.Release()}SetInitialState(){this._lastValue=this._PickResultMode(()=>this._PickTimelinePlaybackMode(()=>0,()=>C3.PropertyTrackState.PropertySourceAdapter.GetValueAtTime(this._propertyTrack)),()=>(this.SetFirstAbsoluteUpdate(!0),this._GetAbsoluteInitialValue(this._FirstKeyframeGetter())))}SetResumeState(){this._FirstKeyframeGetter()===this._CurrentKeyframeGetter()||this._PickResultMode(()=>{},()=>{this.SetFirstAbsoluteUpdate(!0),this._lastValue=this._GetAbsoluteInitialValue(this._CurrentKeyframeGetter())})}GetCurrentState(){return this._Getter()}CompareInitialStateWithCurrent(){const a=this._FirstKeyframeGetter();return a!==this.GetCurrentState()}CompareSaveStateWithCurrent(){return!C3.IsNullOrUndefined(this._saveState)&&this._saveState!==this.GetCurrentState()}_GetAbsoluteInitialValue(a){return a-this.GetCurrentState()}ChangeProperty(a,b,c,d,e){return this._PickResultMode(()=>{this._Setter(b-this._lastValue,c,d),this._MaybeEnsureValue(a,c,d,e,this._lastValue,b)},()=>{this._PickFirstAbsoluteUpdate(()=>{this._Setter(this._lastValue,c,d)},()=>{this._Setter(b-this._lastValue,c,d),this._MaybeEnsureValue(a,c,d,e,this._lastValue,b)})}),this._lastValue=b,this._PickSource(()=>{},()=>C3.TimelineState.LAYOUT_RENDER_CHANGE,()=>{},()=>C3.TimelineState.LAYOUT_RENDER_CHANGE,()=>C3.TimelineState.LAYOUT_RENDER_CHANGE)}_Getter(){const a=this._GetTarget(),b=this._GetIndex();return this._PickSource(()=>a.GetPropertyValueByIndex(b),()=>a[b],()=>a.GetInstanceVariableValue(b),()=>a.GetPropertyValueByIndex(b),()=>this._instance_getter(this.GetWorldInfo()))}_Setter(a){const b=this._GetTarget(),c=this._GetIndex();this._PickSource(()=>b.SetPropertyOffsetValueByIndex(c,a),()=>b[c]+=a,()=>b.SetInstanceVariableOffset(c,a),()=>b.SetPropertyOffsetValueByIndex(c,a),()=>this._instance_setter(this.GetWorldInfo(),a))}_MaybeEnsureValue(a,b,c,d,e,f){d?b&&a===b.GetTime()?this._AddDelta(b.GetValueWithResultMode(),b,c):c&&a===c.GetTime()?this._AddDelta(c.GetValueWithResultMode(),b,c):!c&&this._AddDelta(b.GetValueWithResultMode(),b,c):b&&a===b.GetTime()?this._AddDelta(b.GetValueWithResultMode(),b,c):c&&a===c.GetTime()?this._AddDelta(c.GetValueWithResultMode(),b,c):0==f-e&&this._AddDelta(b.GetValueWithResultMode(),b,c)}_AddDelta(a,b,c){const d=a.toString(),e=d.split(".")[1]||"",f=e.length,g=this._Getter();let h;h=0===f?Math.round(g):C3.toFixed(g,f),this._Setter(h-g,b,c)}}C3.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapter=c} +"use strict";{const a=new Map,b=(b,c,d)=>a.set(b,{setter:c,getter:d});b("offsetX",(a,b)=>a.OffsetX(b),(a)=>a.GetX()),b("offsetY",(a,b)=>a.OffsetY(b),(a)=>a.GetY()),b("offsetWidth",(a,b)=>a.OffsetWidth(b),(a)=>a.GetWidth()),b("offsetHeight",(a,b)=>a.OffsetHeight(b),(a)=>a.GetHeight()),b("offsetAngle",(a,b)=>a.OffsetAngle(b),(a)=>a.GetAngle()),b("offsetOpacity",(a,b)=>a.OffsetOpacity(b),(a)=>a.GetOpacity()),b("offsetOriginX",(a,b)=>a.OffsetOriginX(b),(a)=>a.GetOriginX()),b("offsetOriginY",(a,b)=>a.OffsetOriginY(b),(a)=>a.GetOriginY()),b("offsetZElevation",(a,b)=>a.OffsetZElevation(b),(a)=>a.GetZElevation());class c extends C3.PropertyTrackState.PropertyInterpolationAdapter{constructor(b){super(b),this._lastValue=0,this._instance_getter=null,this._instance_setter=null;const c=this._propertyTrack.GetPropertyName();"world-instance"===this._propertyTrack.GetSourceAdapterId()&&(this._instance_getter=a.get(c).getter,this._instance_setter=a.get(c).setter)}Release(){this._instance_getter=null,this._instance_setter=null,super.Release()}SetInitialState(){this._lastValue=this._PickResultMode(()=>this._PickTimelinePlaybackMode(()=>0,()=>C3.PropertyTrackState.PropertySourceAdapter.GetValueAtTime(this._propertyTrack)),()=>(this.SetFirstAbsoluteUpdate(!0),this._GetAbsoluteInitialValue(this._FirstKeyframeGetter())))}SetResumeState(){this._FirstKeyframeGetter()===this._CurrentKeyframeGetter()||this._PickResultMode(()=>{},()=>{this.SetFirstAbsoluteUpdate(!0),this._lastValue=this._GetAbsoluteInitialValue(this._CurrentKeyframeGetter())})}GetCurrentState(){return this._Getter()}CompareInitialStateWithCurrent(){const a=this._FirstKeyframeGetter();return a!==this.GetCurrentState()}CompareSaveStateWithCurrent(){return!C3.IsNullOrUndefined(this._saveState)&&this._saveState!==this.GetCurrentState()}_GetAbsoluteInitialValue(a){return a-this.GetCurrentState()}ChangeProperty(a,b,c,d,e){return this._PickResultMode(()=>{this._Setter(b-this._lastValue,c,d),this._MaybeEnsureValue(a,c,d,e,this._lastValue,b)},()=>{this._PickFirstAbsoluteUpdate(()=>{this._Setter(this._lastValue,c,d)},()=>{this._Setter(b-this._lastValue,c,d),this._MaybeEnsureValue(a,c,d,e,this._lastValue,b)})}),this._lastValue=b,this._PickSource(()=>{},()=>C3.TimelineState.LAYOUT_RENDER_CHANGE,()=>{},()=>C3.TimelineState.LAYOUT_RENDER_CHANGE,()=>C3.TimelineState.LAYOUT_RENDER_CHANGE)}_Getter(){const a=this._GetTarget(),b=this._GetIndex();return this._PickSource(()=>a.GetPropertyValueByIndex(b),()=>a[b],()=>a.GetInstanceVariableValue(b),()=>a.GetPropertyValueByIndex(b),()=>this._instance_getter(this.GetWorldInfo()))}_Setter(a){const b=this._GetTarget(),c=this._GetIndex();this._PickSource(()=>b.OffsetPropertyValueByIndex(c,a),()=>b[c]+=a,()=>b.SetInstanceVariableOffset(c,a),()=>b.OffsetPropertyValueByIndex(c,a),()=>this._instance_setter(this.GetWorldInfo(),a))}_MaybeEnsureValue(a,b,c,d,e,f){d?b&&a===b.GetTime()?this._AddDelta(b.GetValueWithResultMode(),b,c):c&&a===c.GetTime()?this._AddDelta(c.GetValueWithResultMode(),b,c):!c&&this._AddDelta(b.GetValueWithResultMode(),b,c):b&&a===b.GetTime()?this._AddDelta(b.GetValueWithResultMode(),b,c):c&&a===c.GetTime()?this._AddDelta(c.GetValueWithResultMode(),b,c):0==f-e&&this._AddDelta(b.GetValueWithResultMode(),b,c)}_AddDelta(a,b,c){const d=a.toString(),e=d.split(".")[1]||"",f=e.length,g=this._Getter();let h;if(0===f){const a=this._propertyTrack.GetPropertyName();h="offsetAngle"===a?g:Math.round(g)}else h=C3.toFixed(g,f);this._Setter(h-g,b,c)}}C3.PropertyTrackState.PropertyInterpolationAdapter.NumericInterpolationAdapter=c} // c3/timelines/state/propertyTypeAdapters/numericTypeAdapter.js "use strict";C3.PropertyTrackState.NumericTypeAdapter=class{constructor(){}static WillChange(a,b,c,d){let e;return"behavior"===d?e=b.GetPropertyValueByIndex(a):"effect"===d?e=b[a]:"instance-variable"===d?e=b.GetInstanceVariableValue(a):"plugin"===d?e=b.GetPropertyValueByIndex(a):void 0,e!==c}static Interpolate(a,b,c,d){var f=Math.floor;if(!c){let a=d.GetPropertyTrackDataItem();const b=d.GetPropertyTrackData();return a=b.GetLastPropertyKeyframeDataItem(a),a.GetValueWithResultMode()}let g=d.GetInterpolationMode();if("default"===g&&(g="continuous"),"combo"===d.GetPropertyType()&&(g="discrete"),"discrete"===g)return b.GetValueWithResultMode();if("continuous"===g||"step"===g){if("step"===g){const b=d.GetTimeline().GetStep();if(0!==b){const c=1/b;a=f(a*c)/c}}const h=b.GetTime(),i=c.GetTime(),j=b.GetValueWithResultMode(),k=c.GetValueWithResultMode();if(j===k)return j;const l=C3.normalize(a,h,i),m=b.GetEase();let e;const n=b.GetAddOn("cubic-bezier"),o=c.GetAddOn("cubic-bezier");if(n&&n.GetStartEnable()&&o&&o.GetEndEnable()){const a=i-h;e=Ease.GetEase(m)(a*l,0,1,a),e=Ease.GetEase("cubicbezier")(e,j,j+n.GetStartAnchor(),k+o.GetEndAnchor(),k)}else e=Ease.GetEase(m)((i-h)*l,j,k-j,i-h);return"integer"===d.GetPropertyType()?f(e):e}}}; @@ -292,10 +295,10 @@ "use strict";C3.EventSheet=class extends C3.DefendedBase{constructor(a,b){super(),this._eventSheetManager=a,this._runtime=a.GetRuntime(),this._name=b[0],this._events=[],this._triggers=new Map,this._fastTriggers=new Map,this._eventsByDisplayNumber=new Map,this._hasRun=!1,this._shallowIncludes=[],this._deepIncludes=[],this._alreadyIncludedSheets=new Set;for(const c of b[1])this._CreateEvent(c,null,this._events);this._perfRecord=this._runtime.IsDebug()?{type:"sheet",name:this._name,totalTimeCounter:0,children:[]}:null}Release(){this._eventSheetManager=null,this._runtime=null}_CreateEvent(a,b,c){switch(a[0]){case 0:case 3:this._CreateEventBlock(a,b,c);break;case 1:this._CreateEventVariable(a,b,c);break;case 2:this._CreateInclude(a,b,c);break;case 4:this._CreateFunctionBlock(a,b);break;case 5:this._CreateScriptBlock(a,b,c);break;default:throw new Error("invalid event type");}}_CreateEventBlock(a,b,c){const d=C3.EventBlock.Create(this,b,a);if(d.IsOrBlock()){c.push(d);const a=d.GetConditions();for(let b=0,c=a.length;ba.DebugCanRunFast()),a.canRunAllActionsFast=this._actions.every((b)=>b.DebugCanRunFast()),a.canRunAllSubEventsFast=this._subEvents.every((a)=>a.DebugCanRunFast()),a.canRunSelfFast=a.canRunAllConditionsFast&&a.canRunAllActionsFast&&a.canRunAllSubEventsFast}_UpdateCanRunFastRecursive(){let a=this;do a._UpdateCanRunFast(),a=a.GetParent();while(a)}_IdentifyTopLevelGroup(){if(!this.IsGroup())return;let a=this.GetParent();for(this._isTopLevelGroup=!0;a;){if(!a.IsGroup()){this._isTopLevelGroup=!1;break}a=a.GetParent()}}_IdentifySolModifiersIncludingParents(){const a=this._runtime.GetAllObjectClasses();if(this._solModifiers===a)this._solModifiersIncludingParents=a;else{this._solModifiersIncludingParents=C3.cloneArray(this._solModifiers);for(let a=this.GetParent();a;){for(const b of a._solModifiers)this._AddParentSolModifier(b);a=a.GetParent()}const a=this.GetEventSheetManager();this._solModifiers=a._DeduplicateSolModifierList(this._solModifiers),this._solModifiersIncludingParents=a._DeduplicateSolModifierList(this._solModifiersIncludingParents)}}_IdentifyTriggerParents(){if(this.HasAnyTriggeredCondition()){this._triggerParents=[];for(let a=this.GetParent();a;)this._triggerParents.push(a),a=a.GetParent();this._triggerParents.reverse()}}SetSolWriterAfterCnds(){this._isSolWriterAfterCnds=!0,this._parent&&this._parent.SetSolWriterAfterCnds()}IsSolWriterAfterCnds(){return this._isSolWriterAfterCnds}GetSolModifiers(){return this._solModifiers}GetSolModifiersIncludingParents(){return this._solModifiersIncludingParents}HasSolModifier(a){return this._solModifiers.includes(a)}GetTriggerParents(){return this._triggerParents}GetEventSheet(){return this._eventSheet}GetEventSheetManager(){return this._eventSheet.GetEventSheetManager()}GetRuntime(){return this._runtime}GetParent(){return this._parent}_SetScopeParent(a){this._scopeParent=a}GetScopeParent(){return this._scopeParent||this._parent}GetDisplayNumber(){return this._displayNumber}IsDebugBreakable(){return this._debugData&&this._debugData.isBreakable}IsDebugBreakpoint(){return this.IsDebugBreakable()&&this._debugData.isBreakpoint}_SetDebugBreakpoint(a){this._debugData.isBreakpoint=!!a,this._UpdateCanRunFastRecursive()}IsGroup(){return this._isGroup}IsTopLevelGroup(){return this._isTopLevelGroup}IsElseBlock(){return this._isElseBlock}HasElseBlock(){return this._hasElseBlock}GetGroupName(){return this._groupName}IsGroupActive(){return this._isGroupActive}ResetInitialActivation(){this.SetGroupActive(this._isInitiallyActive)}SetGroupActive(b){if(b=!!b,!this._isGroup)throw new Error("not a group");if(this._isGroupActive!==b){this._isGroupActive=b;for(const a of this._containedIncludes)a.UpdateActive();if(this._containedIncludes.length){const a=this._runtime.GetCurrentLayout(),b=a.GetEventSheet();b&&b._UpdateDeepIncludes()}}}GetSID(){return this._sid}IsOrBlock(){return this._isOrBlock}IsTrigger(){return this._conditions.length&&this._conditions[0].IsTrigger()}IsForFunctionBlock(){return this._scopeParent&&this._scopeParent instanceof C3.FunctionBlock}HasAnyTriggeredCondition(){return this.IsForFunctionBlock()||this._conditions.some((a)=>a.IsTrigger())}GetConditions(){return this._conditions}GetConditionCount(){return this._conditions.length}GetConditionAt(a){if(a=Math.floor(a),0>a||a>=this._conditions.length)throw new RangeError("invalid condition index");return this._conditions[a]}GetConditionByDebugIndex(a){return this.GetConditionAt(a)}IsFirstConditionOfType(a){let b=a.GetIndex();if(0===b)return!0;for(;0<=b;--b)if(this._conditions[b].GetObjectClass()===a.GetObjectClass())return!1;return!0}GetActions(){return this._actions}GetActionCount(){return this._actions.length}GetActionAt(a){if(a=Math.floor(a),0>a||a>=this._actions.length)throw new RangeError("invalid action index");return this._actions[a]}GetActionByDebugIndex(b){b=Math.floor(b);const a=this._actions.find((c)=>c.GetDebugIndex()===b);if(!a)throw new RangeError("invalid action debug index");return a}_HasActionIndex(a){return a=Math.floor(a),0<=a&&aa instanceof C3.EventVariable)}_MaybeFlushPendingInstances(){this._isTopLevelEvent&&this._runtime.FlushPendingInstances()}RunPreTrigger(a){a.SetCurrentEvent(this);let b=!1;const d=this._conditions;for(let e=0,c=d.length;ea.Get(0));a.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(c)}else this._scopeParent.EvaluateFunctionParameters(b)}RunAsFunctionCall(a,b){const c=0a.DebugCanRunFast()),a.canRunAllActionsFast=this._actions.every((b)=>b.DebugCanRunFast()),a.canRunAllSubEventsFast=this._subEvents.every((a)=>a.DebugCanRunFast()),a.canRunSelfFast=a.canRunAllConditionsFast&&a.canRunAllActionsFast&&a.canRunAllSubEventsFast}_UpdateCanRunFastRecursive(){let a=this;do a._UpdateCanRunFast(),a=a.GetParent();while(a)}_IdentifyTopLevelGroup(){if(!this.IsGroup())return;let a=this.GetParent();for(this._isTopLevelGroup=!0;a;){if(!a.IsGroup()){this._isTopLevelGroup=!1;break}a=a.GetParent()}}_IdentifySolModifiersIncludingParents(){const a=this._runtime.GetAllObjectClasses();if(this._solModifiers===a)this._solModifiersIncludingParents=a;else{this._solModifiersIncludingParents=C3.cloneArray(this._solModifiers);for(let a=this.GetParent();a;){for(const b of a._solModifiers)this._AddParentSolModifier(b);a=a.GetParent()}const a=this.GetEventSheetManager();this._solModifiers=a._DeduplicateSolModifierList(this._solModifiers),this._solModifiersIncludingParents=a._DeduplicateSolModifierList(this._solModifiersIncludingParents)}}_IdentifyTriggerParents(){if(this.HasAnyTriggeredCondition()){this._triggerParents=[];for(let a=this.GetParent();a;)this._triggerParents.push(a),a=a.GetParent();this._triggerParents.reverse()}}SetSolWriterAfterCnds(){this._isSolWriterAfterCnds=!0,this._parent&&this._parent.SetSolWriterAfterCnds()}IsSolWriterAfterCnds(){return this._isSolWriterAfterCnds}GetSolModifiers(){return this._solModifiers}GetSolModifiersIncludingParents(){return this._solModifiersIncludingParents}HasSolModifier(a){return this._solModifiers.includes(a)}GetTriggerParents(){return this._triggerParents}GetEventSheet(){return this._eventSheet}GetEventSheetManager(){return this._eventSheet.GetEventSheetManager()}GetRuntime(){return this._runtime}GetParent(){return this._parent}_SetScopeParent(a){this._scopeParent=a}GetScopeParent(){return this._scopeParent||this._parent}GetDisplayNumber(){return this._displayNumber}IsDebugBreakable(){return this._debugData&&this._debugData.isBreakable}IsDebugBreakpoint(){return this.IsDebugBreakable()&&this._debugData.isBreakpoint}_SetDebugBreakpoint(a){this._debugData.isBreakpoint=!!a,this._UpdateCanRunFastRecursive()}IsGroup(){return this._isGroup}IsTopLevelGroup(){return this._isTopLevelGroup}IsElseBlock(){return this._isElseBlock}HasElseBlock(){return this._hasElseBlock}GetGroupName(){return this._groupName}IsGroupActive(){return this._isGroupActive}ResetInitialActivation(){this.SetGroupActive(this._isInitiallyActive)}SetGroupActive(b){if(b=!!b,!this._isGroup)throw new Error("not a group");if(this._isGroupActive!==b){this._isGroupActive=b;for(const a of this._containedIncludes)a.UpdateActive();if(this._containedIncludes.length){const a=this._runtime.GetCurrentLayout(),b=a.GetEventSheet();b&&b._UpdateDeepIncludes()}}}GetSID(){return this._sid}IsOrBlock(){return this._isOrBlock}IsTrigger(){return this._conditions.length&&this._conditions[0].IsTrigger()}IsForFunctionBlock(){return this._scopeParent&&this._scopeParent instanceof C3.FunctionBlock}HasAnyTriggeredCondition(){return this.IsForFunctionBlock()||this._conditions.some((a)=>a.IsTrigger())}GetConditions(){return this._conditions}GetConditionCount(){return this._conditions.length}GetConditionAt(a){if(a=Math.floor(a),0>a||a>=this._conditions.length)throw new RangeError("invalid condition index");return this._conditions[a]}GetConditionByDebugIndex(a){return this.GetConditionAt(a)}IsFirstConditionOfType(a){let b=a.GetIndex();if(0===b)return!0;for(;0<=b;--b)if(this._conditions[b].GetObjectClass()===a.GetObjectClass())return!1;return!0}GetActions(){return this._actions}GetActionCount(){return this._actions.length}GetActionAt(a){if(a=Math.floor(a),0>a||a>=this._actions.length)throw new RangeError("invalid action index");return this._actions[a]}GetActionByDebugIndex(b){b=Math.floor(b);const a=this._actions.find((c)=>c.GetDebugIndex()===b);if(!a)throw new RangeError("invalid action debug index");return a}_HasActionIndex(a){return a=Math.floor(a),0<=a&&aa instanceof C3.EventVariable)}RunPreTrigger(a){a.SetCurrentEvent(this);let b=!1;const d=this._conditions;for(let e=0,c=d.length;ea.Get(0));a.GetLocalVarStack().Push(),this._scopeParent.SetFunctionParameters(c)}else this._scopeParent.EvaluateFunctionParameters(b)}RunAsFunctionCall(a,b){const c=0C3.EventVariable.Create(a,this,b)),this._isEnabled=d[3],this._eventBlock=C3.EventBlock.Create(a,b,c),this._eventBlock._SetScopeParent(this)}static Create(a,b,c){return C3.New(C3.FunctionBlock,a,b,c)}Release(){}_PostInit(){for(const a of this._functionParameters)a._PostInit();this._eventBlock._PostInit(!1)}_GetEventVariableNameInScope(a){for(const b of this._functionParameters)if(C3.equalsNoCase(a,b.GetName()))return b;return null}_GetAllLocalVariablesInScope(){return this._functionParameters}GetFunctionParameters(){return this._functionParameters}GetFunctionParameterCount(){return this._functionParameters.length}EvaluateFunctionParameters(a){const b=this._functionParameters;for(let c=0,d=b.length;ca.GetValue())}GetParent(){return this._parent}GetScopeParent(){return this._parent}GetFunctionName(){return this._functionName}GetReturnType(){return this._returnType}IsEnabled(){return this._isEnabled}GetDefaultReturnValue(){switch(this._returnType){case 0:return null;case 2:return"";default:return 0;}}GetEventBlock(){return this._eventBlock}}; @@ -319,7 +322,7 @@ "use strict";{function a(a,b){for(let c=0,d=a.length;ca.VariesPerInstance())?(this.Run=this._RunObject_AllParamsVary,this.DebugRun=this._DebugRunObject_AllParamsVary):this._anyParamVariesPerInstance?(this.Run=this._RunObject_SomeParamsVary,this.DebugRun=this._DebugRunObject_SomeParamsVary):this._parameters.every((a)=>a.IsConstant())?(a(this._parameters,this._results),this.Run=this._RunObject_ParamsConst,this.DebugRun=this._DebugRunObject_ParamsConst):(this.Run=this._RunObject_ParamsDontVary,this.DebugRun=this._DebugRunObject_ParamsDontVary):(this.Run=this._RunObject_ParamsConst,this.DebugRun=this._DebugRunObject_ParamsConst)}_SetSystemRunMethod(){const a=this._systemPlugin,b=this._systemPlugin;this._SetRunMethodForBoundFunc(a,b,this._RunSystem)}_SetSingleGlobalRunMethod(){const a=this._objectClass.GetPlugin(),b=this._objectClass.GetSingleGlobalInstance().GetSdkInstance();this._SetRunMethodForBoundFunc(a,b,this._RunSingleGlobal)}_SetCallFunctionRunMethod(){const a=this._eventBlock.GetEventSheetManager(),b=a.GetFunctionBlockByName(this._callFunctionName);b.IsEnabled()?(this._callEventBlock=b.GetEventBlock(),this._combinedSolModifiers=[...new Set([...this._eventBlock.GetSolModifiersIncludingParents(),...this._callEventBlock.GetSolModifiersIncludingParents()])],this._combinedSolModifiers=a._DeduplicateSolModifierList(this._combinedSolModifiers),this.Run=C3.EventBlock.prototype.RunAsFunctionCall.bind(this._callEventBlock,this._combinedSolModifiers,this._parameters),this.DebugRun=this._DebugRunCallFunction):(this.Run=c,this.DebugRun=c)}_SetRunMethodForBoundFunc(a,b,c){const d=this._func,e=this._parameters;if(0===e.length)this.Run=a._GetBoundACEMethod(d,b);else if(1===e.length){const c=e[0];if(c.IsConstant())this.Run=a._GetBoundACEMethod_1param(d,b,c.Get(0));else{const e=a._GetBoundACEMethod(d,b);this.Run=function(){return e(c.Get(0))}}}else if(2===e.length){const c=e[0],f=e[1];if(c.IsConstant()&&f.IsConstant())this.Run=a._GetBoundACEMethod_2params(d,b,c.Get(0),f.Get(0));else{const e=a._GetBoundACEMethod(d,b);this.Run=function(){return e(c.Get(0),f.Get(0))}}}else if(3===e.length){const c=e[0],f=e[1],g=e[2];if(c.IsConstant()&&f.IsConstant()&&g.IsConstant())this.Run=a._GetBoundACEMethod_3params(d,b,c.Get(0),f.Get(0),g.Get(0));else{const e=a._GetBoundACEMethod(d,b);this.Run=function(){return e(c.Get(0),f.Get(0),g.Get(0))}}}else this.Run=c}GetSID(){return this._sid}IsAsync(){return 1===this._actionReturnType}CanBailOut(){return 2===this._actionReturnType}HasReturnType(){return 0!==this._actionReturnType}GetObjectClass(){return this._objectClass}GetEventBlock(){return this._eventBlock}GetRuntime(){return this._runtime}GetIndex(){return this._index}GetDebugIndex(){return this._debugData.index}GetCombinedSolModifiers(){return this._combinedSolModifiers}IsBreakpoint(){return this._debugData.isBreakpoint}_SetBreakpoint(a){this._debugData.isBreakpoint=!!a,this._eventBlock._UpdateCanRunFastRecursive()}_DebugReturnsGenerator(){return this._debugData.canDebug}DebugCanRunFast(){return!this.IsBreakpoint()&&!this._runtime.DebugBreakNext()&&!this._DebugReturnsGenerator()}GetSavedDataMap(){return this._savedData||(this._savedData=new Map),this._savedData}GetUnsavedDataMap(){return this._unsavedData||(this._unsavedData=new Map),this._unsavedData}_RunSystem(){const b=this._results;return a(this._parameters,b),this._func.apply(this._systemPlugin,b)}*_DebugRunSystem(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const b=this._results;a(this._parameters,b);const c=yield*this._func.apply(this._systemPlugin,b);return c}return this.Run()}*_DebugRunCallFunction(){(this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this);const a=yield*this._callEventBlock.DebugRunAsFunctionCall(this._combinedSolModifiers,this._parameters);return a}_RunSingleGlobal(){const b=this._results;return a(this._parameters,b),this._func.apply(this._objectClass.GetSingleGlobalInstance().GetSdkInstance(),b)}*_DebugRunSingleGlobal(){if((this.IsBreakpoint()||this._runtime.DebugBreakNext())&&(yield this),this._DebugReturnsGenerator()){const b=this._results;a(this._parameters,b);const c=yield*this._func.apply(this._objectClass.GetSingleGlobalInstance().GetSdkInstance(),b);return c}return this.Run()}_RunObject_ParamsConst(){const a=this._results,b=this._objectClass.GetCurrentSol().GetInstances();for(let c=0,d=b.length;cc.getRight()||0>c.getBottom()||c.getLeft()>b.GetWidth()||c.getTop()>b.GetHeight()}function e(a,b,c){const d=this.GetCurrentSol(),e=d.GetInstances();if(!e.length)return!1;let f=e[0],g=f.GetWorldInfo(),h=f,j=C3.distanceSquared(g.GetX(),g.GetY(),b,c);for(let d=1,i=e.length;dj)&&(j=i,h=f)}return d.PickOne(h),!0}function f(a){const b=this.GetWorldInfo();b.GetX()===a||(b.SetX(a),b.SetBboxChanged())}function g(a){const b=this.GetWorldInfo();b.GetY()===a||(b.SetY(a),b.SetBboxChanged())}function h(a,b){const c=this.GetWorldInfo();c.EqualsXY(a,b)||(c.SetXY(a,b),c.SetBboxChanged())}function i(a,b){if(a){const c=a.GetPairedInstance(this._inst);if(c){const[a,d]=c.GetImagePoint(b),e=this.GetWorldInfo();e.GetX()===a&&e.GetY()===d||(e.SetXY(a,d),e.SetBboxChanged())}}}function j(a){if(0!==a){const b=this.GetWorldInfo();b.OffsetXY(b.GetCosAngle()*a,b.GetSinAngle()*a),b.SetBboxChanged()}}function k(b,a){if(0!==a){const c=this.GetWorldInfo();b=C3.toRadians(b),c.OffsetXY(Math.cos(b)*a,Math.sin(b)*a),c.SetBboxChanged()}}function l(){return this.GetWorldInfo().GetX()}function m(){return this.GetWorldInfo().GetY()}function n(){return this._runtime.GetDt(this._inst)}function o(a,b){return C3.compare(this.GetWorldInfo().GetWidth(),a,b)}function p(a,b){return C3.compare(this.GetWorldInfo().GetHeight(),a,b)}function q(a){const b=this.GetWorldInfo();b.GetWidth()===a||(b.SetWidth(a),b.SetBboxChanged())}function r(a){const b=this.GetWorldInfo();b.GetHeight()===a||(b.SetHeight(a),b.SetBboxChanged())}function s(a,b){const c=this.GetWorldInfo();c.GetWidth()===a&&c.GetHeight()===b||(c.SetSize(a,b),c.SetBboxChanged())}function t(){return this.GetWorldInfo().GetWidth()}function u(){return this.GetWorldInfo().GetHeight()}function v(){return this.GetWorldInfo().GetBoundingBox().getLeft()}function w(){return this.GetWorldInfo().GetBoundingBox().getTop()}function x(){return this.GetWorldInfo().GetBoundingBox().getRight()}function y(){return this.GetWorldInfo().GetBoundingBox().getBottom()}function z(b,c){return C3.angleDiff(this.GetWorldInfo().GetAngle(),C3.toRadians(c))<=C3.toRadians(b)}function A(b){return C3.angleClockwise(this.GetWorldInfo().GetAngle(),C3.toRadians(b))}function B(c,a){const b=C3.toRadians(c),d=C3.toRadians(a),e=this.GetWorldInfo().GetAngle(),f=!C3.angleClockwise(d,b);return f?C3.angleClockwise(e,b)||!C3.angleClockwise(e,d):C3.angleClockwise(e,b)&&!C3.angleClockwise(e,d)}function C(b){const a=this.GetWorldInfo(),c=C3.clampAngle(C3.toRadians(b));isNaN(c)||a.GetAngle()===c||(a.SetAngle(c),a.SetBboxChanged())}function D(b){if(!(isNaN(b)||0===b)){const a=this.GetWorldInfo();a.SetAngle(a.GetAngle()+C3.toRadians(b)),a.SetBboxChanged()}}function E(b){if(!(isNaN(b)||0===b)){const a=this.GetWorldInfo();a.SetAngle(a.GetAngle()-C3.toRadians(b)),a.SetBboxChanged()}}function F(b,c){const d=this.GetWorldInfo(),e=d.GetAngle(),a=C3.angleRotate(e,C3.toRadians(c),C3.toRadians(b));isNaN(a)||e===a||(d.SetAngle(a),d.SetBboxChanged())}function G(b,c,d){const e=this.GetWorldInfo(),f=e.GetAngle(),a=c-e.GetX(),g=d-e.GetY(),h=Math.atan2(g,a),i=C3.angleRotate(f,h,C3.toRadians(b));isNaN(i)||f===i||(e.SetAngle(i),e.SetBboxChanged())}function H(b,c){const d=this.GetWorldInfo(),e=d.GetAngle(),a=b-d.GetX(),f=c-d.GetY(),g=Math.atan2(f,a);isNaN(g)||e===g||(d.SetAngle(g),d.SetBboxChanged())}function I(){return C3.toDegrees(this.GetWorldInfo().GetAngle())}function J(a,b){return C3.compare(C3.round6dp(100*this.GetWorldInfo().GetOpacity()),a,b)}function K(){return this.GetWorldInfo().IsVisible()}function L(a){const b=this.GetWorldInfo();a=2===a?!b.IsVisible():0!=a;b.IsVisible()===a||(b.SetVisible(a),this._runtime.UpdateRender())}function M(a){const b=C3.clamp(a/100,0,1),c=this.GetWorldInfo();c.GetOpacity()===b||(c.SetOpacity(b),this._runtime.UpdateRender())}function N(a){ya.setFromRgbValue(a);const b=this.GetWorldInfo();b.GetUnpremultipliedColor().equalsIgnoringAlpha(ya)||(b.SetUnpremultipliedColor(ya),this._runtime.UpdateRender())}function O(){const a=this.GetWorldInfo().GetUnpremultipliedColor();return C3.PackRGBAEx(a.getR(),a.getG(),a.getB(),a.getA())}function P(){return C3.round6dp(100*this.GetWorldInfo().GetOpacity())}function Q(a){return!!a&&this.GetWorldInfo().GetLayer()===a}function R(a){const b=this.GetCurrentSol(),c=b.GetInstances();if(!c.length)return!1;let d=c[0],e=d;for(let b=1,d=c.length;bi||h===i&&f.GetZIndex()>g.GetZIndex())&&(e=d):(hb||b>=f.length)){const g=d.GetShaderProgram().GetParameterType(b);if("color"===g){ya.setFromRgbValue(c);const a=f[b];if(ya.equalsIgnoringAlpha(a))return;a.copyRgb(ya)}else{if("percent"===g&&(c/=100),f[b]===c)return;f[b]=c}e.IsEffectIndexActive(a)&&this._runtime.UpdateRender()}}}function da(a,b,c){return C3.compare(this.GetInstance().GetInstanceVariableValue(a),b,c)}function ea(a){return!!this.GetInstance().GetInstanceVariableValue(a)}function fa(a,b){const c=this.GetCurrentSol(),d=c.GetInstances();if(!d.length)return!1;let e=d[0],f=e,g=e.GetInstanceVariableValue(b);for(let c=1,h=d.length;cg)&&(g=h,f=e)}return c.PickOne(f),!0}function ga(a){return this._runtime.GetCurrentCondition().IsInverted()?ia(this,a):ha(this,a)}function ha(a,b){const c=a.GetRuntime().GetInstanceByUID(b);if(!c)return!1;const d=a.GetCurrentSol();if(!d.IsSelectAll()&&!d._GetOwnInstances().includes(c))return!1;if(a.IsFamily()){if(c.GetObjectClass().BelongsToFamily(a))return d.PickOne(c),a.ApplySolToContainer(),!0;}else if(c.GetObjectClass()===a)return d.PickOne(c),a.ApplySolToContainer(),!0;return!1}function ia(a,b){const c=a.GetCurrentSol();if(c.IsSelectAll()){c._SetSelectAll(!1),c.ClearArrays();const d=a.GetInstances();for(let a=0,e=d.length;ac.getRight()||0>c.getBottom()||c.getLeft()>b.GetWidth()||c.getTop()>b.GetHeight()}function e(a,b,c){const d=this.GetCurrentSol(),e=d.GetInstances();if(!e.length)return!1;let f=e[0],g=f.GetWorldInfo(),h=f,j=C3.distanceSquared(g.GetX(),g.GetY(),b,c);for(let d=1,i=e.length;dj)&&(j=i,h=f)}return d.PickOne(h),!0}function f(a){const b=this.GetWorldInfo();b.GetX()===a||(b.SetX(a),b.SetBboxChanged())}function g(a){const b=this.GetWorldInfo();b.GetY()===a||(b.SetY(a),b.SetBboxChanged())}function h(a,b){const c=this.GetWorldInfo();c.EqualsXY(a,b)||(c.SetXY(a,b),c.SetBboxChanged())}function i(a,b){if(a){const c=a.GetPairedInstance(this._inst);if(c){const[a,d]=c.GetImagePoint(b),e=this.GetWorldInfo();e.GetX()===a&&e.GetY()===d||(e.SetXY(a,d),e.SetBboxChanged())}}}function j(a){if(0!==a){const b=this.GetWorldInfo();b.OffsetXY(b.GetCosAngle()*a,b.GetSinAngle()*a),b.SetBboxChanged()}}function k(b,a){if(0!==a){const c=this.GetWorldInfo();b=C3.toRadians(b),c.OffsetXY(Math.cos(b)*a,Math.sin(b)*a),c.SetBboxChanged()}}function l(){return this.GetWorldInfo().GetX()}function m(){return this.GetWorldInfo().GetY()}function n(){return this._runtime.GetDt(this._inst)}function o(a,b){return C3.compare(this.GetWorldInfo().GetWidth(),a,b)}function p(a,b){return C3.compare(this.GetWorldInfo().GetHeight(),a,b)}function q(a){const b=this.GetWorldInfo();b.GetWidth()===a||(b.SetWidth(a),b.SetBboxChanged())}function r(a){const b=this.GetWorldInfo();b.GetHeight()===a||(b.SetHeight(a),b.SetBboxChanged())}function s(a,b){const c=this.GetWorldInfo();c.GetWidth()===a&&c.GetHeight()===b||(c.SetSize(a,b),c.SetBboxChanged())}function t(){return this.GetWorldInfo().GetWidth()}function u(){return this.GetWorldInfo().GetHeight()}function v(){return this.GetWorldInfo().GetBoundingBox().getLeft()}function w(){return this.GetWorldInfo().GetBoundingBox().getTop()}function x(){return this.GetWorldInfo().GetBoundingBox().getRight()}function y(){return this.GetWorldInfo().GetBoundingBox().getBottom()}function z(b,c){return C3.angleDiff(this.GetWorldInfo().GetAngle(),C3.toRadians(c))<=C3.toRadians(b)}function A(b){return C3.angleClockwise(this.GetWorldInfo().GetAngle(),C3.toRadians(b))}function B(c,a){const b=C3.toRadians(c),d=C3.toRadians(a),e=this.GetWorldInfo().GetAngle(),f=!C3.angleClockwise(d,b);return f?C3.angleClockwise(e,b)||!C3.angleClockwise(e,d):C3.angleClockwise(e,b)&&!C3.angleClockwise(e,d)}function C(b){const a=this.GetWorldInfo(),c=C3.clampAngle(C3.toRadians(b));isNaN(c)||a.GetAngle()===c||(a.SetAngle(c),a.SetBboxChanged())}function D(b){if(!(isNaN(b)||0===b)){const a=this.GetWorldInfo();a.SetAngle(a.GetAngle()+C3.toRadians(b)),a.SetBboxChanged()}}function E(b){if(!(isNaN(b)||0===b)){const a=this.GetWorldInfo();a.SetAngle(a.GetAngle()-C3.toRadians(b)),a.SetBboxChanged()}}function F(b,c){const d=this.GetWorldInfo(),e=d.GetAngle(),a=C3.angleRotate(e,C3.toRadians(c),C3.toRadians(b));isNaN(a)||e===a||(d.SetAngle(a),d.SetBboxChanged())}function G(b,c,d){const e=this.GetWorldInfo(),f=e.GetAngle(),a=c-e.GetX(),g=d-e.GetY(),h=Math.atan2(g,a),i=C3.angleRotate(f,h,C3.toRadians(b));isNaN(i)||f===i||(e.SetAngle(i),e.SetBboxChanged())}function H(b,c){const d=this.GetWorldInfo(),e=d.GetAngle(),a=b-d.GetX(),f=c-d.GetY(),g=Math.atan2(f,a);isNaN(g)||e===g||(d.SetAngle(g),d.SetBboxChanged())}function I(){return C3.toDegrees(this.GetWorldInfo().GetAngle())}function J(a,b){return C3.compare(C3.round6dp(100*this.GetWorldInfo().GetOpacity()),a,b)}function K(){return this.GetWorldInfo().IsVisible()}function L(a){const b=this.GetWorldInfo();a=2===a?!b.IsVisible():0!=a;b.IsVisible()===a||(b.SetVisible(a),this._runtime.UpdateRender())}function M(a){const b=C3.clamp(a/100,0,1),c=this.GetWorldInfo();c.GetOpacity()===b||(c.SetOpacity(b),this._runtime.UpdateRender())}function N(a){ya.setFromRgbValue(a);const b=this.GetWorldInfo();b.GetUnpremultipliedColor().equalsIgnoringAlpha(ya)||(b.SetUnpremultipliedColor(ya),this._runtime.UpdateRender())}function O(){const a=this.GetWorldInfo().GetUnpremultipliedColor();return C3.PackRGBAEx(a.getR(),a.getG(),a.getB(),a.getA())}function P(){return C3.round6dp(100*this.GetWorldInfo().GetOpacity())}function Q(a){return!!a&&this.GetWorldInfo().GetLayer()===a}function R(a){const b=this.GetCurrentSol(),c=b.GetInstances();if(!c.length)return!1;let d=c[0],e=d;for(let b=1,d=c.length;bi||h===i&&f.GetZIndex()>g.GetZIndex())&&(e=d):(hb||b>=f.length)){const g=d.GetShaderProgram().GetParameterType(b);if("color"===g){ya.setFromRgbValue(c);const a=f[b];if(ya.equalsIgnoringAlpha(a))return;a.copyRgb(ya)}else{if("percent"===g&&(c/=100),f[b]===c)return;f[b]=c}e.IsEffectIndexActive(a)&&this._runtime.UpdateRender()}}}function da(a,b,c){return C3.compare(this.GetInstance().GetInstanceVariableValue(a),b,c)}function ea(a){return!!this.GetInstance().GetInstanceVariableValue(a)}function fa(a,b){const c=this.GetCurrentSol(),d=c.GetInstances();if(!d.length)return!1;let e=d[0],f=e,g=e.GetInstanceVariableValue(b);for(let c=1,h=d.length;cg)&&(g=h,f=e)}return c.PickOne(f),!0}function ga(a){return this._runtime.GetCurrentCondition().IsInverted()?ia(this,a):ha(this,a)}function ha(a,b){const c=a.GetRuntime().GetInstanceByUID(b);if(!c)return!1;const d=a.GetCurrentSol();if(!d.IsSelectAll()&&!d._GetOwnInstances().includes(c))return!1;if(a.IsFamily()){if(c.GetObjectClass().BelongsToFamily(a))return d.PickOne(c),a.ApplySolToContainer(),!0;}else if(c.GetObjectClass()===a)return d.PickOne(c),a.ApplySolToContainer(),!0;return!1}function ia(a,b){const c=a.GetCurrentSol();if(c.IsSelectAll()){c._SetSelectAll(!1),c.ClearArrays();const d=a.GetInstances();for(let a=0,e=d.length;athis.SetSignalled()).catch((a)=>{console.warn("[C3 runtime] Promise rejected in 'Wait for previous actions to complete': ",a),this.SetSignalled()})}IsTimer(){return"timer"===this._type}IsSignal(){return"signal"===this._type}IsPromise(){return"promise"===this._type}GetSignalTag(){return this._signalTag}IsSignalled(){return this._isSignalled}SetSignalled(){this._isSignalled=!0}_ShouldRun(){return this.IsTimer()?this._time<=this._eventSheetManager.GetRuntime().GetGameTime():this.IsSignalled()}_RestoreState(a){a._Restore(this._event,this._actIndex);for(const[b,c]of this._sols.entries()){const a=b.GetCurrentSol();c._Restore(a)}this._callingFunctionBlock&&this._callingFunctionBlock.SetFunctionParameters(this._functionParameters)}_Run(a){this._RestoreState(a),this._event._ResumeActionsAndSubEvents(a),this._eventSheetManager.ClearSol(this._solModifiers),this._shouldRelease=!0}async _DebugRun(a){this._RestoreState(a);for(const b of this._event._DebugResumeActionsAndSubEvents(a))await this._eventSheetManager.GetRuntime().DebugBreak(b);this._eventSheetManager.ClearSol(this._solModifiers),this._shouldRelease=!0}ShouldRelease(){return this._shouldRelease}RemoveInstances(a){for(const b of this._sols.values())b.RemoveInstances(a)}_SaveToJson(){const a={},b={"t":this._time,"st":this._signalTag,"s":this._isSignalled,"ev":this._event.GetSID(),"sm":this._solModifiers.map((a)=>a.GetSID()),"sols":a};this._event._HasActionIndex(this._actIndex)&&(b["act"]=this._event.GetActionAt(this._actIndex).GetSID());for(const[b,c]of this._sols)a[b.GetSID().toString()]=c._SaveToJson();return b}static _CreateFromJson(a,b){const c=a.GetRuntime(),d=a.GetEventBlockBySID(b["ev"]);if(!d)return null;let e=0;if(b.hasOwnProperty("act")){const c=a.GetActionBySID(b["act"]);if(!c)return null;e=c.GetIndex()}const f=C3.New(C3.ScheduledWait,a);f._time=b["t"],f._type=-1===f._time?"signal":"timer",f._signalTag=b["st"],f._isSignalled=b["s"],f._event=d,f._actIndex=e;for(const d of b["sm"]){const a=c.GetObjectClassBySID(d);a&&f._solModifiers.push(a)}for(const[d,e]of Object.entries(b["sols"])){const b=parseInt(d,10),g=c.GetObjectClassBySID(b);if(!g)continue;const h=C3.New(C3.SolState,null);h._LoadFromJson(a,e),f._sols.set(g,h)}return f}}; @@ -337,13 +340,13 @@ "use strict";C3.SDKTypeBase=class extends C3.DefendedBase{constructor(a){super(),this._objectClass=a,this._runtime=a.GetRuntime(),this._plugin=a.GetPlugin()}Release(){this._objectClass=null,this._runtime=null,this._plugin=null}GetObjectClass(){return this._objectClass}GetRuntime(){return this._runtime}GetPlugin(){return this._plugin}GetImageInfo(){return this._objectClass.GetImageInfo()}FinishCondition(){}LoadTextures(){}ReleaseTextures(){}OnDynamicTextureLoadComplete(){}LoadTilePolyData(){}GetScriptInterfaceClass(){return null}}; // c3/sdk/sdkInstanceBase.js -"use strict";C3.SDKInstanceBase=class extends C3.DefendedBase{constructor(a,b){super(),this._inst=a,this._domComponentId=b,this._runtime=a.GetRuntime(),this._objectClass=this._inst.GetObjectClass(),this._sdkType=this._objectClass.GetSdkType(),this._tickFunc=null,this._tick2Func=null,this._isTicking=!1,this._isTicking2=!1,this._disposables=null,this._wasReleased=!1}Release(){this._wasReleased=!0,this._StopTicking(),this._StopTicking2(),this._tickFunc=null,this._tick2Func=null,this._disposables&&(this._disposables.Release(),this._disposables=null),this._inst=null,this._runtime=null,this._objectClass=null,this._sdkType=null}WasReleased(){return this._wasReleased}GetInstance(){return this._inst}GetRuntime(){return this._runtime}GetObjectClass(){return this._objectClass}GetPlugin(){return this._sdkType.GetPlugin()}GetSdkType(){return this._sdkType}GetScriptInterface(){return this._inst.GetInterfaceClass()}Trigger(a){return this._runtime.Trigger(a,this._inst)}DebugTrigger(a){return this._runtime.DebugTrigger(a,this._inst)}TriggerAsync(a){return this._runtime.TriggerAsync(a,this._inst)}FastTrigger(a,b){return this._runtime.FastTrigger(a,this._inst,b)}DebugFastTrigger(a,b){return this._runtime.DebugFastTrigger(a,this._inst,b)}ScheduleTriggers(a){return this._runtime.ScheduleTriggers(a)}AddDOMMessageHandler(a,b){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,a,b)}AddDOMMessageHandlers(a){for(const[b,c]of a)this.AddDOMMessageHandler(b,c)}PostToDOM(a,b){this._runtime.PostComponentMessageToDOM(this._domComponentId,a,b)}PostToDOMAsync(a,b){return this._runtime.PostComponentMessageToDOMAsync(this._domComponentId,a,b)}_PostToDOMMaybeSync(a,b){this._runtime.IsInWorker()?this.PostToDOM(a,b):window["c3_runtimeInterface"]["_OnMessageFromRuntime"]({"type":"event","component":this._domComponentId,"handler":a,"data":b,"responseId":null})}GetCurrentImageInfo(){return null}GetImagePoint(){const a=this._inst.GetWorldInfo();return[a.GetX(),a.GetY()]}Tick(){}Tick2(){}_StartTicking(){this._isTicking||(!this._tickFunc&&(this._tickFunc=()=>this.Tick()),this._runtime.Dispatcher().addEventListener("tick",this._tickFunc),this._isTicking=!0)}_StopTicking(){this._isTicking&&(this._runtime.Dispatcher().removeEventListener("tick",this._tickFunc),this._isTicking=!1)}IsTicking(){return this._isTicking}_StartTicking2(){this._isTicking2||(!this._tick2Func&&(this._tick2Func=()=>this.Tick2()),this._runtime.Dispatcher().addEventListener("tick2",this._tick2Func),this._isTicking2=!0)}_StopTicking2(){this._isTicking2&&(this._runtime.Dispatcher().removeEventListener("tick2",this._tick2Func),this._isTicking2=!1)}IsTicking2(){return this._isTicking2}GetDebuggerProperties(){return[]}SaveToJson(){return null}LoadFromJson(){}LoadTilemapData(){}TestPointOverlapTile(){}GetPropertyValueByIndex(){}SetPropertyValueByIndex(){}SetPropertyOffsetValueByIndex(){}SetPropertyColorOffsetValueByIndex(){}CallAction(a,...b){a.call(this,...b)}CallExpression(a,...b){return a.call(this,...b)}GetScriptInterfaceClass(){return null}}; +"use strict";C3.SDKInstanceBase=class extends C3.DefendedBase{constructor(a,b){super(),this._inst=a,this._domComponentId=b,this._runtime=a.GetRuntime(),this._objectClass=this._inst.GetObjectClass(),this._sdkType=this._objectClass.GetSdkType(),this._tickFunc=null,this._tick2Func=null,this._isTicking=!1,this._isTicking2=!1,this._disposables=null,this._wasReleased=!1}Release(){this._wasReleased=!0,this._StopTicking(),this._StopTicking2(),this._tickFunc=null,this._tick2Func=null,this._disposables&&(this._disposables.Release(),this._disposables=null),this._inst=null,this._runtime=null,this._objectClass=null,this._sdkType=null}WasReleased(){return this._wasReleased}GetInstance(){return this._inst}GetRuntime(){return this._runtime}GetObjectClass(){return this._objectClass}GetPlugin(){return this._sdkType.GetPlugin()}GetSdkType(){return this._sdkType}GetScriptInterface(){return this._inst.GetInterfaceClass()}Trigger(a){return this._runtime.Trigger(a,this._inst)}DebugTrigger(a){return this._runtime.DebugTrigger(a,this._inst)}TriggerAsync(a){return this._runtime.TriggerAsync(a,this._inst)}FastTrigger(a,b){return this._runtime.FastTrigger(a,this._inst,b)}DebugFastTrigger(a,b){return this._runtime.DebugFastTrigger(a,this._inst,b)}ScheduleTriggers(a){return this._runtime.ScheduleTriggers(a)}AddDOMMessageHandler(a,b){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,a,b)}AddDOMMessageHandlers(a){for(const[b,c]of a)this.AddDOMMessageHandler(b,c)}PostToDOM(a,b){this._runtime.PostComponentMessageToDOM(this._domComponentId,a,b)}PostToDOMAsync(a,b){return this._runtime.PostComponentMessageToDOMAsync(this._domComponentId,a,b)}_PostToDOMMaybeSync(a,b){this._runtime.IsInWorker()?this.PostToDOM(a,b):window["c3_runtimeInterface"]["_OnMessageFromRuntime"]({"type":"event","component":this._domComponentId,"handler":a,"data":b,"responseId":null})}GetCurrentImageInfo(){return null}GetImagePoint(){const a=this._inst.GetWorldInfo();return[a.GetX(),a.GetY()]}Tick(){}Tick2(){}_StartTicking(){this._isTicking||(!this._tickFunc&&(this._tickFunc=()=>this.Tick()),this._runtime.Dispatcher().addEventListener("tick",this._tickFunc),this._isTicking=!0)}_StopTicking(){this._isTicking&&(this._runtime.Dispatcher().removeEventListener("tick",this._tickFunc),this._isTicking=!1)}IsTicking(){return this._isTicking}_StartTicking2(){this._isTicking2||(!this._tick2Func&&(this._tick2Func=()=>this.Tick2()),this._runtime.Dispatcher().addEventListener("tick2",this._tick2Func),this._isTicking2=!0)}_StopTicking2(){this._isTicking2&&(this._runtime.Dispatcher().removeEventListener("tick2",this._tick2Func),this._isTicking2=!1)}IsTicking2(){return this._isTicking2}GetDebuggerProperties(){return[]}SaveToJson(){return null}LoadFromJson(){}LoadTilemapData(){}TestPointOverlapTile(){}GetPropertyValueByIndex(){}SetPropertyValueByIndex(){}OffsetPropertyValueByIndex(a,b){if(0!==b){const c=this.GetPropertyValueByIndex(a);if("number"!=typeof c)throw new Error("expected number");this.SetPropertyValueByIndex(a,c+b)}}SetPropertyColorOffsetValueByIndex(){}CallAction(a,...b){a.call(this,...b)}CallExpression(a,...b){return a.call(this,...b)}GetScriptInterfaceClass(){return null}}; // c3/sdk/sdkWorldInstanceBase.js "use strict";C3.SDKWorldInstanceBase=class extends C3.SDKInstanceBase{constructor(a,b){super(a,b),this._worldInfo=a.GetWorldInfo(),this._webglcontextlost_handler=null,this._webglcontextrestored_handler=null}Release(){if(this._webglcontextlost_handler){const a=this._runtime.Dispatcher();a.removeEventListener("webglcontextlost",this._webglcontextlost_handler),a.removeEventListener("webglcontextrestored",this._webglcontextrestored_handler),this._webglcontextlost_handler=null,this._webglcontextrestored_handler=null}this._worldInfo=null,super.Release()}HandleWebGLContextLoss(){if(!this._webglcontextlost_handler){this._webglcontextlost_handler=()=>this.OnWebGLContextLost(),this._webglcontextrestored_handler=()=>this.OnWebGLContextRestored();const a=this._runtime.Dispatcher();a.addEventListener("webglcontextlost",this._webglcontextlost_handler),a.addEventListener("webglcontextrestored",this._webglcontextrestored_handler)}}OnWebGLContextLost(){}OnWebGLContextRestored(){}GetWorldInfo(){return this._worldInfo}}; // c3/sdk/sdkDOMInstanceBase.js -"use strict";{const a=C3.New(C3.Rect);C3.SDKDOMInstanceBase=class extends C3.SDKWorldInstanceBase{constructor(a,b){super(a,b),this._elementId=this.GetPlugin()._AddElement(this),this._isElementShowing=!0,this._autoFontSize=!1,this._lastRect=C3.New(C3.Rect,0,0,-1,-1);const c=this._runtime.GetCanvasManager();this._lastWindowWidth=c.GetLastWidth(),this._lastWindowHeight=c.GetLastHeight(),this._isPendingUpdateState=!1,this._StartTicking()}Release(){this.GetPlugin()._RemoveElement(this._elementId),this.PostToDOMElement("destroy"),this._elementId=-1,super.Release()}PostToDOMElement(a,b){b||(b={}),b["elementId"]=this._elementId,this.PostToDOM(a,b)}PostToDOMElementAsync(a,b){return b||(b={}),b["elementId"]=this._elementId,this.PostToDOMAsync(a,b)}CreateElement(a){a||(a={});const b=this.GetWorldInfo().IsVisible();a["elementId"]=this._elementId,a["isVisible"]=b,Object.assign(a,this.GetElementState()),this._isElementShowing=!!a["isVisible"],this.PostToDOM("create",a),this._UpdatePosition(!0)}SetElementVisible(a){a=!!a;this._isElementShowing===a||(this._isElementShowing=a,this.PostToDOMElement("set-visible",{"isVisible":a}))}Tick(){this._UpdatePosition(!1)}_UpdatePosition(b){var c=Math.round;const d=this.GetWorldInfo(),e=d.GetLayer(),f=d.GetX(),g=d.GetY();let[h,i]=e.LayerToCanvasCss(f,g),[j,k]=e.LayerToCanvasCss(f+d.GetWidth(),g+d.GetHeight());const l=this._runtime.GetCanvasManager(),m=l.GetCssWidth(),n=l.GetCssHeight();if(!d.IsVisible()||!e.IsVisible()||0>=j||0>=k||h>=m||i>=n)return void this.SetElementVisible(!1);1>h&&(h=1),1>i&&(i=1),j>=m&&(j=m-1),k>=n&&(k=n-1),a.set(h,i,j,k);const o=l.GetLastWidth(),p=l.GetLastHeight();if(!b&&a.equals(this._lastRect)&&this._lastWindowWidth===o&&this._lastWindowHeight===p)return void this.SetElementVisible(!0);this._lastRect.copy(a),this._lastWindowWidth=o,this._lastWindowHeight=p,this.SetElementVisible(!0);let q=null;this._autoFontSize&&(q=e.GetDisplayScale()-.2),this.PostToDOMElement("update-position",{"left":c(this._lastRect.getLeft())+l.GetCanvasClientX(),"top":c(this._lastRect.getTop())+l.GetCanvasClientY(),"width":c(this._lastRect.width()),"height":c(this._lastRect.height()),"fontSize":q})}FocusElement(){this.PostToDOMElement("focus",{"focus":!0})}BlurElement(){this.PostToDOMElement("focus",{"focus":!1})}SetElementCSSStyle(a,b){this.PostToDOMElement("set-css-style",{"prop":C3.CSSToCamelCase(a),"val":b})}UpdateElementState(){this._isPendingUpdateState||(this._isPendingUpdateState=!0,Promise.resolve().then(()=>{this._isPendingUpdateState=!1,this.PostToDOMElement("update-state",this.GetElementState())}))}GetElementState(){}GetElementId(){return this._elementId}}} +"use strict";{const a=C3.New(C3.Rect);C3.SDKDOMInstanceBase=class extends C3.SDKWorldInstanceBase{constructor(a,b){super(a,b),this._elementId=this.GetPlugin()._AddElement(this),this._isElementShowing=!0,this._autoFontSize=!1,this._lastRect=C3.New(C3.Rect,0,0,-1,-1);const c=this._runtime.GetCanvasManager();this._lastWindowWidth=c.GetLastWidth(),this._lastWindowHeight=c.GetLastHeight(),this._isPendingUpdateState=!1,this._StartTicking()}Release(){this.GetPlugin()._RemoveElement(this._elementId),this.PostToDOMElement("destroy"),this._elementId=-1,super.Release()}PostToDOMElement(a,b){b||(b={}),b["elementId"]=this._elementId,this.PostToDOM(a,b)}PostToDOMElementAsync(a,b){return b||(b={}),b["elementId"]=this._elementId,this.PostToDOMAsync(a,b)}CreateElement(a){a||(a={});const b=this.GetWorldInfo().IsVisible();a["elementId"]=this._elementId,a["isVisible"]=b,Object.assign(a,this.GetElementState()),this._isElementShowing=!!a["isVisible"],this.PostToDOM("create",a),this._UpdatePosition(!0)}SetElementVisible(a){a=!!a;this._isElementShowing===a||(this._isElementShowing=a,this.PostToDOMElement("set-visible",{"isVisible":a}))}Tick(){this._UpdatePosition(!1)}_ShouldPreserveElement(){const a=this._runtime.GetCanvasManager().GetFullscreenMode();return"Android"===C3.Platform.OS&&("scale-inner"===a||"scale-outer"===a||"crop"===a)}_UpdatePosition(b){var c=Math.round;const d=this.GetWorldInfo(),e=d.GetLayer(),f=d.GetX(),g=d.GetY();let[h,i]=e.LayerToCanvasCss(f,g),[j,k]=e.LayerToCanvasCss(f+d.GetWidth(),g+d.GetHeight());const l=this._runtime.GetCanvasManager(),m=l.GetCssWidth(),n=l.GetCssHeight();if(!d.IsVisible()||!e.IsVisible())return void this.SetElementVisible(!1);if(!this._ShouldPreserveElement()){if(0>=j||0>=k||h>=m||i>=n)return void this.SetElementVisible(!1);1>h&&(h=1),1>i&&(i=1),j>=m&&(j=m-1),k>=n&&(k=n-1)}a.set(h,i,j,k);const o=l.GetLastWidth(),p=l.GetLastHeight();if(!b&&a.equals(this._lastRect)&&this._lastWindowWidth===o&&this._lastWindowHeight===p)return void this.SetElementVisible(!0);this._lastRect.copy(a),this._lastWindowWidth=o,this._lastWindowHeight=p,this.SetElementVisible(!0);let q=null;this._autoFontSize&&(q=e.GetDisplayScale()-.2),this.PostToDOMElement("update-position",{"left":c(this._lastRect.getLeft())+l.GetCanvasClientX(),"top":c(this._lastRect.getTop())+l.GetCanvasClientY(),"width":c(this._lastRect.width()),"height":c(this._lastRect.height()),"fontSize":q})}FocusElement(){this.PostToDOMElement("focus",{"focus":!0})}BlurElement(){this.PostToDOMElement("focus",{"focus":!1})}SetElementCSSStyle(a,b){this.PostToDOMElement("set-css-style",{"prop":C3.CSSToCamelCase(a),"val":b})}UpdateElementState(){this._isPendingUpdateState||(this._isPendingUpdateState=!0,Promise.resolve().then(()=>{this._isPendingUpdateState=!1,this.PostToDOMElement("update-state",this.GetElementState())}))}GetElementState(){}GetElementId(){return this._elementId}}} // c3/sdk/sdkBehaviorBase.js "use strict";C3.SDKBehaviorBase=class extends C3.DefendedBase{constructor(a){super(),this._runtime=a.runtime,this._myObjectClasses=C3.New(C3.ArraySet),this._myInstances=C3.New(C3.ArraySet)}Release(){this._myInstances.Release(),this._myObjectClasses.Release(),this._runtime=null}GetRuntime(){return this._runtime}OnCreate(){}_AddObjectClass(a){this._myObjectClasses.Add(a)}GetObjectClasses(){return this._myObjectClasses.GetArray()}_AddInstance(a){this._myInstances.Add(a)}_RemoveInstance(a){this._myInstances.Delete(a)}GetInstances(){return this._myInstances.GetArray()}}; @@ -352,10 +355,10 @@ "use strict";C3.SDKBehaviorTypeBase=class extends C3.DefendedBase{constructor(a){super(),this._runtime=a.GetRuntime(),this._behaviorType=a,this._objectClass=a.GetObjectClass(),this._behavior=a.GetBehavior(),this._behavior._AddObjectClass(this._objectClass)}Release(){this._runtime=null,this._behaviorType=null,this._objectClass=null,this._behavior=null}GetBehaviorType(){return this._behaviorType}GetObjectClass(){return this._objectClass}GetRuntime(){return this._runtime}GetBehavior(){return this._behavior}}; // c3/sdk/sdkBehaviorInstanceBase.js -"use strict";C3.SDKBehaviorInstanceBase=class extends C3.DefendedBase{constructor(a,b){super(),this._behInst=a,this._domComponentId=b,this._inst=a.GetObjectInstance(),this._runtime=a.GetRuntime(),this._behaviorType=a.GetBehaviorType(),this._sdkType=this._behaviorType.GetSdkType(),this._isTicking=!1,this._isTicking2=!1,this._isPostTicking=!1,this._disposables=null}Release(){this._StopTicking(),this._StopTicking2(),this._StopPostTicking(),this._disposables&&(this._disposables.Release(),this._disposables=null),this._behInst=null,this._inst=null,this._runtime=null,this._behaviorType=null,this._sdkType=null}GetBehavior(){return this._behaviorType.GetBehavior()}GetBehaviorInstance(){return this._behInst}GetObjectInstance(){return this._inst}GetObjectClass(){return this._inst.GetObjectClass()}GetWorldInfo(){return this._inst.GetWorldInfo()}GetRuntime(){return this._runtime}GetBehaviorType(){return this._behaviorType}GetSdkType(){return this._sdkType}Trigger(a){return this._runtime.Trigger(a,this._inst)}DebugTrigger(a){return this._runtime.DebugTrigger(a,this._inst)}TriggerAsync(a){return this._runtime.TriggerAsync(a,this._inst)}PostCreate(){}Tick(){}Tick2(){}PostTick(){}_StartTicking(){this._isTicking||(this._runtime._AddBehInstToTick(this),this._isTicking=!0)}_StopTicking(){this._isTicking&&(this._runtime._RemoveBehInstToTick(this),this._isTicking=!1)}IsTicking(){return this._isTicking}_StartTicking2(){this._isTicking2||(this._runtime._AddBehInstToTick2(this),this._isTicking2=!0)}_StopTicking2(){this._isTicking2&&(this._runtime._RemoveBehInstToTick2(this),this._isTicking2=!1)}IsTicking2(){return this._isTicking2}_StartPostTicking(){this._isPostTicking||(this._runtime._AddBehInstToPostTick(this),this._isPostTicking=!0)}_StopPostTicking(){this._isPostTicking&&(this._runtime._RemoveBehInstToPostTick(this),this._isPostTicking=!1)}IsPostTicking(){return this._isPostTicking}GetDebuggerProperties(){return[]}AddDOMMessageHandler(a,b){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,a,b)}OnSpriteFrameChanged(){}SaveToJson(){return null}LoadFromJson(){}GetPropertyValueByIndex(){}SetPropertyValueByIndex(){}SetPropertyOffsetValueByIndex(){}SetPropertyColorOffsetValueByIndex(){}CallAction(a,...b){a.call(this,...b)}CallExpression(a,...b){return a.call(this,...b)}}; +"use strict";C3.SDKBehaviorInstanceBase=class extends C3.DefendedBase{constructor(a,b){super(),this._behInst=a,this._domComponentId=b,this._inst=a.GetObjectInstance(),this._runtime=a.GetRuntime(),this._behaviorType=a.GetBehaviorType(),this._sdkType=this._behaviorType.GetSdkType(),this._isTicking=!1,this._isTicking2=!1,this._isPostTicking=!1,this._disposables=null}Release(){this._StopTicking(),this._StopTicking2(),this._StopPostTicking(),this._disposables&&(this._disposables.Release(),this._disposables=null),this._behInst=null,this._inst=null,this._runtime=null,this._behaviorType=null,this._sdkType=null}GetBehavior(){return this._behaviorType.GetBehavior()}GetBehaviorInstance(){return this._behInst}GetObjectInstance(){return this._inst}GetObjectClass(){return this._inst.GetObjectClass()}GetWorldInfo(){return this._inst.GetWorldInfo()}GetRuntime(){return this._runtime}GetBehaviorType(){return this._behaviorType}GetSdkType(){return this._sdkType}Trigger(a){return this._runtime.Trigger(a,this._inst)}DebugTrigger(a){return this._runtime.DebugTrigger(a,this._inst)}TriggerAsync(a){return this._runtime.TriggerAsync(a,this._inst)}PostCreate(){}Tick(){}Tick2(){}PostTick(){}_StartTicking(){this._isTicking||(this._runtime._AddBehInstToTick(this),this._isTicking=!0)}_StopTicking(){this._isTicking&&(this._runtime._RemoveBehInstToTick(this),this._isTicking=!1)}IsTicking(){return this._isTicking}_StartTicking2(){this._isTicking2||(this._runtime._AddBehInstToTick2(this),this._isTicking2=!0)}_StopTicking2(){this._isTicking2&&(this._runtime._RemoveBehInstToTick2(this),this._isTicking2=!1)}IsTicking2(){return this._isTicking2}_StartPostTicking(){this._isPostTicking||(this._runtime._AddBehInstToPostTick(this),this._isPostTicking=!0)}_StopPostTicking(){this._isPostTicking&&(this._runtime._RemoveBehInstToPostTick(this),this._isPostTicking=!1)}IsPostTicking(){return this._isPostTicking}GetDebuggerProperties(){return[]}AddDOMMessageHandler(a,b){this._runtime.AddDOMComponentMessageHandler(this._domComponentId,a,b)}OnSpriteFrameChanged(){}SaveToJson(){return null}LoadFromJson(){}GetPropertyValueByIndex(){}SetPropertyValueByIndex(){}OffsetPropertyValueByIndex(a,b){if(0!==b){const c=this.GetPropertyValueByIndex(a);if("number"!=typeof c)throw new Error("expected number");this.SetPropertyValueByIndex(a,c+b)}}SetPropertyColorOffsetValueByIndex(){}CallAction(a,...b){a.call(this,...b)}CallExpression(a,...b){return a.call(this,...b)}GetScriptInterfaceClass(){return null}}; // c3/interfaces/IRuntime.js -"use strict";{let a=null;const b=new Set;self.IRuntime=class{constructor(c,d){a=c,Object.defineProperties(this,{assets:{value:a.GetAssetManager().GetIAssetManager(),writable:!1},objects:{value:d,writable:!1},globalVars:{value:{},writable:!1},projectName:{value:a.GetProjectName(),writable:!1},projectVersion:{value:a.GetProjectVersion(),writable:!1},storage:{value:new IStorage(a),writable:!1}}),a.UserScriptDispatcher().addEventListener("keydown",(a)=>b.has(a["key"])?void a.stopPropagation():void b.add(a["key"])),a.UserScriptDispatcher().addEventListener("keyup",(a)=>b.delete(a["key"])),a.Dispatcher().addEventListener("window-blur",()=>b.clear())}_InitGlobalVars(a){Object.defineProperties(this.globalVars,a)}addEventListener(b,c){a.UserScriptDispatcher().addEventListener(b,c)}removeEventListener(b,c){a.UserScriptDispatcher().removeEventListener(b,c)}callFunction(b,...c){const d=a.GetEventSheetManager(),e=d.GetFunctionBlockByName(b);if(!e)throw new Error(`cannot find function name '${b}'`);if(!e.IsEnabled())return e.GetDefaultReturnValue();if(c.lengtha.GetILayout())}goToLayout(b){const c=a.GetLayoutManager();let d=null;if("number"==typeof b||"string"==typeof b)d=c.GetLayout(b);else throw new TypeError("expected string or number");if(!d)throw new Error("invalid layout");c.IsPendingChangeMainLayout()||c.ChangeMainLayout(d)}get keyboard(){const b=a._GetCommonScriptInterfaces().keyboard;if(!b)throw new Error("runtime.keyboard used but Keyboard object missing - add it to your project first");return b}get mouse(){const b=a._GetCommonScriptInterfaces().mouse;if(!b)throw new Error("runtime.mouse used but Mouse object missing - add it to your project first");return b}get touch(){const b=a._GetCommonScriptInterfaces().touch;if(!b)throw new Error("runtime.touch used but Touch object missing - add it to your project first");return b}invokeDownload(b,c){a.InvokeDownload(b,c)}}} +"use strict";{function a(c,a){const b=c[0],d=a[0],e=b-d;if(0!=e)return e;const f=c[1],g=a[1];return f-g}let b=null;const c=new Set;const d=[],e=[];self.IRuntime=class{constructor(a,d){b=a,Object.defineProperties(this,{assets:{value:b.GetAssetManager().GetIAssetManager(),writable:!1},objects:{value:d,writable:!1},globalVars:{value:{},writable:!1},projectName:{value:b.GetProjectName(),writable:!1},projectVersion:{value:b.GetProjectVersion(),writable:!1},storage:{value:new IStorage(b),writable:!1}}),b.UserScriptDispatcher().addEventListener("keydown",(a)=>c.has(a["key"])?void a.stopPropagation():void c.add(a["key"])),b.UserScriptDispatcher().addEventListener("keyup",(a)=>c.delete(a["key"])),b.Dispatcher().addEventListener("window-blur",()=>c.clear())}_InitGlobalVars(a){Object.defineProperties(this.globalVars,a)}addEventListener(a,c){b.UserScriptDispatcher().addEventListener(a,c)}removeEventListener(a,c){b.UserScriptDispatcher().removeEventListener(a,c)}callFunction(a,...c){const d=b.GetEventSheetManager(),e=d.GetFunctionBlockByName(a);if(!e)throw new Error(`cannot find function name '${a}'`);if(!e.IsEnabled())return e.GetDefaultReturnValue();if(c.lengtha.GetILayout())}goToLayout(a){const c=b.GetLayoutManager();let d=null;if("number"==typeof a||"string"==typeof a)d=c.GetLayout(a);else throw new TypeError("expected string or number");if(!d)throw new Error("invalid layout");c.IsPendingChangeMainLayout()||c.ChangeMainLayout(d)}get keyboard(){const a=b._GetCommonScriptInterfaces().keyboard;if(!a)throw new Error("runtime.keyboard used but Keyboard object missing - add it to your project first");return a}get mouse(){const a=b._GetCommonScriptInterfaces().mouse;if(!a)throw new Error("runtime.mouse used but Mouse object missing - add it to your project first");return a}get touch(){const a=b._GetCommonScriptInterfaces().touch;if(!a)throw new Error("runtime.touch used but Touch object missing - add it to your project first");return a}invokeDownload(a,c){b.InvokeDownload(a,c)}sortZOrder(c,f){const g=b.GetCurrentLayout();for(const a of c){const b=IInstance._Unwrap(a);if(!b||!b.GetWorldInfo())throw new Error("invalid instance");const c=b.GetWorldInfo();d.push([c.GetLayer().GetIndex(),c.GetZIndex()]),e.push(b)}if(0===d.length)return;d.sort(a),e.sort((c,a)=>f(c.GetInterfaceClass(),a.GetInterfaceClass()));let h=!1;for(let a=0,b=d.length;aa.GetILayer())}}} // c3/interfaces/ILayer.js -"use strict";{const a=new WeakMap;self.ILayer=class{constructor(b){a.set(this,b),Object.defineProperties(this,{name:{value:b.GetName(),writable:!1},index:{value:b.GetIndex(),writable:!1},layout:{value:b.GetLayout().GetILayout(),writable:!1}})}get isVisible(){return a.get(this).IsVisible()}set isVisible(b){a.get(this).SetVisible(b)}get opacity(){return a.get(this).GetOpacity()}set opacity(b){b=C3.clamp(+b,0,1);isNaN(b)||a.get(this).SetOpacity(b)}}} +"use strict";{const a=new WeakMap;self.ILayer=class{constructor(b){a.set(this,b),Object.defineProperties(this,{name:{value:b.GetName(),writable:!1},index:{value:b.GetIndex(),writable:!1},layout:{value:b.GetLayout().GetILayout(),writable:!1}})}static _Unwrap(b){return a.get(b)}get isVisible(){return a.get(this).IsVisible()}set isVisible(b){a.get(this).SetVisible(b)}get opacity(){return a.get(this).GetOpacity()}set opacity(b){b=C3.clamp(+b,0,1);isNaN(b)||a.get(this).SetOpacity(b)}getViewport(){return a.get(this).GetViewport().toDOMRect()}}} // c3/interfaces/IInstance.js -"use strict";{function a(a){let b=c.get(a);return b?b:(b=C3.New(C3.Event.Dispatcher),c.set(a,b),b)}const b=new WeakMap,c=new WeakMap;let d=null;self.IInstance=class{constructor(){b.set(this,d);const a={runtime:{value:d.GetRuntime().GetIRuntime(),writable:!1},objectType:{value:d.GetObjectClass().GetIObjectClass(),writable:!1},uid:{value:d.GetUID(),writable:!1}};d._GetInstVarsScriptDescriptor(a),Object.defineProperties(this,a)}static _Init(a){d=a}static _GetInitInst(){return d}_Release(){const a=c.get(this);a&&(a.Release(),c.delete(this)),b.delete(this)}addEventListener(b,c,d){a(this).addEventListener(b,c,d)}removeEventListener(b,c,d){a(this).removeEventListener(b,c,d)}dispatchEvent(b){a(this).dispatchEvent(b)}destroy(){const a=b.get(this);a.GetRuntime().DestroyInstance(a)}}} +"use strict";{function a(a){let b=c.get(a);return b?b:(b=C3.New(C3.Event.Dispatcher),c.set(a,b),b)}const b=new WeakMap,c=new WeakMap;let d=null;self.IInstance=class{constructor(){b.set(this,d);const a={runtime:{value:d.GetRuntime().GetIRuntime(),writable:!1},objectType:{value:d.GetObjectClass().GetIObjectClass(),writable:!1},uid:{value:d.GetUID(),writable:!1}};d._GetInstVarsScriptDescriptor(a),d._GetBehaviorsScriptDescriptor(a),Object.defineProperties(this,a)}static _Init(a){d=a}static _GetInitInst(){return d}static _Unwrap(a){return b.get(a)}_Release(){const a=c.get(this);a&&(a.Release(),c.delete(this)),b.delete(this)}addEventListener(b,c,d){a(this).addEventListener(b,c,d)}removeEventListener(b,c,d){a(this).removeEventListener(b,c,d)}dispatchEvent(b){a(this).dispatchEvent(b)}destroy(){const a=b.get(this);a.GetRuntime().DestroyInstance(a)}}} // c3/interfaces/IWorldInstance.js -"use strict";{const c=new WeakMap;self.IWorldInstance=class extends IInstance{constructor(){super(),c.set(this,IInstance._GetInitInst())}get layout(){return c.get(this).GetWorldInfo().GetLayout().GetILayout()}get layer(){return c.get(this).GetWorldInfo().GetLayer().GetILayer()}get x(){return c.get(this).GetWorldInfo().GetX()}set x(a){a=+a;const b=c.get(this).GetWorldInfo();isNaN(a)||b.GetX()===a||(b.SetX(a),b.SetBboxChanged())}get y(){return c.get(this).GetWorldInfo().GetY()}set y(a){a=+a;const b=c.get(this).GetWorldInfo();isNaN(a)||b.GetY()===a||(b.SetY(a),b.SetBboxChanged())}get zElevation(){return c.get(this).GetWorldInfo().GetZElevation()}set zElevation(a){a=+a;const b=c.get(this),d=b.GetWorldInfo();d.GetZElevation()===a||(d.SetZElevation(a),b.GetRuntime().UpdateRender())}get totalZElevation(){return c.get(this).GetWorldInfo().GetTotalZElevation()}get width(){return c.get(this).GetWorldInfo().GetWidth()}set width(a){a=+a;const b=c.get(this).GetWorldInfo();isNaN(a)||b.GetWidth()===a||(b.SetWidth(a),b.SetBboxChanged())}get height(){return c.get(this).GetWorldInfo().GetHeight()}set height(a){a=+a;const b=c.get(this).GetWorldInfo();isNaN(a)||b.GetHeight()===a||(b.SetHeight(a),b.SetBboxChanged())}get angle(){return c.get(this).GetWorldInfo().GetAngle()}set angle(b){b=C3.clampAngle(+b);const d=c.get(this).GetWorldInfo();isNaN(b)||d.GetAngle()===b||(d.SetAngle(b),d.SetBboxChanged())}get angleDegrees(){return C3.toDegrees(this.angle)}set angleDegrees(b){this.angle=C3.toRadians(b)}getBoundingBox(){return c.get(this).GetWorldInfo().GetBoundingBox().toDOMRect()}getBoundingQuad(){return c.get(this).GetWorldInfo().GetBoundingQuad().toDOMQuad()}get isVisible(){return c.get(this).GetWorldInfo().IsVisible()}set isVisible(a){a=!!a;const b=c.get(this),d=b.GetWorldInfo();d.IsVisible()===a||(d.SetVisible(a),b.GetRuntime().UpdateRender())}get opacity(){return c.get(this).GetWorldInfo().GetOpacity()}set opacity(a){a=C3.clamp(+a,0,1);const b=c.get(this),d=b.GetWorldInfo();isNaN(a)||d.GetOpacity()===a||(d.SetOpacity(a),b.GetRuntime().UpdateRender())}containsPoint(a,b){return c.get(this).GetWorldInfo().ContainsPoint(+a,+b)}testOverlap(d){const e=c.get(this),a=c.get(d);return e.GetRuntime().GetCollisionEngine().TestOverlap(e,a)}testOverlapSolid(){const a=c.get(this),b=a.GetRuntime().GetCollisionEngine().TestOverlapSolid(a);return b?b.GetInterfaceClass():null}}} +"use strict";{const d=new WeakMap,a=new Map([["normal",0],["additive",1],["copy",3],["destination-over",4],["source-in",5],["destination-in",6],["source-out",7],["destination-out",8],["source-atop",9],["destination-atop",10]]),b=new Map([...a.entries()].map((b)=>[b[1],b[0]])),c=C3.New(C3.Color);self.IWorldInstance=class extends IInstance{constructor(){super(),d.set(this,IInstance._GetInitInst())}get layout(){return d.get(this).GetWorldInfo().GetLayout().GetILayout()}get layer(){return d.get(this).GetWorldInfo().GetLayer().GetILayer()}get x(){return d.get(this).GetWorldInfo().GetX()}set x(a){a=+a;const b=d.get(this).GetWorldInfo();isNaN(a)||b.GetX()===a||(b.SetX(a),b.SetBboxChanged())}get y(){return d.get(this).GetWorldInfo().GetY()}set y(a){a=+a;const b=d.get(this).GetWorldInfo();isNaN(a)||b.GetY()===a||(b.SetY(a),b.SetBboxChanged())}get zElevation(){return d.get(this).GetWorldInfo().GetZElevation()}set zElevation(a){a=+a;const b=d.get(this),c=b.GetWorldInfo();c.GetZElevation()===a||(c.SetZElevation(a),b.GetRuntime().UpdateRender())}get totalZElevation(){return d.get(this).GetWorldInfo().GetTotalZElevation()}get width(){return d.get(this).GetWorldInfo().GetWidth()}set width(a){a=+a;const b=d.get(this).GetWorldInfo();isNaN(a)||b.GetWidth()===a||(b.SetWidth(a),b.SetBboxChanged())}get height(){return d.get(this).GetWorldInfo().GetHeight()}set height(a){a=+a;const b=d.get(this).GetWorldInfo();isNaN(a)||b.GetHeight()===a||(b.SetHeight(a),b.SetBboxChanged())}get angle(){return d.get(this).GetWorldInfo().GetAngle()}set angle(b){b=C3.clampAngle(+b);const c=d.get(this).GetWorldInfo();isNaN(b)||c.GetAngle()===b||(c.SetAngle(b),c.SetBboxChanged())}get angleDegrees(){return C3.toDegrees(this.angle)}set angleDegrees(b){this.angle=C3.toRadians(b)}getBoundingBox(){return d.get(this).GetWorldInfo().GetBoundingBox().toDOMRect()}getBoundingQuad(){return d.get(this).GetWorldInfo().GetBoundingQuad().toDOMQuad()}get isVisible(){return d.get(this).GetWorldInfo().IsVisible()}set isVisible(a){a=!!a;const b=d.get(this),c=b.GetWorldInfo();c.IsVisible()===a||(c.SetVisible(a),b.GetRuntime().UpdateRender())}get opacity(){return d.get(this).GetWorldInfo().GetOpacity()}set opacity(a){a=C3.clamp(+a,0,1);const b=d.get(this),c=b.GetWorldInfo();isNaN(a)||c.GetOpacity()===a||(c.SetOpacity(a),b.GetRuntime().UpdateRender())}set colorRgb(a){if(3>a.length)throw new Error("expected 3 elements");c.setRgb(a[0],a[1],a[2]);const b=d.get(this),e=b.GetWorldInfo();e.GetUnpremultipliedColor().equalsIgnoringAlpha(c)||(e.SetUnpremultipliedColor(c),b.GetRuntime().UpdateRender())}get colorRgb(){const a=d.get(this).GetWorldInfo().GetUnpremultipliedColor();return[a.getR(),a.getG(),a.getB()]}set blendMode(b){const c=a.get(b);if("number"!=typeof c)throw new Error("invalid blend mode");const e=d.get(this),f=e.GetWorldInfo();f.SetBlendMode(c),e.GetRuntime().UpdateRender()}get blendMode(){return b.get(d.get(this).GetWorldInfo().GetBlendMode())}moveToTop(){d.get(this).GetWorldInfo().ZOrderMoveToTop()}moveToBottom(){d.get(this).GetWorldInfo().ZOrderMoveToBottom()}moveToLayer(a){const b=ILayer._Unwrap(a);if(!b)throw new Error("invalid layer");d.get(this).GetWorldInfo().ZOrderMoveToLayer(b)}moveAdjacentToInstance(a,b){d.get(this).GetWorldInfo().ZOrderMoveAdjacentToInstance(d.get(a),b)}containsPoint(a,b){return d.get(this).GetWorldInfo().ContainsPoint(+a,+b)}testOverlap(c){const e=d.get(this),a=d.get(c);return e.GetRuntime().GetCollisionEngine().TestOverlap(e,a)}testOverlapSolid(){const a=d.get(this),b=a.GetRuntime().GetCollisionEngine().TestOverlapSolid(a);return b?b.GetInterfaceClass():null}}} // c3/interfaces/IDOMInstance.js "use strict";{const a=new WeakMap;self.IDOMInstance=class extends IWorldInstance{constructor(){super(),a.set(this,IInstance._GetInitInst())}focus(){a.get(this).GetSdkInstance().FocusElement()}blur(){a.get(this).GetSdkInstance().BlurElement()}setCssStyle(b,c){a.get(this).GetSdkInstance().SetElementCSSStyle(b,c)}}} +// c3/interfaces/IBehaviorInstance.js +"use strict";{const a=new WeakMap;let b=null;self.IBehaviorInstance=class{constructor(){a.set(this,b);const c={runtime:{value:b.GetRuntime().GetIRuntime(),writable:!1}};Object.defineProperties(this,c)}static _Init(a){b=a}static _GetInitInst(){return b}get instance(){return a.get(this).GetObjectInstance().GetInterfaceClass()}}} + // c3/objects/pluginManager.js "use strict";C3.Plugins={},C3.Behaviors={},C3.PluginManager=class extends C3.DefendedBase{constructor(a){super(),this._runtime=a,this._allPlugins=[],this._pluginsByCtor=new Map,this._systemPlugin=null,this._allBehaviors=[],this._behaviorsByCtor=new Map,this._solidBehavior=null,this._jumpthruBehavior=null}CreatePlugin(a){const b=this._runtime.GetObjectReference(a[0]);if(!b)throw new Error("missing plugin");C3.AddCommonACEs(a,b);const c=C3.New(b,{runtime:this._runtime,isSingleGlobal:a[1],isWorld:a[2],isRotatable:a[5],hasEffects:a[8],mustPredraw:a[9]});c.OnCreate(),this._allPlugins.push(c),this._pluginsByCtor.set(b,c)}CreateSystemPlugin(){this._systemPlugin=C3.New(C3.Plugins.System,{runtime:this._runtime,isSingleGlobal:!0}),this._systemPlugin.OnCreate()}CreateBehavior(a){const b=this._runtime.GetObjectReference(a[1]);if(!b)throw new Error("missing behavior");const c=C3.New(b,{runtime:this._runtime});c.OnCreate(),this._allBehaviors.push(c),this._behaviorsByCtor.set(b,c),!this._solidBehavior&&C3.Behaviors.solid&&c instanceof C3.Behaviors.solid?this._solidBehavior=c:!this._jumpthruBehavior&&C3.Behaviors.jumpthru&&c instanceof C3.Behaviors.jumpthru&&(this._jumpthruBehavior=c)}GetPluginByConstructorFunction(a){return this._pluginsByCtor.get(a)||null}HasBehaviorByConstructorFunction(a){return this._behaviorsByCtor.has(a)}GetBehaviorByConstructorFunction(a){return this._behaviorsByCtor.get(a)||null}GetSystemPlugin(){return this._systemPlugin}GetSolidBehavior(){return this._solidBehavior}GetJumpthruBehavior(){return this._jumpthruBehavior}}; @@ -403,16 +409,16 @@ "use strict";C3.Container=class extends C3.DefendedBase{constructor(a,b){super(),this._runtime=a,this._objectTypes=b;for(const c of this._objectTypes)c._SetContainer(this)}Release(){this._runtime=null}GetRuntime(){return this._runtime}GetObjectTypes(){return this._objectTypes}objectTypes(){return this._objectTypes}HasAnyWorldType(){return this._objectTypes.some((a)=>a.IsWorldType())}}; // c3/objects/instance.js -"use strict";{const a=[];let b=0;const c=new WeakMap,d=new WeakMap;C3.Instance=class extends C3.DefendedBase{constructor(c){super(),this._runtime=c.runtime,this._objectType=c.objectType,this._worldInfo=null,this._sdkInst=null,this._iScriptInterface=null,this._iid=0,this._uid=c.uid,this._puid=b++,this._flags=0,this._instVarValues=a,this._behaviorInstances=a;const d=this._objectType.GetBehaviorTypesIncludingInherited();0C3.New(C3.BehaviorInstance,{runtime:this._runtime,behaviorType:a,instance:this,index:b}))),this._siblings=this._objectType.IsInContainer()?[]:null,this._timeScale=-1,this._dispatcher=null;const e=this.GetPlugin();if(e.MustPreDraw()&&(this._flags|=4),e.IsWorldType())if(this._worldInfo=C3.New(C3.WorldInfo,this,c.layer),c.worldData)this._worldInfo.Init(c.worldData);else{this._worldInfo.InitNoData();const[a,b]=this._objectType.GetDefaultInstanceSize();this._worldInfo.SetSize(a,b),this.GetObjectClass().UsesEffects()&&this._worldInfo.GetInstanceEffectList().LoadDefaultEffectParameters()}c.instVarData?this._LoadInstanceVariableData(c.instVarData):this._LoadDefaultInstanceVariables()}Release(){if(this._iScriptInterface&&(this._iScriptInterface._Release(),this._iScriptInterface=null),0a||!isFinite(a))&&(a=0),this._timeScale=a}RestoreTimeScale(){this._timeScale=-1}Dispatcher(){return this._dispatcher||(this._dispatcher=C3.New(C3.Event.Dispatcher)),this._dispatcher}Draw(a){this._sdkInst.Draw(a)}OnCreate(a){this._sdkInst.OnCreate(a)}_SetHasTilemap(){this._flags|=2}HasTilemap(){return 0!=(this._flags&2)}_MarkDestroyed(){this._flags|=1}IsDestroyed(){return 0!=(this._flags&1)}MustPreDraw(){return 0!=(this._flags&4)}_IsSolidEnabled(){return 0!=(this._flags&8)}_SetSolidEnabled(a){a?this._flags|=8:this._flags&=-9}_IsJumpthruEnabled(){return 0!=(this._flags&16)}_SetJumpthruEnabled(a){a?this._flags|=16:this._flags&=-17}SetFlag(a,b){a<<=16,b?this._flags|=a:this._flags&=~a}GetFlag(a){return 0!=(this._flags&a<<16)}GetCurrentImageInfo(){return this._sdkInst.GetCurrentImageInfo()}GetImagePoint(a){return this._sdkInst.GetImagePoint(a)}GetObjectClass(){return this._objectType}BelongsToObjectClass(a){return a.IsFamily()?a.FamilyHasMember(this.GetObjectClass()):this.GetObjectClass()===a}IsInContainer(){return null!==this._siblings}_AddSibling(a){this._siblings.push(a)}GetSiblings(){return this._siblings}siblings(){return this._siblings}SetSiblingsSinglePicked(){for(const a of this.siblings())a.GetObjectClass().GetCurrentSol().SetSinglePicked(a)}_PushSiblingsToSolInstances(){for(const a of this.siblings())a.GetObjectClass().GetCurrentSol()._PushInstance(a)}_SetSiblingsToSolInstancesIndex(a){for(const b of this.siblings())b.GetObjectClass().GetCurrentSol()._GetOwnInstances()[a]=b}_PushSiblingsToSolElseInstances(){for(const a of this.siblings())a.GetObjectClass().GetCurrentSol()._PushElseInstance(a)}_SetSiblingsToSolElseInstancesIndex(a){for(const b of this.siblings())b.GetObjectClass().GetCurrentSol()._GetOwnElseInstances()[a]=b}GetPlugin(){return this._objectType.GetPlugin()}_SetIID(a){this._iid=a}GetIID(){return this._objectType._UpdateIIDs(),this._iid}GetUID(){return this._uid}GetPUID(){return this._puid}GetBehaviorInstances(){return this._behaviorInstances}GetBehaviorInstanceFromCtor(a){if(!a)return null;for(const b of this._behaviorInstances)if(b.GetBehavior()instanceof a)return b;return null}GetBehaviorSdkInstanceFromCtor(a){if(!a)return null;const b=this.GetBehaviorInstanceFromCtor(a);return b?b.GetSdkInstance():null}GetBehaviorIndexBySID(a){const b=this._behaviorInstances;for(let c=0,d=b.length;ca||a>=b.length)throw new RangeError("invalid instance variable");return b[a]}_GetInstanceVariableValueUnchecked(a){return this._instVarValues[a]}SetInstanceVariableValue(a,b){a|=0;const c=this._instVarValues;if(0>a||a>=c.length)throw new RangeError("invalid instance variable");const d=c[a];if("number"==typeof d)c[a]="number"==typeof b?b:parseFloat(b);else if("boolean"==typeof d)c[a]="boolean"==typeof b?b:!!b;else if("string"==typeof d)c[a]="string"==typeof b?b:b.toString();else throw new Error("unknown instance variable type")}SetInstanceVariableOffset(a,b){if(0!==b){a|=0;const c=this._instVarValues;if(0>a||a>=c.length)throw new RangeError("invalid instance variable");const d=c[a];if("number"==typeof d)c[a]+="number"==typeof b?b:parseFloat(b);else if("boolean"==typeof d)throw new Error("can not set offset of boolean variable");else if("string"==typeof d)throw new Error("can not set offset of string variable");else throw new Error("unknown instance variable type")}}GetSavedDataMap(){let a=c.get(this);return a?a:(a=new Map,c.set(this,a),a)}GetUnsavedDataMap(){let a=d.get(this);return a?a:(a=new Map,d.set(this,a),a)}_TriggerOnCreated(){this._runtime.Trigger(this.GetPlugin().constructor.Cnds.OnCreated,this)}_TriggerOnDestroyed(){this._runtime.Trigger(this.GetPlugin().constructor.Cnds.OnDestroyed,this)}_GetDebuggerProperties(){return this._sdkInst.GetDebuggerProperties()}SaveToJson(a){const b={};a?b["c3"]=!0:b["uid"]=this.GetUID();const d=c.get(this);if(d&&d.size&&(b["ex"]=C3.ToSuperJSON(d)),-1!==this.GetTimeScale()&&(b["mts"]=this.GetTimeScale()),0d||d>=this._instVarValues.length)continue;let e=b;null===e&&(e=NaN),this._instVarValues[d]=e}if(this.GetPlugin().IsWorldType()){const c=a["w"],d=c["l"];if(this._worldInfo.GetLayer().GetSID()!==d){const a=this._worldInfo.GetLayer(),c=a.GetLayout().GetLayerBySID(d);c?(this._worldInfo._SetLayer(c),a._RemoveInstance(this,!0),c._AddInstance(this,!0),c.SetZIndicesChanged(),this._worldInfo.SetBboxChanged()):!b&&this._runtime.DestroyInstance(this)}this._worldInfo._LoadFromJson(c)}const g=a["behs"];if(g)for(const[a,b]of Object.entries(g)){const c=parseInt(a,10),d=this.GetBehaviorIndexBySID(c);0>d||d>=this._behaviorInstances.length||this._behaviorInstances[d].LoadFromJson(b)}const h=a["data"];h&&this._sdkInst.LoadFromJson(h)}GetInterfaceClass(){return this._iScriptInterface||this._InitUserScriptInterface()}_InitUserScriptInterface(){const a=this._worldInfo?IWorldInstance:IInstance,b=this._sdkInst.GetScriptInterfaceClass(),c=this._objectType._GetUserScriptInstanceClass();if(IInstance._Init(this),this._iScriptInterface=new(c||b||a),IInstance._Init(null),b&&!(this._iScriptInterface instanceof a))throw new TypeError(`script interface class '${b.name}' does not extend the right base class '${a.name}'`);if(c){const d=b||a;if(!(this._iScriptInterface instanceof d))throw new TypeError(`setInstanceClass(): class '${c.name}' does not extend the right base class '${d.name}'`)}return this._iScriptInterface}_GetInstVarsScriptDescriptor(a){if(0!==this._instVarValues.length){const b={},c=this._objectType._GetAllInstanceVariableJsPropNames();for(let a=0,d=c.length;aC3.New(C3.BehaviorInstance,{runtime:this._runtime,behaviorType:a,instance:this,index:b}))),this._siblings=this._objectType.IsInContainer()?[]:null,this._timeScale=-1,this._dispatcher=null;const e=this.GetPlugin();if(e.MustPreDraw()&&(this._flags|=4),e.IsWorldType())if(this._worldInfo=C3.New(C3.WorldInfo,this,c.layer),c.worldData)this._worldInfo.Init(c.worldData);else{this._worldInfo.InitNoData();const[a,b]=this._objectType.GetDefaultInstanceSize();this._worldInfo.SetSize(a,b),this.GetObjectClass().UsesEffects()&&this._worldInfo.GetInstanceEffectList().LoadDefaultEffectParameters()}c.instVarData?this._LoadInstanceVariableData(c.instVarData):this._LoadDefaultInstanceVariables()}Release(){if(this._iScriptInterface&&(this._iScriptInterface._Release(),this._iScriptInterface=null),0a||!isFinite(a))&&(a=0),this._timeScale=a}RestoreTimeScale(){this._timeScale=-1}Dispatcher(){return this._dispatcher||(this._dispatcher=C3.New(C3.Event.Dispatcher)),this._dispatcher}Draw(a){this._sdkInst.Draw(a)}OnCreate(a){this._sdkInst.OnCreate(a)}_SetHasTilemap(){this._flags|=2}HasTilemap(){return 0!=(this._flags&2)}_MarkDestroyed(){this._flags|=1}IsDestroyed(){return 0!=(this._flags&1)}MustPreDraw(){return 0!=(this._flags&4)}_IsSolidEnabled(){return 0!=(this._flags&8)}_SetSolidEnabled(a){a?this._flags|=8:this._flags&=-9}_IsJumpthruEnabled(){return 0!=(this._flags&16)}_SetJumpthruEnabled(a){a?this._flags|=16:this._flags&=-17}SetFlag(a,b){a<<=16,b?this._flags|=a:this._flags&=~a}GetFlag(a){return 0!=(this._flags&a<<16)}GetCurrentImageInfo(){return this._sdkInst.GetCurrentImageInfo()}GetImagePoint(a){return this._sdkInst.GetImagePoint(a)}GetObjectClass(){return this._objectType}BelongsToObjectClass(a){return a.IsFamily()?a.FamilyHasMember(this.GetObjectClass()):this.GetObjectClass()===a}IsInContainer(){return null!==this._siblings}_AddSibling(a){this._siblings.push(a)}GetSiblings(){return this._siblings}siblings(){return this._siblings}SetSiblingsSinglePicked(){for(const a of this.siblings())a.GetObjectClass().GetCurrentSol().SetSinglePicked(a)}_PushSiblingsToSolInstances(){for(const a of this.siblings())a.GetObjectClass().GetCurrentSol()._PushInstance(a)}_SetSiblingsToSolInstancesIndex(a){for(const b of this.siblings())b.GetObjectClass().GetCurrentSol()._GetOwnInstances()[a]=b}_PushSiblingsToSolElseInstances(){for(const a of this.siblings())a.GetObjectClass().GetCurrentSol()._PushElseInstance(a)}_SetSiblingsToSolElseInstancesIndex(a){for(const b of this.siblings())b.GetObjectClass().GetCurrentSol()._GetOwnElseInstances()[a]=b}GetPlugin(){return this._objectType.GetPlugin()}_SetIID(a){this._iid=a}GetIID(){return this._objectType._UpdateIIDs(),this._iid}GetUID(){return this._uid}GetPUID(){return this._puid}GetBehaviorInstances(){return this._behaviorInstances}GetBehaviorInstanceFromCtor(a){if(!a)return null;for(const b of this._behaviorInstances)if(b.GetBehavior()instanceof a)return b;return null}GetBehaviorSdkInstanceFromCtor(a){if(!a)return null;const b=this.GetBehaviorInstanceFromCtor(a);return b?b.GetSdkInstance():null}GetBehaviorIndexBySID(a){const b=this._behaviorInstances;for(let c=0,d=b.length;ca||a>=b.length)throw new RangeError("invalid instance variable");return b[a]}_GetInstanceVariableValueUnchecked(a){return this._instVarValues[a]}SetInstanceVariableValue(a,b){a|=0;const c=this._instVarValues;if(0>a||a>=c.length)throw new RangeError("invalid instance variable");const d=c[a];if("number"==typeof d)c[a]="number"==typeof b?b:parseFloat(b);else if("boolean"==typeof d)c[a]="boolean"==typeof b?b:!!b;else if("string"==typeof d)c[a]="string"==typeof b?b:b.toString();else throw new Error("unknown instance variable type")}SetInstanceVariableOffset(a,b){if(0!==b){a|=0;const c=this._instVarValues;if(0>a||a>=c.length)throw new RangeError("invalid instance variable");const d=c[a];if("number"==typeof d)c[a]+="number"==typeof b?b:parseFloat(b);else if("boolean"==typeof d)throw new Error("can not set offset of boolean variable");else if("string"==typeof d)throw new Error("can not set offset of string variable");else throw new Error("unknown instance variable type")}}GetSavedDataMap(){let a=c.get(this);return a?a:(a=new Map,c.set(this,a),a)}GetUnsavedDataMap(){let a=d.get(this);return a?a:(a=new Map,d.set(this,a),a)}_TriggerOnCreated(){this._runtime.Trigger(this.GetPlugin().constructor.Cnds.OnCreated,this)}_TriggerOnDestroyed(){this._runtime.Trigger(this.GetPlugin().constructor.Cnds.OnDestroyed,this)}_GetDebuggerProperties(){return this._sdkInst.GetDebuggerProperties()}SaveToJson(a="full"){const b={};if("full"===a?b["uid"]=this.GetUID():b["c3"]=!0,"visual-state"!==a){const a=c.get(this);if(a&&a.size&&(b["ex"]=C3.ToSuperJSON(a)),-1!==this.GetTimeScale()&&(b["mts"]=this.GetTimeScale()),0d||d>=this._instVarValues.length)continue;let e=b;null===e&&(e=NaN),this._instVarValues[d]=e}}if(this.GetPlugin().IsWorldType()){const c=a["w"],d=c["l"];if(this._worldInfo.GetLayer().GetSID()!==d){const a=this._worldInfo.GetLayer(),c=a.GetLayout().GetLayerBySID(d);c?(this._worldInfo._SetLayer(c),a._RemoveInstance(this,!0),c._AddInstance(this,!0),c.SetZIndicesChanged(),this._worldInfo.SetBboxChanged()):"full"===b&&this._runtime.DestroyInstance(this)}this._worldInfo._LoadFromJson(c)}if("visual-state"!==b){const b=a["behs"];if(b)for(const[a,c]of Object.entries(b)){const b=parseInt(a,10),d=this.GetBehaviorIndexBySID(b);0>d||d>=this._behaviorInstances.length||this._behaviorInstances[d].LoadFromJson(c)}}const d=a["data"];d&&this._sdkInst.LoadFromJson(d)}GetInterfaceClass(){return this._iScriptInterface||this._InitUserScriptInterface()}_InitUserScriptInterface(){const a=this._worldInfo?IWorldInstance:IInstance,b=this._sdkInst.GetScriptInterfaceClass(),c=this._objectType._GetUserScriptInstanceClass();if(IInstance._Init(this),this._iScriptInterface=new(c||b||a),IInstance._Init(null),b&&!(this._iScriptInterface instanceof a))throw new TypeError(`script interface class '${b.name}' does not extend the right base class '${a.name}'`);if(c){const d=b||a;if(!(this._iScriptInterface instanceof d))throw new TypeError(`setInstanceClass(): class '${c.name}' does not extend the right base class '${d.name}'`)}return this._iScriptInterface}_GetInstVarsScriptDescriptor(a){if(0!==this._instVarValues.length){const b={},c=this._objectType._GetAllInstanceVariableJsPropNames();for(let a=0,d=c.length;a",this.GetSrcBlend(),this.GetDestBlend(),this._colorPremultiplied,this._zElevation)}}GetWebGLStateGroup(){return this._stateGroup}HasDefaultColor(){return this._color===e}SetBlendMode(a){this._blendMode===a||(this._blendMode=a,this._UpdateWebGLStateGroup())}GetBlendMode(){return this._blendMode}GetSrcBlend(){return this._runtime.GetWebGLRenderer().GetSrcBlendByIndex(this._blendMode)}GetDestBlend(){return this._runtime.GetWebGLRenderer().GetDestBlendByIndex(this._blendMode)}_SetLayer(a){this._layer=a,0!==this.GetZElevation()&&this._layer._SetAnyInstanceZElevated()}GetLayer(){return this._layer}GetLayout(){return this.GetLayer().GetLayout()}_SetZIndex(a){this._zIndex=0|a}GetZIndex(){return this._layer._UpdateZIndices(),this._zIndex}_GetLastCachedZIndex(){return this._zIndex}_SetFlag(a,b){b?this._flags|=a:this._flags&=~a}IsVisible(){return 0!=(this._flags&i)}SetVisible(a){this._SetFlag(i,a)}IsCollisionEnabled(){return 0!=(this._flags&8)}SetCollisionEnabled(a){a=!!a;this.IsCollisionEnabled()===a||(this._SetFlag(8,a),a?this.SetBboxChanged():this._RemoveFromCollisionCells())}SetSolidCollisionFilter(a,b){if(this._SetFlag(32,a),this._solidFilterTags&&this._solidFilterTags.clear(),!b.trim())return void(this._solidFilterTags=null);this._solidFilterTags||(this._solidFilterTags=new Set);for(const c of b.split(" "))c&&this._solidFilterTags.add(c.toLowerCase())}IsSolidCollisionAllowed(a){const b=0!=(this._flags&32),c=this._solidFilterTags;if(!a||!c)return!b;for(const d of c)if(a.has(d))return b;return!b}SetBboxChanged(){this._flags|=18,this._objectClass._SetAnyCollisionCellChanged(!0),this._runtime.UpdateRender(),this._layer.UsesRenderCells()&&(this._CalculateBbox(),this._UpdateRenderCell()),0!=(this._flags&4)&&this._inst.Dispatcher().dispatchEvent(c)}_CalculateBbox(){const a=this._boundingBox,b=this._boundingQuad,c=this._x,d=this._y,e=this._w,f=this._h;a.setWH(c-this._ox*e,d-this._oy*f,e,f),0===this._a?b.setFromRect(a):(a.offset(-c,-d),b.setFromRotatedRectPrecalc(a,this._sinA,this._cosA),b.offset(c,d),b.getBoundingBox(a)),a.normalize(),this._flags&=-3}_UpdateBbox(){0!=(this._flags&2)&&this._CalculateBbox()}GetBoundingBox(){return this._UpdateBbox(),this._boundingBox}GetBoundingQuad(){return this._UpdateBbox(),this._boundingQuad}OverwriteBoundingBox(a){this._boundingBox.copy(a),this._boundingQuad.setFromRect(this._boundingBox),this._flags&=-3,this._UpdateCollisionCell(),this._UpdateRenderCell()}SetBboxChangeEventEnabled(a){this._SetFlag(4,a)}IsBboxChangeEventEnabled(){return 0!=(this._flags&4)}IsInViewport(a){return 0===this._zElevation?a.intersectsRect(this.GetBoundingBox()):this._IsInViewport_ZElevated()}_IsInViewport_ZElevated(){const a=this.GetLayer(),c=this.GetTotalZElevation();return!(c>=a.GetCameraZ())&&(a.GetViewportForZ(c,b),b.intersectsRect(this.GetBoundingBox()))}SetSourceCollisionPoly(a){this._sourceCollisionPoly=a;const b=this._transformedPolyInfo;b&&(b.width=-1,b.height=-1,b.angle=0)}GetSourceCollisionPoly(){return this._sourceCollisionPoly}HasOwnCollisionPoly(){return!!this._sourceCollisionPoly}GetTransformedCollisionPoly(){return this._GetCustomTransformedCollisionPolyPrecalc(this.GetWidth(),this.GetHeight(),this.GetAngle(),this.GetSinAngle(),this.GetCosAngle())}GetCustomTransformedCollisionPoly(b,c,d){let a=0,e=1;return 0!==d&&(a=Math.sin(d),e=Math.cos(d)),this._GetCustomTransformedCollisionPolyPrecalc(b,c,d,a,e)}_GetCustomTransformedCollisionPolyPrecalc(b,c,d,a,e){let f=this._transformedPolyInfo;return(null===f&&(f={poly:C3.New(C3.CollisionPoly),width:-1,height:-1,angle:0},this._transformedPolyInfo=f),f.width===b&&f.height===c&&f.angle===d)?f.poly:(this._sourceCollisionPoly?(f.poly.copy(this._sourceCollisionPoly),f.poly.transformPrecalc(b,c,a,e)):f.poly.setFromQuad(this.GetBoundingQuad(),-this.GetX(),-this.GetY()),f.width=b,f.height=c,f.angle=d,f.poly)}HasTilemap(){return this._inst.HasTilemap()}ContainsPoint(a,b){return!!this.GetBoundingBox().containsPoint(a,b)&&!!this.GetBoundingQuad().containsPoint(a,b)&&(this.HasTilemap()?this._inst.GetSdkInstance().TestPointOverlapTile(a,b):!this.HasOwnCollisionPoly()||this.GetTransformedCollisionPoly().containsPoint(a-this.GetX(),b-this.GetY()))}_IsCollisionCellChanged(){return 0!=(this._flags&16)}_UpdateCollisionCell(){if(this._IsCollisionCellChanged()&&this.IsCollisionEnabled()){const b=this.GetBoundingBox(),c=this._objectClass._GetCollisionCellGrid(),d=this._collisionCells;if(a.set(c.XToCell(b.getLeft()),c.YToCell(b.getTop()),c.XToCell(b.getRight()),c.YToCell(b.getBottom())),!d.equals(a)){const b=this._inst;d===g?(c.Update(b,null,a),this._collisionCells=C3.New(C3.Rect,a)):(c.Update(b,d,a),d.copy(a)),this._flags&=-17}}}_RemoveFromCollisionCells(){const a=this._collisionCells;a===g||(this._objectClass._GetCollisionCellGrid().Update(this._inst,a,null),this._collisionCells=g)}_UpdateRenderCell(){const b=this.GetLayer();if(b.UsesRenderCells()){const c=b.GetRenderGrid(),d=this.GetBoundingBox(),e=this._renderCells;if(a.set(c.XToCell(d.getLeft()),c.YToCell(d.getTop()),c.XToCell(d.getRight()),c.YToCell(d.getBottom())),!e.equals(a)){const d=this._inst;e===f?(c.Update(d,null,a),this._renderCells=C3.New(C3.Rect,a)):(c.Update(d,e,a),e.copy(a)),b.SetRenderListStale()}}}_RemoveFromRenderCells(){const a=this._renderCells;a===f||(this.GetLayer().GetRenderGrid().Update(this._inst,a,null),this._renderCells=f)}GetRenderCellRange(){return this._renderCells}GetInstanceEffectList(){return this._instanceEffectList}_SetHasAnyActiveEffect(a){this._SetFlag(64,a)}HasAnyActiveEffect(){return 0!=(this._flags&64)}SaveGeometryState(){this._UpdateBbox();const a=this._boundingBox,b=this._boundingQuad,d=this._color;return[this._x,this._y,this._zElevation,this._w,this._h,this._a,this._ox,this._oy,d.r,d.g,d.b,d.a,a.getLeft(),a.getTop(),a.getRight(),a.getBottom(),b.getTlx(),b.getTly(),b.getTrx(),b.getTry(),b.getBrx(),b.getBry(),b.getBlx(),b.getBly()]}RestoreGeometryState(a){h=!1,this._x=a[0],this._y=a[1],this._zElevation=a[2],this._w=a[3],this._h=a[4],this.SetAngle(a[5]),this._ox=a[6],this._oy=a[7],d.setRgba(a[8],a[9],a[10],a[11]),this._SetColor(d),this._boundingBox.set(a[12],a[13],a[14],a[15]),this._boundingQuad.set(a[16],a[17],a[18],a[19],a[20],a[21],a[22],a[23]),this._flags&=-3,h=!0,this._UpdateWebGLStateGroup()}_SaveToJson(){const a={"x":this.GetX(),"y":this.GetY(),"w":this.GetWidth(),"h":this.GetHeight(),"l":this.GetLayer().GetSID(),"zi":this.GetZIndex()};0!==this.GetZElevation()&&(a["ze"]=this.GetZElevation()),0!==this.GetAngle()&&(a["a"]=this.GetAngle()),this.HasDefaultColor()||(a["c"]=this._color.toJSON()),.5!==this.GetOriginX()&&(a["oX"]=this.GetOriginX()),.5!==this.GetOriginY()&&(a["oY"]=this.GetOriginY()),0!==this.GetBlendMode()&&(a["bm"]=this.GetBlendMode()),this.IsVisible()||(a["v"]=this.IsVisible()),this.IsCollisionEnabled()||(a["ce"]=this.IsCollisionEnabled()),this.IsBboxChangeEventEnabled()&&(a["be"]=this.IsBboxChangeEventEnabled()),this._instanceEffectList&&(a["fx"]=this._instanceEffectList._SaveToJson());const b=0!=(32&this._flags);return b&&(a["sfi"]=b),this._solidFilterTags&&(a["sft"]=[...this._solidFilterTags].join(" ")),a}_LoadFromJson(a){this.SetX(a["x"]),this.SetY(a["y"]),this.SetWidth(a["w"]),this.SetHeight(a["h"]),this._SetZIndex(a["zi"]),this.SetZElevation(a.hasOwnProperty("ze")?a["ze"]:0),this.SetAngle(a.hasOwnProperty("a")?a["a"]:0),a.hasOwnProperty("c")?d.setFromJSON(a["c"]):a.hasOwnProperty("o")?(d.copyRgb(this._color),d.a=a["o"]):d.setRgba(1,1,1,1),this._SetColor(d),this.SetOriginX(a.hasOwnProperty("oX")?a["oX"]:.5),this.SetOriginY(a.hasOwnProperty("oY")?a["oY"]:.5),this.SetBlendMode(a.hasOwnProperty("bm")?a["bm"]:0),this.SetVisible(!a.hasOwnProperty("v")||a["v"]),this.SetCollisionEnabled(!a.hasOwnProperty("ce")||a["ce"]),this.SetBboxChangeEventEnabled(!!a.hasOwnProperty("be")&&a["be"]),this.SetSolidCollisionFilter(!!a.hasOwnProperty("sfi")&&a["sfi"],a.hasOwnProperty("sft")?a["sft"]:""),this._instanceEffectList&&a.hasOwnProperty("fx")&&this._instanceEffectList._LoadFromJson(a["fx"]),this.SetBboxChanged()}}} +"use strict";{const a=C3.New(C3.Rect),b=C3.New(C3.Rect),c=C3.New(C3.Event,"bboxchange",!1),d=C3.New(C3.Color,0,0,0,0),e=C3.New(C3.Color,1,1,1,1),f=C3.New(C3.Rect,0,0,-1,-1),g=C3.New(C3.Rect,0,0,-1,-1);let h=!0;const i=1;C3.WorldInfo=class extends C3.DefendedBase{constructor(a,b){super(),this._inst=a,this._objectClass=a.GetObjectClass(),this._runtime=a.GetRuntime(),this._layer=b,this._zIndex=-1,this._flags=27,this._x=NaN,this._y=NaN,this._zElevation=NaN,this._w=NaN,this._h=NaN,this._a=NaN,this._sinA=NaN,this._cosA=NaN,this._ox=NaN,this._oy=NaN,this._boundingBox=C3.New(C3.Rect),this._boundingQuad=C3.New(C3.Quad),this._collisionCells=g,this._renderCells=f,this._sourceCollisionPoly=null,this._transformedPolyInfo=null,this._solidFilterTags=null,this._color=e,this._colorPremultiplied=e,this._blendMode=-1,this._stateGroup=null,this._instanceEffectList=null,this._inst.GetObjectClass().UsesEffects()&&(this._instanceEffectList=C3.New(C3.InstanceEffectList,this._inst,this)),h=!1,this.SetBlendMode(0),h=!0}Release(){this._stateGroup&&(this._runtime.GetWebGLRenderer().ReleaseStateGroup(this._stateGroup),this._stateGroup=null),this._sourceCollisionPoly=null,this._transformedPolyInfo&&(this._transformedPolyInfo.poly.Release(),this._transformedPolyInfo=null),this._solidFilterTags&&(this._solidFilterTags.clear(),this._solidFilterTags=null),this._inst=null,this._objectClass=null,this._runtime=null,this._layer=null}Init(a){h=!1,this.SetXY(a[0],a[1]),this.SetZElevation(a[2]),this.SetSize(a[3],a[4]),this.SetAngle(a[6]),d.setFromJSON(a[7]),this._SetColor(d),this.SetOriginX(a[8]),this.SetOriginY(a[9]),this.SetBlendMode(a[10]),this._instanceEffectList&&this._instanceEffectList._LoadEffectParameters(a[12]),h=!0,this._UpdateWebGLStateGroup()}InitNoData(){this._x=0,this._y=0,this._zElevation=0,this._w=0,this._h=0,this._a=0,this._sinA=0,this._cosA=1,this._ox=0,this._oy=0,this._UpdateWebGLStateGroup()}GetInstance(){return this._inst}SetX(a){this._x=+a}OffsetX(a){this._x+=+a}GetX(){return this._x}SetY(a){this._y=+a}OffsetY(a){this._y+=+a}GetY(){return this._y}SetXY(a,b){this._x=+a,this._y=+b}OffsetXY(a,b){this._x+=+a,this._y+=+b}EqualsXY(a,b){return this._x===a&&this._y===b}SetZElevation(a){if(a=+a,this._zElevation!==a){this._zElevation=a,this._UpdateWebGLStateGroup();const b=this.GetLayer();0!==this._zElevation&&b._SetAnyInstanceZElevated(),b.SetZIndicesChanged()}}OffsetZElevation(a){this.SetZElevation(this.GetZElevation()+a)}GetZElevation(){return this._zElevation}GetTotalZElevation(){return this.GetLayer().GetZElevation()+this.GetZElevation()}SetWidth(a){this._w=+a}OffsetWidth(a){this._w+=+a}GetWidth(){return this._w}SetHeight(a){this._h=+a}OffsetHeight(a){this._h+=+a}GetHeight(){return this._h}SetSize(a,b){this._w=+a,this._h=+b}SetAngle(b){b=C3.clampAngle(+b);this._a===b||(this._a=b,this._sinA=Math.sin(b),this._cosA=Math.cos(b))}OffsetAngle(b){b=+b;0===b||(this._a=C3.clampAngle(this._a+b),this._sinA=Math.sin(this._a),this._cosA=Math.cos(this._a))}GetAngle(){return this._a}GetSinAngle(){return this._sinA}GetCosAngle(){return this._cosA}SetOriginX(a){this._ox=+a}OffsetOriginX(a){this._ox+=+a}GetOriginX(){return this._ox}SetOriginY(a){this._oy=+a}OffsetOriginY(a){this._oy+=+a}GetOriginY(){return this._oy}_SetColor(a){this._color.equals(a)||(this._color===e?(this._color=C3.New(C3.Color,a),this._colorPremultiplied=C3.New(C3.Color,a),this._colorPremultiplied.premultiply()):a.equalsRgba(1,1,1,1)?(this._color=e,this._colorPremultiplied=e):(this._color.set(a),this._colorPremultiplied.set(a),this._colorPremultiplied.premultiply()),this._UpdateWebGLStateGroup())}SetOpacity(a){a=C3.clamp(+a,0,1);this._color.a===a||(d.copyRgb(this._color),d.a=a,this._SetColor(d))}OffsetOpacity(a){this.SetOpacity(this.GetOpacity()+a)}GetOpacity(){return this._color.a}SetUnpremultipliedColor(a){this._color.equalsIgnoringAlpha(a)||(d.copyRgb(a),d.a=this._color.a,this._SetColor(d))}SetUnpremultipliedColorRGB(a,c,e){d.setRgb(a,c,e),this.SetUnpremultipliedColor(d)}OffsetUnpremultipliedColorRGB(a,c,e){0===a&&0===c&&0===e||(d.copyRgb(this._color),d.r+=a,d.g+=c,d.b+=e,this.SetUnpremultipliedColor(d))}GetUnpremultipliedColor(){return this._color}GetPremultipliedColor(){return this._colorPremultiplied}_UpdateWebGLStateGroup(){if(h){const a=this._runtime.GetWebGLRenderer();this._stateGroup&&a.ReleaseStateGroup(this._stateGroup),this._stateGroup=a.AcquireStateGroup(a.GetTextureFillShaderProgram()||"",this.GetSrcBlend(),this.GetDestBlend(),this._colorPremultiplied,this._zElevation)}}GetWebGLStateGroup(){return this._stateGroup}HasDefaultColor(){return this._color===e}SetBlendMode(a){this._blendMode===a||(this._blendMode=a,this._UpdateWebGLStateGroup())}GetBlendMode(){return this._blendMode}GetSrcBlend(){return this._runtime.GetWebGLRenderer().GetSrcBlendByIndex(this._blendMode)}GetDestBlend(){return this._runtime.GetWebGLRenderer().GetDestBlendByIndex(this._blendMode)}_SetLayer(a){this._layer=a,0!==this.GetZElevation()&&this._layer._SetAnyInstanceZElevated()}GetLayer(){return this._layer}GetLayout(){return this.GetLayer().GetLayout()}_SetZIndex(a){this._zIndex=0|a}GetZIndex(){return this._layer._UpdateZIndices(),this._zIndex}_GetLastCachedZIndex(){return this._zIndex}_SetFlag(a,b){b?this._flags|=a:this._flags&=~a}IsVisible(){return 0!=(this._flags&i)}SetVisible(a){this._SetFlag(i,a)}IsCollisionEnabled(){return 0!=(this._flags&8)}SetCollisionEnabled(a){a=!!a;this.IsCollisionEnabled()===a||(this._SetFlag(8,a),a?this.SetBboxChanged():this._RemoveFromCollisionCells())}SetSolidCollisionFilter(a,b){if(this._SetFlag(32,a),this._solidFilterTags&&this._solidFilterTags.clear(),!b.trim())return void(this._solidFilterTags=null);this._solidFilterTags||(this._solidFilterTags=new Set);for(const c of b.split(" "))c&&this._solidFilterTags.add(c.toLowerCase())}IsSolidCollisionAllowed(a){const b=0!=(this._flags&32),c=this._solidFilterTags;if(!a||!c)return!b;for(const d of c)if(a.has(d))return b;return!b}SetBboxChanged(){this._flags|=18,this._objectClass._SetAnyCollisionCellChanged(!0),this._runtime.UpdateRender(),this._layer.UsesRenderCells()&&(this._CalculateBbox(),this._UpdateRenderCell()),0!=(this._flags&4)&&this._inst.Dispatcher().dispatchEvent(c)}_CalculateBbox(){const a=this._boundingBox,b=this._boundingQuad,c=this._x,d=this._y,e=this._w,f=this._h;a.setWH(c-this._ox*e,d-this._oy*f,e,f),0===this._a?b.setFromRect(a):(a.offset(-c,-d),b.setFromRotatedRectPrecalc(a,this._sinA,this._cosA),b.offset(c,d),b.getBoundingBox(a)),a.normalize(),this._flags&=-3}_UpdateBbox(){0!=(this._flags&2)&&this._CalculateBbox()}GetBoundingBox(){return this._UpdateBbox(),this._boundingBox}GetBoundingQuad(){return this._UpdateBbox(),this._boundingQuad}OverwriteBoundingBox(a){this._boundingBox.copy(a),this._boundingQuad.setFromRect(this._boundingBox),this._flags&=-3,this._UpdateCollisionCell(),this._UpdateRenderCell()}SetBboxChangeEventEnabled(a){this._SetFlag(4,a)}IsBboxChangeEventEnabled(){return 0!=(this._flags&4)}IsInViewport(a){return 0===this._zElevation?a.intersectsRect(this.GetBoundingBox()):this._IsInViewport_ZElevated()}_IsInViewport_ZElevated(){const a=this.GetLayer(),c=this.GetTotalZElevation();return!(c>=a.GetCameraZ())&&(a.GetViewportForZ(c,b),b.intersectsRect(this.GetBoundingBox()))}SetSourceCollisionPoly(a){this._sourceCollisionPoly=a;const b=this._transformedPolyInfo;b&&(b.width=-1,b.height=-1,b.angle=0)}GetSourceCollisionPoly(){return this._sourceCollisionPoly}HasOwnCollisionPoly(){return!!this._sourceCollisionPoly}GetTransformedCollisionPoly(){return this._GetCustomTransformedCollisionPolyPrecalc(this.GetWidth(),this.GetHeight(),this.GetAngle(),this.GetSinAngle(),this.GetCosAngle())}GetCustomTransformedCollisionPoly(b,c,d){let a=0,e=1;return 0!==d&&(a=Math.sin(d),e=Math.cos(d)),this._GetCustomTransformedCollisionPolyPrecalc(b,c,d,a,e)}_GetCustomTransformedCollisionPolyPrecalc(b,c,d,a,e){let f=this._transformedPolyInfo;return(null===f&&(f={poly:C3.New(C3.CollisionPoly),width:-1,height:-1,angle:0},this._transformedPolyInfo=f),f.width===b&&f.height===c&&f.angle===d)?f.poly:(this._sourceCollisionPoly?(f.poly.copy(this._sourceCollisionPoly),f.poly.transformPrecalc(b,c,a,e)):f.poly.setFromQuad(this.GetBoundingQuad(),-this.GetX(),-this.GetY()),f.width=b,f.height=c,f.angle=d,f.poly)}HasTilemap(){return this._inst.HasTilemap()}ContainsPoint(a,b){return!!this.GetBoundingBox().containsPoint(a,b)&&!!this.GetBoundingQuad().containsPoint(a,b)&&(this.HasTilemap()?this._inst.GetSdkInstance().TestPointOverlapTile(a,b):!this.HasOwnCollisionPoly()||this.GetTransformedCollisionPoly().containsPoint(a-this.GetX(),b-this.GetY()))}_IsCollisionCellChanged(){return 0!=(this._flags&16)}_UpdateCollisionCell(){if(this._IsCollisionCellChanged()&&this.IsCollisionEnabled()){const b=this.GetBoundingBox(),c=this._objectClass._GetCollisionCellGrid(),d=this._collisionCells;if(a.set(c.XToCell(b.getLeft()),c.YToCell(b.getTop()),c.XToCell(b.getRight()),c.YToCell(b.getBottom())),!d.equals(a)){const b=this._inst;d===g?(c.Update(b,null,a),this._collisionCells=C3.New(C3.Rect,a)):(c.Update(b,d,a),d.copy(a)),this._flags&=-17}}}_RemoveFromCollisionCells(){const a=this._collisionCells;a===g||(this._objectClass._GetCollisionCellGrid().Update(this._inst,a,null),this._collisionCells=g)}_UpdateRenderCell(){const b=this.GetLayer();if(b.UsesRenderCells()){const c=b.GetRenderGrid(),d=this.GetBoundingBox(),e=this._renderCells;if(a.set(c.XToCell(d.getLeft()),c.YToCell(d.getTop()),c.XToCell(d.getRight()),c.YToCell(d.getBottom())),!e.equals(a)){const d=this._inst;e===f?(c.Update(d,null,a),this._renderCells=C3.New(C3.Rect,a)):(c.Update(d,e,a),e.copy(a)),b.SetRenderListStale()}}}_RemoveFromRenderCells(){const a=this._renderCells;a===f||(this.GetLayer().GetRenderGrid().Update(this._inst,a,null),this._renderCells=f)}GetRenderCellRange(){return this._renderCells}ZOrderMoveToTop(){const a=this._inst,b=this._layer,c=b._GetInstances();c.length&&c[c.length-1]===a||(b._RemoveInstance(a,!1),b._AddInstance(a,!1),this._runtime.UpdateRender())}ZOrderMoveToBottom(){const a=this._inst,b=this._layer,c=b._GetInstances();c.length&&c[0]===a||(b._RemoveInstance(a,!1),b._PrependInstance(a,!1),this._runtime.UpdateRender())}ZOrderMoveToLayer(a){const b=this._inst,c=this._layer;if(c.GetLayout()!==a.GetLayout())throw new Error("layer from different layout");a===c||(c._RemoveInstance(b,!0),this._SetLayer(a),a._AddInstance(b,!0),this._runtime.UpdateRender())}ZOrderMoveAdjacentToInstance(a,b){const c=this._inst,d=this._layer;if(a.GetUID()!==c.GetUID()){const e=a.GetWorldInfo();if(!e)throw new Error("expected world instance");const f=e.GetLayer();d.GetIndex()!==f.GetIndex()&&(d._RemoveInstance(c,!0),this._SetLayer(f),f._AddInstance(c,!0)),f.MoveInstanceAdjacent(c,a,!!b),this._runtime.UpdateRender()}}GetInstanceEffectList(){return this._instanceEffectList}_SetHasAnyActiveEffect(a){this._SetFlag(64,a)}HasAnyActiveEffect(){return 0!=(this._flags&64)}_SaveToJson(){const a={"x":this.GetX(),"y":this.GetY(),"w":this.GetWidth(),"h":this.GetHeight(),"l":this.GetLayer().GetSID(),"zi":this.GetZIndex()};0!==this.GetZElevation()&&(a["ze"]=this.GetZElevation()),0!==this.GetAngle()&&(a["a"]=this.GetAngle()),this.HasDefaultColor()||(a["c"]=this._color.toJSON()),.5!==this.GetOriginX()&&(a["oX"]=this.GetOriginX()),.5!==this.GetOriginY()&&(a["oY"]=this.GetOriginY()),0!==this.GetBlendMode()&&(a["bm"]=this.GetBlendMode()),this.IsVisible()||(a["v"]=this.IsVisible()),this.IsCollisionEnabled()||(a["ce"]=this.IsCollisionEnabled()),this.IsBboxChangeEventEnabled()&&(a["be"]=this.IsBboxChangeEventEnabled()),this._instanceEffectList&&(a["fx"]=this._instanceEffectList._SaveToJson());const b=0!=(32&this._flags);return b&&(a["sfi"]=b),this._solidFilterTags&&(a["sft"]=[...this._solidFilterTags].join(" ")),a}_LoadFromJson(a){h=!1,this.SetX(a["x"]),this.SetY(a["y"]),this.SetWidth(a["w"]),this.SetHeight(a["h"]),this._SetZIndex(a["zi"]),this.SetZElevation(a.hasOwnProperty("ze")?a["ze"]:0),this.SetAngle(a.hasOwnProperty("a")?a["a"]:0),a.hasOwnProperty("c")?d.setFromJSON(a["c"]):a.hasOwnProperty("o")?(d.copyRgb(this._color),d.a=a["o"]):d.setRgba(1,1,1,1),this._SetColor(d),this.SetOriginX(a.hasOwnProperty("oX")?a["oX"]:.5),this.SetOriginY(a.hasOwnProperty("oY")?a["oY"]:.5),this.SetBlendMode(a.hasOwnProperty("bm")?a["bm"]:0),this.SetVisible(!a.hasOwnProperty("v")||a["v"]),this.SetCollisionEnabled(!a.hasOwnProperty("ce")||a["ce"]),this.SetBboxChangeEventEnabled(!!a.hasOwnProperty("be")&&a["be"]),this.SetSolidCollisionFilter(!!a.hasOwnProperty("sfi")&&a["sfi"],a.hasOwnProperty("sft")?a["sft"]:""),this._instanceEffectList&&a.hasOwnProperty("fx")&&this._instanceEffectList._LoadFromJson(a["fx"]),this.SetBboxChanged(),h=!0,this._UpdateWebGLStateGroup()}}} // c3/objects/behaviorType.js -"use strict";C3.BehaviorType=class extends C3.DefendedBase{constructor(a,b){super();const c=a.GetRuntime(),d=c.GetPluginManager(),e=c.GetObjectReference(b[1]);d.HasBehaviorByConstructorFunction(e)||d.CreateBehavior(b),this._runtime=c,this._objectClass=a,this._behavior=d.GetBehaviorByConstructorFunction(e),this._sdkType=null,this._instSdkCtor=e.Instance,this._sid=b[2],this._name=b[0],this._sdkType=C3.New(e.Type,this);this.OnCreate()}static Create(a,b){return C3.New(C3.BehaviorType,a,b)}Release(){this._runtime=null,this._behavior=null,this._sdkType.Release(),this._sdkType=null,this._instSdkCtor=null}GetSdkType(){return this._sdkType}OnCreate(){this._sdkType.OnCreate()}GetRuntime(){return this._runtime}GetObjectClass(){return this._objectClass}GetBehavior(){return this._behavior}GetInstanceSdkCtor(){return this._instSdkCtor}GetName(){return this._name}GetSID(){return this._sid}}; +"use strict";C3.BehaviorType=class extends C3.DefendedBase{constructor(a,b){super();const c=a.GetRuntime(),d=c.GetPluginManager(),e=c.GetObjectReference(b[1]);d.HasBehaviorByConstructorFunction(e)||d.CreateBehavior(b),this._runtime=c,this._objectClass=a,this._behavior=d.GetBehaviorByConstructorFunction(e),this._sdkType=null,this._instSdkCtor=e.Instance,this._sid=b[2],this._name=b[0],this._jsPropName=this._runtime.GetJsPropName(b[3]),this._sdkType=C3.New(e.Type,this);this.OnCreate()}static Create(a,b){return C3.New(C3.BehaviorType,a,b)}Release(){this._runtime=null,this._behavior=null,this._sdkType.Release(),this._sdkType=null,this._instSdkCtor=null}GetSdkType(){return this._sdkType}OnCreate(){this._sdkType.OnCreate()}GetRuntime(){return this._runtime}GetObjectClass(){return this._objectClass}GetBehavior(){return this._behavior}GetInstanceSdkCtor(){return this._instSdkCtor}GetName(){return this._name}GetSID(){return this._sid}GetJsPropName(){return this._jsPropName}}; // c3/objects/behaviorInstance.js -"use strict";C3.BehaviorInstance=class extends C3.DefendedBase{constructor(a){super(),this._runtime=a.runtime,this._behaviorType=a.behaviorType,this._behavior=this._behaviorType.GetBehavior(),this._inst=a.instance,this._index=a.index,this._sdkInst=null,this._behavior._AddInstance(this._inst)}Release(){this._behavior._RemoveInstance(this._inst),this._sdkInst.Release(),this._sdkInst=null,this._runtime=null,this._behaviorType=null,this._behavior=null,this._inst=null}_CreateSdkInstance(a){if(this._sdkInst)throw new Error("already got sdk instance");this._sdkInst=C3.New(this._behaviorType.GetInstanceSdkCtor(),this,a)}GetSdkInstance(){return this._sdkInst}GetObjectInstance(){return this._inst}GetRuntime(){return this._runtime}GetBehaviorType(){return this._behaviorType}GetBehavior(){return this._behavior}_GetIndex(){return this._index}PostCreate(){this._sdkInst.PostCreate()}OnSpriteFrameChanged(a,b){this._sdkInst.OnSpriteFrameChanged(a,b)}_GetDebuggerProperties(){return this._sdkInst.GetDebuggerProperties()}SaveToJson(){return this._sdkInst.SaveToJson()}LoadFromJson(a){return this._sdkInst.LoadFromJson(a)}static SortByTickSequence(c,a){const b=c.GetObjectInstance(),d=a.GetObjectInstance(),e=b.GetObjectClass().GetIndex(),f=d.GetObjectClass().GetIndex();if(e!==f)return e-f;const g=b.GetPUID(),h=d.GetPUID();return g===h?c.GetBehaviorInstance()._GetIndex()-a.GetBehaviorInstance()._GetIndex():g-h}}; +"use strict";C3.BehaviorInstance=class extends C3.DefendedBase{constructor(a){super(),this._runtime=a.runtime,this._behaviorType=a.behaviorType,this._behavior=this._behaviorType.GetBehavior(),this._inst=a.instance,this._index=a.index,this._sdkInst=null,this._iScriptInterface=null,this._behavior._AddInstance(this._inst)}Release(){this._behavior._RemoveInstance(this._inst),this._sdkInst.Release(),this._sdkInst=null,this._iScriptInterface=null,this._runtime=null,this._behaviorType=null,this._behavior=null,this._inst=null}_CreateSdkInstance(a){if(this._sdkInst)throw new Error("already got sdk instance");this._sdkInst=C3.New(this._behaviorType.GetInstanceSdkCtor(),this,a);this._InitScriptInterface()}GetSdkInstance(){return this._sdkInst}GetObjectInstance(){return this._inst}GetRuntime(){return this._runtime}GetBehaviorType(){return this._behaviorType}GetBehavior(){return this._behavior}_GetIndex(){return this._index}PostCreate(){this._sdkInst.PostCreate()}OnSpriteFrameChanged(a,b){this._sdkInst.OnSpriteFrameChanged(a,b)}_GetDebuggerProperties(){return this._sdkInst.GetDebuggerProperties()}SaveToJson(){return this._sdkInst.SaveToJson()}LoadFromJson(a){return this._sdkInst.LoadFromJson(a)}static SortByTickSequence(c,a){const b=c.GetObjectInstance(),d=a.GetObjectInstance(),e=b.GetObjectClass().GetIndex(),f=d.GetObjectClass().GetIndex();if(e!==f)return e-f;const g=b.GetPUID(),h=d.GetPUID();return g===h?c.GetBehaviorInstance()._GetIndex()-a.GetBehaviorInstance()._GetIndex():g-h}_InitScriptInterface(){const a=IBehaviorInstance,b=this._sdkInst.GetScriptInterfaceClass();if(IBehaviorInstance._Init(this),this._iScriptInterface=new(b||a),IBehaviorInstance._Init(null),b&&!(this._iScriptInterface instanceof a))throw new TypeError(`script interface class '${b.name}' does not extend the right base class '${a.name}'`)}GetScriptInterface(){return this._iScriptInterface}}; // c3/objects/effectList.js "use strict";C3.EffectList=class extends C3.DefendedBase{constructor(a,b){super(),this._owner=a,this._allEffectTypes=[],this._activeEffectTypes=[],this._effectTypesByName=new Map,this._effectParams=[],this._preservesOpaqueness=!0;for(const c of b){const a=C3.New(C3.EffectType,this,c,this._allEffectTypes.length);this._allEffectTypes.push(a),this._effectTypesByName.set(a.GetName().toLowerCase(),a),3<=c.length&&this._effectParams.push(this._LoadSingleEffectParameters(c[2]))}this.GetRuntime()._AddEffectList(this)}Release(){C3.clearArray(this._allEffectTypes),C3.clearArray(this._activeEffectTypes),this._effectTypesByName.clear(),C3.clearArray(this._effectParams),this._owner=null}PrependEffectTypes(a){if(a.length){this._allEffectTypes=a.concat(this._allEffectTypes);for(const b of a)this._effectTypesByName.set(b.GetName().toLowerCase(),b);for(let a=0,b=this._allEffectTypes.length;a({"name":a.GetName(),"active":a.IsActive(),"params":C3.EffectList.SaveFxParamsToJson(this._effectParams[a.GetIndex()])}))}LoadFromJson(a){for(const b of a){const a=this.GetEffectTypeByName(b["name"]);a&&(a.SetActive(b["active"]),this._effectParams[a.GetIndex()]=C3.EffectList.LoadFxParamsFromJson(b["params"]))}this.UpdateActiveEffects()}}; @@ -439,7 +445,7 @@ "use strict";{const a=new Set(["off","crop","scale-inner","scale-outer","letterbox-scale","letterbox-integer-scale"]),b=new Set(["high","low"]),c=C3.New(C3.Quad),d=C3.New(C3.Rect);C3.CanvasManager=class extends C3.DefendedBase{constructor(a){super(),this._runtime=a,this._canvas=null,this._webglRenderer=null,this._gpuPreference="high-performance",this._windowInnerWidth=0,this._windowInnerHeight=0,this._canvasCssWidth=0,this._canvasCssHeight=0,this._canvasDeviceWidth=0,this._canvasDeviceHeight=0,this._canvasCssOffsetX=0,this._canvasCssOffsetY=0,this._drawWidth=0,this._drawHeight=0,this._fullscreenMode="letterbox-scale",this._documentFullscreenMode="letterbox-scale",this._deviceTransformOffX=0,this._deviceTransformOffY=0,this._wantFullscreenScalingQuality="high",this._fullscreenScalingQuality=this._wantFullscreenScalingQuality,this._isDocumentFullscreen=!1,this._availableAdditionalRenderTargets=[],this._usedAdditionalRenderTargets=new Set,this._shaderData=null,this._gpuFrameTimingsBuffer=null,this._gpuTimeStartFrame=0,this._gpuTimeEndFrame=0,this._gpuCurUtilisation=NaN,this._gpuLastUtilisation=0,this._layersGpuProfile=new Map,this._snapshotFormat="",this._snapshotQuality=1,this._snapshotUrl="",this._snapshotPromise=null,this._snapshotResolve=null,this._loaderStartTime=0,this._rafId=-1,this._loadingProgress=0,this._loadingprogress_handler=(a)=>this._loadingProgress=a.progress,this._webglPercentText=null,this._loadingLogoAsset=null,this._splashTextures={logo:null,powered:null,website:null},this._splashFrameNumber=0,this._splashFadeInFinishTime=0,this._splashFadeOutStartTime=0,this._splashState="fade-in",this._splashDoneResolve=null,this._splashDonePromise=new Promise((a)=>this._splashDoneResolve=a)}_SetGPUPowerPreference(a){this._gpuPreference=a}async CreateCanvas(a){this._canvas=a["canvas"],this._canvas.addEventListener("webglcontextlost",(a)=>this._OnWebGLContextLost(a)),this._canvas.addEventListener("webglcontextrestored",(a)=>this._OnWebGLContextRestored(a));const b={powerPreference:this._gpuPreference,enableGpuProfiling:!0};"standard"===this._runtime.GetCompositingMode()?b.alpha=!0:(b.alpha=!1,b.lowLatency=!0),this._webglRenderer=C3.New(C3.Gfx.WebGLRenderer,this._canvas,b),await this._webglRenderer.InitState(),this._webglRenderer.SupportsGPUProfiling()||(this._gpuLastUtilisation=NaN),this._runtime.AddDOMComponentMessageHandler("runtime","window-resize",(a)=>this._OnWindowResize(a)),this._runtime.AddDOMComponentMessageHandler("runtime","fullscreenchange",(a)=>this._OnFullscreenChange(a)),this._runtime.AddDOMComponentMessageHandler("runtime","fullscreenerror",(a)=>this._OnFullscreenError(a)),this._isDocumentFullscreen=!!a["isFullscreen"],this.SetSize(a["windowInnerWidth"],a["windowInnerHeight"],!0),this._shaderData=self["C3_Shaders"],await this._LoadShaderPrograms();let c=!1;for(const b of this._runtime._GetAllEffectLists()){for(const a of b.GetAllEffectTypes())a._InitRenderer(this._webglRenderer),a.GetShaderProgram().UsesDest()&&(c=!0);b.UpdateActiveEffects()}this._runtime._SetUsesAnyBackgroundBlending(c),this._webglRenderer.SupportsGPUProfiling()&&(this._gpuFrameTimingsBuffer=C3.New(C3.Gfx.WebGLQueryResultBuffer,this._webglRenderer))}async _LoadShaderPrograms(){if(this._shaderData){const a=[];for(const[b,c]of Object.entries(this._shaderData)){const d=C3.Gfx.WebGLShaderProgram.GetDefaultVertexShaderSource(this._webglRenderer.Is3D());a.push(this._webglRenderer.CreateShaderProgram(c,d,b))}await Promise.all(a),this._webglRenderer.ResetLastProgram(),this._webglRenderer.SetTextureFillMode()}}Release(){this._runtime=null,this._webglRenderer=null,this._canvas=null}_OnWindowResize(a){this._runtime.IsInWorker()&&(self.devicePixelRatio=a["devicePixelRatio"]),this.SetSize(a["innerWidth"],a["innerHeight"]),this._runtime.UpdateRender()}_OnFullscreenChange(a){this._isDocumentFullscreen=!!a["isFullscreen"],this.SetSize(a["innerWidth"],a["innerHeight"],!0),this._runtime.UpdateRender()}_OnFullscreenError(a){this._isDocumentFullscreen=!!a["isFullscreen"],this.SetSize(a["innerWidth"],a["innerHeight"],!0),this._runtime.UpdateRender()}SetSize(a,b,c=!1){var d=Math.floor;if(a=d(a),b=d(b),0>=a||0>=b)throw new Error("invalid size");if(this._windowInnerWidth!==a||this._windowInnerHeight!==b||c){this._windowInnerWidth=a,this._windowInnerHeight=b;const c=this.GetCurrentFullscreenMode();"letterbox-scale"===c?this._CalculateLetterboxScale(a,b):"letterbox-integer-scale"===c?this._CalculateLetterboxIntegerScale(a,b):"off"===c?this._CalculateFixedSizeCanvas(a,b):this._CalculateFullsizeCanvas(a,b),this._UpdateFullscreenScalingQuality(c),this._canvas.width=this._canvasDeviceWidth,this._canvas.height=this._canvasDeviceHeight,this._runtime.PostComponentMessageToDOM("canvas","update-size",{"marginLeft":this._canvasCssOffsetX,"marginTop":this._canvasCssOffsetY,"styleWidth":this._canvasCssWidth,"styleHeight":this._canvasCssHeight}),this._webglRenderer.SetSize(this._canvasDeviceWidth,this._canvasDeviceHeight,!0)}}_CalculateLetterboxScale(a,b){var c=Math.round,d=Math.floor;const e=self.devicePixelRatio,f=this._runtime.GetOriginalViewportWidth(),g=this._runtime.GetOriginalViewportHeight(),h=f/g;if(a/b>h){this._canvasCssWidth=c(b*h),this._canvasCssHeight=b,this._canvasCssOffsetX=d((a-this._canvasCssWidth)/2),this._canvasCssOffsetY=0}else{this._canvasCssWidth=a,this._canvasCssHeight=c(a/h),this._canvasCssOffsetX=0,this._canvasCssOffsetY=d((b-this._canvasCssHeight)/2)}this._canvasDeviceWidth=c(this._canvasCssWidth*e),this._canvasDeviceHeight=c(this._canvasCssHeight*e),this._runtime.SetViewportSize(f,g)}_CalculateLetterboxIntegerScale(a,b){var c=Math.max,d=Math.round,e=Math.floor;const f=self.devicePixelRatio;1!==f&&(a+=1,b+=1);const g=this._runtime.GetOriginalViewportWidth(),h=this._runtime.GetOriginalViewportHeight(),i=g/h,j=a/b;let k;if(j>i){const a=b*i;k=a*f/g}else{const b=a/i;k=b*f/h}1k&&(k=1/Math.ceil(1/k)),this._canvasDeviceWidth=d(g*k),this._canvasDeviceHeight=d(h*k),this._canvasCssWidth=this._canvasDeviceWidth/f,this._canvasCssHeight=this._canvasDeviceHeight/f,this._canvasCssOffsetX=c(e((a-this._canvasCssWidth)/2),0),this._canvasCssOffsetY=c(e((b-this._canvasCssHeight)/2),0),this._runtime.SetViewportSize(g,h)}_CalculateFullsizeCanvas(a,b){var c=Math.round;const d=self.devicePixelRatio;this._canvasCssWidth=a,this._canvasCssHeight=b,this._canvasDeviceWidth=c(this._canvasCssWidth*d),this._canvasDeviceHeight=c(this._canvasCssHeight*d),this._canvasCssOffsetX=0,this._canvasCssOffsetY=0;const e=this.GetDisplayScale();this._runtime.SetViewportSize(this._canvasCssWidth/e,this._canvasCssHeight/e)}_CalculateFixedSizeCanvas(a,b){var c=Math.round,d=Math.floor;const e=self.devicePixelRatio;this._canvasCssWidth=this._runtime.GetViewportWidth(),this._canvasCssHeight=this._runtime.GetViewportHeight(),this._canvasDeviceWidth=c(this._canvasCssWidth*e),this._canvasDeviceHeight=c(this._canvasCssHeight*e),this.IsDocumentFullscreen()?(this._canvasCssOffsetX=d((a-this._canvasCssWidth)/2),this._canvasCssOffsetY=d((b-this._canvasCssHeight)/2)):(this._canvasCssOffsetX=0,this._canvasCssOffsetY=0),this._runtime.SetViewportSize(this._runtime.GetViewportWidth(),this._runtime.GetViewportHeight())}_UpdateFullscreenScalingQuality(a){if("high"===this._wantFullscreenScalingQuality)this._drawWidth=this._canvasDeviceWidth,this._drawHeight=this._canvasDeviceHeight,this._fullscreenScalingQuality="high";else{let b,c;if("off"===this.GetCurrentFullscreenMode()?(b=this._runtime.GetViewportWidth(),c=this._runtime.GetViewportHeight()):(b=this._runtime.GetOriginalViewportWidth(),c=this._runtime.GetOriginalViewportHeight()),this._canvasDeviceWidtha&&(this._drawHeight=this._drawWidth/d)}else if("scale-outer"===a){const a=b/c,d=this._windowInnerWidth/this._windowInnerHeight;d>a?this._drawWidth=this._drawHeight*d:dd||"scale-inner"===a&&eb.IsCompatibleWithOptions(a));let d;return-1===c?d=this._webglRenderer.CreateRenderTarget(a):(d=b[c],b.splice(c,1)),this._usedAdditionalRenderTargets.add(d),d}ReleaseAdditionalRenderTarget(a){if(!this._usedAdditionalRenderTargets.has(a))throw new Error("render target not in use");this._usedAdditionalRenderTargets.delete(a),this._availableAdditionalRenderTargets.push(a)}*activeLayersGpuProfiles(){for(const a of this._runtime.GetLayoutManager().runningLayouts())for(const b of a.GetLayers()){const a=this._layersGpuProfile.get(b);a&&(yield a)}}GetLayerTimingsBuffer(a){if(!this._webglRenderer.SupportsGPUProfiling())return null;let b=this._layersGpuProfile.get(a);return b||(b={name:a.GetName(),timingsBuffer:C3.New(C3.Gfx.WebGLQueryResultBuffer,this._webglRenderer),curUtilisation:0,lastUtilisation:0},this._layersGpuProfile.set(a,b)),b.timingsBuffer}_Update1sFrameRange(){if(this._webglRenderer.SupportsGPUProfiling()&&0===this._gpuTimeEndFrame){this._gpuTimeEndFrame=this._webglRenderer.GetFrameNumber(),this._gpuCurUtilisation=NaN;for(const a of this.activeLayersGpuProfiles())a.curUtilisation=NaN}}_UpdateTick(){var a=Math.min;if(this._webglRenderer.SupportsGPUProfiling()&&isNaN(this._gpuCurUtilisation)&&(this._gpuCurUtilisation=this._gpuFrameTimingsBuffer.GetFrameRangeResultSum(this._gpuTimeStartFrame,this._gpuTimeEndFrame),!isNaN(this._gpuCurUtilisation))){if(this._runtime.IsDebug())for(const a of this.activeLayersGpuProfiles())if(a.curUtilisation=a.timingsBuffer.GetFrameRangeResultSum(this._gpuTimeStartFrame,this._gpuTimeEndFrame),isNaN(a.curUtilisation))return;if(this._gpuFrameTimingsBuffer.DeleteAllBeforeFrameNumber(this._gpuTimeEndFrame),this._gpuLastUtilisation=a(this._gpuCurUtilisation,1),this._runtime.IsDebug()){for(const b of this.activeLayersGpuProfiles())b.timingsBuffer.DeleteAllBeforeFrameNumber(this._gpuTimeEndFrame),b.lastUtilisation=a(b.curUtilisation,1);C3Debugger.UpdateGPUProfile(this._gpuLastUtilisation,[...this.activeLayersGpuProfiles()])}this._gpuTimeStartFrame=this._gpuTimeEndFrame,this._gpuTimeEndFrame=0}}GetGPUFrameTimingsBuffer(){return this._gpuFrameTimingsBuffer}GetGPUUtilisation(){return this._gpuLastUtilisation}SnapshotCanvas(a,b){return(this._snapshotFormat=a,this._snapshotQuality=b,this._snapshotPromise)?this._snapshotPromise:(this._snapshotPromise=new Promise((a)=>{this._snapshotResolve=a}),this._snapshotPromise)}_MaybeTakeSnapshot(){this._snapshotFormat&&(C3.CanvasToBlob(this._canvas,this._snapshotFormat,this._snapshotQuality).then((a)=>{this._snapshotUrl=URL.createObjectURL(a),this._snapshotPromise=null,this._snapshotResolve(this._snapshotUrl)}),this._snapshotFormat="",this._snapshotQuality=1)}GetCanvasSnapshotUrl(){return this._snapshotUrl}InitLoadingScreen(a){if(2===a)this._webglPercentText=C3.New(C3.Gfx.WebGLText,this._webglRenderer),this._webglPercentText.SetIsAsync(!1),this._webglPercentText.SetFontName("Arial"),this._webglPercentText.SetFontSize(16),this._webglPercentText.SetHorizontalAlignment("center"),this._webglPercentText.SetVerticalAlignment("center"),this._webglPercentText.SetSize(300,200);else if(0===a){const a=this._runtime.GetAssetManager();let b;if(this._runtime.IsPreview()){if(!a._HasLocalUrlBlob("loading-logo.png"))return;b=a.GetLocalUrlAsBlobUrl("loading-logo.png")}else b=a.GetIconsSubfolder()+"loading-logo.png";this._loadingLogoAsset=a.LoadImage({url:b}),this._loadingLogoAsset.LoadStaticTexture(this._webglRenderer).catch(()=>console.warn(`[C3 runtime] Failed to load 'loading-logo.png' for loading screen. Check the project has an icon with that name.`))}else 4===a&&(this._LoadSvgSplashImage("splash-images/splash-logo.svg").then((a)=>{"done"===this._splashState?this._webglRenderer.DeleteTexture(a):this._splashTextures.logo=a}).catch((a)=>console.warn("Failed to load splash image: ",a)),this._LoadBitmapSplashImage("splash-images/splash-poweredby-512.png").then((a)=>{"done"===this._splashState?this._webglRenderer.DeleteTexture(a):this._splashTextures.powered=a}).catch((a)=>console.warn("Failed to load splash image: ",a)),this._LoadBitmapSplashImage("splash-images/splash-website-512.png").then((a)=>{"done"===this._splashState?this._webglRenderer.DeleteTexture(a):this._splashTextures.website=a}).catch((a)=>console.warn("Failed to load splash image: ",a)))}async _LoadSvgSplashImage(a){a=new URL(a,this._runtime.GetBaseURL()).toString();const b=await C3.FetchBlob(a),c=await this._runtime.RasterSvgImage(b,2048,2048);return await this._webglRenderer.CreateStaticTextureAsync(c,{mipMapQuality:"high"})}async _LoadBitmapSplashImage(a){a=new URL(a,this._runtime.GetBaseURL()).toString();const b=await C3.FetchBlob(a);return await this._webglRenderer.CreateStaticTextureAsync(b,{mipMapQuality:"high"})}StartLoadingScreen(){this._loaderStartTime=Date.now(),this._runtime.Dispatcher().addEventListener("loadingprogress",this._loadingprogress_handler),this._rafId=requestAnimationFrame(()=>this._DrawLoadingScreen())}async EndLoadingScreen(){this._loadingProgress=1,4===this._runtime.GetLoaderStyle()&&(await this._splashDonePromise),this._splashDoneResolve=null,this._splashDonePromise=null,-1!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=-1),this._runtime.Dispatcher().removeEventListener("loadingprogress",this._loadingprogress_handler),this._loadingprogress_handler=null,this._webglPercentText&&(this._webglPercentText.Release(),this._webglPercentText=null),this._loadingLogoAsset&&(this._loadingLogoAsset.Release(),this._loadingLogoAsset=null),this._webglRenderer.Start(),this._splashTextures.logo&&(this._webglRenderer.DeleteTexture(this._splashTextures.logo),this._splashTextures.logo=null),this._splashTextures.powered&&(this._webglRenderer.DeleteTexture(this._splashTextures.powered),this._splashTextures.powered=null),this._splashTextures.website&&(this._webglRenderer.DeleteTexture(this._splashTextures.website),this._splashTextures.website=null),this._webglRenderer.ClearRgba(0,0,0,0),this._webglRenderer.Finish(),this._splashState="done",this._gpuTimeStartFrame=this._webglRenderer.GetFrameNumber()}_DrawLoadingScreen(){if(-1!==this._rafId){const a=this._webglRenderer;a.Start(),this._rafId=-1;const b=this._runtime.GetAssetManager().HasHadErrorLoading(),c=this._runtime.GetLoaderStyle();if(3!==c&&(this.SetCssTransform(a),a.ClearRgba(0,0,0,0),a.ResetColor(),a.SetTextureFillMode(),a.SetTexture(null)),0===c)this._DrawProgressBarAndLogoLoadingScreen(b);else if(1===c)this._DrawProgressBarLoadingScreen(b,120,0);else if(2===c)this._DrawPercentTextLoadingScreen(b);else if(3===c)C3.noop();else if(4===c)this._DrawSplashLoadingScreen(b);else throw new Error("invalid loader style");a.Finish(),this._rafId=requestAnimationFrame(()=>this._DrawLoadingScreen())}}_DrawPercentTextLoadingScreen(a){a?this._webglPercentText.SetColorRgb(1,0,0):this._webglPercentText.SetColorRgb(.6,.6,.6),this._webglPercentText.SetText(Math.round(100*this._loadingProgress)+"%");const b=this._canvasCssWidth/2,d=this._canvasCssHeight/2;c.setRect(b-150,d-100,b+150,d+100),this._webglRenderer.SetTexture(this._webglPercentText.GetTexture()),this._webglRenderer.Quad3(c,this._webglPercentText.GetTexRect())}_DrawProgressBarLoadingScreen(a,b,c){const e=this._webglRenderer;e.SetColorFillMode(),a?e.SetColorRgba(1,0,0,1):e.SetColorRgba(.118,.565,1,1);const f=this._canvasCssWidth/2,g=this._canvasCssHeight/2,h=b/2;d.setWH(f-h,g-4+c,Math.floor(b*this._loadingProgress),8),e.Rect(d),d.setWH(f-h,g-4+c,b,8),d.offset(-.5,-.5),d.inflate(.5,.5),e.SetColorRgba(0,0,0,1),e.LineRect2(d),d.inflate(1,1),e.SetColorRgba(1,1,1,1),e.LineRect2(d)}_DrawProgressBarAndLogoLoadingScreen(a){if(!this._loadingLogoAsset)return void this._DrawProgressBarLoadingScreen(a,120,0);const b=this._loadingLogoAsset.GetTexture();if(!b)return void this._DrawProgressBarLoadingScreen(a,120,0);const d=b.GetWidth(),e=b.GetHeight(),f=this._canvasCssWidth/2,g=this._canvasCssHeight/2,h=d/2,i=e/2;c.setRect(f-h,g-i,f+h,g+i),this._webglRenderer.SetTexture(b),this._webglRenderer.Quad(c),this._DrawProgressBarLoadingScreen(a,d,i+16)}_DrawSplashLoadingScreen(b){var c=Math.min,e=Math.max,f=Math.ceil;const g=this._webglRenderer,i=this._splashTextures.logo,j=this._splashTextures.powered,k=this._splashTextures.website,l=Date.now();0===this._splashFrameNumber&&(this._loaderStartTime=l);const m=this._runtime.IsPreview()||this._runtime.IsFBInstantAvailable()&&!this._runtime.IsCordova(),n=m?0:200,o=m?0:3000;let p=1;"fade-in"===this._splashState?p=c((l-this._loaderStartTime)/300,1):"fade-out"===this._splashState&&(p=e(1-(l-this._splashFadeOutStartTime)/300,0)),g.SetColorFillMode(),g.SetColorRgba(.231*p,.251*p,.271*p,p),d.set(0,0,this._canvasCssWidth,this._canvasCssHeight),g.Rect(d);const a=f(this._canvasCssWidth),q=f(this._canvasCssHeight);let h,r;256=300&&2<=this._splashFrameNumber&&(this._splashState="wait",this._splashFadeInFinishTime=l),"wait"===this._splashState&&l-this._splashFadeInFinishTime>=o&&1<=this._loadingProgress&&(this._splashState="fade-out",this._splashFadeOutStartTime=l),("fade-out"===this._splashState&&l-this._splashFadeOutStartTime>=300+n||m&&1<=this._loadingProgress&&500>l-this._loaderStartTime)&&this._splashDoneResolve()}}} // c3/runtime.js -"use strict";{const e={"messagePort":null,"baseUrl":"","headless":!1,"hasDom":!0,"isInWorker":!1,"useAudio":!0,"projectData":"","exportType":""};let a=!0;C3.Runtime=class extends C3.DefendedBase{constructor(n){n=Object.assign({},e,n);super(),this._messagePort=n["messagePort"],this._baseUrl=n["baseUrl"],this._isHeadless=!!n["headless"],this._hasDom=!!n["hasDom"],this._isInWorker=!!n["isInWorker"],a=n["ife"],this._useAudio=!!n["useAudio"],this._exportType=n["exportType"],this._isWKWebView=!!n["isWKWebView"],this._isFBInstantAvailable=!!n["isFBInstantAvailable"],this._opusWasmScriptUrl=n["opusWasmScriptUrl"],this._opusWasmBinaryUrl=n["opusWasmBinaryUrl"],this._dataJsonFilename="data.json",this._isDebug=!!("preview"===this._exportType&&n["isDebug"]),this._breakpointsEnabled=this._isDebug,this._isDebugging=this._isDebug,this._debuggingDisabled=0;const t=n["previewImageBlobs"],s=n["previewProjectFileBlobs"];s&&Object.assign(t,s);const i=n["projectData"];i&&(t[this._dataJsonFilename]=i),this._additionalLoadPromises=[],this._projectName="",this._projectVersion="",this._projectUniqueId="",this._originalViewportWidth=0,this._originalViewportHeight=0,this._parallaxXorigin=0,this._parallaxYorigin=0,this._viewportWidth=0,this._viewportHeight=0,this._loaderStyle=0,this._usesLoaderLayout=!1,this._isLoading=!0,this._usesAnyBackgroundBlending=!1;const r="html5"===this._exportType||"scirra-arcade"===this._exportType;this._assetManager=C3.New(C3.AssetManager,this,{defaultLoadPolicy:r?"remote":"local",localUrlBlobs:t,isCordova:"cordova"===this._exportType,isWKWebView:this._isWKWebView,supportedAudioFormats:n["supportedAudioFormats"]}),this._layoutManager=C3.New(C3.LayoutManager,this),this._eventSheetManager=C3.New(C3.EventSheetManager,this),this._pluginManager=C3.New(C3.PluginManager,this),this._collisionEngine=C3.New(C3.CollisionEngine,this),this._timelineManager=C3.New(C3.TimelineManager,this),this._transitionManager=C3.New(C3.TransitionManager,this),this._allObjectClasses=[],this._objectClassesByName=new Map,this._objectClassesBySid=new Map,this._familyCount=0,this._allContainers=[],this._allEffectLists=[],this._currentLayoutStack=[],this._instancesPendingCreate=[],this._instancesPendingDestroy=new Map,this._hasPendingInstances=!1,this._isFlushingPendingInstances=!1,this._objectCount=0,this._nextUid=0,this._instancesByUid=new Map,this._instancesToReleaseAtEndOfTick=new Set,this._instancesToReleaseAffectedObjectClasses=new Set,this._objectReferenceTable=[],this._jsPropNameTable=[],this._canvasManager=null,this._compositingMode="standard",this._sampling="trilinear",this._isPixelRoundingEnabled=!1,this._needRender=!0,this._pauseOnBlur=!1,this._isPausedOnBlur=!1,this._tickCallback=(e)=>this.Tick(e),this._rafId=-1,this._tickCount=0,this._tickCountNoSave=0,this._execCount=0,this._hasStarted=!1,this._isInTick=!1,this._hasStartedTicking=!1,this._isLayoutFirstTick=!0,this._suspendCount=0,this._scheduleTriggersThrottle=new C3.PromiseThrottle(1),this._randomNumberCallback=()=>Math.random(),this._startTime=0,this._lastTickTime=0,this._dt1=0,this._dt=0,this._timeScale=1,this._minimumFramerate=30,this._gameTime=C3.New(C3.KahanSum),this._wallTime=C3.New(C3.KahanSum),this._fpsFrameCount=-1,this._fpsLastTime=0,this._fps=0,this._mainThreadTimeCounter=0,this._mainThreadTime=0,this._isLoadingState=!1,this._saveToSlotName="",this._loadFromSlotName="",this._loadFromJson=null,this._lastSaveJson="",this._triggerOnCreateAfterLoad=[],this._projectStorage=null,this._savegamesStorage=null,this._dispatcher=C3.New(C3.Event.Dispatcher),this._domEventHandlers=new Map,this._pendingResponsePromises=new Map,this._nextDomResponseId=0,this._didRequestDeviceOrientationEvent=!1,this._didRequestDeviceMotionEvent=!1,this._isReadyToHandleEvents=!1,this._waitingToHandleEvents=[],this._eventObjects={"pretick":C3.New(C3.Event,"pretick",!1),"tick":C3.New(C3.Event,"tick",!1),"tick2":C3.New(C3.Event,"tick2",!1),"instancedestroy":C3.New(C3.Event,"instancedestroy",!1),"beforelayoutchange":C3.New(C3.Event,"beforelayoutchange",!1),"layoutchange":C3.New(C3.Event,"layoutchange",!1)},this._eventObjects["instancedestroy"].instance=null,this._userScriptDispatcher=C3.New(C3.Event.Dispatcher),this._userScriptEventObjects=null,this._behInstsToTick=C3.New(C3.RedBlackSet,C3.BehaviorInstance.SortByTickSequence),this._behInstsToPostTick=C3.New(C3.RedBlackSet,C3.BehaviorInstance.SortByTickSequence),this._behInstsToTick2=C3.New(C3.RedBlackSet,C3.BehaviorInstance.SortByTickSequence),this._jobScheduler=C3.New(C3.JobSchedulerRuntime,this,n["jobScheduler"]),n["canvas"]&&(this._canvasManager=C3.New(C3.CanvasManager,this)),this._messagePort.onmessage=(a)=>this["_OnMessageFromDOM"](a.data),this.AddDOMComponentMessageHandler("runtime","visibilitychange",(a)=>this._OnVisibilityChange(a)),this.AddDOMComponentMessageHandler("runtime","opus-decode",(a)=>this._WasmDecodeWebMOpus(a["arrayBuffer"])),this.AddDOMComponentMessageHandler("runtime","get-remote-preview-status-info",()=>this._GetRemotePreviewStatusInfo()),this.AddDOMComponentMessageHandler("runtime","js-invoke-function",(a)=>this._InvokeFunctionFromJS(a)),this.AddDOMComponentMessageHandler("runtime","go-to-last-error-script",self["goToLastErrorScript"]),this._dispatcher.addEventListener("window-blur",(a)=>this._OnWindowBlur(a)),this._dispatcher.addEventListener("window-focus",()=>this._OnWindowFocus()),this._timelineManager.AddRuntimeListeners(),this._iRuntime=null,this._commonScriptInterfaces={keyboard:null,mouse:null,touch:null}}static Create(e){return C3.New(C3.Runtime,e)}Release(){C3.clearArray(this._allObjectClasses),this._objectClassesByName.clear(),this._objectClassesBySid.clear(),this._layoutManager.Release(),this._layoutManager=null,this._eventSheetManager.Release(),this._eventSheetManager=null,this._pluginManager.Release(),this._pluginManager=null,this._assetManager.Release(),this._assetManager=null,this._collisionEngine.Release(),this._collisionEngine=null,this._timelineManager.Release(),this._timelineManager=null,this._transitionManager.Release(),this._transitionManager=null,this._canvasManager&&(this._canvasManager.Release(),this._canvasManager=null),this._dispatcher.Release(),this._dispatcher=null,this._tickEvent=null,this._tickCallback=null}["_OnMessageFromDOM"](e){const a=e["type"];if("event"===a)this._OnEventFromDOM(e);else if("result"===a)this._OnResultFromDOM(e);else throw new Error(`unknown message '${a}'`)}_OnEventFromDOM(a){if(!this._isReadyToHandleEvents)return void this._waitingToHandleEvents.push(a);const e=a["component"],n=a["handler"],t=a["data"],s=a["dispatchOpts"],i=!!(s&&s["dispatchRuntimeEvent"]),r=!!(s&&s["dispatchUserScriptEvent"]),o=a["responseId"];if("runtime"===e){if(i){const e=new C3.Event(n);e.data=t,this._dispatcher.dispatchEventAndWaitAsyncSequential(e)}if(r){const e=new C3.Event(n,!0);for(const[a,n]of Object.entries(t))e[a]=n;this.DispatchUserScriptEvent(e)}}const d=this._domEventHandlers.get(e);if(!d)return void(i||r||console.warn(`[Runtime] No DOM event handlers for component '${e}'`));const _=d.get(n);if(!_)return void(i||r||console.warn(`[Runtime] No DOM handler '${n}' for component '${e}'`));let l=null;try{l=_(t)}catch(a){return console.error(`Exception in '${e}' handler '${n}':`,a),void(null!==o&&this._PostResultToDOM(o,!1,a.toString()))}null!==o&&(l&&l.then?l.then((e)=>this._PostResultToDOM(o,!0,e)).catch((a)=>{console.error(`Rejection from '${e}' handler '${n}':`,a),this._PostResultToDOM(o,!1,a.toString())}):this._PostResultToDOM(o,!0,l))}_PostResultToDOM(e,a,n){this._messagePort.postMessage({"type":"result","responseId":e,"isOk":a,"result":n})}_OnResultFromDOM(e){const a=e["responseId"],n=e["isOk"],t=e["result"],s=this._pendingResponsePromises.get(a);n?s.resolve(t):s.reject(t),this._pendingResponsePromises.delete(a)}AddDOMComponentMessageHandler(e,a,n){let t=this._domEventHandlers.get(e);if(t||(t=new Map,this._domEventHandlers.set(e,t)),t.has(a))throw new Error(`[Runtime] Component '${e}' already has handler '${a}'`);t.set(a,n)}PostComponentMessageToDOM(e,a,n){this._messagePort.postMessage({"type":"event","component":e,"handler":a,"data":n,"responseId":null})}PostComponentMessageToDOMAsync(e,a,n){const t=this._nextDomResponseId++,s=new Promise((e,a)=>{this._pendingResponsePromises.set(t,{resolve:e,reject:a})});return this._messagePort.postMessage({"type":"event","component":e,"handler":a,"data":n,"responseId":t}),s}PostToDebugger(e){if(!this.IsDebug())throw new Error("not in debug mode");this.PostComponentMessageToDOM("runtime","post-to-debugger",e)}async Init(e){this.IsDebug()?await C3Debugger.Init(this):self.C3Debugger&&self.C3Debugger.InitPreview(this);const[a]=await Promise.all([this._assetManager.FetchJson(this._dataJsonFilename),this._MaybeLoadOpusDecoder(),this._jobScheduler.Init()]);this._LoadDataJson(a),await this._InitialiseCanvas(e),this.IsPreview()||console.info("Made with Construct 3, the game and app creator :: https://www.construct.net");const n=this.GetWebGLRenderer();n?(console.info(`[C3 runtime] Hosted in ${this.IsInWorker()?"worker":"DOM"}, rendering with WebGL ${n.GetWebGLVersionNumber()} [${n.GetUnmaskedRenderer()}] (${n.IsDesynchronized()?"desynchronized":"standard"} compositing)`),n.HasMajorPerformanceCaveat()&&console.warn("[C3 runtime] WebGL indicates a major performance caveat. Software rendering may be in use. This can result in significantly degraded performance.")):console.info(`[C3 runtime] Hosted in ${this.IsInWorker()?"worker":"DOM"}, headless`),this._isReadyToHandleEvents=!0;for(const a of this._waitingToHandleEvents)this._OnEventFromDOM(a);C3.clearArray(this._waitingToHandleEvents),this._canvasManager&&this._canvasManager.StartLoadingScreen();for(const a of e["runOnStartupFunctions"])this._additionalLoadPromises.push(this._RunOnStartupFunction(a));if(await Promise.all([this._assetManager.WaitForAllToLoad(),...this._additionalLoadPromises]),!this._assetManager.HasHadErrorLoading())return this._canvasManager&&(await this._canvasManager.EndLoadingScreen()),await this._dispatcher.dispatchEventAndWaitAsync(new C3.Event("beforeruntimestart")),await this.Start(),this._messagePort.postMessage({"type":"runtime-ready"}),this}async _RunOnStartupFunction(e){try{await e(this._iRuntime)}catch(e){console.error("[C3 runtime] Error in runOnStartup function: ",e)}}_LoadDataJson(e){const a=e["project"];this._projectName=a[0],this._projectVersion=a[16],this._projectUniqueId=a[31],this._isPixelRoundingEnabled=!!a[9],this._originalViewportWidth=this._viewportWidth=a[10],this._originalViewportHeight=this._viewportHeight=a[11],this._parallaxXorigin=this._originalViewportWidth/2,this._parallaxYorigin=this._originalViewportHeight/2,this._compositingMode=a[36],this._sampling=a[14],this._usesLoaderLayout=!!a[18],this._loaderStyle=a[19],this._nextUid=a[21],this._pauseOnBlur=a[22],this._assetManager._SetAudioFiles(a[7],a[25]),this._assetManager._SetMediaSubfolder(a[8]),this._assetManager._SetFontsSubfolder(a[32]),this._assetManager._SetIconsSubfolder(a[28]),this._assetManager._SetWebFonts(a[29]),this._canvasManager&&(this._canvasManager.SetFullscreenMode(C3.CanvasManager._FullscreenModeNumberToString(a[12])),this._canvasManager.SetFullscreenScalingQuality(a[23]?"high":"low"),this._canvasManager._SetGPUPowerPreference(a[34])),this._pluginManager.CreateSystemPlugin(),this._objectReferenceTable=self.C3_GetObjectRefTable();for(const n of a[2])this._pluginManager.CreatePlugin(n);this._objectReferenceTable=self.C3_GetObjectRefTable(),this._LoadJsPropNameTable();for(const n of a[3]){const e=C3.ObjectClass.Create(this,this._allObjectClasses.length,n);this._allObjectClasses.push(e),this._objectClassesByName.set(e.GetName().toLowerCase(),e),this._objectClassesBySid.set(e.GetSID(),e)}for(const n of a[4]){const e=this._allObjectClasses[n[0]];e._LoadFamily(n)}for(const n of a[27]){const e=n.map((e)=>this._allObjectClasses[e]);this._allContainers.push(C3.New(C3.Container,this,e))}for(const a of this._allObjectClasses)a._OnAfterCreate();for(const n of a[5])this._layoutManager.Create(n);const n=a[1];if(n){const e=this._layoutManager.GetLayoutByName(n);e&&this._layoutManager.SetFirstLayout(e)}for(const n of a[33])this._timelineManager.Create(n);for(const n of a[35])this._transitionManager.Create(n);this._InitScriptInterfaces();for(const n of a[6])this._eventSheetManager.Create(n);this._eventSheetManager._PostInit(),this._InitGlobalVariableScriptInterface(),C3.clearArray(this._objectReferenceTable),this.FlushPendingInstances();let t="any";const s=a[20];1===s?t="portrait":2===s&&(t="landscape"),this.PostComponentMessageToDOM("runtime","set-target-orientation",{"targetOrientation":t})}GetLoaderStyle(){return this._loaderStyle}IsFBInstantAvailable(){return this._isFBInstantAvailable}IsLoading(){return this._isLoading}AddLoadPromise(e){this._additionalLoadPromises.push(e)}_GetNextFamilyIndex(){return this._familyCount++}GetFamilyCount(){return this._familyCount}_AddEffectList(e){this._allEffectLists.push(e)}_GetAllEffectLists(){return this._allEffectLists}async _InitialiseCanvas(e){this._canvasManager&&(await this._canvasManager.CreateCanvas(e),this._canvasManager.InitLoadingScreen(this._loaderStyle))}async _MaybeLoadOpusDecoder(){if(this._assetManager.IsAudioFormatSupported("audio/webm; codecs=opus"))return;let e=null,a=null;try{this.IsWKWebView()?a=await this._assetManager.CordovaFetchLocalFileAsArrayBuffer(this._opusWasmBinaryUrl):e=await this._assetManager.FetchBlob(this._opusWasmBinaryUrl)}catch(e){return void console.info("Failed to fetch Opus decoder WASM; assuming project has no Opus audio.",e)}a?this.AddJobWorkerBuffer(a,"opus-decoder-wasm"):this.AddJobWorkerBlob(e,"opus-decoder-wasm"),await this.AddJobWorkerScripts([this._opusWasmScriptUrl])}async _WasmDecodeWebMOpus(e){const a=await this.AddJob("OpusDecode",{"arrayBuffer":e},[e]);return a}async Start(){if(this._hasStarted=!0,this._startTime=Date.now(),this._usesLoaderLayout){for(const e of this._allObjectClasses)e.IsFamily()||e.IsOnLoaderLayout()||!e.IsWorldType()||e.OnCreate();this._assetManager.WaitForAllToLoad().then(()=>{this._isLoading=!1,this._OnLoadFinished()})}else this._isLoading=!1;this._assetManager.SetInitialLoadFinished(),this.IsDebug()&&C3Debugger.RuntimeInit(a);for(const e of this._layoutManager.GetAllLayouts())e._CreateGlobalNonWorlds();const e=this._layoutManager.GetFirstLayout();await e._Load(null,this.GetWebGLRenderer()),await e._StartRunning(!0),this._fpsLastTime=performance.now(),this._usesLoaderLayout||this._OnLoadFinished();const n=await this.PostComponentMessageToDOMAsync("runtime","before-start-ticking");n["isSuspended"]?this._suspendCount++:this.Tick()}_OnLoadFinished(){this.Trigger(C3.Plugins.System.Cnds.OnLoadFinished,null),this.PostComponentMessageToDOM("runtime","register-sw")}GetObjectReference(e){e=Math.floor(e);const a=this._objectReferenceTable;if(0>e||e>=a.length)throw new Error("invalid object reference");return a[e]}_LoadJsPropNameTable(){for(const e of self.C3_JsPropNameTable){const a=C3.first(Object.keys(e));this._jsPropNameTable.push(a)}}GetJsPropName(e){e=Math.floor(e);const a=this._jsPropNameTable;if(0>e||e>=a.length)throw new Error("invalid prop reference");return a[e]}HasDOM(){return this._hasDom}IsHeadless(){return this._isHeadless}IsInWorker(){return this._isInWorker}GetBaseURL(){return this._baseUrl}GetEventSheetManager(){return this._eventSheetManager}GetEventStack(){return this._eventSheetManager.GetEventStack()}GetCurrentEventStackFrame(){return this._eventSheetManager.GetCurrentEventStackFrame()}GetCurrentEvent(){return this._eventSheetManager.GetCurrentEvent()}GetCurrentCondition(){return this._eventSheetManager.GetCurrentCondition()}IsCurrentConditionFirst(){return 0===this.GetCurrentEventStackFrame().GetConditionIndex()}GetCurrentAction(){return this._eventSheetManager.GetCurrentAction()}GetPluginManager(){return this._pluginManager}GetSystemPlugin(){return this._pluginManager.GetSystemPlugin()}GetObjectClassByIndex(e){if(e=Math.floor(e),0>e||e>=this._allObjectClasses.length)throw new RangeError("invalid index");return this._allObjectClasses[e]}GetObjectClassByName(e){return this._objectClassesByName.get(e.toLowerCase())||null}GetObjectClassBySID(e){return this._objectClassesBySid.get(e)||null}GetSingleGlobalObjectClassByCtor(e){const a=this._pluginManager.GetPluginByConstructorFunction(e);return a?a.GetSingleGlobalObjectClass():null}GetAllObjectClasses(){return this._allObjectClasses}Dispatcher(){return this._dispatcher}UserScriptDispatcher(){return this._userScriptDispatcher}DispatchUserScriptEvent(a){const e=this.IsDebug()&&!this._eventSheetManager.IsInEventEngine();e&&C3Debugger.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(a),e&&C3Debugger.AddScriptTime()}GetOriginalViewportWidth(){return this._originalViewportWidth}GetOriginalViewportHeight(){return this._originalViewportHeight}SetOriginalViewportSize(e,a){this._originalViewportWidth=e,this._originalViewportHeight=a}GetViewportWidth(){return this._viewportWidth}GetViewportHeight(){return this._viewportHeight}SetViewportSize(e,a){this._viewportWidth=e,this._viewportHeight=a}GetParallaxXOrigin(){return this._parallaxXorigin}GetParallaxYOrigin(){return this._parallaxYorigin}GetCanvasManager(){return this._canvasManager}GetDrawWidth(){return this._canvasManager?this._canvasManager.GetDrawWidth():this._viewportWidth}GetDrawHeight(){return this._canvasManager?this._canvasManager.GetDrawHeight():this._viewportHeight}GetRenderScale(){return this._canvasManager?this._canvasManager.GetRenderScale():1}GetDisplayScale(){return this._canvasManager?this._canvasManager.GetDisplayScale():1}GetCanvasClientX(){return this._canvasManager?this._canvasManager.GetCanvasClientX():0}GetCanvasClientY(){return this._canvasManager?this._canvasManager.GetCanvasClientY():0}GetCanvasCssWidth(){return this._canvasManager?this._canvasManager.GetCssWidth():0}GetCanvasCssHeight(){return this._canvasManager?this._canvasManager.GetCssHeight():0}GetFullscreenMode(){return this._canvasManager?this._canvasManager.GetFullscreenMode():"off"}GetAdditionalRenderTarget(e){return this._canvasManager?this._canvasManager.GetAdditionalRenderTarget(e):null}ReleaseAdditionalRenderTarget(e){this._canvasManager&&this._canvasManager.ReleaseAdditionalRenderTarget(e)}_SetUsesAnyBackgroundBlending(e){this._usesAnyBackgroundBlending=!!e}UsesAnyBackgroundBlending(){return this._usesAnyBackgroundBlending}GetGPUUtilisation(){return this._canvasManager?this._canvasManager.GetGPUUtilisation():NaN}IsLinearSampling(){return"nearest"!==this.GetSampling()}GetCompositingMode(){return this._compositingMode}GetSampling(){return this._sampling}UsesLoaderLayout(){return this._usesLoaderLayout}GetLayoutManager(){return this._layoutManager}GetMainRunningLayout(){return this._layoutManager.GetMainRunningLayout()}GetTimelineManager(){return this._timelineManager}GetTransitionManager(){return this._transitionManager}GetAssetManager(){return this._assetManager}LoadImage(e){return this._assetManager.LoadImage(e)}CreateInstance(e,a,n,t){return this.CreateInstanceFromData(e,a,!1,n,t)}CreateInstanceFromData(e,a,n,t,s,i){let r=null,o=null;if(e instanceof C3.ObjectClass){if(o=e,o.IsFamily()){const e=o.GetFamilyMembers(),a=Math.floor(this.Random()*e.length);o=e[a]}r=o.GetDefaultInstanceData()}else r=e,o=this.GetObjectClassByIndex(r[1]);const d=o.GetPlugin().IsWorldType();if(this._isLoading&&d&&!o.IsOnLoaderLayout())return null;const _=a;d||(a=null);let l=n&&!i&&r&&!this._instancesByUid.has(r[2])?r[2]:this._nextUid++;const g=r?r[0]:null,c=C3.New(C3.Instance,{runtime:this,objectType:o,layer:a,worldData:g,instVarData:r?r[3]:null,uid:l});this._instancesByUid.set(l,c);let u=null;if(d&&(u=c.GetWorldInfo(),"undefined"!=typeof t&&"undefined"!=typeof s&&(u.SetX(t),u.SetY(s)),o._SetAnyCollisionCellChanged(!0)),a&&(a._AddInstance(c,!0),(1!==a.GetParallaxX()||1!==a.GetParallaxY())&&o._SetAnyInstanceParallaxed(!0),a.GetLayout().MaybeLoadTexturesFor(o)),(this._objectCount++,o.IsInContainer()&&!n&&!i)){for(const e of o.GetContainer().objectTypes()){if(e===o)continue;const a=this.CreateInstanceFromData(e,_,!1,u?u.GetX():t,u?u.GetY():s,!0);c._AddSibling(a)}for(const e of c.siblings()){e._AddSibling(c);for(const a of c.siblings())e!==a&&e._AddSibling(a)}}o._SetIIDsStale();const m=r?C3.cloneArray(r[5]):null,p=r?r[4].map((e)=>C3.cloneArray(e)):null;if(c._CreateSdkInstance(m,p),d&&g&&14===g.length){const e=g[13];c._SetHasTilemap(),c.GetSdkInstance().LoadTilemapData(e[2],e[0],e[1])}return this._instancesPendingCreate.push(c),this._hasPendingInstances=!0,this.IsDebug()&&C3Debugger.InstanceCreated(c),c}DestroyInstance(e){if(this._instancesToReleaseAtEndOfTick.has(e))return;const a=e.GetObjectClass();let n=this._instancesPendingDestroy.get(a);if(n){if(n.has(e))return;n.add(e)}else n=new Set,n.add(e),this._instancesPendingDestroy.set(a,n);if(this.IsDebug()&&C3Debugger.InstanceDestroyed(e),e._MarkDestroyed(),this._hasPendingInstances=!0,e.IsInContainer())for(const a of e.siblings())this.DestroyInstance(a);if(this._isFlushingPendingInstances&&C3.NotYetImplemented(),!this._layoutManager.IsEndingLayout()){const a=this.GetEventSheetManager();a.BlockFlushingInstances(!0),e._TriggerOnDestroyed(),a.BlockFlushingInstances(!1)}}FlushPendingInstances(){this._hasPendingInstances&&(this._isFlushingPendingInstances=!0,this._FlushInstancesPendingCreate(),this._FlushInstancesPendingDestroy(),this._isFlushingPendingInstances=!1,this._hasPendingInstances=!1,this.UpdateRender())}_FlushInstancesPendingCreate(){for(const e of this._instancesPendingCreate){const a=e.GetObjectClass();a._AddInstance(e);for(const n of a.GetFamilies())n._AddInstance(e),n._SetIIDsStale()}C3.clearArray(this._instancesPendingCreate)}_FlushInstancesPendingDestroy(){this._dispatcher.SetDelayRemoveEventsEnabled(!0);for(const[e,a]of this._instancesPendingDestroy.entries())this._FlushInstancesPendingDestroyForObjectClass(e,a),a.clear();this._instancesPendingDestroy.clear(),this._dispatcher.SetDelayRemoveEventsEnabled(!1)}_FlushInstancesPendingDestroyForObjectClass(e,a){C3.arrayRemoveAllInSet(e.GetInstances(),a),e._SetIIDsStale(),this._instancesToReleaseAffectedObjectClasses.add(e),0===e.GetInstances().length&&e._SetAnyInstanceParallaxed(!1);for(const n of e.GetFamilies())C3.arrayRemoveAllInSet(n.GetInstances(),a),n._SetIIDsStale(),this._instancesToReleaseAffectedObjectClasses.add(n);if(e.GetPlugin().IsWorldType()){const e=new Set([...a].map((e)=>e.GetWorldInfo().GetLayer()));for(const n of e)n._RemoveAllInstancesInSet(a)}for(const n of a){const e=this._eventObjects["instancedestroy"];e.instance=n,this._dispatcher.dispatchEvent(e),this._instancesByUid.delete(n.GetUID());const a=n.GetWorldInfo();a&&(a._RemoveFromCollisionCells(),a._RemoveFromRenderCells()),this._instancesToReleaseAtEndOfTick.add(n),this._objectCount--}}_GetInstancesPendingCreate(){return this._instancesPendingCreate}_GetNewUID(){return this._nextUid++}_MapInstanceByUID(e,a){this._instancesByUid.set(e,a)}_OnWebGLContextLost(){this._dispatcher.dispatchEvent(C3.New(C3.Event,"webglcontextlost")),this.SetSuspended(!0);for(const e of this._allObjectClasses)!e.IsFamily()&&e.HasLoadedTextures()&&e.ReleaseTextures();this.GetMainRunningLayout()._OnWebGLContextLost(),C3.ImageInfo.OnWebGLContextLost(),C3.ImageAsset.OnWebGLContextLost()}async _OnWebGLContextRestored(){await this.GetMainRunningLayout()._Load(null,this.GetWebGLRenderer()),this._dispatcher.dispatchEvent(C3.New(C3.Event,"webglcontextrestored")),this.SetSuspended(!1),this.UpdateRender()}_OnVisibilityChange(a){this.SetSuspended(a["hidden"])}_OnWindowBlur(a){this.IsPreview()&&this._pauseOnBlur&&!C3.Platform.IsMobile&&(a.data["parentHasFocus"]||(this.SetSuspended(!0),this._isPausedOnBlur=!0))}_OnWindowFocus(){this._isPausedOnBlur&&(this.SetSuspended(!1),this._isPausedOnBlur=!1)}IsSuspended(){return 0this._suspendCount&&(this._suspendCount=0);const n=this.IsSuspended();if(!a&&n)console.log("[Construct 3] Suspending"),-1!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=-1),this._dispatcher.dispatchEvent(C3.New(C3.Event,"suspend")),this.Trigger(C3.Plugins.System.Cnds.OnSuspend,null);else if(a&&!n){console.log("[Construct 3] Resuming");const e=performance.now();this._lastTickTime=e,this._fpsLastTime=e,this._fpsFrameCount=0,this._fps=0,this._mainThreadTime=0,this._mainThreadTimeCounter=0,this._dispatcher.dispatchEvent(C3.New(C3.Event,"resume")),this.Trigger(C3.Plugins.System.Cnds.OnResume,null),this.HitBreakpoint()||this.Tick(e)}}_AddBehInstToTick(e){this._behInstsToTick.Add(e)}_AddBehInstToPostTick(e){this._behInstsToPostTick.Add(e)}_AddBehInstToTick2(e){this._behInstsToTick2.Add(e)}_RemoveBehInstToTick(e){this._behInstsToTick.Remove(e)}_RemoveBehInstToPostTick(e){this._behInstsToPostTick.Remove(e)}_RemoveBehInstToTick2(e){this._behInstsToTick2.Remove(e)}_BehaviorTick(){for(const e of this._behInstsToTick)e.Tick()}_BehaviorPostTick(){for(const e of this._behInstsToPostTick)e.PostTick()}_BehaviorTick2(){for(const e of this._behInstsToTick2)e.Tick2()}*_DebugBehaviorTick(){for(const e of this._behInstsToTick){const a=e.Tick();C3.IsIterator(a)&&(yield*a)}}*_DebugBehaviorPostTick(){for(const e of this._behInstsToPostTick){const a=e.PostTick();C3.IsIterator(a)&&(yield*a)}}*_DebugBehaviorTick2(){for(const e of this._behInstsToTick2){const a=e.Tick2();C3.IsIterator(a)&&(yield*a)}}async Tick(e,a,n){if(this._rafId=-1,this._hasStartedTicking=!0,this._hasStarted&&(!this.IsSuspended()||a||n)){const a=performance.now();this._isInTick=!0,e||(e=a),await this.Step(e),n||this.Render(),this.IsSuspended()||n||-1!==this._rafId||(this._rafId=self.requestAnimationFrame(this._tickCallback)),this._tickCount++,this._tickCountNoSave++,this._execCount++,this._isInTick=!1,this._mainThreadTimeCounter+=performance.now()-a}}async Step(e){const a=this._eventSheetManager,n=this._dispatcher,t=this._eventObjects,s=this._userScriptEventObjects,i=this.IsDebug(),r=this.IsDebugging();if(this._MeasureDt(e),this.FlushPendingInstances(),a.BlockFlushingInstances(!0),this.PushCurrentLayout(this.GetMainRunningLayout()),i&&C3Debugger.StartMeasuringTime(),r?await a.DebugRunScheduledWaits():a.RunScheduledWaits(),i&&C3Debugger.AddEventsTime(),this.PopCurrentLayout(),a.BlockFlushingInstances(!1),this.FlushPendingInstances(),a.BlockFlushingInstances(!0),await n.dispatchEventAndWaitAsync(t["pretick"]),i&&C3Debugger.StartMeasuringTime(),r?await this.DebugIterateAndBreak(this._DebugBehaviorTick()):this._BehaviorTick(),r?await this.DebugIterateAndBreak(this._DebugBehaviorPostTick()):this._BehaviorPostTick(),i&&C3Debugger.AddBehaviorTickTime(),i&&C3Debugger.StartMeasuringTime(),r?await this.DebugFireGeneratorEventAndBreak(t["tick"]):n.dispatchEvent(t["tick"]),i&&C3Debugger.AddPluginTickTime(),a.BlockFlushingInstances(!1),this.DispatchUserScriptEvent(s["tick"]),this._NeedsHandleSaveOrLoad()&&(await this._HandleSaveOrLoad()),this.GetLayoutManager().IsPendingChangeMainLayout()&&(await this._MaybeChangeLayout()),i&&C3Debugger.StartMeasuringTime(),r?await a.DebugRunEvents(this._layoutManager):a.RunEvents(this._layoutManager),i&&C3Debugger.AddEventsTime(),this._collisionEngine.ClearRegisteredCollisions(),0a++;)await this._DoChangeLayout(e.GetPendingChangeMainLayout())}_MeasureDt(e){if(0!==this._lastTickTime){const a=Math.max(e-this._lastTickTime,0);this._dt1=a/1e3;const n=1/this._minimumFramerate;.5n&&(this._dt1=n)}this._lastTickTime=e,this._dt=this._dt1*this._timeScale,this._gameTime.Add(this._dt),this._wallTime.Add(this._dt1),this._canvasManager&&this._canvasManager._UpdateTick(),1e3<=e-this._fpsLastTime&&(this._fpsLastTime+=1e3,1e3<=e-this._fpsLastTime&&(this._fpsLastTime=e),this._fps=this._fpsFrameCount,this._fpsFrameCount=0,this._mainThreadTime=Math.min(this._mainThreadTimeCounter/1e3,1),this._mainThreadTimeCounter=0,this._canvasManager&&this._canvasManager._Update1sFrameRange(),this._collisionEngine._Update1sStats(),this.IsDebug()&&C3Debugger.Update1sPerfStats()),this._fpsFrameCount++}async _DoChangeLayout(e){const a=this._dispatcher,n=this.GetLayoutManager(),t=n.GetMainRunningLayout();await t._StopRunning(),t._Unload(e,this.GetWebGLRenderer()),t===e&&this._eventSheetManager.ClearAllScheduledWaits(),this._collisionEngine.ClearRegisteredCollisions(),a.dispatchEvent(this._eventObjects["beforelayoutchange"]),C3.Asyncify.SetHighThroughputMode(!0),await e._Load(t,this.GetWebGLRenderer()),C3.Asyncify.SetHighThroughputMode(!1),await e._StartRunning(!1),a.dispatchEvent(this._eventObjects["layoutchange"]),this.UpdateRender(),this._isLayoutFirstTick=!0,this.FlushPendingInstances()}UpdateRender(){this._needRender=!0}GetWebGLRenderer(){return this._canvasManager?this._canvasManager.GetWebGLRenderer():null}Render(){if(!this._canvasManager||this._canvasManager.IsWebGLContextLost())return;const e=this.GetWebGLRenderer();if(e.Start(),e.CheckForQueryResults(),!this._needRender)return void e.IncrementFrameNumber();const a=this.IsDebug();a&&C3Debugger.StartMeasuringTime(),this._needRender=!1;let n=null;e.SupportsGPUProfiling()&&(n=this._canvasManager.GetGPUFrameTimingsBuffer().AddTimeElapsedQuery(),e.StartQuery(n)),e.SetTextureFillMode(),e.SetAlphaBlend(),e.SetColorRgba(1,1,1,1),e.SetRenderTarget(null),e.SetTexture(null);const t=this._layoutManager.GetMainRunningLayout();t.Draw(e),n&&e.EndQuery(n),e.Finish(),a&&(C3Debugger.AddDrawCallsTime(),C3Debugger.UpdateInspectHighlight()),this._canvasManager&&this._canvasManager._MaybeTakeSnapshot()}Trigger(e,a){if(!this._hasStarted)return!1;const n=!this._isInTick&&!this._eventSheetManager.IsInTrigger();let t=0;n&&(t=performance.now());const s=this.IsDebug();s&&this.SetDebuggingEnabled(!1);const i=this._eventSheetManager._Trigger(this._layoutManager,e,a);if(n){const e=performance.now()-t;this._mainThreadTimeCounter+=e,s&&C3Debugger.AddTriggersTime(e)}return s&&this.SetDebuggingEnabled(!0),i}DebugTrigger(e,a){if(!this.IsDebug())return this.Trigger(e,a);if(this.HitBreakpoint())throw new Error("called DebugTrigger() while stopped on breakpoint");if(!this._isInTick&&!this._eventSheetManager.IsInTrigger())throw new Error("called DebugTrigger() outside of event code - use TriggerAsync() instead");return this._eventSheetManager._DebugTrigger(this._layoutManager,e,a)}async TriggerAsync(e,a){if(!this.IsDebugging())return this.Trigger(e,a);if(!this._hasStarted)return!1;if(this.HitBreakpoint())return this._eventSheetManager.QueueDebugTrigger(e,a);if(!this.GetMainRunningLayout())return this._eventSheetManager.QueueTrigger(e,a);const n=performance.now(),t=this._eventSheetManager._DebugTrigger(this._layoutManager,e,a);let s=t.next();for(;!s.done;)await this.DebugBreak(s.value),s=t.next();return this.IsSuspended()||this._eventSheetManager.IsInTrigger()||(await this._eventSheetManager.RunQueuedDebugTriggersAsync(),this._hasStartedTicking&&-1===this._rafId&&!this._isInTick&&(this._rafId=self.requestAnimationFrame(this._tickCallback))),this._mainThreadTimeCounter+=performance.now()-n,s.value}FastTrigger(e,a,n){const t=this.IsDebug();t&&this.SetDebuggingEnabled(!1);const s=this._eventSheetManager._FastTrigger(this._layoutManager,e,a,n);return t&&this.SetDebuggingEnabled(!0),s}DebugFastTrigger(e,a,n){return this._eventSheetManager._DebugFastTrigger(this._layoutManager,e,a,n)}ScheduleTriggers(e){return this._scheduleTriggersThrottle.Add(e)}PushCurrentLayout(e){this._currentLayoutStack.push(e)}PopCurrentLayout(){if(!this._currentLayoutStack.length)throw new Error("layout stack empty");this._currentLayoutStack.pop()}GetCurrentLayout(){return this._currentLayoutStack.length?this._currentLayoutStack[this._currentLayoutStack.length-1]:this.GetMainRunningLayout()}GetDt(e){return e&&-1!==e.GetTimeScale()?this._dt1*e.GetTimeScale():this._dt}_GetDtFast(){return this._dt}GetDt1(){return this._dt1}GetTimeScale(){return this._timeScale}SetTimeScale(e){(isNaN(e)||0>e)&&(e=0),this._timeScale=e}SetMinimumFramerate(e){this._minimumFramerate=C3.clamp(e,1,120)}GetMinimumFramerate(){return this._minimumFramerate}GetFPS(){return this._fps}GetMainThreadTime(){return this._mainThreadTime}GetStartTime(){return this._startTime}GetGameTime(){return this._gameTime.Get()}GetWallTime(){return this._wallTime.Get()}GetTickCount(){return this._tickCount}GetTickCountNoSave(){return this._tickCountNoSave}IncrementExecCount(){++this._execCount}GetExecCount(){return this._execCount}GetObjectCount(){return this._objectCount}GetProjectName(){return this._projectName}GetProjectVersion(){return this._projectVersion}GetProjectUniqueId(){return this._projectUniqueId}GetInstanceByUID(e){if(this._isLoadingState)throw new Error("cannot call while loading state - wait until afterload event");return this._instancesByUid.get(e)||null}_RefreshUidMap(){this._instancesByUid.clear();for(const e of this._allObjectClasses)if(!e.IsFamily())for(const a of e.GetInstances())this._instancesByUid.set(a.GetUID(),a)}IsPreview(){return"preview"===this._exportType}IsDebug(){return this._isDebug}GetExportType(){return this._exportType}IsCordova(){return"cordova"===this._exportType}IsWKWebView(){return this._isWKWebView}GetCollisionEngine(){return this._collisionEngine}GetSolidBehavior(){return this._pluginManager.GetSolidBehavior()}GetJumpthruBehavior(){return this._pluginManager.GetJumpthruBehavior()}IsLayoutFirstTick(){return this._isLayoutFirstTick}SetPixelRoundingEnabled(a){a=!!a;this._isPixelRoundingEnabled===a||(this._isPixelRoundingEnabled=a,this.UpdateRender())}IsPixelRoundingEnabled(){return this._isPixelRoundingEnabled}SaveToSlot(e){this._saveToSlotName=e}LoadFromSlot(e){this._loadFromSlotName=e}LoadFromJsonString(e){this._loadFromJson=e}GetLastSaveJsonString(){return this._lastSaveJson}_NeedsHandleSaveOrLoad(){return!!(this._saveToSlotName||this._loadFromSlotName||null!==this._loadFromJson)}async _HandleSaveOrLoad(){if(this._saveToSlotName&&(this.FlushPendingInstances(),await this._DoSaveToSlot(this._saveToSlotName),this._ClearSaveOrLoad()),this._loadFromSlotName&&(await this._DoLoadFromSlot(this._loadFromSlotName),this._ClearSaveOrLoad(),this.IsDebug()&&C3Debugger.StepIfPausedInDebugger()),null!==this._loadFromJson){this.FlushPendingInstances();try{await this._DoLoadFromJsonString(this._loadFromJson),this._lastSaveJson=this._loadFromJson,await this.TriggerAsync(C3.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct 3] Failed to load state from JSON string: ",e),await this.TriggerAsync(C3.Plugins.System.Cnds.OnLoadFailed,null)}this._ClearSaveOrLoad()}}_ClearSaveOrLoad(){this._saveToSlotName="",this._loadFromSlotName="",this._loadFromJson=null}_GetProjectStorage(){return this._projectStorage||(this._projectStorage=localforage.createInstance({name:"c3-localstorage-"+this.GetProjectUniqueId(),description:this.GetProjectName()})),this._projectStorage}_GetSavegamesStorage(){return this._savegamesStorage||(this._savegamesStorage=localforage.createInstance({name:"c3-savegames-"+this.GetProjectUniqueId(),description:this.GetProjectName()})),this._savegamesStorage}async _DoSaveToSlot(e){const a=this._SaveToJsonString();try{await this._GetSavegamesStorage().setItem(e,a),console.log("[Construct 3] Saved state to storage ("+a.length+" chars)"),this._lastSaveJson=a,await this.TriggerAsync(C3.Plugins.System.Cnds.OnSaveComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct 3] Failed to save state to storage: ",e),await this.TriggerAsync(C3.Plugins.System.Cnds.OnSaveFailed,null)}}async _DoLoadFromSlot(e){try{const a=await this._GetSavegamesStorage().getItem(e);if(!a)throw new Error("empty slot");console.log("[Construct 3] Loaded state from storage ("+a.length+" chars)"),await this._DoLoadFromJsonString(a),this._lastSaveJson=a,await this.TriggerAsync(C3.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct 3] Failed to load state from storage: ",e),await this.TriggerAsync(C3.Plugins.System.Cnds.OnLoadFailed,null)}}_SaveToJsonString(){const e={"c3save":!0,"version":1,"rt":{"time":this.GetGameTime(),"walltime":this.GetWallTime(),"timescale":this.GetTimeScale(),"tickcount":this.GetTickCount(),"execcount":this.GetExecCount(),"next_uid":this._nextUid,"running_layout":this.GetMainRunningLayout().GetSID(),"start_time_offset":Date.now()-this._startTime},"types":{},"layouts":{},"events":this._eventSheetManager._SaveToJson()};for(const a of this._allObjectClasses)a.IsFamily()||a.HasNoSaveBehavior()||(e["types"][a.GetSID().toString()]=a._SaveToJson());for(const a of this._layoutManager.GetAllLayouts())e["layouts"][a.GetSID().toString()]=a._SaveToJson();return JSON.stringify(e)}IsLoadingState(){return this._isLoadingState}_TriggerOnCreateAfterLoad(e){C3.shallowAssignArray(this._triggerOnCreateAfterLoad,e)}async _DoLoadFromJsonString(e){const a=JSON.parse(e);if(a["c2save"])throw new Error("C2 saves are incompatible with C3 runtime");if(!a["c3save"])throw new Error("not valid C3 save data");if(1n||n>=s.length)throw new Error("missing sibling instance");e._AddSibling(s[n])}}this._dispatcher.dispatchEvent(C3.New(C3.Event,"afterload")),this.UpdateRender()}async AddJobWorkerScripts(e){const a=await Promise.all(e.map((e)=>this._assetManager.FetchBlob(e))),n=a.map((e)=>URL.createObjectURL(e));this._jobScheduler.ImportScriptsToJobWorkers(n)}AddJobWorkerBlob(e,a){this._jobScheduler.SendBlobToJobWorkers(e,a)}AddJobWorkerBuffer(e,a){this._jobScheduler.SendBufferToJobWorkers(e,a)}AddJob(e,a,n){return this._jobScheduler.AddJob(e,a,n)}BroadcastJob(e,a,n){return this._jobScheduler.BroadcastJob(e,a,n)}InvokeDownload(e,a){this.PostComponentMessageToDOM("runtime","invoke-download",{"url":e,"filename":a})}async RasterSvgImage(e,a,n){if(this.IsInWorker())return await this.PostComponentMessageToDOMAsync("runtime","raster-svg-image",{"blob":e,"width":a,"height":n});else{const t=await C3.BlobToImage(e);return await self["C3_RasterSvgImage"](t,a,n)}}RequestDeviceOrientationEvent(){this._didRequestDeviceOrientationEvent||(this._didRequestDeviceOrientationEvent=!0,this.PostComponentMessageToDOM("runtime","enable-device-orientation"))}RequestDeviceMotionEvent(){this._didRequestDeviceMotionEvent||(this._didRequestDeviceMotionEvent=!0,this.PostComponentMessageToDOM("runtime","enable-device-motion"))}Random(){return this._randomNumberCallback()}SetRandomNumberGeneratorCallback(e){this._randomNumberCallback=e}_GetRemotePreviewStatusInfo(){return{"fps":this.GetFPS(),"cpu":this.GetMainThreadTime(),"gpu":this.GetGPUUtilisation(),"layout":this.GetMainRunningLayout()?this.GetMainRunningLayout().GetName():"","renderer":this.GetWebGLRenderer().GetUnmaskedRenderer()}}HitBreakpoint(){return!!this.IsDebug()&&C3Debugger.HitBreakpoint()}DebugBreak(e){return this.IsDebugging()?C3Debugger.DebugBreak(e):Promise.resolve()}DebugBreakNext(){return!!this.IsDebugging()&&C3Debugger.BreakNext()}SetDebugBreakpointsEnabled(a){this._breakpointsEnabled=!!a,this._UpdateDebuggingFlag()}AreDebugBreakpointsEnabled(){return this._breakpointsEnabled}IsDebugging(){return this._isDebugging}SetDebuggingEnabled(e){e?this._debuggingDisabled--:this._debuggingDisabled++,this._UpdateDebuggingFlag()}_UpdateDebuggingFlag(){this._isDebugging=this.IsDebug()&&this._breakpointsEnabled&&0===this._debuggingDisabled}IsCPUProfiling(){return this.IsDebug()&&C3Debugger.IsCPUProfiling()}IsGPUProfiling(){return this.IsDebug()&&this.GetWebGLRenderer().SupportsGPUProfiling()&&C3Debugger.IsGPUProfiling()}async DebugIterateAndBreak(e){if(e)for(const a of e)await this.DebugBreak(a)}DebugFireGeneratorEventAndBreak(e){return this.DebugIterateAndBreak(this._dispatcher.dispatchGeneratorEvent(e))}_InvokeFunctionFromJS(a){return this._eventSheetManager._InvokeFunctionFromJS(a["name"],a["params"])}GetIRuntime(){return this._iRuntime}_CreateUserScriptEvent(a){const n=C3.New(C3.Event,a,!1);return n.runtime=this._iRuntime,n}_InitScriptInterfaces(){const e={};for(const a of this._allObjectClasses)e[a.GetJsPropName()]={value:a.GetIObjectClass(),enumerable:!0,writable:!1};const a=Object.defineProperties({},e);this._iRuntime=new IRuntime(this,a),this._userScriptEventObjects={"tick":this._CreateUserScriptEvent("tick")}}_InitGlobalVariableScriptInterface(){const e={};for(const a of this.GetEventSheetManager().GetAllGlobalVariables())e[a.GetJsPropName()]=a._GetScriptInterfaceDescriptor();this._iRuntime._InitGlobalVars(e)}_GetCommonScriptInterfaces(){return this._commonScriptInterfaces}},self["C3_CreateRuntime"]=C3.Runtime.Create,self["C3_InitRuntime"]=(e,a)=>e.Init(a)} +"use strict";{const e={"messagePort":null,"baseUrl":"","headless":!1,"hasDom":!0,"isInWorker":!1,"useAudio":!0,"projectData":"","exportType":""};let a=!0;C3.Runtime=class extends C3.DefendedBase{constructor(n){n=Object.assign({},e,n);super(),this._messagePort=n["messagePort"],this._baseUrl=n["baseUrl"],this._isHeadless=!!n["headless"],this._hasDom=!!n["hasDom"],this._isInWorker=!!n["isInWorker"],a=n["ife"],this._useAudio=!!n["useAudio"],this._exportType=n["exportType"],this._isWKWebView=!!n["isWKWebView"],this._isFBInstantAvailable=!!n["isFBInstantAvailable"],this._opusWasmScriptUrl=n["opusWasmScriptUrl"],this._opusWasmBinaryUrl=n["opusWasmBinaryUrl"],this._dataJsonFilename="data.json",this._isDebug=!!("preview"===this._exportType&&n["isDebug"]),this._breakpointsEnabled=this._isDebug,this._isDebugging=this._isDebug,this._debuggingDisabled=0;const t=n["previewImageBlobs"],s=n["previewProjectFileBlobs"];s&&Object.assign(t,s);const i=n["projectData"];i&&(t[this._dataJsonFilename]=i),this._additionalLoadPromises=[],this._projectName="",this._projectVersion="",this._projectUniqueId="",this._originalViewportWidth=0,this._originalViewportHeight=0,this._parallaxXorigin=0,this._parallaxYorigin=0,this._viewportWidth=0,this._viewportHeight=0,this._loaderStyle=0,this._usesLoaderLayout=!1,this._isLoading=!0,this._usesAnyBackgroundBlending=!1;const r="html5"===this._exportType||"scirra-arcade"===this._exportType||"instant-games"===this._exportType;this._assetManager=C3.New(C3.AssetManager,this,{defaultLoadPolicy:r?"remote":"local",localUrlBlobs:t,isCordova:"cordova"===this._exportType,isWKWebView:this._isWKWebView,supportedAudioFormats:n["supportedAudioFormats"]}),this._layoutManager=C3.New(C3.LayoutManager,this),this._eventSheetManager=C3.New(C3.EventSheetManager,this),this._pluginManager=C3.New(C3.PluginManager,this),this._collisionEngine=C3.New(C3.CollisionEngine,this),this._timelineManager=C3.New(C3.TimelineManager,this),this._transitionManager=C3.New(C3.TransitionManager,this),this._allObjectClasses=[],this._objectClassesByName=new Map,this._objectClassesBySid=new Map,this._familyCount=0,this._allContainers=[],this._allEffectLists=[],this._currentLayoutStack=[],this._instancesPendingCreate=[],this._instancesPendingDestroy=new Map,this._hasPendingInstances=!1,this._isFlushingPendingInstances=!1,this._objectCount=0,this._nextUid=0,this._instancesByUid=new Map,this._instancesToReleaseAtEndOfTick=new Set,this._instancesToReleaseAffectedObjectClasses=new Set,this._objectReferenceTable=[],this._jsPropNameTable=[],this._canvasManager=null,this._compositingMode="standard",this._sampling="trilinear",this._isPixelRoundingEnabled=!1,this._needRender=!0,this._pauseOnBlur=!1,this._isPausedOnBlur=!1,this._tickCallback=(e)=>this.Tick(e),this._rafId=-1,this._tickCount=0,this._tickCountNoSave=0,this._execCount=0,this._hasStarted=!1,this._isInTick=!1,this._hasStartedTicking=!1,this._isLayoutFirstTick=!0,this._suspendCount=0,this._scheduleTriggersThrottle=new C3.PromiseThrottle(1),this._randomNumberCallback=()=>Math.random(),this._startTime=0,this._lastTickTime=0,this._dt1=0,this._dt=0,this._timeScale=1,this._minimumFramerate=30,this._gameTime=C3.New(C3.KahanSum),this._wallTime=C3.New(C3.KahanSum),this._fpsFrameCount=-1,this._fpsLastTime=0,this._fps=0,this._mainThreadTimeCounter=0,this._mainThreadTime=0,this._isLoadingState=!1,this._saveToSlotName="",this._loadFromSlotName="",this._loadFromJson=null,this._lastSaveJson="",this._triggerOnCreateAfterLoad=[],this._projectStorage=null,this._savegamesStorage=null,this._dispatcher=C3.New(C3.Event.Dispatcher),this._domEventHandlers=new Map,this._pendingResponsePromises=new Map,this._nextDomResponseId=0,this._didRequestDeviceOrientationEvent=!1,this._didRequestDeviceMotionEvent=!1,this._isReadyToHandleEvents=!1,this._waitingToHandleEvents=[],this._eventObjects={"pretick":C3.New(C3.Event,"pretick",!1),"tick":C3.New(C3.Event,"tick",!1),"tick2":C3.New(C3.Event,"tick2",!1),"instancedestroy":C3.New(C3.Event,"instancedestroy",!1),"beforelayoutchange":C3.New(C3.Event,"beforelayoutchange",!1),"layoutchange":C3.New(C3.Event,"layoutchange",!1)},this._eventObjects["instancedestroy"].instance=null,this._userScriptDispatcher=C3.New(C3.Event.Dispatcher),this._userScriptEventObjects=null,this._behInstsToTick=C3.New(C3.RedBlackSet,C3.BehaviorInstance.SortByTickSequence),this._behInstsToPostTick=C3.New(C3.RedBlackSet,C3.BehaviorInstance.SortByTickSequence),this._behInstsToTick2=C3.New(C3.RedBlackSet,C3.BehaviorInstance.SortByTickSequence),this._jobScheduler=C3.New(C3.JobSchedulerRuntime,this,n["jobScheduler"]),n["canvas"]&&(this._canvasManager=C3.New(C3.CanvasManager,this)),this._messagePort.onmessage=(a)=>this["_OnMessageFromDOM"](a.data),this.AddDOMComponentMessageHandler("runtime","visibilitychange",(a)=>this._OnVisibilityChange(a)),this.AddDOMComponentMessageHandler("runtime","opus-decode",(a)=>this._WasmDecodeWebMOpus(a["arrayBuffer"])),this.AddDOMComponentMessageHandler("runtime","get-remote-preview-status-info",()=>this._GetRemotePreviewStatusInfo()),this.AddDOMComponentMessageHandler("runtime","js-invoke-function",(a)=>this._InvokeFunctionFromJS(a)),this.AddDOMComponentMessageHandler("runtime","go-to-last-error-script",self["goToLastErrorScript"]),this._dispatcher.addEventListener("window-blur",(a)=>this._OnWindowBlur(a)),this._dispatcher.addEventListener("window-focus",()=>this._OnWindowFocus()),this._timelineManager.AddRuntimeListeners(),this._iRuntime=null,this._commonScriptInterfaces={keyboard:null,mouse:null,touch:null}}static Create(e){return C3.New(C3.Runtime,e)}Release(){C3.clearArray(this._allObjectClasses),this._objectClassesByName.clear(),this._objectClassesBySid.clear(),this._layoutManager.Release(),this._layoutManager=null,this._eventSheetManager.Release(),this._eventSheetManager=null,this._pluginManager.Release(),this._pluginManager=null,this._assetManager.Release(),this._assetManager=null,this._collisionEngine.Release(),this._collisionEngine=null,this._timelineManager.Release(),this._timelineManager=null,this._transitionManager.Release(),this._transitionManager=null,this._canvasManager&&(this._canvasManager.Release(),this._canvasManager=null),this._dispatcher.Release(),this._dispatcher=null,this._tickEvent=null,this._tickCallback=null}["_OnMessageFromDOM"](e){const a=e["type"];if("event"===a)this._OnEventFromDOM(e);else if("result"===a)this._OnResultFromDOM(e);else throw new Error(`unknown message '${a}'`)}_OnEventFromDOM(a){if(!this._isReadyToHandleEvents)return void this._waitingToHandleEvents.push(a);const e=a["component"],n=a["handler"],t=a["data"],s=a["dispatchOpts"],i=!!(s&&s["dispatchRuntimeEvent"]),r=!!(s&&s["dispatchUserScriptEvent"]),o=a["responseId"];if("runtime"===e){if(i){const e=new C3.Event(n);e.data=t,this._dispatcher.dispatchEventAndWaitAsyncSequential(e)}if(r){const e=new C3.Event(n,!0);for(const[a,n]of Object.entries(t))e[a]=n;this.DispatchUserScriptEvent(e)}}const d=this._domEventHandlers.get(e);if(!d)return void(i||r||console.warn(`[Runtime] No DOM event handlers for component '${e}'`));const _=d.get(n);if(!_)return void(i||r||console.warn(`[Runtime] No DOM handler '${n}' for component '${e}'`));let l=null;try{l=_(t)}catch(a){return console.error(`Exception in '${e}' handler '${n}':`,a),void(null!==o&&this._PostResultToDOM(o,!1,a.toString()))}null!==o&&(l&&l.then?l.then((e)=>this._PostResultToDOM(o,!0,e)).catch((a)=>{console.error(`Rejection from '${e}' handler '${n}':`,a),this._PostResultToDOM(o,!1,a.toString())}):this._PostResultToDOM(o,!0,l))}_PostResultToDOM(e,a,n){this._messagePort.postMessage({"type":"result","responseId":e,"isOk":a,"result":n})}_OnResultFromDOM(e){const a=e["responseId"],n=e["isOk"],t=e["result"],s=this._pendingResponsePromises.get(a);n?s.resolve(t):s.reject(t),this._pendingResponsePromises.delete(a)}AddDOMComponentMessageHandler(e,a,n){let t=this._domEventHandlers.get(e);if(t||(t=new Map,this._domEventHandlers.set(e,t)),t.has(a))throw new Error(`[Runtime] Component '${e}' already has handler '${a}'`);t.set(a,n)}PostComponentMessageToDOM(e,a,n){this._messagePort.postMessage({"type":"event","component":e,"handler":a,"data":n,"responseId":null})}PostComponentMessageToDOMAsync(e,a,n){const t=this._nextDomResponseId++,s=new Promise((e,a)=>{this._pendingResponsePromises.set(t,{resolve:e,reject:a})});return this._messagePort.postMessage({"type":"event","component":e,"handler":a,"data":n,"responseId":t}),s}PostToDebugger(e){if(!this.IsDebug())throw new Error("not in debug mode");this.PostComponentMessageToDOM("runtime","post-to-debugger",e)}async Init(e){this.IsDebug()?await C3Debugger.Init(this):self.C3Debugger&&self.C3Debugger.InitPreview(this);const[a]=await Promise.all([this._assetManager.FetchJson(this._dataJsonFilename),this._MaybeLoadOpusDecoder(),this._jobScheduler.Init()]);this._LoadDataJson(a),await this._InitialiseCanvas(e),this.IsPreview()||console.info("Made with Construct 3, the game and app creator :: https://www.construct.net");const n=this.GetWebGLRenderer();n?(console.info(`[C3 runtime] Hosted in ${this.IsInWorker()?"worker":"DOM"}, rendering with WebGL ${n.GetWebGLVersionNumber()} [${n.GetUnmaskedRenderer()}] (${n.IsDesynchronized()?"desynchronized":"standard"} compositing)`),n.HasMajorPerformanceCaveat()&&console.warn("[C3 runtime] WebGL indicates a major performance caveat. Software rendering may be in use. This can result in significantly degraded performance.")):console.info(`[C3 runtime] Hosted in ${this.IsInWorker()?"worker":"DOM"}, headless`),this._isReadyToHandleEvents=!0;for(const a of this._waitingToHandleEvents)this._OnEventFromDOM(a);C3.clearArray(this._waitingToHandleEvents),this._canvasManager&&this._canvasManager.StartLoadingScreen();for(const a of e["runOnStartupFunctions"])this._additionalLoadPromises.push(this._RunOnStartupFunction(a));if(await Promise.all([this._assetManager.WaitForAllToLoad(),...this._additionalLoadPromises]),!this._assetManager.HasHadErrorLoading())return this._canvasManager&&(await this._canvasManager.EndLoadingScreen()),await this._dispatcher.dispatchEventAndWaitAsync(new C3.Event("beforeruntimestart")),await this.Start(),this._messagePort.postMessage({"type":"runtime-ready"}),this}async _RunOnStartupFunction(e){try{await e(this._iRuntime)}catch(e){console.error("[C3 runtime] Error in runOnStartup function: ",e)}}_LoadDataJson(e){const a=e["project"];this._projectName=a[0],this._projectVersion=a[16],this._projectUniqueId=a[31],this._isPixelRoundingEnabled=!!a[9],this._originalViewportWidth=this._viewportWidth=a[10],this._originalViewportHeight=this._viewportHeight=a[11],this._parallaxXorigin=this._originalViewportWidth/2,this._parallaxYorigin=this._originalViewportHeight/2,this._compositingMode=a[36],"low-latency"===this._compositingMode&&this.IsAndroidWebView()&&77>=C3.Platform.BrowserVersionNumber&&(console.warn("[C3 runtime] Desynchronized (low-latency) compositing is enabled, but is disabled in the Android WebView <=77 due to crbug.com/1008842. Reverting to synchronized (standard) compositing."),this._compositingMode="standard"),this._sampling=a[14],this._usesLoaderLayout=!!a[18],this._loaderStyle=a[19],this._nextUid=a[21],this._pauseOnBlur=a[22],this._assetManager._SetAudioFiles(a[7],a[25]),this._assetManager._SetMediaSubfolder(a[8]),this._assetManager._SetFontsSubfolder(a[32]),this._assetManager._SetIconsSubfolder(a[28]),this._assetManager._SetWebFonts(a[29]),this._canvasManager&&(this._canvasManager.SetFullscreenMode(C3.CanvasManager._FullscreenModeNumberToString(a[12])),this._canvasManager.SetFullscreenScalingQuality(a[23]?"high":"low"),this._canvasManager._SetGPUPowerPreference(a[34])),this._pluginManager.CreateSystemPlugin(),this._objectReferenceTable=self.C3_GetObjectRefTable();for(const n of a[2])this._pluginManager.CreatePlugin(n);this._objectReferenceTable=self.C3_GetObjectRefTable(),this._LoadJsPropNameTable();for(const n of a[3]){const e=C3.ObjectClass.Create(this,this._allObjectClasses.length,n);this._allObjectClasses.push(e),this._objectClassesByName.set(e.GetName().toLowerCase(),e),this._objectClassesBySid.set(e.GetSID(),e)}for(const n of a[4]){const e=this._allObjectClasses[n[0]];e._LoadFamily(n)}for(const n of a[27]){const e=n.map((e)=>this._allObjectClasses[e]);this._allContainers.push(C3.New(C3.Container,this,e))}for(const a of this._allObjectClasses)a._OnAfterCreate();for(const n of a[5])this._layoutManager.Create(n);const n=a[1];if(n){const e=this._layoutManager.GetLayoutByName(n);e&&this._layoutManager.SetFirstLayout(e)}for(const n of a[33])this._timelineManager.Create(n);for(const n of a[35])this._transitionManager.Create(n);this._InitScriptInterfaces();for(const n of a[6])this._eventSheetManager.Create(n);this._eventSheetManager._PostInit(),this._InitGlobalVariableScriptInterface(),C3.clearArray(this._objectReferenceTable),this.FlushPendingInstances();let t="any";const s=a[20];1===s?t="portrait":2===s&&(t="landscape"),this.PostComponentMessageToDOM("runtime","set-target-orientation",{"targetOrientation":t})}GetLoaderStyle(){return this._loaderStyle}IsFBInstantAvailable(){return this._isFBInstantAvailable}IsLoading(){return this._isLoading}AddLoadPromise(e){this._additionalLoadPromises.push(e)}_GetNextFamilyIndex(){return this._familyCount++}GetFamilyCount(){return this._familyCount}_AddEffectList(e){this._allEffectLists.push(e)}_GetAllEffectLists(){return this._allEffectLists}async _InitialiseCanvas(e){this._canvasManager&&(await this._canvasManager.CreateCanvas(e),this._canvasManager.InitLoadingScreen(this._loaderStyle))}async _MaybeLoadOpusDecoder(){if(this._assetManager.IsAudioFormatSupported("audio/webm; codecs=opus"))return;let e=null,a=null;try{this.IsWKWebView()?a=await this._assetManager.CordovaFetchLocalFileAsArrayBuffer(this._opusWasmBinaryUrl):e=await this._assetManager.FetchBlob(this._opusWasmBinaryUrl)}catch(e){return void console.info("Failed to fetch Opus decoder WASM; assuming project has no Opus audio.",e)}a?this.AddJobWorkerBuffer(a,"opus-decoder-wasm"):this.AddJobWorkerBlob(e,"opus-decoder-wasm"),await this.AddJobWorkerScripts([this._opusWasmScriptUrl])}async _WasmDecodeWebMOpus(e){const a=await this.AddJob("OpusDecode",{"arrayBuffer":e},[e]);return a}async Start(){if(this._hasStarted=!0,this._startTime=Date.now(),this._usesLoaderLayout){for(const e of this._allObjectClasses)e.IsFamily()||e.IsOnLoaderLayout()||!e.IsWorldType()||e.OnCreate();this._assetManager.WaitForAllToLoad().then(()=>{this._isLoading=!1,this._OnLoadFinished()})}else this._isLoading=!1;this._assetManager.SetInitialLoadFinished(),this.IsDebug()&&C3Debugger.RuntimeInit(a);for(const e of this._layoutManager.GetAllLayouts())e._CreateGlobalNonWorlds();const e=this._layoutManager.GetFirstLayout();await e._Load(null,this.GetWebGLRenderer()),await e._StartRunning(!0),this._fpsLastTime=performance.now(),this._usesLoaderLayout||this._OnLoadFinished();const n=await this.PostComponentMessageToDOMAsync("runtime","before-start-ticking");n["isSuspended"]?this._suspendCount++:this.Tick()}_OnLoadFinished(){this.Trigger(C3.Plugins.System.Cnds.OnLoadFinished,null),this.PostComponentMessageToDOM("runtime","register-sw")}GetObjectReference(e){e=Math.floor(e);const a=this._objectReferenceTable;if(0>e||e>=a.length)throw new Error("invalid object reference");return a[e]}_LoadJsPropNameTable(){for(const e of self.C3_JsPropNameTable){const a=C3.first(Object.keys(e));this._jsPropNameTable.push(a)}}GetJsPropName(e){e=Math.floor(e);const a=this._jsPropNameTable;if(0>e||e>=a.length)throw new Error("invalid prop reference");return a[e]}HasDOM(){return this._hasDom}IsHeadless(){return this._isHeadless}IsInWorker(){return this._isInWorker}GetBaseURL(){return this._baseUrl}GetEventSheetManager(){return this._eventSheetManager}GetEventStack(){return this._eventSheetManager.GetEventStack()}GetCurrentEventStackFrame(){return this._eventSheetManager.GetCurrentEventStackFrame()}GetCurrentEvent(){return this._eventSheetManager.GetCurrentEvent()}GetCurrentCondition(){return this._eventSheetManager.GetCurrentCondition()}IsCurrentConditionFirst(){return 0===this.GetCurrentEventStackFrame().GetConditionIndex()}GetCurrentAction(){return this._eventSheetManager.GetCurrentAction()}GetPluginManager(){return this._pluginManager}GetSystemPlugin(){return this._pluginManager.GetSystemPlugin()}GetObjectClassByIndex(e){if(e=Math.floor(e),0>e||e>=this._allObjectClasses.length)throw new RangeError("invalid index");return this._allObjectClasses[e]}GetObjectClassByName(e){return this._objectClassesByName.get(e.toLowerCase())||null}GetObjectClassBySID(e){return this._objectClassesBySid.get(e)||null}GetSingleGlobalObjectClassByCtor(e){const a=this._pluginManager.GetPluginByConstructorFunction(e);return a?a.GetSingleGlobalObjectClass():null}GetAllObjectClasses(){return this._allObjectClasses}Dispatcher(){return this._dispatcher}UserScriptDispatcher(){return this._userScriptDispatcher}DispatchUserScriptEvent(a){const e=this.IsDebug()&&!this._eventSheetManager.IsInEventEngine();e&&C3Debugger.StartMeasuringScriptTime(),this._userScriptDispatcher.dispatchEvent(a),e&&C3Debugger.AddScriptTime()}GetOriginalViewportWidth(){return this._originalViewportWidth}GetOriginalViewportHeight(){return this._originalViewportHeight}SetOriginalViewportSize(e,a){this._originalViewportWidth=e,this._originalViewportHeight=a}GetViewportWidth(){return this._viewportWidth}GetViewportHeight(){return this._viewportHeight}SetViewportSize(e,a){this._viewportWidth=e,this._viewportHeight=a}GetParallaxXOrigin(){return this._parallaxXorigin}GetParallaxYOrigin(){return this._parallaxYorigin}GetCanvasManager(){return this._canvasManager}GetDrawWidth(){return this._canvasManager?this._canvasManager.GetDrawWidth():this._viewportWidth}GetDrawHeight(){return this._canvasManager?this._canvasManager.GetDrawHeight():this._viewportHeight}GetRenderScale(){return this._canvasManager?this._canvasManager.GetRenderScale():1}GetDisplayScale(){return this._canvasManager?this._canvasManager.GetDisplayScale():1}GetCanvasClientX(){return this._canvasManager?this._canvasManager.GetCanvasClientX():0}GetCanvasClientY(){return this._canvasManager?this._canvasManager.GetCanvasClientY():0}GetCanvasCssWidth(){return this._canvasManager?this._canvasManager.GetCssWidth():0}GetCanvasCssHeight(){return this._canvasManager?this._canvasManager.GetCssHeight():0}GetFullscreenMode(){return this._canvasManager?this._canvasManager.GetFullscreenMode():"off"}GetAdditionalRenderTarget(e){return this._canvasManager?this._canvasManager.GetAdditionalRenderTarget(e):null}ReleaseAdditionalRenderTarget(e){this._canvasManager&&this._canvasManager.ReleaseAdditionalRenderTarget(e)}_SetUsesAnyBackgroundBlending(e){this._usesAnyBackgroundBlending=!!e}UsesAnyBackgroundBlending(){return this._usesAnyBackgroundBlending}GetGPUUtilisation(){return this._canvasManager?this._canvasManager.GetGPUUtilisation():NaN}IsLinearSampling(){return"nearest"!==this.GetSampling()}GetCompositingMode(){return this._compositingMode}GetSampling(){return this._sampling}UsesLoaderLayout(){return this._usesLoaderLayout}GetLayoutManager(){return this._layoutManager}GetMainRunningLayout(){return this._layoutManager.GetMainRunningLayout()}GetTimelineManager(){return this._timelineManager}GetTransitionManager(){return this._transitionManager}GetAssetManager(){return this._assetManager}LoadImage(e){return this._assetManager.LoadImage(e)}CreateInstance(e,a,n,t){return this.CreateInstanceFromData(e,a,!1,n,t)}CreateInstanceFromData(e,a,n,t,s,i){let r=null,o=null;if(e instanceof C3.ObjectClass){if(o=e,o.IsFamily()){const e=o.GetFamilyMembers(),a=Math.floor(this.Random()*e.length);o=e[a]}r=o.GetDefaultInstanceData()}else r=e,o=this.GetObjectClassByIndex(r[1]);const d=o.GetPlugin().IsWorldType();if(this._isLoading&&d&&!o.IsOnLoaderLayout())return null;const _=a;d||(a=null);let l=n&&!i&&r&&!this._instancesByUid.has(r[2])?r[2]:this._nextUid++;const g=r?r[0]:null,c=C3.New(C3.Instance,{runtime:this,objectType:o,layer:a,worldData:g,instVarData:r?r[3]:null,uid:l});this._instancesByUid.set(l,c);let u=null;if(d&&(u=c.GetWorldInfo(),"undefined"!=typeof t&&"undefined"!=typeof s&&(u.SetX(t),u.SetY(s)),o._SetAnyCollisionCellChanged(!0)),a&&(a._AddInstance(c,!0),(1!==a.GetParallaxX()||1!==a.GetParallaxY())&&o._SetAnyInstanceParallaxed(!0),a.GetLayout().MaybeLoadTexturesFor(o)),(this._objectCount++,o.IsInContainer()&&!n&&!i)){for(const e of o.GetContainer().objectTypes()){if(e===o)continue;const a=this.CreateInstanceFromData(e,_,!1,u?u.GetX():t,u?u.GetY():s,!0);c._AddSibling(a)}for(const e of c.siblings()){e._AddSibling(c);for(const a of c.siblings())e!==a&&e._AddSibling(a)}}o._SetIIDsStale();const m=r?C3.cloneArray(r[5]):null,p=r?r[4].map((e)=>C3.cloneArray(e)):null;if(c._CreateSdkInstance(m,p),d&&g&&14===g.length){const e=g[13];c._SetHasTilemap(),c.GetSdkInstance().LoadTilemapData(e[2],e[0],e[1])}return this._instancesPendingCreate.push(c),this._hasPendingInstances=!0,this.IsDebug()&&C3Debugger.InstanceCreated(c),c}DestroyInstance(e){if(this._instancesToReleaseAtEndOfTick.has(e))return;const a=e.GetObjectClass();let n=this._instancesPendingDestroy.get(a);if(n){if(n.has(e))return;n.add(e)}else n=new Set,n.add(e),this._instancesPendingDestroy.set(a,n);if(this.IsDebug()&&C3Debugger.InstanceDestroyed(e),e._MarkDestroyed(),this._hasPendingInstances=!0,e.IsInContainer())for(const a of e.siblings())this.DestroyInstance(a);if(this._isFlushingPendingInstances&&C3.NotYetImplemented(),!this._layoutManager.IsEndingLayout()){const a=this.GetEventSheetManager();a.BlockFlushingInstances(!0),e._TriggerOnDestroyed(),a.BlockFlushingInstances(!1)}}FlushPendingInstances(){this._hasPendingInstances&&(this._isFlushingPendingInstances=!0,this._FlushInstancesPendingCreate(),this._FlushInstancesPendingDestroy(),this._isFlushingPendingInstances=!1,this._hasPendingInstances=!1,this.UpdateRender())}_FlushInstancesPendingCreate(){for(const e of this._instancesPendingCreate){const a=e.GetObjectClass();a._AddInstance(e);for(const n of a.GetFamilies())n._AddInstance(e),n._SetIIDsStale()}C3.clearArray(this._instancesPendingCreate)}_FlushInstancesPendingDestroy(){this._dispatcher.SetDelayRemoveEventsEnabled(!0);for(const[e,a]of this._instancesPendingDestroy.entries())this._FlushInstancesPendingDestroyForObjectClass(e,a),a.clear();this._instancesPendingDestroy.clear(),this._dispatcher.SetDelayRemoveEventsEnabled(!1)}_FlushInstancesPendingDestroyForObjectClass(e,a){C3.arrayRemoveAllInSet(e.GetInstances(),a),e._SetIIDsStale(),this._instancesToReleaseAffectedObjectClasses.add(e),0===e.GetInstances().length&&e._SetAnyInstanceParallaxed(!1);for(const n of e.GetFamilies())C3.arrayRemoveAllInSet(n.GetInstances(),a),n._SetIIDsStale(),this._instancesToReleaseAffectedObjectClasses.add(n);if(e.GetPlugin().IsWorldType()){const e=new Set([...a].map((e)=>e.GetWorldInfo().GetLayer()));for(const n of e)n._RemoveAllInstancesInSet(a)}for(const n of a){const e=this._eventObjects["instancedestroy"];e.instance=n,this._dispatcher.dispatchEvent(e),this._instancesByUid.delete(n.GetUID());const a=n.GetWorldInfo();a&&(a._RemoveFromCollisionCells(),a._RemoveFromRenderCells()),this._instancesToReleaseAtEndOfTick.add(n),this._objectCount--}}_GetInstancesPendingCreate(){return this._instancesPendingCreate}_GetNewUID(){return this._nextUid++}_MapInstanceByUID(e,a){this._instancesByUid.set(e,a)}_OnWebGLContextLost(){this._dispatcher.dispatchEvent(C3.New(C3.Event,"webglcontextlost")),this.SetSuspended(!0);for(const e of this._allObjectClasses)!e.IsFamily()&&e.HasLoadedTextures()&&e.ReleaseTextures();this.GetMainRunningLayout()._OnWebGLContextLost(),C3.ImageInfo.OnWebGLContextLost(),C3.ImageAsset.OnWebGLContextLost()}async _OnWebGLContextRestored(){await this.GetMainRunningLayout()._Load(null,this.GetWebGLRenderer()),this._dispatcher.dispatchEvent(C3.New(C3.Event,"webglcontextrestored")),this.SetSuspended(!1),this.UpdateRender()}_OnVisibilityChange(a){this.SetSuspended(a["hidden"])}_OnWindowBlur(a){this.IsPreview()&&this._pauseOnBlur&&!C3.Platform.IsMobile&&(a.data["parentHasFocus"]||(this.SetSuspended(!0),this._isPausedOnBlur=!0))}_OnWindowFocus(){this._isPausedOnBlur&&(this.SetSuspended(!1),this._isPausedOnBlur=!1)}IsSuspended(){return 0this._suspendCount&&(this._suspendCount=0);const n=this.IsSuspended();if(!a&&n)console.log("[Construct 3] Suspending"),-1!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=-1),this._dispatcher.dispatchEvent(C3.New(C3.Event,"suspend")),this.Trigger(C3.Plugins.System.Cnds.OnSuspend,null);else if(a&&!n){console.log("[Construct 3] Resuming");const e=performance.now();this._lastTickTime=e,this._fpsLastTime=e,this._fpsFrameCount=0,this._fps=0,this._mainThreadTime=0,this._mainThreadTimeCounter=0,this._dispatcher.dispatchEvent(C3.New(C3.Event,"resume")),this.Trigger(C3.Plugins.System.Cnds.OnResume,null),this.HitBreakpoint()||this.Tick(e)}}_AddBehInstToTick(e){this._behInstsToTick.Add(e)}_AddBehInstToPostTick(e){this._behInstsToPostTick.Add(e)}_AddBehInstToTick2(e){this._behInstsToTick2.Add(e)}_RemoveBehInstToTick(e){this._behInstsToTick.Remove(e)}_RemoveBehInstToPostTick(e){this._behInstsToPostTick.Remove(e)}_RemoveBehInstToTick2(e){this._behInstsToTick2.Remove(e)}_BehaviorTick(){for(const e of this._behInstsToTick)e.Tick()}_BehaviorPostTick(){for(const e of this._behInstsToPostTick)e.PostTick()}_BehaviorTick2(){for(const e of this._behInstsToTick2)e.Tick2()}*_DebugBehaviorTick(){for(const e of this._behInstsToTick){const a=e.Tick();C3.IsIterator(a)&&(yield*a)}}*_DebugBehaviorPostTick(){for(const e of this._behInstsToPostTick){const a=e.PostTick();C3.IsIterator(a)&&(yield*a)}}*_DebugBehaviorTick2(){for(const e of this._behInstsToTick2){const a=e.Tick2();C3.IsIterator(a)&&(yield*a)}}async Tick(e,a,n){if(this._rafId=-1,this._hasStartedTicking=!0,this._hasStarted&&(!this.IsSuspended()||a||n)){const a=performance.now();this._isInTick=!0,e||(e=a),this._MeasureDt(e);const t=this.Step_BeforePreTick();this.IsDebugging()&&(await t);const s=this._dispatcher.dispatchEventAndWait_AsyncOptional(this._eventObjects["pretick"]);s instanceof Promise&&(await s);const i=this.Step_AfterPreTick();this.IsDebugging()&&(await i),this._NeedsHandleSaveOrLoad()&&(await this._HandleSaveOrLoad()),this.GetLayoutManager().IsPendingChangeMainLayout()&&(await this._MaybeChangeLayout());const r=this.Step_RunEventsEtc();this.IsDebugging()&&(await r),n||this.Render(),this.IsSuspended()||n||-1!==this._rafId||(this._rafId=self.requestAnimationFrame(this._tickCallback)),this._tickCount++,this._tickCountNoSave++,this._execCount++,this._isInTick=!1,this._mainThreadTimeCounter+=performance.now()-a}}async Step_BeforePreTick(){const e=this._eventSheetManager,a=this.IsDebug();this.FlushPendingInstances(),e.BlockFlushingInstances(!0),this.PushCurrentLayout(this.GetMainRunningLayout()),a&&C3Debugger.StartMeasuringTime(),this.IsDebugging()?await e.DebugRunScheduledWaits():e.RunScheduledWaits(),a&&C3Debugger.AddEventsTime(),this.PopCurrentLayout(),e.BlockFlushingInstances(!1),this.FlushPendingInstances(),e.BlockFlushingInstances(!0)}async Step_AfterPreTick(){const e=this.IsDebug(),a=this.IsDebugging(),n=this._dispatcher,t=this._eventObjects,s=this._userScriptEventObjects;e&&C3Debugger.StartMeasuringTime(),a?await this.DebugIterateAndBreak(this._DebugBehaviorTick()):this._BehaviorTick(),a?await this.DebugIterateAndBreak(this._DebugBehaviorPostTick()):this._BehaviorPostTick(),e&&C3Debugger.AddBehaviorTickTime(),e&&C3Debugger.StartMeasuringTime(),a?await this.DebugFireGeneratorEventAndBreak(t["tick"]):n.dispatchEvent(t["tick"]),e&&C3Debugger.AddPluginTickTime(),this._eventSheetManager.BlockFlushingInstances(!1),this.DispatchUserScriptEvent(s["tick"])}async Step_RunEventsEtc(){const e=this._eventSheetManager,a=this._dispatcher,n=this._eventObjects,t=this.IsDebug(),s=this.IsDebugging();if(t&&C3Debugger.StartMeasuringTime(),s?await e.DebugRunEvents(this._layoutManager):e.RunEvents(this._layoutManager),t&&C3Debugger.AddEventsTime(),this._collisionEngine.ClearRegisteredCollisions(),0a++;)await this._DoChangeLayout(e.GetPendingChangeMainLayout())}_MeasureDt(e){if(0!==this._lastTickTime){const a=Math.max(e-this._lastTickTime,0);this._dt1=a/1e3;const n=1/this._minimumFramerate;.5n&&(this._dt1=n)}this._lastTickTime=e,this._dt=this._dt1*this._timeScale,this._gameTime.Add(this._dt),this._wallTime.Add(this._dt1),this._canvasManager&&this._canvasManager._UpdateTick(),1e3<=e-this._fpsLastTime&&(this._fpsLastTime+=1e3,1e3<=e-this._fpsLastTime&&(this._fpsLastTime=e),this._fps=this._fpsFrameCount,this._fpsFrameCount=0,this._mainThreadTime=Math.min(this._mainThreadTimeCounter/1e3,1),this._mainThreadTimeCounter=0,this._canvasManager&&this._canvasManager._Update1sFrameRange(),this._collisionEngine._Update1sStats(),this.IsDebug()&&C3Debugger.Update1sPerfStats()),this._fpsFrameCount++}async _DoChangeLayout(e){const a=this._dispatcher,n=this.GetLayoutManager(),t=n.GetMainRunningLayout();await t._StopRunning(),t._Unload(e,this.GetWebGLRenderer()),t===e&&this._eventSheetManager.ClearAllScheduledWaits(),this._collisionEngine.ClearRegisteredCollisions(),a.dispatchEvent(this._eventObjects["beforelayoutchange"]),C3.Asyncify.SetHighThroughputMode(!0),await e._Load(t,this.GetWebGLRenderer()),C3.Asyncify.SetHighThroughputMode(!1),await e._StartRunning(!1),a.dispatchEvent(this._eventObjects["layoutchange"]),this.UpdateRender(),this._isLayoutFirstTick=!0,this.FlushPendingInstances()}UpdateRender(){this._needRender=!0}GetWebGLRenderer(){return this._canvasManager?this._canvasManager.GetWebGLRenderer():null}Render(){if(!this._canvasManager||this._canvasManager.IsWebGLContextLost())return;const e=this.GetWebGLRenderer();if(e.Start(),e.CheckForQueryResults(),!this._needRender)return void e.IncrementFrameNumber();const a=this.IsDebug();a&&C3Debugger.StartMeasuringTime(),this._needRender=!1;let n=null;e.SupportsGPUProfiling()&&(n=this._canvasManager.GetGPUFrameTimingsBuffer().AddTimeElapsedQuery(),e.StartQuery(n)),e.SetTextureFillMode(),e.SetAlphaBlend(),e.SetColorRgba(1,1,1,1),e.SetRenderTarget(null),e.SetTexture(null);const t=this._layoutManager.GetMainRunningLayout();t.Draw(e),n&&e.EndQuery(n),e.Finish(),a&&(C3Debugger.AddDrawCallsTime(),C3Debugger.UpdateInspectHighlight()),this._canvasManager&&this._canvasManager._MaybeTakeSnapshot()}Trigger(e,a){if(!this._hasStarted)return!1;const n=!this._isInTick&&!this._eventSheetManager.IsInTrigger();let t=0;n&&(t=performance.now());const s=this.IsDebug();s&&this.SetDebuggingEnabled(!1);const i=this._eventSheetManager._Trigger(this._layoutManager,e,a);if(n){const e=performance.now()-t;this._mainThreadTimeCounter+=e,s&&C3Debugger.AddTriggersTime(e)}return s&&this.SetDebuggingEnabled(!0),i}DebugTrigger(e,a){if(!this.IsDebug())return this.Trigger(e,a);if(this.HitBreakpoint())throw new Error("called DebugTrigger() while stopped on breakpoint");if(!this._isInTick&&!this._eventSheetManager.IsInTrigger())throw new Error("called DebugTrigger() outside of event code - use TriggerAsync() instead");return this._eventSheetManager._DebugTrigger(this._layoutManager,e,a)}async TriggerAsync(e,a){if(!this.IsDebugging())return this.Trigger(e,a);if(!this._hasStarted)return!1;if(this.HitBreakpoint())return this._eventSheetManager.QueueDebugTrigger(e,a);if(!this.GetMainRunningLayout())return this._eventSheetManager.QueueTrigger(e,a);const n=performance.now(),t=this._eventSheetManager._DebugTrigger(this._layoutManager,e,a);let s=t.next();for(;!s.done;)await this.DebugBreak(s.value),s=t.next();return this.IsSuspended()||this._eventSheetManager.IsInTrigger()||(await this._eventSheetManager.RunQueuedDebugTriggersAsync(),this._hasStartedTicking&&-1===this._rafId&&!this._isInTick&&(this._rafId=self.requestAnimationFrame(this._tickCallback))),this._mainThreadTimeCounter+=performance.now()-n,s.value}FastTrigger(e,a,n){const t=this.IsDebug();t&&this.SetDebuggingEnabled(!1);const s=this._eventSheetManager._FastTrigger(this._layoutManager,e,a,n);return t&&this.SetDebuggingEnabled(!0),s}DebugFastTrigger(e,a,n){return this._eventSheetManager._DebugFastTrigger(this._layoutManager,e,a,n)}ScheduleTriggers(e){return this._scheduleTriggersThrottle.Add(e)}PushCurrentLayout(e){this._currentLayoutStack.push(e)}PopCurrentLayout(){if(!this._currentLayoutStack.length)throw new Error("layout stack empty");this._currentLayoutStack.pop()}GetCurrentLayout(){return this._currentLayoutStack.length?this._currentLayoutStack[this._currentLayoutStack.length-1]:this.GetMainRunningLayout()}GetDt(e){return e&&-1!==e.GetTimeScale()?this._dt1*e.GetTimeScale():this._dt}_GetDtFast(){return this._dt}GetDt1(){return this._dt1}GetTimeScale(){return this._timeScale}SetTimeScale(e){(isNaN(e)||0>e)&&(e=0),this._timeScale=e}SetMinimumFramerate(e){this._minimumFramerate=C3.clamp(e,1,120)}GetMinimumFramerate(){return this._minimumFramerate}GetFPS(){return this._fps}GetMainThreadTime(){return this._mainThreadTime}GetStartTime(){return this._startTime}GetGameTime(){return this._gameTime.Get()}GetWallTime(){return this._wallTime.Get()}GetTickCount(){return this._tickCount}GetTickCountNoSave(){return this._tickCountNoSave}IncrementExecCount(){++this._execCount}GetExecCount(){return this._execCount}GetObjectCount(){return this._objectCount}GetProjectName(){return this._projectName}GetProjectVersion(){return this._projectVersion}GetProjectUniqueId(){return this._projectUniqueId}GetInstanceByUID(e){if(this._isLoadingState)throw new Error("cannot call while loading state - wait until afterload event");return this._instancesByUid.get(e)||null}_RefreshUidMap(){this._instancesByUid.clear();for(const e of this._allObjectClasses)if(!e.IsFamily())for(const a of e.GetInstances())this._instancesByUid.set(a.GetUID(),a)}IsPreview(){return"preview"===this._exportType}IsDebug(){return this._isDebug}GetExportType(){return this._exportType}IsCordova(){return"cordova"===this._exportType}IsAndroidWebView(){return"Android"===C3.Platform.OS&&("cordova"===this._exportType||"playable-ad"===this._exportType||"instant-games"===this._exportType)}IsWKWebView(){return this._isWKWebView}GetCollisionEngine(){return this._collisionEngine}GetSolidBehavior(){return this._pluginManager.GetSolidBehavior()}GetJumpthruBehavior(){return this._pluginManager.GetJumpthruBehavior()}IsLayoutFirstTick(){return this._isLayoutFirstTick}SetPixelRoundingEnabled(a){a=!!a;this._isPixelRoundingEnabled===a||(this._isPixelRoundingEnabled=a,this.UpdateRender())}IsPixelRoundingEnabled(){return this._isPixelRoundingEnabled}SaveToSlot(e){this._saveToSlotName=e}LoadFromSlot(e){this._loadFromSlotName=e}LoadFromJsonString(e){this._loadFromJson=e}GetLastSaveJsonString(){return this._lastSaveJson}_NeedsHandleSaveOrLoad(){return!!(this._saveToSlotName||this._loadFromSlotName||null!==this._loadFromJson)}async _HandleSaveOrLoad(){if(this._saveToSlotName&&(this.FlushPendingInstances(),await this._DoSaveToSlot(this._saveToSlotName),this._ClearSaveOrLoad()),this._loadFromSlotName&&(await this._DoLoadFromSlot(this._loadFromSlotName),this._ClearSaveOrLoad(),this.IsDebug()&&C3Debugger.StepIfPausedInDebugger()),null!==this._loadFromJson){this.FlushPendingInstances();try{await this._DoLoadFromJsonString(this._loadFromJson),this._lastSaveJson=this._loadFromJson,await this.TriggerAsync(C3.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct 3] Failed to load state from JSON string: ",e),await this.TriggerAsync(C3.Plugins.System.Cnds.OnLoadFailed,null)}this._ClearSaveOrLoad()}}_ClearSaveOrLoad(){this._saveToSlotName="",this._loadFromSlotName="",this._loadFromJson=null}_GetProjectStorage(){return this._projectStorage||(this._projectStorage=localforage.createInstance({name:"c3-localstorage-"+this.GetProjectUniqueId(),description:this.GetProjectName()})),this._projectStorage}_GetSavegamesStorage(){return this._savegamesStorage||(this._savegamesStorage=localforage.createInstance({name:"c3-savegames-"+this.GetProjectUniqueId(),description:this.GetProjectName()})),this._savegamesStorage}async _DoSaveToSlot(e){const a=this._SaveToJsonString();try{await this._GetSavegamesStorage().setItem(e,a),console.log("[Construct 3] Saved state to storage ("+a.length+" chars)"),this._lastSaveJson=a,await this.TriggerAsync(C3.Plugins.System.Cnds.OnSaveComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct 3] Failed to save state to storage: ",e),await this.TriggerAsync(C3.Plugins.System.Cnds.OnSaveFailed,null)}}async _DoLoadFromSlot(e){try{const a=await this._GetSavegamesStorage().getItem(e);if(!a)throw new Error("empty slot");console.log("[Construct 3] Loaded state from storage ("+a.length+" chars)"),await this._DoLoadFromJsonString(a),this._lastSaveJson=a,await this.TriggerAsync(C3.Plugins.System.Cnds.OnLoadComplete,null),this._lastSaveJson=""}catch(e){console.error("[Construct 3] Failed to load state from storage: ",e),await this.TriggerAsync(C3.Plugins.System.Cnds.OnLoadFailed,null)}}_SaveToJsonString(){const e={"c3save":!0,"version":1,"rt":{"time":this.GetGameTime(),"walltime":this.GetWallTime(),"timescale":this.GetTimeScale(),"tickcount":this.GetTickCount(),"execcount":this.GetExecCount(),"next_uid":this._nextUid,"running_layout":this.GetMainRunningLayout().GetSID(),"start_time_offset":Date.now()-this._startTime},"types":{},"layouts":{},"events":this._eventSheetManager._SaveToJson(),"user_script_data":null};for(const a of this._allObjectClasses)a.IsFamily()||a.HasNoSaveBehavior()||(e["types"][a.GetSID().toString()]=a._SaveToJson());for(const a of this._layoutManager.GetAllLayouts())e["layouts"][a.GetSID().toString()]=a._SaveToJson();const a=this._CreateUserScriptEvent("save");return a.saveData=null,this.DispatchUserScriptEvent(a),e["user_script_data"]=a.saveData,JSON.stringify(e)}IsLoadingState(){return this._isLoadingState}_TriggerOnCreateAfterLoad(e){C3.shallowAssignArray(this._triggerOnCreateAfterLoad,e)}async _DoLoadFromJsonString(e){const a=JSON.parse(e);if(a["c2save"])throw new Error("C2 saves are incompatible with C3 runtime");if(!a["c3save"])throw new Error("not valid C3 save data");if(1n||n>=s.length)throw new Error("missing sibling instance");e._AddSibling(s[n])}}this._dispatcher.dispatchEvent(C3.New(C3.Event,"afterload"));const s=this._CreateUserScriptEvent("load");s.saveData=a["user_script_data"],this.DispatchUserScriptEvent(s),this.UpdateRender()}async AddJobWorkerScripts(e){const a=await Promise.all(e.map((e)=>this._assetManager.FetchBlob(e))),n=a.map((e)=>URL.createObjectURL(e));this._jobScheduler.ImportScriptsToJobWorkers(n)}AddJobWorkerBlob(e,a){this._jobScheduler.SendBlobToJobWorkers(e,a)}AddJobWorkerBuffer(e,a){this._jobScheduler.SendBufferToJobWorkers(e,a)}AddJob(e,a,n){return this._jobScheduler.AddJob(e,a,n)}BroadcastJob(e,a,n){return this._jobScheduler.BroadcastJob(e,a,n)}InvokeDownload(e,a){this.PostComponentMessageToDOM("runtime","invoke-download",{"url":e,"filename":a})}async RasterSvgImage(e,a,n){if(this.IsInWorker())return await this.PostComponentMessageToDOMAsync("runtime","raster-svg-image",{"blob":e,"width":a,"height":n});else{const t=await C3.BlobToImage(e);return await self["C3_RasterSvgImage"](t,a,n)}}RequestDeviceOrientationEvent(){this._didRequestDeviceOrientationEvent||(this._didRequestDeviceOrientationEvent=!0,this.PostComponentMessageToDOM("runtime","enable-device-orientation"))}RequestDeviceMotionEvent(){this._didRequestDeviceMotionEvent||(this._didRequestDeviceMotionEvent=!0,this.PostComponentMessageToDOM("runtime","enable-device-motion"))}Random(){return this._randomNumberCallback()}SetRandomNumberGeneratorCallback(e){this._randomNumberCallback=e}_GetRemotePreviewStatusInfo(){return{"fps":this.GetFPS(),"cpu":this.GetMainThreadTime(),"gpu":this.GetGPUUtilisation(),"layout":this.GetMainRunningLayout()?this.GetMainRunningLayout().GetName():"","renderer":this.GetWebGLRenderer().GetUnmaskedRenderer()}}HitBreakpoint(){return!!this.IsDebug()&&C3Debugger.HitBreakpoint()}DebugBreak(e){return this.IsDebugging()?C3Debugger.DebugBreak(e):Promise.resolve()}DebugBreakNext(){return!!this.IsDebugging()&&C3Debugger.BreakNext()}SetDebugBreakpointsEnabled(a){this._breakpointsEnabled=!!a,this._UpdateDebuggingFlag()}AreDebugBreakpointsEnabled(){return this._breakpointsEnabled}IsDebugging(){return this._isDebugging}SetDebuggingEnabled(e){e?this._debuggingDisabled--:this._debuggingDisabled++,this._UpdateDebuggingFlag()}_UpdateDebuggingFlag(){this._isDebugging=this.IsDebug()&&this._breakpointsEnabled&&0===this._debuggingDisabled}IsCPUProfiling(){return this.IsDebug()&&C3Debugger.IsCPUProfiling()}IsGPUProfiling(){return this.IsDebug()&&this.GetWebGLRenderer().SupportsGPUProfiling()&&C3Debugger.IsGPUProfiling()}async DebugIterateAndBreak(e){if(e)for(const a of e)await this.DebugBreak(a)}DebugFireGeneratorEventAndBreak(e){return this.DebugIterateAndBreak(this._dispatcher.dispatchGeneratorEvent(e))}_InvokeFunctionFromJS(a){return this._eventSheetManager._InvokeFunctionFromJS(a["name"],a["params"])}GetIRuntime(){return this._iRuntime}_CreateUserScriptEvent(a){const n=C3.New(C3.Event,a,!1);return n.runtime=this._iRuntime,n}_InitScriptInterfaces(){const e={};for(const a of this._allObjectClasses)e[a.GetJsPropName()]={value:a.GetIObjectClass(),enumerable:!0,writable:!1};const a=Object.defineProperties({},e);this._iRuntime=new IRuntime(this,a),this._userScriptEventObjects={"tick":this._CreateUserScriptEvent("tick")}}_InitGlobalVariableScriptInterface(){const e={};for(const a of this.GetEventSheetManager().GetAllGlobalVariables())e[a.GetJsPropName()]=a._GetScriptInterfaceDescriptor();this._iRuntime._InitGlobalVars(e)}_GetCommonScriptInterfaces(){return this._commonScriptInterfaces}},self["C3_CreateRuntime"]=C3.Runtime.Create,self["C3_InitRuntime"]=(e,a)=>e.Init(a)} // c3/workers/jobSchedulerRuntime.js "use strict";C3.JobSchedulerRuntime=class extends C3.DefendedBase{constructor(a,b){super(),this._runtime=a,this._jobPromises=new Map,this._nextJobId=0,this._inputPort=b["inputPort"],b["outputPort"].onmessage=(a)=>this._OnJobWorkerMessage(a),this._maxNumWorkers=b["maxNumWorkers"],this._jobWorkerCount=1,this._isCreatingWorker=!1,this._hadErrorCreatingWorker=!1,this._isBroken=!1,this._testOkResolve=null}async Init(){await this._TestMessageChannelWorks()}ImportScriptsToJobWorkers(a){this._isBroken||this._inputPort.postMessage({"type":"_import_scripts","scripts":a})}SendBlobToJobWorkers(a,b){this._isBroken||this._inputPort.postMessage({"type":"_send_blob","blob":a,"id":b})}SendBufferToJobWorkers(a,b){this._isBroken||this._inputPort.postMessage({"type":"_send_buffer","buffer":a,"id":b},[a])}AddJob(a,b,c,d,e){if(this._isBroken)return Promise.reject("messagechannels broken");c||(c=[]);const f=this._nextJobId++,g={"type":a,"isBroadcast":!1,"jobId":f,"params":b,"transferables":c},h=new Promise((a,b)=>{this._jobPromises.set(f,{resolve:a,progress:d,reject:b,cancelled:!1})});return e&&e.SetAction(()=>this._CancelJob(f)),this._inputPort.postMessage(g,c),this._MaybeCreateExtraWorker(),h}BroadcastJob(a,b,c){if(!this._isBroken){c||(c=[]);const d=this._nextJobId++,e={"type":a,"isBroadcast":!0,"jobId":d,"params":b,"transferables":c};this._inputPort.postMessage(e,c)}}_CancelJob(a){const b=this._jobPromises.get(a);b&&(b.cancelled=!0,b.resolve=null,b.progress=null,b.reject=null,this._inputPort.postMessage({"type":"_cancel","jobId":a}))}_OnJobWorkerMessage(a){const b=a.data,c=b["type"],d=b["jobId"];switch(c){case"result":this._OnJobResult(d,b["result"]);break;case"progress":this._OnJobProgress(d,b["progress"]);break;case"error":this._OnJobError(d,b["error"]);break;case"ready":this._OnJobWorkerReady();break;case"_testMessageChannelOk":this._OnTestMessageChannelOk();break;default:throw new Error(`unknown message from worker '${c}'`);}}_OnJobResult(a,b){const c=this._jobPromises.get(a);if(!c)throw new Error("invalid job ID");c.cancelled||c.resolve(b),this._jobPromises.delete(a)}_OnJobProgress(a,b){const c=this._jobPromises.get(a);if(!c)throw new Error("invalid job ID");!c.cancelled&&c.progress&&c.progress(b)}_OnJobError(a,b){const c=this._jobPromises.get(a);if(!c)throw new Error("invalid job ID");c.cancelled||c.reject(b),this._jobPromises.delete(a)}_OnJobWorkerReady(){this._isCreatingWorker&&(this._isCreatingWorker=!1,this._jobWorkerCount++,this._jobWorkerCount=this._maxNumWorkers||this._isCreatingWorker||this._hadErrorCreatingWorker||this._jobPromises.size<=this._jobWorkerCount))try{this._isCreatingWorker=!0;const a=await this._runtime.PostComponentMessageToDOMAsync("runtime","create-job-worker");a["outputPort"].onmessage=(a)=>this._OnJobWorkerMessage(a)}catch(a){this._hadErrorCreatingWorker=!0,this._isCreatingWorker=!1,console.error(`[Construct 3] Failed to create job worker; stopping creating any more (created ${this._jobWorkerCount} so far)`,a)}}_TestMessageChannelWorks(){return this._inputPort.postMessage({"type":"_testMessageChannel"}),self.setTimeout(()=>this._CheckMessageChannelTestTimedOut(),2e3),new Promise((a)=>this._testOkResolve=a)}_OnTestMessageChannelOk(){this._testOkResolve(),this._testOkResolve=null}_CheckMessageChannelTestTimedOut(){this._testOkResolve&&(console.warn("MessageChannel determined to be broken. Job scheduler disabled."),this._isBroken=!0,this._testOkResolve(),this._testOkResolve=null)}}; @@ -541,6 +547,9 @@ self["C3_Shaders"] = {}; this.pngPath = properties[2]; this.skinName = properties[3]; this.animationName = properties[4]; + this.skeletonName = properties[5]; + this.skeletonScale = properties[6]; + this.premultipliedAlpha = properties[7]; } this.isMirrored = false; @@ -553,16 +562,13 @@ self["C3_Shaders"] = {}; this.pngURI = "" this.atlasURI = "" this.jsonURI = "" - this.toggleFPS = 0 - - // Control render frame rate 0 = full rate, 1 = 1/2 rate, etc. - var countFPS = 0; + this.c3renderer = null + this.c3wgl = globalThis.c3_runtimeInterface._localRuntime.GetCanvasManager().GetWebGLRenderer() + this.canvas = globalThis.c3_runtimeInterface.GetCanvas() // C3 canvas + this.spineFB = null - //this.canvas = this.CreateElement(); this._StartTicking(); - console.log(this); - } // spineDemos.log = true @@ -572,133 +578,92 @@ self["C3_Shaders"] = {}; this._elementId = "SpineCanvas_" + uid; this.DEMO_NAME = this._elementId; - this.assetManager = new spine.SharedAssetManager(); - this.hackAssetManager(); + // Get C3 canvas gl context + // Context already exists and we want to use (for render to texture) + // XXX Can't change existing context attributes (though we may want to for PMA) + // var config = { alpha: false }; + var config = {} + this.gl = this.canvas.getContext("webgl2", config) || this.canvas.getContext("webgl", config) || canvas.getContext("experimental-webgl", config); + var gl = this.gl + if (!gl) { + alert('WebGL is unavailable.'); + return; + } - this.bgColor = new spine.Color(0.0, 0.0, 0.0, 0.0); - this.mvp = new spine.webgl.Matrix4(); + var version = 0; + this.isWebGL2 = false; + var glVersion = gl.getParameter( gl.VERSION ); + + if ( glVersion.indexOf( 'WebGL' ) !== - 1 ) + { + version = parseFloat( /^WebGL\ ([0-9])/.exec( glVersion )[ 1 ] ); + this.isWebGL2 = ( version >= 2.0 ); + } else if ( glVersion.indexOf( 'OpenGL ES' ) !== - 1 ) + { + + version = parseFloat( /^OpenGL\ ES\ ([0-9])/.exec( glVersion )[ 1 ] ); + this.isWebGL2 = ( version >= 3.0 ); + } - const canvas = this.CreateCanvas(this._elementId); - this.canvas = canvas; + // Init Spine elements + this.mvp = new spine.webgl.Matrix4(); + this.shader = spine.webgl.Shader.newTwoColoredTextured(gl); + this.batcher = new spine.webgl.PolygonBatcher(gl); + this.mvp.ortho2d(0, 0, 0, 0); // XXX Render to texture size unknown until skeleton loaded. + this.renderer = new spine.webgl.SkeletonRenderer(gl); + this.shapes = new spine.webgl.ShapeRenderer(gl); + this.assetManager = new spine.SharedAssetManager(); + this.bgColor = new spine.Color(0.0, 0.0, 0.0, 0.0); - console.log(this._runtime); + console.log(gl) this.pngURI = await globalThis.c3_runtimeInterface._localRuntime._assetManager.GetProjectFileUrl(this.pngPath); this.atlasURI = await globalThis.c3_runtimeInterface._localRuntime._assetManager.GetProjectFileUrl(this.atlasPath); this.jsonURI = await globalThis.c3_runtimeInterface._localRuntime._assetManager.GetProjectFileUrl(this.jsonPath); - const gl = canvas.ctx.gl; - this.gl = gl; - console.log("LOADING SPINE STUFF"); + // Change PMA format to load spine texture + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,false); + console.log("update:gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL:"+gl.getParameter(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL)); + var textureLoader = function(img) { return new spine.webgl.GLTexture(gl, img); }; this.assetManager.loadJson(this.DEMO_NAME, this.jsonURI); this.assetManager.loadTexture(this.DEMO_NAME, textureLoader, this.pngURI); this.assetManager.loadText(this.DEMO_NAME, this.atlasURI); - this.renderer = new spine.webgl.SceneRenderer(canvas, gl); this.isSpineInitialized = true; - console.log("Spine renderer initialized"); - } - - hackAssetManager() { - spine.SharedAssetManager.prototype.loadText = function(clientId, path) { - var _this = this; - path = this.pathPrefix + path; - if (!this.queueAsset(clientId, null, path)) - return; - - fetch(path) - .then(function(response) { - if (!response.ok) { - throw Error(response.statusText); - } - return response.text(); - }) - .then(function(rawText) { - console.log("Text asset loaded"); - _this.rawAssets[path] = rawText; - }) - .catch(function(error) { - console.log('Looks like there was a problem: \n', error); - }); - }; - spine.SharedAssetManager.prototype.loadJson = function(clientId, path) { - var _this = this; - path = this.pathPrefix + path; - if (!this.queueAsset(clientId, null, path)) - return; - - fetch(path) - .then(function(response) { - if (!response.ok) { - throw Error(response.statusText); - } - return response.json(); - }) - .then(function(responseAsJson) { - console.log("Spin json loaded"); - _this.rawAssets[path] = responseAsJson; - }) - .catch(function(error) { - console.log('Looks like there was a problem: \n', error); - }); - }; + // Restore PMA format to C3 state + // XXX Can not be reset here, causes PMA texture load to be incorrect + // gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,true); + + console.log("Spine renderer initialized"); } resize() { - const canvas = this.canvas; - var w = canvas.clientWidth; - var h = canvas.clientHeight; var bounds = this.skeletonInfo.bounds; - if (canvas.width != w || canvas.height != h) { - canvas.width = w; - canvas.height = h; - } // magic - var centerX = bounds.offset.x + bounds.size.x / 2; - var centerY = bounds.offset.y + bounds.size.y / 2; - var scaleX = bounds.size.x / canvas.width; - var scaleY = bounds.size.y / canvas.height; - var scale = Math.max(scaleX, scaleY) * 1.2; + var centerX = bounds.offset.x + (bounds.size.x) / 2; + var centerY = bounds.offset.y + (bounds.size.y) / 2; + var scaleX = bounds.size.x / (bounds.size.x); + var scaleY = bounds.size.y / (bounds.size.y); + var scale = Math.max(scaleX, scaleY) * (1/this.skeletonScale); if (scale < 1) scale = 1; - var width = canvas.width * scale; - var height = canvas.height * scale; + var width = (bounds.size.x) * scale; + var height = (bounds.size.y) * scale; this.mvp.ortho2d(centerX - width / 2, centerY - height / 2, width, height); - //this.gl.viewport(0, 0, canvas.width, canvas.height); - } - - CreateCanvas(elementId) { - - const scale = this._runtime.GetDisplayScale() * 2; - - var wi = this.GetWorldInfo(); - // Create test canvas with transparency for Spine render to, add more canvases for more animations - var canvasNew = document.createElement('canvas'); - canvasNew.id = elementId; - canvasNew.width = wi.GetWidth() * scale; - canvasNew.height = wi.GetHeight() * scale; - canvasNew.style.zIndex = -9990; - canvasNew.style.position = "absolute"; - canvasNew.style.border = "0px solid"; - canvasNew.style.top = 0; - canvasNew.style.left = 0; - canvasNew.background = "Green"; - canvasNew.style.opacity = 0.0; - canvasNew.ctx = new spine.webgl.ManagedWebGLRenderingContext(canvasNew, { alpha: true }); - - var body = document.getElementsByTagName("body")[0]; - body.appendChild(canvasNew); - - return canvasNew; + // XXX will resize c3 canvas, if FB bound to C3 canvas + // this.gl.viewport(0, 0, bounds.size.x, bounds.size.y); + // only do in render function where it can be restored } loadSkeletons() { console.log("Loading skeleton"); - this.skeletonInfo = this.loadSkeleton("hero_human_female", this.animationName); + // this.skeletonInfo = this.loadSkeleton("hero_human_female", this.animationName); + // XXX hack to allow different skeletons loaded by oveloading skinName + this.skeletonInfo = this.loadSkeleton(this.skeletonName, this.animationName); const skins = this.skeletonInfo.skeleton.data.skins; this.skinNames = skins.map(x => x.name); @@ -711,8 +676,10 @@ self["C3_Shaders"] = {}; console.log("Skeleton loaded"); - + // XXX Do not resize C3 canvas + // XXX May need to delete and resize texture buffer that is created instead? this.resize(); + console.log(this.skeletonInfo) this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnSkeletonLoaded); } @@ -739,7 +706,14 @@ self["C3_Shaders"] = {}; console.log("Reading skeleton data"); - var skeletonData = skeletonJson.readSkeletonData(assetManager.get(this.DEMO_NAME, this.jsonURI) /*[name]*/ ); + // XXX JSON file with one skeleton, no name? + if (this.skeletonName == "") + { + var skeletonData = skeletonJson.readSkeletonData(assetManager.get(this.DEMO_NAME, this.jsonURI) /*[name]*/ ); + } else + { + var skeletonData = skeletonJson.readSkeletonData(assetManager.get(this.DEMO_NAME, this.jsonURI) [name] ); + } console.log("creating skeleton"); @@ -817,6 +791,14 @@ self["C3_Shaders"] = {}; const state = this.skeletonInfo.state; const skeleton = this.skeletonInfo.skeleton; state.setAnimation(0, this.animationName, loop); + + state.tracks[0].listener = { + complete: (trackEntry, count) => { + this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnimationFinished); + this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnyAnimationFinished); + } + }; + state.apply(skeleton); } catch (ex) { console.error(ex); @@ -856,28 +838,130 @@ self["C3_Shaders"] = {}; } render() { - const renderer = this.renderer; const gl = this.gl; + const bounds = this.skeletonInfo.bounds; - var active = this.skeletonInfo; - var skeleton = active.skeleton; - var offset = active.bounds.offset; - var size = active.bounds.size; - renderer.camera.position.x = offset.x + size.x / 2; - renderer.camera.position.y = offset.y + size.y / 2 + 20; - renderer.camera.viewportWidth = size.x * 1.5; - renderer.camera.viewportHeight = size.y * 1.5; - renderer.resize(spine.webgl.ResizeMode.Fit); + // End C3 Batch + // this.c3wgl.EndBatch(); + + var oldFrameBuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING); + // Render to our targetTexture by binding the framebuffer to the SpineFB texture + gl.bindFramebuffer(gl.FRAMEBUFFER, this.spineFB); + + // Save C3 webgl context, may be able to reduce some + // Create VAO for Spine to use. May need to change this for non-webgl2 + // Handle webgl1 and webgl2 + if (!this.isWebGL2) + { + var extOESVAO = gl.getExtension("OES_vertex_array_object"); + if (!extOESVAO) + { + alert("Spine plugin error: webGL1 with no OES_vertex_array_object support"); // tell user they don't have the required extension or work around it + return; + } + + } + + // XXX Should move to spine init + if(!this.myVAO) + { + if (this.isWebGL2) + { + this.myVAO = gl.createVertexArray(); + } else + { + this.myVAO = extOESVAO.createVertexArrayOES(); + } + + } + + if (this.isWebGL2) + { + var oldVAO = gl.createVertexArray(); + oldVAO = gl.getParameter(gl.VERTEX_ARRAY_BINDING); + } else + { + var oldVAO = extOESVAO.createVertexArrayOES(); + oldVAO = gl.getParameter(extOESVAO.VERTEX_ARRAY_BINDING_OES); + } + + var oldProgram = gl.getParameter(gl.CURRENT_PROGRAM); + var oldActive = gl.getParameter(gl.ACTIVE_TEXTURE); + var oldTex = gl.getParameter(gl.TEXTURE_BINDING_2D); + var oldBinding = gl.getParameter(gl.ARRAY_BUFFER_BINDING); + var oldElement = gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING); + var oldClearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE); + var oldViewport = gl.getParameter(gl.VIEWPORT); + // Bind to private VAO so Spine use does not impact C3 VAO + + if (this.isWebGL2) + { + gl.bindVertexArray(this.myVAO); + } else + { + extOESVAO.bindVertexArrayOES(this.myVAO); + } + + // Set viewport? + gl.viewport(0, 0, bounds.size.x, bounds.size.y); + + // Set proper webgl blend for Spine render + gl.enable(gl.BLEND); + gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + // Some random appearing alpha / pma issue may be related to blend func + // XXX gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); + + gl.bindTexture(gl.TEXTURE_2D, null); + gl.bindBuffer(gl.ARRAY_BUFFER, null); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); + + // Bind the shader and set the texture and model-view-projection matrix. + this.shader.bind(); + this.shader.setUniformi(spine.webgl.Shader.SAMPLER, 0); + this.shader.setUniform4x4f(spine.webgl.Shader.MVP_MATRIX, this.mvp.values); + + // Start the batch and tell the SkeletonRenderer to render the active skeleton. + this.batcher.begin(this.shader); + + // Apply vertex effect + this.renderer.vertexEffect = null; gl.clearColor(0, 0, 0, 0); gl.clear(gl.COLOR_BUFFER_BIT); - renderer.begin(); - renderer.drawSkeleton(skeleton, true); - renderer.end(); - - gl.bindFramebuffer(gl.FRAMEBUFFER, null); + // Resize + this.resize(); + // Render + this.renderer.premultipliedAlpha = this.premultipliedAlpha; + this.renderer.draw(this.batcher, this.skeletonInfo.skeleton); + this.batcher.end(); + this.shader.unbind(); + + // Change back to C3 FB last used + gl.bindFramebuffer(gl.FRAMEBUFFER, oldFrameBuffer); + + // Restore C3 webgl state + gl.useProgram(oldProgram); + if (this.isWebGL2) + { + gl.bindVertexArray(oldVAO); + } else + { + extOESVAO.bindVertexArrayOES(oldVAO); + } + gl.activeTexture(oldActive); + gl.bindTexture(gl.TEXTURE_2D, oldTex); + gl.bindBuffer(gl.ARRAY_BUFFER, oldBinding); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, oldElement); + gl.clearColor(oldClearColor[0],oldClearColor[1],oldClearColor[2],oldClearColor[3]) + gl.enable(gl.BLEND); + // XXX seems redundant, but C3 set blendFunc twice with different values (may be at end and start?) + // gl.blendFunc(gl.ONE, gl.ZERO) + gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + // XXX incorrect blend, causes first effect to not be drawn (drawn to another FB) + // gl.blendFuncSeparate(gl.DST_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.DST_ALPHA, gl.ONE_MINUS_SRC_ALPHA); + gl.viewport(oldViewport[0],oldViewport[1],oldViewport[2],oldViewport[3]); } @@ -886,7 +970,7 @@ self["C3_Shaders"] = {}; } Tick() { - if (!this.IsSpineReady()) { + if (!this.IsSpineReady()) { return; } const delta = this._runtime.GetDt(); @@ -912,30 +996,47 @@ self["C3_Shaders"] = {}; // this.loggedRenderer = true; // console.log(renderer); // } + var gl = renderer._gl if (this._elementId == "" || !this.isSkeletonLoaded) return; // elementID not set, can't draw the element var myCanvas = this.canvas; + const wi = this.GetWorldInfo(); + const quad = wi.GetBoundingQuad(); + // Create texture if it does not exist (could this be done in constructor?) if (this._elementTexture === null || this._newElementId) { if (this._elementTexture !== null) { renderer.DeleteTexture(this._elementTexture); } + this.c3renderer = renderer + console.log(this.c3renderer) + console.log("BatchState:") + console.log(renderer._batchState.currentShader._shaderProgram) this._newElementId = false; - this._elementTexture = renderer.CreateDynamicTexture(myCanvas.width, myCanvas.height, { mipMap: false }); - console.log("Created dynamic texture for spine " + this._elementId); + var bounds = this.skeletonInfo.bounds; + this._elementTexture = renderer.CreateDynamicTexture(bounds.size.x, bounds.size.y, { mipMap: false }); + + var oldFrameBuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING); + // Create FB and bind texture to spineFB + this.spineFB = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.spineFB); + // attach the texture as the first color attachment + const attachmentPoint = gl.COLOR_ATTACHMENT0; + gl.framebufferTexture2D(gl.FRAMEBUFFER, attachmentPoint, gl.TEXTURE_2D, this._elementTexture._texture, 0); + console.log("this.spineFB created:"+this.spineFB) + // Restore render to the canvas + gl.bindFramebuffer(gl.FRAMEBUFFER, oldFrameBuffer); + console.log("Created dynamic texture for spine:" + this._elementId); } + // Render skeleton if (this.isSkeletonLoaded && this._elementTexture !== null) { this.render(); } - - const wi = this.GetWorldInfo(); - const quad = wi.GetBoundingQuad(); - let x0 = 0; let x1 = 1; if (this.isMirrored) { @@ -943,13 +1044,11 @@ self["C3_Shaders"] = {}; x1 = 0; } - const rcTex = new C3.Rect(x0, 0, x1, 1); // Possible to get from this._texture instead? Not needed, not spritesheeted? - - renderer.UpdateTexture(myCanvas, this._elementTexture, {}); + // Flip Y due to render to texture vs fb, Y is flipped + const rcTex = new C3.Rect(x0, 1, x1, 0); // Possible to get from this._texture instead? Not needed, not spritesheeted? renderer.SetTexture(this._elementTexture); - - + if (this._runtime.IsPixelRoundingEnabled()) { const ox = Math.round(wi.GetX()) - wi.GetX(); const oy = Math.round(wi.GetY()) - wi.GetY(); @@ -960,7 +1059,6 @@ self["C3_Shaders"] = {}; renderer.Quad3(quad, rcTex); } - //console.log(this._elementTexture); } SaveToJson() { @@ -989,8 +1087,20 @@ self["C3_Shaders"] = {}; { C3.Plugins.Gritsenko_Spine.Cnds = { - OnSkeletonLoaded(){ + OnSkeletonLoaded() { return true; + }, + + OnAnimationFinished(animationName) { + return this.animationName == animationName; + }, + + OnAnyAnimationFinished() { + return true; + }, + + IsAnimationPlaying(animationName) { + return this.animationName == animationName; } }; @@ -1115,7 +1225,7 @@ self["C3_Shaders"] = {}; "use strict";C3.Plugins.Text.Type=class extends C3.SDKTypeBase{constructor(a){super(a)}Release(){super.Release()}OnCreate(){}LoadTextures(){}ReleaseTextures(){}}; -"use strict";{const a=[0,0,0],b=["left","center","right"],c=["top","center","bottom"],d=new C3.Rect,e=new C3.Quad;C3.Plugins.Text.Instance=class extends C3.SDKWorldInstanceBase{constructor(a,b){if(super(a),this._text="",this._enableBBcode=!0,this._faceName="Arial",this._ptSize=12,this._lineHeightOffset=0,this._isBold=!1,this._isItalic=!1,this._color=C3.New(C3.Color),this._horizontalAlign=0,this._verticalAlign=0,this._wrapByWord=!0,this._typewriterStartTime=-1,this._typewriterEndTime=-1,this._typewriterLength=0,this._webglText=C3.New(C3.Gfx.WebGLText,this._runtime.GetWebGLRenderer(),{timeout:5}),this._webglText.ontextureupdate=()=>this._runtime.UpdateRender(),this._webglText.SetIsAsync(!1),b){this._text=b[0],this._enableBBcode=!!b[1],this._faceName=b[2],this._ptSize=b[3],this._lineHeightOffset=b[4],this._isBold=!!b[5],this._isItalic=!!b[6],this._horizontalAlign=b[8],this._verticalAlign=b[9],this._wrapByWord=0===b[10];const a=b[7];this._color.setRgb(a[0],a[1],a[2]),this.GetWorldInfo().SetVisible(b[11])}this._UpdateTextSettings()}Release(){this._CancelTypewriter(),this._webglText.Release(),this._webglText=null,super.Release()}_UpdateTextSettings(){const a=this._webglText;a.SetText(this._text),a.SetBBCodeEnabled(this._enableBBcode),a.SetFontName(this._faceName),a.SetFontSize(this._ptSize),a.SetLineHeight(this._lineHeightOffset),a.SetBold(this._isBold),a.SetItalic(this._isItalic),a.SetColor(this._color),a.SetHorizontalAlignment(b[this._horizontalAlign]),a.SetVerticalAlignment(c[this._verticalAlign]),a.SetWordWrapMode(this._wrapByWord?"word":"character")}_UpdateTextSize(){const a=this.GetWorldInfo(),b=a.GetLayer(),c=b.GetRenderScale()*b.Get2DScaleFactorToZ(a.GetTotalZElevation());this._webglText.SetSize(a.GetWidth(),a.GetHeight(),c)}Draw(a){var b=Math.round;const c=this.GetWorldInfo();this._UpdateTextSize();const f=this._webglText.GetTexture();if(!f)return;const g=c.GetLayer();let h=c.GetBoundingQuad();if(0===c.GetAngle()&&0===c.GetLayer().GetAngle()&&0===c.GetTotalZElevation()){const[c,i]=g.LayerToDrawSurface(h.getTlx(),h.getTly()),[j,k]=g.LayerToDrawSurface(h.getBrx(),h.getBry()),l=c-b(c),m=i-b(i);d.set(c,i,j,k),d.offset(-l,-m),e.setFromRect(d);const[n,o]=a.GetRenderTargetSize(a.GetRenderTarget());this._runtime.GetCanvasManager().SetDeviceTransform(a,n,o),a.SetTexture(f),a.Quad3(e,this._webglText.GetTexRect()),g._SetTransform(a)}else{let c=0,d=0;this._runtime.IsPixelRoundingEnabled()&&(c=h.getTlx()-b(h.getTlx()),d=h.getTly()-b(h.getTly())),(0!=c||0!=d)&&(e.copy(h),e.offset(-c,-d),h=e),a.SetTexture(f),a.Quad3(h,this._webglText.GetTexRect())}}SaveToJson(){const a={"t":this._text,"c":this._color.toJSON(),"fn":this._faceName,"ps":this._ptSize};return this._enableBBcode&&(a["bbc"]=this._enableBBcode),0!==this._horizontalAlign&&(a["ha"]=this._horizontalAlign),0!==this._verticalAlign&&(a["va"]=this._verticalAlign),this._wrapByWord||(a["wr"]=this._wrapByWord),0!==this._lineHeightOffset&&(a["lho"]=this._lineHeightOffset),this._isBold&&(a["b"]=this._isBold),this._isItalic&&(a["i"]=this._isItalic),-1!==this._typewriterEndTime&&(a["tw"]={"st":this._typewriterStartTime,"en":this._typewriterEndTime,"l":this._typewriterLength}),a}LoadFromJson(a){if(this._CancelTypewriter(),this._text=a["t"],this._color.setFromJSON(a["c"]),this._faceName=a["fn"],this._ptSize=a["ps"],this._enableBBcode=!!a.hasOwnProperty("bbc")&&a["bbc"],this._horizontalAlign=a.hasOwnProperty("ha")?a["ha"]:0,this._verticalAlign=a.hasOwnProperty("va")?a["va"]:0,this._wrapByWord=!a.hasOwnProperty("wr")||a["wr"],this._lineHeightOffset=a.hasOwnProperty("lho")?a["lho"]:0,this._isBold=!!a.hasOwnProperty("b")&&a["b"],this._isItalic=!!a.hasOwnProperty("i")&&a["i"],a.hasOwnProperty("tw")){const b=a["tw"];this._typewriterStartTime=b["st"],this._typewriterEndTime=b["en"],this._typewriterLength=b["l"]}this._UpdateTextSettings(),-1!==this._typewriterEndTime&&this._StartTicking()}GetPropertyValueByIndex(b){return 0===b?this._text:1===b?this._enableBBcode:2===b?this._faceName:3===b?this._ptSize:4===b?this._lineHeightOffset:5===b?this._isBold:6===b?this._isItalic:7===b?(a[0]=this._color.getR(),a[1]=this._color.getG(),a[2]=this._color.getB(),a):8===b?this._horizontalAlign:9===b?this._verticalAlign:10===b?this._wrapByWord?1:0:void 0}SetPropertyValueByIndex(a,b){switch(a){case 0:if(this._text===b)return;this._text=b,this._UpdateTextSettings();break;case 1:if(this._enableBBcode===!!b)return;this._enableBBcode=!!b,this._UpdateTextSettings();break;case 2:if(this._faceName===b)return;this._faceName=b,this._UpdateTextSettings();break;case 3:if(this._ptSize===b)return;this._ptSize=b,this._UpdateTextSettings();break;case 4:if(this._lineHeightOffset===b)return;this._lineHeightOffset=b,this._UpdateTextSettings();break;case 5:if(this._isBold===!!b)return;this._isBold=!!b,this._UpdateTextSettings();break;case 6:if(this._isItalic===!!b)return;this._isItalic=!!b,this._UpdateTextSettings();break;case 7:const d=this._color,c=b;if(d.getR()===c[0]&&d.getG()===c[1]&&d.getB()===c[2])return;this._color.setRgb(c[0],c[1],c[2]),this._UpdateTextSettings();break;case 8:if(this._horizontalAlign===b)return;this._horizontalAlign=b,this._UpdateTextSettings();break;case 9:if(this._verticalAlign===b)return;this._verticalAlign=b,this._UpdateTextSettings();break;case 10:if(this._wrapByWord===(b===0))return;this._wrapByWord=b===0,this._UpdateTextSettings();}}SetPropertyOffsetValueByIndex(a,b){0!==b&&(3===a?(this._ptSize+=b,this._UpdateTextSettings()):4===a?(this._lineHeightOffset+=b,this._UpdateTextSettings()):void 0)}SetPropertyColorOffsetValueByIndex(a,c,d,e){(0!==c||0!==d||0!==e)&&(7===a?(this._color.addRgb(c,d,e),this._UpdateTextSettings()):void 0)}_SetText(a){this._text===a||(this._text=a,this._webglText.SetText(a),this._runtime.UpdateRender())}GetText(){return this._text}_StartTypewriter(a,b){this._SetText(a),this._typewriterStartTime=this._runtime.GetGameTime(),this._typewriterEndTime=this._typewriterStartTime+b,this._typewriterLength=C3.BBString.StripAnyTags(a).length,this._webglText.SetDrawMaxCharacterCount(0),this._StartTicking()}_CancelTypewriter(){this._typewriterStartTime=-1,this._typewriterEndTime=-1,this._typewriterLength=0,this._webglText.SetDrawMaxCharacterCount(-1),this._StopTicking()}_FinishTypewriter(){-1===this._typewriterEndTime||(this._CancelTypewriter(),this.Trigger(C3.Plugins.Text.Cnds.OnTypewriterTextFinished),this._runtime.UpdateRender())}_SetFontFace(a){this._faceName===a||(this._faceName=a,this._webglText.SetFontName(a),this._runtime.UpdateRender())}_GetFontFace(){return this._faceName}_SetBold(a){a=!!a;this._isBold===a||(this._isBold=a,this._webglText.SetBold(a),this._runtime.UpdateRender())}_IsBold(){return this._isBold}_SetItalic(a){a=!!a;this._isItalic===a||(this._isItalic=a,this._webglText.SetItalic(a),this._runtime.UpdateRender())}_IsItalic(){return this._isItalic}_SetFontSize(a){this._ptSize===a||(this._ptSize=a,this._webglText.SetFontSize(this._ptSize),this._runtime.UpdateRender())}_GetFontSize(){return this._ptSize}_SetLineHeight(a){this._lineHeightOffset===a||(this._lineHeightOffset=a,this._UpdateTextSettings(),this._runtime.UpdateRender())}_GetLineHeight(){return this._lineHeightOffset}_SetHAlign(a){this._horizontalAlign===a||(this._horizontalAlign=a,this._UpdateTextSettings(),this._runtime.UpdateRender())}_GetHAlign(){return this._horizontalAlign}_SetVAlign(a){this._verticalAlign===a||(this._verticalAlign=a,this._UpdateTextSettings(),this._runtime.UpdateRender())}_GetVAlign(){return this._verticalAlign}_SetWrapByWord(a){a=!!a;this._wrapByWord===a||(this._wrapByWord=a,this._UpdateTextSettings(),this._runtime.UpdateRender())}_IsWrapByWord(){return this._wrapByWord}Tick(){const a=this._runtime.GetGameTime();if(a>=this._typewriterEndTime)this._CancelTypewriter(),this.Trigger(C3.Plugins.Text.Cnds.OnTypewriterTextFinished),this._runtime.UpdateRender();else{let b=C3.relerp(this._typewriterStartTime,this._typewriterEndTime,a,0,this._typewriterLength);b=Math.floor(b),b!==this._webglText.GetDrawMaxCharacterCount()&&(this._webglText.SetDrawMaxCharacterCount(b),this._runtime.UpdateRender())}}GetDebuggerProperties(){return[{title:"plugins.text.name",properties:[{name:"plugins.text.properties.text.name",value:this._text,onedit:(a)=>this._SetText(a)}]}]}GetScriptInterfaceClass(){return ITextInstance}};const f=new WeakMap,g=new Map([["left",0],["center",1],["right",2]]),h=new Map([["top",0],["center",1],["bottom",2]]),i=new Map([["word",!0],["character",!1]]);self.ITextInstance=class extends IWorldInstance{constructor(){super(),f.set(this,IInstance._GetInitInst().GetSdkInstance())}get text(){return f.get(this).GetText()}set text(a){const b=f.get(this);b._CancelTypewriter(),b._SetText(a)}typewriterText(a,b){const c=f.get(this);c._CancelTypewriter(),c._StartTypewriter(a,b)}typewriterFinish(){f.get(this)._FinishTypewriter()}set fontFace(a){f.get(this)._SetFontFace(a)}get fontFace(){return f.get(this)._GetFontFace()}set isBold(a){f.get(this)._SetBold(a)}get isBold(){return f.get(this)._IsBold()}set isItalic(a){f.get(this)._SetItalic(a)}get isItalic(){return f.get(this)._IsItalic()}set sizePt(a){f.get(this)._SetFontSize(a)}get sizePt(){return f.get(this)._GetFontSize()}set lineHeight(a){f.get(this)._SetLineHeight(a)}get lineHeight(){return f.get(this)._GetLineHeight()}set horizontalAlign(a){const b=g.get(a);if("undefined"==typeof b)throw new Error("invalid mode");f.get(this)._SetHAlign(b)}get horizontalAlign(){return b[f.get(this)._GetHAlign()]}set verticalAlign(a){const b=h.get(a);if("undefined"==typeof b)throw new Error("invalid mode");f.get(this)._SetVAlign(b)}get verticalAlign(){return c[f.get(this)._GetVAlign()]}set wordWrapMode(a){const b=i.get(a);if("undefined"==typeof b)throw new Error("invalid mode");f.get(this)._SetWrapByWord(b)}get wordWrapMode(){return f.get(this)._IsWrapByWord()?"word":"character"}}} +"use strict";{const a=[0,0,0],b=["left","center","right"],c=["top","center","bottom"],d=new C3.Rect,e=new C3.Quad;C3.Plugins.Text.Instance=class extends C3.SDKWorldInstanceBase{constructor(a,b){if(super(a),this._text="",this._enableBBcode=!0,this._faceName="Arial",this._ptSize=12,this._lineHeightOffset=0,this._isBold=!1,this._isItalic=!1,this._color=C3.New(C3.Color),this._horizontalAlign=0,this._verticalAlign=0,this._wrapByWord=!0,this._typewriterStartTime=-1,this._typewriterEndTime=-1,this._typewriterLength=0,this._webglText=C3.New(C3.Gfx.WebGLText,this._runtime.GetWebGLRenderer(),{timeout:5}),this._webglText.ontextureupdate=()=>this._runtime.UpdateRender(),this._webglText.SetIsAsync(!1),b){this._text=b[0],this._enableBBcode=!!b[1],this._faceName=b[2],this._ptSize=b[3],this._lineHeightOffset=b[4],this._isBold=!!b[5],this._isItalic=!!b[6],this._horizontalAlign=b[8],this._verticalAlign=b[9],this._wrapByWord=0===b[10];const a=b[7];this._color.setRgb(a[0],a[1],a[2]),this.GetWorldInfo().SetVisible(b[11])}this._UpdateTextSettings()}Release(){this._CancelTypewriter(),this._webglText.Release(),this._webglText=null,super.Release()}_UpdateTextSettings(){const a=this._webglText;a.SetText(this._text),a.SetBBCodeEnabled(this._enableBBcode),a.SetFontName(this._faceName),a.SetFontSize(this._ptSize),a.SetLineHeight(this._lineHeightOffset),a.SetBold(this._isBold),a.SetItalic(this._isItalic),a.SetColor(this._color),a.SetHorizontalAlignment(b[this._horizontalAlign]),a.SetVerticalAlignment(c[this._verticalAlign]),a.SetWordWrapMode(this._wrapByWord?"word":"character")}_UpdateTextSize(){const a=this.GetWorldInfo(),b=a.GetLayer(),c=b.GetRenderScale()*b.Get2DScaleFactorToZ(a.GetTotalZElevation());this._webglText.SetSize(a.GetWidth(),a.GetHeight(),c)}Draw(a){var b=Math.round;const c=this.GetWorldInfo();this._UpdateTextSize();const f=this._webglText.GetTexture();if(!f)return;const g=c.GetLayer();let h=c.GetBoundingQuad();if(0===c.GetAngle()&&0===c.GetLayer().GetAngle()&&0===c.GetTotalZElevation()){const[c,i]=g.LayerToDrawSurface(h.getTlx(),h.getTly()),[j,k]=g.LayerToDrawSurface(h.getBrx(),h.getBry()),l=c-b(c),m=i-b(i);d.set(c,i,j,k),d.offset(-l,-m),e.setFromRect(d);const[n,o]=a.GetRenderTargetSize(a.GetRenderTarget());this._runtime.GetCanvasManager().SetDeviceTransform(a,n,o),a.SetTexture(f),a.Quad3(e,this._webglText.GetTexRect()),g._SetTransform(a)}else{let c=0,d=0;this._runtime.IsPixelRoundingEnabled()&&(c=h.getTlx()-b(h.getTlx()),d=h.getTly()-b(h.getTly())),(0!=c||0!=d)&&(e.copy(h),e.offset(-c,-d),h=e),a.SetTexture(f),a.Quad3(h,this._webglText.GetTexRect())}}SaveToJson(){const a={"t":this._text,"c":this._color.toJSON(),"fn":this._faceName,"ps":this._ptSize};return this._enableBBcode&&(a["bbc"]=this._enableBBcode),0!==this._horizontalAlign&&(a["ha"]=this._horizontalAlign),0!==this._verticalAlign&&(a["va"]=this._verticalAlign),this._wrapByWord||(a["wr"]=this._wrapByWord),0!==this._lineHeightOffset&&(a["lho"]=this._lineHeightOffset),this._isBold&&(a["b"]=this._isBold),this._isItalic&&(a["i"]=this._isItalic),-1!==this._typewriterEndTime&&(a["tw"]={"st":this._typewriterStartTime,"en":this._typewriterEndTime,"l":this._typewriterLength}),a}LoadFromJson(a){if(this._CancelTypewriter(),this._text=a["t"],this._color.setFromJSON(a["c"]),this._faceName=a["fn"],this._ptSize=a["ps"],this._enableBBcode=!!a.hasOwnProperty("bbc")&&a["bbc"],this._horizontalAlign=a.hasOwnProperty("ha")?a["ha"]:0,this._verticalAlign=a.hasOwnProperty("va")?a["va"]:0,this._wrapByWord=!a.hasOwnProperty("wr")||a["wr"],this._lineHeightOffset=a.hasOwnProperty("lho")?a["lho"]:0,this._isBold=!!a.hasOwnProperty("b")&&a["b"],this._isItalic=!!a.hasOwnProperty("i")&&a["i"],a.hasOwnProperty("tw")){const b=a["tw"];this._typewriterStartTime=b["st"],this._typewriterEndTime=b["en"],this._typewriterLength=b["l"]}this._UpdateTextSettings(),-1!==this._typewriterEndTime&&this._StartTicking()}GetPropertyValueByIndex(b){return 0===b?this._text:1===b?this._enableBBcode:2===b?this._faceName:3===b?this._ptSize:4===b?this._lineHeightOffset:5===b?this._isBold:6===b?this._isItalic:7===b?(a[0]=this._color.getR(),a[1]=this._color.getG(),a[2]=this._color.getB(),a):8===b?this._horizontalAlign:9===b?this._verticalAlign:10===b?this._wrapByWord?1:0:void 0}SetPropertyValueByIndex(a,b){switch(a){case 0:if(this._text===b)return;this._text=b,this._UpdateTextSettings();break;case 1:if(this._enableBBcode===!!b)return;this._enableBBcode=!!b,this._UpdateTextSettings();break;case 2:if(this._faceName===b)return;this._faceName=b,this._UpdateTextSettings();break;case 3:if(this._ptSize===b)return;this._ptSize=b,this._UpdateTextSettings();break;case 4:if(this._lineHeightOffset===b)return;this._lineHeightOffset=b,this._UpdateTextSettings();break;case 5:if(this._isBold===!!b)return;this._isBold=!!b,this._UpdateTextSettings();break;case 6:if(this._isItalic===!!b)return;this._isItalic=!!b,this._UpdateTextSettings();break;case 7:const d=this._color,c=b;if(d.getR()===c[0]&&d.getG()===c[1]&&d.getB()===c[2])return;this._color.setRgb(c[0],c[1],c[2]),this._UpdateTextSettings();break;case 8:if(this._horizontalAlign===b)return;this._horizontalAlign=b,this._UpdateTextSettings();break;case 9:if(this._verticalAlign===b)return;this._verticalAlign=b,this._UpdateTextSettings();break;case 10:if(this._wrapByWord===(b===0))return;this._wrapByWord=b===0,this._UpdateTextSettings();}}SetPropertyColorOffsetValueByIndex(a,c,d,e){(0!==c||0!==d||0!==e)&&(7===a?(this._color.addRgb(c,d,e),this._UpdateTextSettings()):void 0)}_SetText(a){this._text===a||(this._text=a,this._webglText.SetText(a),this._runtime.UpdateRender())}GetText(){return this._text}_StartTypewriter(a,b){this._SetText(a),this._typewriterStartTime=this._runtime.GetGameTime(),this._typewriterEndTime=this._typewriterStartTime+b,this._typewriterLength=C3.BBString.StripAnyTags(a).length,this._webglText.SetDrawMaxCharacterCount(0),this._StartTicking()}_CancelTypewriter(){this._typewriterStartTime=-1,this._typewriterEndTime=-1,this._typewriterLength=0,this._webglText.SetDrawMaxCharacterCount(-1),this._StopTicking()}_FinishTypewriter(){-1===this._typewriterEndTime||(this._CancelTypewriter(),this.Trigger(C3.Plugins.Text.Cnds.OnTypewriterTextFinished),this._runtime.UpdateRender())}_SetFontFace(a){this._faceName===a||(this._faceName=a,this._webglText.SetFontName(a),this._runtime.UpdateRender())}_GetFontFace(){return this._faceName}_SetBold(a){a=!!a;this._isBold===a||(this._isBold=a,this._webglText.SetBold(a),this._runtime.UpdateRender())}_IsBold(){return this._isBold}_SetItalic(a){a=!!a;this._isItalic===a||(this._isItalic=a,this._webglText.SetItalic(a),this._runtime.UpdateRender())}_IsItalic(){return this._isItalic}_SetFontSize(a){this._ptSize===a||(this._ptSize=a,this._webglText.SetFontSize(this._ptSize),this._runtime.UpdateRender())}_GetFontSize(){return this._ptSize}_SetLineHeight(a){this._lineHeightOffset===a||(this._lineHeightOffset=a,this._UpdateTextSettings(),this._runtime.UpdateRender())}_GetLineHeight(){return this._lineHeightOffset}_SetHAlign(a){this._horizontalAlign===a||(this._horizontalAlign=a,this._UpdateTextSettings(),this._runtime.UpdateRender())}_GetHAlign(){return this._horizontalAlign}_SetVAlign(a){this._verticalAlign===a||(this._verticalAlign=a,this._UpdateTextSettings(),this._runtime.UpdateRender())}_GetVAlign(){return this._verticalAlign}_SetWrapByWord(a){a=!!a;this._wrapByWord===a||(this._wrapByWord=a,this._UpdateTextSettings(),this._runtime.UpdateRender())}_IsWrapByWord(){return this._wrapByWord}Tick(){const a=this._runtime.GetGameTime();if(a>=this._typewriterEndTime)this._CancelTypewriter(),this.Trigger(C3.Plugins.Text.Cnds.OnTypewriterTextFinished),this._runtime.UpdateRender();else{let b=C3.relerp(this._typewriterStartTime,this._typewriterEndTime,a,0,this._typewriterLength);b=Math.floor(b),b!==this._webglText.GetDrawMaxCharacterCount()&&(this._webglText.SetDrawMaxCharacterCount(b),this._runtime.UpdateRender())}}GetDebuggerProperties(){return[{title:"plugins.text.name",properties:[{name:"plugins.text.properties.text.name",value:this._text,onedit:(a)=>this._SetText(a)}]}]}GetScriptInterfaceClass(){return ITextInstance}};const f=new WeakMap,g=new Map([["left",0],["center",1],["right",2]]),h=new Map([["top",0],["center",1],["bottom",2]]),i=new Map([["word",!0],["character",!1]]);self.ITextInstance=class extends IWorldInstance{constructor(){super(),f.set(this,IInstance._GetInitInst().GetSdkInstance())}get text(){return f.get(this).GetText()}set text(a){const b=f.get(this);b._CancelTypewriter(),b._SetText(a)}typewriterText(a,b){const c=f.get(this);c._CancelTypewriter(),c._StartTypewriter(a,b)}typewriterFinish(){f.get(this)._FinishTypewriter()}set fontFace(a){f.get(this)._SetFontFace(a)}get fontFace(){return f.get(this)._GetFontFace()}set isBold(a){f.get(this)._SetBold(a)}get isBold(){return f.get(this)._IsBold()}set isItalic(a){f.get(this)._SetItalic(a)}get isItalic(){return f.get(this)._IsItalic()}set sizePt(a){f.get(this)._SetFontSize(a)}get sizePt(){return f.get(this)._GetFontSize()}set lineHeight(a){f.get(this)._SetLineHeight(a)}get lineHeight(){return f.get(this)._GetLineHeight()}set horizontalAlign(a){const b=g.get(a);if("undefined"==typeof b)throw new Error("invalid mode");f.get(this)._SetHAlign(b)}get horizontalAlign(){return b[f.get(this)._GetHAlign()]}set verticalAlign(a){const b=h.get(a);if("undefined"==typeof b)throw new Error("invalid mode");f.get(this)._SetVAlign(b)}get verticalAlign(){return c[f.get(this)._GetVAlign()]}set wordWrapMode(a){const b=i.get(a);if("undefined"==typeof b)throw new Error("invalid mode");f.get(this)._SetWrapByWord(b)}get wordWrapMode(){return f.get(this)._IsWrapByWord()?"word":"character"}}} "use strict";C3.Plugins.Text.Cnds={CompareText(a,b){return b?this._text===a:C3.equalsNoCase(this._text,a)},IsRunningTypewriterText(){return-1!==this._typewriterEndTime},OnTypewriterTextFinished(){return!0}}; @@ -1139,13 +1249,13 @@ self["C3_Shaders"] = {}; "use strict";C3.Behaviors.EightDir.Type=class extends C3.SDKBehaviorTypeBase{constructor(a){super(a)}Release(){super.Release()}OnCreate(){}}; -"use strict";{C3.Behaviors.EightDir.Instance=class extends C3.SDKBehaviorInstanceBase{constructor(a,b){super(a),this._upKey=!1,this._downKey=!1,this._leftKey=!1,this._rightKey=!1,this._ignoreInput=!1,this._simUp=!1,this._simDown=!1,this._simLeft=!1,this._simRight=!1,this._dx=0,this._dy=0,this._maxSpeed=200,this._acc=600,this._dec=500,this._directions=3,this._angleMode=3,this._defaultControls=!0,this._isEnabled=!0,b&&(this._maxSpeed=b[0],this._acc=b[1],this._dec=b[2],this._directions=b[3],this._angleMode=b[4],this._defaultControls=!!b[5],this._isEnabled=!!b[6]),this._isEnabled&&this._StartTicking(),this._defaultControls&&this._BindEvents()}_BindEvents(){if(!this._disposables){const a=this._runtime.Dispatcher();this._disposables=new C3.CompositeDisposable(C3.Disposable.From(a,"keydown",(a)=>this._OnKeyDown(a.data)),C3.Disposable.From(a,"keyup",(a)=>this._OnKeyUp(a.data)),C3.Disposable.From(a,"window-blur",()=>this._OnWindowBlur()))}}_UnBindEvents(){this._disposables&&(this._disposables.Release(),this._disposables=null)}Release(){super.Release()}SaveToJson(){return{"dx":this._dx,"dy":this._dy,"e":this._isEnabled,"ms":this._maxSpeed,"acc":this._acc,"dec":this._dec,"d":this._directions,"am":this._angleMode,"dc":this._defaultControls,"ii":this._ignoreInput}}LoadFromJson(a){this._dx=a["dx"],this._dy=a["dy"],this._SetEnabled(a["e"]),this._maxSpeed=a["ms"],this._acc=a["acc"],this._dec=a["dec"],this._directions=a["d"],this._angleMode=a["am"],this._defaultControls=a["dc"],this._ignoreInput=a["ii"],this._upKey=!1,this._downKey=!1,this._leftKey=!1,this._rightKey=!1,this._simUp=!1,this._simDown=!1,this._simLeft=!1,this._simRight=!1,this._defaultControls?this._BindEvents():this._UnBindEvents()}_OnKeyDown(a){switch(a["key"]){case"ArrowLeft":this._leftKey=!0;break;case"ArrowUp":this._upKey=!0;break;case"ArrowRight":this._rightKey=!0;break;case"ArrowDown":this._downKey=!0;}}_OnKeyUp(a){switch(a["key"]){case"ArrowLeft":this._leftKey=!1;break;case"ArrowUp":this._upKey=!1;break;case"ArrowRight":this._rightKey=!1;break;case"ArrowDown":this._downKey=!1;}}_OnWindowBlur(){this._upKey=!1,this._downKey=!1,this._leftKey=!1,this._rightKey=!1}Tick(){var b=Math.round,c=Math.floor,d=Math.abs,e=Math.atan2,a=Math.max,f=Math.min;const g=this._runtime.GetDt(this._inst),h=this._runtime.GetCollisionEngine();let i=this._leftKey||this._simLeft,j=this._rightKey||this._simRight,k=this._upKey||this._simUp,l=this._downKey||this._simDown;if(this._simLeft=!1,this._simRight=!1,this._simUp=!1,this._simDown=!1,!this._isEnabled)return;let m=h.TestOverlapSolid(this._inst);if(m&&(h.RegisterCollision(this._inst,m),!h.PushOutSolidNearest(this._inst)))return;this._ignoreInput&&(i=j=k=l=!1),0===this._directions?i=j=!1:1===this._directions&&(k=l=!1),2===this._directions&&(k||l)&&(i=j=!1),i===j&&(0>this._dx?this._dx=f(this._dx+this._dec*g,0):0this._dy?this._dy=f(this._dy+this._dec*g,0):0this._dx?n=this._acc+this._dec:n=this._acc),k&&!l&&(0this._dy?o=this._acc+this._dec:o=this._acc),this._dx+=n*g,this._dy+=o*g,0!==this._dx||0!==this._dy){const f=Math.sqrt(this._dx*this._dx+this._dy*this._dy),i=e(this._dy,this._dx),a=this._maxSpeed*Math.cos(i),j=this._maxSpeed*Math.sin(i);f>this._maxSpeed&&(this._dx=a,this._dy=j);const k=d(a)*g,l=d(j)*g,p=this._inst.GetWorldInfo(),q=p.GetX(),r=p.GetY(),s=p.GetAngle(),t=C3.clamp(this._dx*g+.5*n*g*g,-k,k);p.OffsetX(t),p.SetBboxChanged(),m=h.TestOverlapSolid(this._inst),m&&(!h.PushOutSolid(this._inst,0>this._dx?1:-1,0,d(c(t)))&&(p.SetX(q),p.SetBboxChanged()),this._dx=0,h.RegisterCollision(this._inst,m));const u=C3.clamp(this._dy*g+.5*o*g*g,-l,l);p.OffsetY(u),p.SetBboxChanged(),m=h.TestOverlapSolid(this._inst),m&&(!h.PushOutSolid(this._inst,0,0>this._dy?1:-1,d(c(u)))&&(p.SetY(r),p.SetBboxChanged()),this._dy=0,h.RegisterCollision(this._inst,m));const v=C3.round6dp(this._dx),w=C3.round6dp(this._dy);(0!==v||0!==w)&&this._inst.GetPlugin().IsRotatable()&&(1===this._angleMode?p.SetAngle(C3.toRadians(90*b(C3.toDegrees(e(w,v))/90))):2===this._angleMode?p.SetAngle(C3.toRadians(45*b(C3.toDegrees(e(w,v))/45))):3===this._angleMode&&p.SetAngle(e(w,v))),p.SetBboxChanged(),p.GetAngle()!=s&&(m=h.TestOverlapSolid(this._inst),m&&(p.SetAngle(s),p.SetBboxChanged(),h.RegisterCollision(this._inst,m)))}}GetPropertyValueByIndex(a){return a===0?this._maxSpeed:1===a?this._acc:2===a?this._dec:3===a?this._directions:4===a?this._angleMode:5===a?this._defaultControls:6===a?this._isEnabled:void 0}SetPropertyValueByIndex(a,b){a===0?this._maxSpeed=b:1===a?this._acc=b:2===a?this._dec=b:3===a?this._directions=b:4===a?this._angleMode=b:5===a?(this._defaultControls=!!b,this._defaultControls?this._BindEvents():this._UnBindEvents()):6===a?this._SetEnabled(b):void 0}SetPropertyOffsetValueByIndex(a,b){0!==b&&(0===a?this._maxSpeed+=b:1===a?this._acc+=b:2===a?this._dec+=b:void 0)}_MaybeClampSpeed(){const a=Math.hypot(this._dx,this._dy);a>this._maxSpeed&&this._SetSpeed(a)}_SetSpeed(b){b=C3.clamp(b,0,this._maxSpeed);const c=Math.atan2(this._dy,this._dx);this._dx=b*Math.cos(c),this._dy=b*Math.sin(c)}_SetEnabled(a){this._isEnabled=!!a,this._isEnabled?this._StartTicking():(this._simLeft=!1,this._simRight=!1,this._simUp=!1,this._simDown=!1,this._StopTicking())}GetDebuggerProperties(){return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:"behaviors.eightdir.debugger.vector-x",value:this._dx,onedit:(a)=>this._dx=a},{name:"behaviors.eightdir.debugger.vector-y",value:this._dy,onedit:(a)=>this._dy=a},{name:"behaviors.eightdir.debugger.speed",value:Math.hypot(this._dx,this._dy),onedit:(a)=>this._SetSpeed(a)},{name:"behaviors.eightdir.debugger.angle-of-motion",value:C3.toDegrees(Math.atan2(this._dy,this._dx))},{name:"behaviors.eightdir.properties.max-speed.name",value:this._maxSpeed,onedit:(a)=>this._maxSpeed=a},{name:"behaviors.eightdir.properties.acceleration.name",value:this._acc,onedit:(a)=>this._acc=a},{name:"behaviors.eightdir.properties.deceleration.name",value:this._dec,onedit:(a)=>this._dec=a},{name:"behaviors.eightdir.properties.enabled.name",value:this._isEnabled,onedit:(a)=>this._SetEnabled(a)}]}]}}} +"use strict";{C3.Behaviors.EightDir.Instance=class extends C3.SDKBehaviorInstanceBase{constructor(a,b){super(a),this._upKey=!1,this._downKey=!1,this._leftKey=!1,this._rightKey=!1,this._ignoreInput=!1,this._simUp=!1,this._simDown=!1,this._simLeft=!1,this._simRight=!1,this._dx=0,this._dy=0,this._maxSpeed=200,this._acc=600,this._dec=500,this._directions=3,this._angleMode=3,this._defaultControls=!0,this._isEnabled=!0,b&&(this._maxSpeed=b[0],this._acc=b[1],this._dec=b[2],this._directions=b[3],this._angleMode=b[4],this._defaultControls=!!b[5],this._isEnabled=!!b[6]),this._isEnabled&&this._StartTicking(),this._defaultControls&&this._BindEvents()}_BindEvents(){if(!this._disposables){const a=this._runtime.Dispatcher();this._disposables=new C3.CompositeDisposable(C3.Disposable.From(a,"keydown",(a)=>this._OnKeyDown(a.data)),C3.Disposable.From(a,"keyup",(a)=>this._OnKeyUp(a.data)),C3.Disposable.From(a,"window-blur",()=>this._OnWindowBlur()))}}_UnBindEvents(){this._disposables&&(this._disposables.Release(),this._disposables=null)}Release(){super.Release()}SaveToJson(){return{"dx":this._dx,"dy":this._dy,"e":this._isEnabled,"ms":this._maxSpeed,"acc":this._acc,"dec":this._dec,"d":this._directions,"am":this._angleMode,"dc":this._defaultControls,"ii":this._ignoreInput}}LoadFromJson(a){this._dx=a["dx"],this._dy=a["dy"],this._SetEnabled(a["e"]),this._maxSpeed=a["ms"],this._acc=a["acc"],this._dec=a["dec"],this._directions=a["d"],this._angleMode=a["am"],this._defaultControls=a["dc"],this._ignoreInput=a["ii"],this._upKey=!1,this._downKey=!1,this._leftKey=!1,this._rightKey=!1,this._simUp=!1,this._simDown=!1,this._simLeft=!1,this._simRight=!1,this._defaultControls?this._BindEvents():this._UnBindEvents()}_OnKeyDown(a){switch(a["key"]){case"ArrowLeft":this._leftKey=!0;break;case"ArrowUp":this._upKey=!0;break;case"ArrowRight":this._rightKey=!0;break;case"ArrowDown":this._downKey=!0;}}_OnKeyUp(a){switch(a["key"]){case"ArrowLeft":this._leftKey=!1;break;case"ArrowUp":this._upKey=!1;break;case"ArrowRight":this._rightKey=!1;break;case"ArrowDown":this._downKey=!1;}}_OnWindowBlur(){this._upKey=!1,this._downKey=!1,this._leftKey=!1,this._rightKey=!1}Tick(){var b=Math.round,c=Math.floor,d=Math.abs,e=Math.atan2,a=Math.max,f=Math.min;const g=this._runtime.GetDt(this._inst),h=this._runtime.GetCollisionEngine();let i=this._leftKey||this._simLeft,j=this._rightKey||this._simRight,k=this._upKey||this._simUp,l=this._downKey||this._simDown;if(this._simLeft=!1,this._simRight=!1,this._simUp=!1,this._simDown=!1,!this._isEnabled)return;let m=h.TestOverlapSolid(this._inst);if(m&&(h.RegisterCollision(this._inst,m),!h.PushOutSolidNearest(this._inst)))return;this._ignoreInput&&(i=j=k=l=!1),0===this._directions?i=j=!1:1===this._directions&&(k=l=!1),2===this._directions&&(k||l)&&(i=j=!1),i===j&&(0>this._dx?this._dx=f(this._dx+this._dec*g,0):0this._dy?this._dy=f(this._dy+this._dec*g,0):0this._dx?n=this._acc+this._dec:n=this._acc),k&&!l&&(0this._dy?o=this._acc+this._dec:o=this._acc),this._dx+=n*g,this._dy+=o*g,0!==this._dx||0!==this._dy){const f=Math.sqrt(this._dx*this._dx+this._dy*this._dy),i=e(this._dy,this._dx),a=this._maxSpeed*Math.cos(i),j=this._maxSpeed*Math.sin(i);f>this._maxSpeed&&(this._dx=a,this._dy=j);const k=d(a)*g,l=d(j)*g,p=this._inst.GetWorldInfo(),q=p.GetX(),r=p.GetY(),s=p.GetAngle(),t=C3.clamp(this._dx*g+.5*n*g*g,-k,k);p.OffsetX(t),p.SetBboxChanged(),m=h.TestOverlapSolid(this._inst),m&&(!h.PushOutSolid(this._inst,0>this._dx?1:-1,0,d(c(t)))&&(p.SetX(q),p.SetBboxChanged()),this._dx=0,h.RegisterCollision(this._inst,m));const u=C3.clamp(this._dy*g+.5*o*g*g,-l,l);p.OffsetY(u),p.SetBboxChanged(),m=h.TestOverlapSolid(this._inst),m&&(!h.PushOutSolid(this._inst,0,0>this._dy?1:-1,d(c(u)))&&(p.SetY(r),p.SetBboxChanged()),this._dy=0,h.RegisterCollision(this._inst,m));const v=C3.round6dp(this._dx),w=C3.round6dp(this._dy);(0!==v||0!==w)&&this._inst.GetPlugin().IsRotatable()&&(1===this._angleMode?p.SetAngle(C3.toRadians(90*b(C3.toDegrees(e(w,v))/90))):2===this._angleMode?p.SetAngle(C3.toRadians(45*b(C3.toDegrees(e(w,v))/45))):3===this._angleMode&&p.SetAngle(e(w,v))),p.SetBboxChanged(),p.GetAngle()!=s&&(m=h.TestOverlapSolid(this._inst),m&&(p.SetAngle(s),p.SetBboxChanged(),h.RegisterCollision(this._inst,m)))}}GetPropertyValueByIndex(a){return a===0?this._GetMaxSpeed():1===a?this._GetAcceleration():2===a?this._GetDeceleration():3===a?this._directions:4===a?this._angleMode:5===a?this._IsDefaultControls():6===a?this._IsEnabled():void 0}SetPropertyValueByIndex(a,b){a===0?this._SetMaxSpeed(b):1===a?this._SetAcceleration(b):2===a?this._SetDeceleration(b):3===a?this._directions=b:4===a?this._angleMode=b:5===a?this._SetDefaultControls(!!b):6===a?this._SetEnabled(!!b):void 0}_Stop(){this._dx=0,this._dy=0}_Reverse(){this._dx*=-1,this._dy*=-1}_MaybeClampSpeed(){const a=Math.hypot(this._dx,this._dy);a>this._maxSpeed&&this._SetSpeed(a)}_SetSpeed(b){b=C3.clamp(b,0,this._maxSpeed);const c=Math.atan2(this._dy,this._dx);this._dx=b*Math.cos(c),this._dy=b*Math.sin(c)}_GetSpeed(){return Math.hypot(this._dx,this._dy)}_SetMaxSpeed(a){this._maxSpeed=Math.max(a,0)}_GetMaxSpeed(){return this._maxSpeed}_SetAcceleration(a){this._acc=Math.max(a,0)}_GetAcceleration(){return this._acc}_SetDeceleration(a){this._dec=Math.max(a,0)}_GetDeceleration(){return this._dec}_GetMovingAngle(){return Math.atan2(this._dy,this._dx)}_SetVectorX(a){this._dx=a,this._MaybeClampSpeed()}_GetVectorX(){return this._dx}_SetVectorY(a){this._dy=a,this._MaybeClampSpeed()}_GetVectorY(){return this._dy}_SimulateControl(a){this._isEnabled&&(0===a?this._simLeft=!0:1===a?this._simRight=!0:2===a?this._simUp=!0:3===a?this._simDown=!0:void 0)}_SetDefaultControls(a){a=!!a;this._defaultControls===a||(this._defaultControls=a,this._defaultControls?this._BindEvents():(this._UnBindEvents(),this._OnWindowBlur()))}_IsDefaultControls(){return this._defaultControls}_SetIgnoreInput(a){this._ignoreInput=!!a}_IsIgnoreInput(){return this._ignoreInput}_SetEnabled(a){this._isEnabled=!!a,this._isEnabled?this._StartTicking():(this._simLeft=!1,this._simRight=!1,this._simUp=!1,this._simDown=!1,this._StopTicking())}_IsEnabled(){return this._isEnabled}GetDebuggerProperties(){return[{title:"$"+this.GetBehaviorType().GetName(),properties:[{name:"behaviors.eightdir.debugger.vector-x",value:this._GetVectorX(),onedit:(a)=>this._SetVectorX(a)},{name:"behaviors.eightdir.debugger.vector-y",value:this._GetVectorY(),onedit:(a)=>this._SetVectorY(a)},{name:"behaviors.eightdir.debugger.speed",value:this._GetSpeed(),onedit:(a)=>this._SetSpeed(a)},{name:"behaviors.eightdir.debugger.angle-of-motion",value:C3.toDegrees(this._GetMovingAngle())},{name:"behaviors.eightdir.properties.max-speed.name",value:this._GetMaxSpeed(),onedit:(a)=>this._SetMaxSpeed(a)},{name:"behaviors.eightdir.properties.acceleration.name",value:this._GetAcceleration(),onedit:(a)=>this._SetAcceleration(a)},{name:"behaviors.eightdir.properties.deceleration.name",value:this._GetDeceleration(),onedit:(a)=>this._SetDeceleration(a)},{name:"behaviors.eightdir.properties.enabled.name",value:this._IsEnabled(),onedit:(a)=>this._SetEnabled(a)}]}]}GetScriptInterfaceClass(){return I8DirectionBehaviorInstance}};const b=new WeakMap,a=new Map([["left",0],["right",1],["up",2],["down",3]]);self.I8DirectionBehaviorInstance=class extends IBehaviorInstance{constructor(){super(),b.set(this,IBehaviorInstance._GetInitInst().GetSdkInstance())}stop(){b.get(this)._Stop()}reverse(){b.get(this)._Reverse()}simulateControl(c){const d=a.get(c);if("number"!=typeof d)throw new Error("invalid control");b.get(this)._SimulateControl(d)}get speed(){return b.get(this)._GetSpeed()}set speed(a){b.get(this)._SetSpeed(a)}get maxSpeed(){return b.get(this)._GetMaxSpeed()}set maxSpeed(a){b.get(this)._SetMaxSpeed(a)}get acceleration(){return b.get(this)._GetAcceleration()}set acceleration(c){b.get(this)._SetAcceleration(c)}get deceleration(){return b.get(this)._GetDeceleration()}set deceleration(a){b.get(this)._GetDeceleration(a)}get vectorX(){return b.get(this)._GetVectorX()}set vectorX(a){b.get(this)._SetVectorX(a)}get vectorY(){return b.get(this)._GetVectorY()}set vectorY(a){b.get(this)._SetVectorX(a)}get isDefaultControls(){return b.get(this)._IsDefaultControls()}set isDefaultControls(a){b.get(this)._SetDefaultControls(!!a)}get isIgnoringInput(){return b.get(this)._IsIgnoreInput()}set isIgnoringInput(a){b.get(this)._SetIgnoreInput(!!a)}get isEnabled(){return b.get(this)._IsEnabled()}set isEnabled(a){b.get(this)._SetEnabled(!!a)}}} -"use strict";C3.Behaviors.EightDir.Cnds={IsMoving(){const a=Math.sqrt(this._dx*this._dx+this._dy*this._dy);return 1e-10 "Main", + () => "13_attack", + () => "05_run", + () => "Running", + () => "Idle", + () => "05_idle", + () => "01_idle", + () => 1, p => { const n0 = p._GetNode(0); - return () => n0.ExpObject(); + return () => and("Any animation finished ", n0.ExpInstVar()); }, - () => "05_Run", - () => "05_run", - () => "01_Idle", - () => "01_idle", - () => "13_attack", - () => 100, - () => 50, - () => "http://www.murlyka.com" + p => { + const n0 = p._GetNode(0); + return () => and("Run animation finished ", n0.ExpInstVar()); + } ]; } @@ -1305,10 +1419,7 @@ self.C3_JsPropNameTable = [ { const scriptsInEvents = { - async EventSheet1_Event8_Act1(runtime, localVars) - { - CTA.onClick(); - } + }; diff --git a/docs/LiveDemo/scripts/main.js b/docs/LiveDemo/scripts/main.js index d227215..811e1c8 100644 --- a/docs/LiveDemo/scripts/main.js +++ b/docs/LiveDemo/scripts/main.js @@ -1,10 +1,10 @@ -"use strict";window.DOMHandler=class{constructor(a,b){this._iRuntime=a,this._componentId=b,this._hasTickCallback=!1,this._tickCallback=()=>this.Tick()}Attach(){}PostToRuntime(a,b,c,d){this._iRuntime.PostToRuntimeComponent(this._componentId,a,b,c,d)}PostToRuntimeAsync(a,b,c,d){return this._iRuntime.PostToRuntimeComponentAsync(this._componentId,a,b,c,d)}_PostToRuntimeMaybeSync(a,b,c){this._iRuntime.UsesWorker()?this.PostToRuntime(a,b,c):this._iRuntime._GetLocalRuntime()["_OnMessageFromDOM"]({"type":"event","component":this._componentId,"handler":a,"dispatchOpts":c||null,"data":b,"responseId":null})}AddRuntimeMessageHandler(a,b){this._iRuntime.AddRuntimeComponentMessageHandler(this._componentId,a,b)}AddRuntimeMessageHandlers(a){for(const[b,c]of a)this.AddRuntimeMessageHandler(b,c)}GetRuntimeInterface(){return this._iRuntime}GetComponentID(){return this._componentId}_StartTicking(){this._hasTickCallback||(this._iRuntime._AddRAFCallback(this._tickCallback),this._hasTickCallback=!0)}_StopTicking(){this._hasTickCallback&&(this._iRuntime._RemoveRAFCallback(this._tickCallback),this._hasTickCallback=!1)}Tick(){}}; +"use strict";window.DOMHandler=class{constructor(a,b){this._iRuntime=a,this._componentId=b,this._hasTickCallback=!1,this._tickCallback=()=>this.Tick()}Attach(){}PostToRuntime(a,b,c,d){this._iRuntime.PostToRuntimeComponent(this._componentId,a,b,c,d)}PostToRuntimeAsync(a,b,c,d){return this._iRuntime.PostToRuntimeComponentAsync(this._componentId,a,b,c,d)}_PostToRuntimeMaybeSync(a,b,c){this._iRuntime.UsesWorker()?this.PostToRuntime(a,b,c):this._iRuntime._GetLocalRuntime()["_OnMessageFromDOM"]({"type":"event","component":this._componentId,"handler":a,"dispatchOpts":c||null,"data":b,"responseId":null})}AddRuntimeMessageHandler(a,b){this._iRuntime.AddRuntimeComponentMessageHandler(this._componentId,a,b)}AddRuntimeMessageHandlers(a){for(const[b,c]of a)this.AddRuntimeMessageHandler(b,c)}GetRuntimeInterface(){return this._iRuntime}GetComponentID(){return this._componentId}_StartTicking(){this._hasTickCallback||(this._iRuntime._AddRAFCallback(this._tickCallback),this._hasTickCallback=!0)}_StopTicking(){this._hasTickCallback&&(this._iRuntime._RemoveRAFCallback(this._tickCallback),this._hasTickCallback=!1)}Tick(){}},window.RateLimiter=class{constructor(a,b){this._callback=a,this._interval=b,this._timerId=-1,this._lastCallTime=-Infinity,this._timerCallFunc=()=>this._OnTimer(),this._ignoreReset=!1,this._canRunImmediate=!1}SetCanRunImmediate(a){this._canRunImmediate=!!a}Call(){if(-1===this._timerId){const a=Date.now(),b=a-this._lastCallTime,c=this._interval;b>=c&&this._canRunImmediate?(this._lastCallTime=a,this._RunCallback()):this._timerId=self.setTimeout(this._timerCallFunc,Math.max(c-b,4))}}_RunCallback(){this._ignoreReset=!0,this._callback(),this._ignoreReset=!1}Reset(){this._ignoreReset||(this._CancelTimer(),this._lastCallTime=Date.now())}_OnTimer(){this._timerId=-1,this._lastCallTime=Date.now(),this._RunCallback()}_CancelTimer(){-1!==this._timerId&&(self.clearTimeout(this._timerId),this._timerId=-1)}Release(){this._CancelTimer(),this._callback=null,this._timerCallFunc=null}}; "use strict";window.DOMElementHandler=class extends DOMHandler{constructor(a,b){super(a,b),this._elementMap=new Map,this._autoAttach=!0,this.AddRuntimeMessageHandler("create",(a)=>this._OnCreate(a)),this.AddRuntimeMessageHandler("destroy",(a)=>this._OnDestroy(a)),this.AddRuntimeMessageHandler("set-visible",(a)=>this._OnSetVisible(a)),this.AddRuntimeMessageHandler("update-position",(a)=>this._OnUpdatePosition(a)),this.AddRuntimeMessageHandler("update-state",(a)=>this._OnUpdateState(a)),this.AddRuntimeMessageHandler("focus",(a)=>this._OnSetFocus(a)),this.AddRuntimeMessageHandler("set-css-style",(a)=>this._OnSetCssStyle(a))}SetAutoAttach(a){this._autoAttach=!!a}AddDOMElementMessageHandler(a,b){this.AddRuntimeMessageHandler(a,(a)=>{const c=a["elementId"],d=this._elementMap.get(c);return b(d,a)})}_OnCreate(a){const b=a["elementId"],c=this.CreateElement(b,a);this._elementMap.set(b,c),a["isVisible"]||(c.style.display="none"),this._autoAttach&&document.body.appendChild(c)}CreateElement(){throw new Error("required override")}DestroyElement(){}_OnDestroy(a){const b=a["elementId"],c=this._elementMap.get(b);this.DestroyElement(c),this._autoAttach&&c.parentElement.removeChild(c),this._elementMap.delete(b)}PostToRuntimeElement(a,b,c){c||(c={}),c["elementId"]=b,this.PostToRuntime(a,c)}_PostToRuntimeElementMaybeSync(a,b,c){c||(c={}),c["elementId"]=b,this._PostToRuntimeMaybeSync(a,c)}_OnSetVisible(a){if(this._autoAttach){const b=this._elementMap.get(a["elementId"]);b.style.display=a["isVisible"]?"":"none"}}_OnUpdatePosition(a){if(this._autoAttach){const b=this._elementMap.get(a["elementId"]);b.style.left=a["left"]+"px",b.style.top=a["top"]+"px",b.style.width=a["width"]+"px",b.style.height=a["height"]+"px";const c=a["fontSize"];null!==c&&(b.style.fontSize=c+"em")}}_OnUpdateState(a){const b=this._elementMap.get(a["elementId"]);this.UpdateState(b,a)}UpdateState(){throw new Error("required override")}_OnSetFocus(a){const b=this._elementMap.get(a["elementId"]);a["focus"]?b.focus():b.blur()}_OnSetCssStyle(a){const b=this._elementMap.get(a["elementId"]);b.style[a["prop"]]=a["val"]}GetElementById(a){return this._elementMap.get(a)}}; -"use strict";{function a(a){return new Promise((b,c)=>{const d=document.createElement("script");d.onload=b,d.onerror=c,d.async=!1,d.src=a,document.head.appendChild(d)})}async function b(a){const b=await c(a),d=new TextDecoder("utf-8");return d.decode(b)}function c(a){return new Promise((b,c)=>{const d=new FileReader;d.onload=(a)=>b(a.target.result),d.onerror=(a)=>c(a),d.readAsArrayBuffer(a)})}const d=/(iphone|ipod|ipad)/i.test(navigator.userAgent);let e=new Audio;const f={"audio/webm; codecs=opus":!!e.canPlayType("audio/webm; codecs=opus"),"audio/ogg; codecs=opus":!!e.canPlayType("audio/ogg; codecs=opus"),"audio/webm; codecs=vorbis":!!e.canPlayType("audio/webm; codecs=vorbis"),"audio/ogg; codecs=vorbis":!!e.canPlayType("audio/ogg; codecs=vorbis"),"audio/mp4":!!e.canPlayType("audio/mp4"),"audio/mpeg":!!e.canPlayType("audio/mpeg")};e=null;const g=[];let h=0;window["RealFile"]=window["File"];const i=[],j=new Map,k=new Map;let l=0;const m=[];self.runOnStartup=function(a){if("function"!=typeof a)throw new Error("runOnStartup called without a function");m.push(a)},window.RuntimeInterface=class e{constructor(a){this._useWorker=a.useWorker,this._messageChannelPort=null,this._baseUrl="",this._scriptFolder=a.scriptFolder,this._workerScriptBlobURLs={},this._worker=null,this._localRuntime=null,this._domHandlers=[],this._runtimeDomHandler=null,this._canvas=null,this._jobScheduler=null,this._rafId=-1,this._rafFunc=()=>this._OnRAFCallback(),this._rafCallbacks=[],this._exportType=a.exportType,"cordova"===this._exportType&&this._useWorker&&(console.warn("[C3 runtime] Worker mode is enabled and supported, but is disabled in Cordova due to crbug.com/939775. Reverting to DOM mode."),this._useWorker=!1),this._transferablesBroken=!1,this._localFileBlobs=null,("html5"===this._exportType||"playable-ad"===this._exportType)&&"file"===location.protocol.substr(0,4)&&alert("Exported games won't work until you upload them. (When running on the file: protocol, browsers block many features from working for security reasons.)"),this.AddRuntimeComponentMessageHandler("runtime","cordova-fetch-local-file",(a)=>this._OnCordovaFetchLocalFile(a)),this.AddRuntimeComponentMessageHandler("runtime","create-job-worker",(a)=>this._OnCreateJobWorker(a)),"cordova"===this._exportType?document.addEventListener("deviceready",()=>this._Init(a)):this._Init(a)}Release(){this._CancelAnimationFrame(),this._messageChannelPort&&(this._messageChannelPort.onmessage=null,this._messageChannelPort=null),this._worker&&(this._worker.terminate(),this._worker=null),this._localRuntime&&(this._localRuntime.Release(),this._localRuntime=null),this._canvas&&(this._canvas.parentElement.removeChild(this._canvas),this._canvas=null)}GetCanvas(){return this._canvas}GetBaseURL(){return this._baseUrl}UsesWorker(){return this._useWorker}GetExportType(){return this._exportType}IsWKWebView(){return"cordova"===this._exportType&&d}IsAndroid(){return"cordova"===this._exportType&&!1===d}async _Init(a){if("playable-ad"===this._exportType){this._localFileBlobs=self["c3_base64files"],await this._ConvertDataUrisToBlobs();for(let b=0,c=a.engineScripts.length;bthis["_OnMessageFromRuntime"](a.data),window["c3_addPortMessageHandler"]&&window["c3_addPortMessageHandler"]((a)=>this._OnMessageFromDebugger(a)),this._jobScheduler=new self.JobSchedulerDOM(this),await this._jobScheduler.Init(),this.MaybeForceBodySize(),"object"==typeof window["StatusBar"]&&window["StatusBar"]["hide"](),"object"==typeof window["AndroidFullScreen"]&&window["AndroidFullScreen"]["immersiveMode"](),await this._TestTransferablesWork(),this._useWorker?await this._InitWorker(a,b.port2):await this._InitDOM(a,b.port2)}_GetWorkerURL(a){return this._workerScriptBlobURLs.hasOwnProperty(a)?this._workerScriptBlobURLs[a]:a.endsWith("/workermain.js")&&this._workerScriptBlobURLs.hasOwnProperty("workermain.js")?this._workerScriptBlobURLs["workermain.js"]:"playable-ad"===this._exportType&&this._localFileBlobs.hasOwnProperty(a.toLowerCase())?URL.createObjectURL(this._localFileBlobs[a.toLowerCase()]):a}async CreateWorker(a,b,c){if(a.startsWith("blob:"))return new Worker(a,c);if(this.IsWKWebView()){const b=await this.CordovaFetchLocalFileAsArrayBuffer(this._scriptFolder+a),d=new Blob([b],{type:"application/javascript"});return new Worker(URL.createObjectURL(d),c)}const d=new URL(a,b),e=location.origin!==d.origin;if(e){const a=await fetch(d);if(!a.ok)throw new Error("failed to fetch worker script");const b=await a.blob();return new Worker(URL.createObjectURL(b),c)}return new Worker(d,c)}MaybeForceBodySize(){if(this.IsWKWebView()){const a=document["documentElement"].style,b=document["body"].style,c=window.innerWidthnew a(this)),this._FindRuntimeDOMHandler(),self["c3_callFunction"]=(a,b)=>this._runtimeDomHandler._InvokeFunctionFromJS(a,b),"preview"===this._exportType&&(self["goToLastErrorScript"]=()=>this.PostToRuntimeComponent("runtime","go-to-last-error-script"))}async _InitDOM(b,c){this._canvas=document.createElement("canvas"),this._canvas.style.display="none",document.body.appendChild(this._canvas),window["c3canvas"]=this._canvas,this._domHandlers=i.map((a)=>new a(this)),this._FindRuntimeDOMHandler();const d=b.engineScripts.map((a)=>new URL(a,this._baseUrl).toString());if(Array.isArray(b.workerDependencyScripts)&&d.unshift(...b.workerDependencyScripts),await Promise.all(d.map((b)=>a(b))),b.projectScripts&&0a(b[1]))),Object.values(c).some((a)=>!a))return void self.setTimeout(()=>this._ReportProjectScriptError(c),100)}catch(a){return console.error("[Preview] Error loading project scripts: ",a),void self.setTimeout(()=>this._ReportProjectScriptError(c),100)}}if("preview"===this._exportType&&"object"!=typeof self.C3.ScriptsInEvents){return console.error("[C3 runtime] Failed to load JavaScript code used in events. Check all your JavaScript code has valid syntax."),void alert("Failed to load JavaScript code used in events. Check all your JavaScript code has valid syntax.")}const e=Object.assign(this._GetCommonRuntimeOptions(b),{"isInWorker":!1,"messagePort":c,"canvas":this._canvas,"runOnStartupFunctions":m});this._localRuntime=self["C3_CreateRuntime"](e),await self["C3_InitRuntime"](this._localRuntime,e)}_ReportProjectScriptError(a){const b=Object.entries(a).filter((a)=>!a[1]).map((a)=>a[0]),c=`Failed to load project script '${b[0]}'. Check all your JavaScript code has valid syntax.`;console.error("[Preview] "+c),alert(c)}async _OnCreateJobWorker(){const a=await this._jobScheduler._CreateJobWorker();return{"outputPort":a,"transferables":[a]}}_GetLocalRuntime(){if(this._useWorker)throw new Error("not available in worker mode");return this._localRuntime}PostToRuntimeComponent(a,b,c,d,e){this._messageChannelPort.postMessage({"type":"event","component":a,"handler":b,"dispatchOpts":d||null,"data":c,"responseId":null},this._transferablesBroken?void 0:e)}PostToRuntimeComponentAsync(a,b,c,d,e){const f=l++,g=new Promise((a,b)=>{k.set(f,{resolve:a,reject:b})});return this._messageChannelPort.postMessage({"type":"event","component":a,"handler":b,"dispatchOpts":d||null,"data":c,"responseId":f},this._transferablesBroken?void 0:e),g}["_OnMessageFromRuntime"](a){const b=a["type"];if("event"===b)this._OnEventFromRuntime(a);else if("result"===b)this._OnResultFromRuntime(a);else if("runtime-ready"===b)this._OnRuntimeReady();else if("alert"===b)alert(a["message"]);else throw new Error(`unknown message '${b}'`)}_OnEventFromRuntime(a){const b=a["component"],c=a["handler"],d=a["data"],e=a["responseId"],f=j.get(b);if(!f)return void console.warn(`[DOM] No event handlers for component '${b}'`);const g=f.get(c);if(!g)return void console.warn(`[DOM] No handler '${c}' for component '${b}'`);let h=null;try{h=g(d)}catch(a){return console.error(`Exception in '${b}' handler '${c}':`,a),void(null!==e&&this._PostResultToRuntime(e,!1,a.toString()))}null!==e&&(h&&h.then?h.then((a)=>this._PostResultToRuntime(e,!0,a)).catch((a)=>{console.error(`Rejection from '${b}' handler '${c}':`,a),this._PostResultToRuntime(e,!1,a.toString())}):this._PostResultToRuntime(e,!0,h))}_PostResultToRuntime(a,b,c){let d;c&&c["transferables"]&&(d=c["transferables"]),this._messageChannelPort.postMessage({"type":"result","responseId":a,"isOk":b,"result":c},d)}_OnResultFromRuntime(a){const b=a["responseId"],c=a["isOk"],d=a["result"],e=k.get(b);c?e.resolve(d):e.reject(d),k.delete(b)}AddRuntimeComponentMessageHandler(a,b,c){let d=j.get(a);if(d||(d=new Map,j.set(a,d)),d.has(b))throw new Error(`[DOM] Component '${a}' already has handler '${b}'`);d.set(b,c)}static AddDOMHandlerClass(a){if(i.includes(a))throw new Error("DOM handler already added");i.push(a)}_FindRuntimeDOMHandler(){for(const a of this._domHandlers)if("runtime"===a.GetComponentID())return void(this._runtimeDomHandler=a);throw new Error("cannot find runtime DOM handler")}_OnMessageFromDebugger(a){this.PostToRuntimeComponent("debugger","message",a)}_OnRuntimeReady(){for(const a of this._domHandlers)a.Attach()}static IsDocumentFullscreen(){return!!(document["fullscreenElement"]||document["webkitFullscreenElement"]||document["mozFullScreenElement"])}async GetRemotePreviewStatusInfo(){return await this.PostToRuntimeComponentAsync("runtime","get-remote-preview-status-info")}_AddRAFCallback(a){this._rafCallbacks.push(a),this._RequestAnimationFrame()}_RemoveRAFCallback(a){const b=this._rafCallbacks.indexOf(a);if(-1===b)throw new Error("invalid callback");this._rafCallbacks.splice(b,1),this._rafCallbacks.length||this._CancelAnimationFrame()}_RequestAnimationFrame(){-1===this._rafId&&this._rafCallbacks.length&&(this._rafId=requestAnimationFrame(this._rafFunc))}_CancelAnimationFrame(){-1!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=-1)}_OnRAFCallback(){this._rafId=-1;for(const a of this._rafCallbacks)a();this._RequestAnimationFrame()}TryPlayMedia(a){this._runtimeDomHandler.TryPlayMedia(a)}RemovePendingPlay(a){this._runtimeDomHandler.RemovePendingPlay(a)}_PlayPendingMedia(){this._runtimeDomHandler._PlayPendingMedia()}SetSilent(a){this._runtimeDomHandler.SetSilent(a)}IsAudioFormatSupported(a){return!!f[a]}async _WasmDecodeWebMOpus(a){const b=await this.PostToRuntimeComponentAsync("runtime","opus-decode",{"arrayBuffer":a},null,[a]);return new Float32Array(b)}IsAbsoluteURL(a){return /^(?:[a-z]+:)?\/\//.test(a)||"data:"===a.substr(0,5)||"blob:"===a.substr(0,5)}IsRelativeURL(a){return!this.IsAbsoluteURL(a)}async _OnCordovaFetchLocalFile(a){const b=a["filename"];switch(a["as"]){case"text":return await this.CordovaFetchLocalFileAsText(b);case"buffer":return await this.CordovaFetchLocalFileAsArrayBuffer(b);default:throw new Error("unsupported type");}}CordovaFetchLocalFile(a){const b=window["cordova"]["file"]["applicationDirectory"]+"www/"+a.toLowerCase();return new Promise((a,c)=>{window["resolveLocalFileSystemURL"](b,(b)=>{b["file"](a,c)},c)})}async CordovaFetchLocalFileAsText(a){const c=await this.CordovaFetchLocalFile(a);return await b(c)}_CordovaMaybeStartNextArrayBufferRead(){if(g.length&&!(h>=8)){h++;const a=g.shift();this._CordovaDoFetchLocalFileAsAsArrayBuffer(a.filename,a.successCallback,a.errorCallback)}}CordovaFetchLocalFileAsArrayBuffer(a){return new Promise((b,c)=>{g.push({filename:a,successCallback:(a)=>{h--,this._CordovaMaybeStartNextArrayBufferRead(),b(a)},errorCallback:(a)=>{h--,this._CordovaMaybeStartNextArrayBufferRead(),c(a)}}),this._CordovaMaybeStartNextArrayBufferRead()})}async _CordovaDoFetchLocalFileAsAsArrayBuffer(a,b,d){try{const d=await this.CordovaFetchLocalFile(a),e=await c(d);b(e)}catch(a){d(a)}}async _ConvertDataUrisToBlobs(){const a=[];for(const[b,c]of Object.entries(this._localFileBlobs))a.push(this._ConvertDataUriToBlobs(b,c));await Promise.all(a)}async _ConvertDataUriToBlobs(a,b){if("object"==typeof b)this._localFileBlobs[a]=new Blob([b["str"]],{"type":b["type"]});else{const c=await fetch(b),d=await c.blob();this._localFileBlobs[a]=d}}_TestTransferablesWork(){let a=null;const b=new Promise((b)=>a=b),c=new ArrayBuffer(1),d=new MessageChannel;return d.port2.onmessage=(b)=>{b.data&&b.data["arrayBuffer"]||(this._transferablesBroken=!0,console.warn("MessageChannel transfers determined to be broken. Disabling transferables.")),a()},d.port1.postMessage({"arrayBuffer":c},[c]),b}}} +"use strict";{function a(a){return new Promise((b,c)=>{const d=document.createElement("script");d.onload=b,d.onerror=c,d.async=!1,d.src=a,document.head.appendChild(d)})}async function b(a){const b=await c(a),d=new TextDecoder("utf-8");return d.decode(b)}function c(a){return new Promise((b,c)=>{const d=new FileReader;d.onload=(a)=>b(a.target.result),d.onerror=(a)=>c(a),d.readAsArrayBuffer(a)})}const d=/(iphone|ipod|ipad)/i.test(navigator.userAgent);let e=new Audio;const f={"audio/webm; codecs=opus":!!e.canPlayType("audio/webm; codecs=opus"),"audio/ogg; codecs=opus":!!e.canPlayType("audio/ogg; codecs=opus"),"audio/webm; codecs=vorbis":!!e.canPlayType("audio/webm; codecs=vorbis"),"audio/ogg; codecs=vorbis":!!e.canPlayType("audio/ogg; codecs=vorbis"),"audio/mp4":!!e.canPlayType("audio/mp4"),"audio/mpeg":!!e.canPlayType("audio/mpeg")};e=null;const g=[];let h=0;window["RealFile"]=window["File"];const i=[],j=new Map,k=new Map;let l=0;const m=[];self.runOnStartup=function(a){if("function"!=typeof a)throw new Error("runOnStartup called without a function");m.push(a)},window.RuntimeInterface=class e{constructor(a){this._useWorker=a.useWorker,this._messageChannelPort=null,this._baseUrl="",this._scriptFolder=a.scriptFolder,this._workerScriptBlobURLs={},this._worker=null,this._localRuntime=null,this._domHandlers=[],this._runtimeDomHandler=null,this._canvas=null,this._jobScheduler=null,this._rafId=-1,this._rafFunc=()=>this._OnRAFCallback(),this._rafCallbacks=[],this._exportType=a.exportType,("cordova"===this._exportType||"playable-ad"===this._exportType||"instant-games"===this._exportType)&&this._useWorker&&(console.warn("[C3 runtime] Worker mode is enabled and supported, but is disabled in WebViews due to crbug.com/923007. Reverting to DOM mode."),this._useWorker=!1),/CrOS/.test(navigator.userAgent)&&(console.warn("[C3 runtime] Worker mode is enabled and supported, but is disabled in Chrome OS due to reports of crashes. Reverting to DOM mode."),this._useWorker=!1),this._transferablesBroken=!1,this._localFileBlobs=null,("html5"===this._exportType||"playable-ad"===this._exportType)&&"file"===location.protocol.substr(0,4)&&alert("Exported games won't work until you upload them. (When running on the file: protocol, browsers block many features from working for security reasons.)"),this.AddRuntimeComponentMessageHandler("runtime","cordova-fetch-local-file",(a)=>this._OnCordovaFetchLocalFile(a)),this.AddRuntimeComponentMessageHandler("runtime","create-job-worker",(a)=>this._OnCreateJobWorker(a)),"cordova"===this._exportType?document.addEventListener("deviceready",()=>this._Init(a)):this._Init(a)}Release(){this._CancelAnimationFrame(),this._messageChannelPort&&(this._messageChannelPort.onmessage=null,this._messageChannelPort=null),this._worker&&(this._worker.terminate(),this._worker=null),this._localRuntime&&(this._localRuntime.Release(),this._localRuntime=null),this._canvas&&(this._canvas.parentElement.removeChild(this._canvas),this._canvas=null)}GetCanvas(){return this._canvas}GetBaseURL(){return this._baseUrl}UsesWorker(){return this._useWorker}GetExportType(){return this._exportType}IsWKWebView(){return"cordova"===this._exportType&&d}IsAndroid(){return"cordova"===this._exportType&&!1===d}async _Init(a){if("playable-ad"===this._exportType){this._localFileBlobs=self["c3_base64files"],await this._ConvertDataUrisToBlobs();for(let b=0,c=a.engineScripts.length;bthis["_OnMessageFromRuntime"](a.data),window["c3_addPortMessageHandler"]&&window["c3_addPortMessageHandler"]((a)=>this._OnMessageFromDebugger(a)),this._jobScheduler=new self.JobSchedulerDOM(this),await this._jobScheduler.Init(),this.MaybeForceBodySize(),"object"==typeof window["StatusBar"]&&window["StatusBar"]["hide"](),"object"==typeof window["AndroidFullScreen"]&&window["AndroidFullScreen"]["immersiveMode"](),await this._TestTransferablesWork(),this._useWorker?await this._InitWorker(a,b.port2):await this._InitDOM(a,b.port2)}_GetWorkerURL(a){return this._workerScriptBlobURLs.hasOwnProperty(a)?this._workerScriptBlobURLs[a]:a.endsWith("/workermain.js")&&this._workerScriptBlobURLs.hasOwnProperty("workermain.js")?this._workerScriptBlobURLs["workermain.js"]:"playable-ad"===this._exportType&&this._localFileBlobs.hasOwnProperty(a.toLowerCase())?URL.createObjectURL(this._localFileBlobs[a.toLowerCase()]):a}async CreateWorker(a,b,c){if(a.startsWith("blob:"))return new Worker(a,c);if(this.IsWKWebView()){const b=await this.CordovaFetchLocalFileAsArrayBuffer(this._scriptFolder+a),d=new Blob([b],{type:"application/javascript"});return new Worker(URL.createObjectURL(d),c)}const d=new URL(a,b),e=location.origin!==d.origin;if(e){const a=await fetch(d);if(!a.ok)throw new Error("failed to fetch worker script");const b=await a.blob();return new Worker(URL.createObjectURL(b),c)}return new Worker(d,c)}MaybeForceBodySize(){if(this.IsWKWebView()){const a=document["documentElement"].style,b=document["body"].style,c=window.innerWidthnew a(this)),this._FindRuntimeDOMHandler(),self["c3_callFunction"]=(a,b)=>this._runtimeDomHandler._InvokeFunctionFromJS(a,b),"preview"===this._exportType&&(self["goToLastErrorScript"]=()=>this.PostToRuntimeComponent("runtime","go-to-last-error-script"))}async _InitDOM(b,c){this._canvas=document.createElement("canvas"),this._canvas.style.display="none",document.body.appendChild(this._canvas),window["c3canvas"]=this._canvas,this._domHandlers=i.map((a)=>new a(this)),this._FindRuntimeDOMHandler();const d=b.engineScripts.map((a)=>new URL(a,this._baseUrl).toString());if(Array.isArray(b.workerDependencyScripts)&&d.unshift(...b.workerDependencyScripts),await Promise.all(d.map((b)=>a(b))),b.projectScripts&&0a(b[1]))),Object.values(c).some((a)=>!a))return void self.setTimeout(()=>this._ReportProjectScriptError(c),100)}catch(a){return console.error("[Preview] Error loading project scripts: ",a),void self.setTimeout(()=>this._ReportProjectScriptError(c),100)}}if("preview"===this._exportType&&"object"!=typeof self.C3.ScriptsInEvents){return console.error("[C3 runtime] Failed to load JavaScript code used in events. Check all your JavaScript code has valid syntax."),void alert("Failed to load JavaScript code used in events. Check all your JavaScript code has valid syntax.")}const e=Object.assign(this._GetCommonRuntimeOptions(b),{"isInWorker":!1,"messagePort":c,"canvas":this._canvas,"runOnStartupFunctions":m});this._localRuntime=self["C3_CreateRuntime"](e),await self["C3_InitRuntime"](this._localRuntime,e)}_ReportProjectScriptError(a){const b=Object.entries(a).filter((a)=>!a[1]).map((a)=>a[0]),c=`Failed to load project script '${b[0]}'. Check all your JavaScript code has valid syntax.`;console.error("[Preview] "+c),alert(c)}async _OnCreateJobWorker(){const a=await this._jobScheduler._CreateJobWorker();return{"outputPort":a,"transferables":[a]}}_GetLocalRuntime(){if(this._useWorker)throw new Error("not available in worker mode");return this._localRuntime}PostToRuntimeComponent(a,b,c,d,e){this._messageChannelPort.postMessage({"type":"event","component":a,"handler":b,"dispatchOpts":d||null,"data":c,"responseId":null},this._transferablesBroken?void 0:e)}PostToRuntimeComponentAsync(a,b,c,d,e){const f=l++,g=new Promise((a,b)=>{k.set(f,{resolve:a,reject:b})});return this._messageChannelPort.postMessage({"type":"event","component":a,"handler":b,"dispatchOpts":d||null,"data":c,"responseId":f},this._transferablesBroken?void 0:e),g}["_OnMessageFromRuntime"](a){const b=a["type"];if("event"===b)this._OnEventFromRuntime(a);else if("result"===b)this._OnResultFromRuntime(a);else if("runtime-ready"===b)this._OnRuntimeReady();else if("alert"===b)alert(a["message"]);else throw new Error(`unknown message '${b}'`)}_OnEventFromRuntime(a){const b=a["component"],c=a["handler"],d=a["data"],e=a["responseId"],f=j.get(b);if(!f)return void console.warn(`[DOM] No event handlers for component '${b}'`);const g=f.get(c);if(!g)return void console.warn(`[DOM] No handler '${c}' for component '${b}'`);let h=null;try{h=g(d)}catch(a){return console.error(`Exception in '${b}' handler '${c}':`,a),void(null!==e&&this._PostResultToRuntime(e,!1,a.toString()))}null!==e&&(h&&h.then?h.then((a)=>this._PostResultToRuntime(e,!0,a)).catch((a)=>{console.error(`Rejection from '${b}' handler '${c}':`,a),this._PostResultToRuntime(e,!1,a.toString())}):this._PostResultToRuntime(e,!0,h))}_PostResultToRuntime(a,b,c){let d;c&&c["transferables"]&&(d=c["transferables"]),this._messageChannelPort.postMessage({"type":"result","responseId":a,"isOk":b,"result":c},d)}_OnResultFromRuntime(a){const b=a["responseId"],c=a["isOk"],d=a["result"],e=k.get(b);c?e.resolve(d):e.reject(d),k.delete(b)}AddRuntimeComponentMessageHandler(a,b,c){let d=j.get(a);if(d||(d=new Map,j.set(a,d)),d.has(b))throw new Error(`[DOM] Component '${a}' already has handler '${b}'`);d.set(b,c)}static AddDOMHandlerClass(a){if(i.includes(a))throw new Error("DOM handler already added");i.push(a)}_FindRuntimeDOMHandler(){for(const a of this._domHandlers)if("runtime"===a.GetComponentID())return void(this._runtimeDomHandler=a);throw new Error("cannot find runtime DOM handler")}_OnMessageFromDebugger(a){this.PostToRuntimeComponent("debugger","message",a)}_OnRuntimeReady(){for(const a of this._domHandlers)a.Attach()}static IsDocumentFullscreen(){return!!(document["fullscreenElement"]||document["webkitFullscreenElement"]||document["mozFullScreenElement"])}async GetRemotePreviewStatusInfo(){return await this.PostToRuntimeComponentAsync("runtime","get-remote-preview-status-info")}_AddRAFCallback(a){this._rafCallbacks.push(a),this._RequestAnimationFrame()}_RemoveRAFCallback(a){const b=this._rafCallbacks.indexOf(a);if(-1===b)throw new Error("invalid callback");this._rafCallbacks.splice(b,1),this._rafCallbacks.length||this._CancelAnimationFrame()}_RequestAnimationFrame(){-1===this._rafId&&this._rafCallbacks.length&&(this._rafId=requestAnimationFrame(this._rafFunc))}_CancelAnimationFrame(){-1!==this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=-1)}_OnRAFCallback(){this._rafId=-1;for(const a of this._rafCallbacks)a();this._RequestAnimationFrame()}TryPlayMedia(a){this._runtimeDomHandler.TryPlayMedia(a)}RemovePendingPlay(a){this._runtimeDomHandler.RemovePendingPlay(a)}_PlayPendingMedia(){this._runtimeDomHandler._PlayPendingMedia()}SetSilent(a){this._runtimeDomHandler.SetSilent(a)}IsAudioFormatSupported(a){return!!f[a]}async _WasmDecodeWebMOpus(a){const b=await this.PostToRuntimeComponentAsync("runtime","opus-decode",{"arrayBuffer":a},null,[a]);return new Float32Array(b)}IsAbsoluteURL(a){return /^(?:[a-z]+:)?\/\//.test(a)||"data:"===a.substr(0,5)||"blob:"===a.substr(0,5)}IsRelativeURL(a){return!this.IsAbsoluteURL(a)}async _OnCordovaFetchLocalFile(a){const b=a["filename"];switch(a["as"]){case"text":return await this.CordovaFetchLocalFileAsText(b);case"buffer":return await this.CordovaFetchLocalFileAsArrayBuffer(b);default:throw new Error("unsupported type");}}CordovaFetchLocalFile(a){const b=window["cordova"]["file"]["applicationDirectory"]+"www/"+a.toLowerCase();return new Promise((a,c)=>{window["resolveLocalFileSystemURL"](b,(b)=>{b["file"](a,c)},c)})}async CordovaFetchLocalFileAsText(a){const c=await this.CordovaFetchLocalFile(a);return await b(c)}_CordovaMaybeStartNextArrayBufferRead(){if(g.length&&!(h>=8)){h++;const a=g.shift();this._CordovaDoFetchLocalFileAsAsArrayBuffer(a.filename,a.successCallback,a.errorCallback)}}CordovaFetchLocalFileAsArrayBuffer(a){return new Promise((b,c)=>{g.push({filename:a,successCallback:(a)=>{h--,this._CordovaMaybeStartNextArrayBufferRead(),b(a)},errorCallback:(a)=>{h--,this._CordovaMaybeStartNextArrayBufferRead(),c(a)}}),this._CordovaMaybeStartNextArrayBufferRead()})}async _CordovaDoFetchLocalFileAsAsArrayBuffer(a,b,d){try{const d=await this.CordovaFetchLocalFile(a),e=await c(d);b(e)}catch(a){d(a)}}async _ConvertDataUrisToBlobs(){const a=[];for(const[b,c]of Object.entries(this._localFileBlobs))a.push(this._ConvertDataUriToBlobs(b,c));await Promise.all(a)}async _ConvertDataUriToBlobs(a,b){if("object"==typeof b)this._localFileBlobs[a]=new Blob([b["str"]],{"type":b["type"]});else{const c=await fetch(b),d=await c.blob();this._localFileBlobs[a]=d}}_TestTransferablesWork(){let a=null;const b=new Promise((b)=>a=b),c=new ArrayBuffer(1),d=new MessageChannel;return d.port2.onmessage=(b)=>{b.data&&b.data["arrayBuffer"]||(this._transferablesBroken=!0,console.warn("MessageChannel transfers determined to be broken. Disabling transferables.")),a()},d.port1.postMessage({"arrayBuffer":c},[c]),b}}} -"use strict";{function a(a){return a["sourceCapabilities"]&&a["sourceCapabilities"]["firesTouchEvents"]||a["originalEvent"]&&a["originalEvent"]["sourceCapabilities"]&&a["originalEvent"]["sourceCapabilities"]["firesTouchEvents"]}function b(a){return new Promise((b,c)=>{const d=document.createElement("link");d.onload=()=>b(d),d.onerror=(a)=>c(a),d.rel="stylesheet",d.href=a,document.head.appendChild(d)})}function c(a){return new Promise((b,c)=>{const d=new Image;d.onload=()=>b(d),d.onerror=(a)=>c(a),d.src=a})}async function d(a){const b=URL.createObjectURL(a);try{return await c(b)}finally{URL.revokeObjectURL(b)}}function f(a){do{if(a.parentNode&&a.hasAttribute("contenteditable"))return!0;a=a.parentNode}while(a);return!1}function e(a){const b=a.target.tagName.toLowerCase();m.has(b)&&a.preventDefault()}function g(a){(a.metaKey||a.ctrlKey)&&a.preventDefault()}function h(){try{return window.parent&&window.parent.document.hasFocus()}catch(a){return!1}}const i=new Map([["OSLeft","MetaLeft"],["OSRight","MetaRight"]]),j={"dispatchRuntimeEvent":!0,"dispatchUserScriptEvent":!0},k={"dispatchUserScriptEvent":!0},l={"dispatchRuntimeEvent":!0};const m=new Set(["canvas","body","html"]);self["C3_RasterSvgImage"]=async function(a,b,c){const d=document.createElement("canvas");d.width=b,d.height=c;const e=d.getContext("2d");return e.drawImage(a,0,0,b,c),d};let n=!1;document.addEventListener("pause",()=>n=!0),document.addEventListener("resume",()=>n=!1);const o=class extends DOMHandler{constructor(a){super(a,"runtime"),this._isFirstSizeUpdate=!0,this._simulatedResizeTimerId=-1,this._targetOrientation="any",this._attachedDeviceOrientationEvent=!1,this._attachedDeviceMotionEvent=!1,this._debugHighlightElem=null,a.AddRuntimeComponentMessageHandler("canvas","update-size",(a)=>this._OnUpdateCanvasSize(a)),a.AddRuntimeComponentMessageHandler("runtime","invoke-download",(a)=>this._OnInvokeDownload(a)),a.AddRuntimeComponentMessageHandler("runtime","raster-svg-image",(a)=>this._OnRasterSvgImage(a)),a.AddRuntimeComponentMessageHandler("runtime","set-target-orientation",(a)=>this._OnSetTargetOrientation(a)),a.AddRuntimeComponentMessageHandler("runtime","register-sw",()=>this._OnRegisterSW()),a.AddRuntimeComponentMessageHandler("runtime","post-to-debugger",(a)=>this._OnPostToDebugger(a)),a.AddRuntimeComponentMessageHandler("runtime","go-to-script",(a)=>this._OnPostToDebugger(a)),a.AddRuntimeComponentMessageHandler("runtime","before-start-ticking",()=>this._OnBeforeStartTicking()),a.AddRuntimeComponentMessageHandler("runtime","debug-highlight",(a)=>this._OnDebugHighlight(a)),a.AddRuntimeComponentMessageHandler("runtime","enable-device-orientation",()=>this._AttachDeviceOrientationEvent()),a.AddRuntimeComponentMessageHandler("runtime","enable-device-motion",()=>this._AttachDeviceMotionEvent()),a.AddRuntimeComponentMessageHandler("runtime","add-stylesheet",(a)=>this._OnAddStylesheet(a));const b=new Set(["input","textarea","datalist"]);window.addEventListener("contextmenu",(a)=>{const c=a.target,d=c.tagName.toLowerCase();b.has(d)||f(c)||a.preventDefault()}),window.addEventListener("selectstart",e),window.addEventListener("gesturehold",e),window.addEventListener("touchstart",e,{"passive":!1});const c=a.GetCanvas();"undefined"==typeof PointerEvent?c.addEventListener("touchstart",e):(window.addEventListener("pointerdown",e,{"passive":!1}),c.addEventListener("pointerdown",e)),this._mousePointerLastButtons=0,window.addEventListener("mousedown",(a)=>{1===a.button&&a.preventDefault()}),window.addEventListener("mousewheel",g,{"passive":!1}),window.addEventListener("wheel",g,{"passive":!1}),window.addEventListener("resize",()=>this._OnWindowResize()),this._mediaPendingPlay=new Set,this._mediaRemovedPendingPlay=new WeakSet,this._isSilent=!1}_OnBeforeStartTicking(){return document.addEventListener("visibilitychange",()=>this._OnVisibilityChange(document.hidden)),document.addEventListener("pause",()=>this._OnVisibilityChange(!0)),document.addEventListener("resume",()=>this._OnVisibilityChange(!1)),{"isSuspended":!!(document.hidden||n)}}Attach(){window.addEventListener("focus",()=>this._PostRuntimeEvent("window-focus")),window.addEventListener("blur",()=>{this._PostRuntimeEvent("window-blur",{"parentHasFocus":h()}),this._mousePointerLastButtons=0}),window.addEventListener("fullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("webkitfullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("mozfullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("fullscreenerror",(a)=>this._OnFullscreenError(a)),window.addEventListener("webkitfullscreenerror",(a)=>this._OnFullscreenError(a)),window.addEventListener("mozfullscreenerror",(a)=>this._OnFullscreenError(a)),window.addEventListener("keydown",(a)=>this._OnKeyEvent("keydown",a)),window.addEventListener("keyup",(a)=>this._OnKeyEvent("keyup",a)),window.addEventListener("dblclick",(a)=>this._OnMouseEvent("dblclick",a,j)),window.addEventListener("wheel",(a)=>this._OnMouseWheelEvent("wheel",a)),"undefined"==typeof PointerEvent?(window.addEventListener("mousedown",(a)=>this._OnMouseEventAsPointer("pointerdown",a)),window.addEventListener("mousemove",(a)=>this._OnMouseEventAsPointer("pointermove",a)),window.addEventListener("mouseup",(a)=>this._OnMouseEventAsPointer("pointerup",a)),window.addEventListener("touchstart",(a)=>this._OnTouchEvent("pointerdown",a)),window.addEventListener("touchmove",(a)=>this._OnTouchEvent("pointermove",a)),window.addEventListener("touchend",(a)=>this._OnTouchEvent("pointerup",a)),window.addEventListener("touchcancel",(a)=>this._OnTouchEvent("pointercancel",a))):(window.addEventListener("pointerdown",(a)=>this._OnPointerEvent("pointerdown",a)),window.addEventListener("pointermove",(a)=>this._OnPointerEvent("pointermove",a)),window.addEventListener("pointerup",(a)=>this._OnPointerEvent("pointerup",a)),window.addEventListener("pointercancel",(a)=>this._OnPointerEvent("pointercancel",a)));const a=()=>this._PlayPendingMedia();window.addEventListener("pointerup",a,!0),window.addEventListener("touchend",a,!0),window.addEventListener("click",a,!0),window.addEventListener("keydown",a,!0),window.addEventListener("gamepadconnected",a,!0)}_PostRuntimeEvent(a,b){this.PostToRuntime(a,b||null,l)}_GetWindowInnerWidth(){return Math.max(window.innerWidth,1)}_GetWindowInnerHeight(){return Math.max(window.innerHeight,1)}_OnWindowResize(){const a=this._GetWindowInnerWidth(),b=this._GetWindowInnerHeight();this._PostRuntimeEvent("window-resize",{"innerWidth":a,"innerHeight":b,"devicePixelRatio":window.devicePixelRatio}),this._iRuntime.IsWKWebView()&&(-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId),this._OnSimulatedResize(a,b,0))}_ScheduleSimulatedResize(a,b,c){-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId),this._simulatedResizeTimerId=setTimeout(()=>this._OnSimulatedResize(a,b,c),48)}_OnSimulatedResize(a,b,c){const d=this._GetWindowInnerWidth(),e=this._GetWindowInnerHeight();this._simulatedResizeTimerId=-1,d!=a||e!=b?this._PostRuntimeEvent("window-resize",{"innerWidth":d,"innerHeight":e,"devicePixelRatio":window.devicePixelRatio}):10>c&&this._ScheduleSimulatedResize(d,e,c+1)}_OnSetTargetOrientation(a){this._targetOrientation=a["targetOrientation"]}_TrySetTargetOrientation(){const a=this._targetOrientation;if(screen["orientation"]&&screen["orientation"]["lock"])screen["orientation"]["lock"](a).catch((a)=>console.warn("[Construct 3] Failed to lock orientation: ",a));else try{let b=!1;screen["lockOrientation"]?b=screen["lockOrientation"](a):screen["webkitLockOrientation"]?b=screen["webkitLockOrientation"](a):screen["mozLockOrientation"]?b=screen["mozLockOrientation"](a):screen["msLockOrientation"]&&(b=screen["msLockOrientation"](a)),b||console.warn("[Construct 3] Failed to lock orientation")}catch(a){console.warn("[Construct 3] Failed to lock orientation: ",a)}}_OnFullscreenChange(){const a=RuntimeInterface.IsDocumentFullscreen();a&&"any"!==this._targetOrientation&&this._TrySetTargetOrientation(),this.PostToRuntime("fullscreenchange",{"isFullscreen":a,"innerWidth":this._GetWindowInnerWidth(),"innerHeight":this._GetWindowInnerHeight()})}_OnFullscreenError(a){console.warn("[Construct 3] Fullscreen request failed: ",a),this.PostToRuntime("fullscreenerror",{"isFullscreen":RuntimeInterface.IsDocumentFullscreen(),"innerWidth":this._GetWindowInnerWidth(),"innerHeight":this._GetWindowInnerHeight()})}_OnVisibilityChange(a){a?this._iRuntime._CancelAnimationFrame():this._iRuntime._RequestAnimationFrame(),this.PostToRuntime("visibilitychange",{"hidden":a})}_OnKeyEvent(a,b){const c=i.get(b.code)||b.code;this._PostToRuntimeMaybeSync(a,{"code":c,"key":b.key,"which":b.which,"repeat":b.repeat,"altKey":b.altKey,"ctrlKey":b.ctrlKey,"metaKey":b.metaKey,"shiftKey":b.shiftKey,"timeStamp":b.timeStamp},j)}_OnMouseWheelEvent(a,b){this.PostToRuntime(a,{"clientX":b.clientX,"clientY":b.clientY,"deltaX":b.deltaX,"deltaY":b.deltaY,"deltaZ":b.deltaZ,"deltaMode":b.deltaMode,"timeStamp":b.timeStamp},j)}_OnMouseEvent(b,c,d){a(c)||("mousedown"===b&&window!==window.top&&window.focus(),this._PostToRuntimeMaybeSync(b,{"button":c.button,"buttons":c.buttons,"clientX":c.clientX,"clientY":c.clientY,"timeStamp":c.timeStamp},d))}_OnMouseEventAsPointer(b,c){if(a(c))return;"pointerdown"===b&&window!==window.top&&window.focus();const d=this._mousePointerLastButtons;"pointerdown"===b&&0!==d?b="pointermove":"pointerup"==b&&0!==c.buttons&&(b="pointermove"),this._PostToRuntimeMaybeSync(b,{"pointerId":1,"pointerType":"mouse","button":c.button,"buttons":c.buttons,"lastButtons":d,"clientX":c.clientX,"clientY":c.clientY,"width":0,"height":0,"pressure":0,"tangentialPressure":0,"tiltX":0,"tiltY":0,"twist":0,"timeStamp":c.timeStamp},j),this._mousePointerLastButtons=c.buttons,this._OnMouseEvent(c.type,c,k)}_OnPointerEvent(a,b){"pointerdown"===a&&window!==window.top&&window.focus();let c=0;if("mouse"===b.pointerType&&(c=this._mousePointerLastButtons),this._PostToRuntimeMaybeSync(a,{"pointerId":b.pointerId,"pointerType":b.pointerType,"button":b.button,"buttons":b.buttons,"lastButtons":c,"clientX":b.clientX,"clientY":b.clientY,"width":b.width||0,"height":b.height||0,"pressure":b.pressure||0,"tangentialPressure":b["tangentialPressure"]||0,"tiltX":b.tiltX||0,"tiltY":b.tiltY||0,"twist":b["twist"]||0,"timeStamp":b.timeStamp},j),"mouse"===b.pointerType){let c="mousemove";"pointerdown"===a?c="mousedown":"pointerup"==a&&(c="pointerup"),this._OnMouseEvent(c,b,k),this._mousePointerLastButtons=b.buttons}}_OnTouchEvent(a,b){"pointerdown"===a&&window!==window.top&&window.focus();for(let c=0,d=b.changedTouches.length;cthis._OnDeviceOrientation(a)))}_AttachDeviceMotionEvent(){this._attachedDeviceMotionEvent||(this._attachedDeviceMotionEvent=!0,window.addEventListener("devicemotion",(a)=>this._OnDeviceMotion(a)))}_OnDeviceOrientation(a){this.PostToRuntime("deviceorientation",{"alpha":a["alpha"]||0,"beta":a["beta"]||0,"gamma":a["gamma"]||0,"timeStamp":a.timeStamp},j)}_OnDeviceMotion(a){let b=null;const c=a["acceleration"];c&&(b={"x":c["x"]||0,"y":c["y"]||0,"z":c["z"]||0});let d=null;const e=a["accelerationIncludingGravity"];e&&(d={"x":e["x"]||0,"y":e["y"]||0,"z":e["z"]||0});let f=null;const g=a["rotationRate"];g&&(f={"alpha":g["alpha"]||0,"beta":g["beta"]||0,"gamma":g["gamma"]||0}),this.PostToRuntime("devicemotion",{"acceleration":b,"accelerationIncludingGravity":d,"rotationRate":f,"interval":a["interval"],"timeStamp":a.timeStamp},j)}_OnUpdateCanvasSize(a){const b=this.GetRuntimeInterface(),c=b.GetCanvas();c.style.width=a["styleWidth"]+"px",c.style.height=a["styleHeight"]+"px",c.style.marginLeft=a["marginLeft"]+"px",c.style.marginTop=a["marginTop"]+"px",b.MaybeForceBodySize(),this._isFirstSizeUpdate&&(c.style.display="",this._isFirstSizeUpdate=!1)}_OnInvokeDownload(b){const c=b["url"],d=b["filename"],e=document.createElement("a"),a=document.body;e.textContent=d,e.href=c,e.download=d,a.appendChild(e),e.click(),a.removeChild(e)}async _OnRasterSvgImage(a){const b=a["blob"],c=a["width"],e=a["height"],f=await d(b),g=await self["C3_RasterSvgImage"](f,c,e);return await createImageBitmap(g)}async _OnAddStylesheet(a){await b(a["url"])}_PlayPendingMedia(){const a=[...this._mediaPendingPlay];if(this._mediaPendingPlay.clear(),!this._isSilent)for(const b of a){const a=b.play();a&&a.catch(()=>{this._mediaRemovedPendingPlay.has(b)||this._mediaPendingPlay.add(b)})}}TryPlayMedia(a){if("function"!=typeof a.play)throw new Error("missing play function");this._mediaRemovedPendingPlay.delete(a);let b;try{b=a.play()}catch(b){return void this._mediaPendingPlay.add(a)}b&&b.catch(()=>{this._mediaRemovedPendingPlay.has(a)||this._mediaPendingPlay.add(a)})}RemovePendingPlay(a){this._mediaPendingPlay.delete(a),this._mediaRemovedPendingPlay.add(a)}SetSilent(a){this._isSilent=!!a}_OnDebugHighlight(a){const b=a["show"];if(!b)return void(this._debugHighlightElem&&(this._debugHighlightElem.style.display="none"));this._debugHighlightElem||(this._debugHighlightElem=document.createElement("div"),this._debugHighlightElem.id="inspectOutline",document.body.appendChild(this._debugHighlightElem));const c=this._debugHighlightElem;c.style.display="",c.style.left=a["left"]-1+"px",c.style.top=a["top"]-1+"px",c.style.width=a["width"]+2+"px",c.style.height=a["height"]+2+"px",c.textContent=a["name"]}_OnRegisterSW(){window["C3_RegisterSW"]&&window["C3_RegisterSW"]()}_OnPostToDebugger(a){window["c3_postToMessagePort"]&&(a["from"]="runtime",window["c3_postToMessagePort"](a))}_InvokeFunctionFromJS(a,b){return this.PostToRuntimeAsync("js-invoke-function",{"name":a,"params":b})}};RuntimeInterface.AddDOMHandlerClass(o)} +"use strict";{function a(a){return a["sourceCapabilities"]&&a["sourceCapabilities"]["firesTouchEvents"]||a["originalEvent"]&&a["originalEvent"]["sourceCapabilities"]&&a["originalEvent"]["sourceCapabilities"]["firesTouchEvents"]}function b(a){return new Promise((b,c)=>{const d=document.createElement("link");d.onload=()=>b(d),d.onerror=(a)=>c(a),d.rel="stylesheet",d.href=a,document.head.appendChild(d)})}function c(a){return new Promise((b,c)=>{const d=new Image;d.onload=()=>b(d),d.onerror=(a)=>c(a),d.src=a})}async function d(a){const b=URL.createObjectURL(a);try{return await c(b)}finally{URL.revokeObjectURL(b)}}function f(a){do{if(a.parentNode&&a.hasAttribute("contenteditable"))return!0;a=a.parentNode}while(a);return!1}function e(a){const b=a.target.tagName.toLowerCase();m.has(b)&&a.preventDefault()}function g(a){(a.metaKey||a.ctrlKey)&&a.preventDefault()}function h(){try{return window.parent&&window.parent.document.hasFocus()}catch(a){return!1}}const i=new Map([["OSLeft","MetaLeft"],["OSRight","MetaRight"]]),j={"dispatchRuntimeEvent":!0,"dispatchUserScriptEvent":!0},k={"dispatchUserScriptEvent":!0},l={"dispatchRuntimeEvent":!0};const m=new Set(["canvas","body","html"]);self["C3_RasterSvgImage"]=async function(a,b,c){const d=document.createElement("canvas");d.width=b,d.height=c;const e=d.getContext("2d");return e.drawImage(a,0,0,b,c),d};let n=!1;document.addEventListener("pause",()=>n=!0),document.addEventListener("resume",()=>n=!1);const o=class extends DOMHandler{constructor(a){super(a,"runtime"),this._isFirstSizeUpdate=!0,this._simulatedResizeTimerId=-1,this._targetOrientation="any",this._attachedDeviceOrientationEvent=!1,this._attachedDeviceMotionEvent=!1,this._debugHighlightElem=null,this._pointerRawUpdateRateLimiter=null,this._lastPointerRawUpdateEvent=null,a.AddRuntimeComponentMessageHandler("canvas","update-size",(a)=>this._OnUpdateCanvasSize(a)),a.AddRuntimeComponentMessageHandler("runtime","invoke-download",(a)=>this._OnInvokeDownload(a)),a.AddRuntimeComponentMessageHandler("runtime","raster-svg-image",(a)=>this._OnRasterSvgImage(a)),a.AddRuntimeComponentMessageHandler("runtime","set-target-orientation",(a)=>this._OnSetTargetOrientation(a)),a.AddRuntimeComponentMessageHandler("runtime","register-sw",()=>this._OnRegisterSW()),a.AddRuntimeComponentMessageHandler("runtime","post-to-debugger",(a)=>this._OnPostToDebugger(a)),a.AddRuntimeComponentMessageHandler("runtime","go-to-script",(a)=>this._OnPostToDebugger(a)),a.AddRuntimeComponentMessageHandler("runtime","before-start-ticking",()=>this._OnBeforeStartTicking()),a.AddRuntimeComponentMessageHandler("runtime","debug-highlight",(a)=>this._OnDebugHighlight(a)),a.AddRuntimeComponentMessageHandler("runtime","enable-device-orientation",()=>this._AttachDeviceOrientationEvent()),a.AddRuntimeComponentMessageHandler("runtime","enable-device-motion",()=>this._AttachDeviceMotionEvent()),a.AddRuntimeComponentMessageHandler("runtime","add-stylesheet",(a)=>this._OnAddStylesheet(a));const b=new Set(["input","textarea","datalist"]);window.addEventListener("contextmenu",(a)=>{const c=a.target,d=c.tagName.toLowerCase();b.has(d)||f(c)||a.preventDefault()}),window.addEventListener("selectstart",e),window.addEventListener("gesturehold",e),window.addEventListener("touchstart",e,{"passive":!1});const c=a.GetCanvas();"undefined"==typeof PointerEvent?c.addEventListener("touchstart",e):(window.addEventListener("pointerdown",e,{"passive":!1}),c.addEventListener("pointerdown",e)),this._mousePointerLastButtons=0,window.addEventListener("mousedown",(a)=>{1===a.button&&a.preventDefault()}),window.addEventListener("mousewheel",g,{"passive":!1}),window.addEventListener("wheel",g,{"passive":!1}),window.addEventListener("resize",()=>this._OnWindowResize()),this._mediaPendingPlay=new Set,this._mediaRemovedPendingPlay=new WeakSet,this._isSilent=!1}_OnBeforeStartTicking(){return"cordova"===this._iRuntime.GetExportType()?(document.addEventListener("pause",()=>this._OnVisibilityChange(!0)),document.addEventListener("resume",()=>this._OnVisibilityChange(!1))):document.addEventListener("visibilitychange",()=>this._OnVisibilityChange(document.hidden)),{"isSuspended":!!(document.hidden||n)}}Attach(){window.addEventListener("focus",()=>this._PostRuntimeEvent("window-focus")),window.addEventListener("blur",()=>{this._PostRuntimeEvent("window-blur",{"parentHasFocus":h()}),this._mousePointerLastButtons=0}),window.addEventListener("fullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("webkitfullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("mozfullscreenchange",()=>this._OnFullscreenChange()),window.addEventListener("fullscreenerror",(a)=>this._OnFullscreenError(a)),window.addEventListener("webkitfullscreenerror",(a)=>this._OnFullscreenError(a)),window.addEventListener("mozfullscreenerror",(a)=>this._OnFullscreenError(a)),window.addEventListener("keydown",(a)=>this._OnKeyEvent("keydown",a)),window.addEventListener("keyup",(a)=>this._OnKeyEvent("keyup",a)),window.addEventListener("dblclick",(a)=>this._OnMouseEvent("dblclick",a,j)),window.addEventListener("wheel",(a)=>this._OnMouseWheelEvent("wheel",a)),"undefined"==typeof PointerEvent?(window.addEventListener("mousedown",(a)=>this._OnMouseEventAsPointer("pointerdown",a)),window.addEventListener("mousemove",(a)=>this._OnMouseEventAsPointer("pointermove",a)),window.addEventListener("mouseup",(a)=>this._OnMouseEventAsPointer("pointerup",a)),window.addEventListener("touchstart",(a)=>this._OnTouchEvent("pointerdown",a)),window.addEventListener("touchmove",(a)=>this._OnTouchEvent("pointermove",a)),window.addEventListener("touchend",(a)=>this._OnTouchEvent("pointerup",a)),window.addEventListener("touchcancel",(a)=>this._OnTouchEvent("pointercancel",a))):(window.addEventListener("pointerdown",(a)=>this._OnPointerEvent("pointerdown",a)),this._iRuntime.UsesWorker()&&"undefined"!=typeof window["onpointerrawupdate"]?(this._pointerRawUpdateRateLimiter=new RateLimiter(()=>this._DoSendPointerRawUpdate(),5),this._pointerRawUpdateRateLimiter.SetCanRunImmediate(!0),window.addEventListener("pointerrawupdate",(a)=>this._OnPointerRawUpdate(a))):window.addEventListener("pointermove",(a)=>this._OnPointerEvent("pointermove",a)),window.addEventListener("pointerup",(a)=>this._OnPointerEvent("pointerup",a)),window.addEventListener("pointercancel",(a)=>this._OnPointerEvent("pointercancel",a)));const a=()=>this._PlayPendingMedia();window.addEventListener("pointerup",a,!0),window.addEventListener("touchend",a,!0),window.addEventListener("click",a,!0),window.addEventListener("keydown",a,!0),window.addEventListener("gamepadconnected",a,!0)}_PostRuntimeEvent(a,b){this.PostToRuntime(a,b||null,l)}_GetWindowInnerWidth(){return Math.max(window.innerWidth,1)}_GetWindowInnerHeight(){return Math.max(window.innerHeight,1)}_OnWindowResize(){const a=this._GetWindowInnerWidth(),b=this._GetWindowInnerHeight();this._PostRuntimeEvent("window-resize",{"innerWidth":a,"innerHeight":b,"devicePixelRatio":window.devicePixelRatio}),this._iRuntime.IsWKWebView()&&(-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId),this._OnSimulatedResize(a,b,0))}_ScheduleSimulatedResize(a,b,c){-1!==this._simulatedResizeTimerId&&clearTimeout(this._simulatedResizeTimerId),this._simulatedResizeTimerId=setTimeout(()=>this._OnSimulatedResize(a,b,c),48)}_OnSimulatedResize(a,b,c){const d=this._GetWindowInnerWidth(),e=this._GetWindowInnerHeight();this._simulatedResizeTimerId=-1,d!=a||e!=b?this._PostRuntimeEvent("window-resize",{"innerWidth":d,"innerHeight":e,"devicePixelRatio":window.devicePixelRatio}):10>c&&this._ScheduleSimulatedResize(d,e,c+1)}_OnSetTargetOrientation(a){this._targetOrientation=a["targetOrientation"]}_TrySetTargetOrientation(){const a=this._targetOrientation;if(screen["orientation"]&&screen["orientation"]["lock"])screen["orientation"]["lock"](a).catch((a)=>console.warn("[Construct 3] Failed to lock orientation: ",a));else try{let b=!1;screen["lockOrientation"]?b=screen["lockOrientation"](a):screen["webkitLockOrientation"]?b=screen["webkitLockOrientation"](a):screen["mozLockOrientation"]?b=screen["mozLockOrientation"](a):screen["msLockOrientation"]&&(b=screen["msLockOrientation"](a)),b||console.warn("[Construct 3] Failed to lock orientation")}catch(a){console.warn("[Construct 3] Failed to lock orientation: ",a)}}_OnFullscreenChange(){const a=RuntimeInterface.IsDocumentFullscreen();a&&"any"!==this._targetOrientation&&this._TrySetTargetOrientation(),this.PostToRuntime("fullscreenchange",{"isFullscreen":a,"innerWidth":this._GetWindowInnerWidth(),"innerHeight":this._GetWindowInnerHeight()})}_OnFullscreenError(a){console.warn("[Construct 3] Fullscreen request failed: ",a),this.PostToRuntime("fullscreenerror",{"isFullscreen":RuntimeInterface.IsDocumentFullscreen(),"innerWidth":this._GetWindowInnerWidth(),"innerHeight":this._GetWindowInnerHeight()})}_OnVisibilityChange(a){a?this._iRuntime._CancelAnimationFrame():this._iRuntime._RequestAnimationFrame(),this.PostToRuntime("visibilitychange",{"hidden":a})}_OnKeyEvent(a,b){const c=i.get(b.code)||b.code;this._PostToRuntimeMaybeSync(a,{"code":c,"key":b.key,"which":b.which,"repeat":b.repeat,"altKey":b.altKey,"ctrlKey":b.ctrlKey,"metaKey":b.metaKey,"shiftKey":b.shiftKey,"timeStamp":b.timeStamp},j)}_OnMouseWheelEvent(a,b){this.PostToRuntime(a,{"clientX":b.clientX,"clientY":b.clientY,"deltaX":b.deltaX,"deltaY":b.deltaY,"deltaZ":b.deltaZ,"deltaMode":b.deltaMode,"timeStamp":b.timeStamp},j)}_OnMouseEvent(b,c,d){a(c)||("mousedown"===b&&window!==window.top&&window.focus(),this._PostToRuntimeMaybeSync(b,{"button":c.button,"buttons":c.buttons,"clientX":c.clientX,"clientY":c.clientY,"timeStamp":c.timeStamp},d))}_OnMouseEventAsPointer(b,c){if(a(c))return;"pointerdown"===b&&window!==window.top&&window.focus();const d=this._mousePointerLastButtons;"pointerdown"===b&&0!==d?b="pointermove":"pointerup"==b&&0!==c.buttons&&(b="pointermove"),this._PostToRuntimeMaybeSync(b,{"pointerId":1,"pointerType":"mouse","button":c.button,"buttons":c.buttons,"lastButtons":d,"clientX":c.clientX,"clientY":c.clientY,"width":0,"height":0,"pressure":0,"tangentialPressure":0,"tiltX":0,"tiltY":0,"twist":0,"timeStamp":c.timeStamp},j),this._mousePointerLastButtons=c.buttons,this._OnMouseEvent(c.type,c,k)}_OnPointerEvent(a,b){"pointerdown"===a&&window!==window.top&&window.focus(),this._pointerRawUpdateRateLimiter&&("pointerup"===a||"pointercancel"===a)&&this._pointerRawUpdateRateLimiter.Reset();let c=0;if("mouse"===b.pointerType&&(c=this._mousePointerLastButtons),this._PostToRuntimeMaybeSync(a,{"pointerId":b.pointerId,"pointerType":b.pointerType,"button":b.button,"buttons":b.buttons,"lastButtons":c,"clientX":b.clientX,"clientY":b.clientY,"width":b.width||0,"height":b.height||0,"pressure":b.pressure||0,"tangentialPressure":b["tangentialPressure"]||0,"tiltX":b.tiltX||0,"tiltY":b.tiltY||0,"twist":b["twist"]||0,"timeStamp":b.timeStamp},j),"mouse"===b.pointerType){let c="mousemove";"pointerdown"===a?c="mousedown":"pointerup"==a&&(c="pointerup"),this._OnMouseEvent(c,b,k),this._mousePointerLastButtons=b.buttons}}_OnPointerRawUpdate(a){this._lastPointerRawUpdateEvent=a,this._pointerRawUpdateRateLimiter.Call()}_DoSendPointerRawUpdate(){this._OnPointerEvent("pointermove",this._lastPointerRawUpdateEvent),this._lastPointerRawUpdateEvent=null}_OnTouchEvent(a,b){"pointerdown"===a&&window!==window.top&&window.focus();for(let c=0,d=b.changedTouches.length;cthis._OnDeviceOrientation(a)))}_AttachDeviceMotionEvent(){this._attachedDeviceMotionEvent||(this._attachedDeviceMotionEvent=!0,window.addEventListener("devicemotion",(a)=>this._OnDeviceMotion(a)))}_OnDeviceOrientation(a){this.PostToRuntime("deviceorientation",{"alpha":a["alpha"]||0,"beta":a["beta"]||0,"gamma":a["gamma"]||0,"timeStamp":a.timeStamp},j)}_OnDeviceMotion(a){let b=null;const c=a["acceleration"];c&&(b={"x":c["x"]||0,"y":c["y"]||0,"z":c["z"]||0});let d=null;const e=a["accelerationIncludingGravity"];e&&(d={"x":e["x"]||0,"y":e["y"]||0,"z":e["z"]||0});let f=null;const g=a["rotationRate"];g&&(f={"alpha":g["alpha"]||0,"beta":g["beta"]||0,"gamma":g["gamma"]||0}),this.PostToRuntime("devicemotion",{"acceleration":b,"accelerationIncludingGravity":d,"rotationRate":f,"interval":a["interval"],"timeStamp":a.timeStamp},j)}_OnUpdateCanvasSize(a){const b=this.GetRuntimeInterface(),c=b.GetCanvas();c.style.width=a["styleWidth"]+"px",c.style.height=a["styleHeight"]+"px",c.style.marginLeft=a["marginLeft"]+"px",c.style.marginTop=a["marginTop"]+"px",b.MaybeForceBodySize(),this._isFirstSizeUpdate&&(c.style.display="",this._isFirstSizeUpdate=!1)}_OnInvokeDownload(b){const c=b["url"],d=b["filename"],e=document.createElement("a"),a=document.body;e.textContent=d,e.href=c,e.download=d,a.appendChild(e),e.click(),a.removeChild(e)}async _OnRasterSvgImage(a){const b=a["blob"],c=a["width"],e=a["height"],f=await d(b),g=await self["C3_RasterSvgImage"](f,c,e);return await createImageBitmap(g)}async _OnAddStylesheet(a){await b(a["url"])}_PlayPendingMedia(){const a=[...this._mediaPendingPlay];if(this._mediaPendingPlay.clear(),!this._isSilent)for(const b of a){const a=b.play();a&&a.catch(()=>{this._mediaRemovedPendingPlay.has(b)||this._mediaPendingPlay.add(b)})}}TryPlayMedia(a){if("function"!=typeof a.play)throw new Error("missing play function");this._mediaRemovedPendingPlay.delete(a);let b;try{b=a.play()}catch(b){return void this._mediaPendingPlay.add(a)}b&&b.catch(()=>{this._mediaRemovedPendingPlay.has(a)||this._mediaPendingPlay.add(a)})}RemovePendingPlay(a){this._mediaPendingPlay.delete(a),this._mediaRemovedPendingPlay.add(a)}SetSilent(a){this._isSilent=!!a}_OnDebugHighlight(a){const b=a["show"];if(!b)return void(this._debugHighlightElem&&(this._debugHighlightElem.style.display="none"));this._debugHighlightElem||(this._debugHighlightElem=document.createElement("div"),this._debugHighlightElem.id="inspectOutline",document.body.appendChild(this._debugHighlightElem));const c=this._debugHighlightElem;c.style.display="",c.style.left=a["left"]-1+"px",c.style.top=a["top"]-1+"px",c.style.width=a["width"]+2+"px",c.style.height=a["height"]+2+"px",c.textContent=a["name"]}_OnRegisterSW(){window["C3_RegisterSW"]&&window["C3_RegisterSW"]()}_OnPostToDebugger(a){window["c3_postToMessagePort"]&&(a["from"]="runtime",window["c3_postToMessagePort"](a))}_InvokeFunctionFromJS(a,b){return this.PostToRuntimeAsync("js-invoke-function",{"name":a,"params":b})}};RuntimeInterface.AddDOMHandlerClass(o)} "use strict";{const a=document.currentScript.src;self.JobSchedulerDOM=class{constructor(b){this._runtimeInterface=b,this._baseUrl=a?a.substr(0,a.lastIndexOf("/")+1):b.GetBaseURL(),this._maxNumWorkers=Math.min(navigator.hardwareConcurrency||2,16),this._dispatchWorker=null,this._jobWorkers=[],this._inputPort=null,this._outputPort=null}async Init(){if(this._hasInitialised)throw new Error("already initialised");this._hasInitialised=!0;const a=this._runtimeInterface._GetWorkerURL("dispatchworker.js");this._dispatchWorker=await this._runtimeInterface.CreateWorker(a,this._baseUrl,{name:"DispatchWorker"});const b=new MessageChannel;this._inputPort=b.port1,this._dispatchWorker.postMessage({"type":"_init","in-port":b.port2},[b.port2]),this._outputPort=await this._CreateJobWorker()}async _CreateJobWorker(){const a=this._jobWorkers.length,b=this._runtimeInterface._GetWorkerURL("jobworker.js"),c=await this._runtimeInterface.CreateWorker(b,this._baseUrl,{name:"JobWorker"+a}),d=new MessageChannel,e=new MessageChannel;return this._dispatchWorker.postMessage({"type":"_addJobWorker","port":d.port1},[d.port1]),c.postMessage({"type":"init","number":a,"dispatch-port":d.port2,"output-port":e.port2},[d.port2,e.port2]),this._jobWorkers.push(c),e.port1}GetPortData(){return{"inputPort":this._inputPort,"outputPort":this._outputPort,"maxNumWorkers":this._maxNumWorkers}}GetPortTransferables(){return[this._inputPort,this._outputPort]}}} diff --git a/sample_projects/SpinePluginTest.c3p b/sample_projects/SpinePluginTest.c3p index 51f799b..abc7322 100644 Binary files a/sample_projects/SpinePluginTest.c3p and b/sample_projects/SpinePluginTest.c3p differ diff --git a/src/aces.json b/src/aces.json index 26d8915..45a8d4a 100644 --- a/src/aces.json +++ b/src/aces.json @@ -5,6 +5,33 @@ "id": "on-skeleton-loaded", "scriptName": "OnSkeletonLoaded", "isTrigger": true + }, + { + "id": "on-animation-finished", + "scriptName": "OnAnimationFinished", + "isTrigger": true, + "params": [ + { + "id": "animation-name", + "type": "string" + } + ] + }, + { + "id": "on-any-animation-finished", + "scriptName": "OnAnyAnimationFinished", + "isTrigger": true + }, + { + "id": "is-animation-playing", + "scriptName": "IsAnimationPlaying", + "isTrigger": false, + "params": [ + { + "id": "animation-name", + "type": "string" + } + ] } ], "actions": [ diff --git a/src/addon.json b/src/addon.json index c2ba303..3802c6a 100644 --- a/src/addon.json +++ b/src/addon.json @@ -3,7 +3,7 @@ "type": "plugin", "name": "Spine", "id": "Gritsenko_Spine", - "version": "1.3.0.0", + "version": "1.4.0.0", "author": "Igor Gritsenko", "website": "https://www.gritsenko.biz", "documentation": "https://www.construct.net", diff --git a/src/c3runtime/conditions.js b/src/c3runtime/conditions.js index cdfcb2c..da67aae 100644 --- a/src/c3runtime/conditions.js +++ b/src/c3runtime/conditions.js @@ -2,8 +2,20 @@ { C3.Plugins.Gritsenko_Spine.Cnds = { - OnSkeletonLoaded(){ + OnSkeletonLoaded() { return true; + }, + + OnAnimationFinished(animationName) { + return this.animationName == animationName; + }, + + OnAnyAnimationFinished() { + return true; + }, + + IsAnimationPlaying(animationName) { + return this.animationName == animationName; } }; diff --git a/src/c3runtime/instance.js b/src/c3runtime/instance.js index 0619049..5ed42d0 100644 --- a/src/c3runtime/instance.js +++ b/src/c3runtime/instance.js @@ -30,7 +30,8 @@ this.skinName = properties[3]; this.animationName = properties[4]; this.skeletonName = properties[5]; - this.premultipliedAlpha = properties[6]; + this.skeletonScale = properties[6]; + this.premultipliedAlpha = properties[7]; } this.isMirrored = false; @@ -128,7 +129,7 @@ var centerY = bounds.offset.y + (bounds.size.y) / 2; var scaleX = bounds.size.x / (bounds.size.x); var scaleY = bounds.size.y / (bounds.size.y); - var scale = Math.max(scaleX, scaleY) * 1.2; + var scale = Math.max(scaleX, scaleY) * (1/this.skeletonScale); if (scale < 1) scale = 1; var width = (bounds.size.x) * scale; var height = (bounds.size.y) * scale; @@ -272,6 +273,14 @@ const state = this.skeletonInfo.state; const skeleton = this.skeletonInfo.skeleton; state.setAnimation(0, this.animationName, loop); + + state.tracks[0].listener = { + complete: (trackEntry, count) => { + this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnimationFinished); + this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnyAnimationFinished); + } + }; + state.apply(skeleton); } catch (ex) { console.error(ex); @@ -459,6 +468,7 @@ state.update(delta); state.apply(active.skeleton); active.skeleton.updateWorldTransform(); + this._runtime.UpdateRender(); } } diff --git a/src/lang/en-US.json b/src/lang/en-US.json index 18d7334..d9fddfe 100644 --- a/src/lang/en-US.json +++ b/src/lang/en-US.json @@ -32,6 +32,10 @@ "name": "Skeleton", "desc": "Active Skeleton name" }, + "scale": { + "name": "Scale", + "desc": "Set scale of skeleton inside object frame" + }, "pre-mult-alpha": { "name": "PreMultiplyAlpha", "desc": "Pre Multiply Alpha Texture" @@ -45,6 +49,34 @@ "list-name": "On skeleton loaded", "display-text": "On skeleton loaded", "description": "Triggered skeleton was loaded." + }, + "on-animation-finished": { + "list-name": "On animation finished", + "display-text": "On animation {0} finished", + "description": "Triggered when specified animation finished.", + "params": { + "animation-name": { + "name": "Animation name", + "desc": "Animation name" + } + } + + }, + "on-any-animation-finished": { + "list-name": "On any animation finished", + "display-text": "On any animation finished", + "description": "Triggered on any animation were finished." + }, + "is-animation-playing": { + "list-name": "Is animation playing", + "display-text": "Is animation {0} playing", + "description": "Is animation playing.", + "params": { + "animation-name": { + "name": "Animation name", + "desc": "Animation name" + } + } } }, "actions": { diff --git a/src/plugin.js b/src/plugin.js index e548e7d..17ace54 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -2,7 +2,7 @@ { const PLUGIN_ID = "Gritsenko_Spine"; - const PLUGIN_VERSION = "1.3.0.0"; + const PLUGIN_VERSION = "1.4.0.0"; const PLUGIN_CATEGORY = "general"; const PLUGIN_CLASS = SDK.Plugins.Gritsenko_Spine = class SpinePlugin extends SDK.IPluginBase { @@ -53,6 +53,7 @@ new SDK.PluginProperty("text", "skin", "default"), new SDK.PluginProperty("text", "animation", "idle"), new SDK.PluginProperty("text", "skeleton", ""), + new SDK.PluginProperty("float", "scale", 1), new SDK.PluginProperty("check", "pre-mult-alpha", false) ]); SDK.Lang.PopContext(); //.properties