diff --git a/GemQuest/1904849.json b/GemQuest/1904849.json new file mode 100644 index 0000000..562118e --- /dev/null +++ b/GemQuest/1904849.json @@ -0,0 +1 @@ +{"branch_id":"fa201fb2-9558-40a9-9aae-93e54c6576ef","name":"Untitled","created":"2022-07-28T06:42:52.235Z","settings":{"physics":{"gravity":[0,-9.8,0]},"render":{"lightmapFilterRange":10,"tonemapping":0,"ambientBakeOcclusionContrast":0,"skybox":null,"lightmapFilterSmoothness":0.2,"gamma_correction":1,"fog_start":1,"skyboxIntensity":1,"fog_color":[0,0,0],"lightmapMode":1,"ambientBakeSpherePart":0.4,"fog":"none","lightmapMaxResolution":2048,"skyboxMip":0,"lightmapSizeMultiplier":16,"fog_end":1000,"lightmapFilterEnabled":false,"ambientBake":false,"fog_density":0.01,"exposure":1,"global_ambient":[0.2,0.2,0.2],"ambientBakeNumSamples":1,"ambientBakeOcclusionBrightness":0,"skyboxRotation":[0,0,0],"clusteredLightingEnabled":true,"lightingCells":[10,3,10],"lightingMaxLightsPerCell":255,"lightingCookieAtlasResolution":2048,"lightingShadowAtlasResolution":2048,"lightingShadowType":0,"lightingCookiesEnabled":false,"lightingAreaLightsEnabled":false,"lightingShadowsEnabled":true,"skyType":"infinite","skyMeshPosition":[0,0,0],"skyMeshRotation":[0,0,0],"skyMeshScale":[1,1,1],"skyCenter":[0,1,0]}},"entities":{"!#%":{"!":"Light","#":"! G","$":"!#%","%":{"!8":{"!9":true,"!:":false,"!;":11,"!<":2,"!=":0.05,"+":[1,1,1],"!>":0,"!?":1,"!@":45,"!A":1,"!B":true,"!C":1,"!D":true,"!E":0,"!F":false,"!G":"rgb","!H":40,"!I":0.2,"!J":false,"!K":0,"!L":null,"!M":0.01,"*":[0],"!N":1,"!O":0.5,"!P":[0,0],"!Q":1024,"!R":[1,1]," ":true,"!S":0,"!T":8,"!U":1,"!V":16,",":"directional","!W":true,"!X":0}},"&":[]," ":true,"'":[],"___1":[48,51,3]},"! G":{"!":"Root","#":null,"$":"! G","%":{},"&":[]," ":true,"'":["!#&","!#%","! #","! H"],"___2":0},"!#&":{"!":"Camera","#":"! G","$":"!#&","%":{"!Y":{"!Z":0,"![":1000,"!]":true,"*":[0,1,2,3,4],"!^":0,"!_":45,"!`":true,"!a":true,"!b":[0.118,0.118,0.118,1]," ":true,"!c":4,"!d":0.1,"-":[0,0,1,1],"!e":0,"!f":1}},"&":[]," ":true,"'":[],"___1":[54,57,3]},"! #":{"!":"2D Screen","&":[]," ":true,"$":"! #","#":"! G","'":["!#'","!#(","!!&","! 0","! 1","!!g"],"%":{"!g":{" ":true,"!h":true,"!i":"blend","!j":0.5,"!k":[1280,720],"!l":[1000,1600]}},"___2":0},"!#'":{"!":"BakcgourndCover","&":[]," ":false,"$":"!#'","#":"! #","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":1000,"B":1600,"C":[-500,-800,-500,-800],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!&":{"!":"Top","&":[]," ":true,"$":"!!&","#":"! #","'":["!!h","!!i"],"%":{".":{"0":[0.5,1],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,1,0.5,1],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":1000,"B":250,"C":[-500,-250,-500,0],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["userBalance"],"S":{"!m":{" ":true,"P":{"!n":"!!i","!o":"!!h"}}}}},"___2":0},"!!h":{"!":"UserName","&":[]," ":false,"$":"!!h","#":"!!&","'":[],"%":{".":{"0":[1,1],"1":"UserName","2":null,"3":158042738,"4":60,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[1,1,1,1],":":60,";":true,"(":1,"+":[1,0,0],"<":1,"=":null,">":null,"?":0,"@":null,"A":315,"B":67.44,"C":[-803.943,-102.58,475.143,35],")":[0.5,0.5],"D":[0,0,0,1],"E":0.4,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[60,0,3]},"!!i":{"!":"Balance","&":[]," ":true,"$":"!!i","#":"!!&","'":[],"%":{".":{"0":[0.5,0.5],"1":"100","2":null,"3":214574678,"4":45,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":45,";":true,"(":1,"+":[0.96471,0.89804,0.47843],"<":1,"=":null,">":null,"?":0,"@":null,"A":67.12,"B":44.32,"C":[-41.95,-15.7,-41.95,-39.7],")":[1,0.5],"D":[0,0,0,1],"E":0.4,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[63,0,3]},"! 0":{"!":"Middle","&":[]," ":true,"$":"! 0","#":"! #","'":["! 2","!!'","!!j","!!k"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":1000,"B":1600,"C":[-500,-708.649,-500,-891.351],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["middle","gemController"],"S":{"!p":{" ":true,"P":{"!q":null,"!r":[]}},"!s":{" ":true,"P":{"U":[214407939,214407936,214407934,214407940,214407941,214543430,214816356],"!t":["! 3","! 4","! 5","! 6","! 7"]}}}}},"___1":[66,0,3]},"! 1":{"!":"Bottom","&":[]," ":true,"$":"! 1","#":"! #","'":["!!l","!!(","!!)","!!m"],"%":{".":{"0":[0.5,0],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0,0.5,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":1000,"B":400,"C":[-500,0,-500,-400],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["bottom"],"S":{"!u":{" ":true,"P":{"!v":"!!*","!w":"! 8","!x":"!!+","!-":"! ","!y":"!!n","!.":"! I","!z":"!!,","!/":"!!o","!{":"!!p","!|":214542950,"!}":214542951,"!~":214407944,"# ":214407930}}}}},"___2":0},"!!l":{"!":"Idle","&":[]," ":true,"$":"!!l","#":"! 1","'":["!!*"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":1000,"B":400,"C":[-500,-200,-500,-200],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!(":{"!":"InGame","&":[]," ":true,"$":"!!(","#":"! 1","'":["!!o","!!,"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":1000,"B":400,"C":[-500,-200,-500,-200],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!)":{"!":"Result","&":[]," ":true,"$":"!!)","#":"! 1","'":["! 8","!!+"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":1000,"B":400,"C":[-500,-200,-500,-200],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!*":{"!":"StartButton","&":[]," ":true,"$":"!!*","#":"!!l","'":[],"%":{"W":{" ":true,"X":true,"Y":"!!*","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[0.78431,0.78431,0.78431,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214542950,">":null,"?":0,"@":null,"A":239,"B":67,"C":[-119,-126.5,-120,59.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false}},"___1":[69,0,3]},"! H":{"!":"Controller","&":[]," ":true,"$":"! H","#":"! G","'":["!#)","!#*","!!-"],"%":{},"___2":0},"!#)":{"!":"DummyServer","&":[]," ":true,"$":"!#)","#":"! H","'":[],"%":{"Q":{" ":true,"R":["dummyServer"],"S":{"#!":{" ":true,"P":{}}}}},"___2":0},"!#*":{"!":"GameController","&":[]," ":true,"$":"!#*","#":"! H","'":[],"%":{"Q":{" ":true,"R":["gameController"],"S":{"##":{" ":true,"P":{}}}}},"___2":0},"! 8":{"!":"Win","&":[]," ":false,"$":"! 8","#":"!!)","'":["!#+","!!p","!!n"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0,0,0],"<":0.7,"=":null,">":null,"?":0,"@":null,"A":1000,"B":500,"C":[-500,450,-500,-950],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[39,0,3]},"!#+":{"!":"Text","&":[]," ":true,"$":"!#+","#":"! 8","'":[],"%":{".":{"0":[0.5,0.5],"1":"WIN","2":null,"3":214574678,"4":180,"5":8,"6":150,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":180,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":652.8,"B":332.4,"C":[-326.4,-76.306,-326.4,-256.094],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[72,0,3]},"!!+":{"!":"Lose","&":[]," ":false,"$":"!!+","#":"!!)","'":["!#,"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0,0,0],"<":0.7,"=":null,">":null,"?":0,"@":null,"A":1000,"B":500,"C":[-500,450,-500,-950],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[39,0,3]},"!#,":{"!":"Text","&":[]," ":true,"$":"!#,","#":"!!+","'":[],"%":{".":{"0":[0.5,0.5],"1":"Lose","2":null,"3":214574678,"4":180,"5":8,"6":150,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":180,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":657.9,"B":332.4,"C":[-328.95,-166.2,-328.95,-166.2],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!-":{"!":"AudioController","&":[]," ":true,"$":"!!-","#":"! H","'":["!#-","!!q"],"%":{"Q":{" ":true,"R":["audioController"],"S":{"#$":{" ":true,"P":{"#%":"!!q"}}}}},"___2":0},"!#-":{"!":"Audio Listener","&":[]," ":true,"$":"!#-","#":"!!-","'":[],"%":{"#&":{" ":true}},"___2":0},"!!q":{"!":"Sound","&":[]," ":true,"$":"!!q","#":"!!-","'":[],"%":{"#'":{" ":true,"u":1,"v":1,"#(":true,"#)":1,"#*":10000,"#+":1,"#,":"linear","#-":{"!0":{"!":"Click","w":false,"x":false,"y":false,"z":214814960,"{":0,"V":null,"u":1,"v":1},"!1":{"!":"Lose","w":false,"x":false,"y":false,"z":214840339,"{":0,"V":null,"u":1,"v":1},"!2":{"!":"Win","w":false,"x":false,"y":false,"z":214705393,"{":0,"V":null,"u":1,"v":1},"!3":{"!":"s1","w":false,"x":false,"y":false,"z":214705391,"{":0,"V":null,"u":1,"v":1},"!4":{"!":"s2","w":false,"x":false,"y":false,"z":214705394,"{":0,"V":null,"u":1,"v":1},"!5":{"!":"s3","w":false,"x":false,"y":false,"z":214705396,"{":0,"V":null,"u":1,"v":1},"!6":{"!":"s4","w":false,"x":false,"y":false,"z":214705392,"{":0,"V":null,"u":1,"v":1},"!7":{"!":"s5","w":false,"x":false,"y":false,"z":214705395,"{":0,"V":null,"u":1,"v":1}}}},"___2":0},"!!g":{"!":"SoundButton","&":[]," ":true,"$":"!!g","#":"! #","'":["! J"],"%":{".":{"0":[0,1],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,1,0,1],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":120,"B":120,"C":[20,-140,-140,20],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[75,0,3]},"! J":{"!":"Button","&":[]," ":true,"$":"! J","#":"!!g","'":["!#.","!#/"],"%":{"W":{" ":true,"X":true,"Y":"! J","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[1,1,1,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214407943,">":null,"?":0,"@":null,"A":79,"B":69,"C":[-42.635,-28.231,-36.365,-40.769],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["soundButton"],"S":{"#.":{" ":true,"P":{"#/":214407946,"#0":214407943}}}}},"___1":[78,0,3]},"!#.":{"!":"On","&":[]," ":false,"$":"!#.","#":"! J","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407946,">":null,"?":0,"@":null,"A":79,"B":69,"C":[-39.5,-34.5,-39.5,-34.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!#/":{"!":"Off","&":[]," ":false,"$":"!#/","#":"! J","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407943,">":null,"?":0,"@":null,"A":79,"B":69,"C":[-39.5,-34.5,-39.5,-34.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!m":{"!":"BetController","&":[]," ":true,"$":"!!m","#":"! 1","'":["! "],"%":{".":{"0":[0.5,0],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0,0.5,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":1000,"B":600,"C":[-500,0,-500,-600],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["betController"],"S":{"#1":{" ":true,"P":{"#2":["! K","! L","! M","! N","! O","! P"],"#3":"!!.","#4":"!!/","!.":"! I","!/":"!!r","#5":"!!s","!-":"! "}}}}},"___2":0},"! ":{"!":"BackGround","&":[]," ":false,"$":"! ","#":"!!m","'":["! K","! L","! M","! N","! O","! P","!!/","!!.","!!r","! I","!!s"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214840805,">":null,"?":0,"@":null,"A":930,"B":641,"C":[-465,-268.5,-465,-372.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false}},"___1":[81,0,3]},"! K":{"!":"Button","&":[]," ":true,"$":"! K","#":"! ","'":["!#0"],"%":{"W":{" ":true,"X":true,"Y":"! K","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[1,1,1,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214840804,">":null,"?":0,"@":null,"A":241,"B":67,"C":[-412.5,121.5,171.5,-188.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["numButton"],"S":{"!#":{" ":true,"P":{"!$":1}}}}},"___1":[84,0,3]},"!#0":{"!":"Text","&":[]," ":true,"$":"!#0","#":"! K","'":[],"%":{".":{"0":[0.5,0.5],"1":"Text","2":null,"3":214574678,"4":40,"5":8,"6":80,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":40,";":true,"(":1,"+":[0.79216,0.79216,0.79216],"<":1,"=":null,">":null,"?":0,"@":null,"A":200,"B":32,"C":[-100,-15.436,-100,-16.564],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[87,0,3]},"! L":{"!":"Button","&":[]," ":true,"$":"! L","#":"! ","'":["!#1"],"%":{"W":{" ":true,"X":true,"Y":"! L","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[1,1,1,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214840804,">":null,"?":0,"@":null,"A":241,"B":67,"C":[-117.5,121.5,-123.5,-188.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["numButton"],"S":{"!#":{" ":true,"P":{"!$":10}}}}},"___1":[90,0,3]},"!#1":{"!":"Text","&":[]," ":true,"$":"!#1","#":"! L","'":[],"%":{".":{"0":[0.5,0.5],"1":"Text","2":null,"3":214574678,"4":40,"5":8,"6":80,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":40,";":true,"(":1,"+":[0.79216,0.79216,0.79216],"<":1,"=":null,">":null,"?":0,"@":null,"A":200,"B":32,"C":[-100,-15.436,-100,-16.564],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[42,0,3]},"! M":{"!":"Button","&":[]," ":true,"$":"! M","#":"! ","'":["!#2"],"%":{"W":{" ":true,"X":true,"Y":"! M","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[1,1,1,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214840804,">":null,"?":0,"@":null,"A":241,"B":67,"C":[177.5,121.5,-418.5,-188.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["numButton"],"S":{"!#":{" ":true,"P":{"!$":100}}}}},"___1":[93,0,3]},"!#2":{"!":"Text","&":[]," ":true,"$":"!#2","#":"! M","'":[],"%":{".":{"0":[0.5,0.5],"1":"Text","2":null,"3":214574678,"4":40,"5":8,"6":80,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":40,";":true,"(":1,"+":[0.79216,0.79216,0.79216],"<":1,"=":null,">":null,"?":0,"@":null,"A":200,"B":32,"C":[-100,-15.436,-100,-16.564],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[42,0,3]},"! N":{"!":"Button","&":[]," ":true,"$":"! N","#":"! ","'":["!#3"],"%":{"W":{" ":true,"X":true,"Y":"! N","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[1,1,1,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214840804,">":null,"?":0,"@":null,"A":241,"B":67,"C":[-412.5,8.5,171.5,-75.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["numButton"],"S":{"!#":{" ":true,"P":{"!$":1000}}}}},"___1":[96,0,3]},"!#3":{"!":"Text","&":[]," ":true,"$":"!#3","#":"! N","'":[],"%":{".":{"0":[0.5,0.5],"1":"Text","2":null,"3":214574678,"4":40,"5":8,"6":80,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":40,";":true,"(":1,"+":[0.79216,0.79216,0.79216],"<":1,"=":null,">":null,"?":0,"@":null,"A":200,"B":32,"C":[-100,-15.436,-100,-16.564],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[99,0,3]},"! O":{"!":"Button","&":[]," ":true,"$":"! O","#":"! ","'":["!#4"],"%":{"W":{" ":true,"X":true,"Y":"! O","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[1,1,1,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214840804,">":null,"?":0,"@":null,"A":241,"B":67,"C":[-117.5,8.5,-123.5,-75.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["numButton"],"S":{"!#":{" ":true,"P":{"!$":10000}}}}},"___1":[102,0,3]},"!#4":{"!":"Text","&":[]," ":true,"$":"!#4","#":"! O","'":[],"%":{".":{"0":[0.5,0.5],"1":"Text","2":null,"3":214574678,"4":40,"5":8,"6":80,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":40,";":true,"(":1,"+":[0.79216,0.79216,0.79216],"<":1,"=":null,">":null,"?":0,"@":null,"A":200,"B":32,"C":[-100,-15.436,-100,-16.564],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[45,0,3]},"! P":{"!":"Button","&":[]," ":true,"$":"! P","#":"! ","'":["!#5"],"%":{"W":{" ":true,"X":true,"Y":"! P","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[1,1,1,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214840804,">":null,"?":0,"@":null,"A":241,"B":67,"C":[177.5,8.5,-418.5,-75.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["numButton"],"S":{"!#":{" ":true,"P":{"!$":100000}}}}},"___1":[105,0,3]},"!#5":{"!":"Text","&":[]," ":true,"$":"!#5","#":"! P","'":[],"%":{".":{"0":[0.5,0.5],"1":"+100,000","2":null,"3":214574678,"4":40,"5":8,"6":80,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":40,";":true,"(":1,"+":[0.79216,0.79216,0.79216],"<":1,"=":null,">":null,"?":0,"@":null,"A":200,"B":32,"C":[-100,-15.436,-100,-16.564],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[45,0,3]},"!!/":{"!":"CancelButton","&":[]," ":true,"$":"!!/","#":"! ","'":[],"%":{"W":{" ":true,"X":true,"Y":"!!/","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[1,1,1,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214840801,">":null,"?":0,"@":null,"A":283,"B":67,"C":[21.5,-251.5,-304.5,184.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false}},"___1":[108,0,3]},"!!.":{"!":"OkButton","&":[]," ":true,"$":"!!.","#":"! ","'":[],"%":{"W":{" ":true,"X":true,"Y":"!!.","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[1,1,1,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214840802,">":null,"?":0,"@":null,"A":283,"B":67,"C":[-302.5,-251.5,19.5,184.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false}},"___1":[111,0,3]},"!!p":{"!":"Multiplier","&":[]," ":true,"$":"!!p","#":"! 8","'":[],"%":{".":{"0":[0.5,0.5],"1":"1.5x","2":null,"3":214574678,"4":100,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":100,";":true,"(":1,"+":[0.2902,1,0],"<":1,"=":null,">":null,"?":0,"@":null,"A":207.24,"B":132.96,"C":[-86.35,-80.875,-86.35,-29.925],")":[0.5,0.5],"D":[0,0,0,1],"E":0.42,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[114,0,3]},"!#(":{"!":"BakcgourndCover","&":[]," ":true,"$":"!#(","#":"! #","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407949,">":null,"?":0,"@":null,"A":1000,"B":1600,"C":[-500,-800,-500,-800],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! I":{"!":"ClearButton","&":[]," ":true,"$":"! I","#":"! ","'":[],"%":{"W":{" ":true,"X":true,"Y":"! I","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[1,1,1,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":null,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214840803,">":null,"?":0,"@":null,"A":241,"B":68,"C":[178.5,-121,-419.5,53],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false}},"___1":[117,0,3]},"!!r":{"!":"BetAmount","&":[]," ":true,"$":"!!r","#":"! ","'":[],"%":{".":{"0":[1,0.5],"1":"0","2":null,"3":214574678,"4":60,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[1,0.5,1,0.5],":":60,";":true,"(":1,"+":[1,0.85098,0],"<":1,"=":null,">":null,"?":0,"@":null,"A":38.16,"B":52,"C":[-392.933,-125.308,354.773,58.828],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[120,0,3]},"!!s":{"!":"errorText","&":[]," ":true,"$":"!!s","#":"! ","'":[],"%":{".":{"0":[0.5,0.5],"1":"Not enough balance.","2":null,"3":214574678,"4":70,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":70,";":true,"(":1,"+":[1,0,0],"<":1,"=":null,">":null,"?":0,"@":null,"A":700,"B":65,"C":[0,245,0,-245],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[123,0,3]},"!!o":{"!":"BetAmount","&":[]," ":true,"$":"!!o","#":"!!(","'":[],"%":{".":{"0":[1,0.5],"1":"0","2":null,"3":214574678,"4":50,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[1,0.5,1,0.5],":":50,";":true,"(":1,"+":[0.96471,0.89804,0.47843],"<":1,"=":null,">":null,"?":0,"@":null,"A":25.44,"B":44.32,"C":[-411.8,5.3,380,-60.7],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[126,0,3]},"!!,":{"!":"Edit","&":[]," ":true,"$":"!!,","#":"!!(","'":[],"%":{"W":{" ":true,"X":true,"Y":"!!,","Z":[0,0,0,0],"[":0,"]":[1,1,1,1],"^":[1,1,1,1],"_":[0.78431,0.78431,0.78431,1],"`":0,"a":null,"b":0,"c":null,"d":0,"e":null,"f":0,"g":null,"h":null,"i":null},".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.78431,0.78431,0.78431],"<":1,"=":214407944,">":null,"?":0,"@":null,"A":146,"B":67,"C":[188,3.5,-334,-70.5],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":true,"M":null,"N":false,"*":[4],"O":false}},"___1":[129,0,3]},"!!n":{"!":"Profit","&":[]," ":true,"$":"!!n","#":"! 8","'":[],"%":{".":{"0":[0.5,0.5],"1":"+100","2":null,"3":214574678,"4":120,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[0.5,0.5,0.5,0.5],":":120,";":true,"(":1,"+":[1,0.8,0],"<":1,"=":null,">":null,"?":0,"@":null,"A":331.2,"B":166.2,"C":[-152.479,-203.394,-112.481,70.434],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[132,0,3]},"! 2":{"!":"Slot","&":[]," ":true,"$":"! 2","#":"! 0","'":["! 3","! 4","! 5","!#6"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":1000,"B":300,"C":[-490,-315.907,-510,15.907],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"l":{" ":true,"m":0,"n":false,"o":true,")":[0.5,0.5],"p":[0,0,0,0],"(":[-20,0],"q":0,"r":0,"s":false}},"___1":[135,0,3]},"! 3":{"!":"Element","&":[]," ":true,"$":"! 3","#":"! 2","'":["!!0","! Q"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":400,"C":[344,-50,-644,-350],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["gem"],"S":{"!%":{" ":true,"P":{"U":"! $","t":"! R","!&":"! S","!'":"! Q"}}}}},"j":158051543,"k":{"! 3":"46c38d3e-39d1-4629-8150-d7d70bee70d5","!!0":"9c014850-8148-4911-b636-54fdf9288fa4","! R":"b3c1047f-22ca-4dcf-a8b3-4217e96a3fe6","! S":"ed258efe-c13a-4a3e-b913-9585b6881aee","! $":"5009eb83-b71c-46c2-8e49-4502c110876a","! Q":"68e7f2b0-4289-4b01-bdeb-7a6136f5e78a","!!t":"5cf7f83a-e047-4815-88d9-ca79c1b2de55","!!u":"f1ba2a4d-0157-4f81-b0ef-0be35d506234","!!v":"0cbd6603-13ea-4629-b251-b3b7cbb39631"},"___1":[138,0,24]},"! S":{"!":"Gem","&":[]," ":true,"$":"! S","#":"! Q","'":["! $"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[-16,-16,-16,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["bounce"],"S":{"!(":{" ":true,"P":{"t":"! R"}}}}},"___2":0},"! $":{"!":"Back","&":[]," ":true,"$":"! $","#":"! S","'":["!!t","!!u","!!v"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407939,">":null,"?":0,"@":null,"A":348,"B":316,"C":[-174,-158,-174,-158],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"cover","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!0":{"!":"Bottom","&":[]," ":true,"$":"!!0","#":"! 3","'":["! R"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0,0.5,0],":":32,";":true,"(":1,"+":[1,1,1],"<":0,"=":158043149,">":null,"?":0,"@":null,"A":484,"B":202,"C":[-242,-101,-242,-101],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! R":{"!":"Shadow","&":[]," ":true,"$":"! R","#":"!!0","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407945,">":null,"?":0,"@":null,"A":294,"B":116,"C":[-147,-58,-147,-58],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! 4":{"!":"Element","&":[]," ":true,"$":"! 4","#":"! 2","'":["!!1","! T"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":400,"C":[344,-50,-644,-350],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["gem"],"S":{"!%":{" ":true,"P":{"U":"! %","t":"! U","!&":"! V","!'":"! T"}}}}},"j":158051543,"k":{"! 4":"46c38d3e-39d1-4629-8150-d7d70bee70d5","!!1":"9c014850-8148-4911-b636-54fdf9288fa4","! U":"b3c1047f-22ca-4dcf-a8b3-4217e96a3fe6","! V":"ed258efe-c13a-4a3e-b913-9585b6881aee","! %":"5009eb83-b71c-46c2-8e49-4502c110876a","! T":"68e7f2b0-4289-4b01-bdeb-7a6136f5e78a","!!w":"5cf7f83a-e047-4815-88d9-ca79c1b2de55","!!x":"f1ba2a4d-0157-4f81-b0ef-0be35d506234","!!y":"0cbd6603-13ea-4629-b251-b3b7cbb39631"},"___1":[141,0,24]},"!!1":{"!":"Bottom","&":[]," ":true,"$":"!!1","#":"! 4","'":["! U"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0,0.5,0],":":32,";":true,"(":1,"+":[1,1,1],"<":0,"=":158043149,">":null,"?":0,"@":null,"A":484,"B":202,"C":[-242,-101,-242,-101],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! U":{"!":"Shadow","&":[]," ":true,"$":"! U","#":"!!1","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407945,">":null,"?":0,"@":null,"A":294,"B":116,"C":[-147,-58,-147,-58],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! V":{"!":"Gem","&":[]," ":true,"$":"! V","#":"! T","'":["! %"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[-16,-16,-16,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["bounce"],"S":{"!(":{" ":true,"P":{"t":"! U"}}}}},"___2":0},"! %":{"!":"Back","&":[]," ":true,"$":"! %","#":"! V","'":["!!w","!!x","!!y"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407939,">":null,"?":0,"@":null,"A":348,"B":316,"C":[-174,-158,-174,-158],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"cover","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! 5":{"!":"Element","&":[]," ":true,"$":"! 5","#":"! 2","'":["!!2","! W"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":400,"C":[624,-50,-924,-350],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["gem"],"S":{"!%":{" ":true,"P":{"U":"! &","t":"! X","!&":"! Y","!'":"! W"}}}}},"j":158051543,"k":{"! 5":"46c38d3e-39d1-4629-8150-d7d70bee70d5","!!2":"9c014850-8148-4911-b636-54fdf9288fa4","! X":"b3c1047f-22ca-4dcf-a8b3-4217e96a3fe6","! Y":"ed258efe-c13a-4a3e-b913-9585b6881aee","! &":"5009eb83-b71c-46c2-8e49-4502c110876a","! W":"68e7f2b0-4289-4b01-bdeb-7a6136f5e78a","!!z":"5cf7f83a-e047-4815-88d9-ca79c1b2de55","!!{":"f1ba2a4d-0157-4f81-b0ef-0be35d506234","!!|":"0cbd6603-13ea-4629-b251-b3b7cbb39631"},"___1":[144,0,24]},"!!2":{"!":"Bottom","&":[]," ":true,"$":"!!2","#":"! 5","'":["! X"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0,0.5,0],":":32,";":true,"(":1,"+":[1,1,1],"<":0,"=":158043149,">":null,"?":0,"@":null,"A":484,"B":202,"C":[-242,-101,-242,-101],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! X":{"!":"Shadow","&":[]," ":true,"$":"! X","#":"!!2","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407945,">":null,"?":0,"@":null,"A":294,"B":116,"C":[-147,-58,-147,-58],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! Y":{"!":"Gem","&":[]," ":true,"$":"! Y","#":"! W","'":["! &"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[-16,-16,-16,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["bounce"],"S":{"!(":{" ":true,"P":{"t":"! X"}}}}},"___2":0},"! &":{"!":"Back","&":[]," ":true,"$":"! &","#":"! Y","'":["!!z","!!{","!!|"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407939,">":null,"?":0,"@":null,"A":348,"B":316,"C":[-174,-158,-174,-158],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"cover","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!'":{"!":"Slot","&":[]," ":true,"$":"!!'","#":"! 0","'":["! 6","! 7"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":1000,"B":300,"C":[-495.557,-542,-504.443,242],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"l":{" ":true,"m":0,"n":false,"o":true,")":[0.5,0.5],"p":[0,0,0,0],"(":[-15,0],"q":0,"r":0,"s":false}},"___1":[147,0,3]},"! 6":{"!":"Element","&":[]," ":true,"$":"! 6","#":"!!'","'":["!!3","! Z"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":400,"C":[344,-50,-644,-350],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["gem"],"S":{"!%":{" ":true,"P":{"U":"! '","t":"! [","!&":"! ]","!'":"! Z"}}}}},"j":158051543,"k":{"! 6":"46c38d3e-39d1-4629-8150-d7d70bee70d5","!!3":"9c014850-8148-4911-b636-54fdf9288fa4","! [":"b3c1047f-22ca-4dcf-a8b3-4217e96a3fe6","! ]":"ed258efe-c13a-4a3e-b913-9585b6881aee","! '":"5009eb83-b71c-46c2-8e49-4502c110876a","! Z":"68e7f2b0-4289-4b01-bdeb-7a6136f5e78a","!!}":"5cf7f83a-e047-4815-88d9-ca79c1b2de55","!!~":"f1ba2a4d-0157-4f81-b0ef-0be35d506234","!# ":"0cbd6603-13ea-4629-b251-b3b7cbb39631"},"___1":[150,0,24]},"!!3":{"!":"Bottom","&":[]," ":true,"$":"!!3","#":"! 6","'":["! ["],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0,0.5,0],":":32,";":true,"(":1,"+":[1,1,1],"<":0,"=":158043149,">":null,"?":0,"@":null,"A":484,"B":202,"C":[-242,-101,-242,-101],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! [":{"!":"Shadow","&":[]," ":true,"$":"! [","#":"!!3","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407945,">":null,"?":0,"@":null,"A":294,"B":116,"C":[-147,-58,-147,-58],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! ]":{"!":"Gem","&":[]," ":true,"$":"! ]","#":"! Z","'":["! '"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[-16,-16,-16,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["bounce"],"S":{"!(":{" ":true,"P":{"t":"! ["}}}}},"___2":0},"! '":{"!":"Back","&":[]," ":true,"$":"! '","#":"! ]","'":["!!}","!!~","!# "],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407939,">":null,"?":0,"@":null,"A":348,"B":316,"C":[-174,-158,-174,-158],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"cover","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! 7":{"!":"Element","&":[]," ":true,"$":"! 7","#":"!!'","'":["!!4","! ^"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":400,"C":[492.5,-50,-792.5,-350],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["gem"],"S":{"!%":{" ":true,"P":{"U":"! (","t":"! _","!&":"! `","!'":"! ^"}}}}},"j":158051543,"k":{"! 7":"46c38d3e-39d1-4629-8150-d7d70bee70d5","!!4":"9c014850-8148-4911-b636-54fdf9288fa4","! _":"b3c1047f-22ca-4dcf-a8b3-4217e96a3fe6","! `":"ed258efe-c13a-4a3e-b913-9585b6881aee","! (":"5009eb83-b71c-46c2-8e49-4502c110876a","! ^":"68e7f2b0-4289-4b01-bdeb-7a6136f5e78a","!#!":"5cf7f83a-e047-4815-88d9-ca79c1b2de55","!##":"f1ba2a4d-0157-4f81-b0ef-0be35d506234","!#$":"0cbd6603-13ea-4629-b251-b3b7cbb39631"},"___1":[153,0,24]},"!!4":{"!":"Bottom","&":[]," ":true,"$":"!!4","#":"! 7","'":["! _"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0,0.5,0],":":32,";":true,"(":1,"+":[1,1,1],"<":0,"=":158043149,">":null,"?":0,"@":null,"A":484,"B":202,"C":[-242,-101,-242,-101],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! _":{"!":"Shadow","&":[]," ":true,"$":"! _","#":"!!4","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407945,">":null,"?":0,"@":null,"A":294,"B":116,"C":[-147,-58,-147,-58],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! `":{"!":"Gem","&":[]," ":true,"$":"! `","#":"! ^","'":["! ("],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[-16,-16,-16,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["bounce"],"S":{"!(":{" ":true,"P":{"t":"! _"}}}}},"___2":0},"! (":{"!":"Back","&":[]," ":true,"$":"! (","#":"! `","'":["!#!","!##","!#$"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407939,">":null,"?":0,"@":null,"A":348,"B":316,"C":[-174,-158,-174,-158],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"cover","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! !":{"!":"HandRanking","&":[]," ":true,"$":"! !","#":"!!j","'":["! 9","! :","! ;","! <","! =","! >","! ?"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":500,"B":420,"C":[-318.406,-179.964,-181.594,-240.036],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"l":{" ":true,"m":1,"n":false,"o":true,")":[0,1],"p":[0,0,0,0],"(":[0,6],"q":0,"r":0,"s":false},"Q":{" ":true,"R":["handRankingController"],"S":{"#6":{" ":true,"P":{"|":["! ?","! >","! =","! <","! ;","! :","! 9"]}}}}},"___1":[156,0,3]},"! 9":{"!":"HandRanking","&":[]," ":true,"$":"! 9","#":"! !","'":["! @","!!5"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[0,359,-630,-421],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["handRanking"],"S":{"|":{" ":true,"P":{"}":["!!6","!!7","!!8","!!9","!!:"],"U":["! a","! b","! c","! d","! e"],"~":"! @","! ":"!!;","!!":"!!5"}}}}},"k":{"! 9":"b7994544-cc22-44b8-84a5-3e2ff9c40cf5","! @":"ce17a95e-9203-461a-9489-bcc168463252","! )":"ac0b5905-f06d-426f-bce0-7ec8a8b8bcc5","! a":"c523cddb-0df4-4ceb-a074-0915aa00fa47","!!;":"db40a9d5-4771-42ca-9f37-a6c332bcfc53","!!6":"b859c695-97fb-4cde-9595-7b7345f9bcf8","! b":"df02f698-fd5a-42e0-9e44-39d443455c50","!!7":"d5a9b7a7-728d-4423-8767-f3de4a1776bd","! c":"df495c59-d865-4dd6-902b-1d14f7ed40fd","!!8":"59a56431-62a2-4f01-a28c-ebd168de6515","! d":"fd010274-cbd5-4187-98ac-91954baeb83d","!!9":"b87e83c9-98c3-43ae-9542-9884db97dbe0","! e":"f7fbe189-2953-4b49-b3fe-54a0dd5e02c8","!!:":"7a1c0953-5a4c-44fe-977c-d6a0002f62c3","!!5":"820c557f-61c3-4bb5-b013-e45c036ae530"},"j":158484030,"___2":6},"! @":{"!":"Image","&":[]," ":true,"$":"! @","#":"! 9","'":["! )","!!;"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,1,1],":":32,";":true,"(":1,"+":[0.71373,0.54902,0.36863],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[0,0,0,0],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":9},"! :":{"!":"HandRanking","&":[]," ":true,"$":"! :","#":"! !","'":["! A","!!<"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[0,359,-630,-421],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["handRanking"],"S":{"|":{" ":true,"P":{"}":["!!=","!!>","!!?","!!@","!!A"],"U":["! f","! g","! h","! i","! j"],"~":"! A","! ":"!!B","!!":"!!<"}}}}},"j":158484030,"k":{"! :":"b7994544-cc22-44b8-84a5-3e2ff9c40cf5","! A":"ce17a95e-9203-461a-9489-bcc168463252","! *":"ac0b5905-f06d-426f-bce0-7ec8a8b8bcc5","! f":"c523cddb-0df4-4ceb-a074-0915aa00fa47","!!B":"db40a9d5-4771-42ca-9f37-a6c332bcfc53","!!=":"b859c695-97fb-4cde-9595-7b7345f9bcf8","! g":"df02f698-fd5a-42e0-9e44-39d443455c50","!!>":"d5a9b7a7-728d-4423-8767-f3de4a1776bd","! h":"df495c59-d865-4dd6-902b-1d14f7ed40fd","!!?":"59a56431-62a2-4f01-a28c-ebd168de6515","! i":"fd010274-cbd5-4187-98ac-91954baeb83d","!!@":"b87e83c9-98c3-43ae-9542-9884db97dbe0","! j":"f7fbe189-2953-4b49-b3fe-54a0dd5e02c8","!!A":"7a1c0953-5a4c-44fe-977c-d6a0002f62c3","!!<":"820c557f-61c3-4bb5-b013-e45c036ae530"},"___2":6},"! A":{"!":"Image","&":[]," ":true,"$":"! A","#":"! :","'":["! *","!!B"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,1,1],":":32,";":true,"(":1,"+":[0.71373,0.54902,0.36863],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[0,0,0,0],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":9},"! ;":{"!":"HandRanking","&":[]," ":true,"$":"! ;","#":"! !","'":["! B","!!C"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[0,359,-630,-421],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["handRanking"],"S":{"|":{" ":true,"P":{"}":["!!D","!!E","!!F","!!G","!!H"],"U":["! k","! l","! m","! n","! o"],"~":"! B","! ":"!!I","!!":"!!C"}}}}},"j":158484030,"k":{"! ;":"b7994544-cc22-44b8-84a5-3e2ff9c40cf5","! B":"ce17a95e-9203-461a-9489-bcc168463252","! +":"ac0b5905-f06d-426f-bce0-7ec8a8b8bcc5","! k":"c523cddb-0df4-4ceb-a074-0915aa00fa47","!!I":"db40a9d5-4771-42ca-9f37-a6c332bcfc53","!!D":"b859c695-97fb-4cde-9595-7b7345f9bcf8","! l":"df02f698-fd5a-42e0-9e44-39d443455c50","!!E":"d5a9b7a7-728d-4423-8767-f3de4a1776bd","! m":"df495c59-d865-4dd6-902b-1d14f7ed40fd","!!F":"59a56431-62a2-4f01-a28c-ebd168de6515","! n":"fd010274-cbd5-4187-98ac-91954baeb83d","!!G":"b87e83c9-98c3-43ae-9542-9884db97dbe0","! o":"f7fbe189-2953-4b49-b3fe-54a0dd5e02c8","!!H":"7a1c0953-5a4c-44fe-977c-d6a0002f62c3","!!C":"820c557f-61c3-4bb5-b013-e45c036ae530"},"___2":6},"! B":{"!":"Image","&":[]," ":true,"$":"! B","#":"! ;","'":["! +","!!I"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,1,1],":":32,";":true,"(":1,"+":[0.71373,0.54902,0.36863],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[0,0,0,0],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":9},"! <":{"!":"HandRanking","&":[]," ":true,"$":"! <","#":"! !","'":["! C","!!J"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[0,359,-630,-421],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["handRanking"],"S":{"|":{" ":true,"P":{"}":["!!K","!!L","!!M","!!N","!!O"],"U":["! p","! q","! r","! s","! t"],"~":"! C","! ":"!!P","!!":"!!J"}}}}},"j":158484030,"k":{"! <":"b7994544-cc22-44b8-84a5-3e2ff9c40cf5","! C":"ce17a95e-9203-461a-9489-bcc168463252","! ,":"ac0b5905-f06d-426f-bce0-7ec8a8b8bcc5","! p":"c523cddb-0df4-4ceb-a074-0915aa00fa47","!!P":"db40a9d5-4771-42ca-9f37-a6c332bcfc53","!!K":"b859c695-97fb-4cde-9595-7b7345f9bcf8","! q":"df02f698-fd5a-42e0-9e44-39d443455c50","!!L":"d5a9b7a7-728d-4423-8767-f3de4a1776bd","! r":"df495c59-d865-4dd6-902b-1d14f7ed40fd","!!M":"59a56431-62a2-4f01-a28c-ebd168de6515","! s":"fd010274-cbd5-4187-98ac-91954baeb83d","!!N":"b87e83c9-98c3-43ae-9542-9884db97dbe0","! t":"f7fbe189-2953-4b49-b3fe-54a0dd5e02c8","!!O":"7a1c0953-5a4c-44fe-977c-d6a0002f62c3","!!J":"820c557f-61c3-4bb5-b013-e45c036ae530"},"___2":6},"! C":{"!":"Image","&":[]," ":true,"$":"! C","#":"! <","'":["! ,","!!P"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,1,1],":":32,";":true,"(":1,"+":[0.71373,0.54902,0.36863],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[0,0,0,0],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":9},"! =":{"!":"HandRanking","&":[]," ":true,"$":"! =","#":"! !","'":["! D","!!Q"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[0,359,-630,-421],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["handRanking"],"S":{"|":{" ":true,"P":{"}":["!!R","!!S","!!T","!!U","!!V"],"U":["! u","! v","! w","! x","! y"],"~":"! D","! ":"!!W","!!":"!!Q"}}}}},"j":158484030,"k":{"! =":"b7994544-cc22-44b8-84a5-3e2ff9c40cf5","! D":"ce17a95e-9203-461a-9489-bcc168463252","! -":"ac0b5905-f06d-426f-bce0-7ec8a8b8bcc5","! u":"c523cddb-0df4-4ceb-a074-0915aa00fa47","!!W":"db40a9d5-4771-42ca-9f37-a6c332bcfc53","!!R":"b859c695-97fb-4cde-9595-7b7345f9bcf8","! v":"df02f698-fd5a-42e0-9e44-39d443455c50","!!S":"d5a9b7a7-728d-4423-8767-f3de4a1776bd","! w":"df495c59-d865-4dd6-902b-1d14f7ed40fd","!!T":"59a56431-62a2-4f01-a28c-ebd168de6515","! x":"fd010274-cbd5-4187-98ac-91954baeb83d","!!U":"b87e83c9-98c3-43ae-9542-9884db97dbe0","! y":"f7fbe189-2953-4b49-b3fe-54a0dd5e02c8","!!V":"7a1c0953-5a4c-44fe-977c-d6a0002f62c3","!!Q":"820c557f-61c3-4bb5-b013-e45c036ae530"},"___2":6},"! D":{"!":"Image","&":[]," ":true,"$":"! D","#":"! =","'":["! -","!!W"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,1,1],":":32,";":true,"(":1,"+":[0.71373,0.54902,0.36863],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[0,0,0,0],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":9},"! >":{"!":"HandRanking","&":[]," ":true,"$":"! >","#":"! !","'":["! E","!!X"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[0,359,-630,-421],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["handRanking"],"S":{"|":{" ":true,"P":{"}":["!!Y","!!Z","!![","!!]","!!^"],"U":["! z","! {","! |","! }","! ~"],"~":"! E","! ":"!!_","!!":"!!X"}}}}},"j":158484030,"k":{"! >":"b7994544-cc22-44b8-84a5-3e2ff9c40cf5","! E":"ce17a95e-9203-461a-9489-bcc168463252","! .":"ac0b5905-f06d-426f-bce0-7ec8a8b8bcc5","! z":"c523cddb-0df4-4ceb-a074-0915aa00fa47","!!_":"db40a9d5-4771-42ca-9f37-a6c332bcfc53","!!Y":"b859c695-97fb-4cde-9595-7b7345f9bcf8","! {":"df02f698-fd5a-42e0-9e44-39d443455c50","!!Z":"d5a9b7a7-728d-4423-8767-f3de4a1776bd","! |":"df495c59-d865-4dd6-902b-1d14f7ed40fd","!![":"59a56431-62a2-4f01-a28c-ebd168de6515","! }":"fd010274-cbd5-4187-98ac-91954baeb83d","!!]":"b87e83c9-98c3-43ae-9542-9884db97dbe0","! ~":"f7fbe189-2953-4b49-b3fe-54a0dd5e02c8","!!^":"7a1c0953-5a4c-44fe-977c-d6a0002f62c3","!!X":"820c557f-61c3-4bb5-b013-e45c036ae530"},"___2":6},"! E":{"!":"Image","&":[]," ":true,"$":"! E","#":"! >","'":["! .","!!_"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,1,1],":":32,";":true,"(":1,"+":[0.71373,0.54902,0.36863],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[0,0,0,0],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":9},"! ?":{"!":"HandRanking","&":[]," ":true,"$":"! ?","#":"! !","'":["! F","!!`"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[0,359,-630,-421],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["handRanking"],"S":{"|":{" ":true,"P":{"}":["!!a","!!b","!!c","!!d","!!e"],"U":["!! ","!!!","!!#","!!$","!!%"],"~":"! F","! ":"!!f","!!":"!!`"}}}}},"j":158484030,"k":{"! ?":"b7994544-cc22-44b8-84a5-3e2ff9c40cf5","! F":"ce17a95e-9203-461a-9489-bcc168463252","! /":"ac0b5905-f06d-426f-bce0-7ec8a8b8bcc5","!! ":"c523cddb-0df4-4ceb-a074-0915aa00fa47","!!f":"db40a9d5-4771-42ca-9f37-a6c332bcfc53","!!a":"b859c695-97fb-4cde-9595-7b7345f9bcf8","!!!":"df02f698-fd5a-42e0-9e44-39d443455c50","!!b":"d5a9b7a7-728d-4423-8767-f3de4a1776bd","!!#":"df495c59-d865-4dd6-902b-1d14f7ed40fd","!!c":"59a56431-62a2-4f01-a28c-ebd168de6515","!!$":"fd010274-cbd5-4187-98ac-91954baeb83d","!!d":"b87e83c9-98c3-43ae-9542-9884db97dbe0","!!%":"f7fbe189-2953-4b49-b3fe-54a0dd5e02c8","!!e":"7a1c0953-5a4c-44fe-977c-d6a0002f62c3","!!`":"820c557f-61c3-4bb5-b013-e45c036ae530"},"___2":6},"! F":{"!":"Image","&":[]," ":true,"$":"! F","#":"! ?","'":["! /","!!f"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,1,1],":":32,";":true,"(":1,"+":[0.71373,0.54902,0.36863],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[0,0,0,0],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":9},"!!j":{"!":"Image","&":[]," ":true,"$":"!!j","#":"! 0","'":["! !"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.59608,0.45098,0.28235],"<":1,"=":null,">":null,"?":0,"@":null,"A":650,"B":500,"C":[-325,-31.243,-325,-468.757],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[159,0,3]},"! )":{"!":"icon","&":[]," ":true,"$":"! )","#":"! @","'":["! a","! b","! c","! d","! e"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":32,"C":[-231.22,-16,-68.78,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"l":{" ":true,"m":0,"n":false,"o":true,")":[0,1],"p":[0,0,0,0],"(":[30,0],"q":0,"r":0,"s":false}},"___2":12},"!!;":{"!":"Text","&":[]," ":true,"$":"!!;","#":"! @","'":[],"%":{".":{"0":[1,0.5],"1":"50.00X","2":null,"3":214574678,"4":45,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[1,0.5,1,0.5],":":45,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":150.66,"B":49.86,"C":[-180.778,-28.977,30.118,-20.883],")":[0.5,0.5],"D":[0.58824,0.44706,0.2902,1],"E":1,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":15},"! a":{"!":"Back","&":[]," ":true,"$":"! a","#":"! )","'":["!!6"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[257.5,-3,-297.5,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":18},"! *":{"!":"icon","&":[]," ":true,"$":"! *","#":"! A","'":["! f","! g","! h","! i","! j"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":32,"C":[-231.22,-16,-68.78,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"l":{" ":true,"m":0,"n":false,"o":true,")":[0,1],"p":[0,0,0,0],"(":[30,0],"q":0,"r":0,"s":false}},"___2":12},"! f":{"!":"Back","&":[]," ":true,"$":"! f","#":"! *","'":["!!="],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[257.5,-3,-297.5,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":18},"!!B":{"!":"Text","&":[]," ":true,"$":"!!B","#":"! A","'":[],"%":{".":{"0":[1,0.5],"1":"50.00X","2":null,"3":214574678,"4":45,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[1,0.5,1,0.5],":":45,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":150.66,"B":49.86,"C":[-180.778,-28.977,30.118,-20.883],")":[0.5,0.5],"D":[0.58824,0.44706,0.2902,1],"E":1,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":15},"! +":{"!":"icon","&":[]," ":true,"$":"! +","#":"! B","'":["! k","! l","! m","! n","! o"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":32,"C":[-231.22,-16,-68.78,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"l":{" ":true,"m":0,"n":false,"o":true,")":[0,1],"p":[0,0,0,0],"(":[30,0],"q":0,"r":0,"s":false}},"___2":12},"! k":{"!":"Back","&":[]," ":true,"$":"! k","#":"! +","'":["!!D"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[257.5,-3,-297.5,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":18},"!!I":{"!":"Text","&":[]," ":true,"$":"!!I","#":"! B","'":[],"%":{".":{"0":[1,0.5],"1":"50.00X","2":null,"3":214574678,"4":45,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[1,0.5,1,0.5],":":45,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":150.66,"B":49.86,"C":[-180.778,-28.977,30.118,-20.883],")":[0.5,0.5],"D":[0.58824,0.44706,0.2902,1],"E":1,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":15},"! ,":{"!":"icon","&":[]," ":true,"$":"! ,","#":"! C","'":["! p","! q","! r","! s","! t"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":32,"C":[-231.22,-16,-68.78,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"l":{" ":true,"m":0,"n":false,"o":true,")":[0,1],"p":[0,0,0,0],"(":[30,0],"q":0,"r":0,"s":false}},"___2":12},"! p":{"!":"Back","&":[]," ":true,"$":"! p","#":"! ,","'":["!!K"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[257.5,-3,-297.5,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":18},"!!P":{"!":"Text","&":[]," ":true,"$":"!!P","#":"! C","'":[],"%":{".":{"0":[1,0.5],"1":"50.00X","2":null,"3":214574678,"4":45,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[1,0.5,1,0.5],":":45,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":150.66,"B":49.86,"C":[-180.778,-28.977,30.118,-20.883],")":[0.5,0.5],"D":[0.58824,0.44706,0.2902,1],"E":1,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":15},"! -":{"!":"icon","&":[]," ":true,"$":"! -","#":"! D","'":["! u","! v","! w","! x","! y"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":32,"C":[-231.22,-16,-68.78,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"l":{" ":true,"m":0,"n":false,"o":true,")":[0,1],"p":[0,0,0,0],"(":[30,0],"q":0,"r":0,"s":false}},"___2":12},"! u":{"!":"Back","&":[]," ":true,"$":"! u","#":"! -","'":["!!R"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[257.5,-3,-297.5,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":18},"!!W":{"!":"Text","&":[]," ":true,"$":"!!W","#":"! D","'":[],"%":{".":{"0":[1,0.5],"1":"50.00X","2":null,"3":214574678,"4":45,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[1,0.5,1,0.5],":":45,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":150.66,"B":49.86,"C":[-180.778,-28.977,30.118,-20.883],")":[0.5,0.5],"D":[0.58824,0.44706,0.2902,1],"E":1,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":15},"! .":{"!":"icon","&":[]," ":true,"$":"! .","#":"! E","'":["! z","! {","! |","! }","! ~"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":32,"C":[-231.22,-16,-68.78,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"l":{" ":true,"m":0,"n":false,"o":true,")":[0,1],"p":[0,0,0,0],"(":[30,0],"q":0,"r":0,"s":false}},"___2":12},"! z":{"!":"Back","&":[]," ":true,"$":"! z","#":"! .","'":["!!Y"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0.57647,0.57647,0.57647],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[257.5,-3,-297.5,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":18},"!!_":{"!":"Text","&":[]," ":true,"$":"!!_","#":"! E","'":[],"%":{".":{"0":[1,0.5],"1":"50.00X","2":null,"3":214574678,"4":45,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[1,0.5,1,0.5],":":45,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":150.66,"B":49.86,"C":[-180.778,-28.977,30.118,-20.883],")":[0.5,0.5],"D":[0.58824,0.44706,0.2902,1],"E":1,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":15},"! /":{"!":"icon","&":[]," ":true,"$":"! /","#":"! F","'":["!! ","!!!","!!#","!!$","!!%"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":300,"B":32,"C":[-231.22,-16,-68.78,-16],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"l":{" ":true,"m":0,"n":false,"o":true,")":[0,1],"p":[0,0,0,0],"(":[30,0],"q":0,"r":0,"s":false}},"___2":12},"!! ":{"!":"Back","&":[]," ":true,"$":"!! ","#":"! /","'":["!!a"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[257.5,-3,-297.5,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":18},"!!f":{"!":"Text","&":[]," ":true,"$":"!!f","#":"! F","'":[],"%":{".":{"0":[1,0.5],"1":"50.00X","2":null,"3":214574678,"4":45,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"text","/":[1,0.5,1,0.5],":":45,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":150.66,"B":49.86,"C":[-180.778,-28.977,30.118,-20.883],")":[0.5,0.5],"D":[0.58824,0.44706,0.2902,1],"E":1,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":true,"J":true,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":15},"!!6":{"!":"Front","&":[]," ":true,"$":"!!6","#":"! a","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.5451,0.21569,0.25098],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":44,"B":38,"C":[-22,-19,-22,-19],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! b":{"!":"Back","&":[]," ":true,"$":"! b","#":"! )","'":["!!7"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!7":{"!":"Front","&":[]," ":true,"$":"!!7","#":"! b","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! c":{"!":"Back","&":[]," ":true,"$":"! c","#":"! )","'":["!!8"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!8":{"!":"Front","&":[]," ":true,"$":"!!8","#":"! c","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! d":{"!":"Back","&":[]," ":true,"$":"! d","#":"! )","'":["!!9"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!9":{"!":"Front","&":[]," ":true,"$":"!!9","#":"! d","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! e":{"!":"Back","&":[]," ":true,"$":"! e","#":"! )","'":["!!:"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!:":{"!":"Front","&":[]," ":true,"$":"!!:","#":"! e","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!=":{"!":"Front","&":[]," ":true,"$":"!!=","#":"! f","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.5451,0.21569,0.25098],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":44,"B":38,"C":[-22,-19,-22,-19],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! g":{"!":"Back","&":[]," ":true,"$":"! g","#":"! *","'":["!!>"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!>":{"!":"Front","&":[]," ":true,"$":"!!>","#":"! g","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! h":{"!":"Back","&":[]," ":true,"$":"! h","#":"! *","'":["!!?"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!?":{"!":"Front","&":[]," ":true,"$":"!!?","#":"! h","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! i":{"!":"Back","&":[]," ":true,"$":"! i","#":"! *","'":["!!@"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!@":{"!":"Front","&":[]," ":true,"$":"!!@","#":"! i","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! j":{"!":"Back","&":[]," ":true,"$":"! j","#":"! *","'":["!!A"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!A":{"!":"Front","&":[]," ":true,"$":"!!A","#":"! j","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!D":{"!":"Front","&":[]," ":true,"$":"!!D","#":"! k","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.5451,0.21569,0.25098],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":44,"B":38,"C":[-22,-19,-22,-19],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! l":{"!":"Back","&":[]," ":true,"$":"! l","#":"! +","'":["!!E"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!E":{"!":"Front","&":[]," ":true,"$":"!!E","#":"! l","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! m":{"!":"Back","&":[]," ":true,"$":"! m","#":"! +","'":["!!F"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!F":{"!":"Front","&":[]," ":true,"$":"!!F","#":"! m","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! n":{"!":"Back","&":[]," ":true,"$":"! n","#":"! +","'":["!!G"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!G":{"!":"Front","&":[]," ":true,"$":"!!G","#":"! n","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! o":{"!":"Back","&":[]," ":true,"$":"! o","#":"! +","'":["!!H"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!H":{"!":"Front","&":[]," ":true,"$":"!!H","#":"! o","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!K":{"!":"Front","&":[]," ":true,"$":"!!K","#":"! p","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.5451,0.21569,0.25098],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":44,"B":38,"C":[-22,-19,-22,-19],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! q":{"!":"Back","&":[]," ":true,"$":"! q","#":"! ,","'":["!!L"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!L":{"!":"Front","&":[]," ":true,"$":"!!L","#":"! q","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! r":{"!":"Back","&":[]," ":true,"$":"! r","#":"! ,","'":["!!M"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!M":{"!":"Front","&":[]," ":true,"$":"!!M","#":"! r","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! s":{"!":"Back","&":[]," ":true,"$":"! s","#":"! ,","'":["!!N"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!N":{"!":"Front","&":[]," ":true,"$":"!!N","#":"! s","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! t":{"!":"Back","&":[]," ":true,"$":"! t","#":"! ,","'":["!!O"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!O":{"!":"Front","&":[]," ":true,"$":"!!O","#":"! t","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!R":{"!":"Front","&":[]," ":true,"$":"!!R","#":"! u","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.5451,0.21569,0.25098],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":44,"B":38,"C":[-22,-19,-22,-19],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! v":{"!":"Back","&":[]," ":true,"$":"! v","#":"! -","'":["!!S"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!S":{"!":"Front","&":[]," ":true,"$":"!!S","#":"! v","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! w":{"!":"Back","&":[]," ":true,"$":"! w","#":"! -","'":["!!T"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!T":{"!":"Front","&":[]," ":true,"$":"!!T","#":"! w","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! x":{"!":"Back","&":[]," ":true,"$":"! x","#":"! -","'":["!!U"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!U":{"!":"Front","&":[]," ":true,"$":"!!U","#":"! x","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! y":{"!":"Back","&":[]," ":true,"$":"! y","#":"! -","'":["!!V"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!V":{"!":"Front","&":[]," ":true,"$":"!!V","#":"! y","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!Y":{"!":"Front","&":[]," ":true,"$":"!!Y","#":"! z","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.5451,0.21569,0.25098],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":44,"B":38,"C":[-22,-19,-22,-19],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! {":{"!":"Back","&":[]," ":true,"$":"! {","#":"! .","'":["!!Z"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0.57647,0.57647,0.57647],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!Z":{"!":"Front","&":[]," ":false,"$":"!!Z","#":"! {","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! |":{"!":"Back","&":[]," ":true,"$":"! |","#":"! .","'":["!!["],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!![":{"!":"Front","&":[]," ":false,"$":"!![","#":"! |","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! }":{"!":"Back","&":[]," ":true,"$":"! }","#":"! .","'":["!!]"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!]":{"!":"Front","&":[]," ":false,"$":"!!]","#":"! }","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! ~":{"!":"Back","&":[]," ":true,"$":"! ~","#":"! .","'":["!!^"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!^":{"!":"Front","&":[]," ":false,"$":"!!^","#":"! ~","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!a":{"!":"Front","&":[]," ":true,"$":"!!a","#":"!! ","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0.5451,0.21569,0.25098],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":44,"B":38,"C":[-22,-19,-22,-19],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!!":{"!":"Back","&":[]," ":true,"$":"!!!","#":"! /","'":["!!b"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!b":{"!":"Front","&":[]," ":true,"$":"!!b","#":"!!!","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!#":{"!":"Back","&":[]," ":true,"$":"!!#","#":"! /","'":["!!c"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!c":{"!":"Front","&":[]," ":true,"$":"!!c","#":"!!#","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!$":{"!":"Back","&":[]," ":true,"$":"!!$","#":"! /","'":["!!d"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!d":{"!":"Front","&":[]," ":true,"$":"!!d","#":"!!$","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!%":{"!":"Back","&":[]," ":true,"$":"!!%","#":"! /","'":["!!e"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[0,0,0],"<":1,"=":158483931,">":null,"?":0,"@":null,"A":40,"B":35,"C":[280,-3,-320,-32],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":3},"!!e":{"!":"Front","&":[]," ":true,"$":"!!e","#":"!!%","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,0.95686,0],"<":1,"=":158483964,">":null,"?":0,"@":null,"A":41,"B":36,"C":[-20.5,-18,-20.5,-18],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!#7":{"!":"Image","&":[]," ":true,"$":"!#7","#":"!!k","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214410990,">":null,"?":0,"@":null,"A":700,"B":335,"C":[-350,-38.203,-350,-296.797],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[162,0,3]},"!!k":{"!":"frame","&":[]," ":true,"$":"!!k","#":"! 0","'":["!#7"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214410991,">":null,"?":0,"@":null,"A":721,"B":586,"C":[-360.5,-68.892,-360.5,-517.108],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[165,0,3]},"!!`":{"!":"Image","&":[]," ":true,"$":"!!`","#":"! ?","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0,0,0],"<":0.5,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[-315,-31,-315,-31],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!5":{"!":"Image","&":[]," ":true,"$":"!!5","#":"! 9","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0,0,0],"<":0.5,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[-315,-31,-315,-31],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!<":{"!":"Image","&":[]," ":true,"$":"!!<","#":"! :","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0,0,0],"<":0.5,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[-315,-31,-315,-31],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!C":{"!":"Image","&":[]," ":true,"$":"!!C","#":"! ;","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0,0,0],"<":0.5,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[-315,-31,-315,-31],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!J":{"!":"Image","&":[]," ":true,"$":"!!J","#":"! <","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0,0,0],"<":0.5,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[-315,-31,-315,-31],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!Q":{"!":"Image","&":[]," ":true,"$":"!!Q","#":"! =","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0,0,0],"<":0.5,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[-315,-31,-315,-31],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"!!X":{"!":"Image","&":[]," ":true,"$":"!!X","#":"! >","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[0,0,0],"<":0.5,"=":null,">":null,"?":0,"@":null,"A":630,"B":62,"C":[-315,-31,-315,-31],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___2":0},"! Q":{"!":"Group","&":[]," ":true,"$":"! Q","#":"! 3","'":["! S"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[11.48,-36,-43.48,4],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["fadeMove"],"S":{"!)":{" ":true,"P":{"!*":"! $","!+":60,"V":0.3,"!,":0.2}}}}},"___2":21},"! T":{"!":"Group","&":[]," ":true,"$":"! T","#":"! 4","'":["! V"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[11.48,-36,-43.48,4],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["fadeMove"],"S":{"!)":{" ":true,"P":{"!*":"! %","!+":60,"V":0.3,"!,":0.2}}}}},"___2":21},"! W":{"!":"Group","&":[]," ":true,"$":"! W","#":"! 5","'":["! Y"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[11.48,-36,-43.48,4],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["fadeMove"],"S":{"!)":{" ":true,"P":{"!*":"! &","!+":60,"V":0.3,"!,":0.2}}}}},"___2":21},"! Z":{"!":"Group","&":[]," ":true,"$":"! Z","#":"! 6","'":["! ]"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[11.48,-36,-43.48,4],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["fadeMove"],"S":{"!)":{" ":true,"P":{"!*":"! '","!+":60,"V":0.3,"!,":0.2}}}}},"___2":21},"! ^":{"!":"Group","&":[]," ":true,"$":"! ^","#":"! 7","'":["! `"],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"group","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[11.48,-36,-43.48,4],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["fadeMove"],"S":{"!)":{" ":true,"P":{"!*":"! (","!+":60,"V":0.3,"!,":0.2}}}}},"___2":21},"!#6":{"!":"Image","&":[]," ":true,"$":"!#6","#":"! 2","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0,0,0,0],":":32,";":true,"(":1,"+":[1,1,1],"<":0,"=":null,">":null,"?":0,"@":null,"A":32,"B":32,"C":[904,134,-936,-166],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false}},"___1":[168,0,3]},"!!}":{"!":"Image","&":[]," ":true,"$":"!!}","#":"! '","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[-15.936,-102.045,-19.064,67.045],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":24},"!!~":{"!":"Image","&":[]," ":true,"$":"!!~","#":"! '","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[-80.154,44.161,45.154,-79.161],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":27},"!!t":{"!":"Image","&":[]," ":true,"$":"!!t","#":"! $","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[-15.936,-102.045,-19.064,67.045],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":24},"!!u":{"!":"Image","&":[]," ":true,"$":"!!u","#":"! $","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[-80.154,44.161,45.154,-79.161],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":27},"!!w":{"!":"Image","&":[]," ":true,"$":"!!w","#":"! %","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[-15.936,-102.045,-19.064,67.045],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":24},"!!x":{"!":"Image","&":[]," ":true,"$":"!!x","#":"! %","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[-80.154,44.161,45.154,-79.161],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":27},"!!z":{"!":"Image","&":[]," ":true,"$":"!!z","#":"! &","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[-15.936,-102.045,-19.064,67.045],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":24},"!!{":{"!":"Image","&":[]," ":true,"$":"!!{","#":"! &","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[-80.154,44.161,45.154,-79.161],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":27},"!#!":{"!":"Image","&":[]," ":true,"$":"!#!","#":"! (","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[-15.936,-102.045,-19.064,67.045],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":24},"!##":{"!":"Image","&":[]," ":true,"$":"!##","#":"! (","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[-80.154,44.161,45.154,-79.161],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":27},"!!v":{"!":"Image","&":[]," ":true,"$":"!!v","#":"! $","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[67.202,41.338,-102.202,-76.338],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":30},"!!y":{"!":"Image","&":[]," ":true,"$":"!!y","#":"! %","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[67.202,41.338,-102.202,-76.338],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":30},"!!|":{"!":"Image","&":[]," ":true,"$":"!!|","#":"! &","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[67.202,41.338,-102.202,-76.338],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":30},"!# ":{"!":"Image","&":[]," ":true,"$":"!# ","#":"! '","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[67.202,41.338,-102.202,-76.338],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":30},"!#$":{"!":"Image","&":[]," ":true,"$":"!#$","#":"! (","'":[],"%":{".":{"0":[0.5,0.5],"1":"","2":null,"3":158042738,"4":32,"5":8,"6":32,"7":false,"8":false,"9":null," ":true,",":"image","/":[0.5,0.5,0.5,0.5],":":32,";":true,"(":1,"+":[1,1,1],"<":1,"=":214407935,">":null,"?":0,"@":null,"A":35,"B":35,"C":[67.202,41.338,-102.202,-76.338],")":[0.5,0.5],"D":[0,0,0,1],"E":0,"F":[0,0,0,1],"G":[0,0],"-":[0,0,1,1],"H":null,"I":false,"J":false,"K":"stretch","L":false,"M":null,"N":false,"*":[4],"O":false},"Q":{" ":true,"R":["particleEffect"],"S":{"T":{" ":true,"P":{}}}}},"___2":30}},"checkpoint_id":"695e5fb3-ae3c-4c9c-94c4-0f295a7fb450","id":1904849,"compressedFormat":{"fieldFirstCode":32,"fieldCodeBase":95,"fieldArray":["enabled","name",1,"parent","resource_id","components","tags","children","spacing","alignment","layers","color","type","rect","element","anchor","pivot","text","key","fontAsset","fontSize","minFontSize","maxFontSize","autoFitWidth","autoFitHeight","maxLines","lineHeight","wrapLines","opacity","textureAsset","spriteAsset","spriteFrame","pixelsPerUnit","width","height","margin","outlineColor","outlineThickness","shadowColor","shadowOffset","materialAsset","autoWidth","autoHeight","fitMode","useInput","batchGroupId","mask","enableMarkup","attributes","script","order","scripts","particleEffect","back","duration","button","active","imageEntity","hitPadding","transitionMode",1,"hoverTint","pressedTint","inactiveTint","fadeDuration","hoverSpriteAsset","hoverSpriteFrame","pressedSpriteAsset","pressedSpriteFrame","inactiveSpriteAsset","inactiveSpriteFrame","hoverTextureAsset","pressedTextureAsset","inactiveTextureAsset","template_id","template_ent_ids","layoutgroup","orientation","reverseX","reverseY","padding","widthFitting","heightFitting","wrap","shadow","volume","pitch","loop","autoPlay","overlap","asset","startTime","handRanking","front","background","ratioText","frontImage",1,"numButton","betAmount","gem","gemRoot","fade","bounce","fadeMove","target","moveDistance","duration2","betUi","clearButton","betAmountText","2","3","5","6","7","8","9","10","light","castShadows","isStatic","vsmBlurSize","shadowUpdateMode","normalOffsetBias","bakeArea","numCascades","outerConeAngle","bakeNumSamples","affectDynamic","intensity","bakeDir","cookieAngle","affectLightmapped","cookieChannel","innerConeAngle","shadowBias","bake","falloffMode","cookieAsset","vsmBias","cookieIntensity","cascadeDistribution","cookieOffset","shadowResolution","cookieScale","shape","range","vsmBlurMode","shadowDistance","cookieFalloff","shadowType","camera","projection","farClip",1,"clearColorBuffer","priority","fov","clearDepthBuffer","frustumCulling","clearColor","orthoHeight","nearClip","toneMapping","gammaCorrection","screen","screenSpace","scaleMode","scaleBlend","resolution","referenceResolution","userBalance","userBalanceText","userName","middle","resultText","boxButton","gemController","gems","bottom","startButton","winResult","loseResult","profit","betEditButton","multiplier","defaultStart","disableStart","defaultBet",1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"disableBet","dummyServer",null,"gameController","audioController","soundSource","audiolistener","sound","positional","refDistance","maxDistance","rollOffFactor","distanceModel","slots","soundButton","onImg","offImg","betController","betButton","okButton","cancelButton","errorText","handRankingController"],"singleVecs":[0,0,0,1,1,1,300,14.5,0,250,410,0,250,40,0,-81.22046,-0.00012,0,-30.118,-4.04794,0,16,16,0,0.5,0.5,0.5,27.48,-20,0,1.56405,-84.54498,0,-62.65435,61.66102,0,84.70186,58.83761,0,0,700,0,0,0.56365,0,0,0.56369,0,2,2,-2,45,135,0,4,3.5,4,-30,45,0,-475.14323,-35,0,0,12,0,0,91.35107,0,0.5,-93,0,0,89.89381,0,20,-20,0,-3.13499,6.2695,0,0,52,0,-291.99998,155,0,0.00002,0.56365,0,3,155,0,298,155,0,-291.99998,42,0,0.00002,0.56369,0,3,42,0,298,42,0,163,-218,0,-161,-218,0,0,-25.47521,0,299,-87,0,-354.773,-92.068,0,0,245,0,-380,33,0,261,37,0,-19.999,-136.91408,0,10,-165.907,0,214,150,0,494,150,0,774,150,0,4.4427,-391.99999,0,357.5,150,0,642.5,150,0,-68.406,30.03609,0,0,218.75711,0,0,129.29684,0,0,224.1081,0,920,150,0],"tripleVecs":[0,0,3,6,0,3,9,0,3,12,0,3,15,0,3,18,0,3,21,0,3,27,0,3,30,0,3,33,0,3,36,0,3]}} \ No newline at end of file diff --git a/GemQuest/__game-scripts.js b/GemQuest/__game-scripts.js new file mode 100644 index 0000000..5d19dfb --- /dev/null +++ b/GemQuest/__game-scripts.js @@ -0,0 +1 @@ +pc.extend(pc,function(){var TweenManager=function(t){this._app=t,this._tweens=[],this._add=[]};TweenManager.prototype={add:function(t){return this._add.push(t),t},update:function(t){for(var i=0,e=this._tweens.length;i-1||this._tweens.push(this._add[t]);this._add.length=0}}};var Tween=function(t,i,e){pc.events.attach(this),this.manager=i,e&&(this.entity=null),this.time=0,this.complete=!1,this.playing=!1,this.stopped=!0,this.pending=!1,this.target=t,this.duration=0,this._currentDelay=0,this.timeScale=1,this._reverse=!1,this._delay=0,this._yoyo=!1,this._count=0,this._numRepeats=0,this._repeatDelay=0,this._from=!1,this._slerp=!1,this._fromQuat=new pc.Quat,this._toQuat=new pc.Quat,this._quat=new pc.Quat,this.easing=pc.Linear,this._sv={},this._ev={}},_parseProperties=function(t){var i;return t instanceof pc.Vec2?i={x:t.x,y:t.y}:t instanceof pc.Vec3?i={x:t.x,y:t.y,z:t.z}:t instanceof pc.Vec4||t instanceof pc.Quat?i={x:t.x,y:t.y,z:t.z,w:t.w}:t instanceof pc.Color?(i={r:t.r,g:t.g,b:t.b},void 0!==t.a&&(i.a=t.a)):i=t,i};Tween.prototype={to:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this},from:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this._from=!0,this},rotate:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this._slerp=!0,this},start:function(){var t,i,e,s;if(this.playing=!0,this.complete=!1,this.stopped=!1,this._count=0,this.pending=this._delay>0,this._reverse&&!this.pending?this.time=this.duration:this.time=0,this._from){for(t in this._properties)this._properties.hasOwnProperty(t)&&(this._sv[t]=this._properties[t],this._ev[t]=this.target[t]);this._slerp&&(this._toQuat.setFromEulerAngles(this.target.x,this.target.y,this.target.z),i=void 0!==this._properties.x?this._properties.x:this.target.x,e=void 0!==this._properties.y?this._properties.y:this.target.y,s=void 0!==this._properties.z?this._properties.z:this.target.z,this._fromQuat.setFromEulerAngles(i,e,s))}else{for(t in this._properties)this._properties.hasOwnProperty(t)&&(this._sv[t]=this.target[t],this._ev[t]=this._properties[t]);this._slerp&&(i=void 0!==this._properties.x?this._properties.x:this.target.x,e=void 0!==this._properties.y?this._properties.y:this.target.y,s=void 0!==this._properties.z?this._properties.z:this.target.z,void 0!==this._properties.w?(this._fromQuat.copy(this.target),this._toQuat.set(i,e,s,this._properties.w)):(this._fromQuat.setFromEulerAngles(this.target.x,this.target.y,this.target.z),this._toQuat.setFromEulerAngles(i,e,s)))}return this._currentDelay=this._delay,this.manager.add(this),this},pause:function(){this.playing=!1},resume:function(){this.playing=!0},stop:function(){this.playing=!1,this.stopped=!0},delay:function(t){return this._delay=t,this.pending=!0,this},repeat:function(t,i){return this._count=0,this._numRepeats=t,this._repeatDelay=i||0,this},loop:function(t){return t?(this._count=0,this._numRepeats=1/0):this._numRepeats=0,this},yoyo:function(t){return this._yoyo=t,this},reverse:function(){return this._reverse=!this._reverse,this},chain:function(){for(var t=arguments.length;t--;)t>0?arguments[t-1]._chained=arguments[t]:this._chained=arguments[t];return this},onUpdate:function(t){return this.on("update",t),this},onComplete:function(t){return this.on("complete",t),this},onLoop:function(t){return this.on("loop",t),this},update:function(t){if(this.stopped)return!1;if(!this.playing)return!0;if(!this._reverse||this.pending?this.time+=t*this.timeScale:this.time-=t*this.timeScale,this.pending){if(!(this.time>this._currentDelay))return!0;this._reverse?this.time=this.duration-(this.time-this._currentDelay):this.time-=this._currentDelay,this.pending=!1}var i=0;(!this._reverse&&this.time>this.duration||this._reverse&&this.time<0)&&(this._count++,this.complete=!0,this.playing=!1,this._reverse?(i=this.duration-this.time,this.time=0):(i=this.time-this.duration,this.time=this.duration));var e,s,n=0===this.duration?1:this.time/this.duration,r=this.easing(n);for(var h in this._properties)this._properties.hasOwnProperty(h)&&(e=this._sv[h],s=this._ev[h],this.target[h]=e+(s-e)*r);if(this._slerp&&this._quat.slerp(this._fromQuat,this._toQuat,r),this.entity&&(this.entity._dirtifyLocal(),this.element&&this.entity.element&&(this.entity.element[this.element]=this.target),this._slerp&&this.entity.setLocalRotation(this._quat)),this.fire("update",t),this.complete){var o=this._repeat(i);return o?this.fire("loop"):(this.fire("complete",i),this.entity&&this.entity.off("destroy",this.stop,this),this._chained&&this._chained.start()),o}return!0},_repeat:function(t){if(this._count{this.setOpacityCascade(s.v)})).start()},pc.Entity.prototype.opacityTo=function(t,i,e){if(!this.element.material)return;let s={v:t};return this.setOpacity(t),this.tween(s).to({v:i},e,pc.SineOut).on("update",(()=>{this.setOpacity(s.v)})).start()},pc.Entity.prototype.setTextureFromURL=function(t){let i="t_"+t,e=pc.app.assets.find(i,"texture");if(null===e){pc.app.loader.getHandler("texture").crossOrigin="anonymous";var s=new pc.Asset(i,"texture",{url:t});pc.app.assets.add(s),s.on("load",(t=>{this.element.texture=t.resource})),pc.app.assets.load(s)}else this.element.texture=e.resource},pc.Entity.prototype.blink=function(t,i,e,s){for(let n=0;n{this.setOpacity(t)}),e*n*2),setTimeout((()=>{this.setOpacity(i)}),e*(2*n+1))};var t=pc.AppBase.getApplication();t&&t.addTweenManager()}();var UserBalance=pc.createScript("userBalance");UserBalance.attributes.add("userBalanceText",{type:"entity"}),UserBalance.attributes.add("userName",{type:"entity"}),UserBalance.prototype.initialize=function(){UserBalance.instance=this,this.userBalance=0},UserBalance.prototype.setUserName=function(e){this.userName.element.text=e},UserBalance.prototype.getUserBalance=function(){return this.userBalance},UserBalance.prototype.parseNumber=function(e){return Number(e.replace(/,/g,""))},UserBalance.prototype.setBalance=function(e){this.userBalance=e;let t={value:this.parseNumber(this.userBalanceText.element.text)},a=this.userBalanceText.element,n=this.entity.tween(t).to({value:e},.3,pc.Linear);n.on("update",(function(e){let n=parseFloat(t.value.toFixed(0)),r=getCommaText(n);a.text=`${r}`})),n.start()},UserBalance.prototype.update=function(e){};var DummyServer=pc.createScript("dummyServer");DummyServer.prototype.initialize=function(){DummyServer.instance=this,this.betAmount=-1,this.userBalance=0},DummyServer.prototype.login=async function(){return this.userBalance=getRandomInt(1e3,5e3),{id:"userName",balance:this.userBalance}},DummyServer.prototype.testCode=function(){let e=Array.from({length:40},((e,t)=>t+1)),t=shuffle(e).splice(0,10);console.log(e),console.log(t)},DummyServer.prototype.testCode=function(){let e=Array.from({length:40},((e,t)=>t+1)),t=shuffle(e).splice(0,10);console.log(e),console.log(t)},DummyServer.prototype.getResult=function(e){let t=e.filter((e=>e>=2)).sort(((e,t)=>t-e));if(0===t.length)return 0;if(1===t.length){if(2===t[0])return.1;if(3===t[0])return 3;if(4===t[0])return 5;if(5===t[0])return 50}else if(2===t.length){if(2===t[0])return 2;if(3===t[0])return 4}},DummyServer.prototype.startGame=function(e){if(e<0)return;let t=[],r=getDeck();t=shuffle(r).splice(0,5);let n=getMatchCount(t),l=this.getResult(n);this.userBalance=this.userBalance-e,this.betAmount=e;let o=l*e;this.userBalance=this.userBalance+o;let u={balance:this.userBalance,betAmount:this.betAmount,profit:o,multiplier:l,gems:t};return console.log(u),u};var GlobalFunction=pc.createScript("globalFunction");function getRandomInt(r,o){return r=Math.ceil(r),o=Math.floor(o),Math.floor(Math.random()*(o-r))+r}function changeTexture(r,o){r.element.texture=o.resource}function shuffle(r){var o,e,t;for(t=r.length-1;t>0;t--)o=Math.floor(Math.random()*(t+1)),e=r[t],r[t]=r[o],r[o]=e;return r}function getTable(r,o){let e=[];for(let t=0;t{o[r]++})),o}function getGemColor(r){switch(r){case 0:return rgbToColor(115,189,225,255);case 1:return rgbToColor(152,197,111,255);case 2:return rgbToColor(227,100,156,255);case 3:return rgbToColor(215,39,39,255);case 4:return rgbToColor(235,210,49,255);case 5:return rgbToColor(252,109,23,255);case 6:return rgbToColor(198,169,245,255);default:return rgbToColor(255,255,255,255)}}function setButton(r,o,e){r.element.on("touchend",o,e),r.element.on("mouseup",o,e)}function rgbToColor(r,o,e,t){return new pc.Color(r/255,o/255,e/255,t/255)}function getCommaText(r){return r.toLocaleString("en-US")}async function loadJsonFromUrl(n){return new Promise((e=>{this.loadJsonFromRemote(n,(function(n){console.log(n);let o=JSON.stringify(n),s=JSON.parse(o);e(s)}))}))}async function delay(n){return new Promise((e=>setTimeout((()=>{e(n)}),n)))}async function loadJsonFromRemote(n,e){var o=new XMLHttpRequest;o.addEventListener("load",(function(){e(JSON.parse(this.response))})),o.open("GET",n),o.send()}var Middle=pc.createScript("middle");Middle.attributes.add("boxButton",{type:"entity",array:!0}),Middle.attributes.add("resultText",{type:"entity"}),Middle.prototype.initialize=function(){Middle.instance=this,this.idleTimer=null,this.buttons=[],this.entity.forEach((t=>{"Button"===t.name&&this.buttons.push(t)})),this.selectedIdx=-1};var GameController=pc.createScript("gameController");GameController.prototype.initialize=function(){GameController.instance=this},GameController.prototype.postInitialize=function(){this.init(),this.setIdle(),GemController.instance.init(),HandRankingController.instance.init()},GameController.prototype.init=async function(){let e=await DummyServer.instance.login();UserBalance.instance.setBalance(e.balance),UserBalance.instance.setUserName(e.id)},GameController.prototype.betGame=async function(e){let n=DummyServer.instance.startGame(e);UserBalance.instance.setBalance(UserBalance.instance.getUserBalance()-e),GemController.instance.init(),HandRankingController.instance.init(),HandRankingController.instance.setMatch(0,0,0),await delay(500);for(let e=0;e{this.changeButtonState(this.startButton,!0)}),1e3)},Bottom.prototype.setBetAmount=function(t){let e=getCommaText(t);this.betAmountText.element.text=`${e}`,this.betAmount=t},Bottom.prototype.resetMultiplierColor=function(){ResultController.instance.resetColor(),this.disableButton(!1)},Bottom.prototype.setResultGame=async function(t,e,o){if(t){AudioController.instance.playSound("Win"),this.multiplier.element.text=`${e.toFixed(2)}x`;let t=getCommaText(o);this.profit.element.text=`+${t}`}else AudioController.instance.playSound("Lose");this.winResult.enabled=t,this.loseResult.enabled=!t,await delay(1500),this.winResult.enabled=!1,this.loseResult.enabled=!1},Bottom.prototype.betAmountErr=function(){var t=new pc.Color(246/255,229/255,122/255),e=this.entity.tween(t).yoyo(!0).repeat(4).to(new pc.Color(1,0,0),.2,pc.Linear);e.onUpdate((e=>{this.betAmountText.element.color=t})),e.start()};var AudioController=pc.createScript("audioController");AudioController.attributes.add("soundSource",{type:"entity"}),AudioController.prototype.initialize=function(){AudioController.instance=this,this.isMute=!0,this.soundSource.sound.volume=0},AudioController.prototype.setMute=function(o){this.isMute=o,this.isMute?this.soundSource.sound.volume=0:this.soundSource.sound.volume=.55},AudioController.prototype.playSound=function(o){if(!0===this.isMute)return;this.soundSource.sound.play(o)&&"string"==typeof o&&o.startsWith("s")&&o.length};var BetController=pc.createScript("betController");BetController.attributes.add("betUi",{type:"entity"}),BetController.attributes.add("betButton",{type:"entity",array:!0}),BetController.attributes.add("okButton",{type:"entity"}),BetController.attributes.add("cancelButton",{type:"entity"}),BetController.attributes.add("clearButton",{type:"entity"}),BetController.attributes.add("betAmountText",{type:"entity"}),BetController.attributes.add("errorText",{type:"entity"}),BetController.prototype.initialize=function(){BetController.instance=this,this.timer=null,this.betAmount=0,this.errorText.enabled=!1,setButton(this.cancelButton,this.onBetCancel,this),setButton(this.okButton,this.onBetOk,this),setButton(this.clearButton,this.onBetClear,this)},BetController.prototype.reset=function(){this.betAmount=0,this.updateText(),this.resetAllButton()},BetController.prototype.resetAllButton=function(){this.betButton.forEach((t=>t.element.color=new pc.Color(.5,.5,.5,1)))},BetController.prototype.betChange=function(t){let e=this.betAmount+t;return e>UserBalance.instance.getUserBalance()?(this.showErrorMsg(),!1):(this.errorText.enabled=!1,this.betAmount=e,this.updateText(),!0)},BetController.prototype.updateText=function(){let t=getCommaText(this.betAmount);this.betAmountText.element.text=`${t}`},BetController.prototype.onBetClear=function(){AudioController.instance.playSound("Click"),this.betAmount=0,this.updateText()},BetController.prototype.onBetOk=function(){AudioController.instance.playSound("Click"),this.betUi.enabled=!1,Bottom.instance.setBetAmount(this.betAmount)},BetController.prototype.onBetCancel=function(){AudioController.instance.playSound("Click"),this.betUi.enabled=!1},BetController.prototype.showErrorMsg=function(){this.errorText.enabled=!0,clearTimeout(this.timer),this.timer=setTimeout((()=>{this.errorText.enabled=!1}),1e3)};var NumButton=pc.createScript("numButton");NumButton.attributes.add("betAmount",{type:"number"}),NumButton.prototype.initialize=function(){let t=this.entity.children[0],n=this.betAmount,e=getCommaText(n);t.element.text=`+${e}`,setButton(this.entity,this.onClick,this)},NumButton.prototype.onClick=function(){AudioController.instance.playSound("Click");BetController.instance.betChange(this.betAmount)};var SoundButton=pc.createScript("soundButton");SoundButton.attributes.add("onImg",{type:"asset",assetType:"texture"}),SoundButton.attributes.add("offImg",{type:"asset",assetType:"texture"}),SoundButton.prototype.initialize=function(){SoundButton.instance=this,this.isMute=!0,this.setButton(this.entity,this.onClick)},SoundButton.prototype.onClick=function(){this.isMute=!this.isMute,changeTexture(this.entity,this.isMute?this.offImg:this.onImg),AudioController.instance.setMute(this.isMute),AudioController.instance.playSound("Click")},SoundButton.prototype.setButton=function(t,e){t.element.on("touchend",e,this),t.element.on("mouseup",e,this)};var Bounce=pc.createScript("bounce");Bounce.attributes.add("shadow",{type:"entity"}),Bounce.prototype.initialize=function(){this.onEnable(),this.entity.on("enable",this.onEnable,this)},Bounce.prototype.onEnable=function(){console.log("Bounce onEnable");var t={value:0};let e=getRandomInt(6,12)/10;var o=this.entity.tween(t).yoyo(!0).loop(!0).to({value:15},e,pc.Linear);o.onUpdate((e=>{this.entity.setLocalPosition(0,t.value,0),this.shadow.setLocalScale(1-t.value/100,1-t.value/100,1)})),o.start()};var HandRankingController=pc.createScript("handRankingController");HandRankingController.attributes.add("handRanking",{type:"entity",array:"true"}),HandRankingController.prototype.initialize=function(){HandRankingController.instance=this,this.handInfo=[[0,0,0],[2,0,.1],[2,2,2],[3,0,3],[3,2,4],[4,0,5],[5,0,50]]},HandRankingController.prototype.postInitialize=function(){let n=0;this.handInfo.forEach((t=>{this.handRanking[n].script.handRanking.initHandRanking(t[0],t[1],t[2]),n++}))},HandRankingController.prototype.init=function(){this.handRanking.forEach((n=>{n.script.handRanking.setDefault()}))},HandRankingController.prototype.setMatch=function(n,t,a){this.init(),this.handRanking[n].script.handRanking.setSelected(getGemColor(t),getGemColor(a))};var HandRanking=pc.createScript("handRanking");HandRanking.attributes.add("front",{type:"entity",array:"true"}),HandRanking.attributes.add("back",{type:"entity",array:"true"}),HandRanking.attributes.add("background",{type:"entity"}),HandRanking.attributes.add("ratioText",{type:"entity"}),HandRanking.attributes.add("frontImage",{type:"entity"}),HandRanking.prototype.initialize=function(){this.enableColor=rgbToColor(172,150,124,255),this.disableColor=rgbToColor(74,64,73,255),this.frontDisableColor=rgbToColor(161,122,76,255),this.frontEnableColor=rgbToColor(226,191,149,255),this.selectedColor=rgbToColor(176,200,151,255),this.unselectedColor=rgbToColor(81,81,81,255),this.fillCount=0,this.borderCount=0},HandRanking.prototype.initHandRanking=function(t,e,o){this.fillCount=t,this.borderCount=e,this.ratioText.element.text=`${o.toFixed(2)}x`,this.setDefault()},HandRanking.prototype.setDefault=function(){this.frontImage.enabled=!0;for(let t=0;t<5;++t)this.front[t].enabled=!1,this.back[t].element.color=this.disableColor;for(let t=0;t<5;++t)this.front[t].enabled=!0,this.front[t].element.color=this.frontDisableColor;let t=0;for(let e=0;e{t.script.gem.reset()})),this.gemTypes=[],this.prevColorArray=[]},GemController.prototype.setGem=function(t,e){this.gems[t].script.gem.setGem(e),this.updateMatch(e)},GemController.prototype.getMatchedIndex=function(){let t=getMatchCount(this.gemTypes).filter((t=>t>=2)).sort(((t,e)=>e-t)),e=0;return 0===t.length&&(e=0),1===t.length&&(2===t[0]&&(e=1),3===t[0]&&(e=3),4===t[0]&&(e=5),5===t[0]&&(e=6)),2===t.length&&(2===t[0]&&(e=2),3===t[0]&&(e=4)),e},GemController.prototype.getMatchedCount=function(t){let e=0;return this.gemTypes.forEach((r=>{r===t&&e++})),e},GemController.prototype.getMatchedColor=function(){let t=[];return this.gemTypes.forEach((e=>{let r=this.getMatchedCount(e);if(r>=2){let o=!1;t.forEach((t=>{t.type===e&&(o=!0)})),!1===o&&t.push({type:e,count:r})}})),t.sort(((t,e)=>e.count-t.count)),t},GemController.prototype.countGemType=function(t,e){return t.filter((t=>t===e)).length},GemController.prototype.updateMatch=function(t){let e=this.countGemType(this.gemTypes,t);AudioController.instance.playSound("s"+(e+1)),this.gemTypes.push(t);let r=this.getMatchedIndex(),o=this.getMatchedColor();HandRankingController.instance.setMatch(r,o.length>0?o[0].type:0,o.length>1?o[1].type:0),this.prevColorArray=o},GemController.prototype.getGem=function(t){let e;return e=0<=t&&t<=6?this.back[t]:this.back[0],{back:e}};var ParticleEffect=pc.createScript("particleEffect");ParticleEffect.prototype.initialize=function(){var t=this.entity.getLocalPosition();this.baseX=t.x,this.baseY=t.y,this.spawnParticle()},ParticleEffect.prototype.spawnParticle=function(){let t=.3*Math.random()+.5;if(!1===this.enabled)return void setTimeout((()=>{this.spawnParticle()}),1e3*(t+.5));var e={scale:0,opacity:0,rotation:0};let i=90*Math.random()-45,a=90*Math.random()-45;this.entity.setLocalPosition(this.baseX+i,this.baseY+a,0);this.entity.tween(e).yoyo(!1).loop(!1).to({scale:1,opacity:1},.3,pc.Linear).onUpdate((()=>{this.entity.setLocalScale(e.scale,e.scale,1),this.entity.element.opacity=e.opacity})).delay(t).start(),this.entity.tween(e).loop(!0).to({rotation:360},1.5,pc.Linear).onUpdate((()=>{this.entity.setLocalEulerAngles(0,0,e.rotation)})).start();setTimeout((()=>{this.entity.tween(e).yoyo(!1).loop(!1).to({scale:0,opacity:0},.3,pc.Linear).onUpdate((()=>{this.entity.setLocalScale(e.scale,e.scale,1),this.entity.element.opacity=e.opacity})).onComplete((()=>{setTimeout((()=>{this.spawnParticle()}),500*Math.random()+300)})).start()}),1e3*(t+.8))};var FadeMove=pc.createScript("fadeMove");FadeMove.attributes.add("target",{type:"entity",description:"Opacity를 조정할 엔티티"}),FadeMove.attributes.add("moveDistance",{type:"number",default:60,description:"이동 거리 (px)"}),FadeMove.attributes.add("duration",{type:"number",default:.5,description:"애니메이션 시간 (초)"}),FadeMove.attributes.add("duration2",{type:"number",default:.3,description:"애니메이션 시간 (초)"}),FadeMove.prototype.initialize=function(){this.target&&(this.originalPosition=this.target.getLocalPosition().clone(),this.target.element.opacity=1)},FadeMove.prototype.onEnable=function(){if(console.log("onEnable"),!this.target)return void console.warn("FadeMove: target이 설정되지 않았습니다.");let t=this.originalPosition.y+this.moveDistance,e=this.originalPosition.y;this.target.setLocalPosition(this.originalPosition.x,t,this.originalPosition.z),this.target.element&&(this.target.element.opacity=0),this.target.tween(this.target.getLocalPosition()).to({y:e},this.duration,pc.SineOut).start(),this.target.element&&this.target.tween(this.target.element).to({opacity:1},this.duration,pc.SineOut).start()},FadeMove.prototype.onDisable=function(){if(console.log("onDisable"),!this.target)return;let t=this.originalPosition.y+this.moveDistance;this.target.tween(this.target.getLocalPosition()).to({y:t},this.duration2,pc.SineIn).start(),this.target.element&&this.target.tween(this.target.element).to({opacity:0},this.duration2,pc.SineIn).start()}; \ No newline at end of file diff --git a/OneTwoThree/__loading__.js b/GemQuest/__loading__.js similarity index 100% rename from OneTwoThree/__loading__.js rename to GemQuest/__loading__.js diff --git a/GemQuest/__modules__.js b/GemQuest/__modules__.js new file mode 100644 index 0000000..3b7de4c --- /dev/null +++ b/GemQuest/__modules__.js @@ -0,0 +1,47 @@ +var loadModules = function (modules, urlPrefix, doneCallback) { // eslint-disable-line no-unused-vars + + if (typeof modules === "undefined" || modules.length === 0) { + // caller may depend on callback behaviour being async + setTimeout(doneCallback); + } else { + let remaining = modules.length; + const moduleLoaded = () => { + if (--remaining === 0) { + doneCallback(); + } + }; + + modules.forEach(function (m) { + pc.WasmModule.setConfig(m.moduleName, { + glueUrl: urlPrefix + m.glueUrl, + wasmUrl: urlPrefix + m.wasmUrl, + fallbackUrl: urlPrefix + m.fallbackUrl + }); + + if (!m.hasOwnProperty('preload') || m.preload) { + if (m.moduleName === 'BASIS') { + // preload basis transcoder + pc.basisInitialize(); + moduleLoaded(); + } else if (m.moduleName === 'DracoDecoderModule') { + // preload draco decoder + if (pc.dracoInitialize) { + // 1.63 onwards + pc.dracoInitialize(); + moduleLoaded(); + } else { + // 1.62 and earlier + pc.WasmModule.getInstance(m.moduleName, () => { moduleLoaded(); }); + } + } else { + // load remaining modules in global scope + pc.WasmModule.getInstance(m.moduleName, () => { moduleLoaded(); }); + } + } else { + moduleLoaded(); + } + }); + } +}; + +window.loadModules = loadModules; diff --git a/GemQuest/__settings__.js b/GemQuest/__settings__.js new file mode 100644 index 0000000..807d7df --- /dev/null +++ b/GemQuest/__settings__.js @@ -0,0 +1,22 @@ +window.ASSET_PREFIX = ""; +window.SCRIPT_PREFIX = ""; +window.SCENE_PATH = "1904849.json"; +window.CONTEXT_OPTIONS = { + 'antialias': true, + 'alpha': false, + 'preserveDrawingBuffer': false, + 'deviceTypes': [`webgl2`, `webgl1`], + 'powerPreference': "high-performance" +}; +window.SCRIPTS = [ 158042745, 158042730, 158042727, 158042737, 158042744, 158042709, 158042710, 158042756, 158042742, 158042739, 158042733, 158042731, 158050750, 158486655, 158486658, 159521138, 159521145, 214558249, 214858044 ]; +window.CONFIG_FILENAME = "config.json"; +window.INPUT_SETTINGS = { + useKeyboard: true, + useMouse: true, + useGamepads: false, + useTouch: true +}; +pc.script.legacy = false; +window.PRELOAD_MODULES = [ + {'moduleName' : 'BASIS', 'glueUrl' : 'files/assets/214864109/1/basis.wasm.js', 'wasmUrl' : 'files/assets/214864107/1/basis.wasm.wasm', 'fallbackUrl' : 'files/assets/214864108/1/basis.js', 'preload' : false}, +]; diff --git a/GemQuest/__start__.js b/GemQuest/__start__.js new file mode 100644 index 0000000..df83323 --- /dev/null +++ b/GemQuest/__start__.js @@ -0,0 +1,332 @@ +(function () { + // Shared Lib + var CANVAS_ID = 'application-canvas'; + + // Needed as we will have edge cases for particular versions of iOS + // returns null if not iOS + var getIosVersion = function () { + if (/iP(hone|od|ad)/.test(navigator.platform)) { + var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); + var version = [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)]; + return version; + } + + return null; + }; + + var lastWindowHeight = window.innerHeight; + var lastWindowWidth = window.innerWidth; + var windowSizeChangeIntervalHandler = null; + + var pcBootstrap = { + reflowHandler: null, + iosVersion: getIosVersion(), + + createCanvas: function () { + var canvas = document.createElement('canvas'); + canvas.setAttribute('id', CANVAS_ID); + canvas.setAttribute('tabindex', 0); + + // Disable I-bar cursor on click+drag + canvas.onselectstart = function () { return false; }; + + // Disable long-touch select on iOS devices + canvas.style['-webkit-user-select'] = 'none'; + + document.body.appendChild(canvas); + + return canvas; + }, + + + resizeCanvas: function (app, canvas) { + canvas.style.width = ''; + canvas.style.height = ''; + app.resizeCanvas(canvas.width, canvas.height); + + var fillMode = app._fillMode; + + if (fillMode === pc.FILLMODE_NONE || fillMode === pc.FILLMODE_KEEP_ASPECT) { + if ((fillMode === pc.FILLMODE_NONE && canvas.clientHeight < window.innerHeight) || (canvas.clientWidth / canvas.clientHeight >= window.innerWidth / window.innerHeight)) { + canvas.style.marginTop = Math.floor((window.innerHeight - canvas.clientHeight) / 2) + 'px'; + } else { + canvas.style.marginTop = ''; + } + } + + lastWindowHeight = window.innerHeight; + lastWindowWidth = window.innerWidth; + + // Work around when in landscape to work on iOS 12 otherwise + // the content is under the URL bar at the top + if (this.iosVersion && this.iosVersion[0] <= 12) { + window.scrollTo(0, 0); + } + }, + + reflow: function (app, canvas) { + this.resizeCanvas(app, canvas); + + // Poll for size changes as the window inner height can change after the resize event for iOS + // Have one tab only, and rotate from portrait -> landscape -> portrait + if (windowSizeChangeIntervalHandler === null) { + windowSizeChangeIntervalHandler = setInterval(function () { + if (lastWindowHeight !== window.innerHeight || lastWindowWidth !== window.innerWidth) { + this.resizeCanvas(app, canvas); + } + }.bind(this), 100); + + // Don't want to do this all the time so stop polling after some short time + setTimeout(function () { + if (!!windowSizeChangeIntervalHandler) { + clearInterval(windowSizeChangeIntervalHandler); + windowSizeChangeIntervalHandler = null; + } + }, 2000); + } + } + }; + + // Expose the reflow to users so that they can override the existing + // reflow logic if need be + window.pcBootstrap = pcBootstrap; +})(); + + +(function () { + // template varants + var LTC_MAT_1 = []; + var LTC_MAT_2 = []; + + // varants + var canvas = pcBootstrap.createCanvas(); + var app = new pc.AppBase(canvas); + + function initCSS() { + if (document.head.querySelector) { + // css media query for aspect ratio changes + // TODO: Change these from private properties + var css = `@media screen and (min-aspect-ratio: ${app._width}/${app._height}) { + #application-canvas.fill-mode-KEEP_ASPECT { + width: auto; + height: 100%; + margin: 0 auto; + } + }`; + document.head.querySelector('style').innerHTML += css; + } + + // Configure resolution and resize event + if (canvas.classList) { + canvas.classList.add(`fill-mode-${app.fillMode}`); + } + } + + function displayError(html) { + var div = document.createElement('div'); + div.innerHTML = ` + + + +
+
+
${html}
+
+
`; + document.body.appendChild(div); + } + + function createGraphicsDevice(callback) { + var deviceOptions = window.CONTEXT_OPTIONS ? window.CONTEXT_OPTIONS : {}; + + if (typeof window.Promise === 'function') { + var LEGACY_WEBGL = 'webgl'; + var deviceTypes = [...deviceOptions.deviceTypes, LEGACY_WEBGL]; + + var gpuLibPath = window.ASSET_PREFIX ? (window.ASSET_PREFIX.replace(/\/$/g, '') + '/') : ''; + + // new graphics device creation function with promises + var gfxOptions = { + deviceTypes: deviceTypes, + glslangUrl: gpuLibPath + 'glslang.js', + twgslUrl: gpuLibPath + 'twgsl.js', + powerPreference: deviceOptions.powerPreference, + antialias: deviceOptions.antialias !== false, + alpha: deviceOptions.alpha === true, + preserveDrawingBuffer: !!deviceOptions.preserveDrawingBuffer + }; + + pc.createGraphicsDevice(canvas, gfxOptions).then((device) => { + callback(device); + }).catch((e) => { + console.error('Device creation error:', e); + callback(null); + }) + } else { + var igl1 = deviceOptions.deviceTypes.indexOf('webgl1'); + var igl2 = deviceOptions.deviceTypes.indexOf('webgl2'); + + // old webgl graphics device creation + var options = { + powerPreference: deviceOptions.powerPreference, + antialias: deviceOptions.antialias !== false, + alpha: deviceOptions.transparentCanvas !== false, + preserveDrawingBuffer: !!deviceOptions.preserveDrawingBuffer, + preferWebGl2: igl2 > igl1 + }; + + if (pc.platform.browser && !!navigator.xr) { + options.xrCompatible = true; + } + + callback(new pc.WebglGraphicsDevice(canvas, options)); + } + } + + function initApp(device) { + try { + var createOptions = new pc.AppOptions(); + createOptions.graphicsDevice = device; + + createOptions.componentSystems = [ + pc.RigidBodyComponentSystem, + pc.CollisionComponentSystem, + pc.JointComponentSystem, + pc.AnimationComponentSystem, + pc.AnimComponentSystem, + pc.ModelComponentSystem, + pc.RenderComponentSystem, + pc.CameraComponentSystem, + pc.LightComponentSystem, + pc.script.legacy ? pc.ScriptLegacyComponentSystem : pc.ScriptComponentSystem, + pc.AudioSourceComponentSystem, + pc.SoundComponentSystem, + pc.AudioListenerComponentSystem, + pc.ParticleSystemComponentSystem, + pc.ScreenComponentSystem, + pc.ElementComponentSystem, + pc.ButtonComponentSystem, + pc.ScrollViewComponentSystem, + pc.ScrollbarComponentSystem, + pc.SpriteComponentSystem, + pc.LayoutGroupComponentSystem, + pc.LayoutChildComponentSystem, + pc.ZoneComponentSystem, + pc.GSplatComponentSystem, + ].filter(Boolean); + + createOptions.resourceHandlers = [ + pc.RenderHandler, + pc.AnimationHandler, + pc.AnimClipHandler, + pc.AnimStateGraphHandler, + pc.ModelHandler, + pc.MaterialHandler, + pc.TextureHandler, + pc.TextHandler, + pc.JsonHandler, + pc.AudioHandler, + pc.ScriptHandler, + pc.SceneHandler, + pc.CubemapHandler, + pc.HtmlHandler, + pc.CssHandler, + pc.ShaderHandler, + pc.HierarchyHandler, + pc.FolderHandler, + pc.FontHandler, + pc.BinaryHandler, + pc.TextureAtlasHandler, + pc.SpriteHandler, + pc.TemplateHandler, + pc.ContainerHandler, + pc.GSplatHandler + ].filter(Boolean); + + createOptions.elementInput = new pc.ElementInput(canvas, { + useMouse: INPUT_SETTINGS.useMouse, + useTouch: INPUT_SETTINGS.useTouch + }); + createOptions.keyboard = INPUT_SETTINGS.useKeyboard ? new pc.Keyboard(window) : null; + createOptions.mouse = INPUT_SETTINGS.useMouse ? new pc.Mouse(canvas) : null; + createOptions.gamepads = INPUT_SETTINGS.useGamepads ? new pc.GamePads() : null; + createOptions.touch = INPUT_SETTINGS.useTouch && pc.platform.touch ? new pc.TouchDevice(canvas) : null; + createOptions.assetPrefix = window.ASSET_PREFIX || ''; + createOptions.scriptPrefix = window.SCRIPT_PREFIX || ''; + createOptions.scriptsOrder = window.SCRIPTS || []; + createOptions.soundManager = new pc.SoundManager(); + createOptions.lightmapper = pc.Lightmapper; + createOptions.batchManager = pc.BatchManager; + createOptions.xr = pc.XrManager; + + app.init(createOptions); + return true; + + } catch (e) { + displayError('Could not initialize application. Error: ' + e); + console.error(e); + return false; + } + } + + function configure() { + app.configure(window.CONFIG_FILENAME, (err) => { + if (err) { + console.error(err); + return; + } + + initCSS(canvas, app._fillMode, app._width, app._height); + + if (LTC_MAT_1.length && LTC_MAT_2.length && app.setAreaLightLuts.length === 2) { + app.setAreaLightLuts(LTC_MAT_1, LTC_MAT_2); + } + + // do the first reflow after a timeout because of + // iOS showing a squished iframe sometimes + setTimeout(() => { + pcBootstrap.reflow(app, canvas); + pcBootstrap.reflowHandler = function () { + pcBootstrap.reflow(app, canvas); + }; + + window.addEventListener('resize', pcBootstrap.reflowHandler, false); + window.addEventListener('orientationchange', pcBootstrap.reflowHandler, false); + + app.preload(() => { + app.scenes.loadScene(window.SCENE_PATH, (err) => { + if (err) { + console.error(err); + return; + } + + app.start(); + }) + }) + }); + }); + } + + function main() { + createGraphicsDevice((device) => { + if (!device) { + return; + } + + if (!initApp(device)) { + return; + } + + if (window.PRELOAD_MODULES.length) { + loadModules(window.PRELOAD_MODULES, window.ASSET_PREFIX, () => { + configure(() => { + console.timeEnd('start'); + }); + }) + } else { + configure(); + } + }); + } + main(); +})(); // Add scope to avoid polluting window scope diff --git a/GemQuest/files/assets/158483931/1/Asset_3.png b/GemQuest/files/assets/158483931/1/Asset_3.png new file mode 100644 index 0000000..8c2be2e Binary files /dev/null and b/GemQuest/files/assets/158483931/1/Asset_3.png differ diff --git a/GemQuest/files/assets/158483964/1/Asset_2.png b/GemQuest/files/assets/158483964/1/Asset_2.png new file mode 100644 index 0000000..633c078 Binary files /dev/null and b/GemQuest/files/assets/158483964/1/Asset_2.png differ diff --git a/GemQuest/files/assets/214407930/1/GQ_BetButton_off.png b/GemQuest/files/assets/214407930/1/GQ_BetButton_off.png new file mode 100644 index 0000000..01a95a7 Binary files /dev/null and b/GemQuest/files/assets/214407930/1/GQ_BetButton_off.png differ diff --git a/GemQuest/files/assets/214407934/1/GQ_Gem_P.png b/GemQuest/files/assets/214407934/1/GQ_Gem_P.png new file mode 100644 index 0000000..6f0bb46 Binary files /dev/null and b/GemQuest/files/assets/214407934/1/GQ_Gem_P.png differ diff --git a/GemQuest/files/assets/214407935/1/UI_gem_twinkle.png b/GemQuest/files/assets/214407935/1/UI_gem_twinkle.png new file mode 100644 index 0000000..960eb12 Binary files /dev/null and b/GemQuest/files/assets/214407935/1/UI_gem_twinkle.png differ diff --git a/GemQuest/files/assets/214407936/1/GQ_Gem_G.png b/GemQuest/files/assets/214407936/1/GQ_Gem_G.png new file mode 100644 index 0000000..540f358 Binary files /dev/null and b/GemQuest/files/assets/214407936/1/GQ_Gem_G.png differ diff --git a/GemQuest/files/assets/214407939/1/GQ_Gem_B.png b/GemQuest/files/assets/214407939/1/GQ_Gem_B.png new file mode 100644 index 0000000..93712a7 Binary files /dev/null and b/GemQuest/files/assets/214407939/1/GQ_Gem_B.png differ diff --git a/GemQuest/files/assets/214407940/1/GQ_Gem_R.png b/GemQuest/files/assets/214407940/1/GQ_Gem_R.png new file mode 100644 index 0000000..e3eacc9 Binary files /dev/null and b/GemQuest/files/assets/214407940/1/GQ_Gem_R.png differ diff --git a/GemQuest/files/assets/214407941/1/GQ_Gem_Y.png b/GemQuest/files/assets/214407941/1/GQ_Gem_Y.png new file mode 100644 index 0000000..17169da Binary files /dev/null and b/GemQuest/files/assets/214407941/1/GQ_Gem_Y.png differ diff --git a/GemQuest/files/assets/214407943/1/GQ_speaker_off.png b/GemQuest/files/assets/214407943/1/GQ_speaker_off.png new file mode 100644 index 0000000..8ec9493 Binary files /dev/null and b/GemQuest/files/assets/214407943/1/GQ_speaker_off.png differ diff --git a/GemQuest/files/assets/214407944/1/GQ_BetButton_On.png b/GemQuest/files/assets/214407944/1/GQ_BetButton_On.png new file mode 100644 index 0000000..08b5cb6 Binary files /dev/null and b/GemQuest/files/assets/214407944/1/GQ_BetButton_On.png differ diff --git a/GemQuest/files/assets/214407945/1/GQ_Gem_shadow.png b/GemQuest/files/assets/214407945/1/GQ_Gem_shadow.png new file mode 100644 index 0000000..29b893d Binary files /dev/null and b/GemQuest/files/assets/214407945/1/GQ_Gem_shadow.png differ diff --git a/GemQuest/files/assets/214407946/1/GQ_speaker_On.png b/GemQuest/files/assets/214407946/1/GQ_speaker_On.png new file mode 100644 index 0000000..6b5a57f Binary files /dev/null and b/GemQuest/files/assets/214407946/1/GQ_speaker_On.png differ diff --git a/GemQuest/files/assets/214407949/1/GQ_back.png b/GemQuest/files/assets/214407949/1/GQ_back.png new file mode 100644 index 0000000..dfbaf96 Binary files /dev/null and b/GemQuest/files/assets/214407949/1/GQ_back.png differ diff --git a/GemQuest/files/assets/214410990/1/GQ_Screen_pros.png b/GemQuest/files/assets/214410990/1/GQ_Screen_pros.png new file mode 100644 index 0000000..5eb7701 Binary files /dev/null and b/GemQuest/files/assets/214410990/1/GQ_Screen_pros.png differ diff --git a/GemQuest/files/assets/214410991/1/GQ_Screen_frame.png b/GemQuest/files/assets/214410991/1/GQ_Screen_frame.png new file mode 100644 index 0000000..4f3975b Binary files /dev/null and b/GemQuest/files/assets/214410991/1/GQ_Screen_frame.png differ diff --git a/GemQuest/files/assets/214542950/1/GQ_StartButton_On.png b/GemQuest/files/assets/214542950/1/GQ_StartButton_On.png new file mode 100644 index 0000000..59cd2dd Binary files /dev/null and b/GemQuest/files/assets/214542950/1/GQ_StartButton_On.png differ diff --git a/GemQuest/files/assets/214542951/1/GQ_StartButton_off.png b/GemQuest/files/assets/214542951/1/GQ_StartButton_off.png new file mode 100644 index 0000000..632426e Binary files /dev/null and b/GemQuest/files/assets/214542951/1/GQ_StartButton_off.png differ diff --git a/GemQuest/files/assets/214543430/1/GQ_Gem_O.png b/GemQuest/files/assets/214543430/1/GQ_Gem_O.png new file mode 100644 index 0000000..3bf0778 Binary files /dev/null and b/GemQuest/files/assets/214543430/1/GQ_Gem_O.png differ diff --git a/GemQuest/files/assets/214574678/1/Lora-Bold.png b/GemQuest/files/assets/214574678/1/Lora-Bold.png new file mode 100644 index 0000000..e99bd9a Binary files /dev/null and b/GemQuest/files/assets/214574678/1/Lora-Bold.png differ diff --git a/GemQuest/files/assets/214705391/1/s1.wav b/GemQuest/files/assets/214705391/1/s1.wav new file mode 100644 index 0000000..24ef7c6 Binary files /dev/null and b/GemQuest/files/assets/214705391/1/s1.wav differ diff --git a/GemQuest/files/assets/214705392/1/s4.wav b/GemQuest/files/assets/214705392/1/s4.wav new file mode 100644 index 0000000..f144292 Binary files /dev/null and b/GemQuest/files/assets/214705392/1/s4.wav differ diff --git a/GemQuest/files/assets/214705393/1/win.wav b/GemQuest/files/assets/214705393/1/win.wav new file mode 100644 index 0000000..f5709fa Binary files /dev/null and b/GemQuest/files/assets/214705393/1/win.wav differ diff --git a/GemQuest/files/assets/214705394/1/s2.wav b/GemQuest/files/assets/214705394/1/s2.wav new file mode 100644 index 0000000..a870f06 Binary files /dev/null and b/GemQuest/files/assets/214705394/1/s2.wav differ diff --git a/GemQuest/files/assets/214705395/1/s5.wav b/GemQuest/files/assets/214705395/1/s5.wav new file mode 100644 index 0000000..d3bb14f Binary files /dev/null and b/GemQuest/files/assets/214705395/1/s5.wav differ diff --git a/GemQuest/files/assets/214705396/1/s3.wav b/GemQuest/files/assets/214705396/1/s3.wav new file mode 100644 index 0000000..5cf479d Binary files /dev/null and b/GemQuest/files/assets/214705396/1/s3.wav differ diff --git a/GemQuest/files/assets/214814960/1/click.wav b/GemQuest/files/assets/214814960/1/click.wav new file mode 100644 index 0000000..5e1f560 Binary files /dev/null and b/GemQuest/files/assets/214814960/1/click.wav differ diff --git a/GemQuest/files/assets/214816356/1/GQ_Gem_V.png b/GemQuest/files/assets/214816356/1/GQ_Gem_V.png new file mode 100644 index 0000000..a5fb264 Binary files /dev/null and b/GemQuest/files/assets/214816356/1/GQ_Gem_V.png differ diff --git a/GemQuest/files/assets/214840339/1/lose2.wav b/GemQuest/files/assets/214840339/1/lose2.wav new file mode 100644 index 0000000..f30bf93 Binary files /dev/null and b/GemQuest/files/assets/214840339/1/lose2.wav differ diff --git a/GemQuest/files/assets/214840801/1/betcart_cancel.png b/GemQuest/files/assets/214840801/1/betcart_cancel.png new file mode 100644 index 0000000..baff377 Binary files /dev/null and b/GemQuest/files/assets/214840801/1/betcart_cancel.png differ diff --git a/GemQuest/files/assets/214840802/1/betcart_ok.png b/GemQuest/files/assets/214840802/1/betcart_ok.png new file mode 100644 index 0000000..c432509 Binary files /dev/null and b/GemQuest/files/assets/214840802/1/betcart_ok.png differ diff --git a/GemQuest/files/assets/214840803/1/betcart_clear.png b/GemQuest/files/assets/214840803/1/betcart_clear.png new file mode 100644 index 0000000..f3c1128 Binary files /dev/null and b/GemQuest/files/assets/214840803/1/betcart_clear.png differ diff --git a/GemQuest/files/assets/214840804/1/betcart_money.png b/GemQuest/files/assets/214840804/1/betcart_money.png new file mode 100644 index 0000000..28828fb Binary files /dev/null and b/GemQuest/files/assets/214840804/1/betcart_money.png differ diff --git a/GemQuest/files/assets/214840805/1/betcart_back.png b/GemQuest/files/assets/214840805/1/betcart_back.png new file mode 100644 index 0000000..8480fef Binary files /dev/null and b/GemQuest/files/assets/214840805/1/betcart_back.png differ diff --git a/GemQuest/files/assets/214864107/1/basis.wasm.wasm b/GemQuest/files/assets/214864107/1/basis.wasm.wasm new file mode 100644 index 0000000..059befa Binary files /dev/null and b/GemQuest/files/assets/214864107/1/basis.wasm.wasm differ diff --git a/GemQuest/files/assets/214864108/1/basis.js b/GemQuest/files/assets/214864108/1/basis.js new file mode 100644 index 0000000..0e0a976 --- /dev/null +++ b/GemQuest/files/assets/214864108/1/basis.js @@ -0,0 +1,196 @@ + +var BASIS = (() => { + var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; + if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; + return ( +function(moduleArg = {}) { + +var Module=moduleArg; +var Promise=function(){function noop(){}function bind(fn,thisArg){return function(){fn.apply(thisArg,arguments)}}function Promise(fn){if(!(this instanceof Promise))throw new TypeError("Promises must be constructed via new");if(typeof fn!="function")throw new TypeError("not a function");this._state=0;this._handled=false;this._value=undefined;this._deferreds=[];doResolve(fn,this)}function handle(self,deferred){while(self._state===3)self=self._value;if(self._state===0){self._deferreds.push(deferred);return}self._handled= +true;Promise._immediateFn(function(){var cb=self._state===1?deferred.onFulfilled:deferred.onRejected;if(cb===null){(self._state===1?resolve:reject)(deferred.promise,self._value);return}var ret;try{ret=cb(self._value)}catch(e){reject(deferred.promise,e);return}resolve(deferred.promise,ret)})}function resolve(self,newValue){try{if(newValue===self)throw new TypeError("A promise cannot be resolved with itself.");if(newValue&&(typeof newValue=="object"||typeof newValue=="function")){var then=newValue.then; +if(newValue instanceof Promise){self._state=3;self._value=newValue;finale(self);return}else if(typeof then=="function"){doResolve(bind(then,newValue),self);return}}self._state=1;self._value=newValue;finale(self)}catch(e){reject(self,e)}}function reject(self,newValue){self._state=2;self._value=newValue;finale(self)}function finale(self){if(self._state===2&&self._deferreds.length===0)Promise._immediateFn(function(){if(!self._handled)Promise._unhandledRejectionFn(self._value)});for(var i=0,len=self._deferreds.length;i< +len;i++)handle(self,self._deferreds[i]);self._deferreds=null}function Handler(onFulfilled,onRejected,promise){this.onFulfilled=typeof onFulfilled=="function"?onFulfilled:null;this.onRejected=typeof onRejected=="function"?onRejected:null;this.promise=promise}function doResolve(fn,self){var done=false;try{fn(function(value){if(done)return;done=true;resolve(self,value)},function(reason){if(done)return;done=true;reject(self,reason)})}catch(ex){if(done)return;done=true;reject(self,ex)}}Promise.prototype["catch"]= +function(onRejected){return this.then(null,onRejected)};Promise.prototype.then=function(onFulfilled,onRejected){var prom=new this.constructor(noop);handle(this,new Handler(onFulfilled,onRejected,prom));return prom};Promise.all=function(arr){return new Promise(function(resolve,reject){if(!Array.isArray(arr))return reject(new TypeError("Promise.all accepts an array"));var args=Array.prototype.slice.call(arr);if(args.length===0)return resolve([]);var remaining=args.length;function res(i,val){try{if(val&& +(typeof val=="object"||typeof val=="function")){var then=val.then;if(typeof then=="function"){then.call(val,function(val){res(i,val)},reject);return}}args[i]=val;if(--remaining===0)resolve(args)}catch(ex){reject(ex)}}for(var i=0;i1)thisProgram=process.argv[1].replace(/\\/g,"/");arguments_=process.argv.slice(2);quit_=function(status,toThrow){process.exitCode=status;throw toThrow;};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_WEB|| +ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER)scriptDirectory=self.location.href;else if(typeof document!="undefined"&&document.currentScript)scriptDirectory=document.currentScript.src;if(_scriptDir)scriptDirectory=_scriptDir;if(scriptDirectory.indexOf("blob:")!==0)scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1);else scriptDirectory="";{read_=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}; +if(ENVIRONMENT_IS_WORKER)readBinary=function(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)};readAsync=function(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}}else;var out=Module["print"]||console.log.bind(console); +var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true; +var WebAssembly={Memory:function(opts){this.buffer=new ArrayBuffer(opts["initial"]*65536)},Module:function(binary){},Instance:function(module,info){this.exports=( +// EMSCRIPTEN_START_ASM +function instantiate(Pa){function c(d){d.set=function(a,b){this[a]=b};d.get=function(a){return this[a]};return d}var e;var f=new Uint8Array(123);for(var a=25;a>=0;--a){f[48+a]=52+a;f[65+a]=a;f[97+a]=26+a}f[43]=62;f[47]=63;function l(m,n,o){var g,h,a=0,i=n,j=o.length,k=n+(j*3>>2)-(o[j-2]=="=")-(o[j-1]=="=");for(;a>4;if(i>2;if(i>>0<9){o=m;break b}o=c;if((g|0)!=15){break b}o=m+7>>>3|0;x=-6}ra=L(c,d);ga=p?p:z;c:{if(!j){break c}if(l>>>0>15){break a}k=(L(k,192)+ga|0)+L(l,12)|0;Ca=k+24|0;l=F[k+28>>2];if(ra>>>0<=l>>>0){break c}if(I[k+32>>2]>>0){Wa(Ca,ra,(l+1|0)==(ra|0),4);l=F[k+28>>2]}Ta(F[Ca>>2]+(l<<2)|0,0,ra-l<<2);F[k+28>>2]=ra}if(!(f?e:1)){break a}k=F[a+172>>2];F[t+8>>2]=0;F[t>>2]=0;F[t+4>>2]=0;if(k){Wa(t,k,(k|0)==1,4);l=F[t+4>>2];Ta(F[t>>2]+(l<<2)|0,0,k-l<<2);F[t+4>>2]=k}F[t+12>>2]=k>>>1;d:{if((g&-2)==6){Qa=Ya(L(ra,12));if(!Qa){break d}yb=(ra<<3)+Qa|0}k=F[ga+4>>2];e:{if(k>>>0>=c>>>0){break e}if(I[ga+8>>2]>>0){Wa(ga,c,(k+1|0)==(c|0),4)}F[ga+4>>2]=c;k=F[ga+16>>2];if((k|0)==(c|0)){break e}if(!(c>>>0>>0|I[ga+20>>2]>=c>>>0)){Wa(ga+12|0,c,(k+1|0)==(c|0),4)}F[ga+16>>2]=c}k=F[a>>2];ja=k?k:a;if(!F[ja+8>>2]){break d}k=F[ja+20>>2];if(!k){break d}Na=1;f:{if(!d|!c){break f}R=e+f|0;ub=k+F[a+172>>2]|0;ma=o<<2;da=o<<1;vb=t+37|0;za=t+96|3;La=x>>>0<9?s?s:n:s;sa=La;Na=0;z=0;aa=2;while(1){f=B<<2;k=La-f|0;oa=(k|0)>=4?4:k;ha=(sa|0)>=4?4:sa;wa=L(o,B);xa=L(c,B);ca=L(f,o);Ma=B&1;Oa=L(Ma,12)+ga|0;wb=L(!Ma,12)+ga|0;V=o;J=0;while(1){g:{if(J&1){break g}if(Ma){K=G[(F[ga+12>>2]+(J<<2)|0)+2|0];break g}h:{if(Aa){Aa=Aa-1|0;break h}i:{if(z>>>0>15){break i}l=0;if(e>>>0>>0){l=G[e|0];e=e+1|0}f=z+8|0;C=l<>>0>7){z=f;break i}l=0;if(e>>>0>>0){l=G[e|0];e=e+1|0}z=z+16|0;C=l<>2]+((C&1023)<<2)>>2];j:{if((l|0)<0){f=F[a+52>>2];p=10;while(1){k=C>>>p|0;p=p+1|0;l=E[f+((k&1)+(l^-1)<<1)>>1];if((l|0)<0){continue}break}break j}p=l>>>16|0;l=l&65535}z=z-p|0;p=C>>>p|0;Aa=0;if((l|0)!=256){C=p;$=l;break h}if(!(z>>>0>4)){l=0;if(e>>>0>>0){l=G[e|0];e=e+1|0}p=l<>>5|0;k:{if(!(p&16)){e=f;break k}l:{if(z>>>0>4){e=f;break l}p=0;if(f>>>0>=R>>>0){e=f}else{p=G[f|0];e=f+1|0}C=p<>>5|0;l=C<<4&240|l;if(!(C&16)){C=p;break k}if(!(z>>>0>4)){k=0;if(e>>>0>>0){k=G[e|0];e=e+1|0}p=k<>>5|0;l=p<<8&3840|l;if(!(p&16)){e=m;break k}m:{if(z>>>0>4){e=m;break m}p=0;if(m>>>0>=R>>>0){e=m}else{p=G[m|0];e=m+1|0}C=p<>>5|0;l=C<<12&61440|l;if(!(C&16)){C=p;break k}if(!(z>>>0>4)){k=0;if(e>>>0>>0){k=G[e|0];e=e+1|0}p=k<>>5|0;l=p<<16&983040|l;if(!(p&16)){e=m;break k}n:{if(z>>>0>4){e=m;break n}p=0;if(m>>>0>=R>>>0){e=m}else{p=G[m|0];e=m+1|0}C=p<>>5|0;l=C<<20&15728640|l;if(!(C&16)){C=p;break k}if(!(z>>>0>4)){s=0;if(e>>>0>>0){s=G[e|0];e=e+1|0}p=s<>>5|0;l=p<<24&251658240|l;if(!(p&16)){e=m;C=f;break k}o:{if(z>>>0>4){e=m;break o}s=0;if(m>>>0>=R>>>0){e=m}else{s=G[m|0];e=m+1|0}f=s<>>5|0;l=f<<28|l}Aa=l+2|0}D[(F[ga+12>>2]+(J<<2)|0)+2|0]=$>>>4;K=$}p:{q:{r:{s:{t:{u:{v:{w:{x:{y:{z:{A:{B:{C:{D:{E:{F:{G:{H:{I:{J:{K:{L:{M:{N:{O:{P:{Q:{R:{S:{k=K&3;switch(k|0){case 0:break N;case 1:break R;case 2:break S;default:break P}}if(!j){if(!B|!J){break J}p=J-1|0;break Q}f=F[F[Ca>>2]+(J+xa<<2)>>2];ta=f&65535;p=f>>>16|0;break O}p=J;if(!B){break J}}ta=H[F[wb>>2]+(p<<2)>>1];break M}T:{if(z>>>0>15){break T}l=0;if(e>>>0>>0){l=G[e|0];e=e+1|0}f=z+8|0;C=l<>>0>7){z=f;break T}l=0;if(e>>>0>>0){l=G[e|0];e=e+1|0}z=z+16|0;C=l<>2]+((C&1023)<<2)>>2];U:{if((f|0)<0){m=F[a+88>>2];l=10;while(1){n=C>>>l|0;l=l+1|0;f=E[m+((n&1)+(f^-1)<<1)>>1];if((f|0)<0){continue}break}break U}l=f>>>16|0;f=f&65535}f=f+ta|0;m=F[ja+8>>2];ta=f-(f>>>0>=m>>>0?m:0)|0;z=z-l|0;C=C>>>l|0;p=0}E[F[Oa>>2]+(J<<2)>>1]=ta;if((k|0)!=2){break L}if(j){break K}break L}if(!J){break J}}E[F[Oa>>2]+(J<<2)>>1]=ta}V:{W:{if(va){va=va-1|0;break W}X:{if(z>>>0>15){break X}l=0;if(e>>>0>>0){l=G[e|0];e=e+1|0}f=z+8|0;C=l<>>0>7){z=f;break X}l=0;if(e>>>0>>0){l=G[e|0];e=e+1|0}z=z+16|0;C=l<>2]+((C&1023)<<2)>>2];Y:{if((p|0)<0){f=F[a+124>>2];l=10;while(1){k=C>>>l|0;l=l+1|0;p=E[f+((k&1)+(p^-1)<<1)>>1];if((p|0)<0){continue}break}break Y}l=p>>>16|0;p=p&65535}z=z-l|0;C=C>>>l|0;if((p|0)==(ub|0)){Z:{if(z>>>0>15){break Z}l=0;if(e>>>0>>0){l=G[e|0];e=e+1|0}f=z+8|0;C=l<>>0>7){z=f;break Z}l=0;if(e>>>0>>0){l=G[e|0];e=e+1|0}z=z+16|0;C=l<>2]+((C&1023)<<2)>>2];_:{if((l|0)<0){f=F[a+160>>2];p=10;while(1){k=C>>>p|0;p=p+1|0;l=E[f+((k&1)+(l^-1)<<1)>>1];if((l|0)<0){continue}break}break _}p=l>>>16|0;l=l&65535}z=z-p|0;C=C>>>p|0;m=C;$:{if((l|0)!=63){break $}aa:{if(z>>>0>7){m=e;f=z;break aa}p=0;if(e>>>0>>0){p=G[e|0];e=e+1|0}m=e;C=p<>>8|0;if(!(C&128)){e=m;m=p;break $}ba:{if(z>>>0>7){e=m;f=z;break ba}k=0;if(m>>>0>=R>>>0){e=m}else{k=G[m|0];e=m+1|0}p=k<>>8|0;m=C;if(!(p&128)){break $}ca:{if(z>>>0>7){f=z;break ca}p=0;if(e>>>0>>0){p=G[e|0];e=e+1|0}C=p<>>8|0;l=C<<14&2080768|l;if(!(C&128)){e=m;m=p;break $}da:{if(z>>>0>7){k=m;f=z;break da}s=0;if(m>>>0>=R>>>0){k=m}else{s=G[m|0];k=m+1|0}p=s<>>8|0;l=p<<21&266338304|l;if(!(p&128)){e=k;break $}ea:{if(z>>>0>7){e=k;f=z;break ea}p=0;if(k>>>0>=R>>>0){e=k}else{p=G[k|0];e=k+1|0}m=p<>>8|0}C=m;if(l+3>>>0>ra>>>0){break J}va=l+2|0;break W}va=0;l=F[ja+20>>2];if((p|0)>=(l|0)){break V}if(!F[a+172>>2]){break K}k=F[t+12>>2];f=k+1|0;F[t+12>>2]=f;F[F[t>>2]+(k<<2)>>2]=p;if((f|0)!=F[t+4>>2]){break K}F[t+12>>2]=f>>>1;break K}p=F[ja+20>>2];l=p}f=p-l|0;if((f|0)>=F[t+4>>2]){break J}k=(l|0)==(p|0);l=F[t>>2];m=l+(f<<2)|0;p=F[m>>2];if(k){break K}f=l+(f<<1&-4)|0;k=F[f>>2];F[f>>2]=p;F[m>>2]=k}if(I[ja+8>>2]<=ta>>>0|I[ja+20>>2]<=p>>>0){break J}if(j){F[F[Ca>>2]+(J+xa<<2)>>2]=p<<16|ta}m=(V|0)>=4?4:V;n=F[ja+16>>2];v=n+L(p,11)|0;s=F[ja+4>>2];u=s+(ta<<3)|0;fa:{switch(g|0){case 24:case 25:break fa;case 22:break q;case 21:break r;case 20:break t;case 17:break u;case 16:break v;case 26:break w;case 13:break x;case 12:break y;case 11:break z;case 28:break A;case 27:break B;case 18:break C;case 7:break D;case 6:break E;case 4:break F;case 2:break G;case 0:break H;case 23:break I;default:break p}}k=G[u+4|0]<<4;s=F[k+12764>>2];f=G[u+1|0];l=(f<<3|f>>>2)&255;f=s+l|0;x=(f|0)>=255?255:f;n=G[u|0];n=(n<<3|n>>>2)&255;p=n+s|0;w=(p|0)>=255?255:p;y=s;s=G[u+2|0];s=(s<<3|s>>>2)&255;u=y+s|0;y=(u|0)>=255?255:u;f=L((f>>>0<256?f:(x|0)>0?x:0)&255,63)+128|0;A=(f>>>8|0)+f>>>3&8160;p=p>>>0<256?p:(w|0)>0?w:0;u=u>>>0<256?u:(y|0)>0?y:0;f=(g|0)==24;x=L((f?p:u)&255,31)+128|0;p=L((f?u:p)&255,31)+128|0;E[t+38>>1]=A|(x>>>8|0)+x<<3&63488|(p>>>8|0)+p>>>8;x=F[k+12760>>2];p=x+l|0;w=(p|0)>=255?255:p;u=n+x|0;y=(u|0)>=255?255:u;x=s+x|0;O=(x|0)>=255?255:x;p=L((p>>>0<256?p:(w|0)>0?w:0)&255,63)+128|0;A=(p>>>8|0)+p>>>3&8160;p=u>>>0<256?u:(y|0)>0?y:0;u=x>>>0<256?x:(O|0)>0?O:0;x=L((f?p:u)&255,31)+128|0;p=L((f?u:p)&255,31)+128|0;E[t+36>>1]=A|(x>>>8|0)+x<<3&63488|(p>>>8|0)+p>>>8;x=F[k+12756>>2];p=x+l|0;w=(p|0)>=255?255:p;u=n+x|0;y=(u|0)>=255?255:u;x=s+x|0;O=(x|0)>=255?255:x;p=L((p>>>0<256?p:(w|0)>0?w:0)&255,63)+128|0;A=(p>>>8|0)+p>>>3&8160;p=u>>>0<256?u:(y|0)>0?y:0;u=x>>>0<256?x:(O|0)>0?O:0;x=L((f?p:u)&255,31)+128|0;p=L((f?u:p)&255,31)+128|0;E[t+34>>1]=A|(x>>>8|0)+x<<3&63488|(p>>>8|0)+p>>>8;p=F[k+12752>>2];k=p+n|0;u=(k|0)>=255?255:k;n=p+s|0;s=(n|0)>=255?255:n;l=l+p|0;p=(l|0)>=255?255:l;k=k>>>0<256?k:(u|0)>0?u:0;n=n>>>0<256?n:(s|0)>0?s:0;s=L((f?k:n)&255,31)+128|0;f=L((f?n:k)&255,31)+128|0;k=(s>>>8|0)+s<<3&63488|(f>>>8|0)+f>>>8;f=L((l>>>0<256?l:(p|0)>0?p:0)&255,63)+128|0;E[t+32>>1]=k|(f>>>8|0)+f>>>3&8160;if(!oa){break p}f=J<<2;k=o-f|0;n=(k|0)>=4?4:k;u=m&-2;w=m&1;f=(f+ca<<1)+b|0;x=0;while(1){ga:{if(!n){break ga}k=G[v+x|0];p=0;s=0;if((m|0)!=1){while(1){l=p<<1;E[l+f>>1]=H[(t+32|0)+((k>>>l&3)<<1)>>1];l=l|2;E[l+f>>1]=H[(t+32|0)+((k>>>l&3)<<1)>>1];p=p+2|0;s=s+2|0;if((u|0)!=(s|0)){continue}break}}if(!w){break ga}l=p<<1;E[l+f>>1]=H[(t+32|0)+((k>>>l&3)<<1)>>1]}f=f+da|0;x=x+1|0;if((ha|0)!=(x|0)){continue}break}break p}if(!Qa){break f}Ra(Qa);break f}k=G[u+1|0];k=k<<3|k>>>2;f=G[u+4|0]<<4;l=k+F[f+12764>>2]|0;n=(l|0)>=255?255:l;F[t+44>>2]=l>>>0<256?l:(n|0)>0?n:0;l=k+F[f+12760>>2]|0;n=(l|0)>=255?255:l;F[t+40>>2]=l>>>0<256?l:(n|0)>0?n:0;l=k+F[f+12756>>2]|0;n=(l|0)>=255?255:l;F[t+36>>2]=l>>>0<256?l:(n|0)>0?n:0;f=k+F[f+12752>>2]|0;k=(f|0)>=255?255:f;F[t+32>>2]=f>>>0<256?f:(k|0)>0?k:0;f=J<<2;l=(f+ca<<2)+b|0;f=o-f|0;if((f|0)<=3){if(!oa){break p}n=(f|0)>=4?4:f;s=m&-2;u=m&1;x=0;break s}f=0;if(!oa){break p}while(1){m=t+32|0;k=G[f+v|0];D[l+3|0]=F[(m|(k&3)<<2)>>2];D[l+7|0]=F[(m|k&12)>>2];D[l+11|0]=F[(m|k>>>2&12)>>2];D[l+15|0]=F[(m|k>>>4&12)>>2];l=l+ma|0;f=f+1|0;if((ha|0)!=(f|0)){continue}break}break p}f=L(J+wa|0,h)+b|0;k=G[u|0];Z=Z&7|(k>>>0>=31?31:k)<<3;k=G[u+4|0];aa=aa&3|k<<5|k<<2;k=G[u+2|0];ua=ua&7|(k>>>0>=31?31:k)<<3;k=G[u+1|0];pa=pa&7|(k>>>0>=31?31:k)<<3;F[f>>2]=Z|(aa<<24|ua<<16|pa<<8);F[f+4>>2]=G[v+4|0]|G[v+5|0]<<8|(G[v+6|0]<<16|G[v+7|0]<<24);break p}n=L(J+wa|0,h)+b|0;f=G[u+4|0];k=G[v+8|0];l=G[v+9|0];if((k|0)!=(l|0)){ha:{if(!(k|((l|0)!=3|f>>>0<7))){if(G[v+10|0]==2){break ha}}l=L(F[((k<<4)+(l<<2)|0)+407904>>2],10);m=f<<5;f=l+L(m+G[u|0]|0,60)<<2;y=f;k=l+L(m+G[u+2|0]|0,60)<<2;l=l+L(m+G[u+1|0]|0,60)<<2;m=H[k+74710>>1]+(H[l+136150>>1]+H[f+74710>>1]|0)|0;p=H[k+74706>>1]+(H[l+136146>>1]+H[f+74706>>1]|0)|0;s=m>>>0

>>0;u=H[k+74714>>1]+(H[l+136154>>1]+H[f+74714>>1]|0)|0;m=s?m:p;p=u>>>0>>0;A=p?2:s;s=H[k+74718>>1]+(H[l+136158>>1]+H[f+74718>>1]|0)|0;m=p?u:m;p=s>>>0>>0;A=p?3:A;u=H[k+74722>>1]+(H[l+136162>>1]+H[f+74722>>1]|0)|0;m=p?s:m;p=u>>>0>>0;A=p?4:A;s=H[k+74726>>1]+(H[l+136166>>1]+H[f+74726>>1]|0)|0;m=p?u:m;p=s>>>0>>0;A=p?5:A;u=H[k+74730>>1]+(H[l+136170>>1]+H[f+74730>>1]|0)|0;m=p?s:m;p=u>>>0>>0;A=p?6:A;s=H[k+74734>>1]+(H[l+136174>>1]+H[f+74734>>1]|0)|0;m=p?u:m;p=s>>>0>>0;A=p?7:A;u=H[k+74738>>1]+(H[l+136178>>1]+H[f+74738>>1]|0)|0;m=p?s:m;p=u>>>0>>0;p=H[k+74742>>1]+(H[l+136182>>1]+H[f+74742>>1]|0)>>>0<(p?u:m)>>>0?9:p?8:A;f=p<<2;m=y+f|0;k=f+k|0;l=f+l|0;f=G[m+74704|0]<<11&63488|G[k+74704|0]|G[l+136144|0]<<5;k=G[k+74705|0]|G[m+74705|0]<<11&63488|G[l+136145|0]<<5;l=f>>>0>>0;m=l?f:k;D[n+2|0]=m;k=f>>>0>k>>>0?f:k;D[n|0]=k;D[n+3|0]=m>>>8;D[n+1|0]=k>>>8;if((k|0)!=(m|0)){f=(p<<8)+(l?410528:407968)|0;D[n+4|0]=G[f+G[v|0]|0];D[n+5|0]=G[f+G[v+1|0]|0];D[n+6|0]=G[f+G[v+2|0]|0];D[n+7|0]=G[f+G[v+3|0]|0];break p}f=n;if(i){k=0}else{l=k?k:1;D[n|0]=l;D[n+1|0]=l>>>8;l=k-1|0;l=k>>>0>=l>>>0?l:0;D[n+2|0]=l;D[n+3|0]=l>>>8;k=k?0:85}k=L(k,16843009);D[f+4|0]=k;D[f+5|0]=k>>>8;D[f+6|0]=k>>>16;D[f+7|0]=k>>>24;break p}m=1;s=f<<4;f=F[s+12764>>2];k=G[u+1|0];O=(k<<3|k>>>2)&255;k=f+O|0;x=(k|0)>=255?255:k;l=G[u|0];Q=(l<<3|l>>>2)&255;l=Q+f|0;w=(l|0)>=255?255:l;p=f;f=G[u+2|0];ba=(f<<3|f>>>2)&255;p=p+ba|0;y=(p|0)>=255?255:p;u=F[s+12752>>2];f=u+O|0;O=(f|0)>=255?255:f;s=u+Q|0;Q=(s|0)>=255?255:s;u=u+ba|0;ba=(u|0)>=255?255:u;f=G[(((u>>>0<256?u:(ba|0)>0?ba:0)&255)<<1)+406368|0]|(G[(((f>>>0<256?f:(O|0)>0?O:0)&255)<<1)+407392|0]<<5|G[(((s>>>0<256?s:(Q|0)>0?Q:0)&255)<<1)+406368|0]<<11);s=G[(((p>>>0<256?p:(y|0)>0?y:0)&255)<<1)+406368|0]|(G[(((k>>>0<256?k:(x|0)>0?x:0)&255)<<1)+407392|0]<<5|G[(((l>>>0<256?l:(w|0)>0?w:0)&255)<<1)+406368|0]<<11);ia:{if((f|0)==(s|0)){if(!f){f=0;k=1;l=1;break ia}s=f-1|0;m=0}l=0;if(f>>>0>=s>>>0){k=f;f=s;break ia}l=1;m=0;k=s}D[n+2|0]=f;D[n|0]=k;D[n+3|0]=f>>>8;D[n+1|0]=k>>>8;f=G[n+4|0]&-4|((G[v|0]&3)==3?m:l);D[n+4|0]=f;f=f&-15|((G[v|0]&12)==12?m:l)<<2;D[n+4|0]=f;f=f&-59|((G[v|0]&48)==48?m:l)<<4;D[n+4|0]=f;D[n+4|0]=f&21|(G[v|0]>191?m:l)<<6;f=G[n+5|0]&-4|((G[v+1|0]&3)==3?m:l);D[n+5|0]=f;f=f&-15|((G[v+1|0]&12)==12?m:l)<<2;D[n+5|0]=f;f=f&-59|((G[v+1|0]&48)==48?m:l)<<4;D[n+5|0]=f;D[n+5|0]=f&21|(G[v+1|0]>191?m:l)<<6;f=G[n+6|0]&-4|((G[v+2|0]&3)==3?m:l);D[n+6|0]=f;f=f&-15|((G[v+2|0]&12)==12?m:l)<<2;D[n+6|0]=f;f=f&-59|((G[v+2|0]&48)==48?m:l)<<4;D[n+6|0]=f;D[n+6|0]=f&21|(G[v+2|0]>191?m:l)<<6;f=G[n+7|0]&-4|((G[v+3|0]&3)==3?m:l);D[n+7|0]=f;f=f&-15|((G[v+3|0]&12)==12?m:l)<<2;D[n+7|0]=f;f=f&-59|((G[v+3|0]&48)==48?m:l)<<4;D[n+7|0]=f;D[n+7|0]=f&21|(G[v+3|0]>191?m:l)<<6;break p}l=G[u+1|0];m=l<<3|l>>>2;l=F[((f<<4)+(k<<2)|0)+12752>>2];f=m+l|0;m=(f|0)>=255?255:f;k=G[u|0];k=l+(k<<3|k>>>2)|0;p=(k|0)>=255?255:k;s=G[u+2|0];l=l+(s<<3|s>>>2)|0;s=(l|0)>=255?255:l;f=(f>>>0<256?f:(m|0)>0?m:0)<<1;k=(k>>>0<256?k:(p|0)>0?p:0)<<1;m=(l>>>0<256?l:(s|0)>0?s:0)<<1;l=G[f+406881|0]<<5|G[k+405857|0]<<11|G[m+405857|0];f=G[m+405856|0]|(G[f+406880|0]<<5|G[k+405856|0]<<11);m=170;ja:{if(!((f|0)!=(l|0)|i)){if(!f){m=85;l=1;k=0;break ja}m=0;l=f-1|0}if(f>>>0>=l>>>0){k=l;l=f;break ja}m=m|85;k=f}D[n+2|0]=k;D[n|0]=l;f=L(m,16843009);D[n+4|0]=f;D[n+5|0]=f>>>8;D[n+6|0]=f>>>16;D[n+7|0]=f>>>24;D[n+3|0]=k>>>8;D[n+1|0]=l>>>8;break p}f=L(J+wa|0,h)+b|0;l=G[u+4|0];m=G[v+8|0];k=G[v+9|0];if((m|0)!=(k|0)){if(G[v+10|0]!=2){s=0;ka:{la:{switch(m|0){case 1:s=(k|0)==3?1:(k|0)==2?3:0;break ka;case 0:break la;default:break ka}}s=((k|0)==2)<<1}k=G[u|0]+(l<<5)<<4|s<<2;l=H[k+197584>>1];D[f|0]=l;D[f+1|0]=l>>>8;k=H[k+197586>>1];l=k>>>L(G[v|0]&3,3)&7|G[f+2|0]&-8;D[f+2|0]=l;l=k>>>L(G[v|0]>>>2&3,3)<<3&56|l&-57;D[f+2|0]=l;l=(l&63|G[f+3|0]<<8)&65087|k>>>L(G[v|0]>>>4&3,3)<<6&448;D[f+2|0]=l;D[f+3|0]=l>>>8;l=l>>>8&241|k>>>L(G[v|0]>>>6|0,3)<<1&14;D[f+3|0]=l;l=l&143|k>>>L(G[v+1|0]&3,3)<<4&112;D[f+3|0]=l;l=(l|G[f+4|0]<<8)&64639|k>>>L(G[v+1|0]>>>2&3,3)<<7&896;D[f+3|0]=l;D[f+4|0]=l>>>8;l=l>>>8&227|k>>>L(G[v+1|0]>>>4&3,3)<<2&28;D[f+4|0]=l;D[f+4|0]=l&31|k>>>L(G[v+1|0]>>>6|0,3)<<5;l=k>>>L(G[v+2|0]&3,3)&7|G[f+5|0]&-8;D[f+5|0]=l;l=k>>>L(G[v+2|0]>>>2&3,3)<<3&56|l&-57;D[f+5|0]=l;l=(l&63|G[f+6|0]<<8)&65087|k>>>L(G[v+2|0]>>>4&3,3)<<6&448;D[f+5|0]=l;D[f+6|0]=l>>>8;l=l>>>8&241|k>>>L(G[v+2|0]>>>6|0,3)<<1&14;D[f+6|0]=l;l=l&143|k>>>L(G[v+3|0]&3,3)<<4&112;D[f+6|0]=l;l=(l|G[f+7|0]<<8)&64639|k>>>L(G[v+3|0]>>>2&3,3)<<7&896;D[f+6|0]=l;D[f+7|0]=l>>>8;l=l>>>8&227|k>>>L(G[v+3|0]>>>4&3,3)<<2&28;D[f+7|0]=l;D[f+7|0]=l&31|k>>>L(G[v+3|0]>>>6|0,3)<<5;break p}n=G[u|0];n=(n<<3|n>>>2)&255;l=l<<4;p=n+F[l+12764>>2]|0;s=(p|0)>=255?255:p;D[t+44|0]=p>>>0<256?p:(s|0)>0?s:0;p=n+F[l+12760>>2]|0;s=(p|0)>=255?255:p;D[t+40|0]=p>>>0<256?p:(s|0)>0?s:0;p=n+F[l+12756>>2]|0;s=(p|0)>=255?255:p;D[t+36|0]=p>>>0<256?p:(s|0)>0?s:0;l=n+F[l+12752>>2]|0;n=(l|0)>=255?255:l;D[t+32|0]=l>>>0<256?l:(n|0)>0?n:0;l=t+32|0;m=G[l+(m<<2)|0];D[f+1|0]=G[l+(k<<2)|0];D[f|0]=m;l=G[f+2|0]&-8|(k|0)==(G[v|0]&3);D[f+2|0]=l;l=l&-63|((k|0)==(G[v|0]>>>2&3))<<3;D[f+2|0]=l;m=G[v|0];n=G[f+3|0];D[f+3|0]=n&254;D[f+2|0]=l&9|((k|0)==(m>>>4&3))<<6;l=n&240|((k|0)==(G[v|0]>>>6|0))<<1;D[f+3|0]=l;l=l&130|((k|0)==(G[v+1|0]&3))<<4;D[f+3|0]=l;m=G[v+1|0];l=(l|G[f+4|0]<<8)&64530;n=l>>>8|0;D[f+4|0]=n;D[f+3|0]=l|((k|0)==(m>>>2&3))<<7;l=((k|0)==(G[v+1|0]>>>4&3))<<2;D[f+4|0]=l|n&224;D[f+4|0]=l|((k|0)==(G[v+1|0]>>>6|0))<<5;l=G[f+5|0]&-8|(k|0)==(G[v+2|0]&3);D[f+5|0]=l;l=l&-63|((k|0)==(G[v+2|0]>>>2&3))<<3;D[f+5|0]=l;m=G[v+2|0];n=G[f+6|0];D[f+6|0]=n&254;D[f+5|0]=l&9|((k|0)==(m>>>4&3))<<6;l=n&240|((k|0)==(G[v+2|0]>>>6|0))<<1;D[f+6|0]=l;l=l&130|((k|0)==(G[v+3|0]&3))<<4;D[f+6|0]=l;m=G[v+3|0];l=(l|G[f+7|0]<<8)&64530;n=l>>>8|0;D[f+7|0]=n;D[f+6|0]=l|((k|0)==(m>>>2&3))<<7;l=((k|0)==(G[v+3|0]>>>4&3))<<2;D[f+7|0]=l|n&224;D[f+7|0]=l|((k|0)==(G[v+3|0]>>>6|0))<<5;break p}k=G[u|0];D[f+2|0]=0;D[f+3|0]=0;D[f+4|0]=0;D[f+5|0]=0;D[f+6|0]=0;D[f+7|0]=0;k=F[((l<<4)+(m<<2)|0)+12752>>2]+(k<<3|k>>>2)|0;l=(k|0)>=255?255:k;k=k>>>0<256?k:(l|0)>0?l:0;D[f+1|0]=k;D[f|0]=k;break p}n=G[v+4|0]|G[v+5|0]<<8|G[v+6|0]<<16|G[v+7|0]<<24;f=G[u|0];Z=Z&7|(f>>>0>=31?31:f)<<3;p=Z;f=G[u+4|0];aa=aa&3|f<<5|f<<2;l=aa&255;f=l>>>8|0;s=l<<24;l=f;f=G[u+2|0];ua=ua&7|(f>>>0>=31?31:f)<<3;f=ua>>>16|0;s=ua<<16|s;l=f|l;f=G[u+1|0];pa=pa&7|(f>>>0>=31?31:f)<<3;f=pa>>>24|0;O=J+xa|0;k=(O<<3)+Qa|0;F[k>>2]=p|(pa<<8|s);F[k+4>>2]=f|l|n;m=(G[u+4|0]<<4)+12752|0;l=F[m+(G[v+8|0]<<2)>>2];f=G[u|0];n=(f<<3|f>>>2)&255;f=l+n|0;s=(f|0)>=255?255:f;k=G[u+1|0];p=(k<<3|k>>>2)&255;k=p+l|0;x=(k|0)>=255?255:k;A=l;l=G[u+2|0];y=(l<<3|l>>>2)&255;l=A+y|0;u=(l|0)>=255?255:l;A=p;p=F[m+(G[v+9|0]<<2)>>2];m=A+p|0;v=(m|0)>=255?255:m;n=n+p|0;w=(n|0)>=255?255:n;p=p+y|0;y=(p|0)>=255?255:p;F[(O<<2)+yb>>2]=G[((f>>>0<256?f:(s|0)>0?s:0)&255)+201680|0]<<10&31744|G[((k>>>0<256?k:(x|0)>0?x:0)&255)+201680|0]<<5|G[((l>>>0<256?l:(u|0)>0?u:0)&255)+201936|0]<<1|(G[((p>>>0<256?p:(y|0)>0?y:0)&255)+202192|0]|(G[((m>>>0<256?m:(v|0)>0?v:0)&255)+202192|0]<<5|G[((n>>>0<256?n:(w|0)>0?w:0)&255)+202192|0]<<10))<<16|-2147450880;break p}f=G[u|0];Z=Z&7|(f>>>0>=31?31:f)<<3;m=Z;f=G[u+4|0];aa=aa&3|f<<5|f<<2;l=aa&255;f=l>>>8|0;n=l<<24;l=f;f=G[u+2|0];ua=ua&7|(f>>>0>=31?31:f)<<3;f=ua>>>16|0;n=ua<<16|n;l=f|l;f=G[u+1|0];pa=pa&7|(f>>>0>=31?31:f)<<3;f=pa>>>24|0;m=pa<<8|n|m;l=f|l;f=G[v|0]|G[v+1|0]<<8|(G[v+2|0]<<16|G[v+3|0]<<24);x=J+xa|0;k=(x<<3)+Qa|0;F[k>>2]=m;F[k+4>>2]=f|l;n=(G[u+4|0]<<4)+12752|0;f=F[n+(G[v+9|0]<<2)>>2];k=G[u+2|0];p=(k<<3|k>>>2)&255;k=f+p|0;l=(k|0)>=255?255:k;w=(l|0)>0?l:0;y=k>>>0<256;l=G[u+1|0];s=(l<<3|l>>>2)&255;l=s+f|0;m=(l|0)>=255?255:l;O=(m|0)>0?m:0;Q=l>>>0<256;m=f;f=G[u|0];u=(f<<3|f>>>2)&255;m=m+u|0;f=(m|0)>=255?255:m;ba=(f|0)>0?f:0;S=m>>>0<256;n=F[n+(G[v+8|0]<<2)>>2];f=n+p|0;p=(f|0)>=255?255:f;p=f>>>0<256?f:(p|0)>0?p:0;f=n+s|0;s=(f|0)>=255?255:f;s=f>>>0<256?f:(s|0)>0?s:0;f=n+u|0;n=(f|0)>=255?255:f;n=f>>>0<256?f:(n|0)>0?n:0;x=x<<2;f=x+r|0;u=F[ja+4>>2]+(H[f>>1]<<3)|0;v=(G[u+4|0]<<4)+12752|0;A=F[ja+16>>2]+L(H[f+2>>1],11)|0;f=G[u+1|0];ka=(f<<3|f>>>2)&255;f=F[v+(G[A+9|0]<<2)>>2]+ka|0;u=(f|0)>=255?255:f;u=f>>>0<256?f:(u|0)>0?u:0;f=ka+F[v+(G[A+8|0]<<2)>>2]|0;v=(f|0)>=255?255:f;f=(f>>>0<256?f:(v|0)>0?v:0)&255;ma:{if((f|0)!=255){f=G[(n&255)+201936|0]<<8|G[f+202704|0]<<12|G[(s&255)+201936|0]<<4|G[(p&255)+202960|0]<<1;break ma}f=G[(n&255)+201680|0]<<10|G[(s&255)+201680|0]<<5|G[(p&255)+201936|0]<<1|32768}k=y?k:w;l=Q?l:O;m=S?m:ba;n=x+yb|0;p=u&255;na:{if(p-239>>>0>=17){f=f&65535|(G[(k&255)+202448|0]|(G[(m&255)+202448|0]<<8|G[p+203216|0]<<12|G[(l&255)+202448|0]<<4))<<16;break na}f=f&65535|(G[(k&255)+202192|0]|(G[(l&255)+202192|0]<<5|G[(m&255)+202192|0]<<10))<<16|-2147483648}F[n>>2]=f;break p}k=L(J+wa|0,h)+b|0;m=G[u+4|0];f=G[u|0];n=G[v+8|0];l=G[v+9|0];if((n|0)!=(l|0)){s=0;oa:{pa:{switch(n|0){case 1:s=(l|0)==3?1:(l|0)==2?3:0;break oa;case 0:break pa;default:break oa}}s=((l|0)==2)<<1}f=f+(m<<5)<<4|s<<2;l=G[f+392225|0];E[k>>1]=l<<4&3840|l<<12|G[f+392224|0];p=H[f+392226>>1];l=G[v+3|0];f=p>>>L(l&3,3)&7;m=p>>>L(l>>>2&3,3)<<24&117440512|(p>>>L(l>>>4&3,3)<<12&28672|p>>>L(l>>>6|0,3)&7);l=G[v+2|0];u=m|(p>>>L(l>>>4&3,3)<<15&229376|p>>>L(l>>>6|0,3)<<3&56|p>>>L(l>>>2&3,3)<<27&939524096);m=f<<4;s=G[v+1|0];x=p>>>L(s>>>6|0,3)<<6&448;n=(p>>>L(l&3,3)&7)<<7;v=G[v|0];l=(p>>>L(v>>>2&3,3)&7)<<1;f=p>>>L(v&3,3)&7;v=p>>>L(v>>>4&3,3)<<21&14680064|p>>>L(v>>>6|0,3)<<9&3584;y=f<<13|l|(p>>>L(s&3,3)&7)<<10;l=p>>>L(s>>>2&3,3)&7;f=l>>>2|0;l=p>>>L(s>>>4&3,3)<<18&1835008|(l<<30|v)|x;p=m;m=f|y|n;f=p|m;l=l|u;D[k+7|0]=l;D[k+2|0]=m>>>8;D[k+6|0]=(f&255)<<24|l>>>8;D[k+5|0]=(f&65535)<<16|l>>>16;D[k+4|0]=(f&16777215)<<8|l>>>24;D[k+3|0]=f;break p}l=H[196104]|H[196105]<<16;E[k+2>>1]=l;E[k+4>>1]=l>>>16;E[k+6>>1]=H[196106];f=F[((m<<4)+(n<<2)|0)+12752>>2]+(f<<3|f>>>2)|0;l=(f|0)>=255?255:f;E[k>>1]=(f>>>0<256?f:(l|0)>0?l:0)&255|7424;break p}k=G[u+1|0];k=(k<<3|k>>>2)&255;f=G[u+4|0]<<4;l=k+F[f+12764>>2]|0;n=(l|0)>=255?255:l;l=L((l>>>0<256?l:(n|0)>0?n:0)&255,15)+128|0;E[t+38>>1]=(l>>>8|0)+l>>>8;l=k+F[f+12760>>2]|0;n=(l|0)>=255?255:l;l=L((l>>>0<256?l:(n|0)>0?n:0)&255,15)+128|0;E[t+36>>1]=(l>>>8|0)+l>>>8;l=k+F[f+12756>>2]|0;n=(l|0)>=255?255:l;l=L((l>>>0<256?l:(n|0)>0?n:0)&255,15)+128|0;E[t+34>>1]=(l>>>8|0)+l>>>8;f=k+F[f+12752>>2]|0;k=(f|0)>=255?255:f;f=L((f>>>0<256?f:(k|0)>0?k:0)&255,15)+128|0;E[t+32>>1]=(f>>>8|0)+f>>>8;if(!oa){break p}f=J<<2;k=o-f|0;n=(k|0)>=4?4:k;u=m&-2;w=m&1;f=(f+ca<<1)+b|0;x=0;while(1){qa:{if(!n){break qa}k=G[v+x|0];p=0;s=0;if((m|0)!=1){while(1){l=p<<1;E[l+f>>1]=H[(t+32|0)+((k>>>l&3)<<1)>>1];l=l|2;E[l+f>>1]=H[(t+32|0)+((k>>>l&3)<<1)>>1];p=p+2|0;s=s+2|0;if((u|0)!=(s|0)){continue}break}}if(!w){break qa}l=p<<1;E[l+f>>1]=H[(t+32|0)+((k>>>l&3)<<1)>>1]}f=f+da|0;x=x+1|0;if((ha|0)!=(x|0)){continue}break}break p}f=G[u+4|0]<<4;s=F[f+12764>>2];k=G[u+1|0];k=(k<<3|k>>>2)&255;l=s+k|0;x=(l|0)>=255?255:l;n=G[u|0];n=(n<<3|n>>>2)&255;p=n+s|0;w=(p|0)>=255?255:p;y=s;s=G[u+2|0];s=(s<<3|s>>>2)&255;u=y+s|0;y=(u|0)>=255?255:u;l=L((l>>>0<256?l:(x|0)>0?x:0)&255,15)+128|0;A=(l>>>8|0)+l&16128;l=L((p>>>0<256?p:(w|0)>0?w:0)&255,15)+128|0;p=A|(l>>>8|0)+l<<4&61440;l=L((u>>>0<256?u:(y|0)>0?y:0)&255,15)+128|0;E[t+38>>1]=p|((l>>>8|0)+l&16128)>>>4|15;u=F[f+12760>>2];l=u+k|0;x=(l|0)>=255?255:l;p=n+u|0;w=(p|0)>=255?255:p;u=s+u|0;y=(u|0)>=255?255:u;l=L((l>>>0<256?l:(x|0)>0?x:0)&255,15)+128|0;A=(l>>>8|0)+l&16128;l=L((p>>>0<256?p:(w|0)>0?w:0)&255,15)+128|0;p=A|(l>>>8|0)+l<<4&61440;l=L((u>>>0<256?u:(y|0)>0?y:0)&255,15)+128|0;E[t+36>>1]=p|((l>>>8|0)+l&16128)>>>4|15;u=F[f+12756>>2];l=u+k|0;x=(l|0)>=255?255:l;p=n+u|0;w=(p|0)>=255?255:p;u=s+u|0;y=(u|0)>=255?255:u;l=L((l>>>0<256?l:(x|0)>0?x:0)&255,15)+128|0;A=(l>>>8|0)+l&16128;l=L((p>>>0<256?p:(w|0)>0?w:0)&255,15)+128|0;p=A|(l>>>8|0)+l<<4&61440;l=L((u>>>0<256?u:(y|0)>0?y:0)&255,15)+128|0;E[t+34>>1]=p|((l>>>8|0)+l&16128)>>>4|15;l=F[f+12752>>2];f=l+k|0;p=(f|0)>=255?255:f;k=l+n|0;n=(k|0)>=255?255:k;l=l+s|0;s=(l|0)>=255?255:l;f=L((f>>>0<256?f:(p|0)>0?p:0)&255,15)+128|0;p=(f>>>8|0)+f&16128;f=L((k>>>0<256?k:(n|0)>0?n:0)&255,15)+128|0;k=p|(f>>>8|0)+f<<4&61440;f=L((l>>>0<256?l:(s|0)>0?s:0)&255,15)+128|0;E[t+32>>1]=k|((f>>>8|0)+f&16128)>>>4|15;if(!oa){break p}f=J<<2;k=o-f|0;n=(k|0)>=4?4:k;u=m&-2;w=m&1;f=(f+ca<<1)+b|0;x=0;while(1){ra:{if(!n){break ra}k=G[v+x|0];p=0;s=0;if((m|0)!=1){while(1){l=p<<1;E[l+f>>1]=H[(t+32|0)+((k>>>l&3)<<1)>>1];l=l|2;E[l+f>>1]=H[(t+32|0)+((k>>>l&3)<<1)>>1];p=p+2|0;s=s+2|0;if((u|0)!=(s|0)){continue}break}}if(!w){break ra}l=p<<1;E[l+f>>1]=H[(t+32|0)+((k>>>l&3)<<1)>>1]}f=f+da|0;x=x+1|0;if((ha|0)!=(x|0)){continue}break}break p}k=L(J+wa|0,h)+b|0;m=G[u+4|0];f=G[u|0];n=G[v+8|0];l=G[v+9|0];if((n|0)!=(l|0)){s=0;sa:{ta:{switch(n|0){case 1:s=(l|0)==3?1:(l|0)==2?3:0;break sa;case 0:break ta;default:break sa}}s=((l|0)==2)<<1}f=f+(m<<5)<<4|s<<2;l=G[f+203473|0];E[k>>1]=l<<4&3840|l<<12|G[f+203472|0];p=H[f+203474>>1];l=G[v+3|0];f=p>>>L(l&3,3)&7;m=p>>>L(l>>>2&3,3)<<24&117440512|(p>>>L(l>>>4&3,3)<<12&28672|p>>>L(l>>>6|0,3)&7);l=G[v+2|0];u=m|(p>>>L(l>>>4&3,3)<<15&229376|p>>>L(l>>>6|0,3)<<3&56|p>>>L(l>>>2&3,3)<<27&939524096);m=f<<4;s=G[v+1|0];x=p>>>L(s>>>6|0,3)<<6&448;n=(p>>>L(l&3,3)&7)<<7;v=G[v|0];l=(p>>>L(v>>>2&3,3)&7)<<1;f=p>>>L(v&3,3)&7;v=p>>>L(v>>>4&3,3)<<21&14680064|p>>>L(v>>>6|0,3)<<9&3584;y=f<<13|l|(p>>>L(s&3,3)&7)<<10;l=p>>>L(s>>>2&3,3)&7;f=l>>>2|0;l=p>>>L(s>>>4&3,3)<<18&1835008|(l<<30|v)|x;p=m;m=f|y|n;f=p|m;l=l|u;D[k+7|0]=l;D[k+2|0]=m>>>8;D[k+6|0]=(f&255)<<24|l>>>8;D[k+5|0]=(f&65535)<<16|l>>>16;D[k+4|0]=(f&16777215)<<8|l>>>24;D[k+3|0]=f;break p}l=H[196104]|H[196105]<<16;E[k+2>>1]=l;E[k+4>>1]=l>>>16;E[k+6>>1]=H[196106];f=F[((m<<4)+(n<<2)|0)+12752>>2]+(f<<3|f>>>2)|0;l=(f|0)>=255?255:f;E[k>>1]=(f>>>0<256?f:(l|0)>0?l:0)&255|7424;break p}D[t+40|0]=0;D[t+41|0]=0;k=L(J+wa|0,h)+b|0;x=255;m=1;ua:{if(!q){break ua}w=n+L(H[k+2>>1],11)|0;m=G[w+10|0];if((m|0)!=1){break ua}l=s+(H[k>>1]<<3)|0;f=G[l+4|0]<<4;l=G[l+1|0];l=l<<3|l>>>2;m=F[f+12764>>2]+l|0;p=(m|0)>=255?255:m;F[t+124>>2]=m>>>0<256?m:(p|0)>0?p:0;m=l+F[f+12760>>2]|0;p=(m|0)>=255?255:m;F[t+120>>2]=m>>>0<256?m:(p|0)>0?p:0;m=l+F[f+12756>>2]|0;p=(m|0)>=255?255:m;F[t+116>>2]=m>>>0<256?m:(p|0)>0?p:0;f=l+F[f+12752>>2]|0;l=(f|0)>=255?255:f;F[t+112>>2]=f>>>0<256?f:(l|0)>0?l:0;x=F[(t+112|0)+(G[w+8|0]<<2)>>2];m=1}l=G[v+9|0];f=G[v+8|0];p=G[u+4|0];w=G[v+10|0];if(!((m|0)==1&(w|0)==1)){if(!(w>>>0<3&m>>>0<=2)){va:{if(!q){D[t+73|0]=0;D[t+71|0]=0;D[t+69|0]=0;D[t+67|0]=0;D[t+65|0]=0;D[t+63|0]=0;D[t+61|0]=0;D[t+59|0]=0;D[t+57|0]=0;D[t+55|0]=0;D[t+53|0]=0;D[t+51|0]=0;D[t+49|0]=0;D[t+47|0]=0;D[t+45|0]=0;D[t+43|0]=0;D[t+38|0]=1;D[t+39|0]=1;break va}s=s+(H[k>>1]<<3)|0;m=G[s+4|0];n=n+L(H[k+2>>1],11)|0;x=G[n+8|0];w=G[n+9|0];if((x|0)!=(w|0)){wa:{if(!(x|((w|0)!=3|m>>>0<7))){if(G[n+10|0]==2){break wa}}w=F[((x<<4)+(w<<2)|0)+428448>>2];s=G[s+1|0];x=G[(w+(L(s,48)+L(m,6)|0)|0)+426912|0]<<2;m=H[(x+(L(s+(m<<5)|0,60)+L(w,10)<<2)|0)+13232>>1];D[t+38|0]=m;D[t+39|0]=m>>>8;m=x+330720|0;s=G[n|0];D[t+49|0]=G[m+(s>>>6|0)|0];D[t+43|0]=G[m+(s&3)|0];D[t+47|0]=G[m+(s>>>4&3)|0];D[t+45|0]=G[m+(s>>>2&3)|0];s=G[n+1|0];D[t+57|0]=G[m+(s>>>6|0)|0];D[t+51|0]=G[m+(s&3)|0];D[t+55|0]=G[m+(s>>>4&3)|0];D[t+53|0]=G[m+(s>>>2&3)|0];s=G[n+2|0];D[t+65|0]=G[m+(s>>>6|0)|0];D[t+59|0]=G[m+(s&3)|0];D[t+63|0]=G[m+(s>>>4&3)|0];D[t+61|0]=G[m+(s>>>2&3)|0];n=G[n+3|0];D[t+73|0]=G[m+(n>>>6|0)|0];D[t+67|0]=G[m+(n&3)|0];D[t+71|0]=G[m+(n>>>4&3)|0];D[t+69|0]=G[m+(n>>>2&3)|0];break va}Yb(t+112|0,s,m);D[t+38|0]=G[G[t+113|0]+429216|0];D[t+39|0]=G[G[t+125|0]+429216|0];m=G[n|0];D[t+49|0]=(m&192)==192?3:0;D[t+47|0]=(m&48)==48?3:0;D[t+45|0]=(m&12)==12?3:0;D[t+43|0]=(m&3)==3?3:0;m=G[n+1|0];D[t+57|0]=(m&192)==192?3:0;D[t+55|0]=(m&48)==48?3:0;D[t+53|0]=(m&12)==12?3:0;D[t+51|0]=(m&3)==3?3:0;m=G[n+2|0];D[t+65|0]=(m&192)==192?3:0;D[t+63|0]=(m&48)==48?3:0;D[t+61|0]=(m&12)==12?3:0;D[t+59|0]=(m&3)==3?3:0;m=G[n+3|0];D[t+73|0]=(m&192)==192?3:0;D[t+71|0]=(m&48)==48?3:0;D[t+69|0]=(m&12)==12?3:0;D[t+67|0]=(m&3)==3?3:0;break va}n=G[s+1|0];n=n<<3|n>>>2;m=m<<4;s=n+F[m+12764>>2]|0;w=(s|0)>=255?255:s;F[t+124>>2]=s>>>0<256?s:(w|0)>0?w:0;s=n+F[m+12760>>2]|0;w=(s|0)>=255?255:s;F[t+120>>2]=s>>>0<256?s:(w|0)>0?w:0;s=n+F[m+12756>>2]|0;w=(s|0)>=255?255:s;F[t+116>>2]=s>>>0<256?s:(w|0)>0?w:0;m=n+F[m+12752>>2]|0;n=(m|0)>=255?255:m;F[t+112>>2]=m>>>0<256?m:(n|0)>0?n:0;m=F[(t+112|0)+(x<<2)>>2]<<1;D[t+38|0]=G[m+428704|0];D[t+39|0]=G[m+428705|0];D[t+43|0]=1;D[t+45|0]=1;D[t+47|0]=1;D[t+49|0]=1;D[t+51|0]=1;D[t+53|0]=1;D[t+55|0]=1;D[t+57|0]=1;D[t+59|0]=1;D[t+61|0]=1;D[t+63|0]=1;D[t+65|0]=1;D[t+67|0]=1;D[t+69|0]=1;D[t+71|0]=1;D[t+73|0]=1}xa:{if((f|0)!=(l|0)){ya:{if(!(G[v+8|0]|(G[v+10|0]!=2|p>>>0<7))){if(G[v+9|0]==3){break ya}}n=L(F[((f<<4)+(l<<2)|0)+428448>>2],10);m=p<<5;f=n+L(m+G[u+2|0]|0,60)<<2;l=n+L(m+G[u+1|0]|0,60)<<2;m=n+L(m+G[u|0]|0,60)<<2;p=H[f+13238>>1]+(H[l+13238>>1]+H[m+13238>>1]|0)|0;s=H[f+13234>>1]+(H[l+13234>>1]+H[m+13234>>1]|0)|0;n=p>>>0>>0;y=f;A=n;u=H[f+13242>>1]+(H[l+13242>>1]+H[m+13242>>1]|0)|0;n=n?p:s;p=u>>>0>>0;A=p?2:A;s=H[f+13246>>1]+(H[l+13246>>1]+H[m+13246>>1]|0)|0;n=p?u:n;p=s>>>0>>0;A=p?3:A;u=H[f+13250>>1]+(H[l+13250>>1]+H[m+13250>>1]|0)|0;n=p?s:n;p=u>>>0>>0;A=p?4:A;s=H[f+13254>>1]+(H[l+13254>>1]+H[m+13254>>1]|0)|0;n=p?u:n;p=s>>>0>>0;A=p?5:A;u=H[f+13258>>1]+(H[l+13258>>1]+H[m+13258>>1]|0)|0;n=p?s:n;p=u>>>0>>0;A=p?6:A;s=H[f+13262>>1]+(H[l+13262>>1]+H[m+13262>>1]|0)|0;n=p?u:n;p=s>>>0>>0;A=p?7:A;u=H[f+13266>>1]+(H[l+13266>>1]+H[m+13266>>1]|0)|0;n=p?s:n;p=u>>>0>>0;f=(H[f+13270>>1]+(H[l+13270>>1]+H[m+13270>>1]|0)>>>0<(p?u:n)>>>0?9:p?8:A)<<2;p=y+f|0;n=G[p+13233|0];D[t+37|0]=n;p=G[p+13232|0];D[t+36|0]=p;s=f+l|0;l=G[s+13233|0];D[t+35|0]=l;s=G[s+13232|0];D[t+34|0]=s;u=f+m|0;m=G[u+13233|0];D[t+33|0]=m;u=G[u+13232|0];D[t+32|0]=u;if((F[(n<<2)+428512>>2]+(F[(l<<2)+428512>>2]+F[(m<<2)+428512>>2]|0)|0)>=(F[(p<<2)+428512>>2]+(F[(s<<2)+428512>>2]+F[(u<<2)+428512>>2]|0)|0)){f=f+330720|0;l=G[v|0];D[t+48|0]=G[f+(l>>>6|0)|0];D[t+42|0]=G[f+(l&3)|0];D[t+46|0]=G[f+(l>>>4&3)|0];D[t+44|0]=G[f+(l>>>2&3)|0];l=G[v+1|0];D[t+56|0]=G[f+(l>>>6|0)|0];D[t+50|0]=G[f+(l&3)|0];D[t+54|0]=G[f+(l>>>4&3)|0];D[t+52|0]=G[f+(l>>>2&3)|0];l=G[v+2|0];D[t+64|0]=G[f+(l>>>6|0)|0];D[t+58|0]=G[f+(l&3)|0];D[t+62|0]=G[f+(l>>>4&3)|0];D[t+60|0]=G[f+(l>>>2&3)|0];l=G[v+3|0];D[t+72|0]=G[f+(l>>>6|0)|0];D[t+66|0]=G[f+(l&3)|0];D[t+70|0]=G[f+(l>>>4&3)|0];D[t+68|0]=G[f+(l>>>2&3)|0];break xa}D[t+37|0]=p;D[t+36|0]=n;D[t+35|0]=s;D[t+34|0]=l;D[t+33|0]=u;D[t+32|0]=m;f=f+330720|0;l=G[v|0];D[t+48|0]=3-G[f+(l>>>6|0)|0];D[t+42|0]=3-G[f+(l&3)|0];D[t+46|0]=3-G[f+(l>>>4&3)|0];D[t+44|0]=3-G[f+(l>>>2&3)|0];l=G[v+1|0];D[t+56|0]=3-G[f+(l>>>6|0)|0];D[t+50|0]=3-G[f+(l&3)|0];D[t+54|0]=3-G[f+(l>>>4&3)|0];D[t+52|0]=3-G[f+(l>>>2&3)|0];l=G[v+2|0];D[t+64|0]=3-G[f+(l>>>6|0)|0];D[t+58|0]=3-G[f+(l&3)|0];D[t+62|0]=3-G[f+(l>>>4&3)|0];D[t+60|0]=3-G[f+(l>>>2&3)|0];l=G[v+3|0];D[t+72|0]=3-G[f+(l>>>6|0)|0];D[t+66|0]=3-G[f+(l&3)|0];D[t+70|0]=3-G[f+(l>>>4&3)|0];D[t+68|0]=3-G[f+(l>>>2&3)|0];break xa}Yb(t+112|0,u,p);l=G[G[t+112|0]+429216|0];D[t+32|0]=l;m=G[G[t+124|0]+429216|0];D[t+33|0]=m;n=G[G[t+113|0]+429216|0];D[t+34|0]=n;p=G[G[t+125|0]+429216|0];D[t+35|0]=p;s=G[G[t+114|0]+429216|0];D[t+36|0]=s;u=G[G[t+126|0]+429216|0];D[t+37|0]=u;if((F[(u<<2)+428512>>2]+(F[(p<<2)+428512>>2]+F[(m<<2)+428512>>2]|0)|0)>=(F[(s<<2)+428512>>2]+(F[(n<<2)+428512>>2]+F[(l<<2)+428512>>2]|0)|0)){l=G[v|0];D[t+48|0]=(f|0)!=(l>>>6|0)?3:0;D[t+42|0]=(f|0)!=(l&3)?3:0;D[t+46|0]=(f|0)!=(l>>>4&3)?3:0;D[t+44|0]=(f|0)!=(l>>>2&3)?3:0;l=G[v+1|0];D[t+56|0]=(f|0)!=(l>>>6|0)?3:0;D[t+50|0]=(f|0)!=(l&3)?3:0;D[t+54|0]=(f|0)!=(l>>>4&3)?3:0;D[t+52|0]=(f|0)!=(l>>>2&3)?3:0;l=G[v+2|0];D[t+64|0]=(f|0)!=(l>>>6|0)?3:0;D[t+58|0]=(f|0)!=(l&3)?3:0;D[t+62|0]=(f|0)!=(l>>>4&3)?3:0;D[t+60|0]=(f|0)!=(l>>>2&3)?3:0;l=G[v+3|0];D[t+66|0]=(f|0)!=(l&3)?3:0;D[t+70|0]=(f|0)!=(l>>>4&3)?3:0;D[t+68|0]=(f|0)!=(l>>>2&3)?3:0;D[t+72|0]=(f|0)!=(l>>>6|0)?3:0;break xa}D[t+37|0]=s;D[t+36|0]=u;D[t+35|0]=n;D[t+34|0]=p;D[t+33|0]=l;D[t+32|0]=m;l=G[v|0];D[t+48|0]=(f|0)==(l>>>6|0)?3:0;D[t+42|0]=(f|0)==(l&3)?3:0;D[t+46|0]=(f|0)==(l>>>4&3)?3:0;D[t+44|0]=(f|0)==(l>>>2&3)?3:0;l=G[v+1|0];D[t+56|0]=(f|0)==(l>>>6|0)?3:0;D[t+50|0]=(f|0)==(l&3)?3:0;D[t+54|0]=(f|0)==(l>>>4&3)?3:0;D[t+52|0]=(f|0)==(l>>>2&3)?3:0;l=G[v+2|0];D[t+64|0]=(f|0)==(l>>>6|0)?3:0;D[t+58|0]=(f|0)==(l&3)?3:0;D[t+62|0]=(f|0)==(l>>>4&3)?3:0;D[t+60|0]=(f|0)==(l>>>2&3)?3:0;l=G[v+3|0];D[t+66|0]=(f|0)==(l&3)?3:0;D[t+70|0]=(f|0)==(l>>>4&3)?3:0;D[t+68|0]=(f|0)==(l>>>2&3)?3:0;D[t+72|0]=(f|0)==(l>>>6|0)?3:0;break xa}s=G[u|0];v=G[u+1|0];l=p<<4;x=F[l+12764>>2];m=G[u+2|0];m=(m<<3|m>>>2)&255;n=x+m|0;p=(n|0)>=255?255:n;D[t+126|0]=n>>>0<256?n:(p|0)>0?p:0;n=(v<<3|v>>>2)&255;p=n+x|0;v=(p|0)>=255?255:p;D[t+125|0]=p>>>0<256?p:(v|0)>0?v:0;p=(s<<3|s>>>2)&255;s=p+x|0;v=(s|0)>=255?255:s;D[t+124|0]=s>>>0<256?s:(v|0)>0?v:0;v=F[l+12760>>2];s=v+m|0;u=(s|0)>=255?255:s;D[t+122|0]=s>>>0<256?s:(u|0)>0?u:0;s=n+v|0;u=(s|0)>=255?255:s;D[t+121|0]=s>>>0<256?s:(u|0)>0?u:0;s=p+v|0;v=(s|0)>=255?255:s;D[t+120|0]=s>>>0<256?s:(v|0)>0?v:0;v=F[l+12756>>2];s=v+m|0;u=(s|0)>=255?255:s;D[t+118|0]=s>>>0<256?s:(u|0)>0?u:0;s=n+v|0;u=(s|0)>=255?255:s;D[t+117|0]=s>>>0<256?s:(u|0)>0?u:0;s=p+v|0;v=(s|0)>=255?255:s;D[t+116|0]=s>>>0<256?s:(v|0)>0?v:0;s=m;m=F[l+12752>>2];l=s+m|0;s=(l|0)>=255?255:l;D[t+114|0]=l>>>0<256?l:(s|0)>0?s:0;l=m+n|0;n=(l|0)>=255?255:l;D[t+113|0]=l>>>0<256?l:(n|0)>0?n:0;l=m+p|0;m=(l|0)>=255?255:l;D[t+112|0]=l>>>0<256?l:(m|0)>0?m:0;p=1;f=(t+112|0)+(f<<2)|0;m=G[f|0]<<1;l=G[m+428704|0];D[t+32|0]=l;m=G[m+428705|0];D[t+33|0]=m;s=G[f+1|0]<<1;n=G[s+428704|0];D[t+34|0]=n;s=G[s+428705|0];D[t+35|0]=s;v=G[f+2|0]<<1;f=G[v+428704|0];D[t+36|0]=f;v=G[v+428705|0];D[t+37|0]=v;if((F[(v<<2)+428512>>2]+(F[(s<<2)+428512>>2]+F[(m<<2)+428512>>2]|0)|0)<(F[(f<<2)+428512>>2]+(F[(n<<2)+428512>>2]+F[(l<<2)+428512>>2]|0)|0)){D[t+37|0]=f;D[t+36|0]=v;D[t+35|0]=n;D[t+34|0]=s;D[t+33|0]=l;D[t+32|0]=m;p=2}D[t+72|0]=p;D[t+70|0]=p;D[t+68|0]=p;D[t+66|0]=p;D[t+64|0]=p;D[t+62|0]=p;D[t+60|0]=p;D[t+58|0]=p;D[t+56|0]=p;D[t+54|0]=p;D[t+52|0]=p;D[t+50|0]=p;D[t+48|0]=p;D[t+46|0]=p;D[t+44|0]=p;D[t+42|0]=p}F[k+8>>2]=0;F[k+12>>2]=0;D[k+7|0]=192;p=0;D[k+3|0]=0;D[k+4|0]=0;D[k+5|0]=0;D[k+6|0]=0;D[k+2|0]=1;D[k|0]=66;D[k+1|0]=132;F[t+112>>2]=17;f=t+112|0;Vb(k,t+32|0,f,4);Vb(k,vb,f,4);while(1){f=126-(p<<1)|0;l=k+(f>>>3|0)|0;m=l;n=G[l|0];l=t+42|0;D[m|0]=n|G[G[l+p|0]+207568|0]<<(f&6);f=p|1;m=126-(f<<1)|0;n=k+(m>>>3|0)|0;D[n|0]=G[n|0]|G[G[f+l|0]+207568|0]<<(m&4);p=p+2|0;if((p|0)!=32){continue}break}break p}w=G[u|0];x=G[u+1|0];u=G[u+2|0];D[t+127|0]=255;D[t+123|0]=255;D[t+119|0]=255;D[t+115|0]=255;m=p<<4;y=F[m+12764>>2];p=(u<<3|u>>>2)&255;u=y+p|0;O=(u|0)>=255?255:u;D[t+126|0]=u>>>0<256?u:(O|0)>0?O:0;u=(x<<3|x>>>2)&255;x=u+y|0;O=(x|0)>=255?255:x;D[t+125|0]=x>>>0<256?x:(O|0)>0?O:0;x=(w<<3|w>>>2)&255;w=x+y|0;y=(w|0)>=255?255:w;D[t+124|0]=w>>>0<256?w:(y|0)>0?y:0;y=F[m+12760>>2];w=y+p|0;O=(w|0)>=255?255:w;D[t+122|0]=w>>>0<256?w:(O|0)>0?O:0;w=u+y|0;O=(w|0)>=255?255:w;D[t+121|0]=w>>>0<256?w:(O|0)>0?O:0;w=x+y|0;y=(w|0)>=255?255:w;D[t+120|0]=w>>>0<256?w:(y|0)>0?y:0;y=F[m+12756>>2];w=y+p|0;O=(w|0)>=255?255:w;D[t+118|0]=w>>>0<256?w:(O|0)>0?O:0;w=u+y|0;O=(w|0)>=255?255:w;D[t+117|0]=w>>>0<256?w:(O|0)>0?O:0;w=x+y|0;y=(w|0)>=255?255:w;D[t+116|0]=w>>>0<256?w:(y|0)>0?y:0;y=p;p=F[m+12752>>2];m=y+p|0;w=(m|0)>=255?255:m;D[t+114|0]=m>>>0<256?m:(w|0)>0?w:0;m=p+u|0;u=(m|0)>=255?255:m;D[t+113|0]=m>>>0<256?m:(u|0)>0?u:0;m=p+x|0;p=(m|0)>=255?255:m;D[t+112|0]=m>>>0<256?m:(p|0)>0?p:0;u=t+112|0;f=u+(f<<2)|0;m=G[f|0];D[t+32|0]=m;p=G[f+1|0];D[t+34|0]=p;f=G[f+2|0];D[t+36|0]=f;u=u+(l<<2)|0;x=G[u|0];D[t+33|0]=x;w=G[u+1|0];D[t+35|0]=w;u=G[u+2|0];D[t+37|0]=u;y=u+(w+x|0)|0;O=f+(m+p|0)|0;if(y>>>0>>0){D[t+37|0]=f;D[t+36|0]=u;D[t+35|0]=p;D[t+34|0]=w;D[t+33|0]=m;D[t+32|0]=x}za:{if(!q){D[t+73|0]=0;D[t+71|0]=0;D[t+69|0]=0;D[t+67|0]=0;D[t+65|0]=0;D[t+63|0]=0;D[t+61|0]=0;D[t+59|0]=0;D[t+57|0]=0;D[t+55|0]=0;D[t+53|0]=0;D[t+51|0]=0;D[t+49|0]=0;D[t+47|0]=0;D[t+45|0]=0;D[t+43|0]=0;D[t+38|0]=255;D[t+39|0]=255;break za}m=n+L(H[k+2>>1],11)|0;f=G[m+9|0];x=G[m+8|0];p=s+(H[k>>1]<<3)|0;n=G[p+4|0]<<4;p=G[p+1|0];p=p<<3|p>>>2;s=F[n+12764>>2]+p|0;u=(s|0)>=255?255:s;F[t+108>>2]=s>>>0<256?s:(u|0)>0?u:0;s=p+F[n+12760>>2]|0;u=(s|0)>=255?255:s;F[t+104>>2]=s>>>0<256?s:(u|0)>0?u:0;s=p+F[n+12756>>2]|0;u=(s|0)>=255?255:s;F[t+100>>2]=s>>>0<256?s:(u|0)>0?u:0;n=p+F[n+12752>>2]|0;p=(n|0)>=255?255:n;F[t+96>>2]=n>>>0<256?n:(p|0)>0?p:0;n=t+96|0;D[t+38|0]=F[n+(x<<2)>>2];D[t+39|0]=F[n+(f<<2)>>2];n=G[m|0];D[t+49|0]=(f|0)==(n>>>6|0);D[t+43|0]=(f|0)==(n&3);D[t+47|0]=(f|0)==(n>>>4&3);D[t+45|0]=(f|0)==(n>>>2&3);n=G[m+1|0];D[t+57|0]=(f|0)==(n>>>6|0);D[t+51|0]=(f|0)==(n&3);D[t+55|0]=(f|0)==(n>>>4&3);D[t+53|0]=(f|0)==(n>>>2&3);n=G[m+2|0];D[t+65|0]=(f|0)==(n>>>6|0);D[t+59|0]=(f|0)==(n&3);D[t+63|0]=(f|0)==(n>>>4&3);D[t+61|0]=(f|0)==(n>>>2&3);m=G[m+3|0];D[t+73|0]=(f|0)==(m>>>6|0);D[t+67|0]=(f|0)==(m&3);D[t+71|0]=(f|0)==(m>>>4&3);D[t+69|0]=(f|0)==(m>>>2&3)}f=y>>>0>>0;m=G[v|0];D[t+48|0]=f^(l|0)==(m>>>6|0);D[t+42|0]=f^(l|0)==(m&3);D[t+46|0]=f^(l|0)==(m>>>4&3);D[t+44|0]=f^(l|0)==(m>>>2&3);m=G[v+1|0];D[t+56|0]=f^(l|0)==(m>>>6|0);D[t+50|0]=f^(l|0)==(m&3);D[t+54|0]=f^(l|0)==(m>>>4&3);D[t+52|0]=f^(l|0)==(m>>>2&3);m=G[v+2|0];D[t+64|0]=f^(l|0)==(m>>>6|0);D[t+58|0]=f^(l|0)==(m&3);D[t+62|0]=f^(l|0)==(m>>>4&3);D[t+60|0]=f^(l|0)==(m>>>2&3);m=G[v+3|0];D[t+72|0]=f^(l|0)==(m>>>6|0);D[t+66|0]=f^(l|0)==(m&3);D[t+70|0]=f^(l|0)==(m>>>4&3);D[t+68|0]=f^(l|0)==(m>>>2&3);F[k+12>>2]=0;D[k+11|0]=192;D[k+3|0]=0;D[k+4|0]=0;D[k+5|0]=0;D[k+6|0]=0;D[k+7|0]=0;D[k+8|0]=0;D[k+9|0]=0;D[k+10|0]=0;D[k+2|0]=1;D[k|0]=65;D[k+1|0]=132;f=8;p=17;m=G[t+32|0];while(1){l=k+(p>>3)|0;n=l;s=G[l|0];l=p&7;D[n|0]=s|m<>>l|0;p=l+p|0;f=f-l|0;if(f){continue}break}f=8;m=G[t+33|0];while(1){l=k+(p>>3)|0;n=l;s=G[l|0];l=p&7;D[n|0]=s|m<>>l|0;p=l+p|0;f=f-l|0;if(f){continue}break}f=8;m=G[t+34|0];while(1){l=k+(p>>3)|0;n=l;s=G[l|0];l=p&7;D[n|0]=s|m<>>l|0;p=l+p|0;f=f-l|0;if(f){continue}break}f=8;m=G[t+35|0];while(1){l=k+(p>>3)|0;n=l;s=G[l|0];l=p&7;D[n|0]=s|m<>>l|0;p=l+p|0;f=f-l|0;if(f){continue}break}f=8;m=G[t+36|0];while(1){l=k+(p>>3)|0;n=l;s=G[l|0];l=p&7;D[n|0]=s|m<>>l|0;p=l+p|0;f=f-l|0;if(f){continue}break}f=8;m=G[t+37|0];while(1){l=k+(p>>3)|0;n=l;s=G[l|0];l=p&7;D[n|0]=s|m<>>l|0;p=l+p|0;f=f-l|0;if(f){continue}break}f=8;m=G[t+38|0];while(1){l=k+(p>>3)|0;n=l;s=G[l|0];l=p&7;D[n|0]=s|m<>>l|0;p=l+p|0;f=f-l|0;if(f){continue}break}f=8;m=G[t+39|0];while(1){l=k+(p>>3)|0;n=l;s=G[l|0];l=p&7;D[n|0]=s|m<>>l|0;p=l+p|0;f=f-l|0;if(f){continue}break}p=0;while(1){f=127-p|0;l=k+(f>>>3|0)|0;m=l;n=G[l|0];l=t+42|0;D[m|0]=n|G[l+p|0]<<(f&7);f=p|1;m=127-f|0;n=k+(m>>>3|0)|0;D[n|0]=G[n|0]|G[f+l|0]<<(m&6);p=p+2|0;if((p|0)!=32){continue}break}break p}n=G[u+1|0];l=G[u+2|0];m=G[u|0];F[k+12>>2]=0;F[k+4>>2]=-1;F[k+8>>2]=0;D[k|0]=252;D[k+1|0]=253;D[k+2|0]=255;D[k+3|0]=255;p=F[((p<<4)+(f<<2)|0)+12752>>2];f=p+(m<<3|m>>>2)|0;m=(f|0)>=255?255:f;f=f>>>0<256?f:(m|0)>0?m:0;m=f<<8|f;l=p+(l<<3|l>>>2)|0;s=(l|0)>=255?255:l;n=p+(n<<3|n>>>2)|0;v=(n|0)>=255?255:n;f=16;p=64;while(1){u=k+(p>>3)|0;y=u;A=G[u|0];u=p&7;D[y|0]=A|m<>>u|0;p=p+u|0;f=f-u|0;if(f){continue}break}f=n>>>0<256?n:(v|0)>0?v:0;m=f<<8|f;f=16;while(1){n=k+(p>>3)|0;u=n;y=G[n|0];n=p&7;D[u|0]=y|m<>>n|0;p=n+p|0;f=f-n|0;if(f){continue}break}f=l>>>0<256?l:(s|0)>0?s:0;m=f<<8|f;f=16;while(1){l=k+(p>>3)|0;n=l;s=G[l|0];l=p&7;D[n|0]=s|m<>>l|0;p=l+p|0;f=f-l|0;if(f){continue}break}m=x<<8|x;f=16;while(1){l=k+(p>>3)|0;n=l;s=G[l|0];l=p&7;D[n|0]=s|m<>>l|0;p=l+p|0;f=f-l|0;if(f){continue}break}break p}f=L(J+wa|0,h)+b|0;k=G[u+4|0];l=G[v+8|0];m=G[v+9|0];if((l|0)!=(m|0)){Aa:{if(!(l|((m|0)!=3|k>>>0<7))){if(G[v+10|0]==2){break Aa}}m=L(F[((l<<4)+(m<<2)|0)+432544>>2],10);n=k<<5;k=m+L(n+G[u+2|0]|0,60)<<2;l=m+L(n+G[u+1|0]|0,60)<<2;m=m+L(n+G[u|0]|0,60)<<2;p=H[k+207846>>1]+(H[l+269286>>1]+H[m+207846>>1]|0)|0;s=H[k+207842>>1]+(H[l+269282>>1]+H[m+207842>>1]|0)|0;n=p>>>0>>0;y=k;A=n;u=H[k+207850>>1]+(H[l+269290>>1]+H[m+207850>>1]|0)|0;n=n?p:s;p=u>>>0>>0;A=p?2:A;s=H[k+207854>>1]+(H[l+269294>>1]+H[m+207854>>1]|0)|0;n=p?u:n;p=s>>>0>>0;A=p?3:A;u=H[k+207858>>1]+(H[l+269298>>1]+H[m+207858>>1]|0)|0;n=p?s:n;p=u>>>0>>0;A=p?4:A;s=H[k+207862>>1]+(H[l+269302>>1]+H[m+207862>>1]|0)|0;n=p?u:n;p=s>>>0>>0;A=p?5:A;u=H[k+207866>>1]+(H[l+269306>>1]+H[m+207866>>1]|0)|0;n=p?s:n;p=u>>>0>>0;A=p?6:A;s=H[k+207870>>1]+(H[l+269310>>1]+H[m+207870>>1]|0)|0;n=p?u:n;p=s>>>0>>0;A=p?7:A;u=H[k+207874>>1]+(H[l+269314>>1]+H[m+207874>>1]|0)|0;n=p?s:n;p=u>>>0>>0;n=H[k+207878>>1]+(H[l+269318>>1]+H[m+207878>>1]|0)>>>0<(p?u:n)>>>0?9:p?8:A;k=n<<2;p=y+k|0;l=k+l|0;s=G[l+269281|0]<<5;D[f+2|0]=G[p+207841|0]|s;l=G[l+269280|0]<<5;D[f|0]=l|G[p+207840|0];m=k+m|0;D[f+3|0]=(s|G[m+207841|0]<<11)>>>8;D[f+1|0]=(l|G[m+207840|0]<<10)>>>8;if((n|0)!=6){l=G[v|0];m=G[v+1|0];n=G[v+2|0];k=k+330720|0;p=G[v+3|0];D[f+7|0]=G[k+(p>>>2&3)|0]<<2|G[k+(p&3)|0]|G[k+(p>>>4&3)|0]<<4|G[k+(p>>>6|0)|0]<<6;D[f+6|0]=G[k+(n&3)|0]|G[k+(n>>>2&3)|0]<<2|G[k+(n>>>4&3)|0]<<4|G[k+(n>>>6|0)|0]<<6;D[f+5|0]=G[k+(m&3)|0]|G[k+(m>>>2&3)|0]<<2|G[k+(m>>>4&3)|0]<<4|G[k+(m>>>6|0)|0]<<6;D[f+4|0]=G[k+(l&3)|0]|G[k+(l>>>2&3)|0]<<2|G[k+(l>>>4&3)|0]<<4|G[k+(l>>>6|0)|0]<<6;break p}D[f+4|0]=G[v|0];D[f+5|0]=G[v+1|0];D[f+6|0]=G[v+2|0];D[f+7|0]=G[v+3|0];break p}p=k<<4;l=F[p+12752>>2];k=G[u|0];s=(k<<3|k>>>2)&255;k=l+s|0;m=(k|0)>=255?255:k;x=G[(((k>>>0<256?k:(m|0)>0?m:0)&255)<<1)+431521|0];k=G[u+1|0];w=(k<<3|k>>>2)&255;k=w+l|0;m=(k|0)>=255?255:k;n=l;l=G[u+2|0];u=(l<<3|l>>>2)&255;l=n+u|0;n=(l|0)>=255?255:l;k=G[(((k>>>0<256?k:(m|0)>0?m:0)&255)<<1)+431521|0]<<5;D[f|0]=k|G[(((l>>>0<256?l:(n|0)>0?n:0)&255)<<1)+431521|0];D[f+1|0]=(k|x<<10)>>>8;l=F[p+12764>>2];k=l+s|0;m=(k|0)>=255?255:k;p=G[(((k>>>0<256?k:(m|0)>0?m:0)&255)<<1)+431521|0];k=l+w|0;m=(k|0)>=255?255:k;l=l+u|0;n=(l|0)>=255?255:l;k=G[(((k>>>0<256?k:(m|0)>0?m:0)&255)<<1)+432033|0]<<5;D[f+2|0]=k|G[(((l>>>0<256?l:(n|0)>0?n:0)&255)<<1)+431521|0];D[f+3|0]=(k|p<<11)>>>8;D[f+4|0]=G[v|0];D[f+5|0]=G[v+1|0];D[f+6|0]=G[v+2|0];D[f+7|0]=G[v+3|0];break p}l=F[((k<<4)+(l<<2)|0)+12752>>2];m=G[u|0];k=l+(m<<3|m>>>2)|0;m=(k|0)>=255?255:k;p=(k>>>0<256?k:(m|0)>0?m:0)<<1;s=G[p+429984|0];k=G[u+1|0];k=l+(k<<3|k>>>2)|0;m=(k|0)>=255?255:k;n=G[u+2|0];l=l+(n<<3|n>>>2)|0;n=(l|0)>=255?255:l;k=(k>>>0<256?k:(m|0)>0?m:0)<<1;m=G[k+430496|0]<<5;l=(l>>>0<256?l:(n|0)>0?n:0)<<1;D[f|0]=m|G[l+429984|0];D[f+1|0]=(m|s<<10)>>>8;m=G[p+429985|0];l=G[l+429985|0];k=G[k+430497|0];D[f+4|0]=85;D[f+5|0]=85;D[f+6|0]=85;D[f+7|0]=85;k=k<<5;D[f+2|0]=k|l;D[f+3|0]=(k|m<<11)>>>8;break p}f=G[u+4|0]<<4;s=F[f+12764>>2];k=G[u|0];k=(k<<3|k>>>2)&255;l=s+k|0;x=(l|0)>=255?255:l;n=G[u+1|0];n=(n<<3|n>>>2)&255;p=n+s|0;w=(p|0)>=255?255:p;y=s;s=G[u+2|0];s=(s<<3|s>>>2)&255;u=y+s|0;y=(u|0)>=255?255:u;l=L((l>>>0<256?l:(x|0)>0?x:0)&255,15)+128|0;A=(l>>>8|0)+l<<4&61440;l=L((p>>>0<256?p:(w|0)>0?w:0)&255,15)+128|0;p=A|(l>>>8|0)+l&16128;l=L((u>>>0<256?u:(y|0)>0?y:0)&255,15)+128|0;E[t+38>>1]=p|(l>>>8|0)+l>>>4&1008;u=F[f+12760>>2];l=u+k|0;x=(l|0)>=255?255:l;p=n+u|0;w=(p|0)>=255?255:p;u=s+u|0;y=(u|0)>=255?255:u;l=L((l>>>0<256?l:(x|0)>0?x:0)&255,15)+128|0;A=(l>>>8|0)+l<<4&61440;l=L((p>>>0<256?p:(w|0)>0?w:0)&255,15)+128|0;p=A|(l>>>8|0)+l&16128;l=L((u>>>0<256?u:(y|0)>0?y:0)&255,15)+128|0;E[t+36>>1]=p|(l>>>8|0)+l>>>4&1008;u=F[f+12756>>2];l=u+k|0;x=(l|0)>=255?255:l;p=n+u|0;w=(p|0)>=255?255:p;u=s+u|0;y=(u|0)>=255?255:u;l=L((l>>>0<256?l:(x|0)>0?x:0)&255,15)+128|0;A=(l>>>8|0)+l<<4&61440;l=L((p>>>0<256?p:(w|0)>0?w:0)&255,15)+128|0;p=A|(l>>>8|0)+l&16128;l=L((u>>>0<256?u:(y|0)>0?y:0)&255,15)+128|0;E[t+34>>1]=p|(l>>>8|0)+l>>>4&1008;l=F[f+12752>>2];f=l+k|0;p=(f|0)>=255?255:f;k=l+n|0;n=(k|0)>=255?255:k;l=l+s|0;s=(l|0)>=255?255:l;f=L((f>>>0<256?f:(p|0)>0?p:0)&255,15)+128|0;p=(f>>>8|0)+f<<4&61440;f=L((k>>>0<256?k:(n|0)>0?n:0)&255,15)+128|0;k=p|(f>>>8|0)+f&16128;f=L((l>>>0<256?l:(s|0)>0?s:0)&255,15)+128|0;E[t+32>>1]=k|(f>>>8|0)+f>>>4&1008;if(!oa){break p}f=J<<2;k=o-f|0;u=(k|0)>=4?4:k;x=m&-2;w=m&1;f=(f+ca<<1)+b|0;l=0;while(1){Ba:{if(!u){break Ba}k=G[l+v|0];p=0;s=0;if((m|0)!=1){while(1){n=p<<1;y=n+f|0;E[y>>1]=H[(t+32|0)+((k>>>n&3)<<1)>>1]|H[y>>1]&15;n=n|2;y=n+f|0;E[y>>1]=H[(t+32|0)+((k>>>n&3)<<1)>>1]|H[y>>1]&15;p=p+2|0;s=s+2|0;if((x|0)!=(s|0)){continue}break}}if(!w){break Ba}n=p<<1;p=n+f|0;E[p>>1]=H[(t+32|0)+((k>>>n&3)<<1)>>1]|H[p>>1]&15}f=f+da|0;l=l+1|0;if((ha|0)!=(l|0)){continue}break}break p}Sc(L(J+wa|0,h)+b|0,u,v);break p}k=L(J+wa|0,h)+b|0;F[k+4>>2]=F[k+4>>2]&2147450878|32768;n=n+L(H[k+2>>1],11)|0;O=G[n+10|0];l=s+(H[k>>1]<<3)|0;f=G[l+4|0]<<4;l=G[l+1|0];l=l<<3|l>>>2;m=F[f+12764>>2]+l|0;p=(m|0)>=255?255:m;x=m>>>0<256?m:(p|0)>0?p:0;F[t+124>>2]=x;m=l+F[f+12760>>2]|0;p=(m|0)>=255?255:m;w=m>>>0<256?m:(p|0)>0?p:0;F[t+120>>2]=w;m=l+F[f+12756>>2]|0;p=(m|0)>=255?255:m;y=m>>>0<256?m:(p|0)>0?p:0;F[t+116>>2]=y;f=l+F[f+12752>>2]|0;l=(f|0)>=255?255:f;f=f>>>0<256?f:(l|0)>0?l:0;F[t+112>>2]=f;p=G[n+8|0];l=F[(t+112|0)+(p<<2)>>2];Ca:{Da:{Ea:{if((O|0)==1){break Ea}m=G[n+9|0];m=m>>>0

>>0?p:m;while(1){if((m|0)==(p|0)){break Ea}p=p+1|0;if(F[(t+112|0)+(p<<2)>>2]==(l|0)){continue}break}l=-1;break Da}if((l|0)>249){break Ca}}s=G[v+9|0];m=G[v+8|0];S=G[v+10|0];A=G[u+4|0];p=G[u|0];O=G[u+1|0];Q=G[u+2|0];Ha=x>>>0>=256?-1:x;D[t+111|0]=Ha;Sa=w>>>0>=256?-1:w;D[t+107|0]=Sa;Ia=y>>>0>=256?-1:y;D[t+103|0]=Ia;ba=f>>>0>=256?-1:f;D[t+99|0]=ba;u=A<<4;f=F[u+12764>>2];x=Q<<3|Q>>>2;w=f+x|0;Ja=w>>>0<256?w:(w^-1)>>31;D[t+110|0]=Ja;w=O<<3|O>>>2;y=w+f|0;Xa=y>>>0<256?y:(y^-1)>>31;D[t+109|0]=Xa;y=p<<3|p>>>2;f=y+f|0;Za=f>>>0<256?f:(f^-1)>>31;D[t+108|0]=Za;f=F[u+12760>>2];p=f+x|0;_a=p>>>0<256?p:(p^-1)>>31;D[t+106|0]=_a;p=f+w|0;Da=p>>>0<256?p:(p^-1)>>31;D[t+105|0]=Da;f=f+y|0;$a=f>>>0<256?f:(f^-1)>>31;D[t+104|0]=$a;f=F[u+12756>>2];p=f+x|0;ab=p>>>0<256?p:(p^-1)>>31;D[t+102|0]=ab;p=f+w|0;bb=p>>>0<256?p:(p^-1)>>31;D[t+101|0]=bb;f=f+y|0;cb=f>>>0<256?f:(f^-1)>>31;D[t+100|0]=cb;f=F[u+12752>>2];p=f+x|0;db=p>>>0<256?p:(p^-1)>>31;D[t+98|0]=db;p=f+w|0;Ua=p>>>0<256?p:(p^-1)>>31;D[t+97|0]=Ua;f=f+y|0;Va=f>>>0<256?f:(f^-1)>>31;D[t+96|0]=Va;Fa:{Ga:{Ha:{if(S>>>0<2){break Ha}S=m>>>0>s>>>0?m:s;p=(t+96|0)+(m<<2)|0;f=m;while(1){if((f|0)==(S|0)){break Ha}O=G[p|0];f=f+1|0;Q=(t+96|0)+(f<<2)|0;if(!((O|0)!=G[Q|0]|G[p+1|0]!=G[Q+1|0])&G[p+2|0]==G[Q+2|0]){continue}break}if((l|0)<0){Ia:{if(!O){break Ia}f=(t+96|0)+(s<<2)|0;l=G[f|0];if((l|0)==255){break Ia}m=G[p+1|0];if(!m){break Ia}s=G[f+1|0];if((s|0)==255){break Ia}p=G[p+2|0];if(!p){break Ia}f=G[f+2|0];if((f|0)==255){break Ia}eb=G[(G[n+8|0]<<2)+za|0];if(!eb){break Ia}fb=G[(G[n+9|0]<<2)+za|0];if((fb|0)==255){break Ia}F[t+28>>2]=L(Ha&255,3);F[t+16>>2]=L(ba&255,3);F[t+20>>2]=L(Ia&255,3);F[t+24>>2]=L(Sa&255,3);F[t+32>>2]=((Ua&255)+(Va&255)|0)+(db&255);F[t+36>>2]=((bb&255)+(cb&255)|0)+(ab&255);F[t+40>>2]=((Da&255)+($a&255)|0)+(_a&255);F[t+44>>2]=((Xa&255)+(Za&255)|0)+(Ja&255);Y=M(M(f>>>0)*M(.003921568859368563));ia=M(M(s>>>0)*M(.003921568859368563));P=M(M(l>>>0)*M(.003921568859368563));_=M(M(p>>>0)*M(.003921568859368563));la=M(M(m>>>0)*M(.003921568859368563));na=M(M(O>>>0)*M(.003921568859368563));ea=t+32|0;f=ea;m=G[v|0];gb=F[(f|(m&3)<<2)>>2];Pa=t+16|0;l=Pa;p=G[n|0];hb=F[(l|(p&3)<<2)>>2];s=gb-hb|0;ib=F[(f|m&12)>>2];jb=F[(l|p&12)>>2];u=ib-jb|0;w=(s|0)>(u|0)?s:u;kb=F[(f|m>>>2&12)>>2];lb=F[(l|p>>>2&12)>>2];x=kb-lb|0;w=(w|0)>(x|0)?w:x;mb=F[(f|m>>>4&12)>>2];nb=F[(l|p>>>4&12)>>2];m=mb-nb|0;O=(m|0)<(w|0)?w:m;p=G[v+1|0];ob=F[(f|(p&3)<<2)>>2];w=G[n+1|0];pb=F[(l|(w&3)<<2)>>2];y=ob-pb|0;Q=(y|0)<(O|0)?O:y;qb=F[(f|p&12)>>2];rb=F[(l|w&12)>>2];O=qb-rb|0;S=(O|0)<(Q|0)?Q:O;sb=F[(f|p>>>2&12)>>2];tb=F[(l|w>>>2&12)>>2];Q=sb-tb|0;S=(Q|0)<(S|0)?S:Q;zb=F[(f|p>>>4&12)>>2];Ab=F[(l|w>>>4&12)>>2];p=zb-Ab|0;ka=(p|0)<(S|0)?S:p;w=G[v+2|0];Bb=F[(f|(w&3)<<2)>>2];S=G[n+2|0];Cb=F[(l|(S&3)<<2)>>2];A=Bb-Cb|0;qa=(A|0)<(ka|0)?ka:A;Db=F[(w&12|f)>>2];Eb=F[(S&12|l)>>2];ka=Db-Eb|0;fa=(ka|0)<(qa|0)?qa:ka;Fb=F[(w>>>2&12|f)>>2];Gb=F[(S>>>2&12|l)>>2];qa=Fb-Gb|0;fa=(fa|0)>(qa|0)?fa:qa;Hb=F[(w>>>4&12|f)>>2];Ib=F[(S>>>4&12|l)>>2];w=Hb-Ib|0;fa=(w|0)<(fa|0)?fa:w;S=G[v+3|0];Sb=F[(f|(S&3)<<2)>>2];f=G[n+3|0];Tb=F[(l|(f&3)<<2)>>2];l=Sb-Tb|0;ya=(l|0)<(fa|0)?fa:l;Ub=F[(S&12|ea)>>2];Wb=F[(f&12|Pa)>>2];fa=Ub-Wb|0;xb=(fa|0)<(ya|0)?ya:fa;Xb=F[(S>>>2&12|ea)>>2];Zb=F[(f>>>2&12|Pa)>>2];ya=Xb-Zb|0;xb=(ya|0)<(xb|0)?xb:ya;ea=F[(S>>>4&12|ea)>>2];Pa=F[(f>>>4&12|Pa)>>2];f=ea-Pa|0;s=(s|0)<(u|0)?s:u;s=(s|0)<(x|0)?s:x;m=(m|0)>(s|0)?s:m;m=(m|0)<(y|0)?m:y;m=(m|0)<(O|0)?m:O;m=(m|0)<(Q|0)?m:Q;m=(m|0)<(p|0)?m:p;m=(m|0)<(A|0)?m:A;m=(m|0)<(ka|0)?m:ka;m=(m|0)<(qa|0)?m:qa;m=(m|0)<(w|0)?m:w;l=(l|0)>(m|0)?m:l;l=(l|0)<(fa|0)?l:fa;l=(l|0)<(ya|0)?l:ya;xb=((f|0)<(xb|0)?xb:f)-((f|0)>(l|0)?l:f)|0;f=gb+hb|0;l=ib+jb|0;p=(f|0)>(l|0)?f:l;m=kb+lb|0;s=(m|0)<(p|0)?p:m;p=mb+nb|0;u=(p|0)<(s|0)?s:p;s=ob+pb|0;x=(s|0)<(u|0)?u:s;u=qb+rb|0;w=(u|0)<(x|0)?x:u;x=sb+tb|0;y=(w|0)>(x|0)?w:x;w=zb+Ab|0;O=(w|0)<(y|0)?y:w;y=Bb+Cb|0;Q=(y|0)<(O|0)?O:y;O=Db+Eb|0;S=(O|0)<(Q|0)?Q:O;Q=Fb+Gb|0;A=(Q|0)<(S|0)?S:Q;S=Hb+Ib|0;ka=(S|0)<(A|0)?A:S;A=Sb+Tb|0;qa=(A|0)<(ka|0)?ka:A;ka=Ub+Wb|0;fa=(ka|0)<(qa|0)?qa:ka;qa=Xb+Zb|0;ya=(fa|0)>(qa|0)?fa:qa;fa=ea+Pa|0;f=(f|0)<(l|0)?f:l;f=(f|0)<(m|0)?f:m;f=(f|0)<(p|0)?f:p;f=(f|0)<(s|0)?f:s;f=(f|0)<(u|0)?f:u;f=(f|0)<(x|0)?f:x;f=(f|0)<(w|0)?f:w;f=(f|0)<(y|0)?f:y;f=(f|0)<(O|0)?f:O;f=(f|0)<(Q|0)?f:Q;f=(f|0)<(S|0)?f:S;f=(f|0)<(A|0)?f:A;f=(f|0)<(ka|0)?f:ka;f=(f|0)<(qa|0)?f:qa;Ja:{if((xb|0)<=(((fa|0)<(ya|0)?ya:fa)-((f|0)<(fa|0)?f:fa)|0)){T=P;W=ia;X=Y;P=na;ia=la;Y=_;break Ja}T=na;W=la;X=_}la=M(M(fb>>>0)*M(.003921568859368563));_=M(M(eb>>>0)*M(.003921568859368563));break Ga}m=0;s=0;x=0;l=0;p=0;while(1){u=p>>>2|0;w=G[u+v|0];f=(t+32|0)+(p<<2)|0;y=G[n+u|0];u=p<<1&6;y=G[((y>>>u&3)<<2)+za|0];D[f+3|0]=y;u=t+96|(w>>>u&3)<<2;w=G[u+2|0];D[f+2|0]=w;O=G[u+1|0];D[f+1|0]=O;A=f;f=G[u|0];D[A|0]=f;l=l+y|0;x=w+x|0;s=s+O|0;m=f+m|0;p=p+1|0;if((p|0)!=16){continue}break}ia=M(s>>>0);P=M(ia*M(.00024509805371053517));Lb=M(0);Mb=M(0);T=M(m>>>0);Y=M(T*M(.00024509805371053517));Ka:{if(YM(1))){break Ka}Mb=M(1)}W=M(x>>>0);Y=M(W*M(.00024509805371053517));La:{if(PM(1))){break La}Lb=M(1)}X=M(l>>>0);P=M(X*M(.00024509805371053517));Nb=M(0);_=M(0);Ma:{if(YM(1))){break Ma}_=M(1)}_b=_;Ob=M(X*M(.0625));Pb=M(W*M(.0625));Qb=M(ia*M(.0625));Rb=M(T*M(.0625));Na:{if(PM(1))){break Na}Nb=M(1)}T=M(M(G[t+34|0])-Pb);P=M(M(G[t+35|0])-Ob);la=M(T*P);W=M(M(G[t+33|0])-Qb);na=M(W*P);ia=M(W*T);X=M(M(G[t+32|0])-Rb);Ba=M(X*P);Ka=M(X*T);Fa=M(X*W);Ga=M(P*P);Jb=M(T*T);_=M(X*X);Kb=M(W*W);Y=M(Ga+M(Jb+M(_+Kb)));if(Y!=M(0)){Y=M(M(1)/M(U(Y)));P=M(P*Y);W=M(W*Y);X=M(X*Y);T=M(T*Y)}_=M(M(M(Ba*P)+M(M(Ka*T)+M(M(_*X)+M(Fa*W))))+M(0));Y=M(M(M(na*P)+M(M(ia*T)+M(M(Fa*X)+M(Kb*W))))+M(0));ia=M(M(M(la*P)+M(M(Jb*T)+M(M(Ka*X)+M(ia*W))))+M(0));T=M(M(M(Ga*P)+M(M(la*T)+M(M(Ba*X)+M(na*W))))+M(0));l=1;while(1){f=(t+32|0)+(l<<2)|0;na=M(M(G[f+2|0])-Pb);Ba=M(M(G[f+3|0])-Ob);Jb=M(na*Ba);Ka=M(M(G[f+1|0])-Qb);Kb=M(Ka*Ba);Fa=M(M(G[f|0])-Rb);$b=M(Fa*Ba);la=T;X=ia;P=_;W=Y;Ga=M(M(T*T)+M(M(X*X)+M(M(P*P)+M(W*W))));if(Ga!=M(0)){Ga=M(M(1)/M(U(Ga)));la=M(T*Ga);X=M(X*Ga);W=M(W*Ga);P=M(P*Ga)}T=M(T+M(M(M(Ba*Ba)*la)+M(M(Jb*X)+M(M($b*P)+M(Kb*W)))));Ga=M(M(na*na)*X);Ba=M(Fa*na);na=M(Ka*na);ia=M(ia+M(M(Jb*la)+M(Ga+M(M(Ba*P)+M(na*W)))));Ga=M(na*X);na=M(Fa*Ka);Y=M(Y+M(M(Kb*la)+M(Ga+M(M(na*P)+M(M(Ka*Ka)*W)))));_=M(_+M(M($b*la)+M(M(Ba*X)+M(M(M(Fa*Fa)*P)+M(na*W)))));l=l+1|0;if((l|0)!=16){continue}break}P=M(M(T*T)+M(M(ia*ia)+M(M(_*_)+M(Y*Y))));if(P!=M(0)){P=M(M(1)/M(U(P)));T=M(T*P);ia=M(ia*P);_=M(_*P);Y=M(Y*P);P=M(M(T*T)+M(M(ia*ia)+M(M(_*_)+M(Y*Y))))}if(PX?X:P;l=l+1|0;if((l|0)!=16){continue}break}la=M(X*M(.003921568859368563));na=M(ia*la);P=M(Lb+M(Y*la));Ba=M(0);Ka=M(0);X=M(Mb+M(_*la));Oa:{if(XM(1))){break Oa}Ka=M(1)}la=M(T*la);X=M(_b+na);Pa:{if(PM(1))){break Pa}Ba=M(1)}P=_;_=M(W*M(.003921568859368563));W=M(P*_);P=M(Nb+la);na=M(0);Fa=M(0);Qa:{if(XM(1))){break Qa}Fa=M(1)}X=M(Y*_);Y=M(Mb+W);Ra:{if(PM(1))){break Ra}na=M(1)}la=M(ia*_);W=M(Lb+X);ia=M(0);P=M(0);Sa:{if(YM(1))){break Sa}P=M(1)}Y=M(T*_);T=M(_b+la);Ta:{if(WM(1))){break Ta}ia=M(1)}W=M(Nb+Y);_=M(0);Y=M(0);Ua:{if(TM(1))){break Ua}Y=M(1)}Va:{if(WM(1))){break Va}_=M(1)}if(!(_>>0)*M(.003921568859368563));Y=M(M(G[p+2|0])*M(.003921568859368563));ia=M(M(G[p+1|0])*M(.003921568859368563));f=(t+96|0)+(s<<2)|0;X=M(M(G[f+2|0])*M(.003921568859368563));W=M(M(G[f+1|0])*M(.003921568859368563));T=M(M(G[f|0])*M(.003921568859368563));la=M(M(l|0)*M(.003921568859368563));_=la;break Ga}if((l|0)>=0){break Fa}_=M(M(G[(G[n+8|0]<<2)+za|0])*M(.003921568859368563));la=M(M(G[(G[n+9|0]<<2)+za|0])*M(.003921568859368563));f=(t+96|0)+(m<<2)|0;T=M(M(G[f|0])*M(.003921568859368563));P=T;W=M(M(G[f+1|0])*M(.003921568859368563));ia=W;X=M(M(G[f+2|0])*M(.003921568859368563));Y=X}W=M(M(W*M(15))+M(.5));Wa:{if(M(N(W))>>0<256?f:(f^-1)>>31;p=l<<20&15728640;T=M(M(T*M(15))+M(.5));Xa:{if(M(N(T))>>0<256?f:(f^-1)>>31;p=p|m<<24&251658240;T=M(M(X*M(15))+M(.5));Ya:{if(M(N(T))>>0<256?f:(f^-1)>>31;p=p|w<<16&983040;T=M(M(la*M(7))+M(.5));Za:{if(M(N(T))>>0<256?f:(f^-1)>>31;u=p|s<<28&1879048192;P=M(M(P*M(15))+M(.5));_a:{if(M(N(P))>>0<256?f:(f^-1)>>31;u=u|p<<8&3840;P=M(M(ia*M(15))+M(.5));$a:{if(M(N(P))>>0<256?f:(f^-1)>>31;u=u|x<<4&240;P=M(M(Y*M(7))+M(.5));ab:{if(M(N(P))>>0<256?f:(f^-1)>>31;u=u|Q<<1&14;P=M(M(_*M(7))+M(.5));bb:{if(M(N(P))>>0<256?f:(f^-1)>>31;F[k+4>>2]=u|f<<12&28672|32768;m=m<<1|(m&248)>>>3;u=(m<<3|(m&252)>>>2)&255;m=p<<1|(p&248)>>>3;y=(m<<3|(m&252)>>>2)&255;u=u-y|0;m=s<<1|1;s=(f<<5|f<<1)&254;p=((m<<4|m)&255)-s|0;f=l<<1|(l&248)>>>3;l=(f<<3|(f&252)>>>2)&255;f=x<<1|(x&248)>>>3;O=(f<<3|(f&252)>>>2)&255;x=l-O|0;f=w<<1|(w&248)>>>3;l=(f<<3|(f&252)>>>2)&255;f=Q<<2|(Q&254)>>>1;Q=(f<<3|(f&252)>>>2)&255;w=l-Q|0;m=((L(u,u)+L(p,p)|0)+L(x,x)|0)+L(w,w)|0;f=m>>>1|0;l=L(m,13)>>>4|0;m=L(m,3)>>>4|0;if(w|(u|x)){F[t+28>>2]=L(p,(Ha&255)-s|0);F[t+16>>2]=L(p,(ba&255)-s|0);F[t+20>>2]=L(p,(Ia&255)-s|0);F[t+24>>2]=L(p,(Sa&255)-s|0);F[t+32>>2]=(L(x,(Ua&255)-O|0)+L(u,(Va&255)-y|0)|0)+L(w,(db&255)-Q|0);F[t+36>>2]=(L(x,(bb&255)-O|0)+L(u,(cb&255)-y|0)|0)+L(w,(ab&255)-Q|0);F[t+40>>2]=(L(x,(Da&255)-O|0)+L(u,($a&255)-y|0)|0)+L(w,(_a&255)-Q|0);F[t+44>>2]=(L(x,(Xa&255)-O|0)+L(u,(Za&255)-y|0)|0)+L(w,(Ja&255)-Q|0);y=t+16|0;p=y;u=G[n|0];s=t+32|0;x=G[v|0];w=F[(p|u&12)>>2]+F[(s|x&12)>>2]|0;A=(((w|0)>=(l|0))+((f|0)<=(w|0))|0)+((m|0)<=(w|0))<<2;w=F[(p|(u&3)<<2)>>2]+F[(s|(x&3)<<2)>>2]|0;A=A|(((w|0)>=(l|0))+((f|0)<=(w|0))|0)+((m|0)<=(w|0));w=F[(p|u>>>2&12)>>2]+F[(s|x>>>2&12)>>2]|0;u=F[(p|u>>>4&12)>>2]+F[(s|x>>>4&12)>>2]|0;D[k|0]=A|(((w|0)>=(l|0))+((f|0)<=(w|0))|0)+((m|0)<=(w|0))<<4|(((u|0)>=(l|0))+((f|0)<=(u|0))|0)+((m|0)<=(u|0))<<6;u=G[n+1|0];x=G[v+1|0];w=F[(p|u&12)>>2]+F[(s|x&12)>>2]|0;A=(((w|0)>=(l|0))+((f|0)<=(w|0))|0)+((m|0)<=(w|0))<<2;w=F[(p|(u&3)<<2)>>2]+F[(s|(x&3)<<2)>>2]|0;A=A|(((w|0)>=(l|0))+((f|0)<=(w|0))|0)+((m|0)<=(w|0));w=F[(p|u>>>2&12)>>2]+F[(s|x>>>2&12)>>2]|0;u=F[(p|u>>>4&12)>>2]+F[(s|x>>>4&12)>>2]|0;D[k+1|0]=A|(((w|0)>=(l|0))+((f|0)<=(w|0))|0)+((m|0)<=(w|0))<<4|(((u|0)>=(l|0))+((f|0)<=(u|0))|0)+((m|0)<=(u|0))<<6;u=G[n+2|0];x=G[v+2|0];w=F[(p|u&12)>>2]+F[(s|x&12)>>2]|0;A=(((w|0)>=(l|0))+((f|0)<=(w|0))|0)+((m|0)<=(w|0))<<2;w=F[((u&3)<<2|p)>>2]+F[((x&3)<<2|s)>>2]|0;A=A|(((w|0)>=(l|0))+((f|0)<=(w|0))|0)+((m|0)<=(w|0));w=F[(u>>>2&12|p)>>2]+F[(x>>>2&12|s)>>2]|0;u=F[(u>>>4&12|p)>>2]+F[(x>>>4&12|s)>>2]|0;D[k+2|0]=A|(((w|0)>=(l|0))+((f|0)<=(w|0))|0)+((m|0)<=(w|0))<<4|(((u|0)>=(l|0))+((f|0)<=(u|0))|0)+((m|0)<=(u|0))<<6;u=k;k=G[n+3|0];n=G[v+3|0];p=F[(p|k&12)>>2]+F[(s|n&12)>>2]|0;A=(((p|0)>=(l|0))+((f|0)<=(p|0))|0)+((m|0)<=(p|0))<<2;p=F[((k&3)<<2|y)>>2]+F[((n&3)<<2|s)>>2]|0;A=A|(((p|0)>=(l|0))+((f|0)<=(p|0))|0)+((m|0)<=(p|0));p=F[(k>>>2&12|y)>>2]+F[(n>>>2&12|s)>>2]|0;k=F[(k>>>4&12|y)>>2]+F[(n>>>4&12|s)>>2]|0;D[u+3|0]=A|(((p|0)>=(l|0))+((f|0)<=(p|0))|0)+((m|0)<=(p|0))<<4|(((k|0)>=(l|0))+((f|0)<=(k|0))|0)+((k|0)>=(m|0))<<6;break p}v=L(p,G[t+103|0]-s|0);F[t+36>>2]=(((v|0)>=(l|0))+((f|0)<=(v|0))|0)+((m|0)<=(v|0));v=L(p,G[t+107|0]-s|0);F[t+40>>2]=(((v|0)>=(l|0))+((f|0)<=(v|0))|0)+((m|0)<=(v|0));v=L(p,G[t+111|0]-s|0);F[t+44>>2]=(((v|0)>=(l|0))+((f|0)<=(v|0))|0)+((m|0)<=(v|0));u=l;l=L(p,(ba&255)-s|0);F[t+32>>2]=(((u|0)<=(l|0))+((f|0)<=(l|0))|0)+((l|0)>=(m|0));f=t+32|0;l=G[n|0];D[k|0]=F[(f|l&12)>>2]<<2|F[(f|(l&3)<<2)>>2]|F[(f|l>>>2&12)>>2]<<4|F[(f|l>>>4&12)>>2]<<6;l=G[n+1|0];D[k+1|0]=F[(f|l&12)>>2]<<2|F[(f|(l&3)<<2)>>2]|F[(f|l>>>2&12)>>2]<<4|F[(f|l>>>4&12)>>2]<<6;l=G[n+2|0];D[k+2|0]=F[(f|l&12)>>2]<<2|F[((l&3)<<2|f)>>2]|F[(l>>>2&12|f)>>2]<<4|F[(l>>>4&12|f)>>2]<<6;l=k;k=G[n+3|0];D[l+3|0]=F[(f|k&12)>>2]<<2|F[((k&3)<<2|f)>>2]|F[(k>>>2&12|f)>>2]<<4|F[(k>>>4&12|f)>>2]<<6;break p}n=F[(u+(m<<2)|0)+12752>>2];f=n+w|0;m=(f|0)>=255?255:f;v=f>>>0<256?f:(m|0)>0?m:0;f=(L(v,15)+128>>>0)/255|0;m=n+y|0;p=(m|0)>=255?255:m;u=m>>>0<256?m:(p|0)>0?p:0;m=(L(u,15)+128>>>0)/255|0;n=n+x|0;p=(n|0)>=255?255:n;n=n>>>0<256?n:(p|0)>0?p:0;p=(L(n,7)+128>>>0)/255|0;x=l<<1;s=G[x+433120|0];cb:{if(l>>>0<3){break cb}w=p<<2|p>>>1;w=(w<<3|w>>>2)-n|0;y=L(w,w);w=(s<<5|s<<1)-l|0;y=y+(L(w,w)<<1)|0;w=m<<1|m>>>3;w=(w<<3|w>>>2)-u|0;A=L(w,w);w=f<<1|f>>>3;w=(w<<3|w>>>2)-v|0;ka=A+L(w,w)|0;w=y+ka|0;if(!w){break cb}O=v<<1;y=G[O+434657|0];Q=y<<1|y>>>3;A=L(Q<<3|Q>>>2,3);O=G[O+434656|0];Q=O<<1|O>>>3;v=(A+L(Q<<3|Q>>>2,5)>>>3|0)-v|0;A=L(v,v);Q=u<<1;v=G[Q+434657|0];ba=v<<1|v>>>3;ea=L(ba<<3|ba>>>2,3);Q=G[Q+434656|0];ba=Q<<1|Q>>>3;u=(ea+L(ba<<3|ba>>>2,5)>>>3|0)-u|0;A=A+L(u,u)|0;ba=n<<1;u=G[ba+434145|0];S=u<<1|u>>>3;ea=L(S<<3|S>>>2,3);ba=G[ba+434144|0];S=ba<<2|ba>>>1;S=(ea+L(S<<3|S>>>2,5)>>>3|0)-n|0;ea=A+L(S,S)|0;qa=G[x+432609|0];S=qa<<1|1;A=L(S<<4|S,3);S=G[x+432608|0];A=(A+L(S<<5|S<<1,5)>>>3|0)-l|0;A=ea+(L(A,A)<<1)|0;Pa=A>>>0>>0;ea=A;A=(L(n,15)+128>>>0)/255|0;fa=A<<1|A>>>3;n=(fa<<3|fa>>>2)-n|0;fa=ka+L(n,n)|0;n=G[x+433632|0];x=n<<1|1;l=(x<<4|x)-l|0;l=fa+(L(l,l)<<1)|0;if(!(Pa&ea>>>0>>0)){if(l>>>0<=w>>>0){F[k>>2]=-1;F[k+4>>2]=n<<28&1879048192|(A<<16&983040|(f<<20&15728640|m<<24&251658240))|32768;break p}F[k>>2]=0;F[k+4>>2]=p<<1&14|(f<<4&240|(s<<12&28672|m<<8&3840))|32768;break p}F[k>>2]=1431655765;F[k+4>>2]=qa<<28&1879048192|(S<<12&28672|(u<<16&983040|(y<<20&15728640|(v<<24&251658240|(ba<<1&14|(Q<<8&3840|O<<4&240))))))|32768;break p}F[k>>2]=0;F[k+4>>2]=p<<1&14|(f<<4&240|(s<<12&28672|m<<8&3840))|32768;break p}Sc(k,u,v);break p}f=L(J+wa|0,h)+b|0;E[f+2>>1]=p;E[f>>1]=ta;break p}while(1){db:{if(!n){break db}f=G[v+x|0];p=0;k=0;if((m|0)!=1){while(1){w=t+32|0;D[((p<<2)+l|0)+3|0]=F[(w|(f>>>(p<<1)&3)<<2)>>2];y=p|1;D[((y<<2)+l|0)+3|0]=F[(w|(f>>>(y<<1)&3)<<2)>>2];p=p+2|0;k=k+2|0;if((s|0)!=(k|0)){continue}break}}if(!u){break db}D[((p<<2)+l|0)+3|0]=F[(t+32|(f>>>(p<<1)&3)<<2)>>2]}l=l+ma|0;x=x+1|0;if((ha|0)!=(x|0)){continue}break}break p}f=G[u+4|0];p=G[u|0];n=G[u+1|0];k=G[u+2|0];D[t+43|0]=255;D[t+39|0]=255;D[t+35|0]=255;f=f<<4;s=F[f+12764>>2];k=(k<<3|k>>>2)&255;l=s+k|0;u=(l|0)>=255?255:l;D[t+46|0]=l>>>0<256?l:(u|0)>0?u:0;l=(n<<3|n>>>2)&255;n=l+s|0;u=(n|0)>=255?255:n;D[t+45|0]=n>>>0<256?n:(u|0)>0?u:0;n=(p<<3|p>>>2)&255;p=n+s|0;s=(p|0)>=255?255:p;D[t+44|0]=p>>>0<256?p:(s|0)>0?s:0;s=F[f+12760>>2];p=s+k|0;u=(p|0)>=255?255:p;D[t+42|0]=p>>>0<256?p:(u|0)>0?u:0;p=l+s|0;u=(p|0)>=255?255:p;D[t+41|0]=p>>>0<256?p:(u|0)>0?u:0;p=n+s|0;s=(p|0)>=255?255:p;D[t+40|0]=p>>>0<256?p:(s|0)>0?s:0;s=F[f+12756>>2];p=s+k|0;u=(p|0)>=255?255:p;D[t+38|0]=p>>>0<256?p:(u|0)>0?u:0;p=l+s|0;u=(p|0)>=255?255:p;D[t+37|0]=p>>>0<256?p:(u|0)>0?u:0;p=n+s|0;s=(p|0)>=255?255:p;D[t+36|0]=p>>>0<256?p:(s|0)>0?s:0;p=k;k=F[f+12752>>2];f=p+k|0;p=(f|0)>=255?255:f;D[t+34|0]=f>>>0<256?f:(p|0)>0?p:0;f=k+l|0;l=(f|0)>=255?255:f;D[t+33|0]=f>>>0<256?f:(l|0)>0?l:0;f=k+n|0;k=(f|0)>=255?255:f;D[t+32|0]=f>>>0<256?f:(k|0)>0?k:0;if(!oa){break p}f=J<<2;k=o-f|0;s=(k|0)>=4?4:k;k=(f+ca<<2)+b|0;n=0;while(1){if(s){u=G[n+v|0];p=0;while(1){f=(p<<2)+k|0;l=t+32|(u>>>(p<<1)&3)<<2;D[f|0]=G[l|0];D[f+1|0]=G[l+1|0];D[f+2|0]=G[l+2|0];p=p+1|0;if((m|0)!=(p|0)){continue}break}}k=k+ma|0;n=n+1|0;if((ha|0)!=(n|0)){continue}break}break p}f=G[u+4|0];p=G[u|0];n=G[u+1|0];k=G[u+2|0];D[t+43|0]=255;D[t+39|0]=255;D[t+35|0]=255;f=f<<4;s=F[f+12764>>2];k=(k<<3|k>>>2)&255;l=s+k|0;u=(l|0)>=255?255:l;D[t+46|0]=l>>>0<256?l:(u|0)>0?u:0;l=(n<<3|n>>>2)&255;n=l+s|0;u=(n|0)>=255?255:n;D[t+45|0]=n>>>0<256?n:(u|0)>0?u:0;n=(p<<3|p>>>2)&255;p=n+s|0;s=(p|0)>=255?255:p;D[t+44|0]=p>>>0<256?p:(s|0)>0?s:0;s=F[f+12760>>2];p=s+k|0;u=(p|0)>=255?255:p;D[t+42|0]=p>>>0<256?p:(u|0)>0?u:0;p=l+s|0;u=(p|0)>=255?255:p;D[t+41|0]=p>>>0<256?p:(u|0)>0?u:0;p=n+s|0;s=(p|0)>=255?255:p;D[t+40|0]=p>>>0<256?p:(s|0)>0?s:0;s=F[f+12756>>2];p=s+k|0;u=(p|0)>=255?255:p;D[t+38|0]=p>>>0<256?p:(u|0)>0?u:0;p=l+s|0;u=(p|0)>=255?255:p;D[t+37|0]=p>>>0<256?p:(u|0)>0?u:0;p=n+s|0;s=(p|0)>=255?255:p;D[t+36|0]=p>>>0<256?p:(s|0)>0?s:0;p=k;k=F[f+12752>>2];f=p+k|0;p=(f|0)>=255?255:f;D[t+34|0]=f>>>0<256?f:(p|0)>0?p:0;f=k+l|0;l=(f|0)>=255?255:f;D[t+33|0]=f>>>0<256?f:(l|0)>0?l:0;f=k+n|0;k=(f|0)>=255?255:f;D[t+32|0]=f>>>0<256?f:(k|0)>0?k:0;if(!oa){break p}f=J<<2;k=o-f|0;s=(k|0)>=4?4:k;k=(f+ca<<2)+b|0;n=0;while(1){if(s){u=G[n+v|0];p=0;while(1){f=(p<<2)+k|0;l=t+32|(u>>>(p<<1)&3)<<2;D[f|0]=G[l|0];D[f+1|0]=G[l+1|0];l=G[l+2|0];D[f+3|0]=255;D[f+2|0]=l;p=p+1|0;if((m|0)!=(p|0)){continue}break}}k=k+ma|0;n=n+1|0;if((ha|0)!=(n|0)){continue}break}}K=K>>>2|0;V=V-4|0;J=J+1|0;if((J|0)!=(c|0)){continue}break}sa=sa-4|0;B=B+1|0;Na=B>>>0>=d>>>0;if((d|0)!=(B|0)){continue}break}}if(Aa|!Na){break d}eb:{fb:{switch(g-6|0){case 0:g=b;i=d;f=0;e=0;ua=0;J=0;v=0;u=0;K=Ea-160|0;Ea=K;j=c;p=c-1|0;if(p){a=p;while(1){f=f+1|0;b=a>>>0>1;a=a>>>1|0;if(b){continue}break}}C=i-1|0;gb:{hb:{if(C){a=C;while(1){e=e+1|0;b=a>>>0>1;a=a>>>1|0;if(b){continue}break}if((i|0)<=0){break gb}v=e>>>0>f>>>0?f:e;u=v<<1;V=-1<>2]=b;d=c+(K+32|0)|0;a=F[b+(p<<2)>>2];F[d>>2]=(L(((a>>>26&31)+(a>>>21&31)|0)+(a>>>16&31)|0,255)>>>0)/31;c=c+(K+96|0)|0;h=a&30;F[c>>2]=(L((h+(a>>>5&31)|0)+(a>>>10&31)+(h>>>4)|0,255)>>>0)/31;a=F[b>>2];F[d+16>>2]=(L(((a>>>26&31)+(a>>>21&31)|0)+(a>>>16&31)|0,255)>>>0)/31;h=a&30;F[c+16>>2]=(L((h+(a>>>5&31)|0)+(a>>>10&31)+(h>>>4)|0,255)>>>0)/31;a=F[b+ka>>2];F[d+32>>2]=(L(((a>>>26&31)+(a>>>21&31)|0)+(a>>>16&31)|0,255)>>>0)/31;b=a&30;F[c+32>>2]=(L((b+(a>>>5&31)|0)+(a>>>10&31)+(b>>>4)|0,255)>>>0)/31;f=f+1|0;if((f|0)!=3){continue}break}e=F[K+32>>2];d=F[K+96>>2];if((j|0)>0){qa=H[((ua&255)<<1)+396320>>1]|H[(ua>>>7&33554430)+396320>>1]<<16;fa=ua>>>v<>2];c=F[K+40>>2];h=F[K+120>>2];b=F[K+104>>2];z=F[K+52>>2];a=F[K+36>>2];o=F[K+48>>2];s=F[K+116>>2];f=F[K+100>>2];n=F[K+112>>2];ya=F[K+28>>2];Ma=F[K+24>>2];Oa=F[K+20>>2];while(1){q=e;r=d;d=n;k=f;f=s;e=o;l=a;a=z;$=b;b=h;h=c;c=m;m=(J<<3)+Qa|0;n=qa|H[(pa>>>7&33554430)+396320>>1]<<17|H[((pa&255)<<1)+396320>>1]<<1;ib:{if((i|0)==(j|0)){break ib}o=n&V;n=o|pa>>>v<>>0>>0){break ib}n=o|fa}Ha=(n<<3)+g|0;F[Ha+4>>2]=F[(J<<2)+yb>>2];n=F[m>>2];o=n>>>25&112;n=G[(n>>>19&31)+398112|0]+(G[(n>>>11&31)+398112|0]+G[(n>>>3&31)+398112|0]|0)<<4;F[K+12>>2]=F[o+396832>>2]+n;F[K+8>>2]=n+F[o+396836>>2];F[K+4>>2]=n+F[o+396844>>2];F[K>>2]=n+F[o+396840>>2];n=G[m+5|0];o=G[m+7|0];x=n&240|o>>>4;s=d+f|0;z=L(s,6);za=z+(k+r<<1)|0;R=F[K+(G[x+396960|0]<<2)>>2]-za<<4;ta=a+e|0;B=L(ta,6);Sa=B+(l+q<<1)|0;Ia=(Sa|0)<(za|0);R=Ia?0-R|0:R;ga=n<<4&240|o&15;w=f+k|0;n=d+r|0;Aa=w+n<<2;o=F[K+(G[ga+396960|0]<<2)>>2]-Aa<<4;A=0-o|0;y=o;Z=a+l|0;o=e+q|0;Ja=Z+o<<2;Xa=(Ja|0)<(Aa|0);ja=Xa?A:y;Ca=(L(k,6)+(n<<1)|0)+L(f,6)|0;n=F[K+(G[ga+397216|0]<<2)>>2]-Ca<<4;Za=(L(l,6)+(o<<1)|0)+L(a,6)|0;_a=(Za|0)<(Ca|0);wa=_a?0-n|0:n;A=L(k,3);ma=L(f,9);ha=L(d,3);da=A+(r+(ma+ha|0)|0)|0;n=F[K+(G[x+397216|0]<<2)>>2]-da<<4;Da=L(l,3);sa=L(a,9);ca=L(e,3);$a=Da+(q+(sa+ca|0)|0)|0;ab=($a|0)<(da|0);r=ab?0-n|0:n;aa=G[m+4|0];oa=G[m+6|0];ra=aa<<4&240|oa&15;xa=s<<3;m=F[K+(G[ra+396960|0]<<2)>>2]-xa<<4;bb=ta<<3;cb=(bb|0)<(xa|0);ta=cb?0-m|0:m;pa=pa+1|0;va=(p&pa)<<2;m=F[va+Oa>>2];n=m&30;q=F[va+Ma>>2];o=q&30;aa=aa&240|oa>>>4;n=(L((n+(m>>>5&31)|0)+(m>>>10&31)+(n>>>4)|0,255)>>>0)/31|0;s=(L((o+(q>>>5&31)|0)+(q>>>10&31)+(o>>>4)|0,255)>>>0)/31|0;y=(z+(n<<1)|0)+(s<<1)|0;o=F[K+(G[aa+396960|0]<<2)>>2]-y<<4;ea=0-o|0;La=o;o=(L(((m>>>26&31)+(m>>>21&31)|0)+(m>>>16&31)|0,255)>>>0)/31|0;z=(L(((q>>>26&31)+(q>>>21&31)|0)+(q>>>16&31)|0,255)>>>0)/31|0;db=(B+(o<<1)|0)+(z<<1)|0;Ua=(db|0)<(y|0);q=Ua?ea:La;m=L(f,12);O=m+(d<<2)|0;B=F[K+(G[ra+397216|0]<<2)>>2]-O<<4;ea=0-B|0;La=B;B=L(a,12);Va=B+(e<<2)|0;ub=(Va|0)<(O|0);oa=ub?ea:La;vb=ma+L(s,3)|0;Q=ha+(vb+n|0)|0;ha=F[K+(G[aa+397216|0]<<2)>>2]-Q<<4;La=sa+L(z,3)|0;wb=ca+(La+o|0)|0;eb=(wb|0)<(Q|0);ha=eb?0-ha|0:ha;Na=w<<3;ca=F[K+(G[ga+397472|0]<<2)>>2]-Na<<4;fb=Z<<3;gb=(fb|0)<(Na|0);ca=gb?0-ca|0:ca;ba=m+(k<<2)|0;k=F[K+(G[x+397472|0]<<2)>>2]-ba<<4;hb=B+(l<<2)|0;ib=(hb|0)<(ba|0);l=ib?0-k|0:k;S=L(w,6)+(b+$<<1)|0;k=F[K+(G[ga+397728|0]<<2)>>2]-S<<4;jb=L(Z,6)+(c+h<<1)|0;kb=(jb|0)<(S|0);ga=kb?0-k|0:k;lb=L(b,3);Z=lb+($+(A+ma|0)|0)|0;k=F[K+(G[x+397728|0]<<2)>>2]-Z<<4;h=h+(sa+Da|0)|0;Da=L(c,3);mb=h+Da|0;nb=(mb|0)<(Z|0);$=nb?0-k|0:k;ma=f<<4;h=F[K+(G[ra+397472|0]<<2)>>2]-ma<<4;ob=a<<4;pb=(ob|0)<(ma|0);x=pb?0-h|0:h;sa=m+(s<<2)|0;h=F[K+(G[aa+397472|0]<<2)>>2]-sa<<4;qb=B+(z<<2)|0;rb=(qb|0)<(sa|0);w=rb?0-h|0:h;A=m+(b<<2)|0;h=F[K+(G[ra+397728|0]<<2)>>2]-A<<4;sb=B+(c<<2)|0;tb=(sb|0)<(A|0);ra=tb?0-h|0:h;k=F[va+ya>>2];h=k&30;m=F[K+(G[aa+397728|0]<<2)>>2];h=(L((h+(k>>>5&31)|0)+(k>>>10&31)+(h>>>4)|0,255)>>>0)/31|0;aa=(vb+h|0)+lb|0;m=m-aa<<4;ea=0-m|0;B=m;m=(L(((k>>>26&31)+(k>>>21&31)|0)+(k>>>16&31)|0,255)>>>0)/31|0;va=Da+(La+m|0)|0;Da=(va|0)<(aa|0);k=Da?ea:B;B=Sa-za|0;B=Ia?0-B|0:B;B=(R|0)>(L(B,13)|0)?12:(R|0)>B<<3?8:((R|0)>(L(B,3)|0))<<2;R=Ja-Aa|0;R=Xa?0-R|0:R;B=B|((ja|0)>(L(R,13)|0)?3:(ja|0)>R<<3?2:(ja|0)>(L(R,3)|0));R=Za-Ca|0;R=_a?0-R|0:R;B=B|((wa|0)>(L(R,13)|0)?768:(wa|0)>R<<3?512:((wa|0)>(L(R,3)|0))<<8);R=$a-da|0;R=ab?0-R|0:R;B=B|((r|0)>(L(R,13)|0)?3072:(r|0)>R<<3?2048:((r|0)>(L(R,3)|0))<<10);r=bb-xa|0;r=cb?0-r|0:r;B=B|((ta|0)>(L(r,13)|0)?48:(ta|0)>r<<3?32:((ta|0)>(L(r,3)|0))<<4);r=db-y|0;r=Ua?0-r|0:r;r=B|((q|0)>(L(r,13)|0)?192:(q|0)>r<<3?128:((q|0)>(L(r,3)|0))<<6);q=Va-O|0;q=ub?0-q|0:q;r=r|((oa|0)>(L(q,13)|0)?12288:(oa|0)>q<<3?8192:((oa|0)>(L(q,3)|0))<<12);q=wb-Q|0;q=eb?0-q|0:q;r=r|((ha|0)>(L(q,13)|0)?49152:(ha|0)>q<<3?32768:((ha|0)>(L(q,3)|0))<<14);q=fb-Na|0;q=gb?0-q|0:q;r=r|((ca|0)>(L(q,13)|0)?196608:(ca|0)>q<<3?131072:((ca|0)>(L(q,3)|0))<<16);q=hb-ba|0;q=ib?0-q|0:q;q=r|((l|0)>(L(q,13)|0)?786432:(l|0)>q<<3?524288:((l|0)>(L(q,3)|0))<<18);l=jb-S|0;l=kb?0-l|0:l;q=q|((ga|0)>(L(l,13)|0)?50331648:(ga|0)>l<<3?33554432:((ga|0)>(L(l,3)|0))<<24);l=mb-Z|0;l=nb?0-l|0:l;q=q|(($|0)>(L(l,13)|0)?201326592:($|0)>l<<3?134217728:(($|0)>(L(l,3)|0))<<26);l=ob-ma|0;l=pb?0-l|0:l;q=q|((x|0)>(L(l,13)|0)?3145728:(x|0)>l<<3?2097152:((x|0)>(L(l,3)|0))<<20);l=qb-sa|0;l=rb?0-l|0:l;q=q|((w|0)>(L(l,13)|0)?12582912:(w|0)>l<<3?8388608:((w|0)>(L(l,3)|0))<<22);l=sb-A|0;l=tb?0-l|0:l;q=q|((ra|0)>(L(l,13)|0)?805306368:(ra|0)>l<<3?536870912:((ra|0)>(L(l,3)|0))<<28);l=va-aa|0;l=Da?0-l|0:l;F[Ha>>2]=q|((k|0)>(L(l,13)|0)?-1073741824:(k|0)>l<<3?-2147483648:((k|0)>(L(l,3)|0))<<30);J=J+1|0;if((j|0)!=(pa|0)){continue}break}F[K+116>>2]=s;F[K+100>>2]=f;F[K+112>>2]=n;F[K+48>>2]=o;F[K+52>>2]=z;F[K+36>>2]=a;F[K+120>>2]=h;F[K+104>>2]=b;F[K+56>>2]=m;F[K+40>>2]=c}F[K+32>>2]=e;F[K+96>>2]=d;ua=ua+1|0;if((i|0)!=(ua|0)){continue}break}}Ea=K+160|0;break eb;case 1:break fb;default:break eb}}j=b;n=d;y=F[ja+4>>2];Xa=F[ja+16>>2];f=0;g=0;R=0;wa=0;ra=0;ta=0;J=Ea-176|0;Ea=J;k=c;p=k-1|0;if(p){c=p;while(1){g=g+1|0;a=c>>>0>1;c=c>>>1|0;if(a){continue}break}}q=n-1|0;jb:{kb:{if(q){c=q;while(1){f=f+1|0;a=c>>>0>1;c=c>>>1|0;if(a){continue}break}if((n|0)<=0){break jb}ra=f>>>0>g>>>0?g:f;ta=ra<<1;ua=-1<>2]=e;a=c+(J+112|0)|0;b=F[e+(p<<2)>>2];lb:{if(b&32768){V=(b>>>5&31)+398112|0;K=(b>>>10&31)+398112|0;$=255;d=(b>>>1&15)+398144|0;break lb}V=(b>>>4&15)+398144|0;K=(b>>>8&15)+398144|0;$=G[(b>>>12&7)+398168|0];d=(b>>>1&7)+398160|0}F[a>>2]=G[d|0]+(G[K|0]+(G[V|0]+$|0)|0);f=b>>>16|0;d=c+(J+48|0)|0;mb:{if((b|0)<0){V=(b>>>21&31)+398112|0;K=(b>>>26&31)+398112|0;c=255;b=(f&31)+398112|0;break mb}V=(b>>>20&15)+398144|0;K=(b>>>24&15)+398144|0;c=G[(b>>>28|0)+398168|0];b=(f&15)+398144|0}F[d>>2]=G[b|0]+(G[K|0]+(G[V|0]+c|0)|0);b=F[e>>2];nb:{if(b&32768){V=(b>>>5&31)+398112|0;K=(b>>>10&31)+398112|0;$=255;c=(b>>>1&15)+398144|0;break nb}V=(b>>>4&15)+398144|0;K=(b>>>8&15)+398144|0;$=G[(b>>>12&7)+398168|0];c=(b>>>1&7)+398160|0}F[a+16>>2]=G[c|0]+(G[K|0]+(G[V|0]+$|0)|0);f=b>>>16|0;ob:{if((b|0)<0){V=(b>>>21&31)+398112|0;K=(b>>>26&31)+398112|0;c=255;b=(f&31)+398112|0;break ob}V=(b>>>20&15)+398144|0;K=(b>>>24&15)+398144|0;c=G[(b>>>28|0)+398168|0];b=(f&15)+398144|0}F[d+16>>2]=G[b|0]+(G[K|0]+(G[V|0]+c|0)|0);c=F[e+_a>>2];pb:{if(c&32768){f=(c>>>1&15)+398144|0;V=(c>>>10&31)+398112|0;K=255;b=(c>>>5&31)+398112|0;break pb}f=(c>>>1&7)+398160|0;V=(c>>>8&15)+398144|0;K=G[(c>>>12&7)+398168|0];b=(c>>>4&15)+398144|0}F[a+32>>2]=G[f|0]+(G[V|0]+(G[b|0]+K|0)|0);a=c>>>16|0;qb:{if((c|0)<0){f=(a&31)+398112|0;b=(c>>>21&31)+398112|0;a=(c>>>26&31)+398112|0;c=255;break qb}f=(a&15)+398144|0;b=(c>>>20&15)+398144|0;a=(c>>>24&15)+398144|0;c=G[(c>>>28|0)+398168|0]}F[d+32>>2]=G[f|0]+(G[a|0]+(c+G[b|0]|0)|0);g=g+1|0;if((g|0)!=3){continue}break}g=F[J+48>>2];f=F[J+112>>2];rb:{if((k|0)<=0){b=g;a=f;break rb}Da=H[((R&255)<<1)+396320>>1]|H[(R>>>7&33554430)+396320>>1]<<16;$a=R>>>ra<>2];m=F[J+56>>2];c=F[J+136>>2];l=F[J+120>>2];o=F[J+68>>2];V=F[J+52>>2];C=F[J+64>>2];z=F[J+132>>2];K=F[J+116>>2];s=F[J+128>>2];bb=F[J+44>>2];cb=F[J+40>>2];db=F[J+36>>2];while(1){a=s;d=z;b=C;e=o;h=c;i=$;ja=(wa<<3)+Qa|0;c=ab+(ga<<2)|0;z=H[c>>1];aa=H[c+2>>1];c=Da|H[(ga>>>7&33554430)+396320>>1]<<17|H[((ga&255)<<1)+396320>>1]<<1;sb:{if((k|0)==(n|0)){break sb}o=c&ua;c=o|ga>>>ra<>>0>n>>>0){break sb}c=o|$a}o=(c<<3)+j|0;F[o+4>>2]=F[(wa<<2)+yb>>2];c=F[ja>>2];s=c>>>25&112;c=G[(c>>>19&31)+398112|0]+(G[(c>>>11&31)+398112|0]+G[(c>>>3&31)+398112|0]|0)<<4;C=F[s+396844>>2]+c|0;C=(C|0)>=12240?12240:C;F[J+28>>2]=(C|0)>0?C:0;C=c+F[s+396840>>2]|0;C=(C|0)>=12240?12240:C;F[J+24>>2]=(C|0)>0?C:0;C=c+F[s+396836>>2]|0;C=(C|0)>=12240?12240:C;F[J+20>>2]=(C|0)>0?C:0;c=c+F[s+396832>>2]|0;c=(c|0)>=12240?12240:c;F[J+16>>2]=(c|0)>0?c:0;s=z<<3;c=G[(s+y|0)+4|0]<<4;s=G[G[s+Za|0]+398112|0]<<4;z=F[c+397996>>2]+s|0;z=(z|0)>=4080?4080:z;F[J+12>>2]=(z|0)>0?z:0;z=s+F[c+397992>>2]|0;z=(z|0)>=4080?4080:z;F[J+8>>2]=(z|0)>0?z:0;z=s+F[c+397988>>2]|0;z=(z|0)>=4080?4080:z;F[J+4>>2]=(z|0)>0?z:0;c=s+F[c+397984>>2]|0;c=(c|0)>=4080?4080:c;F[J>>2]=(c|0)>0?c:0;ga=ga+1|0;pa=(p&ga)<<2;c=F[pa+db>>2];tb:{if(c&32768){C=(c>>>10&31)+398112|0;v=255;z=(c>>>5&31)+398112|0;s=(c>>>1&15)+398144|0;break tb}C=(c>>>8&15)+398144|0;v=G[(c>>>12&7)+398168|0];z=(c>>>4&15)+398144|0;s=(c>>>1&7)+398160|0}$=c>>>16|0;B=G[z|0];oa=G[C|0];Ca=G[s|0];ub:{if((c|0)<0){$=($&31)+398112|0;z=(c>>>21&31)+398112|0;C=(c>>>26&31)+398112|0;c=255;break ub}$=($&15)+398144|0;z=(c>>>20&15)+398144|0;C=(c>>>24&15)+398144|0;c=G[(c>>>28|0)+398168|0]}ha=G[z|0];C=G[C|0];ma=G[$|0];s=F[pa+cb>>2];vb:{if(s&32768){$=(s>>>5&31)+398112|0;u=(s>>>10&31)+398112|0;x=255;z=(s>>>1&15)+398144|0;break vb}$=(s>>>4&15)+398144|0;u=(s>>>8&15)+398144|0;x=G[(s>>>12&7)+398168|0];z=(s>>>1&7)+398160|0}v=v+B|0;B=c+ha|0;c=s>>>16|0;ha=G[$|0]+x|0;ca=G[u|0];z=G[z|0];wb:{if((s|0)<0){$=(c&31)+398112|0;u=(s>>>21&31)+398112|0;x=(s>>>26&31)+398112|0;c=255;break wb}$=(c&15)+398144|0;u=(s>>>20&15)+398144|0;x=(s>>>24&15)+398144|0;c=G[(s>>>28|0)+398168|0]}s=L(aa,11);da=v+oa|0;C=C+B|0;sa=ca+ha|0;xa=G[x|0]+(c+G[u|0]|0)|0;va=G[$|0];v=F[pa+bb>>2];xb:{if(v&32768){u=(v>>>10&31)+398112|0;x=255;O=(v>>>1&15)+398144|0;$=(v>>>5&31)+398112|0;break xb}u=(v>>>8&15)+398144|0;x=G[(v>>>12&7)+398168|0];O=(v>>>1&7)+398160|0;$=(v>>>4&15)+398144|0}Q=v>>>16|0;pa=o;aa=s+Xa|0;o=G[aa|0];c=J+16|0;s=G[ja+4|0];Z=a+d|0;ya=L(Z,6);Na=ya+(f+K<<1)|0;B=F[(J|o&12)>>2]+(F[(c|s&12)>>2]-Na|0)<<4;Ma=b+e|0;Oa=L(Ma,6);Ua=Oa+(g+V<<1)|0;Va=(Ua|0)<(Na|0);B=Va?0-B|0:B;ba=d+K|0;w=a+f|0;S=ba+w<<2;oa=F[(J|(o&3)<<2)>>2]+(F[(c|(s&3)<<2)>>2]-S|0)<<4;A=e+V|0;za=b+g|0;ub=A+za<<2;vb=(ub|0)<(S|0);oa=vb?0-oa|0:oa;ha=G[aa+1|0];ca=G[ja+5|0];ka=(L(K,6)+(w<<1)|0)+L(d,6)|0;w=F[(J|(ha&3)<<2)>>2]+(F[(c|(ca&3)<<2)>>2]-ka|0)<<4;La=(L(V,6)+(za<<1)|0)+L(e,6)|0;wb=(La|0)<(ka|0);w=wb?0-w|0:w;Ia=L(K,3);ea=f;za=L(d,9);f=L(a,3);qa=Ia+(ea+(za+f|0)|0)|0;Aa=F[(J|ha&12)>>2]+(F[(c|ca&12)>>2]-qa|0)<<4;Ja=L(V,3);ea=g;g=L(e,9);Ha=L(b,3);eb=Ja+(ea+(g+Ha|0)|0)|0;fb=(eb|0)<(qa|0);Aa=fb?0-Aa|0:Aa;fa=Z<<3;Z=F[(J|o>>>2&12)>>2]+(F[(c|s>>>2&12)>>2]-fa|0)<<4;gb=Ma<<3;hb=(gb|0)<(fa|0);Z=hb?0-Z|0:Z;ea=F[(c|s>>>4&12)>>2];s=da+Ca|0;z=z+sa|0;ya=(ya+(s<<1)|0)+(z<<1)|0;o=F[(J|o>>>4&12)>>2]+(ea-ya|0)<<4;sa=0-o|0;da=o;C=C+ma|0;o=va+xa|0;ib=(Oa+(C<<1)|0)+(o<<1)|0;jb=(ib|0)<(ya|0);Ca=jb?sa:da;ma=L(d,12);Ma=ma+(a<<2)|0;da=F[(J|ha>>>2&12)>>2]+(F[(c|ca>>>2&12)>>2]-Ma|0)<<4;ea=0-da|0;sa=da;da=L(e,12);kb=da+(b<<2)|0;lb=(kb|0)<(Ma|0);sa=lb?ea:sa;mb=L(z,3);Oa=f+((mb+za|0)+s|0)|0;f=F[(J|ha>>>4&12)>>2]+(F[(c|ca>>>4&12)>>2]-Oa|0)<<4;Pa=0-f|0;ea=f;f=g+L(o,3)|0;nb=Ha+(f+C|0)|0;ob=(nb|0)<(Oa|0);ha=ob?Pa:ea;ca=G[aa+2|0];xa=G[ja+6|0];Ha=ba<<3;va=F[(J|(ca&3)<<2)>>2]+(F[(c|(xa&3)<<2)>>2]-Ha|0)<<4;pb=A<<3;qb=(pb|0)<(Ha|0);va=qb?0-va|0:va;Sa=ma+(K<<2)|0;K=F[(J|ca&12)>>2]+(F[(c|xa&12)>>2]-Sa|0)<<4;rb=da+(V<<2)|0;sb=(rb|0)<(Sa|0);V=sb?0-K|0:K;K=G[aa+3|0];ja=G[ja+7|0];ba=L(ba,6)+(h+l<<1)|0;aa=F[(J|(K&3)<<2)>>2]+(F[(c|(ja&3)<<2)>>2]-ba|0)<<4;tb=L(A,6)+(i+m<<1)|0;zb=(tb|0)<(ba|0);aa=zb?0-aa|0:aa;Ab=L(h,3);A=Ab+((za+Ia|0)+l|0)|0;l=F[(J|K&12)>>2]+(F[(c|ja&12)>>2]-A|0)<<4;m=(g+Ja|0)+m|0;g=L(i,3);Bb=m+g|0;Cb=(Bb|0)<(A|0);l=Cb?0-l|0:l;Ia=d<<4;m=F[(J|ca>>>2&12)>>2]+(F[(c|xa>>>2&12)>>2]-Ia|0)<<4;Db=e<<4;Eb=(Db|0)<(Ia|0);m=Eb?0-m|0:m;ea=F[(c|xa>>>4&12)>>2];xa=ma+(z<<2)|0;ca=F[(J|ca>>>4&12)>>2]+(ea-xa|0)<<4;Fb=da+(o<<2)|0;Gb=(Fb|0)<(xa|0);ca=Gb?0-ca|0:ca;Ja=ma+(h<<2)|0;ma=F[(J|K>>>2&12)>>2]+(F[(c|ja>>>2&12)>>2]-Ja|0)<<4;Hb=da+(i<<2)|0;Ib=(Hb|0)<(Ja|0);ma=Ib?0-ma|0:ma;da=Ua-Na|0;da=Va?0-da|0:da;da=(B|0)>(L(da,13)|0)?12:(B|0)>da<<3?8:((B|0)>(L(da,3)|0))<<2;B=ub-S|0;B=vb?0-B|0:B;da=da|((oa|0)>(L(B,13)|0)?3:(oa|0)>B<<3?2:(oa|0)>(L(B,3)|0));B=La-ka|0;B=wb?0-B|0:B;da=da|((w|0)>(L(B,13)|0)?768:(w|0)>B<<3?512:((w|0)>(L(B,3)|0))<<8);B=eb-qa|0;B=fb?0-B|0:B;da=da|((Aa|0)>(L(B,13)|0)?3072:(Aa|0)>B<<3?2048:((Aa|0)>(L(B,3)|0))<<10);B=gb-fa|0;B=hb?0-B|0:B;Z=da|((Z|0)>(L(B,13)|0)?48:(Z|0)>B<<3?32:((Z|0)>(L(B,3)|0))<<4);B=ib-ya|0;B=jb?0-B|0:B;Z=Z|((Ca|0)>(L(B,13)|0)?192:(Ca|0)>B<<3?128:((Ca|0)>(L(B,3)|0))<<6);B=kb-Ma|0;B=lb?0-B|0:B;Z=Z|((sa|0)>(L(B,13)|0)?12288:(sa|0)>B<<3?8192:((sa|0)>(L(B,3)|0))<<12);B=nb-Oa|0;B=ob?0-B|0:B;Z=Z|((ha|0)>(L(B,13)|0)?49152:(ha|0)>B<<3?32768:((ha|0)>(L(B,3)|0))<<14);B=pb-Ha|0;B=qb?0-B|0:B;Z=Z|((va|0)>(L(B,13)|0)?196608:(va|0)>B<<3?131072:((va|0)>(L(B,3)|0))<<16);B=rb-Sa|0;B=sb?0-B|0:B;Z=Z|((V|0)>(L(B,13)|0)?786432:(V|0)>B<<3?524288:((V|0)>(L(B,3)|0))<<18);V=tb-ba|0;V=zb?0-V|0:V;Z=Z|((aa|0)>(L(V,13)|0)?50331648:(aa|0)>V<<3?33554432:((aa|0)>(L(V,3)|0))<<24);V=Bb-A|0;V=Cb?0-V|0:V;V=Z|((l|0)>(L(V,13)|0)?201326592:(l|0)>V<<3?134217728:((l|0)>(L(V,3)|0))<<26);l=Db-Ia|0;l=Eb?0-l|0:l;m=V|((m|0)>(L(l,13)|0)?3145728:(m|0)>l<<3?2097152:((m|0)>(L(l,3)|0))<<20);l=Fb-xa|0;l=Gb?0-l|0:l;m=m|((ca|0)>(L(l,13)|0)?12582912:(ca|0)>l<<3?8388608:((ca|0)>(L(l,3)|0))<<22);l=Hb-Ja|0;l=Ib?0-l|0:l;aa=m|((ma|0)>(L(l,13)|0)?805306368:(ma|0)>l<<3?536870912:((ma|0)>(L(l,3)|0))<<28);l=F[(J|K>>>4&12)>>2];m=F[(c|ja>>>4&12)>>2];c=G[O|0]+(G[u|0]+(G[$|0]+x|0)|0)|0;K=Ab+(za+(mb+c|0)|0)|0;l=l+(m-K|0)<<4;u=0-l|0;m=l;V=g;Z=f;yb:{if((v|0)<0){l=(v>>>21&31)+398112|0;g=(v>>>26&31)+398112|0;f=255;$=(Q&31)+398112|0;break yb}l=(v>>>20&15)+398144|0;g=(v>>>24&15)+398144|0;f=G[(v>>>28|0)+398168|0];$=(Q&15)+398144|0}$=G[$|0]+(G[g|0]+(G[l|0]+f|0)|0)|0;g=V+(Z+$|0)|0;l=(g|0)<(K|0);f=l?u:m;g=g-K|0;g=l?0-g|0:g;F[pa>>2]=((f|0)>(L(g,13)|0)?-1073741824:(f|0)>g<<3?-2147483648:((f|0)>(L(g,3)|0))<<30)|aa;wa=wa+1|0;m=i;l=h;V=e;K=d;f=a;g=b;if((k|0)!=(ga|0)){continue}break}F[J+132>>2]=z;F[J+116>>2]=K;F[J+128>>2]=s;F[J+64>>2]=C;F[J+68>>2]=o;F[J+52>>2]=e;F[J+136>>2]=c;F[J+120>>2]=l;F[J+72>>2]=$;F[J+56>>2]=m}F[J+48>>2]=b;F[J+112>>2]=a;R=R+1|0;if((n|0)!=(R|0)){continue}break}}Ea=J+176|0}ac=1;if(!Qa){break d}Ra(Qa)}a=F[t>>2];if(!a){break a}Ra(a)}Ea=t+128|0;return ac}function fc(a,b,c,d,e,f,g,h,i,j,k,l){var m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,J=0,K=0,M=0,N=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0;p=F[a>>2];a:{if(!p|I[a+92>>2]<=b>>>0){break a}b:{if(I[a+44>>2]>=2){if(d>>>0<=5){break b}break a}if(d){break a}}m=F[a+40>>2];if((m>>>0<=1?1:m)>>>0<=c>>>0){break a}ja=a+776|0;c:{if(F[a+52>>2]!=2){m=F[a+88>>2]+L(b,24)|0;fa=m+8|0;p=p+(G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24))|0;break c}if(F[ja+420>>2]!=(b|0)){m=F[a+88>>2]+L(b,24)|0;M=G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24);U=F[a>>2];p=G[m+8|0]|G[m+9|0]<<8|(G[m+10|0]<<16|G[m+11|0]<<24);fa=F[ja+412>>2];qa=G[m+16|0]|G[m+17|0]<<8|(G[m+18|0]<<16|G[m+19|0]<<24);d:{if((fa|0)!=(qa|0)){if(fa>>>0<=qa>>>0){e:{if(I[ja+416>>2]>=qa>>>0){n=F[ja+408>>2];break e}m=qa;f:{if((m|0)!=(fa+1|0)){break f}s=m-1|0;if(!(!m|s&m)){break f}fa=0;n=0-!m|0;m=n>>>16|0;A=m|n;m=A>>>8|0;ha=m|A;m=ha>>>4|0;q=m|ha;m=q>>>2|0;r=((m|q)&1)<<31;m=n|s;m=(n&65535)<<16|m>>>16|m;m=(A&255)<<24|m>>>8|m;m=(ha&15)<<28|m>>>4|m;m=(q&3)<<30|m>>>2|m;m=(r|m>>>1|m)+1|0;if(qa>>>0>m>>>0){break d}}fa=0;n=nb(F[ja+408>>2],m);if(!n){break d}F[ja+416>>2]=m;F[ja+408>>2]=n;fa=F[ja+412>>2]}Ta(n+fa|0,0,qa-fa|0)}F[ja+412>>2]=qa}if(F[a+52>>2]==2){fa=0;va=F[ja+408>>2];q=-64;x=Ya(160816);if(x){F[x+29556>>2]=0;F[x+29560>>2]=0;F[x+29636>>2]=0;F[x+29620>>2]=0;F[x+29368>>2]=0;F[x+160812>>2]=0;F[x+29652>>2]=0;F[x+29656>>2]=0;F[x+29612>>2]=0;F[x+29616>>2]=0;F[x+29668>>2]=0;F[x+29672>>2]=0;F[x+29628>>2]=134217729;F[x+29576>>2]=0;F[x+29580>>2]=0;F[x+29604>>2]=0;F[x+29608>>2]=0;F[x+29540>>2]=0;F[x+29544>>2]=0;F[x+29596>>2]=0;F[x+29600>>2]=0;F[x+29584>>2]=0;F[x+29588>>2]=0;F[x+29564>>2]=0;ta=qa;n=M+U|0;g:{h:{m=F[x+29540>>2]?1:5;i:{j:{if(p>>>0>>0){ha=va;break j}N=x+29448|0;ba=x+29376|0;Ba=x+4120|0;Ca=x+6176|0;wa=x+26668|0;Da=x+10280|0;Ha=x+16|0;ua=x+29356|0;ra=x+29416|0;pa=x+29488|0;ha=va;while(1){if(((G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24))&-16)==407710288){if(p>>>0<8){break h}s=G[n+4|0]|G[n+5|0]<<8|(G[n+6|0]<<16|G[n+7|0]<<24);q=-14;if(s>>>0>4294967287){break g}s=s+8|0;M=p>>>0>>0?-72:s;if(M>>>0>4294967176){break i}n=n+M|0;p=p-M|0;if(p>>>0>=m>>>0){continue}break j}F[x+29436>>2]=0;F[x+29372>>2]=m;F[ua+8>>2]=0;F[ua+12>>2]=0;F[ua>>2]=0;F[ua+4>>2]=0;F[ra+8>>2]=0;F[ra+12>>2]=0;F[ra>>2]=0;F[ra+4>>2]=0;F[x+10280>>2]=201326604;F[x+29592>>2]=0;F[x+29440>>2]=0;F[x+29444>>2]=0;F[x+29432>>2]=3;F[wa+8>>2]=F[100414];m=F[100413];F[wa>>2]=F[100412];F[wa+4>>2]=m;F[x+12>>2]=Da;F[x+8>>2]=Ba;F[x+4>>2]=Ca;F[x>>2]=Ha;if(!(!ta|!ha)){F[x+29368>>2]=0;F[x+29360>>2]=ha;F[x+29356>>2]=ha;F[x+29364>>2]=ha}v=F[x+29540>>2];if((v?5:9)>>>0>p>>>0){break h}k:{s=v?1:5;q=G[(s+n|0)-1|0];m=q&32;m=(!m+(F[(q>>>4&12)+403136>>2]+(s+F[((q&3)<<2)+403120>>2]|0)|0)|0)+(m>>>5&q>>>0<64)|0;l:{m:{if(m>>>0>4294967176){break m}if(m+3>>>0>p>>>0){break h}q=0;A=0;F[ba>>2]=0;F[ba+4>>2]=0;F[ba+32>>2]=0;F[ba+36>>2]=0;F[ba+24>>2]=0;F[ba+28>>2]=0;F[ba+16>>2]=0;F[ba+20>>2]=0;F[ba+8>>2]=0;F[ba+12>>2]=0;U=m;M=s;n:{if(m>>>0>>0){break n}M=-1;if(!n){break n}m=1;o:{p:{q:{r:{s:{t:{u:{v:{if((v|0)==1){r=n;if(U){break v}M=-72;break u}m=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24);if((m|0)!=-47205080){break t}m=s;r=(n+m|0)-1|0}v=G[r|0];M=v&32;M=(!M+(F[(v>>>4&12)+403136>>2]+(F[((v&3)<<2)+403120>>2]+m|0)|0)|0)+(M>>>5&v>>>0<64)|0}if(U>>>0>>0){break o}F[ba+24>>2]=M;M=-14;m=n+s|0;B=G[m-1|0];if(B&8){break o}t=B&32;if(!t){M=-16;m=G[m|0];if(m>>>0>167){break o}q=m&7;m=(m>>>3|0)+10|0;M=m&31;if((m&63)>>>0>=32){z=1<>>32-M}M=m;q=We(q,0,(z&7)<<29|M>>>3,z>>>3|0);m=z+Fa|0;q=q+M|0;A=M>>>0>q>>>0?m+1|0:m;s=s+1|0}r=B>>>6|0;v=B>>>2|0;M=0;switch((B&3)-1|0){case 2:break q;case 1:break r;case 0:break s;default:break p}}M=-10;if((m&-16)!=407710288){break o}M=8;if(U>>>0<8){break o}m=G[n+4|0]|G[n+5|0]<<8|(G[n+6|0]<<16|G[n+7|0]<<24);F[ba+20>>2]=1;F[ba>>2]=m;F[ba+4>>2]=0;M=0;break n}M=G[n+s|0];s=s+1|0;break p}m=n+s|0;M=G[m|0]|G[m+1|0]<<8;s=s+2|0;break p}m=n+s|0;M=G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24);s=s+4|0}v=v&1;w:{x:{switch(r-1|0){default:m=-1;r=-1;if(!t){break w}m=G[n+s|0];r=0;break w;case 0:m=n+s|0;m=(G[m|0]|G[m+1|0]<<8)+256|0;r=m>>>0<256;break w;case 1:m=n+s|0;m=G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24);r=0;break w;case 2:break x}}s=n+s|0;m=G[s|0]|G[s+1|0]<<8|(G[s+2|0]<<16|G[s+3|0]<<24);r=G[s+4|0]|G[s+5|0]<<8|(G[s+6|0]<<16|G[s+7|0]<<24)}F[ba+32>>2]=v;F[ba+28>>2]=M;F[ba>>2]=m;F[ba+4>>2]=r;M=0;F[ba+20>>2]=0;s=t?m:q;F[ba+8>>2]=s;m=t?r:A;F[ba+12>>2]=m;F[ba+16>>2]=!m&s>>>0>=131072|m?131072:s}}m=M;if(m>>>0>4294967176){break m}if(m){break h}y:{if(F[x+29608>>2]!=1){break y}r=F[x+29604>>2];if(!r){break y}z:{if(!F[x+29588>>2]){break z}A=F[r+4>>2]-1|0;q=F[x+29404>>2];s=We(Ze(We(q,0,-2048144761,-1640531535)^374761417,Fa^668265263,23),Fa,668265295,-1028477379);m=Fa+374761393|0;s=s-1640531463|0;m=s>>>0<2654435833?m+1|0:m;v=We(m>>>1^s,m,668265295,-1028477379);s=Fa;m=s>>>29|0;m=We(v^((s&536870911)<<3|v>>>29),m^s,-1640531463,374761393);M=(m^Fa)&A;s=F[r>>2];while(1){v=F[s+(M<<2)>>2];if(!v){break z}A:{if(I[v+8>>2]<8){break A}m=F[v+4>>2];if((G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24))!=-332356553){break A}m=G[m+4|0]|G[m+5|0]<<8|(G[m+6|0]<<16|G[m+7|0]<<24);if((m|0)==(q|0)){break A}M=(A&M)+1|0;if(m){continue}}break}M=F[x+29584>>2];B:{if(!M){break B}s=F[M+27320>>2];q=F[M+27316>>2];C:{D:{m=F[M>>2];if(m){if(!q){break D}Ga[q|0](s,m);Ga[q|0](s,M);break B}if(!q){break C}Ga[q|0](s,M);break B}Ra(m)}Ra(M)}F[x+29584>>2]=0;F[x+29600>>2]=-1;F[x+29588>>2]=v;F[x+29592>>2]=F[x+29404>>2]}}m=F[x+29404>>2];q=-32;if(!(!m|(m|0)==F[x+29592>>2])){break g}E:{if(F[x+29408>>2]){m=F[x+29544>>2];F[x+29548>>2]=!m;if(m){break E}F[x+29480>>2]=2048144761;F[x+29484>>2]=1640531534;F[x+29472>>2]=0;F[x+29476>>2]=0;F[x+29464>>2]=668265295;F[x+29468>>2]=-1028477379;F[x+29456>>2]=-1379879466;F[x+29460>>2]=1625958382;F[x+29448>>2]=0;F[x+29452>>2]=0;F[pa+32>>2]=0;F[pa+36>>2]=0;F[pa+24>>2]=0;F[pa+28>>2]=0;F[pa+16>>2]=0;F[pa+20>>2]=0;F[pa+8>>2]=0;F[pa+12>>2]=0;F[pa>>2]=0;F[pa+4>>2]=0;break E}F[x+29548>>2]=0}xa=ha+ta|0;m=F[ra+4>>2];s=U+F[ra>>2]|0;m=s>>>0>>0?m+1|0:m;F[ra>>2]=s;F[ra+4>>2]=m;p=p-U|0;n=n+U|0;U=ha;while(1){if(p>>>0<3){break h}ya=G[n|0]|G[n+1|0]<<8;s=ya|G[n+2|0]<<16;m=s>>>3|0;za=-20;q=ya>>>1&3;M=q;F:{switch(q-1|0){default:M=m;break;case 2:break l;case 0:break F}}sa=p-3|0;if(sa>>>0>>0){break h}aa=n+3|0;G:{H:{switch(q|0){case 0:q=-70;if(xa-U>>>0>>0){break g}if(!U){m=0;if(!M){break G}q=-74;break g}Va(U,aa,M);m=M;break G;case 1:q=-70;if(xa-U>>>0>>0){break g}if(!U){m=0;if(s>>>0<8){break G}q=-74;break g}Ta(U,G[aa|0],m);break G;case 2:break H;default:break l}}ea=xa-U|0;u=Ea-192|0;Ea=u;m=x+29384|0;p=F[m>>2];m=F[m+4>>2];Aa=!m&p>>>0>33554432|(m|0)!=0;s=-72;I:{if(M>>>0>131071){break I}A=-20;J:{K:{if(M>>>0<3){break K}L:{M:{N:{O:{m=G[aa|0];ia=m&3;switch(ia-1|0){case 0:break L;case 1:break N;case 2:break O;default:break M}}if(F[x+29440>>2]){break N}s=-30;break J}if(M>>>0<5){break K}q=3;p=G[aa|0]|G[aa+1|0]<<8|(G[aa+2|0]<<16|G[aa+3|0]<<24);P:{Q:{R:{S:{m=m>>>2&3;switch(m-2|0){case 1:break Q;case 0:break R;default:break S}}s=(m|0)!=0;n=p>>>4&1023;Y=p>>>14&1023;break P}q=4;n=p>>>4&16383;s=1;Y=p>>>18|0;break P}n=p>>>4&262143;if(n>>>0>131072){break K}s=1;q=5;Y=G[aa+4|0]<<10|p>>>22}v=q+Y|0;if(v>>>0>M>>>0){break K}T:{if(!F[x+29596>>2]|n>>>0<769){break T}m=0;while(1){if(m>>>0>16323){break T}m=m+512|0;continue}}U:{if((ia|0)==3){r=q+aa|0;q=x+29688|0;m=F[x+12>>2];if(!s){J=0;V:{if(G[m+1|0]){s=-72;W:{if(!Y){break W}X:{Y:{Z:{if(Y>>>0>=4){p=G[(r+Y|0)-1|0];s=-1;if(!p){break X}if(Y>>>0<=4294967176){break Z}s=Y;break W}K=G[r|0];_:{switch(Y-2|0){case 1:K=G[r+2|0]<<16|K;case 0:K=(G[r+1|0]<<8)+K|0;break;default:break _}}p=G[(r+Y|0)-1|0];s=-20;if(!p){break W}p=(O(p)-(Y<<3)|0)+9|0;break Y}J=Y-4|0;s=r+J|0;K=G[s|0]|G[s+1|0]<<8|(G[s+2|0]<<16|G[s+3|0]<<24);p=O(p)-23|0}y=m+4|0;z=n+q|0;t=z-3|0;Q=0-H[m+2>>1]&31;$:{aa:{while(1){ba:{if((J|0)>=4){K=p>>>3|0;o=0;m=p&7;break ba}if(!J){o=z-2|0;J=0;s=r;m=p;break aa}m=p>>>3|0;o=r>>>0>(r+J|0)-m>>>0;K=o?J:m;m=p-(K<<3)|0}J=J-K|0;s=r+J|0;K=G[s|0]|G[s+1|0]<<8|(G[s+2|0]<<16|G[s+3|0]<<24);if(!(!o&q>>>0>>0)){o=z-2|0;if(m>>>0<=32){break aa}p=m;break $}B=y+(K<>>Q<<2)|0;p=H[B>>1];D[q|0]=p;D[q+1|0]=p>>>8;q=G[B+3|0]+q|0;p=G[B+2|0]+m|0;B=y+(K<

>>Q<<2)|0;m=H[B>>1];D[q|0]=m;D[q+1|0]=m>>>8;q=q+G[B+3|0]|0;p=p+G[B+2|0]|0;if(p>>>0<33){continue}break}o=z-2|0;break $}while(1){ca:{if((J|0)>=4){p=m&7;K=m>>>3|0;m=0;break ca}if(!J){p=m;break $}p=m;w=s;s=m>>>3|0;m=r>>>0>w-s>>>0;K=m?J:s;p=p-(K<<3)|0}J=J-K|0;s=r+J|0;K=G[s|0]|G[s+1|0]<<8|(G[s+2|0]<<16|G[s+3|0]<<24);if(m|o>>>0>>0){break $}t=y+(K<

>>Q<<2)|0;m=H[t>>1];D[q|0]=m;D[q+1|0]=m>>>8;q=G[t+3|0]+q|0;m=G[t+2|0]+p|0;if(m>>>0<=32){continue}break}p=m}if(o>>>0>=q>>>0){while(1){t=y+(K<

>>Q<<2)|0;m=H[t>>1];D[q|0]=m;D[q+1|0]=m>>>8;p=G[t+2|0]+p|0;q=G[t+3|0]+q|0;if(q>>>0<=o>>>0){continue}break}}da:{if(q>>>0>=z>>>0){break da}w=q;m=K<

>>Q|0;q=y+(m<<2)|0;D[w|0]=G[q|0];if(G[q+3|0]==1){p=G[q+2|0]+p|0;break da}if(p>>>0>31){break da}m=G[(y+(m<<2)|0)+2|0]+p|0;p=m>>>0>=32?32:m}s=(r|0)!=(s|0)?-20:(p|0)!=32?-20:n}}m=s;break V}m=Mc(q,n,r,Y,m)}break U}ea:{if(G[m+1|0]){m=Jc(q,n,r,Y,m);break ea}m=Lc(q,n,r,Y,m)}break U}p=x+27308|0;ka=q+aa|0;ga=x+29688|0;t=x+10280|0;if(!s){m=Nc(t,ka,Y,p);if(m>>>0>4294967176){break U}if(m>>>0>>0){m=Mc(ga,n,m+ka|0,Y-m|0,t)}else{m=-72}break U}m=-70;fa:{if(!n){break fa}m=-20;if(!Y){break fa}s=n>>>8|0;q=L(n>>>0<=Y>>>0?15:(Y<<4>>>0)/(n>>>0)|0,24);m=L(s,F[q+400284>>2])+F[q+400280>>2]|0;ga:{if((m>>>3|0)+m>>>0>2]+L(s,F[q+400276>>2])>>>0){S=0;R=0;W=Ea-448|0;Ea=W;m=-44;la=F[t>>2];Q=p;ca=Ta(p+624|0,0,108);o=la&255;ha:{if(o>>>0>12){break ha}Z=p+1244|0;q=Oc(Z,ca,W+8|0,W+12|0,ka,Y,W+16|0);if(q>>>0<=4294967176){B=F[W+12>>2];if(B>>>0>o>>>0){break ha}ma=p+732|0;_=p+680|0;na=B+1|0;y=0;p=o;m=B;while(1){r=y;y=r+1|0;s=p;p=p-1|0;z=m;m=m-1|0;if(!F[ca+(z<<2)>>2]){continue}break}y=1;T=z+1|0;ia:{if(T>>>0<2){break ia}m=0;if(B+(r^-1)>>>0>=3){X=z&-4;while(1){V=y<<2;J=F[V+ca>>2];F[V+_>>2]=R;p=V+4|0;C=F[p+ca>>2];J=J+R|0;F[p+_>>2]=J;p=V+8|0;P=F[p+ca>>2];C=C+J|0;F[p+_>>2]=C;p=V+12|0;J=F[p+ca>>2];w=p+_|0;p=C+P|0;F[w>>2]=p;R=p+J|0;y=y+4|0;S=S+4|0;if((X|0)!=(S|0)){continue}break}}C=z&3;if(!C){break ia}while(1){J=y<<2;p=F[J+ca>>2];F[J+_>>2]=R;y=y+1|0;R=p+R|0;m=m+1|0;if((C|0)!=(m|0)){continue}break}}F[_>>2]=R;S=F[W+8>>2];ja:{if(!S){break ja}y=0;if((S|0)!=1){P=S&-2;p=0;while(1){J=G[y+Z|0];m=_+(J<<2)|0;C=F[m>>2];F[m>>2]=C+1;m=(C<<1)+ma|0;D[m+1|0]=J;D[m|0]=y;C=y|1;J=G[C+Z|0];m=_+(J<<2)|0;X=F[m>>2];F[m>>2]=X+1;m=(X<<1)+ma|0;D[m+1|0]=J;D[m|0]=C;y=y+2|0;p=p+2|0;if((P|0)!=(p|0)){continue}break}}if(!(S&1)){break ja}p=G[y+Z|0];m=_+(p<<2)|0;J=F[m>>2];F[m>>2]=J+1;m=(J<<1)+ma|0;D[m+1|0]=p;D[m|0]=y}y=0;F[_>>2]=0;ka:{if(T>>>0>=2){S=1;P=B+(r^-1)|0;if(P){X=(B^-1)+o|0;C=z&-2;m=0;while(1){p=S<<2;J=F[p+ca>>2];F[p+Q>>2]=y;B=S+1|0;p=B<<2;r=F[p+ca>>2];w=p+Q|0;p=(J<>2]=p;y=p+(r<>2]=y}r=na-z|0;if(T>>>0<2|r>>>0>=(o-r|0)+1>>>0){break ka}J=z&-4;z=z&3;m=r;while(1){C=L(m,52)+Q|0;p=0;K=1;if(P>>>0>=3){while(1){y=K<<2;F[y+C>>2]=F[y+Q>>2]>>>m;B=y+4|0;F[B+C>>2]=F[B+Q>>2]>>>m;B=y+8|0;F[B+C>>2]=F[B+Q>>2]>>>m;B=y+12|0;F[B+C>>2]=F[B+Q>>2]>>>m;K=K+4|0;p=p+4|0;if((J|0)!=(p|0)){continue}break}}y=0;if(z){while(1){p=K<<2;F[p+C>>2]=F[p+Q>>2]>>>m;K=K+1|0;y=y+1|0;if((z|0)!=(y|0)){continue}break}}m=m+1|0;if((s|0)!=(m|0)){continue}break}break ka}r=na-z|0}F[W+432>>2]=F[Q+48>>2];m=F[Q+44>>2];F[W+424>>2]=F[Q+40>>2];F[W+428>>2]=m;m=F[Q+36>>2];F[W+416>>2]=F[Q+32>>2];F[W+420>>2]=m;m=F[Q+28>>2];F[W+408>>2]=F[Q+24>>2];F[W+412>>2]=m;m=F[Q+20>>2];F[W+400>>2]=F[Q+16>>2];F[W+404>>2]=m;m=F[Q+4>>2];F[W+384>>2]=F[Q>>2];F[W+388>>2]=m;m=F[Q+12>>2];F[W+392>>2]=F[Q+8>>2];F[W+396>>2]=m;if(R){X=Q+676|0;_=t+4|0;P=na-o|0;ca=0;while(1){p=(ca<<1)+ma|0;m=G[p+1|0];oa=na-m|0;w=o-oa|0;V=1<>2];la:{if(r>>>0<=w>>>0){m=P+oa|0;B=(m|0)<=1?1:m;s=B<<2;T=F[s+X>>2];z=L(oa,52)+Q|0;F[W- -64>>2]=F[z+48>>2];m=F[z+44>>2];F[W+56>>2]=F[z+40>>2];F[W+60>>2]=m;m=F[z+36>>2];F[W+48>>2]=F[z+32>>2];F[W+52>>2]=m;m=F[z+28>>2];F[W+40>>2]=F[z+24>>2];F[W+44>>2]=m;m=F[z+20>>2];F[W+32>>2]=F[z+16>>2];F[W+36>>2]=m;m=F[z+12>>2];F[W+24>>2]=F[z+8>>2];F[W+28>>2]=m;m=F[z+4>>2];F[W+16>>2]=F[z>>2];F[W+20>>2]=m;da=_+(p<<2)|0;ma:{if(B>>>0<2){break ma}z=F[s+(W+16|0)>>2];if(!z){break ma}$=Z|oa<<16&16711680|16777216;m=0;y=0;if(z>>>0>=8){B=z&-8;K=0;while(1){S=y<<2;s=S+da|0;E[s>>1]=$;J=$>>>16|0;E[s+2>>1]=J;s=(S|4)+da|0;E[s>>1]=$;E[s+2>>1]=J;s=(S|8)+da|0;E[s>>1]=$;E[s+2>>1]=J;s=(S|12)+da|0;E[s>>1]=$;E[s+2>>1]=J;s=(S|16)+da|0;E[s>>1]=$;E[s+2>>1]=J;s=(S|20)+da|0;E[s>>1]=$;E[s+2>>1]=J;s=(S|24)+da|0;E[s>>1]=$;E[s+2>>1]=J;s=(S|28)+da|0;E[s>>1]=$;E[s+2>>1]=J;y=y+8|0;K=K+8|0;if((B|0)!=(K|0)){continue}break}}B=z&7;if(!B){break ma}while(1){s=(y<<2)+da|0;E[s>>1]=$;E[s+2>>1]=$>>>16;y=y+1|0;m=m+1|0;if((B|0)!=(m|0)){continue}break}}if((R|0)!=(T|0)){J=R-T|0;y=(T<<1)+ma|0;m=0;while(1){z=y+(m<<1)|0;s=G[z+1|0];S=na-s|0;B=(W+16|0)+(s<<2)|0;K=F[B>>2];T=K+(1<>1]=z;E[s+2>>1]=z>>>16;K=K+1|0;if(T>>>0>K>>>0){continue}break}F[B>>2]=T;m=m+1|0;if((J|0)!=(m|0)){continue}break}}S=p+V|0;break la}S=p+V|0;if(p>>>0>=S>>>0){break la}z=Z|oa<<16&16711680|16777216;if(w>>>0<=2){B=V&7;m=0;while(1){s=_+(p<<2)|0;E[s>>1]=z;E[s+2>>1]=z>>>16;p=p+1|0;m=m+1|0;if((B|0)!=(m|0)){continue}break}}if(w>>>0<3){break la}while(1){s=_+(p<<2)|0;E[s>>1]=z;m=z>>>16|0;E[s+2>>1]=m;E[s+4>>1]=z;E[s+6>>1]=m;E[s+8>>1]=z;E[s+10>>1]=m;E[s+12>>1]=z;E[s+14>>1]=m;E[s+16>>1]=z;E[s+18>>1]=m;E[s+20>>1]=z;E[s+22>>1]=m;E[s+24>>1]=z;E[s+26>>1]=m;E[s+28>>1]=z;E[s+30>>1]=m;p=p+8|0;if((p|0)!=(S|0)){continue}break}}F[C>>2]=S;ca=ca+1|0;if((R|0)!=(ca|0)){continue}break}}F[t>>2]=la&-16777216|o<<16|o|256}m=q}Ea=W+448|0;if(m>>>0>4294967176){break fa}p=-72;if(m>>>0>=Y>>>0){break ga}m=Jc(ga,n,m+ka|0,Y-m|0,t);break fa}m=Nc(t,ka,Y,p);if(m>>>0>4294967176){break fa}p=-72;if(m>>>0>=Y>>>0){break ga}p=Lc(ga,n,m+ka|0,Y-m|0,t)}m=p}}if(m>>>0>4294967176){break K}F[x+29568>>2]=n;F[x+29440>>2]=1;m=x+29688|0;F[x+29552>>2]=m;if((ia|0)==2){F[x+12>>2]=x+10280}m=m+n|0;D[m|0]=0;D[m+1|0]=0;D[m+2|0]=0;D[m+3|0]=0;D[m+4|0]=0;D[m+5|0]=0;D[m+6|0]=0;D[m+7|0]=0;D[m+24|0]=0;D[m+25|0]=0;D[m+26|0]=0;D[m+27|0]=0;D[m+28|0]=0;D[m+29|0]=0;D[m+30|0]=0;D[m+31|0]=0;D[m+16|0]=0;D[m+17|0]=0;D[m+18|0]=0;D[m+19|0]=0;D[m+20|0]=0;D[m+21|0]=0;D[m+22|0]=0;D[m+23|0]=0;D[m+8|0]=0;D[m+9|0]=0;D[m+10|0]=0;D[m+11|0]=0;D[m+12|0]=0;D[m+13|0]=0;D[m+14|0]=0;D[m+15|0]=0;s=v;break J}n=2;na:{oa:{switch((m>>>2&3)-1|0){default:n=1;p=m>>>3|0;break na;case 0:p=(G[aa|0]|G[aa+1|0]<<8)>>>4|0;break na;case 2:break oa}}n=3;p=(G[aa|0]|G[aa+1|0]<<8|G[aa+2|0]<<16)>>>4|0}s=n+p|0;if(s+32>>>0>M>>>0){if(s>>>0>M>>>0){break K}m=Va(x+29688|0,n+aa|0,p);F[x+29568>>2]=p;F[x+29552>>2]=m;m=m+p|0;D[m+24|0]=0;D[m+25|0]=0;D[m+26|0]=0;D[m+27|0]=0;D[m+28|0]=0;D[m+29|0]=0;D[m+30|0]=0;D[m+31|0]=0;D[m+16|0]=0;D[m+17|0]=0;D[m+18|0]=0;D[m+19|0]=0;D[m+20|0]=0;D[m+21|0]=0;D[m+22|0]=0;D[m+23|0]=0;D[m+8|0]=0;D[m+9|0]=0;D[m+10|0]=0;D[m+11|0]=0;D[m+12|0]=0;D[m+13|0]=0;D[m+14|0]=0;D[m+15|0]=0;D[m|0]=0;D[m+1|0]=0;D[m+2|0]=0;D[m+3|0]=0;D[m+4|0]=0;D[m+5|0]=0;D[m+6|0]=0;D[m+7|0]=0;break J}F[x+29568>>2]=p;F[x+29552>>2]=n+aa;break J}n=2;pa:{qa:{switch((m>>>2&3)-1|0){default:n=1;p=m>>>3|0;break pa;case 0:p=(G[aa|0]|G[aa+1|0]<<8)>>>4|0;break pa;case 2:break qa}}if(M>>>0<4){break K}m=G[aa|0]|G[aa+1|0]<<8|G[aa+2|0]<<16;if(m>>>0>2097167){break K}n=3;p=m>>>4|0}m=Ta(x+29688|0,G[n+aa|0],p+32|0);F[x+29568>>2]=p;F[x+29552>>2]=m;A=n+1|0}s=A}if(s>>>0>4294967176){break I}n=F[x+29596>>2];B=s+aa|0;q=-72;r=M-s|0;A=r;ra:{sa:{if(!r){break sa}p=G[B|0];if(!p){F[u+40>>2]=0;m=(r|0)==1?1:-72;break ra}m=p<<24>>24;s=B+1|0;ta:{if((m|0)>=0){break ta}if((m|0)==-1){if((A|0)<3){break sa}p=(G[B+1|0]|G[B+2|0]<<8)+32512|0;s=B+3|0;break ta}if((A|0)<2){break sa}p=(G[B+1|0]|p<<8)-32768|0;s=B+2|0}m=s;F[u+40>>2]=p;s=m+1|0;t=A+B|0;if(s>>>0>t>>>0){break sa}q=-20;v=G[m|0];A=x+27308|0;m=Ob(x+16|0,x,v>>>6|0,35,9,s,t-s|0,401360,401504,401664,F[x+29444>>2],F[x+29596>>2],p,A);if(m>>>0>4294967176){break sa}s=m+s|0;m=Ob(x+4120|0,x+8|0,v>>>4&3,31,8,s,t-s|0,400656,400784,402192,F[x+29444>>2],F[x+29596>>2],p,A);if(m>>>0>4294967176){break sa}s=m+s|0;m=Ob(x+6176|0,x+4|0,v>>>2&3,52,9,s,t-s|0,400912,401136,402464,F[x+29444>>2],F[x+29596>>2],p,A);if(m>>>0>4294967176){break sa}q=(m+s|0)-B|0}m=q}if(m>>>0>4294967176){s=m;break I}$=F[u+40>>2];if(!U){s=-70;if(($|0)>0){break I}}p=r-m|0;R=m+B|0;ua:{va:{wa:{if(!n){s=x+29384|0;n=F[s>>2];if(!F[s+4>>2]&n>>>0<16777217|($|0)<=4){break va}s=F[x+8>>2];n=s+8|0;A=F[s+4>>2];q=0;s=0;while(1){q=(G[(n+(s<<3)|0)+2|0]>22)+q|0;s=s+1|0;if(!(s>>>A|0)){continue}break}F[x+29596>>2]=0;if(q<<8-A>>>0<20){break ua}break wa}F[x+29596>>2]=0}q=F[x+29552>>2];F[u+188>>2]=q;ka=U+ea|0;na=F[x+29568>>2]+q|0;n=U;if($){da=F[x+29368>>2];oa=F[x+29364>>2];B=F[x+29360>>2];F[x+29444>>2]=1;F[u+96>>2]=F[x+26676>>2];z=x+26668|0;q=z;s=F[q+4>>2];F[u+88>>2]=F[q>>2];F[u+92>>2]=s;F[u+104>>2]=da;F[u+100>>2]=B;ea=n-B|0;F[u+108>>2]=ea;s=-20;if((m|0)==(r|0)){break I}F[u+56>>2]=R;F[u+60>>2]=R+4;xa:{if(p>>>0>=4){n=p-4|0;m=R+n|0;F[u+52>>2]=m;q=G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24);F[u+44>>2]=q;if(q>>>0<16777216){break I}m=O(q>>>24|0)-23|0;F[u+48>>2]=m;if(p>>>0<=4294967176){break xa}break I}F[u+52>>2]=R;q=G[R|0];F[u+44>>2]=q;ya:{switch(p-2|0){case 1:q=G[R+2|0]<<16|q;case 0:q=(G[R+1|0]<<8)+q|0;F[u+44>>2]=q;break;default:break ya}}m=G[(p+R|0)-1|0];if(!m){break I}m=(O(m)-(p<<3)|0)+9|0;F[u+48>>2]=m;n=0}A=F[x>>2];p=F[A+4>>2];m=p+m|0;F[u+48>>2]=m;V=F[(p<<2)+402992>>2]&q>>>0-m;F[u+64>>2]=V;za:{if(m>>>0>32){break za}Aa:{if((n|0)>=4){n=n-(m>>>3|0)|0;F[u+52>>2]=R+n;m=m&7;break Aa}if(!n){n=0;break za}p=m>>>3|0;p=(n+R|0)-p>>>0>>0?n:p;n=n-p|0;F[u+52>>2]=R+n;m=m-(p<<3)|0}F[u+48>>2]=m;p=n+R|0;q=G[p|0]|G[p+1|0]<<8|(G[p+2|0]<<16|G[p+3|0]<<24);F[u+44>>2]=q}v=($|0)<4;X=A+8|0;F[u+68>>2]=X;A=F[x+8>>2];p=F[A+4>>2];m=p+m|0;F[u+48>>2]=m;t=F[(p<<2)+402992>>2]&q>>>0-m;F[u+72>>2]=t;Ba:{if(m>>>0>32){break Ba}Ca:{if((n|0)>=4){n=n-(m>>>3|0)|0;F[u+52>>2]=R+n;m=m&7;break Ca}if(!n){n=0;break Ba}p=m>>>3|0;p=(n+R|0)-p>>>0>>0?n:p;n=n-p|0;F[u+52>>2]=R+n;m=m-(p<<3)|0}F[u+48>>2]=m;p=n+R|0;q=G[p|0]|G[p+1|0]<<8|(G[p+2|0]<<16|G[p+3|0]<<24);F[u+44>>2]=q}w=v?$:4;P=A+8|0;F[u+76>>2]=P;v=F[x+4>>2];p=F[v+4>>2];m=p+m|0;F[u+48>>2]=m;A=0;T=F[(p<<2)+402992>>2]&q>>>0-m;F[u+80>>2]=T;Da:{Ea:{if(m>>>0>=33){F[u+84>>2]=v+8;break Ea}Fa:{if((n|0)>=4){p=m&7;F[u+48>>2]=p;o=n-(m>>>3|0)|0;m=R+o|0;F[u+52>>2]=m;q=G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24);F[u+84>>2]=v+8;F[u+44>>2]=q;m=p;break Fa}if(!n){F[u+84>>2]=v+8;o=0;break Fa}q=m;m=m>>>3|0;p=(n+R|0)-m>>>0>>0?n:m;m=q-(p<<3)|0;F[u+48>>2]=m;o=n-p|0;p=R+o|0;F[u+52>>2]=p;q=G[p|0]|G[p+1|0]<<8|(G[p+2|0]<<16|G[p+3|0]<<24);F[u+84>>2]=v+8;F[u+44>>2]=q;if(m>>>0>32){break Ea}}Q=(w|0)>0?w:0;C=v+8|0;r=F[u+92>>2];v=F[u+88>>2];while(1){Ga:{Ha:{if((o|0)>=4){n=m&7;F[u+48>>2]=n;o=o-(m>>>3|0)|0;m=R+o|0;F[u+52>>2]=m;q=G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24);break Ha}if(!o){o=0;n=m;break Ga}p=m;m=m>>>3|0;m=(o+R|0)-m>>>0>>0?o:m;n=p-(m<<3)|0;F[u+48>>2]=n;o=o-m|0;m=R+o|0;F[u+52>>2]=m;q=G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24)}F[u+44>>2]=q}if((A|0)==(Q|0)){m=n;A=Q;break Da}m=X+(V<<3)|0;ga=F[m>>2];m=F[m+4>>2];K=m;J=(m&65535)<<16|ga>>>16;ia=J&255;m=C+(T<<3)|0;_=F[m>>2];m=F[m+4>>2];y=(m&65535)<<16|_>>>16;la=y&255;p=P+(t<<3)|0;ca=F[p>>2];V=F[p+4>>2];p=(V&65535)<<16|ca>>>16;ma=p&255;Ia:{Ja:{Ka:{if(ma>>>0>=2){S=o+R|0;if(!(!Aa|ma>>>0<25)){T=32-n|0;p=T>>>0>>0?T:ma;Z=ma-p|0;t=q<>>0-p<>>0>32){break La}Ma:{if((o|0)>=4){o=o-(n>>>3|0)|0;F[u+52>>2]=R+o;n=n&7;break Ma}if(!o){o=0;break La}p=n>>>3|0;p=S-p>>>0>>0?o:p;o=o-p|0;F[u+52>>2]=R+o;n=n-(p<<3)|0}F[u+48>>2]=n;p=o+R|0;q=G[p|0]|G[p+1|0]<<8|(G[p+2|0]<<16|G[p+3|0]<<24);F[u+44>>2]=q}p=t+V|0;if(T>>>0>=ma>>>0){break Ka}p=(q<>>0-Z|0)+p|0;n=n+Z|0;break Ka}p=V+(q<>>0-p|0)|0;t=n+ma|0;if(t>>>0>32){n=t;break Ka}if((o|0)>=4){n=t&7;F[u+48>>2]=n;o=o-(t>>>3|0)|0;q=R+o|0;F[u+52>>2]=q;q=G[q|0]|G[q+1|0]<<8|(G[q+2|0]<<16|G[q+3|0]<<24);F[u+44>>2]=q;break Ka}if(!o){o=0;n=t;break Ka}n=t>>>3|0;n=S-n>>>0>>0?o:n;o=o-n|0;q=R+o|0;F[u+52>>2]=q;q=G[q|0]|G[q+1|0]<<8|(G[q+2|0]<<16|G[q+3|0]<<24);F[u+44>>2]=q;n=t-(n<<3)|0;break Ka}if(!ma){p=r;if(!K){break Ja}break Ia}t=n+1|0;F[u+48>>2]=t;T=V+(!K+(q<>>31|0)|0)|0;if((T|0)==3){p=v-1|0;p=!p+p|0;n=t;break Ka}p=F[((T<<2)+u|0)+88>>2];p=!p+p|0;n=t;if((T|0)==1){break Ja}}F[u+96>>2]=r}F[u+88>>2]=p;F[u+92>>2]=v;r=v;v=p}t=ia+la|0;p=m;Na:{if(!(_&16711680)){m=n;break Na}m=n+la|0;F[u+48>>2]=m;p=(q<>>0-y|0)+p|0}Oa:{if(t>>>0<20|m>>>0>32){break Oa}Pa:{if((o|0)>=4){o=o-(m>>>3|0)|0;F[u+52>>2]=R+o;m=m&7;break Pa}if(!o){o=0;break Oa}n=m>>>3|0;n=(o+R|0)-n>>>0>>0?o:n;o=o-n|0;F[u+52>>2]=R+o;m=m-(n<<3)|0}n=o+R|0;q=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24);F[u+44>>2]=q}y=_>>>24|0;t=ga>>>24|0;if(ga&16711680){K=(q<>>0-J|0)+K|0;m=m+ia|0}Qa:{if(m>>>0>32){break Qa}Ra:{if((o|0)>=4){o=o-(m>>>3|0)|0;F[u+52>>2]=R+o;m=m&7;break Ra}if(!o){o=0;break Qa}n=m>>>3|0;n=(o+R|0)-n>>>0>>0?o:n;o=o-n|0;F[u+52>>2]=R+o;m=m-(n<<3)|0}n=o+R|0;q=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24);F[u+44>>2]=q}J=(u+112|0)+(A<<4)|0;n=K+ea|0;ea=n+p|0;F[u+108>>2]=ea;m=m+t|0;V=(F[(t<<2)+402992>>2]&q>>>0-m)+(ga&65535)|0;F[u+64>>2]=V;m=m+y|0;T=(F[(y<<2)+402992>>2]&q>>>0-m)+(_&65535)|0;F[u+80>>2]=T;y=(n+(n>>>0>>0?da:B)|0)-v|0;Sa:{if(m>>>0>32){break Sa}Ta:{if((o|0)>=4){o=o-(m>>>3|0)|0;F[u+52>>2]=R+o;m=m&7;break Ta}if(!o){o=0;break Sa}n=m>>>3|0;n=(o+R|0)-n>>>0>>0?o:n;o=o-n|0;F[u+52>>2]=R+o;m=m-(n<<3)|0}n=o+R|0;q=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24);F[u+44>>2]=q}n=ca>>>24|0;m=n+m|0;F[u+48>>2]=m;t=(F[(n<<2)+402992>>2]&q>>>0-m)+(ca&65535)|0;F[u+72>>2]=t;F[J+12>>2]=y;F[J+8>>2]=v;F[J+4>>2]=p;F[J>>2]=K;A=A+1|0;if(m>>>0<=32){continue}break}}if((w|0)>(A|0)){break I}}y=ka-32|0;n=U;Ua:{while(1){if(m>>>0>=33){if((A|0)<($|0)){break I}break Ua}o=F[u+52>>2];ea=F[u+60>>2];Va:{if(o>>>0>=ea>>>0){p=m&7;F[u+48>>2]=p;o=o-(m>>>3|0)|0;F[u+52>>2]=o;F[u+44>>2]=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);break Va}q=F[u+56>>2];if((q|0)==(o|0)){p=m;break Va}p=m>>>3|0;p=q>>>0>o-p>>>0?o-q|0:p;o=o-p|0;F[u+52>>2]=o;p=m-(p<<3)|0;F[u+48>>2]=p;F[u+44>>2]=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24)}if((A|0)>=($|0)){break Ua}m=F[u+68>>2]+(F[u+64>>2]<<3)|0;ia=F[m>>2];m=F[m+4>>2];K=m;Q=(m&65535)<<16|ia>>>16;P=Q&255;m=F[u+84>>2]+(F[u+80>>2]<<3)|0;la=F[m>>2];m=F[m+4>>2];t=(m&65535)<<16|la>>>16;C=t&255;q=F[u+76>>2]+(F[u+72>>2]<<3)|0;S=F[q>>2];T=F[q+4>>2];q=(T&65535)<<16|S>>>16;Z=q&255;Wa:{if(Z>>>0>=2){Xa:{if(!(!Aa|Z>>>0<25)){J=32-p|0;q=J>>>0>>0?J:Z;X=Z-q|0;V=F[u+44>>2];v=V<

>>0-q<>>0>32){break Ya}Za:{if(o>>>0>=ea>>>0){o=o-(q>>>3|0)|0;F[u+52>>2]=o;q=q&7;break Za}r=F[u+56>>2];if((r|0)==(o|0)){break Ya}p=q>>>3|0;p=r>>>0>o-p>>>0?o-r|0:p;o=o-p|0;F[u+52>>2]=o;q=q-(p<<3)|0}F[u+48>>2]=q;V=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);F[u+44>>2]=V}v=v+T|0;if(J>>>0>=Z>>>0){break Xa}v=(V<>>0-X|0)+v|0;q=q+X|0;break Xa}v=T+(F[u+44>>2]<

>>0-q|0)|0;p=p+Z|0;if(p>>>0>32){q=p;break Xa}if(o>>>0>=ea>>>0){q=p&7;F[u+48>>2]=q;o=o-(p>>>3|0)|0;F[u+52>>2]=o;F[u+44>>2]=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);break Xa}r=F[u+56>>2];if((r|0)==(o|0)){q=p;break Xa}q=p>>>3|0;q=r>>>0>o-q>>>0?o-r|0:q;o=o-q|0;F[u+52>>2]=o;q=p-(q<<3)|0;F[u+48>>2]=q;F[u+44>>2]=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24)}r=F[u+88>>2];p=F[u+92>>2];F[u+88>>2]=v;F[u+92>>2]=r;F[u+96>>2]=p;break Wa}if(!Z){if(K){v=F[u+88>>2];q=p;break Wa}v=F[u+92>>2];F[u+92>>2]=F[u+88>>2];F[u+88>>2]=v;q=p;break Wa}q=p+1|0;F[u+48>>2]=q;r=T+!K+(F[u+44>>2]<

>>31)|0;_a:{$a:{if((r|0)==3){p=F[u+88>>2]-1|0;v=!p+p|0;break $a}p=F[((r<<2)+u|0)+88>>2];v=!p+p|0;if((r|0)==1){break _a}}F[u+96>>2]=F[u+92>>2]}F[u+92>>2]=F[u+88>>2];F[u+88>>2]=v}p=m;if(la&16711680){p=(F[u+44>>2]<>>0-t|0)+m|0;q=q+C|0}ab:{if(C+P>>>0<20|q>>>0>32){break ab}bb:{if(o>>>0>=ea>>>0){o=o-(q>>>3|0)|0;F[u+52>>2]=o;q=q&7;break bb}r=F[u+56>>2];if((r|0)==(o|0)){break ab}m=q>>>3|0;m=r>>>0>o-m>>>0?o-r|0:m;o=o-m|0;F[u+52>>2]=o;q=q-(m<<3)|0}F[u+48>>2]=q;F[u+44>>2]=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24)}if(ia&16711680){K=(F[u+44>>2]<>>0-Q|0)+K|0;q=q+P|0}Q=la>>>24|0;t=ia>>>24|0;cb:{if(q>>>0>32){break cb}db:{if(o>>>0>=ea>>>0){o=o-(q>>>3|0)|0;F[u+52>>2]=o;q=q&7;break db}r=F[u+56>>2];if((r|0)==(o|0)){break cb}m=q>>>3|0;m=r>>>0>o-m>>>0?o-r|0:m;o=o-m|0;F[u+52>>2]=o;q=q-(m<<3)|0}F[u+48>>2]=q;F[u+44>>2]=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24)}J=F[u+108>>2]+K|0;F[u+108>>2]=J+p;m=F[u+44>>2];q=q+t|0;F[u+64>>2]=(F[(t<<2)+402992>>2]&m>>>0-q)+(ia&65535);q=q+Q|0;F[u+80>>2]=(F[(Q<<2)+402992>>2]&m>>>0-q)+(la&65535);Q=F[(u+44|0)+(v>>>0>J>>>0?60:56)>>2];eb:{if(q>>>0>32){break eb}fb:{if(o>>>0>=ea>>>0){o=o-(q>>>3|0)|0;F[u+52>>2]=o;q=q&7;break fb}r=F[u+56>>2];if((r|0)==(o|0)){break eb}m=q>>>3|0;m=r>>>0>o-m>>>0?o-r|0:m;o=o-m|0;F[u+52>>2]=o;q=q-(m<<3)|0}F[u+48>>2]=q;m=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);F[u+44>>2]=m}r=S>>>24|0;q=q+r|0;F[u+48>>2]=q;F[u+72>>2]=(F[(r<<2)+402992>>2]&m>>>0-q)+(S&65535);gb:{hb:{P=F[u+188>>2];T=(u+112|0)+((A&3)<<4)|0;C=F[T>>2];m=P+C|0;ib:{if(m>>>0>na>>>0){break ib}V=F[T+4>>2];r=C+V|0;if(y>>>0>>0){break ib}if(r+32>>>0<=ka-n>>>0){break hb}}m=F[T+12>>2];F[u+32>>2]=F[T+8>>2];F[u+36>>2]=m;m=F[T+4>>2];F[u+24>>2]=F[T>>2];F[u+28>>2]=m;r=Pb(n,ka,u+24|0,u+188|0,na,B,oa,da);break gb}q=n+C|0;X=F[T+8>>2];o=G[P+4|0]|G[P+5|0]<<8|(G[P+6|0]<<16|G[P+7|0]<<24);t=G[P|0]|G[P+1|0]<<8|(G[P+2|0]<<16|G[P+3|0]<<24);D[n|0]=t;D[n+1|0]=t>>>8;D[n+2|0]=t>>>16;D[n+3|0]=t>>>24;D[n+4|0]=o;D[n+5|0]=o>>>8;D[n+6|0]=o>>>16;D[n+7|0]=o>>>24;o=G[P+12|0]|G[P+13|0]<<8|(G[P+14|0]<<16|G[P+15|0]<<24);t=G[P+8|0]|G[P+9|0]<<8|(G[P+10|0]<<16|G[P+11|0]<<24);D[n+8|0]=t;D[n+9|0]=t>>>8;D[n+10|0]=t>>>16;D[n+11|0]=t>>>24;D[n+12|0]=o;D[n+13|0]=o>>>8;D[n+14|0]=o>>>16;D[n+15|0]=o>>>24;jb:{if(C>>>0<17){break jb}o=G[P+20|0]|G[P+21|0]<<8|(G[P+22|0]<<16|G[P+23|0]<<24);t=G[P+16|0]|G[P+17|0]<<8|(G[P+18|0]<<16|G[P+19|0]<<24);D[n+16|0]=t;D[n+17|0]=t>>>8;D[n+18|0]=t>>>16;D[n+19|0]=t>>>24;D[n+20|0]=o;D[n+21|0]=o>>>8;D[n+22|0]=o>>>16;D[n+23|0]=o>>>24;o=G[P+28|0]|G[P+29|0]<<8|(G[P+30|0]<<16|G[P+31|0]<<24);t=G[P+24|0]|G[P+25|0]<<8|(G[P+26|0]<<16|G[P+27|0]<<24);D[n+24|0]=t;D[n+25|0]=t>>>8;D[n+26|0]=t>>>16;D[n+27|0]=t>>>24;D[n+28|0]=o;D[n+29|0]=o>>>8;D[n+30|0]=o>>>16;D[n+31|0]=o>>>24;if((C-16|0)<17){break jb}o=P+16|0;t=n+32|0;while(1){P=G[o+20|0]|G[o+21|0]<<8|(G[o+22|0]<<16|G[o+23|0]<<24);C=G[o+16|0]|G[o+17|0]<<8|(G[o+18|0]<<16|G[o+19|0]<<24);D[t|0]=C;D[t+1|0]=C>>>8;D[t+2|0]=C>>>16;D[t+3|0]=C>>>24;D[t+4|0]=P;D[t+5|0]=P>>>8;D[t+6|0]=P>>>16;D[t+7|0]=P>>>24;P=G[o+28|0]|G[o+29|0]<<8|(G[o+30|0]<<16|G[o+31|0]<<24);C=G[o+24|0]|G[o+25|0]<<8|(G[o+26|0]<<16|G[o+27|0]<<24);D[t+8|0]=C;D[t+9|0]=C>>>8;D[t+10|0]=C>>>16;D[t+11|0]=C>>>24;D[t+12|0]=P;D[t+13|0]=P>>>8;D[t+14|0]=P>>>16;D[t+15|0]=P>>>24;P=G[o+36|0]|G[o+37|0]<<8|(G[o+38|0]<<16|G[o+39|0]<<24);C=G[o+32|0]|G[o+33|0]<<8|(G[o+34|0]<<16|G[o+35|0]<<24);D[t+16|0]=C;D[t+17|0]=C>>>8;D[t+18|0]=C>>>16;D[t+19|0]=C>>>24;D[t+20|0]=P;D[t+21|0]=P>>>8;D[t+22|0]=P>>>16;D[t+23|0]=P>>>24;P=G[o+44|0]|G[o+45|0]<<8|(G[o+46|0]<<16|G[o+47|0]<<24);C=G[o+40|0]|G[o+41|0]<<8|(G[o+42|0]<<16|G[o+43|0]<<24);D[t+24|0]=C;D[t+25|0]=C>>>8;D[t+26|0]=C>>>16;D[t+27|0]=C>>>24;D[t+28|0]=P;D[t+29|0]=P>>>8;D[t+30|0]=P>>>16;D[t+31|0]=P>>>24;o=o+32|0;t=t+32|0;if(t>>>0>>0){continue}break}}o=q-X|0;F[u+188>>2]=m;if(X>>>0>q-B>>>0){if(X>>>0>q-oa>>>0){break I}t=o-B|0;m=t+da|0;if(m+V>>>0<=da>>>0){db(q,m,V);break gb}V=t+V|0;o=B;q=db(q,m,0-t|0)-t|0}if(X>>>0>=16){t=G[o+4|0]|G[o+5|0]<<8|(G[o+6|0]<<16|G[o+7|0]<<24);m=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);D[q|0]=m;D[q+1|0]=m>>>8;D[q+2|0]=m>>>16;D[q+3|0]=m>>>24;D[q+4|0]=t;D[q+5|0]=t>>>8;D[q+6|0]=t>>>16;D[q+7|0]=t>>>24;t=G[o+12|0]|G[o+13|0]<<8|(G[o+14|0]<<16|G[o+15|0]<<24);m=G[o+8|0]|G[o+9|0]<<8|(G[o+10|0]<<16|G[o+11|0]<<24);D[q+8|0]=m;D[q+9|0]=m>>>8;D[q+10|0]=m>>>16;D[q+11|0]=m>>>24;D[q+12|0]=t;D[q+13|0]=t>>>8;D[q+14|0]=t>>>16;D[q+15|0]=t>>>24;if((V|0)<17){break gb}m=q+V|0;q=q+16|0;while(1){C=G[o+20|0]|G[o+21|0]<<8|(G[o+22|0]<<16|G[o+23|0]<<24);t=G[o+16|0]|G[o+17|0]<<8|(G[o+18|0]<<16|G[o+19|0]<<24);D[q|0]=t;D[q+1|0]=t>>>8;D[q+2|0]=t>>>16;D[q+3|0]=t>>>24;D[q+4|0]=C;D[q+5|0]=C>>>8;D[q+6|0]=C>>>16;D[q+7|0]=C>>>24;C=G[o+28|0]|G[o+29|0]<<8|(G[o+30|0]<<16|G[o+31|0]<<24);t=G[o+24|0]|G[o+25|0]<<8|(G[o+26|0]<<16|G[o+27|0]<<24);D[q+8|0]=t;D[q+9|0]=t>>>8;D[q+10|0]=t>>>16;D[q+11|0]=t>>>24;D[q+12|0]=C;D[q+13|0]=C>>>8;D[q+14|0]=C>>>16;D[q+15|0]=C>>>24;C=G[o+36|0]|G[o+37|0]<<8|(G[o+38|0]<<16|G[o+39|0]<<24);t=G[o+32|0]|G[o+33|0]<<8|(G[o+34|0]<<16|G[o+35|0]<<24);D[q+16|0]=t;D[q+17|0]=t>>>8;D[q+18|0]=t>>>16;D[q+19|0]=t>>>24;D[q+20|0]=C;D[q+21|0]=C>>>8;D[q+22|0]=C>>>16;D[q+23|0]=C>>>24;C=G[o+44|0]|G[o+45|0]<<8|(G[o+46|0]<<16|G[o+47|0]<<24);t=G[o+40|0]|G[o+41|0]<<8|(G[o+42|0]<<16|G[o+43|0]<<24);D[q+24|0]=t;D[q+25|0]=t>>>8;D[q+26|0]=t>>>16;D[q+27|0]=t>>>24;D[q+28|0]=C;D[q+29|0]=C>>>8;D[q+30|0]=C>>>16;D[q+31|0]=C>>>24;o=o+32|0;q=q+32|0;if(m>>>0>q>>>0){continue}break}break gb}kb:{if(X>>>0<=7){D[q|0]=G[o|0];D[q+1|0]=G[o+1|0];D[q+2|0]=G[o+2|0];D[q+3|0]=G[o+3|0];m=X<<2;o=F[m+403152>>2]+o|0;t=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);D[q+4|0]=t;D[q+5|0]=t>>>8;D[q+6|0]=t>>>16;D[q+7|0]=t>>>24;o=o-F[m+403184>>2]|0;break kb}t=G[o+4|0]|G[o+5|0]<<8|(G[o+6|0]<<16|G[o+7|0]<<24);m=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);D[q|0]=m;D[q+1|0]=m>>>8;D[q+2|0]=m>>>16;D[q+3|0]=m>>>24;D[q+4|0]=t;D[q+5|0]=t>>>8;D[q+6|0]=t>>>16;D[q+7|0]=t>>>24}if(V>>>0<9){break gb}t=q+V|0;m=q+8|0;o=o+8|0;if((m-o|0)<=15){while(1){C=G[o+4|0]|G[o+5|0]<<8|(G[o+6|0]<<16|G[o+7|0]<<24);q=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);D[m|0]=q;D[m+1|0]=q>>>8;D[m+2|0]=q>>>16;D[m+3|0]=q>>>24;D[m+4|0]=C;D[m+5|0]=C>>>8;D[m+6|0]=C>>>16;D[m+7|0]=C>>>24;o=o+8|0;m=m+8|0;if(t>>>0>m>>>0){continue}break gb}}P=G[o+4|0]|G[o+5|0]<<8|(G[o+6|0]<<16|G[o+7|0]<<24);C=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);D[m|0]=C;D[m+1|0]=C>>>8;D[m+2|0]=C>>>16;D[m+3|0]=C>>>24;D[m+4|0]=P;D[m+5|0]=P>>>8;D[m+6|0]=P>>>16;D[m+7|0]=P>>>24;P=G[o+12|0]|G[o+13|0]<<8|(G[o+14|0]<<16|G[o+15|0]<<24);C=G[o+8|0]|G[o+9|0]<<8|(G[o+10|0]<<16|G[o+11|0]<<24);D[m+8|0]=C;D[m+9|0]=C>>>8;D[m+10|0]=C>>>16;D[m+11|0]=C>>>24;D[m+12|0]=P;D[m+13|0]=P>>>8;D[m+14|0]=P>>>16;D[m+15|0]=P>>>24;if((V|0)<25){break gb}q=q+24|0;while(1){C=G[o+20|0]|G[o+21|0]<<8|(G[o+22|0]<<16|G[o+23|0]<<24);m=G[o+16|0]|G[o+17|0]<<8|(G[o+18|0]<<16|G[o+19|0]<<24);D[q|0]=m;D[q+1|0]=m>>>8;D[q+2|0]=m>>>16;D[q+3|0]=m>>>24;D[q+4|0]=C;D[q+5|0]=C>>>8;D[q+6|0]=C>>>16;D[q+7|0]=C>>>24;C=G[o+28|0]|G[o+29|0]<<8|(G[o+30|0]<<16|G[o+31|0]<<24);m=G[o+24|0]|G[o+25|0]<<8|(G[o+26|0]<<16|G[o+27|0]<<24);D[q+8|0]=m;D[q+9|0]=m>>>8;D[q+10|0]=m>>>16;D[q+11|0]=m>>>24;D[q+12|0]=C;D[q+13|0]=C>>>8;D[q+14|0]=C>>>16;D[q+15|0]=C>>>24;C=G[o+36|0]|G[o+37|0]<<8|(G[o+38|0]<<16|G[o+39|0]<<24);m=G[o+32|0]|G[o+33|0]<<8|(G[o+34|0]<<16|G[o+35|0]<<24);D[q+16|0]=m;D[q+17|0]=m>>>8;D[q+18|0]=m>>>16;D[q+19|0]=m>>>24;D[q+20|0]=C;D[q+21|0]=C>>>8;D[q+22|0]=C>>>16;D[q+23|0]=C>>>24;C=G[o+44|0]|G[o+45|0]<<8|(G[o+46|0]<<16|G[o+47|0]<<24);m=G[o+40|0]|G[o+41|0]<<8|(G[o+42|0]<<16|G[o+43|0]<<24);D[q+24|0]=m;D[q+25|0]=m>>>8;D[q+26|0]=m>>>16;D[q+27|0]=m>>>24;D[q+28|0]=C;D[q+29|0]=C>>>8;D[q+30|0]=C>>>16;D[q+31|0]=C>>>24;o=o+32|0;q=q+32|0;if(t>>>0>q>>>0){continue}break}}if(r>>>0<=4294967176){F[T+12>>2]=(J+Q|0)-v;F[T+8>>2]=v;F[T+4>>2]=p;F[T>>2]=K;A=A+1|0;n=n+r|0;m=F[u+48>>2];continue}break}s=r;break I}p=A-w|0;if(($|0)>(p|0)){v=ka-32|0;while(1){lb:{mb:{J=F[u+188>>2];t=(u+112|0)+((p&3)<<4)|0;Q=F[t>>2];m=J+Q|0;nb:{if(m>>>0>na>>>0){break nb}r=F[t+4>>2];A=Q+r|0;if(v>>>0>>0){break nb}if(A+32>>>0<=ka-n>>>0){break mb}}m=F[t+12>>2];F[u+16>>2]=F[t+8>>2];F[u+20>>2]=m;m=F[t+4>>2];F[u+8>>2]=F[t>>2];F[u+12>>2]=m;A=Pb(n,ka,u+8|0,u+188|0,na,B,oa,da);break lb}q=n+Q|0;y=F[t+8>>2];o=G[J+4|0]|G[J+5|0]<<8|(G[J+6|0]<<16|G[J+7|0]<<24);t=G[J|0]|G[J+1|0]<<8|(G[J+2|0]<<16|G[J+3|0]<<24);D[n|0]=t;D[n+1|0]=t>>>8;D[n+2|0]=t>>>16;D[n+3|0]=t>>>24;D[n+4|0]=o;D[n+5|0]=o>>>8;D[n+6|0]=o>>>16;D[n+7|0]=o>>>24;o=G[J+12|0]|G[J+13|0]<<8|(G[J+14|0]<<16|G[J+15|0]<<24);t=G[J+8|0]|G[J+9|0]<<8|(G[J+10|0]<<16|G[J+11|0]<<24);D[n+8|0]=t;D[n+9|0]=t>>>8;D[n+10|0]=t>>>16;D[n+11|0]=t>>>24;D[n+12|0]=o;D[n+13|0]=o>>>8;D[n+14|0]=o>>>16;D[n+15|0]=o>>>24;ob:{if(Q>>>0<17){break ob}o=G[J+20|0]|G[J+21|0]<<8|(G[J+22|0]<<16|G[J+23|0]<<24);t=G[J+16|0]|G[J+17|0]<<8|(G[J+18|0]<<16|G[J+19|0]<<24);D[n+16|0]=t;D[n+17|0]=t>>>8;D[n+18|0]=t>>>16;D[n+19|0]=t>>>24;D[n+20|0]=o;D[n+21|0]=o>>>8;D[n+22|0]=o>>>16;D[n+23|0]=o>>>24;o=G[J+28|0]|G[J+29|0]<<8|(G[J+30|0]<<16|G[J+31|0]<<24);t=G[J+24|0]|G[J+25|0]<<8|(G[J+26|0]<<16|G[J+27|0]<<24);D[n+24|0]=t;D[n+25|0]=t>>>8;D[n+26|0]=t>>>16;D[n+27|0]=t>>>24;D[n+28|0]=o;D[n+29|0]=o>>>8;D[n+30|0]=o>>>16;D[n+31|0]=o>>>24;if((Q-16|0)<17){break ob}o=J+16|0;K=n+32|0;while(1){Q=G[o+20|0]|G[o+21|0]<<8|(G[o+22|0]<<16|G[o+23|0]<<24);t=G[o+16|0]|G[o+17|0]<<8|(G[o+18|0]<<16|G[o+19|0]<<24);D[K|0]=t;D[K+1|0]=t>>>8;D[K+2|0]=t>>>16;D[K+3|0]=t>>>24;D[K+4|0]=Q;D[K+5|0]=Q>>>8;D[K+6|0]=Q>>>16;D[K+7|0]=Q>>>24;Q=G[o+28|0]|G[o+29|0]<<8|(G[o+30|0]<<16|G[o+31|0]<<24);t=G[o+24|0]|G[o+25|0]<<8|(G[o+26|0]<<16|G[o+27|0]<<24);D[K+8|0]=t;D[K+9|0]=t>>>8;D[K+10|0]=t>>>16;D[K+11|0]=t>>>24;D[K+12|0]=Q;D[K+13|0]=Q>>>8;D[K+14|0]=Q>>>16;D[K+15|0]=Q>>>24;Q=G[o+36|0]|G[o+37|0]<<8|(G[o+38|0]<<16|G[o+39|0]<<24);t=G[o+32|0]|G[o+33|0]<<8|(G[o+34|0]<<16|G[o+35|0]<<24);D[K+16|0]=t;D[K+17|0]=t>>>8;D[K+18|0]=t>>>16;D[K+19|0]=t>>>24;D[K+20|0]=Q;D[K+21|0]=Q>>>8;D[K+22|0]=Q>>>16;D[K+23|0]=Q>>>24;Q=G[o+44|0]|G[o+45|0]<<8|(G[o+46|0]<<16|G[o+47|0]<<24);t=G[o+40|0]|G[o+41|0]<<8|(G[o+42|0]<<16|G[o+43|0]<<24);D[K+24|0]=t;D[K+25|0]=t>>>8;D[K+26|0]=t>>>16;D[K+27|0]=t>>>24;D[K+28|0]=Q;D[K+29|0]=Q>>>8;D[K+30|0]=Q>>>16;D[K+31|0]=Q>>>24;o=o+32|0;K=K+32|0;if(K>>>0>>0){continue}break}}o=q-y|0;F[u+188>>2]=m;if(y>>>0>q-B>>>0){if(y>>>0>q-oa>>>0){break I}t=o-B|0;m=t+da|0;if(m+r>>>0<=da>>>0){db(q,m,r);break lb}r=r+t|0;o=B;q=db(q,m,0-t|0)-t|0}if(y>>>0>=16){t=G[o+4|0]|G[o+5|0]<<8|(G[o+6|0]<<16|G[o+7|0]<<24);m=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);D[q|0]=m;D[q+1|0]=m>>>8;D[q+2|0]=m>>>16;D[q+3|0]=m>>>24;D[q+4|0]=t;D[q+5|0]=t>>>8;D[q+6|0]=t>>>16;D[q+7|0]=t>>>24;t=G[o+12|0]|G[o+13|0]<<8|(G[o+14|0]<<16|G[o+15|0]<<24);m=G[o+8|0]|G[o+9|0]<<8|(G[o+10|0]<<16|G[o+11|0]<<24);D[q+8|0]=m;D[q+9|0]=m>>>8;D[q+10|0]=m>>>16;D[q+11|0]=m>>>24;D[q+12|0]=t;D[q+13|0]=t>>>8;D[q+14|0]=t>>>16;D[q+15|0]=t>>>24;if((r|0)<17){break lb}m=q+r|0;q=q+16|0;while(1){t=G[o+20|0]|G[o+21|0]<<8|(G[o+22|0]<<16|G[o+23|0]<<24);r=G[o+16|0]|G[o+17|0]<<8|(G[o+18|0]<<16|G[o+19|0]<<24);D[q|0]=r;D[q+1|0]=r>>>8;D[q+2|0]=r>>>16;D[q+3|0]=r>>>24;D[q+4|0]=t;D[q+5|0]=t>>>8;D[q+6|0]=t>>>16;D[q+7|0]=t>>>24;t=G[o+28|0]|G[o+29|0]<<8|(G[o+30|0]<<16|G[o+31|0]<<24);r=G[o+24|0]|G[o+25|0]<<8|(G[o+26|0]<<16|G[o+27|0]<<24);D[q+8|0]=r;D[q+9|0]=r>>>8;D[q+10|0]=r>>>16;D[q+11|0]=r>>>24;D[q+12|0]=t;D[q+13|0]=t>>>8;D[q+14|0]=t>>>16;D[q+15|0]=t>>>24;t=G[o+36|0]|G[o+37|0]<<8|(G[o+38|0]<<16|G[o+39|0]<<24);r=G[o+32|0]|G[o+33|0]<<8|(G[o+34|0]<<16|G[o+35|0]<<24);D[q+16|0]=r;D[q+17|0]=r>>>8;D[q+18|0]=r>>>16;D[q+19|0]=r>>>24;D[q+20|0]=t;D[q+21|0]=t>>>8;D[q+22|0]=t>>>16;D[q+23|0]=t>>>24;t=G[o+44|0]|G[o+45|0]<<8|(G[o+46|0]<<16|G[o+47|0]<<24);r=G[o+40|0]|G[o+41|0]<<8|(G[o+42|0]<<16|G[o+43|0]<<24);D[q+24|0]=r;D[q+25|0]=r>>>8;D[q+26|0]=r>>>16;D[q+27|0]=r>>>24;D[q+28|0]=t;D[q+29|0]=t>>>8;D[q+30|0]=t>>>16;D[q+31|0]=t>>>24;o=o+32|0;q=q+32|0;if(m>>>0>q>>>0){continue}break}break lb}pb:{if(y>>>0<=7){D[q|0]=G[o|0];D[q+1|0]=G[o+1|0];D[q+2|0]=G[o+2|0];D[q+3|0]=G[o+3|0];m=y<<2;o=o+F[m+403152>>2]|0;t=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);D[q+4|0]=t;D[q+5|0]=t>>>8;D[q+6|0]=t>>>16;D[q+7|0]=t>>>24;o=o-F[m+403184>>2]|0;break pb}t=G[o+4|0]|G[o+5|0]<<8|(G[o+6|0]<<16|G[o+7|0]<<24);m=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);D[q|0]=m;D[q+1|0]=m>>>8;D[q+2|0]=m>>>16;D[q+3|0]=m>>>24;D[q+4|0]=t;D[q+5|0]=t>>>8;D[q+6|0]=t>>>16;D[q+7|0]=t>>>24}if(r>>>0<9){break lb}t=q+r|0;m=q+8|0;o=o+8|0;if((m-o|0)<=15){while(1){r=G[o+4|0]|G[o+5|0]<<8|(G[o+6|0]<<16|G[o+7|0]<<24);q=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);D[m|0]=q;D[m+1|0]=q>>>8;D[m+2|0]=q>>>16;D[m+3|0]=q>>>24;D[m+4|0]=r;D[m+5|0]=r>>>8;D[m+6|0]=r>>>16;D[m+7|0]=r>>>24;o=o+8|0;m=m+8|0;if(t>>>0>m>>>0){continue}break lb}}y=G[o+4|0]|G[o+5|0]<<8|(G[o+6|0]<<16|G[o+7|0]<<24);Q=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);D[m|0]=Q;D[m+1|0]=Q>>>8;D[m+2|0]=Q>>>16;D[m+3|0]=Q>>>24;D[m+4|0]=y;D[m+5|0]=y>>>8;D[m+6|0]=y>>>16;D[m+7|0]=y>>>24;y=G[o+12|0]|G[o+13|0]<<8|(G[o+14|0]<<16|G[o+15|0]<<24);Q=G[o+8|0]|G[o+9|0]<<8|(G[o+10|0]<<16|G[o+11|0]<<24);D[m+8|0]=Q;D[m+9|0]=Q>>>8;D[m+10|0]=Q>>>16;D[m+11|0]=Q>>>24;D[m+12|0]=y;D[m+13|0]=y>>>8;D[m+14|0]=y>>>16;D[m+15|0]=y>>>24;if((r|0)<25){break lb}q=q+24|0;while(1){r=G[o+20|0]|G[o+21|0]<<8|(G[o+22|0]<<16|G[o+23|0]<<24);m=G[o+16|0]|G[o+17|0]<<8|(G[o+18|0]<<16|G[o+19|0]<<24);D[q|0]=m;D[q+1|0]=m>>>8;D[q+2|0]=m>>>16;D[q+3|0]=m>>>24;D[q+4|0]=r;D[q+5|0]=r>>>8;D[q+6|0]=r>>>16;D[q+7|0]=r>>>24;r=G[o+28|0]|G[o+29|0]<<8|(G[o+30|0]<<16|G[o+31|0]<<24);m=G[o+24|0]|G[o+25|0]<<8|(G[o+26|0]<<16|G[o+27|0]<<24);D[q+8|0]=m;D[q+9|0]=m>>>8;D[q+10|0]=m>>>16;D[q+11|0]=m>>>24;D[q+12|0]=r;D[q+13|0]=r>>>8;D[q+14|0]=r>>>16;D[q+15|0]=r>>>24;r=G[o+36|0]|G[o+37|0]<<8|(G[o+38|0]<<16|G[o+39|0]<<24);m=G[o+32|0]|G[o+33|0]<<8|(G[o+34|0]<<16|G[o+35|0]<<24);D[q+16|0]=m;D[q+17|0]=m>>>8;D[q+18|0]=m>>>16;D[q+19|0]=m>>>24;D[q+20|0]=r;D[q+21|0]=r>>>8;D[q+22|0]=r>>>16;D[q+23|0]=r>>>24;r=G[o+44|0]|G[o+45|0]<<8|(G[o+46|0]<<16|G[o+47|0]<<24);m=G[o+40|0]|G[o+41|0]<<8|(G[o+42|0]<<16|G[o+43|0]<<24);D[q+24|0]=m;D[q+25|0]=m>>>8;D[q+26|0]=m>>>16;D[q+27|0]=m>>>24;D[q+28|0]=r;D[q+29|0]=r>>>8;D[q+30|0]=r>>>16;D[q+31|0]=r>>>24;o=o+32|0;q=q+32|0;if(t>>>0>q>>>0){continue}break}}if(A>>>0>4294967176){s=A;break I}n=n+A|0;p=p+1|0;if(($|0)!=(p|0)){continue}break}}m=F[u+92>>2];F[z>>2]=F[u+88>>2];F[z+4>>2]=m;F[z+8>>2]=F[u+96>>2];q=F[u+188>>2]}s=-70;m=na-q|0;if(m>>>0>ka-n>>>0){break I}if(n){m=Va(n,q,m)+m|0}else{m=0}s=m-U|0;break I}F[x+29596>>2]=0}n=p;o=0;s=0;w=Ea-112|0;Ea=w;p=F[x+29552>>2];F[w+92>>2]=p;ca=U+ea|0;ea=F[x+29568>>2]+p|0;qb:{rb:{if(!$){m=U;break rb}ia=F[x+29368>>2];X=F[x+29364>>2];t=F[x+29360>>2];F[x+29444>>2]=1;F[w+76>>2]=F[x+26676>>2];q=x+26668|0;m=F[q+4>>2];F[w+68>>2]=F[q>>2];F[w+72>>2]=m;if(!n){s=-20;break qb}F[w+36>>2]=R;F[w+40>>2]=R+4;sb:{tb:{ub:{if(n>>>0>=4){o=n-4|0;m=R+o|0;F[w+32>>2]=m;m=G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24);F[w+24>>2]=m;if(m>>>0>=16777216){break ub}s=-20;break qb}F[w+32>>2]=R;m=G[R|0];F[w+24>>2]=m;vb:{switch(n-2|0){case 1:m=G[R+2|0]<<16|m;case 0:m=(G[R+1|0]<<8)+m|0;F[w+24>>2]=m;break;default:break vb}}p=G[(n+R|0)-1|0];if(p){break tb}s=-20;break qb}p=O(m>>>24|0)-23|0;F[w+28>>2]=p;if(n>>>0<=4294967176){break sb}s=-20;break qb}p=(O(p)-(n<<3)|0)+9|0;F[w+28>>2]=p}A=F[x>>2];n=F[A+4>>2];v=p+n|0;F[w+28>>2]=v;F[w+44>>2]=F[(n<<2)+402992>>2]&m>>>0-v;wb:{if(v>>>0>32){break wb}xb:{if((o|0)>=4){o=o-(v>>>3|0)|0;F[w+32>>2]=R+o;v=v&7;break xb}if(!o){o=0;break wb}m=v>>>3|0;m=(o+R|0)-m>>>0>>0?o:m;o=o-m|0;F[w+32>>2]=R+o;v=v-(m<<3)|0}F[w+28>>2]=v;m=o+R|0;m=G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24);F[w+24>>2]=m}F[w+48>>2]=A+8;n=F[x+8>>2];p=F[n+4>>2];v=p+v|0;F[w+28>>2]=v;F[w+52>>2]=F[(p<<2)+402992>>2]&m>>>0-v;yb:{if(v>>>0>32){break yb}zb:{if((o|0)>=4){o=o-(v>>>3|0)|0;F[w+32>>2]=R+o;v=v&7;break zb}if(!o){o=0;break yb}m=v>>>3|0;m=(o+R|0)-m>>>0>>0?o:m;o=o-m|0;F[w+32>>2]=R+o;v=v-(m<<3)|0}F[w+28>>2]=v;m=o+R|0;m=G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24);F[w+24>>2]=m}F[w+56>>2]=n+8;A=F[x+4>>2];n=F[A+4>>2];p=v+n|0;F[w+28>>2]=p;F[w+60>>2]=F[(n<<2)+402992>>2]&m>>>0-p;Ab:{if(p>>>0>32){break Ab}n=o+R|0;Bb:{if((o|0)>=4){r=n-(p>>>3|0)|0;F[w+32>>2]=r;p=p&7;break Bb}if(!o){break Ab}m=p>>>3|0;m=n-m>>>0>>0?o:m;r=n-m|0;F[w+32>>2]=r;p=p-(m<<3)|0}F[w+28>>2]=p;F[w+24>>2]=G[r|0]|G[r+1|0]<<8|(G[r+2|0]<<16|G[r+3|0]<<24)}F[w- -64>>2]=A+8;Q=ca-32|0;m=U;while(1){n=F[w+48>>2]+(F[w+44>>2]<<3)|0;V=F[n>>2];n=F[n+4>>2];r=n;z=(n&65535)<<16|V>>>16;P=z&255;n=F[w+64>>2]+(F[w+60>>2]<<3)|0;Z=F[n>>2];v=F[n+4>>2];o=(v&65535)<<16|Z>>>16;C=o&255;n=F[w+56>>2]+(F[w+52>>2]<<3)|0;la=F[n>>2];S=F[n+4>>2];n=(S&65535)<<16|la>>>16;ga=n&255;Cb:{if(ga>>>0>=2){Db:{if(!(!Aa|ga>>>0<25)){J=32-p|0;n=J>>>0>>0?J:ga;T=ga-n|0;y=F[w+24>>2];B=y<

>>0-n<>>0>32){break Eb}_=F[w+32>>2];Fb:{if(_>>>0>=I[w+40>>2]){p=_-(n>>>3|0)|0;F[w+32>>2]=p;n=n&7;break Fb}A=F[w+36>>2];if((A|0)==(_|0)){break Eb}p=n>>>3|0;A=A>>>0>_-p>>>0?_-A|0:p;p=_-A|0;F[w+32>>2]=p;n=n-(A<<3)|0}F[w+28>>2]=n;y=G[p|0]|G[p+1|0]<<8|(G[p+2|0]<<16|G[p+3|0]<<24);F[w+24>>2]=y}A=B+S|0;if(J>>>0>=ga>>>0){break Db}A=(y<>>0-T|0)+A|0;n=n+T|0;break Db}A=S+(F[w+24>>2]<

>>0-n|0)|0;p=p+ga|0;if(p>>>0>32){n=p;break Db}B=F[w+32>>2];if(B>>>0>=I[w+40>>2]){n=p&7;F[w+28>>2]=n;p=B-(p>>>3|0)|0;F[w+32>>2]=p;F[w+24>>2]=G[p|0]|G[p+1|0]<<8|(G[p+2|0]<<16|G[p+3|0]<<24);break Db}n=F[w+36>>2];if((n|0)==(B|0)){n=p;break Db}K=p;p=p>>>3|0;p=n>>>0>B-p>>>0?B-n|0:p;n=K-(p<<3)|0;F[w+28>>2]=n;p=B-p|0;F[w+32>>2]=p;F[w+24>>2]=G[p|0]|G[p+1|0]<<8|(G[p+2|0]<<16|G[p+3|0]<<24)}B=F[w+68>>2];p=F[w+72>>2];F[w+68>>2]=A;F[w+72>>2]=B;F[w+76>>2]=p;break Cb}if(!ga){if(r){A=F[w+68>>2];n=p;break Cb}A=F[w+72>>2];F[w+72>>2]=F[w+68>>2];F[w+68>>2]=A;n=p;break Cb}n=p+1|0;F[w+28>>2]=n;B=S+!r+(F[w+24>>2]<

>>31)|0;Gb:{Hb:{if((B|0)==3){p=F[w+68>>2]-1|0;A=!p+p|0;break Hb}p=F[(w+(B<<2)|0)+68>>2];A=!p+p|0;if((B|0)==1){break Gb}}F[w+76>>2]=F[w+72>>2]}F[w+72>>2]=F[w+68>>2];F[w+68>>2]=A}if(Z&16711680){v=(F[w+24>>2]<>>0-o|0)+v|0;n=n+C|0}Ib:{if(C+P>>>0<20|n>>>0>32){break Ib}o=F[w+32>>2];Jb:{if(o>>>0>=I[w+40>>2]){p=o-(n>>>3|0)|0;F[w+32>>2]=p;n=n&7;break Jb}B=F[w+36>>2];if((B|0)==(o|0)){break Ib}p=n>>>3|0;B=B>>>0>o-p>>>0?o-B|0:p;p=o-B|0;F[w+32>>2]=p;n=n-(B<<3)|0}F[w+28>>2]=n;F[w+24>>2]=G[p|0]|G[p+1|0]<<8|(G[p+2|0]<<16|G[p+3|0]<<24)}if(V&16711680){r=(F[w+24>>2]<>>0-z|0)+r|0;n=n+P|0}z=Z>>>24|0;o=V>>>24|0;Kb:{if(n>>>0>32){break Kb}y=F[w+32>>2];Lb:{if(y>>>0>=I[w+40>>2]){p=y-(n>>>3|0)|0;F[w+32>>2]=p;n=n&7;break Lb}B=F[w+36>>2];if((B|0)==(y|0)){break Kb}p=n>>>3|0;B=B>>>0>y-p>>>0?y-B|0:p;p=y-B|0;F[w+32>>2]=p;n=n-(B<<3)|0}F[w+28>>2]=n;F[w+24>>2]=G[p|0]|G[p+1|0]<<8|(G[p+2|0]<<16|G[p+3|0]<<24)}p=F[w+24>>2];n=n+o|0;F[w+44>>2]=(F[(o<<2)+402992>>2]&p>>>0-n)+(V&65535);n=n+z|0;F[w+60>>2]=(F[(z<<2)+402992>>2]&p>>>0-n)+(Z&65535);Mb:{if(n>>>0>32){break Mb}o=F[w+32>>2];Nb:{if(o>>>0>=I[w+40>>2]){p=o-(n>>>3|0)|0;F[w+32>>2]=p;n=n&7;break Nb}B=F[w+36>>2];if((B|0)==(o|0)){break Mb}p=n>>>3|0;B=B>>>0>o-p>>>0?o-B|0:p;p=o-B|0;F[w+32>>2]=p;n=n-(B<<3)|0}F[w+28>>2]=n;p=G[p|0]|G[p+1|0]<<8|(G[p+2|0]<<16|G[p+3|0]<<24);F[w+24>>2]=p}B=la>>>24|0;n=n+B|0;F[w+28>>2]=n;F[w+52>>2]=(F[(B<<2)+402992>>2]&p>>>0-n)+(la&65535);F[w+96>>2]=r;F[w+100>>2]=v;F[w+104>>2]=A;Ob:{Pb:{y=F[w+92>>2];B=y+r|0;Qb:{if(B>>>0>ea>>>0){break Qb}o=r+v|0;if(Q>>>0>>0){break Qb}if(o+32>>>0<=ca-m>>>0){break Pb}}p=F[w+108>>2];F[w+16>>2]=F[w+104>>2];F[w+20>>2]=p;p=F[w+100>>2];F[w+8>>2]=F[w+96>>2];F[w+12>>2]=p;o=Pb(m,ca,w+8|0,w+92|0,ea,t,X,ia);break Ob}p=m+r|0;z=G[y+4|0]|G[y+5|0]<<8|(G[y+6|0]<<16|G[y+7|0]<<24);n=G[y|0]|G[y+1|0]<<8|(G[y+2|0]<<16|G[y+3|0]<<24);D[m|0]=n;D[m+1|0]=n>>>8;D[m+2|0]=n>>>16;D[m+3|0]=n>>>24;D[m+4|0]=z;D[m+5|0]=z>>>8;D[m+6|0]=z>>>16;D[m+7|0]=z>>>24;z=G[y+12|0]|G[y+13|0]<<8|(G[y+14|0]<<16|G[y+15|0]<<24);n=G[y+8|0]|G[y+9|0]<<8|(G[y+10|0]<<16|G[y+11|0]<<24);D[m+8|0]=n;D[m+9|0]=n>>>8;D[m+10|0]=n>>>16;D[m+11|0]=n>>>24;D[m+12|0]=z;D[m+13|0]=z>>>8;D[m+14|0]=z>>>16;D[m+15|0]=z>>>24;Rb:{if(r>>>0<17){break Rb}z=G[y+20|0]|G[y+21|0]<<8|(G[y+22|0]<<16|G[y+23|0]<<24);n=G[y+16|0]|G[y+17|0]<<8|(G[y+18|0]<<16|G[y+19|0]<<24);D[m+16|0]=n;D[m+17|0]=n>>>8;D[m+18|0]=n>>>16;D[m+19|0]=n>>>24;D[m+20|0]=z;D[m+21|0]=z>>>8;D[m+22|0]=z>>>16;D[m+23|0]=z>>>24;z=G[y+28|0]|G[y+29|0]<<8|(G[y+30|0]<<16|G[y+31|0]<<24);n=G[y+24|0]|G[y+25|0]<<8|(G[y+26|0]<<16|G[y+27|0]<<24);D[m+24|0]=n;D[m+25|0]=n>>>8;D[m+26|0]=n>>>16;D[m+27|0]=n>>>24;D[m+28|0]=z;D[m+29|0]=z>>>8;D[m+30|0]=z>>>16;D[m+31|0]=z>>>24;if((r-16|0)<17){break Rb}n=y+16|0;r=m+32|0;while(1){y=G[n+20|0]|G[n+21|0]<<8|(G[n+22|0]<<16|G[n+23|0]<<24);z=G[n+16|0]|G[n+17|0]<<8|(G[n+18|0]<<16|G[n+19|0]<<24);D[r|0]=z;D[r+1|0]=z>>>8;D[r+2|0]=z>>>16;D[r+3|0]=z>>>24;D[r+4|0]=y;D[r+5|0]=y>>>8;D[r+6|0]=y>>>16;D[r+7|0]=y>>>24;y=G[n+28|0]|G[n+29|0]<<8|(G[n+30|0]<<16|G[n+31|0]<<24);z=G[n+24|0]|G[n+25|0]<<8|(G[n+26|0]<<16|G[n+27|0]<<24);D[r+8|0]=z;D[r+9|0]=z>>>8;D[r+10|0]=z>>>16;D[r+11|0]=z>>>24;D[r+12|0]=y;D[r+13|0]=y>>>8;D[r+14|0]=y>>>16;D[r+15|0]=y>>>24;y=G[n+36|0]|G[n+37|0]<<8|(G[n+38|0]<<16|G[n+39|0]<<24);z=G[n+32|0]|G[n+33|0]<<8|(G[n+34|0]<<16|G[n+35|0]<<24);D[r+16|0]=z;D[r+17|0]=z>>>8;D[r+18|0]=z>>>16;D[r+19|0]=z>>>24;D[r+20|0]=y;D[r+21|0]=y>>>8;D[r+22|0]=y>>>16;D[r+23|0]=y>>>24;y=G[n+44|0]|G[n+45|0]<<8|(G[n+46|0]<<16|G[n+47|0]<<24);z=G[n+40|0]|G[n+41|0]<<8|(G[n+42|0]<<16|G[n+43|0]<<24);D[r+24|0]=z;D[r+25|0]=z>>>8;D[r+26|0]=z>>>16;D[r+27|0]=z>>>24;D[r+28|0]=y;D[r+29|0]=y>>>8;D[r+30|0]=y>>>16;D[r+31|0]=y>>>24;n=n+32|0;r=r+32|0;if(r>>>0

>>0){continue}break}}n=p-A|0;F[w+92>>2]=B;if(p-t>>>0>>0){if(p-X>>>0>>0){o=-20;break Ob}r=n-t|0;n=r+ia|0;if(ia>>>0>=n+v>>>0){db(p,n,v);break Ob}p=db(p,n,0-r|0);v=r+v|0;F[w+100>>2]=v;n=t;p=p-r|0}if(A>>>0>=16){r=G[n+4|0]|G[n+5|0]<<8|(G[n+6|0]<<16|G[n+7|0]<<24);A=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24);D[p|0]=A;D[p+1|0]=A>>>8;D[p+2|0]=A>>>16;D[p+3|0]=A>>>24;D[p+4|0]=r;D[p+5|0]=r>>>8;D[p+6|0]=r>>>16;D[p+7|0]=r>>>24;r=G[n+12|0]|G[n+13|0]<<8|(G[n+14|0]<<16|G[n+15|0]<<24);A=G[n+8|0]|G[n+9|0]<<8|(G[n+10|0]<<16|G[n+11|0]<<24);D[p+8|0]=A;D[p+9|0]=A>>>8;D[p+10|0]=A>>>16;D[p+11|0]=A>>>24;D[p+12|0]=r;D[p+13|0]=r>>>8;D[p+14|0]=r>>>16;D[p+15|0]=r>>>24;if((v|0)<17){break Ob}A=p+v|0;r=p+16|0;while(1){v=G[n+20|0]|G[n+21|0]<<8|(G[n+22|0]<<16|G[n+23|0]<<24);p=G[n+16|0]|G[n+17|0]<<8|(G[n+18|0]<<16|G[n+19|0]<<24);D[r|0]=p;D[r+1|0]=p>>>8;D[r+2|0]=p>>>16;D[r+3|0]=p>>>24;D[r+4|0]=v;D[r+5|0]=v>>>8;D[r+6|0]=v>>>16;D[r+7|0]=v>>>24;v=G[n+28|0]|G[n+29|0]<<8|(G[n+30|0]<<16|G[n+31|0]<<24);p=G[n+24|0]|G[n+25|0]<<8|(G[n+26|0]<<16|G[n+27|0]<<24);D[r+8|0]=p;D[r+9|0]=p>>>8;D[r+10|0]=p>>>16;D[r+11|0]=p>>>24;D[r+12|0]=v;D[r+13|0]=v>>>8;D[r+14|0]=v>>>16;D[r+15|0]=v>>>24;v=G[n+36|0]|G[n+37|0]<<8|(G[n+38|0]<<16|G[n+39|0]<<24);p=G[n+32|0]|G[n+33|0]<<8|(G[n+34|0]<<16|G[n+35|0]<<24);D[r+16|0]=p;D[r+17|0]=p>>>8;D[r+18|0]=p>>>16;D[r+19|0]=p>>>24;D[r+20|0]=v;D[r+21|0]=v>>>8;D[r+22|0]=v>>>16;D[r+23|0]=v>>>24;v=G[n+44|0]|G[n+45|0]<<8|(G[n+46|0]<<16|G[n+47|0]<<24);p=G[n+40|0]|G[n+41|0]<<8|(G[n+42|0]<<16|G[n+43|0]<<24);D[r+24|0]=p;D[r+25|0]=p>>>8;D[r+26|0]=p>>>16;D[r+27|0]=p>>>24;D[r+28|0]=v;D[r+29|0]=v>>>8;D[r+30|0]=v>>>16;D[r+31|0]=v>>>24;n=n+32|0;r=r+32|0;if(A>>>0>r>>>0){continue}break}break Ob}Sb:{if(A>>>0<=7){D[p|0]=G[n|0];D[p+1|0]=G[n+1|0];D[p+2|0]=G[n+2|0];D[p+3|0]=G[n+3|0];r=n;n=A<<2;r=r+F[n+403152>>2]|0;A=G[r|0]|G[r+1|0]<<8|(G[r+2|0]<<16|G[r+3|0]<<24);D[p+4|0]=A;D[p+5|0]=A>>>8;D[p+6|0]=A>>>16;D[p+7|0]=A>>>24;n=r-F[n+403184>>2]|0;break Sb}r=G[n+4|0]|G[n+5|0]<<8|(G[n+6|0]<<16|G[n+7|0]<<24);A=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24);D[p|0]=A;D[p+1|0]=A>>>8;D[p+2|0]=A>>>16;D[p+3|0]=A>>>24;D[p+4|0]=r;D[p+5|0]=r>>>8;D[p+6|0]=r>>>16;D[p+7|0]=r>>>24}if(v>>>0<9){break Ob}A=p+v|0;r=p+8|0;n=n+8|0;if((r-n|0)<=15){while(1){v=G[n+4|0]|G[n+5|0]<<8|(G[n+6|0]<<16|G[n+7|0]<<24);p=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24);D[r|0]=p;D[r+1|0]=p>>>8;D[r+2|0]=p>>>16;D[r+3|0]=p>>>24;D[r+4|0]=v;D[r+5|0]=v>>>8;D[r+6|0]=v>>>16;D[r+7|0]=v>>>24;n=n+8|0;r=r+8|0;if(A>>>0>r>>>0){continue}break Ob}}z=G[n+4|0]|G[n+5|0]<<8|(G[n+6|0]<<16|G[n+7|0]<<24);B=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24);D[r|0]=B;D[r+1|0]=B>>>8;D[r+2|0]=B>>>16;D[r+3|0]=B>>>24;D[r+4|0]=z;D[r+5|0]=z>>>8;D[r+6|0]=z>>>16;D[r+7|0]=z>>>24;z=G[n+12|0]|G[n+13|0]<<8|(G[n+14|0]<<16|G[n+15|0]<<24);B=G[n+8|0]|G[n+9|0]<<8|(G[n+10|0]<<16|G[n+11|0]<<24);D[r+8|0]=B;D[r+9|0]=B>>>8;D[r+10|0]=B>>>16;D[r+11|0]=B>>>24;D[r+12|0]=z;D[r+13|0]=z>>>8;D[r+14|0]=z>>>16;D[r+15|0]=z>>>24;if((v|0)<25){break Ob}r=p+24|0;while(1){v=G[n+20|0]|G[n+21|0]<<8|(G[n+22|0]<<16|G[n+23|0]<<24);p=G[n+16|0]|G[n+17|0]<<8|(G[n+18|0]<<16|G[n+19|0]<<24);D[r|0]=p;D[r+1|0]=p>>>8;D[r+2|0]=p>>>16;D[r+3|0]=p>>>24;D[r+4|0]=v;D[r+5|0]=v>>>8;D[r+6|0]=v>>>16;D[r+7|0]=v>>>24;v=G[n+28|0]|G[n+29|0]<<8|(G[n+30|0]<<16|G[n+31|0]<<24);p=G[n+24|0]|G[n+25|0]<<8|(G[n+26|0]<<16|G[n+27|0]<<24);D[r+8|0]=p;D[r+9|0]=p>>>8;D[r+10|0]=p>>>16;D[r+11|0]=p>>>24;D[r+12|0]=v;D[r+13|0]=v>>>8;D[r+14|0]=v>>>16;D[r+15|0]=v>>>24;v=G[n+36|0]|G[n+37|0]<<8|(G[n+38|0]<<16|G[n+39|0]<<24);p=G[n+32|0]|G[n+33|0]<<8|(G[n+34|0]<<16|G[n+35|0]<<24);D[r+16|0]=p;D[r+17|0]=p>>>8;D[r+18|0]=p>>>16;D[r+19|0]=p>>>24;D[r+20|0]=v;D[r+21|0]=v>>>8;D[r+22|0]=v>>>16;D[r+23|0]=v>>>24;v=G[n+44|0]|G[n+45|0]<<8|(G[n+46|0]<<16|G[n+47|0]<<24);p=G[n+40|0]|G[n+41|0]<<8|(G[n+42|0]<<16|G[n+43|0]<<24);D[r+24|0]=p;D[r+25|0]=p>>>8;D[r+26|0]=p>>>16;D[r+27|0]=p>>>24;D[r+28|0]=v;D[r+29|0]=v>>>8;D[r+30|0]=v>>>16;D[r+31|0]=v>>>24;n=n+32|0;r=r+32|0;if(A>>>0>r>>>0){continue}break}}n=F[w+28>>2];Tb:{if(n>>>0>32){p=n;break Tb}v=F[w+32>>2];if(v>>>0>=I[w+40>>2]){p=n&7;F[w+28>>2]=p;n=v-(n>>>3|0)|0;F[w+32>>2]=n;F[w+24>>2]=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24);break Tb}A=F[w+36>>2];if((A|0)==(v|0)){p=n;break Tb}r=n;p=n>>>3|0;n=A>>>0>v-p>>>0?v-A|0:p;p=r-(n<<3)|0;F[w+28>>2]=p;n=v-n|0;F[w+32>>2]=n;F[w+24>>2]=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24)}A=$-1|0;n=o>>>0<4294967177;$=n?A:$;s=n?s:o;m=m+o|0;if(A?o>>>0<=4294967176:0){continue}break}if(s>>>0>4294967176){break qb}if($){s=-20;break qb}if(p>>>0<=32){if((p|0)!=32){s=-20;break qb}p=F[w+32>>2];if(p>>>0>=I[w+40>>2]){s=-20;break qb}s=-20;if((p|0)!=F[w+36>>2]){break qb}}p=F[w+72>>2];F[q>>2]=F[w+68>>2];F[q+4>>2]=p;F[q+8>>2]=F[w+76>>2];p=F[w+92>>2]}s=-70;n=ea-p|0;if(n>>>0>ca-m>>>0){break qb}if(m){m=Va(m,p,n)+n|0}else{m=0}s=m-U|0}Ea=w+112|0}Ea=u+192|0;m=s;if(m>>>0>4294967176){break m}}if(F[x+29548>>2]){n=U;p=F[N+4>>2];s=F[N>>2]+m|0;p=s>>>0>>0?p+1|0:p;F[N>>2]=s;F[N+4>>2]=p;s=F[N+72>>2];p=s+m|0;Ub:{Vb:{if(p>>>0<=31){if(!n){break Vb}Va((s+N|0)+40|0,n,m);p=F[N+72>>2]+m|0;break Vb}o=m+n|0;if(s){Va(s+(N+40|0)|0,n,32-s|0);A=F[N+72>>2];F[N+72>>2]=0;p=F[N+12>>2];s=F[N+8>>2];q=We(G[N+40|0]|G[N+41|0]<<8|(G[N+42|0]<<16|G[N+43|0]<<24),G[N+44|0]|G[N+45|0]<<8|(G[N+46|0]<<16|G[N+47|0]<<24),668265295,-1028477379);s=s+q|0;p=Fa+p|0;Ka=N,La=We(Ze(s,q>>>0>s>>>0?p+1|0:p,31),Fa,-2048144761,-1640531535),F[Ka+8>>2]=La;F[N+12>>2]=Fa;p=F[N+20>>2];s=F[N+16>>2];q=We(G[N+48|0]|G[N+49|0]<<8|(G[N+50|0]<<16|G[N+51|0]<<24),G[N+52|0]|G[N+53|0]<<8|(G[N+54|0]<<16|G[N+55|0]<<24),668265295,-1028477379);s=s+q|0;p=Fa+p|0;Ka=N,La=We(Ze(s,q>>>0>s>>>0?p+1|0:p,31),Fa,-2048144761,-1640531535),F[Ka+16>>2]=La;F[N+20>>2]=Fa;p=F[N+28>>2];s=F[N+24>>2];q=We(G[N+56|0]|G[N+57|0]<<8|(G[N+58|0]<<16|G[N+59|0]<<24),G[N+60|0]|G[N+61|0]<<8|(G[N+62|0]<<16|G[N+63|0]<<24),668265295,-1028477379);s=s+q|0;p=Fa+p|0;Ka=N,La=We(Ze(s,q>>>0>s>>>0?p+1|0:p,31),Fa,-2048144761,-1640531535),F[Ka+24>>2]=La;F[N+28>>2]=Fa;p=F[N+36>>2];r=F[N+32>>2];s=N- -64|0;q=We(G[s|0]|G[s+1|0]<<8|(G[s+2|0]<<16|G[s+3|0]<<24),G[s+4|0]|G[s+5|0]<<8|(G[s+6|0]<<16|G[s+7|0]<<24),668265295,-1028477379);s=r+q|0;p=Fa+p|0;Ka=N,La=We(Ze(s,q>>>0>s>>>0?p+1|0:p,31),Fa,-2048144761,-1640531535),F[Ka+32>>2]=La;F[N+36>>2]=Fa;n=(n-A|0)+32|0}if(o>>>0>=n+32>>>0){B=o-32|0;p=F[N+32>>2];K=F[N+36>>2];r=F[N+24>>2];J=F[N+28>>2];q=F[N+16>>2];A=F[N+20>>2];z=F[N+8>>2];s=F[N+12>>2];while(1){t=We(G[n+24|0]|G[n+25|0]<<8|(G[n+26|0]<<16|G[n+27|0]<<24),G[n+28|0]|G[n+29|0]<<8|(G[n+30|0]<<16|G[n+31|0]<<24),668265295,-1028477379);v=K+Fa|0;w=v+1|0;u=v;v=p+t|0;p=p>>>0>v>>>0?w:u;p=We(Ze(v,p,31),Fa,-2048144761,-1640531535);K=Fa;t=We(G[n+16|0]|G[n+17|0]<<8|(G[n+18|0]<<16|G[n+19|0]<<24),G[n+20|0]|G[n+21|0]<<8|(G[n+22|0]<<16|G[n+23|0]<<24),668265295,-1028477379);v=J+Fa|0;t=r+t|0;v=r>>>0>t>>>0?v+1|0:v;r=We(Ze(t,v,31),Fa,-2048144761,-1640531535);J=Fa;v=We(G[n+8|0]|G[n+9|0]<<8|(G[n+10|0]<<16|G[n+11|0]<<24),G[n+12|0]|G[n+13|0]<<8|(G[n+14|0]<<16|G[n+15|0]<<24),668265295,-1028477379);A=A+Fa|0;w=A+1|0;u=A;A=q+v|0;q=q>>>0>A>>>0?w:u;q=We(Ze(A,q,31),Fa,-2048144761,-1640531535);A=Fa;v=We(G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24),G[n+4|0]|G[n+5|0]<<8|(G[n+6|0]<<16|G[n+7|0]<<24),668265295,-1028477379);s=s+Fa|0;v=v+z|0;s=z>>>0>v>>>0?s+1|0:s;z=We(Ze(v,s,31),Fa,-2048144761,-1640531535);s=Fa;n=n+32|0;if(B>>>0>=n>>>0){continue}break}F[N+32>>2]=p;F[N+36>>2]=K;F[N+24>>2]=r;F[N+28>>2]=J;F[N+16>>2]=q;F[N+20>>2]=A;F[N+8>>2]=z;F[N+12>>2]=s}if(n>>>0>=o>>>0){break Ub}p=o-n|0;Va(N+40|0,n,p)}F[N+72>>2]=p}}p=sa-M|0;n=M+aa|0;U=m+U|0;if(!(ya&1)){continue}break}q=F[ba>>2];s=F[ba+4>>2];m=U-ha|0;if((q&s)!=-1&((q|0)!=(m|0)|m>>31!=(s|0))){break l}if(F[x+29408>>2]){za=-22;if(p>>>0<4){break l}if(!F[x+29544>>2]){q=N+40|0;y=F[N+72>>2];sa=q+y|0;m=F[N+4>>2];Q=m;X=F[N>>2];Wb:{if(!m&X>>>0>=32|m){m=F[N+20>>2];z=m;o=F[N+16>>2];A=Ze(o,m,7);s=Fa;m=F[N+12>>2];B=m;t=F[N+8>>2];M=Ze(t,m,1);J=A+M|0;A=Fa+s|0;m=F[N+28>>2];r=m;v=F[N+24>>2];s=Ze(v,m,12);P=J+s|0;C=Fa+(J>>>0>>0?A+1|0:A)|0;m=F[N+36>>2];A=m;M=F[N+32>>2];m=Ze(M,m,18);J=P+m|0;s=Fa+(s>>>0>P>>>0?C+1|0:C)|0;m=We(We(Ze(We(t,B,668265295,-1028477379),Fa,31),Fa,-2048144761,-1640531535)^J,Fa^(m>>>0>J>>>0?s+1|0:s),-2048144761,-1640531535);s=m-1028477341|0;m=Fa-((m>>>0<1028477341)+2048144776|0)|0;m=We(We(Ze(We(o,z,668265295,-1028477379),Fa,31),Fa,-2048144761,-1640531535)^s,Fa^m,-2048144761,-1640531535);s=m-1028477341|0;m=Fa-((m>>>0<1028477341)+2048144776|0)|0;m=We(We(Ze(We(v,r,668265295,-1028477379),Fa,31),Fa,-2048144761,-1640531535)^s,Fa^m,-2048144761,-1640531535);s=m-1028477341|0;m=Fa-((m>>>0<1028477341)+2048144776|0)|0;s=We(We(Ze(We(M,A,668265295,-1028477379),Fa,31),Fa,-2048144761,-1640531535)^s,Fa^m,-2048144761,-1640531535);m=s-1028477341|0;s=Fa-((s>>>0<1028477341)+2048144776|0)|0;break Wb}m=F[N+28>>2]+668265263|0;r=m+1|0;s=m;m=F[N+24>>2]+374761413|0;s=m>>>0<374761413?r:s}s=s+Q|0;z=m+X|0;s=z>>>0>>0?s+1|0:s;m=N+48|0;if(sa>>>0>=m>>>0){while(1){s=We(Ze(We(Ze(We(G[q|0]|G[q+1|0]<<8|(G[q+2|0]<<16|G[q+3|0]<<24),G[q+4|0]|G[q+5|0]<<8|(G[q+6|0]<<16|G[q+7|0]<<24),668265295,-1028477379),Fa,31),Fa,-2048144761,-1640531535)^z,s^Fa,27),Fa,-2048144761,-1640531535);z=s-1028477341|0;s=Fa-((s>>>0<1028477341)+2048144776|0)|0;q=m;m=m+8|0;if(sa>>>0>=m>>>0){continue}break}}m=q+4|0;Xb:{if(sa>>>0>>0){m=q;break Xb}q=We(Ze(We(G[q|0]|G[q+1|0]<<8|(G[q+2|0]<<16|G[q+3|0]<<24),0,-2048144761,-1640531535)^z,s^Fa,23),Fa,668265295,-1028477379);s=Fa+374761393|0;z=q-1640531463|0;s=z>>>0<2654435833?s+1|0:s}Yb:{if(m>>>0>=sa>>>0){break Yb}q=y+N|0;M=q+39|0;A=q+40|0;if(A-m&1){z=We(Ze(We(G[m|0],0,374761413,668265263)^z,s^Fa,11),Fa,-2048144761,-1640531535);s=Fa;q=m+1|0}else{q=m}if((m|0)==(M|0)){break Yb}while(1){M=We(G[q+1|0],0,374761413,668265263);m=Fa;z=We(Ze(We(Ze(We(G[q|0],0,374761413,668265263)^z,s^Fa,11),Fa,-2048144761,-1640531535)^M,Fa^m,11),Fa,-2048144761,-1640531535);s=Fa;q=q+2|0;if((A|0)!=(q|0)){continue}break}}q=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24);M=We(z^s>>>1,s,668265295,-1028477379);s=Fa;m=s>>>29|0;m=We(M^((s&536870911)<<3|M>>>29),m^s,-1640531463,374761393);if((m^Fa)!=(q|0)){break l}}n=n+4|0;p=p-4|0}m=U-ha|0;if(m>>>0<4294967177){break k}}M=-72;za=m;if((m|0)==-10&Ia){break i}}q=za;break g}Ia=1;ta=ta-m|0;ha=m+ha|0;m=F[x+29540>>2]?1:5;if(p>>>0>=m>>>0){continue}break}}M=-72;if(p){break i}M=ha-va|0}q=M;break g}q=-72}Zb:{if(F[x+29576>>2]|!x){break Zb}s=F[x+29564>>2];M=F[x+29560>>2];U=F[x+29584>>2];_b:{if(!U){break _b}p=F[U+27320>>2];n=F[U+27316>>2];$b:{ac:{m=F[U>>2];if(m){if(!n){break ac}Ga[n|0](p,m);Ga[n|0](p,U);break _b}if(!n){break $b}Ga[n|0](p,U);break _b}Ra(m)}Ra(U)}F[x+29600>>2]=0;F[x+29584>>2]=0;F[x+29588>>2]=0;m=F[x+29616>>2];bc:{if(!m){break bc}if(M){Ga[M|0](s,m);break bc}Ra(m)}F[x+29616>>2]=0;p=F[x+29604>>2];if(p){cc:{dc:{ec:{m=F[p>>2];if(m){if(!M){break ec}Ga[M|0](s,m);Ga[M|0](s,p);break cc}if(!M){break dc}Ga[M|0](s,p);break cc}Ra(m)}Ra(p)}F[x+29604>>2]=0}if(M){Ga[M|0](s,x);break Zb}Ra(x)}}if((q|0)!=(qa|0)|q>>>0>4294967176){break d}}fa=1}if(!fa){break a}F[ja+420>>2]=b}fa=ja+412|0;p=F[ja+408>>2]}m=F[a+32>>2]>>>b|0;n=m>>>0<=1?1:m;U=n+3>>>2|0;m=F[a+28>>2]>>>b|0;m=m>>>0<=1?1:m;q=m+3>>>2|0;fc:{gc:{switch(F[a+156>>2]){case 0:if(!F[a+196>>2]){break a}k=d;d=F[a+40>>2];c=k+L(F[a+44>>2],c+L(d>>>0<=1?1:d,b)|0)|0;if(c>>>0>=I[a+148>>2]){break a}d=b;b=F[a+88>>2]+L(b,24)|0;b=G[b|0]|G[b+1|0]<<8|(G[b+2|0]<<16|G[b+3|0]<<24);c=F[a+144>>2]+L(c,20)|0;k=b+(G[c+4|0]|G[c+5|0]<<8|(G[c+6|0]<<16|G[c+7|0]<<24))|0;l=b+(G[c+12|0]|G[c+13|0]<<8|(G[c+14|0]<<16|G[c+15|0]<<24))|0;b=G[c+16|0]|G[c+17|0]<<8|(G[c+18|0]<<16|G[c+19|0]<<24);if(Ub(a+188|0,g,e,f,F[a>>2],F[a+4>>2],q,U,m,n,d,k,G[c+8|0]|G[c+9|0]<<8|(G[c+10|0]<<16|G[c+11|0]<<24),b?l:0,b,h,G[a+1200|0],G[a+1201|0],i,ja,j)){break fc}break a;case 1:break gc;default:break a}}s=L(q,U)<<4;c=L(s,L(F[a+44>>2],c)+d|0);b=G[fa|0]|G[fa+1|0]<<8|(G[fa+2|0]<<16|G[fa+3|0]<<24);if(c>>>0>=b>>>0|s>>>0>b-c>>>0&b>>>0>=c>>>0){break a}if(!Fb(g,e,f,c+p|0,s,q,U,m,n,0,s,h,G[a+1200|0],i,j,k,l)){break a}}Ja=1}return Ja}function _a(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,I=0,K=0,O=0,P=0,Q=0,R=M(0),S=0,T=0,U=M(0),V=0,W=0,X=0,Y=0,Z=0,_=0,$=M(0),aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=M(0),ta=0,ua=0,va=0,wa=0,xa=0,ya=M(0),za=0,Aa=0,Ba=0,Ca=0,Da=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0,Ma=0,Na=0,Oa=M(0),Pa=0,Qa=0,Sa=0,Ua=0,Xa=0,Ya=0,_a=0,ab=0,bb=0,cb=0,db=0,eb=0,fb=0,gb=0,hb=0,ib=0,jb=0,kb=0,lb=0,nb=0,ob=0,pb=0,qb=0,rb=0,tb=M(0),vb=M(0),xb=M(0),yb=M(0),zb=M(0),Ab=M(0),Bb=M(0),Cb=M(0),Db=M(0),Eb=0,Fb=0,Hb=0,Ib=M(0),Jb=0,Kb=0;w=Ea-256|0;Ea=w;a:{if(!G[405840]){break a}n=f-21|0;b:{if(j){break b}if(n>>>0<9){j=h;break b}j=b;if((f|0)!=15){break b}j=h+7>>>3|0;n=-6}if(L(b,c)<<4>>>0>e>>>0){break a}if((f&-2)!=6){o=1;if(!c|!b){break a}Na=j<<2;ga=j<<1;Ga=L(g,j);ia=w+216|0;o=0;xa=(f|0)==24;qa=n>>>0<9?k?k:i:k;P=qa;while(1){e=ha<<2;h=qa-e|0;T=(h|0)>=4?4:h;I=(P|0)>=4?4:P;Y=L(e,j);e=L(ha,Ga)+a|0;z=j;i=0;while(1){r=(z|0)>=4?4:z;c:{d:{e:{f:{g:{h:{i:{j:{k:{switch(f|0){case 29:h=w+104|0;k=Za(d,h,0,0);if(k){$a(F[w+208>>2],F[w+212>>2],ia,h,w)}if(T){break j}break e;case 24:case 25:h=w+104|0;n=Za(d,h,0,0);if(n){$a(F[w+208>>2],F[w+212>>2],ia,h,w)}if(T){break i}break f;case 22:h=w+104|0;u=Za(d,h,0,0);if(u){$a(F[w+208>>2],F[w+212>>2],ia,h,w)}if(T){break h}break g;case 18:h=w+104|0;if(!Za(d,h,0,1)){break d}l=(l|0)>0?l:0;k=F[w+208>>2];if((k|0)!=8){$a(k,F[w+212>>2],ia,h,w);if((l|0)!=3){wb(e,l+w|0,4);break c}ub(w+104|0,w,e);break c}h=G[l+ia|0];k=H[196104]|H[196105]<<16;E[e+2>>1]=k;E[e+4>>1]=k>>>16;E[e+6>>1]=H[196106];E[e>>1]=h|3328;break c;case 12:u=w+104|0;if(!Za(d,u,1,0)){break d}k=F[w+208>>2];if((k|0)!=8){C=0;p=Ea-48|0;Ea=p;x=G[u+20|0];D[e+2|0]=0;D[e+3|0]=0;D[e+4|0]=0;D[e+5|0]=0;D[e+6|0]=0;D[e+7|0]=0;D[e+8|0]=0;D[e+9|0]=0;D[e+8|0]=0;D[e+9|0]=0;D[e+10|0]=0;D[e+11|0]=0;D[e+12|0]=0;D[e+13|0]=0;D[e+14|0]=0;D[e+15|0]=0;h=F[(k<<2)+10176>>2];D[e|0]=h;h=h>>>8|0;D[e+1|0]=h;n=F[u>>2];h=h|(G[u+4|0]<<3)-8;D[e+1|0]=h;O=F[L(n,12)+7200>>2];l:{if(F[u+4>>2]==1){n=F[u+12>>2];D[e+2|0]=n>>>3;D[e+1|0]=h|n<<5;n=17;break l}r=F[u+8>>2];h=10;n=13;while(1){q=(n>>3)+e|0;o=q;t=G[q|0];q=n&7;D[o|0]=t|r<>>q|0;n=n+q|0;h=h-q|0;if(h){continue}break}h=(n>>3)+e|0;r=n&7;q=(F[u+12>>2]<<2&60)<>>0>=3){D[h+1|0]=G[h+1|0]|q>>>8}n=n+6|0}if(G[u+20|0]){h=(120-(O<<(x?5:4))>>3)+e|0;D[h|0]=G[h|0]|G[u+16|0]<<6}h=F[u+4>>2];q=F[u+12>>2];F[p+44>>2]=n;F[p+32>>2]=0;F[p+24>>2]=0;F[p+28>>2]=0;F[p+16>>2]=0;F[p+20>>2]=0;s=u+21|0;r=2;v=L((q>>2)+1|0,h);t=v<<1;h=G[k+7072|0];o=F[L(h,12)+7200>>2];m:{n:{k=1497965>>>h&1;if(!k){q=5;r=4;break n}q=3;if(!(1797559>>>h&1)){break n}if(!o|(v|0)<=0){break m}h=0;while(1){k=n>>3;r=k+(p+16|0)|0;q=n&7;C=G[h+s|0]<>>0>8-q>>>0){k=k+p|0;D[k+17|0]=G[k+17|0]|C>>>8}n=n+o|0;h=h+1|0;if((t|0)!=(h|0)){continue}break}break m}B=(r+t|0)/(q|0)|0;if((B|0)<=0){break m}if(!k){n=0;while(1){D[p+12|0]=0;F[p+8>>2]=0;h=L(n,q);if((h|0)<(t|0)){k=h+s|0;h=t-h|0;h=(h|0)>(q|0)?q:h;Va(p+8|0,k,(h|0)<=1?1:h)}Vb(p+16|0,p+8|0,p+44|0,o);n=n+1|0;if((B|0)!=(n|0)){continue}break}break m}h=L(o,3);k=h+7|0;if(!k){break m}S=o+3|0;Q=h+5|0;h=o<<1;K=h+5|0;A=h+3|0;v=-1<>2]=0;r=0;h=0;y=L(q,C);if((y|0)<(t|0)){h=t-y|0;h=(h|0)>(q|0)?q:h;Va(p+8|0,s+y|0,(h|0)<=1?1:h);r=G[p+9|0];h=G[p+10|0];y=G[p+8|0]}else{y=0}W=r&255;r=G[((L(W>>>o|0,5)+(y>>>o|0)|0)+L(h>>>o|0,25)|0)+398192|0];r=v&y|(v&W)<>>3&3)<>>5&3)<>3)|0;V=y;ja=G[y|0];y=n&7;D[V|0]=ja|r<>>y|0;n=n+y|0;h=h-y|0;if(h){continue}break}C=C+1|0;if((B|0)!=(C|0)){continue}break}}h=x?32:16;F[e>>2]=F[e>>2]|F[p+16>>2];F[e+4>>2]=F[e+4>>2]|F[p+20>>2];F[e+8>>2]=F[e+8>>2]|F[p+24>>2];F[e+12>>2]=F[e+12>>2]|F[p+28>>2];n=0;o:{p:{switch(O-1|0){case 0:while(1){k=127-n|0;r=(k>>>3|0)+e|0;o=r;q=G[r|0];r=u+39|0;D[o|0]=q|G[r+n|0]<<(k&7);k=n|1;q=127-k|0;o=(q>>>3|0)+e|0;D[o|0]=G[o|0]|G[k+r|0]<<(q&6);n=n+2|0;if((h|0)!=(n|0)){continue}break};break o;case 1:while(1){k=126-(n<<1)|0;r=(k>>>3|0)+e|0;o=r;q=G[r|0];r=u+39|0;D[o|0]=q|G[G[r+n|0]+207568|0]<<(k&6);k=n|1;q=126-(k<<1)|0;o=(q>>>3|0)+e|0;D[o|0]=G[o|0]|G[G[k+r|0]+207568|0]<<(q&4);n=n+2|0;if((h|0)!=(n|0)){continue}break};break o;case 2:while(1){r=L(n,-3)+125|0;k=(r>>>3|0)+e|0;q=G[G[(n+u|0)+39|0]+10252|0]<<(r&7);D[k|0]=q|G[k|0];if(r>>>0<=119){D[k+1|0]=G[k+1|0]|q>>>8}n=n+1|0;if((h|0)!=(n|0)){continue}break};break o;case 3:while(1){k=(120-(n<<2)>>3)+e|0;o=k;q=G[k|0];k=u+39|0;D[o|0]=q|G[G[k+n|0]+10272|0]<<4;r=n|1;q=(124-(r<<2)>>3)+e|0;D[q|0]=G[q|0]|G[G[k+r|0]+10272|0];n=n+2|0;if((h|0)!=(n|0)){continue}break};break o;case 4:break p;default:break o}}while(1){r=L(n,-5)+123|0;k=(r>>>3|0)+e|0;q=G[G[(n+u|0)+39|0]+10288|0]<<(r&7);D[k|0]=q|G[k|0];if(r>>>0<=119){D[k+1|0]=G[k+1|0]|q>>>8}n=n+1|0;if((h|0)!=(n|0)){continue}break}}Ea=p+48|0;break c}n=G[ia+3|0];r=G[ia+2|0];q=G[ia+1|0];h=G[ia|0];F[e+12>>2]=0;F[e+4>>2]=-1;F[e+8>>2]=0;D[e|0]=252;D[e+1|0]=253;D[e+2|0]=255;D[e+3|0]=255;p=h|h<<8;h=16;k=64;while(1){u=(k>>3)+e|0;o=u;t=G[u|0];u=k&7;D[o|0]=t|p<>>u|0;k=k+u|0;h=h-u|0;if(h){continue}break};p=q|q<<8;h=16;while(1){q=(k>>3)+e|0;o=q;t=G[q|0];q=k&7;D[o|0]=t|p<>>q|0;k=k+q|0;h=h-q|0;if(h){continue}break};p=r|r<<8;h=16;while(1){r=(k>>3)+e|0;o=r;q=G[r|0];r=k&7;D[o|0]=q|p<>>r|0;k=k+r|0;h=h-r|0;if(h){continue}break};p=n|n<<8;h=16;while(1){n=(k>>3)+e|0;o=n;q=G[n|0];n=k&7;D[o|0]=q|p<>>n|0;k=k+n|0;h=h-n|0;if(h){continue}break};break c;case 8:case 9:n=w+104|0;if(!Za(d,n,0,0)){break d}u=0;C=0;t=Ea-48|0;Ea=t;o=Ta(w,0,96);h=F[n+104>>2];s=G[h+7072|0];q:{r:{s:{switch(h|0){case 0:case 5:case 10:case 12:case 14:case 15:case 18:u=G[h+7168|0];F[o>>2]=6;k=(s<<9)+413088|0;U=M(M(G[k+(G[n+21|0]<<1)|0])/M(255));J[t+32>>2]=U;t:{if(h-15>>>0<=2){p=G[k+(G[n+22|0]<<1)|0];J[t+36>>2]=U;J[t+40>>2]=U;U=M(M(p>>>0)/M(255));J[t+16>>2]=U;J[t+20>>2]=U;J[t+24>>2]=U;J[t+44>>2]=M(G[k+(G[n+23|0]<<1)|0])/M(255);u=4;R=M(M(G[k+(G[n+24|0]<<1)|0])/M(255));break t}J[t+36>>2]=M(G[k+(G[n+23|0]<<1)|0])/M(255);J[t+40>>2]=M(G[k+(G[n+25|0]<<1)|0])/M(255);J[t+16>>2]=M(G[k+(G[n+22|0]<<1)|0])/M(255);J[t+20>>2]=M(G[k+(G[n+24|0]<<1)|0])/M(255);J[t+24>>2]=M(G[k+(G[n+26|0]<<1)|0])/M(255);if(h-8>>>0<=6){k=(s<<9)+413088|0;J[t+44>>2]=M(G[k+(G[n+27|0]<<1)|0])/M(255);R=M(M(G[k+(G[n+28|0]<<1)|0])/M(255));break t}F[t+44>>2]=1065353216;R=M(1)}J[t+28>>2]=R;mb(u,7,t+32|0,t+16|0,o+40|0,t+4|0,t+8|0);F[o+52>>2]=F[t+4>>2];if(h-18>>>0<=4294967285){D[o+55|0]=127;D[o+43|0]=127}F[o+64>>2]=F[t+8>>2];F[o+68>>2]=F[t+12>>2];u:{v:{switch(h-5|0){case 9:D[o+8|0]=G[G[n+39|0]+10592|0];D[o+9|0]=G[G[n+40|0]+10592|0];D[o+10|0]=G[G[n+41|0]+10592|0];D[o+11|0]=G[G[n+42|0]+10592|0];D[o+12|0]=G[G[n+43|0]+10592|0];D[o+13|0]=G[G[n+44|0]+10592|0];D[o+14|0]=G[G[n+45|0]+10592|0];D[o+15|0]=G[G[n+46|0]+10592|0];D[o+16|0]=G[G[n+47|0]+10592|0];D[o+17|0]=G[G[n+48|0]+10592|0];D[o+18|0]=G[G[n+49|0]+10592|0];D[o+19|0]=G[G[n+50|0]+10592|0];D[o+20|0]=G[G[n+51|0]+10592|0];D[o+21|0]=G[G[n+52|0]+10592|0];D[o+22|0]=G[G[n+53|0]+10592|0];h=G[n+54|0]+10592|0;break u;case 13:D[o+8|0]=G[G[n+39|0]+10560|0];D[o+9|0]=G[G[n+40|0]+10560|0];D[o+10|0]=G[G[n+41|0]+10560|0];D[o+11|0]=G[G[n+42|0]+10560|0];D[o+12|0]=G[G[n+43|0]+10560|0];D[o+13|0]=G[G[n+44|0]+10560|0];D[o+14|0]=G[G[n+45|0]+10560|0];D[o+15|0]=G[G[n+46|0]+10560|0];D[o+16|0]=G[G[n+47|0]+10560|0];D[o+17|0]=G[G[n+48|0]+10560|0];D[o+18|0]=G[G[n+49|0]+10560|0];D[o+19|0]=G[G[n+50|0]+10560|0];D[o+20|0]=G[G[n+51|0]+10560|0];D[o+21|0]=G[G[n+52|0]+10560|0];D[o+22|0]=G[G[n+53|0]+10560|0];h=G[n+54|0]+10560|0;break u;default:D[o+8|0]=G[n+39|0];D[o+9|0]=G[n+40|0];D[o+10|0]=G[n+41|0];D[o+11|0]=G[n+42|0];D[o+12|0]=G[n+43|0];D[o+13|0]=G[n+44|0];D[o+14|0]=G[n+45|0];D[o+15|0]=G[n+46|0];D[o+16|0]=G[n+47|0];D[o+17|0]=G[n+48|0];D[o+18|0]=G[n+49|0];D[o+19|0]=G[n+50|0];D[o+20|0]=G[n+51|0];D[o+21|0]=G[n+52|0];D[o+22|0]=G[n+53|0];h=n+54|0;break u;case 0:case 7:break v}}D[o+8|0]=G[G[n+39|0]+10596|0];D[o+9|0]=G[G[n+40|0]+10596|0];D[o+10|0]=G[G[n+41|0]+10596|0];D[o+11|0]=G[G[n+42|0]+10596|0];D[o+12|0]=G[G[n+43|0]+10596|0];D[o+13|0]=G[G[n+44|0]+10596|0];D[o+14|0]=G[G[n+45|0]+10596|0];D[o+15|0]=G[G[n+46|0]+10596|0];D[o+16|0]=G[G[n+47|0]+10596|0];D[o+17|0]=G[G[n+48|0]+10596|0];D[o+18|0]=G[G[n+49|0]+10596|0];D[o+19|0]=G[G[n+50|0]+10596|0];D[o+20|0]=G[G[n+51|0]+10596|0];D[o+21|0]=G[G[n+52|0]+10596|0];D[o+22|0]=G[G[n+53|0]+10596|0];h=G[n+54|0]+10596|0}D[o+23|0]=G[h|0];break r;case 1:F[o>>2]=3;J[t+32>>2]=M(G[n+21|0])/M(255);J[t+36>>2]=M(G[n+23|0])/M(255);h=G[n+25|0];F[t+44>>2]=1065353216;J[t+40>>2]=M(h>>>0)/M(255);J[t+16>>2]=M(G[n+22|0])/M(255);J[t+20>>2]=M(G[n+24|0])/M(255);h=G[n+26|0];F[t+28>>2]=1065353216;J[t+24>>2]=M(h>>>0)/M(255);F[t+4>>2]=0;F[t>>2]=0;mb(3,7,t+32|0,t+16|0,t+4|0,t,t+8|0);D[o+42|0]=G[t+6|0];E[o+40>>1]=H[t+4>>1];E[o+44>>1]=H[t+4>>1];D[o+46|0]=G[t+6|0];h=G[t|0];D[o+52|0]=h;D[o+56|0]=h;h=G[t+1|0];D[o+57|0]=h;D[o+53|0]=h;h=G[t+2|0];D[o+58|0]=h;D[o+54|0]=h;h=F[t+8>>2];F[o+64>>2]=h;k=F[t+12>>2];F[o+76>>2]=k;F[o+72>>2]=h;F[o+68>>2]=k;D[o+8|0]=G[n+39|0];D[o+9|0]=G[n+40|0];D[o+10|0]=G[n+41|0];D[o+11|0]=G[n+42|0];D[o+12|0]=G[n+43|0];D[o+13|0]=G[n+44|0];D[o+14|0]=G[n+45|0];D[o+15|0]=G[n+46|0];D[o+16|0]=G[n+47|0];D[o+17|0]=G[n+48|0];D[o+18|0]=G[n+49|0];D[o+19|0]=G[n+50|0];D[o+20|0]=G[n+51|0];D[o+21|0]=G[n+52|0];D[o+22|0]=G[n+53|0];D[o+23|0]=G[n+54|0];break r;case 2:F[o>>2]=1;F[o+4>>2]=G[L(F[n+108>>2],6)+5248|0];K=43795755>>>F[n+108>>2]&1;k=1;while(1){s=0;h=n+L(C,6)|0;p=G[h+24|0];$=M(M((p<<4|p)>>>0)/M(255));yb=M($*M(127));U=M(M(yb*M(.5))+M(.5));w:{if(M(N(U))=0?(r|0)>=126?126:r:0;U=M(M(M(((x>>>6&1|x<<1)&253)>>>0)/M(255))-$);U=M(U*U);p=G[h+23|0];sa=M(M((p<<4|p)>>>0)/M(255));zb=M(sa*M(127));R=M(M(zb*M(.5))+M(.5));x:{if(M(N(R))=0?(r|0)>=126?126:r:0;R=M(M(M(((O>>>6&1|O<<1)&253)>>>0)/M(255))-sa);R=M(R*R);p=G[h+22|0];tb=M(M((p<<4|p)>>>0)/M(255));Ab=M(tb*M(127));ya=M(M(Ab*M(.5))+M(.5));y:{if(M(N(ya))=0?(r|0)>=126?126:r:0;ya=M(M(M(((B>>>6&1|B<<1)&253)>>>0)/M(255))-tb);Oa=M(ya*ya);U=M(R+U);p=G[h+21|0];ya=M(M((p<<4|p)>>>0)/M(255));Bb=M(ya*M(127));R=M(M(Bb*M(.5))+M(.5));z:{if(M(N(R))=0?(r|0)>=126?126:r:0;R=M(M(M(((y>>>6&1|y<<1)&253)>>>0)/M(255))-ya);R=M(M(M(R*R)+Oa)+U);p=G[h+26|0];Oa=M(M((p<<4|p)>>>0)/M(255));Cb=M(Oa*M(127));U=M(M(Cb*M(.5))+M(.5));A:{if(M(N(U))=0?(r|0)>=126?126:r:0;U=M(M(M(((S>>>6&1|S<<1)&253)>>>0)/M(255))-Oa);Ib=M(U*U);U=M(1e9);u=0;q=0;p=0;r=0;v=0;vb=R;h=G[h+25|0];xb=M(M((h<<4|h)>>>0)/M(255));Db=M(xb*M(127));R=M(M(Db*M(.5))+M(.5));B:{if(M(N(R))=0?(Q|0)>=126?126:Q:0;R=M(M(M(((h>>>6&1|h<<1)&253)>>>0)/M(255))-xb);R=M(vb+M(M(R*R)+Ib));if(R>>1|0;u=(h&254)>>>1|0;q=(x&254)>>>1|0;r=(B&254)>>>1|0;v=(y&254)>>>1|0;U=R;p=(O&254)>>>1|0}O=0;R=M(M(M(yb+M(-1))*M(.5))+M(.5));C:{if(M(N(R))=127?127:x;R=M(M(M(((h>>>6&1|h<<1)&255)>>>0)/M(255))-$);R=M(R*R);$=M(M(M(zb+M(-1))*M(.5))+M(.5));D:{if(M(N($))=127?127:B;$=M(M(M(((x>>>6&1|x<<1)&255)>>>0)/M(255))-sa);$=M($*$);sa=M(M(M(Ab+M(-1))*M(.5))+M(.5));E:{if(M(N(sa))=127?127:y;sa=M(M(M(((B>>>6&1|B<<1)&255)>>>0)/M(255))-tb);sa=M(sa*sa);R=M($+R);$=M(M(M(Bb+M(-1))*M(.5))+M(.5));F:{if(M(N($))=127?127:S;$=M(M(M(((y>>>6&1|y<<1)&255)>>>0)/M(255))-ya);R=M(M(M($*$)+sa)+R);$=M(M(M(Cb+M(-1))*M(.5))+M(.5));G:{if(M(N($))=127?127:Q;$=M(M(M(((S>>>6&1|S<<1)&255)>>>0)/M(255))-Oa);$=M($*$);vb=R;R=M(M(M(Db+M(-1))*M(.5))+M(.5));H:{if(M(N(R))=127?127:A;R=M(M(M(((Q>>>6&1|Q<<1)&255)>>>0)/M(255))-xb);if(U>M(vb+M(M(R*R)+$))){O=1;s=(S&254)>>>1|0;q=(h&254)>>>1|0;r=(B&254)>>>1|0;v=(y&254)>>>1|0;u=(Q&254)>>>1|0;p=(x&254)>>>1|0}h=C^K;C=1;x=h^1;h=o+(x<<2)|0;D[h+42|0]=u;D[h+41|0]=p;D[h+40|0]=v;D[h+54|0]=s;D[h+53|0]=q;D[h+52|0]=r;F[(o+(x<<3)|0)- -64>>2]=O;h=k;k=0;if(h){continue}break};D[o+8|0]=G[n+39|0];D[o+9|0]=G[n+40|0];D[o+10|0]=G[n+41|0];D[o+11|0]=G[n+42|0];D[o+12|0]=G[n+43|0];D[o+13|0]=G[n+44|0];D[o+14|0]=G[n+45|0];D[o+15|0]=G[n+46|0];D[o+16|0]=G[n+47|0];D[o+17|0]=G[n+48|0];D[o+18|0]=G[n+49|0];D[o+19|0]=G[n+50|0];D[o+20|0]=G[n+51|0];D[o+21|0]=G[n+52|0];D[o+22|0]=G[n+53|0];D[o+23|0]=G[n+54|0];break r;case 3:F[o>>2]=2;F[o+4>>2]=G[L(F[n+108>>2],6)+5568|0];C=1;h=(s<<9)+413088|0;s=G[h+(G[n+22|0]<<1)|0];k=o+40|0;p=L(G[(L(F[n+108>>2],6)+5568|0)+4|0],3)+5648|0;u=G[p|0]<<2;r=k+u|0;D[r|0]=(L(G[h+(G[n+21|0]<<1)|0],31)+127>>>0)/255;q=o+52|0;u=u+q|0;D[u|0]=(L(s,31)+127>>>0)/255;s=G[h+(G[n+24|0]<<1)|0];D[r+1|0]=(L(G[h+(G[n+23|0]<<1)|0],31)+127>>>0)/255;D[u+1|0]=(L(s,31)+127>>>0)/255;s=G[h+(G[n+26|0]<<1)|0];D[r+2|0]=(L(G[h+(G[n+25|0]<<1)|0],31)+127>>>0)/255;D[u+2|0]=(L(s,31)+127>>>0)/255;s=G[h+(G[n+28|0]<<1)|0];u=G[p+1|0]<<2;r=u+k|0;D[r|0]=(L(G[h+(G[n+27|0]<<1)|0],31)+127>>>0)/255;u=q+u|0;D[u|0]=(L(s,31)+127>>>0)/255;s=G[h+(G[n+30|0]<<1)|0];D[r+1|0]=(L(G[h+(G[n+29|0]<<1)|0],31)+127>>>0)/255;D[u+1|0]=(L(s,31)+127>>>0)/255;s=G[h+(G[n+32|0]<<1)|0];D[r+2|0]=(L(G[h+(G[n+31|0]<<1)|0],31)+127>>>0)/255;D[u+2|0]=(L(s,31)+127>>>0)/255;r=G[h+(G[n+34|0]<<1)|0];p=G[p+2|0]<<2;k=p+k|0;D[k|0]=(L(G[h+(G[n+33|0]<<1)|0],31)+127>>>0)/255;p=p+q|0;D[p|0]=(L(r,31)+127>>>0)/255;r=G[h+(G[n+36|0]<<1)|0];D[k+1|0]=(L(G[h+(G[n+35|0]<<1)|0],31)+127>>>0)/255;D[p+1|0]=(L(r,31)+127>>>0)/255;r=G[h+(G[n+38|0]<<1)|0];D[k+2|0]=(L(G[h+(G[n+37|0]<<1)|0],31)+127>>>0)/255;D[p+2|0]=(L(r,31)+127>>>0)/255;D[o+8|0]=G[n+39|0];D[o+9|0]=G[n+40|0];D[o+10|0]=G[n+41|0];D[o+11|0]=G[n+42|0];D[o+12|0]=G[n+43|0];D[o+13|0]=G[n+44|0];D[o+14|0]=G[n+45|0];D[o+15|0]=G[n+46|0];D[o+16|0]=G[n+47|0];D[o+17|0]=G[n+48|0];D[o+18|0]=G[n+49|0];D[o+19|0]=G[n+50|0];D[o+20|0]=G[n+51|0];D[o+21|0]=G[n+52|0];D[o+22|0]=G[n+53|0];D[o+23|0]=G[n+54|0];break q;case 4:F[o>>2]=3;F[o+4>>2]=G[L(F[n+108>>2],6)+5248|0];k=F[n+108>>2];F[t+44>>2]=1065353216;F[t+28>>2]=1065353216;C=1;h=(s<<9)+413088|0;J[t+32>>2]=M(G[h+(G[n+21|0]<<1)|0])/M(255);J[t+16>>2]=M(G[h+(G[n+22|0]<<1)|0])/M(255);J[t+36>>2]=M(G[h+(G[n+23|0]<<1)|0])/M(255);J[t+20>>2]=M(G[h+(G[n+24|0]<<1)|0])/M(255);J[t+40>>2]=M(G[h+(G[n+25|0]<<1)|0])/M(255);J[t+24>>2]=M(G[h+(G[n+26|0]<<1)|0])/M(255);F[t+8>>2]=0;F[t+12>>2]=0;F[t+4>>2]=0;F[t>>2]=0;q=t+32|0;u=t+16|0;s=t+4|0;v=t+8|0;mb(3,7,q,u,s,t,v);x=o+40|0;k=43795755>>>k&1;O=!k;r=O<<2;p=x+r|0;D[p+2|0]=G[t+6|0];E[p>>1]=H[t+4>>1];B=o+52|0;r=B+r|0;D[r+2|0]=G[t+2|0];E[r>>1]=H[t>>1];D[p+3|0]=127;D[r+3|0]=127;r=o- -64|0;p=r+(O<<3)|0;F[p>>2]=F[t+8>>2];F[p+4>>2]=F[t+12>>2];J[t+32>>2]=M(G[h+(G[n+27|0]<<1)|0])/M(255);J[t+16>>2]=M(G[h+(G[n+28|0]<<1)|0])/M(255);J[t+36>>2]=M(G[h+(G[n+29|0]<<1)|0])/M(255);J[t+20>>2]=M(G[h+(G[n+30|0]<<1)|0])/M(255);J[t+40>>2]=M(G[h+(G[n+31|0]<<1)|0])/M(255);J[t+24>>2]=M(G[h+(G[n+32|0]<<1)|0])/M(255);F[t+8>>2]=0;F[t+12>>2]=0;F[t+4>>2]=0;F[t>>2]=0;mb(3,7,q,u,s,t,v);p=k<<2;h=p+x|0;D[h+2|0]=G[t+6|0];E[h>>1]=H[t+4>>1];p=p+B|0;D[p+2|0]=G[t+2|0];E[p>>1]=H[t>>1];D[h+3|0]=127;D[p+3|0]=127;h=r+(k<<3)|0;F[h>>2]=F[t+8>>2];F[h+4>>2]=F[t+12>>2];D[o+8|0]=G[n+39|0];D[o+9|0]=G[n+40|0];D[o+10|0]=G[n+41|0];D[o+11|0]=G[n+42|0];D[o+12|0]=G[n+43|0];D[o+13|0]=G[n+44|0];D[o+14|0]=G[n+45|0];D[o+15|0]=G[n+46|0];D[o+16|0]=G[n+47|0];D[o+17|0]=G[n+48|0];D[o+18|0]=G[n+49|0];D[o+19|0]=G[n+50|0];D[o+20|0]=G[n+51|0];D[o+21|0]=G[n+52|0];D[o+22|0]=G[n+53|0];D[o+23|0]=G[n+54|0];break q;case 6:case 11:case 13:case 17:F[o>>2]=5;F[o+92>>2]=F[n+16>>2]+1&3;I:{J:{if(h-15>>>0<=2){h=(s<<9)+413088|0;k=(L(G[h+(G[n+21|0]<<1)|0],127)+127>>>0)/255|0;D[o+40|0]=k;p=G[h+(G[n+22|0]<<1)|0];D[o+41|0]=k;D[o+42|0]=k;k=(L(p,127)+127>>>0)/255|0;D[o+53|0]=k;D[o+52|0]=k;D[o+54|0]=k;D[o+43|0]=G[h+(G[n+23|0]<<1)|0];D[o+55|0]=G[h+(G[n+24|0]<<1)|0];break J}u=F[n+16>>2];q=u?0:3;k=(s<<9)+413088|0;p=G[k+(G[n+21|0]<<1)|0];r=G[k+(G[n+22|0]<<1)|0];if(u){r=(L(r&255,127)+127>>>0)/255|0;p=(L(p&255,127)+127>>>0)/255|0}u=o+40|0;D[u+q|0]=p;C=o+52|0;D[C+q|0]=r;p=G[k+(G[n+24|0]<<1)|0];q=G[k+(G[n+23|0]<<1)|0];r=F[n+16>>2]==1;k=r?3:1;if(!r){q=(L(q&255,127)+127>>>0)/255|0;p=(L(p&255,127)+127>>>0)/255|0}D[k+u|0]=q;D[k+C|0]=p;k=(s<<9)+413088|0;q=G[k+(G[n+26|0]<<1)|0];k=G[k+(G[n+25|0]<<1)|0];p=F[n+16>>2]==2;r=p?3:2;x=r+u|0;if(!p){q=(L(q&255,127)+127>>>0)/255|0;k=(L(k,127)+127>>>0)/255|0}D[x|0]=k;D[r+C|0]=q;p=255;r=255;if(h-8>>>0<=6){k=(s<<9)+413088|0;r=G[k+(G[n+28|0]<<1)|0];p=G[k+(G[n+27|0]<<1)|0]}k=F[n+16>>2];if(k>>>0<=2){r=(L(r,127)+127>>>0)/255|0;p=(L(p,127)+127>>>0)/255|0}D[k+u|0]=p;D[k+C|0]=r;if((h|0)==13){break I}}D[o+8|0]=G[n+39|0];D[o+24|0]=G[n+40|0];D[o+9|0]=G[n+41|0];D[o+25|0]=G[n+42|0];D[o+10|0]=G[n+43|0];D[o+26|0]=G[n+44|0];D[o+11|0]=G[n+45|0];D[o+27|0]=G[n+46|0];D[o+12|0]=G[n+47|0];D[o+28|0]=G[n+48|0];D[o+13|0]=G[n+49|0];D[o+29|0]=G[n+50|0];D[o+14|0]=G[n+51|0];D[o+30|0]=G[n+52|0];D[o+15|0]=G[n+53|0];D[o+31|0]=G[n+54|0];D[o+16|0]=G[n+55|0];D[o+32|0]=G[n+56|0];D[o+17|0]=G[n+57|0];D[o+33|0]=G[n+58|0];D[o+18|0]=G[n+59|0];D[o+34|0]=G[n+60|0];D[o+19|0]=G[n+61|0];D[o+35|0]=G[n+62|0];D[o+20|0]=G[n+63|0];D[o+36|0]=G[n- -64|0];D[o+21|0]=G[n+65|0];D[o+37|0]=G[n+66|0];D[o+22|0]=G[n+67|0];D[o+38|0]=G[n+68|0];D[o+23|0]=G[n+69|0];D[o+39|0]=G[n+70|0];break r}D[o+8|0]=G[n+39|0]?3:0;D[o+24|0]=G[n+40|0]?3:0;D[o+9|0]=G[n+41|0]?3:0;D[o+25|0]=G[n+42|0]?3:0;D[o+10|0]=G[n+43|0]?3:0;D[o+26|0]=G[n+44|0]?3:0;D[o+11|0]=G[n+45|0]?3:0;D[o+27|0]=G[n+46|0]?3:0;D[o+12|0]=G[n+47|0]?3:0;D[o+28|0]=G[n+48|0]?3:0;D[o+13|0]=G[n+49|0]?3:0;D[o+29|0]=G[n+50|0]?3:0;D[o+14|0]=G[n+51|0]?3:0;D[o+30|0]=G[n+52|0]?3:0;D[o+15|0]=G[n+53|0]?3:0;D[o+31|0]=G[n+54|0]?3:0;D[o+16|0]=G[n+55|0]?3:0;D[o+32|0]=G[n+56|0]?3:0;D[o+17|0]=G[n+57|0]?3:0;D[o+33|0]=G[n+58|0]?3:0;D[o+18|0]=G[n+59|0]?3:0;D[o+34|0]=G[n+60|0]?3:0;D[o+19|0]=G[n+61|0]?3:0;D[o+35|0]=G[n+62|0]?3:0;D[o+20|0]=G[n+63|0]?3:0;D[o+36|0]=G[n- -64|0]?3:0;D[o+21|0]=G[n+65|0]?3:0;D[o+37|0]=G[n+66|0]?3:0;D[o+22|0]=G[n+67|0]?3:0;D[o+38|0]=G[n+68|0]?3:0;D[o+23|0]=G[n+69|0]?3:0;D[o+39|0]=G[n+70|0]?3:0;break r;case 7:F[o>>2]=2;F[o+4>>2]=G[L(F[n+108>>2],6)+5440|0];C=1;h=(s<<9)+413088|0;p=n+21|0;q=F[n+108>>2];r=G[(L(q,6)+5440|0)+4|0];u=r&1;k=p+L(u,6)|0;D[o+40|0]=(L(G[h+(G[k|0]<<1)|0],31)+127>>>0)/255;D[o+52|0]=(L(G[h+(G[k+1|0]<<1)|0],31)+127>>>0)/255;D[o+41|0]=(L(G[h+(G[k+2|0]<<1)|0],31)+127>>>0)/255;D[o+53|0]=(L(G[h+(G[k+3|0]<<1)|0],31)+127>>>0)/255;D[o+42|0]=(L(G[h+(G[k+4|0]<<1)|0],31)+127>>>0)/255;D[o+54|0]=(L(G[h+(G[k+5|0]<<1)|0],31)+127>>>0)/255;k=p+L((r^87040>>>q^-1)&1,6)|0;D[o+44|0]=(L(G[h+(G[k|0]<<1)|0],31)+127>>>0)/255;D[o+56|0]=(L(G[h+(G[k+1|0]<<1)|0],31)+127>>>0)/255;D[o+45|0]=(L(G[h+(G[k+2|0]<<1)|0],31)+127>>>0)/255;D[o+57|0]=(L(G[h+(G[k+3|0]<<1)|0],31)+127>>>0)/255;D[o+46|0]=(L(G[h+(G[k+4|0]<<1)|0],31)+127>>>0)/255;D[o+58|0]=(L(G[h+(G[k+5|0]<<1)|0],31)+127>>>0)/255;k=F[(r<<1&508)+398484>>2];k=p+L(u?1-k|0:k,6)|0;D[o+48|0]=(L(G[h+(G[k|0]<<1)|0],31)+127>>>0)/255;D[o+60|0]=(L(G[h+(G[k+1|0]<<1)|0],31)+127>>>0)/255;D[o+49|0]=(L(G[h+(G[k+2|0]<<1)|0],31)+127>>>0)/255;D[o+61|0]=(L(G[h+(G[k+3|0]<<1)|0],31)+127>>>0)/255;D[o+50|0]=(L(G[h+(G[k+4|0]<<1)|0],31)+127>>>0)/255;D[o+62|0]=(L(G[h+(G[k+5|0]<<1)|0],31)+127>>>0)/255;D[o+8|0]=G[n+39|0];D[o+9|0]=G[n+40|0];D[o+10|0]=G[n+41|0];D[o+11|0]=G[n+42|0];D[o+12|0]=G[n+43|0];D[o+13|0]=G[n+44|0];D[o+14|0]=G[n+45|0];D[o+15|0]=G[n+46|0];D[o+16|0]=G[n+47|0];D[o+17|0]=G[n+48|0];D[o+18|0]=G[n+49|0];D[o+19|0]=G[n+50|0];D[o+20|0]=G[n+51|0];D[o+21|0]=G[n+52|0];D[o+22|0]=G[n+53|0];D[o+23|0]=G[n+54|0];break q;case 8:k=(G[n+115|0]<<3)+423840|0;p=(G[n+114|0]<<3)+423840|0;r=(G[n+113|0]<<3)+423840|0;q=(G[n+112|0]<<3)+423840|0;h=H[k+4>>1]+(H[p+4>>1]+(H[r+4>>1]+H[q+4>>1]|0)|0)|0;k=H[k>>1]+(H[p>>1]+(H[r>>1]+H[q>>1]|0)|0)|0;if(!(!k|!h)){F[o>>2]=5;D[o+40|0]=G[((G[n+112|0]<<2)+425888|0)+2|0];D[o+52|0]=G[((G[n+112|0]<<2)+425888|0)+3|0];D[o+41|0]=G[((G[n+113|0]<<2)+425888|0)+2|0];D[o+53|0]=G[((G[n+113|0]<<2)+425888|0)+3|0];D[o+42|0]=G[((G[n+114|0]<<2)+425888|0)+2|0];h=G[((G[n+114|0]<<2)+425888|0)+3|0];F[o+8>>2]=16843009;F[o+12>>2]=16843009;D[o+54|0]=h;F[o+16>>2]=16843009;F[o+20>>2]=16843009;D[o+43|0]=G[n+115|0];D[o+55|0]=G[n+115|0];break r}F[o>>2]=6;k=h>>>0>>0;h=k<<2;D[o+40|0]=G[(h+((G[n+112|0]<<3)+423840|0)|0)+2|0];D[o+52|0]=G[(h+((G[n+112|0]<<3)+423840|0)|0)+3|0];D[o+41|0]=G[(h+((G[n+113|0]<<3)+423840|0)|0)+2|0];D[o+53|0]=G[(h+((G[n+113|0]<<3)+423840|0)|0)+3|0];D[o+42|0]=G[(h+((G[n+114|0]<<3)+423840|0)|0)+2|0];D[o+54|0]=G[(h+((G[n+114|0]<<3)+423840|0)|0)+3|0];D[o+43|0]=G[(h+((G[n+115|0]<<3)+423840|0)|0)+2|0];h=G[(h+((G[n+115|0]<<3)+423840|0)|0)+3|0];F[o+68>>2]=k;F[o+64>>2]=k;D[o+55|0]=h;F[o+8>>2]=84215045;F[o+12>>2]=84215045;F[o+16>>2]=84215045;F[o+20>>2]=84215045;break r;case 9:case 16:break s;default:break q}}F[o>>2]=7;F[o+4>>2]=G[L(F[n+108>>2],6)+5248|0];p=43795755>>>F[n+108>>2]&1;r=h-15>>>0>2;h=(s<<9)+413088|0;s=1;while(1){K:{if(!r){q=u<<2;k=q+n|0;U=M(M(G[h+(G[k+21|0]<<1)|0])/M(255));J[t+32>>2]=U;C=G[h+(G[k+22|0]<<1)|0];J[t+36>>2]=U;J[t+40>>2]=U;U=M(M(C>>>0)/M(255));J[t+16>>2]=U;J[t+20>>2]=U;J[t+24>>2]=U;J[t+44>>2]=M(G[h+(G[k+23|0]<<1)|0])/M(255);k=q|3;break K}q=u<<3;k=q+n|0;J[t+32>>2]=M(G[h+(G[k+21|0]<<1)|0])/M(255);J[t+36>>2]=M(G[h+(G[k+23|0]<<1)|0])/M(255);J[t+40>>2]=M(G[h+(G[k+25|0]<<1)|0])/M(255);J[t+44>>2]=M(G[h+(G[k+27|0]<<1)|0])/M(255);J[t+16>>2]=M(G[h+(G[k+22|0]<<1)|0])/M(255);J[t+20>>2]=M(G[h+(G[k+24|0]<<1)|0])/M(255);J[t+24>>2]=M(G[h+(G[k+26|0]<<1)|0])/M(255);k=q|7}J[t+28>>2]=M(G[(G[(k+n|0)+21|0]<<1)+h|0])/M(255);F[t+8>>2]=0;F[t+12>>2]=0;F[t+4>>2]=0;F[t>>2]=0;mb(4,5,t+32|0,t+16|0,t+4|0,t,t+8|0);k=p^u^1;q=o+(k<<2)|0;F[q+40>>2]=F[t+4>>2];F[q+52>>2]=F[t>>2];k=o+(k<<3)|0;F[k- -64>>2]=F[t+8>>2];F[k+68>>2]=F[t+12>>2];k=s&1;s=0;u=1;if(k){continue}break}D[o+8|0]=G[n+39|0];D[o+9|0]=G[n+40|0];D[o+10|0]=G[n+41|0];D[o+11|0]=G[n+42|0];D[o+12|0]=G[n+43|0];D[o+13|0]=G[n+44|0];D[o+14|0]=G[n+45|0];D[o+15|0]=G[n+46|0];D[o+16|0]=G[n+47|0];D[o+17|0]=G[n+48|0];D[o+18|0]=G[n+49|0];D[o+19|0]=G[n+50|0];D[o+20|0]=G[n+51|0];D[o+21|0]=G[n+52|0];D[o+22|0]=G[n+53|0];D[o+23|0]=G[n+54|0]}C=1}Ea=t+48|0;if(!C){break d}p=Ea-112|0;r=F[w>>2];t=G[r+10128|0];za=r-4|0;k=7872;L:{if(za>>>0<3){break L}h=F[w+4>>2]<<4;k=h+7888|0;if(138>>>r&1){break L}k=h+8912|0}h=F[w+12>>2];F[p+96>>2]=F[w+8>>2];F[p+100>>2]=h;h=F[w+20>>2];F[p+104>>2]=F[w+16>>2];F[p+108>>2]=h;h=F[w+36>>2];F[p+88>>2]=F[w+32>>2];F[p+92>>2]=h;h=F[w+28>>2];F[p+80>>2]=F[w+24>>2];F[p+84>>2]=h;F[p+72>>2]=G[w+48|0]|G[w+49|0]<<8|(G[w+50|0]<<16|G[w+51|0]<<24);h=G[w+44|0]|G[w+45|0]<<8|(G[w+46|0]<<16|G[w+47|0]<<24);F[p+64>>2]=G[w+40|0]|G[w+41|0]<<8|(G[w+42|0]<<16|G[w+43|0]<<24);F[p+68>>2]=h;F[p+56>>2]=G[w+60|0]|G[w+61|0]<<8|(G[w+62|0]<<16|G[w+63|0]<<24);h=G[w+56|0]|G[w+57|0]<<8|(G[w+58|0]<<16|G[w+59|0]<<24);F[p+48>>2]=G[w+52|0]|G[w+53|0]<<8|(G[w+54|0]<<16|G[w+55|0]<<24);F[p+52>>2]=h;h=F[w+84>>2];F[p+32>>2]=F[w+80>>2];F[p+36>>2]=h;h=F[w+76>>2];F[p+24>>2]=F[w+72>>2];F[p+28>>2]=h;h=F[w+68>>2];F[p+16>>2]=F[w+64>>2];F[p+20>>2]=h;F[p+8>>2]=-1;F[p>>2]=-1;F[p+4>>2]=-1;Ha=t>>>0<=1?1:t;W=r&-3;Aa=F[w+88>>2];n=1<>>1|0;h=0;V=G[p+95|0];O=G[p+94|0];B=G[p+93|0];y=G[p+92|0];x=G[p+91|0];X=G[p+90|0];ea=G[p+89|0];_=G[p+88|0];aa=G[p+87|0];fa=G[p+86|0];S=G[p+85|0];Q=G[p+84|0];K=G[p+83|0];ka=G[p+82|0];la=G[p+81|0];ma=G[p+80|0];Z=G[p+111|0];ba=G[p+110|0];v=G[p+109|0];ca=G[p+108|0];da=G[p+107|0];oa=G[p+106|0];ja=G[p+105|0];na=G[p+104|0];ra=G[p+103|0];ua=G[p+102|0];C=G[p+101|0];va=G[p+100|0];Ja=G[p+99|0];Ka=G[p+98|0];La=G[p+97|0];Ba=G[p+96|0];Ca=r&-2;Ma=(Ca|0)!=4;wa=r+10160|0;while(1){o=h<<2;s=o+p|0;if(h){u=F[w+4>>2]+1e4|0;M:{if(!((h|0)!=1|W)){break M}q=F[w+4>>2];u=q+10064|0;if(!((h|0)!=2|W)){break M}u=q+9936|0}ta=G[u|0]}else{ta=0}F[s>>2]=ta;N:{if(G[ta+(p+96|0)|0]&Ia){if(G[k|0]==(h|0)){Ba=n+(Ba^-1|-256)|0;D[p+96|0]=Ba}if(G[k+1|0]==(h|0)){La=n+(La^-1|-256)|0;D[p+97|0]=La}if(G[k+2|0]==(h|0)){Ka=n+(Ka^-1|-256)|0;D[p+98|0]=Ka}if(G[k+3|0]==(h|0)){Ja=n+(Ja^-1|-256)|0;D[p+99|0]=Ja}if(G[k+4|0]==(h|0)){va=n+(va^-1|-256)|0;D[p+100|0]=va}if(G[k+5|0]==(h|0)){C=n+(C^-1|-256)|0;D[p+101|0]=C}if(G[k+6|0]==(h|0)){ua=n+(ua^-1|-256)|0;D[p+102|0]=ua}if(G[k+7|0]==(h|0)){ra=n+(ra^-1|-256)|0;D[p+103|0]=ra}if(G[k+8|0]==(h|0)){na=n+(na^-1|-256)|0;D[p+104|0]=na}if(G[k+9|0]==(h|0)){ja=n+(ja^-1|-256)|0;D[p+105|0]=ja}if(G[k+10|0]==(h|0)){oa=n+(oa^-1|-256)|0;D[p+106|0]=oa}if(G[k+11|0]==(h|0)){da=n+(da^-1|-256)|0;D[p+107|0]=da}if(G[k+12|0]==(h|0)){ca=n+(ca^-1|-256)|0;D[p+108|0]=ca}if(G[k+13|0]==(h|0)){v=n+(v^-1|-256)|0;D[p+109|0]=v}if(G[k+14|0]==(h|0)){ba=n+(ba^-1|-256)|0;D[p+110|0]=ba}if(G[k+15|0]==(h|0)){Z=n+(Z^-1|-256)|0;D[p+111|0]=Z}q=o+(p- -64|0)|0;O:{if((Ca|0)!=4){s=G[q|0]|G[q+1|0]<<8|(G[q+2|0]<<16|G[q+3|0]<<24);u=o+(p+48|0)|0;A=G[u|0]|G[u+1|0]<<8|(G[u+2|0]<<16|G[u+3|0]<<24);D[q|0]=A;D[q+1|0]=A>>>8;D[q+2|0]=A>>>16;D[q+3|0]=A>>>24;D[u|0]=s;D[u+1|0]=s>>>8;D[u+2|0]=s>>>16;D[u+3|0]=s>>>24;if((r|0)!=1){break O}break N}s=G[q|0];u=o+(p+48|0)|0;D[q|0]=G[u|0];D[u|0]=s;s=G[q+1|0];D[q+1|0]=G[u+1|0];D[u+1|0]=s;s=G[q+2|0];D[q+2|0]=G[u+2|0];D[u+2|0]=s}q=(p+16|0)+(h<<3)|0;u=F[q>>2];Jb=q,Kb=Ze(u,F[q+4>>2],32),F[Jb>>2]=Kb;F[q+4>>2]=Fa}if(Ma){break N}q=1<>>1)){break N}if(G[k|0]==(h|0)){ma=q+(ma^-1|-256)|0;D[p+80|0]=ma}if(G[k+1|0]==(h|0)){la=q+(la^-1|-256)|0;D[p+81|0]=la}if(G[k+2|0]==(h|0)){ka=q+(ka^-1|-256)|0;D[p+82|0]=ka}if(G[k+3|0]==(h|0)){K=q+(K^-1|-256)|0;D[p+83|0]=K}if(G[k+4|0]==(h|0)){Q=q+(Q^-1|-256)|0;D[p+84|0]=Q}if(G[k+5|0]==(h|0)){S=q+(S^-1|-256)|0;D[p+85|0]=S}if(G[k+6|0]==(h|0)){fa=q+(fa^-1|-256)|0;D[p+86|0]=fa}if(G[k+7|0]==(h|0)){aa=q+(aa^-1|-256)|0;D[p+87|0]=aa}if(G[k+8|0]==(h|0)){_=q+(_^-1|-256)|0;D[p+88|0]=_}if(G[k+9|0]==(h|0)){ea=q+(ea^-1|-256)|0;D[p+89|0]=ea}if(G[k+10|0]==(h|0)){X=q+(X^-1|-256)|0;D[p+90|0]=X}if(G[k+11|0]==(h|0)){x=q+(x^-1|-256)|0;D[p+91|0]=x}if(G[k+12|0]==(h|0)){y=q+(y^-1|-256)|0;D[p+92|0]=y}if(G[k+13|0]==(h|0)){B=q+(B^-1|-256)|0;D[p+93|0]=B}if(G[k+14|0]==(h|0)){O=q+(O^-1|-256)|0;D[p+94|0]=O}if(G[k+15|0]==(h|0)){V=q+(V^-1|-256)|0;D[p+95|0]=V}q=o+(p- -64|0)|0;u=G[q+3|0];s=q;q=o+(p+48|0)|0;D[s+3|0]=G[q+3|0];D[q+3|0]=u}h=h+1|0;if((Ha|0)!=(h|0)){continue}break};D[e|0]=0;D[e+1|0]=0;D[e+2|0]=0;D[e+3|0]=0;D[e+4|0]=0;D[e+5|0]=0;D[e+6|0]=0;D[e+7|0]=0;D[e+8|0]=0;D[e+9|0]=0;D[e+10|0]=0;D[e+11|0]=0;D[e+12|0]=0;D[e+13|0]=0;D[e+14|0]=0;D[e+15|0]=0;h=0;v=0;n=r+1|0;P:{if(n){k=1<>>3|0)+e|0;o=q;u=G[q|0];q=h&7;D[o|0]=u|k<>>0>q>>>0?q:n;h=h+q|0;k=k>>>q|0;n=n-q|0;if(n){continue}break}v=(r&-2)==4;if(v){k=F[w+92>>2];n=2;while(1){q=(h>>>3|0)+e|0;o=q;u=G[q|0];q=h&7;D[o|0]=u|k<>>0>q>>>0?q:n;h=h+q|0;k=k>>>q|0;n=n-q|0;if(n){continue}break}}if((r|0)==4){k=(h>>>3|0)+e|0;D[k|0]=G[k|0]|F[w+88>>2]<<(h&7);h=h+1|0;break P}if(za>>>0<3){break P}}n=142>>>r&1?6:4;k=F[w+4>>2];while(1){q=(h>>>3|0)+e|0;o=q;u=G[q|0];q=h&7;D[o|0]=u|k<>>0>q>>>0?q:n;h=h+q|0;k=k>>>q|0;n=n-q|0;if(n){continue}break}}O=t>>>0<=1?1:t;B=r>>>0>3?4:3;o=0;u=r+10152|0;C=r+10144|0;while(1){y=(p+48|0)+o|0;S=(p- -64|0)+o|0;q=0;while(1){s=q<<2;Q=(o|0)==3;n=Q?D[u|0]:G[C|0];if(n){k=G[s+S|0];while(1){x=(h>>>3|0)+e|0;K=x;V=G[x|0];x=h&7;D[K|0]=V|k<>>0>x>>>0?x:n;h=h+x|0;k=k>>>x|0;n=n-x|0;if(n){continue}break}}n=Q?D[u|0]:G[C|0];if(n){k=G[s+y|0];while(1){s=(h>>>3|0)+e|0;x=s;K=G[s|0];s=h&7;D[x|0]=K|k<>>0>s>>>0?s:n;h=h+s|0;k=k>>>s|0;n=n-s|0;if(n){continue}break}}q=q+1|0;if((O|0)!=(q|0)){continue}break}o=o+1|0;if((B|0)!=(o|0)){continue}break};if(!(52>>>r&1)){q=t>>>0<=1?1:t;n=0;while(1){k=(h>>>3|0)+e|0;u=(p+16|0)+(n<<3)|0;D[k|0]=G[k|0]|F[u>>2]<<(h&7);k=h+1|0;if((r|0)==1){h=k}else{o=(k>>>3|0)+e|0;D[o|0]=G[o|0]|F[u+4>>2]<<(k&7);h=h+2|0}n=n+1|0;if((q|0)!=(n|0)){continue}break}}C=0;q=F[p+8>>2];u=F[p+4>>2];t=F[p>>2];x=r+10136|0;O=r+10160|0;while(1){k=F[w+88>>2];Q:{if(k){o=p+80|0;n=G[O|0]-k|0;break Q}o=p+96|0;n=G[x|0]}s=C<<2;n=n-((s|0)==(t|0)|(s|0)==(u|0)|(q|0)==(s|0))|0;if(n){k=G[o+s|0];while(1){o=(h>>>3|0)+e|0;y=o;B=G[o|0];o=h&7;D[y|0]=B|k<>>0>o>>>0?o:n;h=h+o|0;k=k>>>o|0;n=n-o|0;if(n){continue}break}k=F[w+88>>2]}B=s|1;R:{if(k){o=p+80|0;n=G[O|0]-k|0;break R}o=p+96|0;n=G[x|0]}n=n-((t|0)==(B|0)|(u|0)==(B|0)|(q|0)==(B|0))|0;if(n){k=G[o+B|0];while(1){o=(h>>>3|0)+e|0;y=o;B=G[o|0];o=h&7;D[y|0]=B|k<>>0>o>>>0?o:n;h=h+o|0;k=k>>>o|0;n=n-o|0;if(n){continue}break}k=F[w+88>>2]}B=s|2;S:{if(k){o=p+80|0;n=G[O|0]-k|0;break S}o=p+96|0;n=G[x|0]}n=n-((t|0)==(B|0)|(u|0)==(B|0)|(q|0)==(B|0))|0;if(n){k=G[o+B|0];while(1){o=(h>>>3|0)+e|0;y=o;B=G[o|0];o=h&7;D[y|0]=B|k<>>0>o>>>0?o:n;h=h+o|0;k=k>>>o|0;n=n-o|0;if(n){continue}break}k=F[w+88>>2]}o=s|3;T:{if(k){n=G[O|0]-k|0;k=p+80|0;break T}n=G[x|0];k=p+96|0}n=n-((o|0)==(t|0)|(o|0)==(u|0)|(o|0)==(q|0))|0;if(n){k=G[k+o|0];while(1){o=(h>>>3|0)+e|0;y=o;s=G[o|0];o=h&7;D[y|0]=s|k<>>0>o>>>0?o:n;h=h+o|0;k=k>>>o|0;n=n-o|0;if(n){continue}break}}C=C+1|0;if((C|0)!=4){continue}break};if(v){C=0;s=r+10160|0;v=r+10136|0;while(1){k=F[w+88>>2];U:{if(k){o=p+96|0;n=G[v|0]+k|0;break U}o=p+80|0;n=G[s|0]}r=C<<2;n=n-((r|0)==(t|0)|(r|0)==(u|0)|(q|0)==(r|0))|0;if(n){k=G[o+r|0];while(1){o=(h>>>3|0)+e|0;x=o;y=G[o|0];o=h&7;D[x|0]=y|k<>>0>o>>>0?o:n;h=h+o|0;k=k>>>o|0;n=n-o|0;if(n){continue}break}k=F[w+88>>2]}x=r|1;V:{if(k){o=p+96|0;n=G[v|0]+k|0;break V}o=p+80|0;n=G[s|0]}n=n-((t|0)==(x|0)|(u|0)==(x|0)|(q|0)==(x|0))|0;if(n){k=G[o+x|0];while(1){o=(h>>>3|0)+e|0;x=o;y=G[o|0];o=h&7;D[x|0]=y|k<>>0>o>>>0?o:n;h=h+o|0;k=k>>>o|0;n=n-o|0;if(n){continue}break}k=F[w+88>>2]}x=r|2;r=r|3;W:{if(k){o=p+96|0;n=G[v|0]+k|0;break W}o=p+80|0;n=G[s|0]}n=n-((t|0)==(x|0)|(u|0)==(x|0)|(q|0)==(x|0))|0;if(n){k=G[o+x|0];while(1){o=(h>>>3|0)+e|0;x=o;y=G[o|0];o=h&7;D[x|0]=y|k<>>0>o>>>0?o:n;h=h+o|0;k=k>>>o|0;n=n-o|0;if(n){continue}break}k=F[w+88>>2]}X:{if(k){n=G[v|0]+k|0;k=p+96|0;break X}n=G[s|0];k=p+80|0}n=n-((r|0)==(t|0)|(r|0)==(u|0)|(q|0)==(r|0))|0;if(n){k=G[k+r|0];while(1){r=(h>>>3|0)+e|0;o=r;x=G[r|0];r=h&7;D[o|0]=x|k<>>0>r>>>0?r:n;h=h+r|0;k=k>>>r|0;n=n-r|0;if(n){continue}break}}C=C+1|0;if((C|0)!=4){continue}break}}break c;case 5:h=w+104|0;if(!Za(d,h,0,1)){break d}m=(m|0)<0?3:m;l=(l|0)>0?l:0;k=F[w+208>>2];if((k|0)!=8){$a(k,F[w+212>>2],ia,h,w);sb(e,l+w|0);sb(e+8|0,m+w|0);break c}h=G[l+ia|0];D[e+2|0]=0;D[e+3|0]=0;D[e+4|0]=0;D[e+5|0]=0;D[e+1|0]=h;D[e|0]=h;D[e+6|0]=0;D[e+7|0]=0;h=G[m+ia|0];D[e+10|0]=0;D[e+11|0]=0;D[e+12|0]=0;D[e+13|0]=0;D[e+9|0]=h;D[e+8|0]=h;D[e+14|0]=0;D[e+15|0]=0;break c;case 4:h=w+104|0;if(!Za(d,h,0,1)){break d}l=(l|0)>0?l:0;k=F[w+208>>2];if((k|0)!=8){$a(k,F[w+212>>2],ia,h,w);sb(e,l+w|0);break c}h=G[l+ia|0];D[e+2|0]=0;D[e+3|0]=0;D[e+4|0]=0;D[e+5|0]=0;D[e+1|0]=h;D[e|0]=h;D[e+6|0]=0;D[e+7|0]=0;break c;case 3:o=0;r=Ea-224|0;Ea=r;q=Za(d,r+72|0,0,1);Y:{if(!q){break Y}k=F[r+176>>2];if((k|0)==8){h=G[r+187|0];k=0;D[e+2|0]=0;D[e+3|0]=0;D[e+4|0]=0;D[e+5|0]=0;D[e+1|0]=h;D[e|0]=h;D[e+6|0]=0;D[e+7|0]=0;p=1;u=170;h=G[r+186|0]<<1;t=G[r+185|0]<<1;C=G[r+184|0]<<1;n=G[h+405857|0]|(G[t+406881|0]<<5|G[C+405857|0]<<11);h=G[h+405856|0]|(G[t+406880|0]<<5|G[C+405856|0]<<11);Z:{if((n|0)==(h|0)){if(!h){u=85;break Z}u=0;n=h-1|0}if(h>>>0>=n>>>0){p=h;k=n;break Z}u=u|85;p=n;k=h}D[e+8|0]=p;h=L(u,16843009);D[e+12|0]=h;D[e+13|0]=h>>>8;D[e+14|0]=h>>>16;D[e+15|0]=h>>>24;D[e+11|0]=k>>>8;D[e+10|0]=k;D[e+9|0]=p>>>8;break Y}h=e+8|0;p=k;k=r+72|0;$a(p,F[r+180>>2],r+184|0,k,r);sb(e,r|3);if(G[r+188|0]){qc(k,h);break Y}if(G[r+189|0]){mc(r+72|0,r,h);break Y}Gb(h,r,0)}Ea=r+224|0;if(q){break c}break a;case 2:o=0;n=Ea-224|0;Ea=n;q=Za(d,n+72|0,0,1);_:{if(!q){break _}h=F[n+176>>2];if((h|0)==8){k=1;r=170;h=G[n+186|0]<<1;u=G[n+185|0]<<1;t=G[n+184|0]<<1;p=G[h+405857|0]|(G[u+406881|0]<<5|G[t+405857|0]<<11);h=G[h+405856|0]|(G[u+406880|0]<<5|G[t+405856|0]<<11);$:{if((p|0)==(h|0)){if(!h){r=85;h=0;break $}r=0;p=h-1|0}if(h>>>0>=p>>>0){k=h;h=p;break $}r=r|85;k=p}D[e+2|0]=h;D[e|0]=k;p=L(r,16843009);D[e+4|0]=p;D[e+5|0]=p>>>8;D[e+6|0]=p>>>16;D[e+7|0]=p>>>24;D[e+3|0]=h>>>8;D[e+1|0]=k>>>8;break _}if(G[n+188|0]){qc(n+72|0,e);break _}k=h;h=n+72|0;$a(k,F[n+180>>2],n+184|0,h,n);if(G[n+189|0]){mc(h,n,e);break _}Gb(e,n,0)}Ea=n+224|0;if(q){break c}break a;case 1:h=w+104|0;if(!Za(d,h,0,1)){break d}k=F[w+208>>2];if((k|0)!=8){$a(k,F[w+212>>2],ia,h,w)}h=w+104|0;ub(h,w,e);tc(h,w,e+8|0);break c;case 0:h=w+104|0;if(!Za(d,h,0,1)){break d}k=F[w+208>>2];if((k|0)!=8){$a(k,F[w+212>>2],ia,h,w)}tc(w+104|0,w,e);break c;case 30:h=G[d+4|0]|G[d+5|0]<<8|(G[d+6|0]<<16|G[d+7|0]<<24);k=G[d|0]|G[d+1|0]<<8|(G[d+2|0]<<16|G[d+3|0]<<24);D[e|0]=k;D[e+1|0]=k>>>8;D[e+2|0]=k>>>16;D[e+3|0]=k>>>24;D[e+4|0]=h;D[e+5|0]=h>>>8;D[e+6|0]=h>>>16;D[e+7|0]=h>>>24;h=G[d+12|0]|G[d+13|0]<<8|(G[d+14|0]<<16|G[d+15|0]<<24);k=G[d+8|0]|G[d+9|0]<<8|(G[d+10|0]<<16|G[d+11|0]<<24);D[e+8|0]=k;D[e+9|0]=k>>>8;D[e+10|0]=k>>>16;D[e+11|0]=k>>>24;D[e+12|0]=h;D[e+13|0]=h>>>8;D[e+14|0]=h>>>16;D[e+15|0]=h>>>24;break c;default:if(!(o&1)){break d}break c;case 19:break k}}o=0;l=(l|0)>0?l:0;k=l;m=(m|0)<0?3:m;h=Ea-224|0;Ea=h;p=Za(d,h+72|0,0,1);aa:{if(!p){break aa}n=F[h+176>>2];if((n|0)==8){n=h+184|0;r=G[n+k|0];k=H[196104]|H[196105]<<16;E[e+2>>1]=k;q=k>>>16|0;E[e+4>>1]=q;u=H[196106];E[e+6>>1]=u;E[e>>1]=r|3328;n=G[m+n|0];E[e+10>>1]=k;E[e+12>>1]=q;E[e+14>>1]=u;E[e+8>>1]=n|3328;break aa}q=n;n=h+72|0;$a(q,F[h+180>>2],h+184|0,n,h);ba:{if((k|0)==3){ub(n,h,e);break ba}wb(e,h+k|0,4)}if((m|0)==3){ub(h+72|0,h,e+8|0);break aa}wb(e+8|0,h+m|0,4)}Ea=h+224|0;if(!p){break a}break c}h=i<<2;p=j-h|0;if(!((p|0)>=4?4:p)){break e}n=(h+Y<<1)+a|0;p=0;while(1){o=0;while(1){h=((p<<4)+w|0)+(o<<2)|0;q=G[h|0];u=G[h+1|0];t=(o<<1)+n|0;C=L(G[h+2|0],15)+128|0;C=(C>>>8|0)+C>>>4|0;h=L(G[h+3|0],15)+128|0;D[t|0]=C&240|(h>>>8|0)+h>>>8;h=L(q,15)+128|0;q=(h>>>8|0)+h<<4&61440;h=L(u,15)+128|0;D[t+1|0]=(C|(q|(h>>>8|0)+h&16128))>>>8;o=o+1|0;if((r|0)!=(o|0)){continue}break}n=n+ga|0;p=p+1|0;if((I|0)!=(p|0)){continue}break}break e}h=i<<2;k=j-h|0;if(!((k|0)>=4?4:k)){break f}p=(h+Y<<1)+a|0;k=0;if(!xa){while(1){o=0;while(1){q=(o<<1)+p|0;h=((k<<4)+w|0)+(o<<2)|0;u=L(G[h+1|0],63)+128|0;t=(u>>>8|0)+u>>>3&8160;u=L(G[h+2|0],31)+128|0;h=L(G[h|0],31)+128|0;h=t|(u>>>8|0)+u<<3&260096|(h>>>8|0)+h>>>8;D[q|0]=h;D[q+1|0]=h>>>8;o=o+1|0;if((r|0)!=(o|0)){continue}break}p=p+ga|0;k=k+1|0;if((I|0)!=(k|0)){continue}break f}}while(1){o=0;while(1){q=(o<<1)+p|0;h=((k<<4)+w|0)+(o<<2)|0;u=L(G[h+1|0],63)+128|0;t=(u>>>8|0)+u>>>3&8160;u=L(G[h|0],31)+128|0;h=L(G[h+2|0],31)+128|0;h=t|(u>>>8|0)+u<<3&260096|(h>>>8|0)+h>>>8;D[q|0]=h;D[q+1|0]=h>>>8;o=o+1|0;if((r|0)!=(o|0)){continue}break}p=p+ga|0;k=k+1|0;if((I|0)!=(k|0)){continue}break}break f}h=i<<2;k=j-h|0;if(!((k|0)>=4?4:k)){break g}k=(h+Y<<2)+a|0;h=0;while(1){p=0;while(1){q=p<<2;n=q+k|0;q=q+((h<<4)+w|0)|0;D[n|0]=G[q|0];D[n+1|0]=G[q+1|0];D[n+2|0]=G[q+2|0];D[n+3|0]=G[q+3|0];p=p+1|0;if((r|0)!=(p|0)){continue}break}k=k+Na|0;h=h+1|0;if((I|0)!=(h|0)){continue}break}}if(!u){break d}break c}if(!n){break d}break c}if(k){break c}}o=0;break a}z=z-4|0;e=e+g|0;d=d+16|0;o=1;i=i+1|0;if((i|0)!=(b|0)){continue}break}P=P-4|0;ha=ha+1|0;if((ha|0)!=(c|0)){continue}break}break a}ca:{if((f|0)==7){C=d;s=a;v=Ea-384|0;Ea=v;n=b;o=c;da:{if(!n|!o){break da}if((Xe(n<<2)|0)!=1){break da}if((Xe(o<<2)|0)!=1){break da}F[v+12>>2]=0;F[v+4>>2]=0;F[v+8>>2]=0;a=L(n,o);if(a){Wa(v+4|0,a,(a|0)==1,4);B=F[v+4>>2];b=F[v+8>>2];Ta(B+(b<<2)|0,0,a-b<<2);F[v+8>>2]=a}h=v+344|0;ea:{while(1){i=L(n,p);e=0;while(1){q=e+i|0;a=v+232|0;if(!Za(C+(q<<4)|0,a,0,0)){break ea}b=0;$a(F[v+336>>2],F[v+340>>2],h,a,v+160|0);P=255;j=255;l=255;r=255;k=0;m=0;z=0;d=0;while(1){f=k&255;a=(v+160|0)+(b<<2)|0;c=G[a+3|0];k=c>>>0>>0?f:c;g=m&255;f=G[a+2|0];m=f>>>0>>0?g:f;z=z&255;g=G[a+1|0];z=g>>>0>>0?z:g;d=d&255;a=G[a|0];d=a>>>0>>0?d:a;u=P&255;P=c>>>0>u>>>0?u:c;c=j&255;j=c>>>0>>0?c:f;c=l&255;l=c>>>0>>0?c:g;c=r&255;r=a>>>0>c>>>0?c:a;b=b+1|0;if((b|0)!=16){continue}break}a=(P|0)==255?G[r+201680|0]<<10|G[l+201680|0]<<5|G[j+201936|0]<<1|32768:G[r+201936|0]<<8|G[P+202704|0]<<12|G[l+201936|0]<<4|G[j+202960|0]<<1;F[(q<<2)+B>>2]=k-239>>>0>16?a&65535|(G[m+202448|0]|(G[d+202448|0]<<8|G[k+203216|0]<<12|G[z+202448|0]<<4))<<16:a&65535|(G[m+202192|0]|(G[z+202192|0]<<5|G[d+202192|0]<<10))<<16|-2147483648;e=e+1|0;if((n|0)!=(e|0)){continue}break}p=p+1|0;if((o|0)!=(p|0)){continue}break}d=0;c=0;t=n-1|0;if(t){a=t;while(1){c=c+1|0;b=a>>>0>1;a=a>>>1|0;if(b){continue}break}}ia=o-1|0;fa:{if(ia){a=ia;while(1){d=d+1|0;b=a>>>0>1;a=a>>>1|0;if(b){continue}break}if((o|0)<=0){break ea}S=c>>>0>>0?c:d;Q=S<<1;ua=-1<>2]=b;a=F[b+(t<<2)>>2];ga:{if(a&32768){P=(a>>>1&15)+398144|0;k=(a>>>5&31)+398112|0;j=(a>>>10&31)+398112|0;f=255;break ga}P=(a>>>1&7)+398160|0;k=(a>>>4&15)+398144|0;j=(a>>>8&15)+398144|0;f=G[(a>>>12&7)+398168|0]}e=d+(v+160|0)|0;F[e>>2]=G[P|0]+(G[j|0]+(f+G[k|0]|0)|0);f=a>>>16|0;ha:{if((a|0)<0){P=(f&31)+398112|0;k=(a>>>21&31)+398112|0;j=(a>>>26&31)+398112|0;a=255;break ha}P=(f&15)+398144|0;k=(a>>>20&15)+398144|0;j=(a>>>24&15)+398144|0;a=G[(a>>>28|0)+398168|0]}f=d+(v+96|0)|0;F[f>>2]=G[P|0]+(G[j|0]+(a+G[k|0]|0)|0);a=F[b>>2];ia:{if(a&32768){P=(a>>>1&15)+398144|0;k=(a>>>5&31)+398112|0;j=(a>>>10&31)+398112|0;d=255;break ia}P=(a>>>1&7)+398160|0;k=(a>>>4&15)+398144|0;j=(a>>>8&15)+398144|0;d=G[(a>>>12&7)+398168|0]}F[e+16>>2]=G[P|0]+(G[j|0]+(d+G[k|0]|0)|0);d=a>>>16|0;ja:{if((a|0)<0){P=(d&31)+398112|0;k=(a>>>21&31)+398112|0;j=(a>>>26&31)+398112|0;a=255;break ja}P=(d&15)+398144|0;k=(a>>>20&15)+398144|0;j=(a>>>24&15)+398144|0;a=G[(a>>>28|0)+398168|0]}F[f+16>>2]=G[P|0]+(G[j|0]+(a+G[k|0]|0)|0);b=F[b+Ja>>2];ka:{if(b&32768){P=(b>>>5&31)+398112|0;k=(b>>>10&31)+398112|0;j=255;a=(b>>>1&15)+398144|0;break ka}P=(b>>>4&15)+398144|0;k=(b>>>8&15)+398144|0;j=G[(b>>>12&7)+398168|0];a=(b>>>1&7)+398160|0}F[e+32>>2]=G[a|0]+(G[k|0]+(G[P|0]+j|0)|0);a=b>>>16|0;la:{if((b|0)<0){d=(a&31)+398112|0;P=(b>>>26&31)+398112|0;a=255;b=(b>>>21&31)+398112|0;break la}d=(a&15)+398144|0;P=(b>>>24&15)+398144|0;a=G[(b>>>28|0)+398168|0];b=(b>>>20&15)+398144|0}F[f+32>>2]=G[d|0]+(G[P|0]+(G[b|0]+a|0)|0);c=c+1|0;if((c|0)!=3){continue}break}d=F[v+96>>2];e=F[v+160>>2];ma:{if((n|0)<=0){c=d;b=e;break ma}Ka=H[((y&255)<<1)+396320>>1]|H[(y>>>7&33554430)+396320>>1]<<16;La=y>>>S<>2];r=F[v+104>>2];a=F[v+184>>2];q=F[v+168>>2];k=F[v+116>>2];m=F[v+100>>2];u=F[v+112>>2];j=F[v+180>>2];z=F[v+164>>2];l=F[v+176>>2];Ba=F[v+92>>2];ta=F[v+88>>2];Na=F[v+84>>2];while(1){b=l;f=j;c=u;g=v+232|0;if(Za(C+(ha<<4)|0,g,0,0)){$a(F[v+336>>2],F[v+340>>2],va,g,v+16|0)}g=k;h=a;i=p;a=Ka|H[(P>>>7&33554430)+396320>>1]<<17|H[((P&255)<<1)+396320>>1]<<1;j=a;na:{if((n|0)==(o|0)){break na}a=a&ua;j=a|P>>>S<>>0>o>>>0){break na}j=a|La}Ga=(j<<3)+s|0;F[Ga+4>>2]=F[(ha<<2)+B>>2];P=P+1|0;j=(t&P)<<2;a=F[j+Na>>2];oa:{if(a&32768){u=(a>>>10&31)+398112|0;k=255;l=(a>>>1&15)+398144|0;x=(a>>>5&31)+398112|0;break oa}u=(a>>>8&15)+398144|0;k=G[(a>>>12&7)+398168|0];l=(a>>>1&7)+398160|0;x=(a>>>4&15)+398144|0}p=a>>>16|0;K=G[x|0];u=G[u|0];A=G[l|0];pa:{if((a|0)<0){l=(p&31)+398112|0;p=(a>>>21&31)+398112|0;I=255;a=(a>>>26&31)+398112|0;break pa}l=(p&15)+398144|0;p=(a>>>20&15)+398144|0;I=G[(a>>>28|0)+398168|0];a=(a>>>24&15)+398144|0}p=G[p|0];ga=G[a|0];W=G[l|0];a=F[j+ta>>2];qa:{if(a&32768){x=(a>>>5&31)+398112|0;O=(a>>>10&31)+398112|0;l=255;T=(a>>>1&15)+398144|0;break qa}x=(a>>>4&15)+398144|0;O=(a>>>8&15)+398144|0;l=G[(a>>>12&7)+398168|0];T=(a>>>1&7)+398160|0}K=k+K|0;p=p+I|0;k=a>>>16|0;l=G[x|0]+l|0;I=G[O|0];V=G[T|0];ra:{if((a|0)<0){k=(k&31)+398112|0;x=(a>>>21&31)+398112|0;O=(a>>>26&31)+398112|0;a=255;break ra}k=(k&15)+398144|0;x=(a>>>20&15)+398144|0;O=(a>>>24&15)+398144|0;a=G[(a>>>28|0)+398168|0]}u=u+K|0;X=p+ga|0;l=l+I|0;ea=G[O|0]+(a+G[x|0]|0)|0;k=G[k|0];p=F[j+Ba>>2];sa:{if(p&32768){I=(p>>>1&15)+398144|0;x=(p>>>10&31)+398112|0;O=255;xa=(p>>>5&31)+398112|0;break sa}I=(p>>>1&7)+398160|0;x=(p>>>8&15)+398144|0;O=G[(p>>>12&7)+398168|0];xa=(p>>>4&15)+398144|0}fa=p>>>16|0;j=b+f|0;aa=L(j,6);ka=aa+(e+z<<1)|0;a=(G[v+23|0]+(G[v+22|0]+(G[v+21|0]+G[v+20|0]|0)|0)<<8)-(ka<<4)|0;Z=c+g|0;ba=L(Z,6);qa=ba+(d+m<<1)|0;za=(qa|0)<(ka|0);ga=za?0-a|0:a;K=b+e|0;a=f+z|0;T=K+a|0;Y=(G[v+19|0]+(G[v+18|0]+(G[v+17|0]+G[v+16|0]|0)|0)<<8)-(T<<6)|0;pa=0-Y|0;ja=Y;Y=c+d|0;_=g+m|0;Ha=Y+_<<2;Aa=T<<2;Ia=(Ha|0)<(Aa|0);T=Ia?pa:ja;oa=L(a,6);la=oa+(K<<1)|0;K=(G[v+35|0]+(G[v+34|0]+(G[v+33|0]+G[v+32|0]|0)|0)<<8)-(la<<4)|0;ja=L(_,6);Ca=ja+(Y<<1)|0;Ma=(Ca|0)<(la|0);Y=Ma?0-K|0:K;ca=L(b,3);na=L(z,3);K=L(f,9);ma=e+(ca+(na+K|0)|0)|0;e=(G[v+39|0]+(G[v+38|0]+(G[v+37|0]+G[v+36|0]|0)|0)<<8)-(ma<<4)|0;da=L(g,9);ra=da+L(m,3)|0;wa=L(c,3);Pa=(ra+wa|0)+d|0;Qa=(Pa|0)<(ma|0);d=Qa?0-e|0:e;e=(G[v+27|0]+(G[v+26|0]+(G[v+25|0]+G[v+24|0]|0)|0)<<8)-(j<<7)|0;Sa=Z<<3;Ua=j<<3;Da=(Sa|0)<(Ua|0);e=Da?0-e|0:e;j=l+V|0;l=u+A|0;Z=aa+(j+l<<1)|0;u=(G[v+31|0]+(G[v+30|0]+(G[v+29|0]+G[v+28|0]|0)|0)<<8)-(Z<<4)|0;pa=0-u|0;V=u;k=k+ea|0;u=W+X|0;Xa=ba+(k+u<<1)|0;Ya=(Xa|0)<(Z|0);A=Ya?pa:V;W=L(f,12);ba=W+(b<<2)|0;V=(G[v+43|0]+(G[v+42|0]+(G[v+41|0]+G[v+40|0]|0)|0)<<8)-(ba<<4)|0;X=0-V|0;pa=V;V=L(g,12);_a=V+(c<<2)|0;ab=(_a|0)<(ba|0);X=ab?X:pa;pa=L(j,3);ca=pa+((K+ca|0)+l|0)|0;ea=(G[v+47|0]+(G[v+46|0]+(G[v+45|0]+G[v+44|0]|0)|0)<<8)-(ca<<4)|0;bb=da+L(k,3)|0;wa=bb+(u+wa|0)|0;cb=(wa|0)<(ca|0);ea=cb?0-ea|0:ea;aa=(G[v+51|0]+(G[v+50|0]+(G[v+49|0]+G[v+48|0]|0)|0)<<8)-(a<<7)|0;db=_<<3;eb=a<<3;fb=(db|0)<(eb|0);_=fb?0-aa|0:aa;da=W+(z<<2)|0;a=(G[v+55|0]+(G[v+54|0]+(G[v+53|0]+G[v+52|0]|0)|0)<<8)-(da<<4)|0;gb=V+(m<<2)|0;hb=(gb|0)<(da|0);m=hb?0-a|0:a;oa=oa+(h+q<<1)|0;a=(G[v+67|0]+(G[v+66|0]+(G[v+65|0]+G[v+64|0]|0)|0)<<8)-(oa<<4)|0;ib=ja+(i+r<<1)|0;jb=(ib|0)<(oa|0);z=jb?0-a|0:a;kb=L(h,3);ja=na+(K+(kb+q|0)|0)|0;a=(G[v+71|0]+(G[v+70|0]+(G[v+69|0]+G[v+68|0]|0)|0)<<8)-(ja<<4)|0;lb=L(i,3);nb=lb+(r+ra|0)|0;ob=(nb|0)<(ja|0);r=ob?0-a|0:a;a=G[v+59|0]+(G[v+58|0]+(G[v+57|0]+(G[v+56|0]-f|0)|0)|0)<<8;pb=g<<4;qb=f<<4;rb=(pb|0)<(qb|0);q=rb?0-a|0:a;na=W+(j<<2)|0;a=(G[v+63|0]+(G[v+62|0]+(G[v+61|0]+G[v+60|0]|0)|0)<<8)-(na<<4)|0;Eb=V+(k<<2)|0;Fb=(Eb|0)<(na|0);aa=Fb?0-a|0:a;ra=W+(h<<2)|0;a=(G[v+75|0]+(G[v+74|0]+(G[v+73|0]+G[v+72|0]|0)|0)<<8)-(ra<<4)|0;V=V+(i<<2)|0;Hb=(V|0)<(ra|0);W=Hb?0-a|0:a;a=G[I|0]+(G[x|0]+(G[xa|0]+O|0)|0)|0;O=a+(pa+(K+kb|0)|0)|0;x=(G[v+79|0]+(G[v+78|0]+(G[v+77|0]+G[v+76|0]|0)|0)<<8)-(O<<4)|0;pa=0-x|0;xa=x;ta:{if((p|0)<0){I=(p>>>21&31)+398112|0;x=(p>>>26&31)+398112|0;K=255;p=(fa&31)+398112|0;break ta}I=(p>>>20&15)+398144|0;x=(p>>>24&15)+398144|0;K=G[(p>>>28|0)+398168|0];p=(fa&15)+398144|0}p=G[p|0]+(G[x|0]+(K+G[I|0]|0)|0)|0;K=p+(bb+lb|0)|0;fa=(K|0)<(O|0);x=fa?pa:xa;I=qa-ka|0;I=za?0-I|0:I;qa=(ga|0)>(L(I,13)|0)?12:(ga|0)>I<<3?8:((ga|0)>(L(I,3)|0))<<2;I=Ha-Aa|0;I=Ia?0-I|0:I;T=qa|((T|0)>(L(I,13)|0)?3:(T|0)>I<<3?2:(T|0)>(L(I,3)|0));I=Ca-la|0;I=Ma?0-I|0:I;T=T|((Y|0)>(L(I,13)|0)?768:(Y|0)>I<<3?512:((Y|0)>(L(I,3)|0))<<8);I=Pa-ma|0;I=Qa?0-I|0:I;T=T|((d|0)>(L(I,13)|0)?3072:(d|0)>I<<3?2048:((d|0)>(L(I,3)|0))<<10);d=Sa-Ua|0;d=Da?0-d|0:d;e=T|((e|0)>(L(d,13)|0)?48:(e|0)>d<<3?32:((e|0)>(L(d,3)|0))<<4);d=Xa-Z|0;d=Ya?0-d|0:d;e=e|((A|0)>(L(d,13)|0)?192:(A|0)>d<<3?128:((A|0)>(L(d,3)|0))<<6);d=_a-ba|0;d=ab?0-d|0:d;e=e|((X|0)>(L(d,13)|0)?12288:(X|0)>d<<3?8192:((X|0)>(L(d,3)|0))<<12);d=wa-ca|0;d=cb?0-d|0:d;e=e|((ea|0)>(L(d,13)|0)?49152:(ea|0)>d<<3?32768:((ea|0)>(L(d,3)|0))<<14);d=db-eb|0;d=fb?0-d|0:d;e=e|((_|0)>(L(d,13)|0)?196608:(_|0)>d<<3?131072:((_|0)>(L(d,3)|0))<<16);d=gb-da|0;d=hb?0-d|0:d;e=e|((m|0)>(L(d,13)|0)?786432:(m|0)>d<<3?524288:((m|0)>(L(d,3)|0))<<18);d=ib-oa|0;d=jb?0-d|0:d;e=e|((z|0)>(L(d,13)|0)?50331648:(z|0)>d<<3?33554432:((z|0)>(L(d,3)|0))<<24);d=nb-ja|0;d=ob?0-d|0:d;e=e|((r|0)>(L(d,13)|0)?201326592:(r|0)>d<<3?134217728:((r|0)>(L(d,3)|0))<<26);d=pb-qb|0;d=rb?0-d|0:d;e=e|((q|0)>(L(d,13)|0)?3145728:(q|0)>d<<3?2097152:((q|0)>(L(d,3)|0))<<20);d=Eb-na|0;d=Fb?0-d|0:d;e=e|((aa|0)>(L(d,13)|0)?12582912:(aa|0)>d<<3?8388608:((aa|0)>(L(d,3)|0))<<22);d=V-ra|0;d=Hb?0-d|0:d;e=e|((W|0)>(L(d,13)|0)?805306368:(W|0)>d<<3?536870912:((W|0)>(L(d,3)|0))<<28);d=K-O|0;d=fa?0-d|0:d;F[Ga>>2]=e|((x|0)>(L(d,13)|0)?-1073741824:(x|0)>d<<3?-2147483648:((x|0)>(L(d,3)|0))<<30);ha=ha+1|0;r=i;q=h;m=g;z=f;e=b;d=c;if((n|0)!=(P|0)){continue}break}F[v+180>>2]=j;F[v+164>>2]=z;F[v+176>>2]=l;F[v+112>>2]=u;F[v+116>>2]=k;F[v+100>>2]=m;F[v+184>>2]=a;F[v+168>>2]=h;F[v+120>>2]=p;F[v+104>>2]=r}F[v+96>>2]=c;F[v+160>>2]=b;y=y+1|0;if((o|0)!=(y|0)){continue}break}B=F[v+4>>2]}if(!B){break da}Ra(B)}Ea=v+384|0;break ca}o=d;ia=a;d=0;s=Ea-384|0;Ea=s;h=c;ua:{if(!b|!h){break ua}if((Xe(b<<2)|0)!=1){break ua}if((Xe(h<<2)|0)!=1){break ua}F[s+12>>2]=0;F[s+4>>2]=0;F[s+8>>2]=0;g=b;a=L(h,b);if(a){Wa(s+4|0,a,(a|0)==1,4);C=F[s+4>>2];b=F[s+8>>2];Ta(C+(b<<2)|0,0,a-b<<2);F[s+8>>2]=a}ra=s+344|0;va:{while(1){ua=L(d,g);a=0;while(1){va=a+ua|0;b=s+232|0;if(!Za(o+(va<<4)|0,b,0,0)){break va}$a(F[s+336>>2],F[s+340>>2],ra,b,s+160|0);b=G[s+162|0];c=G[s+166|0];f=b>>>0>c>>>0?b:c;e=G[s+170|0];i=e>>>0>>0?f:e;f=G[s+174|0];j=f>>>0>>0?i:f;i=G[s+178|0];k=i>>>0>>0?j:i;j=G[s+182|0];l=j>>>0>>0?k:j;k=G[s+186|0];m=k>>>0>>0?l:k;l=G[s+190|0];p=l>>>0>>0?m:l;m=G[s+194|0];n=m>>>0

>>0?p:m;p=G[s+198|0];z=n>>>0>p>>>0?n:p;n=G[s+202|0];r=n>>>0>>0?z:n;z=G[s+206|0];q=r>>>0>z>>>0?r:z;r=G[s+210|0];u=q>>>0>r>>>0?q:r;q=G[s+214|0];t=q>>>0>>0?u:q;u=G[s+218|0];oa=t>>>0>u>>>0?t:u;t=G[s+161|0];v=G[s+165|0];x=t>>>0>v>>>0?t:v;P=G[s+169|0];O=x>>>0>P>>>0?x:P;x=G[s+173|0];B=x>>>0>>0?O:x;O=G[s+177|0];y=B>>>0>O>>>0?B:O;B=G[s+181|0];I=y>>>0>B>>>0?y:B;y=G[s+185|0];ha=y>>>0>>0?I:y;I=G[s+189|0];S=I>>>0>>0?ha:I;ha=G[s+193|0];Q=S>>>0>ha>>>0?S:ha;S=G[s+197|0];K=Q>>>0>S>>>0?Q:S;Q=G[s+201|0];ga=K>>>0>Q>>>0?K:Q;K=G[s+205|0];T=K>>>0>>0?ga:K;ga=G[s+209|0];Y=T>>>0>ga>>>0?T:ga;T=G[s+213|0];A=T>>>0>>0?Y:T;Y=G[s+217|0];ja=A>>>0>Y>>>0?A:Y;A=G[s+160|0];W=G[s+164|0];X=A>>>0>W>>>0?A:W;V=G[s+168|0];ea=X>>>0>V>>>0?X:V;X=G[s+172|0];_=X>>>0>>0?ea:X;ea=G[s+176|0];aa=_>>>0>ea>>>0?_:ea;_=G[s+180|0];fa=_>>>0>>0?aa:_;aa=G[s+184|0];ka=aa>>>0>>0?fa:aa;fa=G[s+188|0];la=fa>>>0>>0?ka:fa;ka=G[s+192|0];ma=ka>>>0>>0?la:ka;la=G[s+196|0];Z=la>>>0>>0?ma:la;ma=G[s+200|0];ba=Z>>>0>ma>>>0?Z:ma;Z=G[s+204|0];ca=Z>>>0>>0?ba:Z;ba=G[s+208|0];da=ba>>>0>>0?ca:ba;ca=G[s+212|0];na=ca>>>0>>0?da:ca;da=G[s+216|0];na=da>>>0>>0?na:da;A=A>>>0>>0?A:W;A=A>>>0>>0?A:V;A=A>>>0>>0?A:X;A=A>>>0>>0?A:ea;A=A>>>0<_>>>0?A:_;A=A>>>0>>0?A:aa;A=A>>>0>>0?A:fa;A=A>>>0>>0?A:ka;A=A>>>0>>0?A:la;A=A>>>0>>0?A:ma;A=A>>>0>>0?A:Z;A=A>>>0>>0?A:ba;A=A>>>0>>0?A:ca;W=A>>>0>>0?A:da;A=G[s+220|0];t=t>>>0>>0?t:v;t=t>>>0

>>0?t:P;t=t>>>0>>0?t:x;t=t>>>0>>0?t:O;t=t>>>0>>0?t:B;t=t>>>0>>0?t:y;t=t>>>0>>0?t:I;t=t>>>0>>0?t:ha;t=t>>>0>>0?t:S;t=t>>>0>>0?t:Q;t=t>>>0>>0?t:K;t=t>>>0>>0?t:ga;t=t>>>0>>0?t:T;v=t>>>0>>0?t:Y;t=G[s+221|0];b=b>>>0>>0?b:c;b=b>>>0>>0?b:e;b=b>>>0>>0?b:f;b=b>>>0>>0?b:i;b=b>>>0>>0?b:j;b=b>>>0>>0?b:k;b=b>>>0>>0?b:l;b=b>>>0>>0?b:m;b=b>>>0

>>0?b:p;b=b>>>0>>0?b:n;b=b>>>0>>0?b:z;b=b>>>0>>0?b:r;b=b>>>0>>0?b:q;c=b>>>0>>0?b:u;b=G[s+222|0];F[(va<<2)+C>>2]=G[((A>>>0>W>>>0?W:A)&255)+201680|0]<<10&31744|G[((t>>>0>v>>>0?v:t)&255)+201680|0]<<5|G[((b>>>0>c>>>0?c:b)&255)+201936|0]<<1|(G[((b>>>0>>0?oa:b)&255)+202192|0]|(G[((t>>>0>>0?ja:t)&255)+202192|0]<<5|G[((A>>>0>>0?na:A)&255)+202192|0]<<10))<<16|-2147450880;a=a+1|0;if((g|0)!=(a|0)){continue}break}d=d+1|0;if((h|0)!=(d|0)){continue}break}c=0;b=0;m=g-1|0;if(m){a=m;while(1){b=b+1|0;d=a>>>0>1;a=a>>>1|0;if(d){continue}break}}V=F[s+4>>2];t=h-1|0;wa:{if(t){a=t;while(1){c=c+1|0;d=a>>>0>1;a=a>>>1|0;if(d){continue}break}if((h|0)<=0){break va}O=b>>>0>>0?b:c;B=O<<1;ja=-1<>2]=c;e=d+(s+96|0)|0;a=F[c+(m<<2)>>2];F[e>>2]=(L(((a>>>26&31)+(a>>>21&31)|0)+(a>>>16&31)|0,255)>>>0)/31;d=d+(s+160|0)|0;i=a&30;F[d>>2]=(L((i+(a>>>5&31)|0)+(a>>>10&31)+(i>>>4)|0,255)>>>0)/31;a=F[c>>2];F[e+16>>2]=(L(((a>>>26&31)+(a>>>21&31)|0)+(a>>>16&31)|0,255)>>>0)/31;i=a&30;F[d+16>>2]=(L((i+(a>>>5&31)|0)+(a>>>10&31)+(i>>>4)|0,255)>>>0)/31;a=F[c+ra>>2];F[e+32>>2]=(L(((a>>>26&31)+(a>>>21&31)|0)+(a>>>16&31)|0,255)>>>0)/31;c=a&30;F[d+32>>2]=(L((c+(a>>>5&31)|0)+(a>>>10&31)+(c>>>4)|0,255)>>>0)/31;b=b+1|0;if((b|0)!=3){continue}break}c=F[s+96>>2];d=F[s+160>>2];if((g|0)>0){ua=H[((v&255)<<1)+396320>>1]|H[(v>>>7&33554430)+396320>>1]<<16;va=v>>>O<>2];e=F[s+104>>2];n=F[s+184>>2];f=F[s+168>>2];i=F[s+116>>2];b=F[s+100>>2];k=F[s+112>>2];j=F[s+180>>2];a=F[s+164>>2];l=F[s+176>>2];Ja=F[s+92>>2];Ka=F[s+88>>2];La=F[s+84>>2];while(1){q=c;u=d;d=l;z=a;a=j;c=k;r=b;b=i;C=f;f=n;n=e;e=p;i=s+232|0;if(Za(o+(x<<4)|0,i,0,0)){$a(F[s+336>>2],F[s+340>>2],na,i,s+16|0)}i=ua|H[(P>>>7&33554430)+396320>>1]<<17|H[((P&255)<<1)+396320>>1]<<1;j=i;xa:{if((g|0)==(h|0)){break xa}i=i&ja;j=i|P>>>O<>>0>h>>>0){break xa}j=i|va}Ba=(j<<3)+ia|0;F[Ba+4>>2]=F[V+(x<<2)>>2];i=a+d|0;S=L(i,6);X=S+(u+z<<1)|0;j=(G[s+22|0]+(G[s+21|0]+G[s+20|0]|0)<<8)-(X<<4)|0;l=0-j|0;k=j;j=b+c|0;Q=L(j,6);ta=Q+(q+r<<1)|0;Na=(ta|0)<(X|0);y=Na?l:k;k=d+u|0;p=a+z|0;l=k+p|0;I=(G[s+18|0]+(G[s+17|0]+G[s+16|0]|0)<<8)-(l<<6)|0;ha=c+q|0;Y=b+r|0;Ga=ha+Y<<2;xa=l<<2;qa=(Ga|0)<(xa|0);I=qa?0-I|0:I;A=L(p,6);ea=A+(k<<1)|0;k=(G[s+34|0]+(G[s+33|0]+G[s+32|0]|0)<<8)-(ea<<4)|0;W=L(Y,6);za=W+(ha<<1)|0;Ha=(za|0)<(ea|0);ha=Ha?0-k|0:k;_=L(a,9);T=_+L(d,3)|0;ca=L(z,3);aa=u+(T+ca|0)|0;k=(G[s+38|0]+(G[s+37|0]+G[s+36|0]|0)<<8)-(aa<<4)|0;Z=L(b,9);da=Z+L(r,3)|0;ba=L(c,3);Aa=q+(da+ba|0)|0;Ia=(Aa|0)<(aa|0);q=Ia?0-k|0:k;k=(G[s+26|0]+(G[s+25|0]+G[s+24|0]|0)<<8)-(i<<7)|0;Ca=j<<3;Ma=i<<3;wa=(Ca|0)<(Ma|0);u=wa?0-k|0:k;P=P+1|0;fa=(m&P)<<2;k=F[fa+La>>2];l=k&30;i=F[fa+Ka>>2];j=i&30;j=(L((j+(i>>>5&31)|0)+(i>>>10&31)+(j>>>4)|0,255)>>>0)/31|0;l=(L((l+(k>>>5&31)|0)+(k>>>10&31)+(l>>>4)|0,255)>>>0)/31|0;ka=S+(j+l<<1)|0;S=(G[s+30|0]+(G[s+29|0]+G[s+28|0]|0)<<8)-(ka<<4)|0;i=(L(((i>>>26&31)+(i>>>21&31)|0)+(i>>>16&31)|0,255)>>>0)/31|0;k=(L(((k>>>26&31)+(k>>>21&31)|0)+(k>>>16&31)|0,255)>>>0)/31|0;Pa=Q+(i+k<<1)|0;Qa=(Pa|0)<(ka|0);S=Qa?0-S|0:S;Q=L(a,12);la=Q+(d<<2)|0;K=(G[s+42|0]+(G[s+41|0]+G[s+40|0]|0)<<8)-(la<<4)|0;ga=0-K|0;pa=K;K=L(b,12);Sa=K+(c<<2)|0;Ua=(Sa|0)<(la|0);ga=Ua?ga:pa;Da=L(j,3);ma=Da+(l+T|0)|0;T=(G[s+46|0]+(G[s+45|0]+G[s+44|0]|0)<<8)-(ma<<4)|0;Xa=Z+L(i,3)|0;Ya=Xa+(k+ba|0)|0;_a=(Ya|0)<(ma|0);T=_a?0-T|0:T;Z=(G[s+50|0]+(G[s+49|0]+G[s+48|0]|0)<<8)-(p<<7)|0;ab=Y<<3;pa=p<<3;bb=(ab|0)<(pa|0);Y=bb?0-Z|0:Z;Z=Q+(z<<2)|0;p=(G[s+54|0]+(G[s+53|0]+G[s+52|0]|0)<<8)-(Z<<4)|0;cb=K+(r<<2)|0;db=(cb|0)<(Z|0);z=db?0-p|0:p;ba=A+(f+C<<1)|0;p=(G[s+66|0]+(G[s+65|0]+G[s+64|0]|0)<<8)-(ba<<4)|0;eb=W+(e+n<<1)|0;fb=(eb|0)<(ba|0);r=fb?0-p|0:p;gb=L(f,3);ca=ca+(_+(gb+C|0)|0)|0;p=(G[s+70|0]+(G[s+69|0]+G[s+68|0]|0)<<8)-(ca<<4)|0;hb=L(e,3);ib=hb+(n+da|0)|0;jb=(ib|0)<(ca|0);C=jb?0-p|0:p;p=G[s+58|0]+(G[s+57|0]+(G[s+56|0]-a|0)|0)<<8;kb=b<<4;lb=a<<4;nb=(kb|0)<(lb|0);A=nb?0-p|0:p;da=Q+(j<<2)|0;p=(G[s+62|0]+(G[s+61|0]+G[s+60|0]|0)<<8)-(da<<4)|0;ob=K+(i<<2)|0;pb=(ob|0)<(da|0);W=pb?0-p|0:p;oa=Q+(f<<2)|0;p=(G[s+74|0]+(G[s+73|0]+G[s+72|0]|0)<<8)-(oa<<4)|0;qb=K+(e<<2)|0;rb=(qb|0)<(oa|0);Q=rb?0-p|0:p;p=F[fa+Ja>>2];n=p&30;n=(L((n+(p>>>5&31)|0)+(p>>>10&31)+(n>>>4)|0,255)>>>0)/31|0;_=n+(Da+(_+gb|0)|0)|0;K=(G[s+78|0]+(G[s+77|0]+G[s+76|0]|0)<<8)-(_<<4)|0;p=(L(((p>>>26&31)+(p>>>21&31)|0)+(p>>>16&31)|0,255)>>>0)/31|0;fa=Xa+(hb+p|0)|0;Da=(fa|0)<(_|0);K=Da?0-K|0:K;X=ta-X|0;X=Na?0-X|0:X;ta=(y|0)>(L(X,13)|0)?12:(y|0)>X<<3?8:((y|0)>(L(X,3)|0))<<2;y=Ga-xa|0;y=qa?0-y|0:y;qa=ta|((I|0)>(L(y,13)|0)?3:(I|0)>y<<3?2:(I|0)>(L(y,3)|0));y=za-ea|0;y=Ha?0-y|0:y;qa=qa|((ha|0)>(L(y,13)|0)?768:(ha|0)>y<<3?512:((ha|0)>(L(y,3)|0))<<8);y=Aa-aa|0;y=Ia?0-y|0:y;y=qa|((q|0)>(L(y,13)|0)?3072:(q|0)>y<<3?2048:((q|0)>(L(y,3)|0))<<10);q=Ca-Ma|0;q=wa?0-q|0:q;u=y|((u|0)>(L(q,13)|0)?48:(u|0)>q<<3?32:((u|0)>(L(q,3)|0))<<4);q=Pa-ka|0;q=Qa?0-q|0:q;u=u|((S|0)>(L(q,13)|0)?192:(S|0)>q<<3?128:((S|0)>(L(q,3)|0))<<6);q=Sa-la|0;q=Ua?0-q|0:q;u=u|((ga|0)>(L(q,13)|0)?12288:(ga|0)>q<<3?8192:((ga|0)>(L(q,3)|0))<<12);q=Ya-ma|0;q=_a?0-q|0:q;u=u|((T|0)>(L(q,13)|0)?49152:(T|0)>q<<3?32768:((T|0)>(L(q,3)|0))<<14);q=ab-pa|0;q=bb?0-q|0:q;u=u|((Y|0)>(L(q,13)|0)?196608:(Y|0)>q<<3?131072:((Y|0)>(L(q,3)|0))<<16);q=cb-Z|0;q=db?0-q|0:q;q=u|((z|0)>(L(q,13)|0)?786432:(z|0)>q<<3?524288:((z|0)>(L(q,3)|0))<<18);z=eb-ba|0;z=fb?0-z|0:z;q=q|((r|0)>(L(z,13)|0)?50331648:(r|0)>z<<3?33554432:((r|0)>(L(z,3)|0))<<24);z=ib-ca|0;z=jb?0-z|0:z;q=q|((C|0)>(L(z,13)|0)?201326592:(C|0)>z<<3?134217728:((C|0)>(L(z,3)|0))<<26);z=kb-lb|0;z=nb?0-z|0:z;q=q|((A|0)>(L(z,13)|0)?3145728:(A|0)>z<<3?2097152:((A|0)>(L(z,3)|0))<<20);z=ob-da|0;z=pb?0-z|0:z;q=q|((W|0)>(L(z,13)|0)?12582912:(W|0)>z<<3?8388608:((W|0)>(L(z,3)|0))<<22);z=qb-oa|0;z=rb?0-z|0:z;q=q|((Q|0)>(L(z,13)|0)?805306368:(Q|0)>z<<3?536870912:((Q|0)>(L(z,3)|0))<<28);z=fa-_|0;z=Da?0-z|0:z;F[Ba>>2]=q|((K|0)>(L(z,13)|0)?-1073741824:(K|0)>z<<3?-2147483648:((K|0)>(L(z,3)|0))<<30);x=x+1|0;if((g|0)!=(P|0)){continue}break}F[s+128>>2]=k;F[s+192>>2]=l;F[s+196>>2]=j;F[s+132>>2]=i;F[s+200>>2]=n;F[s+136>>2]=p;F[s+176>>2]=l;F[s+180>>2]=j;F[s+164>>2]=a;F[s+112>>2]=k;F[s+116>>2]=i;F[s+100>>2]=b;F[s+184>>2]=n;F[s+168>>2]=f;F[s+120>>2]=p;F[s+104>>2]=e}F[s+96>>2]=c;F[s+160>>2]=d;v=v+1|0;if((h|0)!=(v|0)){continue}break}}a=F[s+4>>2];if(!a){break ua}Ra(a)}Ea=s+384|0}o=1}Ea=w+256|0;return o}function Ld(){var a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,I=0,J=0,K=0,M=0;if(!G[435168]){t=Ea-112|0;Ea=t;if(!G[405840]){f=Ea-1040|0;Ea=f;while(1){a:{if(!(1497965>>>h&1&(1797559>>>h&1)|898768>>>h&1)){break a}a=L(h,12)+7200|0;j=F[a>>2];k=((F[a+8>>2]<<2)+(F[a+4>>2]<<1)|1)<>>h&1;c=299592>>>h&1;b:{if(!(b|c)){b=k>>>0<=1?1:k;a=0;while(1){d=8;e=0;while(1){c=(d|0)<(j|0);i=c?d:j;d=d-i|0;e=a>>>(c?j-i|0:0)<0){continue}break}F[f+(a<<2)>>2]=e<<8|a;a=a+1|0;if((b|0)!=(a|0)){continue}break}break b}d=h<<3;a=d+7460|0;d=d+7456|0;l=-1<>>0<=1?1:k;i=F[d>>2];m=F[a>>2];c=0;while(1){d=c&l;a=0;e=G[i|0];if((e|0)!=48){a=d>>>e-97<<1&2}e=G[i+1|0];if((e|0)!=48){a=d>>>e-97&1|a}a=a<<1;e=G[i+2|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+3|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+4|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+5|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+6|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+7|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+8|0];if((e|0)!=48){a=d>>>e-97&1|a}e=d&1?511:0;F[f+(c<<2)>>2]=((e^L(m,c>>>j|0)+a)>>>2|e&128)<<8|c;c=c+1|0;if((b|0)!=(c|0)){continue}break}break b}if(!c){b=k>>>0<=1?1:k;i=0;while(1){a=i&l;d=8;e=0;while(1){c=(d|0)<(j|0);m=c?d:j;d=d-m|0;e=a>>>(c?j-m|0:0)<0){continue}break}F[f+(i<<2)>>2]=e<<8|i;i=i+1|0;if((i|0)!=(b|0)){continue}break}break b}b=k>>>0<=1?1:k;i=F[d>>2];m=F[a>>2];c=0;while(1){d=c&l;a=0;e=G[i|0];if((e|0)!=48){a=d>>>e-97<<1&2}e=G[i+1|0];if((e|0)!=48){a=d>>>e-97&1|a}a=a<<1;e=G[i+2|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+3|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+4|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+5|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+6|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+7|0];if((e|0)!=48){a=a|d>>>e-97&1}a=a<<1;e=G[i+8|0];if((e|0)!=48){a=d>>>e-97&1|a}e=d&1?511:0;F[f+(c<<2)>>2]=((e^L(m,c>>>j|0)+a)>>>2|e&128)<<8|c;c=c+1|0;if((b|0)!=(c|0)){continue}break}}a=f+(k<<2)|0;d=a;i=f+1039|0;a=a-f>>2;if(a){a=31-O(a)|0}else{a=0}Ib(f,d,i,a<<1);d=0;if((b|0)!=1){a=b&-2;j=0;while(1){e=(h<<9)+413088|0;c=F[f+(d<<2)>>2];i=e+((c&255)<<1)|0;D[i+1|0]=d;D[i|0]=c>>>8;c=d|1;i=F[f+(c<<2)>>2];e=e+((i&255)<<1)|0;D[e+1|0]=c;D[e|0]=i>>>8;d=d+2|0;j=j+2|0;if((a|0)!=(j|0)){continue}break}}if(!(b&1)){break a}a=F[f+(d<<2)>>2];e=((h<<9)+413088|0)+((a&255)<<1)|0;D[e+1|0]=d;D[e|0]=a>>>8}h=h+1|0;if((h|0)!=21){continue}break}j=0;while(1){b=0;a=65535;while(1){i=L(b,86)+32|0;d=0;while(1){h=(i+L(d,42)>>>6|0)-j|0;k=L(h,h);h=k>>>0<(a&65535)>>>0;k=h?k:a;l=d|1;a=(i+L(l,42)>>>6|0)-j|0;m=L(a,a);a=(k&65535)>>>0>m>>>0;e=a?l:h?d:e;c=a?b:h?b:c;a=a?m:k;d=d+2|0;if((d|0)!=128){continue}break}b=b+1|0;if((b|0)!=128){continue}break}k=(j<<3)+423840|0;D[k+3|0]=e;D[k+2|0]=c;E[k>>1]=a;a=65535;b=0;while(1){h=L(b,86);d=0;while(1){i=((L(d,42)+h|0)+96>>>6|0)-j|0;m=L(i,i);l=m>>>0<(a&65535)>>>0;n=d|1;i=((L(n,42)+h|0)+96>>>6|0)-j|0;i=L(i,i);m=l?m:a;a=i>>>0<(m&65535)>>>0;e=a?n:l?d:e;c=a?b:l?b:c;a=a?i:m;d=d+2|0;if((d|0)!=128){continue}break}b=b+1|0;if((b|0)!=128){continue}break}E[k+4>>1]=a;D[k+7|0]=e;D[k+6|0]=c;j=j+1|0;if((j|0)!=256){continue}break}b=0;while(1){a=0;j=65535;while(1){k=L(a<<1|a>>>6,43)+32|0;d=0;while(1){c=d>>>6|0;m=d|1;e=(k+L(c|m<<1,21)>>>6|0)-b|0;l=L(e,e);c=(k+L(c|d<<1,21)>>>6|0)-b|0;e=L(c,c);c=e>>>0<(j&65535)>>>0;j=c?e:j;e=l>>>0<(j&65535)>>>0;j=e?l:j;h=e?a:c?a:h;i=e?m:c?d:i;d=d+2|0;if((d|0)!=128){continue}break}a=a+1|0;if((a|0)!=128){continue}break}a=(b<<2)+425888|0;D[a+3|0]=i;D[a+2|0]=h;E[a>>1]=j;b=b+1|0;if((b|0)!=256){continue}break}Ea=f+1040|0;while(1){b=0;while(1){a=L((b<<5)+g|0,240);f=H[a+13434>>1];e=H[a+13438>>1];h=e>>>0>f>>>0?f:e;j=H[a+13442>>1];i=h>>>0>>0?h:j;k=H[a+13446>>1];l=i>>>0>>0?i:k;m=H[a+13450>>1];n=l>>>0>>0?l:m;o=H[a+13454>>1];p=n>>>0>>0?n:o;q=H[a+13458>>1];r=p>>>0>>0?p:q;s=H[a+13462>>1];c=r>>>0>>0?r:s;d=L(g,48)+L(b,6)|0;e=r>>>0>s>>>0?7:p>>>0>q>>>0?6:n>>>0>o>>>0?5:l>>>0>m>>>0?4:i>>>0>k>>>0?3:h>>>0>j>>>0?2:e>>>0>>0;f=H[a+13466>>1];D[d+426917|0]=H[a+13470>>1]<(c>>>0>>0?c:f)>>>0?9:f>>>0>>0?8:e;f=H[a+13394>>1];e=H[a+13398>>1];h=e>>>0>f>>>0?f:e;j=H[a+13402>>1];i=h>>>0>>0?h:j;k=H[a+13406>>1];l=i>>>0>>0?i:k;m=H[a+13410>>1];n=l>>>0>>0?l:m;o=H[a+13414>>1];p=n>>>0>>0?n:o;q=H[a+13418>>1];r=p>>>0>>0?p:q;s=H[a+13422>>1];c=r>>>0>>0?r:s;e=r>>>0>s>>>0?7:p>>>0>q>>>0?6:n>>>0>o>>>0?5:l>>>0>m>>>0?4:i>>>0>k>>>0?3:h>>>0>j>>>0?2:e>>>0>>0;f=H[a+13426>>1];D[d+426916|0]=H[a+13430>>1]<(c>>>0>>0?c:f)>>>0?9:f>>>0>>0?8:e;f=H[a+13354>>1];e=H[a+13358>>1];h=e>>>0>f>>>0?f:e;j=H[a+13362>>1];i=h>>>0>>0?h:j;k=H[a+13366>>1];l=i>>>0>>0?i:k;m=H[a+13370>>1];n=l>>>0>>0?l:m;o=H[a+13374>>1];p=n>>>0>>0?n:o;q=H[a+13378>>1];r=p>>>0>>0?p:q;s=H[a+13382>>1];c=r>>>0>>0?r:s;e=r>>>0>s>>>0?7:p>>>0>q>>>0?6:n>>>0>o>>>0?5:l>>>0>m>>>0?4:i>>>0>k>>>0?3:h>>>0>j>>>0?2:e>>>0>>0;f=H[a+13386>>1];D[d+426915|0]=H[a+13390>>1]<(c>>>0>>0?c:f)>>>0?9:f>>>0>>0?8:e;f=H[a+13314>>1];e=H[a+13318>>1];h=e>>>0>f>>>0?f:e;j=H[a+13322>>1];i=h>>>0>>0?h:j;k=H[a+13326>>1];l=i>>>0>>0?i:k;m=H[a+13330>>1];n=l>>>0>>0?l:m;o=H[a+13334>>1];p=n>>>0>>0?n:o;q=H[a+13338>>1];r=p>>>0>>0?p:q;s=H[a+13342>>1];c=r>>>0>>0?r:s;e=r>>>0>s>>>0?7:p>>>0>q>>>0?6:n>>>0>o>>>0?5:l>>>0>m>>>0?4:i>>>0>k>>>0?3:h>>>0>j>>>0?2:e>>>0>>0;f=H[a+13346>>1];D[d+426914|0]=H[a+13350>>1]<(c>>>0>>0?c:f)>>>0?9:f>>>0>>0?8:e;f=H[a+13274>>1];e=H[a+13278>>1];h=e>>>0>f>>>0?f:e;j=H[a+13282>>1];i=h>>>0>>0?h:j;k=H[a+13286>>1];l=i>>>0>>0?i:k;m=H[a+13290>>1];n=l>>>0>>0?l:m;o=H[a+13294>>1];p=n>>>0>>0?n:o;q=H[a+13298>>1];r=p>>>0>>0?p:q;s=H[a+13302>>1];c=r>>>0>>0?r:s;e=r>>>0>s>>>0?7:p>>>0>q>>>0?6:n>>>0>o>>>0?5:l>>>0>m>>>0?4:i>>>0>k>>>0?3:h>>>0>j>>>0?2:e>>>0>>0;f=H[a+13306>>1];D[d+426913|0]=H[a+13310>>1]<(c>>>0>>0?c:f)>>>0?9:f>>>0>>0?8:e;f=H[a+13234>>1];e=H[a+13238>>1];h=e>>>0>f>>>0?f:e;j=H[a+13242>>1];i=h>>>0>>0?h:j;k=H[a+13246>>1];l=i>>>0>>0?i:k;m=H[a+13250>>1];n=l>>>0>>0?l:m;o=H[a+13254>>1];p=n>>>0>>0?n:o;q=H[a+13258>>1];r=p>>>0>>0?p:q;s=H[a+13262>>1];c=r>>>0>>0?r:s;u=d+426912|0;d=H[a+13266>>1];D[u|0]=H[a+13270>>1]<(c>>>0>>0?c:d)>>>0?9:d>>>0>>0?8:r>>>0>s>>>0?7:p>>>0>q>>>0?6:n>>>0>o>>>0?5:l>>>0>m>>>0?4:i>>>0>k>>>0?3:h>>>0>j>>>0?2:e>>>0>>0;b=b+1|0;if((b|0)!=8){continue}break}g=g+1|0;if((g|0)!=32){continue}break}c=0;F[107123]=4;F[107118]=3;F[107119]=1;F[107113]=5;F[107114]=2;F[107174]=124;F[107175]=131;F[107172]=108;F[107173]=147;F[107170]=92;F[107171]=163;F[107168]=76;F[107169]=179;F[107166]=59;F[107167]=196;F[107164]=43;F[107165]=212;F[107162]=27;F[107163]=228;F[107160]=11;F[107161]=244;F[107158]=119;F[107159]=136;F[107156]=103;F[107157]=152;F[107154]=86;F[107155]=169;F[107152]=70;F[107153]=185;F[107150]=54;F[107151]=201;F[107148]=38;F[107149]=217;F[107146]=21;F[107147]=234;F[107144]=5;F[107145]=250;F[107142]=113;F[107143]=142;F[107140]=97;F[107141]=158;F[107138]=81;F[107139]=174;F[107136]=65;F[107137]=190;F[107134]=48;F[107135]=207;F[107132]=32;F[107133]=223;F[107130]=16;F[107131]=239;F[107128]=0;F[107129]=255;F[107115]=0;while(1){a=c<<1;f=a+428705|0;e=a+428704|0;b=2147483647;g=0;while(1){a=F[(g<<2)+428512>>2];h=L(a<<8|a,43)+32|0;a=0;while(1){d=F[(a<<2)+428512>>2];j=((h+L(d<<8|d,21)|0)/64>>8)-c|0;d=j>>31;d=(d^j)-d|0;if((d|0)<(b|0)){D[f|0]=a;D[e|0]=g;b=d}a=a+1|0;if((a|0)!=48){continue}break}g=g+1|0;if((g|0)!=48){continue}break}c=c+1|0;if((c|0)!=256){continue}break}d=0;while(1){b=2147483647;a=0;while(1){f=F[(a<<2)+428512>>2]-d|0;c=f>>31;c=(c^f)-c|0;if((c|0)<(b|0)){D[d+429216|0]=a;b=c}f=a|1;g=F[(f<<2)+428512>>2]-d|0;c=g>>31;c=(c^g)-c|0;if((c|0)<(b|0)){D[d+429216|0]=f;b=c}a=a+2|0;if((a|0)!=48){continue}break}d=d+1|0;if((d|0)!=256){continue}break}F[t+104>>2]=-556347706;F[t+108>>2]=-528409;F[t+96>>2]=-1667986300;F[t+100>>2]=-1112167003;F[t+88>>2]=1515342402;F[t+92>>2]=2071161699;F[t+80>>2]=403703808;F[t+84>>2]=959523105;g=0;while(1){a=g<<1;h=a+405857|0;j=a+405856|0;b=0;c=256;while(1){f=G[(t+80|0)+b|0];a=0;while(1){e=G[(t+80|0)+a|0];i=((f+(e<<1)>>>0)/3|0)-g|0;d=i>>31;k=e-f|0;e=k>>31;d=((d^i)-d|0)+(((L((e^k)-e|0,3)&65535)>>>0)/100|0)|0;if((d|0)<(c|0)){D[j|0]=a;D[h|0]=b;c=d}a=a+1|0;if((a|0)!=32){continue}break}b=b+1|0;if((b|0)!=32){continue}break}g=g+1|0;if((g|0)!=256){continue}break}b=0;while(1){a=b<<1;f=a+406369|0;g=a+406368|0;a=0;d=256;while(1){e=G[(t+80|0)+a|0]-b|0;c=e>>31;c=(c^e)-c|0;if((c|0)<(d|0)){D[g|0]=a;D[f|0]=0;d=c}e=a|1;h=G[e+(t+80|0)|0]-b|0;c=h>>31;c=(c^h)-c|0;if((c|0)<(d|0)){D[g|0]=e;D[f|0]=0;d=c}a=a+2|0;if((a|0)!=32){continue}break}b=b+1|0;if((b|0)!=256){continue}break}g=0;a=0;while(1){d=t+16|0;b=a>>>4|0;D[d+a|0]=b|a<<2;c=a|1;D[c+d|0]=b|c<<2;c=a|2;D[c+d|0]=b|c<<2;c=d;d=a|3;D[c+d|0]=b|d<<2;a=a+4|0;if((a|0)!=64){continue}break}while(1){a=g<<1;h=a+406881|0;j=a+406880|0;b=0;c=256;while(1){f=G[(t+16|0)+b|0];a=0;while(1){e=G[(t+16|0)+a|0];i=((f+(e<<1)>>>0)/3|0)-g|0;d=i>>31;k=e-f|0;e=k>>31;d=((d^i)-d|0)+(((L((e^k)-e|0,3)&65535)>>>0)/100|0)|0;if((d|0)<(c|0)){D[j|0]=a;D[h|0]=b;c=d}a=a+1|0;if((a|0)!=64){continue}break}b=b+1|0;if((b|0)!=64){continue}break}g=g+1|0;if((g|0)!=256){continue}break}b=0;while(1){a=b<<1;f=a+407393|0;g=a+407392|0;a=0;d=256;while(1){e=G[(t+16|0)+a|0]-b|0;c=e>>31;c=(c^e)-c|0;if((c|0)<(d|0)){D[g|0]=a;D[f|0]=0;d=c}e=a|1;h=G[e+(t+16|0)|0]-b|0;c=h>>31;c=(c^h)-c|0;if((c|0)<(d|0)){D[g|0]=e;D[f|0]=0;d=c}a=a+2|0;if((a|0)!=64){continue}break}b=b+1|0;if((b|0)!=256){continue}break}d=0;F[101987]=4;F[101982]=3;F[101983]=1;F[101977]=5;F[101978]=2;F[101979]=0;while(1){a=d<<2;b=G[G[a+330720|0]+13204|0];D[t+12|0]=b;D[t+8|0]=G[b+5230|0];b=G[G[a+330721|0]+13204|0];D[t+13|0]=b;D[t+9|0]=G[b+5230|0];b=G[G[a+330722|0]+13204|0];D[t+14|0]=b;D[t+10|0]=G[b+5230|0];a=G[G[a+330723|0]+13204|0];D[t+15|0]=a;D[t+11|0]=G[a+5230|0];a=0;while(1){c=a>>>6&3;b=t+8|0;f=G[c+b|0];g=a>>>4&3;e=G[g+b|0];h=a&3;j=G[h+b|0];i=a>>>2&3;k=G[i+b|0];l=(d<<8)+a|0;b=t+12|0;D[l+407968|0]=G[b+h|0]|G[b+i|0]<<2|G[b+g|0]<<4|G[b+c|0]<<6;D[l+410528|0]=j|k<<2|e<<4|f<<6;a=a+1|0;if((a|0)!=256){continue}break}d=d+1|0;if((d|0)!=10){continue}break}c=0;while(1){a=c<<1;f=a+429473|0;e=a+429472|0;g=0;b=256;while(1){a=g<<1|g>>>3;h=L(a<<3|a>>2,5);a=0;while(1){j=((h+L(a<<3|a>>>2,3)|0)/8|0)-c|0;d=j>>31;d=(d^j)-d|0;if((d|0)<(b|0)){D[e|0]=g;D[f|0]=a;b=d}a=a+1|0;if((a|0)!=32){continue}break}g=g+1|0;if((g|0)!=16){continue}break}c=c+1|0;if((c|0)!=256){continue}break}c=0;while(1){a=c<<1;f=a+429985|0;e=a+429984|0;g=0;b=256;while(1){h=L(g<<3|g>>>2,5);a=0;while(1){j=((h+L(a<<3|a>>>2,3)|0)/8|0)-c|0;d=j>>31;d=(d^j)-d|0;if((d|0)<(b|0)){D[e|0]=g;D[f|0]=a;b=d}a=a+1|0;if((a|0)!=32){continue}break}g=g+1|0;if((g|0)!=32){continue}break}c=c+1|0;if((c|0)!=256){continue}break}c=0;while(1){a=c<<1;f=a+430497|0;e=a+430496|0;g=0;b=256;while(1){h=L(g<<3|g>>>2,5);a=0;while(1){j=((h+L(a<<2|a>>>4,3)|0)/8|0)-c|0;d=j>>31;d=(d^j)-d|0;if((d|0)<(b|0)){D[e|0]=g;D[f|0]=a;b=d}a=a+1|0;if((a|0)!=64){continue}break}g=g+1|0;if((g|0)!=32){continue}break}c=c+1|0;if((c|0)!=256){continue}break}d=0;while(1){a=d<<1;c=a+431008|0;E[c>>1]=0;f=a+431009|0;a=d;g=16-a|0;b=g>>31;b=(b^g)-b|0;if(b>>>0>>0){D[c|0]=0;D[f|0]=1;a=b}g=33-d|0;b=g>>31;b=(b^g)-b|0;if(b>>>0>>0){D[c|0]=0;D[f|0]=2;a=b}g=49-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=3;a=b}g=66-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=4;a=b}g=82-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=5;a=b}g=99-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=6;a=b}g=115-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=7;a=b}g=140-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=8;a=b}g=156-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=9;a=b}g=173-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=10;a=b}g=189-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=11;a=b}g=206-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=12;a=b}g=222-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=13;a=b}g=239-d|0;b=g>>31;b=(b^g)-b|0;if((b|0)<(a|0)){D[c|0]=0;D[f|0]=14;a=b}if((255-d|0)<(a|0)){D[c|0]=0;D[f|0]=15}d=d+1|0;if((d|0)!=256){continue}break}b=0;while(1){a=b<<1;f=a+431521|0;g=a+431520|0;a=0;d=256;while(1){e=a>>>2|0;h=(e|a<<3)-b|0;c=h>>31;c=(c^h)-c|0;if((c|0)<(d|0)){D[g|0]=0;D[f|0]=a;d=c}h=a|1;e=(e|h<<3)-b|0;c=e>>31;c=(c^e)-c|0;if((c|0)<(d|0)){D[g|0]=0;D[f|0]=h;d=c}a=a+2|0;if((a|0)!=32){continue}break}b=b+1|0;if((b|0)!=256){continue}break}b=0;while(1){a=b<<1;f=a+432033|0;g=a+432032|0;a=0;d=256;while(1){e=a>>>4|0;h=(e|a<<2)-b|0;c=h>>31;c=(c^h)-c|0;if((c|0)<(d|0)){D[g|0]=0;D[f|0]=a;d=c}h=a|1;e=(e|h<<2)-b|0;c=e>>31;c=(c^e)-c|0;if((c|0)<(d|0)){D[g|0]=0;D[f|0]=h;d=c}a=a+2|0;if((a|0)!=64){continue}break}b=b+1|0;if((b|0)!=256){continue}break}F[108147]=4;F[108142]=3;F[108143]=1;F[108137]=5;F[108138]=2;F[108139]=0;d=0;while(1){e=2147483647;c=0;g=0;a=0;while(1){b=L(a<<5|a<<1,5);n=d-(b+765>>>3|0)|0;m=n>>31;o=d-(b+663>>>3|0)|0;l=o>>31;p=d-(b+561>>>3|0)|0;k=p>>31;q=d-(b+459>>>3|0)|0;i=q>>31;r=d-(b+357>>>3|0)|0;j=r>>31;s=d-(b+255>>>3|0)|0;h=s>>31;u=d-(b+153>>>3|0)|0;f=u>>31;v=d-(b+51>>>3|0)|0;b=v>>31;v=(b^v)-b|0;b=(v|0)<(e|0);u=(f^u)-f|0;e=b?v:e;f=(u|0)<(e|0);s=(h^s)-h|0;e=f?u:e;h=(s|0)<(e|0);r=(j^r)-j|0;e=h?s:e;j=(r|0)<(e|0);q=(i^q)-i|0;e=j?r:e;i=(q|0)<(e|0);p=(k^p)-k|0;e=i?q:e;k=(p|0)<(e|0);o=(l^o)-l|0;e=k?p:e;l=(o|0)<(e|0);n=(m^n)-m|0;e=l?o:e;m=(n|0)<(e|0);e=m?n:e;c=m?a:l?a:k?a:i?a:j?a:h?a:f?a:b?a:c;g=m?7:l?6:k?5:i?4:j?3:h?2:f?1:b?0:g;a=a+1|0;if((a|0)!=8){continue}break}a=d<<1;D[a+432609|0]=g;D[a+432608|0]=c;d=d+1|0;if((d|0)!=256){continue}break}a=0;while(1){h=a-34|0;d=h>>31;j=a-68|0;b=j>>31;i=a-102|0;c=i>>31;k=a-136|0;f=k>>31;l=a-170|0;g=l>>31;n=a-204|0;e=n>>31;g=(g^l)-g|0;f=(f^k)-f|0;c=(c^i)-c|0;b=(b^j)-b|0;h=(d^h)-d|0;j=(a|0)>(h|0)?h:a;i=(b|0)<(j|0)?b:j;k=(c|0)<(i|0)?c:i;l=(f|0)<(k|0)?f:k;d=(g|0)<(l|0)?g:l;o=a-238|0;m=o>>31;p=a<<1;c=g>>>0>>0?5:f>>>0>>0?4:c>>>0>>0?3:b>>>0>>0?2:a>>>0>h>>>0;b=(e^n)-e|0;d=((m^o)-m|0)<(((b|0)<(d|0)?b:d)|0)?7:d>>>0>b>>>0?6:c;D[p+433121|0]=d;D[p+433120|0]=d;a=a+1|0;if((a|0)!=256){continue}break}a=0;while(1){j=a-51|0;d=j>>31;i=a-17|0;b=i>>31;k=a-85|0;c=k>>31;l=a-119|0;f=l>>31;m=a-153|0;g=m>>31;n=a-187|0;e=n>>31;o=a-221|0;h=o>>31;e=(e^n)-e|0;g=(g^m)-g|0;f=(f^l)-f|0;c=(c^k)-c|0;j=(d^j)-d|0;b=(b^i)-b|0;i=(b|0)>(j|0)?j:b;k=(c|0)<(i|0)?c:i;l=(f|0)<(k|0)?f:k;m=(g|0)<(l|0)?g:l;d=(e|0)<(m|0)?e:m;p=a-255|0;n=p>>31;q=a<<1;c=e>>>0>>0?5:g>>>0>>0?4:f>>>0>>0?3:c>>>0>>0?2:b>>>0>j>>>0;b=(h^o)-h|0;d=(n^p)-n>>>0<((b|0)<(d|0)?b:d)>>>0?7:d>>>0>b>>>0?6:c;D[q+433633|0]=d;D[q+433632|0]=d;a=a+1|0;if((a|0)!=256){continue}break}e=0;while(1){J=e-95|0;a=J>>31;w=e-89|0;d=w>>31;x=e-83|0;b=x>>31;y=e-77|0;c=y>>31;z=e-70|0;f=z>>31;A=e+-64|0;g=A>>31;B=e-58|0;h=B>>31;C=e-52|0;j=C>>31;q=e-43|0;i=q>>31;r=e-37|0;k=r>>31;s=e-30|0;l=s>>31;u=e-24|0;m=u>>31;v=e-18|0;n=v>>31;I=e-12|0;o=I>>31;K=e-6|0;p=K>>31;M=(i^q)-i|0;i=(k^r)-k|0;k=(l^s)-l|0;l=(m^u)-m|0;m=(n^v)-n|0;n=(o^I)-o|0;o=(p^K)-p|0;p=(e|0)>(o|0)?o:e;q=(n|0)<(p|0)?n:p;r=(m|0)<(q|0)?m:q;s=(l|0)<(r|0)?l:r;u=(k|0)<(s|0)?k:s;I=(i|0)<(u|0)?i:u;v=(M|0)<(I|0);C=(j^C)-j|0;I=v?M:I;j=(C|0)<(I|0);B=(h^B)-h|0;C=j?C:I;h=(B|0)<(C|0);A=(g^A)-g|0;B=h?B:C;g=(A|0)<(B|0);z=(f^z)-f|0;A=g?A:B;f=(z|0)<(A|0);y=(c^y)-c|0;z=f?z:A;c=(y|0)<(z|0);x=(b^x)-b|0;y=c?y:z;b=(x|0)<(y|0);w=(d^w)-d|0;x=b?x:y;d=(w|0)<(x|0);a=(a^J)-a|0;w=d?w:x;J=(a|0)<(w|0);a=J?a:w;d=J?15:d?14:b?13:c?12:f?11:g?10:h?9:j?8:v?7:i>>>0>>0?6:k>>>0>>0?5:l>>>0>>0?4:m>>>0>>0?3:n>>>0

>>0?2:e>>>0>o>>>0;g=0;c=0;b=0;while(1){f=c<<1|c>>>3;h=e-(L(f<<3|f>>>2,3)+165>>>3|0)|0;f=h>>31;h=(f^h)-f|0;f=(h|0)<(a|0);a=f?h:a;d=f?c:d;b=f?1:b;c=c+1|0;if((c|0)!=16){continue}break}while(1){c=g<<1|g>>>3;f=e-(L(c<<3|c>>>2,3)+370>>>3|0)|0;c=f>>31;f=(c^f)-c|0;c=(f|0)<(a|0);a=c?f:a;d=c?g:d;b=c?2:b;c=0;g=g+1|0;if((g|0)!=16){continue}break}g=0;while(1){f=g<<1|g>>>3;h=e-(L(f<<3|f>>>2,3)+535>>>3|0)|0;f=h>>31;h=(f^h)-f|0;f=(h|0)<(a|0);a=f?h:a;d=f?g:d;b=f?3:b;g=g+1|0;if((g|0)!=16){continue}break}while(1){f=c<<1|c>>>3;g=e-(L(f<<3|f>>>2,3)+740>>>3|0)|0;f=g>>31;g=(f^g)-f|0;f=(g|0)<(a|0);a=f?g:a;d=f?c:d;b=f?4:b;g=0;c=c+1|0;if((c|0)!=16){continue}break}c=0;while(1){f=c<<1|c>>>3;h=e-(L(f<<3|f>>>2,3)+905>>>3|0)|0;f=h>>31;h=(f^h)-f|0;f=(h|0)<(a|0);a=f?h:a;d=f?c:d;b=f?5:b;c=c+1|0;if((c|0)!=16){continue}break}while(1){c=g<<1|g>>>3;f=e-(L(c<<3|c>>>2,3)+1110>>>3|0)|0;c=f>>31;f=(c^f)-c|0;c=(f|0)<(a|0);a=c?f:a;d=c?g:d;b=c?6:b;g=g+1|0;if((g|0)!=16){continue}break}c=0;while(1){f=c<<1|c>>>3;g=e-(L(f<<3|f>>>2,3)+1275>>>3|0)|0;f=g>>31;g=(f^g)-f|0;f=(g|0)<(a|0);a=f?g:a;d=f?c:d;b=f?7:b;c=c+1|0;if((c|0)!=16){continue}break}a=e<<1;D[a+434145|0]=d;D[a+434144|0]=b;e=e+1|0;if((e|0)!=256){continue}break}b=0;while(1){d=2147483647;g=0;e=0;c=0;while(1){a=g<<1|g>>>3;h=L(a<<3|a>>>2,5);a=0;while(1){f=a<<1|a>>>3;j=b-(h+L(f<<3|f>>>2,3)>>>3|0)|0;f=j>>31;j=(f^j)-f|0;f=(j|0)<(d|0);d=f?j:d;e=f?a:e;c=f?g:c;a=a+1|0;if((a|0)!=16){continue}break}g=g+1|0;if((g|0)!=16){continue}break}a=b<<1;D[a+434657|0]=e;D[a+434656|0]=c;b=b+1|0;if((b|0)!=256){continue}break}D[405840]=1}Ea=t+112|0;D[435168]=1}}function Se(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,w=0;n=Qa(1224);o=Ea-32|0;Ea=o;F[n>>2]=0;g=n+4|0;F[g+144>>2]=0;F[g+148>>2]=0;F[g+88>>2]=0;F[g+92>>2]=0;F[g+152>>2]=0;F[g+96>>2]=0;F[g+100>>2]=0;F[g+104>>2]=0;F[g+108>>2]=0;F[g+112>>2]=0;F[g+116>>2]=0;F[g+120>>2]=0;Hb(g+188|0);Ta(g+776|0,0,420);Cb(g);F[o+8>>2]=a;q=n+1208|0;e=o+8|0;c=e;Pc(q,c);D[n+1220|0]=0;if(G[435168]){j=F[a>>2];b=$(2413)|0;j=_(j|0,b|0)|0;W(b|0);r=+fa(j|0,405168,c|0);ea(F[o+8>>2]);W(j|0);c=ja(4864)|0;b=$(2107)|0;s=_(c|0,b|0)|0;W(b|0);W(c|0);c=F[a>>2];b=$(2095)|0;c=_(c|0,b|0)|0;W(b|0);b=F[q>>2];aa(s|0);F[o+24>>2]=r<4294967296&r>=0?~~r>>>0:0;F[o+16>>2]=b;F[o+8>>2]=s;t=ia(c|0,3,398496,e|0)|0;W(c|0);if(!(D[435184]&1)){b=ha(2,398536)|0;D[435184]=1;F[108795]=b}b=F[108795];aa(F[a>>2]);F[o+8>>2]=F[a>>2];ka(b|0,t|0,1336,o+8|0);a=F[n+1208>>2];k=F[n+1212>>2];Cb(g);a:{b:{if(!a|k>>>0<81){break b}i=12;b=13208;c:{d:{c=a;e:{if((c|13208)&3){break e}while(1){if(F[c>>2]!=F[b>>2]){break e}b=b+4|0;c=c+4|0;i=i-4|0;if(i>>>0>3){continue}break}if(!i){break d}}while(1){l=G[c|0];j=G[b|0];if((l|0)==(j|0)){b=b+1|0;c=c+1|0;i=i-1|0;if(i){continue}break d}break}b=l-j|0;break c}b=0}if(b){break b}F[g+4>>2]=k;F[g>>2]=a;Va(g+8|0,a,80);if(F[g+20>>2]|F[g+24>>2]!=1){break b}b=F[g+28>>2];if(!b){break b}a=F[g+32>>2];if(F[g+36>>2]|!a){break b}f:{switch(F[g+44>>2]-1|0){case 5:if((a|0)!=(b|0)){break b}break;case 0:break f;default:break b}}j=F[g+48>>2];if(j-17>>>0<4294967280){break b}a=F[g+52>>2];if(a>>>0>2){break b}if((a|0)==1){b=F[g+80>>2];if(b>>>0<21){break b}a=F[g+72>>2];if(a>>>0<80|k>>>0>>0){break b}}h=F[g+92>>2];b=1;g:{if((h|0)==(j|0)){break g}if(!(j>>>0<=I[g+96>>2]|h>>>0>j>>>0)){h:{if((j|0)!=(h+1|0)){a=j;break h}a=j;e=a-1|0;if(!(!a|a&e)){break h}b=0-!a|0;a=b>>>16|0;k=a|b;a=k>>>8|0;l=a|k;a=l>>>4|0;c=a|l;a=c>>>2|0;d=((a|c)&1)<<31;a=b|e;a=(b&65535)<<16|a>>>16|a;a=(k&255)<<24|a>>>8|a;a=(l&15)<<28|a>>>4|a;a=(c&3)<<30|a>>>2|a;a=(d|a>>>1|a)+1|0;b=0;if(j>>>0>a>>>0){break g}}l=Ya(L(a,24));b=0;if(!l){break g}k=F[g+88>>2];i:{if(!h){break i}c=l;b=k;d=L(h,24)-24|0;e=((d>>>0)/24|0)+1&3;if(e){while(1){i=G[b+4|0]|G[b+5|0]<<8|(G[b+6|0]<<16|G[b+7|0]<<24);f=G[b|0]|G[b+1|0]<<8|(G[b+2|0]<<16|G[b+3|0]<<24);D[c|0]=f;D[c+1|0]=f>>>8;D[c+2|0]=f>>>16;D[c+3|0]=f>>>24;D[c+4|0]=i;D[c+5|0]=i>>>8;D[c+6|0]=i>>>16;D[c+7|0]=i>>>24;i=G[b+12|0]|G[b+13|0]<<8|(G[b+14|0]<<16|G[b+15|0]<<24);f=G[b+8|0]|G[b+9|0]<<8|(G[b+10|0]<<16|G[b+11|0]<<24);D[c+8|0]=f;D[c+9|0]=f>>>8;D[c+10|0]=f>>>16;D[c+11|0]=f>>>24;D[c+12|0]=i;D[c+13|0]=i>>>8;D[c+14|0]=i>>>16;D[c+15|0]=i>>>24;i=G[b+20|0]|G[b+21|0]<<8|(G[b+22|0]<<16|G[b+23|0]<<24);f=G[b+16|0]|G[b+17|0]<<8|(G[b+18|0]<<16|G[b+19|0]<<24);D[c+16|0]=f;D[c+17|0]=f>>>8;D[c+18|0]=f>>>16;D[c+19|0]=f>>>24;D[c+20|0]=i;D[c+21|0]=i>>>8;D[c+22|0]=i>>>16;D[c+23|0]=i>>>24;c=c+24|0;b=b+24|0;m=m+1|0;if((e|0)!=(m|0)){continue}break}}if(d>>>0<72){break i}e=k+L(h,24)|0;while(1){f=G[b+4|0]|G[b+5|0]<<8|(G[b+6|0]<<16|G[b+7|0]<<24);d=G[b|0]|G[b+1|0]<<8|(G[b+2|0]<<16|G[b+3|0]<<24);D[c|0]=d;D[c+1|0]=d>>>8;D[c+2|0]=d>>>16;D[c+3|0]=d>>>24;D[c+4|0]=f;D[c+5|0]=f>>>8;D[c+6|0]=f>>>16;D[c+7|0]=f>>>24;f=G[b+12|0]|G[b+13|0]<<8|(G[b+14|0]<<16|G[b+15|0]<<24);d=G[b+8|0]|G[b+9|0]<<8|(G[b+10|0]<<16|G[b+11|0]<<24);D[c+8|0]=d;D[c+9|0]=d>>>8;D[c+10|0]=d>>>16;D[c+11|0]=d>>>24;D[c+12|0]=f;D[c+13|0]=f>>>8;D[c+14|0]=f>>>16;D[c+15|0]=f>>>24;f=G[b+20|0]|G[b+21|0]<<8|(G[b+22|0]<<16|G[b+23|0]<<24);d=G[b+16|0]|G[b+17|0]<<8|(G[b+18|0]<<16|G[b+19|0]<<24);D[c+16|0]=d;D[c+17|0]=d>>>8;D[c+18|0]=d>>>16;D[c+19|0]=d>>>24;D[c+20|0]=f;D[c+21|0]=f>>>8;D[c+22|0]=f>>>16;D[c+23|0]=f>>>24;f=G[b+28|0]|G[b+29|0]<<8|(G[b+30|0]<<16|G[b+31|0]<<24);d=G[b+24|0]|G[b+25|0]<<8|(G[b+26|0]<<16|G[b+27|0]<<24);D[c+24|0]=d;D[c+25|0]=d>>>8;D[c+26|0]=d>>>16;D[c+27|0]=d>>>24;D[c+28|0]=f;D[c+29|0]=f>>>8;D[c+30|0]=f>>>16;D[c+31|0]=f>>>24;f=G[b+36|0]|G[b+37|0]<<8|(G[b+38|0]<<16|G[b+39|0]<<24);d=G[b+32|0]|G[b+33|0]<<8|(G[b+34|0]<<16|G[b+35|0]<<24);D[c+32|0]=d;D[c+33|0]=d>>>8;D[c+34|0]=d>>>16;D[c+35|0]=d>>>24;D[c+36|0]=f;D[c+37|0]=f>>>8;D[c+38|0]=f>>>16;D[c+39|0]=f>>>24;f=G[b+44|0]|G[b+45|0]<<8|(G[b+46|0]<<16|G[b+47|0]<<24);d=G[b+40|0]|G[b+41|0]<<8|(G[b+42|0]<<16|G[b+43|0]<<24);D[c+40|0]=d;D[c+41|0]=d>>>8;D[c+42|0]=d>>>16;D[c+43|0]=d>>>24;D[c+44|0]=f;D[c+45|0]=f>>>8;D[c+46|0]=f>>>16;D[c+47|0]=f>>>24;f=G[b+52|0]|G[b+53|0]<<8|(G[b+54|0]<<16|G[b+55|0]<<24);d=G[b+48|0]|G[b+49|0]<<8|(G[b+50|0]<<16|G[b+51|0]<<24);D[c+48|0]=d;D[c+49|0]=d>>>8;D[c+50|0]=d>>>16;D[c+51|0]=d>>>24;D[c+52|0]=f;D[c+53|0]=f>>>8;D[c+54|0]=f>>>16;D[c+55|0]=f>>>24;f=G[b+60|0]|G[b+61|0]<<8|(G[b+62|0]<<16|G[b+63|0]<<24);d=G[b+56|0]|G[b+57|0]<<8|(G[b+58|0]<<16|G[b+59|0]<<24);D[c+56|0]=d;D[c+57|0]=d>>>8;D[c+58|0]=d>>>16;D[c+59|0]=d>>>24;D[c+60|0]=f;D[c+61|0]=f>>>8;D[c+62|0]=f>>>16;D[c+63|0]=f>>>24;d=b- -64|0;f=G[d+4|0]|G[d+5|0]<<8|(G[d+6|0]<<16|G[d+7|0]<<24);i=c- -64|0;d=G[d|0]|G[d+1|0]<<8|(G[d+2|0]<<16|G[d+3|0]<<24);D[i|0]=d;D[i+1|0]=d>>>8;D[i+2|0]=d>>>16;D[i+3|0]=d>>>24;D[i+4|0]=f;D[i+5|0]=f>>>8;D[i+6|0]=f>>>16;D[i+7|0]=f>>>24;f=G[b+76|0]|G[b+77|0]<<8|(G[b+78|0]<<16|G[b+79|0]<<24);d=G[b+72|0]|G[b+73|0]<<8|(G[b+74|0]<<16|G[b+75|0]<<24);D[c+72|0]=d;D[c+73|0]=d>>>8;D[c+74|0]=d>>>16;D[c+75|0]=d>>>24;D[c+76|0]=f;D[c+77|0]=f>>>8;D[c+78|0]=f>>>16;D[c+79|0]=f>>>24;f=G[b+84|0]|G[b+85|0]<<8|(G[b+86|0]<<16|G[b+87|0]<<24);d=G[b+80|0]|G[b+81|0]<<8|(G[b+82|0]<<16|G[b+83|0]<<24);D[c+80|0]=d;D[c+81|0]=d>>>8;D[c+82|0]=d>>>16;D[c+83|0]=d>>>24;D[c+84|0]=f;D[c+85|0]=f>>>8;D[c+86|0]=f>>>16;D[c+87|0]=f>>>24;f=G[b+92|0]|G[b+93|0]<<8|(G[b+94|0]<<16|G[b+95|0]<<24);d=G[b+88|0]|G[b+89|0]<<8|(G[b+90|0]<<16|G[b+91|0]<<24);D[c+88|0]=d;D[c+89|0]=d>>>8;D[c+90|0]=d>>>16;D[c+91|0]=d>>>24;D[c+92|0]=f;D[c+93|0]=f>>>8;D[c+94|0]=f>>>16;D[c+95|0]=f>>>24;c=c+96|0;b=b+96|0;if((e|0)!=(b|0)){continue}break}}if(k){Ra(k)}F[g+96>>2]=a;F[g+88>>2]=l}F[g+92>>2]=j;b=1}d=0;if(!b){break a}a=F[g+48>>2];a=L(a>>>0<=1?1:a,24);d=0;if(I[g+4>>2]>>0){break a}Va(F[g+88>>2],F[g>>2]+80|0,a);k=F[g+92>>2];j:{if(!k){break j}l=F[g+4>>2];j=F[g+88>>2];a=0;k:{l:{m:{c=F[g+52>>2];switch(c|0){case 0:break l;case 1:break m;default:break k}}while(1){c=j+L(a,24)|0;b=G[c|0]|G[c+1|0]<<8|(G[c+2|0]<<16|G[c+3|0]<<24);if(b>>>0<80|l>>>0>>0|(G[c+16|0]|G[c+17|0]<<8|(G[c+18|0]<<16|G[c+19|0]<<24))){break b}a=a+1|0;if((k|0)!=(a|0)){continue}break}break j}while(1){b=j+L(c,24)|0;a=G[b|0]|G[b+1|0]<<8|(G[b+2|0]<<16|G[b+3|0]<<24);d=0;if(a>>>0<80){break a}d=0;if(l>>>0>>0){break a}if((G[b+16|0]|G[b+17|0]<<8|(G[b+18|0]<<16|G[b+19|0]<<24))<0){break b}c=c+1|0;if((k|0)!=(c|0)){continue}break}break j}while(1){c=j+L(a,24)|0;b=G[c|0]|G[c+1|0]<<8|(G[c+2|0]<<16|G[c+3|0]<<24);if(b>>>0<80|l>>>0>>0|(G[c+16|0]|G[c+17|0]<<8|(G[c+18|0]<<16|G[c+19|0]<<24))<=0){break b}a=a+1|0;if((k|0)!=(a|0)){continue}break}}b=F[g+60>>2];a=b-44|0;if((a|0)!=16?a:0){break b}e=F[g+56>>2];d=0;if(e>>>0<80){break a}if(I[g+4>>2]>>0){break b}l=F[g>>2];a=F[g+104>>2];j=1;n:{if((b|0)==(a|0)){break n}if(a>>>0<=b>>>0){if(b>>>0>I[g+108>>2]){o:{if((b|0)!=(a+1|0)){a=b;break o}a=b;j=b-1|0;if(!(!b|j&b)){break o}c=0-!b|0;a=c>>>16|0;k=a|c;a=c|j;a=(c&65535)<<16|a>>>16|a;j=(k&255)<<24|a>>>8|a;c=k|k>>>8;a=c>>>4|0;a=a|c;k=((a|a>>>2)&1)<<31;d=(a&3)<<30;a=j|((c&15)<<28|j>>>4);a=d|a>>>2|a;a=(k|a>>>1|a)+1|0;j=0;if(b>>>0>a>>>0){break n}}c=nb(F[g+100>>2],a);j=0;if(!c){break n}F[g+108>>2]=a;F[g+100>>2]=c;a=F[g+104>>2]}Ta(F[g+100>>2]+a|0,0,b-a|0)}F[g+104>>2]=b;j=1}if(!j){break b}k=e+l|0;Va(F[g+100>>2],k,F[g+60>>2]);l=G[k|0]|G[k+1|0]<<8|(G[k+2|0]<<16|G[k+3|0]<<24);if((l|0)!=F[g+60>>2]|((l|0)!=(F[g- -64>>2]-F[g+56>>2]|0)?F[g+68>>2]:0)){break b}c=G[k+28|0]|G[k+29|0]<<8|(G[k+30|0]<<16|G[k+31|0]<<24);j=G[k+12|0]|G[k+13|0]<<8|(G[k+14|0]<<16|G[k+15|0]<<24);F[g+172>>2]=j>>>24;b=j&255;F[g+160>>2]=b;a=j>>>16&255;F[g+168>>2]=a;F[g+164>>2]=j>>>8&255;if(a-1>>>0>1){break b}p:{q:{switch(b-163|0){case 0:F[g+156>>2]=0;a=(l|0)==60;D[g+1200|0]=a;F[g+180>>2]=c>>>24&15;F[g+176>>2]=a?2:1;if((l|0)!=60){break p}F[g+184>>2]=G[k+47|0]&15;break p;case 3:break q;default:break b}}F[g+176>>2]=1;F[g+156>>2]=1;a=c>>>24&15;F[g+180>>2]=a;D[g+1200|0]=(a|0)==3|(a|0)==5}c=0;k=F[g- -64>>2];i=F[g+68>>2];e=!k;r:{if(!i){break r}s:{if(k>>>0<80|I[g+4>>2]>>0){break s}l=F[g>>2];h=Ea-288|0;Ea=h;t:{u:{v:{w:{f=g+112|0;a=F[f+8>>2];x:{if(a>>>0<8){a=Ya(192);if(!a){break w}e=F[f>>2];b=F[f+4>>2];if(b){j=L(b,24)+e|0;b=a;while(1){c=pb(b,e);b=F[e+12>>2];if(b){Ra(b)}b=F[e>>2];if(b){Ra(b)}b=c+24|0;e=e+24|0;if((j|0)!=(e|0)){continue}break}e=F[f>>2]}if(e){Ra(e)}F[f+8>>2]=8;F[f>>2]=a;break x}if(a>>>0<=8){break x}F[h+28>>2]=0;F[h+20>>2]=0;F[h+24>>2]=0;a=F[f+4>>2];c=a>>>0<=8?8:a;if(c){b=L(c,24);a=Ya(b);if(!a){break v}F[h+28>>2]=c;F[h+20>>2]=a}d=Ea-272|0;Ea=d;if((f|0)!=(h+20|0)){y:{z:{A:{e=F[f+4>>2];m=F[h+28>>2];B:{if(e>>>0<=m>>>0){a=F[h+20>>2];b=F[h+24>>2];if(!b){break B}c=L(b,24)+a|0;while(1){b=F[a+12>>2];if(b){Ra(b)}b=F[a>>2];if(b){Ra(b)}a=a+24|0;if((c|0)!=(a|0)){continue}break}F[h+24>>2]=0;a=F[h+20>>2];break B}a=F[h+20>>2];if(a){b=F[h+24>>2];if(b){c=L(b,24)+a|0;while(1){b=F[a+12>>2];if(b){Ra(b)}b=F[a>>2];if(b){Ra(b)}a=a+24|0;if((c|0)!=(a|0)){continue}break}a=F[h+20>>2]}Ra(a);F[h+28>>2]=0;F[h+20>>2]=0;F[h+24>>2]=0;m=0;e=F[f+4>>2]}a=0;if(e>>>0<=m>>>0){break B}b=L(e,24);a=Ya(b);if(!a){break A}b=F[h+24>>2];C:{if(!b){break C}j=L(b,24);m=0;b=a;while(1){c=pb(b,m);b=F[m+12>>2];if(b){Ra(b)}b=F[m>>2];if(b){Ra(b)}b=c+24|0;m=m+24|0;if((j|0)!=(m|0)){continue}break}b=F[h+20>>2];if(!b){break C}Ra(b)}F[h+28>>2]=e;F[h+20>>2]=a}b=F[f+4>>2];c=0;if(!b){break y}m=F[f>>2];while(1){pb(a,m);m=m+24|0;a=a+24|0;b=b-1|0;if(b){continue}break}break z}F[d>>2]=b;a=d+16|0;hb(a,1776,d);break u}c=F[f+4>>2]}F[h+24>>2]=c}Ea=d+272|0;e=F[f>>2];F[f>>2]=F[h+20>>2];F[h+20>>2]=e;b=F[f+4>>2];F[f+4>>2]=F[h+24>>2];F[h+24>>2]=b;a=F[f+8>>2];F[f+8>>2]=F[h+28>>2];F[h+28>>2]=a;if(!e){break x}if(b){b=L(b,24)+e|0;while(1){a=F[e+12>>2];if(a){Ra(a)}a=F[e>>2];if(a){Ra(a)}e=e+24|0;if((b|0)!=(e|0)){continue}break}e=F[h+20>>2]}Ra(e)}Ea=h+288|0;break t}F[h>>2]=192;a=h+32|0;hb(a,1776,h);break u}F[h+16>>2]=b;a=h+32|0;hb(a,1776,h+16|0)}Nb(a,F[101008]);na();v()}m=k+l|0;while(1){k=i>>>0<5;e=1;if(k){break r}c=0;b=G[m|0]|G[m+1|0]<<8|(G[m+2|0]<<16|G[m+3|0]<<24);if(b>>>0<2){break s}p=i-4|0;if(p>>>0>>0){break s}e=F[g+116>>2];j=e+1|0;d=1;D:{if((e|0)==(j|0)){break D}E:{if(e>>>0>j>>>0){a=F[g+112>>2];l=a+L(e,24)|0;i=a+L(j,24)|0;while(1){a=F[i+12>>2];if(a){Ra(a)}a=F[i>>2];if(a){Ra(a)}i=i+24|0;if((l|0)!=(i|0)){continue}break}break E}if(j>>>0>I[g+120>>2]){F:{if((j|0)!=(e+1|0)){a=j;break F}a=j;d=a-1|0;if(!(!a|a&d)){break F}l=0-!a|0;a=l>>>16|0;h=a|l;a=h>>>8|0;i=a|h;a=i>>>4|0;f=a|i;a=f>>>2|0;w=((a|f)&1)<<31;a=d|l;a=(l&65535)<<16|a>>>16|a;a=(h&255)<<24|a>>>8|a;a=(i&15)<<28|a>>>4|a;a=(f&3)<<30|a>>>2|a;a=(w|a>>>1|a)+1|0;d=0;if(j>>>0>a>>>0){break D}}l=Ya(L(a,24));d=0;if(!l){break D}i=F[g+112>>2];if(e){f=L(e,24)+i|0;e=l;while(1){d=pb(e,i);e=F[i+12>>2];if(e){Ra(e)}e=F[i>>2];if(e){Ra(e)}e=d+24|0;i=i+24|0;if((f|0)!=(i|0)){continue}break}i=F[g+112>>2]}if(i){Ra(i)}F[g+120>>2]=a;F[g+112>>2]=l;e=F[g+116>>2]}if((e|0)==(j|0)){break E}a=L(j-e|0,24);Ta(F[g+112>>2]+L(e,24)|0,0,a-((a-24>>>0)%24|0)|0)}F[g+116>>2]=j;d=1}if(!d){break s}a=m+4|0;h=F[g+112>>2]+L(F[g+116>>2]-1|0,24)|0;while(1){l=a;j=b;if(!b){break s}b=F[h+4>>2];e=F[h+8>>2];G:{if(b>>>0>>0){break G}a=b+1|0;if(e>>>0>=a>>>0){break G}H:{if(!(!a|a-1&a)){b=a;break H}d=0-!a|0;b=d|a-1;e=d>>>16|d;b=b|((d&65535)<<16|b>>>16);i=(e&255)<<24|b>>>8|b;f=e|e>>>8;b=f>>>4|0;d=b|f;e=d>>>2|0;b=i|((f&15)<<28|i>>>4);b=(d&3)<<30|b>>>2|b;b=(b|(((d|e)&1)<<31|b>>>1))+1|0;if(a>>>0>b>>>0){break s}}a=nb(F[h>>2],b);if(!a){break s}F[h+8>>2]=b;F[h>>2]=a;b=F[h+4>>2]}a=l+1|0;D[F[h>>2]+b|0]=G[l|0];e=F[h+4>>2];F[h+4>>2]=e+1;b=j-1|0;p=p-1|0;if(G[e+F[h>>2]|0]){continue}break}e=F[h+16>>2];if((e|0)!=(b|0)){if(b>>>0>=e>>>0){I:{if(I[h+20>>2]>=b>>>0){m=F[h+12>>2];break I}c=b;J:{if((j-2|0)!=(e|0)){break J}e=b-1|0;if(!(!b|e&b)){break J}c=e;e=0-!b|0;c=c|e;c=c|((e&65535)<<16|c>>>16);d=e>>>16|e;e=d>>>8|0;c=c|((d&255)<<24|c>>>8);d=d|e;e=d>>>4|0;c=c|((d&15)<<28|c>>>4);d=d|e;e=d>>>2|0;c=c|((d&3)<<30|c>>>2);c=(c|(((d|e)&1)<<31|c>>>1))+1|0;if(c>>>0>=b>>>0){break J}e=k;break r}m=nb(F[h+12>>2],c);e=k;if(!m){break r}F[h+12>>2]=m;F[h+20>>2]=c;e=F[h+16>>2]}Ta(e+m|0,0,b-e|0)}F[h+16>>2]=b}if(b){Va(F[h+12>>2],a,b);p=p-b|0;a=j+l|0}b=F[g>>2]-a&3;i=p-b|0;m=a+b|0;c=k;if(b>>>0<=p>>>0){continue}break}}e=c}if(!e){break b}b=F[g+116>>2];d=1;if(!b){break a}a=F[g+112>>2];c=0;while(1){if(Lb(F[a+L(c,24)>>2],3139)){u=1;c=c+1|0;if((b|0)!=(c|0)){continue}break b}break}u=1;D[g+1201|0]=1}d=u}K:{if(d){break K}a=F[q>>2];if(!a){break K}Ra(a);F[n+1216>>2]=0;F[n+1208>>2]=0;F[n+1212>>2]=0}F[n>>2]=-559038750;D[n+1220|0]=1;W(t|0);W(s|0)}Ea=o+32|0;return n|0}function Gb(a,b,c){var d=0,e=0,f=0,g=0,h=M(0),i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=M(0),u=0,v=0,w=0,x=0,y=0,z=M(0),A=M(0),B=M(0),C=M(0),E=0,H=0,I=0,K=M(0),O=M(0),P=M(0),Q=M(0),R=0,S=M(0),T=M(0),U=M(0),V=0,W=0;j=Ea-48|0;Ea=j;a:{b:{if(c&4){e=G[a+4|0]|G[a+5|0]<<8|(G[a+6|0]<<16|G[a+7|0]<<24);D[j+47|0]=G[(e>>>30|0)+13200|0];D[j+32|0]=G[(e&3)+13200|0];D[j+46|0]=G[(e>>>28&3)+13200|0];D[j+45|0]=G[(e>>>26&3)+13200|0];D[j+44|0]=G[(e>>>24&3)+13200|0];D[j+43|0]=G[(e>>>22&3)+13200|0];D[j+42|0]=G[(e>>>20&3)+13200|0];D[j+41|0]=G[(e>>>18&3)+13200|0];D[j+40|0]=G[(e>>>16&3)+13200|0];D[j+39|0]=G[(e>>>14&3)+13200|0];D[j+38|0]=G[(e>>>12&3)+13200|0];D[j+37|0]=G[(e>>>10&3)+13200|0];D[j+36|0]=G[(e>>>8&3)+13200|0];D[j+35|0]=G[(e>>>6&3)+13200|0];D[j+34|0]=G[(e>>>4&3)+13200|0];D[j+33|0]=G[(e>>>2&3)+13200|0];H=-1;break b}d=G[b+2|0];c:{d:{e:{E=G[b+4|0];f=G[b|0];l=G[b+1|0];f:{if((E|0)!=(f|0)|(l|0)!=G[b+5|0]|((d|0)!=G[b+6|0]|(f|0)!=G[b+8|0])){break f}if((l|0)!=G[b+9|0]|(d|0)!=G[b+10|0]|((f|0)!=G[b+12|0]|(l|0)!=G[b+13|0])){break f}if((d|0)!=G[b+14|0]|(f|0)!=G[b+16|0]|((l|0)!=G[b+17|0]|(d|0)!=G[b+18|0])){break f}if((f|0)!=G[b+20|0]|(l|0)!=G[b+21|0]|((d|0)!=G[b+22|0]|(f|0)!=G[b+24|0])){break f}if((l|0)!=G[b+25|0]|(d|0)!=G[b+26|0]|((f|0)!=G[b+28|0]|(l|0)!=G[b+29|0])){break f}if((d|0)!=G[b+30|0]|(f|0)!=G[b+32|0]|((l|0)!=G[b+33|0]|(d|0)!=G[b+34|0])){break f}if((f|0)!=G[b+36|0]|(l|0)!=G[b+37|0]|((d|0)!=G[b+38|0]|(f|0)!=G[b+40|0])){break f}if((l|0)!=G[b+41|0]|(d|0)!=G[b+42|0]|((f|0)!=G[b+44|0]|(l|0)!=G[b+45|0])){break f}if((d|0)!=G[b+46|0]|(f|0)!=G[b+48|0]|((l|0)!=G[b+49|0]|(d|0)!=G[b+50|0])){break f}if((f|0)!=G[b+52|0]|(l|0)!=G[b+53|0]|((d|0)!=G[b+54|0]|(f|0)!=G[b+56|0])){break f}if((l|0)!=G[b+57|0]|(d|0)!=G[b+58|0]|((f|0)!=G[b+60|0]|(l|0)!=G[b+61|0])){break f}if((d|0)==G[b+62|0]){break e}}H=1;g=f;q=f;i=f;p=d;n=d;I=d;o=l;e=l;R=e;while(1){m=(H<<2)+b|0;r=G[m+2|0];p=(p|0)<(r|0)?p:r;s=G[m+1|0];o=(o|0)<(s|0)?o:s;m=G[m|0];q=(m|0)>(q|0)?q:m;n=(n|0)>(r|0)?n:r;e=(e|0)>(s|0)?e:s;i=(i|0)>(m|0)?i:m;I=r+I|0;R=s+R|0;g=g+m|0;H=H+1|0;if((H|0)!=16){continue}break}I=I+8>>>4|0;R=R+8>>>4|0;H=g+8>>>4|0;g=0;while(1){m=(g<<2)+b|0;r=G[m+2|0]-I|0;s=G[m+1|0]-R|0;u=L(r,s)+u|0;m=G[m|0]-H|0;w=L(m,r)+w|0;x=L(m,s)+x|0;v=L(r,r)+v|0;k=L(s,s)+k|0;y=L(m,m)+y|0;g=g+1|0;if((g|0)!=16){continue}break}z=M(n-p|0);S=M(M(v|0)*M(.003921568859368563));t=M(i-q|0);O=M(M(w|0)*M(.003921568859368563));P=M(M(u|0)*M(.003921568859368563));h=M(e-o|0);K=M(M(z*S)+M(M(t*O)+M(P*h)));B=M(M(y|0)*M(.003921568859368563));Q=M(M(x|0)*M(.003921568859368563));C=M(M(z*O)+M(M(t*B)+M(Q*h)));T=M(M(k|0)*M(.003921568859368563));h=M(M(z*P)+M(M(t*Q)+M(T*h)));z=M(M(K*S)+M(M(C*O)+M(h*P)));t=M(M(K*O)+M(M(C*B)+M(h*Q)));h=M(M(K*P)+M(M(C*Q)+M(h*T)));U=M(M(z*S)+M(M(t*O)+M(h*P)));A=M(M(z*O)+M(M(t*B)+M(h*Q)));C=M(A*B);B=M(M(z*P)+M(M(t*Q)+M(h*T)));K=M(M(U*O)+M(C+M(B*Q)));t=M(N(K));C=M(M(U*P)+M(M(A*Q)+M(B*T)));h=M(N(C));z=h=M(2)){break d}e=117;i=601;g=306;break c}e=1;i=170;d=d<<1;c=l<<1;b=f<<1;g=G[d+405857|0]|(G[c+406881|0]<<5|G[b+405857|0]<<11);b=G[d+405856|0]|(G[c+406880|0]<<5|G[b+405856|0]<<11);g:{if((g|0)==(b|0)){if(!b){i=85;b=0;break g}i=0;g=b-1|0}if(b>>>0>=g>>>0){e=b;b=g;break g}i=i|85;e=g}D[a+2|0]=b;D[a|0]=e;c=L(i,16843009);D[a+4|0]=c;D[a+5|0]=c>>>8;D[a+6|0]=c>>>16;D[a+7|0]=c>>>24;D[a+3|0]=b>>>8;D[a+1|0]=e>>>8;break a}z=t;t=M(M(1024)/h);h=M(z*t);h:{if(M(N(h))(f|0)?15:d?14:V)<<2)+b|0;e=L(G[i|0],31)+128|0;g=(l|0)<(q|0);d=g?q:l;l=(d|0)<(y|0);q=e+(e>>>8|0)>>>8|0;e=L(G[i+1|0],63)+128|0;V=(e>>>8|0)+e>>>8|0;e=L(G[i+2|0],31)+128|0;i=(e>>>8|0)+e>>>8|0;d=l?y:d;e=(d|0)<(x|0);g=e?3:l?2:g;d=e?x:d;e=(d|0)<(w|0);g=e?4:g;d=e?w:d;e=(d|0)<(r|0);g=e?5:g;d=e?r:d;e=(d|0)<(s|0);g=e?6:g;d=e?s:d;e=(d|0)<(u|0);g=e?7:g;d=e?u:d;e=(d|0)<(m|0);g=e?8:g;d=e?m:d;e=(d|0)<(v|0);g=e?9:g;d=e?v:d;e=(d|0)<(k|0);g=e?10:g;d=e?k:d;e=(d|0)<(E|0);g=e?11:g;d=e?E:d;e=(d|0)<(p|0);g=e?12:g;d=e?p:d;e=(d|0)<(n|0);g=e?13:g;d=e?n:d;e=(d|0)<(o|0);d=(((f|0)>((e?o:d)|0)?15:e?14:g)<<2)+b|0;e=L(G[d|0],31)+128|0;g=(e>>>8|0)+e>>>8|0;e=L(G[d+1|0],63)+128|0;f=(e>>>8|0)+e>>>8|0;e=L(G[d+2|0],31)+128|0;gc(b,q,V,i,g,f,(e>>>8|0)+e>>>8|0,j+32|0)}E=c&2?3:c&1?2:1;e=0;while(1){n=j+32|0;u=0;m=0;v=0;p=0;o=0;i=0;c=0;g=0;while(1){k=G[g+n|0];d=(g<<2)+b|0;l=G[d+2|0];o=L(k,l)+o|0;f=G[d+1|0];v=L(f,k)+v|0;d=G[d|0];u=L(d,k)+u|0;i=i+l|0;p=f+p|0;m=d+m|0;c=F[(k<<2)+398336>>2]+c|0;g=g+1|0;if((g|0)!=16){continue}break}z=M((c>>>16&255)>>>0);t=M((c&255)>>>0);A=M((c>>>8&255)>>>0);h=M(M(z*t)-M(A*A));d=M(N(h))>>0);K=M(M(M(m>>>0)*M(3))-B);h=M(M(3)/h);C=M(h*t);A=M(h*M(-A));J[j+20>>2]=M(C*B)+M(A*K);z=M(h*z);J[j+8>>2]=M(A*B)+M(z*K);t=M(v>>>0);h=M(M(M(p>>>0)*M(3))-t);J[j+24>>2]=M(C*t)+M(h*A);J[j+12>>2]=M(A*t)+M(h*z);t=M(o>>>0);h=M(M(M(i>>>0)*M(3))-t);J[j+28>>2]=M(C*t)+M(h*A);J[j+16>>2]=M(A*t)+M(h*z);k:{if(!(J[j+20>>2]>2]>M(255))){break k}q=G[b|0];y=G[b+4|0];c=q>>>0>>0?q:y;x=G[b+8|0];c=c>>>0>>0?c:x;w=G[b+12|0];c=c>>>0>>0?c:w;r=G[b+16|0];c=c>>>0>>0?c:r;s=G[b+20|0];c=c>>>0>>0?c:s;u=G[b+24|0];c=c>>>0>>0?c:u;m=G[b+28|0];c=c>>>0>>0?c:m;v=G[b+32|0];c=c>>>0>>0?c:v;k=G[b+36|0];c=c>>>0>>0?c:k;p=G[b+40|0];c=c>>>0

>>0?c:p;n=G[b+44|0];c=c>>>0>>0?c:n;o=G[b+48|0];c=c>>>0>>0?c:o;i=G[b+52|0];c=c>>>0>>0?c:i;l=G[b+56|0];c=c>>>0>>0?c:l;f=G[b+60|0];g=c>>>0>>0?c:f;c=q>>>0>y>>>0?q:y;c=c>>>0>x>>>0?c:x;c=c>>>0>w>>>0?c:w;c=c>>>0>r>>>0?c:r;c=c>>>0>s>>>0?c:s;c=c>>>0>u>>>0?c:u;c=c>>>0>m>>>0?c:m;c=c>>>0>v>>>0?c:v;c=c>>>0>k>>>0?c:k;c=c>>>0>p>>>0?c:p;c=c>>>0>n>>>0?c:n;c=c>>>0>o>>>0?c:o;c=c>>>0>i>>>0?c:i;c=c>>>0>l>>>0?c:l;if((g|0)!=((c>>>0>f>>>0?c:f)|0)){break k}h=M(g>>>0);J[j+20>>2]=h;J[j+8>>2]=h}l:{if(!(J[j+24>>2]>2]>M(255))){break l}q=G[b+1|0];y=G[b+5|0];c=q>>>0>>0?q:y;x=G[b+9|0];c=c>>>0>>0?c:x;w=G[b+13|0];c=c>>>0>>0?c:w;r=G[b+17|0];c=c>>>0>>0?c:r;s=G[b+21|0];c=c>>>0>>0?c:s;u=G[b+25|0];c=c>>>0>>0?c:u;m=G[b+29|0];c=c>>>0>>0?c:m;v=G[b+33|0];c=c>>>0>>0?c:v;k=G[b+37|0];c=c>>>0>>0?c:k;p=G[b+41|0];c=c>>>0

>>0?c:p;n=G[b+45|0];c=c>>>0>>0?c:n;o=G[b+49|0];c=c>>>0>>0?c:o;i=G[b+53|0];c=c>>>0>>0?c:i;l=G[b+57|0];c=c>>>0>>0?c:l;f=G[b+61|0];g=c>>>0>>0?c:f;c=q>>>0>y>>>0?q:y;c=c>>>0>x>>>0?c:x;c=c>>>0>w>>>0?c:w;c=c>>>0>r>>>0?c:r;c=c>>>0>s>>>0?c:s;c=c>>>0>u>>>0?c:u;c=c>>>0>m>>>0?c:m;c=c>>>0>v>>>0?c:v;c=c>>>0>k>>>0?c:k;c=c>>>0>p>>>0?c:p;c=c>>>0>n>>>0?c:n;c=c>>>0>o>>>0?c:o;c=c>>>0>i>>>0?c:i;c=c>>>0>l>>>0?c:l;if((g|0)!=((c>>>0>f>>>0?c:f)|0)){break l}h=M(g>>>0);J[j+24>>2]=h;J[j+12>>2]=h}if(!(J[j+28>>2]>2]>M(255))){break j}q=G[b+2|0];y=G[b+6|0];c=q>>>0>>0?q:y;x=G[b+10|0];c=c>>>0>>0?c:x;w=G[b+14|0];c=c>>>0>>0?c:w;r=G[b+18|0];c=c>>>0>>0?c:r;s=G[b+22|0];c=c>>>0>>0?c:s;u=G[b+26|0];c=c>>>0>>0?c:u;m=G[b+30|0];c=c>>>0>>0?c:m;v=G[b+34|0];c=c>>>0>>0?c:v;k=G[b+38|0];c=c>>>0>>0?c:k;p=G[b+42|0];c=c>>>0

>>0?c:p;n=G[b+46|0];c=c>>>0>>0?c:n;o=G[b+50|0];c=c>>>0>>0?c:o;i=G[b+54|0];c=c>>>0>>0?c:i;l=G[b+58|0];c=c>>>0>>0?c:l;f=G[b+62|0];g=c>>>0>>0?c:f;c=q>>>0>y>>>0?q:y;c=c>>>0>x>>>0?c:x;c=c>>>0>w>>>0?c:w;c=c>>>0>r>>>0?c:r;c=c>>>0>s>>>0?c:s;c=c>>>0>u>>>0?c:u;c=c>>>0>m>>>0?c:m;c=c>>>0>v>>>0?c:v;c=c>>>0>k>>>0?c:k;c=c>>>0>p>>>0?c:p;c=c>>>0>n>>>0?c:n;c=c>>>0>o>>>0?c:o;c=c>>>0>i>>>0?c:i;c=c>>>0>l>>>0?c:l;if((g|0)!=((c>>>0>f>>>0?c:f)|0)){break j}h=M(g>>>0);J[j+28>>2]=h;J[j+16>>2]=h}m:{if(d){if((H|0)<0){R=(G[b+61|0]+(G[b+57|0]+(G[b+53|0]+(G[b+49|0]+(G[b+45|0]+(G[b+41|0]+(G[b+37|0]+(G[b+33|0]+(G[b+29|0]+(G[b+25|0]+(G[b+21|0]+(G[b+17|0]+(G[b+13|0]+(G[b+9|0]+(G[b+1|0]+G[b+5|0]|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)+8>>>4|0;H=(G[b+60|0]+(G[b+56|0]+(G[b+52|0]+(G[b+48|0]+(G[b+44|0]+(G[b+40|0]+(G[b+36|0]+(G[b+32|0]+(G[b+28|0]+(G[b+24|0]+(G[b+20|0]+(G[b+16|0]+(G[b+12|0]+(G[b+8|0]+(G[b|0]+G[b+4|0]|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)+8>>>4|0;I=(G[b+62|0]+(G[b+58|0]+(G[b+54|0]+(G[b+50|0]+(G[b+46|0]+(G[b+42|0]+(G[b+38|0]+(G[b+34|0]+(G[b+30|0]+(G[b+26|0]+(G[b+22|0]+(G[b+18|0]+(G[b+14|0]+(G[b+10|0]+(G[b+2|0]+G[b+6|0]|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)|0)+8>>>4|0}f=I<<1;i=G[f+405857|0];d=R<<1;g=G[d+406881|0];c=H<<1;p=G[c+405857|0];q=G[d+406880|0];n=G[c+405856|0];c=G[f+405856|0];break m}h=M(M(J[j+16>>2]*M(.12156862765550613))+M(.5));n:{if(M(N(h))>2]*M(.24705882370471954))+M(.5));o:{if(M(N(h))0;o=g?c:63;g=(o|0)>0;h=M(M(J[j+8>>2]*M(.12156862765550613))+M(.5));p:{if(M(N(h))=31?31:l;c=(l|0)>0;h=M(M(J[j+28>>2]*M(.12156862765550613))+M(.5));q:{if(M(N(h))=31?31:d;d=(f|0)>0;i=i?n:0;g=g?o:0;p=c?l:0;h=M(M(J[j+24>>2]*M(.24705882370471954))+M(.5));r:{if(M(N(h))=63?63:k;q=(c|0)>0?c:0;h=M(M(J[j+20>>2]*M(.12156862765550613))+M(.5));s:{if(M(N(h))=31?31:c;n=(c|0)>0?c:0;c=d?f:0}gc(b,n,q,c,p,g,i,j+32|0);e=e+1|0;if((E|0)!=(e|0)){continue}break}c=c|(q<<5|n<<11);d=c&65535;b=g<<5|p<<11|i;e=b&65535;if((d|0)==(e|0)){e=d?0:1431655765;D[a+4|0]=e;D[a+5|0]=e>>>8;D[a+6|0]=e>>>16;D[a+7|0]=e>>>24;c=d?c:1;D[a|0]=c;b=d?b-1|0:0;D[a+2|0]=b;D[a+1|0]=c>>>8;D[a+3|0]=b>>>8;break a}k=d>>>0>>0;c=k?d:e;D[a+2|0]=c;b=d>>>0>e>>>0?d:e;D[a|0]=b;D[a+3|0]=c>>>8;D[a+1|0]=b>>>8;E=G[j+46|0];p=G[j+47|0];n=G[j+44|0];o=G[j+45|0];I=G[j+42|0];i=G[j+43|0];l=G[j+40|0];f=G[j+41|0];g=G[j+38|0];d=G[j+39|0];e=G[j+36|0];c=G[j+37|0];b=G[G[j+32|0]+13204|0]|G[G[j+33|0]+13204|0]<<2|G[G[j+34|0]+13204|0]<<4|G[G[j+35|0]+13204|0]<<6;k=k?85:0;D[a+4|0]=b^k;b=G[g+13204|0]<<12|G[d+13204|0]<<14|(b|(G[e+13204|0]<<8|G[c+13204|0]<<10));D[a+5|0]=k^b>>>8;b=G[I+13204|0]<<20|G[i+13204|0]<<22|(b|(G[l+13204|0]<<16|G[f+13204|0]<<18));D[a+6|0]=k^b>>>16;D[a+7|0]=k^(G[E+13204|0]<<28|G[p+13204|0]<<30|(b|(G[n+13204|0]<<24|G[o+13204|0]<<26)))>>>24}Ea=j+48|0}function Za(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,I=0,J=0,K=0,M=0;t=Ea-48|0;e=G[a|0]&127;a:{if((e|0)==69){break a}o=G[e+10336|0];F[b+104>>2]=o;e=F[((o<<3)+6848|0)+4>>2];b:{if((o|0)==8){c=(e>>>3|0)+a|0;f=e&7;D[b+112|0]=(G[c+1|0]<<8|G[c|0])>>>f;c=(e+8>>>3|0)+a|0;D[b+113|0]=(G[c+1|0]<<8|G[c|0])>>>f;c=(e+16>>>3|0)+a|0;D[b+114|0]=(G[c+1|0]<<8|G[c|0])>>>f;c=(e+24>>>3|0)+a|0;D[b+115|0]=(G[c+1|0]<<8|G[c|0])>>>f;h=1;if(!d){break a}D[b+118|0]=0;D[b+119|0]=G[(e+32>>>3|0)+a|0]>>>f&1;c=e+33|0;d=(c>>>3|0)+a|0;c=c&7;h=G[d|0]>>>c|0;h=c>>>0>=6?G[d+1|0]<<8-c|h:h;F[b+124>>2]=0;F[b+120>>2]=h&7;c=e+36|0;d=(c>>>3|0)+a|0;m=c&7;c=G[d|0]>>>m|0;if((m|0)==7){c=c|G[d+1|0]<<1}F[b+136>>2]=c&3;c=e+38|0;m=(c>>>3|0)+a|0;d=c&7;c=G[m|0]>>>d|0;if(d>>>0>=4){c=c|G[m+1|0]<<8-d}F[b+140>>2]=c&31;c=e+43|0;m=(c>>>3|0)+a|0;d=c&7;c=G[m|0]>>>d|0;if(d>>>0>=4){c=c|G[m+1|0]<<8-d}F[b+144>>2]=c&31;a=(e+48>>>3|0)+a|0;c=G[a|0];a=G[a+1|0];F[b+128>>2]=0;F[b+132>>2]=0;F[b+148>>2]=(a<<8-f|c>>>f)&31;break b}c:{if(d){D[b+116|0]=G[(e>>>3|0)+a|0]>>>(e&7)&1;d=e+1|0;n=7424>>>o&1;if(!n){g=G[(d>>>3|0)+a|0]>>>(d&7)&1;d=e+2|0}D[b+117|0]=g;p=d&7;D[b+118|0]=G[(d>>>3|0)+a|0]>>>p&1;e=d+1|0;D[b+119|0]=G[(e>>>3|0)+a|0]>>>(e&7)&1;e=d+2|0;i=(e>>>3|0)+a|0;g=e&7;e=G[i|0]>>>g|0;if(g>>>0>=6){e=e|G[i+1|0]<<8-g}F[b+120>>2]=e&7;e=d+5|0;i=(e>>>3|0)+a|0;g=e&7;e=G[i|0]>>>g|0;if(g>>>0>=6){e=e|G[i+1|0]<<8-g}F[b+124>>2]=e&7;k=d+8|0;g=0;if(!n){g=(k>>>3|0)+a|0;e=G[g|0]>>>p|0;if(p>>>0>=4){e=e|G[g+1|0]<<8-p}k=d+13|0;g=e&31}F[b+128>>2]=g;if(o-18>>>0>=4294967286){g=(k>>>3|0)+a|0;e=k&7;d=G[g|0]>>>e|0;if(e){d=d|G[g+1|0]<<8-e}F[b+132>>2]=d&255;k=k+8|0;break c}F[b+132>>2]=0;break c}k=e+G[o+10464|0]|0}z=1;d:{e:{f:{g:{h:{i:{j:{k:{l:{m:{g=o>>>0>16;p=1;n:{if(g){break n}if(!(1<>>3|0)+a|0;e=k&7;d=G[p|0]>>>e|0;if(e>>>0>=4){d=d|G[p+1|0]<<8-e}F[b+108>>2]=d&31;k=k+5|0;z=0;p=2}d=0;if(g){break k}if(1<>2];if(d>>>0>18){break a}d=L(d,6)+5442|0;break h}g=(k>>>3|0)+a|0;e=k&7;d=G[g|0]>>>e|0;if(e>>>0>=5){d=d|G[g+1|0]<<8-e}d=d&15;F[b+108>>2]=d;k=k+4|0;z=0;p=3;break i}d=F[b+108>>2];if(d>>>0>29){break a}d=H[(L(d,6)+5248|0)+2>>1]}A=1;switch(o-6|0){case 11:break f;case 0:case 5:case 7:break g;default:break d}}d=F[b+108>>2]}if(d>>>0>10){break a}d=L(d,6)+5570|0}d=H[d>>1];A=1;break d}g=(k>>>3|0)+a|0;n=k&7;e=G[g|0]>>>n|0;if((n|0)==7){e=e|G[g+1|0]<<1}F[b+16>>2]=e&3;k=k+2|0;break e}F[b+16>>2]=3}A=2;B=1}F[b+4>>2]=p;D[b+20|0]=B;F[b+8>>2]=d&65535;F[b+12>>2]=G[o+10496|0];F[b>>2]=G[o+7040|0];x=G[o+7168|0];l=L(x,p)<<1;i=G[o+7008|0];v=G[o+7072|0];j=F[L(v,12)+7200>>2];o:{p:{q:{n=1497965>>>v&1;r:{if(!n){r=3;h=4;e=5;break r}y=1;if(1797559>>>v&1){break q}r=5;h=2;e=3}d=h+l|0;u=(d>>>0)/(e>>>0)|0;y=d>>>0>>0;if(!y){break p}y=1;break o}e=0;break o}C=n?7:8;s=u-1|0;d=l-L(s,e)|0;q=1797559>>>v&1?7:(d|0)==1?3:(d|0)==2?5:7;I=d-1|0;K=(I<<2)+398468|0;d=0;while(1){h=(d|0)!=(s|0);g=h|n;h=g?h?C:q:8;h=I>>>0>3|g?h:F[K>>2];J=(k>>>3|0)+a|0;w=k&7;g=G[J|0]>>>w|0;M=(t+16|0)+(d<<2)|0;w=8-w|0;if(w>>>0>>0){g=g|G[J+1|0]<>2]=(-1<>>3|0)+a|0;q=k&7;d=G[s|0]>>>q|0;k=k+j|0;q=8-q|0;if((q|0)<(j|0)){d=d|G[s+1|0]<>2];u=u+1|0;n=e}n=n-1|0;q=g;g=(g>>>0)/(r>>>0)|0;d=d|q-L(r,g)<>>0<2){break u}d=F[b+108>>2];if((p|0)==3){r=(d<<4)+6160|0;g=L(d,3)+6736|0;break u}if((o|0)==7){g=L(d,3)+6784|0;r=(d<<4)+6336|0;break t}r=(d<<4)+5680|0;g=L(d,3)+6640|0}if((o|0)!=18){break t}h=0;while(1){e=b+h|0;f=i-!h|0;if(f){m=(k>>>3|0)+a|0;g=k&7;d=G[m|0]>>>g|0;k=f+k|0;g=8-g|0;if((g|0)<(f|0)){d=d|G[m+1|0]<=64?64:d;if(j){h=0;while(1){d=j-h|0;e=k&7;n=8-e|0;n=(d|0)<(n|0)?d:n;d=(-1<>>3|0)+a|0]>>>e;e=h&31;if((h&63)>>>0>=32){l=d<>>32-e;d=d<>>0>h>>>0){continue}break}}a=-1<>>0>=32?f>>>g|0:((1<>>g);e=d<<1;d=e&31;g=m;D[b+41|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+42|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+43|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+44|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+45|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+46|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+47|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+48|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+49|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+50|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+51|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+52|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+53|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+54|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+55|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+56|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+57|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+58|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+59|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+60|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+61|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+62|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+63|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b- -64|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+65|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+66|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+67|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+68|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+69|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+70|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);break s}if(z){if(33793>>>o&1){D[b+39|0]=m&7;D[b+54|0]=f>>>27&15;D[b+53|0]=f>>>23&15;D[b+52|0]=f>>>19&15;D[b+51|0]=f>>>15&15;D[b+50|0]=f>>>11&15;D[b+49|0]=f>>>7&15;D[b+48|0]=f>>>3&15;D[b+47|0]=((f&2147483647)<<1|m>>>31)&15;D[b+46|0]=m>>>27&15;D[b+45|0]=m>>>23&15;D[b+44|0]=m>>>19&15;D[b+43|0]=m>>>15&15;D[b+42|0]=m>>>11&15;D[b+41|0]=m>>>7&15;D[b+40|0]=m>>>3&15;break s}D[b+39|0]=e&m;e=d&31;g=m;D[b+40|0]=a&((d&63)>>>0>=32?f>>>e|0:((1<>>e);e=d+i|0;d=e&31;D[b+41|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+42|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+43|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+44|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+45|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+46|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+47|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+48|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+49|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+50|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+51|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+52|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+53|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);e=e+i|0;d=e&31;D[b+54|0]=a&((e&63)>>>0>=32?f>>>d|0:((1<>>d);break s}n=G[g+2|0];k=G[g|0];g=G[g+1|0];h=!n|(!k|!g);D[b+39|0]=(h?e:a)&m;j=h?d:i;h=j&31;l=(k|0)==1|(g|0)==1|(n|0)==1;D[b+40|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==2|(g|0)==2|(n|0)==2;D[b+41|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==3|(g|0)==3|(n|0)==3;D[b+42|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==4|(g|0)==4|(n|0)==4;D[b+43|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==5|(g|0)==5|(n|0)==5;D[b+44|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==6|(g|0)==6|(n|0)==6;D[b+45|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==7|(g|0)==7|(n|0)==7;D[b+46|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==8|(g|0)==8|(n|0)==8;D[b+47|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==9|(g|0)==9|(n|0)==9;D[b+48|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==10|(g|0)==10|(n|0)==10;D[b+49|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==11|(g|0)==11|(n|0)==11;D[b+50|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==12|(g|0)==12|(n|0)==12;D[b+51|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==13|(g|0)==13|(n|0)==13;D[b+52|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);j=j+(l?d:i)|0;h=j&31;l=(k|0)==14|(g|0)==14|(n|0)==14;D[b+53|0]=((j&63)>>>0>=32?f>>>h|0:((1<>>h)&(l?e:a);h=j+(l?d:i)|0;d=h&31;D[b+54|0]=((h&63)>>>0>=32?f>>>d|0:((1<>>d)&((k|0)==15?e:(g|0)==15?e:(n|0)==15?e:a)}if(!c|o-18>>>0>4294967292){break b}h=0;D[t+14|0]=0;E[t+12>>1]=0;a=x>>>0<=1?1:x;e=a&254;m=a&1;c=(v<<9)+413088|0;g=0;v:{while(1){d=L(h,x);a=(d<<1)+b|0;if((G[c+(G[a+24|0]<<1)|0]+G[c+(G[a+22|0]<<1)|0]|0)+G[c+(G[a+26|0]<<1)|0]>>>0>>0){a=0;n=0;while(1){g=b+21|0;f=g+(a+d<<1)|0;k=G[f+1|0];D[f+1|0]=G[f|0];D[f|0]=k;f=g+(d+(a|1)<<1)|0;g=G[f+1|0];D[f+1|0]=G[f|0];D[f|0]=g;a=a+2|0;n=n+2|0;if((e|0)!=(n|0)){continue}break}if(m){a=(a+d<<1)+b|0;d=G[a+22|0];D[a+22|0]=G[a+21|0];D[a+21|0]=d}g=1;D[(t+12|0)+h|0]=1;h=h+1|0;if((p|0)!=(h|0)){continue}break v}h=h+1|0;if((p|0)!=(h|0)){continue}break}if(!(g&1)){break b}}c=-1<>2]=0;b=Qa(4);F[b>>2]=0;X(398592,2260,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=4;b=Qa(4);F[b>>2]=4;X(398592,2789,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=8;b=Qa(4);F[b>>2]=8;X(398592,2025,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=12;b=Qa(4);F[b>>2]=12;X(398592,5129,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=16;b=Qa(4);F[b>>2]=16;X(398592,5059,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=20;b=Qa(4);F[b>>2]=20;X(398592,1389,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=24;b=Qa(4);F[b>>2]=24;X(398592,2969,405084,398602,9,a|0,405084,398606,10,b|0);a=Qa(4);F[a>>2]=25;b=Qa(4);F[b>>2]=25;X(398592,2037,405084,398602,9,a|0,405084,398606,10,b|0);a=Qa(4);F[a>>2]=28;b=Qa(4);F[b>>2]=28;X(398592,1440,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=32;b=Qa(4);F[b>>2]=32;X(398592,1714,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=36;b=Qa(4);F[b>>2]=36;X(398592,2278,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=40;b=Qa(4);F[b>>2]=40;X(398592,1522,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=44;b=Qa(4);F[b>>2]=44;X(398592,1733,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=48;b=Qa(4);F[b>>2]=48;X(398592,2297,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=52;b=Qa(4);F[b>>2]=52;X(398592,1704,405168,398602,7,a|0,405168,398606,8,b|0);a=Qa(4);F[a>>2]=56;b=Qa(4);F[b>>2]=56;X(398592,2268,405168,398602,7,a|0,405168,398606,8,b|0);la(398592);ma(398632,3065,398600,11,398568,12);a=Qa(4);F[a>>2]=0;b=Qa(4);F[b>>2]=0;X(398632,2519,405168,398602,13,a|0,405168,398606,14,b|0);a=Qa(4);F[a>>2]=4;b=Qa(4);F[b>>2]=4;X(398632,1272,405168,398602,13,a|0,405168,398606,14,b|0);a=Qa(4);F[a>>2]=8;b=Qa(4);F[b>>2]=8;X(398632,3230,405168,398602,13,a|0,405168,398606,14,b|0);a=Qa(4);F[a>>2]=12;b=Qa(4);F[b>>2]=12;X(398632,3219,405168,398602,13,a|0,405168,398606,14,b|0);a=Qa(4);F[a>>2]=16;b=Qa(4);F[b>>2]=16;X(398632,1555,405168,398602,13,a|0,405168,398606,14,b|0);a=Qa(4);F[a>>2]=20;b=Qa(4);F[b>>2]=20;X(398632,2653,405084,398602,15,a|0,405084,398606,16,b|0);a=Qa(4);F[a>>2]=21;b=Qa(4);F[b>>2]=21;X(398632,2642,405084,398602,15,a|0,405084,398606,16,b|0);la(398632);ma(398668,3006,398600,17,398568,18);a=Qa(4);F[a>>2]=0;b=Qa(4);F[b>>2]=0;X(398668,1752,405168,398602,19,a|0,405168,398606,20,b|0);a=Qa(4);F[a>>2]=4;b=Qa(4);F[b>>2]=4;X(398668,2316,405168,398602,19,a|0,405168,398606,20,b|0);a=Qa(4);F[a>>2]=8;b=Qa(4);F[b>>2]=8;X(398668,1763,405168,398602,19,a|0,405168,398606,20,b|0);a=Qa(4);F[a>>2]=12;b=Qa(4);F[b>>2]=12;X(398668,2327,405168,398602,19,a|0,405168,398606,20,b|0);la(398668);ga(398716,1363,4,1);V(398716,3886,0);V(398716,4126,1);V(398716,3898,2);V(398716,4114,3);V(398716,3362,4);V(398716,3476,5);V(398716,4051,6);V(398716,3858,8);V(398716,4097,9);V(398716,4063,10);V(398716,3831,11);V(398716,4039,12);V(398716,3874,17);V(398716,3842,18);V(398716,4080,19);V(398716,5086,20);V(398716,5102,21);V(398716,5049,13);V(398716,4880,14);V(398716,4870,15);V(398716,4925,16);V(398716,1499,22);ba(2345,2,398724,398602,21,22,0);ba(3163,2,398732,398602,23,24,0);ba(2948,2,398732,398602,23,25,0);ba(2930,2,398732,398602,23,26,0);ba(2499,2,398724,398602,21,27,0);ba(1251,2,398724,398602,21,28,0);ga(398772,2727,4,0);V(398772,3706,0);V(398772,1088,1);V(398772,1062,2);V(398772,1910,3);V(398772,2746,4);ga(398808,1346,4,1);V(398808,3331,0);V(398808,4915,1);qa(398832,398856,398888,0,398904,29,398907,0,398907,0,2800,398568,30);pa(398832,2,398912,398602,31,32);a=Qa(4);F[a>>2]=33;Y(398832,2721,2,398920,398928,34,a|0,0,0);a=Qa(4);F[a>>2]=35;Y(398832,3151,2,398932,398602,36,a|0,0,0);a=Qa(4);F[a>>2]=37;Y(398832,3722,2,398940,398602,38,a|0,0,0);a=Qa(4);F[a>>2]=39;Y(398832,2012,2,398932,398602,36,a|0,0,0);a=Qa(4);F[a>>2]=40;Y(398832,1565,3,398948,398960,41,a|0,0,0);a=Qa(4);F[a>>2]=42;Y(398832,2529,4,398976,398992,43,a|0,0,0);a=Qa(4);F[a>>2]=44;Y(398832,1283,4,398976,398992,43,a|0,0,0);a=Qa(4);F[a>>2]=45;Y(398832,1865,5,399008,399028,46,a|0,0,0);a=Qa(4);F[a>>2]=47;Y(398832,2625,2,398932,398602,36,a|0,0,0);a=Qa(4);F[a>>2]=48;Y(398832,2826,8,399040,399072,49,a|0,0,0);a=Qa(4);F[a>>2]=50;Y(398832,3026,2,399084,398602,51,a|0,0,0);a=Qa(4);F[a>>2]=52;Y(398832,3052,3,399092,398960,53,a|0,0,0);a=Qa(4);F[a>>2]=54;Y(398832,2988,4,399104,398992,55,a|0,0,0);ga(399152,1644,4,0);V(399152,4992,2);V(399152,1453,4);V(399152,1578,8);V(399152,2052,16);V(399152,1024,32);qa(399248,399296,399348,0,398904,56,398907,0,398907,0,2114,398568,57);pa(399248,1,399364,398904,58,59);a=Qa(8);F[a+4>>2]=0;F[a>>2]=60;Y(399248,1895,6,399376,399400,61,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=62;Y(399248,1954,3,399408,398960,63,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=64;Y(399248,2826,20,399424,399504,65,a|0,0,0);ba(2841,19,399536,399616,66,67,0);ba(5026,1,399640,398904,68,69,0);ba(2871,1,399640,398904,68,70,0);ga(399680,2238,4,0);V(399680,3591,0);V(399680,3203,1);V(399680,3626,2);da(3651,405168,0);da(3730,405168,166);da(3338,405168,163);da(3604,405168,2);da(3539,405168,16);da(3269,405168,16);da(3423,405168,1);da(3932,405168,2);ga(399720,2911,4,0);V(399720,3779,0);V(399720,3371,3);V(399720,3513,4);V(399720,4139,15);V(399720,3985,0);V(399720,3805,0);V(399720,4012,3);V(399720,3397,4);V(399720,3486,5);V(399720,3451,6);ga(399764,1967,4,0);V(399764,3676,0);V(399764,4840,1);V(399764,3909,1);V(399764,3241,2);V(399764,3561,3);V(399764,5156,4);V(399764,3178,5);V(399764,3300,6);V(399764,3754,7);V(399764,4965,8);V(399764,4890,9);V(399764,4937,10);V(399764,3958,11);ma(399808,2196,398600,71,398568,72);a=Qa(4);F[a>>2]=0;b=Qa(4);F[b>>2]=0;X(399808,1131,405168,398602,73,a|0,405168,398606,74,b|0);a=Qa(4);F[a>>2]=4;b=Qa(4);F[b>>2]=4;X(399808,1120,405168,398602,73,a|0,405168,398606,74,b|0);a=Qa(4);F[a>>2]=8;b=Qa(4);F[b>>2]=8;X(399808,1142,405168,398602,73,a|0,405168,398606,74,b|0);a=Qa(4);F[a>>2]=12;b=Qa(4);F[b>>2]=12;X(399808,2519,405168,398602,73,a|0,405168,398606,74,b|0);a=Qa(4);F[a>>2]=16;b=Qa(4);F[b>>2]=16;X(399808,1272,405168,398602,73,a|0,405168,398606,74,b|0);a=Qa(4);F[a>>2]=20;b=Qa(4);F[b>>2]=20;X(399808,2473,405168,398602,73,a|0,405168,398606,74,b|0);a=Qa(4);F[a>>2]=24;b=Qa(4);F[b>>2]=24;X(399808,1222,405168,398602,73,a|0,405168,398606,74,b|0);a=Qa(4);F[a>>2]=28;b=Qa(4);F[b>>2]=28;X(399808,3230,405168,398602,73,a|0,405168,398606,74,b|0);a=Qa(4);F[a>>2]=32;b=Qa(4);F[b>>2]=32;X(399808,3219,405168,398602,73,a|0,405168,398606,74,b|0);a=Qa(4);F[a>>2]=36;b=Qa(4);F[b>>2]=36;X(399808,1616,405168,398602,73,a|0,405168,398606,74,b|0);a=Qa(4);F[a>>2]=40;b=Qa(4);F[b>>2]=40;X(399808,2653,405084,398602,75,a|0,405084,398606,76,b|0);a=Qa(4);F[a>>2]=41;b=Qa(4);F[b>>2]=41;X(399808,2642,405084,398602,75,a|0,405084,398606,76,b|0);la(399808);ma(399836,2153,398600,77,398568,78);a=Qa(4);F[a>>2]=0;b=Qa(4);F[b>>2]=0;X(399836,1409,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=4;b=Qa(4);F[b>>2]=4;X(399836,2689,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=8;b=Qa(4);F[b>>2]=8;X(399836,2488,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=12;b=Qa(4);F[b>>2]=12;X(399836,1239,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=16;b=Qa(4);F[b>>2]=16;X(399836,2402,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=20;b=Qa(4);F[b>>2]=20;X(399836,1177,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=24;b=Qa(4);F[b>>2]=24;X(399836,1199,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=28;b=Qa(4);F[b>>2]=28;X(399836,1188,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=32;b=Qa(4);F[b>>2]=32;X(399836,2766,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=36;b=Qa(4);F[b>>2]=36;X(399836,1326,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=40;b=Qa(4);F[b>>2]=40;X(399836,2459,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=44;b=Qa(4);F[b>>2]=44;X(399836,1298,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=48;b=Qa(4);F[b>>2]=48;X(399836,2431,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=52;b=Qa(4);F[b>>2]=52;X(399836,1312,405168,398602,79,a|0,405168,398606,80,b|0);a=Qa(4);F[a>>2]=56;b=Qa(4);F[b>>2]=56;X(399836,2445,405168,398602,79,a|0,405168,398606,80,b|0);la(399836);qa(399856,399876,399908,0,398904,81,398907,0,398907,0,2810,398568,82);pa(399856,2,399924,398602,83,84);a=Qa(8);F[a+4>>2]=0;F[a>>2]=85;Y(399856,2903,2,399932,398602,86,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=87;Y(399856,2721,2,399940,398928,88,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=89;Y(399856,2698,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=91;Y(399856,3644,3,399956,398960,92,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=93;Y(399856,2143,2,399968,398602,94,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=95;Y(399856,1055,3,399976,398960,96,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=97;Y(399856,1427,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=98;Y(399856,1048,3,400060,398960,99,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=100;Y(399856,2673,3,400072,398960,101,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=102;Y(399856,2709,4,400096,398992,103,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=104;Y(399856,2479,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=105;Y(399856,1229,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=106;Y(399856,2086,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=107;Y(399856,1535,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=108;Y(399856,1545,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=109;Y(399856,1399,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=110;Y(399856,3722,2,399932,398602,86,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=111;Y(399856,3323,2,399932,398602,86,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=112;Y(399856,3151,2,399932,398602,86,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=113;Y(399856,2369,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=114;Y(399856,1991,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=115;Y(399856,3080,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=116;Y(399856,1692,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=117;Y(399856,1935,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=118;Y(399856,5139,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=119;Y(399856,5069,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=120;Y(399856,2215,2,399932,398602,86,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=121;Y(399856,1664,5,400112,399028,122,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=123;Y(399856,2178,5,400144,399028,124,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=125;Y(399856,1865,6,400176,399400,126,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=127;Y(399856,2625,2,399948,398602,90,a|0,0,0);a=Qa(8);F[a+4>>2]=0;F[a>>2]=128;Y(399856,2826,10,400208,400248,129,a|0,0,0)}function Oc(a,b,c,d,e,f,g){var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,I=0,J=0,K=0,L=0,M=0,N=0;k=-72;a:{b:{if(!f){break b}h=D[e|0];u=h&255;c:{if((h|0)<0){g=u-126>>>1|0;if(g>>>0>=f>>>0){break b}k=-20;h=u-127|0;if(h>>>0>=256){break b}if(!h){break a}e=e+1|0;k=u-128|0;i=(k>>>1|0)+1|0;j=i&1;f=0;if(k>>>0>=2){i=i&-2;u=0;while(1){k=e+(f>>>1|0)|0;D[a+f|0]=G[k|0]>>>4;D[(f|1)+a|0]=G[k|0]&15;l=f|2;k=e+(l>>>1|0)|0;D[a+l|0]=G[k|0]>>>4;D[(f|3)+a|0]=G[k|0]&15;f=f+4|0;u=u+2|0;if((i|0)!=(u|0)){continue}break}}if(j){e=e+(f>>>1|0)|0;D[a+f|0]=G[e|0]>>>4;D[(f|1)+a|0]=G[e|0]&15}u=g;break c}if(f>>>0<=u>>>0){break b}v=Ea-528|0;Ea=v;F[v+8>>2]=255;N=e+1|0;m=Qb(v+16|0,v+8|0,v+12|0,N,u);d:{if(m>>>0>4294967176){h=m;break d}h=-44;k=F[v+12>>2];if(k>>>0>6){break d}q=F[v+8>>2];o=(q<<1)+2|0;f=k&31;if((k&63)>>>0>=32){e=1<>>32-f}f=e;i=(1<>31<<2|i>>>30;p=i<<2;j=p+j|0;e=e+f|0;e=j>>>0

>>0?e+1|0:e;f=j+o|0;e=f>>>0>>0?e+1|0:e;f=f+11|0;e=f>>>0<11?e+1|0:e;if(!e&(f&-4)>>>0>356|e){break d}t=v+16|0;o=g;e=i<<2;J=e+g|0;e=356-e|0;j=-46;e:{if(q>>>0>255){break e}f=e;h=k&31;I=(q<<1)+2|0;if((k&63)>>>0>=32){e=1<>>32-h}h=I+i|0;e=h>>>0>>0?e+1|0:e;h=h+8|0;e=h>>>0<8?e+1|0:e;if(!e&f>>>0>>0|e){break e}j=-44;if(k>>>0>12){break e}s=g+4|0;r=1<>16;f:{if(!q){g=0;e=f;break f}M=e&-2;e=f;g=0;j=0;while(1){w=g<<1;i=H[w+t>>1];g:{if((i|0)==65535){D[(s+(e<<2)|0)+2|0]=g;e=e-1|0;i=1;break g}p=(h|0)>i<<16>>16?p:0}E[w+J>>1]=i;w=g|1;L=w<<1;i=H[L+t>>1];h:{if((i|0)!=65535){p=(h|0)>i<<16>>16?p:0;break h}D[(s+(e<<2)|0)+2|0]=w;e=e-1|0;i=1}E[J+L>>1]=i;g=g+2|0;j=j+2|0;if((M|0)!=(j|0)){continue}break}}if(K){i=H[t+(g<<1)>>1];i:{if((i|0)!=65535){p=(h|0)>i<<16>>16?p:0;break i}D[(s+(e<<2)|0)+2|0]=g;e=e-1|0;i=1}E[J+(g<<1)>>1]=i}E[o+2>>1]=p;E[o>>1]=k;j:{if((e|0)==(f|0)){j=J+I|0;M=((r>>>3)+(r>>>1)|0)+3|0;I=0;g=0;while(1){h=g;K=E[t+(g<<1)>>1];w=j+I|0;e=w;D[e|0]=n;D[e+1|0]=n>>>8;D[e+2|0]=n>>>16;D[e+3|0]=n>>>24;D[e+4|0]=l;D[e+5|0]=l>>>8;D[e+6|0]=l>>>16;D[e+7|0]=l>>>24;k:{if((K|0)<9){break k}g=K-9|0;i=(g>>>3|0)+1|0;L=i&7;e=8;if(g>>>0>=56){i=i&1073741816;p=0;while(1){g=e+w|0;D[g|0]=n;x=n>>>8|0;D[g+1|0]=x;y=n>>>16|0;D[g+2|0]=y;z=n>>>24|0;D[g+3|0]=z;D[g+4|0]=l;A=l>>>8|0;D[g+5|0]=A;B=l>>>16|0;D[g+6|0]=B;C=l>>>24|0;D[g+7|0]=C;D[g+56|0]=n;D[g+57|0]=x;D[g+58|0]=y;D[g+59|0]=z;D[g+60|0]=l;D[g+61|0]=A;D[g+62|0]=B;D[g+63|0]=C;D[g+48|0]=n;D[g+49|0]=x;D[g+50|0]=y;D[g+51|0]=z;D[g+52|0]=l;D[g+53|0]=A;D[g+54|0]=B;D[g+55|0]=C;D[g+40|0]=n;D[g+41|0]=x;D[g+42|0]=y;D[g+43|0]=z;D[g+44|0]=l;D[g+45|0]=A;D[g+46|0]=B;D[g+47|0]=C;D[g+32|0]=n;D[g+33|0]=x;D[g+34|0]=y;D[g+35|0]=z;D[g+36|0]=l;D[g+37|0]=A;D[g+38|0]=B;D[g+39|0]=C;D[g+24|0]=n;D[g+25|0]=x;D[g+26|0]=y;D[g+27|0]=z;D[g+28|0]=l;D[g+29|0]=A;D[g+30|0]=B;D[g+31|0]=C;D[g+16|0]=n;D[g+17|0]=x;D[g+18|0]=y;D[g+19|0]=z;D[g+20|0]=l;D[g+21|0]=A;D[g+22|0]=B;D[g+23|0]=C;D[g+8|0]=n;D[g+9|0]=x;D[g+10|0]=y;D[g+11|0]=z;D[g+12|0]=l;D[g+13|0]=A;D[g+14|0]=B;D[g+15|0]=C;e=e- -64|0;p=p+8|0;if((i|0)!=(p|0)){continue}break}}g=0;if(!L){break k}while(1){i=e+w|0;D[i|0]=n;D[i+1|0]=n>>>8;D[i+2|0]=n>>>16;D[i+3|0]=n>>>24;D[i+4|0]=l;D[i+5|0]=l>>>8;D[i+6|0]=l>>>16;D[i+7|0]=l>>>24;e=e+8|0;g=g+1|0;if((L|0)!=(g|0)){continue}break}}l=l+16843009|0;n=n+16843009|0;l=n>>>0<16843009?l+1|0:l;g=h+1|0;I=I+K|0;if((h|0)!=(q|0)){continue}break}h=M<<1;g=0;e=0;while(1){D[(s+((e&f)<<2)|0)+2|0]=G[g+j|0];D[(s+((f&e+M)<<2)|0)+2|0]=G[j+(g|1)|0];e=f&e+h;g=g+2|0;if(r>>>0>g>>>0){continue}break}break j}h=((r>>>3)+(r>>>1)|0)+3|0;g=0;j=0;while(1){i=t+(j<<1)|0;if(E[i>>1]>0){p=0;while(1){D[(s+(g<<2)|0)+2|0]=j;while(1){g=f&g+h;if(g>>>0>e>>>0){continue}break}p=p+1|0;if((p|0)>1]){continue}break}}i=(j|0)!=(q|0);j=j+1|0;if(i){continue}break}j=-1;if(g){break e}}k=k+1|0;j=0;g=0;while(1){f=s+(g<<2)|0;h=J+(G[f+2|0]<<1)|0;e=H[h>>1];E[h>>1]=e+1;h=k+(O(e)^-32)|0;D[f+3|0]=h;E[f>>1]=(e<>>0>4294967176){break d}e=u-m|0;m=m+N|0;s=a+255|0;r=s-3|0;l:{m:{if(H[o+2>>1]){if(!e){h=-72;break d}n:{o:{if(e>>>0>=4){h=-1;f=G[(e+m|0)-1|0];if(!f){break d}if(e>>>0<=4294967176){break o}h=e;break d}i=G[m|0];p:{switch(e-2|0){case 1:i=G[m+2|0]<<16|i;case 0:i=(G[m+1|0]<<8)+i|0;break;default:break p}}f=G[(e+m|0)-1|0];if(!f){h=-20;break d}g=0;e=(O(f)-(e<<3)|0)+9|0;break n}g=e-4|0;e=m+g|0;i=G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24);e=O(f)-23|0}f=H[o>>1];k=f+e|0;j=i>>>0-k|0;h=F[(f<<2)+402992>>2];q:{if(k>>>0>32){break q}r:{if((g|0)>=4){i=k>>>3|0;k=k&7;break r}if(!g){g=0;break q}e=k>>>3|0;i=m>>>0>(g+m|0)-e>>>0?g:e;k=k-(i<<3)|0}g=g-i|0;e=m+g|0;i=G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24)}l=h&j;p=o+4|0;e=f+k|0;k=h&i>>>0-e;if(e>>>0>32){f=e;e=a;break l}if((g|0)>=4){f=e&7;g=g-(e>>>3|0)|0;e=m+g|0;i=G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24);break m}if(!g){g=0;f=e;break m}f=e>>>3|0;h=m>>>0>(g+m|0)-f>>>0?g:f;g=g-h|0;f=m+g|0;i=G[f|0]|G[f+1|0]<<8|(G[f+2|0]<<16|G[f+3|0]<<24);f=e-(h<<3)|0;if(f>>>0<=32){break m}e=a;break l}if(!e){h=-72;break d}s:{t:{if(e>>>0>=4){h=-1;f=G[(e+m|0)-1|0];if(!f){break d}if(e>>>0<=4294967176){break t}h=e;break d}i=G[m|0];u:{switch(e-2|0){case 1:i=G[m+2|0]<<16|i;case 0:i=(G[m+1|0]<<8)+i|0;break;default:break u}}f=G[(e+m|0)-1|0];if(!f){h=-20;break d}g=0;e=(O(f)-(e<<3)|0)+9|0;break s}g=e-4|0;e=m+g|0;i=G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24);e=O(f)-23|0}f=H[o>>1];k=f+e|0;j=i>>>0-k|0;h=F[(f<<2)+402992>>2];v:{if(k>>>0>32){break v}w:{if((g|0)>=4){i=k>>>3|0;k=k&7;break w}if(!g){g=0;break v}e=k>>>3|0;i=m>>>0>(g+m|0)-e>>>0?g:e;k=k-(i<<3)|0}g=g-i|0;e=m+g|0;i=G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24)}l=h&j;p=o+4|0;e=f+k|0;k=h&i>>>0-e;x:{if(e>>>0>32){f=e;e=a;break x}y:{if((g|0)>=4){f=e&7;g=g-(e>>>3|0)|0;e=m+g|0;i=G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24);break y}if(!g){g=0;f=e;break y}f=e>>>3|0;h=m>>>0>(g+m|0)-f>>>0?g:f;g=g-h|0;f=m+g|0;i=G[f|0]|G[f+1|0]<<8|(G[f+2|0]<<16|G[f+3|0]<<24);f=e-(h<<3)|0;if(f>>>0<=32){break y}e=a;break x}e=a;z:{A:{while(1){B:{if((g|0)>=4){j=f>>>3|0;h=0;f=f&7;break B}if(!g){g=0;break x}i=f>>>3|0;h=m>>>0>(g+m|0)-i>>>0;j=h?g:i;f=f-(j<<3)|0}n=g-j|0;o=n+m|0;i=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);if(h|e>>>0>=r>>>0){break z}h=p+(l<<2)|0;q=H[h>>1];l=G[h+3|0];D[e|0]=G[h+2|0];k=p+(k<<2)|0;t=H[k>>1];h=G[k+3|0];D[e+1|0]=G[k+2|0];f=f+l|0;l=(F[(l<<2)+402992>>2]&i>>>0-f)+q|0;k=F[(h<<2)+402992>>2];h=f+h|0;k=t+(k&i>>>0-h)|0;C:{if(h>>>0>32){break C}D:{if((n|0)>=4){f=h&7;g=n-(h>>>3|0)|0;h=m+g|0;i=G[h|0]|G[h+1|0]<<8|(G[h+2|0]<<16|G[h+3|0]<<24);break D}if((g|0)==(j|0)){break C}f=h>>>3|0;j=o-f|0;j=j>>>0>>0;g=j?n:f;f=h-(g<<3)|0;g=n-g|0;h=m+g|0;i=G[h|0]|G[h+1|0]<<8|(G[h+2|0]<<16|G[h+3|0]<<24);if(j){break A}}h=p+(l<<2)|0;l=H[h>>1];j=G[h+3|0];D[e+2|0]=G[h+2|0];k=p+(k<<2)|0;n=H[k>>1];h=G[k+3|0];D[e+3|0]=G[k+2|0];f=f+j|0;l=(F[(j<<2)+402992>>2]&i>>>0-f)+l|0;f=f+h|0;k=n+(F[(h<<2)+402992>>2]&i>>>0-f)|0;e=e+4|0;if(f>>>0<33){continue}break x}break}f=h;g=n}e=e+2|0;break x}g=n}h=-70;r=s-2|0;if(r>>>0>>0){break d}s=2;while(1){j=p+(l<<2)|0;t=H[j>>1];q=G[j+3|0];D[e|0]=G[j+2|0];n=e+1|0;E:{o=f+q|0;F:{if(o>>>0>32){l=k;break F}G:{H:{if((g|0)>=4){l=o>>>3|0;f=o&7;break H}if(!g){g=0;f=o;j=i;break G}f=o>>>3|0;l=m>>>0>(g+m|0)-f>>>0?g:f;f=o-(l<<3)|0}g=g-l|0;j=m+g|0;j=G[j|0]|G[j+1|0]<<8|(G[j+2|0]<<16|G[j+3|0]<<24)}if(n>>>0>r>>>0){break d}l=t+(F[(q<<2)+402992>>2]&i>>>0-o)|0;k=p+(k<<2)|0;o=H[k>>1];i=G[k+3|0];D[e+1|0]=G[k+2|0];n=e+2|0;f=f+i|0;if(f>>>0<=32){break E}s=3}D[n|0]=G[(p+(l<<2)|0)+2|0];h=(e+s|0)-a|0;break d}q=F[(i<<2)+402992>>2]&j>>>0-f;I:{J:{if((g|0)>=4){k=f>>>3|0;f=f&7;break J}if(!g){g=0;break I}e=f>>>3|0;k=m>>>0>(g+m|0)-e>>>0?g:e;f=f-(k<<3)|0}g=g-k|0;e=m+g|0;j=G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24)}i=j;k=o+q|0;e=n;if(r>>>0>=e>>>0){continue}break}break d}e=a;K:{L:{while(1){M:{if((g|0)>=4){o=f>>>3|0;j=0;f=f&7;break M}if(!g){g=0;break l}h=f>>>3|0;j=m>>>0>(g+m|0)-h>>>0;o=j?g:h;f=f-(o<<3)|0}h=g-o|0;n=h+m|0;i=G[n|0]|G[n+1|0]<<8|(G[n+2|0]<<16|G[n+3|0]<<24);if(j|e>>>0>=r>>>0){break K}j=p+(l<<2)|0;l=H[j>>1];q=G[j+3|0];D[e|0]=G[j+2|0];k=p+(k<<2)|0;t=H[k>>1];j=G[k+3|0];D[e+1|0]=G[k+2|0];l=(i<>>0-q|0)+l|0;f=f+q|0;k=t+(i<>>0-j|0)|0;N:{j=f+j|0;if(j>>>0>32){break N}O:{if((h|0)>=4){f=j&7;g=h-(j>>>3|0)|0;h=m+g|0;i=G[h|0]|G[h+1|0]<<8|(G[h+2|0]<<16|G[h+3|0]<<24);break O}if((g|0)==(o|0)){break N}f=j>>>3|0;n=n-f|0;n=m>>>0>n>>>0;g=n?h:f;f=j-(g<<3)|0;g=h-g|0;h=m+g|0;i=G[h|0]|G[h+1|0]<<8|(G[h+2|0]<<16|G[h+3|0]<<24);if(n){break L}}h=p+(l<<2)|0;l=H[h>>1];j=G[h+3|0];D[e+2|0]=G[h+2|0];k=p+(k<<2)|0;n=H[k>>1];h=G[k+3|0];D[e+3|0]=G[k+2|0];l=(i<>>0-j|0)+l|0;f=f+j|0;k=n+(i<>>0-h|0)|0;e=e+4|0;f=f+h|0;if(f>>>0<33){continue}break l}break}f=j;g=h}e=e+2|0;break l}g=h}h=-70;r=s-2|0;if(r>>>0>>0){break d}s=2;while(1){j=p+(l<<2)|0;t=H[j>>1];q=G[j+3|0];D[e|0]=G[j+2|0];n=e+1|0;P:{j=f+q|0;Q:{if(j>>>0>32){l=k;break Q}R:{S:{if((g|0)>=4){o=j>>>3|0;j=j&7;break S}if(!g){g=0;o=i;break R}l=j;j=j>>>3|0;o=m>>>0>(g+m|0)-j>>>0?g:j;j=l-(o<<3)|0}g=g-o|0;l=m+g|0;o=G[l|0]|G[l+1|0]<<8|(G[l+2|0]<<16|G[l+3|0]<<24)}if(n>>>0>r>>>0){break d}l=t+(i<>>0-q|0)|0;f=p+(k<<2)|0;q=H[f>>1];k=G[f+3|0];D[e+1|0]=G[f+2|0];n=e+2|0;f=j+k|0;if(f>>>0<=32){break P}s=3}D[n|0]=G[(p+(l<<2)|0)+2|0];h=(e+s|0)-a|0;break d}j=o<>>0-k|0;T:{U:{if((g|0)>=4){k=f>>>3|0;f=f&7;break U}if(!g){g=0;i=o;break T}e=f>>>3|0;k=m>>>0>(g+m|0)-e>>>0?g:e;f=f-(k<<3)|0}g=g-k|0;e=m+g|0;i=G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24)}k=j+q|0;e=n;if(r>>>0>=e>>>0){continue}break}}Ea=v+528|0;k=h;if(h>>>0>=4294967177){break b}}F[b>>2]=0;F[b+4>>2]=0;e=0;F[b+48>>2]=0;F[b+40>>2]=0;F[b+44>>2]=0;F[b+32>>2]=0;F[b+36>>2]=0;F[b+24>>2]=0;F[b+28>>2]=0;F[b+16>>2]=0;F[b+20>>2]=0;F[b+8>>2]=0;F[b+12>>2]=0;k=-20;if(!h){break b}f=0;while(1){g=a+f|0;i=G[g|0];if(i>>>0>11){break b}i=(i<<2)+b|0;F[i>>2]=F[i>>2]+1;e=(1<>1)+e|0;f=f+1|0;if((h|0)!=(f|0)){continue}break}if(!e){break b}f=O(e);g=f^31;if(g>>>0>11){break b}F[d>>2]=32-f;d=(2<>2]=F[a>>2]+1;a=F[b+4>>2];if(a>>>0<2|a&1){break b}F[c>>2]=h+1;k=u+1|0}return k}F[b>>2]=0;F[b+4>>2]=0;F[b+48>>2]=0;F[b+40>>2]=0;F[b+44>>2]=0;F[b+32>>2]=0;F[b+36>>2]=0;F[b+24>>2]=0;F[b+28>>2]=0;F[b+16>>2]=0;F[b+20>>2]=0;F[b+8>>2]=0;F[b+12>>2]=0;return-20}function tc(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,H=0,I=0;j=Ea-32|0;Ea=j;a:{if(F[a+104>>2]==8){b=F[a+120>>2];D[c+3|0]=b<<5|G[a+119|0]<<1|b<<2;b=F[a+140>>2];b:{if(G[a+119|0]){D[c|0]=b<<3;D[c+1|0]=G[a+144|0]<<3;b=G[a+148|0]<<3;break b}D[c|0]=b|b<<4;b=F[a+144>>2];D[c+1|0]=b<<4|b;b=F[a+148>>2];b=b<<4|b}D[c+2|0]=b;a=F[(F[a+136>>2]<<2)+10608>>2];D[c+4|0]=a;D[c+5|0]=a>>>8;D[c+6|0]=a>>>16;D[c+7|0]=a>>>24;break a}d=G[a+118|0];i=G[a+119|0];D[c+3|0]=d|i<<1|F[a+120>>2]<<5|F[a+124>>2]<<2;h=i?31:15;c:{if(7424>>>F[a+104>>2]&1){a=d<<5;d=((G[a+10639|0]<<4)+b|0)+(G[a+10638|0]<<2)|0;o=G[d|0];k=((G[a+10637|0]<<4)+b|0)+(G[a+10636|0]<<2)|0;p=G[k|0];g=((G[a+10635|0]<<4)+b|0)+(G[a+10634|0]<<2)|0;q=G[g|0];e=((G[a+10633|0]<<4)+b|0)+(G[a+10632|0]<<2)|0;r=G[e|0];m=((G[a+10631|0]<<4)+b|0)+(G[a+10630|0]<<2)|0;s=G[m|0];n=((G[a+10629|0]<<4)+b|0)+(G[a+10628|0]<<2)|0;t=G[n|0];f=((G[a+10627|0]<<4)+b|0)+(G[a+10626|0]<<2)|0;u=G[f|0];l=((G[a+10625|0]<<4)+b|0)+(G[a+10624|0]<<2)|0;v=G[l|0];w=G[d+1|0];x=G[k+1|0];y=G[g+1|0];z=G[e+1|0];A=G[m+1|0];B=G[n+1|0];C=G[f+1|0];H=G[l+1|0];D[j+10|0]=((L(h,G[d+2|0]+(G[k+2|0]+(G[g+2|0]+(G[e+2|0]+(G[m+2|0]+(G[n+2|0]+(G[l+2|0]+G[f+2|0]|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040;D[j+9|0]=((L(h,w+(x+(y+(z+(A+(B+(C+H|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040;D[j+8|0]=((L(h,o+(p+(q+(r+(s+(t+(u+v|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040;d=((G[a+10655|0]<<4)+b|0)+(G[a+10654|0]<<2)|0;e=((G[a+10653|0]<<4)+b|0)+(G[a+10652|0]<<2)|0;m=((G[a+10651|0]<<4)+b|0)+(G[a+10650|0]<<2)|0;n=((G[a+10649|0]<<4)+b|0)+(G[a+10648|0]<<2)|0;f=((G[a+10647|0]<<4)+b|0)+(G[a+10646|0]<<2)|0;l=((G[a+10645|0]<<4)+b|0)+(G[a+10644|0]<<2)|0;o=((G[a+10641|0]<<4)+b|0)+(G[a+10640|0]<<2)|0;a=((G[a+10643|0]<<4)+b|0)+(G[a+10642|0]<<2)|0;k=((L(h,G[d+2|0]+(G[e+2|0]+(G[m+2|0]+(G[n+2|0]+(G[f+2|0]+(G[l+2|0]+(G[o+2|0]+G[a+2|0]|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040|0;g=((L(h,G[d+1|0]+(G[e+1|0]+(G[m+1|0]+(G[n+1|0]+(G[f+1|0]+(G[l+1|0]+(G[o+1|0]+G[a+1|0]|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040|0;a=((L(h,G[d|0]+(G[e|0]+(G[m|0]+(G[n|0]+(G[f|0]+(G[l|0]+(G[o|0]+G[a|0]|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040|0;break c}d=d<<5;k=((G[d+10639|0]<<4)+b|0)+(G[d+10638|0]<<2)|0;p=G[k|0];g=((G[d+10637|0]<<4)+b|0)+(G[d+10636|0]<<2)|0;q=G[g|0];e=((G[d+10635|0]<<4)+b|0)+(G[d+10634|0]<<2)|0;r=G[e|0];m=((G[d+10633|0]<<4)+b|0)+(G[d+10632|0]<<2)|0;s=G[m|0];n=((G[d+10631|0]<<4)+b|0)+(G[d+10630|0]<<2)|0;t=G[n|0];f=((G[d+10629|0]<<4)+b|0)+(G[d+10628|0]<<2)|0;u=G[f|0];l=((G[d+10627|0]<<4)+b|0)+(G[d+10626|0]<<2)|0;v=G[l|0];o=((G[d+10625|0]<<4)+b|0)+(G[d+10624|0]<<2)|0;w=G[o|0];x=G[k+1|0];y=G[g+1|0];z=G[e+1|0];A=G[m+1|0];B=G[n+1|0];C=G[f+1|0];H=G[l+1|0];I=G[o+1|0];k=G[k+2|0];g=G[g+2|0];e=G[e+2|0];m=G[m+2|0];n=G[n+2|0];f=G[f+2|0];l=G[l+2|0];o=G[o+2|0];a=F[a+128>>2];D[j+11|0]=0;D[j+10|0]=((L(h,k+(g+(e+(m+(n+(f+(l+o|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040;D[j+9|0]=((L(h,x+(y+(z+(A+(B+(C+(H+I|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040;D[j+8|0]=((L(h,p+(q+(r+(s+(t+(u+(v+w|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040;o=j+16|0;hc(o,j+8|0,a,h,0);F[j+8>>2]=F[j+16>>2];k=((G[d+10655|0]<<4)+b|0)+(G[d+10654|0]<<2)|0;p=G[k|0];g=((G[d+10653|0]<<4)+b|0)+(G[d+10652|0]<<2)|0;q=G[g|0];e=((G[d+10651|0]<<4)+b|0)+(G[d+10650|0]<<2)|0;r=G[e|0];m=((G[d+10649|0]<<4)+b|0)+(G[d+10648|0]<<2)|0;s=G[m|0];n=((G[d+10647|0]<<4)+b|0)+(G[d+10646|0]<<2)|0;t=G[n|0];f=((G[d+10645|0]<<4)+b|0)+(G[d+10644|0]<<2)|0;u=G[f|0];l=((G[d+10643|0]<<4)+b|0)+(G[d+10642|0]<<2)|0;v=G[l|0];d=((G[d+10641|0]<<4)+b|0)+(G[d+10640|0]<<2)|0;w=G[d|0];x=G[k+1|0];y=G[g+1|0];z=G[e+1|0];A=G[m+1|0];B=G[n+1|0];C=G[f+1|0];H=G[l+1|0];I=G[d+1|0];k=G[k+2|0];g=G[g+2|0];e=G[e+2|0];m=G[m+2|0];n=G[n+2|0];f=G[f+2|0];l=G[l+2|0];d=G[d+2|0];D[j+15|0]=0;D[j+14|0]=((L(h,k+(g+(e+(m+(n+(f+(d+l|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040;D[j+13|0]=((L(h,x+(y+(z+(A+(B+(C+(H+I|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040;D[j+12|0]=((L(h,p+(q+(r+(s+(t+(u+(v+w|0)|0)|0)|0)|0)|0)|0)+1020&65535)>>>0)/2040;hc(o,j+12|0,a,h,1);a=F[j+16>>2];k=a>>>16|0;g=a>>>8|0}h=G[j+8|0];d:{if(i){i=G[j+10|0];d=(k&255)-i|0;k=(d|0)>=3?3:d;d=((k|0)<=-4?-4:k)+(d>>>28&8)|i<<3;k=G[j+9|0];i=(g&255)-k|0;g=(i|0)>=3?3:i;k=((g|0)<=-4?-4:g)+(i>>>28&8)|k<<3;a=(a&255)-h|0;i=(a|0)>=3?3:a;a=((i|0)<=-4?-4:i)+(a>>>28&8)|h<<3;break d}d=G[j+10|0]<<4|k;k=G[j+9|0]<<4|g;a=h<<4|a}D[c+2|0]=d;D[c+1|0]=k;D[c|0]=a;m=0;n=0;a=1;k=0;while(1){i=G[c|0];f=G[c+3|0];e:{if(f&2){if(k){h=G[c+1|0];g=h<<3&56;d=G[c+2|0];e=g|d&7;h=((e>>>0>31?-8:0)|g>>>3)+(h>>>3|0)|0;g=e&7;e=((g>>>0>3?-8:0)|g)+(d>>>3|0)|0;d=i&7;d=((d>>>0>3?-8:0)|d)+((i&248)>>>3|0)|0;if((e|(d|h))>>>0>=32){i=(e|0)>=31?31:e;e=(i|0)>0?i:0;h=(h|0)>=31?31:h;h=(h|0)>0?h:0;d=(d|0)>=31?31:d;d=(d|0)>0?d:0}i=h<<3|h>>>2;g=d<<3|d>>>2;d=e<<3|e>>>2;break e}g=i&-8|(i&224)>>>5;d=G[c+1|0];i=(d<<3&1792|d<<8&63488)>>>8|0;d=L(G[c+2|0]>>>3|0,540672)>>>16|0;break e}d=G[c+2|0];g=G[c+1|0];f:{if(k){h=d&15;i=i&15;d=g&15;break f}h=(d&240)>>>4|0;i=(i&240)>>>4|0;d=(g&240)>>>4|0}g=L(i,17);i=L(d,17);d=L(h,17)}D[j+31|0]=255;D[j+27|0]=255;D[j+23|0]=255;D[j+19|0]=255;h=(f>>>(k?2:5)&7)<<4;f=F[h+12764>>2];d=d&255;e=f+d|0;l=(e|0)>=255?255:e;D[j+30|0]=e>>>0<256?e:(l|0)>0?l:0;i=i&255;e=i+f|0;l=(e|0)>=255?255:e;D[j+29|0]=e>>>0<256?e:(l|0)>0?l:0;g=g&255;e=g+f|0;f=(e|0)>=255?255:e;D[j+28|0]=e>>>0<256?e:(f|0)>0?f:0;f=F[h+12760>>2];e=f+d|0;l=(e|0)>=255?255:e;D[j+26|0]=e>>>0<256?e:(l|0)>0?l:0;e=f+i|0;l=(e|0)>=255?255:e;D[j+25|0]=e>>>0<256?e:(l|0)>0?l:0;e=f+g|0;f=(e|0)>=255?255:e;D[j+24|0]=e>>>0<256?e:(f|0)>0?f:0;f=F[h+12756>>2];e=f+d|0;l=(e|0)>=255?255:e;D[j+22|0]=e>>>0<256?e:(l|0)>0?l:0;e=f+i|0;l=(e|0)>=255?255:e;D[j+21|0]=e>>>0<256?e:(l|0)>0?l:0;e=f+g|0;f=(e|0)>=255?255:e;D[j+20|0]=e>>>0<256?e:(f|0)>0?f:0;h=F[h+12752>>2];d=h+d|0;e=(d|0)>=255?255:d;D[j+18|0]=d>>>0<256?d:(e|0)>0?e:0;d=h+i|0;i=(d|0)>=255?255:d;D[j+17|0]=d>>>0<256?d:(i|0)>0?i:0;d=g+h|0;h=(d|0)>=255?255:d;D[j+16|0]=d>>>0<256?d:(h|0)>0?h:0;i=(L(G[j+25|0],183)+L(G[j+24|0],54)|0)+L(G[j+26|0],19)|0;h=(L(G[j+21|0],183)+L(G[j+20|0],54)|0)+L(G[j+22|0],19)|0;d=i+h|0;h=h+((L(G[j+17|0],183)+L(G[j+16|0],54)|0)+L(G[j+18|0],19)|0)|0;i=((i+L(G[j+28|0],54)|0)+L(G[j+29|0],183)|0)+L(G[j+30|0],19)|0;e=k<<3;k=k<<1;g:{if(D[c+3|0]&1){g=e<<2;e=(g|4)+b|0;e=(L(G[e+1|0],366)+L(G[e|0],108)|0)+L(G[e+2|0],38)|0;l=G[(((e>>>0>>0)+(d>>>0>e>>>0)|0)+(e>>>0>>0)|0)+398317|0];o=k|4;e=b+g|0;e=(L(G[e+1|0],366)+L(G[e|0],108)|0)+L(G[e+2|0],38)|0;p=G[(((e>>>0>>0)+(d>>>0>e>>>0)|0)+(e>>>0>>0)|0)+398317|0];e=(g|8)+b|0;e=(L(G[e+1|0],366)+L(G[e|0],108)|0)+L(G[e+2|0],38)|0;q=G[(((e>>>0>>0)+(d>>>0>e>>>0)|0)+(e>>>0>>0)|0)+398317|0];r=k|8;g=(g|12)+b|0;g=(L(G[g+1|0],366)+L(G[g|0],108)|0)+L(G[g+2|0],38)|0;s=G[(((g>>>0>>0)+(d>>>0>g>>>0)|0)+(g>>>0>>0)|0)+398317|0];t=k|12;e=k|1;g=(e<<4)+b|0;f=(L(G[g+1|0],366)+L(G[g|0],108)|0)+L(G[g+2|0],38)|0;u=G[(((f>>>0>>0)+(d>>>0>f>>>0)|0)+(f>>>0>>0)|0)+398317|0];f=(L(G[g+5|0],366)+L(G[g+4|0],108)|0)+L(G[g+6|0],38)|0;v=G[(((f>>>0>>0)+(d>>>0>f>>>0)|0)+(f>>>0>>0)|0)+398317|0];w=k|5;g=(L(G[g+9|0],366)+L(G[g+8|0],108)|0)+L(G[g+10|0],38)|0;g=G[(((g>>>0>>0)+(d>>>0>g>>>0)|0)+(g>>>0>>0)|0)+398317|0];x=k|9;f=l>>>1<>>1<>>1<>>1<>>1<>>1<>>1<>>0>>0)+(d>>>0>f>>>0)|0)+(f>>>0>>0)|0)+398317|0];o=e|1;f=b+g|0;f=(L(G[f+1|0],366)+L(G[f|0],108)|0)+L(G[f+2|0],38)|0;p=G[(((f>>>0>>0)+(d>>>0>f>>>0)|0)+(f>>>0>>0)|0)+398317|0];f=(g|32)+b|0;f=(L(G[f+1|0],366)+L(G[f|0],108)|0)+L(G[f+2|0],38)|0;q=G[(((f>>>0>>0)+(d>>>0>f>>>0)|0)+(f>>>0>>0)|0)+398317|0];r=e|2;f=(g|48)+b|0;f=(L(G[f+1|0],366)+L(G[f|0],108)|0)+L(G[f+2|0],38)|0;s=G[(((f>>>0>>0)+(d>>>0>f>>>0)|0)+(f>>>0>>0)|0)+398317|0];t=e|3;f=(g|4)+b|0;f=(L(G[f+1|0],366)+L(G[f|0],108)|0)+L(G[f+2|0],38)|0;u=G[(((f>>>0>>0)+(d>>>0>f>>>0)|0)+(f>>>0>>0)|0)+398317|0];v=e|4;f=(g|20)+b|0;f=(L(G[f+1|0],366)+L(G[f|0],108)|0)+L(G[f+2|0],38)|0;w=G[(((f>>>0>>0)+(d>>>0>f>>>0)|0)+(f>>>0>>0)|0)+398317|0];x=e|5;g=(g|36)+b|0;g=(L(G[g+1|0],366)+L(G[g|0],108)|0)+L(G[g+2|0],38)|0;g=G[(((g>>>0>>0)+(d>>>0>g>>>0)|0)+(g>>>0>>0)|0)+398317|0];y=e|6;f=l>>>1<>>1<>>1<>>1<>>1<>>1<>>1<>>0>h>>>0)+(d>>>0>h>>>0)|0)+(h>>>0>>0)|0)+398317|0];n=d>>>1<>>8;E[c+6>>1]=m<<8|(m&65280)>>>8}Ea=j+32|0}function Eb(a,b,c,d,e,f,g){var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;h=Ea-240|0;Ea=h;a:{if(F[a>>2]){break a}F[h+232>>2]=0;F[h+236>>2]=0;F[h+224>>2]=0;F[h+228>>2]=0;F[h+216>>2]=0;F[h+220>>2]=0;F[h+208>>2]=0;F[h+200>>2]=0;F[h+204>>2]=0;F[h+192>>2]=0;F[h+196>>2]=0;F[h+184>>2]=0;F[h+188>>2]=0;F[h+176>>2]=0;F[h+180>>2]=0;F[h+168>>2]=0;F[h+160>>2]=0;F[h+164>>2]=0;F[h+152>>2]=0;F[h+156>>2]=0;F[h+144>>2]=0;F[h+148>>2]=0;F[h+136>>2]=0;F[h+140>>2]=0;F[h+128>>2]=0;F[h+120>>2]=0;F[h+124>>2]=0;F[h+112>>2]=0;F[h+116>>2]=0;F[h+104>>2]=0;F[h+108>>2]=0;F[h+96>>2]=0;F[h+100>>2]=0;F[h+88>>2]=0;F[h+80>>2]=0;F[h+84>>2]=0;F[h+72>>2]=0;F[h+76>>2]=0;j=h- -64|0;F[j>>2]=0;F[j+4>>2]=0;F[h+56>>2]=0;F[h+60>>2]=0;b:{if(!(d?c:1)){break b}F[h+232>>2]=0;F[h+236>>2]=0;F[h+224>>2]=c;F[h+220>>2]=c;F[h+216>>2]=d;F[h+228>>2]=c+d;c=h+216|0;if(!bb(c,h+176|0)){break b}if(!bb(c,h+136|0)){break b}if(!bb(c,h+96|0)){break b}if(!bb(c,h+56|0)|!F[h+180>>2]|(!F[h+140>>2]|!F[h+100>>2])|!F[h+60>>2]){break b}c=F[h+236>>2];c:{if(c){i=F[h+232>>2];break c}d=F[h+232>>2];c=F[h+220>>2];if(c>>>0>2]){F[h+220>>2]=c+1;c=G[c|0]}else{c=0}i=c|d;c=8}F[h+236>>2]=c-1;F[h+232>>2]=i>>>1;l=b;c=a+4|0;d=F[c+4>>2];if((d|0)!=(b|0)){if(!(b>>>0>>0|I[c+8>>2]>=b>>>0)){Wa(c,b,(d+1|0)==(b|0),8)}F[c+4>>2]=l}F[h+52>>2]=1052688;if(l){q=i&1;while(1){j=F[h+236>>2];d:{if(j>>>0>=16){k=F[h+232>>2];break d}i=0;b=F[h+220>>2];c=F[h+228>>2];e:{if(b>>>0>=c>>>0){d=b;break e}d=b+1|0;F[h+220>>2]=d;i=G[b|0]}k=F[h+232>>2];b=j+8|0;F[h+236>>2]=b;k=k|i<>2]=k;if(j>>>0>7){j=b;break d}i=0;if(c>>>0>d>>>0){F[h+220>>2]=d+1;i=G[d|0]}j=j+16|0;F[h+236>>2]=j;k=i<>2]=k}c=F[F[h+68>>2]+((k&1023)<<2)>>2];f:{if((c|0)<0){i=10;b=F[h+80>>2];while(1){d=k>>>i|0;i=i+1|0;c=E[b+((d&1)+(c^-1)<<1)>>1];if((c|0)<0){continue}break}break f}i=c>>>16|0;c=c&65535}F[h+236>>2]=j-i;F[h+232>>2]=k>>>i;n=o<<3;D[(n+F[a+4>>2]|0)+4|0]=c+s&7;s=G[(n+F[a+4>>2]|0)+4|0];j=0;while(1){g:{h:{i:{j:{k:{l:{m:{r=(h+52|0)+j|0;p=G[r|0];if(p>>>0<=9){b=F[h+236>>2];n:{if(b>>>0>=16){k=F[h+232>>2];break n}i=0;c=F[h+220>>2];m=F[h+228>>2];o:{if(c>>>0>=m>>>0){d=c;break o}d=c+1|0;F[h+220>>2]=d;i=G[c|0]}k=F[h+232>>2];c=b+8|0;F[h+236>>2]=c;k=k|i<>2]=k;if(b>>>0>7){b=c;break n}i=0;if(d>>>0>>0){F[h+220>>2]=d+1;i=G[d|0]}b=b+16|0;F[h+236>>2]=b;k=i<>2]=k}i=F[F[h+188>>2]+((k&1023)<<2)>>2];if((i|0)>=0){break m}c=10;d=F[h+200>>2];while(1){m=k>>>c|0;c=c+1|0;i=E[d+((m&1)+(i^-1)<<1)>>1];if((i|0)<0){continue}break}break h}b=F[h+236>>2];if(p>>>0<=21){p:{if(b>>>0>=16){k=F[h+232>>2];break p}i=0;c=F[h+220>>2];m=F[h+228>>2];q:{if(c>>>0>=m>>>0){d=c;break q}d=c+1|0;F[h+220>>2]=d;i=G[c|0]}k=F[h+232>>2];c=b+8|0;F[h+236>>2]=c;k=k|i<>2]=k;if(b>>>0>7){b=c;break p}i=0;if(d>>>0>>0){F[h+220>>2]=d+1;i=G[d|0]}b=b+16|0;F[h+236>>2]=b;k=i<>2]=k}i=F[F[h+148>>2]+((k&1023)<<2)>>2];if((i|0)>=0){break l}c=10;d=F[h+160>>2];while(1){m=k>>>c|0;c=c+1|0;i=E[d+((m&1)+(i^-1)<<1)>>1];if((i|0)<0){continue}break}break i}r:{if(b>>>0>=16){k=F[h+232>>2];break r}i=0;c=F[h+220>>2];m=F[h+228>>2];s:{if(c>>>0>=m>>>0){d=c;break s}d=c+1|0;F[h+220>>2]=d;i=G[c|0]}k=F[h+232>>2];c=b+8|0;F[h+236>>2]=c;k=k|i<>2]=k;if(b>>>0>7){b=c;break r}i=0;if(d>>>0>>0){F[h+220>>2]=d+1;i=G[d|0]}b=b+16|0;F[h+236>>2]=b;k=i<>2]=k}i=F[F[h+108>>2]+((k&1023)<<2)>>2];if((i|0)>=0){break k}c=10;d=F[h+120>>2];while(1){m=k>>>c|0;c=c+1|0;i=E[d+((m&1)+(i^-1)<<1)>>1];if((i|0)<0){continue}break}break j}c=i>>>16|0;i=i&65535;break h}c=i>>>16|0;i=i&65535;break i}c=i>>>16|0;i=i&65535}F[h+232>>2]=k>>>c;b=b-c|0;break g}F[h+232>>2]=k>>>c;b=b-c|0;break g}F[h+232>>2]=k>>>c;b=b-c|0}F[h+236>>2]=b;b=i+p&31;D[(n+F[a+4>>2]|0)+j|0]=b;D[r|0]=b;if(!q){b=j>>>0<2;j=j+1|0;if(b){continue}}break}if(q){b=n+F[a+4>>2]|0;D[b+1|0]=G[b|0];b=n+F[a+4>>2]|0;D[b+2|0]=G[b|0]}o=o+1|0;if((l|0)!=(o|0)){continue}break}}i=0;b=a+16|0;c=F[b+4>>2];if((c|0)!=(e|0)){if(!(c>>>0>e>>>0|I[b+8>>2]>=e>>>0)){Wa(b,e,(c+1|0)==(e|0),11)}F[b+4>>2]=e}if(!(g?f:1)){break b}F[h+224>>2]=f;F[h+220>>2]=f;F[h+216>>2]=g;F[h+228>>2]=f+g;F[h+48>>2]=0;F[h+40>>2]=0;F[h+44>>2]=0;F[h+32>>2]=0;F[h+36>>2]=0;F[h+24>>2]=0;F[h+28>>2]=0;F[h+16>>2]=0;F[h+20>>2]=0;c=0;if((g|0)>0){F[h+220>>2]=f+1;c=G[f|0]}F[h+236>>2]=7;F[h+232>>2]=c>>>1;t:{if(c&1){break t}F[h+236>>2]=6;F[h+232>>2]=c>>>2;if(c&2){break t}F[h+236>>2]=5;F[h+232>>2]=c>>>3;u:{if(c&4){if(!e){break u}f=0;while(1){i=0;while(1){b=F[h+236>>2];v:{if(b>>>0>=8){d=b;b=F[h+232>>2];break v}c=0;d=F[h+220>>2];if(d>>>0>2]){F[h+220>>2]=d+1;c=G[d|0]}d=b+8|0;b=F[h+232>>2]|c<>2]=d-8;F[h+232>>2]=b>>>8;c=L(f,11);d=c+F[a+16>>2]|0;g=d+i|0;j=b&3;D[g|0]=j|G[g|0]&252;g=Ye(i);d=d-(i>>>3|0)|0;j=G[j+74693|0];D[d+7|0]=g&G[d+7|0]|(j&1)<>>1<>2]|0;g=d+i|0;j=b>>>2&3;D[g|0]=G[g|0]&243|j<<2;g=i+4|0;d=d-(g>>>3|0)|0;l=16<>>1<>2]|0;g=d+i|0;l=b>>>4&3;D[g|0]=G[g|0]&207|l<<4;g=i&7;j=Ye(g);d=d-(i+8>>>3|0)|0;l=G[l+74693|0];D[d+7|0]=j&G[d+7|0]|(l&1)<>>1<>2]|0;g=d+i|0;D[g|0]=G[g|0]&63|b&192;g=i+12|0;d=d-(g>>>3|0)|0;g=g&7;j=Ye(g);b=G[(b>>>6&3)+74693|0];D[d+7|0]=j&G[d+7|0]|(b&1)<>>1<>2]|0);i=1;f=f+1|0;if((f|0)!=(e|0)){continue}break}break t}if(!bb(h+216|0,h+16|0)|!F[h+20>>2]&e>>>0>=2){break t}f=0;F[h+12>>2]=0;if(!e){break u}while(1){i=0;w:{if(!f){while(1){g=(h+12|0)+i|0;b=F[h+236>>2];x:{if(b>>>0>=8){d=b;b=F[h+232>>2];break x}c=0;d=F[h+220>>2];if(d>>>0>2]){F[h+220>>2]=d+1;c=G[d|0]}d=b+8|0;b=F[h+232>>2]|c<>2]=d-8;F[h+232>>2]=b>>>8;c=F[a+16>>2];d=c+i|0;g=b&3;D[d|0]=g|G[d|0]&252;d=Ye(i);c=c-(i>>>3|0)|0;g=G[g+74693|0];D[c+7|0]=d&G[c+7|0]|(g&1)<>>1<>2];d=c+i|0;g=b>>>2&3;D[d|0]=G[d|0]&243|g<<2;d=i+4|0;c=c-(d>>>3|0)|0;j=16<>>1<>2];d=c+i|0;j=b>>>4&3;D[d|0]=G[d|0]&207|j<<4;d=i&7;g=Ye(d);c=c-(i+8>>>3|0)|0;j=G[j+74693|0];D[c+7|0]=g&G[c+7|0]|(j&1)<>>1<>2];d=c+i|0;D[d|0]=G[d|0]&63|b&192;d=i+12|0;c=c-(d>>>3|0)|0;d=d&7;g=Ye(d);b=G[(b>>>6&3)+74693|0];D[c+7|0]=g&G[c+7|0]|(b&1)<>>1<>2];break w}while(1){g=0;j=10;b=F[h+236>>2];y:{if(b>>>0>=16){l=F[h+232>>2];break y}l=F[h+232>>2];d=F[h+220>>2];k=F[h+228>>2];z:{if(d>>>0>=k>>>0){c=d;break z}c=d+1|0;F[h+220>>2]=c;g=G[d|0]}d=b+8|0;F[h+236>>2]=d;l=l|g<>2]=l;if(b>>>0>7){b=d;break y}g=0;if(c>>>0>>0){F[h+220>>2]=c+1;g=G[c|0]}b=b+16|0;F[h+236>>2]=b;l=g<>2]=l}g=F[F[h+28>>2]+((l&1023)<<2)>>2];A:{if((g|0)<0){c=F[h+40>>2];while(1){d=l>>>j|0;j=j+1|0;g=E[c+((d&1)+(g^-1)<<1)>>1];if((g|0)<0){continue}break}break A}j=g>>>16|0;g=g&65535}F[h+236>>2]=b-j;F[h+232>>2]=l>>>j;c=(h+12|0)+i|0;b=G[c|0]^g;D[c|0]=b;c=L(f,11);d=c+F[a+16>>2]|0;g=d+i|0;j=b&3;D[g|0]=j|G[g|0]&252;g=Ye(i);d=d-(i>>>3|0)|0;j=G[j+74693|0];D[d+7|0]=g&G[d+7|0]|(j&1)<>>1<>2]|0;g=d+i|0;j=b>>>2&3;D[g|0]=G[g|0]&243|j<<2;g=i+4|0;d=d-(g>>>3|0)|0;l=16<>>1<>2]|0;g=d+i|0;l=b>>>4&3;D[g|0]=G[g|0]&207|l<<4;g=i&7;j=Ye(g);d=d-(i+8>>>3|0)|0;l=G[l+74693|0];D[d+7|0]=j&G[d+7|0]|(l&1)<>>1<>2]|0;g=d+i|0;D[g|0]=G[g|0]&63|b&192;g=i+12|0;d=d-(g>>>3|0)|0;g=g&7;j=Ye(g);b=G[(b>>>6&3)+74693|0];D[d+7|0]=j&G[d+7|0]|(b&1)<>>1<>2]|0}dc(b);f=f+1|0;if((f|0)!=(e|0)){continue}break}}i=1}a=F[h+40>>2];if(a){Ra(a)}a=F[h+28>>2];if(a){Ra(a)}a=F[h+16>>2];if(a){Ra(a)}}a=F[h+80>>2];if(a){Ra(a)}a=F[h+68>>2];if(a){Ra(a)}a=F[h+56>>2];if(a){Ra(a)}a=F[h+120>>2];if(a){Ra(a)}a=F[h+108>>2];if(a){Ra(a)}a=F[h+96>>2];if(a){Ra(a)}a=F[h+160>>2];if(a){Ra(a)}a=F[h+148>>2];if(a){Ra(a)}a=F[h+136>>2];if(a){Ra(a)}a=F[h+200>>2];if(a){Ra(a)}a=F[h+188>>2];if(a){Ra(a)}a=F[h+176>>2];if(!a){break a}Ra(a)}Ea=h+240|0;return i}function Jc(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,I=0,J=0,K=0,L=0,M=0,N=0,P=0,Q=0,R=0,S=0;m=Ea-32|0;Ea=m;j=-20;a:{if(d>>>0<10){break a}i=G[c+4|0]|G[c+5|0]<<8;f=G[c|0]|G[c+1|0]<<8;k=f+6|0;g=G[c+2|0]|G[c+3|0]<<8;u=i+(k+g|0)|0;if(u>>>0>d>>>0){break a}if(!f){j=-72;break a}h=c+6|0;Q=H[e+2>>1];b:{if(f>>>0>=4){j=-1;h=G[(f+h|0)-1|0];if(!h){break a}q=f+2|0;f=q+c|0;l=G[f|0]|G[f+1|0]<<8|(G[f+2|0]<<16|G[f+3|0]<<24);f=O(h)-23|0;break b}l=G[h|0];c:{switch(f-2|0){case 1:l=G[c+8|0]<<16|l;case 0:l=(G[c+7|0]<<8)+l|0;break;default:break c}}h=G[(f+h|0)-1|0];if(!h){break a}q=6;f=(O(h)-(f<<3)|0)+9|0}if(!g){j=-72;break a}w=c+k|0;d:{if(g>>>0>=4){j=-1;k=G[(g+w|0)-1|0];if(!k){break a}s=g-4|0;h=w+s|0;o=G[h|0]|G[h+1|0]<<8|(G[h+2|0]<<16|G[h+3|0]<<24);h=O(k)-23|0;break d}o=G[w|0];e:{switch(g-2|0){case 1:o=G[w+2|0]<<16|o;case 0:o=(G[w+1|0]<<8)+o|0;break;default:break e}}h=G[(g+w|0)-1|0];if(!h){j=-20;break a}h=(O(h)-(g<<3)|0)+9|0}j=-72;if(!i){break a}z=g+w|0;k=i+z|0;f:{if(i>>>0>=4){j=-1;x=G[k-1|0];if(!x){break a}t=i-4|0;g=z+t|0;y=G[g|0]|G[g+1|0]<<8|(G[g+2|0]<<16|G[g+3|0]<<24);g=O(x)-23|0;break f}y=G[z|0];g:{switch(i-2|0){case 1:y=G[z+2|0]<<16|y;case 0:y=(G[z+1|0]<<8)+y|0;break;default:break g}}g=G[k-1|0];if(!g){j=-20;break a}g=(O(g)-(i<<3)|0)+9|0}j=Kc(m+12|0,k,d-u|0);if(j>>>0>4294967176){break a}n=e+4|0;p=F[m+12>>2];d=b+3>>>2|0;u=d+a|0;x=d+u|0;C=d+x|0;K=a+b|0;L=K-3|0;h:{if(C>>>0>=L>>>0){k=C;i=x;d=u;break h}j=0-Q&31;v=F[m+20>>2];e=F[m+16>>2];R=F[m+28>>2];d=u;i=x;k=C;while(1){r=(l<>>j<<2)+n|0;A=H[r>>1];D[a|0]=A;D[a+1|0]=A>>>8;A=G[r+2|0];E=G[r+3|0];r=(o<>>j<<2)+n|0;B=H[r>>1];D[d|0]=B;D[d+1|0]=B>>>8;B=G[r+2|0];M=G[r+3|0];r=(y<>>j<<2)+n|0;J=H[r>>1];D[i|0]=J;D[i+1|0]=J>>>8;J=G[r+2|0];N=G[r+3|0];r=(p<>>j<<2)+n|0;I=H[r>>1];D[k|0]=I;D[k+1|0]=I>>>8;I=G[r+2|0];P=G[r+3|0];r=a+E|0;f=f+A|0;a=(l<>>j<<2)+n|0;A=H[a>>1];D[r|0]=A;D[r+1|0]=A>>>8;A=G[a+2|0];S=G[a+3|0];d=d+M|0;h=h+B|0;a=(o<>>j<<2)+n|0;E=H[a>>1];D[d|0]=E;D[d+1|0]=E>>>8;E=G[a+2|0];M=G[a+3|0];i=i+N|0;g=g+J|0;a=(y<>>j<<2)+n|0;B=H[a>>1];D[i|0]=B;D[i+1|0]=B>>>8;J=G[a+2|0];N=G[a+3|0];k=k+P|0;I=e+I|0;e=(p<>>j<<2)+n|0;a=H[e>>1];D[k|0]=a;D[k+1|0]=a>>>8;f=f+A|0;if((q|0)<10){A=3}else{q=q-(f>>>3|0)|0;a=q+c|0;l=G[a|0]|G[a+1|0]<<8|(G[a+2|0]<<16|G[a+3|0]<<24);f=f&7;A=0}P=G[e+3|0];e=G[e+2|0];h=h+E|0;E=3;if((s|0)<4){B=3}else{s=s-(h>>>3|0)|0;a=w+s|0;o=G[a|0]|G[a+1|0]<<8|(G[a+2|0]<<16|G[a+3|0]<<24);h=h&7;B=0}g=g+J|0;if((t|0)>=4){t=t-(g>>>3|0)|0;a=z+t|0;y=G[a|0]|G[a+1|0]<<8|(G[a+2|0]<<16|G[a+3|0]<<24);E=0;g=g&7}e=e+I|0;a=r+S|0;d=d+M|0;i=i+N|0;if(v>>>0>>0){r=3}else{v=v-(e>>>3|0)|0;p=G[v|0]|G[v+1|0]<<8|(G[v+2|0]<<16|G[v+3|0]<<24);e=e&7;r=0}k=k+P|0;if(!(r|(A|B|E))&L>>>0>k>>>0){continue}break}F[m+20>>2]=v;F[m+16>>2]=e}F[m+12>>2]=p;if(a>>>0>u>>>0){j=-20;break a}if(d>>>0>x>>>0){j=-20;break a}j=-20;if(i>>>0>C>>>0){break a}j=0-Q&31;i:{j:{if(f>>>0<=32){v=u-3|0;while(1){k:{if((q|0)>=10){l=f>>>3|0;p=0;e=f&7;break k}if((q|0)==6){p=u-2|0;q=6;e=f;break j}e=f>>>3|0;p=(q-e|0)<6;l=p?q-6|0:e;e=f-(l<<3)|0}q=q-l|0;f=q+c|0;l=G[f|0]|G[f+1|0]<<8|(G[f+2|0]<<16|G[f+3|0]<<24);if(!(!p&a>>>0>>0)){p=u-2|0;if(e>>>0<=32){break j}f=e;break i}f=(l<>>j<<2)+n|0;p=H[f>>1];D[a|0]=p;D[a+1|0]=p>>>8;a=G[f+3|0]+a|0;f=G[f+2|0]+e|0;e=(l<>>j<<2)+n|0;p=H[e>>1];D[a|0]=p;D[a+1|0]=p>>>8;a=a+G[e+3|0]|0;f=f+G[e+2|0]|0;if(f>>>0<=32){continue}break}}p=u-2|0;break i}while(1){l:{if((q|0)>=10){l=e>>>3|0;v=0;f=e&7;break l}if((q|0)==6){q=6;f=e;break i}f=e>>>3|0;v=(q-f|0)<6;l=v?q-6|0:f;f=e-(l<<3)|0}q=q-l|0;e=q+c|0;l=G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24);if(v|a>>>0>p>>>0){break i}e=(l<>>j<<2)+n|0;v=H[e>>1];D[a|0]=v;D[a+1|0]=v>>>8;a=G[e+3|0]+a|0;e=G[e+2|0]+f|0;if(e>>>0<=32){continue}break}f=e}if(a>>>0<=p>>>0){while(1){c=(l<>>j<<2)+n|0;e=H[c>>1];D[a|0]=e;D[a+1|0]=e>>>8;f=G[c+2|0]+f|0;a=G[c+3|0]+a|0;if(p>>>0>=a>>>0){continue}break}}m:{if(a>>>0>=u>>>0){break m}e=a;c=l<>>j|0;a=(c<<2)+n|0;D[e|0]=G[a|0];if(G[a+3|0]==1){f=G[a+2|0]+f|0;break m}if(f>>>0>31){break m}a=G[((c<<2)+n|0)+2|0]+f|0;f=a>>>0>=32?32:a}n:{o:{if(h>>>0<=32){u=x-3|0;while(1){p:{if((s|0)>=4){a=h>>>3|0;e=0;c=h&7;break p}if(!s){a=x-2|0;s=0;l=w;c=h;break o}a=h>>>3|0;e=(w+s|0)-a>>>0>>0;a=e?s:a;c=h-(a<<3)|0}s=s-a|0;l=w+s|0;o=G[l|0]|G[l+1|0]<<8|(G[l+2|0]<<16|G[l+3|0]<<24);if(!(!e&d>>>0>>0)){a=x-2|0;if(c>>>0<=32){break o}h=c;break n}a=(o<>>j<<2)+n|0;e=H[a>>1];D[d|0]=e;D[d+1|0]=e>>>8;d=G[a+3|0]+d|0;c=G[a+2|0]+c|0;a=(o<>>j<<2)+n|0;e=H[a>>1];D[d|0]=e;D[d+1|0]=e>>>8;d=d+G[a+3|0]|0;h=c+G[a+2|0]|0;if(h>>>0<=32){continue}break}}l=w+s|0;a=x-2|0;break n}while(1){q:{if((s|0)>=4){e=c>>>3|0;p=0;h=c&7;break q}if(!s){h=c;break n}e=c>>>3|0;p=l-e>>>0>>0;e=p?s:e;h=c-(e<<3)|0}s=s-e|0;l=w+s|0;o=G[l|0]|G[l+1|0]<<8|(G[l+2|0]<<16|G[l+3|0]<<24);if(p|a>>>0>>0){break n}c=(o<>>j<<2)+n|0;e=H[c>>1];D[d|0]=e;D[d+1|0]=e>>>8;d=G[c+3|0]+d|0;c=G[c+2|0]+h|0;if(c>>>0<=32){continue}break}h=c}if(a>>>0>=d>>>0){while(1){c=(o<>>j<<2)+n|0;e=H[c>>1];D[d|0]=e;D[d+1|0]=e>>>8;h=G[c+2|0]+h|0;d=G[c+3|0]+d|0;if(d>>>0<=a>>>0){continue}break}}r:{if(d>>>0>=x>>>0){break r}c=o<>>j|0;a=(c<<2)+n|0;D[d|0]=G[a|0];if(G[a+3|0]==1){h=G[a+2|0]+h|0;break r}if(h>>>0>31){break r}a=G[((c<<2)+n|0)+2|0]+h|0;h=a>>>0>=32?32:a}s:{t:{if(g>>>0<=32){u=C-3|0;while(1){u:{if((t|0)>=4){a=g>>>3|0;e=0;c=g&7;break u}if(!t){a=C-2|0;t=0;o=z;c=g;break t}a=g>>>3|0;e=(t+z|0)-a>>>0>>0;a=e?t:a;c=g-(a<<3)|0}t=t-a|0;o=z+t|0;y=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);if(!(!e&i>>>0>>0)){a=C-2|0;if(c>>>0<=32){break t}g=c;break s}a=(y<>>j<<2)+n|0;d=H[a>>1];D[i|0]=d;D[i+1|0]=d>>>8;d=G[a+3|0]+i|0;c=G[a+2|0]+c|0;a=(y<>>j<<2)+n|0;e=H[a>>1];D[d|0]=e;D[d+1|0]=e>>>8;i=d+G[a+3|0]|0;g=c+G[a+2|0]|0;if(g>>>0<=32){continue}break}}o=t+z|0;a=C-2|0;break s}while(1){v:{if((t|0)>=4){e=c>>>3|0;d=0;g=c&7;break v}if(!t){g=c;break s}e=c>>>3|0;d=o-e>>>0>>0;e=d?t:e;g=c-(e<<3)|0}t=t-e|0;o=z+t|0;y=G[o|0]|G[o+1|0]<<8|(G[o+2|0]<<16|G[o+3|0]<<24);if(d|a>>>0>>0){break s}c=(y<>>j<<2)+n|0;d=H[c>>1];D[i|0]=d;D[i+1|0]=d>>>8;i=G[c+3|0]+i|0;c=G[c+2|0]+g|0;if(c>>>0<=32){continue}break}g=c}if(a>>>0>=i>>>0){while(1){c=(y<>>j<<2)+n|0;d=H[c>>1];D[i|0]=d;D[i+1|0]=d>>>8;g=G[c+2|0]+g|0;i=G[c+3|0]+i|0;if(i>>>0<=a>>>0){continue}break}}w:{if(i>>>0>=C>>>0){break w}c=y<>>j|0;a=(c<<2)+n|0;D[i|0]=G[a|0];if(G[a+3|0]==1){g=G[a+2|0]+g|0;break w}if(g>>>0>31){break w}a=G[((c<<2)+n|0)+2|0]+g|0;g=a>>>0>=32?32:a}c=F[m+16>>2];x:{if(c>>>0<=32){while(1){y:{a=F[m+20>>2];u=F[m+28>>2];z:{A:{if(a>>>0>=u>>>0){a=a-(c>>>3|0)|0;F[m+20>>2]=a;d=0;c=c&7;break A}e=F[m+24>>2];if((e|0)==(a|0)){e=K-2|0;break z}i=c>>>3|0;d=e>>>0>a-i>>>0;e=d?a-e|0:i;a=a-e|0;F[m+20>>2]=a;c=c-(e<<3)|0}F[m+16>>2]=c;e=G[a|0]|G[a+1|0]<<8|(G[a+2|0]<<16|G[a+3|0]<<24);F[m+12>>2]=e;if(!d&k>>>0>>0){break y}e=K-2|0;if(c>>>0>32){break x}}while(1){B:{if(a>>>0>=u>>>0){a=a-(c>>>3|0)|0;F[m+20>>2]=a;d=0;c=c&7;break B}i=F[m+24>>2];if((i|0)==(a|0)){break x}x=c>>>3|0;d=i>>>0>a-x>>>0;i=d?a-i|0:x;a=a-i|0;F[m+20>>2]=a;c=c-(i<<3)|0}F[m+16>>2]=c;i=G[a|0]|G[a+1|0]<<8|(G[a+2|0]<<16|G[a+3|0]<<24);F[m+12>>2]=i;if(d|e>>>0>>0){break x}d=(i<>>j<<2)+n|0;i=H[d>>1];D[k|0]=i;D[k+1|0]=i>>>8;c=G[d+2|0]+c|0;F[m+16>>2]=c;k=G[d+3|0]+k|0;if(c>>>0<=32){continue}break}break x}a=(e<>>j<<2)+n|0;d=H[a>>1];D[k|0]=d;D[k+1|0]=d>>>8;d=G[a+3|0]+k|0;c=G[a+2|0]+c|0;a=(e<>>j<<2)+n|0;e=H[a>>1];D[d|0]=e;D[d+1|0]=e>>>8;c=c+G[a+2|0]|0;F[m+16>>2]=c;k=d+G[a+3|0]|0;if(c>>>0<=32){continue}break}}e=K-2|0}if(e>>>0>=k>>>0){while(1){a=(F[m+12>>2]<>>j<<2)+n|0;c=H[a>>1];D[k|0]=c;D[k+1|0]=c>>>8;c=F[m+16>>2]+G[a+2|0]|0;F[m+16>>2]=c;k=G[a+3|0]+k|0;if(k>>>0<=e>>>0){continue}break}}C:{if(k>>>0>=K>>>0){break C}d=F[m+12>>2]<>>j|0;a=(d<<2)+n|0;D[k|0]=G[a|0];if(G[a+3|0]==1){c=F[m+16>>2]+G[a+2|0]|0;break C}c=F[m+16>>2];if(c>>>0>31){break C}a=G[((d<<2)+n|0)+2|0]+c|0;c=a>>>0>=32?32:a}j=(q|0)!=6?-20:(f|0)!=32?-20:(l|0)!=(w|0)?-20:(h|0)!=32?-20:(o|0)!=(z|0)?-20:(g|0)!=32?-20:F[m+20>>2]!=F[m+24>>2]?-20:(c|0)!=32?-20:b}Ea=m+32|0;return j}function Pb(a,b,c,d,e,f,g,h){var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;n=-70;m=F[c+4>>2];j=F[c>>2];p=m+j|0;a:{if(p>>>0>b-a>>>0){break a}n=-20;i=F[d>>2];if(j>>>0>e-i>>>0){break a}e=b-32|0;r=i+j|0;b=a+j|0;o=F[c+8>>2];b:{if((j|0)<=7){if((j|0)<=0){break b}while(1){D[a|0]=G[i|0];i=i+1|0;a=a+1|0;if(b>>>0>a>>>0){continue}break}break b}if(b>>>0<=e>>>0){k=G[i+4|0]|G[i+5|0]<<8|(G[i+6|0]<<16|G[i+7|0]<<24);l=G[i|0]|G[i+1|0]<<8|(G[i+2|0]<<16|G[i+3|0]<<24);D[a|0]=l;D[a+1|0]=l>>>8;D[a+2|0]=l>>>16;D[a+3|0]=l>>>24;D[a+4|0]=k;D[a+5|0]=k>>>8;D[a+6|0]=k>>>16;D[a+7|0]=k>>>24;k=G[i+12|0]|G[i+13|0]<<8|(G[i+14|0]<<16|G[i+15|0]<<24);l=G[i+8|0]|G[i+9|0]<<8|(G[i+10|0]<<16|G[i+11|0]<<24);D[a+8|0]=l;D[a+9|0]=l>>>8;D[a+10|0]=l>>>16;D[a+11|0]=l>>>24;D[a+12|0]=k;D[a+13|0]=k>>>8;D[a+14|0]=k>>>16;D[a+15|0]=k>>>24;if(j>>>0<17){break b}a=a+16|0;while(1){j=G[i+20|0]|G[i+21|0]<<8|(G[i+22|0]<<16|G[i+23|0]<<24);k=G[i+16|0]|G[i+17|0]<<8|(G[i+18|0]<<16|G[i+19|0]<<24);D[a|0]=k;D[a+1|0]=k>>>8;D[a+2|0]=k>>>16;D[a+3|0]=k>>>24;D[a+4|0]=j;D[a+5|0]=j>>>8;D[a+6|0]=j>>>16;D[a+7|0]=j>>>24;j=G[i+28|0]|G[i+29|0]<<8|(G[i+30|0]<<16|G[i+31|0]<<24);k=G[i+24|0]|G[i+25|0]<<8|(G[i+26|0]<<16|G[i+27|0]<<24);D[a+8|0]=k;D[a+9|0]=k>>>8;D[a+10|0]=k>>>16;D[a+11|0]=k>>>24;D[a+12|0]=j;D[a+13|0]=j>>>8;D[a+14|0]=j>>>16;D[a+15|0]=j>>>24;j=G[i+36|0]|G[i+37|0]<<8|(G[i+38|0]<<16|G[i+39|0]<<24);k=G[i+32|0]|G[i+33|0]<<8|(G[i+34|0]<<16|G[i+35|0]<<24);D[a+16|0]=k;D[a+17|0]=k>>>8;D[a+18|0]=k>>>16;D[a+19|0]=k>>>24;D[a+20|0]=j;D[a+21|0]=j>>>8;D[a+22|0]=j>>>16;D[a+23|0]=j>>>24;j=G[i+44|0]|G[i+45|0]<<8|(G[i+46|0]<<16|G[i+47|0]<<24);k=G[i+40|0]|G[i+41|0]<<8|(G[i+42|0]<<16|G[i+43|0]<<24);D[a+24|0]=k;D[a+25|0]=k>>>8;D[a+26|0]=k>>>16;D[a+27|0]=k>>>24;D[a+28|0]=j;D[a+29|0]=j>>>8;D[a+30|0]=j>>>16;D[a+31|0]=j>>>24;i=i+32|0;a=a+32|0;if(b>>>0>a>>>0){continue}break}break b}if(a>>>0<=e>>>0){j=G[i+4|0]|G[i+5|0]<<8|(G[i+6|0]<<16|G[i+7|0]<<24);k=G[i|0]|G[i+1|0]<<8|(G[i+2|0]<<16|G[i+3|0]<<24);D[a|0]=k;D[a+1|0]=k>>>8;D[a+2|0]=k>>>16;D[a+3|0]=k>>>24;D[a+4|0]=j;D[a+5|0]=j>>>8;D[a+6|0]=j>>>16;D[a+7|0]=j>>>24;j=G[i+12|0]|G[i+13|0]<<8|(G[i+14|0]<<16|G[i+15|0]<<24);k=G[i+8|0]|G[i+9|0]<<8|(G[i+10|0]<<16|G[i+11|0]<<24);D[a+8|0]=k;D[a+9|0]=k>>>8;D[a+10|0]=k>>>16;D[a+11|0]=k>>>24;D[a+12|0]=j;D[a+13|0]=j>>>8;D[a+14|0]=j>>>16;D[a+15|0]=j>>>24;q=e-a|0;if((q|0)>=17){a=a+16|0;j=i;while(1){k=G[j+20|0]|G[j+21|0]<<8|(G[j+22|0]<<16|G[j+23|0]<<24);l=G[j+16|0]|G[j+17|0]<<8|(G[j+18|0]<<16|G[j+19|0]<<24);D[a|0]=l;D[a+1|0]=l>>>8;D[a+2|0]=l>>>16;D[a+3|0]=l>>>24;D[a+4|0]=k;D[a+5|0]=k>>>8;D[a+6|0]=k>>>16;D[a+7|0]=k>>>24;k=G[j+28|0]|G[j+29|0]<<8|(G[j+30|0]<<16|G[j+31|0]<<24);l=G[j+24|0]|G[j+25|0]<<8|(G[j+26|0]<<16|G[j+27|0]<<24);D[a+8|0]=l;D[a+9|0]=l>>>8;D[a+10|0]=l>>>16;D[a+11|0]=l>>>24;D[a+12|0]=k;D[a+13|0]=k>>>8;D[a+14|0]=k>>>16;D[a+15|0]=k>>>24;k=G[j+36|0]|G[j+37|0]<<8|(G[j+38|0]<<16|G[j+39|0]<<24);l=G[j+32|0]|G[j+33|0]<<8|(G[j+34|0]<<16|G[j+35|0]<<24);D[a+16|0]=l;D[a+17|0]=l>>>8;D[a+18|0]=l>>>16;D[a+19|0]=l>>>24;D[a+20|0]=k;D[a+21|0]=k>>>8;D[a+22|0]=k>>>16;D[a+23|0]=k>>>24;k=G[j+44|0]|G[j+45|0]<<8|(G[j+46|0]<<16|G[j+47|0]<<24);l=G[j+40|0]|G[j+41|0]<<8|(G[j+42|0]<<16|G[j+43|0]<<24);D[a+24|0]=l;D[a+25|0]=l>>>8;D[a+26|0]=l>>>16;D[a+27|0]=l>>>24;D[a+28|0]=k;D[a+29|0]=k>>>8;D[a+30|0]=k>>>16;D[a+31|0]=k>>>24;j=j+32|0;a=a+32|0;if(e>>>0>a>>>0){continue}break}}i=i+q|0;a=e}if(a>>>0>=b>>>0){break b}while(1){D[a|0]=G[i|0];i=i+1|0;a=a+1|0;if(b>>>0>a>>>0){continue}break}}a=b-o|0;F[d>>2]=r;c:{d:{if(b-f>>>0>>0){if(b-g>>>0>>0){break a}a=a-f|0;d=a+h|0;if(d+m>>>0<=h>>>0){db(b,d,m);break c}b=db(b,d,0-a|0);m=a+m|0;F[c+4>>2]=m;b=b-a|0;break d}f=a}c=b+m|0;if((m|0)<=7){if((m|0)<=0){break c}while(1){D[b|0]=G[f|0];f=f+1|0;b=b+1|0;if(c>>>0>b>>>0){continue}break}break c}a=b-f|0;e:{if(a>>>0<=7){D[b|0]=G[f|0];D[b+1|0]=G[f+1|0];D[b+2|0]=G[f+2|0];D[b+3|0]=G[f+3|0];d=f;f=a<<2;a=d+F[f+403152>>2]|0;d=G[a|0]|G[a+1|0]<<8|(G[a+2|0]<<16|G[a+3|0]<<24);D[b+4|0]=d;D[b+5|0]=d>>>8;D[b+6|0]=d>>>16;D[b+7|0]=d>>>24;f=a-F[f+403184>>2]|0;break e}a=G[f+4|0]|G[f+5|0]<<8|(G[f+6|0]<<16|G[f+7|0]<<24);d=G[f|0]|G[f+1|0]<<8|(G[f+2|0]<<16|G[f+3|0]<<24);D[b|0]=d;D[b+1|0]=d>>>8;D[b+2|0]=d>>>16;D[b+3|0]=d>>>24;D[b+4|0]=a;D[b+5|0]=a>>>8;D[b+6|0]=a>>>16;D[b+7|0]=a>>>24}a=b+8|0;i=f+8|0;if(c>>>0<=e>>>0){e=a+m|0;if((a-i|0)<=15){while(1){b=G[i+4|0]|G[i+5|0]<<8|(G[i+6|0]<<16|G[i+7|0]<<24);c=G[i|0]|G[i+1|0]<<8|(G[i+2|0]<<16|G[i+3|0]<<24);D[a|0]=c;D[a+1|0]=c>>>8;D[a+2|0]=c>>>16;D[a+3|0]=c>>>24;D[a+4|0]=b;D[a+5|0]=b>>>8;D[a+6|0]=b>>>16;D[a+7|0]=b>>>24;i=i+8|0;a=a+8|0;if(e>>>0>a>>>0){continue}break c}}c=G[i+4|0]|G[i+5|0]<<8|(G[i+6|0]<<16|G[i+7|0]<<24);d=G[i|0]|G[i+1|0]<<8|(G[i+2|0]<<16|G[i+3|0]<<24);D[a|0]=d;D[a+1|0]=d>>>8;D[a+2|0]=d>>>16;D[a+3|0]=d>>>24;D[a+4|0]=c;D[a+5|0]=c>>>8;D[a+6|0]=c>>>16;D[a+7|0]=c>>>24;c=G[i+12|0]|G[i+13|0]<<8|(G[i+14|0]<<16|G[i+15|0]<<24);d=G[i+8|0]|G[i+9|0]<<8|(G[i+10|0]<<16|G[i+11|0]<<24);D[a+8|0]=d;D[a+9|0]=d>>>8;D[a+10|0]=d>>>16;D[a+11|0]=d>>>24;D[a+12|0]=c;D[a+13|0]=c>>>8;D[a+14|0]=c>>>16;D[a+15|0]=c>>>24;if(m>>>0<17){break c}a=b+24|0;while(1){b=G[i+20|0]|G[i+21|0]<<8|(G[i+22|0]<<16|G[i+23|0]<<24);c=G[i+16|0]|G[i+17|0]<<8|(G[i+18|0]<<16|G[i+19|0]<<24);D[a|0]=c;D[a+1|0]=c>>>8;D[a+2|0]=c>>>16;D[a+3|0]=c>>>24;D[a+4|0]=b;D[a+5|0]=b>>>8;D[a+6|0]=b>>>16;D[a+7|0]=b>>>24;b=G[i+28|0]|G[i+29|0]<<8|(G[i+30|0]<<16|G[i+31|0]<<24);c=G[i+24|0]|G[i+25|0]<<8|(G[i+26|0]<<16|G[i+27|0]<<24);D[a+8|0]=c;D[a+9|0]=c>>>8;D[a+10|0]=c>>>16;D[a+11|0]=c>>>24;D[a+12|0]=b;D[a+13|0]=b>>>8;D[a+14|0]=b>>>16;D[a+15|0]=b>>>24;b=G[i+36|0]|G[i+37|0]<<8|(G[i+38|0]<<16|G[i+39|0]<<24);c=G[i+32|0]|G[i+33|0]<<8|(G[i+34|0]<<16|G[i+35|0]<<24);D[a+16|0]=c;D[a+17|0]=c>>>8;D[a+18|0]=c>>>16;D[a+19|0]=c>>>24;D[a+20|0]=b;D[a+21|0]=b>>>8;D[a+22|0]=b>>>16;D[a+23|0]=b>>>24;b=G[i+44|0]|G[i+45|0]<<8|(G[i+46|0]<<16|G[i+47|0]<<24);c=G[i+40|0]|G[i+41|0]<<8|(G[i+42|0]<<16|G[i+43|0]<<24);D[a+24|0]=c;D[a+25|0]=c>>>8;D[a+26|0]=c>>>16;D[a+27|0]=c>>>24;D[a+28|0]=b;D[a+29|0]=b>>>8;D[a+30|0]=b>>>16;D[a+31|0]=b>>>24;i=i+32|0;a=a+32|0;if(e>>>0>a>>>0){continue}break}break c}f:{if(a>>>0>e>>>0){e=a;break f}g=e-a|0;g:{if((a-i|0)<=15){b=i;while(1){d=G[b+4|0]|G[b+5|0]<<8|(G[b+6|0]<<16|G[b+7|0]<<24);f=G[b|0]|G[b+1|0]<<8|(G[b+2|0]<<16|G[b+3|0]<<24);D[a|0]=f;D[a+1|0]=f>>>8;D[a+2|0]=f>>>16;D[a+3|0]=f>>>24;D[a+4|0]=d;D[a+5|0]=d>>>8;D[a+6|0]=d>>>16;D[a+7|0]=d>>>24;b=b+8|0;a=a+8|0;if(e>>>0>a>>>0){continue}break}break g}d=G[i+4|0]|G[i+5|0]<<8|(G[i+6|0]<<16|G[i+7|0]<<24);f=G[i|0]|G[i+1|0]<<8|(G[i+2|0]<<16|G[i+3|0]<<24);D[a|0]=f;D[a+1|0]=f>>>8;D[a+2|0]=f>>>16;D[a+3|0]=f>>>24;D[a+4|0]=d;D[a+5|0]=d>>>8;D[a+6|0]=d>>>16;D[a+7|0]=d>>>24;d=G[i+12|0]|G[i+13|0]<<8|(G[i+14|0]<<16|G[i+15|0]<<24);f=G[i+8|0]|G[i+9|0]<<8|(G[i+10|0]<<16|G[i+11|0]<<24);D[a+8|0]=f;D[a+9|0]=f>>>8;D[a+10|0]=f>>>16;D[a+11|0]=f>>>24;D[a+12|0]=d;D[a+13|0]=d>>>8;D[a+14|0]=d>>>16;D[a+15|0]=d>>>24;if((g|0)<17){break g}a=b+24|0;b=i;while(1){d=G[b+20|0]|G[b+21|0]<<8|(G[b+22|0]<<16|G[b+23|0]<<24);f=G[b+16|0]|G[b+17|0]<<8|(G[b+18|0]<<16|G[b+19|0]<<24);D[a|0]=f;D[a+1|0]=f>>>8;D[a+2|0]=f>>>16;D[a+3|0]=f>>>24;D[a+4|0]=d;D[a+5|0]=d>>>8;D[a+6|0]=d>>>16;D[a+7|0]=d>>>24;d=G[b+28|0]|G[b+29|0]<<8|(G[b+30|0]<<16|G[b+31|0]<<24);f=G[b+24|0]|G[b+25|0]<<8|(G[b+26|0]<<16|G[b+27|0]<<24);D[a+8|0]=f;D[a+9|0]=f>>>8;D[a+10|0]=f>>>16;D[a+11|0]=f>>>24;D[a+12|0]=d;D[a+13|0]=d>>>8;D[a+14|0]=d>>>16;D[a+15|0]=d>>>24;d=G[b+36|0]|G[b+37|0]<<8|(G[b+38|0]<<16|G[b+39|0]<<24);f=G[b+32|0]|G[b+33|0]<<8|(G[b+34|0]<<16|G[b+35|0]<<24);D[a+16|0]=f;D[a+17|0]=f>>>8;D[a+18|0]=f>>>16;D[a+19|0]=f>>>24;D[a+20|0]=d;D[a+21|0]=d>>>8;D[a+22|0]=d>>>16;D[a+23|0]=d>>>24;d=G[b+44|0]|G[b+45|0]<<8|(G[b+46|0]<<16|G[b+47|0]<<24);f=G[b+40|0]|G[b+41|0]<<8|(G[b+42|0]<<16|G[b+43|0]<<24);D[a+24|0]=f;D[a+25|0]=f>>>8;D[a+26|0]=f>>>16;D[a+27|0]=f>>>24;D[a+28|0]=d;D[a+29|0]=d>>>8;D[a+30|0]=d>>>16;D[a+31|0]=d>>>24;b=b+32|0;a=a+32|0;if(e>>>0>a>>>0){continue}break}}i=g+i|0}if(c>>>0<=e>>>0){break c}while(1){D[e|0]=G[i|0];i=i+1|0;e=e+1|0;if(c>>>0>e>>>0){continue}break}}n=p}return n}function Lc(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,I=0,J=0,K=0,L=0,M=0,N=0;l=Ea-32|0;Ea=l;f=-20;a:{if(d>>>0<10){break a}g=G[c+4|0]|G[c+5|0]<<8;h=G[c|0]|G[c+1|0]<<8;m=h+6|0;j=G[c+2|0]|G[c+3|0]<<8;s=g+(m+j|0)|0;if(s>>>0>d>>>0){break a}if(!h){f=-72;break a}k=c+6|0;A=H[e+2>>1];b:{if(h>>>0>=4){f=-1;k=G[(h+k|0)-1|0];if(!k){break a}o=h+2|0;f=o+c|0;i=G[f|0]|G[f+1|0]<<8|(G[f+2|0]<<16|G[f+3|0]<<24);h=O(k)-23|0;break b}i=G[k|0];c:{switch(h-2|0){case 1:i=G[c+8|0]<<16|i;case 0:i=(G[c+7|0]<<8)+i|0;break;default:break c}}f=G[(h+k|0)-1|0];if(!f){f=-20;break a}o=6;h=(O(f)-(h<<3)|0)+9|0}if(!j){f=-72;break a}u=c+m|0;d:{if(j>>>0>=4){f=-1;k=G[(j+u|0)-1|0];if(!k){break a}q=j-4|0;f=u+q|0;x=G[f|0]|G[f+1|0]<<8|(G[f+2|0]<<16|G[f+3|0]<<24);k=O(k)-23|0;break d}x=G[u|0];e:{switch(j-2|0){case 1:x=G[u+2|0]<<16|x;case 0:x=(G[u+1|0]<<8)+x|0;break;default:break e}}f=G[(j+u|0)-1|0];if(!f){f=-20;break a}k=(O(f)-(j<<3)|0)+9|0}f=-72;if(!g){break a}w=j+u|0;m=g+w|0;f:{if(g>>>0>=4){f=-1;j=G[m-1|0];if(!j){break a}r=g-4|0;f=w+r|0;y=G[f|0]|G[f+1|0]<<8|(G[f+2|0]<<16|G[f+3|0]<<24);j=O(j)-23|0;break f}y=G[w|0];g:{switch(g-2|0){case 1:y=G[w+2|0]<<16|y;case 0:y=(G[w+1|0]<<8)+y|0;break;default:break g}}f=G[m-1|0];if(!f){f=-20;break a}j=(O(f)-(g<<3)|0)+9|0}f=Kc(l+12|0,m,d-s|0);if(f>>>0>4294967176){break a}n=e+4|0;t=F[l+12>>2];d=b+3>>>2|0;s=d+a|0;v=d+s|0;B=v+d|0;J=a+b|0;K=J-3|0;h:{if(B>>>0>=K>>>0){m=B;e=v;g=s;break h}f=0-A&31;z=F[l+20>>2];d=F[l+16>>2];M=F[l+28>>2];g=s;e=v;m=B;while(1){p=(i<>>f<<1)+n|0;E=G[p+1|0];D[a|0]=G[p|0];p=(x<>>f<<1)+n|0;I=G[p+1|0];D[g|0]=G[p|0];p=(y<>>f<<1)+n|0;L=G[p+1|0];D[e|0]=G[p|0];p=(t<>>f<<1)+n|0;C=G[p+1|0];D[m|0]=G[p|0];h=h+E|0;p=(i<>>f<<1)+n|0;E=G[p+1|0];D[a+1|0]=G[p|0];k=k+I|0;p=(x<>>f<<1)+n|0;I=G[p+1|0];D[g+1|0]=G[p|0];j=j+L|0;p=(y<>>f<<1)+n|0;L=G[p+1|0];D[e+1|0]=G[p|0];C=d+C|0;d=(t<>>f<<1)+n|0;N=G[d+1|0];D[m+1|0]=G[d|0];h=h+E|0;if((o|0)<10){p=3}else{o=o-(h>>>3|0)|0;d=o+c|0;i=G[d|0]|G[d+1|0]<<8|(G[d+2|0]<<16|G[d+3|0]<<24);h=h&7;p=0}k=k+I|0;E=3;if((q|0)<4){I=3}else{q=q-(k>>>3|0)|0;d=u+q|0;x=G[d|0]|G[d+1|0]<<8|(G[d+2|0]<<16|G[d+3|0]<<24);k=k&7;I=0}j=j+L|0;if((r|0)>=4){r=r-(j>>>3|0)|0;d=w+r|0;y=G[d|0]|G[d+1|0]<<8|(G[d+2|0]<<16|G[d+3|0]<<24);E=0;j=j&7}d=C+N|0;e=e+2|0;g=g+2|0;a=a+2|0;if(z>>>0>>0){C=3}else{z=z-(d>>>3|0)|0;t=G[z|0]|G[z+1|0]<<8|(G[z+2|0]<<16|G[z+3|0]<<24);d=d&7;C=0}m=m+2|0;if(!(C|(p|I|E))&K>>>0>m>>>0){continue}break}F[l+20>>2]=z;F[l+16>>2]=d}F[l+12>>2]=t;if(a>>>0>s>>>0){f=-20;break a}if(g>>>0>v>>>0){f=-20;break a}f=-20;if(e>>>0>B>>>0){break a}i:{j:{k:{if(h>>>0>=33){f=0-A&31;break k}z=s-3|0;f=0-A&31;l:{m:{while(1){n:{if((o|0)>=10){i=h>>>3|0;t=0;d=h&7;break n}if((o|0)==6){d=h;o=6;break m}d=h>>>3|0;t=(o-d|0)<6;i=t?o-6|0:d;d=h-(i<<3)|0}o=o-i|0;h=o+c|0;i=G[h|0]|G[h+1|0]<<8|(G[h+2|0]<<16|G[h+3|0]<<24);if(!(t|a>>>0>=z>>>0)){h=(i<>>f<<1)+n|0;t=G[h+1|0];D[a|0]=G[h|0];d=d+t|0;h=(i<>>f<<1)+n|0;t=G[h+1|0];D[a+1|0]=G[h|0];a=a+2|0;h=d+t|0;if(h>>>0<=32){continue}break k}break}if(d>>>0>32){break l}}while(1){o:{if((o|0)>=10){i=d>>>3|0;t=0;h=d&7;break o}if((o|0)==6){o=6;break l}h=d>>>3|0;t=(o-h|0)<6;i=t?o-6|0:h;h=d-(i<<3)|0}o=o-i|0;d=o+c|0;i=G[d|0]|G[d+1|0]<<8|(G[d+2|0]<<16|G[d+3|0]<<24);d=a>>>0>=s>>>0;if(d|t){if(d){break i}break j}d=(i<>>f<<1)+n|0;t=G[d+1|0];D[a|0]=G[d|0];a=a+1|0;d=h+t|0;if(d>>>0<=32){continue}break}}h=d}if(a>>>0>=s>>>0){break i}}while(1){c=(i<>>f<<1)+n|0;d=G[c+1|0];D[a|0]=G[c|0];h=d+h|0;a=a+1|0;if(s>>>0>a>>>0){continue}break}}p:{q:{r:{if(k>>>0>=33){c=0-A&31;d=u+q|0;break r}s=v-3|0;c=0-A&31;s:{t:{u:{while(1){v:{if((q|0)>=4){a=k>>>3|0;i=0;f=k&7;break v}if(!q){q=0;d=u;f=k;break t}a=k>>>3|0;i=(u+q|0)-a>>>0>>0;a=i?q:a;f=k-(a<<3)|0}q=q-a|0;d=u+q|0;x=G[d|0]|G[d+1|0]<<8|(G[d+2|0]<<16|G[d+3|0]<<24);if(i|g>>>0>=s>>>0){break u}a=(x<>>c<<1)+n|0;d=G[a+1|0];D[g|0]=G[a|0];a=d+f|0;d=(x<>>c<<1)+n|0;f=G[d+1|0];D[g+1|0]=G[d|0];g=g+2|0;k=a+f|0;if(k>>>0<33){continue}break}d=u+q|0;break r}if(f>>>0>32){break s}}while(1){w:{if((q|0)>=4){a=f>>>3|0;i=0;k=f&7;break w}if(!q){break s}a=f>>>3|0;i=d-a>>>0>>0;a=i?q:a;k=f-(a<<3)|0}q=q-a|0;d=u+q|0;x=G[d|0]|G[d+1|0]<<8|(G[d+2|0]<<16|G[d+3|0]<<24);a=g>>>0>=v>>>0;if(a|i){if(a){break p}break q}a=(x<>>c<<1)+n|0;f=G[a+1|0];D[g|0]=G[a|0];g=g+1|0;f=f+k|0;if(f>>>0<=32){continue}break}}k=f}if(g>>>0>=v>>>0){break p}}while(1){a=(x<>>c<<1)+n|0;f=G[a+1|0];D[g|0]=G[a|0];k=f+k|0;g=g+1|0;if(v>>>0>g>>>0){continue}break}}x:{y:{z:{if(j>>>0>=33){c=0-A&31;i=r+w|0;break z}s=B-3|0;c=0-A&31;A:{B:{C:{while(1){D:{if((r|0)>=4){a=j>>>3|0;g=0;f=j&7;break D}if(!r){r=0;i=w;f=j;break B}a=j>>>3|0;g=(r+w|0)-a>>>0>>0;a=g?r:a;f=j-(a<<3)|0}r=r-a|0;i=w+r|0;y=G[i|0]|G[i+1|0]<<8|(G[i+2|0]<<16|G[i+3|0]<<24);if(g|e>>>0>=s>>>0){break C}a=(y<>>c<<1)+n|0;j=G[a+1|0];D[e|0]=G[a|0];a=f+j|0;f=(y<>>c<<1)+n|0;j=G[f+1|0];D[e+1|0]=G[f|0];e=e+2|0;j=a+j|0;if(j>>>0<33){continue}break}i=r+w|0;break z}if(f>>>0>32){break A}}while(1){E:{if((r|0)>=4){a=f>>>3|0;g=0;j=f&7;break E}if(!r){break A}a=f>>>3|0;g=i-a>>>0>>0;a=g?r:a;j=f-(a<<3)|0}r=r-a|0;i=w+r|0;y=G[i|0]|G[i+1|0]<<8|(G[i+2|0]<<16|G[i+3|0]<<24);a=e>>>0>=B>>>0;if(a|g){if(a){break x}break y}a=(y<>>c<<1)+n|0;f=G[a+1|0];D[e|0]=G[a|0];e=e+1|0;f=f+j|0;if(f>>>0<=32){continue}break}}j=f}if(e>>>0>=B>>>0){break x}}while(1){a=(y<>>c<<1)+n|0;f=G[a+1|0];D[e|0]=G[a|0];j=f+j|0;e=e+1|0;if(B>>>0>e>>>0){continue}break}}c=F[l+16>>2];F:{G:{H:{if(c>>>0>=33){a=0-A&31;break H}a=0-A&31;I:{while(1){f=F[l+20>>2];s=F[l+28>>2];J:{if(f>>>0>=s>>>0){f=f-(c>>>3|0)|0;F[l+20>>2]=f;e=0;c=c&7;break J}g=F[l+24>>2];if((g|0)==(f|0)){break I}v=c>>>3|0;e=g>>>0>f-v>>>0;g=e?f-g|0:v;f=f-g|0;F[l+20>>2]=f;c=c-(g<<3)|0}F[l+16>>2]=c;g=G[f|0]|G[f+1|0]<<8|(G[f+2|0]<<16|G[f+3|0]<<24);F[l+12>>2]=g;if(!(e|m>>>0>=K>>>0)){e=(g<>>a<<1)+n|0;f=G[e+1|0];D[m|0]=G[e|0];c=c+f|0;e=(g<>>a<<1)+n|0;f=G[e|0];c=c+G[e+1|0]|0;F[l+16>>2]=c;D[m+1|0]=f;m=m+2|0;if(c>>>0<33){continue}break H}break}if(c>>>0>32){break H}}while(1){K:{if(f>>>0>=s>>>0){f=f-(c>>>3|0)|0;F[l+20>>2]=f;g=0;c=c&7;break K}e=F[l+24>>2];if((e|0)==(f|0)){break H}v=c>>>3|0;g=e>>>0>f-v>>>0;e=g?f-e|0:v;f=f-e|0;F[l+20>>2]=f;c=c-(e<<3)|0}F[l+16>>2]=c;e=G[f|0]|G[f+1|0]<<8|(G[f+2|0]<<16|G[f+3|0]<<24);F[l+12>>2]=e;v=g;g=m>>>0>=J>>>0;if(v|g){if(g){break F}break G}e=(e<>>a<<1)+n|0;g=G[e|0];c=c+G[e+1|0]|0;F[l+16>>2]=c;D[m|0]=g;m=m+1|0;if(c>>>0<=32){continue}break}}if(m>>>0>=J>>>0){break F}}while(1){c=F[l+16>>2];e=(F[l+12>>2]<>>a<<1)+n|0;f=G[e|0];F[l+16>>2]=c+G[e+1|0];D[m|0]=f;m=m+1|0;if(J>>>0>m>>>0){continue}break}}f=(o|0)!=6?-20:(h|0)!=32?-20:(d|0)!=(u|0)?-20:(k|0)!=32?-20:(i|0)!=(w|0)?-20:(j|0)!=32?-20:F[l+20>>2]!=F[l+24>>2]?-20:F[l+16>>2]!=32?-20:b}Ea=l+32|0;return f}function Ub(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u){var v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;B=Ea-16|0;Ea=B;x=l+m|0;v=x>>>0>>0?1:v;a:{if(!v&f>>>0>>0|v){break a}v=0;x=n+o|0;v=x>>>0>>0?1:v;if(!v&f>>>0>>0|v?o:0){break a}f=8;if((b&-2)==8){if((Xe(g<<2)|0)!=1){break a}if((Xe(h<<2)|0)!=1){break a}}v=4;b:{c:{d:{e:{f:{g:{h:{i:{x=(b|0)==9?q?9:8:b;switch(x|0){case 0:case 2:case 4:case 8:case 9:case 11:case 18:case 19:case 20:break e;case 1:case 3:case 5:case 6:case 7:case 10:case 12:case 17:case 21:break f;case 13:break g;case 14:case 15:case 16:break h;default:break i}}f=0;break e}v=2}b=L(g,h);break d}f=16}b=L(g,h);if(x-13>>>0>3){break c}v=f}if(L(u?u:j,s?s:i)>>>0<=d>>>0){break b}break a}if(b>>>0>d>>>0){break a}v=f;if((x|0)==17){break a}}f=e+n|0;e=e+l|0;d=(p&4)!=0&q;l=d?f:e;n=d?o:m;j:{switch(x|0){case 0:w=Ua(a,c,g,h,l,n,0,v,0,r,d,k,i,j,s,t,0,0,u);break a;case 2:w=Ua(a,c,g,h,l,n,2,v,1,r,d,k,i,j,s,t,0,0,u);break a;case 4:w=Ua(a,c,g,h,l,n,4,v,0,r,d,k,i,j,s,t,0,0,u);break a;case 8:w=Ua(a,c,g,h,l,n,6,v,0,r,d,k,i,j,s,t,0,0,u);break a;case 9:d=B+4|0;F[d+8>>2]=0;F[d>>2]=0;F[d+4>>2]=0;if(b){Wa(d,b,(b|0)==1,4);l=F[d+4>>2];Ta(F[d>>2]+(l<<2)|0,0,b-l<<2);F[d+4>>2]=b}if(Ua(a,F[d>>2],g,h,f,o,20,4,0,r,1,k,i,j,g,t,0,0,0)){w=Ua(a,c,g,h,e,m,7,v,0,r,0,k,i,j,s,t,0,F[d>>2],0)}a=F[d>>2];if(!a){break a}Ra(a);break a;case 1:k:{if(!q){if(!h|!g){break k}o=(s?s:g)<<4;p=g&-2;w=g&1;q=0;while(1){l=L(o,q);f=0;if((g|0)!=1){while(1){b=c+l|0;D[b|0]=255;D[b+1|0]=29;d=H[196104]|H[196105]<<16;D[b+2|0]=d;x=d>>>8|0;D[b+3|0]=x;y=d>>>16|0;D[b+4|0]=y;z=d>>>24|0;D[b+5|0]=z;n=H[196106];D[b+6|0]=n;A=n>>>8|0;D[b+7|0]=A;D[b+16|0]=255;D[b+17|0]=29;D[b+18|0]=d;D[b+19|0]=x;D[b+20|0]=y;D[b+21|0]=z;D[b+22|0]=n;D[b+23|0]=A;l=l+32|0;f=f+2|0;if((p|0)!=(f|0)){continue}break}}if(w){b=c+l|0;D[b|0]=255;D[b+1|0]=29;d=H[196104]|H[196105]<<16;D[b+2|0]=d;D[b+3|0]=d>>>8;D[b+4|0]=d>>>16;D[b+5|0]=d>>>24;d=H[196106];D[b+6|0]=d;D[b+7|0]=d>>>8}q=q+1|0;if((q|0)!=(h|0)){continue}break}break k}if(!Ua(a,c,g,h,f,o,11,v,0,r,1,k,i,j,s,t,0,0,u)){break a}}w=Ua(a,c+8|0,g,h,e,m,0,v,0,r,0,k,i,j,s,t,0,0,u);break a;case 3:l:{if(!q){if(!h|!g){break l}o=(s?s:g)<<4;p=g&-4;d=g&3;q=g-1>>>0<3;n=0;while(1){l=L(n,o);f=0;if(!q){while(1){b=c+l|0;D[b+2|0]=0;D[b+3|0]=0;D[b+4|0]=0;D[b+5|0]=0;D[b|0]=255;D[b+1|0]=255;D[b+6|0]=0;D[b+7|0]=0;D[b+18|0]=0;D[b+19|0]=0;D[b+20|0]=0;D[b+21|0]=0;D[b+16|0]=255;D[b+17|0]=255;D[b+22|0]=0;D[b+23|0]=0;D[b+34|0]=0;D[b+35|0]=0;D[b+36|0]=0;D[b+37|0]=0;D[b+32|0]=255;D[b+33|0]=255;D[b+38|0]=0;D[b+39|0]=0;D[b+50|0]=0;D[b+51|0]=0;D[b+52|0]=0;D[b+53|0]=0;D[b+48|0]=255;D[b+49|0]=255;D[b+54|0]=0;D[b+55|0]=0;l=l- -64|0;f=f+4|0;if((p|0)!=(f|0)){continue}break}}f=0;if(d){while(1){b=c+l|0;D[b+2|0]=0;D[b+3|0]=0;D[b+4|0]=0;D[b+5|0]=0;D[b|0]=255;D[b+1|0]=255;D[b+6|0]=0;D[b+7|0]=0;l=l+16|0;f=f+1|0;if((d|0)!=(f|0)){continue}break}}n=n+1|0;if((n|0)!=(h|0)){continue}break}break l}if(!Ua(a,c,g,h,f,o,4,v,0,r,1,k,i,j,s,t,0,0,u)){break a}}w=Ua(a,c+8|0,g,h,e,m,2,v,0,r,0,k,i,j,s,t,0,0,u);break a;case 5:if(!Ua(a,c,g,h,e,m,4,v,0,r,0,k,i,j,s,t,0,0,u)){break a}d=c+8|0;if(q){w=Ua(a,d,g,h,f,o,4,v,0,r,1,k,i,j,s,t,0,0,u);break a}w=1;if(!h|!g){break a}f=(s?s:g)<<4;i=g&-4;e=g&3;g=g-1>>>0<3;b=0;while(1){c=L(b,f);l=0;if(!g){while(1){a=c+d|0;D[a+2|0]=0;D[a+3|0]=0;D[a+4|0]=0;D[a+5|0]=0;D[a|0]=255;D[a+1|0]=255;D[a+6|0]=0;D[a+7|0]=0;D[a+18|0]=0;D[a+19|0]=0;D[a+20|0]=0;D[a+21|0]=0;D[a+16|0]=255;D[a+17|0]=255;D[a+22|0]=0;D[a+23|0]=0;D[a+34|0]=0;D[a+35|0]=0;D[a+36|0]=0;D[a+37|0]=0;D[a+32|0]=255;D[a+33|0]=255;D[a+38|0]=0;D[a+39|0]=0;D[a+50|0]=0;D[a+51|0]=0;D[a+52|0]=0;D[a+53|0]=0;D[a+48|0]=255;D[a+49|0]=255;D[a+54|0]=0;D[a+55|0]=0;c=c- -64|0;l=l+4|0;if((i|0)!=(l|0)){continue}break}}l=0;if(e){while(1){a=c+d|0;D[a+2|0]=0;D[a+3|0]=0;D[a+4|0]=0;D[a+5|0]=0;D[a|0]=255;D[a+1|0]=255;D[a+6|0]=0;D[a+7|0]=0;c=c+16|0;l=l+1|0;if((e|0)!=(l|0)){continue}break}}b=b+1|0;if((h|0)!=(b|0)){continue}break};break a;case 10:if(q){if(!Ua(a,c,g,h,f,o,20,v,0,r,1,k,i,j,s,t,0,0,u)){break a}w=Ua(a,c,g,h,e,m,12,v,0,r,0,k,i,j,s,t,1,0,u);break a}w=Ua(a,c,g,h,e,m,12,v,0,r,0,k,i,j,s,t,0,0,u);break a;case 11:w=Ua(a,c,g,h,l,n,13,v,0,r,d,k,i,j,s,t,0,0,u);break a;case 12:m:{if(!q){if(!h|!g){break m}o=(s?s:g)<<4;p=g&-4;d=g&3;q=g>>>0<4;n=0;while(1){l=L(n,o);f=0;if(!q){while(1){b=c+l|0;D[b+2|0]=0;D[b+3|0]=0;D[b+4|0]=0;D[b+5|0]=0;D[b|0]=255;D[b+1|0]=255;D[b+6|0]=0;D[b+7|0]=0;D[b+18|0]=0;D[b+19|0]=0;D[b+20|0]=0;D[b+21|0]=0;D[b+16|0]=255;D[b+17|0]=255;D[b+22|0]=0;D[b+23|0]=0;D[b+34|0]=0;D[b+35|0]=0;D[b+36|0]=0;D[b+37|0]=0;D[b+32|0]=255;D[b+33|0]=255;D[b+38|0]=0;D[b+39|0]=0;D[b+50|0]=0;D[b+51|0]=0;D[b+52|0]=0;D[b+53|0]=0;D[b+48|0]=255;D[b+49|0]=255;D[b+54|0]=0;D[b+55|0]=0;l=l- -64|0;f=f+4|0;if((p|0)!=(f|0)){continue}break}}f=0;if(d){while(1){b=c+l|0;D[b+2|0]=0;D[b+3|0]=0;D[b+4|0]=0;D[b+5|0]=0;D[b|0]=255;D[b+1|0]=255;D[b+6|0]=0;D[b+7|0]=0;l=l+16|0;f=f+1|0;if((d|0)!=(f|0)){continue}break}}n=n+1|0;if((n|0)!=(h|0)){continue}break}break m}if(!Ua(a,c,g,h,f,o,4,v,0,r,1,k,i,j,s,t,0,0,u)){break a}}w=Ua(a,c+8|0,g,h,e,m,13,v,0,r,0,k,i,j,s,t,0,0,u);break a;case 18:w=Ua(a,c,g,h,l,n,16,v,0,r,d,k,i,j,s,t,0,0,u);break a;case 19:if(q){if(!Ua(a,c,g,h,f,o,20,v,0,r,1,k,i,j,s,t,0,0,u)){break a}w=Ua(a,c,g,h,e,m,17,v,0,r,0,k,i,j,s,t,1,0,u);break a}w=Ua(a,c,g,h,e,m,16,v,0,r,0,k,i,j,s,t,0,0,u);break a;case 13:l=22;if(q){l=21;if(!Ua(a,c,g,h,f,o,23,4,0,r,1,k,i,j,s,t,0,0,u)){break a}}w=Ua(a,c,g,h,e,m,l,4,0,r,0,k,i,j,s,t,0,0,u);break a;case 14:case 15:w=Ua(a,c,g,h,l,n,(x|0)==14?24:25,2,0,r,d,k,i,j,s,t,0,0,u);break a;case 16:l=28;if(q){l=26;if(!Ua(a,c,g,h,f,o,27,2,0,r,1,k,i,j,s,t,0,0,u)){break a}}w=Ua(a,c,g,h,e,m,l,2,0,r,0,k,i,j,s,t,0,0,u);break a;case 20:w=Ua(a,c,g,h,l,n,18,v,0,r,d,k,i,j,s,t,0,0,u);break a;case 21:break j;default:break a}}p=c+8|0;n:{if(!q){if(!h|!g){break n}q=(s?s:g)<<4;w=g&-2;x=g&1;d=0;while(1){l=L(d,q);f=0;if((g|0)!=1){while(1){b=l+p|0;D[b|0]=255;D[b+1|0]=29;n=H[196104]|H[196105]<<16;D[b+2|0]=n;y=n>>>8|0;D[b+3|0]=y;z=n>>>16|0;D[b+4|0]=z;A=n>>>24|0;D[b+5|0]=A;o=H[196106];D[b+6|0]=o;C=o>>>8|0;D[b+7|0]=C;D[b+16|0]=255;D[b+17|0]=29;D[b+18|0]=n;D[b+19|0]=y;D[b+20|0]=z;D[b+21|0]=A;D[b+22|0]=o;D[b+23|0]=C;l=l+32|0;f=f+2|0;if((w|0)!=(f|0)){continue}break}}if(x){b=l+p|0;D[b|0]=255;D[b+1|0]=29;f=H[196104]|H[196105]<<16;D[b+2|0]=f;D[b+3|0]=f>>>8;D[b+4|0]=f>>>16;D[b+5|0]=f>>>24;f=H[196106];D[b+6|0]=f;D[b+7|0]=f>>>8}d=d+1|0;if((h|0)!=(d|0)){continue}break}break n}if(!Ua(a,p,g,h,f,o,18,v,0,r,1,k,i,j,s,t,0,0,u)){break a}}w=Ua(a,c,g,h,e,m,18,v,0,r,0,k,i,j,s,t,0,0,u)}Ea=B+16|0;return w}function Ec(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,H=0,I=0,J=0,K=0,M=0;i=Ea-80|0;Ea=i;F[i+76>>2]=b;I=i+55|0;t=i+56|0;a:{b:{c:{d:while(1){f=0;e:while(1){h=b;if((p^2147483647)<(f|0)){break c}p=f+p|0;f:{g:{h:{f=h;g=G[f|0];if(g){while(1){i:{b=g&255;j:{if(!b){b=f;break j}if((b|0)!=37){break i}g=f;while(1){if(G[g+1|0]!=37){b=g;break j}f=f+1|0;k=G[g+2|0];b=g+2|0;g=b;if((k|0)==37){continue}break}}f=f-h|0;H=p^2147483647;if((f|0)>(H|0)){break c}if(a){gb(a,h,f)}if(f){continue e}F[i+76>>2]=b;f=b+1|0;o=-1;g=D[b+1|0]-48|0;if(!(G[b+2|0]!=36|g>>>0>=10)){o=g;u=1;f=b+3|0}F[i+76>>2]=f;n=0;g=D[f|0];b=g-32|0;k:{if(b>>>0>31){k=f;break k}k=f;b=1<>2]=k;n=b|n;g=D[f+1|0];b=g-32|0;if(b>>>0>=32){break k}f=k;b=1<>>0>=10)){b=D[g|0]-48|0;g=k+3|0;u=1;n:{if(!a){F[(b<<2)+e>>2]=10;b=0;break n}b=F[(b<<3)+d>>2]}break m}if(u){break h}if(!a){F[i+76>>2]=g;u=0;q=0;break l}b=F[c>>2];F[c>>2]=b+4;u=0;b=F[b>>2]}q=b;F[i+76>>2]=g;if((q|0)>=0){break l}q=0-q|0;n=n|8192;break l}q=Dc(i+76|0);if((q|0)<0){break c}g=F[i+76>>2]}f=0;l=-1;o:{if(G[g|0]!=46){b=g;g=0;break o}if(G[g+1|0]==42){b=g+2|0;p:{if(!(G[g+3|0]!=36|D[g+2|0]-48>>>0>=10)){b=D[b|0]-48|0;q:{if(!a){F[(b<<2)+e>>2]=10;l=0;break q}l=F[(b<<3)+d>>2]}b=g+4|0;break p}if(u){break h}if(!a){l=0;break p}g=F[c>>2];F[c>>2]=g+4;l=F[g>>2]}F[i+76>>2]=b;g=(l|0)>=0;break o}F[i+76>>2]=g+1;l=Dc(i+76|0);b=F[i+76>>2];g=1}A=g;while(1){r=f;j=28;m=b;g=D[m|0];if(g-123>>>0<4294967238){break b}b=m+1|0;f=G[(g+L(f,58)|0)+403983|0];if(f-1>>>0<8){continue}break}F[i+76>>2]=b;r:{if((f|0)!=27){if(!f){break b}if((o|0)>=0){if(!a){F[(o<<2)+e>>2]=f;continue d}g=(o<<3)+d|0;f=F[g+4>>2];F[i+64>>2]=F[g>>2];F[i+68>>2]=f;break r}if(!a){break f}Cc(i- -64|0,f,c);break r}if((o|0)>=0){break b}f=0;if(!a){continue e}}j=-1;if(G[a|0]&32){break a}g=n&-65537;n=n&8192?g:n;o=0;B=1152;k=t;s:{t:{u:{v:{w:{x:{y:{z:{A:{B:{C:{D:{E:{F:{G:{H:{f=D[m|0];f=r?(f&15)==3?f&-33:f:f;switch(f-88|0){case 11:break s;case 9:case 13:case 14:case 15:break t;case 27:break y;case 12:case 17:break B;case 23:break C;case 0:case 32:break D;case 24:break E;case 22:break F;case 29:break G;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 10:case 16:case 18:case 19:case 20:case 21:case 25:case 26:case 28:case 30:case 31:break g;default:break H}}I:{switch(f-65|0){case 0:case 4:case 5:case 6:break t;case 2:break w;case 1:case 3:break g;default:break I}}if((f|0)==83){break x}break g}m=F[i+64>>2];j=F[i+68>>2];h=1152;break A}f=0;J:{switch(r&255){case 0:F[F[i+64>>2]>>2]=p;continue e;case 1:F[F[i+64>>2]>>2]=p;continue e;case 2:h=F[i+64>>2];F[h>>2]=p;F[h+4>>2]=p>>31;continue e;case 3:E[F[i+64>>2]>>1]=p;continue e;case 4:D[F[i+64>>2]]=p;continue e;case 6:F[F[i+64>>2]>>2]=p;continue e;case 7:break J;default:continue e}}h=F[i+64>>2];F[h>>2]=p;F[h+4>>2]=p>>31;continue e}l=l>>>0<=8?8:l;n=n|8;f=120}h=t;m=F[i+64>>2];j=F[i+68>>2];if(m|j){z=f&32;while(1){h=h-1|0;D[h|0]=z|G[(m&15)+404512|0];r=!j&m>>>0>15|(j|0)!=0;g=j;j=g>>>4|0;m=(g&15)<<28|m>>>4;if(r){continue}break}}if(!(F[i+64>>2]|F[i+68>>2])|!(n&8)){break z}B=(f>>>4|0)+1152|0;o=2;break z}f=t;h=F[i+68>>2];j=h;m=F[i+64>>2];if(h|m){while(1){f=f-1|0;D[f|0]=m&7|48;g=!j&m>>>0>7|(j|0)!=0;h=j;j=h>>>3|0;m=(h&7)<<29|m>>>3;if(g){continue}break}}h=f;if(!(n&8)){break z}f=t-f|0;l=(f|0)<(l|0)?l:f+1|0;break z}m=F[i+64>>2];h=F[i+68>>2];j=h;if((h|0)<0){h=0-(((m|0)!=0)+h|0)|0;j=h;m=0-m|0;F[i+64>>2]=m;F[i+68>>2]=h;o=1;h=1152;break A}if(n&2048){o=1;h=1153;break A}o=n&1;h=o?1154:1152}B=h;g=t;if(j){while(1){g=g-1|0;J=m;r=0;z=0;h=j;K:{if(!h){Fa=0;m=(m>>>0)/10|0;break K}w=61-O(h)|0;j=0-w|0;f=w&63;s=f&31;if(f>>>0>=32){C=0;s=h>>>s|0}else{C=h>>>s|0;s=((1<>>s}f=j&63;j=f&31;if(f>>>0>=32){y=m<>>32-j|h<>>31;r=s<<1|y>>>31;m=0-(j+(r>>>0>9)|0)>>31;f=m&10;s=r-f|0;C=j-(f>>>0>r>>>0)|0;y=y<<1|x>>>31;x=z|x<<1;r=m&1;z=r;w=w-1|0;if(w){continue}break}}Fa=y<<1|x>>>31;m=r|x<<1}j=Fa;K=g,M=J-We(m,j,10,0)|48,D[K|0]=M;if(h>>>0>9){continue}break}}h=m;if(h){while(1){g=g-1|0;f=(h>>>0)/10|0;D[g|0]=h-L(f,10)|48;j=h>>>0>9;h=f;if(j){continue}break}}h=g}if((l|0)<0&A){break c}n=A?n&-65537:n;g=F[i+64>>2];f=F[i+68>>2];if(!(l|(g|f)!=0)){h=t;l=0;break g}f=!(f|g)+(t-h|0)|0;l=(f|0)<(l|0)?l:f;break g}m=l>>>0>=2147483647?2147483647:l;k=m;n=(k|0)!=0;h=F[i+64>>2];h=h?h:5201;f=h;L:{M:{N:{O:{if(!(f&3)|!k){break O}while(1){if(!G[f|0]){break N}k=k-1|0;n=(k|0)!=0;f=f+1|0;if(!(f&3)){break O}if(k){continue}break}}if(!n){break M}if(!(!G[f|0]|k>>>0<4)){while(1){j=F[f>>2];if((j^-1)&j-16843009&-2139062144){break N}f=f+4|0;k=k-4|0;if(k>>>0>3){continue}break}}if(!k){break M}}while(1){if(!G[f|0]){break L}f=f+1|0;k=k-1|0;if(k){continue}break}}f=0}f=f?f-h|0:m;k=f+h|0;if((l|0)>=0){n=g;l=f;break g}n=g;l=f;if(G[k|0]){break c}break g}if(l){g=F[i+64>>2];break v}f=0;eb(a,32,q,0,n);break u}F[i+12>>2]=0;F[i+8>>2]=F[i+64>>2];g=i+8|0;F[i+64>>2]=g;l=-1}f=0;P:{while(1){h=F[g>>2];if(!h){break P}k=Bc(i+4|0,h);h=(k|0)<0;if(!(h|k>>>0>l-f>>>0)){g=g+4|0;f=f+k|0;if(l>>>0>f>>>0){continue}break P}break}if(h){break a}}j=61;if((f|0)<0){break b}eb(a,32,q,f,n);if(!f){f=0;break u}k=0;g=F[i+64>>2];while(1){h=F[g>>2];if(!h){break u}j=i+4|0;h=Bc(j,h);k=h+k|0;if(k>>>0>f>>>0){break u}gb(a,j,h);g=g+4|0;if(f>>>0>k>>>0){continue}break}}eb(a,32,q,f,n^8192);f=(f|0)<(q|0)?q:f;continue e}if((l|0)<0&A){break c}v()}D[i+55|0]=F[i+64>>2];l=1;h=I;n=g;break g}g=G[f+1|0];f=f+1|0;continue}}j=p;if(a){break a}if(!u){break f}f=1;while(1){a=F[(f<<2)+e>>2];if(a){Cc((f<<3)+d|0,a,c);j=1;f=f+1|0;if((f|0)!=10){continue}break a}break}j=1;if(f>>>0>=10){break a}while(1){if(F[(f<<2)+e>>2]){break h}f=f+1|0;if((f|0)!=10){continue}break}break a}j=28;break b}k=k-h|0;g=(l|0)>(k|0)?l:k;if((g|0)>(o^2147483647)){break c}j=61;l=g+o|0;f=(l|0)<(q|0)?q:l;if((H|0)<(f|0)){break b}eb(a,32,f,l,n);gb(a,B,o);eb(a,48,f,l,n^65536);eb(a,48,g,k,0);gb(a,h,k);eb(a,32,f,l,n^8192);continue}break}break}j=0;break a}j=61}F[108804]=j;j=-1}Ea=i+80|0;return j}function wb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=M(0),w=0,x=0,y=0,z=0,A=0,B=0,C=0,I=0,J=0,K=0,O=0,P=M(0),Q=0,R=0,S=0,T=0,U=M(0);n=Ea-96|0;Ea=n;d=G[b|0];k=b+c|0;j=G[k|0];e=d>>>0>j>>>0?d:j;o=(c<<1)+b|0;g=G[o|0];e=e>>>0>g>>>0?e:g;p=L(c,3)+b|0;i=G[p|0];e=e>>>0>i>>>0?e:i;Q=(c<<2)+b|0;f=G[Q|0];e=e>>>0>f>>>0?e:f;q=L(c,5)+b|0;m=G[q|0];e=e>>>0>m>>>0?e:m;r=L(c,6)+b|0;l=G[r|0];e=e>>>0>l>>>0?e:l;s=L(c,7)+b|0;u=G[s|0];e=e>>>0>u>>>0?e:u;t=(c<<3)+b|0;w=G[t|0];e=e>>>0>w>>>0?e:w;B=L(c,9)+b|0;x=G[B|0];e=e>>>0>x>>>0?e:x;J=L(c,10)+b|0;y=G[J|0];e=e>>>0>y>>>0?e:y;K=L(c,11)+b|0;z=G[K|0];e=e>>>0>z>>>0?e:z;O=L(c,12)+b|0;A=G[O|0];e=e>>>0>A>>>0?e:A;R=L(c,13)+b|0;C=G[R|0];e=e>>>0>C>>>0?e:C;S=L(c,14)+b|0;h=G[S|0];e=e>>>0>h>>>0?e:h;T=L(c,15)+b|0;I=G[T|0];e=e>>>0>I>>>0?e:I;d=d>>>0>>0?d:j;d=d>>>0>>0?d:g;d=d>>>0>>0?d:i;d=d>>>0>>0?d:f;d=d>>>0>>0?d:m;d=d>>>0>>0?d:l;d=d>>>0>>0?d:u;d=d>>>0>>0?d:w;d=d>>>0>>0?d:x;d=d>>>0>>0?d:y;d=d>>>0>>0?d:z;d=d>>>0>>0?d:A;d=d>>>0>>0?d:C;d=d>>>0>>0?d:h;d=d>>>0>>0?d:I;a:{if((e|0)==(d|0)){E[a>>1]=d|3328;b=H[196104]|H[196105]<<16;E[a+2>>1]=b;E[a+4>>1]=b>>>16;E[a+6>>1]=H[196106];break a}j=e-d|0;if(j>>>0<=5){c=e-2|0;d=(c>>>0<256?c:e>>>0>1?-1:0)&255;E[a>>1]=d|7424;j=G[R|0];g=G[T|0];i=G[S|0];c=G[(G[k|0]-d|0)+398355|0]<<1|G[(G[b|0]-d|0)+398355|0]<<13;b=G[(G[o|0]-d|0)+398355|0];e=b>>>11|0;f=b<<21;e=c|e;b=G[(G[p|0]-d|0)+398355|0];c=b>>>23|0;f=b<<9|f;e=c|e|G[(G[Q|0]-d|0)+398355|0]<<10;b=G[(G[q|0]-d|0)+398355|0];c=b>>>2|0;f=b<<30|f;c=c|e;b=G[(G[r|0]-d|0)+398355|0];e=b>>>14|0;f=b<<18|f;e=c|e;b=G[(G[s|0]-d|0)+398355|0];c=b>>>26|0;f=b<<6|f;e=c|e|G[(G[t|0]-d|0)+398355|0]<<7;b=G[(G[B|0]-d|0)+398355|0];c=b>>>5|0;f=b<<27|f;c=c|e;b=G[(G[J|0]-d|0)+398355|0];e=b>>>17|0;f=b<<15|f;e=c|e;b=G[(G[K|0]-d|0)+398355|0];c=b>>>29|0;f=b<<3|f;b=c|e|G[(G[O|0]-d|0)+398355|0]<<4;D[a+3|0]=b;D[a+2|0]=b>>>8;c=G[(j-d|0)+398355|0];e=c>>>8|0;j=f|c<<24;b=b|e;e=b;b=G[(i-d|0)+398355|0];c=b>>>20|0;d=G[(g-d|0)+398355|0]|b<<12|j;D[a+7|0]=d;D[a+4|0]=(e&16777215)<<8|j>>>24;b=c|e;D[a+6|0]=(b&255)<<24|d>>>8;D[a+5|0]=(b&65535)<<16|d>>>16;break a}v=M(j>>>0);P=fb(M(v/M(25)));b:{if(M(N(P))=15?15:j;A=(j|0)<=1?1:j;F[n+64>>2]=A;v=fb(M(v/M(19)));c:{if(M(N(v))=15?15:j;j=(j|0)<=1?1:j;F[n+68>>2]=j;F[n+72>>2]=j;F[n+76>>2]=j;v=M(d>>>0);P=M(M(e>>>0)-v);U=fb(M(M(P*M(.5199999809265137))+v));d:{if(M(N(U))>>0<256?e:(e^-1)>>31)&255;F[n+80>>2]=I;v=fb(M(M(P*M(.5263158082962036))+v));e:{if(M(N(v))>>0<256?e:(e^-1)>>31)&255;F[n+84>>2]=u;F[n+88>>2]=u;F[n+92>>2]=u;w=0;Q=(j|A)!=1;x=0;y=0;z=0;C=0;while(1){g=-1;i=-1;f=-1;m=-1;e=0;l=G[L(c,w)+b|0];f:{if((l+7&255)>>>0<=13){while(1){d=u+L(j,D[e+12984|0])|0;h=((d>>>0<256?d:(d^-1)>>31)&255)-l|0;d=h>>31;d=(d^h)-d<<3|e;m=d>>>0>m>>>0?m:d;d=u+L(j,D[e+12968|0])|0;h=((d>>>0<256?d:(d^-1)>>31)&255)-l|0;d=h>>31;d=(d^h)-d<<3|e;f=d>>>0>f>>>0?f:d;d=u+L(j,D[e+12944|0])|0;h=((d>>>0<256?d:(d^-1)>>31)&255)-l|0;d=h>>31;d=(d^h)-d<<3|e;i=d>>>0>i>>>0?i:d;d=I+L(A,D[e+12896|0])|0;h=((d>>>0<256?d:(d^-1)>>31)&255)-l|0;d=h>>31;d=(d^h)-d<<3|e;g=d>>>0>g>>>0?g:d;e=e+1|0;if((e|0)!=8){continue}break f}}d=u-l|0;l=I-l|0;if(Q){while(1){k=d+L(j,D[e+12984|0])|0;h=k>>31;h=(h^k)-h<<3|e;m=h>>>0>m>>>0?m:h;k=d+L(j,D[e+12968|0])|0;h=k>>31;h=(h^k)-h<<3|e;f=f>>>0>>0?f:h;k=d+L(j,D[e+12944|0])|0;h=k>>31;h=(h^k)-h<<3|e;i=i>>>0>>0?i:h;k=l+L(A,D[e+12896|0])|0;h=k>>31;h=(h^k)-h<<3|e;g=g>>>0>>0?g:h;e=e+1|0;if((e|0)!=8){continue}break}break f}i=d-1|0;e=i>>31;p=d-2|0;g=p>>31;q=d-3|0;f=q>>31;r=d-10|0;m=r>>31;s=d+1|0;h=s>>31;t=d+2|0;k=t>>31;B=d+9|0;o=B>>31;e=(e^i)-e<<3;i=(g^p)-g<<3;g=i|1;e=e>>>0>>0?e:g;g=(f^q)-f<<3|2;g=e>>>0>>0?e:g;e=(m^r)-m<<3|3;g=e>>>0>g>>>0?g:e;f=d>>31;f=(f^d)-f<<3|4;g=f>>>0>g>>>0?g:f;p=(h^s)-h<<3;f=p|5;g=f>>>0>g>>>0?g:f;f=(k^t)-k<<3|6;f=f>>>0>g>>>0?g:f;g=(o^B)-o<<3|7;m=f>>>0>>0?f:g;q=d-5|0;f=q>>31;r=d-7|0;h=r>>31;s=d+4|0;k=s>>31;t=d+6|0;o=t>>31;f=(f^q)-f<<3|1;f=f>>>0>i>>>0?i:f;h=(h^r)-h<<3|2;f=f>>>0>>0?f:h;f=e>>>0>f>>>0?f:e;h=p|4;f=f>>>0>>0?f:h;k=(k^s)-k<<3|5;f=f>>>0>>0?f:k;k=(o^t)-o<<3|6;f=f>>>0>>0?f:k;f=f>>>0>>0?f:g;q=d-6|0;k=q>>31;r=d-8|0;o=r>>31;s=d+5|0;p=s>>31;t=d+7|0;d=t>>31;k=(k^q)-k<<3|1;i=i>>>0>>0?i:k;k=(o^r)-o<<3|2;i=i>>>0>>0?i:k;e=e>>>0>i>>>0?i:e;e=e>>>0>>0?e:h;i=(p^s)-p<<3|5;e=e>>>0>>0?e:i;d=(d^t)-d<<3|6;e=d>>>0>e>>>0?e:d;i=e>>>0>>0?e:g;q=l-2|0;e=q>>31;r=l-5|0;d=r>>31;s=l-8|0;g=s>>31;t=l-13|0;h=t>>31;B=l+1|0;k=B>>31;J=l+4|0;o=J>>31;K=l+7|0;p=K>>31;O=l+12|0;l=O>>31;e=(e^q)-e<<3;d=(d^r)-d<<3|1;e=d>>>0>e>>>0?e:d;d=(g^s)-g<<3|2;e=d>>>0>e>>>0?e:d;d=(h^t)-h<<3|3;e=d>>>0>e>>>0?e:d;d=(k^B)-k<<3|4;e=d>>>0>e>>>0?e:d;d=(o^J)-o<<3|5;e=d>>>0>e>>>0?e:d;d=(p^K)-p<<3|6;e=d>>>0>e>>>0?e:d;d=(l^O)-l<<3|7;g=d>>>0>e>>>0?e:d}e=n+w|0;D[e|0]=g&7;D[e+16|0]=i&7;D[e+32|0]=f&7;D[e+48|0]=m&7;e=m>>>3|0;C=L(e,e)+C|0;e=f>>>3|0;z=L(e,e)+z|0;e=i>>>3|0;y=L(e,e)+y|0;e=g>>>3|0;x=L(e,e)+x|0;w=w+1|0;if((w|0)!=16){continue}break}c=x>>>0>y>>>0;e=c?y:x;b=e>>>0>z>>>0;b=(b?z:e)>>>0>C>>>0?3:b?2:c;c=b<<2;E[a>>1]=G[c|n+80]|((G[b+398358|0]&15)<<8|H[(c|n- -64)>>1]<<12);g=(b<<4)+n|0;d=g;b=G[d+13|0];j=G[d+15|0];e=G[d+14|0];f=G[d+1|0]<<1|G[d|0]<<13;c=G[d+2|0];d=c>>>11|0;c=c<<21;i=d|f;f=c;d=G[g+3|0];c=d>>>23|0;d=f|d<<9;i=c|i;c=d;d=G[g+4|0]<<10;c=c|0;i=d|i;f=c;d=G[g+5|0];c=d>>>2|0;d=f|d<<30;i=c|i;f=d;c=G[g+6|0];d=c>>>14|0;c=f|c<<18;i=d|i;f=c;d=G[g+7|0];c=d>>>26|0;d=f|d<<6;i=c|i;c=d;d=G[g+8|0]<<7;c=c|0;i=d|i;f=c;d=G[g+9|0];c=d>>>5|0;d=f|d<<27;i=c|i;f=d;c=G[g+10|0];d=c>>>17|0;c=f|c<<15;i=d|i;f=c;d=G[g+11|0];c=d>>>29|0;d=f|d<<3;i=c|i;c=d;d=G[g+12|0]<<4;g=c|0;c=d|i;d=c;D[a+3|0]=d;D[a+2|0]=d>>>8;g=g|b<<24;b=d|b>>>8;d=e>>>20|0;e=e<<12|j|g;D[a+7|0]=e;D[a+4|0]=(b&16777215)<<8|g>>>24;b=b|d;D[a+6|0]=(b&255)<<24|e>>>8;D[a+5|0]=(b&65535)<<16|e>>>16}Ea=n+96|0}function de(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=M(0),J=0,K=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=M(0),V=M(0),W=M(0),X=M(0);h=Ea-448|0;Ea=h;d=G[b|0];v=b+c|0;k=G[v|0];e=d>>>0>k>>>0?d:k;w=(c<<1)+b|0;f=G[w|0];e=e>>>0>f>>>0?e:f;x=L(c,3)+b|0;i=G[x|0];e=e>>>0>i>>>0?e:i;y=(c<<2)+b|0;j=G[y|0];e=e>>>0>j>>>0?e:j;z=L(c,5)+b|0;s=G[z|0];e=e>>>0>s>>>0?e:s;A=L(c,6)+b|0;l=G[A|0];e=e>>>0>l>>>0?e:l;B=L(c,7)+b|0;g=G[B|0];e=e>>>0>g>>>0?e:g;J=(c<<3)+b|0;m=G[J|0];e=e>>>0>m>>>0?e:m;K=L(c,9)+b|0;n=G[K|0];e=e>>>0>n>>>0?e:n;O=L(c,10)+b|0;o=G[O|0];e=e>>>0>o>>>0?e:o;P=L(c,11)+b|0;p=G[P|0];e=e>>>0>p>>>0?e:p;Q=L(c,12)+b|0;q=G[Q|0];e=e>>>0>q>>>0?e:q;R=L(c,13)+b|0;r=G[R|0];e=e>>>0>r>>>0?e:r;S=L(c,14)+b|0;t=G[S|0];e=e>>>0>t>>>0?e:t;T=L(c,15)+b|0;u=G[T|0];e=e>>>0>u>>>0?e:u;d=d>>>0>>0?d:k;d=d>>>0>>0?d:f;d=d>>>0>>0?d:i;d=d>>>0>>0?d:j;d=d>>>0>>0?d:s;d=d>>>0>>0?d:l;d=d>>>0>>0?d:g;d=d>>>0>>0?d:m;d=d>>>0>>0?d:n;d=d>>>0>>0?d:o;d=d>>>0

>>0?d:p;d=d>>>0>>0?d:q;d=d>>>0>>0?d:r;d=d>>>0>>0?d:t;d=d>>>0>>0?d:u;a:{if((e|0)==(d|0)){E[a>>1]=d|3328;b=H[196104]|H[196105]<<16;E[a+2>>1]=b;E[a+4>>1]=b>>>16;E[a+6>>1]=H[196106];break a}k=e-d|0;if(k>>>0<=5){c=e-2|0;d=(c>>>0<256?c:e>>>0>1?-1:0)&255;E[a>>1]=d|7424;k=G[R|0];f=G[T|0];i=G[S|0];c=G[(G[v|0]-d|0)+398355|0]<<1|G[(G[b|0]-d|0)+398355|0]<<13;b=G[(G[w|0]-d|0)+398355|0];e=b>>>11|0;j=b<<21;e=c|e;b=G[(G[x|0]-d|0)+398355|0];c=b>>>23|0;j=b<<9|j;e=c|e|G[(G[y|0]-d|0)+398355|0]<<10;b=G[(G[z|0]-d|0)+398355|0];c=b>>>2|0;j=b<<30|j;c=c|e;b=G[(G[A|0]-d|0)+398355|0];e=b>>>14|0;j=b<<18|j;e=c|e;b=G[(G[B|0]-d|0)+398355|0];c=b>>>26|0;j=b<<6|j;e=c|e|G[(G[J|0]-d|0)+398355|0]<<7;b=G[(G[K|0]-d|0)+398355|0];c=b>>>5|0;j=b<<27|j;c=c|e;b=G[(G[O|0]-d|0)+398355|0];e=b>>>17|0;j=b<<15|j;e=c|e;b=G[(G[P|0]-d|0)+398355|0];c=b>>>29|0;j=b<<3|j;b=c|e|G[(G[Q|0]-d|0)+398355|0]<<4;D[a+3|0]=b;D[a+2|0]=b>>>8;c=G[(k-d|0)+398355|0];e=c>>>8|0;k=j|c<<24;b=b|e;e=b;b=G[(i-d|0)+398355|0];c=b>>>20|0;d=G[(f-d|0)+398355|0]|b<<12|k;D[a+7|0]=d;D[a+4|0]=(e&16777215)<<8|k>>>24;b=c|e;D[a+6|0]=(b&255)<<24|d>>>8;D[a+5|0]=(b&65535)<<16|d>>>16;break a}U=M(d>>>0);W=M(M(e>>>0)-U);X=M(k>>>0);d=0;while(1){f=d<<2;g=f+(h+320|0)|0;e=d<<3;k=D[e+12883|0];C=M(D[e+12887|0]-k|0);V=fb(M(X/C));b:{if(M(N(V))=15?15:e;F[g>>2]=(e|0)<=1?1:e;f=f+(h+384|0)|0;C=fb(M(M(W*M(M(0-k|0)/C))+U));c:{if(M(N(C))>2]=(e>>>0<256?e:(e^-1)>>31)&255;d=d+1|0;if((d|0)!=16){continue}break}F[h+312>>2]=0;F[h+316>>2]=0;F[h+304>>2]=0;F[h+308>>2]=0;F[h+296>>2]=0;F[h+300>>2]=0;F[h+288>>2]=0;F[h+292>>2]=0;F[h+280>>2]=0;F[h+284>>2]=0;F[h+272>>2]=0;F[h+276>>2]=0;F[h+264>>2]=0;F[h+268>>2]=0;F[h+256>>2]=0;F[h+260>>2]=0;j=0;while(1){k=(j<<3)+12880|0;e=j<<2;t=e+(h+256|0)|0;s=F[t>>2];f=F[e+(h+384|0)>>2];i=F[e+(h+320|0)>>2];l=0;d=-1;g=0;while(1){e=G[L(c,l)+b|0];d:{if((e|0)==(d|0)){D[((j<<4)+h|0)+l|0]=g&7;e=g>>>3|0;s=L(e,e)+s|0;break d}d=f+L(i,D[k|0])|0;u=((d>>>0<256?d:(d^-1)>>31)&255)-e|0;d=u>>31;g=f+L(i,D[k+1|0])|0;v=((g>>>0<256?g:(g^-1)>>31)&255)-e|0;g=v>>31;m=f+L(i,D[k+2|0])|0;w=((m>>>0<256?m:(m^-1)>>31)&255)-e|0;m=w>>31;n=f+L(i,D[k+3|0])|0;x=((n>>>0<256?n:(n^-1)>>31)&255)-e|0;n=x>>31;o=f+L(i,D[k+4|0])|0;y=((o>>>0<256?o:(o^-1)>>31)&255)-e|0;o=y>>31;p=f+L(i,D[k+5|0])|0;z=((p>>>0<256?p:(p^-1)>>31)&255)-e|0;p=z>>31;q=f+L(i,D[k+6|0])|0;A=((q>>>0<256?q:(q^-1)>>31)&255)-e|0;q=A>>31;r=f+L(i,D[k+7|0])|0;B=((r>>>0<256?r:(r^-1)>>31)&255)-e|0;r=B>>31;d=(d^u)-d<<3;g=(g^v)-g<<3|1;d=d>>>0>>0?d:g;g=(m^w)-m<<3|2;d=d>>>0>>0?d:g;g=(n^x)-n<<3|3;d=d>>>0>>0?d:g;g=(o^y)-o<<3|4;d=d>>>0>>0?d:g;g=(p^z)-p<<3|5;d=d>>>0>>0?d:g;g=(q^A)-q<<3|6;d=d>>>0>>0?d:g;g=(r^B)-r<<3|7;g=d>>>0>>0?d:g;D[((j<<4)+h|0)+l|0]=g&7;d=g>>>3|0;s=L(d,d)+s|0;d=e}l=l+1|0;if((l|0)!=16){continue}break}F[t>>2]=s;j=j+1|0;if((j|0)!=16){continue}break}b=F[h+260>>2];c=F[h+256>>2];e=b>>>0>>0;d=F[h+264>>2];b=e?b:c;c=d>>>0>>0;f=c?2:e;e=F[h+268>>2];b=c?d:b;c=e>>>0>>0;f=c?3:f;d=F[h+272>>2];b=c?e:b;c=d>>>0>>0;f=c?4:f;e=F[h+276>>2];b=c?d:b;c=e>>>0>>0;f=c?5:f;d=F[h+280>>2];b=c?e:b;c=d>>>0>>0;f=c?6:f;e=F[h+284>>2];b=c?d:b;c=e>>>0>>0;f=c?7:f;d=F[h+288>>2];b=c?e:b;c=d>>>0>>0;f=c?8:f;e=F[h+292>>2];b=c?d:b;c=e>>>0>>0;f=c?9:f;d=F[h+296>>2];b=c?e:b;c=d>>>0>>0;f=c?10:f;e=F[h+300>>2];b=c?d:b;c=e>>>0>>0;f=c?11:f;d=F[h+304>>2];b=c?e:b;c=d>>>0>>0;f=c?12:f;e=F[h+308>>2];b=c?d:b;c=e>>>0>>0;f=c?13:f;d=F[h+312>>2];b=c?e:b;c=d>>>0>>0;b=I[h+316>>2]<(c?d:b)>>>0?15:c?14:f;c=b<<2;E[a>>1]=H[c+(h+320|0)>>1]<<12|b<<8&3840|G[c+(h+384|0)|0];f=(b<<4)+h|0;d=f;b=G[d+13|0];k=G[d+15|0];e=G[d+14|0];j=G[d+1|0]<<1|G[d|0]<<13;c=G[d+2|0];d=c>>>11|0;c=c<<21;i=d|j;g=c;d=G[f+3|0];c=d>>>23|0;d=g|d<<9;i=c|i;c=d;d=G[f+4|0]<<10;c=c|0;i=d|i;g=c;d=G[f+5|0];c=d>>>2|0;d=g|d<<30;i=c|i;g=d;c=G[f+6|0];d=c>>>14|0;c=g|c<<18;i=d|i;g=c;d=G[f+7|0];c=d>>>26|0;d=g|d<<6;i=c|i;c=d;d=G[f+8|0]<<7;c=c|0;i=d|i;g=c;d=G[f+9|0];c=d>>>5|0;d=g|d<<27;i=c|i;g=d;c=G[f+10|0];d=c>>>17|0;c=g|c<<15;i=d|i;g=c;d=G[f+11|0];c=d>>>29|0;d=g|d<<3;i=c|i;c=d;d=G[f+12|0]<<4;f=c|0;c=d|i;d=c;D[a+3|0]=d;D[a+2|0]=d>>>8;f=f|b<<24;b=d|b>>>8;d=e>>>20|0;e=e<<12|k|f;D[a+7|0]=e;D[a+4|0]=(b&16777215)<<8|f>>>24;b=b|d;D[a+6|0]=(b&255)<<24|e>>>8;D[a+5|0]=(b&65535)<<16|e>>>16}Ea=h+448|0}function Ib(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;g=Ea-32|0;Ea=g;F[g+24>>2]=b;F[g+28>>2]=a;a:while(1){h=a;b:while(1){l=b-4|0;c:while(1){d:{e:{f:{g:{h:{i:{j:{k:{e=b-h|0;f=e>>2;switch(f|0){case 4:break j;case 2:break k;case 0:case 1:break d;case 3:break g;case 5:break i;default:break h}}a=b-4|0;F[g+24>>2]=a;if(I[a>>2]>=I[h>>2]){break d}a=F[g+28>>2];b=F[a>>2];c=a;a=F[g+24>>2];F[c>>2]=F[a>>2];F[a>>2]=b;break d}a=b-4|0;F[g+24>>2]=a;Ac(h,h+4|0,h+8|0,a);break d}a=b-4|0;F[g+24>>2]=a;zc(h,h+4|0,h+8|0,h+12|0,a);break d}if((e|0)<=123){c=Ea-16|0;Ea=c;d=h+8|0;tb(h,h+4|0,d);a=h+12|0;while(1){F[c+12>>2]=a;if((a|0)!=(b|0)){if(I[a>>2]>2]){F[c+8>>2]=F[F[c+12>>2]>>2];F[c+4>>2]=d;a=F[c+12>>2];while(1){l:{F[a>>2]=F[F[c+4>>2]>>2];a=F[c+4>>2];if((h|0)==(a|0)){a=h;break l}d=a-4|0;F[c+4>>2]=d;if(I[c+8>>2]>2]){continue}}break}F[a>>2]=F[c+8>>2]}d=F[c+12>>2];a=d+4|0;continue}break}Ea=c+16|0;break d}if(!d){if((b|0)==(h|0)){break d}e=Ea-16|0;Ea=e;F[e+12>>2]=h;a=b;if((a|0)!=(h|0)){m:{b=a-h|0;if((b|0)<5){break m}c=b>>2;b=c-2>>>1|0;while(1){if((b|0)<0){break m}wc(h,c,(b<<2)+h|0);b=b-1|0;continue}}d=a-h>>2;b=a;while(1){F[e+8>>2]=b;c=F[e+12>>2];k=c;if((a|0)!=(b|0)){if(I[b>>2]>2]){b=F[e+8>>2];h=F[b>>2];F[b>>2]=F[c>>2];F[c>>2]=h;b=F[e+12>>2];wc(b,d,b)}b=F[e+8>>2]+4|0;continue}break}b=a-k>>2;while(1){if((b|0)>1){c=a;i=Ea-16|0;Ea=i;F[i+12>>2]=k;n:{if(b>>>0<2){break n}h=F[i+12>>2];l=F[h>>2];a=0;f=Ea-16|0;Ea=f;n=b-2>>>1|0;while(1){m=(a<<2)+h|0;F[f+12>>2]=m+4;d=a<<1;a=d|1;d=d+2|0;if(!((d|0)>=(b|0)|I[m+4>>2]>=I[m+8>>2])){F[f+12>>2]=F[f+12>>2]+4;a=d}F[h>>2]=F[F[f+12>>2]>>2];h=F[f+12>>2];if((a|0)<=(n|0)){continue}break}Ea=f+16|0;a=c-4|0;F[i+8>>2]=a;if((a|0)==(h|0)){F[h>>2]=l;break n}F[h>>2]=F[F[i+8>>2]>>2];F[F[i+8>>2]>>2]=l;a=Ea-16|0;Ea=a;d=h+4|0;f=F[i+12>>2];h=d-f>>2;o:{if((h|0)<2){break o}l=d-4|0;F[a+12>>2]=l;d=h-2>>>1|0;h=f+(d<<2)|0;F[a+8>>2]=h;if(I[h>>2]>=I[l>>2]){break o}F[a+4>>2]=F[F[a+12>>2]>>2];p:{while(1){F[F[a+12>>2]>>2]=F[F[a+8>>2]>>2];h=F[a+8>>2];F[a+12>>2]=h;if(!d){break p}d=d-1>>>1|0;h=f+(d<<2)|0;F[a+8>>2]=h;if(I[h>>2]>2]){continue}break}h=F[a+12>>2]}F[h>>2]=F[a+4>>2]}Ea=a+16|0}Ea=i+16|0;b=b-1|0;a=c-4|0;continue}break}}Ea=e+16|0;break d}k=(f<<1&-4)+h|0;F[g+20>>2]=k;q:{if(e>>>0>=3997){i=Ea-32|0;Ea=i;e=f&-4;m=e+h|0;F[i+24>>2]=m;F[i+28>>2]=h;F[i+20>>2]=k;n=e+k|0;F[i+16>>2]=n;F[i+12>>2]=l;f=Ea-16|0;Ea=f;F[f+8>>2]=m;F[f+12>>2]=h;F[f+4>>2]=k;F[f>>2]=n;e=yc(h,m,k);r:{if(I[n>>2]>=I[k>>2]){break r}j=F[f+4>>2];o=F[j>>2];p=j;j=F[f>>2];F[p>>2]=F[j>>2];F[j>>2]=o;if(I[F[f+4>>2]>>2]>=I[m>>2]){e=e+1|0;break r}j=F[f+8>>2];o=F[j>>2];p=j;j=F[f+4>>2];F[p>>2]=F[j>>2];F[j>>2]=o;if(I[F[f+8>>2]>>2]>=I[h>>2]){e=e+2|0;break r}e=e+3|0;j=F[f+12>>2];o=F[j>>2];p=j;j=F[f+8>>2];F[p>>2]=F[j>>2];F[j>>2]=o}Ea=f+16|0;s:{if(I[l>>2]>=I[n>>2]){break s}f=F[i+16>>2];n=F[f>>2];j=f;f=F[i+12>>2];F[j>>2]=F[f>>2];F[f>>2]=n;if(I[F[i+16>>2]>>2]>=I[k>>2]){e=e+1|0;break s}f=F[i+20>>2];k=F[f>>2];j=f;f=F[i+16>>2];F[j>>2]=F[f>>2];F[f>>2]=k;if(I[F[i+20>>2]>>2]>=I[m>>2]){e=e+2|0;break s}f=F[i+24>>2];k=F[f>>2];j=f;f=F[i+20>>2];F[j>>2]=F[f>>2];F[f>>2]=k;if(I[F[i+24>>2]>>2]>=I[h>>2]){e=e+3|0;break s}e=e+4|0;f=F[i+28>>2];k=F[f>>2];j=f;f=F[i+24>>2];F[j>>2]=F[f>>2];F[f>>2]=k}Ea=i+32|0;break q}e=yc(h,k,l)}i=e;d=d-1|0;F[g+16>>2]=h;F[g+12>>2]=l;if(I[h>>2]>=I[F[g+20>>2]>>2]){while(1){e=F[g+12>>2]-4|0;F[g+12>>2]=e;f=F[g+16>>2];if((f|0)==(e|0)){F[g+12>>2]=l;F[g+16>>2]=f+4;e=F[g+16>>2];if(I[h>>2]>2]){break e}while(1){a=F[g+12>>2];if((a|0)==(e|0)){break d}if(I[h>>2]>2]){e=F[g+16>>2];i=F[e>>2];F[e>>2]=F[a>>2];F[a>>2]=i;e=F[g+16>>2]+4|0;F[g+16>>2]=e;break e}else{e=F[g+16>>2]+4|0;F[g+16>>2]=e;continue}}}if(I[e>>2]>=I[F[g+20>>2]>>2]){continue}break}e=F[g+16>>2];f=F[e>>2];j=e;e=F[g+12>>2];F[j>>2]=F[e>>2];F[e>>2]=f;i=i+1|0}e=F[g+16>>2]+4|0;F[g+16>>2]=e;t:{if(I[g+12>>2]<=e>>>0){break t}while(1){if(I[e>>2]>2]>>2]){e=F[g+16>>2]+4|0;F[g+16>>2]=e;continue}while(1){e=F[g+12>>2]-4|0;F[g+12>>2]=e;if(I[e>>2]>=I[F[g+20>>2]>>2]){continue}break}e=F[g+16>>2];if(e>>>0>I[g+12>>2]){break t}f=F[e>>2];j=e;e=F[g+12>>2];F[j>>2]=F[e>>2];F[e>>2]=f;e=F[g+16>>2];if((e|0)==F[g+20>>2]){F[g+20>>2]=F[g+12>>2]}i=i+1|0;e=e+4|0;F[g+16>>2]=e;continue}}f=F[g+20>>2];if(!((f|0)==(e|0)|I[f>>2]>=I[e>>2])){e=F[g+16>>2];k=F[e>>2];F[e>>2]=F[f>>2];F[f>>2]=k;i=i+1|0}e=F[g+16>>2];u:{if(i){break u}i=xc(h,e);if(xc(F[g+16>>2]+4|0,b)){if(i){break d}b=F[g+16>>2];F[g+24>>2]=b;continue b}e=F[g+16>>2];if(!i){break u}a=e+4|0;break f}if((e-a|0)<(b-e|0)){Ib(a,e,c,d);a=F[g+16>>2]+4|0;break f}Ib(e+4|0,b,c,d);b=F[g+16>>2];F[g+24>>2]=b;continue a}a=b-4|0;F[g+24>>2]=a;tb(h,h+4|0,a);break d}F[g+28>>2]=a;continue a}if(F[g+12>>2]==(e|0)){break d}while(1){v:{if(I[h>>2]>=I[e>>2]){break v}while(1){a=F[g+12>>2]-4|0;F[g+12>>2]=a;if(I[h>>2]>2]){continue}break}a=F[g+16>>2];if(a>>>0>2]){e=F[a>>2];f=a;a=F[g+12>>2];F[f>>2]=F[a>>2];F[a>>2]=e;break v}F[g+28>>2]=a;h=a;continue c}e=F[g+16>>2]+4|0;F[g+16>>2]=e;continue}}break}break}break}Ea=g+32|0}function $a(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;f=Ea-416|0;Ea=f;a:{if((a|0)==8){F[e>>2]=F[c>>2];F[e+4>>2]=F[c>>2];F[e+8>>2]=F[c>>2];F[e+12>>2]=F[c>>2];F[e+16>>2]=F[c>>2];F[e+20>>2]=F[c>>2];F[e+24>>2]=F[c>>2];F[e+28>>2]=F[c>>2];F[e+32>>2]=F[c>>2];F[e+36>>2]=F[c>>2];F[e+40>>2]=F[c>>2];F[e+44>>2]=F[c>>2];F[e+48>>2]=F[c>>2];F[e+52>>2]=F[c>>2];F[e+56>>2]=F[c>>2];F[e+60>>2]=F[c>>2];break a}u=G[a+7008|0];c=G[a+7072|0];m=G[a+7104|0];g=G[a+7168|0];h=g>>>0>=4?4:g;b:{if((h|0)!=2){n=m>>>0<=1?1:m;p=h>>>0<=3?3:h;q=p-h|0;j=q+1&3;k=a-15>>>0>4294967288;o=(c<<9)+413088|0;while(1){c:{if(!h){break c}g=(f+384|0)+(r<<3)|0;i=(L(h,r)<<1)+d|0;D[g|0]=G[o+(G[i+21|0]<<1)|0];D[g+4|0]=G[o+(G[i+22|0]<<1)|0];if((h|0)==1){break c}D[g+1|0]=G[o+(G[i+23|0]<<1)|0];c=g|4;D[c+1|0]=G[o+(G[i+24|0]<<1)|0];D[g+2|0]=G[o+(G[i+25|0]<<1)|0];D[c+2|0]=G[o+(G[i+26|0]<<1)|0];if((h|0)==3){break c}D[g+3|0]=G[o+(G[i+27|0]<<1)|0];D[c+3|0]=G[o+(G[i+28|0]<<1)|0]}d:{if(k){break d}g=(f+384|0)+(r<<3)|0;s=g|4;l=0;c=h;if(j){while(1){D[c+g|0]=255;D[c+s|0]=255;c=c+1|0;l=l+1|0;if((j|0)!=(l|0)){continue}break}}if(q>>>0<3){break d}while(1){D[c+g|0]=255;D[c+s|0]=255;i=c+1|0;D[i+g|0]=255;D[i+s|0]=255;i=c+2|0;D[i+g|0]=255;D[i+s|0]=255;i=c+3|0;D[i+g|0]=255;D[i+s|0]=255;c=c+4|0;if((i|0)!=(p|0)){continue}break}}r=r+1|0;if((n|0)!=(r|0)){continue}break}break b}i=m>>>0<=1?1:m;g=0;n=(c<<9)+413088|0;while(1){p=(g<<2)+d|0;q=G[n+(G[p+21|0]<<1)|0];c=G[n+(G[p+23|0]<<1)|0];k=G[n+(G[p+22|0]<<1)|0];j=(f+384|0)+(g<<3)|0;D[j+7|0]=G[n+(G[p+24|0]<<1)|0];D[j+6|0]=k;D[j+5|0]=k;D[j+4|0]=k;D[j+3|0]=c;D[j+2|0]=q;D[j+1|0]=q;D[j|0]=q;g=g+1|0;if((i|0)!=(g|0)){continue}break}}y=F[(u<<2)+10528>>2];e:{f:{switch(h|0){case 2:p=m>>>0<=1?1:m;l=0;while(1){h=(f+384|0)+(l<<3)|0;c=G[h+7|0];q=c<<8|c;c=G[h+3|0];k=c<<8|c;c=G[h+4|0];i=c<<8|c;c=G[h|0];h=c<<8|c;g=0;while(1){c=g<<2;j=c+((l<<7)+f|0)|0;n=F[c+y>>2];c=64-n|0;D[j+3|0]=(L(c,k)+L(n,q)|0)+32>>>14;c=(L(c,h)+L(i,n)|0)+32>>>14|0;D[j+2|0]=c;D[j+1|0]=c;D[j|0]=c;g=g+1|0;if(!(g>>>u|0)){continue}break}l=l+1|0;if((p|0)!=(l|0)){continue}break};break e;case 0:h=m>>>0<=1?1:m;k=h&1;g=0;c=0;if(!(458083>>>a&1)){i=h&254;l=0;while(1){h=t<<7;c=0;while(1){F[(h+(c<<2)|0)+f>>2]=-1;c=c+1|0;if(!(c>>>u|0)){continue}break}h=h|128;c=0;while(1){F[(h+(c<<2)|0)+f>>2]=-1;c=c+1|0;if(!(c>>>u|0)){continue}break}t=t+2|0;l=l+2|0;if((i|0)!=(l|0)){continue}break}c=t<<7}if(!k){break e}while(1){F[((g<<2)+c|0)+f>>2]=-1;g=g+1|0;if(!(g>>>u|0)){continue}break};break e;default:break f}}c=3-h|0;j=(c>>>0<=3?c:0)+1|0;n=m>>>0<=1?1:m;p=h&6;q=h&1;while(1){k=t<<7;i=k|1;v=(f+384|0)+(t<<3)|0;w=v|4;r=0;while(1){o=r<<2;x=o+(f+k|0)|0;m=F[o+y>>2];l=64-m|0;c=0;s=0;if((h|0)!=1){while(1){D[c+x|0]=(L(L(l,G[c+v|0]),257)+L(L(m,G[c+w|0]),257)|0)+32>>>14;g=c|1;D[x+g|0]=(L(L(l,G[g+v|0]),257)+L(L(m,G[g+w|0]),257)|0)+32>>>14;c=c+2|0;s=s+2|0;if((p|0)!=(s|0)){continue}break}}if(q){D[c+x|0]=(L(L(l,G[c+v|0]),257)+L(L(m,G[c+w|0]),257)|0)+32>>>14;g=c}if(g>>>0<=2){Ta(((i+o|0)+g|0)+f|0,255,j)}r=r+1|0;if(!(r>>>u|0)){continue}break}t=t+1|0;if((n|0)!=(t|0)){continue}break}}if(!(382655>>>a&1)){g=f|3;h=f|2;b=f|1;c=0;while(1){k=(c<<2)+e|0;a=(c<<1)+d|0;i=G[a+39|0];a=G[a+40|0];D[k|0]=G[((F[d+16>>2]?i:a)<<2)+f|0];D[k+1|0]=G[b+((F[d+16>>2]==1?a:i)<<2)|0];D[k+2|0]=G[h+((F[d+16>>2]==2?a:i)<<2)|0];D[k+3|0]=G[g+((F[d+16>>2]==3?a:i)<<2)|0];c=c+1|0;if((c|0)!=16){continue}break}break a}c=10320;g:{if(!(66204>>>a&1)){break g}h:{switch(a-3|0){case 0:c=(b<<4)+6160|0;break g;case 4:c=(b<<4)+6336|0;break g;default:break h}}c=(b<<4)+5680|0}i:{if(457827>>>a&1){F[e>>2]=F[(G[d+39|0]<<2)+f>>2];F[e+4>>2]=F[(G[d+40|0]<<2)+f>>2];F[e+8>>2]=F[(G[d+41|0]<<2)+f>>2];F[e+12>>2]=F[(G[d+42|0]<<2)+f>>2];F[e+16>>2]=F[(G[d+43|0]<<2)+f>>2];F[e+20>>2]=F[(G[d+44|0]<<2)+f>>2];F[e+24>>2]=F[(G[d+45|0]<<2)+f>>2];F[e+28>>2]=F[(G[d+46|0]<<2)+f>>2];F[e+32>>2]=F[(G[d+47|0]<<2)+f>>2];F[e+36>>2]=F[(G[d+48|0]<<2)+f>>2];F[e+40>>2]=F[(G[d+49|0]<<2)+f>>2];F[e+44>>2]=F[(G[d+50|0]<<2)+f>>2];F[e+48>>2]=F[(G[d+51|0]<<2)+f>>2];F[e+52>>2]=F[(G[d+52|0]<<2)+f>>2];F[e+56>>2]=F[(G[d+53|0]<<2)+f>>2];a=(G[d+54|0]<<2)+f|0;break i}F[e>>2]=F[((G[c|0]<<7)+f|0)+(G[d+39|0]<<2)>>2];F[e+4>>2]=F[((G[c+1|0]<<7)+f|0)+(G[d+40|0]<<2)>>2];F[e+8>>2]=F[((G[c+2|0]<<7)+f|0)+(G[d+41|0]<<2)>>2];F[e+12>>2]=F[((G[c+3|0]<<7)+f|0)+(G[d+42|0]<<2)>>2];F[e+16>>2]=F[((G[c+4|0]<<7)+f|0)+(G[d+43|0]<<2)>>2];F[e+20>>2]=F[((G[c+5|0]<<7)+f|0)+(G[d+44|0]<<2)>>2];F[e+24>>2]=F[((G[c+6|0]<<7)+f|0)+(G[d+45|0]<<2)>>2];F[e+28>>2]=F[((G[c+7|0]<<7)+f|0)+(G[d+46|0]<<2)>>2];F[e+32>>2]=F[((G[c+8|0]<<7)+f|0)+(G[d+47|0]<<2)>>2];F[e+36>>2]=F[((G[c+9|0]<<7)+f|0)+(G[d+48|0]<<2)>>2];F[e+40>>2]=F[((G[c+10|0]<<7)+f|0)+(G[d+49|0]<<2)>>2];F[e+44>>2]=F[((G[c+11|0]<<7)+f|0)+(G[d+50|0]<<2)>>2];F[e+48>>2]=F[((G[c+12|0]<<7)+f|0)+(G[d+51|0]<<2)>>2];F[e+52>>2]=F[((G[c+13|0]<<7)+f|0)+(G[d+52|0]<<2)>>2];F[e+56>>2]=F[((G[c+14|0]<<7)+f|0)+(G[d+53|0]<<2)>>2];a=((G[c+15|0]<<7)+f|0)+(G[d+54|0]<<2)|0}F[e+60>>2]=F[a>>2]}Ea=f+416|0}function Nc(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;s=Ea-16|0;Ea=s;F[s+12>>2]=0;F[s+8>>2]=0;e=-44;z=Oc(d+740|0,d,s+8|0,s+12|0,b,c,d+128|0);a:{b:{if(z>>>0>4294967176){break b}t=F[s+12>>2];b=F[a>>2];if(t>>>0>(b&255)+1>>>0){break a}F[a>>2]=b&-16776961|t<<16&16711680;q=F[s+8>>2];e=0;c:{if((t|0)<0){break c}c=t+1|0;j=c&3;b=0;if(t>>>0>=3){n=c&-4;l=d- -64|0;while(1){i=e<<2;f=F[i+d>>2];F[i+l>>2]=b;c=i|4;h=F[c+d>>2];g=c+l|0;c=b+f|0;F[g>>2]=c;b=i|8;f=F[b+d>>2];h=c+h|0;F[b+l>>2]=h;b=i|12;c=F[b+d>>2];g=b+l|0;b=f+h|0;F[g>>2]=b;b=b+c|0;e=e+4|0;m=m+4|0;if((n|0)!=(m|0)){continue}break}}if(!j){break c}c=0;while(1){h=(e<<2)+d|0;F[h- -64>>2]=b;e=e+1|0;b=F[h>>2]+b|0;c=c+1|0;if((j|0)!=(c|0)){continue}break}}e=0;if((q|0)>3){h=q-3|0;i=d- -64|0;j=d+740|0;n=d+484|0;while(1){b=i+(G[e+j|0]<<2)|0;c=F[b>>2];F[b>>2]=c+1;D[c+n|0]=e;c=e|1;b=i+(G[c+j|0]<<2)|0;f=F[b>>2];F[b>>2]=f+1;D[f+n|0]=c;c=e|2;b=i+(G[c+j|0]<<2)|0;f=F[b>>2];F[b>>2]=f+1;D[f+n|0]=c;c=e|3;b=i+(G[c+j|0]<<2)|0;f=F[b>>2];F[b>>2]=f+1;D[f+n|0]=c;e=e+4|0;if((h|0)>(e|0)){continue}break}}d:{if((e|0)>=(q|0)){break d}b=e+1|0;if(q-e&1){c=((G[(d+e|0)+740|0]<<2)+d|0)- -64|0;h=F[c>>2];F[c>>2]=h+1;D[(d+h|0)+484|0]=e;e=b}if((b|0)==(q|0)){break d}j=d- -64|0;n=d+740|0;f=d+484|0;while(1){b=j+(G[e+n|0]<<2)|0;c=F[b>>2];F[b>>2]=c+1;D[c+f|0]=e;c=e+1|0;b=j+(G[c+n|0]<<2)|0;h=F[b>>2];F[b>>2]=h+1;D[f+h|0]=c;e=e+2|0;if((q|0)!=(e|0)){continue}break}}q=t+1|0;if(q>>>0<2){break b}r=a+4|0;m=F[d>>2];c=0;e=1;while(1){n=e;g=q-e|0;k=F[(e<<2)+d>>2];e:{f:{g:{h:{i:{j:{l=1<>1;switch(y-1|0){case 0:break g;case 1:break h;case 3:break i;case 7:break j;default:break f}}if((k|0)<=0){break e}l=g<<8&65280;e=0;b=c;if((k|0)!=1){i=k&-2;a=0;while(1){f=r+(b<<1)|0;j=d+484|0;h=We(l|G[j+(e+m|0)|0],0,65537,65537);D[f+8|0]=h;o=h>>>8|0;D[f+9|0]=o;p=h>>>16|0;D[f+10|0]=p;u=h>>>24|0;D[f+11|0]=u;g=Fa;D[f+12|0]=g;v=g>>>8|0;D[f+13|0]=v;w=g>>>16|0;D[f+14|0]=w;x=g>>>24|0;D[f+15|0]=x;D[f|0]=h;D[f+1|0]=o;D[f+2|0]=p;D[f+3|0]=u;D[f+4|0]=g;D[f+5|0]=v;D[f+6|0]=w;D[f+7|0]=x;h=We(l|G[j+((e|1)+m|0)|0],0,65537,65537);D[f+24|0]=h;D[f+25|0]=h>>>8;D[f+26|0]=h>>>16;D[f+27|0]=h>>>24;j=Fa;D[f+28|0]=j;g=j>>>8|0;D[f+29|0]=g;o=j>>>16|0;D[f+30|0]=o;p=j>>>24|0;D[f+31|0]=p;D[f+16|0]=h;D[f+17|0]=h>>>8;D[f+18|0]=h>>>16;D[f+19|0]=h>>>24;D[f+20|0]=j;D[f+21|0]=g;D[f+22|0]=o;D[f+23|0]=p;e=e+2|0;b=b+16|0;a=a+2|0;if((i|0)!=(a|0)){continue}break}}if(!(k&1)){break e}a=We(l|G[((e+m|0)+d|0)+484|0],0,65537,65537);e=r+(b<<1)|0;D[e+8|0]=a;h=a>>>8|0;D[e+9|0]=h;f=a>>>16|0;D[e+10|0]=f;g=a>>>24|0;D[e+11|0]=g;b=Fa;D[e+12|0]=b;i=b>>>8|0;D[e+13|0]=i;j=b>>>16|0;D[e+14|0]=j;l=b>>>24|0;D[e+15|0]=l;D[e|0]=a;D[e+1|0]=h;D[e+2|0]=f;D[e+3|0]=g;D[e+4|0]=b;D[e+5|0]=i;D[e+6|0]=j;D[e+7|0]=l;break e}if((k|0)<=0){break e}l=g<<8&65280;e=0;b=c;if((k|0)!=1){i=k&-2;h=0;while(1){a=r+(b<<1)|0;j=d+484|0;f=We(l|G[j+(e+m|0)|0],0,65537,65537);D[a|0]=f;D[a+1|0]=f>>>8;D[a+2|0]=f>>>16;D[a+3|0]=f>>>24;f=Fa;D[a+4|0]=f;D[a+5|0]=f>>>8;D[a+6|0]=f>>>16;D[a+7|0]=f>>>24;f=We(l|G[j+((e|1)+m|0)|0],0,65537,65537);D[a+8|0]=f;D[a+9|0]=f>>>8;D[a+10|0]=f>>>16;D[a+11|0]=f>>>24;f=Fa;D[a+12|0]=f;D[a+13|0]=f>>>8;D[a+14|0]=f>>>16;D[a+15|0]=f>>>24;e=e+2|0;b=b+8|0;h=h+2|0;if((i|0)!=(h|0)){continue}break}}if(!(k&1)){break e}b=r+(b<<1)|0;a=We(l|G[((e+m|0)+d|0)+484|0],0,65537,65537);D[b|0]=a;D[b+1|0]=a>>>8;D[b+2|0]=a>>>16;D[b+3|0]=a>>>24;a=Fa;D[b+4|0]=a;D[b+5|0]=a>>>8;D[b+6|0]=a>>>16;D[b+7|0]=a>>>24;break e}if((k|0)<=0){break e}b=0;h=c;if((k|0)!=1){j=k&-2;a=0;while(1){i=r+(h<<1)|0;f=d+484|0;e=G[f+(b+m|0)|0];D[i+2|0]=e;D[i+1|0]=g;D[i|0]=e;D[i+3|0]=g;e=G[f+((b|1)+m|0)|0];D[i+5|0]=g;D[i+4|0]=e;D[i+7|0]=g;D[i+6|0]=e;b=b+2|0;h=h+4|0;a=a+2|0;if((j|0)!=(a|0)){continue}break}}if(!(k&1)){break e}e=r+(h<<1)|0;a=G[((b+m|0)+d|0)+484|0];D[e+2|0]=a;D[e+1|0]=g;D[e|0]=a;D[e+3|0]=g;break e}if((k|0)<=0){break e}e=0;h=c;if((k|0)!=1){j=k&-2;a=0;while(1){f=d+484|0;b=G[f+(e+m|0)|0];i=r+(h<<1)|0;D[i+1|0]=g;D[i|0]=b;b=G[f+((e|1)+m|0)|0];D[i+3|0]=g;D[i+2|0]=b;e=e+2|0;h=h+2|0;a=a+2|0;if((j|0)!=(a|0)){continue}break}}if(!(k&1)){break e}b=G[((e+m|0)+d|0)+484|0];a=r+(h<<1)|0;D[a+1|0]=g;D[a|0]=b;break e}if((k|0)<=0){break e}i=g<<8&65280;h=0;a=c;while(1){if((l|0)>=2){f=We(i|G[((h+m|0)+d|0)+484|0],0,65537,65537);e=Fa;j=r+(a<<1)|0;b=0;while(1){g=j+(b<<1)|0;D[g+24|0]=f;o=f>>>8|0;D[g+25|0]=o;p=f>>>16|0;D[g+26|0]=p;u=f>>>24|0;D[g+27|0]=u;D[g+28|0]=e;v=e>>>8|0;D[g+29|0]=v;w=e>>>16|0;D[g+30|0]=w;x=e>>>24|0;D[g+31|0]=x;D[g+16|0]=f;D[g+17|0]=o;D[g+18|0]=p;D[g+19|0]=u;D[g+20|0]=e;D[g+21|0]=v;D[g+22|0]=w;D[g+23|0]=x;D[g+8|0]=f;D[g+9|0]=o;D[g+10|0]=p;D[g+11|0]=u;D[g+12|0]=e;D[g+13|0]=v;D[g+14|0]=w;D[g+15|0]=x;D[g|0]=f;D[g+1|0]=o;D[g+2|0]=p;D[g+3|0]=u;D[g+4|0]=e;D[g+5|0]=v;D[g+6|0]=w;D[g+7|0]=x;b=b+16|0;if((y|0)>(b|0)){continue}break}}a=a+y|0;h=h+1|0;if((k|0)!=(h|0)){continue}break}}e=n+1|0;m=k+m|0;c=L(k,y)+c|0;if((n|0)!=(t|0)){continue}break}}e=z}Ea=s+16|0;return e}function ge(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;if(F[a>>2]==-559038750){c=a+4|0;a:{b:{if(!F[c>>2]){break b}a=1;if(F[c+52>>2]!=1){break a}a=1;if(F[c+196>>2]){break a}m=F[c>>2]+F[c+72>>2]|0;e=m;f=G[e+4|0]|G[e+5|0]<<8|(G[e+6|0]<<16|G[e+7|0]<<24);a=G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24);D[c+124|0]=a;D[c+125|0]=a>>>8;D[c+126|0]=a>>>16;D[c+127|0]=a>>>24;D[c+128|0]=f;D[c+129|0]=f>>>8;D[c+130|0]=f>>>16;D[c+131|0]=f>>>24;f=G[e+12|0]|G[e+13|0]<<8|(G[e+14|0]<<16|G[e+15|0]<<24);a=G[e+8|0]|G[e+9|0]<<8|(G[e+10|0]<<16|G[e+11|0]<<24);D[c+132|0]=a;D[c+133|0]=a>>>8;D[c+134|0]=a>>>16;D[c+135|0]=a>>>24;D[c+136|0]=f;D[c+137|0]=f>>>8;D[c+138|0]=f>>>16;D[c+139|0]=f>>>24;a=G[e+16|0]|G[e+17|0]<<8|(G[e+18|0]<<16|G[e+19|0]<<24);D[c+140|0]=a;D[c+141|0]=a>>>8;D[c+142|0]=a>>>16;D[c+143|0]=a>>>24;g=F[c+128>>2];c:{if(!g){break c}e=F[c+132>>2];if(!e){break c}f=F[c+136>>2];if(!H[c+126>>1]|(!f|!H[c+124>>1])){break c}a=F[c+40>>2];i=L(F[c+48>>2],L(F[c+44>>2],a>>>0<=1?1:a));k=L(i,20);if(I[c+80>>2]<(F[c+140>>2]+(f+(e+(g+k|0)|0)|0)|0)+20>>>0){break c}d=F[c+148>>2];if((d|0)!=(i|0)){if(!(i>>>0<=I[c+152>>2]|d>>>0>i>>>0)){a=k;e=i;d:{if((e|0)!=(d+1|0)){break d}f=e-1|0;if(!(!e|f&e)){break d}a=0-!e|0;j=f|a;g=a>>>16|a;f=g>>>8|0;e=f|g;f=e>>>4|0;a=j|((a&65535)<<16|j>>>16);a=(g&255)<<24|a>>>8|a;a=(e&15)<<28|a>>>4|a;e=e|f;f=e>>>2|0;a=a|((e&3)<<30|a>>>2);e=(a|(((e|f)&1)<<31|a>>>1))+1|0;if(i>>>0>e>>>0){break c}a=L(e,20)}f=Ya(a);if(!f){break c}g=F[c+144>>2];e:{if(!d){break e}b=f;a=g;d=L(d,20);j=d-20|0;if(!((j>>>0)/20&1)){h=G[a|0]|G[a+1|0]<<8|(G[a+2|0]<<16|G[a+3|0]<<24);D[b|0]=h;D[b+1|0]=h>>>8;D[b+2|0]=h>>>16;D[b+3|0]=h>>>24;h=G[a+4|0]|G[a+5|0]<<8|(G[a+6|0]<<16|G[a+7|0]<<24);D[b+4|0]=h;D[b+5|0]=h>>>8;D[b+6|0]=h>>>16;D[b+7|0]=h>>>24;h=G[a+8|0]|G[a+9|0]<<8|(G[a+10|0]<<16|G[a+11|0]<<24);D[b+8|0]=h;D[b+9|0]=h>>>8;D[b+10|0]=h>>>16;D[b+11|0]=h>>>24;h=G[a+12|0]|G[a+13|0]<<8|(G[a+14|0]<<16|G[a+15|0]<<24);D[b+12|0]=h;D[b+13|0]=h>>>8;D[b+14|0]=h>>>16;D[b+15|0]=h>>>24;h=G[a+16|0]|G[a+17|0]<<8|(G[a+18|0]<<16|G[a+19|0]<<24);D[b+16|0]=h;D[b+17|0]=h>>>8;D[b+18|0]=h>>>16;D[b+19|0]=h>>>24;b=b+20|0;a=a+20|0}if(j>>>0<20){break e}j=d+g|0;while(1){d=G[a|0]|G[a+1|0]<<8|(G[a+2|0]<<16|G[a+3|0]<<24);D[b|0]=d;D[b+1|0]=d>>>8;D[b+2|0]=d>>>16;D[b+3|0]=d>>>24;d=G[a+4|0]|G[a+5|0]<<8|(G[a+6|0]<<16|G[a+7|0]<<24);D[b+4|0]=d;D[b+5|0]=d>>>8;D[b+6|0]=d>>>16;D[b+7|0]=d>>>24;d=G[a+8|0]|G[a+9|0]<<8|(G[a+10|0]<<16|G[a+11|0]<<24);D[b+8|0]=d;D[b+9|0]=d>>>8;D[b+10|0]=d>>>16;D[b+11|0]=d>>>24;d=G[a+12|0]|G[a+13|0]<<8|(G[a+14|0]<<16|G[a+15|0]<<24);D[b+12|0]=d;D[b+13|0]=d>>>8;D[b+14|0]=d>>>16;D[b+15|0]=d>>>24;d=G[a+16|0]|G[a+17|0]<<8|(G[a+18|0]<<16|G[a+19|0]<<24);D[b+16|0]=d;D[b+17|0]=d>>>8;D[b+18|0]=d>>>16;D[b+19|0]=d>>>24;d=G[a+20|0]|G[a+21|0]<<8|(G[a+22|0]<<16|G[a+23|0]<<24);D[b+20|0]=d;D[b+21|0]=d>>>8;D[b+22|0]=d>>>16;D[b+23|0]=d>>>24;d=G[a+24|0]|G[a+25|0]<<8|(G[a+26|0]<<16|G[a+27|0]<<24);D[b+24|0]=d;D[b+25|0]=d>>>8;D[b+26|0]=d>>>16;D[b+27|0]=d>>>24;d=G[a+28|0]|G[a+29|0]<<8|(G[a+30|0]<<16|G[a+31|0]<<24);D[b+28|0]=d;D[b+29|0]=d>>>8;D[b+30|0]=d>>>16;D[b+31|0]=d>>>24;d=G[a+32|0]|G[a+33|0]<<8|(G[a+34|0]<<16|G[a+35|0]<<24);D[b+32|0]=d;D[b+33|0]=d>>>8;D[b+34|0]=d>>>16;D[b+35|0]=d>>>24;d=G[a+36|0]|G[a+37|0]<<8|(G[a+38|0]<<16|G[a+39|0]<<24);D[b+36|0]=d;D[b+37|0]=d>>>8;D[b+38|0]=d>>>16;D[b+39|0]=d>>>24;b=b+40|0;a=a+40|0;if((j|0)!=(a|0)){continue}break}}if(g){Ra(g)}F[c+152>>2]=e;F[c+144>>2]=f}F[c+148>>2]=i}f=m+20|0;Va(F[c+144>>2],f,k);f:{if(!i){break f}e=F[c+144>>2];a=0;if(!G[c+1200|0]){while(1){b=0;g=e+L(a,20)|0;if(!(G[g+8|0]|G[g+9|0]<<8|(G[g+10|0]<<16|G[g+11|0]<<24))){break c}a=a+1|0;if((i|0)!=(a|0)){continue}break f}}while(1){b=0;g=e+L(a,20)|0;if(!(G[g+8|0]|G[g+9|0]<<8|(G[g+10|0]<<16|G[g+11|0]<<24))|!(G[g+16|0]|G[g+17|0]<<8|(G[g+18|0]<<16|G[g+19|0]<<24))){break c}a=a+1|0;if((i|0)!=(a|0)){continue}break}}b=0;e=c+188|0;f=f+k|0;a=f+F[c+128>>2]|0;if(!xb(e,a+F[c+132>>2]|0,F[c+136>>2])){break c}b=Eb(e,H[c+124>>1],f,F[c+128>>2],H[c+126>>1],a,F[c+132>>2])}if(!b){break b}a=1;if(G[c+1201|0]){break a}a=1;if(F[c+44>>2]!=1){break a}n=1;if(I[c+40>>2]<2){break b}f=F[c+148>>2];a=1;if(!f){break a}a=F[c+144>>2];while(1){if(!(G[a+L(l,20)|0]&2)){l=l+1|0;if((f|0)!=(l|0)){continue}break b}break}D[c+1201|0]=1}a=n}}else{a=0}return a|0}function sb(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=G[b|0];c=G[b+16|0];g=d>>>0>>0?d:c;e=G[b+32|0];h=e>>>0>g>>>0?g:e;g=G[b+48|0];i=g>>>0>h>>>0?h:g;h=G[b+4|0];k=G[b+20|0];j=h>>>0>>0?h:k;l=G[b+36|0];f=j>>>0>>0?j:l;j=G[b+52|0];f=f>>>0>>0?f:j;n=f>>>0>i>>>0?i:f;i=G[b+8|0];f=G[b+24|0];o=f>>>0>i>>>0?i:f;r=G[b+40|0];m=o>>>0>>0?o:r;o=G[b+56|0];m=m>>>0>>0?m:o;p=m>>>0>n>>>0?n:m;n=G[b+12|0];m=G[b+28|0];q=m>>>0>n>>>0?n:m;t=G[b+44|0];s=q>>>0>>0?q:t;q=G[b+60|0];s=q>>>0>s>>>0?s:q;p=p>>>0>>0?p:s;D[a+1|0]=p;d=d>>>0>c>>>0?d:c;d=d>>>0>e>>>0?d:e;d=d>>>0>g>>>0?d:g;c=h>>>0>k>>>0?h:k;c=c>>>0>l>>>0?c:l;c=c>>>0>j>>>0?c:j;d=d>>>0>c>>>0?d:c;c=f>>>0>>0?i:f;c=c>>>0>r>>>0?c:r;c=c>>>0>o>>>0?c:o;d=d>>>0>c>>>0?d:c;c=m>>>0>>0?n:m;c=c>>>0>t>>>0?c:t;c=c>>>0>q>>>0?c:q;c=d>>>0>c>>>0?d:c;D[a|0]=c;if((c|0)==(p|0)){D[a+2|0]=0;D[a+3|0]=0;D[a+4|0]=0;D[a+5|0]=0;D[a+6|0]=0;D[a+7|0]=0;return}r=G[b+44|0];o=G[b+40|0];n=G[b+32|0];m=G[b+36|0];t=G[b+48|0];q=G[b+52|0];s=G[b+56|0];u=G[b+60|0];g=L(p,-14)+4|0;d=g+L(G[b+20|0],14)|0;e=c-p|0;h=L(e,13);k=L(e,11);l=L(e,9);j=L(e,7);i=L(e,5);f=L(e,3);c=F[((((((((d|0)>=(h|0))+((k|0)<=(d|0))|0)+((l|0)<=(d|0))|0)+((j|0)<=(d|0))|0)+((i|0)<=(d|0))|0)+((f|0)<=(d|0))|0)+((d|0)>=(e|0))<<2)+13104>>2];d=g+L(G[b+16|0],14)|0;c=(c|F[((((((((d|0)>=(h|0))+((d|0)>=(k|0))|0)+((d|0)>=(l|0))|0)+((d|0)>=(j|0))|0)+((d|0)>=(i|0))|0)+((d|0)>=(f|0))|0)+((d|0)>=(e|0))<<2)+13072>>2])<<12;d=g+L(G[b+4|0],14)|0;c=c|F[((((((((d|0)>=(h|0))+((d|0)>=(k|0))|0)+((d|0)>=(l|0))|0)+((d|0)>=(j|0))|0)+((d|0)>=(i|0))|0)+((d|0)>=(f|0))|0)+((d|0)>=(e|0))<<2)+13104>>2];d=g+L(G[b|0],14)|0;c=c|F[((((((((d|0)>=(h|0))+((d|0)>=(k|0))|0)+((d|0)>=(l|0))|0)+((d|0)>=(j|0))|0)+((d|0)>=(i|0))|0)+((d|0)>=(f|0))|0)+((d|0)>=(e|0))<<2)+13072>>2];d=g+L(G[b+8|0],14)|0;p=F[((((((((d|0)>=(h|0))+((d|0)>=(k|0))|0)+((d|0)>=(l|0))|0)+((d|0)>=(j|0))|0)+((d|0)>=(i|0))|0)+((d|0)>=(f|0))|0)+((d|0)>=(e|0))<<2)+13136>>2];d=g+L(G[b+24|0],14)|0;c=c|(p|F[((((((((d|0)>=(h|0))+((d|0)>=(k|0))|0)+((d|0)>=(l|0))|0)+((d|0)>=(j|0))|0)+((d|0)>=(i|0))|0)+((d|0)>=(f|0))|0)+((d|0)>=(e|0))<<2)+13136>>2]<<12);d=g+L(G[b+12|0],14)|0;b=g+L(G[b+28|0],14)|0;d=c|(F[((((((((d|0)>=(h|0))+((d|0)>=(k|0))|0)+((d|0)>=(l|0))|0)+((d|0)>=(j|0))|0)+((d|0)>=(i|0))|0)+((d|0)>=(f|0))|0)+((d|0)>=(e|0))<<2)+13168>>2]|F[((((((((b|0)>=(h|0))+((b|0)>=(k|0))|0)+((b|0)>=(l|0))|0)+((b|0)>=(j|0))|0)+((b|0)>=(i|0))|0)+((b|0)>=(f|0))|0)+((b|0)>=(e|0))<<2)+13168>>2]<<12);D[a+2|0]=d;b=g+L(r,14)|0;c=F[((((((((b|0)>=(h|0))+((b|0)>=(k|0))|0)+((b|0)>=(l|0))|0)+((b|0)>=(j|0))|0)+((b|0)>=(i|0))|0)+((b|0)>=(f|0))|0)+((b|0)>=(e|0))<<2)+13168>>2];b=g+L(o,14)|0;o=F[((((((((b|0)>=(h|0))+((b|0)>=(k|0))|0)+((b|0)>=(l|0))|0)+((b|0)>=(j|0))|0)+((b|0)>=(i|0))|0)+((b|0)>=(f|0))|0)+((b|0)>=(e|0))<<2)+13136>>2];b=g+L(n,14)|0;n=F[((((((((b|0)>=(h|0))+((b|0)>=(k|0))|0)+((b|0)>=(l|0))|0)+((b|0)>=(j|0))|0)+((b|0)>=(i|0))|0)+((b|0)>=(f|0))|0)+((b|0)>=(e|0))<<2)+13072>>2];b=g+L(m,14)|0;b=c|(o|(n|F[((((((((b|0)>=(h|0))+((b|0)>=(k|0))|0)+((b|0)>=(l|0))|0)+((b|0)>=(j|0))|0)+((b|0)>=(i|0))|0)+((b|0)>=(f|0))|0)+((b|0)>=(e|0))<<2)+13104>>2]));c=b>>>8|0;r=b<<24;b=c;c=g+L(t,14)|0;m=F[((((((((c|0)>=(h|0))+((c|0)>=(k|0))|0)+((c|0)>=(l|0))|0)+((c|0)>=(j|0))|0)+((c|0)>=(i|0))|0)+((c|0)>=(f|0))|0)+((c|0)>=(e|0))<<2)+13072>>2];c=g+L(q,14)|0;n=F[((((((((c|0)>=(h|0))+((c|0)>=(k|0))|0)+((c|0)>=(l|0))|0)+((c|0)>=(j|0))|0)+((c|0)>=(i|0))|0)+((c|0)>=(f|0))|0)+((c|0)>=(e|0))<<2)+13104>>2];c=g+L(s,14)|0;o=F[((((((((c|0)>=(h|0))+((c|0)>=(k|0))|0)+((c|0)>=(l|0))|0)+((c|0)>=(j|0))|0)+((c|0)>=(i|0))|0)+((c|0)>=(f|0))|0)+((c|0)>=(e|0))<<2)+13136>>2];c=g+L(u,14)|0;c=b|(m|(n|(o|F[((((((((c|0)>=(h|0))+((c|0)>=(k|0))|0)+((c|0)>=(l|0))|0)+((c|0)>=(j|0))|0)+((c|0)>=(i|0))|0)+((c|0)>=(f|0))|0)+((c|0)>=(e|0))<<2)+13168>>2])))<<4;D[a+7|0]=c>>>8;D[a+6|0]=c;D[a+4|0]=d>>>16;D[a+3|0]=d>>>8;D[a+5|0]=(b&16777215)<<8|(d|r)>>>24}function Ob(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,I=0,J=0;q=Ea-128|0;Ea=q;F[q+124>>2]=d;o=-1;a:{b:{switch(c|0){case 1:if(!g){o=-72;break a}o=-20;c=G[f|0];if(c>>>0>d>>>0){break a}c=c<<2;d=F[c+i>>2];c=F[c+h>>2];D[a+11|0]=0;F[a>>2]=0;F[a+4>>2]=0;F[a+12>>2]=c;D[a+10|0]=d;E[a+8>>1]=0;F[b>>2]=a;o=1;break a;case 0:F[b>>2]=j;o=0;break a;case 3:if(!k){o=-20;break a}o=0;if(!l|(m|0)<25){break a}b=8<>>6|0)+1|0;a=c&7;d=0;if(b>>>0>=448){b=c&134217720;c=0;while(1){d=d+512|0;c=c+8|0;if((b|0)!=(c|0)){continue}break}}if(!a){break a}c=0;while(1){d=d- -64|0;c=c+1|0;if((a|0)!=(c|0)){continue}break};break a;case 2:break b;default:break a}}o=-20;j=Qb(q,q+124|0,q+120|0,f,g);if(j>>>0>4294967176){break a}c=F[q+120>>2];if(c>>>0>e>>>0){break a}k=h;e=0;l=0;m=0;f=0;z=n+106|0;v=a+8|0;o=1;h=c;w=1<>2];e:{if((y|0)==-1){F[a+4>>2]=c;F[a>>2]=1;f=((w>>>3)+(w>>>1)|0)+3|0;break e}c=y+1|0;t=c&1;r=65536<>16;f:{if(!y){c=d;break f}u=c&-2;c=d;while(1){p=e<<1;g=H[p+q>>1];g:{if((g|0)==65535){F[((c<<3)+v|0)+4>>2]=e;c=c-1|0;g=1;break g}o=(r|0)>g<<16>>16?o:0}E[n+p>>1]=g;p=e|1;s=p<<1;g=H[s+q>>1];h:{if((g|0)!=65535){o=(r|0)>g<<16>>16?o:0;break h}F[((c<<3)+v|0)+4>>2]=p;c=c-1|0;g=1}E[n+s>>1]=g;e=e+2|0;f=f+2|0;if((u|0)!=(f|0)){continue}break}}if(t){g=H[(e<<1)+q>>1];i:{if((g|0)!=65535){o=(r|0)>g<<16>>16?o:0;break i}F[((c<<3)+v|0)+4>>2]=e;c=c-1|0;g=1}E[(e<<1)+n>>1]=g}F[a+4>>2]=h;F[a>>2]=o;C=w>>>3|0;if((c|0)!=(d|0)){break d}f=0;e=0;while(1){g=e;A=E[(e<<1)+q>>1];B=f+z|0;c=B;D[c|0]=m;D[c+1|0]=m>>>8;D[c+2|0]=m>>>16;D[c+3|0]=m>>>24;D[c+4|0]=l;D[c+5|0]=l>>>8;D[c+6|0]=l>>>16;D[c+7|0]=l>>>24;j:{if((A|0)<9){break j}e=A-9|0;o=(e>>>3|0)+1|0;I=o&7;c=8;if(e>>>0>=56){J=o&1073741816;o=0;while(1){e=c+B|0;D[e|0]=m;r=m>>>8|0;D[e+1|0]=r;t=m>>>16|0;D[e+2|0]=t;u=m>>>24|0;D[e+3|0]=u;D[e+4|0]=l;p=l>>>8|0;D[e+5|0]=p;s=l>>>16|0;D[e+6|0]=s;x=l>>>24|0;D[e+7|0]=x;D[e+56|0]=m;D[e+57|0]=r;D[e+58|0]=t;D[e+59|0]=u;D[e+60|0]=l;D[e+61|0]=p;D[e+62|0]=s;D[e+63|0]=x;D[e+48|0]=m;D[e+49|0]=r;D[e+50|0]=t;D[e+51|0]=u;D[e+52|0]=l;D[e+53|0]=p;D[e+54|0]=s;D[e+55|0]=x;D[e+40|0]=m;D[e+41|0]=r;D[e+42|0]=t;D[e+43|0]=u;D[e+44|0]=l;D[e+45|0]=p;D[e+46|0]=s;D[e+47|0]=x;D[e+32|0]=m;D[e+33|0]=r;D[e+34|0]=t;D[e+35|0]=u;D[e+36|0]=l;D[e+37|0]=p;D[e+38|0]=s;D[e+39|0]=x;D[e+24|0]=m;D[e+25|0]=r;D[e+26|0]=t;D[e+27|0]=u;D[e+28|0]=l;D[e+29|0]=p;D[e+30|0]=s;D[e+31|0]=x;D[e+16|0]=m;D[e+17|0]=r;D[e+18|0]=t;D[e+19|0]=u;D[e+20|0]=l;D[e+21|0]=p;D[e+22|0]=s;D[e+23|0]=x;D[e+8|0]=m;D[e+9|0]=r;D[e+10|0]=t;D[e+11|0]=u;D[e+12|0]=l;D[e+13|0]=p;D[e+14|0]=s;D[e+15|0]=x;c=c- -64|0;o=o+8|0;if((J|0)!=(o|0)){continue}break}}e=0;if(!I){break j}while(1){o=c+B|0;D[o|0]=m;D[o+1|0]=m>>>8;D[o+2|0]=m>>>16;D[o+3|0]=m>>>24;D[o+4|0]=l;D[o+5|0]=l>>>8;D[o+6|0]=l>>>16;D[o+7|0]=l>>>24;c=c+8|0;e=e+1|0;if((I|0)!=(e|0)){continue}break}}c=l+16843009|0;m=m+16843009|0;l=m>>>0<16843009?c+1|0:c;e=g+1|0;f=f+A|0;if((g|0)!=(y|0)){continue}break}f=(C+(w>>>1|0)|0)+3|0}g=f<<1;e=0;c=0;while(1){F[(((c&d)<<3)+v|0)+4>>2]=G[e+z|0];F[(((d&c+f)<<3)+v|0)+4>>2]=G[z+(e|1)|0];c=d&c+g;e=e+2|0;if(w>>>0>e>>>0){continue}break}break c}l=(C+(w>>>1|0)|0)+3|0;e=0;f=0;while(1){g=f;m=E[(g<<1)+q>>1];k:{if((m|0)<=0){break k}if((m|0)!=1){o=m&-2;f=0;while(1){F[((e<<3)+v|0)+4>>2]=g;while(1){e=d&e+l;if(c>>>0>>0){continue}break}F[((e<<3)+v|0)+4>>2]=g;while(1){e=d&e+l;if(c>>>0>>0){continue}break}f=f+2|0;if((o|0)!=(f|0)){continue}break}}if(!(m&1)){break k}F[((e<<3)+v|0)+4>>2]=g;while(1){e=d&e+l;if(c>>>0>>0){continue}break}}f=g+1|0;if((g|0)!=(y|0)){continue}break}}f=h+1|0;d=0;while(1){c=(d<<3)+v|0;g=F[c+4>>2];h=(g<<1)+n|0;e=H[h>>1];E[h>>1]=e+1;h=f+(O(e)^-32)|0;D[c+3|0]=h;E[c>>1]=(e<>2];F[c+4>>2]=F[e+k>>2];d=d+1|0;if((w|0)!=(d|0)){continue}break}F[b>>2]=a;o=j}Ea=q+128|0;return o}function ac(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0;e=Ea-256|0;Ea=e;g=F[a+4>>2];a:{if(!b){if((g|0)>0){F[a+4>>2]=0}b=F[a+16>>2];if((b|0)>0){F[a+16>>2]=b&-1073741824}o=1;b=F[a+28>>2];if((b|0)<=0){break a}F[a+28>>2]=b&-2147483648;break a}if((b|0)!=(g|0)){if(b>>>0>=g>>>0){if(I[a+8>>2]>>0){Wa(a,b,(g+1|0)==(b|0),1);g=F[a+4>>2]}Ta(F[a>>2]+g|0,0,b-g|0)}F[a+4>>2]=b}Va(F[a>>2],c,b);if(F[a+16>>2]){F[a+16>>2]=0}p=a+12|0;g=0;if(I[a+20>>2]<1024){Wa(p,1024,0,4);g=F[a+16>>2]}Ta(F[a+12>>2]+(g<<2)|0,0,1024-g<<2);F[a+16>>2]=1024;if(F[a+28>>2]){F[a+28>>2]=0}n=a+24|0;f=b<<1;if(f){if(f>>>0>I[a+32>>2]){Wa(n,f,0,2);h=F[a+28>>2]}Ta(F[a+24>>2]+(h<<1)|0,0,f-h<<1);F[a+28>>2]=f}Ta(e+128|0,0,128);g=0;while(1){f=G[c+g|0];if(f>>>0>31){break a}f=(e+128|0)+(f<<2)|0;F[f>>2]=F[f>>2]+1;g=g+1|0;if((g|0)!=(b|0)){continue}break}F[e+4>>2]=0;f=F[e+132>>2];j=f<<1;F[e+8>>2]=j;g=j;j=F[e+136>>2];g=g+j<<1;F[e+12>>2]=g;h=g;g=F[e+140>>2];h=h+g<<1;F[e+16>>2]=h;i=h;h=F[e+144>>2];i=i+h<<1;F[e+20>>2]=i;k=i;i=F[e+148>>2];l=k+i<<1;F[e+24>>2]=l;k=l;l=F[e+152>>2];k=k+l<<1;F[e+28>>2]=k;m=k;k=F[e+156>>2];m=m+k<<1;F[e+32>>2]=m;d=m;m=F[e+160>>2];d=d+m<<1;F[e+36>>2]=d;q=F[e+164>>2];d=d+q<<1;F[e+40>>2]=d;r=F[e+168>>2];d=d+r<<1;F[e+44>>2]=d;s=F[e+172>>2];d=d+s<<1;F[e+48>>2]=d;t=F[e+176>>2];d=d+t<<1;F[e+52>>2]=d;u=F[e+180>>2];d=d+u<<1;F[e+56>>2]=d;v=F[e+184>>2];d=d+v<<1;F[e+60>>2]=d;w=F[e+188>>2];d=d+w<<1;F[e+64>>2]=d;x=F[e+192>>2];d=d+x<<1;F[e+68>>2]=d;y=F[e+196>>2];d=d+y<<1;F[e+72>>2]=d;z=F[e+200>>2];d=d+z<<1;F[e+76>>2]=d;A=F[e+204>>2];d=d+A<<1;F[e+80>>2]=d;B=F[e+208>>2];d=d+B<<1;F[e+84>>2]=d;C=F[e+212>>2];d=d+C<<1;F[e+88>>2]=d;D=F[e+216>>2];d=d+D<<1;F[e+92>>2]=d;J=F[e+220>>2];d=d+J<<1;F[e+96>>2]=d;K=F[e+224>>2];d=d+K<<1;F[e+100>>2]=d;L=F[e+228>>2];d=d+L<<1;F[e+104>>2]=d;M=F[e+232>>2];d=d+M<<1;F[e+108>>2]=d;N=F[e+236>>2];d=d+N<<1;F[e+112>>2]=d;O=F[e+240>>2];d=d+O<<1;F[e+116>>2]=d;P=F[e+244>>2];d=d+P<<1;F[e+120>>2]=d;Q=F[e+248>>2];d=d+Q<<1;F[e+124>>2]=d;if((d|0)!=-2147483648&(((((((((((((((((((((((m+(k+(l+(i+(h+(g+(f+j|0)|0)|0)|0)|0)|0)|0)+q|0)+r|0)+s|0)+t|0)+u|0)+v|0)+w|0)+x|0)+y|0)+z|0)+A|0)+B|0)+C|0)+D|0)+J|0)+K|0)+L|0)+M|0)+N|0)+O|0)+P|0)+Q|0)!=1){break a}o=1;if((b|0)<=0){break a}o=0;l=0;f=-1;while(1){i=G[c+l|0];b:{if(!i){break b}j=(i<<2)+e|0;g=F[j>>2];F[j>>2]=g+1;j=i&3;k=0;c:{if(i>>>0<4){h=0;break c}d=i&252;h=0;m=0;while(1){h=g>>>3&1|(g>>>2&1|(g&2|(g<<2&4|h<<3)))<<1;g=g>>>4|0;m=m+4|0;if((d|0)!=(m|0)){continue}break}}if(j){while(1){h=g&1|h<<1;g=g>>>1|0;k=k+1|0;if((j|0)!=(k|0)){continue}break}}if(i>>>0<=10){if(h>>>0>=1024){break b}j=i<<16|l;g=1<>2]+(h<<2)|0;if(F[i>>2]){break a}F[i>>2]=j;h=g+h|0;if(h>>>0<1024){continue}break}break b}j=F[p>>2]+((h&1023)<<2)|0;g=F[j>>2];d:{if(g){j=f;f=g;break d}F[j>>2]=f;j=f-2|0}if((f|0)>=0){break a}k=h>>>9|0;if((i|0)>11){while(1){k=k>>>1|0;f=f-(k&1)|0;if((f|0)>=0){break a}g=F[a+28>>2];h=f^-1;e:{if((g|0)>(h|0)){break e}f=0-f|0;if((f|0)==(g|0)){break e}if(g>>>0<=f>>>0){if(f>>>0>I[a+32>>2]){Wa(n,f,(f|0)==(g+1|0),2);g=F[a+28>>2]}Ta(F[n>>2]+(g<<1)|0,0,f-g<<1)}F[a+28>>2]=f}g=F[n>>2]+(h<<1)|0;f=E[g>>1];f:{if(!f){E[g>>1]=j;f=j;j=f-2|0;break f}if((f|0)>=0){break a}}i=i-1|0;if((i|0)>11){continue}break}}f=(k>>>1&1)-f|0;if((f|0)<=0){break a}h=F[a+28>>2];if((f|0)>(h|0)){if(f>>>0>=h>>>0){if(f>>>0>I[a+32>>2]){Wa(n,f,(f|0)==(h+1|0),2);h=F[a+28>>2]}Ta(F[n>>2]+(h<<1)|0,0,f-h<<1)}F[a+28>>2]=f}f=F[n>>2]+(f-1<<1)|0;if(H[f>>1]){break a}E[f>>1]=l;f=j}l=l+1|0;o=(l|0)>=(b|0);if((b|0)!=(l|0)){continue}break}}Ea=e+256|0;return o}function id(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;d=Ea-96|0;Ea=d;F[a>>2]=0;F[a+4>>2]=0;F[a+56>>2]=0;F[a+48>>2]=0;F[a+52>>2]=0;F[a+40>>2]=0;F[a+44>>2]=0;F[a+32>>2]=0;F[a+36>>2]=0;F[a+24>>2]=0;F[a+28>>2]=0;F[a+16>>2]=0;F[a+20>>2]=0;F[a+8>>2]=0;F[a+12>>2]=0;a:{if(F[b>>2]!=-559038751){break a}F[d+76>>2]=0;F[d+60>>2]=0;F[d+68>>2]=0;F[d+72>>2]=0;F[d+52>>2]=0;F[d+56>>2]=0;c=F[b+592>>2];b:{if(!lc(c,F[b+596>>2])){break b}b=c+8|0;g=65535;e=69;while(1){f=G[b|0]^(g&65280)>>>8;f=f>>>4^f;g=(f|g<<8)^f<<5;f=g^f<<12;if((e|0)!=1){f=G[b+1|0]^(f&65280)>>>8;f=f>>>4^f;g=(f|g<<8)^f<<5^f<<12;e=e-2|0;b=b+2|0;continue}break}if(((f^-1)&65535)!=(G[c+6|0]|G[c+7|0]<<8)){break b}e=G[c+65|0]|G[c+66|0]<<8|(G[c+67|0]<<16|G[c+68|0]<<24);F[d>>2]=G[c+2|0]|G[c+3|0]<<8;F[d+4>>2]=L(G[c+14|0]|(G[c+15|0]<<8|G[c+16|0]<<16),23)+77;F[d+8>>2]=G[c+48|0]|G[c+49|0]<<8;F[d+12>>2]=G[c+50|0]|G[c+51|0]<<8|(G[c+52|0]<<16|G[c+53|0]<<24);F[d+16>>2]=G[c+54|0]|(G[c+55|0]<<8|G[c+56|0]<<16);F[d+20>>2]=G[c+39|0]|G[c+40|0]<<8;F[d+24>>2]=G[c+41|0]|G[c+42|0]<<8|(G[c+43|0]<<16|G[c+44|0]<<24);F[d+28>>2]=G[c+45|0]|(G[c+46|0]<<8|G[c+47|0]<<16);F[d+32>>2]=G[c+57|0]|G[c+58|0]<<8|(G[c+59|0]<<16|G[c+60|0]<<24);F[d+36>>2]=G[c+61|0]|G[c+62|0]<<8|(G[c+63|0]<<16|G[c+64|0]<<24);F[d+88>>2]=G[c+20|0];D[d+93|0]=!G[c+20|0];D[d+92|0]=G[c+21|0]>>>1&1;D[d+94|0]=G[c+21|0]>>>2&1;f=G[c+14|0]|(G[c+15|0]<<8|G[c+16|0]<<16);b=F[d+56>>2];if((f|0)!=(b|0)){if(!(b>>>0>f>>>0|I[d+60>>2]>=f>>>0)){Wa(d+52|0,f,(b+1|0)==(f|0),52)}F[d+56>>2]=f}F[d+40>>2]=0;b=G[c+23|0];F[d+44>>2]=b;if(b>>>0>5){break b}F[d+48>>2]=G[c+24|0]|(G[c+25|0]<<8|G[c+26|0]<<16);F[d+80>>2]=G[c+31|0]|G[c+32|0]<<8|(G[c+33|0]<<16|G[c+34|0]<<24);F[d+84>>2]=G[c+35|0]|G[c+36|0]<<8|(G[c+37|0]<<16|G[c+38|0]<<24);if(F[d+72>>2]){F[d+72>>2]=0}j=d+68|0;g=0;b=G[c+17|0]|(G[c+18|0]<<8|G[c+19|0]<<16);if(b){if(b>>>0>I[d+76>>2]){Wa(j,b,(b|0)==1,4);g=F[d+72>>2]}Ta(F[d+68>>2]+(g<<2)|0,0,b-g<<2);F[d+72>>2]=b;b=G[c+17|0]|(G[c+18|0]<<8|G[c+19|0]<<16)}else{b=0}F[d+64>>2]=b;if(!f){k=1;break b}l=c+e|0;g=0;while(1){b=l+L(g,23)|0;F[d+40>>2]=F[d+40>>2]+(G[b+17|0]|G[b+18|0]<<8|(G[b+19|0]<<16|G[b+20|0]<<24));e=F[d+52>>2]+L(g,52)|0;F[e>>2]=G[b+5|0]|G[b+6|0]<<8;F[e+4>>2]=G[b+7|0]|G[b+8|0]<<8;F[e+8>>2]=G[b+9|0]<<2|G[b+10|0]<<10;F[e+12>>2]=G[b+11|0]<<2|G[b+12|0]<<10;h=G[b+9|0]|G[b+10|0]<<8;F[e+16>>2]=h;i=G[b+11|0]|G[b+12|0]<<8;F[e+20>>2]=i;F[e+24>>2]=L(h,i);h=G[b+17|0]|G[b+18|0]<<8|(G[b+19|0]<<16|G[b+20|0]<<24);F[e+32>>2]=g;F[e+28>>2]=h;F[e+36>>2]=G[b|0]|(G[b+1|0]<<8|G[b+2|0]<<16);F[e+40>>2]=G[b+3|0];F[e+44>>2]=G[b+21|0]|G[b+22|0]<<8;D[e+48|0]=D[b+4|0]&1;D[e+49|0]=G[b+4|0]>>>1&1;e=G[b|0]|(G[b+1|0]<<8|G[b+2|0]<<16);if(e>>>0>=(G[c+17|0]|(G[c+18|0]<<8|G[c+19|0]<<16))>>>0){break b}h=F[j>>2]+(e<<2)|0;e=F[h>>2];i=h;h=G[b+3|0]+1|0;F[i>>2]=e>>>0>h>>>0?e:h;if(I[F[j>>2]+((G[b|0]|(G[b+1|0]<<8|G[b+2|0]<<16))<<2)>>2]>=17){break b}g=g+1|0;k=f>>>0<=g>>>0;if((f|0)!=(g|0)){continue}break}}if(k){F[a>>2]=F[d>>2];F[a+4>>2]=F[d+48>>2];F[a+8>>2]=F[d+64>>2];F[a+12>>2]=F[d+80>>2];F[a+16>>2]=F[d+84>>2];F[a+20>>2]=F[d+88>>2];D[a+24|0]=G[d+92|0];D[a+25|0]=G[d+94|0];F[a+28>>2]=F[d+20>>2];F[a+32>>2]=F[d+24>>2];F[a+36>>2]=F[d+28>>2];F[a+40>>2]=F[d+8>>2];F[a+44>>2]=F[d+12>>2];F[a+48>>2]=F[d+16>>2];F[a+52>>2]=F[d+32>>2];F[a+56>>2]=F[d+36>>2]}a=F[d+68>>2];if(a){Ra(a)}a=F[d+52>>2];if(!a){break a}Ra(a)}Ea=d+96|0}function bb(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;g=Ea-96|0;Ea=g;if(F[b+4>>2]>0){F[b+4>>2]=0}c=F[b+16>>2];if((c|0)>0){F[b+16>>2]=c&-1073741824}c=F[b+28>>2];if((c|0)>0){F[b+28>>2]=c&-2147483648}e=F[a+20>>2];a:{if(e>>>0>=14){d=F[a+16>>2];break a}h=F[a+16>>2];c=F[a+4>>2];j=F[a+12>>2];b:{if(c>>>0>=j>>>0){f=c;break b}f=c+1|0;F[a+4>>2]=f;d=G[c|0]}c=e+8|0;F[a+20>>2]=c;d=h|d<>2]=d;if(e>>>0>5){e=c;break a}if(f>>>0>>0){F[a+4>>2]=f+1;i=G[f|0]}e=e+16|0;F[a+20>>2]=e;d=i<>2]=d}f=e-14|0;F[a+20>>2]=f;c=d>>>14|0;F[a+16>>2]=c;j=d&16383;c:{if(!j){d=1;break c}D[g+77|0]=0;D[g+78|0]=0;D[g+79|0]=0;D[g+80|0]=0;D[g+81|0]=0;D[g+82|0]=0;D[g+83|0]=0;D[g+84|0]=0;F[g+72>>2]=0;F[g+76>>2]=0;F[g+64>>2]=0;F[g+68>>2]=0;if(f>>>0<=4){d=F[a+4>>2];if(d>>>0>2]){F[a+4>>2]=d+1;d=G[d|0]}else{d=0}c=d<>2]=e;i=c>>>5|0;F[a+16>>2]=i;d=0;k=c&31;if(k-22>>>0<4294967275){break c}h=F[a+4>>2];l=F[a+12>>2];while(1){d:{if(e>>>0>2){c=i;break d}c=0;if(h>>>0>>0){f=h+1|0;F[a+4>>2]=f;c=G[h|0];h=f}c=c<>2]=e;i=c>>>3|0;F[a+16>>2]=i;f=g- -64|0;D[f+G[d+74672|0]|0]=c&7;d=d+1|0;if((k|0)!=(d|0)){continue}break}d=0;F[g+56>>2]=0;F[g+48>>2]=0;F[g+52>>2]=0;F[g+40>>2]=0;F[g+44>>2]=0;F[g+32>>2]=0;F[g+36>>2]=0;F[g+24>>2]=0;F[g+28>>2]=0;e:{if(!ac(g+24|0,21,f)|!F[g+28>>2]){break e}F[g+20>>2]=0;F[g+12>>2]=0;F[g+16>>2]=0;Wa(g+12|0,j,(j|0)==1,1);k=F[g+12>>2];c=F[g+16>>2];Ta(k+c|0,0,j-c|0);F[g+16>>2]=j;h=0;f:{g:{while(1){c=F[a+20>>2];h:{if(c>>>0>=16){i=F[a+16>>2];break h}e=0;d=F[a+4>>2];l=F[a+12>>2];i:{if(d>>>0>=l>>>0){f=d;break i}f=d+1|0;F[a+4>>2]=f;e=G[d|0]}i=F[a+16>>2];d=c+8|0;F[a+20>>2]=d;i=i|e<>2]=i;if(c>>>0>7){c=d;break h}e=0;if(f>>>0>>0){F[a+4>>2]=f+1;e=G[f|0]}c=c+16|0;F[a+20>>2]=c;i=e<>2]=i}d=F[F[g+36>>2]+((i&1023)<<2)>>2];j:{if((d|0)<0){e=10;f=F[g+48>>2];while(1){l=i>>>e|0;e=e+1|0;d=E[f+((l&1)+(d^-1)<<1)>>1];if((d|0)<0){continue}break}break j}e=d>>>16|0;d=d&65535}c=c-e|0;F[a+20>>2]=c;e=i>>>e|0;F[a+16>>2]=e;k:{if((d|0)<=16){D[h+k|0]=d;h=h+1|0;break k}l:{switch(d-17|0){case 0:if(c>>>0<=2){f=F[a+4>>2];if(f>>>0>2]){F[a+4>>2]=f+1;d=G[f|0]}else{d=0}e=d<>2]=c-3;F[a+16>>2]=e>>>3;h=((e&7)+h|0)+3|0;break k;case 1:if(c>>>0<=6){f=F[a+4>>2];if(f>>>0>2]){F[a+4>>2]=f+1;d=G[f|0]}else{d=0}e=d<>2]=c-7;F[a+16>>2]=e>>>7;h=((e&127)+h|0)+11|0;break k;default:break l}}f=0;if(!h){break g}m:{if((d|0)==19){if(c>>>0<=1){f=F[a+4>>2];if(f>>>0>2]){F[a+4>>2]=f+1;d=G[f|0]}else{d=0}e=d<>2]=c-2;F[a+16>>2]=e>>>2;e=(e&3)+3|0;break m}if(c>>>0<=6){f=F[a+4>>2];if(f>>>0>2]){F[a+4>>2]=f+1;d=G[f|0]}else{d=0}e=d<>2]=c-7;F[a+16>>2]=e>>>7;e=(e&127)+7|0}c=G[(h+k|0)-1|0];if(!c){d=0;break f}d=h>>>0>j>>>0?h:j;while(1){f=0;if((d|0)==(h|0)){break g}D[h+k|0]=c;h=h+1|0;e=e-1|0;if(e){continue}break}}if(h>>>0>>0){continue}break}f=0;if((h|0)!=(j|0)){break g}f=ac(b,j,k)}d=f;if(!k){break e}}Ra(k)}a=F[g+48>>2];if(a){Ra(a)}a=F[g+36>>2];if(a){Ra(a)}a=F[g+24>>2];if(!a){break c}Ra(a)}Ea=g+96|0;return d}function Sc(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;g=F[a+4>>2]&2147450878|-2147450880;F[a+4>>2]=g;e=G[b+4|0];d=G[c+8|0];f=G[c+9|0];if((d|0)==(f|0)){d=F[((e<<4)+(d<<2)|0)+12752>>2];c=G[b+1|0];c=d+(c<<3|c>>>2)|0;f=(c|0)>=255?255:c;e=G[b|0];e=d+(e<<3|e>>>2)|0;h=(e|0)>=255?255:e;b=G[b+2|0];b=d+(b<<3|b>>>2)|0;d=(b|0)>=255?255:b;b=(b>>>0<256?b:(d|0)>0?d:0)<<1;c=(c>>>0<256?c:(f|0)>0?f:0)<<1;e=(e>>>0<256?e:(h|0)>0?h:0)<<1;d=G[b+429472|0]<<1&30|(G[c+429984|0]<<5&992|G[e+429984|0]<<10&31744);F[a+4>>2]=d|g&-32768;b=G[b+429473|0];c=G[c+429985|0];e=G[e+429985|0];F[a>>2]=1431655765;F[a+4>>2]=d|(b<<16&2031616|(c<<21&65011712|e<<26))|-2147450880;return}a:{if(!((f|0)!=3|e>>>0<7|(G[c+10|0]!=2|d))){k=e<<4;f=F[k+12752>>2];e=G[b+1|0];j=(e<<3|e>>>2)&255;e=f+j|0;h=(e|0)>=255?255:e;d=G[b|0];l=(d<<3|d>>>2)&255;d=l+f|0;i=(d|0)>=255?255:d;b=G[b+2|0];m=(b<<3|b>>>2)&255;b=m+f|0;f=(b|0)>=255?255:b;i=G[(((b>>>0<256?b:(f|0)>0?f:0)&255)<<1)+431009|0]<<1&30|(G[(((e>>>0<256?e:(h|0)>0?h:0)&255)<<1)+431521|0]<<5&992|G[(((d>>>0<256?d:(i|0)>0?i:0)&255)<<1)+431521|0]<<10&31744);F[a+4>>2]=i|g&-32768;d=F[k+12764>>2];b=d+j|0;g=(b|0)>=255?255:b;e=d+l|0;f=(e|0)>=255?255:e;d=d+m|0;h=(d|0)>=255?255:d;F[a+4>>2]=i|(G[(((d>>>0<256?d:(h|0)>0?h:0)&255)<<1)+431521|0]<<16&2031616|(G[(((b>>>0<256?b:(g|0)>0?g:0)&255)<<1)+431521|0]<<21&65011712|G[(((e>>>0<256?e:(f|0)>0?f:0)&255)<<1)+431521|0]<<26))|-2147450880;break a}f=L(F[((d<<4)+(f<<2)|0)+432544>>2],10);g=e<<5;e=f+L(g+G[b+1|0]|0,60)<<2;k=e;d=f+L(g+G[b+2|0]|0,60)<<2;b=f+L(g+G[b|0]|0,60)<<2;g=H[d+330774>>1]+(H[e+207846>>1]+H[b+207846>>1]|0)|0;f=H[d+330770>>1]+(H[e+207842>>1]+H[b+207842>>1]|0)|0;h=g>>>0>>0;i=H[d+330778>>1]+(H[e+207850>>1]+H[b+207850>>1]|0)|0;g=h?g:f;f=i>>>0>>0;j=f?2:h;h=H[d+330782>>1]+(H[e+207854>>1]+H[b+207854>>1]|0)|0;g=f?i:g;f=h>>>0>>0;j=f?3:j;i=H[d+330786>>1]+(H[e+207858>>1]+H[b+207858>>1]|0)|0;g=f?h:g;f=i>>>0>>0;j=f?4:j;h=H[d+330790>>1]+(H[e+207862>>1]+H[b+207862>>1]|0)|0;g=f?i:g;f=h>>>0>>0;j=f?5:j;i=H[d+330794>>1]+(H[e+207866>>1]+H[b+207866>>1]|0)|0;g=f?h:g;f=i>>>0>>0;j=f?6:j;h=H[d+330798>>1]+(H[e+207870>>1]+H[b+207870>>1]|0)|0;g=f?i:g;f=h>>>0>>0;j=f?7:j;i=H[d+330802>>1]+(H[e+207874>>1]+H[b+207874>>1]|0)|0;g=f?h:g;f=i>>>0>>0;e=H[d+330806>>1]+(H[e+207878>>1]+H[b+207878>>1]|0)>>>0<(f?i:g)>>>0?9:f?8:j;f=e<<2;g=k+f|0;b=b+f|0;d=d+f|0;F[a+4>>2]=G[g+207840|0]<<5&992|G[b+207840|0]<<10&31744|G[d+330768|0]<<1&30|(G[d+330769|0]<<16&2031616|(G[g+207841|0]<<21&65011712|G[b+207841|0]<<26))|-2147450880;if((e|0)==6){break a}e=G[c|0];d=G[c+1|0];g=G[c+2|0];b=f+330720|0;c=G[c+3|0];D[a+3|0]=G[b+(c>>>2&3)|0]<<2|G[b+(c&3)|0]|G[b+(c>>>4&3)|0]<<4|G[b+(c>>>6|0)|0]<<6;D[a+2|0]=G[b+(g&3)|0]|G[b+(g>>>2&3)|0]<<2|G[b+(g>>>4&3)|0]<<4|G[b+(g>>>6|0)|0]<<6;D[a+1|0]=G[b+(d&3)|0]|G[b+(d>>>2&3)|0]<<2|G[b+(d>>>4&3)|0]<<4|G[b+(d>>>6|0)|0]<<6;D[a|0]=G[b+(e&3)|0]|G[b+(e>>>2&3)|0]<<2|G[b+(e>>>4&3)|0]<<4|G[b+(e>>>6|0)|0]<<6;return}D[a|0]=G[c|0];D[a+1|0]=G[c+1|0];D[a+2|0]=G[c+2|0];D[a+3|0]=G[c+3|0]}function ub(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=M(0),x=0,y=0,z=0,A=0,B=0,C=0,I=0,J=0,K=M(0);d=F[a+104>>2];if(d-18>>>0>=4294967287){d=G[b+3|0];f=G[b+7|0];g=d>>>0>>0?d:f;e=G[b+11|0];h=e>>>0>g>>>0?g:e;g=G[b+15|0];i=g>>>0>h>>>0?h:g;h=G[b+19|0];k=h>>>0>i>>>0?i:h;i=G[b+23|0];l=i>>>0>k>>>0?k:i;k=G[b+27|0];m=k>>>0>l>>>0?l:k;l=G[b+31|0];n=l>>>0>m>>>0?m:l;m=G[b+35|0];o=m>>>0>n>>>0?n:m;n=G[b+39|0];p=n>>>0>o>>>0?o:n;o=G[b+43|0];q=o>>>0>p>>>0?p:o;p=G[b+47|0];r=p>>>0>q>>>0?q:p;q=G[b+51|0];s=q>>>0>r>>>0?r:q;r=G[b+55|0];j=r>>>0>s>>>0?s:r;s=G[b+59|0];t=s>>>0>j>>>0?j:s;j=G[b+63|0];t=j>>>0>t>>>0?t:j;d=d>>>0>f>>>0?d:f;d=d>>>0>e>>>0?d:e;d=d>>>0>g>>>0?d:g;d=d>>>0>h>>>0?d:h;d=d>>>0>i>>>0?d:i;d=d>>>0>k>>>0?d:k;d=d>>>0>l>>>0?d:l;d=d>>>0>m>>>0?d:m;d=d>>>0>n>>>0?d:n;d=d>>>0>o>>>0?d:o;d=d>>>0>p>>>0?d:p;d=d>>>0>q>>>0?d:q;d=d>>>0>r>>>0?d:r;d=d>>>0>s>>>0?d:s;d=d>>>0>j>>>0?d:j;if((t|0)==(d|0)){E[c>>1]=t|7424;a=H[196104]|H[196105]<<16;E[c+2>>1]=a;E[c+4>>1]=a>>>16;E[c+6>>1]=H[196106];return}k=b+3|0;w=M(t>>>0);K=M(M(d>>>0)-w);d=F[a+132>>2];b=(d&15)<<3;f=D[b+12883|0];e=D[b+12887|0];w=fb(M(M(K*M(M(0-f|0)/M(e-f|0)))+w));a:{if(M(N(w))>1]=a&255|d<<8;d=d>>>4|0;e=a+L(d,e)|0;l=(e>>>0<256?e:(e^-1)>>31)&255;e=a+L(d,D[b+12886|0])|0;m=(e>>>0<256?e:(e^-1)>>31)&255;e=a+L(d,D[b+12885|0])|0;n=(e>>>0<256?e:(e^-1)>>31)&255;e=a+L(d,D[b+12884|0])|0;o=(e>>>0<256?e:(e^-1)>>31)&255;f=a+L(d,f)|0;p=(f>>>0<256?f:(f^-1)>>31)&255;f=a+L(d,D[b+12882|0])|0;q=(f>>>0<256?f:(f^-1)>>31)&255;f=a+L(d,D[b+12881|0])|0;r=(f>>>0<256?f:(f^-1)>>31)&255;a=a+L(d,D[b+12880|0])|0;s=(a>>>0<256?a:(a^-1)>>31)&255;while(1){a=G[(k+((u&3)<<4)|0)+(u&-4)|0];j=s-a|0;b=j>>31;t=r-a|0;d=t>>31;z=q-a|0;f=z>>31;A=p-a|0;e=A>>31;B=o-a|0;g=B>>31;C=n-a|0;h=C>>31;I=m-a|0;i=I>>31;J=l-a|0;a=J>>31;b=(b^j)-b<<3;d=(d^t)-d<<3|1;b=b>>>0>>0?b:d;d=(f^z)-f<<3|2;b=b>>>0>>0?b:d;d=(e^A)-e<<3|3;b=b>>>0>>0?b:d;d=(g^B)-g<<3|4;b=b>>>0>>0?b:d;d=(h^C)-h<<3|5;b=b>>>0>>0?b:d;d=(i^I)-i<<3|6;b=b>>>0>>0?b:d;a=(a^J)-a<<3|7;a=(a>>>0>b>>>0?b:a)&7;d=We(u,y,-3,-1);d=d+45|0;b=d&31;if((d&63)>>>0>=32){d=a<>>32-b;a=a<>>8;D[c+5|0]=(v&65535)<<16|x>>>16;D[c+4|0]=(v&16777215)<<8|x>>>24;D[c+3|0]=v;D[c+2|0]=v>>>8;return}a=G[a+115|0];b=H[196104]|H[196105]<<16;E[c+2>>1]=b;E[c+4>>1]=b>>>16;E[c+6>>1]=H[196106];E[c>>1]=(d|0)!=8?7679:a|7424}function mb(a,b,c,d,e,f,g){var h=0,i=0,j=M(0),k=0,l=M(0),m=0,n=0,o=0,p=M(0),q=M(0),r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=M(0),z=M(0),A=M(0),B=M(0),C=M(0),E=M(0),H=0,I=M(0),K=0,L=0;m=Ea-16|0;n=7-b|0;o=b+1|0;b=2<>2]*p)-j)*M(.5))+M(.5));a:{if(M(N(l))>2];q=J[c+12>>2];y=J[d+8>>2];z=J[c+8>>2];A=J[d+4>>2];B=J[c+4>>2];C=J[d>>2];r=h<<1|i;k=i|L;r=(h|0)<0?i:(k|0)>(r|0)?r:k;h=(r&255)<>>o|h;C=M(M(M(M(C*p)-j)*M(.5))+M(.5));b:{if(M(N(C))(s|0)?s:k;h=(s&255)<>>o|h;B=M(M(M(M(B*p)-j)*M(.5))+M(.5));c:{if(M(N(B))(t|0)?t:k;h=(t&255)<>>o|h;A=M(M(M(M(A*p)-j)*M(.5))+M(.5));d:{if(M(N(A))(u|0)?u:k;h=(u&255)<>>o|h;z=M(M(M(M(z*p)-j)*M(.5))+M(.5));e:{if(M(N(z))(v|0)?v:k;h=(v&255)<>>o|h;y=M(M(M(M(y*p)-j)*M(.5))+M(.5));f:{if(M(N(y))(w|0)?w:k;h=(w&255)<>>o|h;q=M(M(M(M(q*p)-j)*M(.5))+M(.5));g:{if(M(N(q))(x|0)?x:k;h=(x&255)<>>o|h;j=M(M(M(M(l*p)-j)*M(.5))+M(.5));h:{if(M(N(j))(K|0)?K:k;h=(k&255)<>>o|h;j=M(0);l=M(0);if(a){while(1){q=l;h=b<<2;l=M(M(G[(m+8|0)+b|0])-M(J[h+d>>2]*M(255)));l=M(q+M(l*l));q=j;j=M(M(G[(m+12|0)+b|0])-M(J[c+h>>2]*M(255)));j=M(q+M(j*j));b=b+1|0;if((b|0)!=(a|0)){continue}break}}if(j>2]=i;D[e+3|0]=(x&254)>>>1;D[e+2|0]=(v&254)>>>1;D[e+1|0]=(t&254)>>>1;D[e|0]=(r&254)>>>1;I=j}if(l>2]=i;D[f+3|0]=(k&254)>>>1;D[f+2|0]=(w&254)>>>1;D[f+1|0]=(u&254)>>>1;D[f|0]=(s&254)>>>1;E=l}i=1;b=H;H=0;if(b){continue}break}} +function Cb(a){var b=0,c=0,d=0,e=0,f=0;d=Ta(a,0,88);a=F[d+88>>2];if(a){Ra(a);F[d+96>>2]=0;F[d+88>>2]=0;F[d+92>>2]=0}a=F[d+100>>2];if(a){Ra(a);F[d+108>>2]=0;F[d+100>>2]=0;F[d+104>>2]=0}a=F[d+112>>2];if(a){b=F[d+116>>2];if(b){b=L(b,24)+a|0;while(1){c=F[a+12>>2];if(c){Ra(c)}c=F[a>>2];if(c){Ra(c)}a=a+24|0;if((b|0)!=(a|0)){continue}break}a=F[d+112>>2]}Ra(a);F[d+120>>2]=0;F[d+112>>2]=0;F[d+116>>2]=0}F[d+124>>2]=0;F[d+128>>2]=0;F[d+140>>2]=0;F[d+132>>2]=0;F[d+136>>2]=0;a=F[d+144>>2];if(a){Ra(a);F[d+152>>2]=0;F[d+144>>2]=0;F[d+148>>2]=0}F[d+156>>2]=0;F[d+160>>2]=0;F[d+180>>2]=0;F[d+184>>2]=0;F[d+172>>2]=0;F[d+176>>2]=0;F[d+164>>2]=0;F[d+168>>2]=0;Db(d+188|0);e=d+776|0;c=0;a=1;while(1){b=L(c,12)+e|0;f=F[b>>2];if(f){Ra(f);F[b>>2]=0;F[b+4>>2]=0;F[b+8>>2]=0}b=L(c,192)+e|0;c=F[b+24>>2];if(c){Ra(c);F[b+24>>2]=0;F[b+28>>2]=0;F[b+32>>2]=0}c=F[b+36>>2];if(c){Ra(c);F[b+36>>2]=0;F[b+40>>2]=0;F[b+44>>2]=0}c=F[b+48>>2];if(c){Ra(c);F[b+48>>2]=0;F[b+52>>2]=0;F[b+56>>2]=0}c=F[b+60>>2];if(c){Ra(c);F[b+60>>2]=0;c=b- -64|0;F[c>>2]=0;F[c+4>>2]=0}c=F[b+72>>2];if(c){Ra(c);F[b+72>>2]=0;F[b+76>>2]=0;F[b+80>>2]=0}c=F[b+84>>2];if(c){Ra(c);F[b+84>>2]=0;F[b+88>>2]=0;F[b+92>>2]=0}c=F[b+96>>2];if(c){Ra(c);F[b+96>>2]=0;F[b+100>>2]=0;F[b+104>>2]=0}c=F[b+108>>2];if(c){Ra(c);F[b+108>>2]=0;F[b+112>>2]=0;F[b+116>>2]=0}c=F[b+120>>2];if(c){Ra(c);F[b+120>>2]=0;F[b+124>>2]=0;F[b+128>>2]=0}c=F[b+132>>2];if(c){Ra(c);F[b+132>>2]=0;F[b+136>>2]=0;F[b+140>>2]=0}c=F[b+144>>2];if(c){Ra(c);F[b+144>>2]=0;F[b+148>>2]=0;F[b+152>>2]=0}c=F[b+156>>2];if(c){Ra(c);F[b+156>>2]=0;F[b+160>>2]=0;F[b+164>>2]=0}c=F[b+168>>2];if(c){Ra(c);F[b+168>>2]=0;F[b+172>>2]=0;F[b+176>>2]=0}c=F[b+180>>2];if(c){Ra(c);F[b+180>>2]=0;F[b+184>>2]=0;F[b+188>>2]=0}c=F[b+192>>2];if(c){Ra(c);F[b+192>>2]=0;F[b+196>>2]=0;F[b+200>>2]=0}c=F[b+204>>2];if(c){Ra(c);F[b+204>>2]=0;F[b+208>>2]=0;F[b+212>>2]=0}c=1;b=a;a=0;if(b){continue}break}a=F[d+1184>>2];if(a){Ra(a);F[d+1192>>2]=0;F[d+1184>>2]=0;F[d+1188>>2]=0}E[d+1200>>1]=0;F[d+1196>>2]=-1}function ic(a,b,c,d,e,f,g,h,i,j,k){var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;p=h>>>0<=21?F[(h<<2)+398364>>2]:p;a:{if(i&2|c>>>0<78|(!G[a+585|0]|(G[b|0]|G[b+1|0]<<8)!=17011)){break a}if((G[b+2|0]|G[b+3|0]<<8)!=19|(G[b+4|0]|G[b+5|0]<<8)!=77|(G[b+8|0]|G[b+9|0]<<8|(G[b+10|0]<<16|G[b+11|0]<<24))+77>>>0>c>>>0){break a}l=G[b+14|0]|(G[b+15|0]<<8|G[b+16|0]<<16);if(!l|!(G[b+17|0]|(G[b+18|0]<<8|G[b+19|0]<<16))){break a}m=G[b+65|0]|G[b+66|0]<<8|(G[b+67|0]<<16|G[b+68|0]<<24);if(m>>>0>=c>>>0|c-m>>>0>>0){break a}n=b+m|0;q=G[b+21|0]&4;m=0;while(1){o=n+L(m,23)|0;if(!((G[o+1|0]<<8|G[o+2|0]<<16|G[o|0])==(d|0)&G[o+3|0]==(e|0))){m=m+1|0;if((l|0)!=(m|0)){continue}break a}break}d=G[b+20|0];b:{if(d){break b}e=n+L(m,23)|0;if(D[e+4|0]&1){break a}if(!q){break b}s=l;l=m+1|0;if(s>>>0<=l>>>0){break a}l=n+L(l,23)|0;if(!(D[l+4|0]&1)|(G[e+9|0]|G[e+10|0]<<8)!=(G[l+9|0]|G[l+10|0]<<8)|(G[e+11|0]|G[e+12|0]<<8)!=(G[l+11|0]|G[l+12|0]<<8)){break a}}e=n+L(m,23)|0;h=(h|0)==9?q?9:8:h;c:{if((h&-2)!=8){break c}l=L(G[e+11|0]|G[e+12|0]<<8,G[e+9|0]|G[e+10|0]<<8);if(l>>>0>=g>>>0){break c}Ta(L(l,p)+f|0,0,L(g-l|0,p));d=G[b+20|0]}l=G[e+7|0]|G[e+8|0]<<8;p=G[e+5|0]|G[e+6|0]<<8;r=G[e+11|0]|G[e+12|0]<<8;e=G[e+9|0]|G[e+10|0]<<8;if((d&255)==1){a=n+L(m,23)|0;return Fb(h,f,g,b,c,e,r,p,l,G[a+13|0]|G[a+14|0]<<8|(G[a+15|0]<<16|G[a+16|0]<<24),G[a+17|0]|G[a+18|0]<<8|(G[a+19|0]<<16|G[a+20|0]<<24),i,(q|0)!=0,j,k,-1,-1)}d=n+L(m,23)|0;t=G[d+17|0]|G[d+18|0]<<8|(G[d+19|0]<<16|G[d+20|0]<<24);s=G[d+13|0]|G[d+14|0]<<8|(G[d+15|0]<<16|G[d+16|0]<<24);o=G[o+3|0];n=0;m=0;if(q){n=G[d+36|0]|G[d+37|0]<<8|(G[d+38|0]<<16|G[d+39|0]<<24);m=G[d+40|0]|G[d+41|0]<<8|(G[d+42|0]<<16|G[d+43|0]<<24)}r=Ub(a,h,f,g,b,c,e,r,p,l,o,s,t,n,m,i,(q|0)!=0,G[b+23|0]==3,j,0,k)}return r}function hc(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;h=e?0:-1;l=e?-1:1;i=e?-1:0;f=-2;j=(e|0)!=0;k=!e;a:{b:{switch(c-2|0){case 0:f=h;break a;case 3:case 4:f=0;break a;case 5:f=k;break a;case 9:case 13:f=0;break a;case 16:f=i;break a;case 17:case 18:f=0;break a;case 19:f=j;break a;case 6:case 22:f=0;break a;case 25:f=h;break a;case 26:f=l;break a;case 27:f=j;break a;case 28:f=i;break a;case 29:f=k;break a;case 8:break a;default:break b}}f=((c>>>0)%3|0)-1|0}g=G[b|0];e=(f|0)==-2?3:f+1|0;c:{if(!g){break c}e=(d+f|0)-1|0;if((d|0)==(g|0)){break c}e=g-f|0;m=e;e=f+g|0;e=(e|0)<0?m:(d|0)<(e|0)?m:e}D[a|0]=e;e=-2;d:{e:{switch(c-2|0){case 29:e=k;break d;case 28:e=i;break d;case 27:e=j;break d;case 26:e=l;break d;case 25:e=h;break d;case 6:e=0;break d;case 22:e=j;break d;case 18:case 19:e=0;break d;case 17:e=i;break d;case 13:case 16:e=0;break d;case 9:e=k;break d;case 4:case 5:e=0;break d;case 3:e=h;break d;case 0:e=0;break d;case 8:break d;default:break e}}e=(((c>>>0)/3>>>0)%3|0)-1|0}f=G[b+1|0];f:{if(f){if((d|0)!=(f|0)){g=f-e|0;e=e+f|0;e=(e|0)<0?g:(d|0)<(e|0)?g:e;break f}e=(d+e|0)-1|0;break f}e=(e|0)==-2?3:e+1|0}D[a+1|0]=e;e=-2;g:{h:{switch(c-2|0){case 29:e=k;break g;case 28:e=i;break g;case 27:e=j;break g;case 26:e=l;break g;case 25:e=h;break g;case 6:e=j;break g;case 19:case 22:e=0;break g;case 18:e=i;break g;case 16:case 17:e=0;break g;case 13:e=k;break g;case 5:case 9:e=0;break g;case 4:e=h;break g;case 0:case 3:e=0;break g;case 8:break g;default:break h}}e=(((c>>>0)/9>>>0)%3|0)-1|0}b=G[b+2|0];if(b){if((b|0)!=(d|0)){f=a;a=b-e|0;c=a;a=b+e|0;D[f+2|0]=(a|0)<0?c:(a|0)>(d|0)?c:a;return}D[a+2|0]=(d+e|0)-1;return}D[a+2|0]=(e|0)==-2?3:e+1|0}function ld(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;if(F[a>>2]==-559038751){e=a+4|0;b=F[a+592>>2];d=F[a+596>>2];a:{if((G[b|0]|G[b+1|0]<<8)!=17011|d>>>0<78|((G[b+2|0]|G[b+3|0]<<8)!=19|(G[b+4|0]|G[b+5|0]<<8)!=77)){break a}if(d>>>0<(G[b+8|0]|G[b+9|0]<<8|(G[b+10|0]<<16|G[b+11|0]<<24))+77>>>0){break a}c=G[b+14|0]|(G[b+15|0]<<8|G[b+16|0]<<16);if(!c|!(G[b+17|0]|(G[b+18|0]<<8|G[b+19|0]<<16))){break a}a=G[b+65|0]|G[b+66|0]<<8|(G[b+67|0]<<16|G[b+68|0]<<24);if(a>>>0>=d>>>0|d-a>>>0>>0){break a}a=F[e+8>>2];b:{if(!G[b+20|0]){if(a){Db(e)}c:{if(G[b+21|0]&8){c=F[e>>2];if(!c){break a}a=F[c+8>>2];if(!a|(a|0)!=(G[b+39|0]|G[b+40|0]<<8)|F[c+20>>2]!=(G[b+48|0]|G[b+49|0]<<8)){break a}c=G[b+61|0]|G[b+62|0]<<8|(G[b+63|0]<<16|G[b+64|0]<<24);if(!c){break a}a=G[b+57|0]|G[b+58|0]<<8|(G[b+59|0]<<16|G[b+60|0]<<24);if(d>>>0>>0){break a}if(d-a>>>0>=c>>>0){break c}break a}f=G[b+45|0]|(G[b+46|0]<<8|G[b+47|0]<<16);if(!f){break a}g=G[b+54|0]|(G[b+55|0]<<8|G[b+56|0]<<16);if(!g){break a}a=G[b+61|0]|G[b+62|0]<<8|(G[b+63|0]<<16|G[b+64|0]<<24);if(!a){break a}h=G[b+41|0]|G[b+42|0]<<8|(G[b+43|0]<<16|G[b+44|0]<<24);if(d>>>0>>0){break a}c=G[b+50|0]|G[b+51|0]<<8|(G[b+52|0]<<16|G[b+53|0]<<24);if(d>>>0>>0){break a}i=a;a=G[b+57|0]|G[b+58|0]<<8|(G[b+59|0]<<16|G[b+60|0]<<24);if(i>>>0>d-a>>>0|g>>>0>d-c>>>0|(f>>>0>d-h>>>0|a>>>0>d>>>0)){break a}if(!Eb(e,G[b+39|0]|G[b+40|0]<<8,b+h|0,f,G[b+48|0]|G[b+49|0]<<8,b+c|0,g)){break a}c=G[b+61|0]|G[b+62|0]<<8|(G[b+63|0]<<16|G[b+64|0]<<24);a=G[b+57|0]|G[b+58|0]<<8|(G[b+59|0]<<16|G[b+60|0]<<24)}if(xb(e,a+b|0,c)){break b}break a}if(!a){break b}Db(e)}j=1;D[e+585|0]=1}}return j|0}function qc(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;h=F[a+104>>2];c=(G[h+7072|0]<<9)+413088|0;d=G[c+(G[a+21|0]<<1)|0];a:{if(h-15>>>0<=2){c=G[c+(G[a+22|0]<<1)|0];f=(L(d,63)+127>>>0)/255<<5;d=(L(d,31)+127>>>0)/255|0;e=f|d;D[b|0]=e;g=((f|d<<11)&65280)>>>8|0;D[b+1|0]=g;f=(L(c,63)+127>>>0)/255<<5;c=(L(c,31)+127>>>0)/255|0;d=f|c;c=((f|c<<11)&65280)>>>8|0;break a}e=(L(G[c+(G[a+25|0]<<1)|0],31)+127>>>0)/255|(L(G[c+(G[a+23|0]<<1)|0],63)+127>>>0)/255<<5;D[b|0]=e;g=(((L(d,31)+127>>>0)/255<<11|e)&65280)>>>8|0;D[b+1|0]=g;d=(L(G[c+(G[a+26|0]<<1)|0],31)+127>>>0)/255|(L(G[c+(G[a+24|0]<<1)|0],63)+127>>>0)/255<<5;c=((d|(L(G[c+(G[a+22|0]<<1)|0],31)+127>>>0)/255<<11)&65280)>>>8|0}D[b+2|0]=d;D[b+3|0]=c;i=d&255|c<<8;f=e&255|g<<8;if((i|0)==(f|0)){a=f?0:1431655765;D[b+4|0]=a;D[b+5|0]=a>>>8;D[b+6|0]=a>>>16;D[b+7|0]=a>>>24;a=f?f:1;D[b|0]=a;c=f?f-1|0:0;D[b+2|0]=c;D[b+1|0]=a>>>8;D[b+3|0]=c>>>8;return}if(f>>>0>>0){D[b+2|0]=e;D[b|0]=d;D[b+3|0]=g;D[b+1|0]=c}c=F[(G[h+7008|0]<<2)+405664>>2];d=a+39|0;e=G[h+7136|0]-1|0;h=G[c+G[d+(1<>>0>>0;c=(((a^G[c+G[d+(15<>>6;c=(c<<4|(a^o)<<2|a^n)<<4|(a^m)<<2|a^l;D[b+6|0]=c>>>6;c=(c<<4|(a^k)<<2|a^j)<<4|(a^g)<<2|a^h;D[b+5|0]=c>>>6;D[b+4|0]=a^p|c<<2}function Ya(a){var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;h=8;a:{b:{if(a>>>0>4294967239){break b}while(1){h=h>>>0<=8?8:h;d=F[109111];e=F[109110];a=a>>>0<=8?8:a+3&-4;c:{if(a>>>0<=127){f=(a>>>3|0)-1|0;break c}c=O(a);f=((a>>>29-c^4)-(c<<2)|0)+110|0;if(a>>>0<=4095){break c}c=((a>>>30-c^2)-(c<<1)|0)+71|0;f=c>>>0>=63?63:c}b=f&31;if((f&63)>>>0>=32){c=0;b=d>>>b|0}else{c=d>>>b|0;b=((1<>>b}if(b|c){while(1){d=b;d:{if(c|d){e=c-1|0;g=e+1|0;b=e;e=d-1|0;g=(e|0)!=-1?g:b;b=O(c^g);b=(b|0)==32?O(d^e)+32|0:b;e=63-b|0;Fa=0-(b>>>0>63)|0;break d}Fa=0;e=64}g=e;e=g&31;if((g&63)>>>0>=32){b=0;e=c>>>e|0}else{b=c>>>e|0;e=((1<>>e}c=b;f=f+g|0;g=f<<4;d=F[g+435416>>2];i=g+435408|0;e:{if((d|0)!=(i|0)){b=Jb(d,h,a);if(b){break b}b=F[d+4>>2];F[b+8>>2]=F[d+8>>2];F[F[d+8>>2]+4>>2]=b;F[d+8>>2]=i;b=g+435412|0;F[d+4>>2]=F[b>>2];F[b>>2]=d;F[F[d+4>>2]+8>>2]=d;f=f+1|0;b=(c&1)<<31|e>>>1;c=c>>>1|0;break e}b=F[109111];j=436440,k=F[109110]&Ze(-2,-1,f),F[j>>2]=k;F[109111]=Fa&b;b=e^1}if(c|b){continue}break}e=F[109110];d=F[109111]}f:{if(d|e){c=O(d);g=63-((c|0)==32?O(e)+32|0:c)|0;b=g<<4;c=F[b+435416>>2];g:{if(!d&e>>>0<1073741824){break g}f=99;d=b+435408|0;if((d|0)==(c|0)){break g}while(1){if(!f){break g}b=Jb(c,h,a);if(b){break b}f=f-1|0;c=F[c+8>>2];if((d|0)!=(c|0)){continue}break}c=d}if(Kb(a+48|0)){break f}if(!c){break a}d=(g<<4)+435408|0;if((d|0)==(c|0)){break a}while(1){b=Jb(c,h,a);if(b){break b}c=F[c+8>>2];if((d|0)!=(c|0)){continue}break}break a}if(!Kb(a+48|0)){break a}}b=0;if(h-1&h){break b}if(a>>>0<=4294967239){continue}break}}return b}return 0}function nb(a,b){var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;a:{if(!a){a=Ya(b);break a}if(!b){Ra(a);a=0;break a}b:{if(b>>>0>4294967239){break b}h=b>>>0<=8?8:b+3&-4;b=h+8|0;c:{d:{k=a-4|0;f=k;e=F[f>>2];c=e+f|0;j=F[c>>2];g=j+c|0;e:{f:{if(F[g-4>>2]!=(j|0)){d=b+f|0;if(d+16>>>0<=g>>>0){e=F[c+4>>2];F[e+8>>2]=F[c+8>>2];F[F[c+8>>2]+4>>2]=e;c=g-d|0;F[d>>2]=c;F[(d+(c&-4)|0)-4>>2]=c|1;e=F[d>>2]-8|0;g:{if(e>>>0<=127){c=(e>>>3|0)-1|0;break g}g=O(e);c=((e>>>29-g^4)-(g<<2)|0)+110|0;if(e>>>0<=4095){break g}c=((e>>>30-g^2)-(g<<1)|0)+71|0;c=c>>>0>=63?63:c}e=c<<4;F[d+4>>2]=e+435408;e=e+435416|0;F[d+8>>2]=F[e>>2];F[e>>2]=d;F[F[d+8>>2]+4>>2]=d;e=F[109111];d=c&31;if((c&63)>>>0>=32){c=1<>>32-d}F[109110]=g|F[109110];F[109111]=c|e;F[f>>2]=b;break d}if(d>>>0>g>>>0){break f}b=F[c+4>>2];F[b+8>>2]=F[c+8>>2];F[F[c+8>>2]+4>>2]=b;b=e+j|0;F[f>>2]=b;break d}if(e>>>0>=b+16>>>0){F[f>>2]=b;F[(f+(b&-4)|0)-4>>2]=b;d=b+f|0;b=e-b|0;F[d>>2]=b;F[(d+(b&-4)|0)-4>>2]=b|1;c=F[d>>2]-8|0;h:{if(c>>>0<=127){b=(c>>>3|0)-1|0;break h}f=O(c);b=((c>>>29-f^4)-(f<<2)|0)+110|0;if(c>>>0<=4095){break h}b=((c>>>30-f^2)-(f<<1)|0)+71|0;b=b>>>0>=63?63:b}c=b<<4;F[d+4>>2]=c+435408;c=c+435416|0;F[d+8>>2]=F[c>>2];F[c>>2]=d;F[F[d+8>>2]+4>>2]=d;c=F[109111];d=b&31;if((b&63)>>>0>=32){b=1<>>32-d}F[109110]=e|F[109110];F[109111]=b|c;d=1;break c}d=1;if(b>>>0<=e>>>0){break e}}d=0}break c}F[(f+(b&-4)|0)-4>>2]=b;d=1}if(d){break a}b=Ya(h);if(!b){break b}i=F[k>>2]-8|0;Va(b,a,h>>>0>>0?h:i);Ra(a);i=b}a=i}return a}function Fb(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r=0,s=0,t=0;r=j+k|0;s=j>>>0>r>>>0;a:{if(!s&e>>>0>>0|s){break a}e=8;if((a&-2)==8){if((Xe(f<<2)|0)!=1){break a}if((Xe(g<<2)|0)!=1){break a}}r=4;b:{c:{d:{e:{f:{g:{h:{a=(a|0)==9?m?9:8:a;switch(a|0){case 13:break d;case 0:case 2:case 4:case 8:case 9:case 11:case 18:case 19:case 20:break e;case 14:case 15:case 16:break g;case 1:case 3:case 5:case 6:case 7:case 10:case 12:case 17:case 21:break h;default:break f}}e=16;break e}r=2;break d}e=0}if(a-13>>>0>3){break c}r=e}if(L(o?o:i,n?n:h)>>>0<=c>>>0){break b}break a}if(L(f,g)>>>0>c>>>0){break a}r=e;if((a|0)==17){break a}}c=l&4;i:{switch(a|0){case 0:return _a(b,f,g,d+j|0,k,0,r,h,i,n,o,p,q);case 1:return _a(b,f,g,d+j|0,k,1,r,h,i,n,o,p,q);case 2:return _a(b,f,g,d+j|0,k,2,r,h,i,n,o,p,q);case 3:return _a(b,f,g,d+j|0,k,3,r,h,i,n,o,p,q);case 4:return _a(b,f,g,d+j|0,k,4,r,h,i,n,o,c?m?3:0:0,-1);case 5:return _a(b,f,g,d+j|0,k,5,r,h,i,n,o,0,3);case 6:case 7:return _a(b,f,g,d+j|0,k,8,r,h,i,n,o,-1,-1);case 8:return _a(b,f,g,d+j|0,k,6,r,h,i,n,o,-1,-1);case 9:return _a(b,f,g,d+j|0,k,7,r,h,i,n,o,-1,-1);case 10:return _a(b,f,g,d+j|0,k,12,r,h,i,n,o,-1,-1);case 20:return _a(b,f,g,d+j|0,k,18,r,h,i,n,o,c?m?3:0:0,-1);case 21:return _a(b,f,g,d+j|0,k,19,r,h,i,n,o,0,3);case 13:return _a(b,f,g,d+j|0,k,22,r,h,i,n,o,-1,-1);case 14:return _a(b,f,g,d+j|0,k,24,r,h,i,n,o,-1,-1);case 15:return _a(b,f,g,d+j|0,k,25,r,h,i,n,o,-1,-1);case 16:break i;default:break a}}t=_a(b,f,g,d+j|0,k,29,r,h,i,n,o,-1,-1)}return t}function Qb(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;l=Ea-16|0;Ea=l;a:{if(e>>>0<=7){F[l+8>>2]=0;F[l+12>>2]=0;g=l+8|0;Va(g,d,e);a=Qb(a,b,c,g,8);g=a>>>0<4294967177?a>>>0>e>>>0?-20:a:a;break a}m=F[b>>2]+1|0;q=Ta(a,0,m<<1);f=G[d|0]|G[d+1|0]<<8|(G[d+2|0]<<16|G[d+3|0]<<24);a=f&15;g=-44;if(a>>>0>10){break a}F[c>>2]=a+5;c=d+e|0;g=c-4|0;n=c-7|0;o=a+6|0;c=4;f=f>>>4|0;k=32<>>0>=24){while(1){a=a+36|0;if(e>>>0<=n>>>0){e=e+3|0}else{c=(e-n<<3)+c&31;e=g}f=(G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24))>>>c|0;h=Ve(f^-1|-2147483648);if(h>>>0>23){continue}break}}i=h&30;c=(i+c|0)+2|0;a=(L(h>>>1|0,3)+a|0)+(f>>>i&3)|0;if(m>>>0<=a>>>0){break b}f=(c>>>3|0)+e|0;c:{if(!(e>>>0>n>>>0&f>>>0>g>>>0)){c=c&7;e=f;break c}c=(e-g<<3)+c&31;e=g}f=(G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24))>>>c|0}h=k-1&f;i=(k<<1)-1|0;p=i-j|0;if(h>>>0

>>0){f=o-1|0}else{f=f&i;h=f-((f|0)>=(k|0)?p:0)|0;f=o}i=h-1|0;E[(a<<1)+q>>1]=i;a=a+1|0;c=c+f|0;j=((h|0)>0?1-h|0:i)+j|0;if((j|0)<(k|0)){if((j|0)<2){break b}f=O(j);o=32-f|0;k=1<<(f^31)}if(a>>>0>=m>>>0){break b}h=(i|0)!=0;f=(c>>3)+e|0;d:{if(!(e>>>0>n>>>0&f>>>0>g>>>0)){c=c&7;e=f;break d}c=(e-g<<3)+c&31;e=g}f=(G[e|0]|G[e+1|0]<<8|(G[e+2|0]<<16|G[e+3|0]<<24))>>>c|0;continue}break}g=-20;if((j|0)!=1){break a}g=-48;if(a>>>0>m>>>0){break a}g=-20;if((c|0)>32){break a}F[b>>2]=a-1;g=((c+7>>3)+e|0)-d|0}Ea=l+16|0;return g}function Mc(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;if(!d){return-72}i=H[e+2>>1];a:{b:{c:{if(d>>>0>=4){g=G[(c+d|0)-1|0];f=-1;if(!g){break a}if(d>>>0<=4294967176){break c}return d}h=G[c|0];d:{switch(d-2|0){case 1:h=G[c+2|0]<<16|h;case 0:h=(G[c+1|0]<<8)+h|0;break;default:break d}}f=G[(c+d|0)-1|0];if(!f){return-20}f=(O(f)-(d<<3)|0)+9|0;d=0;break b}f=O(g)-23|0;d=d-4|0;g=d+c|0;h=G[g|0]|G[g+1|0]<<8|(G[g+2|0]<<16|G[g+3|0]<<24)}k=e+4|0;l=a+b|0;j=l-3|0;i=0-i&31;e:{f:{g:{h:{while(1){i:{if((d|0)>=4){e=f&7;h=f>>>3|0;f=0;break i}if(!d){d=0;g=c;e=f;break h}e=f;g=f>>>3|0;f=(c+d|0)-g>>>0>>0;h=f?d:g;e=e-(h<<3)|0}d=d-h|0;g=d+c|0;h=G[g|0]|G[g+1|0]<<8|(G[g+2|0]<<16|G[g+3|0]<<24);if(!(f|a>>>0>=j>>>0)){f=(h<>>i<<1)+k|0;m=G[f+1|0];D[a|0]=G[f|0];e=e+m|0;f=(h<>>i<<1)+k|0;m=G[f+1|0];D[a+1|0]=G[f|0];a=a+2|0;f=e+m|0;if(f>>>0<=32){continue}break g}break}if(e>>>0<=32){break h}f=e;break g}f=e;while(1){j:{if((d|0)>=4){e=f&7;h=f>>>3|0;f=0;break j}if(!d){break g}e=f;h=g;g=f>>>3|0;f=h-g>>>0>>0;h=f?d:g;e=e-(h<<3)|0}d=d-h|0;g=d+c|0;h=G[g|0]|G[g+1|0]<<8|(G[g+2|0]<<16|G[g+3|0]<<24);j=a>>>0>=l>>>0;if(!(f|j)){f=(h<>>i<<1)+k|0;j=G[f+1|0];D[a|0]=G[f|0];a=a+1|0;f=e+j|0;if(f>>>0>32){break g}continue}break}f=e;if(j){break e}break f}if(a>>>0>=l>>>0){break e}}while(1){d=(h<>>i<<1)+k|0;e=G[d+1|0];D[a|0]=G[d|0];f=e+f|0;a=a+1|0;if(l>>>0>a>>>0){continue}break}}f=(c|0)!=(g|0)?-20:(f|0)!=32?-20:b}return f}function jc(a,b,c,d,e){var f=0,g=0,h=0,i=0,j=0;a:{if((G[a|0]|G[a+1|0]<<8)!=17011|b>>>0<78|((G[a+2|0]|G[a+3|0]<<8)!=19|(G[a+4|0]|G[a+5|0]<<8)!=77)){break a}if((G[a+8|0]|G[a+9|0]<<8|(G[a+10|0]<<16|G[a+11|0]<<24))+77>>>0>b>>>0){break a}g=G[a+14|0]|(G[a+15|0]<<8|G[a+16|0]<<16);if(!g){break a}i=G[a+17|0]|(G[a+18|0]<<8|G[a+19|0]<<16);if(!i){break a}f=G[a+65|0]|G[a+66|0]<<8|(G[a+67|0]<<16|G[a+68|0]<<24);if(f>>>0>=b>>>0|b-f>>>0>>0){break a}f=a+f|0;while(1){b=f+L(h,23)|0;if(!((G[b+1|0]<<8|G[b+2|0]<<16|G[b|0])==(d|0)&G[b+3|0]==(e|0))){h=h+1|0;if((g|0)!=(h|0)){continue}break a}break}if(d>>>0>=i>>>0){break a}F[c+4>>2]=e;F[c>>2]=d;j=1;if(G[a+20|0]){b=G[(f+L(h,23)|0)+4|0]}else{b=G[a+21|0]>>>2|0}D[c+56|0]=b&1;e=L(h,23);b=e+f|0;D[c+57|0]=G[b+4|0]>>>1&1;F[c+16>>2]=G[b+9|0]<<2|G[b+10|0]<<10;F[c+20>>2]=G[b+11|0]<<2|G[b+12|0]<<10;F[c+8>>2]=G[b+5|0]|G[b+6|0]<<8;F[c+12>>2]=G[b+7|0]|G[b+8|0]<<8;g=G[b+9|0]|G[b+10|0]<<8;F[c+24>>2]=g;d=G[b+11|0]|G[b+12|0]<<8;F[c+36>>2]=h;F[c+28>>2]=d;F[c+32>>2]=L(d,g);F[c+40>>2]=G[b+13|0]|G[b+14|0]<<8|(G[b+15|0]<<16|G[b+16|0]<<24);b=G[b+17|0]|G[b+18|0]<<8|(G[b+19|0]<<16|G[b+20|0]<<24);F[c+48>>2]=0;F[c+52>>2]=0;F[c+44>>2]=b;if(G[a+20|0]|!(G[a+21|0]&4)){break a}a=e+f|0;F[c+48>>2]=G[a+36|0]|G[a+37|0]<<8|(G[a+38|0]<<16|G[a+39|0]<<24);F[c+52>>2]=G[a+40|0]|G[a+41|0]<<8|(G[a+42|0]<<16|G[a+43|0]<<24)}return j}function Ud(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;f=Ea+-64|0;Ea=f;a:{if(Xa(b,405072,0)){F[c>>2]=0;d=1;break a}b:{if(G[a+8|0]&24){e=1}else{if(!b){break b}e=ab(b,404804);if(!e){break b}e=(G[e+8|0]&24)!=0}g=Xa(a,b,e)}if(g){d=1;a=F[c>>2];if(!a){break a}F[c>>2]=F[a>>2];break a}c:{if(!b){break c}e=ab(b,404852);if(!e){break a}b=F[c>>2];if(b){F[c>>2]=F[b>>2]}g=F[e+8>>2];b=F[a+8>>2];if(g&(b^-1)&7|b&(g^-1)&96){break a}d=1;if(Xa(F[a+12>>2],F[e+12>>2],0)){break a}if(Xa(F[a+12>>2],405060,0)){a=F[e+12>>2];if(!a){break a}d=!ab(a,404904);break a}g=F[a+12>>2];if(!g){break c}d=0;b=ab(g,404852);if(b){if(!(D[a+8|0]&1)){break a}a=F[e+12>>2];c=0;d:{e:{while(1){d=0;if(!a){break d}a=ab(a,404852);if(!a|F[a+8>>2]&(F[b+8>>2]^-1)){break e}d=1;if(Xa(F[b+12>>2],F[a+12>>2],0)){break d}if(!(D[b+8|0]&1)){break e}d=F[b+12>>2];if(!d){break e}b=ab(d,404852);if(b){a=F[a+12>>2];continue}break}b=ab(d,404964);if(!b){break e}c=sc(b,F[a+12>>2])}d=c}break a}b=ab(g,404964);if(b){if(!(D[a+8|0]&1)){break a}d=sc(b,F[e+12>>2]);break a}b=ab(g,404756);if(!b){break a}a=F[e+12>>2];if(!a){break a}a=ab(a,404756);if(!a){break a}Ta(f+12|0,0,52);F[f+56>>2]=1;F[f+20>>2]=-1;F[f+16>>2]=b;F[f+8>>2]=a;Ga[F[F[a>>2]+28>>2]](a,f+8|0,F[c>>2],1);a=F[f+32>>2];if(!(!F[c>>2]|(a|0)!=1)){F[c>>2]=F[f+24>>2]}d=(a|0)==1;break a}d=0}Ea=f- -64|0;return d|0}function kd(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0;f=Ea-48|0;Ea=f;a:{if(F[a>>2]!=-559038751|e>>>0>21){break a}k=a+4|0;if(!qb(k,F[a+592>>2],F[a+596>>2],c,d,f+20|0,f+16|0,f+12|0)){break a}F[f>>2]=0;F[f+4>>2]=0;F[f+8>>2]=0;l=((g|0)!=0)<<2;h=e-13|0;b:{if(h>>>0<4){i=F[f+16>>2];g=F[f+20>>2];h=L(i,L(g,h>>>0<=3?F[(h<<2)+398452>>2]:0));if(h){Wa(f,h,(h|0)==1,1);g=F[f+4>>2];Ta(g+F[f>>2]|0,0,h-g|0);F[f+4>>2]=h;j=F[f>>2];i=F[f+16>>2];g=F[f+20>>2]}j=ic(k,F[a+592>>2],F[a+596>>2],c,d,j,L(g,i),e,l,g,i);break b}i=e>>>0<=21?F[(e<<2)+398364>>2]:0;g=0;if((e&-2)!=8){h=L(i,F[f+12>>2])}else{h=F[f+16>>2]+3&-4;j=h>>>0<=8?8:h;h=F[f+20>>2]+3&-4;h=L(j,h>>>0<=8?8:h)>>>1&536870904}if(h){Wa(f,h,(h|0)==1,1);g=F[f+4>>2];Ta(g+F[f>>2]|0,0,h-g|0);F[f+4>>2]=h;g=F[f>>2]}j=ic(k,F[a+592>>2],F[a+596>>2],c,d,g,(h>>>0)/(i>>>0)|0,e,l,0,0)}c=ja(4864)|0;d=$(2107)|0;a=_(c|0,d|0)|0;W(d|0);W(c|0);d=ra(1109)|0;c=F[f>>2];e=F[f+4>>2];aa(a|0);F[f+40>>2]=e;F[f+32>>2]=c;F[f+24>>2]=a;c=ia(d|0,3,398544,f+24|0)|0;W(d|0);b=F[b>>2];if(!(D[435192]&1)){d=ha(2,398556)|0;D[435192]=1;F[108797]=d}d=F[108797];aa(c|0);F[f+24>>2]=c;ka(d|0,b|0,1336,f+24|0);W(c|0);W(a|0);a=F[f>>2];if(!a){break a}Ra(a)}Ea=f+48|0;return j|0}function kc(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0;a:{if((G[a|0]|G[a+1|0]<<8)!=17011|b>>>0<78|((G[a+2|0]|G[a+3|0]<<8)!=19|(G[a+4|0]|G[a+5|0]<<8)!=77)){break a}if((G[a+8|0]|G[a+9|0]<<8|(G[a+10|0]<<16|G[a+11|0]<<24))+77>>>0>b>>>0){break a}h=G[a+14|0]|(G[a+15|0]<<8|G[a+16|0]<<16);if(!h){break a}f=G[a+17|0]|(G[a+18|0]<<8|G[a+19|0]<<16);if(!f){break a}e=G[a+65|0]|G[a+66|0]<<8|(G[a+67|0]<<16|G[a+68|0]<<24);if(e>>>0>=b>>>0|b-e>>>0>>0){break a}i=a+e|0;b=0;while(1){e=L(b,23)+i|0;if(!((G[e+1|0]<<8|G[e+2|0]<<16|G[e|0])==(d|0)&!G[e+3|0])){b=b+1|0;if((h|0)!=(b|0)){continue}break a}break}if(d>>>0>=f>>>0){break a}e=1;f=b+1|0;if(h>>>0>f>>>0){while(1){g=L(f,23)+i|0;if((G[g+1|0]<<8|G[g+2|0]<<16|G[g|0])==(d|0)){g=G[g+3|0]+1|0;e=e>>>0>g>>>0?e:g;f=f+1|0;if(h>>>0>f>>>0){continue}}break}if(e>>>0>16){break a}}D[c+40|0]=0;F[c+4>>2]=e;F[c>>2]=d;j=1;if(G[a+20|0]){a=G[(L(b,23)+i|0)+4|0]}else{a=G[a+21|0]>>>2|0}D[c+40|0]=a&1;a=L(b,23)+i|0;D[c+41|0]=G[a+4|0]>>>1&1;F[c+16>>2]=G[a+9|0]<<2|G[a+10|0]<<10;F[c+20>>2]=G[a+11|0]<<2|G[a+12|0]<<10;F[c+8>>2]=G[a+5|0]|G[a+6|0]<<8;F[c+12>>2]=G[a+7|0]|G[a+8|0]<<8;d=G[a+9|0]|G[a+10|0]<<8;F[c+24>>2]=d;a=G[a+11|0]|G[a+12|0]<<8;F[c+36>>2]=b;F[c+28>>2]=a;F[c+32>>2]=L(a,d)}return j}function fe(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0;j=Ea-80|0;Ea=j;a:{if(F[a>>2]!=-559038750|f>>>0>21){break a}a=a+4|0;if(!Ab(a,j+12|0,c,d,e)){break a}k=F[j+48>>2];m=F[j+28>>2];n=F[j+24>>2];F[j>>2]=0;F[j+4>>2]=0;F[j+8>>2]=0;o=((g|0)!=0)<<2;g=f-13|0;b:{if(g>>>0<4){l=L(m,n);k=L(l,g>>>0<=3?F[(g<<2)+398452>>2]:0);if(k){Wa(j,k,(k|0)==1,1);g=F[j+4>>2];Ta(g+F[j>>2]|0,0,k-g|0);F[j+4>>2]=k;g=F[j>>2]}else{g=0}l=fc(a,c,d,e,g,l,f,o,n,m,h,i);break b}l=f>>>0<=21?F[(f<<2)+398364>>2]:0;if((f&-2)!=8){g=L(k,l)}else{g=m+3&-4;k=g>>>0<=8?8:g;g=n+3&-4;g=L(k,g>>>0<=8?8:g)>>>1&536870904}if(g){Wa(j,g,(g|0)==1,1);k=F[j+4>>2];Ta(k+F[j>>2]|0,0,g-k|0);F[j+4>>2]=g;k=F[j>>2]}else{k=0}l=fc(a,c,d,e,k,(g>>>0)/(l>>>0)|0,f,o,0,0,h,i)}c=ja(4864)|0;a=$(2107)|0;e=_(c|0,a|0)|0;W(a|0);W(c|0);d=ra(1109)|0;c=F[j>>2];a=F[j+4>>2];aa(e|0);F[j+72>>2]=a;F[j+64>>2]=c;F[j+56>>2]=e;c=ia(d|0,3,398544,j+56|0)|0;W(d|0);b=F[b>>2];if(!(D[435192]&1)){a=ha(2,398556)|0;D[435192]=1;F[108797]=a}a=F[108797];aa(c|0);F[j+56>>2]=c;ka(a|0,b|0,1336,j+56|0);W(c|0);W(e|0);a=F[j>>2];if(!a){break a}Ra(a)}Ea=j+80|0;return l|0}function Va(a,b,c){var d=0,e=0,f=0;if(c>>>0>=512){za(a|0,b|0,c|0);return a}e=a+c|0;a:{if(!((a^b)&3)){b:{if(!(a&3)){c=a;break b}if(!c){c=a;break b}c=a;while(1){D[c|0]=G[b|0];b=b+1|0;c=c+1|0;if(!(c&3)){break b}if(c>>>0>>0){continue}break}}d=e&-4;c:{if(d>>>0<64){break c}f=d+-64|0;if(f>>>0>>0){break c}while(1){F[c>>2]=F[b>>2];F[c+4>>2]=F[b+4>>2];F[c+8>>2]=F[b+8>>2];F[c+12>>2]=F[b+12>>2];F[c+16>>2]=F[b+16>>2];F[c+20>>2]=F[b+20>>2];F[c+24>>2]=F[b+24>>2];F[c+28>>2]=F[b+28>>2];F[c+32>>2]=F[b+32>>2];F[c+36>>2]=F[b+36>>2];F[c+40>>2]=F[b+40>>2];F[c+44>>2]=F[b+44>>2];F[c+48>>2]=F[b+48>>2];F[c+52>>2]=F[b+52>>2];F[c+56>>2]=F[b+56>>2];F[c+60>>2]=F[b+60>>2];b=b- -64|0;c=c- -64|0;if(f>>>0>=c>>>0){continue}break}}if(c>>>0>=d>>>0){break a}while(1){F[c>>2]=F[b>>2];b=b+4|0;c=c+4|0;if(d>>>0>c>>>0){continue}break}break a}if(e>>>0<4){c=a;break a}d=e-4|0;if(d>>>0>>0){c=a;break a}c=a;while(1){D[c|0]=G[b|0];D[c+1|0]=G[b+1|0];D[c+2|0]=G[b+2|0];D[c+3|0]=G[b+3|0];b=b+4|0;c=c+4|0;if(d>>>0>=c>>>0){continue}break}}if(c>>>0>>0){while(1){D[c|0]=G[b|0];b=b+1|0;c=c+1|0;if((e|0)!=(c|0)){continue}break}}return a}function dc(a){var b=0,c=0,d=0,e=0,f=0;d=Ea-16|0;F[d+8>>2]=0;F[d+12>>2]=0;F[d>>2]=0;F[d+4>>2]=0;f=1;c=G[a|0];b=(c&3)<<2|d;F[b>>2]=F[b>>2]+1;b=c&12|d;F[b>>2]=F[b>>2]+1;b=c>>>2&12|d;F[b>>2]=F[b>>2]+1;c=c>>>4&12|d;F[c>>2]=F[c>>2]+1;c=G[a+1|0];b=(c&3)<<2|d;F[b>>2]=F[b>>2]+1;b=c&12|d;F[b>>2]=F[b>>2]+1;b=c>>>2&12|d;F[b>>2]=F[b>>2]+1;c=c>>>4&12|d;F[c>>2]=F[c>>2]+1;c=G[a+2|0];b=(c&3)<<2|d;F[b>>2]=F[b>>2]+1;b=c&12|d;F[b>>2]=F[b>>2]+1;b=c>>>2&12|d;F[b>>2]=F[b>>2]+1;c=c>>>4&12|d;F[c>>2]=F[c>>2]+1;c=G[a+3|0];b=(c&3)<<2|d;F[b>>2]=F[b>>2]+1;b=c&12|d;F[b>>2]=F[b>>2]+1;b=c>>>2&12|d;F[b>>2]=F[b>>2]+1;c=c>>>4&12|d;F[c>>2]=F[c>>2]+1;D[a+10|0]=0;D[a+8|0]=3;D[a+9|0]=0;b=a+10|0;c=a+8|0;a:{b:{c:{d:{e:{f:{if(!F[d>>2]){if(!F[d+4>>2]){break e}D[a+10|0]=1;D[c|0]=1;e=1;break f}D[a+10|0]=1;D[c|0]=0;if(!F[d+4>>2]){break d}D[a+10|0]=2;e=2}D[a+9|0]=1;f=0}if(!F[d+8>>2]){break a}e=e+1|0;D[a+10|0]=e;b=c;if(!f){break b}break c}e=2;if(F[d+8>>2]){break c}e=1;break a}D[b|0]=2}D[a+9|0]=2}if(F[d+12>>2]){D[a+9|0]=3;D[a+10|0]=e+1}}function Kb(a){var b=0,c=0,d=0,e=0,f=0;d=F[101458];c=a+7&-8;b=d+c|0;a:{b:{if(b>>>0<=d>>>0?c:0){break b}if(b>>>0>Ha()<<16>>>0){if(!(xa(b|0)|0)){break b}}F[101458]=b;break a}F[108804]=48;d=-1}if((d|0)!=-1){a=a+d|0;F[a-4>>2]=16;c=a-16|0;F[c>>2]=16;b=F[109108];if(b){f=F[b+8>>2]}else{f=0}c:{d:{if((f|0)==(d|0)){e=d-(F[d-4>>2]&-2)|0;f=F[e-4>>2];F[b+8>>2]=a;a=e-(f&-2)|0;b=-16;if(!(D[(a+F[a>>2]|0)-4|0]&1)){break d}b=F[a+4>>2];F[b+8>>2]=F[a+8>>2];F[F[a+8>>2]+4>>2]=b;b=c-a|0;F[a>>2]=b;break c}F[d+12>>2]=16;F[d>>2]=16;F[d+8>>2]=a;F[d+4>>2]=b;F[109108]=d;b=16}a=b+d|0;b=c-a|0;F[a>>2]=b}F[((b&-4)+a|0)-4>>2]=b|1;c=F[a>>2]-8|0;e:{if(c>>>0<=127){b=(c>>>3|0)-1|0;break e}e=O(c);b=((c>>>29-e^4)-(e<<2)|0)+110|0;if(c>>>0<=4095){break e}b=((c>>>30-e^2)-(e<<1)|0)+71|0;b=b>>>0>=63?63:b}c=b<<4;F[a+4>>2]=c+435408;c=c+435416|0;F[a+8>>2]=F[c>>2];F[c>>2]=a;F[F[a+8>>2]+4>>2]=a;c=F[109110];e=F[109111];a=b&31;if((b&63)>>>0>=32){b=1<>>32-a}F[109110]=f|c;F[109111]=b|e}return(d|0)!=-1}function Yb(a,b,c){var d=0,e=0,f=0,g=0,h=0;d=G[b|0];h=G[b+1|0];g=G[b+2|0];D[a+15|0]=255;D[a+11|0]=255;D[a+7|0]=255;D[a+3|0]=255;b=c<<4;e=F[b+12764>>2];c=(g<<3|g>>>2)&255;g=e+c|0;f=(g|0)>=255?255:g;D[a+14|0]=g>>>0<256?g:(f|0)>0?f:0;g=(h<<3|h>>>2)&255;h=g+e|0;f=(h|0)>=255?255:h;D[a+13|0]=h>>>0<256?h:(f|0)>0?f:0;h=(d<<3|d>>>2)&255;d=h+e|0;e=(d|0)>=255?255:d;D[a+12|0]=d>>>0<256?d:(e|0)>0?e:0;e=F[b+12760>>2];d=e+c|0;f=(d|0)>=255?255:d;D[a+10|0]=d>>>0<256?d:(f|0)>0?f:0;d=e+g|0;f=(d|0)>=255?255:d;D[a+9|0]=d>>>0<256?d:(f|0)>0?f:0;d=e+h|0;e=(d|0)>=255?255:d;D[a+8|0]=d>>>0<256?d:(e|0)>0?e:0;e=F[b+12756>>2];d=e+c|0;f=(d|0)>=255?255:d;D[a+6|0]=d>>>0<256?d:(f|0)>0?f:0;d=e+g|0;f=(d|0)>=255?255:d;D[a+5|0]=d>>>0<256?d:(f|0)>0?f:0;d=e+h|0;e=(d|0)>=255?255:d;D[a+4|0]=d>>>0<256?d:(e|0)>0?e:0;d=c;c=F[b+12752>>2];b=d+c|0;d=(b|0)>=255?255:b;D[a+2|0]=b>>>0<256?b:(d|0)>0?d:0;b=c+g|0;g=(b|0)>=255?255:b;D[a+1|0]=b>>>0<256?b:(g|0)>0?g:0;b=c+h|0;c=(b|0)>=255?255:b;D[a|0]=b>>>0<256?b:(c|0)>0?c:0}function Rb(a){var b=0;b=F[a+396>>2];if(b){Ra(b)}b=F[a+384>>2];if(b){Ra(b)}b=F[a+372>>2];if(b){Ra(b)}b=F[a+360>>2];if(b){Ra(b)}b=F[a+348>>2];if(b){Ra(b)}b=F[a+336>>2];if(b){Ra(b)}b=F[a+324>>2];if(b){Ra(b)}b=F[a+312>>2];if(b){Ra(b)}b=F[a+300>>2];if(b){Ra(b)}b=F[a+288>>2];if(b){Ra(b)}b=F[a+276>>2];if(b){Ra(b)}b=F[a+264>>2];if(b){Ra(b)}b=F[a+252>>2];if(b){Ra(b)}b=F[a+240>>2];if(b){Ra(b)}b=F[a+228>>2];if(b){Ra(b)}b=F[a+216>>2];if(b){Ra(b)}b=F[a+204>>2];if(b){Ra(b)}b=F[a+192>>2];if(b){Ra(b)}b=F[a+180>>2];if(b){Ra(b)}b=F[a+168>>2];if(b){Ra(b)}b=F[a+156>>2];if(b){Ra(b)}b=F[a+144>>2];if(b){Ra(b)}b=F[a+132>>2];if(b){Ra(b)}b=F[a+120>>2];if(b){Ra(b)}b=F[a+108>>2];if(b){Ra(b)}b=F[a+96>>2];if(b){Ra(b)}b=F[a+84>>2];if(b){Ra(b)}b=F[a+72>>2];if(b){Ra(b)}b=F[a+60>>2];if(b){Ra(b)}b=F[a+48>>2];if(b){Ra(b)}b=F[a+36>>2];if(b){Ra(b)}b=F[a+24>>2];if(b){Ra(b)}b=F[a+12>>2];if(b){Ra(b)}a=F[a>>2];if(a){Ra(a)}}function Ic(){Ca(405060,2898);Ba(405084,2340,1,0);ca(405096,2173,1,-128,127);ca(405120,2166,1,-128,127);ca(405108,2164,1,0,255);ca(405132,1171,2,-32768,32767);ca(405144,1162,2,0,65535);ca(405156,1218,4,-2147483648,2147483647);ca(405168,1209,4,0,-1);ca(405180,2552,4,-2147483648,2147483647);ca(405192,2543,4,0,-1);nc(405204,1419,-2147483648,2147483647);nc(405216,1418,0,-1);ua(405228,1340,4);ua(405240,2819,8);ta(400052,2583);ta(403280,4669);oa(403352,4,2557);oa(403428,2,2595);oa(403504,4,2610);Aa(398528,2386);Z(403544,0,4600);Z(403584,0,4702);Z(403624,1,4630);Z(403664,2,4165);Z(403704,3,4196);Z(403744,4,4236);Z(403784,5,4265);Z(403824,4,4739);Z(403864,5,4769);Z(403584,0,4367);Z(403624,1,4334);Z(403664,2,4433);Z(403704,3,4399);Z(403744,4,4567);Z(403784,5,4533);Z(403904,8,4500);Z(403944,9,4466);Z(403984,6,4303);Z(404024,7,4808)}function Jb(a,b,c){var d=0,e=0,f=0,g=0;d=a+4|0;e=(d+b|0)-1&0-b;b=F[a>>2];if(e+c>>>0<=(b+a|0)-4>>>0){f=F[a+4>>2];F[f+8>>2]=F[a+8>>2];F[F[a+8>>2]+4>>2]=f;if((d|0)!=(e|0)){e=e-d|0;f=a-(F[a-4>>2]&-2)|0;d=e+F[f>>2]|0;F[f>>2]=d;F[(f+(d&-4)|0)-4>>2]=d;a=a+e|0;b=b-e|0;F[a>>2]=b}a:{if(c+24>>>0<=b>>>0){d=(a+c|0)+8|0;b=(b-c|0)-8|0;F[d>>2]=b;F[(d+(b&-4)|0)-4>>2]=b|1;e=F[d>>2]-8|0;b:{if(e>>>0<=127){b=(e>>>3|0)-1|0;break b}f=O(e);b=((e>>>29-f^4)-(f<<2)|0)+110|0;if(e>>>0<=4095){break b}b=((e>>>30-f^2)-(f<<1)|0)+71|0;b=b>>>0>=63?63:b}e=b<<4;F[d+4>>2]=e+435408;e=e+435416|0;F[d+8>>2]=F[e>>2];F[e>>2]=d;F[F[d+8>>2]+4>>2]=d;e=F[109110];f=F[109111];d=b&31;if((b&63)>>>0>=32){b=1<>>32-d;d=g}F[109110]=d|e;F[109111]=b|f;b=c+8|0;F[a>>2]=b;F[((b&-4)+a|0)-4>>2]=b;break a}F[(a+b|0)-4>>2]=b}a=a+4|0}else{a=0}return a}function xc(a,b){var c=0,d=0,e=0,f=0,g=0;c=Ea-32|0;Ea=c;F[c+28>>2]=a;f=1;a:{b:{switch(b-a>>2){case 2:b=b-4|0;F[c+24>>2]=b;if(I[b>>2]>=I[a>>2]){break a}a=F[c+28>>2];b=F[a>>2];d=a;a=F[c+24>>2];F[d>>2]=F[a>>2];F[a>>2]=b;break a;case 3:tb(a,a+4|0,b-4|0);break a;case 4:Ac(a,a+4|0,a+8|0,b-4|0);break a;case 5:zc(a,a+4|0,a+8|0,a+12|0,b-4|0);break a;case 0:case 1:break a;default:break b}}e=a+8|0;tb(a,a+4|0,e);d=a+12|0;while(1){F[c+20>>2]=d;if((b|0)==(d|0)){break a}c:{if(I[d>>2]>=I[e>>2]){break c}F[c+16>>2]=F[F[c+20>>2]>>2];F[c+12>>2]=e;d=F[c+20>>2];while(1){d:{F[d>>2]=F[F[c+12>>2]>>2];d=F[c+12>>2];if((d|0)==(a|0)){d=a;break d}e=d-4|0;F[c+12>>2]=e;if(I[c+16>>2]>2]){continue}}break}F[d>>2]=F[c+16>>2];g=g+1|0;if((g|0)!=8){break c}f=(F[c+20>>2]+4|0)==(b|0);break a}e=F[c+20>>2];d=e+4|0;continue}}Ea=c+32|0;return f}function hb(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0;g=Ea-16|0;Ea=g;F[g+12>>2]=c;f=Ea-160|0;Ea=f;d=f+8|0;Va(d,404528,144);F[f+52>>2]=a;F[f+28>>2]=a;e=-2-a|0;h=e>>>0>2147483647?2147483647:e;F[f+56>>2]=h;a=a+h|0;F[f+36>>2]=a;F[f+24>>2]=a;e=Ea-208|0;Ea=e;F[e+204>>2]=c;a=e+160|0;Ta(a,0,40);F[e+200>>2]=F[e+204>>2];a:{if((Ec(0,b,e+200|0,e+80|0,a)|0)<0){break a}c=F[d+76>>2]<0;a=F[d>>2];F[d>>2]=a&-33;b:{c:{d:{if(!F[d+48>>2]){F[d+48>>2]=80;F[d+28>>2]=0;F[d+16>>2]=0;F[d+20>>2]=0;i=F[d+44>>2];F[d+44>>2]=e;break d}if(F[d+16>>2]){break c}}if(Gc(d)){break b}}Ec(d,b,e+200|0,e+80|0,e+160|0)}if(i){Ga[F[d+36>>2]](d,0,0)|0;F[d+48>>2]=0;F[d+44>>2]=i;F[d+28>>2]=0;F[d+16>>2]=0;F[d+20>>2]=0}F[d>>2]=F[d>>2]|a&32;if(c){break a}}Ea=e+208|0;if(h){a=F[f+28>>2];D[a-((a|0)==F[f+24>>2])|0]=0}Ea=f+160|0;Ea=g+16|0}function $d(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;f=Ea-32|0;Ea=f;d=F[a+28>>2];F[f+16>>2]=d;g=F[a+20>>2];F[f+28>>2]=c;F[f+24>>2]=b;b=g-d|0;F[f+20>>2]=b;g=b+c|0;i=2;a:{b:{b=f+16|0;d=sa(F[a+60>>2],b|0,2,f+12|0)|0;if(d){F[108804]=d;d=-1}else{d=0}c:{d:{if(d){d=b;break d}while(1){e=F[f+12>>2];if((e|0)==(g|0)){break c}if((e|0)<0){d=b;break b}h=F[b+4>>2];j=h>>>0>>0;d=(j<<3)+b|0;h=e-(j?h:0)|0;F[d>>2]=h+F[d>>2];b=(j?12:4)+b|0;F[b>>2]=F[b>>2]-h;g=g-e|0;b=d;i=i-j|0;e=sa(F[a+60>>2],b|0,i|0,f+12|0)|0;if(e){F[108804]=e;e=-1}else{e=0}if(!e){continue}break}}if((g|0)!=-1){break b}}b=F[a+44>>2];F[a+28>>2]=b;F[a+20>>2]=b;F[a+16>>2]=b+F[a+48>>2];a=c;break a}F[a+28>>2]=0;F[a+16>>2]=0;F[a+20>>2]=0;F[a>>2]=F[a>>2]|32;a=0;if((i|0)==2){break a}a=c-F[d+4>>2]|0}Ea=f+32|0;return a|0}function yd(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0;d=Qa(604);f=Ea-32|0;Ea=f;F[d>>2]=0;e=d+4|0;Hb(e);D[e+585|0]=0;F[f+8>>2]=a;h=f+8|0;b=h;Pc(d+592|0,b);if(G[435168]){e=F[a>>2];c=$(2413)|0;e=_(e|0,c|0)|0;W(c|0);g=+fa(e|0,405168,b|0);ea(F[f+8>>2]);W(e|0);b=ja(4864)|0;c=$(2107)|0;e=_(b|0,c|0)|0;W(c|0);W(b|0);b=F[a>>2];c=$(2095)|0;b=_(b|0,c|0)|0;W(c|0);c=F[d+592>>2];aa(e|0);F[f+24>>2]=g<4294967296&g>=0?~~g>>>0:0;F[f+16>>2]=c;F[f+8>>2]=e;c=ia(b|0,3,398496,h|0)|0;W(b|0);if(!(D[435184]&1)){b=ha(2,398536)|0;D[435184]=1;F[108795]=b}b=F[108795];aa(F[a>>2]);F[f+8>>2]=F[a>>2];ka(b|0,c|0,1336,f+8|0);a:{if(lc(F[d+592>>2],F[d+596>>2])){break a}a=F[d+592>>2];if(!a){break a}Ra(a);F[d+600>>2]=0;F[d+592>>2]=0;F[d+596>>2]=0}F[d>>2]=-559038751;W(c|0);W(e|0)}Ea=f+32|0;return d|0}function qb(a,b,c,d,e,f,g,h){var i=0,j=0,k=0;a=0;a:{if((G[b|0]|G[b+1|0]<<8)!=17011|c>>>0<78|((G[b+2|0]|G[b+3|0]<<8)!=19|(G[b+4|0]|G[b+5|0]<<8)!=77)){break a}if((G[b+8|0]|G[b+9|0]<<8|(G[b+10|0]<<16|G[b+11|0]<<24))+77>>>0>c>>>0){break a}i=G[b+14|0]|(G[b+15|0]<<8|G[b+16|0]<<16);if(!i){break a}k=G[b+17|0]|(G[b+18|0]<<8|G[b+19|0]<<16);if(!k){break a}j=G[b+65|0]|G[b+66|0]<<8|(G[b+67|0]<<16|G[b+68|0]<<24);if(j>>>0>=c>>>0|c-j>>>0>>0){break a}b=b+j|0;c=0;while(1){a=b+L(c,23)|0;if(!((G[a+1|0]<<8|G[a+2|0]<<16|G[a|0])==(d|0)&G[a+3|0]==(e|0))){a=0;c=c+1|0;if((i|0)!=(c|0)){continue}break a}break}a=0;if(d>>>0>=k>>>0){break a}a=b+L(c,23)|0;F[f>>2]=G[a+5|0]|G[a+6|0]<<8;F[g>>2]=G[a+7|0]|G[a+8|0]<<8;F[h>>2]=L(G[a+11|0]|G[a+12|0]<<8,G[a+9|0]|G[a+10|0]<<8);a=1}return a}function Yc(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;q=q|0;r=r|0;s=s|0;var t=0,u=0,v=0,w=0,x=0;t=Ea-32|0;Ea=t;a:{if(!G[435168]){break a}F[t+28>>2]=0;F[t+20>>2]=0;F[t+24>>2]=0;lb(e,t+20|0);b:{if(!F[t+24>>2]){break b}e=F[c>>2];u=$(2420)|0;e=_(e|0,u|0)|0;W(u|0);v=+fa(e|0,405168,t+8|0);ea(F[t+8>>2]);W(e|0);if(v<4294967296&v>=0){e=~~v>>>0}else{e=0}if(!e){break b}F[t+16>>2]=0;F[t+8>>2]=0;F[t+12>>2]=0;u=t+8|0;Wa(u,e,(e|0)==1,1);w=F[t+12>>2];Ta(w+F[t+8>>2]|0,0,e-w|0);F[t+12>>2]=e;if(Ub(a,b,F[t+8>>2],d,F[t+20>>2],F[t+24>>2],f,g,h,i,j,k,l,m,n,o,p,q,r,a+584|0,s)){x=ob(c,u)}a=F[t+8>>2];if(!a){break b}Ra(a)}a=F[t+20>>2];if(!a){break a}Ra(a)}Ea=t+32|0;return x|0}function db(a,b,c){var d=0,e=0;a:{if((a|0)==(b|0)){break a}e=a+c|0;if(b-e>>>0<=0-(c<<1)>>>0){return Va(a,b,c)}d=(a^b)&3;b:{c:{if(a>>>0>>0){if(d){d=a;break b}if(!(a&3)){d=a;break c}d=a;while(1){if(!c){break a}D[d|0]=G[b|0];b=b+1|0;c=c-1|0;d=d+1|0;if(d&3){continue}break}break c}d:{if(d){break d}if(e&3){while(1){if(!c){break a}c=c-1|0;d=c+a|0;D[d|0]=G[b+c|0];if(d&3){continue}break}}if(c>>>0<=3){break d}while(1){c=c-4|0;F[c+a>>2]=F[b+c>>2];if(c>>>0>3){continue}break}}if(!c){break a}while(1){c=c-1|0;D[c+a|0]=G[b+c|0];if(c){continue}break}break a}if(c>>>0<=3){break b}while(1){F[d>>2]=F[b>>2];b=b+4|0;d=d+4|0;c=c-4|0;if(c>>>0>3){continue}break}}if(!c){break a}while(1){D[d|0]=G[b|0];d=d+1|0;b=b+1|0;c=c-1|0;if(c){continue}break}}return a}function Cc(a,b,c){a:{switch(b-9|0){case 0:b=F[c>>2];F[c>>2]=b+4;F[a>>2]=F[b>>2];return;case 6:b=F[c>>2];F[c>>2]=b+4;b=E[b>>1];F[a>>2]=b;F[a+4>>2]=b>>31;return;case 7:b=F[c>>2];F[c>>2]=b+4;F[a>>2]=H[b>>1];F[a+4>>2]=0;return;case 8:b=F[c>>2];F[c>>2]=b+4;b=D[b|0];F[a>>2]=b;F[a+4>>2]=b>>31;return;case 9:b=F[c>>2];F[c>>2]=b+4;F[a>>2]=G[b|0];F[a+4>>2]=0;return;case 16:b=F[c>>2]+7&-8;F[c>>2]=b+8;K[a>>3]=K[b>>3];return;case 17:v();default:return;case 1:case 4:case 14:b=F[c>>2];F[c>>2]=b+4;b=F[b>>2];F[a>>2]=b;F[a+4>>2]=b>>31;return;case 2:case 5:case 11:case 15:b=F[c>>2];F[c>>2]=b+4;F[a>>2]=F[b>>2];F[a+4>>2]=0;return;case 3:case 10:case 12:case 13:break a}}b=F[c>>2]+7&-8;F[c>>2]=b+8;c=F[b+4>>2];F[a>>2]=F[b>>2];F[a+4>>2]=c}function Kd(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;q=q|0;r=r|0;var s=0,t=0,u=0;i=Ea-32|0;Ea=i;a:{if(!G[435168]){break a}F[i+28>>2]=0;F[i+20>>2]=0;F[i+24>>2]=0;lb(d,i+20|0);b:{if(!F[i+24>>2]){break b}d=F[b>>2];n=$(2420)|0;d=_(d|0,n|0)|0;W(n|0);s=+fa(d|0,405168,i+8|0);ea(F[i+8>>2]);W(d|0);if(s<4294967296&s>=0){d=~~s>>>0}else{d=0}if(!d){break b}F[i+16>>2]=0;F[i+8>>2]=0;F[i+12>>2]=0;n=i+8|0;Wa(n,d,(d|0)==1,1);t=F[i+12>>2];Ta(t+F[i+8>>2]|0,0,d-t|0);F[i+12>>2]=d;if(Fb(a,F[i+8>>2],c,F[i+20>>2],F[i+24>>2],e,f,g,h,j,k,l,m,o,p,q,r)){u=ob(b,n)}a=F[i+8>>2];if(!a){break b}Ra(a)}a=F[i+20>>2];if(!a){break a}Ra(a)}Ea=i+32|0;return u|0}function ab(a,b){var c=0,d=0,e=0;c=Ea+-64|0;Ea=c;d=F[a>>2];e=F[d-4>>2];d=F[d-8>>2];F[c+32>>2]=0;F[c+36>>2]=0;F[c+40>>2]=0;F[c+44>>2]=0;F[c+48>>2]=0;F[c+52>>2]=0;D[c+55|0]=0;D[c+56|0]=0;D[c+57|0]=0;D[c+58|0]=0;D[c+59|0]=0;D[c+60|0]=0;D[c+61|0]=0;D[c+62|0]=0;F[c+24>>2]=0;F[c+28>>2]=0;F[c+20>>2]=0;F[c+16>>2]=404708;F[c+12>>2]=a;F[c+8>>2]=b;a=a+d|0;d=0;a:{if(Xa(e,b,0)){F[c+56>>2]=1;Ga[F[F[e>>2]+20>>2]](e,c+8|0,a,a,1,0);d=F[c+32>>2]==1?a:0;break a}Ga[F[F[e>>2]+24>>2]](e,c+8|0,a,1,0);b:{switch(F[c+44>>2]){case 0:d=F[c+48>>2]==1?F[c+36>>2]==1?F[c+40>>2]==1?F[c+28>>2]:0:0:0;break a;case 1:break b;default:break a}}if(F[c+32>>2]!=1){if(F[c+48>>2]|F[c+36>>2]!=1|F[c+40>>2]!=1){break a}}d=F[c+24>>2]}Ea=c- -64|0;return d}function Ta(a,b,c){var d=0,e=0,f=0,g=0;a:{if(!c){break a}D[a|0]=b;d=a+c|0;D[d-1|0]=b;if(c>>>0<3){break a}D[a+2|0]=b;D[a+1|0]=b;D[d-3|0]=b;D[d-2|0]=b;if(c>>>0<7){break a}D[a+3|0]=b;D[d-4|0]=b;if(c>>>0<9){break a}d=0-a&3;e=d+a|0;b=L(b&255,16843009);F[e>>2]=b;d=c-d&-4;c=d+e|0;F[c-4>>2]=b;if(d>>>0<9){break a}F[e+8>>2]=b;F[e+4>>2]=b;F[c-8>>2]=b;F[c-12>>2]=b;if(d>>>0<25){break a}F[e+24>>2]=b;F[e+20>>2]=b;F[e+16>>2]=b;F[e+12>>2]=b;F[c-16>>2]=b;F[c-20>>2]=b;F[c-24>>2]=b;F[c-28>>2]=b;g=e&4|24;c=d-g|0;if(c>>>0<32){break a}d=We(b,0,1,1);f=Fa;b=e+g|0;while(1){F[b+24>>2]=d;F[b+28>>2]=f;F[b+16>>2]=d;F[b+20>>2]=f;F[b+8>>2]=d;F[b+12>>2]=f;F[b>>2]=d;F[b+4>>2]=f;b=b+32|0;c=c-32|0;if(c>>>0>31){continue}break}}return a}function Db(a){var b=0;b=F[a+4>>2];if(b){Ra(b);F[a+12>>2]=0;F[a+4>>2]=0;F[a+8>>2]=0}b=F[a+16>>2];if(b){Ra(b);F[a+24>>2]=0;F[a+16>>2]=0;F[a+20>>2]=0}if(F[a+32>>2]>0){F[a+32>>2]=0}b=F[a+44>>2];if((b|0)>0){F[a+44>>2]=b&-1073741824}b=F[a+56>>2];if((b|0)>0){F[a+56>>2]=b&-2147483648}if(F[a+68>>2]>0){F[a+68>>2]=0}b=F[a+80>>2];if((b|0)>0){F[a+80>>2]=b&-1073741824}b=F[a+92>>2];if((b|0)>0){F[a+92>>2]=b&-2147483648}if(F[a+104>>2]>0){F[a+104>>2]=0}b=F[a+116>>2];if((b|0)>0){F[a+116>>2]=b&-1073741824}b=F[a+128>>2];if((b|0)>0){F[a+128>>2]=b&-2147483648}if(F[a+140>>2]>0){F[a+140>>2]=0}b=F[a+152>>2];if((b|0)>0){F[a+152>>2]=b&-1073741824}b=F[a+164>>2];if((b|0)>0){F[a+164>>2]=b&-2147483648}F[a+172>>2]=0}function mc(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=F[a+104>>2];D[c|0]=1;D[c+1|0]=0;D[c+2|0]=0;D[c+3|0]=0;e=a+39|0;f=G[d+7136|0]-1|0;d=F[(G[d+7008|0]<<2)+405664>>2];g=G[G[e+(1<>>6;d=(d<<4|n<<2|m)<<4|l<<2|k;D[c+6|0]=d>>>6;d=(d<<4|j<<2|i)<<4|h<<2|g;D[c+5|0]=d>>>6;D[c+4|0]=a|d<<2;Gb(c,b,4)}function Ra(a){var b=0,c=0,d=0,e=0,f=0;if(a){b=a-4|0;e=F[b>>2];d=e;c=b;f=F[a-8>>2];a=f&-2;if((a|0)!=(f|0)){c=b-a|0;f=F[c+4>>2];F[f+8>>2]=F[c+8>>2];F[F[c+8>>2]+4>>2]=f;d=a+d|0}a=b+e|0;b=F[a>>2];if((b|0)!=F[(a+b|0)-4>>2]){e=F[a+4>>2];F[e+8>>2]=F[a+8>>2];F[F[a+8>>2]+4>>2]=e;d=b+d|0}F[c>>2]=d;F[((d&-4)+c|0)-4>>2]=d|1;b=F[c>>2]-8|0;a:{if(b>>>0<=127){a=(b>>>3|0)-1|0;break a}d=O(b);a=((b>>>29-d^4)-(d<<2)|0)+110|0;if(b>>>0<=4095){break a}a=((b>>>30-d^2)-(d<<1)|0)+71|0;a=a>>>0>=63?63:a}b=a<<4;F[c+4>>2]=b+435408;b=b+435416|0;F[c+8>>2]=F[b>>2];F[b>>2]=c;F[F[c+8>>2]+4>>2]=c;b=F[109110];d=F[109111];c=a&31;if((a&63)>>>0>=32){a=1<>>32-c}F[109110]=e|b;F[109111]=a|d}}function xb(a,b,c){var d=0,e=0,f=0,g=0,h=0;d=Ea-32|0;Ea=d;a:{if(!(c?b:1)){break a}F[d+24>>2]=0;F[d+28>>2]=0;F[d+16>>2]=b;F[d+12>>2]=b;F[d+8>>2]=c;F[d+20>>2]=b+c;b=d+8|0;if(!bb(b,a+28|0)|!F[a+32>>2]){break a}if(!bb(b,a- -64|0)|!F[a+68>>2]){break a}if(!bb(b,a+100|0)|!F[a+104>>2]){break a}if(!bb(b,a+136|0)|!F[a+140>>2]){break a}f=F[d+28>>2];b:{if(f>>>0>=13){c=F[d+24>>2];break b}c=0;g=F[d+24>>2];h=F[d+20>>2];b=F[d+12>>2];c:{if(h>>>0<=b>>>0){e=b;break c}e=b+1|0;F[d+12>>2]=e;c=G[b|0]}b=f+8|0;F[d+28>>2]=b;c=g|c<>2]=c;if(f>>>0>4){break b}g=0;if(e>>>0>>0){F[d+12>>2]=e+1;g=G[e|0]}F[d+28>>2]=f+16;c=g<>2]=c}b=a;a=c&8191;F[b+172>>2]=a;e=(a|0)!=0}Ea=d+32|0;return e}function Vb(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;f=G[b+1|0];e=G[b|0];k=G[b+2|0];l=G[b+3|0];m=G[b+4|0];h=G[((((L(f>>>d|0,3)+(e>>>d|0)|0)+L(k>>>d|0,9)|0)+L(l>>>d|0,27)|0)+L(m>>>d|0,81)|0)+207584|0];n=d+2|0;i=-1<>2];while(1){g=(e>>3)+a|0;e=e&7;D[g|0]=G[g|0]|f<>2]|0;F[c>>2]=e;f=f>>>g|0;b=b-g|0;if(b){continue}break}}f=L(d,3);b=f+6|0;if(b){f=(h>>>4&1)<>>7<>>5&3)<>>2&3|(i&k)<<2)|(i&l)<>2];while(1){d=(e>>3)+a|0;g=d;h=G[d|0];d=e&7;D[g|0]=h|f<>2]|0;F[c>>2]=e;f=f>>>d|0;b=b-d|0;if(b){continue}break}}}function wc(a,b,c){var d=0,e=0,f=0,g=0,h=0,i=0;d=Ea-16|0;Ea=d;F[d+12>>2]=c;a:{if((b|0)<2){break a}i=b-2>>>1|0;e=c-a|0;if((i|0)>2){break a}f=e>>1;e=f+1|0;g=(e<<2)+a|0;F[d+8>>2]=g;f=f+2|0;b:{if((f|0)>=(b|0)){break b}h=g+4|0;if(I[g>>2]>=I[h>>2]){break b}F[d+8>>2]=h;g=h;e=f}if(I[g>>2]>2]){break a}F[d+4>>2]=F[F[d+12>>2]>>2];c:{while(1){F[F[d+12>>2]>>2]=F[F[d+8>>2]>>2];c=F[d+8>>2];F[d+12>>2]=c;if((e|0)>(i|0)){break c}e=e<<1;f=e|1;c=(f<<2)+a|0;F[d+8>>2]=c;d:{e:{e=e+2|0;if((e|0)>=(b|0)){break e}g=F[c>>2];h=F[c+4>>2];c=F[d+8>>2];if(g>>>0>=h>>>0){break e}c=c+4|0;F[d+8>>2]=c;break d}e=f}if(I[c>>2]>=I[d+4>>2]){continue}break}c=F[d+12>>2]}F[c>>2]=F[d+4>>2]}Ea=d+16|0}function lb(a,b){var c=0,d=0,e=0,f=0,g=0,h=0;e=Ea-32|0;Ea=e;c=F[a>>2];d=$(2413)|0;c=_(c|0,d|0)|0;W(d|0);h=+fa(c|0,405168,e+8|0);ea(F[e+8>>2]);W(c|0);d=F[b+4>>2];if(h<4294967296&h>=0){c=~~h>>>0}else{c=0}if((d|0)!=(c|0)){if(c>>>0>=d>>>0){if(c>>>0>I[b+8>>2]){Wa(b,c,(c|0)==(d+1|0),1);d=F[b+4>>2]}Ta(F[b>>2]+d|0,0,c-d|0)}F[b+4>>2]=c}f=ja(4864)|0;g=$(2107)|0;d=_(f|0,g|0)|0;W(g|0);W(f|0);f=F[a>>2];g=$(2095)|0;f=_(f|0,g|0)|0;W(g|0);b=F[b>>2];aa(d|0);F[e+24>>2]=c;F[e+16>>2]=b;F[e+8>>2]=d;b=ia(f|0,3,398496,e+8|0)|0;W(f|0);if(!(D[435184]&1)){c=ha(2,398536)|0;D[435184]=1;F[108795]=c}c=F[108795];aa(F[a>>2]);F[e+8>>2]=F[a>>2];ka(c|0,b|0,1336,e+8|0);W(b|0);W(d|0);Ea=e+32|0}function Ab(a,b,c,d,e){var f=0,g=0,h=0,i=0;a:{if(I[a+92>>2]<=c>>>0){break a}b:{if(I[a+44>>2]>=2){if(e>>>0<=5){break b}break a}if(e){break a}}f=F[a+40>>2];if((f>>>0<=1?1:f)>>>0<=d>>>0){break a}f=F[a+28>>2];g=F[a+32>>2];F[b+4>>2]=d;F[b+8>>2]=e;F[b>>2]=c;g=g>>>c|0;g=g>>>0<=1?1:g;F[b+16>>2]=g;f=f>>>c|0;f=f>>>0<=1?1:f;F[b+12>>2]=f;g=g+3|0;h=g>>>2|0;F[b+32>>2]=h;f=f+3|0;i=f>>>2|0;F[b+28>>2]=i;F[b+24>>2]=g&-4;F[b+20>>2]=f&-4;F[b+36>>2]=L(h,i);f=G[a+1200|0];D[b+41|0]=0;D[b+40|0]=f;g=1;if(!F[a+148>>2]){break a}f=F[a+144>>2];h=F[a+44>>2];a=F[a+40>>2];a=f+L(L(h,L(a>>>0<=1?1:a,c)+d|0)+e|0,20)|0;D[b+41|0]=!((G[a|0]|G[a+1|0]<<8|(G[a+2|0]<<16|G[a+3|0]<<24))&2)}return g}function yc(a,b,c){var d=0,e=0,f=0;d=Ea-16|0;Ea=d;F[d+8>>2]=b;F[d+12>>2]=a;F[d+4>>2]=c;b=F[b>>2];e=b>>>0>I[c>>2];Ea=d+16|0;a:{b:{if(b>>>0>=I[a>>2]){b=0;if(!e){break a}c=d+8|0;b=F[c>>2];e=F[b>>2];f=b;b=F[d+4>>2];F[f>>2]=F[b>>2];F[b>>2]=e;b=1;if(I[F[d+8>>2]>>2]>=I[a>>2]){break a}a=F[d+12>>2];b=F[a>>2];f=a;a=F[c>>2];F[f>>2]=F[a>>2];break b}if(e){a=F[d+12>>2];b=F[a>>2];c=a;a=F[d+4>>2];F[c>>2]=F[a>>2];F[a>>2]=b;b=1;break a}a=F[d+12>>2];b=F[a>>2];f=a;a=d+8|0;e=F[a>>2];F[f>>2]=F[e>>2];F[e>>2]=b;b=1;if(I[c>>2]>=I[F[d+8>>2]>>2]){break a}a=F[a>>2];b=F[a>>2];c=a;a=F[d+4>>2];F[c>>2]=F[a>>2]}F[a>>2]=b;b=2}return b}function gc(a,b,c,d,e,f,g,h){var i=0,j=0,k=0,l=0,m=0,n=0;f=f<<2|f>>>4;i=c<<2|c>>>4;c=f-i|0;e=e<<3|e>>>2;j=b<<3|b>>>2;b=e-j|0;g=g<<3|g>>>2;k=d<<3|d>>>2;d=g-k|0;l=(L(c,(i+(f<<1)>>>0)/3|0)+L(b,((e<<1)+j>>>0)/3|0)|0)+L(d,((g<<1)+k>>>0)/3|0)|0;m=(L(c,(f+(i<<1)>>>0)/3|0)+L(b,(e+(j<<1)>>>0)/3|0)|0)+L(d,(g+(k<<1)>>>0)/3|0)|0;n=l+m|0;g=((L(c,f)+L(b,e)|0)+L(d,g)|0)+l|0;i=((L(c,i)+L(b,j)|0)+L(d,k)|0)+m|0;f=0;while(1){e=(f<<2)+a|0;e=(L(c,G[e+1|0])+L(b,G[e|0])|0)+L(d,G[e+2|0])<<1;D[f+h|0]=G[((((e|0)<=(i|0))+((e|0)<(n|0))|0)+((e|0)<(g|0))|0)+5226|0];f=f+1|0;if((f|0)!=16){continue}break}}function ob(a,b){var c=0,d=0,e=0,f=0,g=0;d=Ea-32|0;Ea=d;a:{if(!F[b+4>>2]){break a}e=F[a>>2];c=$(2420)|0;e=_(e|0,c|0)|0;W(c|0);g=+fa(e|0,405156,d+8|0);ea(F[d+8>>2]);W(e|0);if(N(g)<2147483648){c=~~g}else{c=-2147483648}if(c>>>0>2]){break a}c=ja(4864)|0;f=$(2107)|0;e=_(c|0,f|0)|0;W(f|0);W(c|0);c=ra(1109)|0;f=F[b>>2];b=F[b+4>>2];aa(e|0);F[d+24>>2]=b;F[d+16>>2]=f;F[d+8>>2]=e;b=ia(c|0,3,398544,d+8|0)|0;W(c|0);a=F[a>>2];if(!(D[435192]&1)){c=ha(2,398556)|0;D[435192]=1;F[108797]=c}c=F[108797];aa(b|0);F[d+8>>2]=b;ka(c|0,a|0,1336,d+8|0);W(b|0);W(e|0);f=1}Ea=d+32|0;return f}function Me(a,b){a=a|0;b=b|0;F[a>>2]=0;F[a+4>>2]=0;F[a+56>>2]=0;F[a+48>>2]=0;F[a+52>>2]=0;F[a+40>>2]=0;F[a+44>>2]=0;F[a+32>>2]=0;F[a+36>>2]=0;F[a+24>>2]=0;F[a+28>>2]=0;F[a+16>>2]=0;F[a+20>>2]=0;F[a+8>>2]=0;F[a+12>>2]=0;if(F[b>>2]==-559038750){F[a>>2]=F[b+24>>2];F[a+4>>2]=F[b+28>>2];F[a+8>>2]=F[b+32>>2];F[a+12>>2]=F[b+36>>2];F[a+16>>2]=F[b+40>>2];F[a+20>>2]=F[b+44>>2];F[a+24>>2]=F[b+48>>2];F[a+28>>2]=F[b+52>>2];F[a+32>>2]=F[b+56>>2];F[a+36>>2]=F[b+60>>2];F[a+40>>2]=F[b- -64>>2];F[a+44>>2]=F[b+68>>2];F[a+48>>2]=F[b+72>>2];F[a+52>>2]=F[b+76>>2];F[a+56>>2]=F[b+84>>2]}}function lc(a,b){var c=0,d=0,e=0,f=0;a:{if((G[a|0]|G[a+1|0]<<8)!=17011|b>>>0<78|((G[a+2|0]|G[a+3|0]<<8)!=19|(G[a+4|0]|G[a+5|0]<<8)!=77)){break a}if((G[a+8|0]|G[a+9|0]<<8|(G[a+10|0]<<16|G[a+11|0]<<24))+77>>>0>b>>>0){break a}c=G[a+17|0]|(G[a+18|0]<<8|G[a+19|0]<<16);if(!c){break a}d=G[a+14|0];e=d|(G[a+15|0]<<8|G[a+16|0]<<16);if(c>>>0>e>>>0){break a}c=G[a+21|0];b:{if(!G[a+20|0]){if(!(c&1)){break a}if(!((c&4)>>>2&d)){break b}break a}if(c&1){break a}}a=G[a+65|0]|G[a+66|0]<<8|(G[a+67|0]<<16|G[a+68|0]<<24);if(a>>>0>=b>>>0){break a}f=b-a>>>0>=L(e,23)>>>0}return f}function Td(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;if(Xa(a,F[b+8>>2],e)){if(!(F[b+28>>2]==1|F[b+4>>2]!=(c|0))){F[b+28>>2]=d}return}a:{if(Xa(a,F[b>>2],e)){if(!(F[b+16>>2]!=(c|0)&F[b+20>>2]!=(c|0))){if((d|0)!=1){break a}F[b+32>>2]=1;return}F[b+32>>2]=d;b:{if(F[b+44>>2]==4){break b}E[b+52>>1]=0;a=F[a+8>>2];Ga[F[F[a>>2]+20>>2]](a,b,c,c,1,e);if(G[b+53|0]){F[b+44>>2]=3;if(!G[b+52|0]){break b}break a}F[b+44>>2]=4}F[b+20>>2]=c;F[b+40>>2]=F[b+40>>2]+1;if(F[b+36>>2]!=1|F[b+24>>2]!=2){break a}D[b+54|0]=1;return}a=F[a+8>>2];Ga[F[F[a>>2]+24>>2]](a,b,c,d,e)}}function Wa(a,b,c,d){var e=0,f=0,g=0,h=0;h=Ea-288|0;Ea=h;a:{if(I[a+8>>2]>>0){b:{c:{if(!c){break c}c=b-1|0;if(!(!b|c&b)){break c}f=0-!b|0;g=f;f=c|f;e=g;c=e>>>16|0;e=f|((e&65535)<<16|f>>>16);c=c|g;g=c;f=c>>>8|0;c=(c&255)<<24|e>>>8|e;f=f|g;g=f;e=f>>>4|0;f=(f&15)<<28|c>>>4|c;e=e|g;c=e>>>2|0;c=c|e;e=(e&3)<<30|f>>>2|f;c=(e|((c&1)<<31|e>>>1))+1|0;if(c>>>0>=b>>>0){break b}Fc(5208,17,1,F[101008]);na();v()}c=b}b=L(c,d);d=nb(F[a>>2],b);if(!d){F[h>>2]=b;a=h+32|0;hb(a,1820,h);break a}F[a+8>>2]=c;F[a>>2]=d}Ea=h+288|0;return}Nb(a,F[101008]);na();v()}function pb(a,b){var c=0,d=0,e=0,f=0;d=Ea-288|0;Ea=d;F[a+8>>2]=0;F[a>>2]=0;F[a+4>>2]=0;a:{b:{c:{c=F[b+4>>2];d:{if(!c){break d}e=Ya(c);if(!e){break c}F[a+8>>2]=c;F[a>>2]=e;c=F[b+4>>2];F[a+4>>2]=c;f=F[b>>2];if(!f){break d}Va(e,f,c)}F[a+12>>2]=0;F[a+16>>2]=0;F[a+20>>2]=0;c=F[b+16>>2];e:{if(!c){break e}e=Ya(c);if(!e){break b}F[a+20>>2]=c;F[a+12>>2]=e;c=F[b+16>>2];F[a+16>>2]=c;b=F[b+12>>2];if(!b){break e}Va(e,b,c)}Ea=d+288|0;return a}F[d+16>>2]=c;a=d+32|0;hb(a,1820,d+16|0);break a}F[d>>2]=c;a=d+32|0;hb(a,1820,d)}Nb(a,F[101008]);na();v()}function Le(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=Ea+-64|0;Ea=c;d=F[a>>2];e=b;b=F[a+4>>2];a=e+(b>>1)|0;Ga[(b&1?F[d+F[a>>2]>>2]:d)|0](c+4|0,a);b=Qa(60);F[b+56>>2]=F[c+60>>2];a=F[c+56>>2];F[b+48>>2]=F[c+52>>2];F[b+52>>2]=a;a=F[c+48>>2];F[b+40>>2]=F[c+44>>2];F[b+44>>2]=a;a=F[c+40>>2];F[b+32>>2]=F[c+36>>2];F[b+36>>2]=a;a=F[c+32>>2];F[b+24>>2]=F[c+28>>2];F[b+28>>2]=a;a=F[c+24>>2];F[b+16>>2]=F[c+20>>2];F[b+20>>2]=a;a=F[c+16>>2];F[b+8>>2]=F[c+12>>2];F[b+12>>2]=a;a=F[c+8>>2];F[b>>2]=F[c+4>>2];F[b+4>>2]=a;Ea=c- -64|0;return b|0}function ud(a){a=a|0;var b=0,c=0,d=0,e=0;if(F[a>>2]==-559038751){b=F[a+592>>2];a=F[a+596>>2];a:{if((G[b|0]|G[b+1|0]<<8)!=17011|a>>>0<78|((G[b+2|0]|G[b+3|0]<<8)!=19|(G[b+4|0]|G[b+5|0]<<8)!=77)){break a}if(a>>>0<(G[b+8|0]|G[b+9|0]<<8|(G[b+10|0]<<16|G[b+11|0]<<24))+77>>>0){break a}c=G[b+14|0]|(G[b+15|0]<<8|G[b+16|0]<<16);if(!c|!(G[b+17|0]|(G[b+18|0]<<8|G[b+19|0]<<16))){break a}d=G[b+65|0]|G[b+66|0]<<8|(G[b+67|0]<<16|G[b+68|0]<<24);if(a>>>0<=d>>>0|a-d>>>0>>0){break a}e=G[b+20|0]}a=(e|0)==1}else{a=0}return a|0}function Kc(a,b,c){var d=0;if(!c){F[a>>2]=0;F[a+4>>2]=0;F[a+16>>2]=0;F[a+8>>2]=0;F[a+12>>2]=0;return-72}F[a+12>>2]=b;F[a+16>>2]=b+4;if(c>>>0>=4){d=b+c|0;b=d-4|0;F[a+8>>2]=b;F[a>>2]=G[b|0]|G[b+1|0]<<8|(G[b+2|0]<<16|G[b+3|0]<<24);b=G[d-1|0];if(b){F[a+4>>2]=O(b)-23;return c}F[a+4>>2]=0;return-1}F[a+8>>2]=b;d=G[b|0];F[a>>2]=d;a:{switch(c-2|0){case 1:d=G[b+2|0]<<16|d;F[a>>2]=d;case 0:F[a>>2]=(G[b+1|0]<<8)+d;break;default:break a}}b=G[(b+c|0)-1|0];if(!b){F[a+4>>2]=0;return-20}F[a+4>>2]=(O(b)-(c<<3)|0)+9;return c}function td(a){a=a|0;var b=0,c=0,d=0,e=0;if(F[a>>2]==-559038751){a:{b=F[a+596>>2];a=F[a+592>>2];if(b>>>0<78|(G[a|0]|G[a+1|0]<<8)!=17011|((G[a+2|0]|G[a+3|0]<<8)!=19|(G[a+4|0]|G[a+5|0]<<8)!=77)){break a}if(b>>>0<(G[a+8|0]|G[a+9|0]<<8|(G[a+10|0]<<16|G[a+11|0]<<24))+77>>>0){break a}c=G[a+14|0]|(G[a+15|0]<<8|G[a+16|0]<<16);if(!c){break a}d=G[a+17|0]|(G[a+18|0]<<8|G[a+19|0]<<16);if(!d){break a}a=G[a+65|0]|G[a+66|0]<<8|(G[a+67|0]<<16|G[a+68|0]<<24);if(a>>>0>=b>>>0){break a}e=b-a>>>0>=L(c,23)>>>0?d:0}}return e|0}function Bc(a,b){if(!a){return 0}a:{b:{if(a){if(b>>>0<=127){break b}c:{if(!F[F[108843]>>2]){if((b&-128)==57216){break b}break c}if(b>>>0<=2047){D[a+1|0]=b&63|128;D[a|0]=b>>>6|192;a=2;break a}if(!((b&-8192)!=57344&b>>>0>=55296)){D[a+2|0]=b&63|128;D[a|0]=b>>>12|224;D[a+1|0]=b>>>6&63|128;a=3;break a}if(b-65536>>>0<=1048575){D[a+3|0]=b&63|128;D[a|0]=b>>>18|240;D[a+2|0]=b>>>6&63|128;D[a+1|0]=b>>>12&63|128;a=4;break a}}F[108804]=25;a=-1}else{a=1}break a}D[a|0]=b;a=1}return a}function hd(a,b){a=a|0;b=b|0;var c=0;c=Ea+-64|0;Ea=c;Ga[F[a>>2]](c+4|0,b);b=Qa(60);F[b+56>>2]=F[c+60>>2];a=F[c+56>>2];F[b+48>>2]=F[c+52>>2];F[b+52>>2]=a;a=F[c+48>>2];F[b+40>>2]=F[c+44>>2];F[b+44>>2]=a;a=F[c+40>>2];F[b+32>>2]=F[c+36>>2];F[b+36>>2]=a;a=F[c+32>>2];F[b+24>>2]=F[c+28>>2];F[b+28>>2]=a;a=F[c+24>>2];F[b+16>>2]=F[c+20>>2];F[b+20>>2]=a;a=F[c+16>>2];F[b+8>>2]=F[c+12>>2];F[b+12>>2]=a;a=F[c+8>>2];F[b>>2]=F[c+4>>2];F[b+4>>2]=a;Ea=c- -64|0;return b|0}function nd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=Ea-16|0;Ea=e;a:{if(F[a>>2]!=-559038751|d>>>0>21){break a}if(!qb(a+4|0,F[a+592>>2],F[a+596>>2],b,c,e+12|0,e+8|0,e+4|0)){break a}a=d-13|0;if(a>>>0<4){f=L(F[e+8>>2],L(F[e+12>>2],a>>>0<=3?F[(a<<2)+398452>>2]:0));break a}a=d>>>0<=21?F[(d<<2)+398364>>2]:0;if((d&-2)==8){a=F[e+8>>2]+3&-4;b=a>>>0<=8?8:a;a=F[e+12>>2]+3&-4;f=L(b,a>>>0<=8?8:a)>>>1&536870904;break a}f=L(a,F[e+4>>2])}Ea=e+16|0;return f|0}function je(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=Ea-48|0;Ea=f;g=F[a>>2];h=b;b=F[a+4>>2];a=h+(b>>1)|0;Ga[(b&1?F[g+F[a>>2]>>2]:g)|0](f+4|0,a,c,d,e);b=Qa(44);F[b+40>>2]=F[f+44>>2];a=F[f+40>>2];F[b+32>>2]=F[f+36>>2];F[b+36>>2]=a;a=F[f+32>>2];F[b+24>>2]=F[f+28>>2];F[b+28>>2]=a;a=F[f+24>>2];F[b+16>>2]=F[f+20>>2];F[b+20>>2]=a;a=F[f+16>>2];F[b+8>>2]=F[f+12>>2];F[b+12>>2]=a;a=F[f+8>>2];F[b>>2]=F[f+4>>2];F[b+4>>2]=a;Ea=f+48|0;return b|0}function Ee(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=Ea-16|0;Ea=e;f=F[a+4>>2];g=(f>>1)+b|0;b=F[c>>2];if(b>>>0<2147483632){a=F[a>>2];f=f&1?F[a+F[g>>2]>>2]:a;a:{if(b>>>0<=10){D[e+15|0]=b;a=e+4|0;break a}h=(b|15)+1|0;a=Qa(h);F[e+12>>2]=h|-2147483648;F[e+4>>2]=a;F[e+8>>2]=b}i=Va(a,c+4|0,b)+b|0,j=0,D[i|0]=j;F[e>>2]=d;a=Ga[f|0](g,e+4|0,e)|0;W(F[e>>2]);if(D[e+15|0]<0){Ra(F[e+4>>2])}Ea=e+16|0;return a|0}Tb();v()}function ie(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;f=Ea-48|0;Ea=f;a:{if(F[a>>2]!=-559038750|e>>>0>21){break a}if(!Ab(a+4|0,f+4|0,b,c,d)){break a}b=F[f+40>>2];d=F[f+20>>2];c=F[f+16>>2];a=e-13|0;if(a>>>0<4){g=L(L(c,d),a>>>0<=3?F[(a<<2)+398452>>2]:0);break a}a=e>>>0<=21?F[(e<<2)+398364>>2]:0;if((e&-2)==8){a=d+3&-4;b=a>>>0<=8?8:a;a=c+3&-4;g=L(b,a>>>0<=8?8:a)>>>1&536870904;break a}g=L(a,b)}Ea=f+48|0;return g|0}function Sb(a){var b=0;Rb(a+176|0);b=F[a+160>>2];if(b){Ra(b)}b=F[a+148>>2];if(b){Ra(b)}b=F[a+136>>2];if(b){Ra(b)}b=F[a+124>>2];if(b){Ra(b)}b=F[a+112>>2];if(b){Ra(b)}b=F[a+100>>2];if(b){Ra(b)}b=F[a+88>>2];if(b){Ra(b)}b=F[a+76>>2];if(b){Ra(b)}b=F[a+64>>2];if(b){Ra(b)}b=F[a+52>>2];if(b){Ra(b)}b=F[a+40>>2];if(b){Ra(b)}b=F[a+28>>2];if(b){Ra(b)}b=F[a+16>>2];if(b){Ra(b)}b=F[a+4>>2];if(b){Ra(b)}return a}function Rc(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0;d=Ea-16|0;Ea=d;e=F[a+4>>2];f=(e>>1)+b|0;b=F[c>>2];if(b>>>0<2147483632){a=F[a>>2];e=e&1?F[a+F[f>>2]>>2]:a;a:{if(b>>>0<=10){D[d+15|0]=b;a=d+4|0;break a}g=(b|15)+1|0;a=Qa(g);F[d+12>>2]=g|-2147483648;F[d+4>>2]=a;F[d+8>>2]=b}h=Va(a,c+4|0,b)+b|0,i=0,D[h|0]=i;a=Ga[e|0](f,d+4|0)|0;if(D[d+15|0]<0){Ra(F[d+4>>2])}Ea=d+16|0;return a|0}Tb();v()}function Ze(a,b,c){var d=0,e=0,f=0,g=0;g=c&63;f=g;e=f&31;if(f>>>0>=32){f=-1>>>e|0}else{d=-1>>>e|0;f=d|(1<>>0>=32){d=f<>>32-e|d<>>0>=32){d=-1<>>32-d}a=c&a;b=b&d;d=e&31;if(e>>>0>=32){c=0;a=b>>>d|0}else{c=b>>>d|0;a=((1<>>d}a=a|g;Fa=c|f;return a} +function Xc(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;q=q|0;r=r|0;s=s|0;t=t|0;var u=0,v=0;u=Ea-16|0;Ea=u;v=F[a+4>>2];b=(v>>1)+b|0;a=F[a>>2];a=v&1?F[F[b>>2]+a>>2]:a;F[u+12>>2]=d;F[u+8>>2]=f;a=Ga[a|0](b,c,u+12|0,e,u+8|0,g,h,i,j,k,l,m,n,o,p,q,r,s,t)|0;W(F[u+8>>2]);W(F[u+12>>2]);Ea=u+16|0;return a|0}function Mb(a,b,c){var d=0,e=0,f=0;d=F[c+16>>2];a:{if(!d){if(Gc(c)){break a}d=F[c+16>>2]}f=F[c+20>>2];if(d-f>>>0>>0){return Ga[F[c+36>>2]](c,a,b)|0}b:{if(F[c+80>>2]<0){d=0;break b}e=b;while(1){d=e;if(!d){d=0;break b}e=d-1|0;if(G[e+a|0]!=10){continue}break}e=Ga[F[c+36>>2]](c,a,d)|0;if(e>>>0>>0){break a}a=a+d|0;b=b-d|0;f=F[c+20>>2]}Va(f,a,b);F[c+20>>2]=F[c+20>>2]+b;e=b+d|0}return e}function Te(a){a=a|0;var b=0,c=0,d=0,e=0;if(a){c=F[a+1208>>2];if(c){Ra(c)}c=a+4|0;b=F[c+1184>>2];if(b){Ra(b)}Rb(c+776|0);Sb(c+188|0);b=F[c+144>>2];if(b){Ra(b)}b=F[c+112>>2];if(b){e=F[c+116>>2];if(e){e=L(e,24)+b|0;while(1){d=F[b+12>>2];if(d){Ra(d)}d=F[b>>2];if(d){Ra(d)}b=b+24|0;if((e|0)!=(b|0)){continue}break}b=F[c+112>>2]}Ra(b)}b=F[c+100>>2];if(b){Ra(b)}c=F[c+88>>2];if(c){Ra(c)}Ra(a)}}function gd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=Ea-48|0;Ea=d;F[a>>2]=0;F[a+4>>2]=0;F[a+16>>2]=0;F[a+20>>2]=0;F[a+8>>2]=0;F[a+12>>2]=0;a:{if(F[b>>2]!=-559038751){break a}if(!kc(F[b+592>>2],F[b+596>>2],d+4|0,c)){break a}F[a>>2]=F[d+12>>2];F[a+4>>2]=F[d+16>>2];F[a+8>>2]=F[d+28>>2];F[a+12>>2]=F[d+32>>2];F[a+16>>2]=F[d+8>>2];D[a+20|0]=G[d+44|0];D[a+21|0]=G[d+45|0]}Ea=d+48|0}function Sd(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;if(Xa(a,F[b+8>>2],e)){if(!(F[b+28>>2]==1|F[b+4>>2]!=(c|0))){F[b+28>>2]=d}return}a:{if(!Xa(a,F[b>>2],e)){break a}if(!(F[b+16>>2]!=(c|0)&F[b+20>>2]!=(c|0))){if((d|0)!=1){break a}F[b+32>>2]=1;return}F[b+20>>2]=c;F[b+32>>2]=d;F[b+40>>2]=F[b+40>>2]+1;if(!(F[b+36>>2]!=1|F[b+24>>2]!=2)){D[b+54|0]=1}F[b+44>>2]=4}}function Zd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0;e=F[a+84>>2];f=F[e>>2];d=F[e+4>>2];h=F[a+28>>2];g=F[a+20>>2]-h|0;g=d>>>0>>0?d:g;if(g){Va(f,h,g);f=g+F[e>>2]|0;F[e>>2]=f;d=F[e+4>>2]-g|0;F[e+4>>2]=d}d=c>>>0>d>>>0?d:c;if(d){Va(f,b,d);f=d+F[e>>2]|0;F[e>>2]=f;F[e+4>>2]=F[e+4>>2]-d}D[f|0]=0;b=F[a+44>>2];F[a+28>>2]=b;F[a+20>>2]=b;return c|0}function $c(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0;f=Ea-32|0;Ea=f;F[f+28>>2]=0;F[f+20>>2]=0;F[f+24>>2]=0;F[f+16>>2]=0;F[f+8>>2]=0;F[f+12>>2]=0;lb(c,f+20|0);lb(e,f+8|0);c=F[f+24>>2];a:{if(!c){break a}e=F[f+12>>2];if(!e){break a}g=Eb(a,b,F[f+20>>2],c,d,F[f+8>>2],e)}a=F[f+8>>2];if(a){Ra(a)}a=F[f+20>>2];if(a){Ra(a)}Ea=f+32|0;return g|0}function rc(a,b,c,d){D[a+53|0]=1;a:{if(F[a+4>>2]!=(c|0)){break a}D[a+52|0]=1;c=F[a+16>>2];b:{if(!c){F[a+36>>2]=1;F[a+24>>2]=d;F[a+16>>2]=b;if((d|0)!=1){break a}if(F[a+48>>2]==1){break b}break a}if((b|0)==(c|0)){c=F[a+24>>2];if((c|0)==2){F[a+24>>2]=d;c=d}if(F[a+48>>2]!=1){break a}if((c|0)==1){break b}break a}F[a+36>>2]=F[a+36>>2]+1}D[a+54|0]=1}}function Xd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=Ea+-64|0;Ea=d;e=1;a:{if(Xa(a,b,0)){break a}e=0;if(!b){break a}b=ab(b,404756);e=0;if(!b){break a}Ta(d+12|0,0,52);F[d+56>>2]=1;F[d+20>>2]=-1;F[d+16>>2]=a;F[d+8>>2]=b;Ga[F[F[b>>2]+28>>2]](b,d+8|0,F[c>>2],1);a=F[d+32>>2];if((a|0)==1){F[c>>2]=F[d+24>>2]}e=(a|0)==1}a=e;Ea=d- -64|0;return a|0}function Wc(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;q=q|0;r=r|0;s=s|0;var t=0;t=Ea-16|0;Ea=t;F[t+12>>2]=c;F[t+8>>2]=e;a=Ga[a|0](b,t+12|0,d,t+8|0,f,g,h,i,j,k,l,m,n,o,p,q,r,s)|0;W(F[t+8>>2]);W(F[t+12>>2]);Ea=t+16|0;return a|0}function Ie(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;if(F[b>>2]!=-559038750){D[a|0]=0;D[a+11|0]=0;return}d=F[F[b+116>>2]+L(c,24)>>2];c=vb(d);if(c>>>0<2147483632){a:{if(c>>>0<=10){D[a+11|0]=c;break a}e=(c|15)+1|0;b=Qa(e);F[a+8>>2]=e|-2147483648;F[a>>2]=b;F[a+4>>2]=c;a=b}f=db(a,d,c)+c|0,g=0,D[f|0]=g;return}Tb();v()}function Uc(){var a=0,b=0,c=0;while(1){b=a<<4;c=b+435408|0;F[b+435412>>2]=c;F[b+435416>>2]=c;a=a+1|0;if((a|0)!=64){continue}break}Kb(48);F[108793]=131;F[108794]=0;cc();F[108794]=F[108799];F[108799]=435172;F[108800]=132;F[108801]=0;Ic();F[108801]=F[108799];F[108799]=435200;F[108843]=435252;F[108825]=42}function Pc(a,b){var c=0,d=0,e=0;d=Ea-16|0;Ea=d;b=F[F[b>>2]>>2];c=$(2420)|0;b=_(b|0,c|0)|0;W(c|0);e=+fa(b|0,405192,d+12|0);ea(F[d+12>>2]);W(b|0);F[a+8>>2]=0;F[a>>2]=0;F[a+4>>2]=0;if(e<4294967296&e>=0){b=~~e>>>0}else{b=0}if(b){Wa(a,b,(b|0)==1,1);c=F[a+4>>2];Ta(c+F[a>>2]|0,0,b-c|0);F[a+4>>2]=b}Ea=d+16|0}function ed(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=Ea+-64|0;Ea=e;F[a>>2]=0;F[a+4>>2]=0;F[a+8>>2]=0;F[a+12>>2]=0;a:{if(F[b>>2]!=-559038751){break a}if(!jc(F[b+592>>2],F[b+596>>2],e+4|0,c,d)){break a}F[a>>2]=F[e+44>>2];F[a+4>>2]=F[e+48>>2];F[a+8>>2]=F[e+52>>2];F[a+12>>2]=F[e+56>>2]}Ea=e- -64|0}function He(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0;d=Ea-16|0;Ea=d;e=F[a>>2];g=d+4|0;f=b;b=F[a+4>>2];a=f+(b>>1)|0;Ga[(b&1?F[e+F[a>>2]>>2]:e)|0](g,a,c);b=G[d+15|0];e=b<<24>>24;a=(e|0)<0;b=a?F[d+8>>2]:b;c=Ya(b+4|0);F[c>>2]=b;f=F[d+4>>2];Va(c+4|0,a?f:g,b);if((e|0)<0){Ra(f)}Ea=d+16|0;return c|0}function vb(a){var b=0,c=0,d=0;a:{b:{b=a;if(!(b&3)){break b}if(!G[b|0]){return 0}while(1){b=b+1|0;if(!(b&3)){break b}if(G[b|0]){continue}break}break a}while(1){c=b;b=b+4|0;d=F[c>>2];if(!((d^-1)&d-16843009&-2139062144)){continue}break}while(1){b=c;c=b+1|0;if(G[b|0]){continue}break}}return b-a|0}function fb(a){var b=M(0),c=0,d=0;c=(w(a),y(2));d=c>>>23&255;if(d>>>0<=149){if(d>>>0<=125){return M(a*M(0))}a=(c|0)>=0?a:M(-a);b=M(M(M(a+M(8388608))+M(-8388608))-a);a:{if(b>M(.5)){a=M(M(a+b)+M(-1));break a}a=M(a+b);if(!(b<=M(-.5))){break a}a=M(a+M(1))}a=(c|0)>=0?a:M(-a)}return a}function ee(a,b,c,d,e,f,g,h,i,j){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=i|0;j=j|0;var k=0,l=0;k=Ea-16|0;Ea=k;l=F[a+4>>2];b=(l>>1)+b|0;a=F[a>>2];a=l&1?F[F[b>>2]+a>>2]:a;F[k+12>>2]=c;a=Ga[a|0](b,k+12|0,d,e,f,g,h,i,j)|0;W(F[k+12>>2]);Ea=k+16|0;return a|0}function me(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;if(F[a>>2]==-559038750){e=b;b=F[a+44>>2];b=L(F[a+48>>2],L(e,b>>>0<=1?1:b)+c|0)+d|0;if(b>>>0>2]){a=F[a+148>>2]+L(b,20)|0;a=G[a|0]|G[a+1|0]<<8|(G[a+2|0]<<16|G[a+3|0]<<24)}else{a=0}}else{a=0}return a|0}function _c(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0,h=0;g=Ea-16|0;Ea=g;h=F[a+4>>2];b=(h>>1)+b|0;a=F[a>>2];a=h&1?F[F[b>>2]+a>>2]:a;F[g+12>>2]=d;F[g+8>>2]=f;a=Ga[a|0](b,c,g+12|0,e,g+8|0)|0;W(F[g+8>>2]);W(F[g+12>>2]);Ea=g+16|0;return a|0}function fd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;d=Ea-32|0;Ea=d;Ga[F[a>>2]](d+8|0,b,c);a=Qa(24);b=F[d+28>>2];F[a+16>>2]=F[d+24>>2];F[a+20>>2]=b;b=F[d+20>>2];F[a+8>>2]=F[d+16>>2];F[a+12>>2]=b;b=F[d+12>>2];F[a>>2]=F[d+8>>2];F[a+4>>2]=b;Ea=d+32|0;return a|0}function ke(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;F[a>>2]=0;F[a+4>>2]=0;F[a+40>>2]=0;F[a+32>>2]=0;F[a+36>>2]=0;F[a+24>>2]=0;F[a+28>>2]=0;F[a+16>>2]=0;F[a+20>>2]=0;F[a+8>>2]=0;F[a+12>>2]=0;if(F[b>>2]==-559038750){Ab(b+4|0,a,c,d,e)}}function bc(){var a=0;a=Qa(60);F[a>>2]=0;F[a+4>>2]=0;F[a+56>>2]=0;F[a+48>>2]=0;F[a+52>>2]=0;F[a+40>>2]=0;F[a+44>>2]=0;F[a+32>>2]=0;F[a+36>>2]=0;F[a+24>>2]=0;F[a+28>>2]=0;F[a+16>>2]=0;F[a+20>>2]=0;F[a+8>>2]=0;F[a+12>>2]=0;return a|0}function Dc(a){var b=0,c=0,d=0;if(D[F[a>>2]]-48>>>0>=10){return 0}while(1){d=F[a>>2];c=-1;if(b>>>0<=214748364){c=D[d|0]-48|0;b=L(b,10);c=(c|0)>(b^2147483647)?-1:c+b|0}F[a>>2]=d+1;b=c;if(D[d+1|0]-48>>>0<10){continue}break}return b}function Tb(){var a=0,b=0,c=0,d=0,e=0;a=Ya(88)+80|0;F[a>>2]=405492;F[a>>2]=405536;b=vb(2570);c=Qa(b+13|0);F[c+8>>2]=0;F[c+4>>2]=b;F[c>>2]=b;d=a,e=Va(c+12|0,2570,b+1|0),F[d+4>>2]=e;F[a>>2]=405584;Da(a|0,405616,130);v()}function We(a,b,c,d){var e=0,f=0,g=0,h=0,i=0,j=0;e=c>>>16|0;f=a>>>16|0;j=L(e,f);g=c&65535;h=a&65535;i=L(g,h);f=(i>>>16|0)+L(f,g)|0;e=(f&65535)+L(e,h)|0;Fa=(L(b,c)+j|0)+L(a,d)+(f>>>16)+(e>>>16)|0;return i&65535|e<<16}function uc(a,b,c){var d=0;d=F[a+16>>2];if(!d){F[a+36>>2]=1;F[a+24>>2]=c;F[a+16>>2]=b;return}a:{if((b|0)==(d|0)){if(F[a+24>>2]!=2){break a}F[a+24>>2]=c;return}D[a+54|0]=1;F[a+24>>2]=2;F[a+36>>2]=F[a+36>>2]+1}}function dd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=Ea-16|0;Ea=e;Ga[F[a>>2]](e,b,c,d);a=Qa(16);b=F[e+12>>2];F[a+8>>2]=F[e+8>>2];F[a+12>>2]=b;b=F[e+4>>2];F[a>>2]=F[e>>2];F[a+4>>2]=b;Ea=e+16|0;return a|0}function eb(a,b,c,d,e){var f=0;f=Ea-256|0;Ea=f;if(!(e&73728|(c|0)<=(d|0))){d=c-d|0;c=d>>>0<256;Ta(f,b&255,c?d:256);if(!c){while(1){gb(a,f,256);d=d-256|0;if(d>>>0>255){continue}break}}gb(a,f,d)}Ea=f+256|0}function Bb(a,b){var c=0,d=0,e=0;d=F[a+116>>2];if(d){b=D[b+11|0]<0?F[b>>2]:b;a=F[a+112>>2];while(1){e=a+L(c,24)|0;if(!Lb(F[e>>2],b)){return e+12|0}c=c+1|0;if((d|0)!=(c|0)){continue}break}}return 0}function rb(a,b,c){var d=0,e=0;e=Ea-16|0;Ea=e;d=I[c>>2]>2];F[e+12>>2]=F[(d?c:a)>>2];F[c>>2]=F[(d?a:c)>>2];d=a;a=e+12|0;c=I[a>>2]>2];F[d>>2]=F[(c?d:b)>>2];F[b>>2]=F[(c?b:a)>>2];Ea=e+16|0}function _d(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;e=Ea-16|0;Ea=e;a=va(F[a+60>>2],b|0,c|0,d&255,e+8|0)|0;if(a){F[108804]=a;a=-1}else{a=0}Ea=e+16|0;Fa=a?-1:F[e+12>>2];return(a?-1:F[e+8>>2])|0}function Wb(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=Ea-16|0;Ea=d;e=F[a+4>>2];b=(e>>1)+b|0;a=F[a>>2];a=e&1?F[F[b>>2]+a>>2]:a;F[d+12>>2]=c;a=Ga[a|0](b,d+12|0)|0;W(F[d+12>>2]);Ea=d+16|0;return a|0}function jd(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0;i=Ea-16|0;Ea=i;a=F[a>>2];F[i+12>>2]=c;a=Ga[a|0](b,i+12|0,d,e,f,g,h)|0;W(F[i+12>>2]);Ea=i+16|0;return a|0}function Gc(a){var b=0;b=F[a+72>>2];F[a+72>>2]=b-1|b;b=F[a>>2];if(b&8){F[a>>2]=b|32;return-1}F[a+4>>2]=0;F[a+8>>2]=0;b=F[a+44>>2];F[a+28>>2]=b;F[a+20>>2]=b;F[a+16>>2]=b+F[a+48>>2];return 0}function Zc(a,b){a=a|0;b=b|0;var c=0,d=0;c=Ea-16|0;Ea=c;F[c+12>>2]=0;F[c+4>>2]=0;F[c+8>>2]=0;lb(b,c+4|0);b=F[c+8>>2];if(b){d=xb(a,F[c+4>>2],b)}a=F[c+4>>2];if(a){Ra(a)}Ea=c+16|0;return d|0}function Lb(a,b){var c=0,d=0;c=G[a|0];d=G[b|0];a:{if(!c|(c|0)!=(d|0)){break a}while(1){d=G[b+1|0];c=G[a+1|0];if(!c){break a}b=b+1|0;a=a+1|0;if((c|0)==(d|0)){continue}break}}return c-d|0}function qd(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=Ea-16|0;Ea=d;if(F[a>>2]==-559038751){a=qb(a+4|0,F[a+592>>2],F[a+596>>2],b,c,d+12|0,d+8|0,d+4|0);e=a?F[d+12>>2]:0}Ea=d+16|0;return e|0}function od(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;d=Ea-16|0;Ea=d;if(F[a>>2]==-559038751){a=qb(a+4|0,F[a+592>>2],F[a+596>>2],b,c,d+12|0,d+8|0,d+4|0);e=a?F[d+8>>2]:0}Ea=d+16|0;return e|0}function Vc(){var a=0;a=Qa(44);F[a>>2]=0;F[a+4>>2]=0;F[a+40>>2]=0;F[a+32>>2]=0;F[a+36>>2]=0;F[a+24>>2]=0;F[a+28>>2]=0;F[a+16>>2]=0;F[a+20>>2]=0;F[a+8>>2]=0;F[a+12>>2]=0;return a|0}function sc(a,b){var c=0;a:{if(!b){break a}b=ab(b,404964);if(!b|F[b+8>>2]&(F[a+8>>2]^-1)){break a}if(!Xa(F[a+12>>2],F[b+12>>2],0)){break a}c=Xa(F[a+16>>2],F[b+16>>2],0)}return c}function he(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;var g=0;g=F[a>>2];a=F[a+4>>2];b=(a>>1)+b|0;if(a&1){g=F[g+F[b>>2]>>2]}return Ga[g|0](b,c,d,e,f)|0}function sd(a,b){a=a|0;b=b|0;var c=0,d=0;c=Ea-48|0;Ea=c;if(F[a>>2]==-559038751){a=kc(F[a+592>>2],F[a+596>>2],c+4|0,b);d=a?F[c+8>>2]:0}Ea=c+48|0;return d|0}function Fe(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;a:{if(F[a>>2]!=-559038750){break a}a=Bb(a+4|0,b);if(!a){break a}if(!F[a+4>>2]){return 1}d=ob(c,a)}return d|0}function vd(a){a=a|0;var b=0,c=0;b=Ea+-64|0;Ea=b;if(F[a>>2]==-559038751){a=jc(F[a+592>>2],F[a+596>>2],b+4|0,0,0);c=a?G[b+60|0]:0}Ea=b- -64|0;return c|0}function le(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0;f=F[a>>2];a=F[a+4>>2];b=(a>>1)+b|0;if(a&1){f=F[f+F[b>>2]>>2]}return Ga[f|0](b,c,d,e)|0}function Rd(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if(Xa(a,F[b+8>>2],f)){rc(b,c,d,e);return}a=F[a+8>>2];Ga[F[F[a>>2]+20>>2]](a,b,c,d,e,f)}function xd(a){a=a|0;var b=0;a:{if(F[a>>2]!=-559038751){break a}b=F[a+592>>2];if(!b){break a}Ra(b);F[a+600>>2]=0;F[a+592>>2]=0;F[a+596>>2]=0}}function Qe(a){a=a|0;var b=0;if(F[a>>2]==-559038750){b=F[a+1208>>2];if(b){Ra(b);F[a+1216>>2]=0;F[a+1208>>2]=0;F[a+1212>>2]=0}Cb(a+4|0)}}function Qa(a){var b=0;a=a>>>0<=1?1:a;a:{while(1){b=Ya(a);if(b){break a}b=F[109112];if(b){Ga[b|0]();continue}break}na();v()}return b}function Vd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if(Xa(a,F[b+8>>2],0)){uc(b,c,d);return}a=F[a+8>>2];Ga[F[F[a>>2]+28>>2]](a,b,c,d)}function Ge(a,b){a=a|0;b=b|0;var c=0;a:{if(F[a>>2]!=-559038750){break a}a=Bb(a+4|0,b);if(!a){break a}c=F[a+4>>2]}return c|0}function pc(a){a=a|0;var b=0,c=0;F[a>>2]=405536;b=F[a+4>>2]-12|0;c=F[b+8>>2]-1|0;F[b+8>>2]=c;if((c|0)<0){Ra(b)}return a|0}function _b(a,b){a=a|0;b=b|0;var c=0;c=Ea-16|0;Ea=c;F[c+12>>2]=b;a=Ga[a|0](c+12|0)|0;W(F[c+12>>2]);Ea=c+16|0;return a|0}function Tc(a,b){a=a|0;b=b|0;var c=0;c=F[a>>2];a=F[a+4>>2];b=(a>>1)+b|0;if(a&1){c=F[c+F[b>>2]>>2]}return Ga[c|0](b)|0}function Ne(a,b){a=a|0;b=b|0;if(F[a>>2]==-559038750){if(!F[a+108>>2]){return 1}a=ob(b,a+104|0)}else{a=0}return a|0}function Cd(){var a=0;a=Qa(24);F[a>>2]=0;F[a+4>>2]=0;F[a+16>>2]=0;F[a+20>>2]=0;F[a+8>>2]=0;F[a+12>>2]=0;return a|0}function Xa(a,b,c){if(!c){return F[a+4>>2]==F[b+4>>2]}if((a|0)==(b|0)){return 1}return!Lb(F[a+4>>2],F[b+4>>2])}function Pe(a,b){a=a|0;b=b|0;var c=0;c=F[a>>2];a=F[a+4>>2];b=(a>>1)+b|0;if(a&1){c=F[c+F[b>>2]>>2]}Ga[c|0](b)}function ce(a){a=a|0;var b=0,c=0;a=F[a+4>>2];b=vb(a)+1|0;c=Ya(b);if(c){a=Va(c,a,b)}else{a=0}return a|0}function be(){var a=0;a=F[108799];if(a){while(1){Ga[F[a>>2]]();a=F[a+4>>2];if(a){continue}break}}}function Qd(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;if(Xa(a,F[b+8>>2],f)){rc(b,c,d,e)}}function cb(a,b){var c=0,d=0;c=I[a>>2]>2];d=F[(c?a:b)>>2];F[b>>2]=F[(c?b:a)>>2];F[a>>2]=d}function Ke(a,b){a=a|0;b=b|0;if(F[a>>2]==-559038750){a=(Bb(a+4|0,b)|0)!=0}else{a=0}return a|0}function Bd(){var a=0;a=Qa(16);F[a>>2]=0;F[a+4>>2]=0;F[a+8>>2]=0;F[a+12>>2]=0;return a|0}function md(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return Ga[F[a>>2]](b,c,d,e)|0}function Fc(a,b,c,d){b=L(b,c);a:{if(F[d+76>>2]<0){a=Mb(a,b,d);break a}a=Mb(a,b,d)}}function Md(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return Ga[a|0](b,c,d,e)|0}function zd(a){a=a|0;var b=0;if(a){b=F[a+592>>2];if(b){Ra(b)}Sb(a+4|0);Ra(a)}}function Xe(a){var b=0;while(1){if(a){a=a-1&a;b=b+1|0;continue}break}return b}function Wd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;if(Xa(a,F[b+8>>2],0)){uc(b,c,d)}}function zc(a,b,c,d,e){cb(a,b);cb(d,e);rb(c,d,e);cb(b,e);rb(a,c,d);rb(b,c,d)}function Ye(a){var b=0;b=a&31;a=0-a&31;return(-1>>>b&-2)<>>a}function pd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Ga[F[a>>2]](b,c,d)|0}function ye(a){a=a|0;return(F[a>>2]==-559038750?F[a+160>>2]:0)|0}function ue(a){a=a|0;return(F[a>>2]==-559038750?F[a+164>>2]:0)|0}function te(a){a=a|0;return(F[a>>2]==-559038750?F[a+168>>2]:0)|0}function se(a){a=a|0;return(F[a>>2]==-559038750?F[a+172>>2]:0)|0}function re(a){a=a|0;return(F[a>>2]==-559038750?F[a+176>>2]:0)|0}function qe(a){a=a|0;return(F[a>>2]==-559038750?F[a+180>>2]:0)|0}function pe(a){a=a|0;return(F[a>>2]==-559038750?F[a+184>>2]:0)|0}function oe(a){a=a|0;return(F[a>>2]==-559038750?F[a+188>>2]:0)|0}function ad(){var a=0;a=Hb(Qa(992));Ta(a+584|0,0,408);return a|0}function Pd(a){a=a|0;if(!a){return 0}return(ab(a,404852)|0)!=0|0}function Je(a){a=a|0;return(F[a>>2]==-559038750?F[a+120>>2]:0)|0}function ze(a){a=a|0;return(F[a>>2]==-559038750?F[a+52>>2]:0)|0}function De(a){a=a|0;return(F[a>>2]==-559038750?F[a+32>>2]:0)|0}function Ce(a){a=a|0;return(F[a>>2]==-559038750?F[a+36>>2]:0)|0}function Be(a){a=a|0;return(F[a>>2]==-559038750?F[a+48>>2]:0)|0}function Ae(a){a=a|0;return(F[a>>2]==-559038750?F[a+44>>2]:0)|0}function xe(a){a=a|0;return F[a>>2]==-559038750&F[a+160>>2]==1}function ve(a){a=a|0;return F[a>>2]==-559038750&G[a+1204|0]!=0}function rd(a,b,c){a=a|0;b=b|0;c=c|0;return Ga[F[a>>2]](b,c)|0}function ne(a){a=a|0;return F[a>>2]==-559038750&G[a+1205|0]!=0}function Re(a){a=a|0;return F[a>>2]==-559038750&G[a+1220|0]!=0}function Jd(a){a=a|0;return(a>>>0<=21?F[(a<<2)+398364>>2]:0)|0}function Ac(a,b,c,d){cb(a,c);cb(b,d);cb(a,b);cb(c,d);cb(b,c)} +function we(a){a=a|0;return!F[a+160>>2]&F[a>>2]==-559038750}function vc(a,b,c){a=a|0;b=b|0;c=c|0;return Xa(a,b,0)|0}function ib(a,b,c){a=a|0;b=b|0;c=c|0;F[F[a>>2]+b>>2]=c}function yb(a,b,c){a=a|0;b=b|0;c=c|0;D[F[a>>2]+b|0]=c}function Zb(a,b){a=a|0;b=b|0;return Ga[F[a>>2]](b)|0}function jb(a,b){a=a|0;b=b|0;return F[F[a>>2]+b>>2]}function Ve(a){if(a){return 31-O(a-1^a)|0}return 32}function zb(a,b){a=a|0;b=b|0;return G[F[a>>2]+b|0]}function Gd(a){a=a|0;return 4063039>>>a&1&a>>>0<22}function bd(a){a=a|0;if(a){Rb(a+584|0);Ra(Sb(a))}}function $b(a,b){a=a|0;b=b|0;return Ga[a|0](b)|0}function nc(a,b,c,d){wa(a|0,b|0,8,0,c|0,-1,d|0)}function Id(a){a=a|0;return 603850>>>a&a>>>0<20}function gb(a,b,c){if(!(G[a|0]&32)){Mb(b,c,a)}}function ae(a){a=a|0;return ya(F[a+60>>2])|0}function Fd(a){a=a|0;return((a|0)==17?8:4)|0}function wd(a,b){a=a|0;b=b|0;Ga[F[a>>2]](b)}function Hd(a){a=a|0;return a-13>>>0<4|0}function Xb(a){a=a|0;return Ga[a|0]()|0}function Oe(a){a=a|0;return F[a+108>>2]}function Nd(a){a=a|0;return F[a+4>>2]}function tb(a,b,c){cb(b,c);rb(a,b,c)}function Yd(a){a=a|0;return Ya(a)|0}function cd(a){a=a|0;return 399248}function Ue(a){a=a|0;return 399856}function Ad(a){a=a|0;return 398832}function kb(a){a=a|0;if(a){Ra(a)}}function Hb(a){return Ta(a,0,584)}function oc(a){a=a|0;pc(a);Ra(a)}function Od(a){a=a|0;return 2223}function Nb(a,b){Fc(a,1,vb(a),b)}function Qc(a){a=a|0;return a|0}function Dd(a){a=a|0;Ga[a|0]()}function Ed(a){a=a|0;return 4}function Sa(a){a=a|0;Ra(a)}function ec(){return 1}function Hc(a){a=a|0} +// EMSCRIPTEN_END_FUNCS +e=G;p(q);var Ga=c([null,de,wb,Dd,Ld,bc,kb,jb,ib,zb,yb,Cd,kb,jb,ib,zb,yb,Bd,kb,jb,ib,$b,Jd,$b,Id,Hd,Gd,Fd,Ed,Ad,zd,_b,yd,xd,wd,vd,Zb,ud,Zb,td,sd,rd,qd,pd,od,nd,md,ld,kd,jd,id,hd,gd,fd,ed,dd,cd,bd,Xb,ad,$c,_c,Zc,Wb,Yc,Xc,Wc,Kd,Xb,ec,ec,Vc,kb,jb,ib,zb,yb,bc,kb,jb,ib,Ue,Te,_b,Se,Re,Tc,Qe,Pe,Oe,Tc,Ne,Wb,Me,Le,Ke,Rc,Je,Ie,He,Ge,Rc,Fe,Ee,De,Ce,Be,Ae,ze,ye,xe,we,ve,ue,te,se,re,qe,pe,oe,ne,me,le,ke,je,ie,he,ge,fe,ee,pc,cc,Ic,ae,$d,_d,Zd,Qc,Sa,Hc,Hc,vc,Sa,vc,Sa,Xd,Qd,Sd,Wd,Sa,Rd,Td,Vd,Sa,Ud,Qc,Sa,Od,oc,Nd,oc]);function Ha(){return C.byteLength/65536|0}function Ma(Na){Na=Na|0;var Ia=Ha()|0;var Ja=Ia+Na|0;if(Ia=65536,"INITIAL_MEMORY should be larger than STACK_SIZE, was "+INITIAL_MEMORY+"! (STACK_SIZE="+65536+")");if(Module["wasmMemory"])wasmMemory=Module["wasmMemory"];else wasmMemory=new WebAssembly.Memory({"initial":INITIAL_MEMORY/65536,"maximum":2147483648/65536});updateMemoryViews();INITIAL_MEMORY=wasmMemory.buffer.byteLength;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false; +function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length)addOnPreRun(Module["preRun"].shift())}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)} +function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length)addOnPostRun(Module["postRun"].shift())}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)} +if(!Math.imul||Math.imul(4294967295,5)!==-5)Math.imul=function(a,b){var ah=a>>>16;var al=a&65535;var bh=b>>>16;var bl=b&65535;return al*bl+(ah*bl+al*bh<<16)|0};if(!Math.fround){var froundBuffer=new Float32Array(1);Math.fround=function(x){froundBuffer[0]=x;return froundBuffer[0]}}if(!Math.clz32)Math.clz32=function(x){var n=32;var y=x>>16;if(y){n-=16;x=y}y=x>>8;if(y){n-=8;x=y}y=x>>4;if(y){n-=4;x=y}y=x>>2;if(y){n-=2;x=y}y=x>>1;if(y)return n-2;return n-x}; +if(!Math.trunc)Math.trunc=function(x){return x<0?Math.ceil(x):Math.floor(x)};var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"])Module["monitorRunDependencies"](runDependencies)} +function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"])Module["monitorRunDependencies"](runDependencies);if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}} +function abort(what){if(Module["onAbort"])Module["onAbort"](what);what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e;}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}function isFileURI(filename){return filename.startsWith("file://")}var wasmBinaryFile;wasmBinaryFile="<<< WASM_BINARY_FILE >>>"; +if(!isDataURI(wasmBinaryFile))wasmBinaryFile=locateFile(wasmBinaryFile);function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary)return new Uint8Array(wasmBinary);var binary=tryParseAsDataURI(file);if(binary)return binary;if(readBinary)return readBinary(file);throw"both async and sync fetching of the wasm failed";}function getBinaryPromise(binaryFile){return Promise.resolve().then(function(){return getBinarySync(binaryFile)})} +function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(function(binary){return WebAssembly.instantiate(binary,imports)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){return instantiateArrayBuffer(binaryFile,imports,callback)} +function createWasm(){var info={"a":wasmImports};function receiveInstance(instance,module){wasmExports=instance.exports;wasmTable=wasmExports["P"];addOnInit(wasmExports["M"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}if(Module["instantiateWasm"])try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err("Module.instantiateWasm callback failed with error: "+ +e);readyPromiseReject(e)}instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult).catch(readyPromiseReject);return{}}var callRuntimeCallbacks=function(callbacks){while(callbacks.length>0)callbacks.shift()(Module)}; +function ExceptionInfo(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24;this.set_type=function(type){HEAPU32[this.ptr+4>>2]=type};this.get_type=function(){return HEAPU32[this.ptr+4>>2]};this.set_destructor=function(destructor){HEAPU32[this.ptr+8>>2]=destructor};this.get_destructor=function(){return HEAPU32[this.ptr+8>>2]};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+12>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+12>>0]!=0};this.set_rethrown=function(rethrown){rethrown= +rethrown?1:0;HEAP8[this.ptr+13>>0]=rethrown};this.get_rethrown=function(){return HEAP8[this.ptr+13>>0]!=0};this.init=function(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)};this.set_adjusted_ptr=function(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr};this.get_adjusted_ptr=function(){return HEAPU32[this.ptr+16>>2]};this.get_exception_ptr=function(){var isPointer=___cxa_is_pointer_type(this.get_type());if(isPointer)return HEAPU32[this.excPtr>>2];var adjusted= +this.get_adjusted_ptr();if(adjusted!==0)return adjusted;return this.excPtr}}var exceptionLast=0;var uncaughtExceptionCount=0;var ___cxa_throw=function(ptr,type,destructor){var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast;};var structRegistrations={};var runDestructors=function(destructors){while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}}; +function simpleReadValueFromPointer(pointer){return this["fromWireType"](HEAP32[pointer>>2])}var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var InternalError;var throwInternalError=function(message){throw new InternalError(message);}; +var whenDependentTypesAreResolved=function(myTypes,dependentTypes,getTypeConverters){myTypes.forEach(function(type){typeDependencies[type]=dependentTypes});function onComplete(typeConverters){var myTypeConverters=getTypeConverters(typeConverters);if(myTypeConverters.length!==myTypes.length)throwInternalError("Mismatched type converter count");for(var i=0;i=char_0&&f<=char_9)return"_"+name;return name}; +function createNamedFunction(name,body){name=makeLegalFunctionName(name);var $jscomp$compprop1={};return($jscomp$compprop1[name]=function(){return body.apply(this,arguments)},$jscomp$compprop1)[name]} +var ensureOverloadTable=function(proto,methodName,humanName){if(undefined===proto[methodName].overloadTable){var prevFunc=proto[methodName];proto[methodName]=function(){if(!proto[methodName].overloadTable.hasOwnProperty(arguments.length))throwBindingError("Function '"+humanName+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+proto[methodName].overloadTable+")!");return proto[methodName].overloadTable[arguments.length].apply(this,arguments)};proto[methodName].overloadTable= +[];proto[methodName].overloadTable[prevFunc.argCount]=prevFunc}}; +var exposePublicSymbol=function(name,value,numArguments){if(Module.hasOwnProperty(name)){if(undefined===numArguments||undefined!==Module[name].overloadTable&&undefined!==Module[name].overloadTable[numArguments])throwBindingError("Cannot register public name '"+name+"' twice");ensureOverloadTable(Module,name,name);if(Module.hasOwnProperty(numArguments))throwBindingError("Cannot register multiple overloads of a function with the same number of arguments ("+numArguments+")!");Module[name].overloadTable[numArguments]= +value}else{Module[name]=value;if(undefined!==numArguments)Module[name].numArguments=numArguments}};function RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast){this.name=name;this.constructor=constructor;this.instancePrototype=instancePrototype;this.rawDestructor=rawDestructor;this.baseClass=baseClass;this.getActualType=getActualType;this.upcast=upcast;this.downcast=downcast;this.pureVirtualFunctions=[]} +var upcastPointer=function(ptr,ptrClass,desiredClass){while(ptrClass!==desiredClass){if(!ptrClass.upcast)throwBindingError("Expected null or instance of "+desiredClass.name+", got an instance of "+ptrClass.name);ptr=ptrClass.upcast(ptr);ptrClass=ptrClass.baseClass}return ptr}; +function constNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference)throwBindingError("null is not a valid "+this.name);return 0}if(!handle.$$)throwBindingError('Cannot pass "'+embindRepr(handle)+'" as a '+this.name);if(!handle.$$.ptr)throwBindingError("Cannot pass deleted object as a pointer of type "+this.name);var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr} +function genericPointerToWireType(destructors,handle){var ptr;if(handle===null){if(this.isReference)throwBindingError("null is not a valid "+this.name);if(this.isSmartPointer){ptr=this.rawConstructor();if(destructors!==null)destructors.push(this.rawDestructor,ptr);return ptr}else return 0}if(!handle.$$)throwBindingError('Cannot pass "'+embindRepr(handle)+'" as a '+this.name);if(!handle.$$.ptr)throwBindingError("Cannot pass deleted object as a pointer of type "+this.name);if(!this.isConst&&handle.$$.ptrType.isConst)throwBindingError("Cannot convert argument of type "+ +(handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name)+" to parameter type "+this.name);var handleClass=handle.$$.ptrType.registeredClass;ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);if(this.isSmartPointer){if(undefined===handle.$$.smartPtr)throwBindingError("Passing raw pointer to smart pointer is illegal");switch(this.sharingPolicy){case 0:if(handle.$$.smartPtrType===this)ptr=handle.$$.smartPtr;else throwBindingError("Cannot convert argument of type "+(handle.$$.smartPtrType? +handle.$$.smartPtrType.name:handle.$$.ptrType.name)+" to parameter type "+this.name);break;case 1:ptr=handle.$$.smartPtr;break;case 2:if(handle.$$.smartPtrType===this)ptr=handle.$$.smartPtr;else{var clonedHandle=handle["clone"]();ptr=this.rawShare(ptr,Emval.toHandle(function(){return clonedHandle["delete"]()}));if(destructors!==null)destructors.push(this.rawDestructor,ptr)}break;default:throwBindingError("Unsupporting sharing policy")}}return ptr} +function nonConstNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference)throwBindingError("null is not a valid "+this.name);return 0}if(!handle.$$)throwBindingError('Cannot pass "'+embindRepr(handle)+'" as a '+this.name);if(!handle.$$.ptr)throwBindingError("Cannot pass deleted object as a pointer of type "+this.name);if(handle.$$.ptrType.isConst)throwBindingError("Cannot convert argument of type "+handle.$$.ptrType.name+" to parameter type "+this.name);var handleClass= +handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}function readPointer(pointer){return this["fromWireType"](HEAPU32[pointer>>2])} +var init_RegisteredPointer=function(){var $jscomp$compprop2={};Object.assign(RegisteredPointer.prototype,($jscomp$compprop2.getPointee=function(ptr){if(this.rawGetPointee)ptr=this.rawGetPointee(ptr);return ptr},$jscomp$compprop2.destructor=function(ptr){if(this.rawDestructor)this.rawDestructor(ptr)},$jscomp$compprop2["argPackAdvance"]=GenericWireTypeSize,$jscomp$compprop2["readValueFromPointer"]=readPointer,$jscomp$compprop2["deleteObject"]=function(handle){if(handle!==null)handle["delete"]()},$jscomp$compprop2["fromWireType"]= +RegisteredPointer_fromWireType,$jscomp$compprop2))}; +function RegisteredPointer(name,registeredClass,isReference,isConst,isSmartPointer,pointeeType,sharingPolicy,rawGetPointee,rawConstructor,rawShare,rawDestructor){this.name=name;this.registeredClass=registeredClass;this.isReference=isReference;this.isConst=isConst;this.isSmartPointer=isSmartPointer;this.pointeeType=pointeeType;this.sharingPolicy=sharingPolicy;this.rawGetPointee=rawGetPointee;this.rawConstructor=rawConstructor;this.rawShare=rawShare;this.rawDestructor=rawDestructor;if(!isSmartPointer&& +registeredClass.baseClass===undefined)if(isConst){this["toWireType"]=constNoSmartPtrRawPointerToWireType;this.destructorFunction=null}else{this["toWireType"]=nonConstNoSmartPtrRawPointerToWireType;this.destructorFunction=null}else this["toWireType"]=genericPointerToWireType} +var replacePublicSymbol=function(name,value,numArguments){if(!Module.hasOwnProperty(name))throwInternalError("Replacing nonexistant public symbol");if(undefined!==Module[name].overloadTable&&undefined!==numArguments)Module[name].overloadTable[numArguments]=value;else{Module[name]=value;Module[name].argCount=numArguments}};var dynCallLegacy=function(sig,ptr,args){var f=Module["dynCall_"+sig];return args&&args.length?f.apply(null,[ptr].concat(args)):f.call(null,ptr)};var wasmTableMirror=[];var wasmTable; +var getWasmTableEntry=function(funcPtr){var func=wasmTableMirror[funcPtr];if(!func){if(funcPtr>=wasmTableMirror.length)wasmTableMirror.length=funcPtr+1;wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var dynCall=function(sig,ptr,args){if(sig.includes("j"))return dynCallLegacy(sig,ptr,args);var rtn=getWasmTableEntry(ptr).apply(null,args);return rtn}; +var getDynCaller=function(sig,ptr){var argCache=[];return function(){argCache.length=0;Object.assign(argCache,arguments);return dynCall(sig,ptr,argCache)}}; +var embind__requireFunction=function(signature,rawFunction){signature=readLatin1String(signature);function makeDynCaller(){if(signature.includes("j"))return getDynCaller(signature,rawFunction);return getWasmTableEntry(rawFunction)}var fp=makeDynCaller();if(typeof fp!="function")throwBindingError("unknown function pointer with signature "+signature+": "+rawFunction);return fp}; +var extendError=function(baseErrorType,errorName){var errorClass=createNamedFunction(errorName,function(message){this.name=errorName;this.message=message;var stack=(new Error(message)).stack;if(stack!==undefined)this.stack=this.toString()+"\n"+stack.replace(/^Error(:[^\n]*)?\n/,"")});errorClass.prototype=Object.create(baseErrorType.prototype);errorClass.prototype.constructor=errorClass;errorClass.prototype.toString=function(){if(this.message===undefined)return this.name;else return this.name+": "+ +this.message};return errorClass};var UnboundTypeError;var getTypeName=function(type){var ptr=___getTypeName(type);var rv=readLatin1String(ptr);_free(ptr);return rv}; +var throwUnboundTypeError=function(message,types){var unboundTypes=[];var seen={};function visit(type){if(seen[type])return;if(registeredTypes[type])return;if(typeDependencies[type]){typeDependencies[type].forEach(visit);return}unboundTypes.push(type);seen[type]=true}types.forEach(visit);throw new UnboundTypeError(message+": "+unboundTypes.map(getTypeName).join([", "]));}; +var __embind_register_class=function(rawType,rawPointerType,rawConstPointerType,baseClassRawType,getActualTypeSignature,getActualType,upcastSignature,upcast,downcastSignature,downcast,name,destructorSignature,rawDestructor){name=readLatin1String(name);getActualType=embind__requireFunction(getActualTypeSignature,getActualType);if(upcast)upcast=embind__requireFunction(upcastSignature,upcast);if(downcast)downcast=embind__requireFunction(downcastSignature,downcast);rawDestructor=embind__requireFunction(destructorSignature, +rawDestructor);var legalFunctionName=makeLegalFunctionName(name);exposePublicSymbol(legalFunctionName,function(){throwUnboundTypeError("Cannot construct "+name+" due to unbound types",[baseClassRawType])});whenDependentTypesAreResolved([rawType,rawPointerType,rawConstPointerType],baseClassRawType?[baseClassRawType]:[],function(base){base=base[0];var baseClass;var basePrototype;if(baseClassRawType){baseClass=base.registeredClass;basePrototype=baseClass.instancePrototype}else basePrototype=ClassHandle.prototype; +var constructor=createNamedFunction(legalFunctionName,function(){if(Object.getPrototypeOf(this)!==instancePrototype)throw new BindingError("Use 'new' to construct "+name);if(undefined===registeredClass.constructor_body)throw new BindingError(name+" has no accessible constructor");var body=registeredClass.constructor_body[arguments.length];if(undefined===body)throw new BindingError("Tried to invoke ctor of "+name+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(registeredClass.constructor_body).toString()+ +") parameters instead!");return body.apply(this,arguments)});var instancePrototype=Object.create(basePrototype,{constructor:{value:constructor}});constructor.prototype=instancePrototype;var registeredClass=new RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast);if(registeredClass.baseClass){if(registeredClass.baseClass.__derivedClasses===undefined)registeredClass.baseClass.__derivedClasses=[];registeredClass.baseClass.__derivedClasses.push(registeredClass)}var referenceConverter= +new RegisteredPointer(name,registeredClass,true,false,false);var pointerConverter=new RegisteredPointer(name+"*",registeredClass,false,false,false);var constPointerConverter=new RegisteredPointer(name+" const*",registeredClass,false,true,false);registeredPointers[rawType]={pointerType:pointerConverter,constPointerType:constPointerConverter};replacePublicSymbol(legalFunctionName,constructor);return[referenceConverter,pointerConverter,constPointerConverter]})}; +var heap32VectorToArray=function(count,firstElement){var array=[];for(var i=0;i>2]);return array}; +function newFunc(constructor,argumentList){if(!(constructor instanceof Function))throw new TypeError("new_ called with constructor type "+typeof constructor+" which is not a function");var dummy=createNamedFunction(constructor.name||"unknownFunctionName",function(){});dummy.prototype=constructor.prototype;var obj=new dummy;var r=constructor.apply(obj,argumentList);return r instanceof Object?r:obj} +function craftInvokerFunction(humanName,argTypes,classType,cppInvokerFunc,cppTargetFunc,isAsync){var argCount=argTypes.length;if(argCount<2)throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");var isClassMethodFunc=argTypes[1]!==null&&classType!==null;var needsDestructorStack=false;for(var i=1;i0?", ":"")+argsListWired;invokerFnBody+=(returns||isAsync?"var rv = ":"")+"invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";if(needsDestructorStack)invokerFnBody+="runDestructors(destructors);\n";else for(var i=isClassMethodFunc?1:2;i=emval_handles.reserved&&0===--emval_handles.get(handle).refcount)emval_handles.free(handle)};var count_emval_handles=function(){var count=0;for(var i=emval_handles.reserved;i>0])}:function(pointer){return this["fromWireType"](HEAPU8[pointer>>0])};case 2:return signed?function(pointer){return this["fromWireType"](HEAP16[pointer>>1])}:function(pointer){return this["fromWireType"](HEAPU16[pointer>>1])};case 4:return signed?function(pointer){return this["fromWireType"](HEAP32[pointer>>2])}:function(pointer){return this["fromWireType"](HEAPU32[pointer>> +2])};default:throw new TypeError("invalid integer width ("+width+"): "+name);}}; +var __embind_register_enum=function(rawType,name,size,isSigned){name=readLatin1String(name);function ctor(){}ctor.values={};registerType(rawType,{name:name,constructor:ctor,"fromWireType":function(c){return this.constructor.values[c]},"toWireType":function(destructors,c){return c.value},"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":enumReadValueFromPointer(name,size,isSigned),destructorFunction:null});exposePublicSymbol(name,ctor)}; +var requireRegisteredType=function(rawType,humanName){var impl=registeredTypes[rawType];if(undefined===impl)throwBindingError(humanName+" has unknown type "+getTypeName(rawType));return impl}; +var __embind_register_enum_value=function(rawEnumType,name,enumValue){var enumType=requireRegisteredType(rawEnumType,"enum");name=readLatin1String(name);var Enum=enumType.constructor;var Value=Object.create(enumType.constructor.prototype,{value:{value:enumValue},constructor:{value:createNamedFunction(enumType.name+"_"+name,function(){})}});Enum.values[enumValue]=Value;Enum[name]=Value}; +var embindRepr=function(v){if(v===null)return"null";var t=typeof v;if(t==="object"||t==="array"||t==="function")return v.toString();else return""+v};var floatReadValueFromPointer=function(name,width){switch(width){case 4:return function(pointer){return this["fromWireType"](HEAPF32[pointer>>2])};case 8:return function(pointer){return this["fromWireType"](HEAPF64[pointer>>3])};default:throw new TypeError("invalid float width ("+width+"): "+name);}}; +var __embind_register_float=function(rawType,name,size){name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":function(value){return value},"toWireType":function(destructors,value){return value},"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":floatReadValueFromPointer(name,size),destructorFunction:null})}; +var __embind_register_function=function(name,argCount,rawArgTypesAddr,signature,rawInvoker,fn,isAsync){var argTypes=heap32VectorToArray(argCount,rawArgTypesAddr);name=readLatin1String(name);rawInvoker=embind__requireFunction(signature,rawInvoker);exposePublicSymbol(name,function(){throwUnboundTypeError("Cannot call "+name+" due to unbound types",argTypes)},argCount-1);whenDependentTypesAreResolved([],argTypes,function(argTypes){var invokerArgsArray=[argTypes[0],null].concat(argTypes.slice(1));replacePublicSymbol(name, +craftInvokerFunction(name,invokerArgsArray,null,rawInvoker,fn,isAsync),argCount-1);return[]})}; +var integerReadValueFromPointer=function(name,width,signed){switch(width){case 1:return signed?function(pointer){return HEAP8[pointer>>0]}:function(pointer){return HEAPU8[pointer>>0]};case 2:return signed?function(pointer){return HEAP16[pointer>>1]}:function(pointer){return HEAPU16[pointer>>1]};case 4:return signed?function(pointer){return HEAP32[pointer>>2]}:function(pointer){return HEAPU32[pointer>>2]};default:throw new TypeError("invalid integer width ("+width+"): "+name);}}; +var __embind_register_integer=function(primitiveType,name,size,minRange,maxRange){name=readLatin1String(name);if(maxRange===-1)maxRange=4294967295;var fromWireType=function(value){return value};if(minRange===0){var bitshift=32-8*size;fromWireType=function(value){return value<>>bitshift}}var isUnsignedType=name.includes("unsigned");var checkAssertions=function(value,toTypeName){};var toWireType;if(isUnsignedType)toWireType=function(destructors,value){checkAssertions(value,this.name);return value>>> +0};else toWireType=function(destructors,value){checkAssertions(value,this.name);return value};registerType(primitiveType,{name:name,"fromWireType":fromWireType,"toWireType":toWireType,"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":integerReadValueFromPointer(name,size,minRange!==0),destructorFunction:null})}; +var __embind_register_memory_view=function(rawType,dataTypeIndex,name){var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){var size=HEAPU32[handle>>2];var data=HEAPU32[handle+4>>2];return new TA(HEAP8.buffer,data,size)}name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":decodeMemoryView,"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":decodeMemoryView}, +{ignoreDuplicateRegistrations:true})}; +var stringToUTF8Array=function(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]= +128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=function(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}; +var lengthBytesUTF8=function(str){var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else len+=3}return len};var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined; +var UTF8ArrayToString=function(heapOrArray,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder)return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr));var str="";while(idx>10,56320|ch&1023)}}return str};var UTF8ToString=function(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}; +var __embind_register_std_string=function(rawType,name){name=readLatin1String(name);var stdStringIsUTF8=name==="std::string";var $jscomp$compprop3={};registerType(rawType,($jscomp$compprop3.name=name,$jscomp$compprop3["fromWireType"]=function(value){var length=HEAPU32[value>>2];var payload=value+4;var str;if(stdStringIsUTF8){var decodeStartPtr=payload;for(var i=0;i<=length;++i){var currentBytePtr=payload+i;if(i==length||HEAPU8[currentBytePtr]==0){var maxRead=currentBytePtr-decodeStartPtr;var stringSegment= +UTF8ToString(decodeStartPtr,maxRead);if(str===undefined)str=stringSegment;else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+1}}}else{var a=new Array(length);for(var i=0;i>2]=length;if(stdStringIsUTF8&&valueIsOfTypeString)stringToUTF8(value,ptr,length+1);else if(valueIsOfTypeString)for(var i=0;i255){_free(ptr); +throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}HEAPU8[ptr+i]=charCode}else for(var i=0;i>1;var maxIdx=idx+maxBytesToRead/2;while(!(idx>=maxIdx)&&HEAPU16[idx])++idx;endPtr=idx<<1;if(endPtr-ptr>32&&UTF16Decoder)return UTF16Decoder.decode(HEAPU8.subarray(ptr,endPtr));var str="";for(var i=0;!(i>=maxBytesToRead/2);++i){var codeUnit=HEAP16[ptr+i*2>>1];if(codeUnit==0)break;str+=String.fromCharCode(codeUnit)}return str}; +var stringToUTF16=function(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined)maxBytesToWrite=2147483647;if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr};var lengthBytesUTF16=function(str){return str.length*2}; +var UTF32ToString=function(ptr,maxBytesToRead){var i=0;var str="";while(!(i>=maxBytesToRead/4)){var utf32=HEAP32[ptr+i*4>>2];if(utf32==0)break;++i;if(utf32>=65536){var ch=utf32-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}else str+=String.fromCharCode(utf32)}return str}; +var stringToUTF32=function(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined)maxBytesToWrite=2147483647;if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i=55296&&codeUnit<=57343){var trailSurrogate=str.charCodeAt(++i);codeUnit=65536+((codeUnit&1023)<<10)|trailSurrogate&1023}HEAP32[outPtr>>2]=codeUnit;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=0;return outPtr-startPtr}; +var lengthBytesUTF32=function(str){var len=0;for(var i=0;i=55296&&codeUnit<=57343)++i;len+=4}return len}; +var __embind_register_std_wstring=function(rawType,charSize,name){name=readLatin1String(name);var decodeString,encodeString,getHeap,lengthBytesUTF,shift;if(charSize===2){decodeString=UTF16ToString;encodeString=stringToUTF16;lengthBytesUTF=lengthBytesUTF16;getHeap=function(){return HEAPU16};shift=1}else if(charSize===4){decodeString=UTF32ToString;encodeString=stringToUTF32;lengthBytesUTF=lengthBytesUTF32;getHeap=function(){return HEAPU32};shift=2}registerType(rawType,{name:name,"fromWireType":function(value){var length= +HEAPU32[value>>2];var HEAP=getHeap();var str;var decodeStartPtr=value+4;for(var i=0;i<=length;++i){var currentBytePtr=value+4+i*charSize;if(i==length||HEAP[currentBytePtr>>shift]==0){var maxReadBytes=currentBytePtr-decodeStartPtr;var stringSegment=decodeString(decodeStartPtr,maxReadBytes);if(str===undefined)str=stringSegment;else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+charSize}}_free(value);return str},"toWireType":function(destructors,value){if(!(typeof value== +"string"))throwBindingError("Cannot pass non-string to C++ string type "+name);var length=lengthBytesUTF(value);var ptr=_malloc(4+length+charSize);HEAPU32[ptr>>2]=length>>shift;encodeString(value,ptr+4,length+charSize);if(destructors!==null)destructors.push(_free,ptr);return ptr},"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":simpleReadValueFromPointer,destructorFunction:function(ptr){_free(ptr)}})}; +var __embind_register_value_object=function(rawType,name,constructorSignature,rawConstructor,destructorSignature,rawDestructor){structRegistrations[rawType]={name:readLatin1String(name),rawConstructor:embind__requireFunction(constructorSignature,rawConstructor),rawDestructor:embind__requireFunction(destructorSignature,rawDestructor),fields:[]}}; +var __embind_register_value_object_field=function(structType,fieldName,getterReturnType,getterSignature,getter,getterContext,setterArgumentType,setterSignature,setter,setterContext){structRegistrations[structType].fields.push({fieldName:readLatin1String(fieldName),getterReturnType:getterReturnType,getter:embind__requireFunction(getterSignature,getter),getterContext:getterContext,setterArgumentType:setterArgumentType,setter:embind__requireFunction(setterSignature,setter),setterContext:setterContext})}; +var __embind_register_void=function(rawType,name){name=readLatin1String(name);registerType(rawType,{isVoid:true,name:name,"argPackAdvance":0,"fromWireType":function(){return undefined},"toWireType":function(destructors,o){return undefined}})}; +var __emval_as=function(handle,returnType,destructorsRef){handle=Emval.toValue(handle);returnType=requireRegisteredType(returnType,"emval::as");var destructors=[];var rd=Emval.toHandle(destructors);HEAPU32[destructorsRef>>2]=rd;return returnType["toWireType"](destructors,handle)};var emval_symbols={};var getStringOrSymbol=function(address){var symbol=emval_symbols[address];if(symbol===undefined)return readLatin1String(address);return symbol};var emval_methodCallers=[]; +var __emval_call_void_method=function(caller,handle,methodName,args){caller=emval_methodCallers[caller];handle=Emval.toValue(handle);methodName=getStringOrSymbol(methodName);caller(handle,methodName,null,args)};var emval_get_global=function(){if(typeof globalThis=="object")return globalThis;return function(){return Function}()("return this")()};var __emval_get_global=function(name){if(name===0)return Emval.toHandle(emval_get_global());else{name=getStringOrSymbol(name);return Emval.toHandle(emval_get_global()[name])}}; +var emval_addMethodCaller=function(caller){var id=emval_methodCallers.length;emval_methodCallers.push(caller);return id};var emval_lookupTypes=function(argCount,argTypes){var a=new Array(argCount);for(var i=0;i>2],"parameter "+i);return a};var emval_registeredMethods={}; +var __emval_get_method_caller=function(argCount,argTypes){var types=emval_lookupTypes(argCount,argTypes);var retType=types[0];var signatureName=retType.name+"_$"+types.slice(1).map(function(t){return t.name}).join("_")+"$";var returnId=emval_registeredMethods[signatureName];if(returnId!==undefined)return returnId;var params=["retType"];var args=[retType];var argsList="";for(var i=0;i4)emval_handles.get(handle).refcount+=1}; +var craftEmvalAllocator=function(argCount){var argsList="";for(var i=0;i>2)], 'parameter "+i+"');\n"+"var arg"+i+" = argType"+i+".readValueFromPointer(args);\n"+"args += argType"+ +i+"['argPackAdvance'];\n"+"argTypes += 4;\n";functionBody+="var obj = new constructor("+argsList+");\n"+"return valueToHandle(obj);\n"+"}\n";return(new Function("requireRegisteredType","Module","valueToHandle","getMemory",functionBody))(requireRegisteredType,Module,Emval.toHandle,getMemory)};var emval_newers={}; +var __emval_new=function(handle,argCount,argTypes,args){handle=Emval.toValue(handle);var newer=emval_newers[argCount];if(!newer){newer=craftEmvalAllocator(argCount);emval_newers[argCount]=newer}return newer(handle,argTypes,args)};var __emval_new_cstring=function(v){return Emval.toHandle(getStringOrSymbol(v))};var __emval_run_destructors=function(handle){var destructors=Emval.toValue(handle);runDestructors(destructors);__emval_decref(handle)};var _abort=function(){abort("")}; +var _emscripten_memcpy_js=Uint8Array.prototype.copyWithin?function(dest,src,num){return HEAPU8.copyWithin(dest,src,src+num)}:function(dest,src,num){return HEAPU8.set(HEAPU8.subarray(src,src+num),dest)};var getHeapMax=function(){return 2147483648};var growMemory=function(size){var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}}; +var _emscripten_resize_heap=function(requestedSize){var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize)return false;var alignUp=function(x,multiple){return x+(multiple-x%multiple)%multiple};for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement= +growMemory(newSize);if(replacement)return true}return false};var SYSCALLS={varargs:undefined,get:function(){var ret=HEAP32[+SYSCALLS.varargs>>2];SYSCALLS.varargs+=4;return ret},getp:function(){return SYSCALLS.get()},getStr:function(ptr){var ret=UTF8ToString(ptr);return ret}};var _fd_close=function(fd){return 52};var convertI32PairToI53Checked=function(lo,hi){return hi+2097152>>>0<4194305-!!lo?(lo>>>0)+hi*4294967296:NaN}; +function _fd_seek(fd,offset_low,offset_high,whence,newOffset){var offset=convertI32PairToI53Checked(offset_low,offset_high);return 70}var printCharBuffers=[null,[],[]];var printChar=function(stream,curr){var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else buffer.push(curr)}; +var _fd_write=function(fd,iov,iovcnt,pnum){var num=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j>2]=num;return 0}; +var $var$folders$74$xvts57r10jj4_q1973jnyqgc0000gn$T$emscripten_temp_nbrkql29$basis_jso4$classdecl$var0=function(message){var $jscomp$tmp$error;$jscomp$tmp$error=Error.call(this,message),this.message=$jscomp$tmp$error.message,"stack"in $jscomp$tmp$error&&(this.stack=$jscomp$tmp$error.stack),this;this.name="InternalError"};$jscomp.inherits($var$folders$74$xvts57r10jj4_q1973jnyqgc0000gn$T$emscripten_temp_nbrkql29$basis_jso4$classdecl$var0,Error);InternalError=Module["InternalError"]=$var$folders$74$xvts57r10jj4_q1973jnyqgc0000gn$T$emscripten_temp_nbrkql29$basis_jso4$classdecl$var0; +embind_init_charCodes();var $var$folders$74$xvts57r10jj4_q1973jnyqgc0000gn$T$emscripten_temp_nbrkql29$basis_jso4$classdecl$var1=function(message){var $jscomp$tmp$error;$jscomp$tmp$error=Error.call(this,message),this.message=$jscomp$tmp$error.message,"stack"in $jscomp$tmp$error&&(this.stack=$jscomp$tmp$error.stack),this;this.name="BindingError"};$jscomp.inherits($var$folders$74$xvts57r10jj4_q1973jnyqgc0000gn$T$emscripten_temp_nbrkql29$basis_jso4$classdecl$var1,Error); +BindingError=Module["BindingError"]=$var$folders$74$xvts57r10jj4_q1973jnyqgc0000gn$T$emscripten_temp_nbrkql29$basis_jso4$classdecl$var1;init_ClassHandle();init_embind();init_RegisteredPointer();UnboundTypeError=Module["UnboundTypeError"]=extendError(Error,"UnboundTypeError");handleAllocatorInit();init_emval(); +var wasmImports={L:___cxa_throw,t:__embind_finalize_value_object,E:__embind_register_bigint,J:__embind_register_bool,y:__embind_register_class,x:__embind_register_class_constructor,e:__embind_register_class_function,l:__embind_register_constant,I:__embind_register_emval,o:__embind_register_enum,b:__embind_register_enum_value,C:__embind_register_float,j:__embind_register_function,k:__embind_register_integer,f:__embind_register_memory_view,B:__embind_register_std_string,w:__embind_register_std_wstring, +u:__embind_register_value_object,d:__embind_register_value_object_field,K:__embind_register_void,n:__emval_as,s:__emval_call_void_method,c:__emval_decref,z:__emval_get_global,p:__emval_get_method_caller,r:__emval_get_module_property,g:__emval_get_property,i:__emval_incref,q:__emval_new,h:__emval_new_cstring,m:__emval_run_destructors,v:_abort,H:_emscripten_memcpy_js,F:_emscripten_resize_heap,G:_fd_close,D:_fd_seek,A:_fd_write,a:wasmMemory};var wasmExports=createWasm(); +var ___wasm_call_ctors=function(){return(___wasm_call_ctors=wasmExports["M"])()};var _malloc=function(a0){return(_malloc=wasmExports["N"])(a0)};var _free=function(a0){return(_free=wasmExports["O"])(a0)};var ___getTypeName=function(a0){return(___getTypeName=wasmExports["Q"])(a0)};var __embind_initialize_bindings=Module["__embind_initialize_bindings"]=function(){return(__embind_initialize_bindings=Module["__embind_initialize_bindings"]=wasmExports["R"])()}; +var ___errno_location=function(){return(___errno_location=wasmExports["__errno_location"])()};var ___cxa_is_pointer_type=function(a0){return(___cxa_is_pointer_type=wasmExports["S"])(a0)};var dynCall_jiji=Module["dynCall_jiji"]=function(a0,a1,a2,a3,a4){return(dynCall_jiji=Module["dynCall_jiji"]=wasmExports["T"])(a0,a1,a2,a3,a4)}; +if(typeof atob=="undefined"){if(typeof global!="undefined"&&typeof globalThis=="undefined")globalThis=global;globalThis.atob=function(input){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/=]/g,"");do{enc1=keyStr.indexOf(input.charAt(i++));enc2=keyStr.indexOf(input.charAt(i++));enc3=keyStr.indexOf(input.charAt(i++));enc4=keyStr.indexOf(input.charAt(i++));chr1=enc1<<2| +enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!==64)output=output+String.fromCharCode(chr2);if(enc4!==64)output=output+String.fromCharCode(chr3)}while(i0)return;preRun();if(runDependencies>0)return;function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else doRun()} +if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0)Module["preInit"].pop()()}run(); + + + return moduleArg.ready +} + +); +})(); +if (typeof exports === 'object' && typeof module === 'object') + module.exports = BASIS; +else if (typeof define === 'function' && define['amd']) + define([], () => BASIS); diff --git a/GemQuest/files/assets/214864109/1/basis.wasm.js b/GemQuest/files/assets/214864109/1/basis.wasm.js new file mode 100644 index 0000000..3ad6183 --- /dev/null +++ b/GemQuest/files/assets/214864109/1/basis.wasm.js @@ -0,0 +1,19 @@ + +var BASIS = (() => { + var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; + if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; + return ( +function(moduleArg = {}) { + +var Module=moduleArg;var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("fs");var nodePath=require("path");if(ENVIRONMENT_IS_WORKER){scriptDirectory=nodePath.dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}read_=(filename,binary)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);return fs.readFileSync(filename,binary?undefined:"utf8")};readBinary=filename=>{var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}return ret};readAsync=(filename,onload,onerror,binary=true)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);fs.readFile(filename,binary?undefined:"utf8",(err,data)=>{if(err)onerror(err);else onload(binary?data.buffer:data)})};if(!Module["thisProgram"]&&process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow};Module["inspect"]=()=>"[Emscripten Module object]"}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.error.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b)}var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}function isFileURI(filename){return filename.startsWith("file://")}var wasmBinaryFile;wasmBinaryFile="basis.wasm.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}function getBinaryPromise(binaryFile){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"&&!isFileURI(binaryFile)){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{if(!response["ok"]){throw"failed to load wasm binary file at '"+binaryFile+"'"}return response["arrayBuffer"]()}).catch(()=>getBinarySync(binaryFile))}else if(readAsync){return new Promise((resolve,reject)=>{readAsync(binaryFile,response=>resolve(new Uint8Array(response)),reject)})}}return Promise.resolve().then(()=>getBinarySync(binaryFile))}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(binary=>WebAssembly.instantiate(binary,imports)).then(instance=>instance).then(receiver,reason=>{err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(response=>{var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(binaryFile,imports,callback)})})}return instantiateArrayBuffer(binaryFile,imports,callback)}function createWasm(){var info={"a":wasmImports};function receiveInstance(instance,module){wasmExports=instance.exports;wasmMemory=wasmExports["L"];updateMemoryViews();wasmTable=wasmExports["P"];addOnInit(wasmExports["M"]);removeRunDependency("wasm-instantiate");return wasmExports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"])}if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err(`Module.instantiateWasm callback failed with error: ${e}`);readyPromiseReject(e)}}instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult).catch(readyPromiseReject);return{}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};function ExceptionInfo(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24;this.set_type=function(type){HEAPU32[this.ptr+4>>2]=type};this.get_type=function(){return HEAPU32[this.ptr+4>>2]};this.set_destructor=function(destructor){HEAPU32[this.ptr+8>>2]=destructor};this.get_destructor=function(){return HEAPU32[this.ptr+8>>2]};this.set_caught=function(caught){caught=caught?1:0;HEAP8[this.ptr+12>>0]=caught};this.get_caught=function(){return HEAP8[this.ptr+12>>0]!=0};this.set_rethrown=function(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13>>0]=rethrown};this.get_rethrown=function(){return HEAP8[this.ptr+13>>0]!=0};this.init=function(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)};this.set_adjusted_ptr=function(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr};this.get_adjusted_ptr=function(){return HEAPU32[this.ptr+16>>2]};this.get_exception_ptr=function(){var isPointer=___cxa_is_pointer_type(this.get_type());if(isPointer){return HEAPU32[this.excPtr>>2]}var adjusted=this.get_adjusted_ptr();if(adjusted!==0)return adjusted;return this.excPtr}}var exceptionLast=0;var uncaughtExceptionCount=0;var ___cxa_throw=(ptr,type,destructor)=>{var info=new ExceptionInfo(ptr);info.init(type,destructor);exceptionLast=ptr;uncaughtExceptionCount++;throw exceptionLast};var structRegistrations={};var runDestructors=destructors=>{while(destructors.length){var ptr=destructors.pop();var del=destructors.pop();del(ptr)}};function simpleReadValueFromPointer(pointer){return this["fromWireType"](HEAP32[pointer>>2])}var awaitingDependencies={};var registeredTypes={};var typeDependencies={};var InternalError;var throwInternalError=message=>{throw new InternalError(message)};var whenDependentTypesAreResolved=(myTypes,dependentTypes,getTypeConverters)=>{myTypes.forEach(function(type){typeDependencies[type]=dependentTypes});function onComplete(typeConverters){var myTypeConverters=getTypeConverters(typeConverters);if(myTypeConverters.length!==myTypes.length){throwInternalError("Mismatched type converter count")}for(var i=0;i{if(registeredTypes.hasOwnProperty(dt)){typeConverters[i]=registeredTypes[dt]}else{unregisteredTypes.push(dt);if(!awaitingDependencies.hasOwnProperty(dt)){awaitingDependencies[dt]=[]}awaitingDependencies[dt].push(()=>{typeConverters[i]=registeredTypes[dt];++registered;if(registered===unregisteredTypes.length){onComplete(typeConverters)}})}});if(0===unregisteredTypes.length){onComplete(typeConverters)}};var __embind_finalize_value_object=structType=>{var reg=structRegistrations[structType];delete structRegistrations[structType];var rawConstructor=reg.rawConstructor;var rawDestructor=reg.rawDestructor;var fieldRecords=reg.fields;var fieldTypes=fieldRecords.map(field=>field.getterReturnType).concat(fieldRecords.map(field=>field.setterArgumentType));whenDependentTypesAreResolved([structType],fieldTypes,fieldTypes=>{var fields={};fieldRecords.forEach((field,i)=>{var fieldName=field.fieldName;var getterReturnType=fieldTypes[i];var getter=field.getter;var getterContext=field.getterContext;var setterArgumentType=fieldTypes[i+fieldRecords.length];var setter=field.setter;var setterContext=field.setterContext;fields[fieldName]={read:ptr=>getterReturnType["fromWireType"](getter(getterContext,ptr)),write:(ptr,o)=>{var destructors=[];setter(setterContext,ptr,setterArgumentType["toWireType"](destructors,o));runDestructors(destructors)}}});return[{name:reg.name,"fromWireType":ptr=>{var rv={};for(var i in fields){rv[i]=fields[i].read(ptr)}rawDestructor(ptr);return rv},"toWireType":(destructors,o)=>{for(var fieldName in fields){if(!(fieldName in o)){throw new TypeError(`Missing field: "${fieldName}"`)}}var ptr=rawConstructor();for(fieldName in fields){fields[fieldName].write(ptr,o[fieldName])}if(destructors!==null){destructors.push(rawDestructor,ptr)}return ptr},"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":simpleReadValueFromPointer,destructorFunction:rawDestructor}]})};var __embind_register_bigint=(primitiveType,name,size,minRange,maxRange)=>{};var embind_init_charCodes=()=>{var codes=new Array(256);for(var i=0;i<256;++i){codes[i]=String.fromCharCode(i)}embind_charCodes=codes};var embind_charCodes;var readLatin1String=ptr=>{var ret="";var c=ptr;while(HEAPU8[c]){ret+=embind_charCodes[HEAPU8[c++]]}return ret};var BindingError;var throwBindingError=message=>{throw new BindingError(message)};function sharedRegisterType(rawType,registeredInstance,options={}){var name=registeredInstance.name;if(!rawType){throwBindingError(`type "${name}" must have a positive integer typeid pointer`)}if(registeredTypes.hasOwnProperty(rawType)){if(options.ignoreDuplicateRegistrations){return}else{throwBindingError(`Cannot register type '${name}' twice`)}}registeredTypes[rawType]=registeredInstance;delete typeDependencies[rawType];if(awaitingDependencies.hasOwnProperty(rawType)){var callbacks=awaitingDependencies[rawType];delete awaitingDependencies[rawType];callbacks.forEach(cb=>cb())}}function registerType(rawType,registeredInstance,options={}){if(!("argPackAdvance"in registeredInstance)){throw new TypeError("registerType registeredInstance requires argPackAdvance")}return sharedRegisterType(rawType,registeredInstance,options)}var GenericWireTypeSize=8;var __embind_register_bool=(rawType,name,trueValue,falseValue)=>{name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":function(wt){return!!wt},"toWireType":function(destructors,o){return o?trueValue:falseValue},"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":function(pointer){return this["fromWireType"](HEAPU8[pointer])},destructorFunction:null})};var shallowCopyInternalPointer=o=>({count:o.count,deleteScheduled:o.deleteScheduled,preservePointerOnDelete:o.preservePointerOnDelete,ptr:o.ptr,ptrType:o.ptrType,smartPtr:o.smartPtr,smartPtrType:o.smartPtrType});var throwInstanceAlreadyDeleted=obj=>{function getInstanceTypeName(handle){return handle.$$.ptrType.registeredClass.name}throwBindingError(getInstanceTypeName(obj)+" instance already deleted")};var finalizationRegistry=false;var detachFinalizer=handle=>{};var runDestructor=$$=>{if($$.smartPtr){$$.smartPtrType.rawDestructor($$.smartPtr)}else{$$.ptrType.registeredClass.rawDestructor($$.ptr)}};var releaseClassHandle=$$=>{$$.count.value-=1;var toDelete=0===$$.count.value;if(toDelete){runDestructor($$)}};var downcastPointer=(ptr,ptrClass,desiredClass)=>{if(ptrClass===desiredClass){return ptr}if(undefined===desiredClass.baseClass){return null}var rv=downcastPointer(ptr,ptrClass,desiredClass.baseClass);if(rv===null){return null}return desiredClass.downcast(rv)};var registeredPointers={};var getInheritedInstanceCount=()=>Object.keys(registeredInstances).length;var getLiveInheritedInstances=()=>{var rv=[];for(var k in registeredInstances){if(registeredInstances.hasOwnProperty(k)){rv.push(registeredInstances[k])}}return rv};var deletionQueue=[];var flushPendingDeletes=()=>{while(deletionQueue.length){var obj=deletionQueue.pop();obj.$$.deleteScheduled=false;obj["delete"]()}};var delayFunction;var setDelayFunction=fn=>{delayFunction=fn;if(deletionQueue.length&&delayFunction){delayFunction(flushPendingDeletes)}};var init_embind=()=>{Module["getInheritedInstanceCount"]=getInheritedInstanceCount;Module["getLiveInheritedInstances"]=getLiveInheritedInstances;Module["flushPendingDeletes"]=flushPendingDeletes;Module["setDelayFunction"]=setDelayFunction};var registeredInstances={};var getBasestPointer=(class_,ptr)=>{if(ptr===undefined){throwBindingError("ptr should not be undefined")}while(class_.baseClass){ptr=class_.upcast(ptr);class_=class_.baseClass}return ptr};var getInheritedInstance=(class_,ptr)=>{ptr=getBasestPointer(class_,ptr);return registeredInstances[ptr]};var makeClassHandle=(prototype,record)=>{if(!record.ptrType||!record.ptr){throwInternalError("makeClassHandle requires ptr and ptrType")}var hasSmartPtrType=!!record.smartPtrType;var hasSmartPtr=!!record.smartPtr;if(hasSmartPtrType!==hasSmartPtr){throwInternalError("Both smartPtrType and smartPtr must be specified")}record.count={value:1};return attachFinalizer(Object.create(prototype,{$$:{value:record}}))};function RegisteredPointer_fromWireType(ptr){var rawPointer=this.getPointee(ptr);if(!rawPointer){this.destructor(ptr);return null}var registeredInstance=getInheritedInstance(this.registeredClass,rawPointer);if(undefined!==registeredInstance){if(0===registeredInstance.$$.count.value){registeredInstance.$$.ptr=rawPointer;registeredInstance.$$.smartPtr=ptr;return registeredInstance["clone"]()}else{var rv=registeredInstance["clone"]();this.destructor(ptr);return rv}}function makeDefaultHandle(){if(this.isSmartPointer){return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:rawPointer,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(this.registeredClass.instancePrototype,{ptrType:this,ptr:ptr})}}var actualType=this.registeredClass.getActualType(rawPointer);var registeredPointerRecord=registeredPointers[actualType];if(!registeredPointerRecord){return makeDefaultHandle.call(this)}var toType;if(this.isConst){toType=registeredPointerRecord.constPointerType}else{toType=registeredPointerRecord.pointerType}var dp=downcastPointer(rawPointer,this.registeredClass,toType.registeredClass);if(dp===null){return makeDefaultHandle.call(this)}if(this.isSmartPointer){return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp,smartPtrType:this,smartPtr:ptr})}else{return makeClassHandle(toType.registeredClass.instancePrototype,{ptrType:toType,ptr:dp})}}var attachFinalizer=handle=>{if("undefined"===typeof FinalizationRegistry){attachFinalizer=handle=>handle;return handle}finalizationRegistry=new FinalizationRegistry(info=>{releaseClassHandle(info.$$)});attachFinalizer=handle=>{var $$=handle.$$;var hasSmartPtr=!!$$.smartPtr;if(hasSmartPtr){var info={$$:$$};finalizationRegistry.register(handle,info,handle)}return handle};detachFinalizer=handle=>finalizationRegistry.unregister(handle);return attachFinalizer(handle)};var init_ClassHandle=()=>{Object.assign(ClassHandle.prototype,{"isAliasOf"(other){if(!(this instanceof ClassHandle)){return false}if(!(other instanceof ClassHandle)){return false}var leftClass=this.$$.ptrType.registeredClass;var left=this.$$.ptr;other.$$=other.$$;var rightClass=other.$$.ptrType.registeredClass;var right=other.$$.ptr;while(leftClass.baseClass){left=leftClass.upcast(left);leftClass=leftClass.baseClass}while(rightClass.baseClass){right=rightClass.upcast(right);rightClass=rightClass.baseClass}return leftClass===rightClass&&left===right},"clone"(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.preservePointerOnDelete){this.$$.count.value+=1;return this}else{var clone=attachFinalizer(Object.create(Object.getPrototypeOf(this),{$$:{value:shallowCopyInternalPointer(this.$$)}}));clone.$$.count.value+=1;clone.$$.deleteScheduled=false;return clone}},"delete"(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}detachFinalizer(this);releaseClassHandle(this.$$);if(!this.$$.preservePointerOnDelete){this.$$.smartPtr=undefined;this.$$.ptr=undefined}},"isDeleted"(){return!this.$$.ptr},"deleteLater"(){if(!this.$$.ptr){throwInstanceAlreadyDeleted(this)}if(this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete){throwBindingError("Object already scheduled for deletion")}deletionQueue.push(this);if(deletionQueue.length===1&&delayFunction){delayFunction(flushPendingDeletes)}this.$$.deleteScheduled=true;return this}})};function ClassHandle(){}var char_0=48;var char_9=57;var makeLegalFunctionName=name=>{if(undefined===name){return"_unknown"}name=name.replace(/[^a-zA-Z0-9_]/g,"$");var f=name.charCodeAt(0);if(f>=char_0&&f<=char_9){return`_${name}`}return name};function createNamedFunction(name,body){name=makeLegalFunctionName(name);return{[name]:function(){return body.apply(this,arguments)}}[name]}var ensureOverloadTable=(proto,methodName,humanName)=>{if(undefined===proto[methodName].overloadTable){var prevFunc=proto[methodName];proto[methodName]=function(){if(!proto[methodName].overloadTable.hasOwnProperty(arguments.length)){throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${arguments.length}) - expects one of (${proto[methodName].overloadTable})!`)}return proto[methodName].overloadTable[arguments.length].apply(this,arguments)};proto[methodName].overloadTable=[];proto[methodName].overloadTable[prevFunc.argCount]=prevFunc}};var exposePublicSymbol=(name,value,numArguments)=>{if(Module.hasOwnProperty(name)){if(undefined===numArguments||undefined!==Module[name].overloadTable&&undefined!==Module[name].overloadTable[numArguments]){throwBindingError(`Cannot register public name '${name}' twice`)}ensureOverloadTable(Module,name,name);if(Module.hasOwnProperty(numArguments)){throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`)}Module[name].overloadTable[numArguments]=value}else{Module[name]=value;if(undefined!==numArguments){Module[name].numArguments=numArguments}}};function RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast){this.name=name;this.constructor=constructor;this.instancePrototype=instancePrototype;this.rawDestructor=rawDestructor;this.baseClass=baseClass;this.getActualType=getActualType;this.upcast=upcast;this.downcast=downcast;this.pureVirtualFunctions=[]}var upcastPointer=(ptr,ptrClass,desiredClass)=>{while(ptrClass!==desiredClass){if(!ptrClass.upcast){throwBindingError(`Expected null or instance of ${desiredClass.name}, got an instance of ${ptrClass.name}`)}ptr=ptrClass.upcast(ptr);ptrClass=ptrClass.baseClass}return ptr};function constNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}function genericPointerToWireType(destructors,handle){var ptr;if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}if(this.isSmartPointer){ptr=this.rawConstructor();if(destructors!==null){destructors.push(this.rawDestructor,ptr)}return ptr}else{return 0}}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(!this.isConst&&handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);if(this.isSmartPointer){if(undefined===handle.$$.smartPtr){throwBindingError("Passing raw pointer to smart pointer is illegal")}switch(this.sharingPolicy){case 0:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{throwBindingError(`Cannot convert argument of type ${handle.$$.smartPtrType?handle.$$.smartPtrType.name:handle.$$.ptrType.name} to parameter type ${this.name}`)}break;case 1:ptr=handle.$$.smartPtr;break;case 2:if(handle.$$.smartPtrType===this){ptr=handle.$$.smartPtr}else{var clonedHandle=handle["clone"]();ptr=this.rawShare(ptr,Emval.toHandle(()=>clonedHandle["delete"]()));if(destructors!==null){destructors.push(this.rawDestructor,ptr)}}break;default:throwBindingError("Unsupporting sharing policy")}}return ptr}function nonConstNoSmartPtrRawPointerToWireType(destructors,handle){if(handle===null){if(this.isReference){throwBindingError(`null is not a valid ${this.name}`)}return 0}if(!handle.$$){throwBindingError(`Cannot pass "${embindRepr(handle)}" as a ${this.name}`)}if(!handle.$$.ptr){throwBindingError(`Cannot pass deleted object as a pointer of type ${this.name}`)}if(handle.$$.ptrType.isConst){throwBindingError(`Cannot convert argument of type ${handle.$$.ptrType.name} to parameter type ${this.name}`)}var handleClass=handle.$$.ptrType.registeredClass;var ptr=upcastPointer(handle.$$.ptr,handleClass,this.registeredClass);return ptr}function readPointer(pointer){return this["fromWireType"](HEAPU32[pointer>>2])}var init_RegisteredPointer=()=>{Object.assign(RegisteredPointer.prototype,{getPointee(ptr){if(this.rawGetPointee){ptr=this.rawGetPointee(ptr)}return ptr},destructor(ptr){if(this.rawDestructor){this.rawDestructor(ptr)}},"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":readPointer,"deleteObject"(handle){if(handle!==null){handle["delete"]()}},"fromWireType":RegisteredPointer_fromWireType})};function RegisteredPointer(name,registeredClass,isReference,isConst,isSmartPointer,pointeeType,sharingPolicy,rawGetPointee,rawConstructor,rawShare,rawDestructor){this.name=name;this.registeredClass=registeredClass;this.isReference=isReference;this.isConst=isConst;this.isSmartPointer=isSmartPointer;this.pointeeType=pointeeType;this.sharingPolicy=sharingPolicy;this.rawGetPointee=rawGetPointee;this.rawConstructor=rawConstructor;this.rawShare=rawShare;this.rawDestructor=rawDestructor;if(!isSmartPointer&®isteredClass.baseClass===undefined){if(isConst){this["toWireType"]=constNoSmartPtrRawPointerToWireType;this.destructorFunction=null}else{this["toWireType"]=nonConstNoSmartPtrRawPointerToWireType;this.destructorFunction=null}}else{this["toWireType"]=genericPointerToWireType}}var replacePublicSymbol=(name,value,numArguments)=>{if(!Module.hasOwnProperty(name)){throwInternalError("Replacing nonexistant public symbol")}if(undefined!==Module[name].overloadTable&&undefined!==numArguments){Module[name].overloadTable[numArguments]=value}else{Module[name]=value;Module[name].argCount=numArguments}};var dynCallLegacy=(sig,ptr,args)=>{var f=Module["dynCall_"+sig];return args&&args.length?f.apply(null,[ptr].concat(args)):f.call(null,ptr)};var wasmTableMirror=[];var wasmTable;var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){if(funcPtr>=wasmTableMirror.length)wasmTableMirror.length=funcPtr+1;wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var dynCall=(sig,ptr,args)=>{if(sig.includes("j")){return dynCallLegacy(sig,ptr,args)}var rtn=getWasmTableEntry(ptr).apply(null,args);return rtn};var getDynCaller=(sig,ptr)=>{var argCache=[];return function(){argCache.length=0;Object.assign(argCache,arguments);return dynCall(sig,ptr,argCache)}};var embind__requireFunction=(signature,rawFunction)=>{signature=readLatin1String(signature);function makeDynCaller(){if(signature.includes("j")){return getDynCaller(signature,rawFunction)}return getWasmTableEntry(rawFunction)}var fp=makeDynCaller();if(typeof fp!="function"){throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`)}return fp};var extendError=(baseErrorType,errorName)=>{var errorClass=createNamedFunction(errorName,function(message){this.name=errorName;this.message=message;var stack=new Error(message).stack;if(stack!==undefined){this.stack=this.toString()+"\n"+stack.replace(/^Error(:[^\n]*)?\n/,"")}});errorClass.prototype=Object.create(baseErrorType.prototype);errorClass.prototype.constructor=errorClass;errorClass.prototype.toString=function(){if(this.message===undefined){return this.name}else{return`${this.name}: ${this.message}`}};return errorClass};var UnboundTypeError;var getTypeName=type=>{var ptr=___getTypeName(type);var rv=readLatin1String(ptr);_free(ptr);return rv};var throwUnboundTypeError=(message,types)=>{var unboundTypes=[];var seen={};function visit(type){if(seen[type]){return}if(registeredTypes[type]){return}if(typeDependencies[type]){typeDependencies[type].forEach(visit);return}unboundTypes.push(type);seen[type]=true}types.forEach(visit);throw new UnboundTypeError(`${message}: `+unboundTypes.map(getTypeName).join([", "]))};var __embind_register_class=(rawType,rawPointerType,rawConstPointerType,baseClassRawType,getActualTypeSignature,getActualType,upcastSignature,upcast,downcastSignature,downcast,name,destructorSignature,rawDestructor)=>{name=readLatin1String(name);getActualType=embind__requireFunction(getActualTypeSignature,getActualType);if(upcast){upcast=embind__requireFunction(upcastSignature,upcast)}if(downcast){downcast=embind__requireFunction(downcastSignature,downcast)}rawDestructor=embind__requireFunction(destructorSignature,rawDestructor);var legalFunctionName=makeLegalFunctionName(name);exposePublicSymbol(legalFunctionName,function(){throwUnboundTypeError(`Cannot construct ${name} due to unbound types`,[baseClassRawType])});whenDependentTypesAreResolved([rawType,rawPointerType,rawConstPointerType],baseClassRawType?[baseClassRawType]:[],function(base){base=base[0];var baseClass;var basePrototype;if(baseClassRawType){baseClass=base.registeredClass;basePrototype=baseClass.instancePrototype}else{basePrototype=ClassHandle.prototype}var constructor=createNamedFunction(legalFunctionName,function(){if(Object.getPrototypeOf(this)!==instancePrototype){throw new BindingError("Use 'new' to construct "+name)}if(undefined===registeredClass.constructor_body){throw new BindingError(name+" has no accessible constructor")}var body=registeredClass.constructor_body[arguments.length];if(undefined===body){throw new BindingError(`Tried to invoke ctor of ${name} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(registeredClass.constructor_body).toString()}) parameters instead!`)}return body.apply(this,arguments)});var instancePrototype=Object.create(basePrototype,{constructor:{value:constructor}});constructor.prototype=instancePrototype;var registeredClass=new RegisteredClass(name,constructor,instancePrototype,rawDestructor,baseClass,getActualType,upcast,downcast);if(registeredClass.baseClass){if(registeredClass.baseClass.__derivedClasses===undefined){registeredClass.baseClass.__derivedClasses=[]}registeredClass.baseClass.__derivedClasses.push(registeredClass)}var referenceConverter=new RegisteredPointer(name,registeredClass,true,false,false);var pointerConverter=new RegisteredPointer(name+"*",registeredClass,false,false,false);var constPointerConverter=new RegisteredPointer(name+" const*",registeredClass,false,true,false);registeredPointers[rawType]={pointerType:pointerConverter,constPointerType:constPointerConverter};replacePublicSymbol(legalFunctionName,constructor);return[referenceConverter,pointerConverter,constPointerConverter]})};var heap32VectorToArray=(count,firstElement)=>{var array=[];for(var i=0;i>2])}return array};function newFunc(constructor,argumentList){if(!(constructor instanceof Function)){throw new TypeError(`new_ called with constructor type ${typeof constructor} which is not a function`)}var dummy=createNamedFunction(constructor.name||"unknownFunctionName",function(){});dummy.prototype=constructor.prototype;var obj=new dummy;var r=constructor.apply(obj,argumentList);return r instanceof Object?r:obj}function craftInvokerFunction(humanName,argTypes,classType,cppInvokerFunc,cppTargetFunc,isAsync){var argCount=argTypes.length;if(argCount<2){throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!")}var isClassMethodFunc=argTypes[1]!==null&&classType!==null;var needsDestructorStack=false;for(var i=1;i0?", ":"")+argsListWired}invokerFnBody+=(returns||isAsync?"var rv = ":"")+"invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";if(needsDestructorStack){invokerFnBody+="runDestructors(destructors);\n"}else{for(var i=isClassMethodFunc?1:2;i{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);invoker=embind__requireFunction(invokerSignature,invoker);whenDependentTypesAreResolved([],[rawClassType],function(classType){classType=classType[0];var humanName=`constructor ${classType.name}`;if(undefined===classType.registeredClass.constructor_body){classType.registeredClass.constructor_body=[]}if(undefined!==classType.registeredClass.constructor_body[argCount-1]){throw new BindingError(`Cannot register multiple constructors with identical number of parameters (${argCount-1}) for class '${classType.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`)}classType.registeredClass.constructor_body[argCount-1]=()=>{throwUnboundTypeError(`Cannot construct ${classType.name} due to unbound types`,rawArgTypes)};whenDependentTypesAreResolved([],rawArgTypes,argTypes=>{argTypes.splice(1,0,null);classType.registeredClass.constructor_body[argCount-1]=craftInvokerFunction(humanName,argTypes,null,invoker,rawConstructor);return[]});return[]})};var __embind_register_class_function=(rawClassType,methodName,argCount,rawArgTypesAddr,invokerSignature,rawInvoker,context,isPureVirtual,isAsync)=>{var rawArgTypes=heap32VectorToArray(argCount,rawArgTypesAddr);methodName=readLatin1String(methodName);rawInvoker=embind__requireFunction(invokerSignature,rawInvoker);whenDependentTypesAreResolved([],[rawClassType],function(classType){classType=classType[0];var humanName=`${classType.name}.${methodName}`;if(methodName.startsWith("@@")){methodName=Symbol[methodName.substring(2)]}if(isPureVirtual){classType.registeredClass.pureVirtualFunctions.push(methodName)}function unboundTypesHandler(){throwUnboundTypeError(`Cannot call ${humanName} due to unbound types`,rawArgTypes)}var proto=classType.registeredClass.instancePrototype;var method=proto[methodName];if(undefined===method||undefined===method.overloadTable&&method.className!==classType.name&&method.argCount===argCount-2){unboundTypesHandler.argCount=argCount-2;unboundTypesHandler.className=classType.name;proto[methodName]=unboundTypesHandler}else{ensureOverloadTable(proto,methodName,humanName);proto[methodName].overloadTable[argCount-2]=unboundTypesHandler}whenDependentTypesAreResolved([],rawArgTypes,function(argTypes){var memberFunction=craftInvokerFunction(humanName,argTypes,classType,rawInvoker,context,isAsync);if(undefined===proto[methodName].overloadTable){memberFunction.argCount=argCount-2;proto[methodName]=memberFunction}else{proto[methodName].overloadTable[argCount-2]=memberFunction}return[]});return[]})};var __embind_register_constant=(name,type,value)=>{name=readLatin1String(name);whenDependentTypesAreResolved([],[type],function(type){type=type[0];Module[name]=type["fromWireType"](value);return[]})};function handleAllocatorInit(){Object.assign(HandleAllocator.prototype,{get(id){return this.allocated[id]},has(id){return this.allocated[id]!==undefined},allocate(handle){var id=this.freelist.pop()||this.allocated.length;this.allocated[id]=handle;return id},free(id){this.allocated[id]=undefined;this.freelist.push(id)}})}function HandleAllocator(){this.allocated=[undefined];this.freelist=[]}var emval_handles=new HandleAllocator;var __emval_decref=handle=>{if(handle>=emval_handles.reserved&&0===--emval_handles.get(handle).refcount){emval_handles.free(handle)}};var count_emval_handles=()=>{var count=0;for(var i=emval_handles.reserved;i{emval_handles.allocated.push({value:undefined},{value:null},{value:true},{value:false});emval_handles.reserved=emval_handles.allocated.length;Module["count_emval_handles"]=count_emval_handles};var Emval={toValue:handle=>{if(!handle){throwBindingError("Cannot use deleted val. handle = "+handle)}return emval_handles.get(handle).value},toHandle:value=>{switch(value){case undefined:return 1;case null:return 2;case true:return 3;case false:return 4;default:{return emval_handles.allocate({refcount:1,value:value})}}}};var __embind_register_emval=(rawType,name)=>{name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":handle=>{var rv=Emval.toValue(handle);__emval_decref(handle);return rv},"toWireType":(destructors,value)=>Emval.toHandle(value),"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":simpleReadValueFromPointer,destructorFunction:null})};var enumReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?function(pointer){return this["fromWireType"](HEAP8[pointer>>0])}:function(pointer){return this["fromWireType"](HEAPU8[pointer>>0])};case 2:return signed?function(pointer){return this["fromWireType"](HEAP16[pointer>>1])}:function(pointer){return this["fromWireType"](HEAPU16[pointer>>1])};case 4:return signed?function(pointer){return this["fromWireType"](HEAP32[pointer>>2])}:function(pointer){return this["fromWireType"](HEAPU32[pointer>>2])};default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_enum=(rawType,name,size,isSigned)=>{name=readLatin1String(name);function ctor(){}ctor.values={};registerType(rawType,{name:name,constructor:ctor,"fromWireType":function(c){return this.constructor.values[c]},"toWireType":(destructors,c)=>c.value,"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":enumReadValueFromPointer(name,size,isSigned),destructorFunction:null});exposePublicSymbol(name,ctor)};var requireRegisteredType=(rawType,humanName)=>{var impl=registeredTypes[rawType];if(undefined===impl){throwBindingError(humanName+" has unknown type "+getTypeName(rawType))}return impl};var __embind_register_enum_value=(rawEnumType,name,enumValue)=>{var enumType=requireRegisteredType(rawEnumType,"enum");name=readLatin1String(name);var Enum=enumType.constructor;var Value=Object.create(enumType.constructor.prototype,{value:{value:enumValue},constructor:{value:createNamedFunction(`${enumType.name}_${name}`,function(){})}});Enum.values[enumValue]=Value;Enum[name]=Value};var embindRepr=v=>{if(v===null){return"null"}var t=typeof v;if(t==="object"||t==="array"||t==="function"){return v.toString()}else{return""+v}};var floatReadValueFromPointer=(name,width)=>{switch(width){case 4:return function(pointer){return this["fromWireType"](HEAPF32[pointer>>2])};case 8:return function(pointer){return this["fromWireType"](HEAPF64[pointer>>3])};default:throw new TypeError(`invalid float width (${width}): ${name}`)}};var __embind_register_float=(rawType,name,size)=>{name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":value=>value,"toWireType":(destructors,value)=>value,"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":floatReadValueFromPointer(name,size),destructorFunction:null})};var __embind_register_function=(name,argCount,rawArgTypesAddr,signature,rawInvoker,fn,isAsync)=>{var argTypes=heap32VectorToArray(argCount,rawArgTypesAddr);name=readLatin1String(name);rawInvoker=embind__requireFunction(signature,rawInvoker);exposePublicSymbol(name,function(){throwUnboundTypeError(`Cannot call ${name} due to unbound types`,argTypes)},argCount-1);whenDependentTypesAreResolved([],argTypes,function(argTypes){var invokerArgsArray=[argTypes[0],null].concat(argTypes.slice(1));replacePublicSymbol(name,craftInvokerFunction(name,invokerArgsArray,null,rawInvoker,fn,isAsync),argCount-1);return[]})};var integerReadValueFromPointer=(name,width,signed)=>{switch(width){case 1:return signed?pointer=>HEAP8[pointer>>0]:pointer=>HEAPU8[pointer>>0];case 2:return signed?pointer=>HEAP16[pointer>>1]:pointer=>HEAPU16[pointer>>1];case 4:return signed?pointer=>HEAP32[pointer>>2]:pointer=>HEAPU32[pointer>>2];default:throw new TypeError(`invalid integer width (${width}): ${name}`)}};var __embind_register_integer=(primitiveType,name,size,minRange,maxRange)=>{name=readLatin1String(name);if(maxRange===-1){maxRange=4294967295}var fromWireType=value=>value;if(minRange===0){var bitshift=32-8*size;fromWireType=value=>value<>>bitshift}var isUnsignedType=name.includes("unsigned");var checkAssertions=(value,toTypeName)=>{};var toWireType;if(isUnsignedType){toWireType=function(destructors,value){checkAssertions(value,this.name);return value>>>0}}else{toWireType=function(destructors,value){checkAssertions(value,this.name);return value}}registerType(primitiveType,{name:name,"fromWireType":fromWireType,"toWireType":toWireType,"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":integerReadValueFromPointer(name,size,minRange!==0),destructorFunction:null})};var __embind_register_memory_view=(rawType,dataTypeIndex,name)=>{var typeMapping=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];var TA=typeMapping[dataTypeIndex];function decodeMemoryView(handle){var size=HEAPU32[handle>>2];var data=HEAPU32[handle+4>>2];return new TA(HEAP8.buffer,data,size)}name=readLatin1String(name);registerType(rawType,{name:name,"fromWireType":decodeMemoryView,"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":decodeMemoryView},{ignoreDuplicateRegistrations:true})};var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx};var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var lengthBytesUTF8=str=>{var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i}else{len+=3}}return len};var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;var UTF8ArrayToString=(heapOrArray,idx,maxBytesToRead)=>{var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):"";var __embind_register_std_string=(rawType,name)=>{name=readLatin1String(name);var stdStringIsUTF8=name==="std::string";registerType(rawType,{name:name,"fromWireType"(value){var length=HEAPU32[value>>2];var payload=value+4;var str;if(stdStringIsUTF8){var decodeStartPtr=payload;for(var i=0;i<=length;++i){var currentBytePtr=payload+i;if(i==length||HEAPU8[currentBytePtr]==0){var maxRead=currentBytePtr-decodeStartPtr;var stringSegment=UTF8ToString(decodeStartPtr,maxRead);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+1}}}else{var a=new Array(length);for(var i=0;i>2]=length;if(stdStringIsUTF8&&valueIsOfTypeString){stringToUTF8(value,ptr,length+1)}else{if(valueIsOfTypeString){for(var i=0;i255){_free(ptr);throwBindingError("String has UTF-16 code units that do not fit in 8 bits")}HEAPU8[ptr+i]=charCode}}else{for(var i=0;i{var endPtr=ptr;var idx=endPtr>>1;var maxIdx=idx+maxBytesToRead/2;while(!(idx>=maxIdx)&&HEAPU16[idx])++idx;endPtr=idx<<1;if(endPtr-ptr>32&&UTF16Decoder)return UTF16Decoder.decode(HEAPU8.subarray(ptr,endPtr));var str="";for(var i=0;!(i>=maxBytesToRead/2);++i){var codeUnit=HEAP16[ptr+i*2>>1];if(codeUnit==0)break;str+=String.fromCharCode(codeUnit)}return str};var stringToUTF16=(str,outPtr,maxBytesToWrite)=>{if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr};var lengthBytesUTF16=str=>str.length*2;var UTF32ToString=(ptr,maxBytesToRead)=>{var i=0;var str="";while(!(i>=maxBytesToRead/4)){var utf32=HEAP32[ptr+i*4>>2];if(utf32==0)break;++i;if(utf32>=65536){var ch=utf32-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}else{str+=String.fromCharCode(utf32)}}return str};var stringToUTF32=(str,outPtr,maxBytesToWrite)=>{if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i=55296&&codeUnit<=57343){var trailSurrogate=str.charCodeAt(++i);codeUnit=65536+((codeUnit&1023)<<10)|trailSurrogate&1023}HEAP32[outPtr>>2]=codeUnit;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=0;return outPtr-startPtr};var lengthBytesUTF32=str=>{var len=0;for(var i=0;i=55296&&codeUnit<=57343)++i;len+=4}return len};var __embind_register_std_wstring=(rawType,charSize,name)=>{name=readLatin1String(name);var decodeString,encodeString,getHeap,lengthBytesUTF,shift;if(charSize===2){decodeString=UTF16ToString;encodeString=stringToUTF16;lengthBytesUTF=lengthBytesUTF16;getHeap=()=>HEAPU16;shift=1}else if(charSize===4){decodeString=UTF32ToString;encodeString=stringToUTF32;lengthBytesUTF=lengthBytesUTF32;getHeap=()=>HEAPU32;shift=2}registerType(rawType,{name:name,"fromWireType":value=>{var length=HEAPU32[value>>2];var HEAP=getHeap();var str;var decodeStartPtr=value+4;for(var i=0;i<=length;++i){var currentBytePtr=value+4+i*charSize;if(i==length||HEAP[currentBytePtr>>shift]==0){var maxReadBytes=currentBytePtr-decodeStartPtr;var stringSegment=decodeString(decodeStartPtr,maxReadBytes);if(str===undefined){str=stringSegment}else{str+=String.fromCharCode(0);str+=stringSegment}decodeStartPtr=currentBytePtr+charSize}}_free(value);return str},"toWireType":(destructors,value)=>{if(!(typeof value=="string")){throwBindingError(`Cannot pass non-string to C++ string type ${name}`)}var length=lengthBytesUTF(value);var ptr=_malloc(4+length+charSize);HEAPU32[ptr>>2]=length>>shift;encodeString(value,ptr+4,length+charSize);if(destructors!==null){destructors.push(_free,ptr)}return ptr},"argPackAdvance":GenericWireTypeSize,"readValueFromPointer":simpleReadValueFromPointer,destructorFunction(ptr){_free(ptr)}})};var __embind_register_value_object=(rawType,name,constructorSignature,rawConstructor,destructorSignature,rawDestructor)=>{structRegistrations[rawType]={name:readLatin1String(name),rawConstructor:embind__requireFunction(constructorSignature,rawConstructor),rawDestructor:embind__requireFunction(destructorSignature,rawDestructor),fields:[]}};var __embind_register_value_object_field=(structType,fieldName,getterReturnType,getterSignature,getter,getterContext,setterArgumentType,setterSignature,setter,setterContext)=>{structRegistrations[structType].fields.push({fieldName:readLatin1String(fieldName),getterReturnType:getterReturnType,getter:embind__requireFunction(getterSignature,getter),getterContext:getterContext,setterArgumentType:setterArgumentType,setter:embind__requireFunction(setterSignature,setter),setterContext:setterContext})};var __embind_register_void=(rawType,name)=>{name=readLatin1String(name);registerType(rawType,{isVoid:true,name:name,"argPackAdvance":0,"fromWireType":()=>undefined,"toWireType":(destructors,o)=>undefined})};var __emval_as=(handle,returnType,destructorsRef)=>{handle=Emval.toValue(handle);returnType=requireRegisteredType(returnType,"emval::as");var destructors=[];var rd=Emval.toHandle(destructors);HEAPU32[destructorsRef>>2]=rd;return returnType["toWireType"](destructors,handle)};var emval_symbols={};var getStringOrSymbol=address=>{var symbol=emval_symbols[address];if(symbol===undefined){return readLatin1String(address)}return symbol};var emval_methodCallers=[];var __emval_call_void_method=(caller,handle,methodName,args)=>{caller=emval_methodCallers[caller];handle=Emval.toValue(handle);methodName=getStringOrSymbol(methodName);caller(handle,methodName,null,args)};var emval_get_global=()=>{if(typeof globalThis=="object"){return globalThis}return function(){return Function}()("return this")()};var __emval_get_global=name=>{if(name===0){return Emval.toHandle(emval_get_global())}else{name=getStringOrSymbol(name);return Emval.toHandle(emval_get_global()[name])}};var emval_addMethodCaller=caller=>{var id=emval_methodCallers.length;emval_methodCallers.push(caller);return id};var emval_lookupTypes=(argCount,argTypes)=>{var a=new Array(argCount);for(var i=0;i>2],"parameter "+i)}return a};var emval_registeredMethods={};var __emval_get_method_caller=(argCount,argTypes)=>{var types=emval_lookupTypes(argCount,argTypes);var retType=types[0];var signatureName=retType.name+"_$"+types.slice(1).map(function(t){return t.name}).join("_")+"$";var returnId=emval_registeredMethods[signatureName];if(returnId!==undefined){return returnId}var params=["retType"];var args=[retType];var argsList="";for(var i=0;i{name=getStringOrSymbol(name);return Emval.toHandle(Module[name])};var __emval_get_property=(handle,key)=>{handle=Emval.toValue(handle);key=Emval.toValue(key);return Emval.toHandle(handle[key])};var __emval_incref=handle=>{if(handle>4){emval_handles.get(handle).refcount+=1}};var craftEmvalAllocator=argCount=>{var argsList="";for(var i=0;iHEAPU32;var functionBody="return function emval_allocator_"+argCount+"(constructor, argTypes, args) {\n"+" var HEAPU32 = getMemory();\n";for(var i=0;i>2)], 'parameter "+i+"');\n"+"var arg"+i+" = argType"+i+".readValueFromPointer(args);\n"+"args += argType"+i+"['argPackAdvance'];\n"+"argTypes += 4;\n"}functionBody+="var obj = new constructor("+argsList+");\n"+"return valueToHandle(obj);\n"+"}\n";return new Function("requireRegisteredType","Module","valueToHandle","getMemory",functionBody)(requireRegisteredType,Module,Emval.toHandle,getMemory)};var emval_newers={};var __emval_new=(handle,argCount,argTypes,args)=>{handle=Emval.toValue(handle);var newer=emval_newers[argCount];if(!newer){newer=craftEmvalAllocator(argCount);emval_newers[argCount]=newer}return newer(handle,argTypes,args)};var __emval_new_cstring=v=>Emval.toHandle(getStringOrSymbol(v));var __emval_run_destructors=handle=>{var destructors=Emval.toValue(handle);runDestructors(destructors);__emval_decref(handle)};var _abort=()=>{abort("")};var _emscripten_memcpy_js=(dest,src,num)=>HEAPU8.copyWithin(dest,src,src+num);var getHeapMax=()=>2147483648;var growMemory=size=>{var b=wasmMemory.buffer;var pages=(size-b.byteLength+65535)/65536;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}var alignUp=(x,multiple)=>x+(multiple-x%multiple)%multiple;for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignUp(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var SYSCALLS={varargs:undefined,get(){var ret=HEAP32[+SYSCALLS.varargs>>2];SYSCALLS.varargs+=4;return ret},getp(){return SYSCALLS.get()},getStr(ptr){var ret=UTF8ToString(ptr);return ret}};var _fd_close=fd=>52;var convertI32PairToI53Checked=(lo,hi)=>hi+2097152>>>0<4194305-!!lo?(lo>>>0)+hi*4294967296:NaN;function _fd_seek(fd,offset_low,offset_high,whence,newOffset){var offset=convertI32PairToI53Checked(offset_low,offset_high);return 70}var printCharBuffers=[null,[],[]];var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0}else{buffer.push(curr)}};var _fd_write=(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j>2]=num;return 0};InternalError=Module["InternalError"]=class InternalError extends Error{constructor(message){super(message);this.name="InternalError"}};embind_init_charCodes();BindingError=Module["BindingError"]=class BindingError extends Error{constructor(message){super(message);this.name="BindingError"}};init_ClassHandle();init_embind();init_RegisteredPointer();UnboundTypeError=Module["UnboundTypeError"]=extendError(Error,"UnboundTypeError");handleAllocatorInit();init_emval();var wasmImports={K:___cxa_throw,s:__embind_finalize_value_object,D:__embind_register_bigint,I:__embind_register_bool,x:__embind_register_class,w:__embind_register_class_constructor,d:__embind_register_class_function,k:__embind_register_constant,H:__embind_register_emval,n:__embind_register_enum,a:__embind_register_enum_value,B:__embind_register_float,i:__embind_register_function,j:__embind_register_integer,e:__embind_register_memory_view,A:__embind_register_std_string,v:__embind_register_std_wstring,t:__embind_register_value_object,c:__embind_register_value_object_field,J:__embind_register_void,m:__emval_as,r:__emval_call_void_method,b:__emval_decref,y:__emval_get_global,o:__emval_get_method_caller,q:__emval_get_module_property,f:__emval_get_property,h:__emval_incref,p:__emval_new,g:__emval_new_cstring,l:__emval_run_destructors,u:_abort,G:_emscripten_memcpy_js,E:_emscripten_resize_heap,F:_fd_close,C:_fd_seek,z:_fd_write};var wasmExports=createWasm();var ___wasm_call_ctors=()=>(___wasm_call_ctors=wasmExports["M"])();var _malloc=a0=>(_malloc=wasmExports["N"])(a0);var _free=a0=>(_free=wasmExports["O"])(a0);var ___getTypeName=a0=>(___getTypeName=wasmExports["Q"])(a0);var __embind_initialize_bindings=Module["__embind_initialize_bindings"]=()=>(__embind_initialize_bindings=Module["__embind_initialize_bindings"]=wasmExports["R"])();var ___errno_location=()=>(___errno_location=wasmExports["__errno_location"])();var ___cxa_is_pointer_type=a0=>(___cxa_is_pointer_type=wasmExports["S"])(a0);var dynCall_jiji=Module["dynCall_jiji"]=(a0,a1,a2,a3,a4)=>(dynCall_jiji=Module["dynCall_jiji"]=wasmExports["T"])(a0,a1,a2,a3,a4);var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller};function run(){if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("")},1);doRun()},1)}else{doRun()}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}run(); + + + return moduleArg.ready +} + +); +})(); +if (typeof exports === 'object' && typeof module === 'object') + module.exports = BASIS; +else if (typeof define === 'function' && define['amd']) + define([], () => BASIS); diff --git a/GemQuest/index.html b/GemQuest/index.html new file mode 100644 index 0000000..8afb060 --- /dev/null +++ b/GemQuest/index.html @@ -0,0 +1,18 @@ + + + + + + + + + GemQuest + + + + + + + + + diff --git a/OneTwoThree/logo.png b/GemQuest/logo.png similarity index 100% rename from OneTwoThree/logo.png rename to GemQuest/logo.png diff --git a/GemQuest/manifest.json b/GemQuest/manifest.json new file mode 100644 index 0000000..feef44e --- /dev/null +++ b/GemQuest/manifest.json @@ -0,0 +1 @@ +{"short_name":"GemQuest","name":"GemQuest","start_url":"","display":"fullscreen","icons":[{"src":"thumbs/180.jpg","sizes":"180x180","type":"image/jpeg"},{"src":"thumbs/360.jpg","sizes":"360x360","type":"image/jpeg"},{"src":"thumbs/540.jpg","sizes":"540x540","type":"image/jpeg"},{"src":"thumbs/720.jpg","sizes":"720x720","type":"image/jpeg"}]} \ No newline at end of file diff --git a/GemQuest/playcanvas-stable.min.js b/GemQuest/playcanvas-stable.min.js new file mode 100644 index 0000000..5c13d0f --- /dev/null +++ b/GemQuest/playcanvas-stable.min.js @@ -0,0 +1,9 @@ +/** + * @license + * PlayCanvas Engine v1.76.3 revision f5d22d7 (RELEASE) + * Copyright 2011-2025 PlayCanvas Ltd. All rights reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).pc={})}(this,(function(t){var e="undefined"!=typeof document?document.currentScript:null;function i(t,e,i){t.prototype[e]||Object.defineProperty(t.prototype,e,{value:i,configurable:!0,enumerable:!1,writable:!0})}i(Array,"fill",(function(t){if(null==this)throw new TypeError("this is null or not defined");for(var e=Object(this),i=e.length>>>0,n=arguments[1]|0,s=n<0?Math.max(i+n,0):Math.min(n,i),r=arguments[2],a=void 0===r?i:r|0,o=a<0?Math.max(i+a,0):Math.min(a,i);s>>0;if("function"!=typeof t)throw TypeError("predicate must be a function");for(var n=arguments[1],s=0;s>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],s=0;s0)-(t<0)||+t}),void 0===Number.isFinite&&(Number.isFinite=function(t){return"number"==typeof t&&isFinite(t)}),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),n=1;nthis.length)&&(e=this.length),this.substring(e-t.length,e)===t})),i(String,"includes",(function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)})),i(String,"startsWith",(function(t,e){var i=e>0?0|e:0;return this.substring(i,i+t.length)===t})),i(String,"trimEnd",(function(){return this.replace(new RegExp(/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/.source+"$","g"),"")}));for(var n=0,s=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array];nt.length)&&(e=t.length);for(var i=0,n=Array(e);i=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function y(){return y=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0;--r){var a=this.tryEntries[r],o=a.completion;if("root"===a.tryLoc)return s("end");if(a.tryLoc<=this.prev){var h=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(h&&l){if(this.prev=0;--i){var s=this.tryEntries[i];if(s.tryLoc<=this.prev&&n.call(s,"finallyLoc")&&this.prev=0;--e){var i=this.tryEntries[e];if(i.finallyLoc===t)return this.complete(i.completion,i.afterLoc),R(i),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var i=this.tryEntries[e];if(i.tryLoc===t){var n=i.completion;if("throw"===n.type){var s=n.arg;R(i)}return s}}throw Error("illegal catch attempt")},delegateYield:function(e,i,n){return this.delegate={iterator:D(e),resultName:i,nextLoc:n},"next"===this.method&&(this.arg=t),_}},e}function b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}function T(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}var w=function(){function t(){}return t.set=function(t,e){},t.get=function(e){return t._traceChannels.has(e)},t}();w._traceChannels=new Set,w.stack=!1;var E,A,C,M=function(){function t(t,e,i,n,s){void 0===s&&(s=!1),this.handler=void 0,this.name=void 0,this.callback=void 0,this.scope=void 0,this._once=void 0,this._removed=!1,this.handler=t,this.name=e,this.callback=i,this.scope=n,this._once=s}var e=t.prototype;return e.off=function(){this._removed||this.handler.offByHandle(this)},e.on=function(t,e,i){return void 0===i&&(i=this),this.handler._addCallback(t,e,i,!1)},e.once=function(t,e,i){return void 0===i&&(i=this),this.handler._addCallback(t,e,i,!0)},v(t,[{key:"removed",get:function(){return this._removed},set:function(t){t&&(this._removed=!0)}}])}(),P=function(){function t(){this._callbacks=new Map,this._callbackActive=new Map}var e=t.prototype;return e.initEventHandler=function(){this._callbacks=new Map,this._callbackActive=new Map},e._addCallback=function(t,e,i,n){if(this._callbacks.has(t)||this._callbacks.set(t,[]),this._callbackActive.has(t)){var s=this._callbackActive.get(t);s&&s===this._callbacks.get(t)&&this._callbackActive.set(t,s.slice())}var r=new M(this,t,e,i,n);return this._callbacks.get(t).push(r),r},e.on=function(t,e,i){return void 0===i&&(i=this),this._addCallback(t,e,i,!1)},e.once=function(t,e,i){return void 0===i&&(i=this),this._addCallback(t,e,i,!0)},e.off=function(t,e,i){if(t)this._callbackActive.has(t)&&this._callbackActive.get(t)===this._callbacks.get(t)&&this._callbackActive.set(t,this._callbackActive.get(t).slice());else for(var n,s=g(this._callbackActive);!(n=s()).done;){var r=n.value,a=r[0],o=r[1];this._callbacks.has(a)&&(this._callbacks.get(a)===o&&this._callbackActive.set(a,o.slice()))}if(t)if(e){var h=this._callbacks.get(t);if(!h)return this;for(var l=0;l0?r=r.slice(0,r.length-2):(a>0&&r.push(D.delimiter),r.push(n[a])));return s=r.join(""),e||s[0]!==D.delimiter||(s=s.slice(1)),i&&s[s.length-1]!==D.delimiter&&(s+=D.delimiter),s},split:function(t){var e=t.lastIndexOf(D.delimiter);return-1!==e?[t.substring(0,e),t.substring(e+1)]:["",t]},getBasename:function(t){return D.split(t)[1]},getDirectory:function(t){return D.split(t)[0]},getExtension:function(t){var e=t.split("?")[0].split(".").pop();return e!==t?"."+e:""},isRelativePath:function(t){return"/"!==t.charAt(0)&&null===t.match(/:\/\//)},extractPath:function(t){var e="",i=t.split("/"),n=0;if(i.length>1)if(D.isRelativePath(t))if("."===i[0])for(n=0;n0),U=!("browser"!==k||!navigator.getGamepads&&!navigator.webkitGetGamepads),z="undefined"!=typeof Worker,V=function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){return t=!0,!1}});window.addEventListener("testpassive",null,e),window.removeEventListener("testpassive",null,e)}catch(t){}return t}(),G={name:O,environment:k,global:null!=(E=null!=(A=null!=(C="undefined"!=typeof globalThis&&globalThis)?C:"browser"===k&&window)?A:"node"===k&&global)?E:"worker"===k&&self,browser:"browser"===k,worker:"worker"===k,desktop:["windows","osx","linux","cros"].includes(O),mobile:["android","ios"].includes(O),ios:"ios"===O,android:"android"===O,xbox:B,gamepads:U,touch:N,workers:z,passiveEvents:V,browserName:F},H="abcdefghijklmnopqrstuvwxyz",W="ABCDEFGHIJKLMNOPQRSTUVWXYZ",X=55296,j=127462,q=127487,Y=65024,K=65039;function Z(t,e){void 0===e&&(e=0);var i=t.length;if(e<0||e>=i)return null;var n=t.charCodeAt(e);if(i>1&&n>=X&&n<=56319){var s=t.charCodeAt(e+1);if(s>=56320&&s<=57343)return{code:1024*(n-X)+s-56320+65536,long:!0}}return{code:n,long:!1}}function Q(t,e,i){if(!t)return!1;var n=Z(t);if(n){var s=n.code;return s>=e&&s<=i}return!1}function J(t,e){if(e===t.length-1)return 1;if(Q(t[e],X,56319)){var i=t.substring(e,e+2),n=t.substring(e+2,e+4);return Q(n,127995,127999)||Q(i,j,q)&&Q(n,j,q)?4:Q(n,Y,K)?3:2}return Q(t[e+1],Y,K)?2:1}var $,tt,et,it={ASCII_LOWERCASE:H,ASCII_UPPERCASE:W,ASCII_LETTERS:H+W,format:function(t){for(var e=0;e<(arguments.length<=1?0:arguments.length-1);e++)t=t.replace("{"+e+"}",e+1<1||arguments.length<=e+1?void 0:arguments[e+1]);return t},getCodePoint:function(t,e){var i=Z(t,e);return i&&i.code},getCodePoints:function(t){if("string"!=typeof t)throw new TypeError("Not a string");for(var e,i=0,n=[];e=Z(t,i);)n.push(e.code),i+=e.long?2:1;return n},getSymbols:function(t){if("string"!=typeof t)throw new TypeError("Not a string");for(var e,i=0,n=t.length,s=[],r=0;i65535?[55296+(e>>10),e%1024+56320]:[t],n.push(String.fromCharCode.apply(null,i));return n.join("")}},nt=function(){function t(){this._list=[],this._index={}}var e=t.prototype;return e.push=function(t,e){if(this._index[t])throw Error("Key already in index "+t);var i=this._list.push(e)-1;this._index[t]=i},e.has=function(t){return void 0!==this._index[t]},e.get=function(t){var e=this._index[t];return void 0!==e?this._list[e]:null},e.remove=function(t){var e=this._index[t];if(void 0!==e){for(t in this._list.splice(e,1),delete this._index[t],this._index){var i=this._index[t];i>e&&(this._index[t]=i-1)}return!0}return!1},e.list=function(){return this._list},e.clear=function(){for(var t in this._list.length=0,this._index)delete this._index[t]},t}(),st=function(){function t(){}return t.loadScript=function(t,e){var i=document.createElement("script");i.setAttribute("src",t),i.onload=function(){e(null)},i.onerror=function(){e("Failed to load script='"+t+"'")},document.body.appendChild(i)},t.loadWasm=function(e,i,n){var s=t.wasmSupported()&&i.glueUrl&&i.wasmUrl?i.glueUrl:i.fallbackUrl;s?t.loadScript(s,(function(t){if(t)n(t,null);else{var s=window[e];window[e]=void 0,s({locateFile:function(){return i.wasmUrl},onAbort:function(){n("wasm module aborted.")}}).then((function(t){n(null,t)}))}})):n("No supported wasm modules found.",null)},t.getModule=function(e){return t.modules.hasOwnProperty(e)||(t.modules[e]={config:null,initializing:!1,instance:null,callbacks:[]}),t.modules[e]},t.initialize=function(e,i){if(!i.initializing){var n=i.config;(n.glueUrl||n.wasmUrl||n.fallbackUrl)&&(i.initializing=!0,t.loadWasm(e,n,(function(t,s){t?n.errorHandler?n.errorHandler(t):console.error("failed to initialize module="+e+" error="+t):(i.instance=s,i.callbacks.forEach((function(t){t(s)})))})))}},t}();st.modules={},st.wasmSupported=($=function(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){var t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1},et=tt={},function(){return et===tt&&(et=$()),et});var rt=function(){function t(){}return t.setConfig=function(t,e){var i=st.getModule(t);i.config=e,i.callbacks.length>0&&st.initialize(t,i)},t.getConfig=function(t){var e;return null==(e=st.modules)||null==(e=e[t])?void 0:e.config},t.getInstance=function(t,e){var i=st.getModule(t);i.instance?e(i.instance):(i.callbacks.push(e),i.config&&st.initialize(t,i))},t}(),at=function(){function t(t){this.arraybuffer=void 0,this.dataView=void 0,this.offset=0,this.arraybuffer=t,this.dataView=new DataView(t)}var e=t.prototype;return e.reset=function(t){void 0===t&&(t=0),this.offset=t},e.skip=function(t){this.offset+=t},e.align=function(t){this.offset=this.offset+t-1&~(t-1)},e._inc=function(t){return this.offset+=t,this.offset-t},e.readChar=function(){return String.fromCharCode(this.dataView.getUint8(this.offset++))},e.readChars=function(t){for(var e="",i=0;i=t.byteLength);){var i=String.fromCharCode(this.readU8());if("\n"===i)break;e+=i}return e},v(t,[{key:"remainingBytes",get:function(){return this.dataView.byteLength-this.offset}}])}(),ot=function(){function t(t){this.items=[],this.length=0,this.loopIndex=-1,this._sortBy=void 0,this._sortHandler=void 0,this._sortBy=t.sortBy,this._sortHandler=this._doSort.bind(this)}var e=t.prototype;return e._binarySearch=function(t){for(var e,i,n=0,s=this.items.length-1,r=t[this._sortBy];n<=s;)e=Math.floor((n+s)/2),(i=this.items[e][this._sortBy])<=r?n=e+1:i>r&&(s=e-1);return n},e._doSort=function(t,e){var i=this._sortBy;return t[i]-e[i]},e.insert=function(t){var e=this._binarySearch(t);this.items.splice(e,0,t),this.length++,this.loopIndex>=e&&this.loopIndex++},e.append=function(t){this.items.push(t),this.length++},e.remove=function(t){var e=this.items.indexOf(t);e<0||(this.items.splice(e,1),this.length--,this.loopIndex>=e&&this.loopIndex--)},e.sort=function(){var t=this.loopIndex>=0?this.items[this.loopIndex]:null;this.items.sort(this._sortHandler),null!==t&&(this.loopIndex=this.items.indexOf(t))},t}(),ht=function(t){function e(e){var i;return(i=t.call(this)||this)._index={},i._list=[],i._parent=e,i}x(e,t);var i=e.prototype;return i.add=function(){for(var t=!1,e=arguments.length,i=new Array(e),n=0;n=i?i:t<=e?e:t},intToBytes24:function(t){return[t>>16&255,t>>8&255,255&t]},intToBytes32:function(t){return[t>>24&255,t>>16&255,t>>8&255,255&t]},bytesToInt24:function(t,e,i){return t.length&&(i=t[2],e=t[1],t=t[0]),t<<16|e<<8|i},bytesToInt32:function(t,e,i,n){return t.length&&(n=t[3],i=t[2],e=t[1],t=t[0]),(t<<24|e<<16|i<<8|n)>>>0},lerp:function(t,e,i){return t+(e-t)*ft.clamp(i,0,1)},lerpAngle:function(t,e,i){return e-t>180&&(e-=360),e-t<-180&&(e+=360),ft.lerp(t,e,ft.clamp(i,0,1))},powerOfTwo:function(t){return 0!==t&&!(t&t-1)},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.log(2)))},random:function(t,e){var i=e-t;return Math.random()*i+t},smoothstep:function(t,e,i){return i<=t?0:i>=e?1:(i=(i-t)/(e-t))*i*(3-2*i)},smootherstep:function(t,e,i){return i<=t?0:i>=e?1:(i=(i-t)/(e-t))*i*i*(i*(6*i-15)+10)},roundUp:function(t,e){return 0===e?t:Math.ceil(t/e)*e},between:function(t,e,i,n){var s=Math.min(e,i),r=Math.max(e,i);return n?t>=s&&t<=r:t>s&&t7?e=ft.intToBytes32(i):(e=ft.intToBytes24(i))[3]=255,this.set(e[0]/255,e[1]/255,e[2]/255,e[3]/255),this},e.toString=function(t){var e="#"+((1<<24)+(Math.round(255*this.r)<<16)+(Math.round(255*this.g)<<8)+Math.round(255*this.b)).toString(16).slice(1);if(!0===t){var i=Math.round(255*this.a).toString(16);this.a<16/255?e+="0"+i:e+=i}return e},t}();ct=pt,pt.BLACK=Object.freeze(new ct(0,0,0,1)),pt.BLUE=Object.freeze(new ct(0,0,1,1)),pt.CYAN=Object.freeze(new ct(0,1,1,1)),pt.GRAY=Object.freeze(new ct(.5,.5,.5,1)),pt.GREEN=Object.freeze(new ct(0,1,0,1)),pt.MAGENTA=Object.freeze(new ct(1,0,1,1)),pt.RED=Object.freeze(new ct(1,0,0,1)),pt.WHITE=Object.freeze(new ct(1,1,1,1)),pt.YELLOW=Object.freeze(new ct(1,1,0,1));var mt,_t,vt=function(){function t(t,e){void 0===e&&(e=0),this._curve=void 0,this._left=-1/0,this._right=1/0,this._recip=0,this._p0=0,this._p1=0,this._m0=0,this._m1=0,this._curve=t,this._reset(e)}var e=t.prototype;return e.evaluate=function(t,e){var i;void 0===e&&(e=!1),(e||t=this._right)&&this._reset(t);var n=this._curve.type;if(5===n)i=this._p0;else{var s=0===this._recip?0:(t-this._left)*this._recip;i=0===n?ft.lerp(this._p0,this._p1,s):1===n?ft.lerp(this._p0,this._p1,s*s*(3-2*s)):this._evaluateHermite(this._p0,this._p1,this._m0,this._m1,s)}return i},e._reset=function(t){var e=this._curve.keys,i=e.length;if(i)if(t=e[i-1][0])this._left=e[i-1][0],this._right=1/0,this._recip=0,this._p0=this._p1=e[i-1][1],this._m0=this._m1=0;else{for(var n=0;t>=e[n+1][0];)n++;this._left=e[n][0],this._right=e[n+1][0];var s=1/(this._right-this._left);this._recip=isFinite(s)?s:0,this._p0=e[n][1],this._p1=e[n+1][1],this._isHermite()&&this._calcTangents(e,n)}else this._left=-1/0,this._right=1/0,this._recip=0,this._p0=this._p1=this._m0=this._m1=0},e._isHermite=function(){return 2===this._curve.type||3===this._curve.type||4===this._curve.type},e._calcTangents=function(t,e){var i,n,s=t[e],r=t[e+1];if(i=0===e?[t[0][0]+(t[0][0]-t[1][0]),t[0][1]+(t[0][1]-t[1][1])]:t[e-1],n=e===t.length-2?[t[e+1][0]+(t[e+1][0]-t[e][0]),t[e+1][1]+(t[e+1][1]-t[e][1])]:t[e+2],4===this._curve.type){var a=2*(r[0]-s[0])/(r[0]-i[0]),o=2*(r[0]-s[0])/(n[0]-s[0]);this._m0=this._curve.tension*(isFinite(a)?a:0)*(r[1]-i[1]),this._m1=this._curve.tension*(isFinite(o)?o:0)*(n[1]-s[1])}else{var h=(r[0]-s[0])/(s[0]-i[0]),l=(r[0]-s[0])/(n[0]-r[0]),c=s[1]+(i[1]-s[1])*(isFinite(h)?h:0),u=r[1]+(n[1]-r[1])*(isFinite(l)?l:0),d=2===this._curve.type?.5:this._curve.tension;this._m0=d*(r[1]-c),this._m1=d*(u-s[1])}},e._evaluateHermite=function(t,e,i,n,s){var r=s*s,a=s+s,o=1-s,h=o*o;return t*((1+a)*h)+i*(s*h)+e*(r*(3-a))+n*(r*(s-1))},t}(),gt=function(){function t(t){if(this.keys=[],this.type=1,this.tension=.5,this._eval=new vt(this),t)for(var e=0;et);s++);var r=[t,e];return this.keys.splice(s,0,r),r},e.get=function(t){return this.keys[t]},e.sort=function(){this.keys.sort((function(t,e){return t[0]-e[0]}))},e.value=function(t){return this._eval.evaluate(t,!0)},e.closest=function(t){for(var e=this.keys,i=e.length,n=2,s=null,r=0;r=a))break;n=a,s=e[r]}return s},e.clone=function(){var t=new this.constructor;return t.keys=this.keys.map((function(t){return[].concat(t)})),t.type=this.type,t.tension=this.tension,t},e.quantize=function(t){t=Math.max(t,2);var e=new Float32Array(t),i=1/(t-1);e[0]=this._eval.evaluate(0,!0);for(var n=1;n1)for(var t=0;t>16&32768,n=e>>12&2047,s=e>>23&255;return s<103?i:s>142?(i|=31744,i|=(255===s?0:1)&&8388607&e):s<113?i|=((n|=2048)>>114-s)+(n>>113-s&1):(i|=s-112<<10|n>>1,i+=1&n)},t.float2Bytes=function(t,e,i,n){var s=255*t%1;if(e[i+0]=Math.round(255*(t%1-xt*s)),n>1){var r=65025*t%1;if(e[i+1]=Math.round(255*(s-xt*r)),n>2){var a=16581375*t%1;e[i+2]=Math.round(255*(r-xt*a)),n>3&&(e[i+3]=Math.round(255*a))}}},t.float2BytesRange=function(e,i,n,s,r,a){e=ft.clamp((e-s)/(r-s),0,1),t.float2Bytes(e,i,n,a)},t.float2MantissaExponent=function(e,i,n,s){var r=Math.floor(Math.log2(Math.abs(e)))+1;e/=Math.pow(2,r),t.float2BytesRange(e,i,n,-1,1,s-1),i[n+s-1]=Math.round(r+127)},t}(),wt=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=void 0,this.y=void 0,this.z=void 0,3===t.length?(this.x=t[0],this.y=t[1],this.z=t[2]):(this.x=t,this.y=e,this.z=i)}var e=t.prototype;return e.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},e.add2=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},e.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},e.addScaled=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},e.clone=function(){return new(0,this.constructor)(this.x,this.y,this.z)},e.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},e.cross=function(t,e){var i=t.x,n=t.y,s=t.z,r=e.x,a=e.y,o=e.z;return this.x=n*o-a*s,this.y=s*r-o*i,this.z=i*a-r*n,this},e.distance=function(t){var e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return Math.sqrt(e*e+i*i+n*n)},e.div=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},e.div2=function(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this.z=t.z/e.z,this},e.divScalar=function(t){return this.x/=t,this.y/=t,this.z/=t,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},e.equals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},e.equalsApprox=function(t,e){return void 0===e&&(e=1e-6),Math.abs(this.x-t.x)0){var i=1/Math.sqrt(e);this.x=t.x*i,this.y=t.y*i,this.z=t.z*i}return this},e.floor=function(t){return void 0===t&&(t=this),this.x=Math.floor(t.x),this.y=Math.floor(t.y),this.z=Math.floor(t.z),this},e.ceil=function(t){return void 0===t&&(t=this),this.x=Math.ceil(t.x),this.y=Math.ceil(t.y),this.z=Math.ceil(t.z),this},e.round=function(t){return void 0===t&&(t=this),this.x=Math.round(t.x),this.y=Math.round(t.y),this.z=Math.round(t.z),this},e.min=function(t){return t.xthis.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),this},e.project=function(t){var e=(this.x*t.x+this.y*t.y+this.z*t.z)/(t.x*t.x+t.y*t.y+t.z*t.z);return this.x=t.x*e,this.y=t.y*e,this.z=t.z*e,this},e.set=function(t,e,i){return this.x=t,this.y=e,this.z=i,this},e.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},e.sub2=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},e.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},e.toString=function(){return"["+this.x+", "+this.y+", "+this.z+"]"},t}();mt=wt,wt.ZERO=Object.freeze(new mt(0,0,0)),wt.ONE=Object.freeze(new mt(1,1,1)),wt.UP=Object.freeze(new mt(0,1,0)),wt.DOWN=Object.freeze(new mt(0,-1,0)),wt.RIGHT=Object.freeze(new mt(1,0,0)),wt.LEFT=Object.freeze(new mt(-1,0,0)),wt.FORWARD=Object.freeze(new mt(0,0,-1)),wt.BACK=Object.freeze(new mt(0,0,1));var Et,At=function(){function t(){this.data=new Float32Array(9),this.data[0]=this.data[4]=this.data[8]=1}var e=t.prototype;return e.clone=function(){return(new(0,this.constructor)).copy(this)},e.copy=function(t){var e=t.data,i=this.data;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],this},e.set=function(t){var e=this.data;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],this},e.getX=function(t){return void 0===t&&(t=new wt),t.set(this.data[0],this.data[1],this.data[2])},e.getY=function(t){return void 0===t&&(t=new wt),t.set(this.data[3],this.data[4],this.data[5])},e.getZ=function(t){return void 0===t&&(t=new wt),t.set(this.data[6],this.data[7],this.data[8])},e.equals=function(t){var e=this.data,i=t.data;return e[0]===i[0]&&e[1]===i[1]&&e[2]===i[2]&&e[3]===i[3]&&e[4]===i[4]&&e[5]===i[5]&&e[6]===i[6]&&e[7]===i[7]&&e[8]===i[8]},e.isIdentity=function(){var t=this.data;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&1===t[4]&&0===t[5]&&0===t[6]&&0===t[7]&&1===t[8]},e.setIdentity=function(){var t=this.data;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},e.toString=function(){return"["+this.data.join(", ")+"]"},e.transpose=function(t){void 0===t&&(t=this);var e,i=t.data,n=this.data;i===n?(e=i[1],n[1]=i[3],n[3]=e,e=i[2],n[2]=i[6],n[6]=e,e=i[5],n[5]=i[7],n[7]=e):(n[0]=i[0],n[1]=i[3],n[2]=i[6],n[3]=i[1],n[4]=i[4],n[5]=i[7],n[6]=i[2],n[7]=i[5],n[8]=i[8]);return this},e.setFromMat4=function(t){var e=t.data,i=this.data;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},e.setFromQuat=function(t){var e=t.x,i=t.y,n=t.z,s=t.w,r=e+e,a=i+i,o=n+n,h=e*r,l=e*a,c=e*o,u=i*a,d=i*o,f=n*o,p=s*r,m=s*a,_=s*o,v=this.data;return v[0]=1-(u+f),v[1]=l+_,v[2]=c-m,v[3]=l-_,v[4]=1-(h+f),v[5]=d+p,v[6]=c+m,v[7]=d-p,v[8]=1-(h+u),this},e.invertMat4=function(t){var e=t.data,i=e[0],n=e[1],s=e[2],r=e[4],a=e[5],o=e[6],h=e[8],l=e[9],c=e[10],u=c*a-o*l,d=-c*n+s*l,f=o*n-s*a,p=-c*r+o*h,m=c*i-s*h,_=-o*i+s*r,v=l*r-a*h,g=-l*i+n*h,y=a*i-n*r,x=i*u+n*p+s*v;if(0===x)this.setIdentity();else{var S=1/x,b=this.data;b[0]=u*S,b[1]=d*S,b[2]=f*S,b[3]=p*S,b[4]=m*S,b[5]=_*S,b[6]=v*S,b[7]=g*S,b[8]=y*S}return this},e.transformVector=function(t,e){void 0===e&&(e=new wt);var i=this.data,n=t.x,s=t.y,r=t.z;return e.x=n*i[0]+s*i[3]+r*i[6],e.y=n*i[1]+s*i[4]+r*i[7],e.z=n*i[2]+s*i[5]+r*i[8],e},t}();_t=At,At.IDENTITY=Object.freeze(new _t),At.ZERO=Object.freeze((new _t).set([0,0,0,0,0,0,0,0,0]));var Ct,Mt=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=void 0,this.y=void 0,2===t.length?(this.x=t[0],this.y=t[1]):(this.x=t,this.y=e)}var e=t.prototype;return e.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.add2=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},e.addScalar=function(t){return this.x+=t,this.y+=t,this},e.addScaled=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},e.clone=function(){return new(0,this.constructor)(this.x,this.y)},e.copy=function(t){return this.x=t.x,this.y=t.y,this},e.cross=function(t){return this.x*t.y-this.y*t.x},e.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},e.div=function(t){return this.x/=t.x,this.y/=t.y,this},e.div2=function(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this},e.divScalar=function(t){return this.x/=t,this.y/=t,this},e.dot=function(t){return this.x*t.x+this.y*t.y},e.equals=function(t){return this.x===t.x&&this.y===t.y},e.equalsApprox=function(t,e){return void 0===e&&(e=1e-6),Math.abs(this.x-t.x)0){var i=1/Math.sqrt(e);this.x=t.x*i,this.y=t.y*i}return this},e.rotate=function(t){var e=Math.atan2(this.x,this.y)+t*ft.DEG_TO_RAD,i=Math.sqrt(this.x*this.x+this.y*this.y);return this.x=Math.sin(e)*i,this.y=Math.cos(e)*i,this},e.angle=function(){return Math.atan2(this.x,this.y)*ft.RAD_TO_DEG},e.angleTo=function(t){return Math.atan2(this.x*t.y+this.y*t.x,this.x*t.x+this.y*t.y)*ft.RAD_TO_DEG},e.floor=function(t){return void 0===t&&(t=this),this.x=Math.floor(t.x),this.y=Math.floor(t.y),this},e.ceil=function(t){return void 0===t&&(t=this),this.x=Math.ceil(t.x),this.y=Math.ceil(t.y),this},e.round=function(t){return void 0===t&&(t=this),this.x=Math.round(t.x),this.y=Math.round(t.y),this},e.min=function(t){return t.xthis.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),this},e.set=function(t,e){return this.x=t,this.y=e,this},e.sub=function(t){return this.x-=t.x,this.y-=t.y,this},e.sub2=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},e.subScalar=function(t){return this.x-=t,this.y-=t,this},e.toString=function(){return"["+this.x+", "+this.y+"]"},t.angleRad=function(t,e){return Math.atan2(t.x*e.y-t.y*e.x,t.x*e.x+t.y*e.y)},t}();Et=Mt,Mt.ZERO=Object.freeze(new Et(0,0)),Mt.ONE=Object.freeze(new Et(1,1)),Mt.UP=Object.freeze(new Et(0,1)),Mt.DOWN=Object.freeze(new Et(0,-1)),Mt.RIGHT=Object.freeze(new Et(1,0)),Mt.LEFT=Object.freeze(new Et(-1,0));var Pt,Rt=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=void 0,this.y=void 0,this.z=void 0,this.w=void 0,4===t.length?(this.x=t[0],this.y=t[1],this.z=t[2],this.w=t[3]):(this.x=t,this.y=e,this.z=i,this.w=n)}var e=t.prototype;return e.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},e.add2=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},e.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},e.addScaled=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},e.clone=function(){return new(0,this.constructor)(this.x,this.y,this.z,this.w)},e.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},e.div=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this},e.div2=function(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this.z=t.z/e.z,this.w=t.w/e.w,this},e.divScalar=function(t){return this.x/=t,this.y/=t,this.z/=t,this.w/=t,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},e.equals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},e.equalsApprox=function(t,e){return void 0===e&&(e=1e-6),Math.abs(this.x-t.x)0){var i=1/Math.sqrt(e);this.x=t.x*i,this.y=t.y*i,this.z=t.z*i,this.w=t.w*i}return this},e.floor=function(t){return void 0===t&&(t=this),this.x=Math.floor(t.x),this.y=Math.floor(t.y),this.z=Math.floor(t.z),this.w=Math.floor(t.w),this},e.ceil=function(t){return void 0===t&&(t=this),this.x=Math.ceil(t.x),this.y=Math.ceil(t.y),this.z=Math.ceil(t.z),this.w=Math.ceil(t.w),this},e.round=function(t){return void 0===t&&(t=this),this.x=Math.round(t.x),this.y=Math.round(t.y),this.z=Math.round(t.z),this.w=Math.round(t.w),this},e.min=function(t){return t.xthis.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),t.w>this.w&&(this.w=t.w),this},e.set=function(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this},e.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},e.sub2=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},e.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},e.toString=function(){return"["+this.x+", "+this.y+", "+this.z+", "+this.w+"]"},t}();Ct=Rt,Rt.ZERO=Object.freeze(new Ct(0,0,0,0)),Rt.ONE=Object.freeze(new Ct(1,1,1,1));var It,Dt=new Mt,Lt=new wt,kt=new wt,Ot=new wt,Ft=new wt,Bt=function(){function t(){this.data=new Float32Array(16),this.data[0]=this.data[5]=this.data[10]=this.data[15]=1}t._getPerspectiveHalfSize=function(t,e,i,n,s){s?(t.x=n*Math.tan(e*Math.PI/360),t.y=t.x/i):(t.y=n*Math.tan(e*Math.PI/360),t.x=t.y*i)};var e=t.prototype;return e.add2=function(t,e){var i=t.data,n=e.data,s=this.data;return s[0]=i[0]+n[0],s[1]=i[1]+n[1],s[2]=i[2]+n[2],s[3]=i[3]+n[3],s[4]=i[4]+n[4],s[5]=i[5]+n[5],s[6]=i[6]+n[6],s[7]=i[7]+n[7],s[8]=i[8]+n[8],s[9]=i[9]+n[9],s[10]=i[10]+n[10],s[11]=i[11]+n[11],s[12]=i[12]+n[12],s[13]=i[13]+n[13],s[14]=i[14]+n[14],s[15]=i[15]+n[15],this},e.add=function(t){return this.add2(this,t)},e.clone=function(){return(new(0,this.constructor)).copy(this)},e.copy=function(t){var e=t.data,i=this.data;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],this},e.equals=function(t){var e=this.data,i=t.data;return e[0]===i[0]&&e[1]===i[1]&&e[2]===i[2]&&e[3]===i[3]&&e[4]===i[4]&&e[5]===i[5]&&e[6]===i[6]&&e[7]===i[7]&&e[8]===i[8]&&e[9]===i[9]&&e[10]===i[10]&&e[11]===i[11]&&e[12]===i[12]&&e[13]===i[13]&&e[14]===i[14]&&e[15]===i[15]},e.isIdentity=function(){var t=this.data;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&0===t[4]&&1===t[5]&&0===t[6]&&0===t[7]&&0===t[8]&&0===t[9]&&1===t[10]&&0===t[11]&&0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]},e.mul2=function(t,e){var i,n,s,r,a=t.data,o=e.data,h=this.data,l=a[0],c=a[1],u=a[2],d=a[3],f=a[4],p=a[5],m=a[6],_=a[7],v=a[8],g=a[9],y=a[10],x=a[11],S=a[12],b=a[13],T=a[14],w=a[15];return i=o[0],n=o[1],s=o[2],r=o[3],h[0]=l*i+f*n+v*s+S*r,h[1]=c*i+p*n+g*s+b*r,h[2]=u*i+m*n+y*s+T*r,h[3]=d*i+_*n+x*s+w*r,i=o[4],n=o[5],s=o[6],r=o[7],h[4]=l*i+f*n+v*s+S*r,h[5]=c*i+p*n+g*s+b*r,h[6]=u*i+m*n+y*s+T*r,h[7]=d*i+_*n+x*s+w*r,i=o[8],n=o[9],s=o[10],r=o[11],h[8]=l*i+f*n+v*s+S*r,h[9]=c*i+p*n+g*s+b*r,h[10]=u*i+m*n+y*s+T*r,h[11]=d*i+_*n+x*s+w*r,i=o[12],n=o[13],s=o[14],r=o[15],h[12]=l*i+f*n+v*s+S*r,h[13]=c*i+p*n+g*s+b*r,h[14]=u*i+m*n+y*s+T*r,h[15]=d*i+_*n+x*s+w*r,this},e.mulAffine2=function(t,e){var i,n,s,r=t.data,a=e.data,o=this.data,h=r[0],l=r[1],c=r[2],u=r[4],d=r[5],f=r[6],p=r[8],m=r[9],_=r[10],v=r[12],g=r[13],y=r[14];return i=a[0],n=a[1],s=a[2],o[0]=h*i+u*n+p*s,o[1]=l*i+d*n+m*s,o[2]=c*i+f*n+_*s,o[3]=0,i=a[4],n=a[5],s=a[6],o[4]=h*i+u*n+p*s,o[5]=l*i+d*n+m*s,o[6]=c*i+f*n+_*s,o[7]=0,i=a[8],n=a[9],s=a[10],o[8]=h*i+u*n+p*s,o[9]=l*i+d*n+m*s,o[10]=c*i+f*n+_*s,o[11]=0,i=a[12],n=a[13],s=a[14],o[12]=h*i+u*n+p*s+v,o[13]=l*i+d*n+m*s+g,o[14]=c*i+f*n+_*s+y,o[15]=1,this},e.mul=function(t){return this.mul2(this,t)},e.transformPoint=function(t,e){void 0===e&&(e=new wt);var i=this.data,n=t.x,s=t.y,r=t.z;return e.x=n*i[0]+s*i[4]+r*i[8]+i[12],e.y=n*i[1]+s*i[5]+r*i[9]+i[13],e.z=n*i[2]+s*i[6]+r*i[10]+i[14],e},e.transformVector=function(t,e){void 0===e&&(e=new wt);var i=this.data,n=t.x,s=t.y,r=t.z;return e.x=n*i[0]+s*i[4]+r*i[8],e.y=n*i[1]+s*i[5]+r*i[9],e.z=n*i[2]+s*i[6]+r*i[10],e},e.transformVec4=function(t,e){void 0===e&&(e=new Rt);var i=this.data,n=t.x,s=t.y,r=t.z,a=t.w;return e.x=n*i[0]+s*i[4]+r*i[8]+a*i[12],e.y=n*i[1]+s*i[5]+r*i[9]+a*i[13],e.z=n*i[2]+s*i[6]+r*i[10]+a*i[14],e.w=n*i[3]+s*i[7]+r*i[11]+a*i[15],e},e.setLookAt=function(t,e,i){Ot.sub2(t,e).normalize(),kt.copy(i).normalize(),Lt.cross(kt,Ot).normalize(),kt.cross(Ot,Lt);var n=this.data;return n[0]=Lt.x,n[1]=Lt.y,n[2]=Lt.z,n[3]=0,n[4]=kt.x,n[5]=kt.y,n[6]=kt.z,n[7]=0,n[8]=Ot.x,n[9]=Ot.y,n[10]=Ot.z,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this},e.setFrustum=function(t,e,i,n,s,r){var a=2*s,o=e-t,h=n-i,l=r-s,c=this.data;return c[0]=a/o,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=a/h,c[6]=0,c[7]=0,c[8]=(e+t)/o,c[9]=(n+i)/h,c[10]=(-r-s)/l,c[11]=-1,c[12]=0,c[13]=0,c[14]=-a*r/l,c[15]=0,this},e.setPerspective=function(e,i,n,s,r){return t._getPerspectiveHalfSize(Dt,e,i,n,r),this.setFrustum(-Dt.x,Dt.x,-Dt.y,Dt.y,n,s)},e.setOrtho=function(t,e,i,n,s,r){var a=this.data;return a[0]=2/(e-t),a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=2/(n-i),a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=-2/(r-s),a[11]=0,a[12]=-(e+t)/(e-t),a[13]=-(n+i)/(n-i),a[14]=-(r+s)/(r-s),a[15]=1,this},e.setFromAxisAngle=function(t,e){e*=ft.DEG_TO_RAD;var i=t.x,n=t.y,s=t.z,r=Math.cos(e),a=Math.sin(e),o=1-r,h=o*i,l=o*n,c=this.data;return c[0]=h*i+r,c[1]=h*n+a*s,c[2]=h*s-a*n,c[3]=0,c[4]=h*n-a*s,c[5]=l*n+r,c[6]=l*s+a*i,c[7]=0,c[8]=h*s+a*n,c[9]=l*s-i*a,c[10]=o*s*s+r,c[11]=0,c[12]=0,c[13]=0,c[14]=0,c[15]=1,this},e.setTranslate=function(t,e,i){var n=this.data;return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=t,n[13]=e,n[14]=i,n[15]=1,this},e.setScale=function(t,e,i){var n=this.data;return n[0]=t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this},e.setViewport=function(t,e,i,n){var s=this.data;return s[0]=.5*i,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=.5*n,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=.5,s[11]=0,s[12]=t+.5*i,s[13]=e+.5*n,s[14]=.5,s[15]=1,this},e.setReflection=function(t,e){var i=t.x,n=t.y,s=t.z,r=this.data;return r[0]=1-2*i*i,r[1]=-2*i*n,r[2]=-2*i*s,r[3]=0,r[4]=-2*i*n,r[5]=1-2*n*n,r[6]=-2*n*s,r[7]=0,r[8]=-2*i*s,r[9]=-2*n*s,r[10]=1-2*s*s,r[11]=0,r[12]=-2*i*e,r[13]=-2*n*e,r[14]=-2*s*e,r[15]=1,this},e.invert=function(t){void 0===t&&(t=this);var e=t.data,i=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],h=e[6],l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],_=e[14],v=e[15],g=i*o-n*a,y=i*h-s*a,x=i*l-r*a,S=n*h-s*o,b=n*l-r*o,T=s*l-r*h,w=c*m-u*p,E=c*_-d*p,A=c*v-f*p,C=u*_-d*m,M=u*v-f*m,P=d*v-f*_,R=g*P-y*M+x*C+S*A-b*E+T*w;if(0===R)this.setIdentity();else{var I=1/R,D=this.data;D[0]=(o*P-h*M+l*C)*I,D[1]=(-n*P+s*M-r*C)*I,D[2]=(m*T-_*b+v*S)*I,D[3]=(-u*T+d*b-f*S)*I,D[4]=(-a*P+h*A-l*E)*I,D[5]=(i*P-s*A+r*E)*I,D[6]=(-p*T+_*x-v*y)*I,D[7]=(c*T-d*x+f*y)*I,D[8]=(a*M-o*A+l*w)*I,D[9]=(-i*M+n*A-r*w)*I,D[10]=(p*b-m*x+v*g)*I,D[11]=(-c*b+u*x-f*g)*I,D[12]=(-a*C+o*E-h*w)*I,D[13]=(i*C-n*E+s*w)*I,D[14]=(-p*S+m*y-_*g)*I,D[15]=(c*S-u*y+d*g)*I}return this},e.set=function(t){var e=this.data;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],this},e.setIdentity=function(){var t=this.data;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},e.setTRS=function(t,e,i){var n=e.x,s=e.y,r=e.z,a=e.w,o=i.x,h=i.y,l=i.z,c=n+n,u=s+s,d=r+r,f=n*c,p=n*u,m=n*d,_=s*u,v=s*d,g=r*d,y=a*c,x=a*u,S=a*d,b=this.data;return b[0]=(1-(_+g))*o,b[1]=(p+S)*o,b[2]=(m-x)*o,b[3]=0,b[4]=(p-S)*h,b[5]=(1-(f+g))*h,b[6]=(v+y)*h,b[7]=0,b[8]=(m+x)*l,b[9]=(v-y)*l,b[10]=(1-(f+_))*l,b[11]=0,b[12]=t.x,b[13]=t.y,b[14]=t.z,b[15]=1,this},e.transpose=function(t){void 0===t&&(t=this);var e,i=t.data,n=this.data;i===n?(e=i[1],n[1]=i[4],n[4]=e,e=i[2],n[2]=i[8],n[8]=e,e=i[3],n[3]=i[12],n[12]=e,e=i[6],n[6]=i[9],n[9]=e,e=i[7],n[7]=i[13],n[13]=e,e=i[11],n[11]=i[14],n[14]=e):(n[0]=i[0],n[1]=i[4],n[2]=i[8],n[3]=i[12],n[4]=i[1],n[5]=i[5],n[6]=i[9],n[7]=i[13],n[8]=i[2],n[9]=i[6],n[10]=i[10],n[11]=i[14],n[12]=i[3],n[13]=i[7],n[14]=i[11],n[15]=i[15]);return this},e.getTranslation=function(t){return void 0===t&&(t=new wt),t.set(this.data[12],this.data[13],this.data[14])},e.getX=function(t){return void 0===t&&(t=new wt),t.set(this.data[0],this.data[1],this.data[2])},e.getY=function(t){return void 0===t&&(t=new wt),t.set(this.data[4],this.data[5],this.data[6])},e.getZ=function(t){return void 0===t&&(t=new wt),t.set(this.data[8],this.data[9],this.data[10])},e.getScale=function(t){return void 0===t&&(t=new wt),this.getX(Lt),this.getY(kt),this.getZ(Ot),t.set(Lt.length(),kt.length(),Ot.length()),t},e.setFromEulerAngles=function(t,e,i){t*=ft.DEG_TO_RAD,e*=ft.DEG_TO_RAD,i*=ft.DEG_TO_RAD;var n=Math.sin(-t),s=Math.cos(-t),r=Math.sin(-e),a=Math.cos(-e),o=Math.sin(-i),h=Math.cos(-i),l=this.data;return l[0]=a*h,l[1]=-a*o,l[2]=r,l[3]=0,l[4]=s*o+h*n*r,l[5]=s*h-n*r*o,l[6]=-a*n,l[7]=0,l[8]=n*o-s*h*r,l[9]=h*n+s*r*o,l[10]=s*a,l[11]=0,l[12]=0,l[13]=0,l[14]=0,l[15]=1,this},e.getEulerAngles=function(t){void 0===t&&(t=new wt),this.getScale(Ft);var e=Ft.x,i=Ft.y,n=Ft.z;if(0===e||0===i||0===n)return t.set(0,0,0);var s,r,a=this.data,o=Math.asin(-a[2]/e),h=.5*Math.PI;return o-h?(s=Math.atan2(a[6]/i,a[10]/n),r=Math.atan2(a[1]/e,a[0]/e)):(r=0,s=-Math.atan2(a[4]/i,a[5]/i)):(r=0,s=Math.atan2(a[4]/i,a[5]/i)),t.set(s,o,r).mulScalar(ft.RAD_TO_DEG)},e.toString=function(){return"["+this.data.join(", ")+"]"},v(t,[{key:"scaleSign",get:function(){return this.getX(Lt),this.getY(kt),this.getZ(Ot),Lt.cross(Lt,kt),Lt.dot(Ot)<0?-1:1}}])}();Pt=Bt,Bt.IDENTITY=Object.freeze(new Pt),Bt.ZERO=Object.freeze((new Pt).set([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]));var Nt=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),this.x=void 0,this.y=void 0,this.z=void 0,this.w=void 0,4===t.length?(this.x=t[0],this.y=t[1],this.z=t[2],this.w=t[3]):(this.x=t,this.y=e,this.z=i,this.w=n)}var e=t.prototype;return e.clone=function(){return new(0,this.constructor)(this.x,this.y,this.z,this.w)},e.conjugate=function(t){return void 0===t&&(t=this),this.x=-1*t.x,this.y=-1*t.y,this.z=-1*t.z,this.w=t.w,this},e.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},e.equals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},e.equalsApprox=function(t,e){return void 0===e&&(e=1e-6),Math.abs(this.x-t.x)=.99999?(e=2*Math.atan2(s,o),i=Math.PI/2,n=0):(e=Math.atan2(2*(o*s+r*a),1-2*(s*s+r*r)),i=Math.asin(h),n=Math.atan2(2*(o*a+s*r),1-2*(r*r+a*a))),t.set(e,i,n).mulScalar(ft.RAD_TO_DEG)},e.invert=function(t){return void 0===t&&(t=this),this.conjugate(t).normalize()},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.mul=function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.x,a=t.y,o=t.z,h=t.w;return this.x=s*r+e*h+i*o-n*a,this.y=s*a+i*h+n*r-e*o,this.z=s*o+n*h+e*a-i*r,this.w=s*h-e*r-i*a-n*o,this},e.mulScalar=function(t,e){return void 0===e&&(e=this),this.x=e.x*t,this.y=e.y*t,this.z=e.z*t,this.w=e.w*t,this},e.mul2=function(t,e){var i=t.x,n=t.y,s=t.z,r=t.w,a=e.x,o=e.y,h=e.z,l=e.w;return this.x=r*a+i*l+n*h-s*o,this.y=r*o+n*l+s*a-i*h,this.z=r*h+s*l+i*o-n*a,this.w=r*l-i*a-n*o-s*h,this},e.normalize=function(t){void 0===t&&(t=this);var e=t.length();return 0===e?(this.x=this.y=this.z=0,this.w=1):(e=1/e,this.x=t.x*e,this.y=t.y*e,this.z=t.z*e,this.w=t.w*e),this},e.set=function(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this},e.setFromAxisAngle=function(t,e){e*=.5*ft.DEG_TO_RAD;var i=Math.sin(e),n=Math.cos(e);return this.x=i*t.x,this.y=i*t.y,this.z=i*t.z,this.w=n,this},e.setFromEulerAngles=function(t,e,i){if(t instanceof wt){var n=t;t=n.x,e=n.y,i=n.z}var s=.5*ft.DEG_TO_RAD;t*=s,e*=s,i*=s;var r=Math.sin(t),a=Math.cos(t),o=Math.sin(e),h=Math.cos(e),l=Math.sin(i),c=Math.cos(i);return this.x=r*h*c-a*o*l,this.y=a*o*c+r*h*l,this.z=a*h*l-r*o*c,this.w=a*h*c+r*o*l,this},e.setFromMat4=function(t){var e,i=t.data,n=i[0],s=i[1],r=i[2],a=i[4],o=i[5],h=i[6],l=i[8],c=i[9],u=i[10];return 0===(e=n*n+s*s+r*r)?this.set(0,0,0,1):(n*=e=1/Math.sqrt(e),s*=e,r*=e,0===(e=a*a+o*o+h*h)?this.set(0,0,0,1):(a*=e=1/Math.sqrt(e),o*=e,h*=e,0===(e=l*l+c*c+u*u)?this.set(0,0,0,1):(l*=e=1/Math.sqrt(e),c*=e,(u*=e)<0?n>o?this.set(1+n-o-u,s+a,l+r,h-c):this.set(s+a,1-n+o-u,h+c,l-r):n<-o?this.set(l+r,h+c,1-n-o+u,s-a):this.set(h-c,l-r,s-a,1+n+o+u),this.mulScalar(1/this.length()))))},e.setFromDirections=function(t,e){var i=1+t.dot(e);return iMath.abs(t.y)?(this.x=-t.z,this.y=0,this.z=t.x,this.w=0):(this.x=0,this.y=-t.z,this.z=t.y,this.w=0):(this.x=t.y*e.z-t.z*e.y,this.y=t.z*e.x-t.x*e.z,this.z=t.x*e.y-t.y*e.x,this.w=i),this.normalize()},e.slerp=function(t,e,i){var n=t.x,s=t.y,r=t.z,a=t.w,o=e.x,h=e.y,l=e.z,c=e.w,u=a*c+n*o+s*h+r*l;if(u<0&&(c=-c,o=-o,h=-h,l=-l,u=-u),Math.abs(u)>=1)return this.w=a,this.x=n,this.y=s,this.z=r,this;var d=Math.acos(u),f=Math.sqrt(1-u*u);if(Math.abs(f)<.001)return this.w=.5*a+.5*c,this.x=.5*n+.5*o,this.y=.5*s+.5*h,this.z=.5*r+.5*l,this;var p=Math.sin((1-i)*d)/f,m=Math.sin(i*d)/f;return this.w=a*p+c*m,this.x=n*p+o*m,this.y=s*p+h*m,this.z=r*p+l*m,this},e.transformVector=function(t,e){void 0===e&&(e=new wt);var i=t.x,n=t.y,s=t.z,r=this.x,a=this.y,o=this.z,h=this.w,l=h*i+a*s-o*n,c=h*n+o*i-r*s,u=h*s+r*n-a*i,d=-r*i-a*n-o*s;return e.x=l*h+d*-r+c*-o-u*-a,e.y=c*h+d*-a+u*-r-l*-o,e.z=u*h+d*-o+l*-a-c*-r,e},e.toString=function(){return"["+this.x+", "+this.y+", "+this.z+", "+this.w+"]"},t}();It=Nt,Nt.IDENTITY=Object.freeze(new It(0,0,0,1)),Nt.ZERO=Object.freeze(new It(0,0,0,0));var Ut=new wt,zt=new wt,Vt=new wt,Gt=new wt,Ht=new wt,Wt=function(){function t(t,e){void 0===t&&(t=new wt),void 0===e&&(e=new wt(.5,.5,.5)),this.center=void 0,this.halfExtents=void 0,this._min=new wt,this._max=new wt,this.center=t,this.halfExtents=e}var e=t.prototype;return e.add=function(t){var e=this.center,i=e.x,n=e.y,s=e.z,r=this.halfExtents,a=r.x,o=r.y,h=r.z,l=i-a,c=i+a,u=n-o,d=n+o,f=s-h,p=s+h,m=t.center,_=m.x,v=m.y,g=m.z,y=t.halfExtents,x=y.x,S=y.y,b=y.z,T=_-x,w=_+x,E=v-S,A=v+S,C=g-b,M=g+b;Tc&&(c=w),Ed&&(d=A),Cp&&(p=M),e.x=.5*(l+c),e.y=.5*(u+d),e.z=.5*(f+p),r.x=.5*(c-l),r.y=.5*(d-u),r.z=.5*(p-f)},e.copy=function(t){this.center.copy(t.center),this.halfExtents.copy(t.halfExtents)},e.clone=function(){return new t(this.center.clone(),this.halfExtents.clone())},e.intersects=function(t){var e=this.getMax(),i=this.getMin(),n=t.getMax(),s=t.getMin();return i.x<=n.x&&e.x>=s.x&&i.y<=n.y&&e.y>=s.y&&i.z<=n.z&&e.z>=s.z},e._intersectsRay=function(t,e){var i=Ut.copy(this.getMin()).sub(t.origin),n=zt.copy(this.getMax()).sub(t.origin),s=t.direction;0===s.x?(i.x=i.x<0?-Number.MAX_VALUE:Number.MAX_VALUE,n.x=n.x<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.x/=s.x,n.x/=s.x),0===s.y?(i.y=i.y<0?-Number.MAX_VALUE:Number.MAX_VALUE,n.y=n.y<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.y/=s.y,n.y/=s.y),0===s.z?(i.z=i.z<0?-Number.MAX_VALUE:Number.MAX_VALUE,n.z=n.z<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.z/=s.z,n.z/=s.z);var r=Vt.set(Math.min(i.x,n.x),Math.min(i.y,n.y),Math.min(i.z,n.z)),a=Gt.set(Math.max(i.x,n.x),Math.max(i.y,n.y),Math.max(i.z,n.z)),o=Math.min(Math.min(a.x,a.y),a.z),h=Math.max(Math.max(r.x,r.y),r.z),l=o>=h&&h>=0;return l&&e.copy(t.direction).mulScalar(h).add(t.origin),l},e._fastIntersectsRay=function(t){var e=Ut,i=zt,n=Vt,s=Gt,r=Ht,a=t.direction;return e.sub2(t.origin,this.center),s.set(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z)),n.mul2(e,a),!(s.x>this.halfExtents.x&&n.x>=0)&&(!(s.y>this.halfExtents.y&&n.y>=0)&&(!(s.z>this.halfExtents.z&&n.z>=0)&&(r.set(Math.abs(a.x),Math.abs(a.y),Math.abs(a.z)),i.cross(a,e),i.set(Math.abs(i.x),Math.abs(i.y),Math.abs(i.z)),!(i.x>this.halfExtents.y*r.z+this.halfExtents.z*r.y)&&(!(i.y>this.halfExtents.x*r.z+this.halfExtents.z*r.x)&&!(i.z>this.halfExtents.x*r.y+this.halfExtents.y*r.x)))))},e.intersectsRay=function(t,e){return e?this._intersectsRay(t,e):this._fastIntersectsRay(t)},e.setMinMax=function(t,e){this.center.add2(e,t).mulScalar(.5),this.halfExtents.sub2(e,t).mulScalar(.5)},e.getMin=function(){return this._min.copy(this.center).sub(this.halfExtents)},e.getMax=function(){return this._max.copy(this.center).add(this.halfExtents)},e.containsPoint=function(t){var e=this.getMin(),i=this.getMax();return!(t.xi.x||t.yi.y||t.zi.z)},e.setFromTransformedAabb=function(t,e,i){void 0===i&&(i=!1);var n=t.center,s=t.halfExtents,r=e.data,a=r[0],o=r[4],h=r[8],l=r[1],c=r[5],u=r[9],d=r[2],f=r[6],p=r[10];if(i){var m=a*a+o*o+h*h;if(m>0){var _=1/Math.sqrt(m);a*=_,o*=_,h*=_}if((m=l*l+c*c+u*u)>0){var v=1/Math.sqrt(m);l*=v,c*=v,u*=v}if((m=d*d+f*f+p*p)>0){var g=1/Math.sqrt(m);d*=g,f*=g,p*=g}}this.center.set(r[12]+a*n.x+o*n.y+h*n.z,r[13]+l*n.x+c*n.y+u*n.z,r[14]+d*n.x+f*n.y+p*n.z),this.halfExtents.set(Math.abs(a)*s.x+Math.abs(o)*s.y+Math.abs(h)*s.z,Math.abs(l)*s.x+Math.abs(c)*s.y+Math.abs(u)*s.z,Math.abs(d)*s.x+Math.abs(f)*s.y+Math.abs(p)*s.z)},t.computeMinMax=function(t,e,i,n){if(void 0===n&&(n=t.length/3),n>0){for(var s=t[0],r=t[1],a=t[2],o=s,h=r,l=a,c=3*n,u=3;uo&&(o=d),f>h&&(h=f),p>l&&(l=p)}e.set(s,r,a),i.set(o,h,l)}},e.compute=function(e,i){t.computeMinMax(e,Ut,zt,i),this.setMinMax(Ut,zt)},e.intersectsBoundingSphere=function(t){return this._distanceToBoundingSphereSq(t)<=t.radius*t.radius},e._distanceToBoundingSphereSq=function(t){for(var e=this.getMin(),i=this.getMax(),n=0,s=["x","y","z"],r=0;r<3;++r){var a=0,o=t.center[s[r]],h=e[s[r]],l=i[s[r]],c=0;ol&&(a+=(c=o-l)*c),n+=a}return n},e._expand=function(t,e){Ut.add2(this.getMin(),t),zt.add2(this.getMax(),e),this.setMinMax(Ut,zt)},t}(),Xt=new wt,jt=new wt,qt=function(){function t(t,e){void 0===t&&(t=new wt),void 0===e&&(e=.5),this.center=void 0,this.radius=void 0,this.center=t,this.radius=e}var e=t.prototype;return e.containsPoint=function(t){var e=Xt.sub2(t,this.center).lengthSq(),i=this.radius;return e0&&n>0)return!1;var r=n*n-s;if(r<0)return!1;var a=Math.abs(-n-Math.sqrt(r));return e&&e.copy(t.direction).mulScalar(a).add(t.origin),!0},e.intersectsBoundingSphere=function(t){Xt.sub2(t.center,this.center);var e=t.radius+this.radius;return Xt.lengthSq()<=e*e},t}(),Yt=function(){function t(){this.planes=[];for(var t=0;t<6;t++)this.planes[t]=[]}var e=t.prototype;return e.setFromMat4=function(t){var e,i=t.data,n=this.planes;(e=n[0])[0]=i[3]-i[0],e[1]=i[7]-i[4],e[2]=i[11]-i[8],e[3]=i[15]-i[12];var s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s,(e=n[1])[0]=i[3]+i[0],e[1]=i[7]+i[4],e[2]=i[11]+i[8],e[3]=i[15]+i[12],s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s,(e=n[2])[0]=i[3]+i[1],e[1]=i[7]+i[5],e[2]=i[11]+i[9],e[3]=i[15]+i[13],s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s,(e=n[3])[0]=i[3]-i[1],e[1]=i[7]-i[5],e[2]=i[11]-i[9],e[3]=i[15]-i[13],s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s,(e=n[4])[0]=i[3]-i[2],e[1]=i[7]-i[6],e[2]=i[11]-i[10],e[3]=i[15]-i[14],s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s,(e=n[5])[0]=i[3]+i[2],e[1]=i[7]+i[6],e[2]=i[11]+i[10],e[3]=i[15]+i[14],s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s},e.containsPoint=function(t){var e,i;for(e=0;e<6;e++)if((i=this.planes[e])[0]*t.x+i[1]*t.y+i[2]*t.z+i[3]<=0)return!1;return!0},e.containsSphere=function(t){var e,i,n,s=0,r=t.radius,a=t.center,o=a.x,h=a.y,l=a.z,c=this.planes;for(i=0;i<6;i++){if((e=(n=c[i])[0]*o+n[1]*h+n[2]*l+n[3])<=-r)return 0;e>r&&s++}return 6===s?2:1},t}(),Kt=function(){function t(t,e){this.origin=new wt,this.direction=wt.FORWARD.clone(),t&&this.origin.copy(t),e&&this.direction.copy(e)}var e=t.prototype;return e.set=function(t,e){return this.origin.copy(t),this.direction.copy(e),this},e.copy=function(t){return this.set(t.origin,t.direction)},e.clone=function(){return new this.constructor(this.origin,this.direction)},t}(),Zt=new Kt,Qt=new wt,Jt=new qt,$t=new Bt,te=function(){function t(t,e){void 0===t&&(t=new Bt),void 0===e&&(e=new wt(.5,.5,.5)),this.halfExtents=void 0,this._modelTransform=void 0,this._worldTransform=void 0,this._aabb=void 0,this.halfExtents=e,this._modelTransform=t.clone().invert(),this._worldTransform=t.clone(),this._aabb=new Wt(new wt,this.halfExtents)}var e=t.prototype;return e.intersectsRay=function(t,e){if(this._modelTransform.transformPoint(t.origin,Zt.origin),this._modelTransform.transformVector(t.direction,Zt.direction),e){var i=this._aabb._intersectsRay(Zt,e);return $t.copy(this._modelTransform).invert().transformPoint(e,e),i}return this._aabb._fastIntersectsRay(Zt)},e.containsPoint=function(t){return this._modelTransform.transformPoint(t,Qt),this._aabb.containsPoint(Qt)},e.intersectsBoundingSphere=function(t){return this._modelTransform.transformPoint(t.center,Jt.center),Jt.radius=t.radius,!!this._aabb.intersectsBoundingSphere(Jt)},v(t,[{key:"worldTransform",get:function(){return this._worldTransform},set:function(t){this._worldTransform.copy(t),this._modelTransform.copy(t).invert()}}])}(),ee=function(){function t(t,e){void 0===t&&(t=wt.UP),void 0===e&&(e=0),this.normal=new wt,this.distance=void 0,this.normal.copy(t),this.distance=e}var e=t.prototype;return e.setFromPointNormal=function(t,e){return this.normal.copy(e),this.distance=-this.normal.dot(t),this},e.intersectsLine=function(t,e,i){var n=this.distance,s=this.normal.dot(t)+n,r=s/(s-(this.normal.dot(e)+n)),a=r>=0&&r<=1;return a&&i&&i.lerp(t,e,r),a},e.intersectsRay=function(t,e){var i=this.normal.dot(t.direction);if(0===i)return!1;var n=-(this.normal.dot(t.origin)+this.distance)/i;return n>=0&&e&&e.copy(t.direction).mulScalar(n).add(t.origin),n>=0},e.copy=function(t){return this.normal.copy(t.normal),this.distance=t.distance,this},e.clone=function(){return(new(0,this.constructor)).copy(this)},t}(),ie=new wt,ne=new wt,se=new wt,re=new wt,ae=new wt,oe=1e-6,he=function(){function t(t,e,i){void 0===t&&(t=wt.ZERO),void 0===e&&(e=wt.ZERO),void 0===i&&(i=wt.ZERO),this.v0=new wt,this.v1=new wt,this.v2=new wt,this.set(t,e,i)}var e=t.prototype;return e.set=function(t,e,i){return this.v0.copy(t),this.v1.copy(e),this.v2.copy(i),this},e.intersectsRay=function(t,e){ie.sub2(this.v1,this.v0),ne.sub2(this.v2,this.v0),se.cross(t.direction,ne);var i=ie.dot(se);if(i>-oe&&i1)return!1;ae.cross(re,ie);var r=n*t.direction.dot(ae);if(r<0||s+r>1)return!1;var a=n*ne.dot(ae);return a>oe&&(e instanceof wt&&e.copy(t.direction).mulScalar(a).add(t.origin),!0)},e.toString=function(){return"["+this.v0.toString()+", "+this.v1.toString()+", "+this.v2.toString()+"]"},t}(),le="linear",ce="inverse",ue="exponential",de=128,fe=10,pe=11,me=12,_e=13,ve=14,ge=15,ye=16,xe=17,Se=18,be=21,Te=24,we=25,Ee=26,Ae=27,Ce=37,Me=49,Pe=new Map([[0,{name:"A8",size:1}],[1,{name:"L8",size:1}],[2,{name:"LA8",size:2}],[3,{name:"RGB565",size:2}],[4,{name:"RGBA5551",size:2}],[5,{name:"RGBA4",size:2}],[6,{name:"RGB8",size:4}],[7,{name:"RGBA8",size:4}],[50,{name:"R16F",size:2}],[51,{name:"RG16F",size:4}],[pe,{name:"RGB16F",size:8}],[me,{name:"RGBA16F",size:8}],[_e,{name:"RGB32F",size:16}],[ve,{name:"RGBA32F",size:16}],[ge,{name:"R32F",size:4}],[ye,{name:"DEPTH",size:4}],[xe,{name:"DEPTHSTENCIL",size:4}],[Se,{name:"111110F",size:4}],[19,{name:"SRGB",size:4}],[20,{name:"SRGBA",size:4}],[31,{name:"BGRA8",size:4}],[8,{name:"DXT1",blockSize:8}],[9,{name:"DXT3",blockSize:16}],[fe,{name:"DXT5",blockSize:16}],[be,{name:"ETC1",blockSize:8}],[22,{name:"ETC2_RGB",blockSize:8}],[23,{name:"ETC2_RGBA",blockSize:16}],[Te,{name:"PVRTC_2BPP_RGB_1",blockSize:8}],[we,{name:"PVRTC_2BPP_RGBA_1",blockSize:8}],[Ee,{name:"PVRTC_4BPP_RGB_1",blockSize:8}],[Ae,{name:"PVRTC_4BPP_RGBA_1",blockSize:8}],[28,{name:"ASTC_4x4",blockSize:16}],[29,{name:"ATC_RGB",blockSize:8}],[30,{name:"ATC_RGBA",blockSize:16}],[32,{name:"R8I",size:1,isInt:!0}],[33,{name:"R8U",size:1,isInt:!0}],[34,{name:"R16I",size:2,isInt:!0}],[35,{name:"R16U",size:2,isInt:!0}],[36,{name:"R32I",size:4,isInt:!0}],[Ce,{name:"R32U",size:4,isInt:!0}],[38,{name:"RG8I",size:2,isInt:!0}],[39,{name:"RG8U",size:2,isInt:!0}],[40,{name:"RG16I",size:4,isInt:!0}],[41,{name:"RG16U",size:4,isInt:!0}],[42,{name:"RG32I",size:8,isInt:!0}],[43,{name:"RG32U",size:8,isInt:!0}],[44,{name:"RGBA8I",size:4,isInt:!0}],[45,{name:"RGBA8U",size:4,isInt:!0}],[46,{name:"RGBA16I",size:8,isInt:!0}],[47,{name:"RGBA16U",size:8,isInt:!0}],[48,{name:"RGBA32I",size:16,isInt:!0}],[Me,{name:"RGBA32U",size:16,isInt:!0}]]),Re=function(t){var e;return void 0!==(null==(e=Pe.get(t))?void 0:e.blockSize)},Ie=function(t){var e;return!0===(null==(e=Pe.get(t))?void 0:e.isInt)},De=function(t){switch(t){case ge:case _e:case ve:return Float32Array;case 36:case 42:case 48:return Int32Array;case Ce:case 43:case Me:return Uint32Array;case 34:case 40:case 46:return Int16Array;case 35:case 41:case 47:case 3:case 4:case 5:case 50:case 51:case pe:case me:return Uint16Array;case 32:case 38:case 44:return Int8Array;default:return Uint8Array}},Le="POSITION",ke="NORMAL",Oe="TANGENT",Fe="BLENDWEIGHT",Be="BLENDINDICES",Ne="COLOR",Ue="TEXCOORD",ze="TEXCOORD0",Ve="TEXCOORD1",Ge="TEXCOORD2",He="TEXCOORD3",We="TEXCOORD4",Xe="TEXCOORD5",je="TEXCOORD6",qe="TEXCOORD7",Ye="ATTR",Ke="ATTR0",Ze="ATTR1",Qe="ATTR2",Je="ATTR3",$e="ATTR4",ti="ATTR5",ei="ATTR6",ii="ATTR7",ni="ATTR8",si="ATTR9",ri="ATTR10",ai="ATTR11",oi="ATTR12",hi="ATTR13",li="ATTR14",ci="ATTR15",ui="default",di="rgbm",fi="rgbe",pi="rgbp",mi="swizzleGGGR",_i="2d",vi="2d-array",gi="cube",yi="3d",xi="none",Si="cube",bi="equirect",Ti="octahedral",wi="wgsl",Ei=10,Ai=11,Ci=13,Mi=14,Pi=26,Ri=27,Ii=28,Di=29,Li=30,ki=33,Oi=36,Fi=["bool","int","float","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","mat2","mat3","mat4","sampler2D","samplerCube","","sampler2DShadow","samplerCubeShadow","sampler3D","","","","","sampler2DArray","uint","uvec2","uvec3","uvec4","","","","","","","","","","","","","isampler2D","usampler2D","isamplerCube","usamplerCube","isampler3D","usampler3D","isampler2DArray","usampler2DArray"],Bi=new Uint8Array([4,4,6,6,6,6,4,4,4,4,4,4,6,6,6,4,4,6,4,4,4,6,6,6,6,4,5,5,5,5,4,5,4,4,5,4,4,5,4,4,5,4,4,5,4,5,4,5,4,5]),Ni="webgl1",Ui="webgl2",zi="webgpu",Vi="null",Gi=["mesh","view"],Hi="default",Wi=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Uint16Array],Xi=[1,1,2,2,4,4,4,2],ji={Int8Array:0,Uint8Array:1,Int16Array:2,Uint16Array:3,Int32Array:4,Uint32Array:5,Float32Array:6},qi=[Uint8Array,Uint16Array,Uint32Array],Yi=[1,2,4],Ki={};Ki[Le]=0,Ki[ke]=1,Ki[Fe]=2,Ki[Be]=3,Ki[Ne]=4,Ki[ze]=5,Ki[Ve]=6,Ki[Ge]=7,Ki[He]=8,Ki[We]=9,Ki[Xe]=10,Ki[je]=11,Ki[qe]=12,Ki[Oe]=13,Ki[Ke]=0,Ki[Ze]=1,Ki[Qe]=2,Ki[Je]=3,Ki[$e]=4,Ki[ti]=5,Ki[ei]=6,Ki[ii]=7,Ki[ni]=8,Ki[si]=9,Ki[ri]=10,Ki[ai]=11,Ki[oi]=12,Ki[hi]=13,Ki[li]=14,Ki[ci]=15;var Zi,Qi="1.65",Ji=function(t,e,i,n){return void 0===n&&(n=1),t&~(n<>e&i},tn=function(t,e,i){void 0===i&&(i=1);var n=i<3){var a;this.usage=null!=(a=arguments[3])?a:0,s=arguments[4]}this.device=t,this.format=e,this.numVertices=i,this.id=fn++,this.impl=t.createVertexBufferImpl(this,e,n),this.numBytes=e.verticesByteSize?e.verticesByteSize:e.size*i,this.adjustVramSizeTracking(t._vram,this.numBytes),s?this.setData(s):this.storage=new ArrayBuffer(this.numBytes),this.device.buffers.push(this)}var e=t.prototype;return e.destroy=function(){var t=this.device,e=t.buffers.indexOf(this);-1!==e&&t.buffers.splice(e,1),this.impl.initialized&&(this.impl.destroy(t),this.adjustVramSizeTracking(t._vram,-this.storage.byteLength))},e.adjustVramSizeTracking=function(t,e){t.vb+=e},e.loseContext=function(){this.impl.loseContext()},e.getFormat=function(){return this.format},e.getUsage=function(){return this.usage},e.getNumVertices=function(){return this.numVertices},e.lock=function(){return this.storage},e.unlock=function(){this.impl.unlock(this)},e.setData=function(t){return t.byteLength===this.numBytes&&(this.storage=t,this.unlock(),!0)},t}();function mn(t){for(var e=0,i=0,n=t.length;i>>0}var vn,gn=function(){function t(){this._cache=new Map}var e=t.prototype;return e.get=function(t,e){var i=this;return this._cache.has(t)||(this._cache.set(t,e()),t.on("destroy",(function(){i.remove(t)})),t.on("devicelost",(function(){var e;null==(e=i._cache.get(t))||null==e.loseContext||e.loseContext(t)}))),this._cache.get(t)},e.remove=function(t){var e;null==(e=this._cache.get(t))||null==e.destroy||e.destroy(t),this._cache.delete(t)},t}(),yn=new rn,xn=[2,4,8,12,16],Sn=new gn,bn=function(){function t(t,e,i){this.device=t,this._elements=[],this.hasUv0=!1,this.hasUv1=!1,this.hasColor=!1,this.hasTangents=!1,this.verticesByteSize=0,this.vertexCount=i,this.interleaved=void 0===i,this.instancing=!1,this.size=e.reduce((function(t,e){return t+4*Math.ceil(e.components*Xi[e.type]/4)}),0);for(var n,s=0,r=0,a=e.length;r1?m:1),this.autoResolve=null==(r=t.autoResolve)||r,this.name=t.name,this.name)||(this.name=null==(f=this._colorBuffer)?void 0:f.name);this.name||(this.name=null==(p=this._depthBuffer)?void 0:p.name);this.name||(this.name="Untitled"),this.flipY=null!=(a=t.flipY)&&a,this.validateMrt(),this.impl=d.createRenderTargetImpl(this)}var e=t.prototype;return e.destroy=function(){var t=this._device;t&&(t.targets.delete(this),t.renderTarget===this&&t.setRenderTarget(null),this.destroyFrameBuffers())},e.destroyFrameBuffers=function(){var t=this._device;t&&this.impl.destroy(t)},e.destroyTextureBuffers=function(){var t,e;null==(t=this._depthBuffer)||t.destroy(),this._depthBuffer=null,null==(e=this._colorBuffers)||e.forEach((function(t){t.destroy()})),this._colorBuffers=null,this._colorBuffer=null},e.resize=function(t,e){if(this.width!==t||this.height!==e){var i,n,s=this._device;this.destroyFrameBuffers(),s.renderTarget===this&&s.setRenderTarget(null),null==(i=this._depthBuffer)||i.resize(t,e),null==(n=this._colorBuffers)||n.forEach((function(i){i.resize(t,e)})),this.validateMrt(),this.impl=s.createRenderTargetImpl(this)}},e.validateMrt=function(){},e.init=function(){this.impl.init(this._device,this)},e.loseContext=function(){this.impl.loseContext()},e.resolve=function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!!this._depthBuffer),this._device&&this._samples>1&&this.impl.resolve(this._device,this,t,e)},e.copy=function(t,e,i){if(!this._device){if(!t._device)return!1;this._device=t._device}return this._device.copyRenderTarget(t,this,e,i)},e.getColorBuffer=function(t){var e;return null==(e=this._colorBuffers)?void 0:e[t]},v(t,[{key:"initialized",get:function(){return this.impl.initialized}},{key:"device",get:function(){return this._device}},{key:"samples",get:function(){return this._samples}},{key:"depth",get:function(){return this._depth}},{key:"stencil",get:function(){return this._stencil}},{key:"colorBuffer",get:function(){return this._colorBuffer}},{key:"depthBuffer",get:function(){return this._depthBuffer}},{key:"face",get:function(){return this._face}},{key:"width",get:function(){var t,e;return(null==(t=this._colorBuffer)?void 0:t.width)||(null==(e=this._depthBuffer)?void 0:e.width)||this._device.width}},{key:"height",get:function(){var t,e;return(null==(t=this._colorBuffer)?void 0:t.height)||(null==(e=this._depthBuffer)?void 0:e.height)||this._device.height}}])}(),Mn=function(){function t(){this.bindGroup=void 0}var e=t.prototype;return e.update=function(t){this.destroy();var e=t.device,i=this.createDescriptor(e,t);this.bindGroup=e.wgpu.createBindGroup(i)},e.destroy=function(){this.bindGroup=null},e.createDescriptor=function(t,e){var i=[],n=e.format,s=e.format.uniformBufferFormats;e.uniformBuffers.forEach((function(t,e){var n=s[e].slot,r=t.persistent?t.impl.buffer:t.allocation.gpuBuffer.buffer;i.push({binding:n,resource:{buffer:r,offset:0,size:t.format.byteSize}})}));var r=e.format.textureFormats;e.textures.forEach((function(e,s){var a=e.impl,o=n.textureFormats[s],h=r[s].slot,l=a.getView(t);if(i.push({binding:h,resource:l}),o.hasSampler){var c=a.getSampler(t,o.sampleType);i.push({binding:h+1,resource:c})}}));var a=e.format.storageTextureFormats;e.storageTextures.forEach((function(e,n){var s=e.impl,r=a[n].slot,o=s.getView(t);i.push({binding:r,resource:o})}));var o=e.format.storageBufferFormats;return e.storageBuffers.forEach((function(t,e){var n=t.impl.buffer,s=o[e].slot;i.push({binding:s,resource:{buffer:n}})})),{layout:e.format.impl.bindGroupLayout,entries:i}},t}(),Pn=function(){function t(){}return t.shaderStage=function(t){var e=0;return 1&t&&(e|=GPUShaderStage.VERTEX),2&t&&(e|=GPUShaderStage.FRAGMENT),4&t&&(e|=GPUShaderStage.COMPUTE),e},t}(),Rn=[];Rn[0]="",Rn[1]="r8unorm",Rn[2]="rg8unorm",Rn[3]="",Rn[4]="",Rn[5]="",Rn[6]="rgba8unorm",Rn[7]="rgba8unorm",Rn[8]="bc1-rgba-unorm",Rn[9]="bc2-rgba-unorm",Rn[10]="bc3-rgba-unorm",Rn[11]="",Rn[12]="rgba16float",Rn[50]="r16float",Rn[51]="rg16float",Rn[13]="",Rn[14]="rgba32float",Rn[15]="r32float",Rn[16]="depth32float",Rn[17]="depth24plus-stencil8",Rn[18]="rg11b10ufloat",Rn[19]="",Rn[20]="",Rn[21]="",Rn[22]="etc2-rgb8unorm",Rn[23]="etc2-rgba8unorm",Rn[24]="",Rn[25]="",Rn[26]="",Rn[27]="",Rn[28]="astc-4x4-unorm",Rn[29]="",Rn[30]="",Rn[31]="bgra8unorm",Rn[32]="r8sint",Rn[33]="r8uint",Rn[34]="r16sint",Rn[35]="r16uint",Rn[36]="r32sint",Rn[37]="r32uint",Rn[38]="rg8sint",Rn[39]="rg8uint",Rn[40]="rg16sint",Rn[41]="rg16uint",Rn[42]="rg32sint",Rn[43]="rg32uint",Rn[44]="rgba8sint",Rn[45]="rgba8uint",Rn[46]="rgba16sint",Rn[47]="rgba16uint",Rn[48]="rgba32sint",Rn[49]="rgba32uint";var In=[];In[0]="filtering",In[1]="non-filtering",In[2]="comparison",In[3]="comparison",In[4]="comparison";var Dn=[];Dn[0]="float",Dn[1]="unfilterable-float",Dn[2]="depth",Dn[3]="sint",Dn[4]="uint";var Ln=new rn,kn=function(){function t(t){var e=t.device,i=this.createDescriptor(t),n=i.key,s=i.descr;this.key=Ln.get(n),this.bindGroupLayout=e.wgpu.createBindGroupLayout(s)}var e=t.prototype;return e.destroy=function(){this.bindGroupLayout=null},e.loseContext=function(){},e.createDescriptor=function(t){var e=[],i="";return t.uniformBufferFormats.forEach((function(t){var n=Pn.shaderStage(t.visibility);i+="#"+t.slot+"U:"+n,e.push({binding:t.slot,visibility:n,buffer:{type:"uniform",hasDynamicOffset:!0}})})),t.textureFormats.forEach((function(t){var n=Pn.shaderStage(t.visibility),s=t.sampleType,r=t.textureDimension,a=!1,o=Dn[s];if(i+="#"+t.slot+"T:"+n+"-"+o+"-"+r+"-"+a,e.push({binding:t.slot,visibility:n,texture:{sampleType:o,viewDimension:r,multisampled:a}}),t.hasSampler){var h=In[s];i+="#"+(t.slot+1)+"S:"+n+"-"+h,e.push({binding:t.slot+1,visibility:n,sampler:{type:h}})}})),t.storageTextureFormats.forEach((function(t){var n=t.format,s=t.textureDimension,r=t.read,a=t.write;i+="#"+t.slot+"ST:"+n+"-"+s+"-"+(r?"r1":"r0")+"-"+(a?"w1":"w0"),e.push({binding:t.slot,visibility:GPUShaderStage.COMPUTE,storageTexture:{access:r?a?"read-write":"read-only":"write-only",format:Rn[n],viewDimension:s}})})),t.storageBufferFormats.forEach((function(t){var n=t.readOnly,s=Pn.shaderStage(t.visibility);i+="#"+t.slot+"SB:"+s+"-"+(n?"ro":"rw"),e.push({binding:t.slot,visibility:s,buffer:{type:n?"read-only-storage":"storage"}})})),{key:i,descr:{entries:e}}},t}(),On=function(){function t(t){void 0===t&&(t=0),this.buffer=null,this.usageFlags=0,this.usageFlags=t}var e=t.prototype;return e.destroy=function(t){this.buffer&&(this.buffer.destroy(),this.buffer=null)},e.loseContext=function(){},e.allocate=function(t,e){this.buffer=t.wgpu.createBuffer({size:e,usage:this.usageFlags})},e.unlock=function(t,e){var i,n,s=t.wgpu;if(!this.buffer){var r=e.byteLength+3&-4;this.usageFlags|=GPUBufferUsage.COPY_DST,this.allocate(t,r)}var a=null!=(i=e.byteOffset)?i:0,o=new Uint8Array(null!=(n=e.buffer)?n:e,a,e.byteLength),h=new Uint8Array(this.buffer.size);h.set(o),s.queue.writeBuffer(this.buffer,0,h,0,h.length)},e.read=function(t,e,i,n){return t.readStorageBuffer(this,e,i,n)},e.write=function(t,e,i,n,s){t.writeStorageBuffer(this,e,i,n,s)},e.clear=function(t,e,i){t.clearStorageBuffer(this,e,i)},v(t,[{key:"initialized",get:function(){return!!this.buffer}}])}(),Fn=function(t){function e(e,i){var n;return(n=t.call(this,16|(null!=i&&i.storage?de:0))||this).format=null,n.format=1===e.format?"uint16":"uint32",n}return x(e,t),e.prototype.unlock=function(e){var i=e.device;t.prototype.unlock.call(this,i,e.storage)},e}(On),Bn=function(t,e){if(t.length!==e.length)return!1;for(var i=0;i1?"x"+o.numComponents:"")}),e&&a!==r-1||(i.push({attributes:s,arrayStride:o.stride,stepMode:n}),s=[])}};return t&&n(t),e&&n(e),i},t}(),Vn=function(){function t(t){this.device=t}return t.prototype.getPipelineLayout=function(t){var e=[];t.forEach((function(t){e.push(t.bindGroupLayout)}));var i={bindGroupLayouts:e};return this.device.wgpu.createPipelineLayout(i)},t}(),Gn=["point-list","line-list",void 0,"line-strip","triangle-list","triangle-strip",void 0],Hn=["add","subtract","reverse-subtract","min","max"],Wn=["zero","one","src","one-minus-src","dst","one-minus-dst","src-alpha","src-alpha-saturated","one-minus-src-alpha","dst-alpha","one-minus-dst-alpha","constant","one-minus-constant"],Xn=["never","less","equal","less-equal","greater","not-equal","greater-equal","always"],jn=["none","back","front"],qn=["keep","zero","replace","increment-clamp","increment-wrap","decrement-clamp","decrement-wrap","invert"],Yn=function(){this.pipeline=void 0,this.hashes=void 0},Kn=function(t){function e(e){var i;return(i=t.call(this,e)||this).lookupHashes=new Uint32Array(13),i.vertexBufferLayout=new zn,i.cache=new Map,i}x(e,t);var i=e.prototype;return i.get=function(t,e,i,n,s,r,a,o,h,l,c,u){var d,f,p,m,_,v,g,y,x=this.lookupHashes;x[0]=t.type,x[1]=n.id,x[2]=h,x[3]=o.key,x[4]=a.key,x[5]=null!=(d=null==e?void 0:e.renderingHash)?d:0,x[6]=null!=(f=null==i?void 0:i.renderingHash)?f:0,x[7]=s.impl.key,x[8]=null!=(p=null==(m=r[0])?void 0:m.key)?p:0,x[9]=null!=(_=null==(v=r[1])?void 0:v.key)?_:0,x[10]=null!=(g=null==(y=r[2])?void 0:y.key)?g:0,x[11]=l?c.key:0,x[12]=l?u.key:0;var S=_n(x),b=this.cache.get(S);if(b)for(var T=0;T0){var m=0;s.redWrite&&(m|=GPUColorWrite.RED),s.greenWrite&&(m|=GPUColorWrite.GREEN),s.blueWrite&&(m|=GPUColorWrite.BLUE),s.alphaWrite&&(m|=GPUColorWrite.ALPHA);var _=this.getBlend(s);p.forEach((function(t){f.fragment.targets.push({format:t.format,writeMask:m,blend:_})}))}return u.createRenderPipeline(f)},e}(Vn),Zn=function(t){function e(){return t.apply(this,arguments)||this}x(e,t);var i=e.prototype;return i.get=function(t,e){var i=this.getPipelineLayout([e.impl]);return this.create(t,i)},i.create=function(t,e){var i=this.device.wgpu,n=t.impl,s={compute:{module:n.getComputeShaderModule(),entryPoint:n.computeEntryPoint},layout:e};return i.createComputePipeline(s)},e}(Vn),Qn=new rn,Jn=function(){function t(){this.format=void 0,this.multisampledBuffer=void 0}return t.prototype.destroy=function(){var t;null==(t=this.multisampledBuffer)||t.destroy(),this.multisampledBuffer=null},t}(),$n=function(){function t(t){var e=this;this.initialized=!1,this.key=void 0,this.colorAttachments=[],this.depthFormat=void 0,this.hasStencil=void 0,this.depthTexture=null,this.depthTextureInternal=!1,this.assignedColorTexture=null,this.renderPassDescriptor={},this.renderTarget=t,t._colorBuffers&&t._colorBuffers.forEach((function(t,i){e.setColorAttachment(i,void 0,t.impl.format)})),this.updateKey()}var e=t.prototype;return e.destroy=function(t){var e;(this.initialized=!1,this.depthTextureInternal)&&(null==(e=this.depthTexture)||e.destroy(),this.depthTexture=null);this.assignedColorTexture=null,this.colorAttachments.forEach((function(t){t.destroy()})),this.colorAttachments.length=0},e.updateKey=function(){var t=this.renderTarget,e=t.samples+":"+(t.depth?this.depthFormat:"nodepth");this.colorAttachments.forEach((function(t){e+=":"+t.format})),this.key=Qn.get(e)},e.setDepthFormat=function(t){this.depthFormat=t,this.hasStencil="depth24plus-stencil8"===t},e.assignColorTexture=function(t){this.assignedColorTexture=t;var e=t.createView(),i=this.renderPassDescriptor.colorAttachments[0];this.renderTarget.samples>1?i.resolveTarget=e:i.view=e,this.setColorAttachment(0,void 0,t.format),this.updateKey()},e.setColorAttachment=function(t,e,i){this.colorAttachments[t]||(this.colorAttachments[t]=new Jn),e&&(this.colorAttachments[t].multisampledBuffer=e),i&&(this.colorAttachments[t].format=i)},e.init=function(t,e){var i,n,s=t.wgpu;this.initDepthStencil(s,e),this.renderPassDescriptor.colorAttachments=[];for(var r=null!=(i=null==(n=e._colorBuffers)?void 0:n.length)?i:1,a=0;a1?GPUTextureUsage.TEXTURE_BINDING:GPUTextureUsage.COPY_SRC,this.depthTexture=t.createTexture(o),this.depthTextureInternal=!0}this.renderPassDescriptor.depthStencilAttachment={view:this.depthTexture.createView()}}},e.initColor=function(t,e,i){var n={},s=e.samples,r=e.width,a=e.height,o=e.getColorBuffer(i),h=null;if(o){h=o.cubemap?o.impl.createView({dimension:"2d",baseArrayLayer:e.face,arrayLayerCount:1,mipLevelCount:1}):o.impl.createView({mipLevelCount:1})}if(s>1){var l,c,u={size:[r,a,1],dimension:"2d",sampleCount:s,format:null!=(l=null==(c=this.colorAttachments[i])?void 0:c.format)?l:o.impl.format,usage:GPUTextureUsage.RENDER_ATTACHMENT},d=t.createTexture(u);this.setColorAttachment(i,d,u.format),n.view=d.createView(),n.resolveTarget=h}else n.view=h;return n},e.setupForRenderPass=function(t){for(var e,i,n=null!=(e=null==(i=this.renderPassDescriptor.colorAttachments)?void 0:i.length)?e:0,s=0;s0)switch(e){case 2:this.updateType=17;break;case 1:this.updateType=Li;break;case Pi:this.updateType=31;break;case 0:this.updateType=32;break;case 3:this.updateType=21;break;case 6:this.updateType=ki;break;case Ri:this.updateType=34;break;case 9:this.updateType=35;break;case 4:this.updateType=22;break;case 7:this.updateType=Oi;break;case Ii:this.updateType=37;break;case Ei:this.updateType=38;break;case 5:this.updateType=23;break;case 8:this.updateType=39;break;case Di:this.updateType=40;break;case Ai:this.updateType=41;break;case Mi:this.updateType=24}this.count=i;var n=this.numComponents;i&&(n=ft.roundUp(n,4)),this.byteSize=4*n,i&&(this.byteSize*=i)}return t.prototype.calculateOffset=function(t){var e=this.byteSize<=8?this.byteSize:16;this.count&&(e=16),t=ft.roundUp(t,e),this.offset=t/4},v(t,[{key:"isArrayType",get:function(){return this.count>0}}])}(),ns=function(){function t(t,e){this.byteSize=0,this.map=new Map,this.scope=t.scope,this.uniforms=e;for(var i=0,n=0;n>e,1)},t.calcMipLevelsCount=function(t,e,i){return void 0===i&&(i=1),1+Math.floor(Math.log2(Math.max(t,e,i)))},t.calcLevelGpuSize=function(t,e,i,n){var s,r,a,o=Pe.get(n),h=null!=(s=null==(r=Pe.get(n))?void 0:r.size)?s:0;if(h>0)return t*e*i*h;var l=null!=(a=o.blockSize)?a:0,c=Math.floor((t+3)/4),u=Math.floor((e+3)/4),d=Math.floor((i+3)/4);return n!==Te&&n!==we||(c=Math.max(Math.floor(c/2),1)),c*u*d*l},t.calcGpuSize=function(e,i,n,s,r,a){for(var o=0;o+=t.calcLevelGpuSize(e,i,n,s),r&&(1!==e||1!==i||1!==n);)e=Math.max(e>>1,1),i=Math.max(i>>1,1),n=Math.max(n>>1,1);return o*(a?6:1)},t}(),Ts=[];Ts[0]="repeat",Ts[1]="clamp-to-edge",Ts[2]="mirror-repeat";var ws=[];ws[0]={level:"nearest",mip:"nearest"},ws[1]={level:"linear",mip:"nearest"},ws[2]={level:"nearest",mip:"nearest"},ws[3]={level:"nearest",mip:"linear"},ws[4]={level:"linear",mip:"nearest"},ws[5]={level:"linear",mip:"linear"};var Es=function(){function t(t){this.gpuTexture=void 0,this.view=void 0,this.samplers=[],this.descr=void 0,this.format=void 0,this.texture=t,this.format=Rn[t.format],this.create(t.device)}var e=t.prototype;return e.create=function(t){var e,i=this.texture,n=t.wgpu,s=i.requiredMipLevels;this.descr={size:{width:i.width,height:i.height,depthOrArrayLayers:i.cubemap?6:i.array?i.arrayLength:1},format:this.format,mipLevelCount:s,sampleCount:1,dimension:i.volume?"3d":"2d",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|(Re(i.format)?0:GPUTextureUsage.RENDER_ATTACHMENT)|(i.storage?GPUTextureUsage.STORAGE_BINDING:0)},this.gpuTexture=n.createTexture(this.descr),this.texture.format===xe&&(e={format:"depth24plus",aspect:"depth-only"}),this.view=this.createView(e)},e.destroy=function(t){},e.propertyChanged=function(t){this.samplers.length=0},e.getView=function(t){return this.uploadImmediate(t,this.texture),this.view},e.createView=function(t){var e,i,n,s,r,a,o,h=null!=t?t:{},l=this.descr,c=this.texture,u={format:null!=(e=h.format)?e:l.format,dimension:null!=(i=h.dimension)?i:c.cubemap?"cube":c.volume?"3d":c.array?"2d-array":"2d",aspect:null!=(n=h.aspect)?n:"all",baseMipLevel:null!=(s=h.baseMipLevel)?s:0,mipLevelCount:null!=(r=h.mipLevelCount)?r:l.mipLevelCount,baseArrayLayer:null!=(a=h.baseArrayLayer)?a:0,arrayLayerCount:null!=(o=h.arrayLayerCount)?o:l.depthOrArrayLayers};return this.gpuTexture.createView(u)},e.getSampler=function(t,e){var i=this.samplers[e];if(!i){var n=this.texture,s={addressModeU:Ts[n.addressU],addressModeV:Ts[n.addressV],addressModeW:Ts[n.addressW]};if(!e&&n.compareOnRead&&(e=2),2===e||3===e||4===e)s.compare="less",s.magFilter="linear",s.minFilter="linear";else if(1===e)s.magFilter="nearest",s.minFilter="nearest",s.mipmapFilter="nearest";else{!t.textureFloatFilterable&&(n.format===ve||n.format===me)||this.texture.format===xe||Ie(this.texture.format)?(s.magFilter="nearest",s.minFilter="nearest",s.mipmapFilter="nearest"):(s.magFilter=ws[n.magFilter].level,s.minFilter=ws[n.minFilter].level,s.mipmapFilter=ws[n.minFilter].mip)}var r="linear"===s.minFilter&&"linear"===s.magFilter&&"linear"===s.mipmapFilter;s.maxAnisotropy=r?ft.clamp(Math.round(n._anisotropy),1,t.maxTextureAnisotropy):1,i=t.wgpu.createSampler(s),this.samplers[e]=i}return i},e.loseContext=function(){},e.uploadImmediate=function(t,e){(e._needsUpload||e._needsMipmapsUpload)&&(this.uploadData(t),e._needsUpload=!1,e._needsMipmapsUpload=!1)},e.uploadData=function(t){var e=this.texture;if(e._levels){for(var i=!1,n=!1,s=e.requiredMipLevels,r=0;r<=|&+-]/g,Bs=/include[ \t]+"([\w-]+)"\r?(?:\n|$)/g,Ns=function(){function t(){}return t.run=function(t,e,i){void 0===e&&(e=new Map),void 0===i&&(i=!1),t=(t=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1")).split(/\r?\n/).map((function(t){return t.trimEnd()})).join("\n");var n=new Map;if(i){var s=new Map,r=t.match(/(pcFragColor[1-8])\b/g);null==r||r.forEach((function(t){var e,i=parseInt(t.charAt(t.length-1),10);s.set(i,(null!=(e=s.get(i))?e:0)+1)})),s.forEach((function(t,e){1===t&&n.set("REMOVE_COLOR_ATTACHMENT_"+e,"")}))}t=this._preprocess(t,n,e);var a=new Map;return n.forEach((function(t,e){Number.isInteger(parseFloat(t))&&!t.includes(".")&&a.set(e,t)})),t=this.RemoveEmptyLines(t),t=this.processArraySize(t,a)},t.processArraySize=function(t,e){return null!==t&&e.forEach((function(e,i){t=t.replace(new RegExp("\\["+i+"\\]","g"),"["+e+"]")})),t},t.RemoveEmptyLines=function(t){return null!==t&&(t=(t=t.split(/\r?\n/).map((function(t){return""===t.trim()?"":t})).join("\n")).replace(/(\n\n){3,}/g,"\n\n")),t},t._preprocess=function(e,i,n){void 0===i&&(i=new Map);for(var s,r=e,a=[],o=!1;null!==(s=Ms.exec(e));){var h=s[1];switch(h){case"define":Ps.lastIndex=s.index;var l=Ps.exec(e);o||(o=null===l);var c=l[1];ks.lastIndex=l.index;var u=ks.exec(c)[1],d=c.substring(u.length).trim();""===d&&(d="true"),t._keep(a)&&i.set(u,d),Ms.lastIndex=l.index+l[0].length;break;case"undef":Is.lastIndex=s.index;var f=Is.exec(e),p=f[1].trim();t._keep(a)&&i.delete(p),Ms.lastIndex=f.index+f[0].length;break;case"extension":Rs.lastIndex=s.index;var m=Rs.exec(e);if(o||(o=null===m),m){var _=m[1];t._keep(a)&&i.set(_,"true")}Ms.lastIndex=m.index+m[0].length;break;case"ifdef":case"ifndef":case"if":Ds.lastIndex=s.index;var v=Ds.exec(e),g=v[2],y=t.evaluate(g,i);o||(o=y.error);var x=y.result;"ifndef"===h&&(x=!x),a.push({anyKeep:x,keep:x,start:s.index,end:Ds.lastIndex}),Ms.lastIndex=v.index+v[0].length;break;case"endif":case"else":case"elif":Ls.lastIndex=s.index;var S=Ls.exec(e),b=a.pop(),T=b.keep?e.substring(b.end,s.index):"";e=e.substring(0,b.start)+T+e.substring(Ls.lastIndex),Ms.lastIndex=b.start+T.length;var w=S[1];if("else"===w||"elif"===w){var E=!1;if(!b.anyKeep)if("else"===w)E=!b.keep;else{var A=t.evaluate(S[2],i);E=A.result,o||(o=A.error)}a.push({anyKeep:b.anyKeep||E,keep:E,start:Ms.lastIndex,end:Ms.lastIndex})}break;case"include":Bs.lastIndex=s.index;var C=Bs.exec(e);o||(o=null===C);var M=C[1].trim();if(t._keep(a)){var P=null==n?void 0:n.get(M);P?(e=e.substring(0,C.index-1)+P+e.substring(Bs.lastIndex),Ms.lastIndex=C.index):(console.error("Include not found: "+M),o=!0)}}}return o?(console.warn("Failed to preprocess shader: ",{source:r}),r):e},t._keep=function(t){for(var e=0;e=0;r--){var a=this.usedBuffers[r],o=a.stagingBuffer,h=a.gpuBuffer,l=a.offset,c=a.size,u=o.buffer;u.unmap(),s.copyBufferToBuffer(u,l,h.buffer,l,c),n.push(h)}var d=s.finish();i.addCommandBuffer(d,!0);for(var f=0;f0&&(this._frameTime=e[0]),w.get(a))for(var n=0;n0&&(this.dynamicBuffers.submit(),this.wgpu.queue.submit(this.commandBuffers),this.commandBuffers.length=0,this.dynamicBuffers.onCommandBuffersSubmitted())},n.clear=function(t){t.flags&&this.clearRenderer.clear(this,this.renderTarget,t,this.defaultClearOptions)},n.setViewport=function(t,e,i,n){this.passEncoder&&(this.renderTarget.flipY||(e=this.renderTarget.height-e-n),this.vx=t,this.vy=e,this.vw=i,this.vh=n,this.passEncoder.setViewport(t,e,i,n,0,1))},n.setScissor=function(t,e,i,n){this.passEncoder&&(this.renderTarget.flipY||(e=this.renderTarget.height-e-n),this.sx=t,this.sy=e,this.sw=i,this.sh=n,this.passEncoder.setScissorRect(t,e,i,n))},n.clearStorageBuffer=function(t,e,i){var n;void 0===e&&(e=0),void 0===i&&(i=t.byteSize);var s=null!=(n=this.commandEncoder)?n:this.wgpu.createCommandEncoder();if(s.clearBuffer(t.buffer,e,i),!this.commandEncoder){var r=s.finish();this.addCommandBuffer(r)}},n.readStorageBuffer=function(t,e,i,n,s){var r,a=this;void 0===e&&(e=0),void 0===i&&(i=t.byteSize-e),void 0===n&&(n=null),void 0===s&&(s=!1);var o=this.createBufferImpl(9);o.allocate(this,i);var h=o.buffer,l=null!=(r=this.commandEncoder)?r:this.wgpu.createCommandEncoder();if(l.copyBufferToBuffer(t.buffer,e,h,0,i),!this.commandEncoder){var c=l.finish();this.addCommandBuffer(c)}return new Promise((function(t,e){var r=function(){null==h||h.mapAsync(GPUMapMode.READ).then((function(){null!=n||(n=new Uint8Array(i));var e=h.getMappedRange(0,i),s=n.constructor;n.set(new s(e)),h.unmap(),o.destroy(a),t(n)}))};s?(a.submit(),r()):setTimeout((function(){r()}))}))},n.writeStorageBuffer=function(t,e,i,n,s){void 0===e&&(e=0),void 0===n&&(n=0),this.wgpu.queue.writeBuffer(t.buffer,e,i,n,s)},n.copyRenderTarget=function(t,e,i,n){var s,r={width:t?t.width:e.width,height:t?t.height:e.height,depthOrArrayLayers:1},a=null!=(s=this.commandEncoder)?s:this.wgpu.createCommandEncoder();if(i){var o={texture:t?t.colorBuffer.impl.gpuTexture:this.renderTarget.impl.assignedColorTexture,mipLevel:0},h={texture:e?e.colorBuffer.impl.gpuTexture:this.renderTarget.impl.assignedColorTexture,mipLevel:0};a.copyTextureToTexture(o,h,r)}if(n){var l=(t||this.renderTarget).impl.depthTexture;if(t.samples>1){var c=e.colorBuffer.impl.gpuTexture;this.resolver.resolveDepth(a,l,c)}else{var u={texture:l,mipLevel:0},d={texture:e?e.depthBuffer.impl.gpuTexture:this.renderTarget.impl.depthTexture,mipLevel:0};a.copyTextureToTexture(u,d,r)}}if(!this.commandEncoder){var f=a.finish();this.addCommandBuffer(f)}return!0},e}(En),ar=0,or=function(){function t(t,e){var i,n,s,r,a,o,h,l,c,u,d,f,p,m,_,v,g,y,x,S,b,T;(void 0===e&&(e={}),this.name=void 0,this._gpuSize=0,this.id=ar++,this._invalid=!1,this._lockedLevel=-1,this._lockedMode=0,this.renderVersionDirty=0,this._storage=!1,this.device=t,this.name=null!=(i=e.name)?i:"",this._width=Math.floor(null!=(n=e.width)?n:4),this._height=Math.floor(null!=(s=e.height)?s:4),this._format=null!=(r=e.format)?r:7,this._compressed=Re(this._format),this._integerFormat=Ie(this._format),this._integerFormat&&(e.mipmaps=!1,e.minFilter=0,e.magFilter=0),t.supportsVolumeTextures)?(this._volume=null!=(S=e.volume)&&S,this._depth=Math.floor(null!=(b=e.depth)?b:1),this._arrayLength=Math.floor(null!=(T=e.arrayLength)?T:0)):(this._volume=!1,this._depth=1,this._arrayLength=0);this._storage=null!=(a=e.storage)&&a,this._cubemap=null!=(o=e.cubemap)&&o,this.fixCubemapSeams=null!=(h=e.fixCubemapSeams)&&h,this._flipY=null!=(l=e.flipY)&&l,this._premultiplyAlpha=null!=(c=e.premultiplyAlpha)&&c,this._mipmaps=null==(u=null!=(d=e.mipmaps)?d:e.autoMipmap)||u,this._minFilter=null!=(f=e.minFilter)?f:5,this._magFilter=null!=(p=e.magFilter)?p:1,this._anisotropy=null!=(m=e.anisotropy)?m:1,this._addressU=null!=(_=e.addressU)?_:0,this._addressV=null!=(v=e.addressV)?v:0,this._addressW=null!=(g=e.addressW)?g:0,this._compareOnRead=null!=(y=e.compareOnRead)&&y,this._compareFunc=null!=(x=e.compareFunc)?x:1,this.type=ui,e.hasOwnProperty("type")?this.type=e.type:e.hasOwnProperty("rgbm")?this.type=e.rgbm?di:ui:e.hasOwnProperty("swizzleGGGR")&&(this.type=e.swizzleGGGR?mi:ui),this.projection=xi,this._cubemap?this.projection=Si:e.projection&&e.projection!==Si&&(this.projection=e.projection),this.impl=t.createTextureImpl(this),this.dirtyAll(),this._levels=e.levels,this._levels?this.upload():this._levels=this._cubemap?[[null,null,null,null,null,null]]:[null],t.textures.push(this)}var e,i=t.prototype;return i.destroy=function(){var t=this.device;if(t){var e=t.textures.indexOf(this);-1!==e&&t.textures.splice(e,1),t.scope.removeValue(this),this.impl.destroy(t),this.adjustVramSizeTracking(t._vram,-this._gpuSize),this._levels=null,this.device=null}},i.resize=function(t,e,i){void 0===i&&(i=1);var n=this.device;this.adjustVramSizeTracking(n._vram,-this._gpuSize),this.impl.destroy(n),this._width=Math.floor(t),this._height=Math.floor(e),this._depth=Math.floor(i),this.impl=n.createTextureImpl(this),this.dirtyAll()},i.loseContext=function(){this.impl.loseContext(),this.dirtyAll()},i.adjustVramSizeTracking=function(t,e){t.tex+=e},i.propertyChanged=function(t){this.impl.propertyChanged(t),this.renderVersionDirty=this.device.renderVersion},i.dirtyAll=function(){this._levelsUpdated=this._cubemap?[[!0,!0,!0,!0,!0,!0]]:[!0],this._needsUpload=!0,this._needsMipmapsUpload=this._mipmaps,this._mipmapsUploaded=!1,this.propertyChanged(255)},i.lock=function(t){var e,i,n;void 0===t&&(t={}),null!=(e=t).level||(e.level=0),null!=(i=t).face||(i.face=0),null!=(n=t).mode||(n.mode=2),this._lockedMode=t.mode,this._lockedLevel=t.level;var s=this.cubemap?this._levels[t.face]:this._levels;if(null===s[t.level]){var r=Math.max(1,this._width>>t.level),a=Math.max(1,this._height>>t.level),o=Math.max(1,this._depth>>t.level),h=new ArrayBuffer(bs.calcLevelGpuSize(r,a,o,this._format));s[t.level]=new(De(this._format))(h)}return s[t.level]},i.setSource=function(t,e){void 0===e&&(e=0);var i,n,s=!1;if(this._cubemap){if(t[0]){i=t[0].width||0,n=t[0].height||0;for(var r=0;r<6;r++){var a=t[r];if(!a||a.width!==i||a.height!==n||!this.device._isBrowserInterface(a)){s=!0;break}}}else s=!0;if(!s)for(var o=0;o<6;o++)this._levels[e][o]!==t[o]&&(this._levelsUpdated[e][o]=!0)}else this.device._isBrowserInterface(t)||(s=!0),s||(t!==this._levels[e]&&(this._levelsUpdated[e]=!0),i=t.width,n=t.height);if(s)if(this._width=4,this._height=4,this._cubemap)for(var h=0;h<6;h++)this._levels[e][h]=null,this._levelsUpdated[e][h]=!0;else this._levels[e]=null,this._levelsUpdated[e]=!0;else 0===e&&(this._width=i,this._height=n),this._levels[e]=t;this._invalid===s&&s||(this._invalid=s,this.upload())},i.getSource=function(t){return void 0===t&&(t=0),this._levels[t]},i.unlock=function(){this._lockedMode,2===this._lockedMode&&this.upload(),this._lockedLevel=-1,this._lockedMode=0},i.upload=function(){var t,e;this._needsUpload=!0,this._needsMipmapsUpload=this._mipmaps,null==(t=(e=this.impl).uploadImmediate)||t.call(e,this.device,this)},i.downloadAsync=(e=m(S().mark((function t(){var e,i,n,s=this;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=[],i=S().mark((function t(){var i,r,a,o;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=new Cn({colorBuffer:s,depth:!1,face:n}),s.device.setRenderTarget(i),s.device.initRenderTarget(i),(r=s.cubemap?s._levels[n]:s._levels)[0],r[0]&&s.device._isBrowserInterface(r[0])&&(r[0]=null),a=s.lock({face:n}),o=null==s.device.readPixelsAsync?void 0:s.device.readPixelsAsync(0,0,s.width,s.height,a).then((function(){return i.destroy()})),e.push(o);case 9:case"end":return t.stop()}}),t)})),n=0;case 3:if(!(n<(this.cubemap?6:1))){t.next=8;break}return t.delegateYield(i(),"t0",5);case 5:n++,t.next=3;break;case 8:return t.next=10,Promise.all(e);case 10:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)}),v(t,[{key:"requiredMipLevels",get:function(){return this.mipmaps?bs.calcMipLevelsCount(this.width,this.height):1}},{key:"lockedMode",get:function(){return this._lockedMode}},{key:"minFilter",get:function(){return this._minFilter},set:function(t){this._minFilter!==t&&(Ie(this._format)||(this._minFilter=t,this.propertyChanged(1)))}},{key:"magFilter",get:function(){return this._magFilter},set:function(t){this._magFilter!==t&&(Ie(this._format)||(this._magFilter=t,this.propertyChanged(2)))}},{key:"addressU",get:function(){return this._addressU},set:function(t){this._addressU!==t&&(this._addressU=t,this.propertyChanged(4))}},{key:"addressV",get:function(){return this._addressV},set:function(t){this._addressV!==t&&(this._addressV=t,this.propertyChanged(8))}},{key:"addressW",get:function(){return this._addressW},set:function(t){this.device.supportsVolumeTextures&&this._volume&&t!==this._addressW&&(this._addressW=t,this.propertyChanged(16))}},{key:"compareOnRead",get:function(){return this._compareOnRead},set:function(t){this._compareOnRead!==t&&(this._compareOnRead=t,this.propertyChanged(32))}},{key:"compareFunc",get:function(){return this._compareFunc},set:function(t){this._compareFunc!==t&&(this._compareFunc=t,this.propertyChanged(64))}},{key:"anisotropy",get:function(){return this._anisotropy},set:function(t){this._anisotropy!==t&&(this._anisotropy=t,this.propertyChanged(128))}},{key:"mipmaps",get:function(){return this._mipmaps},set:function(t){this._mipmaps!==t&&(this.device.isWebGPU||Ie(this._format)||(this._mipmaps=t),t&&(this._needsMipmapsUpload=!0))}},{key:"storage",get:function(){return this._storage}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"depth",get:function(){return this._depth}},{key:"format",get:function(){return this._format}},{key:"cubemap",get:function(){return this._cubemap}},{key:"gpuSize",get:function(){var t=this.pot&&this._mipmaps&&!(this._compressed&&1===this._levels.length);return bs.calcGpuSize(this._width,this._height,this._depth,this._format,t,this._cubemap)}},{key:"array",get:function(){return this._arrayLength>0}},{key:"arrayLength",get:function(){return this._arrayLength}},{key:"volume",get:function(){return this._volume}},{key:"flipY",get:function(){return this._flipY},set:function(t){this._flipY!==t&&(this._flipY=t,this._needsUpload=!0)}},{key:"premultiplyAlpha",get:function(){return this._premultiplyAlpha},set:function(t){this._premultiplyAlpha!==t&&(this._premultiplyAlpha=t,this._needsUpload=!0)}},{key:"pot",get:function(){return ft.powerOfTwo(this._width)&&ft.powerOfTwo(this._height)}},{key:"encoding",get:function(){switch(this.type){case di:return"rgbm";case fi:return"rgbe";case pi:return"rgbp";default:return this.format===pe||this.format===_e||this.format===me||this.format===ve||Ie(this.format)?"linear":"srgb"}}}])}(),hr=function(){function t(){this.bufferId=null}var e=t.prototype;return e.destroy=function(t){this.bufferId&&(t.gl.deleteBuffer(this.bufferId),this.bufferId=null)},e.loseContext=function(){this.bufferId=null},e.unlock=function(t,e,i,n){var s=t.gl;if(this.bufferId)s.bindBuffer(i,this.bufferId),s.bufferSubData(i,0,n);else{var r;switch(e){case 0:r=s.STATIC_DRAW;break;case 1:r=s.DYNAMIC_DRAW;break;case 2:r=s.STREAM_DRAW;break;case 3:r=t.isWebGL2?s.DYNAMIC_COPY:s.STATIC_DRAW}this.bufferId=s.createBuffer(),s.bindBuffer(i,this.bufferId),s.bufferData(i,n,r)}},v(t,[{key:"initialized",get:function(){return!!this.bufferId}}])}(),lr=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),s=0;se||n>e){var s=e/Math.max(i,n),r=Math.floor(i*s),a=Math.floor(n*s),o=document.createElement("canvas");return o.width=r,o.height=a,o.getContext("2d").drawImage(t,0,0,i,n,0,0,r,a),o}return t}var gr=function(){function t(){this._glTexture=null,this._glTarget=void 0,this._glFormat=void 0,this._glInternalFormat=void 0,this._glPixelType=void 0,this._glCreated=void 0,this.dirtyParameterFlags=0}var e=t.prototype;return e.destroy=function(t){if(this._glTexture){for(var e=0;et.maxCubeMapSize||h.height>t.maxCubeMapSize)&&(h=vr(h,t.maxCubeMapSize),0===r&&(e._width=h.width,e._height=h.height)),t.setUnpackFlipY(!1),t.setUnpackPremultiplyAlpha(e._premultiplyAlpha),this._glCreated?i.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,0,0,this._glFormat,this._glPixelType,h):i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,this._glInternalFormat,this._glFormat,this._glPixelType,h)}}else for(s=1/Math.pow(2,r),o=0;o<6;o++)if(e._levelsUpdated[0][o]){var l=n[o];e._compressed?this._glCreated&&l?i.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,0,0,Math.max(e._width*s,1),Math.max(e._height*s,1),this._glInternalFormat,l):i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,this._glInternalFormat,Math.max(e._width*s,1),Math.max(e._height*s,1),0,l):(t.setUnpackFlipY(!1),t.setUnpackPremultiplyAlpha(e._premultiplyAlpha),this._glCreated&&l?i.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,0,0,Math.max(e._width*s,1),Math.max(e._height*s,1),this._glFormat,this._glPixelType,l):i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,this._glInternalFormat,Math.max(e._width*s,1),Math.max(e._height*s,1),0,this._glFormat,this._glPixelType,l))}}else if(e._volume)e._compressed?i.compressedTexImage3D(i.TEXTURE_3D,r,this._glInternalFormat,Math.max(e._width*s,1),Math.max(e._height*s,1),Math.max(e._depth*s,1),0,n):(t.setUnpackFlipY(!1),t.setUnpackPremultiplyAlpha(e._premultiplyAlpha),i.texImage3D(i.TEXTURE_3D,r,this._glInternalFormat,Math.max(e._width*s,1),Math.max(e._height*s,1),Math.max(e._depth*s,1),0,this._glFormat,this._glPixelType,n));else if(e.array&&"object"==typeof n){if(e._arrayLength===n.length)if(e._compressed)for(var c=0;ct.maxTextureSize||n.height>t.maxTextureSize)&&(n=vr(n,t.maxTextureSize),0===r&&(e._width=n.width,e._height=n.height));var d=n.width||n.videoWidth,f=n.height||n.videoHeight;t.setUnpackFlipY(e._flipY),t.setUnpackPremultiplyAlpha(e._premultiplyAlpha),this._glCreated&&e._width===d&&e._height===f&&!t._isImageVideoInterface(n)?i.texSubImage2D(i.TEXTURE_2D,r,0,0,this._glFormat,this._glPixelType,n):(i.texImage2D(i.TEXTURE_2D,r,this._glInternalFormat,this._glFormat,this._glPixelType,n),0===r&&(e._width=d,e._height=f))}else s=1/Math.pow(2,r),e._compressed?this._glCreated&&n?i.compressedTexSubImage2D(i.TEXTURE_2D,r,0,0,Math.max(Math.floor(e._width*s),1),Math.max(Math.floor(e._height*s),1),this._glInternalFormat,n):i.compressedTexImage2D(i.TEXTURE_2D,r,this._glInternalFormat,Math.max(Math.floor(e._width*s),1),Math.max(Math.floor(e._height*s),1),0,n):(t.setUnpackFlipY(!1),t.setUnpackPremultiplyAlpha(e._premultiplyAlpha),this._glCreated&&n?i.texSubImage2D(i.TEXTURE_2D,r,0,0,Math.max(e._width*s,1),Math.max(e._height*s,1),this._glFormat,this._glPixelType,n):i.texImage2D(i.TEXTURE_2D,r,this._glInternalFormat,Math.max(e._width*s,1),Math.max(e._height*s,1),0,this._glFormat,this._glPixelType,n));e._mipmapsUploaded=0!==r}r++}else r++;if(e._needsUpload)if(e._cubemap)for(var p=0;p<6;p++)e._levelsUpdated[0][p]=!1;else e._levelsUpdated[0]=!1;!e._compressed&&!e._integerFormat&&e._mipmaps&&e._needsMipmapsUpload&&(e.pot||t.isWebGL2)&&1===e._levels.length&&(i.generateMipmap(this._glTarget),e._mipmapsUploaded=!0),e._gpuSize&&e.adjustVramSizeTracking(t._vram,-e._gpuSize),e._gpuSize=e.gpuSize,e.adjustVramSizeTracking(t._vram,e._gpuSize),this._glCreated=!0}},t}(),yr=function(){function t(t,e){this.msaaFB=void 0,this.resolveFB=void 0,this.msaaFB=t,this.resolveFB=e}return t.prototype.destroy=function(t){this.msaaFB&&(t.deleteRenderbuffer(this.msaaFB),this.msaaFB=null),this.resolveFB&&(t.deleteRenderbuffer(this.resolveFB),this.resolveFB=null)},t}(),xr=function(){function t(){this._glFrameBuffer=null,this._glDepthBuffer=null,this._glResolveFrameBuffer=null,this.colorMrtFramebuffers=null,this._glMsaaColorBuffers=[],this._glMsaaDepthBuffer=null,this.suppliedColorFramebuffer=void 0,this._isInitialized=!1}var e=t.prototype;return e.destroy=function(t){var e,i=t.gl;this._isInitialized=!1,this._glFrameBuffer&&(this._glFrameBuffer!==this.suppliedColorFramebuffer&&i.deleteFramebuffer(this._glFrameBuffer),this._glFrameBuffer=null),this._glDepthBuffer&&(i.deleteRenderbuffer(this._glDepthBuffer),this._glDepthBuffer=null),this._glResolveFrameBuffer&&(this._glResolveFrameBuffer!==this.suppliedColorFramebuffer&&i.deleteFramebuffer(this._glResolveFrameBuffer),this._glResolveFrameBuffer=null),this._glMsaaColorBuffers.forEach((function(t){i.deleteRenderbuffer(t)})),this._glMsaaColorBuffers.length=0,null==(e=this.colorMrtFramebuffers)||e.forEach((function(t){t.destroy(i)})),this.colorMrtFramebuffers=null,this._glMsaaDepthBuffer&&(i.deleteRenderbuffer(this._glMsaaDepthBuffer),this._glMsaaDepthBuffer=null),this.suppliedColorFramebuffer=void 0},e.init=function(t,e){var i=t.gl;this._isInitialized=!0;var n=[];if(void 0!==this.suppliedColorFramebuffer)this._glFrameBuffer=this.suppliedColorFramebuffer;else{var s,r,a,o;this._glFrameBuffer=i.createFramebuffer(),t.setFramebuffer(this._glFrameBuffer);for(var h=null!=(s=null==(r=e._colorBuffers)?void 0:r.length)?s:0,l=t.isWebGL2?i.COLOR_ATTACHMENT0:null!=(a=null==(o=t.extDrawBuffers)?void 0:o.COLOR_ATTACHMENT0_WEBGL)?a:i.COLOR_ATTACHMENT0,c=0;c1&&t.isWebGL2)){if(this._glDepthBuffer||(this._glDepthBuffer=i.createRenderbuffer()),i.bindRenderbuffer(i.RENDERBUFFER,this._glDepthBuffer),e._stencil)i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,this._glDepthBuffer);else{var f=t.isWebGL2?i.DEPTH_COMPONENT32F:i.DEPTH_COMPONENT16;i.renderbufferStorage(i.RENDERBUFFER,f,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,this._glDepthBuffer)}i.bindRenderbuffer(i.RENDERBUFFER,null)}}}if(t.isWebGL2&&e._samples>1){var p,m;this._glResolveFrameBuffer=this._glFrameBuffer,this._glFrameBuffer=i.createFramebuffer(),t.setFramebuffer(this._glFrameBuffer);var _=null!=(p=null==(m=e._colorBuffers)?void 0:m.length)?p:0;if(void 0!==this.suppliedColorFramebuffer){var v=i.createRenderbuffer();this._glMsaaColorBuffers.push(v);var g=7===t.backBufferFormat?i.RGBA8:i.RGB8;i.bindRenderbuffer(i.RENDERBUFFER,v),i.renderbufferStorageMultisample(i.RENDERBUFFER,e._samples,g,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,v)}else for(var y=0;y<_;++y){var x=e.getColorBuffer(y);if(x){var S=i.createRenderbuffer();this._glMsaaColorBuffers.push(S),i.bindRenderbuffer(i.RENDERBUFFER,S),i.renderbufferStorageMultisample(i.RENDERBUFFER,e._samples,x.impl._glInternalFormat,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+y,i.RENDERBUFFER,S)}}e._depth&&(this._glMsaaDepthBuffer||(this._glMsaaDepthBuffer=i.createRenderbuffer()),i.bindRenderbuffer(i.RENDERBUFFER,this._glMsaaDepthBuffer),e._stencil?(i.renderbufferStorageMultisample(i.RENDERBUFFER,e._samples,i.DEPTH24_STENCIL8,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,this._glMsaaDepthBuffer)):(i.renderbufferStorageMultisample(i.RENDERBUFFER,e._samples,i.DEPTH_COMPONENT32F,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,this._glMsaaDepthBuffer))),_>1&&(this._createMsaaMrtFramebuffers(t,e,_),t.setFramebuffer(this._glFrameBuffer),t.drawBuffers(n))}},e._createMsaaMrtFramebuffers=function(t,e,i){var n=t.gl;this.colorMrtFramebuffers=[];for(var s=0;s=0&&!(n>0&&"/"===t[n-1]);){var s=t.indexOf(";",n),r=t.lastIndexOf(" ",s),a=t.substring(r+1,s);if(e[a]);else{var o=Mr[a];void 0!==o?e[a]=o:(e[a]="ATTR"+i,i++)}n=t.indexOf("attribute",n+1)}return e},t}(),Rr=function(){function t(){this.renderVersion=void 0,this.queries=[]}return t.prototype.destroy=function(t){this.queries.forEach((function(e){return t.deleteQuery(e)})),this.queries=null},t}(),Ir=function(t){function e(e){var i;return(i=t.call(this)||this).device=void 0,i.freeQueries=[],i.frameQueries=[],i.previousFrameQueries=[],i.timings=[],i.device=e,i.ext=e.extDisjointTimerQuery,i}x(e,t);var i=e.prototype;return i.destroy=function(){var t=this;this.freeQueries.forEach((function(e){return t.device.gl.deleteQuery(e)})),this.frameQueries.forEach((function(e){return t.device.gl.deleteQuery(e)})),this.previousFrameQueries.forEach((function(e){return e.destroy(t.device.gl)})),this.freeQueries=null,this.frameQueries=null,this.previousFrameQueries=null},i.loseContext=function(){t.prototype.loseContext.call(this),this.freeQueries=[],this.frameQueries=[],this.previousFrameQueries=[]},i.restoreContext=function(){this.ext=this.device.extDisjointTimerQuery},i.getQuery=function(){var t;return null!=(t=this.freeQueries.pop())?t:this.device.gl.createQuery()},i.start=function(t){if(this.ext){var e=this.getSlot(t),i=this.getQuery();return this.frameQueries[e]=i,this.device.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,i),e}},i.end=function(t){void 0!==t&&this.device.gl.endQuery(this.ext.TIME_ELAPSED_EXT)},i.frameStart=function(){this.processEnableRequest(),this._enabled&&(this.frameGPUMarkerSlot=this.start("GpuFrame"))},i.frameEnd=function(){this._enabled&&this.end(this.frameGPUMarkerSlot)},i.request=function(){var e=this;if(this._enabled){var i=this.ext,n=this.device.gl,s=this.device.renderVersion,r=this.frameQueries;if(r.length>0){this.frameQueries=[];var a=new Rr;a.queries=r,a.renderVersion=s,this.previousFrameQueries.push(a)}if(this.previousFrameQueries.length>0){var o=this.previousFrameQueries[0],h=o.queries,l=h[h.length-1],c=n.getQueryParameter(l,n.QUERY_RESULT_AVAILABLE),u=n.getParameter(i.GPU_DISJOINT_EXT);if(c&&!u){this.previousFrameQueries.shift();var d=this.timings;d.length=0;for(var f=0;f=120||115===h)||"android"===G.name&&h>=132)&&(i.antialias=!1)}}var l=null;if(s.backBufferAntialias=null!=(n=i.antialias)&&n,i.antialias=!1,i.gl)l=i.gl;else for(var c=void 0===i.preferWebGl2||i.preferWebGl2?["webgl2","webgl","experimental-webgl"]:["webgl","experimental-webgl"],u=0;u0;var x=s.vertexUniformsCount;return x-=16,x-=8,x-=1,x-=16,s.boneLimit=Math.floor(x/3),s.boneLimit=Math.min(s.boneLimit,128),s.constantTexSource=s.scope.resolve("source"),s.extTextureFloat?s.isWebGL2?s.textureFloatRenderable=!!s.extColorBufferFloat:s.textureFloatRenderable=Or(l,l.FLOAT):s.textureFloatRenderable=!1,s.extColorBufferHalfFloat?s.textureHalfFloatRenderable=!!s.extColorBufferHalfFloat:s.extTextureHalfFloat?s.isWebGL2?s.textureHalfFloatRenderable=!!s.extColorBufferFloat:s.textureHalfFloatRenderable=Or(l,s.extTextureHalfFloat.HALF_FLOAT_OES):s.textureHalfFloatRenderable=!1,s.supportsMorphTargetTexturesCore="highp"===s.maxPrecision&&s.maxVertexTextures>=2,s.supportsDepthShadow=s.isWebGL2,s._textureFloatHighPrecision=void 0,s._textureHalfFloatUpdatable=void 0,s.areaLightLutFormat=7,s.extTextureHalfFloat&&s.textureHalfFloatUpdatable&&s.extTextureHalfFloatLinear?s.areaLightLutFormat=me:s.extTextureFloat&&s.extTextureFloatLinear&&(s.areaLightLutFormat=ve),s.postInit(),s}x(e,t);var i,n=e.prototype;return n.postInit=function(){t.prototype.postInit.call(this),this.gpuProfiler=new Ir(this)},n.destroy=function(){t.prototype.destroy.call(this);var e=this.gl;this.isWebGL2&&this.feedback&&e.deleteTransformFeedback(this.feedback),this.clearVertexArrayObjectCache(),this.canvas.removeEventListener("webglcontextlost",this._contextLostHandler,!1),this.canvas.removeEventListener("webglcontextrestored",this._contextRestoredHandler,!1),this._contextLostHandler=null,this._contextRestoredHandler=null,this.gl=null,t.prototype.postDestroy.call(this)},n.createBackbuffer=function(t){this.supportsStencil=this.initOptions.stencil,this.backBuffer=new Cn({name:"WebglFramebuffer",graphicsDevice:this,depth:this.initOptions.depth,stencil:this.supportsStencil,samples:this.samples}),this.backBuffer.impl.suppliedColorFramebuffer=t},n.updateBackbufferFormat=function(t){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t);var i=this.gl.getParameter(this.gl.ALPHA_BITS);this.backBufferFormat=i?7:6},n.updateBackbuffer=function(){var t=this.canvas.width!==this.backBufferSize.x||this.canvas.height!==this.backBufferSize.y;(this._defaultFramebufferChanged||t)&&(this._defaultFramebufferChanged&&this.updateBackbufferFormat(this._defaultFramebuffer),this._defaultFramebufferChanged=!1,this.backBufferSize.set(this.canvas.width,this.canvas.height),this.backBuffer.destroy(),this.createBackbuffer(this._defaultFramebuffer))},n.createVertexBufferImpl=function(t,e){return new lr},n.createIndexBufferImpl=function(t){return new cr(t)},n.createShaderImpl=function(t){return new _r(t)},n.createTextureImpl=function(t){return new gr},n.createRenderTargetImpl=function(t){return new xr},n.getPrecision=function(){var t=this.gl,e="highp";if(t.getShaderPrecisionFormat){var i=t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT),n=t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT),s=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT),r=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT);if(i&&n&&s&&r){var a=i.precision>0&&s.precision>0,o=n.precision>0&&r.precision>0;a||(e=o?"mediump":"lowp")}}return e},n.getExtension=function(){for(var t=0;t0&&t.fullSizeClearRect&&s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Dr)}null!=(n=t.colorOps)&&n.resolve&&this.isWebGL2&&t.samples>1&&e.autoResolve&&e.resolve(!0,!1);for(var o=0;o1&&t.autoResolve&&t.resolve();var e=t._colorBuffer;e&&e.impl._glTexture&&e.mipmaps&&(e.pot||this.isWebGL2)&&(this.activeTexture(this.maxCombinedTextures-1),this.bindTexture(e),this.gl.generateMipmap(e.impl._glTarget))}},n.setUnpackFlipY=function(t){if(this.unpackFlipY!==t){this.unpackFlipY=t;var e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t)}},n.setUnpackPremultiplyAlpha=function(t){if(this.unpackPremultiplyAlpha!==t){this.unpackPremultiplyAlpha=t;var e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t)}},n.activeTexture=function(t){this.textureUnit!==t&&(this.gl.activeTexture(this.gl.TEXTURE0+t),this.textureUnit=t)},n.bindTexture=function(t){var e=t.impl,i=e._glTarget,n=e._glTexture,s=this.textureUnit,r=this.targetToSlot[i];this.textureUnits[s][r]!==n&&(this.gl.bindTexture(i,n),this.textureUnits[s][r]=n)},n.bindTextureOnUnit=function(t,e){var i=t.impl,n=i._glTarget,s=i._glTexture,r=this.targetToSlot[n];this.textureUnits[e][r]!==s&&(this.activeTexture(e),this.gl.bindTexture(n,s),this.textureUnits[e][r]=s)},n.setTextureParameters=function(t){var e=this.gl,i=t.impl.dirtyParameterFlags,n=t.impl._glTarget;if(1&i){var s=t._minFilter;(!t.pot&&!this.isWebGL2||!t._mipmaps||t._compressed&&1===t._levels.length)&&(2===s||3===s?s=0:4!==s&&5!==s||(s=1)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,this.glFilter[s])}if(2&i&&e.texParameteri(n,e.TEXTURE_MAG_FILTER,this.glFilter[t._magFilter]),4&i&&(this.isWebGL2?e.texParameteri(n,e.TEXTURE_WRAP_S,this.glAddress[t._addressU]):e.texParameteri(n,e.TEXTURE_WRAP_S,this.glAddress[t.pot?t._addressU:1])),8&i&&(this.isWebGL2?e.texParameteri(n,e.TEXTURE_WRAP_T,this.glAddress[t._addressV]):e.texParameteri(n,e.TEXTURE_WRAP_T,this.glAddress[t.pot?t._addressV:1])),16&i&&this.isWebGL2&&e.texParameteri(n,e.TEXTURE_WRAP_R,this.glAddress[t._addressW]),32&i&&this.isWebGL2&&e.texParameteri(n,e.TEXTURE_COMPARE_MODE,t._compareOnRead?e.COMPARE_REF_TO_TEXTURE:e.NONE),64&i&&this.isWebGL2&&e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,this.glComparison[t._compareFunc]),128&i){var r=this.extTextureFilterAnisotropic;r&&e.texParameterf(n,r.TEXTURE_MAX_ANISOTROPY_EXT,ft.clamp(Math.round(t._anisotropy),1,this.maxAnisotropy))}},n.setTexture=function(t,e){var i=t.impl;i._glTexture||i.initialize(this,t),i.dirtyParameterFlags>0||t._needsUpload||t._needsMipmapsUpload?(this.activeTexture(e),this.bindTexture(t),i.dirtyParameterFlags&&(this.setTextureParameters(t),i.dirtyParameterFlags=0),(t._needsUpload||t._needsMipmapsUpload)&&(i.upload(this,t),t._needsUpload=!1,t._needsMipmapsUpload=!1)):this.bindTextureOnUnit(t,e)},n.createVertexArray=function(t){var e,i,n=t.length>1;if(n){e="";for(var s=0;s0?n.drawElementsInstanced(S,b,w,E,e):n.drawElements(S,b,w,E)}else{var A=t.base;e>0?n.drawArraysInstanced(S,A,b,e):n.drawArrays(S,A,b)}this.isWebGL2&&this.transformFeedbackBuffer&&(n.endTransformFeedback(),n.bindBufferBase(n.TRANSFORM_FEEDBACK_BUFFER,0,null)),this._drawCallsPerFrame++}}},n.clear=function(t){var e,i=this.defaultClearOptions,n=null!=(e=(t=t||i).flags)?e:i.flags;if(0!==n){var s=this.gl;if(1&n){var r,a=null!=(r=t.color)?r:i.color,o=a[0],h=a[1],l=a[2],c=a[3],u=this.clearColor;o===u.r&&h===u.g&&l===u.b&&c===u.a||(this.gl.clearColor(o,h,l,c),this.clearColor.set(o,h,l,c)),this.setBlendState(nn.NOBLEND)}if(2&n){var d,f=null!=(d=t.depth)?d:i.depth;f!==this.clearDepth&&(this.gl.clearDepth(f),this.clearDepth=f),this.setDepthState(on.WRITEDEPTH)}if(4&n){var p,m=null!=(p=t.stencil)?p:i.stencil;m!==this.clearStencil&&(this.gl.clearStencil(m),this.clearStencil=m),s.stencilMask(255),this.stencilWriteMaskFront=255,this.stencilWriteMaskBack=255}s.clear(this.glClearFlag[n])}},n.submit=function(){this.gl.flush()},n.readPixels=function(t,e,i,n,s){var r=this.gl;r.readPixels(t,e,i,n,r.RGBA,r.UNSIGNED_BYTE,s)},n.readPixelsAsync=(i=m(S().mark((function t(e,i,n,s,r){var a,o,h,l,c,u,d,f,p,m=this;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(l=this.gl,this.isWebGL2){t.next=4;break}return this.readPixels(e,i,n,s,r),t.abrupt("return");case 4:return c=function(t,e){var i=l.fenceSync(l.SYNC_GPU_COMMANDS_COMPLETE,0);return m.submit(),new Promise((function(n,s){!function r(){var a=l.clientWaitSync(i,t,0);a===l.WAIT_FAILED?(l.deleteSync(i),s(new Error("webgl clientWaitSync sync failed"))):a===l.TIMEOUT_EXPIRED?setTimeout(r,e):(l.deleteSync(i),n())}()}))},u=null==(a=this.renderTarget.colorBuffer)?void 0:a.impl,d=null!=(o=null==u?void 0:u._glFormat)?o:l.RGBA,f=null!=(h=null==u?void 0:u._glPixelType)?h:l.UNSIGNED_BYTE,p=l.createBuffer(),l.bindBuffer(l.PIXEL_PACK_BUFFER,p),l.bufferData(l.PIXEL_PACK_BUFFER,r.byteLength,l.STREAM_READ),l.readPixels(e,i,n,s,d,f,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),t.next=15,c(0,20);case 15:l.bindBuffer(l.PIXEL_PACK_BUFFER,p),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,r),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),l.deleteBuffer(p);case 19:case"end":return t.stop()}}),t,this)}))),function(t,e,n,s,r){return i.apply(this,arguments)}),n.setAlphaToCoverage=function(t){this.isWebGL1||this.alphaToCoverage!==t&&(this.alphaToCoverage=t,t?this.gl.enable(this.gl.SAMPLE_ALPHA_TO_COVERAGE):this.gl.disable(this.gl.SAMPLE_ALPHA_TO_COVERAGE))},n.setTransformFeedbackBuffer=function(t){if(this.transformFeedbackBuffer!==t&&(this.transformFeedbackBuffer=t,this.isWebGL2)){var e=this.gl;t?(this.feedback||(this.feedback=e.createTransformFeedback()),e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,this.feedback)):e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null)}},n.setRaster=function(t){this.raster!==t&&(this.raster=t,this.isWebGL2&&(t?this.gl.disable(this.gl.RASTERIZER_DISCARD):this.gl.enable(this.gl.RASTERIZER_DISCARD)))},n.setStencilTest=function(t){if(this.stencil!==t){var e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.stencil=t}},n.setStencilFunc=function(t,e,i){this.stencilFuncFront===t&&this.stencilRefFront===e&&this.stencilMaskFront===i&&this.stencilFuncBack===t&&this.stencilRefBack===e&&this.stencilMaskBack===i||(this.gl.stencilFunc(this.glComparison[t],e,i),this.stencilFuncFront=this.stencilFuncBack=t,this.stencilRefFront=this.stencilRefBack=e,this.stencilMaskFront=this.stencilMaskBack=i)},n.setStencilFuncFront=function(t,e,i){if(this.stencilFuncFront!==t||this.stencilRefFront!==e||this.stencilMaskFront!==i){var n=this.gl;n.stencilFuncSeparate(n.FRONT,this.glComparison[t],e,i),this.stencilFuncFront=t,this.stencilRefFront=e,this.stencilMaskFront=i}},n.setStencilFuncBack=function(t,e,i){if(this.stencilFuncBack!==t||this.stencilRefBack!==e||this.stencilMaskBack!==i){var n=this.gl;n.stencilFuncSeparate(n.BACK,this.glComparison[t],e,i),this.stencilFuncBack=t,this.stencilRefBack=e,this.stencilMaskBack=i}},n.setStencilOperation=function(t,e,i,n){this.stencilFailFront===t&&this.stencilZfailFront===e&&this.stencilZpassFront===i&&this.stencilFailBack===t&&this.stencilZfailBack===e&&this.stencilZpassBack===i||(this.gl.stencilOp(this.glStencilOp[t],this.glStencilOp[e],this.glStencilOp[i]),this.stencilFailFront=this.stencilFailBack=t,this.stencilZfailFront=this.stencilZfailBack=e,this.stencilZpassFront=this.stencilZpassBack=i),this.stencilWriteMaskFront===n&&this.stencilWriteMaskBack===n||(this.gl.stencilMask(n),this.stencilWriteMaskFront=n,this.stencilWriteMaskBack=n)},n.setStencilOperationFront=function(t,e,i,n){this.stencilFailFront===t&&this.stencilZfailFront===e&&this.stencilZpassFront===i||(this.gl.stencilOpSeparate(this.gl.FRONT,this.glStencilOp[t],this.glStencilOp[e],this.glStencilOp[i]),this.stencilFailFront=t,this.stencilZfailFront=e,this.stencilZpassFront=i),this.stencilWriteMaskFront!==n&&(this.gl.stencilMaskSeparate(this.gl.FRONT,n),this.stencilWriteMaskFront=n)},n.setStencilOperationBack=function(t,e,i,n){this.stencilFailBack===t&&this.stencilZfailBack===e&&this.stencilZpassBack===i||(this.gl.stencilOpSeparate(this.gl.BACK,this.glStencilOp[t],this.glStencilOp[e],this.glStencilOp[i]),this.stencilFailBack=t,this.stencilZfailBack=e,this.stencilZpassBack=i),this.stencilWriteMaskBack!==n&&(this.gl.stencilMaskSeparate(this.gl.BACK,n),this.stencilWriteMaskBack=n)},n.setBlendState=function(t){var e=this.blendState;if(!e.equals(t)){var i=this.gl,n=t.blend,s=t.colorOp,r=t.alphaOp,a=t.colorSrcFactor,o=t.colorDstFactor,h=t.alphaSrcFactor,l=t.alphaDstFactor;if(e.blend!==n&&(n?i.enable(i.BLEND):i.disable(i.BLEND)),e.colorOp!==s||e.alphaOp!==r){var c=this.glBlendEquation;i.blendEquationSeparate(c[s],c[r])}e.colorSrcFactor===a&&e.colorDstFactor===o&&e.alphaSrcFactor===h&&e.alphaDstFactor===l||i.blendFuncSeparate(this.glBlendFunctionColor[a],this.glBlendFunctionColor[o],this.glBlendFunctionAlpha[h],this.glBlendFunctionAlpha[l]),e.allWrite!==t.allWrite&&this.gl.colorMask(t.redWrite,t.greenWrite,t.blueWrite,t.alphaWrite),e.copy(t)}},n.setBlendColor=function(t,e,i,n){var s=this.blendColor;t===s.r&&e===s.g&&i===s.b&&n===s.a||(this.gl.blendColor(t,e,i,n),s.set(t,e,i,n))},n.setStencilState=function(t,e){t||e?(this.setStencilTest(!0),t===e?(this.setStencilFunc(t.func,t.ref,t.readMask),this.setStencilOperation(t.fail,t.zfail,t.zpass,t.writeMask)):(null!=t||(t=wn.DEFAULT),this.setStencilFuncFront(t.func,t.ref,t.readMask),this.setStencilOperationFront(t.fail,t.zfail,t.zpass,t.writeMask),null!=e||(e=wn.DEFAULT),this.setStencilFuncBack(e.func,e.ref,e.readMask),this.setStencilOperationBack(e.fail,e.zfail,e.zpass,e.writeMask))):this.setStencilTest(!1)},n.setDepthState=function(t){var e=this.depthState;if(!e.equals(t)){var i=this.gl,n=t.write;e.write!==n&&i.depthMask(n);var s=t.func,r=t.test;!r&&n&&(r=!0,s=7),e.func!==s&&i.depthFunc(this.glComparison[s]),e.test!==r&&(r?i.enable(i.DEPTH_TEST):i.disable(i.DEPTH_TEST));var a=t.depthBias,o=t.depthBiasSlope;a||o?(this.depthBiasEnabled||(this.depthBiasEnabled=!0,this.gl.enable(this.gl.POLYGON_OFFSET_FILL)),i.polygonOffset(o,a)):this.depthBiasEnabled&&(this.depthBiasEnabled=!1,this.gl.disable(this.gl.POLYGON_OFFSET_FILL)),e.copy(t)}},n.setCullMode=function(t){if(this.cullMode!==t){if(0===t)this.gl.disable(this.gl.CULL_FACE);else{0===this.cullMode&&this.gl.enable(this.gl.CULL_FACE);var e=this.glCull[t];this.cullFace!==e&&(this.gl.cullFace(e),this.cullFace=e)}this.cullMode=t}},n.setShader=function(t,e){void 0===e&&(e=!1),t!==this.shader&&(this.shader=t,this.shaderAsyncCompile=e,this.shaderValid=void 0)},n.activateShader=function(t){var e=this.shader,i=e.impl;void 0===this.shaderValid&&(e.failed?this.shaderValid=!1:e.ready||(this.shaderAsyncCompile?i.isLinked(t)?i.finalize(this,e)||(e.failed=!0,this.shaderValid=!1):this.shaderValid=!1:i.finalize(this,e)||(e.failed=!0,this.shaderValid=!1))),void 0===this.shaderValid&&(this.gl.useProgram(i.glProgram),this.shaderValid=!0)},n.clearVertexArrayObjectCache=function(){var t=this.gl;this._vaoMap.forEach((function(e,i,n){t.deleteVertexArray(e)})),this._vaoMap.clear()},v(e,[{key:"extDisjointTimerQuery",get:function(){return this._extDisjointTimerQuery||this.isWebGL2&&(this._extDisjointTimerQuery=this.getExtension("EXT_disjoint_timer_query_webgl2","EXT_disjoint_timer_query")),this._extDisjointTimerQuery}},{key:"defaultFramebuffer",get:function(){return this._defaultFramebuffer},set:function(t){this._defaultFramebuffer!==t&&(this._defaultFramebuffer=t,this._defaultFramebufferChanged=!0)}},{key:"fullscreen",get:function(){return!!document.fullscreenElement},set:function(t){t?this.gl.canvas.requestFullscreen():document.exitFullscreen()}},{key:"textureFloatHighPrecision",get:function(){return void 0===this._textureFloatHighPrecision&&(this._textureFloatHighPrecision=function(t){if(!t.textureFloatRenderable)return!1;var e=new zs(t,Pr.createDefinition(t,{name:"ptest1",vertexCode:Lr,fragmentCode:"\nvoid main(void) { \n\tgl_FragColor = vec4(2147483648.0);\n}\n"})),i=new zs(t,Pr.createDefinition(t,{name:"ptest2",vertexCode:Lr,fragmentCode:"\nuniform sampler2D source;\nvec4 packFloat(float depth) {\n\tconst vec4 bit_shift = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0);\n\tconst vec4 bit_mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);\n\tvec4 res = mod(depth * bit_shift * vec4(255), vec4(256) ) / vec4(255);\n\tres -= res.xxyz * bit_mask;\n\treturn res;\n}\nvoid main(void) {\n\tfloat c = texture2D(source, vec2(0.0)).r;\n\tfloat diff = abs(c - 2147483648.0) / 2147483648.0;\n\tgl_FragColor = packFloat(diff);\n}\n"})),n={format:ve,width:1,height:1,mipmaps:!1,minFilter:0,magFilter:0,name:"testFHP"},s=new or(t,n),r=new Cn({colorBuffer:s,depth:!1});kr(t,r,e),n.format=7;var a=new or(t,n),o=new Cn({colorBuffer:a,depth:!1});t.constantTexSource.setValue(s),kr(t,o,i);var h=t.activeFramebuffer;t.setFramebuffer(o.impl._glFrameBuffer);var l=new Uint8Array(4);t.readPixels(0,0,1,1,l),t.setFramebuffer(h);var c=l[0]/255/16777216+l[1]/255/65536+l[2]/255/256+l[3]/255;return s.destroy(),r.destroy(),a.destroy(),o.destroy(),e.destroy(),i.destroy(),0===c}(this)),this._textureFloatHighPrecision}},{key:"textureHalfFloatUpdatable",get:function(){return void 0===this._textureHalfFloatUpdatable&&(this.isWebGL2?this._textureHalfFloatUpdatable=!0:this._textureHalfFloatUpdatable=function(t,e){var i=!0,n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE);var s=new Uint16Array(16);return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,2,2,0,t.RGBA,e,s),t.getError()!==t.NO_ERROR&&(i=!1,console.log("Above error related to HALF_FLOAT_OES can be ignored, it was triggered by testing half float texture support")),t.bindTexture(t.TEXTURE_2D,null),t.deleteTexture(n),i}(this.gl,this.extTextureHalfFloat.HALF_FLOAT_OES)),this._textureHalfFloatUpdatable}}])}(En),Br=function(){function t(){}return t.prototype.unlock=function(t){},t}(),Nr=function(){function t(){}var e=t.prototype;return e.destroy=function(t){},e.init=function(t,e){},e.loseContext=function(){},e.resolve=function(t,e,i,n){},t}(),Ur=function(){function t(){}var e=t.prototype;return e.destroy=function(t){},e.loseContext=function(){},e.restoreContext=function(t,e){},t}(),zr=function(){function t(){}var e=t.prototype;return e.destroy=function(t){},e.propertyChanged=function(t){},e.loseContext=function(){},t}(),Vr=function(){function t(){}var e=t.prototype;return e.destroy=function(t){},e.unlock=function(t){},t}(),Gr=function(t){function e(e,i){var n;return void 0===i&&(i={}),i=(n=t.call(this,e,i)||this).initOptions,n.isNull=!0,n._deviceType=Vi,n.samples=1,n}x(e,t);var i=e.prototype;return i.destroy=function(){t.prototype.destroy.call(this)},i.initDeviceCaps=function(){this.disableParticleSystem=!0,this.precision="highp",this.maxPrecision="highp",this.maxSamples=4,this.maxTextures=16,this.maxTextureSize=4096,this.maxCubeMapSize=4096,this.maxVolumeSize=4096,this.maxColorAttachments=8,this.maxPixelRatio=1,this.maxAnisotropy=16,this.supportsInstancing=!0,this.supportsUniformBuffers=!1,this.supportsVolumeTextures=!0,this.supportsBoneTextures=!0,this.supportsMorphTargetTexturesCore=!0,this.supportsAreaLights=!0,this.supportsDepthShadow=!0,this.supportsGpuParticles=!1,this.supportsMrt=!0,this.extUintElement=!0,this.extTextureFloat=!0,this.textureFloatRenderable=!0,this.extTextureHalfFloat=!0,this.textureHalfFloatRenderable=!0,this.textureHalfFloatUpdatable=!0,this.boneLimit=1024,this.supportsImageBitmap=!0,this.extStandardDerivatives=!0,this.extBlendMinmax=!0,this.areaLightLutFormat=7,this.supportsTextureFetch=!0},i.postInit=function(){t.prototype.postInit.call(this)},i.frameStart=function(){t.prototype.frameStart.call(this)},i.frameEnd=function(){t.prototype.frameEnd.call(this)},i.updateBegin=function(){},i.updateEnd=function(){},i.readPixels=function(t,e,i,n,s){},i.createVertexBufferImpl=function(t,e){return new Vr(t,e)},i.createIndexBufferImpl=function(t){return new Br(t)},i.createShaderImpl=function(t){return new Ur(t)},i.createTextureImpl=function(t){return new zr(t)},i.createRenderTargetImpl=function(t){return new Nr(t)},i.draw=function(t,e,i){},i.setShader=function(t,e){},i.setBlendState=function(t){},i.setDepthState=function(t){},i.setStencilState=function(t,e){},i.setBlendColor=function(t,e,i,n){},i.setCullMode=function(t){},i.setAlphaToCoverage=function(t){},i.initializeContextCaches=function(){t.prototype.initializeContextCaches.call(this)},i.clear=function(t){},i.setViewport=function(t,e,i,n){},i.setScissor=function(t,e,i,n){},i.copyRenderTarget=function(t,e,i,n){return!0},e}(En);var Hr=function(){this.value=void 0,this.scopeId=null},Wr=function(){function t(t,e,i){void 0===i&&(i="Unnamed"),this.shader=null,this.name=void 0,this.parameters=new Map,this.countX=1,this.countY=void 0,this.countZ=void 0,this.device=t,this.shader=e,this.name=i,t.supportsCompute&&(this.impl=t.createComputeImpl(this))}var e=t.prototype;return e.setParameter=function(t,e){var i=this.parameters.get(t);i||((i=new Hr).scopeId=this.device.scope.resolve(t),this.parameters.set(t,i)),i.value=e},e.getParameter=function(t){var e;return null==(e=this.parameters.get(t))?void 0:e.value},e.deleteParameter=function(t){this.parameters.delete(t)},e.applyParameters=function(){for(var t,e=g(this.parameters);!(t=e()).done;){var i=t.value[1];i.scopeId.setValue(i.value)}},e.setupDispatch=function(t,e,i){this.countX=t,this.countY=e,this.countZ=i},t}(),Xr=0,jr=function(){function t(t,e,i,n,s,r){void 0===n&&(n=0),this.device=t,this.format=e,this.numIndices=i,this.usage=n,this.id=Xr++,this.impl=t.createIndexBufferImpl(this,r);var a=Yi[e];this.bytesPerIndex=a,this.numBytes=this.numIndices*a,s?this.setData(s):this.storage=new ArrayBuffer(this.numBytes),this.adjustVramSizeTracking(t._vram,this.numBytes),this.device.buffers.push(this)}var e=t.prototype;return e.destroy=function(){var t=this.device,e=t.buffers.indexOf(this);-1!==e&&t.buffers.splice(e,1),this.device.indexBuffer===this&&(this.device.indexBuffer=null),this.impl.initialized&&(this.impl.destroy(t),this.adjustVramSizeTracking(t._vram,-this.storage.byteLength))},e.adjustVramSizeTracking=function(t,e){t.ib+=e},e.loseContext=function(){this.impl.loseContext()},e.getFormat=function(){return this.format},e.getNumIndices=function(){return this.numIndices},e.lock=function(){return this.storage},e.unlock=function(){this.impl.unlock(this)},e.setData=function(t){return t.byteLength===this.numBytes&&(this.storage=t,this.unlock(),!0)},e._lockTypedArray=function(){var t=this.lock();return 2===this.format?new Uint32Array(t):1===this.format?new Uint16Array(t):new Uint8Array(t)},e.writeData=function(t,e){var i=this._lockTypedArray();if(t.length>e)if(ArrayBuffer.isView(t))t=t.subarray(0,e),i.set(t);else for(var n=0;nthis.vertexBuffer.numVertices&&(i=this.vertexBuffer.numVertices);var s=n.numComponents;if(this.vertexBuffer.getFormat().interleaved)for(var r=0,a=0;ai*s){var o=i*s;if(ArrayBuffer.isView(e))e=e.subarray(0,o),n.array.set(e);else for(var h=0;h0?this.wheelDelta=1:i.deltaY<0&&(this.wheelDelta=-1)),Pa()?(this.dx=i.movementX||i.webkitMovementX||i.mozMovementX||0,this.dy=i.movementY||i.webkitMovementY||i.mozMovementY||0):(this.dx=this.x-e._lastX,this.dy=this.y-e._lastY),"mousedown"!==i.type&&"mouseup"!==i.type||(this.button=i.button),this.buttons=e._buttons.slice(0),this.element=i.target,this.ctrlKey=null!=(n=i.ctrlKey)&&n,this.altKey=null!=(s=i.altKey)&&s,this.shiftKey=null!=(r=i.shiftKey)&&r,this.metaKey=null!=(a=i.metaKey)&&a,this.event=i},Ia=function(t){function e(e){var i;return(i=t.call(this)||this)._lastX=0,i._lastY=0,i._buttons=[!1,!1,!1],i._lastbuttons=[!1,!1,!1],i._target=null,i._attached=!1,i._upHandler=i._handleUp.bind(i),i._downHandler=i._handleDown.bind(i),i._moveHandler=i._handleMove.bind(i),i._wheelHandler=i._handleWheel.bind(i),i._contextMenuHandler=function(t){t.preventDefault()},i.attach(e),i}x(e,t),e.isPointerLocked=function(){return Pa()};var i=e.prototype;return i.attach=function(t){if(this._target=t,!this._attached){this._attached=!0;var e=!!G.passiveEvents&&{passive:!1};window.addEventListener("mouseup",this._upHandler,e),window.addEventListener("mousedown",this._downHandler,e),window.addEventListener("mousemove",this._moveHandler,e),window.addEventListener("wheel",this._wheelHandler,e)}},i.detach=function(){if(this._attached){this._attached=!1,this._target=null;var t=!!G.passiveEvents&&{passive:!1};window.removeEventListener("mouseup",this._upHandler,t),window.removeEventListener("mousedown",this._downHandler,t),window.removeEventListener("mousemove",this._moveHandler,t),window.removeEventListener("wheel",this._wheelHandler,t)}},i.disableContextMenu=function(){this._target&&this._target.addEventListener("contextmenu",this._contextMenuHandler)},i.enableContextMenu=function(){this._target&&this._target.removeEventListener("contextmenu",this._contextMenuHandler)},i.enablePointerLock=function(t,e){if(document.body.requestPointerLock){var i=function(){t(),document.removeEventListener("pointerlockchange",i)},n=function(){e(),document.removeEventListener("pointerlockerror",n)};t&&document.addEventListener("pointerlockchange",i,!1),e&&document.addEventListener("pointerlockerror",n,!1),document.body.requestPointerLock()}else e&&e()},i.disablePointerLock=function(t){if(document.exitPointerLock){var e=function(){t(),document.removeEventListener("pointerlockchange",e)};t&&document.addEventListener("pointerlockchange",e,!1),document.exitPointerLock()}},i.update=function(){this._lastbuttons[0]=this._buttons[0],this._lastbuttons[1]=this._buttons[1],this._lastbuttons[2]=this._buttons[2]},i.isPressed=function(t){return this._buttons[t]},i.wasPressed=function(t){return this._buttons[t]&&!this._lastbuttons[t]},i.wasReleased=function(t){return!this._buttons[t]&&this._lastbuttons[t]},i._handleUp=function(t){this._buttons[t.button]=!1;var e=new Ra(this,t);e.event&&this.fire(ya,e)},i._handleDown=function(t){this._buttons[t.button]=!0;var e=new Ra(this,t);e.event&&this.fire(va,e)},i._handleMove=function(t){var e=new Ra(this,t);e.event&&(this.fire(ga,e),this._lastX=e.x,this._lastY=e.y)},i._handleWheel=function(t){var e=new Ra(this,t);e.event&&this.fire(xa,e)},i._getTargetCoords=function(t){var e=this._target.getBoundingClientRect(),i=Math.floor(e.left),n=Math.floor(e.top);return t.clientX=i+this._target.clientWidth||t.clientY=n+this._target.clientHeight?null:{x:t.clientX-i,y:t.clientY-n}},e}(P);Ia.EVENT_MOUSEMOVE=ga,Ia.EVENT_MOUSEDOWN=va,Ia.EVENT_MOUSEUP=ya,Ia.EVENT_MOUSEWHEEL=xa;var Da=function(){function t(t,e){void 0===e&&(e={}),this._keyboard=void 0,this._mouse=void 0,this._gamepads=void 0,this._element=null,this._actions={},this._axes={},this._axesValues={},this._keyboard=e.keyboard||null,this._mouse=e.mouse||null,this._gamepads=e.gamepads||null,t&&this.attach(t)}var e=t.prototype;return e.attach=function(t){this._element=t,this._keyboard&&this._keyboard.attach(t),this._mouse&&this._mouse.attach(t)},e.detach=function(){this._keyboard&&this._keyboard.detach(),this._mouse&&this._mouse.detach(),this._element=null},e.disableContextMenu=function(){this._mouse||this._enableMouse(),this._mouse.disableContextMenu()},e.enableContextMenu=function(){this._mouse||this._enableMouse(),this._mouse.enableContextMenu()},e.update=function(t){for(var e in this._keyboard&&this._keyboard.update(),this._mouse&&this._mouse.update(),this._gamepads&&this._gamepads.update(),this._axesValues={},this._axes)this._axesValues[e]=[]},e.appendAction=function(t,e){this._actions[t]=this._actions[t]||[],this._actions[t].push(e)},e.registerKeys=function(t,e){if(this._keyboard||this._enableKeyboard(),this._actions[t])throw new Error("Action: "+t+" already registered");if(void 0===e)throw new Error("Invalid button");e.length||(e=[e]),this.appendAction(t,{type:ma,keys:e})},e.registerMouse=function(t,e){if(this._mouse||this._enableMouse(),void 0===e)throw new Error("Invalid button");this.appendAction(t,{type:pa,button:e})},e.registerPadButton=function(t,e,i){if(void 0===i)throw new Error("Invalid button");this.appendAction(t,{type:_a,button:i,pad:e})},e.registerAxis=function(t){var e=t.name;this._axes[e]||(this._axes[e]=[]);var i=this._axes[e].push(e);(t=t||{}).pad=t.pad||0;var n=function(n,s,r,a){switch(s){case"mousex":n._mouse.on(ga,(function(t){n._axesValues[e][i]=t.dx/10}));break;case"mousey":n._mouse.on(ga,(function(t){n._axesValues[e][i]=t.dy/10}));break;case"key":n._axes[e].push((function(){return n._keyboard.isPressed(a)?r:0}));break;case"padrx":n._axes[e].push((function(){return n._gamepads.getAxis(t.pad,2)}));break;case"padry":n._axes[e].push((function(){return n._gamepads.getAxis(t.pad,3)}));break;case"padlx":n._axes[e].push((function(){return n._gamepads.getAxis(t.pad,0)}));break;case"padly":n._axes[e].push((function(){return n._gamepads.getAxis(t.pad,1)}));break;default:throw new Error("Unknown axis")}};n(this,t.positive,1,t.positiveKey),(t.negativeKey||t.negative!==t.positive)&&n(this,t.negative,-1,t.negativeKey)},e.isPressed=function(t){if(!this._actions[t])return!1;for(var e=this._actions[t].length,i=0;iMath.abs(e)&&(e=s)}else this._axesValues[t]&&Math.abs(this._axesValues[t][n])>Math.abs(e)&&(e=this._axesValues[t][n]);return e},e._enableMouse=function(){if(this._mouse=new Ia,!this._element)throw new Error("Controller must be attached to an Element");this._mouse.attach(this._element)},e._enableKeyboard=function(){if(this._keyboard=new Ma,!this._element)throw new Error("Controller must be attached to an Element");this._keyboard.attach(this._element)},t}(),La=Object.freeze([]),ka=function(){return La};"undefined"!=typeof navigator&&(ka=(navigator.getGamepads||navigator.webkitGetGamepads||ka).bind(navigator));var Oa={buttons:{PAD_FACE_1:0,PAD_FACE_2:1,PAD_FACE_3:2,PAD_FACE_4:3,PAD_L_SHOULDER_1:4,PAD_R_SHOULDER_1:5,PAD_L_SHOULDER_2:6,PAD_R_SHOULDER_2:7,PAD_SELECT:8,PAD_START:9,PAD_L_STICK_BUTTON:10,PAD_R_STICK_BUTTON:11,PAD_UP:12,PAD_DOWN:13,PAD_LEFT:14,PAD_RIGHT:15,PAD_VENDOR:16,XRPAD_TRIGGER:0,XRPAD_SQUEEZE:1,XRPAD_TOUCHPAD_BUTTON:2,XRPAD_STICK_BUTTON:3,XRPAD_A:4,XRPAD_B:5},axes:{PAD_L_STICK_X:0,PAD_L_STICK_Y:1,PAD_R_STICK_X:2,PAD_R_STICK_Y:3,XRPAD_TOUCHPAD_X:0,XRPAD_TOUCHPAD_Y:1,XRPAD_STICK_X:2,XRPAD_STICK_Y:3}},Fa={DEFAULT:{buttons:["PAD_FACE_1","PAD_FACE_2","PAD_FACE_3","PAD_FACE_4","PAD_L_SHOULDER_1","PAD_R_SHOULDER_1","PAD_L_SHOULDER_2","PAD_R_SHOULDER_2","PAD_SELECT","PAD_START","PAD_L_STICK_BUTTON","PAD_R_STICK_BUTTON","PAD_UP","PAD_DOWN","PAD_LEFT","PAD_RIGHT","PAD_VENDOR"],axes:["PAD_L_STICK_X","PAD_L_STICK_Y","PAD_R_STICK_X","PAD_R_STICK_Y"]},DEFAULT_DUAL:{buttons:["PAD_FACE_1","PAD_FACE_2","PAD_FACE_3","PAD_FACE_4","PAD_L_SHOULDER_1","PAD_R_SHOULDER_1","PAD_L_SHOULDER_2","PAD_R_SHOULDER_2","PAD_SELECT","PAD_START","PAD_L_STICK_BUTTON","PAD_R_STICK_BUTTON","PAD_VENDOR"],axes:["PAD_L_STICK_X","PAD_L_STICK_Y","PAD_R_STICK_X","PAD_R_STICK_Y"],synthesizedButtons:{PAD_UP:{axis:0,min:0,max:1},PAD_DOWN:{axis:0,min:-1,max:0},PAD_LEFT:{axis:0,min:-1,max:0},PAD_RIGHT:{axis:0,min:0,max:1}}},PS3:{buttons:["PAD_FACE_1","PAD_FACE_2","PAD_FACE_4","PAD_FACE_3","PAD_L_SHOULDER_1","PAD_R_SHOULDER_1","PAD_L_SHOULDER_2","PAD_R_SHOULDER_2","PAD_SELECT","PAD_START","PAD_L_STICK_BUTTON","PAD_R_STICK_BUTTON","PAD_UP","PAD_DOWN","PAD_LEFT","PAD_RIGHT","PAD_VENDOR"],axes:["PAD_L_STICK_X","PAD_L_STICK_Y","PAD_R_STICK_X","PAD_R_STICK_Y"],mapping:"standard"},DEFAULT_XR:{buttons:["XRPAD_TRIGGER","XRPAD_SQUEEZE","XRPAD_TOUCHPAD_BUTTON","XRPAD_STICK_BUTTON","XRPAD_A","XRPAD_B"],axes:["XRPAD_TOUCHPAD_X","XRPAD_TOUCHPAD_Y","XRPAD_STICK_X","XRPAD_STICK_Y"],mapping:"xr-standard"}},Ba={"Product: 0268":"PS3"},Na={};function Ua(t){var e=Na[t.id];if(e)return e;for(var i in Ba)if(-1!==t.id.indexOf(i)){var n=Ba[i];if(!t.mapping){var s=Fa["RAW_"+n];if(s)return s}return Fa[n]}if("xr-standard"===t.mapping)return Fa.DEFAULT_XR;var r=Fa.DEFAULT,a=t.buttons.length0):(this.value=t.value,this.pressed=t.pressed,this.touched=null!=(i=t.touched)?i:t.value>0);e&&("number"==typeof e?(this.wasPressed=1!==e&&this.pressed,this.wasReleased=1===e&&!this.pressed,this.wasTouched=0===e&&this.touched):(this.wasPressed=!e.pressed&&this.pressed,this.wasReleased=e.pressed&&!this.pressed,this.wasTouched=!(null!=(n=e.touched)?n:e.value>0)&&this.touched))}return t.prototype.update=function(t){var e,i=t.value,n=t.pressed,s=null!=(e=t.touched)?e:i>0;this.wasPressed=!this.pressed&&n,this.wasReleased=this.pressed&&!n,this.wasTouched=!this.touched&&s,this.value=i,this.pressed=n,this.touched=s},t}(),Ha=Object.freeze(new Ga(0)),Wa=function(){function t(t,e){this._compiledMapping={buttons:[],axes:[]},this.id=t.id,this.index=t.index,this._buttons=t.buttons.map((function(t){return new Ga(t)})),this._axes=[].concat(t.axes),this._previousAxes=[].concat(t.axes),this.mapping=e.mapping,this.map=e,this.hand=t.hand||"none",this.pad=t,this._compileMapping()}var e,i=t.prototype;return i._compileMapping=function(){var t=this,e=this._compiledMapping,i=e.axes,n=e.buttons,s=Oa.axes,r=Oa.buttons;i.length=0,n.length=0,this.map.axes&&this.map.axes.forEach((function(e,n){i[s[e]]=function(){return t.pad.axes[n]||0}}));for(var a=0,o=i.length;aza?e:0},v(t,[{key:"connected",get:function(){return this.pad.connected}},{key:"axes",get:function(){return this._compiledMapping.axes.map((function(t){return t()}))}},{key:"buttons",get:function(){return this._compiledMapping.buttons.map((function(t){return t()}))}}])}(),Xa=function(t){function e(){var e;return(e=t.call(this)||this).gamepadsSupported=G.gamepads,e.current=[],e._previous=[],e._ongamepadconnectedHandler=e._ongamepadconnected.bind(e),e._ongamepaddisconnectedHandler=e._ongamepaddisconnected.bind(e),window.addEventListener("gamepadconnected",e._ongamepadconnectedHandler,!1),window.addEventListener("gamepaddisconnected",e._ongamepaddisconnectedHandler,!1),e.poll(),e}x(e,t);var i=e.prototype;return i._ongamepadconnected=function(t){for(var e=new Wa(t.gamepad,this.getMap(t.gamepad)),i=this.current,n=i.findIndex((function(t){return t.index===e.index}));-1!==n;)i.splice(n,1),n=i.findIndex((function(t){return t.index===e.index}));i.push(e),this.fire(Sa,e)},i._ongamepaddisconnected=function(t){var e=this.current,i=e.findIndex((function(e){return e.index===t.gamepad.index}));-1!==i&&(this.fire(ba,e[i]),e.splice(i,1))},i.update=function(){this.poll()},i.poll=function(t){void 0===t&&(t=[]),t.length>0&&(t.length=0);for(var e=ka(),i=0,n=e.length;i=0?t.ResponseType.ARRAY_BUFFER:".json"===n?t.ResponseType.JSON:".xml"===n?t.ResponseType.DOCUMENT:t.ResponseType.TEXT},e._isBinaryContentType=function(e){return[t.ContentType.BASIS,t.ContentType.BIN,t.ContentType.DDS,t.ContentType.GLB,t.ContentType.MP3,t.ContentType.MP4,t.ContentType.OGG,t.ContentType.OPUS,t.ContentType.WAV].indexOf(e)>=0},e._isBinaryResponseType=function(e){return e===t.ResponseType.ARRAY_BUFFER||e===t.ResponseType.BLOB||e===t.ResponseType.JSON},e._onReadyStateChange=function(t,e,i,n){if(4===n.readyState)switch(n.status){case 0:n.responseURL&&n.responseURL.startsWith("file:///")?this._onSuccess(t,e,i,n):this._onError(t,e,i,n);break;case 200:case 201:case 206:case 304:this._onSuccess(t,e,i,n);break;default:this._onError(t,e,i,n)}},e._onSuccess=function(e,i,n,s){var r,a,o=s.getResponseHeader("Content-Type");o&&(a=o.split(";")[0].trim());try{r=this._isBinaryContentType(a)||this._isBinaryResponseType(s.responseType)?s.response:a===t.ContentType.JSON||i.split("?")[0].endsWith(".json")?JSON.parse(s.responseText):s.responseType===t.ResponseType.DOCUMENT||a===t.ContentType.XML?s.responseXML:s.responseText,n.callback(null,r)}catch(t){n.callback(t)}},e._onError=function(e,i,n,s){var r=this;if(!n.retrying)if(n.retry&&n.retriesn)return 0;var o=0;return r===le?o=1-s*(a-i)/(n-i):r===ce?o=i/(i+s*(a-i)):r===ue&&(o=Math.pow(a/i,-s)),ft.clamp(o,0,1)}(this.manager.listener.getPosition(),this.position,this.minDistance,this.maxDistance,this.rollOffFactor,this.distanceModel),i=this.getVolume();this.source.volume=i*e}},getMaxDistance:function(){return this.maxDistance},setMaxDistance:function(t){this.maxDistance=t},getMinDistance:function(){return this.minDistance},setMinDistance:function(t){this.minDistance=t},getRollOffFactor:function(){return this.rollOffFactor},setRollOffFactor:function(t){this.rollOffFactor=t},getDistanceModel:function(){return this.distanceModel},setDistanceModel:function(t){this.distanceModel=t}})}var io=function(){function t(t){this._manager=void 0,this.position=new wt,this.velocity=new wt,this.orientation=new Bt,this._manager=t}var e=t.prototype;return e.getPosition=function(){return this.position},e.setPosition=function(t){this.position.copy(t);var e=this.listener;e&&("positionX"in e?(e.positionX.value=t.x,e.positionY.value=t.y,e.positionZ.value=t.z):e.setPosition&&e.setPosition(t.x,t.y,t.z))},e.getVelocity=function(){return this.velocity},e.setVelocity=function(t){},e.setOrientation=function(t){this.orientation.copy(t);var e=this.listener;if(e){var i=t.data;"forwardX"in e?(e.forwardX.value=-i[8],e.forwardY.value=-i[9],e.forwardZ.value=-i[10],e.upX.value=i[4],e.upY.value=i[5],e.upZ.value=i[6]):e.setOrientation&&e.setOrientation(-i[8],-i[9],-i[10],i[4],i[5],i[6])}},e.getOrientation=function(){return this.orientation},v(t,[{key:"listener",get:function(){var t=this._manager.context;return t?t.listener:null}}])}(),no="running",so=["click","touchstart","mousedown"],ro=function(t){function e(){var e;return(e=t.call(this)||this)._context=null,e.AudioContext="undefined"!=typeof AudioContext&&AudioContext||"undefined"!=typeof webkitAudioContext&&webkitAudioContext,e.AudioContext,e._unlockHandlerFunc=e._unlockHandler.bind(e),e._userSuspended=!1,e.listener=new io(e),e._volume=1,e}x(e,t);var i=e.prototype;return i.suspend=function(){this._userSuspended||(this._userSuspended=!0,this._context&&this._context.state===no&&this._suspend())},i.resume=function(){this._userSuspended&&(this._userSuspended=!1,this._context&&this._context.state!==no&&this._resume())},i.destroy=function(){var t;(this.fire("destroy"),this._context)&&(this._removeUnlockListeners(),null==(t=this._context)||t.close(),this._context=null)},i.playSound=function(t,e){void 0===e&&(e={});var i=null;return $a&&(i=new $a(this,t,e)).play(),i},i.playSound3d=function(t,e,i){void 0===i&&(i={});var n=null;return to&&((n=new to(this,t,i)).setPosition(e),i.volume&&n.setVolume(i.volume),i.loop&&n.setLoop(i.loop),i.maxDistance&&n.setMaxDistance(i.maxDistance),i.minDistance&&n.setMinDistance(i.minDistance),i.rollOffFactor&&n.setRollOffFactor(i.rollOffFactor),i.distanceModel&&n.setDistanceModel(i.distanceModel),n.play()),n},i._resume=function(){var t=this;this._context.resume().then((function(){var e=t._context.createBufferSource();e.buffer=t._context.createBuffer(1,1,t._context.sampleRate),e.connect(t._context.destination),e.start(0),e.onended=function(i){e.disconnect(0),t.fire("resume")}}),(function(t){})).catch((function(t){}))},i._suspend=function(){var t=this;this._context.suspend().then((function(){t.fire("suspend")}),(function(t){})).catch((function(t){}))},i._unlockHandler=function(){this._removeUnlockListeners(),this._userSuspended||this._context.state===no||this._resume()},i._registerUnlockListeners=function(){var t=this;so.forEach((function(e){window.addEventListener(e,t._unlockHandlerFunc,!1)}))},i._removeUnlockListeners=function(){var t=this;so.forEach((function(e){window.removeEventListener(e,t._unlockHandlerFunc,!1)}))},v(e,[{key:"volume",get:function(){return this._volume},set:function(t){t=ft.clamp(t,0,1),this._volume=t,this.fire("volumechange",t)}},{key:"suspended",get:function(){return this._userSuspended}},{key:"context",get:function(){return!this._context&&this.AudioContext&&(this._context=new this.AudioContext,this._context.state!==no&&this._registerUnlockListeners()),this._context}}])}(P),ao=v((function(t){this.audio=void 0,this.buffer=void 0,t instanceof Audio?this.audio=t:this.buffer=t}),[{key:"duration",get:function(){var t=0;return this.buffer?t=this.buffer.duration:this.audio&&(t=this.audio.duration),t||0}}]);function oo(t,e){return t%e||0}var ho=function(t){function e(e,i,n){var s;return(s=t.call(this)||this).source=null,s._manager=e,s._volume=void 0!==n.volume?ft.clamp(Number(n.volume)||0,0,1):1,s._pitch=void 0!==n.pitch?Math.max(.01,Number(n.pitch)||0):1,s._loop=!(void 0===n.loop||!n.loop),s._sound=i,s._state=2,s._suspended=!1,s._suspendEndEvent=0,s._suspendInstanceEvents=!1,s._playWhenLoaded=!0,s._startTime=Math.max(0,Number(n.startTime)||0),s._duration=Math.max(0,Number(n.duration)||0),s._startOffset=null,s._onPlayCallback=n.onPlay,s._onPauseCallback=n.onPause,s._onResumeCallback=n.onResume,s._onStopCallback=n.onStop,s._onEndCallback=n.onEnd,Ja()?(s._startedAt=0,s._currentTime=0,s._currentOffset=0,s._inputNode=null,s._connectorNode=null,s._firstNode=null,s._lastNode=null,s._waitingContextSuspension=!1,s._initializeNodes(),s._endedHandler=s._onEnded.bind(s)):(s._isReady=!1,s._loadedMetadataHandler=s._onLoadedMetadata.bind(s),s._timeUpdateHandler=s._onTimeUpdate.bind(s),s._endedHandler=s._onEnded.bind(s),s._createSource()),s}x(e,t);var i=e.prototype;return i._onPlay=function(){this.fire("play"),this._onPlayCallback&&this._onPlayCallback(this)},i._onPause=function(){this.fire("pause"),this._onPauseCallback&&this._onPauseCallback(this)},i._onResume=function(){this.fire("resume"),this._onResumeCallback&&this._onResumeCallback(this)},i._onStop=function(){this.fire("stop"),this._onStopCallback&&this._onStopCallback(this)},i._onEnded=function(){this._suspendEndEvent>0?this._suspendEndEvent--:(this.fire("end"),this._onEndCallback&&this._onEndCallback(this),this.stop())},i._onManagerVolumeChange=function(){this.volume=this._volume},i._onManagerSuspend=function(){0!==this._state||this._suspended||(this._suspended=!0,this.pause())},i._onManagerResume=function(){this._suspended&&(this._suspended=!1,this.resume())},i._initializeNodes=function(){this.gain=this._manager.context.createGain(),this._inputNode=this.gain,this._connectorNode=this.gain,this._connectorNode.connect(this._manager.context.destination)},i.play=function(){return 2!==this._state&&this.stop(),this._state=0,this._playWhenLoaded=!1,!this._waitingContextSuspension&&(this._manager.suspended?(this._manager.once("resume",this._playAudioImmediate,this),this._waitingContextSuspension=!0,!1):(this._playAudioImmediate(),!0))},i._playAudioImmediate=function(){if(this._waitingContextSuspension=!1,0===this._state){this.source||this._createSource();var t=oo(this._startOffset,this.duration);t=oo(this._startTime+t,this._sound.duration),this._startOffset=null,this._duration?this.source.start(0,t,this._duration):this.source.start(0,t),this._startedAt=this._manager.context.currentTime,this._currentTime=0,this._currentOffset=t,this.volume=this._volume,this.loop=this._loop,this.pitch=this._pitch,this._manager.on("volumechange",this._onManagerVolumeChange,this),this._manager.on("suspend",this._onManagerSuspend,this),this._manager.on("resume",this._onManagerResume,this),this._manager.on("destroy",this._onManagerDestroy,this),this._suspendInstanceEvents||this._onPlay()}},i.pause=function(){return this._playWhenLoaded=!1,0===this._state&&(this._state=1,this._waitingContextSuspension||(this._updateCurrentTime(),this._suspendEndEvent++,this.source.stop(0),this.source=null,this._startOffset=null,this._suspendInstanceEvents||this._onPause()),!0)},i.resume=function(){if(1!==this._state)return!1;var t=this.currentTime;return this._state=0,this._waitingContextSuspension||(this.source||this._createSource(),null!==this._startOffset&&(t=oo(this._startOffset,this.duration),t=oo(this._startTime+t,this._sound.duration),this._startOffset=null),this._duration?this.source.start(0,t,this._duration):this.source.start(0,t),this._startedAt=this._manager.context.currentTime,this._currentOffset=t,this.volume=this._volume,this.loop=this._loop,this.pitch=this._pitch,this._playWhenLoaded=!1,this._suspendInstanceEvents||this._onResume()),!0},i.stop=function(){if(this._playWhenLoaded=!1,2===this._state)return!1;var t=0===this._state;return this._state=2,this._waitingContextSuspension||(this._manager.off("volumechange",this._onManagerVolumeChange,this),this._manager.off("suspend",this._onManagerSuspend,this),this._manager.off("resume",this._onManagerResume,this),this._manager.off("destroy",this._onManagerDestroy,this),this._startedAt=0,this._currentTime=0,this._currentOffset=0,this._startOffset=null,this._suspendEndEvent++,t&&this.source&&this.source.stop(0),this.source=null,this._suspendInstanceEvents||this._onStop()),!0},i.setExternalNodes=function(t,e){if(t){e||(e=t);var i=this._manager.context.destination;this._firstNode!==t&&(this._firstNode?this._connectorNode.disconnect(this._firstNode):this._connectorNode.disconnect(i),this._firstNode=t,this._connectorNode.connect(t)),this._lastNode!==e&&(this._lastNode&&this._lastNode.disconnect(i),this._lastNode=e,this._lastNode.connect(i))}else console.error("The firstNode must be a valid Audio Node")},i.clearExternalNodes=function(){var t=this._manager.context.destination;this._firstNode&&(this._connectorNode.disconnect(this._firstNode),this._firstNode=null),this._lastNode&&(this._lastNode.disconnect(t),this._lastNode=null),this._connectorNode.connect(t)},i.getExternalNodes=function(){return[this._firstNode,this._lastNode]},i._createSource=function(){if(!this._sound)return null;var t=this._manager.context;return this._sound.buffer&&(this.source=t.createBufferSource(),this.source.buffer=this._sound.buffer,this.source.connect(this._inputNode),this.source.onended=this._endedHandler,this.source.loopStart=oo(this._startTime,this.source.buffer.duration),this._duration&&(this.source.loopEnd=Math.max(this.source.loopStart,oo(this._startTime+this._duration,this.source.buffer.duration)))),this.source},i._updateCurrentTime=function(){this._currentTime=oo((this._manager.context.currentTime-this._startedAt)*this._pitch+this._currentOffset,this.duration)},i._onManagerDestroy=function(){this.source&&0===this._state&&(this.source.stop(0),this.source=null)},v(e,[{key:"currentTime",get:function(){return null!==this._startOffset?this._startOffset:1===this._state?this._currentTime:2!==this._state&&this.source?(this._updateCurrentTime(),this._currentTime):0},set:function(t){if(!(t<0))if(0===this._state){var e=this._suspendInstanceEvents;this._suspendInstanceEvents=!0,this.stop(),this._startOffset=t,this.play(),this._suspendInstanceEvents=e}else this._startOffset=t,this._currentTime=t}},{key:"duration",get:function(){return this._sound?this._duration?oo(this._duration,this._sound.duration):this._sound.duration:0},set:function(t){this._duration=Math.max(0,Number(t)||0);var e=0===this._state;this.stop(),e&&this.play()}},{key:"isPaused",get:function(){return 1===this._state}},{key:"isPlaying",get:function(){return 0===this._state}},{key:"isStopped",get:function(){return 2===this._state}},{key:"isSuspended",get:function(){return this._suspended}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=!!t,this.source&&(this.source.loop=this._loop)}},{key:"pitch",get:function(){return this._pitch},set:function(t){this._currentOffset=this.currentTime,this._startedAt=this._manager.context.currentTime,this._pitch=Math.max(Number(t)||0,.01),this.source&&(this.source.playbackRate.value=this._pitch)}},{key:"sound",get:function(){return this._sound},set:function(t){this._sound=t,2!==this._state?this.stop():this._createSource()}},{key:"startTime",get:function(){return this._startTime},set:function(t){this._startTime=Math.max(0,Number(t)||0);var e=0===this._state;this.stop(),e&&this.play()}},{key:"volume",get:function(){return this._volume},set:function(t){t=ft.clamp(t,0,1),this._volume=t,this.gain&&(this.gain.gain.value=t*this._manager.volume)}}])}(P);ho.EVENT_PLAY="play",ho.EVENT_PAUSE="pause",ho.EVENT_RESUME="resume",ho.EVENT_STOP="stop",ho.EVENT_END="end",Ja()||(Object.assign(ho.prototype,{play:function(){return 2!==this._state&&this.stop(),!(!this.source&&!this._createSource())&&(this.volume=this._volume,this.pitch=this._pitch,this.loop=this._loop,this.source.play(),this._state=0,this._playWhenLoaded=!1,this._manager.on("volumechange",this._onManagerVolumeChange,this),this._manager.on("suspend",this._onManagerSuspend,this),this._manager.on("resume",this._onManagerResume,this),this._manager.on("destroy",this._onManagerDestroy,this),this._manager.suspended&&this._onManagerSuspend(),this._suspendInstanceEvents||this._onPlay(),!0)},pause:function(){return!(!this.source||0!==this._state)&&(this._suspendEndEvent++,this.source.pause(),this._playWhenLoaded=!1,this._state=1,this._startOffset=null,this._suspendInstanceEvents||this._onPause(),!0)},resume:function(){return!(!this.source||1!==this._state)&&(this._state=0,this._playWhenLoaded=!1,this.source.paused&&(this.source.play(),this._suspendInstanceEvents||this._onResume()),!0)},stop:function(){return!(!this.source||2===this._state)&&(this._manager.off("volumechange",this._onManagerVolumeChange,this),this._manager.off("suspend",this._onManagerSuspend,this),this._manager.off("resume",this._onManagerResume,this),this._manager.off("destroy",this._onManagerDestroy,this),this._suspendEndEvent++,this.source.pause(),this._playWhenLoaded=!1,this._state=2,this._startOffset=null,this._suspendInstanceEvents||this._onStop(),!0)},setExternalNodes:function(){},clearExternalNodes:function(){},getExternalNodes:function(){return[null,null]},_onLoadedMetadata:function(){this.source.removeEventListener("loadedmetadata",this._loadedMetadataHandler),this._isReady=!0;var t=oo(this._startOffset,this.duration);t=oo(this._startTime+t,this._sound.duration),this._startOffset=null,this.source.currentTime=t},_createSource:function(){return this._sound&&this._sound.audio&&(this._isReady=!1,this.source=this._sound.audio.cloneNode(!0),this.source.addEventListener("loadedmetadata",this._loadedMetadataHandler),this.source.addEventListener("timeupdate",this._timeUpdateHandler),this.source.onended=this._endedHandler),this.source},_onTimeUpdate:function(){this._duration&&this.source.currentTime>oo(this._startTime+this._duration,this.source.duration)&&(this.loop?this.source.currentTime=oo(this._startTime,this.source.duration):(this.source.removeEventListener("timeupdate",this._timeUpdateHandler),this.source.pause(),this._onEnded()))},_onManagerDestroy:function(){this.source&&this.source.pause()}}),Object.defineProperty(ho.prototype,"volume",{get:function(){return this._volume},set:function(t){t=ft.clamp(t,0,1),this._volume=t,this.source&&(this.source.volume=t*this._manager.volume)}}),Object.defineProperty(ho.prototype,"pitch",{get:function(){return this._pitch},set:function(t){this._pitch=Math.max(Number(t)||0,.01),this.source&&(this.source.playbackRate=this._pitch)}}),Object.defineProperty(ho.prototype,"sound",{get:function(){return this._sound},set:function(t){this.stop(),this._sound=t}}),Object.defineProperty(ho.prototype,"currentTime",{get:function(){return null!==this._startOffset?this._startOffset:2!==this._state&&this.source?this.source.currentTime-this._startTime:0},set:function(t){t<0||(this._startOffset=t,this.source&&this._isReady&&(this.source.currentTime=oo(this._startTime+oo(t,this.duration),this._sound.duration),this._startOffset=null))}}));var lo=function(t){function e(e,i,n){var s;return void 0===n&&(n={}),(s=t.call(this,e,i,n)||this)._position=new wt,s._velocity=new wt,n.position&&(s.position=n.position),s.maxDistance=void 0!==n.maxDistance?Number(n.maxDistance):1e4,s.refDistance=void 0!==n.refDistance?Number(n.refDistance):1,s.rollOffFactor=void 0!==n.rollOffFactor?Number(n.rollOffFactor):1,s.distanceModel=void 0!==n.distanceModel?n.distanceModel:le,s}return x(e,t),e.prototype._initializeNodes=function(){this.gain=this._manager.context.createGain(),this.panner=this._manager.context.createPanner(),this.panner.connect(this.gain),this._inputNode=this.panner,this._connectorNode=this.gain,this._connectorNode.connect(this._manager.context.destination)},v(e,[{key:"position",get:function(){return this._position},set:function(t){this._position.copy(t);var e=this.panner;"positionX"in e?(e.positionX.value=t.x,e.positionY.value=t.y,e.positionZ.value=t.z):e.setPosition&&e.setPosition(t.x,t.y,t.z)}},{key:"velocity",get:function(){return this._velocity},set:function(t){this._velocity.copy(t)}},{key:"maxDistance",get:function(){return this.panner.maxDistance},set:function(t){this.panner.maxDistance=t}},{key:"refDistance",get:function(){return this.panner.refDistance},set:function(t){this.panner.refDistance=t}},{key:"rollOffFactor",get:function(){return this.panner.rolloffFactor},set:function(t){this.panner.rolloffFactor=t}},{key:"distanceModel",get:function(){return this.panner.distanceModel},set:function(t){this.panner.distanceModel=t}}])}(ho);if(!Ja()){var co=new wt;Object.defineProperty(lo.prototype,"position",{get:function(){return this._position},set:function(t){if(this._position.copy(t),this.source){var e=function(t,e,i,n,s,r){var a=(co=co.sub2(t,e)).length();if(an)return 0;var o=0;return r===le?o=1-s*(a-i)/(n-i):r===ce?o=i/(i+s*(a-i)):r===ue&&(o=Math.pow(a/i,-s)),ft.clamp(o,0,1)}(this._manager.listener.getPosition(),this._position,this.refDistance,this.maxDistance,this.rollOffFactor,this.distanceModel),i=this.volume;this.source.volume=i*e*this._manager.volume}}}),Object.defineProperty(lo.prototype,"maxDistance",{get:function(){return this._maxDistance},set:function(t){this._maxDistance=t}}),Object.defineProperty(lo.prototype,"refDistance",{get:function(){return this._refDistance},set:function(t){this._refDistance=t}}),Object.defineProperty(lo.prototype,"rollOffFactor",{get:function(){return this._rollOffFactor},set:function(t){this._rollOffFactor=t}}),Object.defineProperty(lo.prototype,"distanceModel",{get:function(){return this._distanceModel},set:function(t){this._distanceModel=t}})}var uo="none",fo="linear",po={0:"PCF3",1:"VSM8",2:"VSM16",3:"VSM32",4:"PCF5",5:"PCF1",6:"PCSS"},mo="mul",_o=32,vo=128,go=256,yo=512,xo=1024,So=2048,bo=4096,To=8192,wo="infinite",Eo="dome",Ao="none",Co="bayer8",Mo="\nvec3 decodeLinear(vec4 raw) {\n\treturn raw.rgb;\n}\nfloat decodeGamma(float raw) {\n\treturn pow(raw, 2.2);\n}\nvec3 decodeGamma(vec3 raw) {\n\treturn pow(raw, vec3(2.2));\n}\nvec3 decodeGamma(vec4 raw) {\n\treturn pow(raw.xyz, vec3(2.2));\n}\nvec3 decodeRGBM(vec4 raw) {\n\tvec3 color = (8.0 * raw.a) * raw.rgb;\n\treturn color * color;\n}\nvec3 decodeRGBP(vec4 raw) {\n\tvec3 color = raw.rgb * (-raw.a * 7.0 + 8.0);\n\treturn color * color;\n}\nvec3 decodeRGBE(vec4 raw) {\n\tif (raw.a == 0.0) {\n\t\treturn vec3(0.0, 0.0, 0.0);\n\t} else {\n\t\treturn raw.xyz * pow(2.0, raw.w * 255.0 - 128.0);\n\t}\n}\nvec4 passThrough(vec4 raw) {\n\treturn raw;\n}\n",Po="\nvec4 encodeLinear(vec3 source) {\n\treturn vec4(source, 1.0);\n}\nvec4 encodeGamma(vec3 source) {\n\treturn vec4(pow(source + 0.0000001, vec3(1.0 / 2.2)), 1.0);\n}\nvec4 encodeRGBM(vec3 source) {\n\tvec4 result;\n\tresult.rgb = pow(source.rgb, vec3(0.5));\n\tresult.rgb *= 1.0 / 8.0;\n\tresult.a = saturate( max( max( result.r, result.g ), max( result.b, 1.0 / 255.0 ) ) );\n\tresult.a = ceil(result.a * 255.0) / 255.0;\n\tresult.rgb /= result.a;\n\treturn result;\n}\nvec4 encodeRGBP(vec3 source) {\n\tvec3 gamma = pow(source, vec3(0.5));\n\tfloat maxVal = min(8.0, max(1.0, max(gamma.x, max(gamma.y, gamma.z))));\n\tfloat v = 1.0 - ((maxVal - 1.0) / 7.0);\n\tv = ceil(v * 255.0) / 255.0;\n\treturn vec4(gamma / (-v * 7.0 + 8.0), v);\t\n}\nvec4 encodeRGBE(vec3 source) {\n\tfloat maxVal = max(source.x, max(source.y, source.z));\n\tif (maxVal < 1e-32) {\n\t\treturn vec4(0, 0, 0, 0);\n\t} else {\n\t\tfloat e = ceil(log2(maxVal));\n\t\treturn vec4(source / pow(2.0, e), (e + 128.0) / 255.0);\n\t}\n}\n",Ro={alphaTestPS:"\nuniform float alpha_ref;\nvoid alphaTest(float a) {\n\tif (a < alpha_ref) discard;\n}\n",ambientConstantPS:"\nvoid addAmbient(vec3 worldNormal) {\n\tdDiffuseLight += light_globalAmbient;\n}\n",ambientEnvPS:"\n#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nvoid addAmbient(vec3 worldNormal) {\n\tvec3 dir = normalize(cubeMapRotate(worldNormal) * vec3(-1.0, 1.0, 1.0));\n\tvec2 uv = mapUv(toSphericalUv(dir), vec4(128.0, 256.0 + 128.0, 64.0, 32.0) / atlasSize);\n\tvec4 raw = texture2D(texture_envAtlas, uv);\n\tvec3 linear = $DECODE(raw);\n\tdDiffuseLight += processEnvironment(linear);\n}\n",ambientSHPS:"\nuniform vec3 ambientSH[9];\nvoid addAmbient(vec3 worldNormal) {\n\tvec3 n = cubeMapRotate(worldNormal);\n\tvec3 color =\n\t\tambientSH[0] +\n\t\tambientSH[1] * n.x +\n\t\tambientSH[2] * n.y +\n\t\tambientSH[3] * n.z +\n\t\tambientSH[4] * n.x * n.z +\n\t\tambientSH[5] * n.z * n.y +\n\t\tambientSH[6] * n.y * n.x +\n\t\tambientSH[7] * (3.0 * n.z * n.z - 1.0) +\n\t\tambientSH[8] * (n.x * n.x - n.y * n.y);\n\tdDiffuseLight += processEnvironment(max(color, vec3(0.0)));\n}\n",aoPS:"\nvoid getAO() {\n\tdAo = 1.0;\n\t#ifdef MAPTEXTURE\n\tfloat aoBase = texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\tdAo *= addAoDetail(aoBase);\n\t#endif\n\t#ifdef MAPVERTEX\n\tdAo *= saturate(vVertexColor.$VC);\n\t#endif\n}\n",aoDetailMapPS:"\nfloat addAoDetail(float ao) {\n#ifdef MAPTEXTURE\n\tfloat aoDetail = texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\treturn detailMode_$DETAILMODE(vec3(ao), vec3(aoDetail)).r;\n#else\n\treturn ao;\n#endif\n}\n",aoDiffuseOccPS:"\nvoid occludeDiffuse(float ao) {\n\tdDiffuseLight *= ao;\n}\n",aoSpecOccPS:"\nuniform float material_occludeSpecularIntensity;\nvoid occludeSpecular(float gloss, float ao, vec3 worldNormal, vec3 viewDir) {\n\tfloat specPow = exp2(gloss * 11.0);\n\tfloat specOcc = saturate(pow(dot(worldNormal, viewDir) + ao, 0.01*specPow) - 1.0 + ao);\n\tspecOcc = mix(1.0, specOcc, material_occludeSpecularIntensity);\n\tdSpecularLight *= specOcc;\n\tdReflection *= specOcc;\n\t\n#ifdef LIT_SHEEN\n\tsSpecularLight *= specOcc;\n\tsReflection *= specOcc;\n#endif\n}\n",aoSpecOccConstPS:"\nvoid occludeSpecular(float gloss, float ao, vec3 worldNormal, vec3 viewDir) {\n\tfloat specPow = exp2(gloss * 11.0);\n\tfloat specOcc = saturate(pow(dot(worldNormal, viewDir) + ao, 0.01*specPow) - 1.0 + ao);\n\tdSpecularLight *= specOcc;\n\tdReflection *= specOcc;\n\t\n#ifdef LIT_SHEEN\n\tsSpecularLight *= specOcc;\n\tsReflection *= specOcc;\n#endif\n}\n",aoSpecOccConstSimplePS:"\nvoid occludeSpecular(float gloss, float ao, vec3 worldNormal, vec3 viewDir) {\n\tdSpecularLight *= ao;\n\tdReflection *= ao;\n#ifdef LIT_SHEEN\n\tsSpecularLight *= ao;\n\tsReflection *= ao;\n#endif\n}\n",aoSpecOccSimplePS:"\nuniform float material_occludeSpecularIntensity;\nvoid occludeSpecular(float gloss, float ao, vec3 worldNormal, vec3 viewDir) {\n\tfloat specOcc = mix(1.0, ao, material_occludeSpecularIntensity);\n\tdSpecularLight *= specOcc;\n\tdReflection *= specOcc;\n#ifdef LIT_SHEEN\n\tsSpecularLight *= specOcc;\n\tsReflection *= specOcc;\n#endif\n}\n",basePS:"\nuniform vec3 view_position;\nuniform vec3 light_globalAmbient;\nfloat square(float x) {\n\treturn x*x;\n}\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\nvec3 saturate(vec3 x) {\n\treturn clamp(x, vec3(0.0), vec3(1.0));\n}\n",baseVS:"\nattribute vec3 vertex_position;\nattribute vec3 vertex_normal;\nattribute vec4 vertex_tangent;\nattribute vec2 vertex_texCoord0;\nattribute vec2 vertex_texCoord1;\nattribute vec4 vertex_color;\nuniform mat4 matrix_viewProjection;\nuniform mat4 matrix_model;\nuniform mat3 matrix_normal;\nvec3 dPositionW;\nmat4 dModelMatrix;\nmat3 dNormalMatrix;\n",baseNineSlicedPS:"\n#define NINESLICED\nvarying vec2 vMask;\nvarying vec2 vTiledUv;\nuniform mediump vec4 innerOffset;\nuniform mediump vec2 outerScale;\nuniform mediump vec4 atlasRect;\nvec2 nineSlicedUv;\n",baseNineSlicedVS:"\n#define NINESLICED\nvarying vec2 vMask;\nvarying vec2 vTiledUv;\nuniform mediump vec4 innerOffset;\nuniform mediump vec2 outerScale;\nuniform mediump vec4 atlasRect;\n",baseNineSlicedTiledPS:"\n#define NINESLICED\n#define NINESLICETILED\nvarying vec2 vMask;\nvarying vec2 vTiledUv;\nuniform mediump vec4 innerOffset;\nuniform mediump vec2 outerScale;\nuniform mediump vec4 atlasRect;\nvec2 nineSlicedUv;\n",bayerPS:"\nfloat bayer2(vec2 p) {\n\treturn mod(2.0 * p.y + p.x + 1.0, 4.0);\n}\nfloat bayer4(vec2 p) {\n\tvec2 p1 = mod(p, 2.0);\n\tvec2 p2 = floor(0.5 * mod(p, 4.0));\n\treturn 4.0 * bayer2(p1) + bayer2(p2);\n}\nfloat bayer8(vec2 p) {\n\tvec2 p1 = mod(p, 2.0);\n\tvec2 p2 = floor(0.5 * mod(p, 4.0));\n\tvec2 p4 = floor(0.25 * mod(p, 8.0));\n\treturn 4.0 * (4.0 * bayer2(p1) + bayer2(p2)) + bayer2(p4);\n}\n",biasConstPS:"\n#define SHADOWBIAS\n#define SHADOW_SAMPLE_Z_BIAS\nfloat getShadowBias(float resolution, float maxBias) {\n\treturn maxBias;\n}\n",blurVSMPS:"\nvarying vec2 vUv0;\nuniform sampler2D source;\nuniform vec2 pixelOffset;\n#ifdef GAUSS\nuniform float weight[SAMPLES];\n#endif\n#ifdef PACKED\nfloat decodeFloatRG(vec2 rg) {\n\treturn rg.y*(1.0/255.0) + rg.x;\n}\nvec2 encodeFloatRG( float v ) {\n\tvec2 enc = vec2(1.0, 255.0) * v;\n\tenc = fract(enc);\n\tenc -= enc.yy * vec2(1.0/255.0, 1.0/255.0);\n\treturn enc;\n}\n#endif\nvoid main(void) {\n\tvec3 moments = vec3(0.0);\n\tvec2 uv = vUv0 - pixelOffset * (float(SAMPLES) * 0.5);\n\tfor (int i=0; i shadowZ ? 1.0 : 0.0;\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF3)\n\tfloat getShadowOmniClusteredPCF3(sampler2D shadowMap, vec4 shadowParams, vec3 omniAtlasViewport, float shadowEdgePixels, vec3 lightDir) {\n\t\tfloat shadowTextureResolution = shadowParams.x;\n\t\tvec2 uv = getCubemapAtlasCoordinates(omniAtlasViewport, shadowEdgePixels, shadowTextureResolution, lightDir);\n\t\tfloat shadowZ = length(lightDir) * shadowParams.w + shadowParams.z;\n\t\tvec3 shadowCoord = vec3(uv, shadowZ);\n\t\treturn getShadowPCF3x3(shadowMap, shadowCoord, shadowParams);\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF5)\n\tfloat getShadowOmniClusteredPCF5(sampler2D shadowMap, vec4 shadowParams, vec3 omniAtlasViewport, float shadowEdgePixels, vec3 lightDir) {\n\t\tfloat shadowTextureResolution = shadowParams.x;\n\t\tvec2 uv = getCubemapAtlasCoordinates(omniAtlasViewport, shadowEdgePixels, shadowTextureResolution, lightDir);\n\t\tfloat shadowZ = length(lightDir) * shadowParams.w + shadowParams.z;\n\t\tvec3 shadowCoord = vec3(uv, shadowZ);\n\t\treturn getShadowPCF3x3(shadowMap, shadowCoord, shadowParams);\n\t}\n\t#endif\n#endif\n#ifdef GL2\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF1)\n\tfloat getShadowSpotClusteredPCF1(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\t\treturn textureShadow(shadowMap, shadowCoord);\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF3)\n\tfloat getShadowSpotClusteredPCF3(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\t\treturn getShadowSpotPCF3x3(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams);\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF5)\n\tfloat getShadowSpotClusteredPCF5(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\t\treturn getShadowPCF5x5(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams);\n\t}\n\t#endif\n#else\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF1)\n\tfloat getShadowSpotClusteredPCF1(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\t\tfloat depth = unpackFloat(textureShadow(shadowMap, shadowCoord.xy));\n\t\treturn depth > shadowCoord.z ? 1.0 : 0.0;\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF3)\n\tfloat getShadowSpotClusteredPCF3(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\t\treturn getShadowSpotPCF3x3(shadowMap, shadowCoord, shadowParams);\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF5)\n\tfloat getShadowSpotClusteredPCF5(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\t\treturn getShadowSpotPCF3x3(shadowMap, shadowCoord, shadowParams);\n\t}\n\t#endif\n#endif\n",clusteredLightUtilsPS:"\nvec2 getCubemapFaceCoordinates(const vec3 dir, out float faceIndex, out vec2 tileOffset)\n{\n\tvec3 vAbs = abs(dir);\n\tfloat ma;\n\tvec2 uv;\n\tif (vAbs.z >= vAbs.x && vAbs.z >= vAbs.y) {\n\t\tfaceIndex = dir.z < 0.0 ? 5.0 : 4.0;\n\t\tma = 0.5 / vAbs.z;\n\t\tuv = vec2(dir.z < 0.0 ? -dir.x : dir.x, -dir.y);\n\t\ttileOffset.x = 2.0;\n\t\ttileOffset.y = dir.z < 0.0 ? 1.0 : 0.0;\n\t} else if(vAbs.y >= vAbs.x) {\n\t\tfaceIndex = dir.y < 0.0 ? 3.0 : 2.0;\n\t\tma = 0.5 / vAbs.y;\n\t\tuv = vec2(dir.x, dir.y < 0.0 ? -dir.z : dir.z);\n\t\ttileOffset.x = 1.0;\n\t\ttileOffset.y = dir.y < 0.0 ? 1.0 : 0.0;\n\t} else {\n\t\tfaceIndex = dir.x < 0.0 ? 1.0 : 0.0;\n\t\tma = 0.5 / vAbs.x;\n\t\tuv = vec2(dir.x < 0.0 ? dir.z : -dir.z, -dir.y);\n\t\ttileOffset.x = 0.0;\n\t\ttileOffset.y = dir.x < 0.0 ? 1.0 : 0.0;\n\t}\n\treturn uv * ma + 0.5;\n}\nvec2 getCubemapAtlasCoordinates(const vec3 omniAtlasViewport, float shadowEdgePixels, float shadowTextureResolution, const vec3 dir) {\n\tfloat faceIndex;\n\tvec2 tileOffset;\n\tvec2 uv = getCubemapFaceCoordinates(dir, faceIndex, tileOffset);\n\tfloat atlasFaceSize = omniAtlasViewport.z;\n\tfloat tileSize = shadowTextureResolution * atlasFaceSize;\n\tfloat offset = shadowEdgePixels / tileSize;\n\tuv = uv * vec2(1.0 - offset * 2.0) + vec2(offset * 1.0);\n\tuv *= atlasFaceSize;\n\tuv += tileOffset * atlasFaceSize;\n\tuv += omniAtlasViewport.xy;\n\treturn uv;\n}\n",clusteredLightPS:"\nuniform highp sampler2D clusterWorldTexture;\nuniform highp sampler2D lightsTexture8;\nuniform highp sampler2D lightsTextureFloat;\n#if defined(CLUSTER_COOKIES)\n\t#define CLUSTER_COOKIES_OR_SHADOWS\n#endif\n#if defined(CLUSTER_SHADOWS)\n\t#define CLUSTER_COOKIES_OR_SHADOWS\n#endif\n#ifdef CLUSTER_SHADOWS\n\t#ifdef GL2\n\t\tuniform sampler2DShadow shadowAtlasTexture;\n\t#else\n\t\tuniform sampler2D shadowAtlasTexture;\n\t#endif\n#endif\n#ifdef CLUSTER_COOKIES\n\tuniform sampler2D cookieAtlasTexture;\n#endif\n#ifdef GL2\n\tuniform int clusterMaxCells;\n#else\n\tuniform float clusterMaxCells;\n\tuniform vec4 lightsTextureInvSize;\n#endif\nuniform float clusterSkip;\nuniform vec3 clusterCellsCountByBoundsSize;\nuniform vec3 clusterTextureSize;\nuniform vec3 clusterBoundsMin;\nuniform vec3 clusterBoundsDelta;\nuniform vec3 clusterCellsDot;\nuniform vec3 clusterCellsMax;\nuniform vec2 clusterCompressionLimit0;\nuniform vec2 shadowAtlasParams;\nstruct ClusterLightData {\n\tvec3 halfWidth;\n\tfloat lightType;\n\tvec3 halfHeight;\n\t#ifdef GL2\n\t\tint lightIndex;\n\t#else\n\t\tfloat lightV;\n\t#endif\n\tvec3 position;\n\tfloat shape;\n\tvec3 direction;\n\tfloat falloffMode;\n\tvec3 color;\n\tfloat shadowIntensity;\n\tvec3 omniAtlasViewport;\n\tfloat range;\n\tvec4 cookieChannelMask;\n\tfloat shadowBias;\n\tfloat shadowNormalBias;\n\tfloat innerConeAngleCos;\n\tfloat outerConeAngleCos;\n\tfloat cookie;\n\tfloat cookieRgb;\n\tfloat cookieIntensity;\n\tfloat mask;\n};\nmat4 lightProjectionMatrix;\n#define isClusteredLightCastShadow(light) ( light.shadowIntensity > 0.0 )\n#define isClusteredLightCookie(light) (light.cookie > 0.5 )\n#define isClusteredLightCookieRgb(light) (light.cookieRgb > 0.5 )\n#define isClusteredLightSpot(light) ( light.lightType > 0.5 )\n#define isClusteredLightFalloffLinear(light) ( light.falloffMode < 0.5 )\n#define isClusteredLightArea(light) ( light.shape > 0.1 )\n#define isClusteredLightRect(light) ( light.shape < 0.3 )\n#define isClusteredLightDisk(light) ( light.shape < 0.6 )\n#ifdef CLUSTER_MESH_DYNAMIC_LIGHTS\n\t#define acceptLightMask(light) ( light.mask < 0.75)\n#else\n\t#define acceptLightMask(light) ( light.mask > 0.25)\n#endif\nvec4 decodeClusterLowRange4Vec4(vec4 d0, vec4 d1, vec4 d2, vec4 d3) {\n\treturn vec4(\n\t\tbytes2floatRange4(d0, -2.0, 2.0),\n\t\tbytes2floatRange4(d1, -2.0, 2.0),\n\t\tbytes2floatRange4(d2, -2.0, 2.0),\n\t\tbytes2floatRange4(d3, -2.0, 2.0)\n\t);\n}\n#ifdef GL2\n\tvec4 sampleLightsTexture8(const ClusterLightData clusterLightData, int index) {\n\t\treturn texelFetch(lightsTexture8, ivec2(index, clusterLightData.lightIndex), 0);\n\t}\n\tvec4 sampleLightTextureF(const ClusterLightData clusterLightData, int index) {\n\t\treturn texelFetch(lightsTextureFloat, ivec2(index, clusterLightData.lightIndex), 0);\n\t}\n#else\n\tvec4 sampleLightsTexture8(const ClusterLightData clusterLightData, float index) {\n\t\treturn texture2DLodEXT(lightsTexture8, vec2(index * lightsTextureInvSize.z, clusterLightData.lightV), 0.0);\n\t}\n\tvec4 sampleLightTextureF(const ClusterLightData clusterLightData, float index) {\n\t\treturn texture2DLodEXT(lightsTextureFloat, vec2(index * lightsTextureInvSize.x, clusterLightData.lightV), 0.0);\n\t}\n#endif\nvoid decodeClusterLightCore(inout ClusterLightData clusterLightData, float lightIndex) {\n\t#ifdef GL2\n\t\tclusterLightData.lightIndex = int(lightIndex);\n\t#else\n\t\tclusterLightData.lightV = (lightIndex + 0.5) * lightsTextureInvSize.w;\n\t#endif\n\tvec4 lightInfo = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_FLAGS);\n\tclusterLightData.lightType = lightInfo.x;\n\tclusterLightData.shape = lightInfo.y;\n\tclusterLightData.falloffMode = lightInfo.z;\n\tclusterLightData.shadowIntensity = lightInfo.w;\n\tvec4 colorA = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_COLOR_A);\n\tvec4 colorB = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_COLOR_B);\n\tclusterLightData.color = vec3(bytes2float2(colorA.xy), bytes2float2(colorA.zw), bytes2float2(colorB.xy)) * clusterCompressionLimit0.y;\n\tclusterLightData.cookie = colorB.z;\n\tclusterLightData.mask = colorB.w;\n\t#ifdef CLUSTER_TEXTURE_FLOAT\n\t\tvec4 lightPosRange = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_POSITION_RANGE);\n\t\tclusterLightData.position = lightPosRange.xyz;\n\t\tclusterLightData.range = lightPosRange.w;\n\t\tvec4 lightDir_Unused = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_SPOT_DIRECTION);\n\t\tclusterLightData.direction = lightDir_Unused.xyz;\n\t#else\n\t\tvec4 encPosX = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_POSITION_X);\n\t\tvec4 encPosY = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_POSITION_Y);\n\t\tvec4 encPosZ = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_POSITION_Z);\n\t\tclusterLightData.position = vec3(bytes2float4(encPosX), bytes2float4(encPosY), bytes2float4(encPosZ)) * clusterBoundsDelta + clusterBoundsMin;\n\t\tvec4 encRange = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_RANGE);\n\t\tclusterLightData.range = bytes2float4(encRange) * clusterCompressionLimit0.x;\n\t\tvec4 encDirX = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_SPOT_DIRECTION_X);\n\t\tvec4 encDirY = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_SPOT_DIRECTION_Y);\n\t\tvec4 encDirZ = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_SPOT_DIRECTION_Z);\n\t\tclusterLightData.direction = vec3(bytes2float4(encDirX), bytes2float4(encDirY), bytes2float4(encDirZ)) * 2.0 - 1.0;\n\t#endif\n}\nvoid decodeClusterLightSpot(inout ClusterLightData clusterLightData) {\n\tvec4 coneAngle = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_SPOT_ANGLES);\n\tclusterLightData.innerConeAngleCos = bytes2float2(coneAngle.xy) * 2.0 - 1.0;\n\tclusterLightData.outerConeAngleCos = bytes2float2(coneAngle.zw) * 2.0 - 1.0;\n}\nvoid decodeClusterLightOmniAtlasViewport(inout ClusterLightData clusterLightData) {\n\t#ifdef CLUSTER_TEXTURE_FLOAT\n\t\tclusterLightData.omniAtlasViewport = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_PROJ_MAT_0).xyz;\n\t#else\n\t\tvec4 viewportA = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_ATLAS_VIEWPORT_A);\n\t\tvec4 viewportB = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_ATLAS_VIEWPORT_B);\n\t\tclusterLightData.omniAtlasViewport = vec3(bytes2float2(viewportA.xy), bytes2float2(viewportA.zw), bytes2float2(viewportB.xy));\n\t#endif\n}\nvoid decodeClusterLightAreaData(inout ClusterLightData clusterLightData) {\n\t#ifdef CLUSTER_TEXTURE_FLOAT\n\t\tclusterLightData.halfWidth = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_AREA_DATA_WIDTH).xyz;\n\t\tclusterLightData.halfHeight = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_AREA_DATA_HEIGHT).xyz;\n\t#else\n\t\tvec4 areaWidthX = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_WIDTH_X);\n\t\tvec4 areaWidthY = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_WIDTH_Y);\n\t\tvec4 areaWidthZ = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_WIDTH_Z);\n\t\tclusterLightData.halfWidth = vec3(mantissaExponent2Float(areaWidthX), mantissaExponent2Float(areaWidthY), mantissaExponent2Float(areaWidthZ));\n\t\tvec4 areaHeightX = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_HEIGHT_X);\n\t\tvec4 areaHeightY = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_HEIGHT_Y);\n\t\tvec4 areaHeightZ = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_HEIGHT_Z);\n\t\tclusterLightData.halfHeight = vec3(mantissaExponent2Float(areaHeightX), mantissaExponent2Float(areaHeightY), mantissaExponent2Float(areaHeightZ));\n\t#endif\n}\nvoid decodeClusterLightProjectionMatrixData(inout ClusterLightData clusterLightData) {\n\t\n\t#ifdef CLUSTER_TEXTURE_FLOAT\n\t\tvec4 m0 = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_PROJ_MAT_0);\n\t\tvec4 m1 = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_PROJ_MAT_1);\n\t\tvec4 m2 = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_PROJ_MAT_2);\n\t\tvec4 m3 = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_PROJ_MAT_3);\n\t#else\n\t\tvec4 m00 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_00);\n\t\tvec4 m01 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_01);\n\t\tvec4 m02 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_02);\n\t\tvec4 m03 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_03);\n\t\tvec4 m0 = decodeClusterLowRange4Vec4(m00, m01, m02, m03);\n\t\tvec4 m10 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_10);\n\t\tvec4 m11 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_11);\n\t\tvec4 m12 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_12);\n\t\tvec4 m13 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_13);\n\t\tvec4 m1 = decodeClusterLowRange4Vec4(m10, m11, m12, m13);\n\t\tvec4 m20 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_20);\n\t\tvec4 m21 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_21);\n\t\tvec4 m22 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_22);\n\t\tvec4 m23 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_23);\n\t\tvec4 m2 = decodeClusterLowRange4Vec4(m20, m21, m22, m23);\n\t\tvec4 m30 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_30);\n\t\tvec4 m31 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_31);\n\t\tvec4 m32 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_32);\n\t\tvec4 m33 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_33);\n\t\tvec4 m3 = vec4(mantissaExponent2Float(m30), mantissaExponent2Float(m31), mantissaExponent2Float(m32), mantissaExponent2Float(m33));\n\t#endif\n\t\n\tlightProjectionMatrix = mat4(m0, m1, m2, m3);\n}\nvoid decodeClusterLightShadowData(inout ClusterLightData clusterLightData) {\n\t\n\tvec4 biases = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_SHADOW_BIAS);\n\tclusterLightData.shadowBias = bytes2floatRange2(biases.xy, -1.0, 20.0),\n\tclusterLightData.shadowNormalBias = bytes2float2(biases.zw);\n}\nvoid decodeClusterLightCookieData(inout ClusterLightData clusterLightData) {\n\tvec4 cookieA = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_COOKIE_A);\n\tclusterLightData.cookieIntensity = cookieA.x;\n\tclusterLightData.cookieRgb = cookieA.y;\n\tclusterLightData.cookieChannelMask = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_COOKIE_B);\n}\nvoid evaluateLight(\n\tClusterLightData light, \n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tvec3 reflectionDir,\n#if defined(LIT_CLEARCOAT)\n\tvec3 clearcoatReflectionDir,\n#endif\n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 geometricNormal, \n\tmat3 tbn, \n#if defined(LIT_IRIDESCENCE)\n\tvec3 iridescenceFresnel,\n#endif\n\tvec3 clearcoat_worldNormal,\n\tfloat clearcoat_gloss,\n\tfloat sheen_gloss,\n\tfloat iridescence_intensity\n) {\n\tvec3 cookieAttenuation = vec3(1.0);\n\tfloat diffuseAttenuation = 1.0;\n\tfloat falloffAttenuation = 1.0;\n\tgetLightDirPoint(light.position);\n\t#ifdef CLUSTER_AREALIGHTS\n\tif (isClusteredLightArea(light)) {\n\t\tdecodeClusterLightAreaData(light);\n\t\tif (isClusteredLightRect(light)) {\n\t\t\tcalcRectLightValues(light.position, light.halfWidth, light.halfHeight);\n\t\t} else if (isClusteredLightDisk(light)) {\n\t\t\tcalcDiskLightValues(light.position, light.halfWidth, light.halfHeight);\n\t\t} else {\n\t\t\tcalcSphereLightValues(light.position, light.halfWidth, light.halfHeight);\n\t\t}\n\t\tfalloffAttenuation = getFalloffWindow(light.range, dLightDirW);\n\t} else\n\t#endif\n\t{\n\t\tif (isClusteredLightFalloffLinear(light))\n\t\t\tfalloffAttenuation = getFalloffLinear(light.range, dLightDirW);\n\t\telse\n\t\t\tfalloffAttenuation = getFalloffInvSquared(light.range, dLightDirW);\n\t}\n\tif (falloffAttenuation > 0.00001) {\n\t\t#ifdef CLUSTER_AREALIGHTS\n\t\tif (isClusteredLightArea(light)) {\n\t\t\tif (isClusteredLightRect(light)) {\n\t\t\t\tdiffuseAttenuation = getRectLightDiffuse(worldNormal, viewDir, dLightDirW, dLightDirNormW) * 16.0;\n\t\t\t} else if (isClusteredLightDisk(light)) {\n\t\t\t\tdiffuseAttenuation = getDiskLightDiffuse(worldNormal, viewDir, dLightDirW, dLightDirNormW) * 16.0;\n\t\t\t} else {\n\t\t\t\tdiffuseAttenuation = getSphereLightDiffuse(worldNormal, viewDir, dLightDirW, dLightDirNormW) * 16.0;\n\t\t\t}\n\t\t} else\n\t\t#endif\n\t\t{\n\t\t\tfalloffAttenuation *= getLightDiffuse(worldNormal, viewDir, dLightDirW, dLightDirNormW); \n\t\t}\n\t\tif (isClusteredLightSpot(light)) {\n\t\t\tdecodeClusterLightSpot(light);\n\t\t\tfalloffAttenuation *= getSpotEffect(light.direction, light.innerConeAngleCos, light.outerConeAngleCos, dLightDirNormW);\n\t\t}\n\t\t#if defined(CLUSTER_COOKIES_OR_SHADOWS)\n\t\tif (falloffAttenuation > 0.00001) {\n\t\t\tif (isClusteredLightCastShadow(light) || isClusteredLightCookie(light)) {\n\t\t\t\tif (isClusteredLightSpot(light)) {\n\t\t\t\t\tdecodeClusterLightProjectionMatrixData(light);\n\t\t\t\t} else {\n\t\t\t\t\tdecodeClusterLightOmniAtlasViewport(light);\n\t\t\t\t}\n\t\t\t\tfloat shadowTextureResolution = shadowAtlasParams.x;\n\t\t\t\tfloat shadowEdgePixels = shadowAtlasParams.y;\n\t\t\t\t#ifdef CLUSTER_COOKIES\n\t\t\t\tif (isClusteredLightCookie(light)) {\n\t\t\t\t\tdecodeClusterLightCookieData(light);\n\t\t\t\t\tif (isClusteredLightSpot(light)) {\n\t\t\t\t\t\tcookieAttenuation = getCookie2DClustered(TEXTURE_PASS(cookieAtlasTexture), lightProjectionMatrix, vPositionW, light.cookieIntensity, isClusteredLightCookieRgb(light), light.cookieChannelMask);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcookieAttenuation = getCookieCubeClustered(TEXTURE_PASS(cookieAtlasTexture), dLightDirW, light.cookieIntensity, isClusteredLightCookieRgb(light), light.cookieChannelMask, shadowTextureResolution, shadowEdgePixels, light.omniAtlasViewport);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t#endif\n\t\t\t\t#ifdef CLUSTER_SHADOWS\n\t\t\t\tif (isClusteredLightCastShadow(light)) {\n\t\t\t\t\tdecodeClusterLightShadowData(light);\n\t\t\t\t\tvec4 shadowParams = vec4(shadowTextureResolution, light.shadowNormalBias, light.shadowBias, 1.0 / light.range);\n\t\t\t\t\tif (isClusteredLightSpot(light)) {\n\t\t\t\t\t\tgetShadowCoordPerspZbufferNormalOffset(lightProjectionMatrix, shadowParams, geometricNormal);\n\t\t\t\t\t\t\n\t\t\t\t\t\t#if defined(CLUSTER_SHADOW_TYPE_PCF1)\n\t\t\t\t\t\t\tfloat shadow = getShadowSpotClusteredPCF1(SHADOWMAP_PASS(shadowAtlasTexture), dShadowCoord, shadowParams);\n\t\t\t\t\t\t#elif defined(CLUSTER_SHADOW_TYPE_PCF3)\n\t\t\t\t\t\t\tfloat shadow = getShadowSpotClusteredPCF3(SHADOWMAP_PASS(shadowAtlasTexture), dShadowCoord, shadowParams);\n\t\t\t\t\t\t#elif defined(CLUSTER_SHADOW_TYPE_PCF5)\n\t\t\t\t\t\t\tfloat shadow = getShadowSpotClusteredPCF5(SHADOWMAP_PASS(shadowAtlasTexture), dShadowCoord, shadowParams);\n\t\t\t\t\t\t#elif defined(CLUSTER_SHADOW_TYPE_PCSS)\n\t\t\t\t\t\t\tfloat shadow = getShadowSpotClusteredPCSS(SHADOWMAP_PASS(shadowAtlasTexture), dShadowCoord, shadowParams);\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tfalloffAttenuation *= mix(1.0, shadow, light.shadowIntensity);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvec3 dir = normalOffsetPointShadow(shadowParams, dLightPosW, dLightDirW, dLightDirNormW, geometricNormal);\n\t\t\t\t\t\t#if defined(CLUSTER_SHADOW_TYPE_PCF1)\n\t\t\t\t\t\t\tfloat shadow = getShadowOmniClusteredPCF1(SHADOWMAP_PASS(shadowAtlasTexture), shadowParams, light.omniAtlasViewport, shadowEdgePixels, dir);\n\t\t\t\t\t\t#elif defined(CLUSTER_SHADOW_TYPE_PCF3)\n\t\t\t\t\t\t\tfloat shadow = getShadowOmniClusteredPCF3(SHADOWMAP_PASS(shadowAtlasTexture), shadowParams, light.omniAtlasViewport, shadowEdgePixels, dir);\n\t\t\t\t\t\t#elif defined(CLUSTER_SHADOW_TYPE_PCF5)\n\t\t\t\t\t\t\tfloat shadow = getShadowOmniClusteredPCF5(SHADOWMAP_PASS(shadowAtlasTexture), shadowParams, light.omniAtlasViewport, shadowEdgePixels, dir);\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tfalloffAttenuation *= mix(1.0, shadow, light.shadowIntensity);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t#endif\n\t\t\t}\n\t\t}\n\t\t#endif\n\t\t#ifdef CLUSTER_AREALIGHTS\n\t\tif (isClusteredLightArea(light)) {\n\t\t\t{\n\t\t\t\tvec3 areaDiffuse = (diffuseAttenuation * falloffAttenuation) * light.color * cookieAttenuation;\n\t\t\t\t#if defined(LIT_SPECULAR)\n\t\t\t\t\t#if defined(LIT_CONSERVE_ENERGY)\n\t\t\t\t\t\tareaDiffuse = mix(areaDiffuse, vec3(0), dLTCSpecFres);\n\t\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t\tdDiffuseLight += areaDiffuse;\n\t\t\t}\n\t\t\t#ifdef LIT_SPECULAR\n\t\t\t\tfloat areaLightSpecular;\n\t\t\t\tif (isClusteredLightRect(light)) {\n\t\t\t\t\tareaLightSpecular = getRectLightSpecular(worldNormal, viewDir);\n\t\t\t\t} else if (isClusteredLightDisk(light)) {\n\t\t\t\t\tareaLightSpecular = getDiskLightSpecular(worldNormal, viewDir);\n\t\t\t\t} else {\n\t\t\t\t\tareaLightSpecular = getSphereLightSpecular(worldNormal, viewDir);\n\t\t\t\t}\n\t\t\t\tdSpecularLight += dLTCSpecFres * areaLightSpecular * falloffAttenuation * light.color * cookieAttenuation;\n\t\t\t\t#ifdef LIT_CLEARCOAT\n\t\t\t\t\tfloat areaLightSpecularCC;\n\t\t\t\t\tif (isClusteredLightRect(light)) {\n\t\t\t\t\t\tareaLightSpecularCC = getRectLightSpecular(clearcoat_worldNormal, viewDir);\n\t\t\t\t\t} else if (isClusteredLightDisk(light)) {\n\t\t\t\t\t\tareaLightSpecularCC = getDiskLightSpecular(clearcoat_worldNormal, viewDir);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tareaLightSpecularCC = getSphereLightSpecular(clearcoat_worldNormal, viewDir);\n\t\t\t\t\t}\n\t\t\t\t\tccSpecularLight += ccLTCSpecFres * areaLightSpecularCC * falloffAttenuation * light.color * cookieAttenuation;\n\t\t\t\t#endif\n\t\t\t#endif\n\t\t} else\n\t\t#endif\n\t\t{\n\t\t\t{\n\t\t\t\tvec3 punctualDiffuse = falloffAttenuation * light.color * cookieAttenuation;\n\t\t\t\t#if defined(CLUSTER_AREALIGHTS)\n\t\t\t\t#if defined(LIT_SPECULAR)\n\t\t\t\t#if defined(LIT_CONSERVE_ENERGY)\n\t\t\t\t\tpunctualDiffuse = mix(punctualDiffuse, vec3(0), specularity);\n\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t\tdDiffuseLight += punctualDiffuse;\n\t\t\t}\n \n\t\t\t#ifdef LIT_SPECULAR\n\t\t\t\tvec3 halfDir = normalize(-dLightDirNormW + viewDir);\n\t\t\t\t\n\t\t\t\t#ifdef LIT_SPECULAR_FRESNEL\n\t\t\t\t\tdSpecularLight += \n\t\t\t\t\t\tgetLightSpecular(halfDir, reflectionDir, worldNormal, viewDir, dLightDirNormW, gloss, tbn) * falloffAttenuation * light.color * cookieAttenuation * \n\t\t\t\t\t\tgetFresnel(\n\t\t\t\t\t\t\tdot(viewDir, halfDir), \n\t\t\t\t\t\t\tgloss, \n\t\t\t\t\t\t\tspecularity\n\t\t\t\t\t\t#if defined(LIT_IRIDESCENCE)\n\t\t\t\t\t\t\t, iridescenceFresnel,\n\t\t\t\t\t\t\tiridescence_intensity\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t\t);\n\t\t\t\t#else\n\t\t\t\t\tdSpecularLight += getLightSpecular(halfDir, reflectionDir, worldNormal, viewDir, dLightDirNormW, gloss, tbn) * falloffAttenuation * light.color * cookieAttenuation * specularity;\n\t\t\t\t#endif\n\t\t\t\t#ifdef LIT_CLEARCOAT\n\t\t\t\t\t#ifdef LIT_SPECULAR_FRESNEL\n\t\t\t\t\t\tccSpecularLight += getLightSpecular(halfDir, clearcoatReflectionDir, clearcoat_worldNormal, viewDir, dLightDirNormW, clearcoat_gloss, tbn) * falloffAttenuation * light.color * cookieAttenuation * getFresnelCC(dot(viewDir, halfDir));\n\t\t\t\t\t#else\n\t\t\t\t\t\tccSpecularLight += getLightSpecular(halfDir, clearcoatReflectionDir, clearcoat_worldNormal, viewDir, dLightDirNormW, clearcoat_gloss, tbn) * falloffAttenuation * light.color * cookieAttenuation; \n\t\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t\t#ifdef LIT_SHEEN\n\t\t\t\t\tsSpecularLight += getLightSpecularSheen(halfDir, worldNormal, viewDir, dLightDirNormW, sheen_gloss) * falloffAttenuation * light.color * cookieAttenuation;\n\t\t\t\t#endif\n\t\t\t#endif\n\t\t}\n\t}\n\tdAtten = falloffAttenuation;\n\tdAttenD = diffuseAttenuation;\n\tdAtten3 = cookieAttenuation;\n}\nvoid evaluateClusterLight(\n\tfloat lightIndex, \n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tvec3 reflectionDir, \n#if defined(LIT_CLEARCOAT)\n\tvec3 clearcoatReflectionDir,\n#endif\n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 geometricNormal, \n\tmat3 tbn, \n#if defined(LIT_IRIDESCENCE)\n\tvec3 iridescenceFresnel,\n#endif\n\tvec3 clearcoat_worldNormal,\n\tfloat clearcoat_gloss,\n\tfloat sheen_gloss,\n\tfloat iridescence_intensity\n) {\n\tClusterLightData clusterLightData;\n\tdecodeClusterLightCore(clusterLightData, lightIndex);\n\tif (acceptLightMask(clusterLightData))\n\t\tevaluateLight(\n\t\t\tclusterLightData, \n\t\t\tworldNormal, \n\t\t\tviewDir, \n\t\t\treflectionDir, \n#if defined(LIT_CLEARCOAT)\n\t\t\tclearcoatReflectionDir, \n#endif\n\t\t\tgloss, \n\t\t\tspecularity, \n\t\t\tgeometricNormal, \n\t\t\ttbn, \n#if defined(LIT_IRIDESCENCE)\n\t\t\tiridescenceFresnel,\n#endif\n\t\t\tclearcoat_worldNormal,\n\t\t\tclearcoat_gloss,\n\t\t\tsheen_gloss,\n\t\t\tiridescence_intensity\n\t\t);\n}\nvoid addClusteredLights(\n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tvec3 reflectionDir, \n#if defined(LIT_CLEARCOAT)\n\tvec3 clearcoatReflectionDir,\n#endif\n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 geometricNormal, \n\tmat3 tbn, \n#if defined(LIT_IRIDESCENCE)\n\tvec3 iridescenceFresnel,\n#endif\n\tvec3 clearcoat_worldNormal,\n\tfloat clearcoat_gloss,\n\tfloat sheen_gloss,\n\tfloat iridescence_intensity\n) {\n\tif (clusterSkip > 0.5)\n\t\treturn;\n\tvec3 cellCoords = floor((vPositionW - clusterBoundsMin) * clusterCellsCountByBoundsSize);\n\tif (!(any(lessThan(cellCoords, vec3(0.0))) || any(greaterThanEqual(cellCoords, clusterCellsMax)))) {\n\t\tfloat cellIndex = dot(clusterCellsDot, cellCoords);\n\t\tfloat clusterV = floor(cellIndex * clusterTextureSize.y);\n\t\tfloat clusterU = cellIndex - (clusterV * clusterTextureSize.x);\n\t\t#ifdef GL2\n\t\t\tfor (int lightCellIndex = 0; lightCellIndex < clusterMaxCells; lightCellIndex++) {\n\t\t\t\tfloat lightIndex = texelFetch(clusterWorldTexture, ivec2(int(clusterU) + lightCellIndex, clusterV), 0).x;\n\t\t\t\tif (lightIndex <= 0.0)\n\t\t\t\t\t\treturn;\n\t\t\t\tevaluateClusterLight(\n\t\t\t\t\tlightIndex * 255.0, \n\t\t\t\t\tworldNormal, \n\t\t\t\t\tviewDir, \n\t\t\t\t\treflectionDir,\n#if defined(LIT_CLEARCOAT)\n\t\t\t\t\tclearcoatReflectionDir,\n#endif\n\t\t\t\t\tgloss, \n\t\t\t\t\tspecularity, \n\t\t\t\t\tgeometricNormal, \n\t\t\t\t\ttbn, \n#if defined(LIT_IRIDESCENCE)\n\t\t\t\t\tiridescenceFresnel,\n#endif\n\t\t\t\t\tclearcoat_worldNormal,\n\t\t\t\t\tclearcoat_gloss,\n\t\t\t\t\tsheen_gloss,\n\t\t\t\t\tiridescence_intensity\n\t\t\t\t); \n\t\t\t}\n\t\t#else\n\t\t\tclusterV = (clusterV + 0.5) * clusterTextureSize.z;\n\t\t\tconst float maxLightCells = 256.0;\n\t\t\tfor (float lightCellIndex = 0.5; lightCellIndex < maxLightCells; lightCellIndex++) {\n\t\t\t\tfloat lightIndex = texture2DLodEXT(clusterWorldTexture, vec2(clusterTextureSize.y * (clusterU + lightCellIndex), clusterV), 0.0).x;\n\t\t\t\tif (lightIndex <= 0.0)\n\t\t\t\t\treturn;\n\t\t\t\t\n\t\t\t\tevaluateClusterLight(\n\t\t\t\t\tlightIndex * 255.0, \n\t\t\t\t\tworldNormal, \n\t\t\t\t\tviewDir, \n\t\t\t\t\treflectionDir,\n#if defined(LIT_CLEARCOAT)\n\t\t\t\t\tclearcoatReflectionDir,\n#endif\n\t\t\t\t\tgloss, \n\t\t\t\t\tspecularity, \n\t\t\t\t\tgeometricNormal, \n\t\t\t\t\ttbn, \n#if defined(LIT_IRIDESCENCE)\n\t\t\t\t\tiridescenceFresnel,\n#endif\n\t\t\t\t\tclearcoat_worldNormal,\n\t\t\t\t\tclearcoat_gloss,\n\t\t\t\t\tsheen_gloss,\n\t\t\t\t\tiridescence_intensity\n\t\t\t\t); \n\t\t\t\tif (lightCellIndex >= clusterMaxCells) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t#endif\n\t}\n}\n",combinePS:"\nvec3 combineColor(vec3 albedo, vec3 sheenSpecularity, float clearcoatSpecularity) {\n\tvec3 ret = vec3(0);\n#ifdef LIT_OLD_AMBIENT\n\tret += (dDiffuseLight - light_globalAmbient) * albedo + material_ambient * light_globalAmbient;\n#else\n\tret += albedo * dDiffuseLight;\n#endif\n#ifdef LIT_SPECULAR\n\tret += dSpecularLight;\n#endif\n#ifdef LIT_REFLECTIONS\n\tret += dReflection.rgb * dReflection.a;\n#endif\n#ifdef LIT_SHEEN\n\tfloat sheenScaling = 1.0 - max(max(sheenSpecularity.r, sheenSpecularity.g), sheenSpecularity.b) * 0.157;\n\tret = ret * sheenScaling + (sSpecularLight + sReflection.rgb) * sheenSpecularity;\n#endif\n#ifdef LIT_CLEARCOAT\n\tfloat clearCoatScaling = 1.0 - ccFresnel * clearcoatSpecularity;\n\tret = ret * clearCoatScaling + (ccSpecularLight + ccReflection.rgb) * clearcoatSpecularity;\n#endif\n\treturn ret;\n}\n",cookiePS:"\nvec4 getCookie2D(sampler2D tex, mat4 transform, float intensity) {\n\tvec4 projPos = transform * vec4(vPositionW, 1.0);\n\tprojPos.xy /= projPos.w;\n\treturn mix(vec4(1.0), texture2D(tex, projPos.xy), intensity);\n}\nvec4 getCookie2DClip(sampler2D tex, mat4 transform, float intensity) {\n\tvec4 projPos = transform * vec4(vPositionW, 1.0);\n\tprojPos.xy /= projPos.w;\n\tif (projPos.x < 0.0 || projPos.x > 1.0 || projPos.y < 0.0 || projPos.y > 1.0 || projPos.z < 0.0) return vec4(0.0);\n\treturn mix(vec4(1.0), texture2D(tex, projPos.xy), intensity);\n}\nvec4 getCookie2DXform(sampler2D tex, mat4 transform, float intensity, vec4 cookieMatrix, vec2 cookieOffset) {\n\tvec4 projPos = transform * vec4(vPositionW, 1.0);\n\tprojPos.xy /= projPos.w;\n\tprojPos.xy += cookieOffset;\n\tvec2 uv = mat2(cookieMatrix) * (projPos.xy-vec2(0.5)) + vec2(0.5);\n\treturn mix(vec4(1.0), texture2D(tex, uv), intensity);\n}\nvec4 getCookie2DClipXform(sampler2D tex, mat4 transform, float intensity, vec4 cookieMatrix, vec2 cookieOffset) {\n\tvec4 projPos = transform * vec4(vPositionW, 1.0);\n\tprojPos.xy /= projPos.w;\n\tprojPos.xy += cookieOffset;\n\tif (projPos.x < 0.0 || projPos.x > 1.0 || projPos.y < 0.0 || projPos.y > 1.0 || projPos.z < 0.0) return vec4(0.0);\n\tvec2 uv = mat2(cookieMatrix) * (projPos.xy-vec2(0.5)) + vec2(0.5);\n\treturn mix(vec4(1.0), texture2D(tex, uv), intensity);\n}\nvec4 getCookieCube(samplerCube tex, mat4 transform, float intensity) {\n\treturn mix(vec4(1.0), textureCube(tex, dLightDirNormW * mat3(transform)), intensity);\n}\n",cubeMapProjectBoxPS:"\nuniform vec3 envBoxMin;\nuniform vec3 envBoxMax;\nvec3 cubeMapProject(vec3 nrdir) {\n\tnrdir = cubeMapRotate(nrdir);\n\tvec3 rbmax = (envBoxMax - vPositionW) / nrdir;\n\tvec3 rbmin = (envBoxMin - vPositionW) / nrdir;\n\tvec3 rbminmax;\n\trbminmax.x = nrdir.x>0.0? rbmax.x : rbmin.x;\n\trbminmax.y = nrdir.y>0.0? rbmax.y : rbmin.y;\n\trbminmax.z = nrdir.z>0.0? rbmax.z : rbmin.z;\n\tfloat fa = min(min(rbminmax.x, rbminmax.y), rbminmax.z);\n\tvec3 posonbox = vPositionW + nrdir * fa;\n\tvec3 envBoxPos = (envBoxMin + envBoxMax) * 0.5;\n\treturn normalize(posonbox - envBoxPos);\n}\n",cubeMapProjectNonePS:"\nvec3 cubeMapProject(vec3 dir) {\n\treturn cubeMapRotate(dir);\n}\n",cubeMapRotatePS:"\n#ifdef CUBEMAP_ROTATION\nuniform mat3 cubeMapRotationMatrix;\n#endif\nvec3 cubeMapRotate(vec3 refDir) {\n#ifdef CUBEMAP_ROTATION\n\treturn refDir * cubeMapRotationMatrix;\n#else\n\treturn refDir;\n#endif\n}\n",debugOutputPS:"\n#ifdef DEBUG_ALBEDO_PASS\ngl_FragColor = vec4(gammaCorrectOutput(dAlbedo), 1.0);\n#endif\n#ifdef DEBUG_UV0_PASS\ngl_FragColor = vec4(litArgs_albedo , 1.0);\n#endif\n#ifdef DEBUG_WORLD_NORMAL_PASS\ngl_FragColor = vec4(litArgs_worldNormal * 0.5 + 0.5, 1.0);\n#endif\n#ifdef DEBUG_OPACITY_PASS\ngl_FragColor = vec4(vec3(litArgs_opacity) , 1.0);\n#endif\n#ifdef DEBUG_SPECULARITY_PASS\ngl_FragColor = vec4(litArgs_specularity, 1.0);\n#endif\n#ifdef DEBUG_GLOSS_PASS\ngl_FragColor = vec4(vec3(litArgs_gloss) , 1.0);\n#endif\n#ifdef DEBUG_METALNESS_PASS\ngl_FragColor = vec4(vec3(litArgs_metalness) , 1.0);\n#endif\n#ifdef DEBUG_AO_PASS\ngl_FragColor = vec4(vec3(litArgs_ao) , 1.0);\n#endif\n#ifdef DEBUG_EMISSION_PASS\ngl_FragColor = vec4(gammaCorrectOutput(litArgs_emission), 1.0);\n#endif\n",debugProcessFrontendPS:"\n#ifdef DEBUG_LIGHTING_PASS\nlitArgs_albedo = vec3(0.5);\n#endif\n#ifdef DEBUG_UV0_PASS\n#ifdef VARYING_VUV0\nlitArgs_albedo = vec3(vUv0, 0);\n#else\nlitArgs_albedo = vec3(0);\n#endif\n#endif\n",detailModesPS:"\nvec3 detailMode_mul(vec3 c1, vec3 c2) {\n\treturn c1 * c2;\n}\nvec3 detailMode_add(vec3 c1, vec3 c2) {\n\treturn c1 + c2;\n}\nvec3 detailMode_screen(vec3 c1, vec3 c2) {\n\treturn 1.0 - (1.0 - c1)*(1.0 - c2);\n}\nvec3 detailMode_overlay(vec3 c1, vec3 c2) {\n\treturn mix(1.0 - 2.0*(1.0 - c1)*(1.0 - c2), 2.0*c1*c2, step(c1, vec3(0.5)));\n}\nvec3 detailMode_min(vec3 c1, vec3 c2) {\n\treturn min(c1, c2);\n}\nvec3 detailMode_max(vec3 c1, vec3 c2) {\n\treturn max(c1, c2);\n}\n",diffusePS:"\n#ifdef MAPCOLOR\nuniform vec3 material_diffuse;\n#endif\nvoid getAlbedo() {\n\tdAlbedo = vec3(1.0);\n#ifdef MAPCOLOR\n\tdAlbedo *= material_diffuse.rgb;\n#endif\n#ifdef MAPTEXTURE\n\tvec3 albedoBase = $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\tdAlbedo *= addAlbedoDetail(albedoBase);\n#endif\n#ifdef MAPVERTEX\n\tdAlbedo *= gammaCorrectInput(saturate(vVertexColor.$VC));\n#endif\n}\n",diffuseDetailMapPS:"\nvec3 addAlbedoDetail(vec3 albedo) {\n#ifdef MAPTEXTURE\n\tvec3 albedoDetail = $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\treturn detailMode_$DETAILMODE(albedo, albedoDetail);\n#else\n\treturn albedo;\n#endif\n}\n",decodePS:Mo,emissivePS:"\n#ifdef MAPCOLOR\nuniform vec3 material_emissive;\n#endif\n#ifdef MAPFLOAT\nuniform float material_emissiveIntensity;\n#endif\nvoid getEmission() {\n\tdEmission = vec3(1.0);\n\t#ifdef MAPFLOAT\n\tdEmission *= material_emissiveIntensity;\n\t#endif\n\t#ifdef MAPCOLOR\n\tdEmission *= material_emissive;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tdEmission *= $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tdEmission *= gammaCorrectInput(saturate(vVertexColor.$VC));\n\t#endif\n}\n",encodePS:Po,endPS:"\n\tgl_FragColor.rgb = combineColor(litArgs_albedo, litArgs_sheen_specularity, litArgs_clearcoat_specularity);\n\tgl_FragColor.rgb += litArgs_emission;\n\tgl_FragColor.rgb = addFog(gl_FragColor.rgb);\n\t#ifndef HDR\n\tgl_FragColor.rgb = toneMap(gl_FragColor.rgb);\n\tgl_FragColor.rgb = gammaCorrectOutput(gl_FragColor.rgb);\n\t#endif\n",endVS:"\n",envAtlasPS:"\nconst float atlasSize = 512.0;\nconst float seamSize = 1.0 / atlasSize;\nvec2 mapUv(vec2 uv, vec4 rect) {\n\treturn vec2(mix(rect.x + seamSize, rect.x + rect.z - seamSize, uv.x),\n\t\t\t\tmix(rect.y + seamSize, rect.y + rect.w - seamSize, uv.y));\n}\nvec2 mapRoughnessUv(vec2 uv, float level) {\n\tfloat t = 1.0 / exp2(level);\n\treturn mapUv(uv, vec4(0, 1.0 - t, t, t * 0.5));\n}\nvec2 mapShinyUv(vec2 uv, float level) {\n\tfloat t = 1.0 / exp2(level);\n\treturn mapUv(uv, vec4(1.0 - t, 1.0 - t, t, t * 0.5));\n}\n",envConstPS:"\nvec3 processEnvironment(vec3 color) {\n\treturn color;\n}\n",envMultiplyPS:"\nuniform float skyboxIntensity;\nvec3 processEnvironment(vec3 color) {\n\treturn color * skyboxIntensity;\n}\n",extensionPS:"\n",extensionVS:"\n",falloffInvSquaredPS:"\nfloat getFalloffWindow(float lightRadius, vec3 lightDir) {\n\tfloat sqrDist = dot(lightDir, lightDir);\n\tfloat invRadius = 1.0 / lightRadius;\n\treturn square( saturate( 1.0 - square( sqrDist * square(invRadius) ) ) );\n}\nfloat getFalloffInvSquared(float lightRadius, vec3 lightDir) {\n\tfloat sqrDist = dot(lightDir, lightDir);\n\tfloat falloff = 1.0 / (sqrDist + 1.0);\n\tfloat invRadius = 1.0 / lightRadius;\n\tfalloff *= 16.0;\n\tfalloff *= square( saturate( 1.0 - square( sqrDist * square(invRadius) ) ) );\n\treturn falloff;\n}\n",falloffLinearPS:"\nfloat getFalloffLinear(float lightRadius, vec3 lightDir) {\n\tfloat d = length(lightDir);\n\treturn max(((lightRadius - d) / lightRadius), 0.0);\n}\n",fixCubemapSeamsNonePS:"\nvec3 fixSeams(vec3 vec, float mipmapIndex) {\n\treturn vec;\n}\nvec3 fixSeams(vec3 vec) {\n\treturn vec;\n}\nvec3 fixSeamsStatic(vec3 vec, float invRecMipSize) {\n\treturn vec;\n}\nvec3 calcSeam(vec3 vec) {\n\treturn vec3(0);\n}\nvec3 applySeam(vec3 vec, vec3 seam, float scale) {\n\treturn vec;\n}\n",fixCubemapSeamsStretchPS:"\nvec3 fixSeams(vec3 vec, float mipmapIndex) {\n\tvec3 avec = abs(vec);\n\tfloat scale = 1.0 - exp2(mipmapIndex) / 128.0;\n\tfloat M = max(max(avec.x, avec.y), avec.z);\n\tif (avec.x != M) vec.x *= scale;\n\tif (avec.y != M) vec.y *= scale;\n\tif (avec.z != M) vec.z *= scale;\n\treturn vec;\n}\nvec3 fixSeams(vec3 vec) {\n\tvec3 avec = abs(vec);\n\tfloat scale = 1.0 - 1.0 / 128.0;\n\tfloat M = max(max(avec.x, avec.y), avec.z);\n\tif (avec.x != M) vec.x *= scale;\n\tif (avec.y != M) vec.y *= scale;\n\tif (avec.z != M) vec.z *= scale;\n\treturn vec;\n}\nvec3 fixSeamsStatic(vec3 vec, float invRecMipSize) {\n\tvec3 avec = abs(vec);\n\tfloat scale = invRecMipSize;\n\tfloat M = max(max(avec.x, avec.y), avec.z);\n\tif (avec.x != M) vec.x *= scale;\n\tif (avec.y != M) vec.y *= scale;\n\tif (avec.z != M) vec.z *= scale;\n\treturn vec;\n}\nvec3 calcSeam(vec3 vec) {\n\tvec3 avec = abs(vec);\n\tfloat M = max(avec.x, max(avec.y, avec.z));\n\treturn vec3(avec.x != M ? 1.0 : 0.0,\n\t\t\t\tavec.y != M ? 1.0 : 0.0,\n\t\t\t\tavec.z != M ? 1.0 : 0.0);\n}\nvec3 applySeam(vec3 vec, vec3 seam, float scale) {\n\treturn vec * (seam * -scale + vec3(1.0));\n}\n",floatUnpackingPS:"\nfloat bytes2float2(vec2 data) {\n\treturn dot(data, vec2(1.0, 1.0 / 255.0));\n}\nfloat bytes2float3(vec3 data) {\n\treturn dot(data, vec3(1.0, 1.0 / 255.0, 1.0 / 65025.0));\n}\nfloat bytes2float4(vec4 data) {\n\treturn dot(data, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n}\nfloat bytes2floatRange2(vec2 data, float min, float max) {\n\treturn mix(min, max, bytes2float2(data));\n}\nfloat bytes2floatRange3(vec3 data, float min, float max) {\n\treturn mix(min, max, bytes2float3(data));\n}\nfloat bytes2floatRange4(vec4 data, float min, float max) {\n\treturn mix(min, max, bytes2float4(data));\n}\nfloat mantissaExponent2Float(vec4 pack)\n{\n\tfloat value = bytes2floatRange3(pack.xyz, -1.0, 1.0);\n\tfloat exponent = floor(pack.w * 255.0 - 127.0);\n\treturn value * exp2(exponent);\n}\n",fogExpPS:"\nuniform vec3 fog_color;\nuniform float fog_density;\nfloat dBlendModeFogFactor = 1.0;\nvec3 addFog(vec3 color) {\n\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\tfloat fogFactor = exp(-depth * fog_density);\n\tfogFactor = clamp(fogFactor, 0.0, 1.0);\n\treturn mix(fog_color * dBlendModeFogFactor, color, fogFactor);\n}\n",fogExp2PS:"\nuniform vec3 fog_color;\nuniform float fog_density;\nfloat dBlendModeFogFactor = 1.0;\nvec3 addFog(vec3 color) {\n\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\tfloat fogFactor = exp(-depth * depth * fog_density * fog_density);\n\tfogFactor = clamp(fogFactor, 0.0, 1.0);\n\treturn mix(fog_color * dBlendModeFogFactor, color, fogFactor);\n}\n",fogLinearPS:"\nuniform vec3 fog_color;\nuniform float fog_start;\nuniform float fog_end;\nfloat dBlendModeFogFactor = 1.0;\nvec3 addFog(vec3 color) {\n\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\tfloat fogFactor = (fog_end - depth) / (fog_end - fog_start);\n\tfogFactor = clamp(fogFactor, 0.0, 1.0);\n\treturn mix(fog_color * dBlendModeFogFactor, color, fogFactor);\n}\n",fogNonePS:"\nfloat dBlendModeFogFactor = 1.0;\nvec3 addFog(vec3 color) {\n\treturn color;\n}\n",fresnelSchlickPS:"\nvec3 getFresnel(\n\t\tfloat cosTheta, \n\t\tfloat gloss, \n\t\tvec3 specularity\n#if defined(LIT_IRIDESCENCE)\n\t\t, vec3 iridescenceFresnel, \n\t\tfloat iridescenceIntensity\n#endif\n\t) {\n\tfloat fresnel = pow(1.0 - max(cosTheta, 0.0), 5.0);\n\tfloat glossSq = gloss * gloss;\n\tvec3 ret = specularity + (max(vec3(glossSq), specularity) - specularity) * fresnel;\n#if defined(LIT_IRIDESCENCE)\n\treturn mix(ret, iridescenceFresnel, iridescenceIntensity);\n#else\n\treturn ret;\n#endif\t\n}\nfloat getFresnelCC(float cosTheta) {\n\tfloat fresnel = pow(1.0 - max(cosTheta, 0.0), 5.0);\n\treturn 0.04 + (1.0 - 0.04) * fresnel;\n}\n",fullscreenQuadPS:"\nvarying vec2 vUv0;\nuniform sampler2D source;\nvoid main(void) {\n\tgl_FragColor = texture2D(source, vUv0);\n}\n",fullscreenQuadVS:"\nattribute vec2 vertex_position;\nvarying vec2 vUv0;\nvoid main(void)\n{\n\tgl_Position = vec4(vertex_position, 0.5, 1.0);\n\tvUv0 = vertex_position.xy*0.5+0.5;\n}\n",gamma1_0PS:"\nfloat gammaCorrectInput(float color) {\n\treturn color;\n}\nvec3 gammaCorrectInput(vec3 color) {\n\treturn color;\n}\nvec4 gammaCorrectInput(vec4 color) {\n\treturn color;\n}\nvec3 gammaCorrectOutput(vec3 color) {\n\treturn color;\n}\n",gamma2_2PS:"\nfloat gammaCorrectInput(float color) {\n\treturn decodeGamma(color);\n}\nvec3 gammaCorrectInput(vec3 color) {\n\treturn decodeGamma(color);\n}\nvec4 gammaCorrectInput(vec4 color) {\n\treturn vec4(decodeGamma(color.xyz), color.w);\n}\nvec3 gammaCorrectOutput(vec3 color) {\n#ifdef HDR\n\treturn color;\n#else\n\treturn pow(color + 0.0000001, vec3(1.0 / 2.2));\n#endif\n}\n",gles2PS:Sr,gles2VS:br,gles3PS:Tr,gles3VS:wr,glossPS:"\n#ifdef MAPFLOAT\nuniform float material_gloss;\n#endif\nvoid getGlossiness() {\n\tdGlossiness = 1.0;\n\t#ifdef MAPFLOAT\n\tdGlossiness *= material_gloss;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tdGlossiness *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tdGlossiness *= saturate(vVertexColor.$VC);\n\t#endif\n\t#ifdef MAPINVERT\n\tdGlossiness = 1.0 - dGlossiness;\n\t#endif\n\tdGlossiness += 0.0000001;\n}\n",iridescenceDiffractionPS:"\nuniform float material_iridescenceRefractionIndex;\n#ifndef PI\n#define PI 3.14159265\n#endif\nfloat iridescence_iorToFresnel(float transmittedIor, float incidentIor) {\n\treturn pow((transmittedIor - incidentIor) / (transmittedIor + incidentIor), 2.0);\n}\nvec3 iridescence_iorToFresnel(vec3 transmittedIor, float incidentIor) {\n\treturn pow((transmittedIor - vec3(incidentIor)) / (transmittedIor + vec3(incidentIor)), vec3(2.0));\n}\nvec3 iridescence_fresnelToIor(vec3 f0) {\n\tvec3 sqrtF0 = sqrt(f0);\n\treturn (vec3(1.0) + sqrtF0) / (vec3(1.0) - sqrtF0);\n}\nvec3 iridescence_sensitivity(float opd, vec3 shift) {\n\tfloat phase = 2.0 * PI * opd * 1.0e-9;\n\tconst vec3 val = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);\n\tconst vec3 pos = vec3(1.6810e+06, 1.7953e+06, 2.2084e+06);\n\tconst vec3 var = vec3(4.3278e+09, 9.3046e+09, 6.6121e+09);\n\tvec3 xyz = val * sqrt(2.0 * PI * var) * cos(pos * phase + shift) * exp(-pow(phase, 2.0) * var);\n\txyz.x += 9.7470e-14 * sqrt(2.0 * PI * 4.5282e+09) * cos(2.2399e+06 * phase + shift[0]) * exp(-4.5282e+09 * pow(phase, 2.0));\n\txyz /= vec3(1.0685e-07);\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t3.2404542, -0.9692660, 0.0556434,\n\t -1.5371385, 1.8760108, -0.2040259,\n\t -0.4985314, 0.0415560, 1.0572252\n\t);\n\treturn XYZ_TO_REC709 * xyz;\n}\nfloat iridescence_fresnel(float cosTheta, float f0) {\n\tfloat x = clamp(1.0 - cosTheta, 0.0, 1.0);\n\tfloat x2 = x * x;\n\tfloat x5 = x * x2 * x2;\n\treturn f0 + (1.0 - f0) * x5;\n} \nvec3 iridescence_fresnel(float cosTheta, vec3 f0) {\n\tfloat x = clamp(1.0 - cosTheta, 0.0, 1.0);\n\tfloat x2 = x * x;\n\tfloat x5 = x * x2 * x2; \n\treturn f0 + (vec3(1.0) - f0) * x5;\n}\nvec3 calcIridescence(float outsideIor, float cosTheta, vec3 base_f0, float iridescenceThickness) {\n\tfloat iridescenceIor = mix(outsideIor, material_iridescenceRefractionIndex, smoothstep(0.0, 0.03, iridescenceThickness));\n\tfloat sinTheta2Sq = pow(outsideIor / iridescenceIor, 2.0) * (1.0 - pow(cosTheta, 2.0));\n\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\tif (cosTheta2Sq < 0.0) {\n\t\treturn vec3(1.0);\n\t}\n\tfloat cosTheta2 = sqrt(cosTheta2Sq);\n\tfloat r0 = iridescence_iorToFresnel(iridescenceIor, outsideIor);\n\tfloat r12 = iridescence_fresnel(cosTheta, r0);\n\tfloat r21 = r12;\n\tfloat t121 = 1.0 - r12;\n\tfloat phi12 = iridescenceIor < outsideIor ? PI : 0.0;\n\tfloat phi21 = PI - phi12;\n\tvec3 baseIor = iridescence_fresnelToIor(base_f0 + vec3(0.0001));\n\tvec3 r1 = iridescence_iorToFresnel(baseIor, iridescenceIor);\n\tvec3 r23 = iridescence_fresnel(cosTheta2, r1);\n\tvec3 phi23 = vec3(0.0);\n\tif (baseIor[0] < iridescenceIor) phi23[0] = PI;\n\tif (baseIor[1] < iridescenceIor) phi23[1] = PI;\n\tif (baseIor[2] < iridescenceIor) phi23[2] = PI;\n\tfloat opd = 2.0 * iridescenceIor * iridescenceThickness * cosTheta2;\n\tvec3 phi = vec3(phi21) + phi23; \n\tvec3 r123Sq = clamp(r12 * r23, 1e-5, 0.9999);\n\tvec3 r123 = sqrt(r123Sq);\n\tvec3 rs = pow(t121, 2.0) * r23 / (1.0 - r123Sq);\n\tvec3 c0 = r12 + rs;\n\tvec3 i = c0;\n\tvec3 cm = rs - t121;\n\tfor (int m = 1; m <= 2; m++) {\n\t\tcm *= r123;\n\t\tvec3 sm = 2.0 * iridescence_sensitivity(float(m) * opd, float(m) * phi);\n\t\ti += cm * sm;\n\t}\n\treturn max(i, vec3(0.0));\n}\nvec3 getIridescence(float cosTheta, vec3 specularity, float iridescenceThickness) {\n\treturn calcIridescence(1.0, cosTheta, specularity, iridescenceThickness);\n}\n",iridescencePS:"\n#ifdef MAPFLOAT\nuniform float material_iridescence;\n#endif\nvoid getIridescence() {\n\tfloat iridescence = 1.0;\n\t#ifdef MAPFLOAT\n\tiridescence *= material_iridescence;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tiridescence *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\tdIridescence = iridescence; \n}\n",iridescenceThicknessPS:"\nuniform float material_iridescenceThicknessMax;\n#ifdef MAPTEXTURE\nuniform float material_iridescenceThicknessMin;\n#endif\nvoid getIridescenceThickness() {\n\t#ifdef MAPTEXTURE\n\tfloat blend = texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\tfloat iridescenceThickness = mix(material_iridescenceThicknessMin, material_iridescenceThicknessMax, blend);\n\t#else\n\tfloat iridescenceThickness = material_iridescenceThicknessMax;\n\t#endif\n\tdIridescenceThickness = iridescenceThickness; \n}\n",instancingVS:"\nattribute vec4 instance_line1;\nattribute vec4 instance_line2;\nattribute vec4 instance_line3;\nattribute vec4 instance_line4;\n",iorPS:"\n#ifdef MAPFLOAT\nuniform float material_refractionIndex;\n#endif\nvoid getIor() {\n#ifdef MAPFLOAT\n\tdIor = material_refractionIndex;\n#else\n\tdIor = 1.0 / 1.5;\n#endif\n}\n",lightDiffuseLambertPS:"\nfloat getLightDiffuse(vec3 worldNormal, vec3 viewDir, vec3 lightDir, vec3 lightDirNorm) {\n\treturn max(dot(worldNormal, -lightDirNorm), 0.0);\n}\n",lightDirPointPS:"\nvoid getLightDirPoint(vec3 lightPosW) {\n\tdLightDirW = vPositionW - lightPosW;\n\tdLightDirNormW = normalize(dLightDirW);\n\tdLightPosW = lightPosW;\n}\n",lightmapAddPS:"\nvoid addLightMap(\n\tvec3 lightmap, \n\tvec3 dir, \n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tvec3 reflectionDir, \n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 vertexNormal, \n\tmat3 tbn\n#if defined(LIT_IRIDESCENCE)\n\tvec3 iridescenceFresnel, \n\tfloat iridescenceIntensity\n#endif\n) {\n\tdDiffuseLight += lightmap;\n}\n",lightmapDirAddPS:"\nvoid addLightMap(\n\tvec3 lightmap, \n\tvec3 dir, \n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tvec3 reflectionDir, \n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 vertexNormal, \n\tmat3 tbn\n#if defined(LIT_IRIDESCENCE)\n\tvec3 iridescenceFresnel, \n\tfloat iridescenceIntensity\n#endif\n) {\n\tif (dot(dir, dir) < 0.0001) {\n\t\tdDiffuseLight += lightmap;\n\t} else {\n\t\tfloat vlight = saturate(dot(dir, -vertexNormal));\n\t\tfloat flight = saturate(dot(dir, -worldNormal));\n\t\tfloat nlight = (flight / max(vlight, 0.01)) * 0.5;\n\t\tdDiffuseLight += lightmap * nlight * 2.0;\n\t\tvec3 halfDir = normalize(-dir + viewDir);\n\t\tvec3 specularLight = lightmap * getLightSpecular(halfDir, reflectionDir, worldNormal, viewDir, dir, gloss, tbn);\n#ifdef LIT_SPECULAR_FRESNEL\n\t\tspecularLight *= \n\t\t\tgetFresnel(dot(viewDir, halfDir), \n\t\t\tgloss, \n\t\t\tspecularity\n\t\t#if defined(LIT_IRIDESCENCE)\n\t\t\t, iridescenceFresnel,\n\t\t\tiridescenceIntensity\n\t\t#endif\n\t\t\t);\n#endif\n\t\tdSpecularLight += specularLight;\n\t}\n}\n",lightmapDirPS:"\nuniform sampler2D texture_lightMap;\nuniform sampler2D texture_dirLightMap;\nvoid getLightMap() {\n\tdLightmap = $DECODE(texture2DBias(texture_lightMap, $UV, textureBias)).$CH;\n\tvec3 dir = texture2DBias(texture_dirLightMap, $UV, textureBias).xyz * 2.0 - 1.0;\n\tfloat dirDot = dot(dir, dir);\n\tdLightmapDir = (dirDot > 0.001) ? dir / sqrt(dirDot) : vec3(0.0);\n}\n",lightmapSinglePS:"\nvoid getLightMap() {\n\tdLightmap = vec3(1.0);\n\t#ifdef MAPTEXTURE\n\tdLightmap *= $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tdLightmap *= saturate(vVertexColor.$VC);\n\t#endif\n}\n",lightSpecularAnisoGGXPS:"\nfloat calcLightSpecular(float gloss, vec3 worldNormal, vec3 viewDir, vec3 h, vec3 lightDirNorm, mat3 tbn) {\n\tfloat PI = 3.141592653589793;\n\tfloat roughness = max((1.0 - gloss) * (1.0 - gloss), 0.001);\n\tfloat anisotropy = material_anisotropy * roughness;\n \n\tfloat at = max((roughness + anisotropy), roughness / 4.0);\n\tfloat ab = max((roughness - anisotropy), roughness / 4.0);\n\tfloat NoH = dot(worldNormal, h);\n\tfloat ToH = dot(tbn[0], h);\n\tfloat BoH = dot(tbn[1], h);\n\tfloat a2 = at * ab;\n\tvec3 v = vec3(ab * ToH, at * BoH, a2 * NoH);\n\tfloat v2 = dot(v, v);\n\tfloat w2 = a2 / v2;\n\tfloat D = a2 * w2 * w2 * (1.0 / PI);\n\tfloat ToV = dot(tbn[0], viewDir);\n\tfloat BoV = dot(tbn[1], viewDir);\n\tfloat ToL = dot(tbn[0], -lightDirNorm);\n\tfloat BoL = dot(tbn[1], -lightDirNorm);\n\tfloat NoV = dot(worldNormal, viewDir);\n\tfloat NoL = dot(worldNormal, -lightDirNorm);\n\tfloat lambdaV = NoL * length(vec3(at * ToV, ab * BoV, NoV));\n\tfloat lambdaL = NoV * length(vec3(at * ToL, ab * BoL, NoL));\n\tfloat G = 0.5 / (lambdaV + lambdaL);\n\treturn D * G;\n}\nfloat getLightSpecular(vec3 h, vec3 reflDir, vec3 worldNormal, vec3 viewDir, vec3 lightDirNorm, float gloss, mat3 tbn) {\n\treturn calcLightSpecular(gloss, worldNormal, viewDir, h, lightDirNorm, tbn);\n}\n",lightSpecularBlinnPS:"\nfloat calcLightSpecular(float gloss, vec3 worldNormal, vec3 h) {\n\tfloat nh = max( dot( h, worldNormal ), 0.0 );\n\tfloat specPow = exp2(gloss * 11.0);\n\tspecPow = max(specPow, 0.0001);\n\treturn pow(nh, specPow) * (specPow + 2.0) / 8.0;\n}\nfloat getLightSpecular(vec3 h, vec3 reflDir, vec3 worldNormal, vec3 viewDir, vec3 lightDirNorm, float gloss, mat3 tbn) {\n\treturn calcLightSpecular(gloss, worldNormal, h);\n}\n",lightSpecularPhongPS:"\nfloat calcLightSpecular(float gloss, vec3 reflDir, vec3 lightDirNorm) {\n\tfloat specPow = gloss;\n\treturn pow(max(dot(reflDir, -lightDirNorm), 0.0), specPow + 0.0001);\n}\nfloat getLightSpecular(vec3 h, vec3 reflDir, vec3 worldNormal, vec3 viewDir, vec3 lightDirNorm, float gloss, mat3 tbn) {\n\treturn calcLightSpecular(gloss, reflDir, lightDirNorm);\n}\n",lightSheenPS:"\nfloat sheenD(vec3 normal, vec3 h, float roughness) {\n\tfloat invR = 1.0 / (roughness * roughness);\n\tfloat cos2h = max(dot(normal, h), 0.0);\n\tcos2h *= cos2h;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\n\treturn (2.0 + invR) * pow(sin2h, invR * 0.5) / (2.0 * PI);\n}\nfloat sheenV(vec3 normal, vec3 viewDir, vec3 light) {\n\tfloat NoV = max(dot(normal, viewDir), 0.000001);\n\tfloat NoL = max(dot(normal, light), 0.000001);\n\treturn 1.0 / (4.0 * (NoL + NoV - NoL * NoV));\n}\nfloat getLightSpecularSheen(vec3 h, vec3 worldNormal, vec3 viewDir, vec3 lightDirNorm, float sheenGloss) {\n\tfloat D = sheenD(worldNormal, h, sheenGloss);\n\tfloat V = sheenV(worldNormal, viewDir, -lightDirNorm);\n\treturn D * V;\n}\n",linearizeDepthPS:"\n#ifndef LINEARIZE_DEPTH\n#define LINEARIZE_DEPTH\nfloat linearizeDepth(float z, vec4 cameraParams) {\n\tif (cameraParams.w == 0.0)\n\t\treturn (cameraParams.z * cameraParams.y) / (cameraParams.y + z * (cameraParams.z - cameraParams.y));\n\telse\n\t\treturn cameraParams.z + z * (cameraParams.y - cameraParams.z);\n}\n#ifndef CAMERAPLANES\n#define CAMERAPLANES\nuniform vec4 camera_params;\n#endif\n#ifdef GL2\nfloat linearizeDepth(float z) {\n\treturn linearizeDepth(z, camera_params);\n}\n#else\n#ifndef UNPACKFLOAT\n#define UNPACKFLOAT\nfloat unpackFloat(vec4 rgbaDepth) {\n\tconst vec4 bitShift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n\treturn dot(rgbaDepth, bitShift);\n}\n#endif\n#endif\n#endif\n",litShaderArgsPS:"\nvec3 litArgs_albedo;\nfloat litArgs_opacity;\nvec3 litArgs_emission;\nvec3 litArgs_worldNormal;\nfloat litArgs_ao;\nvec3 litArgs_lightmap;\nvec3 litArgs_lightmapDir;\nfloat litArgs_metalness;\nvec3 litArgs_specularity;\nfloat litArgs_specularityFactor;\nfloat litArgs_gloss;\nfloat litArgs_sheen_gloss;\nvec3 litArgs_sheen_specularity;\nfloat litArgs_transmission;\nfloat litArgs_thickness;\nfloat litArgs_ior;\nfloat litArgs_dispersion;\nfloat litArgs_iridescence_intensity;\nfloat litArgs_iridescence_thickness;\nvec3 litArgs_clearcoat_worldNormal;\nfloat litArgs_clearcoat_specularity;\nfloat litArgs_clearcoat_gloss;\n",ltcPS:"\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nstruct Coords {\n\tvec3 coord0;\n\tvec3 coord1;\n\tvec3 coord2;\n\tvec3 coord3;\n};\nfloat LTC_EvaluateRect( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in Coords rectCoords) {\n\tvec3 v1 = rectCoords.coord1 - rectCoords.coord0;\n\tvec3 v2 = rectCoords.coord3 - rectCoords.coord0;\n\t\n\tvec3 lightNormal = cross( v1, v2 );\n\tfloat factor = sign(-dot( lightNormal, P - rectCoords.coord0 ));\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = factor * cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords.coord0 - P );\n\tcoords[ 1 ] = mat * ( rectCoords.coord1 - P );\n\tcoords[ 2 ] = mat * ( rectCoords.coord2 - P );\n\tcoords[ 3 ] = mat * ( rectCoords.coord3 - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn result;\n}\nCoords dLTCCoords;\nCoords getLTCLightCoords(vec3 lightPos, vec3 halfWidth, vec3 halfHeight){\n\tCoords coords;\n\tcoords.coord0 = lightPos + halfWidth - halfHeight;\n\tcoords.coord1 = lightPos - halfWidth - halfHeight;\n\tcoords.coord2 = lightPos - halfWidth + halfHeight;\n\tcoords.coord3 = lightPos + halfWidth + halfHeight;\n\treturn coords;\n}\nfloat dSphereRadius;\nCoords getSphereLightCoords(vec3 lightPos, vec3 halfWidth, vec3 halfHeight){\n\tdSphereRadius = max(length(halfWidth), length(halfHeight));\n\tvec3 f = reflect(normalize(lightPos - view_position), vNormalW);\n\tvec3 w = normalize(cross(f, halfHeight));\n\tvec3 h = normalize(cross(f, w));\n\treturn getLTCLightCoords(lightPos, w * dSphereRadius, h * dSphereRadius);\n}\nvec2 dLTCUV;\n#ifdef LIT_CLEARCOAT\nvec2 ccLTCUV;\n#endif\nvec2 getLTCLightUV(float gloss, vec3 worldNormal, vec3 viewDir)\n{\n\tfloat roughness = max((1.0 - gloss) * (1.0 - gloss), 0.001);\n\treturn LTC_Uv( worldNormal, viewDir, roughness );\n}\nvec3 dLTCSpecFres;\n#ifdef LIT_CLEARCOAT\nvec3 ccLTCSpecFres;\n#endif\nvec3 getLTCLightSpecFres(vec2 uv, vec3 specularity)\n{\n\tvec4 t2 = texture2DLodEXT(areaLightsLutTex2, uv, 0.0);\n\t#ifdef AREA_R8_G8_B8_A8_LUTS\n\tt2 *= vec4(0.693103,1,1,1);\n\tt2 += vec4(0.306897,0,0,0);\n\t#endif\n\treturn specularity * t2.x + ( vec3( 1.0 ) - specularity) * t2.y;\n}\nvoid calcLTCLightValues(float gloss, vec3 worldNormal, vec3 viewDir, vec3 specularity, float clearcoatGloss, vec3 clearcoatWorldNormal, float clearcoatSpecularity)\n{\n\tdLTCUV = getLTCLightUV(gloss, worldNormal, viewDir);\n\tdLTCSpecFres = getLTCLightSpecFres(dLTCUV, specularity); \n#ifdef LIT_CLEARCOAT\n\tccLTCUV = getLTCLightUV(clearcoatGloss, clearcoatWorldNormal, viewDir);\n\tccLTCSpecFres = getLTCLightSpecFres(ccLTCUV, vec3(clearcoatSpecularity));\n#endif\n}\nvoid calcRectLightValues(vec3 lightPos, vec3 halfWidth, vec3 halfHeight)\n{\n\tdLTCCoords = getLTCLightCoords(lightPos, halfWidth, halfHeight);\n}\nvoid calcDiskLightValues(vec3 lightPos, vec3 halfWidth, vec3 halfHeight)\n{\n\tcalcRectLightValues(lightPos, halfWidth, halfHeight);\n}\nvoid calcSphereLightValues(vec3 lightPos, vec3 halfWidth, vec3 halfHeight)\n{\n\tdLTCCoords = getSphereLightCoords(lightPos, halfWidth, halfHeight);\n}\nvec3 SolveCubic(vec4 Coefficient)\n{\n\tfloat pi = 3.14159;\n\tCoefficient.xyz /= Coefficient.w;\n\tCoefficient.yz /= 3.0;\n\tfloat A = Coefficient.w;\n\tfloat B = Coefficient.z;\n\tfloat C = Coefficient.y;\n\tfloat D = Coefficient.x;\n\tvec3 Delta = vec3(\n\t\t-Coefficient.z * Coefficient.z + Coefficient.y,\n\t\t-Coefficient.y * Coefficient.z + Coefficient.x,\n\t\tdot(vec2(Coefficient.z, -Coefficient.y), Coefficient.xy)\n\t);\n\tfloat Discriminant = dot(vec2(4.0 * Delta.x, -Delta.y), Delta.zy);\n\tvec3 RootsA, RootsD;\n\tvec2 xlc, xsc;\n\t{\n\t\tfloat A_a = 1.0;\n\t\tfloat C_a = Delta.x;\n\t\tfloat D_a = -2.0 * B * Delta.x + Delta.y;\n\t\tfloat Theta = atan(sqrt(Discriminant), -D_a) / 3.0;\n\t\tfloat x_1a = 2.0 * sqrt(-C_a) * cos(Theta);\n\t\tfloat x_3a = 2.0 * sqrt(-C_a) * cos(Theta + (2.0 / 3.0) * pi);\n\t\tfloat xl;\n\t\tif ((x_1a + x_3a) > 2.0 * B)\n\t\t\txl = x_1a;\n\t\telse\n\t\t\txl = x_3a;\n\t\txlc = vec2(xl - B, A);\n\t}\n\t{\n\t\tfloat A_d = D;\n\t\tfloat C_d = Delta.z;\n\t\tfloat D_d = -D * Delta.y + 2.0 * C * Delta.z;\n\t\tfloat Theta = atan(D * sqrt(Discriminant), -D_d) / 3.0;\n\t\tfloat x_1d = 2.0 * sqrt(-C_d) * cos(Theta);\n\t\tfloat x_3d = 2.0 * sqrt(-C_d) * cos(Theta + (2.0 / 3.0) * pi);\n\t\tfloat xs;\n\t\tif (x_1d + x_3d < 2.0 * C)\n\t\t\txs = x_1d;\n\t\telse\n\t\t\txs = x_3d;\n\t\txsc = vec2(-D, xs + C);\n\t}\n\tfloat E = xlc.y * xsc.y;\n\tfloat F = -xlc.x * xsc.y - xlc.y * xsc.x;\n\tfloat G = xlc.x * xsc.x;\n\tvec2 xmc = vec2(C * F - B * G, -B * F + C * E);\n\tvec3 Root = vec3(xsc.x / xsc.y, xmc.x / xmc.y, xlc.x / xlc.y);\n\tif (Root.x < Root.y && Root.x < Root.z)\n\t\tRoot.xyz = Root.yxz;\n\telse if (Root.z < Root.x && Root.z < Root.y)\n\t\tRoot.xyz = Root.xzy;\n\treturn Root;\n}\nfloat LTC_EvaluateDisk(vec3 N, vec3 V, vec3 P, mat3 Minv, Coords points)\n{\n\tvec3 T1, T2;\n\tT1 = normalize(V - N * dot(V, N));\n\tT2 = cross(N, T1);\n\tmat3 R = transposeMat3( mat3( T1, T2, N ) );\n\tvec3 L_[ 3 ];\n\tL_[ 0 ] = R * ( points.coord0 - P );\n\tL_[ 1 ] = R * ( points.coord1 - P );\n\tL_[ 2 ] = R * ( points.coord2 - P );\n\tvec3 Lo_i = vec3(0);\n\tvec3 C = 0.5 * (L_[0] + L_[2]);\n\tvec3 V1 = 0.5 * (L_[1] - L_[2]);\n\tvec3 V2 = 0.5 * (L_[1] - L_[0]);\n\tC = Minv * C;\n\tV1 = Minv * V1;\n\tV2 = Minv * V2;\n\tfloat a, b;\n\tfloat d11 = dot(V1, V1);\n\tfloat d22 = dot(V2, V2);\n\tfloat d12 = dot(V1, V2);\n\tif (abs(d12) / sqrt(d11 * d22) > 0.0001)\n\t{\n\t\tfloat tr = d11 + d22;\n\t\tfloat det = -d12 * d12 + d11 * d22;\n\t\tdet = sqrt(det);\n\t\tfloat u = 0.5 * sqrt(tr - 2.0 * det);\n\t\tfloat v = 0.5 * sqrt(tr + 2.0 * det);\n\t\tfloat e_max = (u + v) * (u + v);\n\t\tfloat e_min = (u - v) * (u - v);\n\t\tvec3 V1_, V2_;\n\t\tif (d11 > d22)\n\t\t{\n\t\t\tV1_ = d12 * V1 + (e_max - d11) * V2;\n\t\t\tV2_ = d12 * V1 + (e_min - d11) * V2;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tV1_ = d12*V2 + (e_max - d22)*V1;\n\t\t\tV2_ = d12*V2 + (e_min - d22)*V1;\n\t\t}\n\t\ta = 1.0 / e_max;\n\t\tb = 1.0 / e_min;\n\t\tV1 = normalize(V1_);\n\t\tV2 = normalize(V2_);\n\t}\n\telse\n\t{\n\t\ta = 1.0 / dot(V1, V1);\n\t\tb = 1.0 / dot(V2, V2);\n\t\tV1 *= sqrt(a);\n\t\tV2 *= sqrt(b);\n\t}\n\tvec3 V3 = normalize(cross(V1, V2));\n\tif (dot(C, V3) < 0.0)\n\t\tV3 *= -1.0;\n\tfloat L = dot(V3, C);\n\tfloat x0 = dot(V1, C) / L;\n\tfloat y0 = dot(V2, C) / L;\n\tfloat E1 = inversesqrt(a);\n\tfloat E2 = inversesqrt(b);\n\ta *= L * L;\n\tb *= L * L;\n\tfloat c0 = a * b;\n\tfloat c1 = a * b * (1.0 + x0 * x0 + y0 * y0) - a - b;\n\tfloat c2 = 1.0 - a * (1.0 + x0 * x0) - b * (1.0 + y0 * y0);\n\tfloat c3 = 1.0;\n\tvec3 roots = SolveCubic(vec4(c0, c1, c2, c3));\n\tfloat e1 = roots.x;\n\tfloat e2 = roots.y;\n\tfloat e3 = roots.z;\n\tvec3 avgDir = vec3(a * x0 / (a - e2), b * y0 / (b - e2), 1.0);\n\tmat3 rotate = mat3(V1, V2, V3);\n\tavgDir = rotate * avgDir;\n\tavgDir = normalize(avgDir);\n\tfloat L1 = sqrt(-e2 / e3);\n\tfloat L2 = sqrt(-e2 / e1);\n\tfloat formFactor = max(0.0, L1 * L2 * inversesqrt((1.0 + L1 * L1) * (1.0 + L2 * L2)));\n\t\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tvec2 uv = vec2(avgDir.z * 0.5 + 0.5, formFactor);\n\tuv = uv*LUT_SCALE + LUT_BIAS;\n\tfloat scale = texture2DLodEXT(areaLightsLutTex2, uv, 0.0).w;\n\treturn formFactor*scale;\n}\nfloat getRectLightDiffuse(vec3 worldNormal, vec3 viewDir, vec3 lightDir, vec3 lightDirNorm) {\n\treturn LTC_EvaluateRect( worldNormal, viewDir, vPositionW, mat3( 1.0 ), dLTCCoords );\n}\nfloat getDiskLightDiffuse(vec3 worldNormal, vec3 viewDir, vec3 lightDir, vec3 lightDirNorm) {\n\treturn LTC_EvaluateDisk( worldNormal, viewDir, vPositionW, mat3( 1.0 ), dLTCCoords );\n}\nfloat getSphereLightDiffuse(vec3 worldNormal, vec3 viewDir, vec3 lightDir, vec3 lightDirNorm) {\n\tfloat falloff = dSphereRadius / (dot(lightDir, lightDir) + dSphereRadius);\n\treturn getLightDiffuse(worldNormal, viewDir, lightDir, lightDirNorm) * falloff;\n}\nmat3 getLTCLightInvMat(vec2 uv)\n{\n\tvec4 t1 = texture2DLodEXT(areaLightsLutTex1, uv, 0.0);\n\t#ifdef AREA_R8_G8_B8_A8_LUTS\n\tt1 *= vec4(1.001, 0.3239, 0.60437568, 1.0);\n\tt1 += vec4(0.0, -0.2976, -0.01381, 0.0);\n\t#endif\n\treturn mat3(\n\t\tvec3( t1.x, 0, t1.y ),\n\t\tvec3(\t0, 1,\t0 ),\n\t\tvec3( t1.z, 0, t1.w )\n\t);\n}\nfloat calcRectLightSpecular(vec3 worldNormal, vec3 viewDir, vec2 uv) {\n\tmat3 mInv = getLTCLightInvMat(uv);\n\treturn LTC_EvaluateRect( worldNormal, viewDir, vPositionW, mInv, dLTCCoords );\n}\nfloat getRectLightSpecular(vec3 worldNormal, vec3 viewDir) {\n\treturn calcRectLightSpecular(worldNormal, viewDir, dLTCUV);\n}\nfloat calcDiskLightSpecular(vec3 worldNormal, vec3 viewDir, vec2 uv) {\n\tmat3 mInv = getLTCLightInvMat(uv);\n\treturn LTC_EvaluateDisk( worldNormal, viewDir, vPositionW, mInv, dLTCCoords );\n}\nfloat getDiskLightSpecular(vec3 worldNormal, vec3 viewDir) {\n\treturn calcDiskLightSpecular(worldNormal, viewDir, dLTCUV);\n}\nfloat getSphereLightSpecular(vec3 worldNormal, vec3 viewDir) {\n\treturn calcDiskLightSpecular(worldNormal, viewDir, dLTCUV);\n}\n",metalnessPS:"\n#ifdef MAPFLOAT\nuniform float material_metalness;\n#endif\nvoid getMetalness() {\n\tfloat metalness = 1.0;\n\t#ifdef MAPFLOAT\n\tmetalness *= material_metalness;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tmetalness *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tmetalness *= saturate(vVertexColor.$VC);\n\t#endif\n\tdMetalness = metalness;\n}\n",metalnessModulatePS:"\nvec3 getSpecularModulate(in vec3 specularity, in vec3 albedo, in float metalness, in float f0) {\n\tvec3 dielectricF0 = f0 * specularity;\n\treturn mix(dielectricF0, albedo, metalness);\n}\nvec3 getAlbedoModulate(in vec3 albedo, in float metalness) {\n\treturn albedo * (1.0 - metalness);\n}\n",msdfPS:"\nuniform sampler2D texture_msdfMap;\n#ifdef GL_OES_standard_derivatives\n#define USE_FWIDTH\n#endif\n#ifdef GL2\n#define USE_FWIDTH\n#endif\nfloat median(float r, float g, float b) {\n\treturn max(min(r, g), min(max(r, g), b));\n}\nfloat map (float min, float max, float v) {\n\treturn (v - min) / (max - min);\n}\nuniform float font_sdfIntensity;\nuniform float font_pxrange;\nuniform float font_textureWidth;\n#ifdef UNIFORM_TEXT_PARAMETERS\nuniform vec4 outline_color;\nuniform float outline_thickness;\nuniform vec4 shadow_color;\nuniform vec2 shadow_offset;\n#else\nvarying vec4 outline_color;\nvarying float outline_thickness;\nvarying vec4 shadow_color;\nvarying vec2 shadow_offset;\n#endif\nvec4 applyMsdf(vec4 color) {\n\tvec3 tsample = texture2D(texture_msdfMap, vUv0).rgb;\n\tvec2 uvShdw = vUv0 - shadow_offset;\n\tvec3 ssample = texture2D(texture_msdfMap, uvShdw).rgb;\n\tfloat sigDist = median(tsample.r, tsample.g, tsample.b);\n\tfloat sigDistShdw = median(ssample.r, ssample.g, ssample.b);\n\tfloat smoothingMax = 0.2;\n\t#ifdef USE_FWIDTH\n\tvec2 w = fwidth(vUv0);\n\tfloat smoothing = clamp(w.x * font_textureWidth / font_pxrange, 0.0, smoothingMax);\n\t#else\n\tfloat font_size = 16.0;\n\tfloat smoothing = clamp(font_pxrange / font_size, 0.0, smoothingMax);\n\t#endif\n\tfloat mapMin = 0.05;\n\tfloat mapMax = clamp(1.0 - font_sdfIntensity, mapMin, 1.0);\n\tfloat sigDistInner = map(mapMin, mapMax, sigDist);\n\tfloat sigDistOutline = map(mapMin, mapMax, sigDist + outline_thickness);\n\tsigDistShdw = map(mapMin, mapMax, sigDistShdw + outline_thickness);\n\tfloat center = 0.5;\n\tfloat inside = smoothstep(center-smoothing, center+smoothing, sigDistInner);\n\tfloat outline = smoothstep(center-smoothing, center+smoothing, sigDistOutline);\n\tfloat shadow = smoothstep(center-smoothing, center+smoothing, sigDistShdw);\n\tvec4 tcolor = (outline > inside) ? outline * vec4(outline_color.a * outline_color.rgb, outline_color.a) : vec4(0.0);\n\ttcolor = mix(tcolor, color, inside);\n\tvec4 scolor = (shadow > outline) ? shadow * vec4(shadow_color.a * shadow_color.rgb, shadow_color.a) : tcolor;\n\ttcolor = mix(scolor, tcolor, outline);\n\t\n\treturn tcolor;\n}\n",msdfVS:"\nattribute vec3 vertex_outlineParameters;\nattribute vec3 vertex_shadowParameters;\nvarying vec4 outline_color;\nvarying float outline_thickness;\nvarying vec4 shadow_color;\nvarying vec2 shadow_offset;\nvoid unpackMsdfParams() {\n\tvec3 little = mod(vertex_outlineParameters, 256.);\n\tvec3 big = (vertex_outlineParameters - little) / 256.;\n\toutline_color.rb = little.xy / 255.;\n\toutline_color.ga = big.xy / 255.;\n\toutline_thickness = little.z / 255. * 0.2;\n\tlittle = mod(vertex_shadowParameters, 256.);\n\tbig = (vertex_shadowParameters - little) / 256.;\n\tshadow_color.rb = little.xy / 255.;\n\tshadow_color.ga = big.xy / 255.;\n\tshadow_offset = (vec2(little.z, big.z) / 127. - 1.) * 0.005;\n}\n",normalVS:"\n#ifdef MORPHING_TEXTURE_BASED_NORMAL\nuniform highp sampler2D morphNormalTex;\n#endif\nvec3 getNormal() {\n\t#ifdef SKIN\n\tdNormalMatrix = mat3(dModelMatrix[0].xyz, dModelMatrix[1].xyz, dModelMatrix[2].xyz);\n\t#elif defined(INSTANCING)\n\tdNormalMatrix = mat3(instance_line1.xyz, instance_line2.xyz, instance_line3.xyz);\n\t#else\n\tdNormalMatrix = matrix_normal;\n\t#endif\n\tvec3 tempNormal = vertex_normal;\n\t#ifdef MORPHING\n\t#ifdef MORPHING_NRM03\n\ttempNormal += morph_weights_a[0] * morph_nrm0;\n\ttempNormal += morph_weights_a[1] * morph_nrm1;\n\ttempNormal += morph_weights_a[2] * morph_nrm2;\n\ttempNormal += morph_weights_a[3] * morph_nrm3;\n\t#endif\n\t#ifdef MORPHING_NRM47\n\ttempNormal += morph_weights_b[0] * morph_nrm4;\n\ttempNormal += morph_weights_b[1] * morph_nrm5;\n\ttempNormal += morph_weights_b[2] * morph_nrm6;\n\ttempNormal += morph_weights_b[3] * morph_nrm7;\n\t#endif\n\t#endif\n\t#ifdef MORPHING_TEXTURE_BASED_NORMAL\n\t\t#ifdef WEBGPU\n\t\t\tivec2 morphUV = getTextureMorphCoords();\n\t\t\tvec3 morphNormal = texelFetch(morphNormalTex, ivec2(morphUV), 0).xyz;\n\t\t#else\n\t\t\tvec2 morphUV = getTextureMorphCoords();\n\t\t\tvec3 morphNormal = texture2D(morphNormalTex, morphUV).xyz;\n\t\t#endif\n\ttempNormal += morphNormal;\n\t#endif\n\treturn normalize(dNormalMatrix * tempNormal);\n}\n",normalDetailMapPS:"\n#ifdef MAPTEXTURE\nuniform float material_normalDetailMapBumpiness;\nvec3 blendNormals(vec3 n1, vec3 n2) {\n\tn1 += vec3(0, 0, 1);\n\tn2 *= vec3(-1, -1, 1);\n\treturn n1 * dot(n1, n2) / n1.z - n2;\n}\n#endif\nvec3 addNormalDetail(vec3 normalMap) {\n#ifdef MAPTEXTURE\n\tvec3 normalDetailMap = unpackNormal(texture2DBias($SAMPLER, $UV, textureBias));\n\tnormalDetailMap = mix(vec3(0.0, 0.0, 1.0), normalDetailMap, material_normalDetailMapBumpiness);\n\treturn blendNormals(normalMap, normalDetailMap);\n#else\n\treturn normalMap;\n#endif\n}\n",normalInstancedVS:"\nvec3 getNormal() {\n\tdNormalMatrix = mat3(instance_line1.xyz, instance_line2.xyz, instance_line3.xyz);\n\treturn normalize(dNormalMatrix * vertex_normal);\n}\n",normalMapPS:"\n#ifdef MAPTEXTURE\nuniform float material_bumpiness;\n#endif\nvoid getNormal() {\n#ifdef MAPTEXTURE\n\tvec3 normalMap = unpackNormal(texture2DBias($SAMPLER, $UV, textureBias));\n\tnormalMap = mix(vec3(0.0, 0.0, 1.0), normalMap, material_bumpiness);\n\tdNormalW = normalize(dTBN * addNormalDetail(normalMap));\n#else\n\tdNormalW = dVertexNormalW;\n#endif\n}\n",normalSkinnedVS:"\nvec3 getNormal() {\n\tdNormalMatrix = mat3(dModelMatrix[0].xyz, dModelMatrix[1].xyz, dModelMatrix[2].xyz);\n\treturn normalize(dNormalMatrix * vertex_normal);\n}\n",normalXYPS:"\nvec3 unpackNormal(vec4 nmap) {\n\tvec3 normal;\n\tnormal.xy = nmap.wy * 2.0 - 1.0;\n\tnormal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));\n\treturn normal;\n}\n",normalXYZPS:"\nvec3 unpackNormal(vec4 nmap) {\n\treturn nmap.xyz * 2.0 - 1.0;\n}\n",opacityPS:"\n#ifdef MAPFLOAT\nuniform float material_opacity;\n#endif\nvoid getOpacity() {\n\tdAlpha = 1.0;\n\t#ifdef MAPFLOAT\n\tdAlpha *= material_opacity;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tdAlpha *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tdAlpha *= clamp(vVertexColor.$VC, 0.0, 1.0);\n\t#endif\n}\n",opacityDitherPS:"\nuniform vec4 blueNoiseJitter;\n#ifdef DITHER_BLUENOISE\n\tuniform sampler2D blueNoiseTex32;\n#endif\nvoid opacityDither(float alpha, float id) {\n\t#ifdef DITHER_BAYER8\n\t\tfloat noise = bayer8(floor(mod(gl_FragCoord.xy + blueNoiseJitter.xy + id, 8.0))) / 64.0;\n\t#else\n\t\t#ifdef DITHER_BLUENOISE\n\t\t\tvec2 uv = fract(gl_FragCoord.xy / 32.0 + blueNoiseJitter.xy + id);\n\t\t\tfloat noise = texture2DLodEXT(blueNoiseTex32, uv, 0.0).y;\n\t\t#endif\n\t\t#ifdef DITHER_IGNNOISE\n\t\t\tvec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);\n\t\t\tfloat noise = fract(magic.z * fract(dot(gl_FragCoord.xy + blueNoiseJitter.xy + id, magic.xy)));\n\t\t#endif\n\t#endif\n\tif (alpha < noise)\n\t\tdiscard;\n}\n",outputPS:"\n",outputAlphaPS:"\ngl_FragColor.a = litArgs_opacity;\n",outputAlphaOpaquePS:"\n\tgl_FragColor.a = 1.0;\n",outputAlphaPremulPS:"\ngl_FragColor.rgb *= litArgs_opacity;\ngl_FragColor.a = litArgs_opacity;\n",outputTex2DPS:"\nvarying vec2 vUv0;\nuniform sampler2D source;\nvoid main(void) {\n\tgl_FragColor = texture2D(source, vUv0);\n}\n",packDepthPS:"\nvec4 packFloat(float depth) {\n\tconst vec4 bit_shift = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0);\n\tconst vec4 bit_mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);\n\tvec4 res = mod(depth * bit_shift * vec4(255), vec4(256) ) / vec4(255);\n\tres -= res.xxyz * bit_mask;\n\treturn res;\n}\n",sheenPS:"\n#ifdef MAPCOLOR\nuniform vec3 material_sheen;\n#endif\nvoid getSheen() {\n\tvec3 sheenColor = vec3(1, 1, 1);\n\t#ifdef MAPCOLOR\n\tsheenColor *= material_sheen;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tsheenColor *= $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tsheenColor *= saturate(vVertexColor.$VC);\n\t#endif\n\tsSpecularity = sheenColor;\n}\n",sheenGlossPS:"\n#ifdef MAPFLOAT\nuniform float material_sheenGloss;\n#endif\nvoid getSheenGlossiness() {\n\tfloat sheenGlossiness = 1.0;\n\t#ifdef MAPFLOAT\n\tsheenGlossiness *= material_sheenGloss;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tsheenGlossiness *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tsheenGlossiness *= saturate(vVertexColor.$VC);\n\t#endif\n\t#ifdef MAPINVERT\n\tsheenGlossiness = 1.0 - sheenGlossiness;\n\t#endif\n\tsheenGlossiness += 0.0000001;\n\tsGlossiness = sheenGlossiness;\n}\n",parallaxPS:"\nuniform float material_heightMapFactor;\nvoid getParallax() {\n\tfloat parallaxScale = material_heightMapFactor;\n\tfloat height = texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\theight = height * parallaxScale - parallaxScale*0.5;\n\tvec3 viewDirT = dViewDirW * dTBN;\n\tviewDirT.z += 0.42;\n\tdUvOffset = height * (viewDirT.xy / viewDirT.z);\n}\n",particlePS:"\nvarying vec4 texCoordsAlphaLife;\nuniform sampler2D colorMap;\nuniform sampler2D colorParam;\nuniform float graphSampleSize;\nuniform float graphNumSamples;\n#ifndef CAMERAPLANES\n#define CAMERAPLANES\nuniform vec4 camera_params;\n#endif\nuniform float softening;\nuniform float colorMult;\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\n#ifndef UNPACKFLOAT\n#define UNPACKFLOAT\nfloat unpackFloat(vec4 rgbaDepth) {\n\tconst vec4 bitShift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n\tfloat depth = dot(rgbaDepth, bitShift);\n\treturn depth;\n}\n#endif\nvoid main(void) {\n\tvec4 tex = gammaCorrectInput(texture2D(colorMap, vec2(texCoordsAlphaLife.x, 1.0 - texCoordsAlphaLife.y)));\n\tvec4 ramp = gammaCorrectInput(texture2D(colorParam, vec2(texCoordsAlphaLife.w, 0.0)));\n\tramp.rgb *= colorMult;\n\tramp.a += texCoordsAlphaLife.z;\n\tvec3 rgb = tex.rgb * ramp.rgb;\n\tfloat a = tex.a * ramp.a;\n",particleVS:"\nvec3 unpack3NFloats(float src) {\n\tfloat r = fract(src);\n\tfloat g = fract(src * 256.0);\n\tfloat b = fract(src * 65536.0);\n\treturn vec3(r, g, b);\n}\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\nvec4 tex1Dlod_lerp(TEXTURE_ACCEPT_HIGHP(tex), vec2 tc) {\n\treturn mix( texture2D(tex,tc), texture2D(tex,tc + graphSampleSize), fract(tc.x*graphNumSamples) );\n}\nvec4 tex1Dlod_lerp(TEXTURE_ACCEPT_HIGHP(tex), vec2 tc, out vec3 w) {\n\tvec4 a = texture2D(tex,tc);\n\tvec4 b = texture2D(tex,tc + graphSampleSize);\n\tfloat c = fract(tc.x*graphNumSamples);\n\tvec3 unpackedA = unpack3NFloats(a.w);\n\tvec3 unpackedB = unpack3NFloats(b.w);\n\tw = mix(unpackedA, unpackedB, c);\n\treturn mix(a, b, c);\n}\nvec2 rotate(vec2 quadXY, float pRotation, out mat2 rotMatrix) {\n\tfloat c = cos(pRotation);\n\tfloat s = sin(pRotation);\n\tmat2 m = mat2(c, -s, s, c);\n\trotMatrix = m;\n\treturn m * quadXY;\n}\nvec3 billboard(vec3 InstanceCoords, vec2 quadXY) {\n\t#ifdef SCREEN_SPACE\n\t\tvec3 pos = vec3(-1, 0, 0) * quadXY.x + vec3(0, -1, 0) * quadXY.y;\n\t#else\n\t\tvec3 pos = -matrix_viewInverse[0].xyz * quadXY.x + -matrix_viewInverse[1].xyz * quadXY.y;\n\t#endif\n\treturn pos;\n}\nvec3 customFace(vec3 InstanceCoords, vec2 quadXY) {\n\tvec3 pos = faceTangent * quadXY.x + faceBinorm * quadXY.y;\n\treturn pos;\n}\nvec2 safeNormalize(vec2 v) {\n\tfloat l = length(v);\n\treturn (l > 1e-06) ? v / l : v;\n}\nvoid main(void) {\n\tvec3 meshLocalPos = particle_vertexData.xyz;\n\tfloat id = floor(particle_vertexData.w);\n\tfloat rndFactor = fract(sin(id + 1.0 + seed));\n\tvec3 rndFactor3 = vec3(rndFactor, fract(rndFactor*10.0), fract(rndFactor*100.0));\n\tfloat uv = id / numParticlesPot;\n\treadInput(uv);\n#ifdef LOCAL_SPACE\n\tinVel = mat3(matrix_model) * inVel;\n#endif\n\tvec2 velocityV = safeNormalize((mat3(matrix_view) * inVel).xy);\n\tfloat particleLifetime = lifetime;\n\tif (inLife <= 0.0 || inLife > particleLifetime || !inShow) meshLocalPos = vec3(0.0);\n\tvec2 quadXY = meshLocalPos.xy;\n\tfloat nlife = clamp(inLife / particleLifetime, 0.0, 1.0);\n\tvec3 paramDiv;\n\tvec4 params = tex1Dlod_lerp(TEXTURE_PASS(internalTex2), vec2(nlife, 0), paramDiv);\n\tfloat scale = params.y;\n\tfloat scaleDiv = paramDiv.x;\n\tfloat alphaDiv = paramDiv.z;\n\tscale += (scaleDiv * 2.0 - 1.0) * scaleDivMult * fract(rndFactor*10000.0);\n#ifndef USE_MESH\n\ttexCoordsAlphaLife = vec4(quadXY * -0.5 + 0.5, (alphaDiv * 2.0 - 1.0) * alphaDivMult * fract(rndFactor*1000.0), nlife);\n#else\n\ttexCoordsAlphaLife = vec4(particle_uv, (alphaDiv * 2.0 - 1.0) * alphaDivMult * fract(rndFactor*1000.0), nlife);\n#endif\n\tvec3 particlePos = inPos;\n\tvec3 particlePosMoved = vec3(0.0);\n\tmat2 rotMatrix;\n",particleAnimFrameClampVS:"\n\tfloat animFrame = min(floor(texCoordsAlphaLife.w * animTexParams.y) + animTexParams.x, animTexParams.z);\n",particleAnimFrameLoopVS:"\n\tfloat animFrame = floor(mod(texCoordsAlphaLife.w * animTexParams.y + animTexParams.x, animTexParams.z + 1.0));\n",particleAnimTexVS:"\n\tfloat animationIndex;\n\tif (animTexIndexParams.y == 1.0) {\n\t\tanimationIndex = floor((animTexParams.w + 1.0) * rndFactor3.z) * (animTexParams.z + 1.0);\n\t} else {\n\t\tanimationIndex = animTexIndexParams.x * (animTexParams.z + 1.0);\n\t}\n\tfloat atlasX = (animationIndex + animFrame) * animTexTilesParams.x;\n\tfloat atlasY = 1.0 - floor(atlasX + 1.0) * animTexTilesParams.y;\n\tatlasX = fract(atlasX);\n\ttexCoordsAlphaLife.xy *= animTexTilesParams.xy;\n\ttexCoordsAlphaLife.xy += vec2(atlasX, atlasY);\n",particleInputFloatPS:"\nvoid readInput(float uv) {\n\tvec4 tex = texture2D(particleTexIN, vec2(uv, 0.25));\n\tvec4 tex2 = texture2D(particleTexIN, vec2(uv, 0.75));\n\tinPos = tex.xyz;\n\tinVel = tex2.xyz;\n\tinAngle = (tex.w < 0.0? -tex.w : tex.w) - 1000.0;\n\tinShow = tex.w >= 0.0;\n\tinLife = tex2.w;\n}\n",particleInputRgba8PS:"\n#define PI2 6.283185307179586\nuniform vec3 inBoundsSize;\nuniform vec3 inBoundsCenter;\nuniform float maxVel;\nfloat decodeFloatRG(vec2 rg) {\n\treturn rg.y*(1.0/255.0) + rg.x;\n}\nfloat decodeFloatRGBA( vec4 rgba ) {\n return dot( rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/160581375.0) );\n}\nvoid readInput(float uv) {\n\tvec4 tex0 = texture2D(particleTexIN, vec2(uv, 0.125));\n\tvec4 tex1 = texture2D(particleTexIN, vec2(uv, 0.375));\n\tvec4 tex2 = texture2D(particleTexIN, vec2(uv, 0.625));\n\tvec4 tex3 = texture2D(particleTexIN, vec2(uv, 0.875));\n\tinPos = vec3(decodeFloatRG(tex0.rg), decodeFloatRG(tex0.ba), decodeFloatRG(tex1.rg));\n\tinPos = (inPos - vec3(0.5)) * inBoundsSize + inBoundsCenter;\n\tinVel = tex2.xyz;\n\tinVel = (inVel - vec3(0.5)) * maxVel;\n\tinAngle = decodeFloatRG(tex1.ba) * PI2;\n\tinShow = tex2.a > 0.5;\n\tinLife = decodeFloatRGBA(tex3);\n\tfloat maxNegLife = max(lifetime, (numParticles - 1.0) * (rate+rateDiv));\n\tfloat maxPosLife = lifetime+1.0;\n\tinLife = inLife * (maxNegLife + maxPosLife) - maxNegLife;\n}\n",particleOutputFloatPS:"\nvoid writeOutput() {\n\tif (gl_FragCoord.y<1.0) {\n\t\tgl_FragColor = vec4(outPos, (outAngle + 1000.0) * visMode);\n\t} else {\n\t\tgl_FragColor = vec4(outVel, outLife);\n\t}\n}\n",particleOutputRgba8PS:"\nuniform vec3 outBoundsMul;\nuniform vec3 outBoundsAdd;\nvec2 encodeFloatRG( float v ) {\n\tvec2 enc = vec2(1.0, 255.0) * v;\n\tenc = fract(enc);\n\tenc -= enc.yy * vec2(1.0/255.0, 1.0/255.0);\n\treturn enc;\n}\nvec4 encodeFloatRGBA( float v ) {\n\tvec4 enc = vec4(1.0, 255.0, 65025.0, 160581375.0) * v;\n\tenc = fract(enc);\n\tenc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);\n\treturn enc;\n}\nvoid writeOutput() {\n\toutPos = outPos * outBoundsMul + outBoundsAdd;\n\toutAngle = fract(outAngle / PI2);\n\toutVel = (outVel / maxVel) + vec3(0.5);\n\tfloat maxNegLife = max(lifetime, (numParticles - 1.0) * (rate+rateDiv));\n\tfloat maxPosLife = lifetime+1.0;\n\toutLife = (outLife + maxNegLife) / (maxNegLife + maxPosLife);\n\tif (gl_FragCoord.y < 1.0) {\n\t\tgl_FragColor = vec4(encodeFloatRG(outPos.x), encodeFloatRG(outPos.y));\n\t} else if (gl_FragCoord.y < 2.0) {\n\t\tgl_FragColor = vec4(encodeFloatRG(outPos.z), encodeFloatRG(outAngle));\n\t} else if (gl_FragCoord.y < 3.0) {\n\t\tgl_FragColor = vec4(outVel, visMode*0.5+0.5);\n\t} else {\n\t\tgl_FragColor = encodeFloatRGBA(outLife);\n\t}\n}\n",particleUpdaterAABBPS:"\nuniform mat3 spawnBounds;\nuniform vec3 spawnPosInnerRatio;\nvec3 calcSpawnPosition(vec3 inBounds, float rndFactor) {\n\tvec3 pos = inBounds - vec3(0.5);\n\tvec3 posAbs = abs(pos);\n\tvec3 maxPos = vec3(max(posAbs.x, max(posAbs.y, posAbs.z)));\n\tvec3 edge = maxPos + (vec3(0.5) - maxPos) * spawnPosInnerRatio;\n\tpos.x = edge.x * (maxPos.x == posAbs.x ? sign(pos.x) : 2.0 * pos.x);\n\tpos.y = edge.y * (maxPos.y == posAbs.y ? sign(pos.y) : 2.0 * pos.y);\n\tpos.z = edge.z * (maxPos.z == posAbs.z ? sign(pos.z) : 2.0 * pos.z);\n#ifndef LOCAL_SPACE\n\treturn emitterPos + spawnBounds * pos;\n#else\n\treturn spawnBounds * pos;\n#endif\n}\nvoid addInitialVelocity(inout vec3 localVelocity, vec3 inBounds) {\n\tlocalVelocity -= vec3(0, 0, initialVelocity);\n}\n",particleUpdaterEndPS:"\n\twriteOutput();\n}\n",particleUpdaterInitPS:"\nvarying vec2 vUv0;\nuniform highp sampler2D particleTexIN;\nuniform highp sampler2D internalTex0;\nuniform highp sampler2D internalTex1;\nuniform highp sampler2D internalTex2;\nuniform highp sampler2D internalTex3;\nuniform mat3 emitterMatrix;\nuniform mat3 emitterMatrixInv;\nuniform vec3 emitterScale;\nuniform vec3 emitterPos;\nuniform vec3 frameRandom;\nuniform vec3 localVelocityDivMult;\nuniform vec3 velocityDivMult;\nuniform float delta;\nuniform float rate;\nuniform float rateDiv;\nuniform float lifetime;\nuniform float numParticles;\nuniform float rotSpeedDivMult;\nuniform float radialSpeedDivMult;\nuniform float seed;\nuniform float startAngle;\nuniform float startAngle2;\nuniform float initialVelocity;\nuniform float graphSampleSize;\nuniform float graphNumSamples;\nvec3 inPos;\nvec3 inVel;\nfloat inAngle;\nbool inShow;\nfloat inLife;\nfloat visMode;\nvec3 outPos;\nvec3 outVel;\nfloat outAngle;\nbool outShow;\nfloat outLife;\n",particleUpdaterNoRespawnPS:"\n\tif (outLife >= lifetime) {\n\t\toutLife -= max(lifetime, (numParticles - 1.0) * particleRate);\n\t\tvisMode = -1.0;\n\t}\n",particleUpdaterOnStopPS:"\n\tvisMode = outLife < 0.0? -1.0: visMode;\n",particleUpdaterRespawnPS:"\n\tif (outLife >= lifetime) {\n\t\toutLife -= max(lifetime, (numParticles - 1.0) * particleRate);\n\t\tvisMode = 1.0;\n\t}\n\tvisMode = outLife < 0.0? 1.0: visMode;\n",particleUpdaterSpherePS:"\nuniform float spawnBoundsSphere;\nuniform float spawnBoundsSphereInnerRatio;\nvec3 calcSpawnPosition(vec3 inBounds, float rndFactor) {\n\tfloat rnd4 = fract(rndFactor * 1000.0);\n\tvec3 norm = normalize(inBounds.xyz - vec3(0.5));\n\tfloat r = rnd4 * (1.0 - spawnBoundsSphereInnerRatio) + spawnBoundsSphereInnerRatio;\n#ifndef LOCAL_SPACE\n\treturn emitterPos + norm * r * spawnBoundsSphere;\n#else\n\treturn norm * r * spawnBoundsSphere;\n#endif\n}\nvoid addInitialVelocity(inout vec3 localVelocity, vec3 inBounds) {\n\tlocalVelocity += normalize(inBounds - vec3(0.5)) * initialVelocity;\n}\n",particleUpdaterStartPS:"\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\nvec3 unpack3NFloats(float src) {\n\tfloat r = fract(src);\n\tfloat g = fract(src * 256.0);\n\tfloat b = fract(src * 65536.0);\n\treturn vec3(r, g, b);\n}\nvec3 tex1Dlod_lerp(TEXTURE_ACCEPT_HIGHP(tex), vec2 tc, out vec3 w) {\n\tvec4 a = texture2D(tex, tc);\n\tvec4 b = texture2D(tex, tc + graphSampleSize);\n\tfloat c = fract(tc.x * graphNumSamples);\n\tvec3 unpackedA = unpack3NFloats(a.w);\n\tvec3 unpackedB = unpack3NFloats(b.w);\n\tw = mix(unpackedA, unpackedB, c);\n\treturn mix(a.xyz, b.xyz, c);\n}\n#define HASHSCALE4 vec4(1031, .1030, .0973, .1099)\nvec4 hash41(float p) {\n\tvec4 p4 = fract(vec4(p) * HASHSCALE4);\n\tp4 += dot(p4, p4.wzxy+19.19);\n\treturn fract(vec4((p4.x + p4.y)*p4.z, (p4.x + p4.z)*p4.y, (p4.y + p4.z)*p4.w, (p4.z + p4.w)*p4.x));\n}\nvoid main(void) {\n\tif (gl_FragCoord.x > numParticles) discard;\n\treadInput(vUv0.x);\n\tvisMode = inShow? 1.0 : -1.0;\n\tvec4 rndFactor = hash41(gl_FragCoord.x + seed);\n\tfloat particleRate = rate + rateDiv * rndFactor.x;\n\toutLife = inLife + delta;\n\tfloat nlife = clamp(outLife / lifetime, 0.0, 1.0);\n\tvec3 localVelocityDiv;\n\tvec3 velocityDiv;\n\tvec3 paramDiv;\n\tvec3 localVelocity = tex1Dlod_lerp(TEXTURE_PASS(internalTex0), vec2(nlife, 0), localVelocityDiv);\n\tvec3 velocity =\t tex1Dlod_lerp(TEXTURE_PASS(internalTex1), vec2(nlife, 0), velocityDiv);\n\tvec3 params =\t\ttex1Dlod_lerp(TEXTURE_PASS(internalTex2), vec2(nlife, 0), paramDiv);\n\tfloat rotSpeed = params.x;\n\tfloat rotSpeedDiv = paramDiv.y;\n\tvec3 radialParams = tex1Dlod_lerp(TEXTURE_PASS(internalTex3), vec2(nlife, 0), paramDiv);\n\tfloat radialSpeed = radialParams.x;\n\tfloat radialSpeedDiv = radialParams.y;\n\tbool respawn = inLife <= 0.0 || outLife >= lifetime;\n\tinPos = respawn ? calcSpawnPosition(rndFactor.xyz, rndFactor.x) : inPos;\n\tinAngle = respawn ? mix(startAngle, startAngle2, rndFactor.x) : inAngle;\n#ifndef LOCAL_SPACE\n\tvec3 radialVel = inPos - emitterPos;\n#else\n\tvec3 radialVel = inPos;\n#endif\n\tradialVel = (dot(radialVel, radialVel) > 1.0E-8) ? radialSpeed * normalize(radialVel) : vec3(0.0);\n\tradialVel += (radialSpeedDiv * vec3(2.0) - vec3(1.0)) * radialSpeedDivMult * rndFactor.xyz;\n\tlocalVelocity +=\t(localVelocityDiv * vec3(2.0) - vec3(1.0)) * localVelocityDivMult * rndFactor.xyz;\n\tvelocity +=\t\t (velocityDiv * vec3(2.0) - vec3(1.0)) * velocityDivMult * rndFactor.xyz;\n\trotSpeed +=\t\t (rotSpeedDiv * 2.0 - 1.0) * rotSpeedDivMult * rndFactor.y;\n\taddInitialVelocity(localVelocity, rndFactor.xyz);\n#ifndef LOCAL_SPACE\n\toutVel = emitterMatrix * localVelocity + (radialVel + velocity) * emitterScale;\n#else\n\toutVel = (localVelocity + radialVel) / emitterScale + emitterMatrixInv * velocity;\n#endif\n\toutPos = inPos + outVel * delta;\n\toutAngle = inAngle + rotSpeed * delta;\n",particle_billboardVS:"\n\tquadXY = rotate(quadXY, inAngle, rotMatrix);\n\tvec3 localPos = billboard(particlePos, quadXY);\n",particle_blendAddPS:"\n\tdBlendModeFogFactor = 0.0;\n\trgb *= saturate(gammaCorrectInput(max(a, 0.0)));\n\tif ((rgb.r + rgb.g + rgb.b) < 0.000001) discard;\n",particle_blendMultiplyPS:"\n\trgb = mix(vec3(1.0), rgb, vec3(a));\n\tif (rgb.r + rgb.g + rgb.b > 2.99) discard;\n",particle_blendNormalPS:"\n\tif (a < 0.01) discard;\n",particle_cpuVS:"\nattribute vec4 particle_vertexData;\nattribute vec4 particle_vertexData2;\nattribute vec4 particle_vertexData3;\nattribute float particle_vertexData4;\n#ifndef USE_MESH\nattribute vec2 particle_vertexData5;\n#else\nattribute vec4 particle_vertexData5;\n#endif\nuniform mat4 matrix_viewProjection;\nuniform mat4 matrix_model;\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform mat3 matrix_normal;\nuniform mat4 matrix_viewInverse;\nuniform float numParticles;\nuniform float lifetime;\nuniform float stretch;\nuniform float seed;\nuniform vec3 wrapBounds;\nuniform vec3 emitterScale;\nuniform vec3 faceTangent;\nuniform vec3 faceBinorm;\n#ifdef PARTICLE_GPU\n\tuniform highp sampler2D internalTex0;\n\tuniform highp sampler2D internalTex1;\n\tuniform highp sampler2D internalTex2;\n#endif\nuniform vec3 emitterPos;\nvarying vec4 texCoordsAlphaLife;\nvec2 rotate(vec2 quadXY, float pRotation, out mat2 rotMatrix)\n{\n\tfloat c = cos(pRotation);\n\tfloat s = sin(pRotation);\n\tmat2 m = mat2(c, -s, s, c);\n\trotMatrix = m;\n\treturn m * quadXY;\n}\nvec3 billboard(vec3 InstanceCoords, vec2 quadXY)\n{\n\tvec3 pos = -matrix_viewInverse[0].xyz * quadXY.x + -matrix_viewInverse[1].xyz * quadXY.y;\n\treturn pos;\n}\nvec3 customFace(vec3 InstanceCoords, vec2 quadXY)\n{\n\tvec3 pos = faceTangent * quadXY.x + faceBinorm * quadXY.y;\n\treturn pos;\n}\nvoid main(void)\n{\n\tvec3 particlePos = particle_vertexData.xyz;\n\tvec3 inPos = particlePos;\n\tvec3 vertPos = particle_vertexData3.xyz;\n\tvec3 inVel = vec3(particle_vertexData2.w, particle_vertexData3.w, particle_vertexData5.x);\n\tfloat id = floor(particle_vertexData4);\n\tfloat rndFactor = fract(sin(id + 1.0 + seed));\n\tvec3 rndFactor3 = vec3(rndFactor, fract(rndFactor*10.0), fract(rndFactor*100.0));\n#ifdef LOCAL_SPACE\n\tinVel = mat3(matrix_model) * inVel;\n#endif\n\tvec2 velocityV = normalize((mat3(matrix_view) * inVel).xy);\n\tvec2 quadXY = vertPos.xy;\n#ifdef USE_MESH\n\ttexCoordsAlphaLife = vec4(particle_vertexData5.zw, particle_vertexData2.z, particle_vertexData.w);\n#else\n\ttexCoordsAlphaLife = vec4(quadXY * -0.5 + 0.5, particle_vertexData2.z, particle_vertexData.w);\n#endif\n\tmat2 rotMatrix;\n\tfloat inAngle = particle_vertexData2.x;\n\tvec3 particlePosMoved = vec3(0.0);\n\tvec3 meshLocalPos = particle_vertexData3.xyz;\n",particle_cpu_endVS:"\n\tlocalPos *= particle_vertexData2.y * emitterScale;\n\tlocalPos += particlePos;\n\tgl_Position = matrix_viewProjection * vec4(localPos, 1.0);\n",particle_customFaceVS:"\n\tquadXY = rotate(quadXY, inAngle, rotMatrix);\n\tvec3 localPos = customFace(particlePos, quadXY);\n",particle_endPS:"\n\trgb = addFog(rgb);\n\trgb = toneMap(rgb);\n\trgb = gammaCorrectOutput(rgb);\n\tgl_FragColor = vec4(rgb, a);\n}\n",particle_endVS:"\n\tlocalPos *= scale * emitterScale;\n\tlocalPos += particlePos;\n\t#ifdef SCREEN_SPACE\n\tgl_Position = vec4(localPos.x, localPos.y, 0.0, 1.0);\n\t#else\n\tgl_Position = matrix_viewProjection * vec4(localPos.xyz, 1.0);\n\t#endif\n",particle_halflambertPS:"\n\tvec3 negNormal = normal*0.5+0.5;\n\tvec3 posNormal = -normal*0.5+0.5;\n\tnegNormal *= negNormal;\n\tposNormal *= posNormal;\n",particle_initVS:"\nattribute vec4 particle_vertexData;\n#ifdef USE_MESH\nattribute vec2 particle_uv;\n#endif\nuniform mat4 matrix_viewProjection;\nuniform mat4 matrix_model;\nuniform mat3 matrix_normal;\nuniform mat4 matrix_viewInverse;\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform float numParticles;\nuniform float numParticlesPot;\nuniform float graphSampleSize;\nuniform float graphNumSamples;\nuniform float stretch;\nuniform vec3 wrapBounds;\nuniform vec3 emitterScale;\nuniform vec3 emitterPos;\nuniform vec3 faceTangent;\nuniform vec3 faceBinorm;\nuniform float rate;\nuniform float rateDiv;\nuniform float lifetime;\nuniform float deltaRandomnessStatic;\nuniform float scaleDivMult;\nuniform float alphaDivMult;\nuniform float seed;\nuniform float delta;\nuniform sampler2D particleTexOUT;\nuniform sampler2D particleTexIN;\n#ifdef PARTICLE_GPU\n\tuniform highp sampler2D internalTex0;\n\tuniform highp sampler2D internalTex1;\n\tuniform highp sampler2D internalTex2;\n#endif\n#ifndef CAMERAPLANES\n#define CAMERAPLANES\nuniform vec4 camera_params;\n#endif\nvarying vec4 texCoordsAlphaLife;\nvec3 inPos;\nvec3 inVel;\nfloat inAngle;\nbool inShow;\nfloat inLife;\n",particle_lambertPS:"\n\tvec3 negNormal = max(normal, vec3(0.0));\n\tvec3 posNormal = max(-normal, vec3(0.0));\n",particle_lightingPS:"\n\tvec3 light = negNormal.x*lightCube[0] + posNormal.x*lightCube[1] +\n\t\t\t\t\t\tnegNormal.y*lightCube[2] + posNormal.y*lightCube[3] +\n\t\t\t\t\t\tnegNormal.z*lightCube[4] + posNormal.z*lightCube[5];\n\trgb *= light;\n",particle_localShiftVS:"\n\tparticlePos = (matrix_model * vec4(particlePos, 1.0)).xyz;\n",particle_meshVS:"\n\tvec3 localPos = meshLocalPos;\n\tlocalPos.xy = rotate(localPos.xy, inAngle, rotMatrix);\n\tlocalPos.yz = rotate(localPos.yz, inAngle, rotMatrix);\n\tbillboard(particlePos, quadXY);\n",particle_normalVS:"\n\tNormal = normalize(localPos + matrix_viewInverse[2].xyz);\n",particle_normalMapPS:"\n\tvec3 normalMap = normalize(texture2D(normalMap, vec2(texCoordsAlphaLife.x, 1.0 - texCoordsAlphaLife.y)).xyz * 2.0 - 1.0);\n\tvec3 normal = ParticleMat * normalMap;\n",particle_pointAlongVS:"\n\tinAngle = atan(velocityV.x, velocityV.y);\n",particle_softPS:"\n\tfloat depth = getLinearScreenDepth();\n\tfloat particleDepth = vDepth;\n\tfloat depthDiff = saturate(abs(particleDepth - depth) * softening);\n\ta *= depthDiff;\n",particle_softVS:"\n\tvDepth = getLinearDepth(localPos);\n",particle_stretchVS:"\n\tvec3 moveDir = inVel * stretch;\n\tvec3 posPrev = particlePos - moveDir;\n\tposPrev += particlePosMoved;\n\tvec2 centerToVertexV = normalize((mat3(matrix_view) * localPos).xy);\n\tfloat interpolation = dot(-velocityV, centerToVertexV) * 0.5 + 0.5;\n\tparticlePos = mix(particlePos, posPrev, interpolation);\n",particle_TBNVS:"\n\tmat3 rot3 = mat3(rotMatrix[0][0], rotMatrix[0][1], 0.0, rotMatrix[1][0], rotMatrix[1][1], 0.0, 0.0, 0.0, 1.0);\n\tParticleMat = mat3(-matrix_viewInverse[0].xyz, -matrix_viewInverse[1].xyz, matrix_viewInverse[2].xyz) * rot3;\n",particle_wrapVS:"\n\tvec3 origParticlePos = particlePos;\n\tparticlePos -= matrix_model[3].xyz;\n\tparticlePos = mod(particlePos, wrapBounds) - wrapBounds * 0.5;\n\tparticlePos += matrix_model[3].xyz;\n\tparticlePosMoved = particlePos - origParticlePos;\n",reflDirPS:"\nvoid getReflDir(vec3 worldNormal, vec3 viewDir, float gloss, mat3 tbn) {\n\tdReflDirW = normalize(-reflect(viewDir, worldNormal));\n}\n",reflDirAnisoPS:"\nvoid getReflDir(vec3 worldNormal, vec3 viewDir, float gloss, mat3 tbn) {\n\tfloat roughness = sqrt(1.0 - min(gloss, 1.0));\n\tfloat anisotropy = material_anisotropy * roughness;\n\tvec3 anisotropicDirection = anisotropy >= 0.0 ? tbn[1] : tbn[0];\n\tvec3 anisotropicTangent = cross(anisotropicDirection, viewDir);\n\tvec3 anisotropicNormal = cross(anisotropicTangent, anisotropicDirection);\n\tvec3 bentNormal = normalize(mix(normalize(worldNormal), normalize(anisotropicNormal), anisotropy));\n\tdReflDirW = reflect(-viewDir, bentNormal);\n}\n",reflectionCCPS:"\n#ifdef LIT_CLEARCOAT\nvoid addReflectionCC(vec3 reflDir, float gloss) {\n\tccReflection += calcReflection(reflDir, gloss);\n}\n#endif\n",reflectionCubePS:"\nuniform samplerCube texture_cubeMap;\nuniform float material_reflectivity;\nvec3 calcReflection(vec3 reflDir, float gloss) {\n\tvec3 lookupVec = fixSeams(cubeMapProject(reflDir));\n\tlookupVec.x *= -1.0;\n\treturn $DECODE(textureCube(texture_cubeMap, lookupVec));\n}\nvoid addReflection(vec3 reflDir, float gloss) { \n\tdReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n",reflectionEnvHQPS:"\n#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform samplerCube texture_cubeMap;\nuniform float material_reflectivity;\nvec3 calcReflection(vec3 reflDir, float gloss) {\n\tvec3 dir = cubeMapProject(reflDir) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(dir);\n\tfloat level = saturate(1.0 - gloss) * 5.0;\n\tfloat ilevel = floor(level);\n\tfloat flevel = level - ilevel;\n\tvec3 sharp = $DECODE_CUBEMAP(textureCube(texture_cubeMap, fixSeams(dir)));\n\tvec3 roughA = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel)));\n\tvec3 roughB = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\treturn processEnvironment(mix(sharp, mix(roughA, roughB, flevel), min(level, 1.0)));\n}\nvoid addReflection(vec3 reflDir, float gloss) { \n\tdReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n",reflectionEnvPS:"\n#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform float material_reflectivity;\nfloat shinyMipLevel(vec2 uv) {\n\tvec2 dx = dFdx(uv);\n\tvec2 dy = dFdy(uv);\n\tvec2 uv2 = vec2(fract(uv.x + 0.5), uv.y);\n\tvec2 dx2 = dFdx(uv2);\n\tvec2 dy2 = dFdy(uv2);\n\tfloat maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2)));\n\treturn clamp(0.5 * log2(maxd) - 1.0 + textureBias, 0.0, 5.0);\n}\nvec3 calcReflection(vec3 reflDir, float gloss) {\n\tvec3 dir = cubeMapProject(reflDir) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(dir);\n\tfloat level = saturate(1.0 - gloss) * 5.0;\n\tfloat ilevel = floor(level);\n\tfloat level2 = shinyMipLevel(uv * atlasSize);\n\tfloat ilevel2 = floor(level2);\n\tvec2 uv0, uv1;\n\tfloat weight;\n\tif (ilevel == 0.0) {\n\t\tuv0 = mapShinyUv(uv, ilevel2);\n\t\tuv1 = mapShinyUv(uv, ilevel2 + 1.0);\n\t\tweight = level2 - ilevel2;\n\t} else {\n\t\tuv0 = uv1 = mapRoughnessUv(uv, ilevel);\n\t\tweight = 0.0;\n\t}\n\tvec3 linearA = $DECODE(texture2D(texture_envAtlas, uv0));\n\tvec3 linearB = $DECODE(texture2D(texture_envAtlas, uv1));\n\tvec3 linear0 = mix(linearA, linearB, weight);\n\tvec3 linear1 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\treturn processEnvironment(mix(linear0, linear1, level - ilevel));\n}\nvoid addReflection(vec3 reflDir, float gloss) { \n\tdReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n",reflectionSpherePS:"\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform sampler2D texture_sphereMap;\nuniform float material_reflectivity;\nvec3 calcReflection(vec3 reflDir, float gloss) {\n\tvec3 reflDirV = (mat3(matrix_view) * reflDir).xyz;\n\tfloat m = 2.0 * sqrt( dot(reflDirV.xy, reflDirV.xy) + (reflDirV.z+1.0)*(reflDirV.z+1.0) );\n\tvec2 sphereMapUv = reflDirV.xy / m + 0.5;\n\treturn $DECODE(texture2D(texture_sphereMap, sphereMapUv));\n}\nvoid addReflection(vec3 reflDir, float gloss) { \n\tdReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n",reflectionSheenPS:"\nvoid addReflectionSheen(vec3 worldNormal, vec3 viewDir, float gloss) {\n\tfloat NoV = dot(worldNormal, viewDir);\n\tfloat alphaG = gloss * gloss;\n\tfloat a = gloss < 0.25 ? -339.2 * alphaG + 161.4 * gloss - 25.9 : -8.48 * alphaG + 14.3 * gloss - 9.95;\n\tfloat b = gloss < 0.25 ? 44.0 * alphaG - 23.7 * gloss + 3.26 : 1.97 * alphaG - 3.27 * gloss + 0.72;\n\tfloat DG = exp( a * NoV + b ) + ( gloss < 0.25 ? 0.0 : 0.1 * ( gloss - 0.25 ) );\n\tsReflection += calcReflection(worldNormal, 0.0) * saturate(DG);\n}\n",refractionCubePS:"\nvec3 refract2(vec3 viewVec, vec3 normal, float IOR) {\n\tfloat vn = dot(viewVec, normal);\n\tfloat k = 1.0 - IOR * IOR * (1.0 - vn * vn);\n\tvec3 refrVec = IOR * viewVec - (IOR * vn + sqrt(k)) * normal;\n\treturn refrVec;\n}\nvoid addRefraction(\n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tfloat thickness, \n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 albedo, \n\tfloat transmission,\n\tfloat refractionIndex,\n\tfloat dispersion\n#if defined(LIT_IRIDESCENCE)\n\t, vec3 iridescenceFresnel,\n\tfloat iridescenceIntensity\n#endif \n) {\n\tvec4 tmpRefl = dReflection;\n\tvec3 reflectionDir = refract2(-viewDir, worldNormal, refractionIndex);\n\tdReflection = vec4(0);\n\taddReflection(reflectionDir, gloss);\n\tdDiffuseLight = mix(dDiffuseLight, dReflection.rgb * albedo, transmission);\n\tdReflection = tmpRefl;\n}\n",refractionDynamicPS:"\nuniform float material_invAttenuationDistance;\nuniform vec3 material_attenuation;\nvec3 evalRefractionColor(vec3 refractionVector, float gloss, float refractionIndex) {\n\tvec4 pointOfRefraction = vec4(vPositionW + refractionVector, 1.0);\n\tvec4 projectionPoint = matrix_viewProjection * pointOfRefraction;\n\tvec2 uv = getGrabScreenPos(projectionPoint);\n\t#ifdef SUPPORTS_TEXLOD\n\t\tfloat iorToRoughness = (1.0 - gloss) * clamp((1.0 / refractionIndex) * 2.0 - 2.0, 0.0, 1.0);\n\t\tfloat refractionLod = log2(uScreenSize.x) * iorToRoughness;\n\t\tvec3 refraction = texture2DLodEXT(uSceneColorMap, uv, refractionLod).rgb;\n\t#else\n\t\tvec3 refraction = texture2D(uSceneColorMap, uv).rgb;\n\t#endif\n\treturn refraction;\n}\nvoid addRefraction(\n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tfloat thickness, \n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 albedo, \n\tfloat transmission,\n\tfloat refractionIndex,\n\tfloat dispersion\n#if defined(LIT_IRIDESCENCE)\n\t, vec3 iridescenceFresnel,\n\tfloat iridescenceIntensity\n#endif\n) {\n\tvec3 modelScale;\n\tmodelScale.x = length(vec3(matrix_model[0].xyz));\n\tmodelScale.y = length(vec3(matrix_model[1].xyz));\n\tmodelScale.z = length(vec3(matrix_model[2].xyz));\n\tvec3 scale = thickness * modelScale;\n\tvec3 refractionVector = normalize(refract(-viewDir, worldNormal, refractionIndex)) * scale;\n\tvec3 refraction = evalRefractionColor(refractionVector, gloss, refractionIndex);\n\t#ifdef DISPERSION\n\t\tfloat halfSpread = (1.0 / refractionIndex - 1.0) * 0.025 * dispersion;\n\t\tfloat refractionIndexR = refractionIndex - halfSpread;\n\t\trefractionVector = normalize(refract(-viewDir, worldNormal, refractionIndexR)) * scale;\n\t\trefraction.r = evalRefractionColor(refractionVector, gloss, refractionIndexR).r;\n\t\tfloat refractionIndexB = refractionIndex + halfSpread;\n\t\trefractionVector = normalize(refract(-viewDir, worldNormal, refractionIndexB)) * scale;\n\t\trefraction.b = evalRefractionColor(refractionVector, gloss, refractionIndexB).b;\n\t#endif\n\tvec3 transmittance;\n\tif (material_invAttenuationDistance != 0.0)\n\t{\n\t\tvec3 attenuation = -log(material_attenuation) * material_invAttenuationDistance;\n\t\ttransmittance = exp(-attenuation * length(refractionVector));\n\t}\n\telse\n\t{\n\t\ttransmittance = refraction;\n\t}\n\tvec3 fresnel = vec3(1.0) - \n\t\tgetFresnel(\n\t\t\tdot(viewDir, worldNormal), \n\t\t\tgloss, \n\t\t\tspecularity\n\t\t#if defined(LIT_IRIDESCENCE)\n\t\t\t, iridescenceFresnel,\n\t\t\tiridescenceIntensity\n\t\t#endif\n\t\t);\n\tdDiffuseLight = mix(dDiffuseLight, refraction * transmittance * fresnel, transmission);\n}\n",reprojectPS:"\nvarying vec2 vUv0;\n#ifdef CUBEMAP_SOURCE\n\tuniform samplerCube sourceCube;\n#else\n\tuniform sampler2D sourceTex;\n#endif\n#ifdef USE_SAMPLES_TEX\n\tuniform sampler2D samplesTex;\n\tuniform vec2 samplesTexInverseSize;\n#endif\nuniform vec3 params;\nfloat targetFace() { return params.x; }\nfloat sourceCubeSeamScale() { return params.y; }\nfloat targetCubeSeamScale() { return params.z; }\nfloat PI = 3.141592653589793;\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\n"+Mo+"\n"+Po+"\nvec3 modifySeams(vec3 dir, float scale) {\n\tvec3 adir = abs(dir);\n\tfloat M = max(max(adir.x, adir.y), adir.z);\n\treturn dir / M * vec3(\n\t\tadir.x == M ? 1.0 : scale,\n\t\tadir.y == M ? 1.0 : scale,\n\t\tadir.z == M ? 1.0 : scale\n\t);\n}\nvec2 toSpherical(vec3 dir) {\n\treturn vec2(dir.xz == vec2(0.0) ? 0.0 : atan(dir.x, dir.z), asin(dir.y));\n}\nvec3 fromSpherical(vec2 uv) {\n\treturn vec3(cos(uv.y) * sin(uv.x),\n\t\t\t\tsin(uv.y),\n\t\t\t\tcos(uv.y) * cos(uv.x));\n}\nvec3 getDirectionEquirect() {\n\treturn fromSpherical((vec2(vUv0.x, 1.0 - vUv0.y) * 2.0 - 1.0) * vec2(PI, PI * 0.5));\n}\nfloat signNotZero(float k){\n\treturn(k >= 0.0) ? 1.0 : -1.0;\n}\nvec2 signNotZero(vec2 v) {\n\treturn vec2(signNotZero(v.x), signNotZero(v.y));\n}\nvec3 octDecode(vec2 o) {\n\tvec3 v = vec3(o.x, 1.0 - abs(o.x) - abs(o.y), o.y);\n\tif (v.y < 0.0) {\n\t\tv.xz = (1.0 - abs(v.zx)) * signNotZero(v.xz);\n\t}\n\treturn normalize(v);\n}\nvec3 getDirectionOctahedral() {\n\treturn octDecode(vec2(vUv0.x, 1.0 - vUv0.y) * 2.0 - 1.0);\n}\nvec2 octEncode(in vec3 v) {\n\tfloat l1norm = abs(v.x) + abs(v.y) + abs(v.z);\n\tvec2 result = v.xz * (1.0 / l1norm);\n\tif (v.y < 0.0) {\n\t\tresult = (1.0 - abs(result.yx)) * signNotZero(result.xy);\n\t}\n\treturn result;\n}\n#ifdef CUBEMAP_SOURCE\n\tvec4 sampleCubemap(vec3 dir) {\n\t\treturn textureCube(sourceCube, modifySeams(dir, 1.0 - sourceCubeSeamScale()));\n\t}\n\tvec4 sampleCubemap(vec2 sph) {\n\treturn sampleCubemap(fromSpherical(sph));\n}\n\tvec4 sampleCubemap(vec3 dir, float mipLevel) {\n\t\treturn textureCubeLodEXT(sourceCube, modifySeams(dir, 1.0 - exp2(mipLevel) * sourceCubeSeamScale()), mipLevel);\n\t}\n\tvec4 sampleCubemap(vec2 sph, float mipLevel) {\n\t\treturn sampleCubemap(fromSpherical(sph), mipLevel);\n\t}\n#else\n\tvec4 sampleEquirect(vec2 sph) {\n\t\tvec2 uv = sph / vec2(PI * 2.0, PI) + 0.5;\n\t\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n\t}\n\tvec4 sampleEquirect(vec3 dir) {\n\t\treturn sampleEquirect(toSpherical(dir));\n\t}\n\tvec4 sampleEquirect(vec2 sph, float mipLevel) {\n\t\tvec2 uv = sph / vec2(PI * 2.0, PI) + 0.5;\n\t\treturn texture2DLodEXT(sourceTex, vec2(uv.x, 1.0 - uv.y), mipLevel);\n\t}\n\tvec4 sampleEquirect(vec3 dir, float mipLevel) {\n\t\treturn sampleEquirect(toSpherical(dir), mipLevel);\n\t}\n\tvec4 sampleOctahedral(vec3 dir) {\n\t\tvec2 uv = octEncode(dir) * 0.5 + 0.5;\n\t\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n\t}\n\tvec4 sampleOctahedral(vec2 sph) {\n\t\treturn sampleOctahedral(fromSpherical(sph));\n\t}\n\tvec4 sampleOctahedral(vec3 dir, float mipLevel) {\n\t\tvec2 uv = octEncode(dir) * 0.5 + 0.5;\n\t\treturn texture2DLodEXT(sourceTex, vec2(uv.x, 1.0 - uv.y), mipLevel);\n\t}\n\tvec4 sampleOctahedral(vec2 sph, float mipLevel) {\n\t\treturn sampleOctahedral(fromSpherical(sph), mipLevel);\n\t}\n#endif\nvec3 getDirectionCubemap() {\n\tvec2 st = vUv0 * 2.0 - 1.0;\n\tfloat face = targetFace();\n\tvec3 vec;\n\tif (face == 0.0) {\n\t\tvec = vec3(1, -st.y, -st.x);\n\t} else if (face == 1.0) {\n\t\tvec = vec3(-1, -st.y, st.x);\n\t} else if (face == 2.0) {\n\t\tvec = vec3(st.x, 1, st.y);\n\t} else if (face == 3.0) {\n\t\tvec = vec3(st.x, -1, -st.y);\n\t} else if (face == 4.0) {\n\t\tvec = vec3(st.x, -st.y, 1);\n\t} else {\n\t\tvec = vec3(-st.x, -st.y, -1);\n\t}\n\treturn normalize(modifySeams(vec, 1.0 / (1.0 - targetCubeSeamScale())));\n}\nmat3 matrixFromVector(vec3 n) {\n\tfloat a = 1.0 / (1.0 + n.z);\n\tfloat b = -n.x * n.y * a;\n\tvec3 b1 = vec3(1.0 - n.x * n.x * a, b, -n.x);\n\tvec3 b2 = vec3(b, 1.0 - n.y * n.y * a, -n.y);\n\treturn mat3(b1, b2, n);\n}\nmat3 matrixFromVectorSlow(vec3 n) {\n\tvec3 up = (1.0 - abs(n.y) <= 0.0000001) ? vec3(0.0, 0.0, n.y > 0.0 ? 1.0 : -1.0) : vec3(0.0, 1.0, 0.0);\n\tvec3 x = normalize(cross(up, n));\n\tvec3 y = cross(n, x);\n\treturn mat3(x, y, n);\n}\nvec4 reproject() {\n\tif (NUM_SAMPLES <= 1) {\n\t\treturn ENCODE_FUNC(DECODE_FUNC(SOURCE_FUNC(TARGET_FUNC())));\n\t} else {\n\t\tvec3 t = TARGET_FUNC();\n\t\tvec3 tu = dFdx(t);\n\t\tvec3 tv = dFdy(t);\n\t\tvec3 result = vec3(0.0);\n\t\tfor (float u = 0.0; u < NUM_SAMPLES_SQRT; ++u) {\n\t\t\tfor (float v = 0.0; v < NUM_SAMPLES_SQRT; ++v) {\n\t\t\t\tresult += DECODE_FUNC(SOURCE_FUNC(normalize(t +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttu * (u / NUM_SAMPLES_SQRT - 0.5) +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttv * (v / NUM_SAMPLES_SQRT - 0.5))));\n\t\t\t}\n\t\t}\n\t\treturn ENCODE_FUNC(result / (NUM_SAMPLES_SQRT * NUM_SAMPLES_SQRT));\n\t}\n}\nvec4 unpackFloat = vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0);\n#ifdef USE_SAMPLES_TEX\n\tvoid unpackSample(int i, out vec3 L, out float mipLevel) {\n\t\tfloat u = (float(i * 4) + 0.5) * samplesTexInverseSize.x;\n\t\tfloat v = (floor(u) + 0.5) * samplesTexInverseSize.y;\n\t\tvec4 raw;\n\t\traw.x = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\t\traw.y = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\t\traw.z = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\t\traw.w = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat);\n\t\tL.xyz = raw.xyz * 2.0 - 1.0;\n\t\tmipLevel = raw.w * 8.0;\n\t}\n\tvec4 prefilterSamples() {\n\t\tmat3 vecSpace = matrixFromVectorSlow(TARGET_FUNC());\n\t\tvec3 L;\n\t\tfloat mipLevel;\n\t\tvec3 result = vec3(0.0);\n\t\tfloat totalWeight = 0.0;\n\t\tfor (int i = 0; i < NUM_SAMPLES; ++i) {\n\t\t\tunpackSample(i, L, mipLevel);\n\t\t\tresult += DECODE_FUNC(SOURCE_FUNC(vecSpace * L, mipLevel)) * L.z;\n\t\t\ttotalWeight += L.z;\n\t\t}\n\t\treturn ENCODE_FUNC(result / totalWeight);\n\t}\n\tvec4 prefilterSamplesUnweighted() {\n\t\tmat3 vecSpace = matrixFromVectorSlow(TARGET_FUNC());\n\t\tvec3 L;\n\t\tfloat mipLevel;\n\t\tvec3 result = vec3(0.0);\n\t\tfloat totalWeight = 0.0;\n\t\tfor (int i = 0; i < NUM_SAMPLES; ++i) {\n\t\t\tunpackSample(i, L, mipLevel);\n\t\t\tresult += DECODE_FUNC(SOURCE_FUNC(vecSpace * L, mipLevel));\n\t\t}\n\t\treturn ENCODE_FUNC(result / float(NUM_SAMPLES));\n\t}\n#endif\nvoid main(void) {\n\tgl_FragColor = PROCESS_FUNC();\n}\n",sampleCatmullRomPS:"\nvec4 SampleTextureCatmullRom(TEXTURE_ACCEPT(tex), vec2 uv, vec2 texSize) {\n\tvec2 samplePos = uv * texSize;\n\tvec2 texPos1 = floor(samplePos - 0.5) + 0.5;\n\tvec2 f = samplePos - texPos1;\n\tvec2 w0 = f * (-0.5 + f * (1.0 - 0.5 * f));\n\tvec2 w1 = 1.0 + f * f * (-2.5 + 1.5 * f);\n\tvec2 w2 = f * (0.5 + f * (2.0 - 1.5 * f));\n\tvec2 w3 = f * f * (-0.5 + 0.5 * f);\n\tvec2 w12 = w1 + w2;\n\tvec2 offset12 = w2 / (w1 + w2);\n\tvec2 texPos0 = (texPos1 - 1.0) / texSize;\n\tvec2 texPos3 = (texPos1 + 2.0) / texSize;\n\tvec2 texPos12 = (texPos1 + offset12) / texSize;\n\tvec4 result = vec4(0.0);\n\tresult += texture2DLodEXT(tex, vec2(texPos0.x, texPos0.y), 0.0) * w0.x * w0.y;\n\tresult += texture2DLodEXT(tex, vec2(texPos12.x, texPos0.y), 0.0) * w12.x * w0.y;\n\tresult += texture2DLodEXT(tex, vec2(texPos3.x, texPos0.y), 0.0) * w3.x * w0.y;\n\tresult += texture2DLodEXT(tex, vec2(texPos0.x, texPos12.y), 0.0) * w0.x * w12.y;\n\tresult += texture2DLodEXT(tex, vec2(texPos12.x, texPos12.y), 0.0) * w12.x * w12.y;\n\tresult += texture2DLodEXT(tex, vec2(texPos3.x, texPos12.y), 0.0) * w3.x * w12.y;\n\tresult += texture2DLodEXT(tex, vec2(texPos0.x, texPos3.y), 0.0) * w0.x * w3.y;\n\tresult += texture2DLodEXT(tex, vec2(texPos12.x, texPos3.y), 0.0) * w12.x * w3.y;\n\tresult += texture2DLodEXT(tex, vec2(texPos3.x, texPos3.y), 0.0) * w3.x * w3.y;\n\treturn result;\n}\n",screenDepthPS:"\nuniform highp sampler2D uSceneDepthMap;\n#ifndef SCREENSIZE\n#define SCREENSIZE\nuniform vec4 uScreenSize;\n#endif\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\n#ifndef LINEARIZE_DEPTH\n#ifndef CAMERAPLANES\n#define CAMERAPLANES\nuniform vec4 camera_params;\n#endif\n#define LINEARIZE_DEPTH\n#ifdef GL2\nfloat linearizeDepth(float z) {\n\tif (camera_params.w == 0.0)\n\t\treturn (camera_params.z * camera_params.y) / (camera_params.y + z * (camera_params.z - camera_params.y));\n\telse\n\t\treturn camera_params.z + z * (camera_params.y - camera_params.z);\n}\n#else\n#ifndef UNPACKFLOAT\n#define UNPACKFLOAT\nfloat unpackFloat(vec4 rgbaDepth) {\n\tconst vec4 bitShift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n\treturn dot(rgbaDepth, bitShift);\n}\n#endif\n#endif\n#endif\nfloat getLinearScreenDepth(vec2 uv) {\n\t#ifdef GL2\n\t\treturn linearizeDepth(texture2D(uSceneDepthMap, uv).r);\n\t#else\n\t\treturn unpackFloat(texture2D(uSceneDepthMap, uv)) * camera_params.y;\n\t#endif\n}\n#ifndef VERTEXSHADER\nfloat getLinearScreenDepth() {\n\tvec2 uv = gl_FragCoord.xy * uScreenSize.zw;\n\treturn getLinearScreenDepth(uv);\n}\n#endif\nfloat getLinearDepth(vec3 pos) {\n\treturn -(matrix_view * vec4(pos, 1.0)).z;\n}\n",shadowCascadesPS:"\nconst float maxCascades = 4.0;\nmat4 cascadeShadowMat;\nvoid getShadowCascadeMatrix(mat4 shadowMatrixPalette[4], float shadowCascadeDistances[4], float shadowCascadeCount) {\n\tfloat depth = 1.0 / gl_FragCoord.w;\n\tfloat cascadeIndex = 0.0;\n\tfor (float i = 0.0; i < maxCascades; i++) {\n\t\tif (depth < shadowCascadeDistances[int(i)]) {\n\t\t\tcascadeIndex = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tcascadeIndex = min(cascadeIndex, shadowCascadeCount - 1.0);\n\t#ifdef GL2\n\t\tcascadeShadowMat = shadowMatrixPalette[int(cascadeIndex)];\n\t#else\n\t\tif (cascadeIndex == 0.0) {\n\t\t\tcascadeShadowMat = shadowMatrixPalette[0];\n\t\t}\n\t\telse if (cascadeIndex == 1.0) {\n\t\t\tcascadeShadowMat = shadowMatrixPalette[1];\n\t\t}\n\t\telse if (cascadeIndex == 2.0) {\n\t\t\tcascadeShadowMat = shadowMatrixPalette[2];\n\t\t}\n\t\telse {\n\t\t\tcascadeShadowMat = shadowMatrixPalette[3];\n\t\t}\n\t#endif\n}\nvoid fadeShadow(float shadowCascadeDistances[4]) {\t\t\t\t \n\tfloat depth = 1.0 / gl_FragCoord.w;\n\tif (depth > shadowCascadeDistances[int(maxCascades - 1.0)]) {\n\t\tdShadowCoord.z = -9999999.0;\n\t}\n}\n",shadowEVSMPS:"\nfloat VSM$(TEXTURE_ACCEPT(tex), vec2 texCoords, float resolution, float Z, float vsmBias, float exponent) {\n\tvec3 moments = texture2D(tex, texCoords).xyz;\n\treturn calculateEVSM(moments, Z, vsmBias, exponent);\n}\nfloat getShadowVSM$(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM$(TEXTURE_PASS(shadowMap), shadowCoord.xy, shadowParams.x, shadowCoord.z, shadowParams.y, exponent);\n}\nfloat getShadowSpotVSM$(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM$(TEXTURE_PASS(shadowMap), shadowCoord.xy, shadowParams.x, length(lightDir) * shadowParams.w + shadowParams.z, shadowParams.y, exponent);\n}\n",shadowEVSMnPS:"\nfloat VSM$(TEXTURE_ACCEPT(tex), vec2 texCoords, float resolution, float Z, float vsmBias, float exponent) {\n\tfloat pixelSize = 1.0 / resolution;\n\ttexCoords -= vec2(pixelSize);\n\tvec3 s00 = texture2D(tex, texCoords).xyz;\n\tvec3 s10 = texture2D(tex, texCoords + vec2(pixelSize, 0)).xyz;\n\tvec3 s01 = texture2D(tex, texCoords + vec2(0, pixelSize)).xyz;\n\tvec3 s11 = texture2D(tex, texCoords + vec2(pixelSize)).xyz;\n\tvec2 fr = fract(texCoords * resolution);\n\tvec3 h0 = mix(s00, s10, fr.x);\n\tvec3 h1 = mix(s01, s11, fr.x);\n\tvec3 moments = mix(h0, h1, fr.y);\n\treturn calculateEVSM(moments, Z, vsmBias, exponent);\n}\nfloat getShadowVSM$(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM$(TEXTURE_PASS(shadowMap), shadowCoord.xy, shadowParams.x, shadowCoord.z, shadowParams.y, exponent);\n}\nfloat getShadowSpotVSM$(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM$(TEXTURE_PASS(shadowMap), shadowCoord.xy, shadowParams.x, length(lightDir) * shadowParams.w + shadowParams.z, shadowParams.y, exponent);\n}\n",shadowPCSSPS:"\n#define PCSS_SAMPLE_COUNT 16\nuniform float pcssDiskSamples[PCSS_SAMPLE_COUNT];\nuniform float pcssSphereSamples[PCSS_SAMPLE_COUNT];\nvec2 vogelDisk(int sampleIndex, float count, float phi, float r) {\n\tconst float GoldenAngle = 2.4;\n\tfloat theta = float(sampleIndex) * GoldenAngle + phi;\n\tfloat sine = sin(theta);\n\tfloat cosine = cos(theta);\n\treturn vec2(r * cosine, r * sine);\n}\nvec3 vogelSphere(int sampleIndex, float count, float phi, float r) {\n\tconst float GoldenAngle = 2.4;\n\tfloat theta = float(sampleIndex) * GoldenAngle + phi;\n\tfloat weight = float(sampleIndex) / count;\n\treturn vec3(cos(theta) * r, weight, sin(theta) * r);\n}\nfloat noise(vec2 screenPos) {\n\tconst float PHI = 1.61803398874989484820459;\n\treturn fract(sin(dot(screenPos * PHI, screenPos)) * screenPos.x);\n}\n#ifndef UNPACKFLOAT\n#define UNPACKFLOAT\nfloat unpackFloat(vec4 rgbaDepth) {\n\tconst vec4 bitShift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n\treturn dot(rgbaDepth, bitShift);\n}\n#endif\nfloat viewSpaceDepth(float depth, mat4 invProjection) {\n\tfloat z = depth * 2.0 - 1.0;\n\tvec4 clipSpace = vec4(0.0, 0.0, z, 1.0);\n\tvec4 viewSpace = invProjection * clipSpace;\n\treturn viewSpace.z;\n}\nfloat PCSSBlockerDistance(TEXTURE_ACCEPT(shadowMap), vec2 sampleCoords[PCSS_SAMPLE_COUNT], vec2 shadowCoords, vec2 searchSize, float z) {\n\tfloat blockers = 0.0;\n\tfloat averageBlocker = 0.0;\n\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i++) {\n\t\tvec2 offset = sampleCoords[i] * searchSize;\n\t\tvec2 sampleUV = shadowCoords + offset;\n\t#ifdef GL2\n\t\tfloat blocker = textureLod(shadowMap, sampleUV, 0.0).r;\n\t#else\n\t\tfloat blocker = unpackFloat(texture2D(shadowMap, sampleUV));\n\t#endif\t\t\n\t\tfloat isBlocking = step(blocker, z);\n\t\tblockers += isBlocking;\n\t\taverageBlocker += blocker * isBlocking;\n\t}\n\tif (blockers > 0.0)\n\t\treturn averageBlocker /= blockers;\n\treturn -1.0;\n}\nfloat PCSS(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoords, vec4 cameraParams, vec2 shadowSearchArea) {\n\tfloat receiverDepth = shadowCoords.z;\n#ifndef GL2\n\treceiverDepth *= 1.0 / (cameraParams.y - cameraParams.z);\n#endif\n\tvec2 samplePoints[PCSS_SAMPLE_COUNT];\n\tfloat noise = noise( gl_FragCoord.xy ) * 2.0 * PI;\n\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i++) {\n\t\tfloat pcssPresample = pcssDiskSamples[i];\n\t\tsamplePoints[i] = vogelDisk(i, float(PCSS_SAMPLE_COUNT), noise, pcssPresample);\n\t}\n\tfloat averageBlocker = PCSSBlockerDistance(TEXTURE_PASS(shadowMap), samplePoints, shadowCoords.xy, shadowSearchArea, receiverDepth);\n\tif (averageBlocker == -1.0) {\n\t\treturn 1.0;\n\t} else {\n\t\tvec2 filterRadius = ((receiverDepth - averageBlocker) / averageBlocker) * shadowSearchArea * cameraParams.x;\n\t\tfloat shadow = 0.0;\n\t\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i ++)\n\t\t{\n\t\t\tvec2 sampleUV = samplePoints[i] * filterRadius;\n\t\t\tsampleUV = shadowCoords.xy + sampleUV;\n\t\t#ifdef GL2\n\t\t\tfloat depth = textureLod(shadowMap, sampleUV, 0.0).r;\n\t\t#else\n\t\t\tfloat depth = unpackFloat(texture2D(shadowMap, sampleUV));\n\t\t#endif\n\t\t\tshadow += step(receiverDepth, depth);\n\t\t}\n\t\treturn shadow / float(PCSS_SAMPLE_COUNT);\n\t} \n}\nfloat PCSSCubeBlockerDistance(samplerCube shadowMap, vec3 lightDirNorm, vec3 samplePoints[PCSS_SAMPLE_COUNT], float z, float shadowSearchArea) {\n\tfloat blockers = 0.0;\n\tfloat averageBlocker = 0.0;\n\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i++) {\n\t\tvec3 sampleDir = lightDirNorm + samplePoints[i] * shadowSearchArea;\n\t\tsampleDir = normalize(sampleDir);\n\t#ifdef GL2\n\t\tfloat blocker = textureCubeLodEXT(shadowMap, sampleDir, 0.0).r;\n\t#else\n\t\tfloat blocker = unpackFloat(textureCube(shadowMap, sampleDir));\n\t#endif\n\t\tfloat isBlocking = step(blocker, z);\n\t\tblockers += isBlocking;\n\t\taverageBlocker += blocker * isBlocking;\n\t}\n\tif (blockers > 0.0)\n\t\treturn averageBlocker /= float(blockers);\n\treturn -1.0;\n}\nfloat PCSSCube(samplerCube shadowMap, vec4 shadowParams, vec3 shadowCoords, vec4 cameraParams, float shadowSearchArea, vec3 lightDir) {\n\t\n\tvec3 samplePoints[PCSS_SAMPLE_COUNT];\n\tfloat noise = noise( gl_FragCoord.xy ) * 2.0 * PI;\n\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i++) {\n\t\tfloat r = pcssSphereSamples[i];\n\t\tsamplePoints[i] = vogelSphere(i, float(PCSS_SAMPLE_COUNT), noise, r);\n\t}\n\tfloat receiverDepth = length(lightDir) * shadowParams.w + shadowParams.z;\n\tvec3 lightDirNorm = normalize(lightDir);\n\t\n\tfloat averageBlocker = PCSSCubeBlockerDistance(shadowMap, lightDirNorm, samplePoints, receiverDepth, shadowSearchArea);\n\tif (averageBlocker == -1.0) {\n\t\treturn 1.0;\n\t} else {\n\t\tfloat filterRadius = ((receiverDepth - averageBlocker) / averageBlocker) * shadowSearchArea;\n\t\tfloat shadow = 0.0;\n\t\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i++)\n\t\t{\n\t\t\tvec3 offset = samplePoints[i] * filterRadius;\n\t\t\tvec3 sampleDir = lightDirNorm + offset;\n\t\t\tsampleDir = normalize(sampleDir);\n\t\t\t#ifdef GL2\n\t\t\t\tfloat depth = textureCubeLodEXT(shadowMap, sampleDir, 0.0).r;\n\t\t\t#else\n\t\t\t\tfloat depth = unpackFloat(textureCube(shadowMap, sampleDir));\n\t\t\t#endif\n\t\t\tshadow += step(receiverDepth, depth);\n\t\t}\n\t\treturn shadow / float(PCSS_SAMPLE_COUNT);\n\t}\n}\nfloat getShadowPointPCSS(samplerCube shadowMap, vec3 shadowCoord, vec4 shadowParams, vec4 cameraParams, vec2 shadowSearchArea, vec3 lightDir) {\n\treturn PCSSCube(shadowMap, shadowParams, shadowCoord, cameraParams, shadowSearchArea.x, lightDir);\n}\nfloat getShadowSpotPCSS(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, vec4 cameraParams, vec2 shadowSearchArea, vec3 lightDir) {\n\treturn PCSS(TEXTURE_PASS(shadowMap), shadowCoord, cameraParams, shadowSearchArea);\n}\nfloat getShadowPCSS(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, vec4 cameraParams, vec2 shadowSearchArea, vec3 lightDir) {\n\treturn PCSS(TEXTURE_PASS(shadowMap), shadowCoord, cameraParams, shadowSearchArea);\n}\n",shadowSampleCoordPS:"\nvec3 getShadowSampleCoord$LIGHT(mat4 shadowTransform, vec4 shadowParams, vec3 worldPosition, vec3 lightPos, inout vec3 lightDir, vec3 lightDirNorm, vec3 normal) {\n\tvec3 surfacePosition = worldPosition;\n#ifdef SHADOW_SAMPLE_POINT\n\t#ifdef SHADOW_SAMPLE_NORMAL_OFFSET\n\t\tfloat distScale = length(lightDir);\n\t\tsurfacePosition = worldPosition + normal * shadowParams.y * clamp(1.0 - dot(normal, -lightDirNorm), 0.0, 1.0) * distScale;\n\t\tlightDir = surfacePosition - lightPos;\n\t\treturn lightDir;\n\t#endif\n#else\n\t#ifdef SHADOW_SAMPLE_SOURCE_ZBUFFER\n\t\t#ifdef SHADOW_SAMPLE_NORMAL_OFFSET\n\t\t\tsurfacePosition = worldPosition + normal * shadowParams.y;\n\t\t#endif\n\t#else\n\t\t#ifdef SHADOW_SAMPLE_NORMAL_OFFSET\n\t\t\t#ifdef SHADOW_SAMPLE_ORTHO\n\t\t\t\tfloat distScale = 1.0;\n\t\t\t#else\n\t\t\t\tfloat distScale = abs(dot(vPositionW - lightPos, lightDirNorm));\n\t\t\t#endif\n\t\t\tsurfacePosition = worldPosition + normal * shadowParams.y * clamp(1.0 - dot(normal, -lightDirNorm), 0.0, 1.0) * distScale;\n\t\t#endif\n\t#endif\n\tvec4 positionInShadowSpace = shadowTransform * vec4(surfacePosition, 1.0);\n\t#ifdef SHADOW_SAMPLE_ORTHO\n\t\tpositionInShadowSpace.z = saturate(positionInShadowSpace.z) - 0.0001;\n\t#else\n\t\t#ifdef SHADOW_SAMPLE_SOURCE_ZBUFFER\n\t\t\tpositionInShadowSpace.xyz /= positionInShadowSpace.w;\n\t\t#else\n\t\t\tpositionInShadowSpace.xy /= positionInShadowSpace.w;\n\t\t\tpositionInShadowSpace.z = length(lightDir) * shadowParams.w;\n\t\t#endif\n\t#endif\n\t#ifdef SHADOW_SAMPLE_Z_BIAS\n\t\tpositionInShadowSpace.z += getShadowBias(shadowParams.x, shadowParams.z);\n\t#endif\n\tsurfacePosition = positionInShadowSpace.xyz;\n#endif\n\treturn surfacePosition;\n}\n",shadowStandardPS:"\nvec3 lessThan2(vec3 a, vec3 b) {\n\treturn clamp((b - a)*1000.0, 0.0, 1.0);\n}\n#ifndef UNPACKFLOAT\n#define UNPACKFLOAT\n\tfloat unpackFloat(vec4 rgbaDepth) {\n\t\tconst vec4 bitShift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n\t\treturn dot(rgbaDepth, bitShift);\n\t}\n#endif\n#ifdef GL2\nfloat _getShadowPCF3x3(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec3 shadowParams) {\n\tfloat z = shadowCoord.z;\n\tvec2 uv = shadowCoord.xy * shadowParams.x;\n\tfloat shadowMapSizeInv = 1.0 / shadowParams.x;\n\tvec2 base_uv = floor(uv + 0.5);\n\tfloat s = (uv.x + 0.5 - base_uv.x);\n\tfloat t = (uv.y + 0.5 - base_uv.y);\n\tbase_uv -= vec2(0.5);\n\tbase_uv *= shadowMapSizeInv;\n\tfloat sum = 0.0;\n\tfloat uw0 = (3.0 - 2.0 * s);\n\tfloat uw1 = (1.0 + 2.0 * s);\n\tfloat u0 = (2.0 - s) / uw0 - 1.0;\n\tfloat u1 = s / uw1 + 1.0;\n\tfloat vw0 = (3.0 - 2.0 * t);\n\tfloat vw1 = (1.0 + 2.0 * t);\n\tfloat v0 = (2.0 - t) / vw0 - 1.0;\n\tfloat v1 = t / vw1 + 1.0;\n\tu0 = u0 * shadowMapSizeInv + base_uv.x;\n\tv0 = v0 * shadowMapSizeInv + base_uv.y;\n\tu1 = u1 * shadowMapSizeInv + base_uv.x;\n\tv1 = v1 * shadowMapSizeInv + base_uv.y;\n\tsum += uw0 * vw0 * textureShadow(shadowMap, vec3(u0, v0, z));\n\tsum += uw1 * vw0 * textureShadow(shadowMap, vec3(u1, v0, z));\n\tsum += uw0 * vw1 * textureShadow(shadowMap, vec3(u0, v1, z));\n\tsum += uw1 * vw1 * textureShadow(shadowMap, vec3(u1, v1, z));\n\tsum *= 1.0f / 16.0;\n\treturn sum;\n}\nfloat getShadowPCF3x3(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF3x3(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams.xyz);\n}\nfloat getShadowSpotPCF3x3(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF3x3(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams.xyz);\n}\nfloat getShadowPCF1x1(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn textureShadow(shadowMap, shadowCoord);\n}\nfloat getShadowSpotPCF1x1(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn textureShadow(shadowMap, shadowCoord);\n}\n#else\nfloat _xgetShadowPCF3x3(mat3 depthKernel, vec3 shadowCoord, sampler2D shadowMap, vec3 shadowParams) {\n\tmat3 shadowKernel;\n\tvec3 shadowZ = vec3(shadowCoord.z);\n\tshadowKernel[0] = vec3(greaterThan(depthKernel[0], shadowZ));\n\tshadowKernel[1] = vec3(greaterThan(depthKernel[1], shadowZ));\n\tshadowKernel[2] = vec3(greaterThan(depthKernel[2], shadowZ));\n\tvec2 fractionalCoord = fract( shadowCoord.xy * shadowParams.x );\n\tshadowKernel[0] = mix(shadowKernel[0], shadowKernel[1], fractionalCoord.x);\n\tshadowKernel[1] = mix(shadowKernel[1], shadowKernel[2], fractionalCoord.x);\n\tvec4 shadowValues;\n\tshadowValues.x = mix(shadowKernel[0][0], shadowKernel[0][1], fractionalCoord.y);\n\tshadowValues.y = mix(shadowKernel[0][1], shadowKernel[0][2], fractionalCoord.y);\n\tshadowValues.z = mix(shadowKernel[1][0], shadowKernel[1][1], fractionalCoord.y);\n\tshadowValues.w = mix(shadowKernel[1][1], shadowKernel[1][2], fractionalCoord.y);\n\treturn dot( shadowValues, vec4( 1.0 ) ) * 0.25;\n}\nfloat _getShadowPCF3x3(sampler2D shadowMap, vec3 shadowCoord, vec3 shadowParams) {\n\tfloat xoffset = 1.0 / shadowParams.x;\n\tfloat dx0 = -xoffset;\n\tfloat dx1 = xoffset;\n\tmat3 depthKernel;\n\tdepthKernel[0][0] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx0, dx0)));\n\tdepthKernel[0][1] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx0, 0.0)));\n\tdepthKernel[0][2] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx0, dx1)));\n\tdepthKernel[1][0] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(0.0, dx0)));\n\tdepthKernel[1][1] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy));\n\tdepthKernel[1][2] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(0.0, dx1)));\n\tdepthKernel[2][0] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx1, dx0)));\n\tdepthKernel[2][1] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx1, 0.0)));\n\tdepthKernel[2][2] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx1, dx1)));\n\treturn _xgetShadowPCF3x3(depthKernel, shadowCoord, shadowMap, shadowParams);\n}\nfloat getShadowPCF3x3(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF3x3(shadowMap, shadowCoord, shadowParams.xyz);\n}\nfloat getShadowSpotPCF3x3(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF3x3(shadowMap, shadowCoord, shadowParams.xyz);\n}\nfloat _getShadowPCF1x1(sampler2D shadowMap, vec3 shadowCoord) {\n\tfloat shadowSample = unpackFloat(textureShadow(shadowMap, shadowCoord.xy));\n\treturn shadowSample > shadowCoord.z ? 1.0 : 0.0;\n}\nfloat getShadowPCF1x1(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF1x1(shadowMap, shadowCoord);\n}\nfloat getShadowSpotPCF1x1(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF1x1(shadowMap, shadowCoord);\n}\n#endif\n#ifndef WEBGPU\nfloat _getShadowPoint(samplerCube shadowMap, vec4 shadowParams, vec3 dir) {\n\tvec3 tc = normalize(dir);\n\tvec3 tcAbs = abs(tc);\n\tvec4 dirX = vec4(1,0,0, tc.x);\n\tvec4 dirY = vec4(0,1,0, tc.y);\n\tfloat majorAxisLength = tc.z;\n\tif ((tcAbs.x > tcAbs.y) && (tcAbs.x > tcAbs.z)) {\n\t\tdirX = vec4(0,0,1, tc.z);\n\t\tdirY = vec4(0,1,0, tc.y);\n\t\tmajorAxisLength = tc.x;\n\t} else if ((tcAbs.y > tcAbs.x) && (tcAbs.y > tcAbs.z)) {\n\t\tdirX = vec4(1,0,0, tc.x);\n\t\tdirY = vec4(0,0,1, tc.z);\n\t\tmajorAxisLength = tc.y;\n\t}\n\tfloat shadowParamsInFaceSpace = ((1.0/shadowParams.x) * 2.0) * abs(majorAxisLength);\n\tvec3 xoffset = (dirX.xyz * shadowParamsInFaceSpace);\n\tvec3 yoffset = (dirY.xyz * shadowParamsInFaceSpace);\n\tvec3 dx0 = -xoffset;\n\tvec3 dy0 = -yoffset;\n\tvec3 dx1 = xoffset;\n\tvec3 dy1 = yoffset;\n\tmat3 shadowKernel;\n\tmat3 depthKernel;\n\tdepthKernel[0][0] = unpackFloat(textureCube(shadowMap, tc + dx0 + dy0));\n\tdepthKernel[0][1] = unpackFloat(textureCube(shadowMap, tc + dx0));\n\tdepthKernel[0][2] = unpackFloat(textureCube(shadowMap, tc + dx0 + dy1));\n\tdepthKernel[1][0] = unpackFloat(textureCube(shadowMap, tc + dy0));\n\tdepthKernel[1][1] = unpackFloat(textureCube(shadowMap, tc));\n\tdepthKernel[1][2] = unpackFloat(textureCube(shadowMap, tc + dy1));\n\tdepthKernel[2][0] = unpackFloat(textureCube(shadowMap, tc + dx1 + dy0));\n\tdepthKernel[2][1] = unpackFloat(textureCube(shadowMap, tc + dx1));\n\tdepthKernel[2][2] = unpackFloat(textureCube(shadowMap, tc + dx1 + dy1));\n\tvec3 shadowZ = vec3(length(dir) * shadowParams.w + shadowParams.z);\n\tshadowKernel[0] = vec3(lessThan2(depthKernel[0], shadowZ));\n\tshadowKernel[1] = vec3(lessThan2(depthKernel[1], shadowZ));\n\tshadowKernel[2] = vec3(lessThan2(depthKernel[2], shadowZ));\n\tvec2 uv = (vec2(dirX.w, dirY.w) / abs(majorAxisLength)) * 0.5;\n\tvec2 fractionalCoord = fract( uv * shadowParams.x );\n\tshadowKernel[0] = mix(shadowKernel[0], shadowKernel[1], fractionalCoord.x);\n\tshadowKernel[1] = mix(shadowKernel[1], shadowKernel[2], fractionalCoord.x);\n\tvec4 shadowValues;\n\tshadowValues.x = mix(shadowKernel[0][0], shadowKernel[0][1], fractionalCoord.y);\n\tshadowValues.y = mix(shadowKernel[0][1], shadowKernel[0][2], fractionalCoord.y);\n\tshadowValues.z = mix(shadowKernel[1][0], shadowKernel[1][1], fractionalCoord.y);\n\tshadowValues.w = mix(shadowKernel[1][1], shadowKernel[1][2], fractionalCoord.y);\n\treturn 1.0 - dot( shadowValues, vec4( 1.0 ) ) * 0.25;\n}\nfloat getShadowPointPCF3x3(samplerCube shadowMap, vec3 shadowCoord, vec4 shadowParams, vec3 lightDir) {\n\treturn _getShadowPoint(shadowMap, shadowParams, lightDir);\n}\n#endif\n",shadowStandardGL2PS:"\nfloat _getShadowPCF5x5(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec3 shadowParams) {\n\tfloat z = shadowCoord.z;\n\tvec2 uv = shadowCoord.xy * shadowParams.x;\n\tfloat shadowMapSizeInv = 1.0 / shadowParams.x;\n\tvec2 base_uv = floor(uv + 0.5);\n\tfloat s = (uv.x + 0.5 - base_uv.x);\n\tfloat t = (uv.y + 0.5 - base_uv.y);\n\tbase_uv -= vec2(0.5);\n\tbase_uv *= shadowMapSizeInv;\n\tfloat uw0 = (4.0 - 3.0 * s);\n\tfloat uw1 = 7.0;\n\tfloat uw2 = (1.0 + 3.0 * s);\n\tfloat u0 = (3.0 - 2.0 * s) / uw0 - 2.0;\n\tfloat u1 = (3.0 + s) / uw1;\n\tfloat u2 = s / uw2 + 2.0;\n\tfloat vw0 = (4.0 - 3.0 * t);\n\tfloat vw1 = 7.0;\n\tfloat vw2 = (1.0 + 3.0 * t);\n\tfloat v0 = (3.0 - 2.0 * t) / vw0 - 2.0;\n\tfloat v1 = (3.0 + t) / vw1;\n\tfloat v2 = t / vw2 + 2.0;\n\tfloat sum = 0.0;\n\tu0 = u0 * shadowMapSizeInv + base_uv.x;\n\tv0 = v0 * shadowMapSizeInv + base_uv.y;\n\tu1 = u1 * shadowMapSizeInv + base_uv.x;\n\tv1 = v1 * shadowMapSizeInv + base_uv.y;\n\tu2 = u2 * shadowMapSizeInv + base_uv.x;\n\tv2 = v2 * shadowMapSizeInv + base_uv.y;\n\tsum += uw0 * vw0 * textureShadow(shadowMap, vec3(u0, v0, z));\n\tsum += uw1 * vw0 * textureShadow(shadowMap, vec3(u1, v0, z));\n\tsum += uw2 * vw0 * textureShadow(shadowMap, vec3(u2, v0, z));\n\tsum += uw0 * vw1 * textureShadow(shadowMap, vec3(u0, v1, z));\n\tsum += uw1 * vw1 * textureShadow(shadowMap, vec3(u1, v1, z));\n\tsum += uw2 * vw1 * textureShadow(shadowMap, vec3(u2, v1, z));\n\tsum += uw0 * vw2 * textureShadow(shadowMap, vec3(u0, v2, z));\n\tsum += uw1 * vw2 * textureShadow(shadowMap, vec3(u1, v2, z));\n\tsum += uw2 * vw2 * textureShadow(shadowMap, vec3(u2, v2, z));\n\tsum *= 1.0f / 144.0;\n\tsum = saturate(sum);\n\treturn sum;\n}\nfloat getShadowPCF5x5(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF5x5(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams.xyz);\n}\nfloat getShadowSpotPCF5x5(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF5x5(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams.xyz);\n}\n",shadowVSM8PS:"\nfloat calculateVSM8(vec3 moments, float Z, float vsmBias) {\n\tfloat VSMBias = vsmBias;\n\tfloat depthScale = VSMBias * Z;\n\tfloat minVariance1 = depthScale * depthScale;\n\treturn chebyshevUpperBound(moments.xy, Z, minVariance1, 0.1);\n}\nfloat decodeFloatRG(vec2 rg) {\n\treturn rg.y*(1.0/255.0) + rg.x;\n}\nfloat VSM8(TEXTURE_ACCEPT(tex), vec2 texCoords, float resolution, float Z, float vsmBias, float exponent) {\n\tvec4 c = texture2D(tex, texCoords);\n\tvec3 moments = vec3(decodeFloatRG(c.xy), decodeFloatRG(c.zw), 0.0);\n\treturn calculateVSM8(moments, Z, vsmBias);\n}\nfloat getShadowVSM8(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM8(TEXTURE_PASS(shadowMap), shadowCoord.xy, shadowParams.x, shadowCoord.z, shadowParams.y, 0.0);\n}\nfloat getShadowSpotVSM8(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM8(TEXTURE_PASS(shadowMap), shadowCoord.xy, shadowParams.x, length(lightDir) * shadowParams.w + shadowParams.z, shadowParams.y, 0.0);\n}\n",shadowVSM_commonPS:"\nfloat linstep(float a, float b, float v) {\n\treturn saturate((v - a) / (b - a));\n}\nfloat reduceLightBleeding(float pMax, float amount) {\n return linstep(amount, 1.0, pMax);\n}\nfloat chebyshevUpperBound(vec2 moments, float mean, float minVariance, float lightBleedingReduction) {\n\tfloat variance = moments.y - (moments.x * moments.x);\n\tvariance = max(variance, minVariance);\n\tfloat d = mean - moments.x;\n\tfloat pMax = variance / (variance + (d * d));\n\tpMax = reduceLightBleeding(pMax, lightBleedingReduction);\n\treturn (mean <= moments.x ? 1.0 : pMax);\n}\nfloat calculateEVSM(vec3 moments, float Z, float vsmBias, float exponent) {\n\tZ = 2.0 * Z - 1.0;\n\tfloat warpedDepth = exp(exponent * Z);\n\tmoments.xy += vec2(warpedDepth, warpedDepth*warpedDepth) * (1.0 - moments.z);\n\tfloat VSMBias = vsmBias;\n\tfloat depthScale = VSMBias * exponent * warpedDepth;\n\tfloat minVariance1 = depthScale * depthScale;\n\treturn chebyshevUpperBound(moments.xy, warpedDepth, minVariance1, 0.1);\n}\n",skinBatchConstVS:"\nattribute float vertex_boneIndices;\nuniform vec4 matrix_pose[BONE_LIMIT * 3];\nmat4 getBoneMatrix(const in float i) {\n\tvec4 v1 = matrix_pose[int(3.0 * i)];\n\tvec4 v2 = matrix_pose[int(3.0 * i + 1.0)];\n\tvec4 v3 = matrix_pose[int(3.0 * i + 2.0)];\n\treturn mat4(\n\t\tv1.x, v2.x, v3.x, 0,\n\t\tv1.y, v2.y, v3.y, 0,\n\t\tv1.z, v2.z, v3.z, 0,\n\t\tv1.w, v2.w, v3.w, 1\n\t);\n}\n",skinBatchTexVS:"\nattribute float vertex_boneIndices;\nuniform highp sampler2D texture_poseMap;\nuniform vec4 texture_poseMapSize;\nmat4 getBoneMatrix(const in float i) {\n\tfloat j = i * 3.0;\n\tfloat dx = texture_poseMapSize.z;\n\tfloat dy = texture_poseMapSize.w;\n\tfloat y = floor(j * dx);\n\tfloat x = j - (y * texture_poseMapSize.x);\n\ty = dy * (y + 0.5);\n\tvec4 v1 = texture2D(texture_poseMap, vec2(dx * (x + 0.5), y));\n\tvec4 v2 = texture2D(texture_poseMap, vec2(dx * (x + 1.5), y));\n\tvec4 v3 = texture2D(texture_poseMap, vec2(dx * (x + 2.5), y));\n\treturn mat4(\n\t\tv1.x, v2.x, v3.x, 0,\n\t\tv1.y, v2.y, v3.y, 0,\n\t\tv1.z, v2.z, v3.z, 0,\n\t\tv1.w, v2.w, v3.w, 1\n\t);\n}\n",skinConstVS:"\nattribute vec4 vertex_boneWeights;\nattribute vec4 vertex_boneIndices;\nuniform vec4 matrix_pose[BONE_LIMIT * 3];\nvoid getBoneMatrix(const in float i, out vec4 v1, out vec4 v2, out vec4 v3) {\n\tv1 = matrix_pose[int(3.0 * i)];\n\tv2 = matrix_pose[int(3.0 * i + 1.0)];\n\tv3 = matrix_pose[int(3.0 * i + 2.0)];\n}\nmat4 getSkinMatrix(const in vec4 indices, const in vec4 weights) {\n\tvec4 a1, a2, a3;\n\tgetBoneMatrix(indices.x, a1, a2, a3);\n\tvec4 b1, b2, b3;\n\tgetBoneMatrix(indices.y, b1, b2, b3);\n\tvec4 c1, c2, c3;\n\tgetBoneMatrix(indices.z, c1, c2, c3);\n\tvec4 d1, d2, d3;\n\tgetBoneMatrix(indices.w, d1, d2, d3);\n\tvec4 v1 = a1 * weights.x + b1 * weights.y + c1 * weights.z + d1 * weights.w;\n\tvec4 v2 = a2 * weights.x + b2 * weights.y + c2 * weights.z + d2 * weights.w;\n\tvec4 v3 = a3 * weights.x + b3 * weights.y + c3 * weights.z + d3 * weights.w;\n\tfloat one = dot(weights, vec4(1.0));\n\treturn mat4(\n\t\tv1.x, v2.x, v3.x, 0,\n\t\tv1.y, v2.y, v3.y, 0,\n\t\tv1.z, v2.z, v3.z, 0,\n\t\tv1.w, v2.w, v3.w, one\n\t);\n}\n",skinTexVS:"\nattribute vec4 vertex_boneWeights;\nattribute vec4 vertex_boneIndices;\nuniform highp sampler2D texture_poseMap;\nuniform vec4 texture_poseMapSize;\nvoid getBoneMatrix(const in float index, out vec4 v1, out vec4 v2, out vec4 v3) {\n\tfloat i = float(index);\n\tfloat j = i * 3.0;\n\tfloat dx = texture_poseMapSize.z;\n\tfloat dy = texture_poseMapSize.w;\n\t\n\tfloat y = floor(j * dx);\n\tfloat x = j - (y * texture_poseMapSize.x);\n\ty = dy * (y + 0.5);\n\tv1 = texture2D(texture_poseMap, vec2(dx * (x + 0.5), y));\n\tv2 = texture2D(texture_poseMap, vec2(dx * (x + 1.5), y));\n\tv3 = texture2D(texture_poseMap, vec2(dx * (x + 2.5), y));\n}\nmat4 getSkinMatrix(const in vec4 indices, const in vec4 weights) {\n\tvec4 a1, a2, a3;\n\tgetBoneMatrix(indices.x, a1, a2, a3);\n\tvec4 b1, b2, b3;\n\tgetBoneMatrix(indices.y, b1, b2, b3);\n\tvec4 c1, c2, c3;\n\tgetBoneMatrix(indices.z, c1, c2, c3);\n\tvec4 d1, d2, d3;\n\tgetBoneMatrix(indices.w, d1, d2, d3);\n\tvec4 v1 = a1 * weights.x + b1 * weights.y + c1 * weights.z + d1 * weights.w;\n\tvec4 v2 = a2 * weights.x + b2 * weights.y + c2 * weights.z + d2 * weights.w;\n\tvec4 v3 = a3 * weights.x + b3 * weights.y + c3 * weights.z + d3 * weights.w;\n\tfloat one = dot(weights, vec4(1.0));\n\treturn mat4(\n\t\tv1.x, v2.x, v3.x, 0,\n\t\tv1.y, v2.y, v3.y, 0,\n\t\tv1.z, v2.z, v3.z, 0,\n\t\tv1.w, v2.w, v3.w, one\n\t);\n}\n",skyboxEnvPS:"\nvarying vec3 vViewDir;\nuniform sampler2D texture_envAtlas;\nuniform float mipLevel;\nvoid main(void) {\n\tvec3 dir = vViewDir * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(normalize(dir));\n\tvec3 linear = SKYBOX_DECODE_FNC(texture2D(texture_envAtlas, mapRoughnessUv(uv, mipLevel)));\n\tgl_FragColor = vec4(gammaCorrectOutput(toneMap(processEnvironment(linear))), 1.0);\n}\n",skyboxHDRPS:"\nvarying vec3 vViewDir;\nuniform samplerCube texture_cubeMap;\n#ifdef SKYMESH\n\tvarying vec3 vWorldPos;\n\tuniform mat3 cubeMapRotationMatrix;\n\tuniform vec3 projectedSkydomeCenter;\n#endif\nvoid main(void) {\n\t#ifdef SKYMESH\n\t\tvec3 envDir = normalize(vWorldPos - projectedSkydomeCenter);\n\t\tvec3 dir = envDir * cubeMapRotationMatrix;\n\t#else\n\t\tvec3 dir = vViewDir;\n\t#endif\n\tdir.x *= -1.0;\n\tvec3 linear = SKYBOX_DECODE_FNC(textureCube(texture_cubeMap, fixSeamsStatic(dir, SKYBOX_MIP)));\n\tgl_FragColor = vec4(gammaCorrectOutput(toneMap(processEnvironment(linear))), 1.0);\n}\n",skyboxVS:"\nattribute vec3 aPosition;\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform mat4 matrix_projectionSkybox;\nuniform mat3 cubeMapRotationMatrix;\nvarying vec3 vViewDir;\n#ifdef SKYMESH\n\tuniform mat4 matrix_model;\n\tvarying vec3 vWorldPos;\n#endif\nvoid main(void) {\n\tmat4 view = matrix_view;\n\t#ifdef SKYMESH\n\t\tvec4 worldPos = matrix_model * vec4(aPosition, 1.0);\n\t\tvWorldPos = worldPos.xyz;\n\t\tgl_Position = matrix_projectionSkybox * view * worldPos;\n\t#else\n\t\tview[3][0] = view[3][1] = view[3][2] = 0.0;\n\t\tgl_Position = matrix_projectionSkybox * view * vec4(aPosition, 1.0);\n\t\tvViewDir = aPosition * cubeMapRotationMatrix;\n\t#endif\n\tgl_Position.z = gl_Position.w - 1.0e-7;\n}\n",specularPS:"\n#ifdef MAPCOLOR\nuniform vec3 material_specular;\n#endif\nvoid getSpecularity() {\n\tvec3 specularColor = vec3(1,1,1);\n\t#ifdef MAPCOLOR\n\tspecularColor *= material_specular;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tspecularColor *= $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tspecularColor *= saturate(vVertexColor.$VC);\n\t#endif\n\tdSpecularity = specularColor;\n}\n",sphericalPS:"\nconst float PI = 3.141592653589793;\nvec2 toSpherical(vec3 dir) {\n\treturn vec2(dir.xz == vec2(0.0) ? 0.0 : atan(dir.x, dir.z), asin(dir.y));\n}\nvec2 toSphericalUv(vec3 dir) {\n\tvec2 uv = toSpherical(dir) / vec2(PI * 2.0, PI) + 0.5;\n\treturn vec2(uv.x, 1.0 - uv.y);\n}\n",specularityFactorPS:"\n#ifdef MAPFLOAT\nuniform float material_specularityFactor;\n#endif\nvoid getSpecularityFactor() {\n\tfloat specularityFactor = 1.0;\n\t#ifdef MAPFLOAT\n\tspecularityFactor *= material_specularityFactor;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tspecularityFactor *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tspecularityFactor *= saturate(vVertexColor.$VC);\n\t#endif\n\tdSpecularityFactor = specularityFactor;\n}\n",spotPS:"\nfloat getSpotEffect(vec3 lightSpotDir, float lightInnerConeAngle, float lightOuterConeAngle, vec3 lightDirNorm) {\n\tfloat cosAngle = dot(lightDirNorm, lightSpotDir);\n\treturn smoothstep(lightOuterConeAngle, lightInnerConeAngle, cosAngle);\n}\n",startPS:"\nvoid main(void) {\n\tdReflection = vec4(0);\n\t#ifdef LIT_CLEARCOAT\n\tccSpecularLight = vec3(0);\n\tccReflection = vec3(0);\n\t#endif\n",startVS:"\nvoid main(void) {\n\tgl_Position = getPosition();\n",startNineSlicedPS:"\n\tnineSlicedUv = vUv0;\n\tnineSlicedUv.y = 1.0 - nineSlicedUv.y;\n",startNineSlicedTiledPS:"\n\tvec2 tileMask = step(vMask, vec2(0.99999));\n\tvec2 tileSize = 0.5 * (innerOffset.xy + innerOffset.zw);\n\tvec2 tileScale = vec2(1.0) / (vec2(1.0) - tileSize);\n\tvec2 clampedUv = mix(innerOffset.xy * 0.5, vec2(1.0) - innerOffset.zw * 0.5, fract((vTiledUv - tileSize) * tileScale));\n\tclampedUv = clampedUv * atlasRect.zw + atlasRect.xy;\n\tnineSlicedUv = vUv0 * tileMask + clampedUv * (vec2(1.0) - tileMask);\n\tnineSlicedUv.y = 1.0 - nineSlicedUv.y;\n\t\n",storeEVSMPS:"\nfloat exponent = VSM_EXPONENT;\ndepth = 2.0 * depth - 1.0;\ndepth = exp(exponent * depth);\ngl_FragColor = vec4(depth, depth*depth, 1.0, 1.0);\n",tangentBinormalVS:"\nvec3 getTangent() {\n\treturn normalize(dNormalMatrix * vertex_tangent.xyz);\n}\nvec3 getBinormal() {\n\treturn cross(vNormalW, vTangentW) * vertex_tangent.w;\n}\n",TBNPS:"\nvoid getTBN(vec3 tangent, vec3 binormal, vec3 normal) {\n\tdTBN = mat3(normalize(tangent), normalize(binormal), normalize(normal));\n}\n",TBNderivativePS:"\nuniform float tbnBasis;\nvoid getTBN(vec3 tangent, vec3 binormal, vec3 normal) {\n\tvec2 uv = $UV;\n\tvec3 dp1 = dFdx( vPositionW );\n\tvec3 dp2 = dFdy( vPositionW );\n\tvec2 duv1 = dFdx( uv );\n\tvec2 duv2 = dFdy( uv );\n\tvec3 dp2perp = cross( dp2, normal );\n\tvec3 dp1perp = cross( normal, dp1 );\n\tvec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\n\tvec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\n\tfloat denom = max( dot(T,T), dot(B,B) );\n\tfloat invmax = (denom == 0.0) ? 0.0 : tbnBasis / sqrt( denom );\n\tdTBN = mat3(T * invmax, -B * invmax, normal );\n}\n",TBNfastPS:"\nvoid getTBN(vec3 tangent, vec3 binormal, vec3 normal) {\n\tdTBN = mat3(tangent, binormal, normal);\n}\n",TBNObjectSpacePS:"\nvoid getTBN(vec3 tangent, vec3 binormal, vec3 normal) {\n\tvec3 B = cross(normal, vObjectSpaceUpW);\n\tvec3 T = cross(normal, B);\n\tif (dot(B,B)==0.0)\n\t{\n\t\tfloat major=max(max(normal.x, normal.y), normal.z);\n\t\tif (normal.x == major)\n\t\t{\n\t\t\tB=cross(normal, vec3(0,1,0));\n\t\t\tT=cross(normal, B);\n\t\t}\n\t\telse if (normal.y == major)\n\t\t{\n\t\t\tB=cross(normal, vec3(0,0,1));\n\t\t\tT=cross(normal, B);\n\t\t}\n\t\telse if (normal.z == major)\n\t\t{\n\t\t\tB=cross(normal, vec3(1,0,0));\n\t\t\tT=cross(normal, B);\n\t\t}\n\t}\n\tdTBN = mat3(normalize(T), normalize(B), normalize(normal));\n}\n",textureSamplePS:"\nvec4 texture2DSRGB(sampler2D tex, vec2 uv) {\n\treturn gammaCorrectInput(texture2D(tex, uv));\n}\nvec4 texture2DSRGB(sampler2D tex, vec2 uv, float bias) {\n\treturn gammaCorrectInput(texture2D(tex, uv, bias));\n}\nvec3 texture2DRGBM(sampler2D tex, vec2 uv) {\n\treturn decodeRGBM(texture2D(tex, uv));\n}\nvec3 texture2DRGBM(sampler2D tex, vec2 uv, float bias) {\n\treturn decodeRGBM(texture2D(tex, uv, bias));\n}\nvec3 texture2DRGBE(sampler2D tex, vec2 uv) {\n\treturn decodeRGBM(texture2D(tex, uv));\n}\nvec3 texture2DRGBE(sampler2D tex, vec2 uv, float bias) {\n\treturn decodeRGBM(texture2D(tex, uv, bias));\n}\n",thicknessPS:"\n#ifdef MAPFLOAT\nuniform float material_thickness;\n#endif\nvoid getThickness() {\n\tdThickness = 1.0;\n\t#ifdef MAPFLOAT\n\tdThickness *= material_thickness;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tdThickness *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tdThickness *= saturate(vVertexColor.$VC);\n\t#endif\n}\n",tonemappingAcesPS:"\nuniform float exposure;\nvec3 toneMap(vec3 color) {\n\tfloat tA = 2.51;\n\tfloat tB = 0.03;\n\tfloat tC = 2.43;\n\tfloat tD = 0.59;\n\tfloat tE = 0.14;\n\tvec3 x = color * exposure;\n\treturn (x*(tA*x+tB))/(x*(tC*x+tD)+tE);\n}\n",tonemappingAces2PS:"\nuniform float exposure;\nconst mat3 ACESInputMat = mat3(\n\t0.59719, 0.35458, 0.04823,\n\t0.07600, 0.90834, 0.01566,\n\t0.02840, 0.13383, 0.83777\n);\nconst mat3 ACESOutputMat = mat3(\n\t 1.60475, -0.53108, -0.07367,\n\t-0.10208, 1.10813, -0.00605,\n\t-0.00327, -0.07276, 1.07602\n);\nvec3 RRTAndODTFit(vec3 v) {\n\tvec3 a = v * (v + 0.0245786) - 0.000090537;\n\tvec3 b = v * (0.983729 * v + 0.4329510) + 0.238081;\n\treturn a / b;\n}\nvec3 toneMap(vec3 color) {\n\tcolor *= exposure / 0.6;\n\tcolor = color * ACESInputMat;\n\tcolor = RRTAndODTFit(color);\n\tcolor = color * ACESOutputMat;\n\tcolor = clamp(color, 0.0, 1.0);\n\treturn color;\n}\n",tonemappingFilmicPS:"\nconst float A = 0.15;\nconst float B = 0.50;\nconst float C = 0.10;\nconst float D = 0.20;\nconst float E = 0.02;\nconst float F = 0.30;\nconst float W = 11.2;\nuniform float exposure;\nvec3 uncharted2Tonemap(vec3 x) {\n return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;\n}\nvec3 toneMap(vec3 color) {\n\tcolor = uncharted2Tonemap(color * exposure);\n\tvec3 whiteScale = 1.0 / uncharted2Tonemap(vec3(W,W,W));\n\tcolor = color * whiteScale;\n\treturn color;\n}\n",tonemappingHejlPS:"\nuniform float exposure;\nvec3 toneMap(vec3 color) {\n\tcolor *= exposure;\n\tconst float A = 0.22, B = 0.3, C = .1, D = 0.2, E = .01, F = 0.3;\n\tconst float Scl = 1.25;\n\tvec3 h = max( vec3(0.0), color - vec3(0.004) );\n\treturn (h*((Scl*A)*h+Scl*vec3(C*B,C*B,C*B))+Scl*vec3(D*E,D*E,D*E)) / (h*(A*h+vec3(B,B,B))+vec3(D*F,D*F,D*F)) - Scl*vec3(E/F,E/F,E/F);\n}\n",tonemappingLinearPS:"\nuniform float exposure;\nvec3 toneMap(vec3 color) {\n\treturn color * exposure;\n}\n",tonemappingNeutralPS:"\nuniform float exposure;\nvec3 toneMap(vec3 color) {\n\tcolor *= exposure;\n\tfloat startCompression = 0.8 - 0.04;\n\tfloat desaturation = 0.15;\n\tfloat x = min(color.r, min(color.g, color.b));\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max(color.r, max(color.g, color.b));\n\tif (peak < startCompression) return color;\n\tfloat d = 1. - startCompression;\n\tfloat newPeak = 1. - d * d / (peak + d - startCompression);\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);\n\treturn mix(color, newPeak * vec3(1, 1, 1), g);\n}\n",tonemappingNonePS:"\nvec3 toneMap(vec3 color) {\n\treturn color;\n}\n",transformVS:"\n#ifdef PIXELSNAP\nuniform vec4 uScreenSize;\n#endif\n#ifdef SCREENSPACE\nuniform float projectionFlipY;\n#endif\n#ifdef MORPHING\nuniform vec4 morph_weights_a;\nuniform vec4 morph_weights_b;\n#endif\n#ifdef MORPHING_TEXTURE_BASED\n\tuniform vec4 morph_tex_params;\n\t#ifdef WEBGPU\n\t\tivec2 getTextureMorphCoords() {\n\t\t\tivec2 textureSize = ivec2(morph_tex_params.xy);\n\t\t\tint morphGridV = int(morph_vertex_id / textureSize.x);\n\t\t\tint morphGridU = int(morph_vertex_id - (morphGridV * textureSize.x));\n\t\t\tmorphGridV = textureSize.y - morphGridV - 1;\n\t\t\treturn ivec2(morphGridU, morphGridV);\n\t\t}\n\t#else\n\t\tvec2 getTextureMorphCoords() {\n\t\t\tvec2 textureSize = morph_tex_params.xy;\n\t\t\tvec2 invTextureSize = morph_tex_params.zw;\n\t\t\tfloat morphGridV = floor(morph_vertex_id * invTextureSize.x);\n\t\t\tfloat morphGridU = morph_vertex_id - (morphGridV * textureSize.x);\n\t\t\treturn vec2(morphGridU, morphGridV) * invTextureSize + (0.5 * invTextureSize);\n\t\t}\n\t#endif\n#endif\n#ifdef MORPHING_TEXTURE_BASED_POSITION\nuniform highp sampler2D morphPositionTex;\n#endif\nmat4 getModelMatrix() {\n\t#ifdef DYNAMICBATCH\n\treturn getBoneMatrix(vertex_boneIndices);\n\t#elif defined(SKIN)\n\treturn matrix_model * getSkinMatrix(vertex_boneIndices, vertex_boneWeights);\n\t#elif defined(INSTANCING)\n\treturn mat4(instance_line1, instance_line2, instance_line3, instance_line4);\n\t#else\n\treturn matrix_model;\n\t#endif\n}\nvec4 getPosition() {\n\tdModelMatrix = getModelMatrix();\n\tvec3 localPos = vertex_position;\n\t#ifdef NINESLICED\n\tlocalPos.xz *= outerScale;\n\tvec2 positiveUnitOffset = clamp(vertex_position.xz, vec2(0.0), vec2(1.0));\n\tvec2 negativeUnitOffset = clamp(-vertex_position.xz, vec2(0.0), vec2(1.0));\n\tlocalPos.xz += (-positiveUnitOffset * innerOffset.xy + negativeUnitOffset * innerOffset.zw) * vertex_texCoord0.xy;\n\tvTiledUv = (localPos.xz - outerScale + innerOffset.xy) * -0.5 + 1.0;\n\tlocalPos.xz *= -0.5;\n\tlocalPos = localPos.xzy;\n\t#endif\n\t#ifdef MORPHING\n\t#ifdef MORPHING_POS03\n\tlocalPos.xyz += morph_weights_a[0] * morph_pos0;\n\tlocalPos.xyz += morph_weights_a[1] * morph_pos1;\n\tlocalPos.xyz += morph_weights_a[2] * morph_pos2;\n\tlocalPos.xyz += morph_weights_a[3] * morph_pos3;\n\t#endif\n\t#ifdef MORPHING_POS47\n\tlocalPos.xyz += morph_weights_b[0] * morph_pos4;\n\tlocalPos.xyz += morph_weights_b[1] * morph_pos5;\n\tlocalPos.xyz += morph_weights_b[2] * morph_pos6;\n\tlocalPos.xyz += morph_weights_b[3] * morph_pos7;\n\t#endif\n\t#endif\n\t#ifdef MORPHING_TEXTURE_BASED_POSITION\n\t\t#ifdef WEBGPU\n\t\t\tivec2 morphUV = getTextureMorphCoords();\n\t\t\tvec3 morphPos = texelFetch(morphPositionTex, ivec2(morphUV), 0).xyz;\n\t\t#else\n\t\t\tvec2 morphUV = getTextureMorphCoords();\n\t\t\tvec3 morphPos = texture2D(morphPositionTex, morphUV).xyz;\n\t\t#endif\n\t\tlocalPos += morphPos;\n\t#endif\n\tvec4 posW = dModelMatrix * vec4(localPos, 1.0);\n\t#ifdef SCREENSPACE\n\tposW.zw = vec2(0.0, 1.0);\n\t#endif\n\tdPositionW = posW.xyz;\n\tvec4 screenPos;\n\t#ifdef UV1LAYOUT\n\tscreenPos = vec4(vertex_texCoord1.xy * 2.0 - 1.0, 0.5, 1);\n\t\t#ifdef WEBGPU\n\t\tscreenPos.y *= -1.0;\n\t\t#endif\n\t#else\n\t#ifdef SCREENSPACE\n\tscreenPos = posW;\n\tscreenPos.y *= projectionFlipY;\n\t#else\n\tscreenPos = matrix_viewProjection * posW;\n\t#endif\n\t#ifdef PIXELSNAP\n\tscreenPos.xy = (screenPos.xy * 0.5) + 0.5;\n\tscreenPos.xy *= uScreenSize.xy;\n\tscreenPos.xy = floor(screenPos.xy);\n\tscreenPos.xy *= uScreenSize.zw;\n\tscreenPos.xy = (screenPos.xy * 2.0) - 1.0;\n\t#endif\n\t#endif\n\treturn screenPos;\n}\nvec3 getWorldPosition() {\n\treturn dPositionW;\n}\n",transformDeclVS:"\nattribute vec3 vertex_position;\nuniform mat4 matrix_model;\nuniform mat4 matrix_viewProjection;\nvec3 dPositionW;\nmat4 dModelMatrix;\n",transmissionPS:"\n#ifdef MAPFLOAT\nuniform float material_refraction;\n#endif\nvoid getRefraction() {\n\tfloat refraction = 1.0;\n\t#ifdef MAPFLOAT\n\trefraction = material_refraction;\n\t#endif\n\t#ifdef MAPTEXTURE\n\trefraction *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\trefraction *= saturate(vVertexColor.$VC);\n\t#endif\n\tdTransmission = refraction;\n}\n",twoSidedLightingPS:"\nuniform float twoSidedLightingNegScaleFactor;\nvoid handleTwoSidedLighting() {\n\tdTBN[2] *= gl_FrontFacing ? twoSidedLightingNegScaleFactor : -twoSidedLightingNegScaleFactor;\n}\n",uv0VS:"\n#ifdef NINESLICED\nvec2 getUv0() {\n\tvec2 uv = vertex_position.xz;\n\tvec2 positiveUnitOffset = clamp(vertex_position.xz, vec2(0.0), vec2(1.0));\n\tvec2 negativeUnitOffset = clamp(-vertex_position.xz, vec2(0.0), vec2(1.0));\n\tuv += (-positiveUnitOffset * innerOffset.xy + negativeUnitOffset * innerOffset.zw) * vertex_texCoord0.xy;\n\tuv = uv * -0.5 + 0.5;\n\tuv = uv * atlasRect.zw + atlasRect.xy;\n\tvMask = vertex_texCoord0.xy;\n\treturn uv;\n}\n#else\nvec2 getUv0() {\n\treturn vertex_texCoord0;\n}\n#endif\n",uv1VS:"\nvec2 getUv1() {\n\treturn vertex_texCoord1;\n}\n",viewDirPS:"\nvoid getViewDir() {\n\tdViewDirW = normalize(view_position - vPositionW);\n}\n",viewNormalVS:"\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nvec3 getViewNormal() {\n\treturn mat3(matrix_view) * vNormalW;\n}\n",webgpuPS:Er,webgpuVS:Ar},Io=new gn;function Do(t){return Io.get(t)}function Lo(t,e){Io.get(t,(function(){return e}))}var ko=function(){function t(){}return t.begin=function(){return"void main(void)\n{\n"},t.end=function(){return"}\n"},t.skinCode=function(t,e){return void 0===e&&(e=Ro),t.supportsBoneTextures?e.skinTexVS:"#define BONE_LIMIT "+t.getBoneLimit()+"\n"+e.skinConstVS},t.fogCode=function(t,e){return void 0===e&&(e=Ro),"linear"===t?e.fogLinearPS?e.fogLinearPS:Ro.fogLinearPS:"exp"===t?e.fogExpPS?e.fogExpPS:Ro.fogExpPS:"exp2"===t?e.fogExp2PS?e.fogExp2PS:Ro.fogExp2PS:e.fogNonePS?e.fogNonePS:Ro.fogNonePS},t.gammaCode=function(t,e){return void 0===e&&(e=Ro),1===t||2===t?e.gamma2_2PS?e.gamma2_2PS:Ro.gamma2_2PS:3===t?"#define HDR\n"+(e.gamma2_2PS?e.gamma2_2PS:Ro.gamma2_2PS):e.gamma1_0PS?e.gamma1_0PS:Ro.gamma1_0PS},t.tonemapCode=function(t,e){var i,n,s,r,a,o,h;switch(void 0===e&&(e=Ro),t){case 1:return null!=(i=e.tonemappingFilmicPS)?i:Ro.tonemappingFilmicPS;case 0:return null!=(n=e.tonemappingLinearPS)?n:Ro.tonemappingLinearPS;case 2:return null!=(s=e.tonemappingHejlPS)?s:Ro.tonemappingHejlPS;case 3:return null!=(r=e.tonemappingAcesPS)?r:Ro.tonemappingAcesPS;case 4:return null!=(a=e.tonemappingAces2PS)?a:Ro.tonemappingAces2PS;case 5:return null!=(o=e.tonemappingNeutralPS)?o:Ro.tonemappingNeutralPS}return null!=(h=e.tonemapingNonePS)?h:Ro.tonemappingNonePS},t}();function Oo(t,e,i,n,s){return void 0===n&&(n=!1),void 0===s&&(s={}),"boolean"==typeof n?s.useTransformFeedback=n:"object"==typeof n&&(s=y({},s,n)),new zs(t,Pr.createDefinition(t,y({},s,{name:e+"_"+i,vertexCode:Ro[e],fragmentCode:Ro[i]})))}function Fo(t,e,i,n,s,r,a){void 0===r&&(r=!1),void 0===a&&(a={}),"boolean"==typeof r?a.useTransformFeedback=r:"object"==typeof r&&(a=y({},a,r));var o=Do(t),h=o.getCachedShader(n);return h||(h=new zs(t,Pr.createDefinition(t,y({},a,{name:n,vertexCode:e,fragmentCode:i,attributes:s}))),o.setCachedShader(n,h)),h}var Bo=function(t){function e(e,i){var n;return(n=t.call(this)||this).key=e,n.shaderDefinition=i,n}x(e,t);var i=e.prototype;return i.generateKey=function(t){return this.key},i.createShaderDefinition=function(t,e){return this.shaderDefinition},e}(ko);function No(t,e){var i,n=t.definition,s=(null!=(i=n.name)?i:"shader")+"-id-"+t.id,r=new Bo(s,n),a="shader",o=Do(t.device);o.register(a,r);var h=o.getProgram(a,{},e);return t.definition.shaderLanguage===wi&&(h.meshUniformBufferFormat=n.meshUniformBufferFormat,h.meshBindGroupFormat=n.meshBindGroupFormat),o.unregister(a),h}Ro.createShader=Oo,Ro.createShaderFromCode=Fo;var Uo={type:5,base:0,count:4,indexed:!1},zo=new Rt,Vo=new Rt,Go=function(){function t(t){this.uniformBuffer=void 0,this.bindGroup=void 0;var e=t.device;if(this.shader=t,e.supportsUniformBuffers){var i=new Zr;this.shader=No(t,i);var n=this.shader.meshUniformBufferFormat;n&&(this.uniformBuffer=new qs(e,n,!1));var s=this.shader.meshBindGroupFormat;this.bindGroup=new Gs(e,s,this.uniformBuffer)}}var e=t.prototype;return e.destroy=function(){var t,e;null==(t=this.uniformBuffer)||t.destroy(),this.uniformBuffer=null,null==(e=this.bindGroup)||e.destroy(),this.bindGroup=null},e.render=function(t,e){var i,n=this.shader.device;t&&(zo.set(n.vx,n.vy,n.vw,n.vh),Vo.set(n.sx,n.sy,n.sw,n.sh),e=null!=(i=e)?i:t,n.setViewport(t.x,t.y,t.z,t.w),n.setScissor(e.x,e.y,e.z,e.w));n.setVertexBuffer(n.quadVertexBuffer,0);var s=this.shader;if(n.setShader(s),n.supportsUniformBuffers){var r,a=this.bindGroup;null==(r=a.defaultUniformBuffer)||r.update(),a.update(),n.setBindGroup(0,a)}n.draw(Uo),t&&(n.setViewport(zo.x,zo.y,zo.z,zo.w),n.setScissor(Vo.x,Vo.y,Vo.z,Vo.w))},t}(),Ho=function(t){function e(e,i,n,s){var r;return(r=t.call(this,e)||this).quad=i,r.rect=n,r.scissorRect=s,r}return x(e,t),e.prototype.execute=function(){var t=this.device;t.setCullMode(0),t.setDepthState(on.NODEPTH),t.setStencilState(null,null),this.quad.render(this.rect,this.scissorRect)},e}(Kr),Wo=new Rt;function Xo(t,e,i,n,s){var r=new Go(i);n||((n=Wo).x=0,n.y=0,n.z=e?e.width:t.width,n.w=e?e.height:t.height);var a=new Ho(t,r,n,s);a.init(e),a.colorOps.clear=!1,a.depthStencilOps.clearDepth=!1,t.isWebGPU&&null===e&&t.samples>1&&(a.colorOps.store=!0),a.render(),r.destroy()}var jo=new gn,qo=function(){function t(t,e,i){void 0===i&&(i={}),this.index=void 0,this.name=void 0,this.shaderDefines=void 0,this.name=t,this.index=e,Object.assign(this,i),this.shaderDefines=this.buildShaderDefines()}return t.prototype.buildShaderDefines=function(){var t;return this.isShadow?t="SHADOW":this.isForward?t="FORWARD":2===this.index?t="DEPTH":3===this.index&&(t="PICK"),(t?"#define "+t+"_PASS\n":"")+("#define "+this.name.toUpperCase()+"_PASS\n")},t}(),Yo=function(){function t(){var t=this;this.passesNamed=new Map,this.passesIndexed=[],this.nextIndex=0;var e=function(e,i,n){t.allocate(e,n)};e("forward",0,{isForward:!0}),e("forward_hdr",0,{isForward:!0}),e("depth"),e("pick"),e("shadow"),e("prepass")}t.get=function(e){return jo.get(e,(function(){return new t}))};var e=t.prototype;return e.allocate=function(t,e){var i=this.passesNamed.get(t);return void 0===i&&(i=new qo(t,this.nextIndex,e),this.passesNamed.set(i.name,i),this.passesIndexed[i.index]=i,this.nextIndex++),i},e.getByIndex=function(t){return this.passesIndexed[t]},e.getByName=function(t){return this.passesNamed.get(t)},t}(),Ko=function(t){function e(){return t.apply(this,arguments)||this}x(e,t);var i=e.prototype;return i.generateKey=function(t){var e="basic";return t.fog&&(e+="_fog"),t.alphaTest&&(e+="_atst"),t.vertexColors&&(e+="_vcol"),t.diffuseMap&&(e+="_diff"),t.skin&&(e+="_skin"),t.screenSpace&&(e+="_ss"),t.useInstancing&&(e+="_inst"),t.useMorphPosition&&(e+="_morphp"),t.useMorphNormal&&(e+="_morphn"),t.useMorphTextureBased&&(e+="_morpht"),e+="_"+t.pass},i.createAttributesDefinition=function(t,e){var i={vertex_position:Le};e.skin&&(i.vertex_boneWeights=Fe,i.vertex_boneIndices=Be),e.vertexColors&&(i.vertex_color=Ne),e.diffuseMap&&(i.vertex_texCoord0=ze),t.attributes=i},i.createVertexDefinition=function(t,e,i,n){var s=new Map,r=new Map;s.set("shaderPassDefines",n.shaderDefines),s.set("transformDeclVS",Ro.transformDeclVS),s.set("transformVS",Ro.transformVS),s.set("skinCode",ko.skinCode(t)),i.skin&&r.set("SKIN",!0),i.vertexColors&&r.set("VERTEX_COLORS",!0),i.diffuseMap&&r.set("DIFFUSE_MAP",!0),e.vertexCode='\n\n #include "shaderPassDefines"\n #include "transformDeclVS"\n\n #ifdef SKIN\n #include "skinCode"\n #endif\n\n #include "transformVS"\n\n #ifdef VERTEX_COLORS\n attribute vec4 vertex_color;\n varying vec4 vColor;\n #endif\n\n #ifdef DIFFUSE_MAP\n attribute vec2 vertex_texCoord0;\n varying vec2 vUv0;\n #endif\n\n #ifdef DEPTH_PASS\n varying float vDepth;\n \n #ifndef VIEWMATRIX\n #define VIEWMATRIX\n uniform mat4 matrix_view;\n #endif\n\n #ifndef CAMERAPLANES\n #define CAMERAPLANES\n uniform vec4 camera_params;\n #endif\n #endif\n\n void main(void) {\n gl_Position = getPosition();\n\n #ifdef DEPTH_PASS\n vDepth = -(matrix_view * vec4(getWorldPosition(),1.0)).z * camera_params.x;\n #endif \n\n #ifdef VERTEX_COLORS\n vColor = vertex_color;\n #endif\n\n #ifdef DIFFUSE_MAP\n vUv0 = vertex_texCoord0;\n #endif\n }\n',e.vertexIncludes=s,e.vertexDefines=r},i.createFragmentDefinition=function(t,e,i){var n=new Map,s=new Map;n.set("shaderPassDefines",i.shaderDefines),n.set("fogCode",ko.fogCode(e.fog)),n.set("alphaTestPS",Ro.alphaTestPS),n.set("packDepthPS",Ro.packDepthPS),e.vertexColors&&s.set("VERTEX_COLORS",!0),e.diffuseMap&&s.set("DIFFUSE_MAP",!0),e.fog&&s.set("FOG",!0),e.alphaTest&&s.set("ALPHA_TEST",!0),t.fragmentCode='\n\n #include "shaderPassDefines"\n\n #ifdef VERTEX_COLORS\n varying vec4 vColor;\n #else\n uniform vec4 uColor;\n #endif\n\n #ifdef DIFFUSE_MAP\n varying vec2 vUv0;\n uniform sampler2D texture_diffuseMap;\n #endif\n\n #ifdef FOG\n #include "fogCode"\n #endif\n\n #ifdef ALPHA_TEST\n #include "alphaTestPS"\n #endif\n\n #ifdef DEPTH_PASS\n varying float vDepth;\n #include "packDepthPS"\n #endif\n\n void main(void) {\n\n #ifdef VERTEX_COLORS\n gl_FragColor = vColor;\n #else\n gl_FragColor = uColor;\n #endif\n\n #ifdef DIFFUSE_MAP\n gl_FragColor *= texture2D(texture_diffuseMap, vUv0);\n #endif\n\n #ifdef ALPHA_TEST\n alphaTest(gl_FragColor.a);\n #endif\n\n #ifndef PICK_PASS\n\n #ifdef DEPTH_PASS\n gl_FragColor = packFloat(vDepth);\n #else\n #ifdef FOG\n glFragColor.rgb = addFog(gl_FragColor.rgb);\n #endif\n #endif\n #endif\n }\n',t.fragmentIncludes=n,t.fragmentDefines=s},i.createShaderDefinition=function(t,e){var i={name:"BasicShader"},n=Yo.get(t).getByIndex(e.pass);return this.createAttributesDefinition(i,e),this.createVertexDefinition(t,i,e,n),this.createFragmentDefinition(i,e,n),Pr.createDefinition(t,i)},e}(ko),Zo=new Ko,Qo=new gn;function Jo(t){return Qo.get(t)}var $o=[];$o[0]={src:1,dst:1,op:2},$o[3]={src:1,dst:0,op:0},$o[2]={src:6,dst:8,op:0},$o[4]={src:1,dst:8,op:0},$o[1]={src:1,dst:1,op:0},$o[6]={src:6,dst:1,op:0},$o[7]={src:4,dst:2,op:0},$o[8]={src:5,dst:1,op:0},$o[5]={src:4,dst:0,op:0},$o[9]={src:1,dst:1,op:3},$o[10]={src:1,dst:1,op:4};var th=0,eh=function(){function t(){this._shader=null,this.meshInstances=[],this.name="Untitled",this.userId="",this.id=th++,this.variants=new Map,this.parameters={},this.alphaTest=0,this.alphaToCoverage=!1,this._blendState=new nn,this._depthState=new on,this.cull=1,this.stencilFront=null,this.stencilBack=null,this._shaderVersion=0,this._scene=null,this.dirty=!0}var e=t.prototype;return e._updateTransparency=function(){for(var t=this.transparent,e=this.meshInstances,i=0;i0,vertexColors:this.vertexColors,diffuseMap:!!this.colorMap,pass:s},c=new Zr(a,o,h),u=Do(t);return u.register("basic",Zo),u.getProgram("basic",l,c,this.userId)},e}(eh),nh=function(){function t(t,e,i){this._aabb=new Wt,this.origMeshInstances=void 0,this.meshInstance=null,this.dynamic=void 0,this.batchGroupId=void 0,this.origMeshInstances=t,this.dynamic=e,this.batchGroupId=i}var e=t.prototype;return e.destroy=function(t,e){this.meshInstance&&(this.removeFromLayers(t,e),this.meshInstance.destroy(),this.meshInstance=null)},e.addToLayers=function(t,e){for(var i=0;i=0;i--)this.matrices[i].mulAffine2(rh,this.bones[i].getWorldTransform()),this.matrices[i].mulAffine2(this.matrices[i],this.skin.inverseBindPose[i])}},e.updateMatrices=function(t,e){this._updateBeforeCull&&this._updateMatrices(t,e)},e.updateMatrixPalette=function(t,e){this._updateMatrices(t,e);for(var i=this.matrixPalette,n=this.bones.length,s=0;s0){var S=v.array[v.index+x];if(u[S]=!0,e=m.array[m.index],i=m.array[m.index+1],n=m.array[m.index+2],s=c[S],(r=l[S]).x>e&&(r.x=e),r.y>i&&(r.y=i),r.z>n&&(r.z=n),s.xb&&(r.x=b),r.y>T&&(r.y=T),r.z>w&&(r.z=w),s.x0&&this.indexBuffer[0]&&(this._geometryData.indexCount=this.indexBuffer[0].numIndices,this._geometryData.maxIndices=this.indexBuffer[0].numIndices))},i.clear=function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=0),this._initGeometryData(),this._geometryData.initDefaults(),this._geometryData.recreate=!0,this._geometryData.maxVertices=i,this._geometryData.maxIndices=n,this._geometryData.verticesUsage=t?0:1,this._geometryData.indicesUsage=e?0:1},i.setVertexStream=function(t,e,i,n,s,r,a){void 0===s&&(s=6),void 0===r&&(r=!1),void 0===a&&(a=!1),this._initGeometryData();var o=n||e.length/i;this._geometryData._changeVertexCount(o,t),this._geometryData.vertexStreamsUpdated=!0,this._geometryData.vertexStreamDictionary[t]=new uh(e,i,s,r,a)},i.getVertexStream=function(t,e){var i=0,n=!1;if(this._geometryData){var s=this._geometryData.vertexStreamDictionary[t];s&&(n=!0,i=this._geometryData.vertexCount,ArrayBuffer.isView(e)?e.set(s.data):(e.length=0,e.push(s.data)))}n||this.vertexBuffer&&(i=new fa(this.vertexBuffer).readData(t,e));return i},i.setPositions=function(t,e,i){void 0===e&&(e=ch.DEFAULT_COMPONENTS_POSITION),this.setVertexStream(Le,t,e,i,6,!1)},i.setNormals=function(t,e,i){void 0===e&&(e=ch.DEFAULT_COMPONENTS_NORMAL),this.setVertexStream(ke,t,e,i,6,!1)},i.setUvs=function(t,e,i,n){void 0===i&&(i=ch.DEFAULT_COMPONENTS_UV),this.setVertexStream(Ue+t,e,i,n,6,!1)},i.setColors=function(t,e,i){void 0===e&&(e=ch.DEFAULT_COMPONENTS_COLORS),this.setVertexStream(Ne,t,e,i,6,!1)},i.setColors32=function(t,e){this.setVertexStream(Ne,t,ch.DEFAULT_COMPONENTS_COLORS,e,1,!0)},i.setIndices=function(t,e){this._initGeometryData(),this._geometryData.indexStreamUpdated=!0,this._geometryData.indices=t,this._geometryData.indexCount=e||t.length},i.getPositions=function(t){return this.getVertexStream(Le,t)},i.getNormals=function(t){return this.getVertexStream(ke,t)},i.getUvs=function(t,e){return this.getVertexStream(Ue+t,e)},i.getColors=function(t){return this.getVertexStream(Ne,t)},i.getIndices=function(t){var e=0;if(this._geometryData&&this._geometryData.indices){var i=this._geometryData.indices;if(e=this._geometryData.indexCount,ArrayBuffer.isView(t))t.set(i);else{t.length=0;for(var n=0,s=i.length;n0&&this.indexBuffer[0])e=this.indexBuffer[0].readData(t)}return e},i.update=function(t,e){if(void 0===t&&(t=4),void 0===e&&(e=!0),this._geometryData){if(e){var i=this._geometryData.vertexStreamDictionary[Le];i&&3===i.componentCount&&(this._aabb.compute(i.data,this._geometryData.vertexCount),this._aabbVer++)}var n=this._geometryData.recreate;this._geometryData.vertexCount>this._geometryData.maxVertices&&(n=!0,this._geometryData.maxVertices=this._geometryData.vertexCount),n&&this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBuffer=null);var s=this._geometryData.recreate;this._geometryData.indexCount>this._geometryData.maxIndices&&(s=!0,this._geometryData.maxIndices=this._geometryData.indexCount),s&&this.indexBuffer.length>0&&this.indexBuffer[0]&&(this.indexBuffer[0].destroy(),this.indexBuffer[0]=null),this._geometryData.vertexStreamsUpdated&&this._updateVertexBuffer(),this._geometryData.indexStreamUpdated&&this._updateIndexBuffer(),this.primitive[0].type=t,this.indexBuffer.length>0&&this.indexBuffer[0]?this._geometryData.indexStreamUpdated&&(this.primitive[0].count=this._geometryData.indexCount,this.primitive[0].indexed=!0):this._geometryData.vertexStreamsUpdated&&(this.primitive[0].count=this._geometryData.vertexCount,this.primitive[0].indexed=!1),this._geometryData.vertexCount=0,this._geometryData.indexCount=0,this._geometryData.vertexStreamsUpdated=!1,this._geometryData.indexStreamUpdated=!1,this._geometryData.recreate=!1,this.updateRenderStates()}},i._buildVertexFormat=function(t){var e=[];for(var i in this._geometryData.vertexStreamDictionary){var n=this._geometryData.vertexStreamDictionary[i];e.push({semantic:i,components:n.componentCount,type:n.dataType,normalize:n.dataTypeNormalize,asInt:n.asInt})}return new bn(this.device,e,t)},i._updateVertexBuffer=function(){if(!this.vertexBuffer){var t=this._geometryData.maxVertices,e=this._buildVertexFormat(t);this.vertexBuffer=new pn(this.device,e,t,{usage:this._geometryData.verticesUsage,storage:this._storageVertex})}var i=new fa(this.vertexBuffer),n=this._geometryData.vertexCount;for(var s in this._geometryData.vertexStreamDictionary){var r=this._geometryData.vertexStreamDictionary[s];i.writeData(s,r.data,n),delete this._geometryData.vertexStreamDictionary[s]}i.end()},i._updateIndexBuffer=function(){if(this.indexBuffer.length<=0||!this.indexBuffer[0]){var t=this._geometryData.maxVertices,e=t>65535||0===t?2:1,i=this._storageIndex?{storage:!0}:void 0;this.indexBuffer[0]=new jr(this.device,e,this._geometryData.maxIndices,this._geometryData.indicesUsage,void 0,i)}var n=this._geometryData.indices;n&&(this.indexBuffer[0].writeData(n,this._geometryData.indexCount),this._geometryData.indices=null)},i.prepareRenderState=function(t){1===t?this.generateWireframe():2===t&&(this.primitive[2]={type:0,base:0,count:this.vertexBuffer?this.vertexBuffer.numVertices:0,indexed:!1})},i.updateRenderStates=function(){this.primitive[2]&&this.prepareRenderState(2),this.primitive[1]&&this.prepareRenderState(1)},i.generateWireframe=function(){this._destroyIndexBuffer(1);var t,e=this.vertexBuffer.numVertices,i=[];if(this.indexBuffer.length>0&&this.indexBuffer[0]){for(var n=[[0,1],[1,2],[2,0]],s=this.primitive[0].base,r=this.primitive[0].count,a=this.indexBuffer[0],o=new qi[a.format](a.storage),h=new Set,l=s;ld?d*e+u:u*e+d;h.has(f)||(h.add(f),i.push(u,d))}t=a.format}else{for(var p=0;p65535?2:1}var m=new jr(this.vertexBuffer.device,t,i.length);new qi[m.format](m.storage).set(i),m.unlock(),this.primitive[1]={type:1,base:0,count:i.length,indexed:!0},this.indexBuffer[1]=m},v(e,[{key:"morph",get:function(){return this._morph},set:function(t){t!==this._morph&&(this._morph&&this._morph.decRefCount(),this._morph=t,t&&t.incRefCount())}},{key:"aabb",get:function(){return this._aabb},set:function(t){this._aabb=t,this._aabbVer++}}])}(hh),fh=new Bt,ph=new wt,mh=new Nt,_h=new Nt,vh=new wt,gh=new wt,yh=new Bt,xh=new Nt,Sh=new wt,bh=new Bt,Th=new Nt,wh=new Nt,Eh=new Bt,Ah=new wt,Ch=new wt;function Mh(t,e){return t instanceof Function?t:function(i){var n=i[t];return n instanceof Function&&(n=n()),n===e}}function Ph(t,e){if(e(t))return t;for(var i=t._children,n=i.length,s=0;s=0?t.insertChild(this,e):t.addChild(this))},i.setLocalEulerAngles=function(t,e,i){this.localRotation.setFromEulerAngles(t,e,i),this._dirtyLocal||this._dirtifyLocal()},i.setLocalPosition=function(t,e,i){t instanceof wt?this.localPosition.copy(t):this.localPosition.set(t,e,i),this._dirtyLocal||this._dirtifyLocal()},i.setLocalRotation=function(t,e,i,n){t instanceof Nt?this.localRotation.copy(t):this.localRotation.set(t,e,i,n),this._dirtyLocal||this._dirtifyLocal()},i.setLocalScale=function(t,e,i){t instanceof wt?this.localScale.copy(t):this.localScale.set(t,e,i),this._dirtyLocal||this._dirtifyLocal()},i._dirtifyLocal=function(){this._dirtyLocal||(this._dirtyLocal=!0,this._dirtyWorld||this._dirtifyWorld())},i._unfreezeParentToRoot=function(){for(var t=this._parent;t;)t._frozen=!1,t=t._parent},i._dirtifyWorld=function(){this._dirtyWorld||this._unfreezeParentToRoot(),this._dirtifyWorldInternal()},i._dirtifyWorldInternal=function(){if(!this._dirtyWorld){this._frozen=!1,this._dirtyWorld=!0;for(var t=0;t>16},set:function(t){var e=65535&this._shaderDefs;this._updateShaderDefs(e|t<<16)}},{key:"instancingCount",get:function(){return this.instancingData?this.instancingData.count:0},set:function(t){this.instancingData&&(this.instancingData.count=t)}}])}();function Gh(t,e){if(t&&!e)return!1;if(!t&&e)return!1;if((t=t.data)===(e=e.data))return!0;if(t instanceof Float32Array&&e instanceof Float32Array){if(t.length!==e.length)return!1;for(var i=0;i=0&&(n._obj[t].splice(s,1),this.markGroupDirty(e))}},e._extractRender=function(t,e,i,n){return t.render&&(e=n[t.render.batchGroupId]=e.concat(t.render.meshInstances),t.render.removeFromLayers()),e},e._extractModel=function(t,e,i,n){return t.model&&t.model.model&&(e=n[t.model.batchGroupId]=e.concat(t.model.meshInstances),t.model.removeModelFromLayers()),e},e._extractElement=function(t,e,i){if(t.element){var n=!1;t.element._text&&t.element._text._model.meshInstances.length>0?(e.push(t.element._text._model.meshInstances[0]),t.element.removeModelFromLayers(t.element._text._model),n=!0):t.element._image&&(e.push(t.element._image._renderable.meshInstance),t.element.removeModelFromLayers(t.element._image._renderable.model),t.element._image._renderable.unmaskMeshInstance&&(e.push(t.element._image._renderable.unmaskMeshInstance),t.element._image._renderable.unmaskMeshInstance.stencilFront&&t.element._image._renderable.unmaskMeshInstance.stencilBack||(t.element._dirtifyMask(),t.element._onPrerender())),n=!0),n&&(i._ui=!0)}},e._collectAndRemoveMeshInstances=function(t,e){for(var i=0;i0;){u[d]=[p[0]],f=[];var _=p[0].material,v=p[0].layer,g=p[0]._shaderDefs,y=p[0].parameters,x=p[0].stencilFront,S=p[0].mesh.vertexBuffer.getNumVertices(),b=p[0].drawOrder;h.copy(p[0].aabb);var T=qh(p[0]),w=p[0].mesh.vertexBuffer.format.batchingHash,E=p[0].mesh.primitive[0].indexed;c=null;for(var A=1;A=a){f=f.concat(p.slice(A));break}_!==C.material||v!==C.layer||w!==C.mesh.vertexBuffer.format.batchingHash||E!==C.mesh.primitive[0].indexed||g!==C._shaderDefs||S+C.mesh.vertexBuffer.getNumVertices()>o?m(C):(l.copy(h),l.add(C.aabb),l.halfExtents.x>r||l.halfExtents.y>r||l.halfExtents.z>r?m(C):(!x||(s=C.stencilFront)&&x.func===s.func&&x.zpass===s.zpass)&&T===qh(C)&&Hh(y,C.parameters)?n&&c&&c.intersects(C.aabb)&&C.drawOrder!==b?m(C):(h.add(C.aabb),S+=C.mesh.vertexBuffer.getNumVertices(),u[d].push(C)):m(C))}d++,p=f}return u},e.collectBatchedMeshData=function(t,e){for(var i=null,n=0,s=0,r=null,a=0;a=3)if(s===Le)for(var w=v.data,E=w[0],A=w[1],C=w[2],M=w[4],P=w[5],R=w[6],I=w[8],D=w[9],L=w[10],k=w[12],O=w[13],F=w[14],B=void 0,N=void 0,U=void 0,z=0;z0&&r.setIndices(x),r.update(4,!1),e&&((p=p.clone()).chunks.transformVS=this.transformVS,p.chunks.skinTexVS=this.skinTexVS,p.chunks.skinConstVS=this.skinConstVS,p.update());var rt=new Vh(r,p,this.rootNode);rt.castShadow=h.origMeshInstances[0].castShadow,rt.parameters=h.origMeshInstances[0].parameters,rt.layer=h.origMeshInstances[0].layer,rt._shaderDefs=h.origMeshInstances[0]._shaderDefs,rt.cull=h.origMeshInstances[0].cull;var at=this._batchGroups[i];if(at&&at._ui&&(rt.cull=!1),e){for(var ot=[],ht=0;ht0&&this.generate(this._dirtyGroups);for(var t=0;t1&&(h=ge,o=!1));var l=null!=(e=null==(i=s.renderTarget)?void 0:i.depthBuffer)?e:null==(n=s.renderTarget)?void 0:n.colorBuffer;this.shouldReallocate(this.depthRenderTarget,l)&&(this.releaseRenderTarget(this.depthRenderTarget),this.depthRenderTarget=this.allocateRenderTarget(this.depthRenderTarget,s.renderTarget,r,h,o));var c=o?this.depthRenderTarget.depthBuffer:this.depthRenderTarget.colorBuffer;Qh.forEach((function(t){return r.scope.resolve(t).setValue(c)}))},i.execute=function(){var t=this.device;if(t.isWebGL2&&t.renderTarget.samples>1){var e=t.renderTarget.impl._glFrameBuffer,i=this.depthRenderTarget;t.renderTarget=i,t.updateBegin(),this.depthRenderTarget.impl.internalResolve(t,e,i.impl._glFrameBuffer,this.depthRenderTarget,t.gl.DEPTH_BUFFER_BIT)}else t.copyRenderTarget(t.renderTarget,this.depthRenderTarget,!1,!0)},e}(Kr),$h=new pt(254/255,254/255,254/255,254/255),tl=[],el=[[],[],[]],il=["uSceneDepthMap","uDepthMap"],nl=function(t){function e(e,i,n){var s;return(s=t.call(this,e)||this).renderer=i,s.camera=n,s.setupRenderTarget(),s}x(e,t);var i=e.prototype;return i.destroy=function(){t.prototype.destroy.call(this),this.renderTarget&&(this.renderTarget.destroyTextureBuffers(),this.renderTarget.destroy(),this.renderTarget=null)},i.update=function(t){this.scene=t},i.setupRenderTarget=function(){var t=new or(this.device,{name:il[0],format:7,width:4,height:4,mipmaps:!1,minFilter:0,magFilter:0,addressU:1,addressV:1}),e=new Cn({name:il[0]+"RT}",colorBuffer:t,depth:!0,stencil:!1});this.init(e,{}),this.setClearColor($h),this.setClearDepth(1)},i.before=function(){var t=this.device,e=this.renderTarget.colorBuffer;il.forEach((function(i){return t.scope.resolve(i).setValue(e)}))},i.execute=function(){for(var t=this.device,e=this.renderer,i=this.camera,n=this.scene,s=this.renderTarget,r=n.layers.layerList,a=n.layers.subLayerEnabled,o=n.layers.subLayerList,h=0;h0,t.blendType=e.blendType,t.screenSpace=n&&!!(n&go),t.skin=n&&!!(2&n),t.useInstancing=n&&!!(n&_o),t.useMorphPosition=n&&!!(n&xo),t.useMorphNormal=n&&!!(n&So),t.useMorphTextureBased=n&&!!(n&bo),t.hasTangents=n&&!!(n&yo),t.nineSlicedMode=e.nineSlicedMode||0,e.useLighting&&i.clusteredLightingEnabled?(t.clusteredLightingEnabled=!0,t.clusteredLightingCookiesEnabled=i.lighting.cookiesEnabled,t.clusteredLightingShadowsEnabled=i.lighting.shadowsEnabled,t.clusteredLightingShadowType=i.lighting.shadowType,t.clusteredLightingAreaLightsEnabled=i.lighting.areaLightsEnabled):(t.clusteredLightingEnabled=!1,t.clusteredLightingCookiesEnabled=!1,t.clusteredLightingShadowsEnabled=!1,t.clusteredLightingAreaLightsEnabled=!1)},t.updateMaterialOptions=function(t,e){t.useAmbientTint=!1,t.separateAmbient=!1,t.customFragmentShader=null,t.pixelSnap=e.pixelSnap,t.shadingModel=e.shadingModel,t.ambientSH=e.ambientSH,t.fastTbn=e.fastTbn,t.twoSidedLighting=e.twoSidedLighting,t.occludeDirect=e.occludeDirect,t.occludeSpecular=e.occludeSpecular,t.occludeSpecularFloat=1!==e.occludeSpecularIntensity,t.useMsdf=!1,t.msdfTextAttribute=!1,t.alphaToCoverage=e.alphaToCoverage,t.opacityFadesSpecular=e.opacityFadesSpecular,t.opacityDither=e.opacityDither,t.cubeMapProjection=0,t.conserveEnergy=e.conserveEnergy&&1===e.shadingModel,t.useSpecular=e.hasSpecular,t.useSpecularityFactor=e.hasSpecularityFactor,t.enableGGXSpecular=e.ggxSpecular,t.fresnelModel=e.fresnelModel,t.useRefraction=e.hasRefraction,t.useClearCoat=e.hasClearCoat,t.useSheen=e.hasSheen,t.useIridescence=e.hasIrridescence,t.useMetalness=e.hasMetalness,t.useDynamicRefraction=e.dynamicRefraction,t.dispersion=e.dispersion>0,t.vertexColors=!1,t.lightMapEnabled=e.hasLighting,t.dirLightMapEnabled=e.dirLightMap,t.useHeights=e.hasHeights,t.useNormals=e.hasNormals,t.useClearCoatNormals=e.hasClearCoatNormals,t.useAo=e.hasAo,t.diffuseMapEnabled=e.hasDiffuseMap},t.updateEnvOptions=function(t,e,i){t.fog=e.useFog?i.fog:"none",t.gamma=e.useGammaTonemap?i.gammaCorrection:0,t.toneMap=e.useGammaTonemap?i.toneMapping:-1,t.fixSeams=!1,e.useSkybox&&i.envAtlas&&i.skybox?(t.reflectionSource="envAtlasHQ",t.reflectionEncoding=i.envAtlas.encoding,t.reflectionCubemapEncoding=i.skybox.encoding):e.useSkybox&&i.envAtlas?(t.reflectionSource="envAtlas",t.reflectionEncoding=i.envAtlas.encoding):e.useSkybox&&i.skybox?(t.reflectionSource="cubeMap",t.reflectionEncoding=i.skybox.encoding):(t.reflectionSource=null,t.reflectionEncoding=null),e.ambientSH?(t.ambientSource="ambientSH",t.ambientEncoding=null):t.reflectionSource&&i.envAtlas?(t.ambientSource="envAtlas",t.ambientEncoding=i.envAtlas.encoding):(t.ambientSource="constant",t.ambientEncoding=null);var n=!!t.reflectionSource;t.skyboxIntensity=n,t.useCubeMapRotation=n&&i._skyboxRotationShaderInclude},t.updateLightingOptions=function(e,i,n,s){if(e.lightMapWithoutAmbient=!1,i.useLighting){var r=[],a=n?n>>16:1;e.lightMaskDynamic=!!(1&a),e.lightMapWithoutAmbient=!1,s&&(t.collectLights(0,s[0],r,a),t.collectLights(1,s[1],r,a),t.collectLights(2,s[2],r,a)),e.lights=r}else e.lights=[];(0===e.lights.length||1&n)&&(e.noShadow=!0)},t.collectLights=function(t,e,i,n){for(var s=0;s8?0:1},t.getShaderDefines=function(e){return Al.get(e,(function(){var i=function(t,e,i,n){return Object.keys(e).map((function(t){return"#define "+i+t+" "+e[t]+n})).join("\n")},n=0===t.getLightTextureFormat(e)?"FLOAT":"8BIT",s=e.supportsTextureFetch?"":".5";return"\n \n#define CLUSTER_TEXTURE_"+n+"\n "+i(0,wl,"CLUSTER_TEXTURE_8_",s)+"\n "+i(0,El,"CLUSTER_TEXTURE_F_",s)+"\n "}))};var e=t.prototype;return e.destroy=function(){this.lightsTexture8&&(this.lightsTexture8.destroy(),this.lightsTexture8=null),this.lightsTextureFloat&&(this.lightsTextureFloat.destroy(),this.lightsTextureFloat=null)},e.createTexture=function(t,e,i,n,s){return new or(t,{name:s,width:e,height:i,mipmaps:!1,format:n,addressU:1,addressV:1,type:ui,magFilter:0,minFilter:0,anisotropy:1})},e.setCompressionRanges=function(t,e){this.invMaxColorValue=1/e,this.invMaxAttenuation=1/t},e.setBounds=function(t,e){this.boundsMin.copy(t),this.boundsDelta.copy(e)},e.uploadTextures=function(){this.lightsTextureFloat&&(this.lightsTextureFloat.lock().set(this.lightsFloat),this.lightsTextureFloat.unlock()),this.lightsTexture8.lock().set(this.lights8),this.lightsTexture8.unlock()},e.updateUniforms=function(){this._lightsTexture8Id.setValue(this.lightsTexture8),0===this.lightTextureFormat&&this._lightsTextureFloatId.setValue(this.lightsTextureFloat),this._lightsTextureInvSizeId.setValue(this._lightsTextureInvSizeData)},e.getSpotDirection=function(t,e){e._node.getWorldTransform().getY(t).mulScalar(-1),t.normalize()},e.getLightAreaSizes=function(t){var e=t._node.getWorldTransform();return e.transformVector(bl,xl),Sl[0]=xl.x,Sl[1]=xl.y,Sl[2]=xl.z,e.transformVector(Tl,xl),Sl[3]=xl.x,Sl[4]=xl.y,Sl[5]=xl.z,Sl},e.addLightDataFlags=function(t,e,i,n,s,r){t[e+0]=n?255:0,t[e+1]=64*i._shape,t[e+2]=255*i._falloffMode,t[e+3]=s?255*r:0},e.addLightDataColor=function(t,e,i,n,s){var r=this.invMaxColorValue,a=n?i._linearFinalColor:i._finalColor;Tt.float2Bytes(a[0]*r,t,e+0,2),Tt.float2Bytes(a[1]*r,t,e+2,2),Tt.float2Bytes(a[2]*r,t,e+4,2),t[e+6]=s?255:0;var o=!!(1&i.mask),h=!!(2&i.mask);t[e+7]=o&&h?127:h?255:0},e.addLightDataSpotAngles=function(t,e,i){Tt.float2Bytes(.499999*i._innerConeAngleCos+.5,t,e+0,2),Tt.float2Bytes(.499999*i._outerConeAngleCos+.5,t,e+2,2)},e.addLightDataShadowBias=function(t,e,i){var n=i.getRenderData(null,0),s=i._getUniformBiasValues(n);Tt.float2BytesRange(s.bias,t,e,-1,20,2),Tt.float2Bytes(s.normalBias,t,e+2,2)},e.addLightDataPositionRange=function(t,e,i,n){var s=xl.sub2(n,this.boundsMin).div(this.boundsDelta);Tt.float2Bytes(s.x,t,e+0,4),Tt.float2Bytes(s.y,t,e+4,4),Tt.float2Bytes(s.z,t,e+8,4),Tt.float2Bytes(i.attenuationEnd*this.invMaxAttenuation,t,e+12,4)},e.addLightDataSpotDirection=function(t,e,i){this.getSpotDirection(xl,i),Tt.float2Bytes(.499999*xl.x+.5,t,e+0,4),Tt.float2Bytes(.499999*xl.y+.5,t,e+4,4),Tt.float2Bytes(.499999*xl.z+.5,t,e+8,4)},e.addLightDataLightProjMatrix=function(t,e,i){for(var n=i.data,s=0;s<12;s++)Tt.float2BytesRange(n[s],t,e+4*s,-2,2,4);for(var r=12;r<16;r++)Tt.float2MantissaExponent(n[r],t,e+4*r,4)},e.addLightDataCookies=function(t,e,i){var n="rgb"===i._cookieChannel;if(t[e+0]=Math.floor(255*i.cookieIntensity),t[e+1]=n?255:0,!n){var s=i._cookieChannel;t[e+4]="rrr"===s?255:0,t[e+5]="ggg"===s?255:0,t[e+6]="bbb"===s?255:0,t[e+7]="aaa"===s?255:0}},e.addLightAtlasViewport=function(t,e,i){Tt.float2Bytes(i.x,t,e+0,2),Tt.float2Bytes(i.y,t,e+2,2),Tt.float2Bytes(i.z/3,t,e+4,2)},e.addLightAreaSizes=function(t,e,i){for(var n=this.getLightAreaSizes(i),s=0;s<6;s++)Tt.float2MantissaExponent(n[s],t,e+4*s,4)},e.addLightData=function(t,e,i){var n=2===t._type,s=t.atlasViewportAllocated,r=this.cookiesEnabled&&!!t._cookie&&s,a=this.areaLightsEnabled&&0!==t.shape,o=this.shadowsEnabled&&t.castShadows&&s,h=t._node.getPosition(),l=null,c=null;n?o?l=t.getRenderData(null,0).shadowMatrix:r&&(l=yl.evalSpotCookieMatrix(t)):(o||r)&&(c=t.atlasViewport);var u=this.lights8,d=e*this.lightsTexture8.width*4;if(this.addLightDataFlags(u,d+4*wl.FLAGS,t,n,o,t.shadowIntensity),this.addLightDataColor(u,d+4*wl.COLOR_A,t,i,r),n&&this.addLightDataSpotAngles(u,d+4*wl.SPOT_ANGLES,t),t.castShadows&&this.addLightDataShadowBias(u,d+4*wl.SHADOW_BIAS,t),r&&this.addLightDataCookies(u,d+4*wl.COOKIE_A,t),0===this.lightTextureFormat){var f=this.lightsFloat,p=e*this.lightsTextureFloat.width*4;if(f[p+4*El.POSITION_RANGE+0]=h.x,f[p+4*El.POSITION_RANGE+1]=h.y,f[p+4*El.POSITION_RANGE+2]=h.z,f[p+4*El.POSITION_RANGE+3]=t.attenuationEnd,n&&(this.getSpotDirection(xl,t),f[p+4*El.SPOT_DIRECTION+0]=xl.x,f[p+4*El.SPOT_DIRECTION+1]=xl.y,f[p+4*El.SPOT_DIRECTION+2]=xl.z),l)for(var m=l.data,_=0;_<16;_++)f[p+4*El.PROJ_MAT_0+_]=m[_];if(c&&(f[p+4*El.ATLAS_VIEWPORT+0]=c.x,f[p+4*El.ATLAS_VIEWPORT+1]=c.y,f[p+4*El.ATLAS_VIEWPORT+2]=c.z/3),a){var v=this.getLightAreaSizes(t);f[p+4*El.AREA_DATA_WIDTH+0]=v[0],f[p+4*El.AREA_DATA_WIDTH+1]=v[1],f[p+4*El.AREA_DATA_WIDTH+2]=v[2],f[p+4*El.AREA_DATA_HEIGHT+0]=v[3],f[p+4*El.AREA_DATA_HEIGHT+1]=v[4],f[p+4*El.AREA_DATA_HEIGHT+2]=v[5]}}else this.addLightDataPositionRange(u,d+4*wl.POSITION_X,t,h),n&&this.addLightDataSpotDirection(u,d+4*wl.SPOT_DIRECTION_X,t),l&&this.addLightDataLightProjMatrix(u,d+4*wl.PROJ_MAT_00,l),c&&this.addLightAtlasViewport(u,d+4*wl.ATLAS_VIEWPORT_A,c),a&&this.addLightAreaSizes(u,d+4*wl.AREA_DATA_WIDTH_X,t)},t}(),Ml={vertex_normal:ke,vertex_tangent:Oe,vertex_texCoord0:ze,vertex_texCoord1:Ve,vertex_color:Ne,vertex_boneWeights:Fe,vertex_boneIndices:Be},Pl={vVertexColor:"vec4",vPositionW:"vec3",vNormalV:"vec3",vNormalW:"vec3",vTangentW:"vec3",vBinormalW:"vec3",vObjectSpaceUpW:"vec3",vUv0:"vec2",vUv1:"vec2"},Rl=function(){function t(t,e){if(this.device=t,this.options=e,this.attributes={vertex_position:Le},e.userAttributes)for(var i=0,n=Object.entries(e.userAttributes);i=0&&(this.attributes[c]=Ml[c]);this.chunks[h]=l}}else this.chunks=Ro;this.shaderPassInfo=Yo.get(this.device).getByIndex(e.pass),this.shadowPass=this.shaderPassInfo.isShadow,this.lighting=e.lights.length>0||e.dirLightMapEnabled||e.clusteredLightingEnabled,this.reflections=!!e.reflectionSource,this.needsNormal=this.lighting||this.reflections||e.useSpecular||e.ambientSH||e.useHeights||e.enableGGXSpecular||e.clusteredLightingEnabled&&!this.shadowPass||e.useClearCoatNormals,this.needsNormal=this.needsNormal&&!this.shadowPass,this.needsSceneColor=e.useDynamicRefraction,this.needsScreenSize=e.useDynamicRefraction,this.needsTransforms=e.useDynamicRefraction,this.varyings="",this.varyingDefines="",this.vshader=null,this.frontendDecl=null,this.frontendCode=null,this.frontendFunc=null,this.lightingUv=null,this.defines=[],this.fshader=null}var e=t.prototype;return e._vsAddBaseCode=function(t,e,i){return t+=e.baseVS,1!==i.nineSlicedMode&&2!==i.nineSlicedMode||(t+=e.baseNineSlicedVS),t},e._vsAddTransformCode=function(t,e,i,n){return t+=this.chunks.transformVS},e._setMapTransform=function(t,e,i,n){var s=i+100*n;if(!t[3][s]){var r="texture_"+e+"MapTransform";t[0]+="uniform vec3 "+r+"0;\n",t[0]+="uniform vec3 "+r+"1;\n",t[1]+="varying vec2 vUV"+n+"_"+i+";\n",t[2]+=" vUV"+n+"_"+i+" = vec2(dot(vec3(uv"+n+", 1), "+r+"0), dot(vec3(uv"+n+", 1), "+r+"1));\n",t[3][s]=!0}return t},e._fsGetBaseCode=function(){var t=this.options,e=this.chunks,i=this.chunks.basePS;return 1===t.nineSlicedMode?i+=e.baseNineSlicedPS:2===t.nineSlicedMode&&(i+=e.baseNineSlicedTiledPS),i},e._fsGetStartCode=function(t,e,i,n){var s=i.startPS;return 1===n.nineSlicedMode?s+=i.startNineSlicedPS:2===n.nineSlicedMode&&(s+=i.startNineSlicedTiledPS),s},e._getLightSourceShapeString=function(t){switch(t){case 1:return"Rect";case 2:return"Disk";case 3:return"Sphere";default:return""}},e.generateVertexShader=function(t,e,i){var n=this,s=this.device,r=this.options,a=this.chunks,o="",h="";o=this._vsAddBaseCode(o,a,r),h+=" vPositionW = getWorldPosition();\n",2!==this.options.pass&&5!==this.options.pass||(o+="varying float vDepth;\n",o+="#ifndef VIEWMATRIX\n",o+="#define VIEWMATRIX\n",o+="uniform mat4 matrix_view;\n",o+="#endif\n",o+="#ifndef CAMERAPLANES\n",o+="#define CAMERAPLANES\n",o+="uniform vec4 camera_params;\n\n",o+="#endif\n",h+=" vDepth = -(matrix_view * vec4(vPositionW,1.0)).z * camera_params.x;\n"),this.options.pass,this.options.useInstancing&&(this.attributes.instance_line1=oi,this.attributes.instance_line2=hi,this.attributes.instance_line3=li,this.attributes.instance_line4=ci,o+=a.instancingVS),this.needsNormal&&(this.attributes.vertex_normal=ke,h+=" vNormalW = getNormal();\n","sphereMap"===r.reflectionSource&&s.fragmentUniformsCount<=16&&(o+=a.viewNormalVS,h+=" vNormalV = getViewNormal();\n"),r.hasTangents&&(r.useHeights||r.useNormals||r.enableGGXSpecular)?(this.attributes.vertex_tangent=Oe,o+=a.tangentBinormalVS,h+=" vTangentW = getTangent();\n",h+=" vBinormalW = getBinormal();\n"):!r.enableGGXSpecular&&s.extStandardDerivatives||(h+=" vObjectSpaceUpW = normalize(dNormalMatrix * vec3(0, 1, 0));\n"));for(var l=0;l<2;l++)t[l]&&(this.attributes["vertex_texCoord"+l]="TEXCOORD"+l,o+=a["uv"+l+"VS"],h+=" vec2 uv"+l+" = getUv"+l+"();\n"),e[l]&&(h+=" vUv"+l+" = uv"+l+";\n");var c=[o,this.varyings,h,[]];if(i.forEach((function(t){n._setMapTransform(c,t.name,t.id,t.uv)})),o=c[0],this.varyings=c[1],h=c[2],r.vertexColors&&(this.attributes.vertex_color=Ne,h+=" vVertexColor = vertex_color;\n"),r.useMsdf&&r.msdfTextAttribute&&(this.attributes.vertex_outlineParameters=ni,this.attributes.vertex_shadowParameters=si,h+=" unpackMsdfParams();\n",o+=a.msdfVS),r.useMorphPosition||r.useMorphNormal)if(r.useMorphTextureBased){o+="#define MORPHING_TEXTURE_BASED\n",r.useMorphPosition&&(o+="#define MORPHING_TEXTURE_BASED_POSITION\n"),r.useMorphNormal&&(o+="#define MORPHING_TEXTURE_BASED_NORMAL\n"),this.attributes.morph_vertex_id=ci;var u=s.isWebGPU?"uint":"float";o+="attribute "+u+" morph_vertex_id;\n"}else o+="#define MORPHING\n",r.useMorphPosition?(this.attributes.morph_pos0=ni,this.attributes.morph_pos1=si,this.attributes.morph_pos2=ri,this.attributes.morph_pos3=ai,o+="#define MORPHING_POS03\n",o+="attribute vec3 morph_pos0;\n",o+="attribute vec3 morph_pos1;\n",o+="attribute vec3 morph_pos2;\n",o+="attribute vec3 morph_pos3;\n"):r.useMorphNormal&&(this.attributes.morph_nrm0=ni,this.attributes.morph_nrm1=si,this.attributes.morph_nrm2=ri,this.attributes.morph_nrm3=ai,o+="#define MORPHING_NRM03\n",o+="attribute vec3 morph_nrm0;\n",o+="attribute vec3 morph_nrm1;\n",o+="attribute vec3 morph_nrm2;\n",o+="attribute vec3 morph_nrm3;\n"),r.useMorphNormal?(this.attributes.morph_nrm4=oi,this.attributes.morph_nrm5=hi,this.attributes.morph_nrm6=li,this.attributes.morph_nrm7=ci,o+="#define MORPHING_NRM47\n",o+="attribute vec3 morph_nrm4;\n",o+="attribute vec3 morph_nrm5;\n",o+="attribute vec3 morph_nrm6;\n",o+="attribute vec3 morph_nrm7;\n"):(this.attributes.morph_pos4=oi,this.attributes.morph_pos5=hi,this.attributes.morph_pos6=li,this.attributes.morph_pos7=ci,o+="#define MORPHING_POS47\n",o+="attribute vec3 morph_pos4;\n",o+="attribute vec3 morph_pos5;\n",o+="attribute vec3 morph_pos6;\n",o+="attribute vec3 morph_pos7;\n");r.skin?(this.attributes.vertex_boneWeights=Fe,this.attributes.vertex_boneIndices=Be,o+=ko.skinCode(s,a),o+="#define SKIN\n"):r.useInstancing&&(o+="#define INSTANCING\n"),r.screenSpace&&(o+="#define SCREENSPACE\n"),r.pixelSnap&&(o+="#define PIXELSNAP\n"),o=this._vsAddTransformCode(o,s,a,r),this.needsNormal&&(o+=a.normalVS),o+="\n",o+=a.startVS,o+=h,o+=a.endVS,o+="}",Object.keys(Pl).forEach((function(t){o.indexOf(t)>=0&&(n.varyings+="varying "+Pl[t]+" "+t+";\n",n.varyingDefines+="#define VARYING_"+t.toUpperCase()+"\n")}));var d=this.shaderPassInfo.shaderDefines;this.vshader=d+this.varyings+o},e._fsGetBeginCode=function(){for(var t=this.shaderPassInfo.shaderDefines,e=0;e0&&this.defines.push("LIT_SPECULAR_FRESNEL"),e.conserveEnergy&&this.defines.push("LIT_CONSERVE_ENERGY"),e.useSheen&&this.defines.push("LIT_SHEEN"),e.useIridescence&&this.defines.push("LIT_IRIDESCENCE"));var o=[],h=0,l=!1,c=!1,u=!1,d=e.lights.some((function(t){return t._shape&&0!==t._shape}));if(e.clusteredLightingEnabled&&e.clusteredLightingAreaLightsEnabled&&(d=!0),d||e.clusteredLightingEnabled){var f="highp";7===t.areaLightLutFormat&&(n.append("#define AREA_R8_G8_B8_A8_LUTS"),f="lowp"),n.append("#define AREA_LIGHTS"),n.append("uniform "+f+" sampler2D areaLightsLutTex1;"),n.append("uniform "+f+" sampler2D areaLightsLutTex2;")}for(var p=0;p0?i.cubeMapProjectBoxPS:i.cubeMapProjectNonePS),s.append(e.skyboxIntensity?i.envMultiplyPS:i.envConstPS)),(this.lighting&&e.useSpecular||this.reflections)&&(e.useMetalness&&s.append(i.metalnessModulatePS),2===e.fresnelModel&&s.append(i.fresnelSchlickPS),e.useIridescence&&s.append(i.iridescenceDiffractionPS)),e.useAo)switch(s.append(i.aoDiffuseOccPS),e.occludeSpecular){case 1:s.append(e.occludeSpecularFloat?i.aoSpecOccSimplePS:i.aoSpecOccConstSimplePS);break;case 2:s.append(e.occludeSpecularFloat?i.aoSpecOccPS:i.aoSpecOccConstPS)}"envAtlasHQ"===e.reflectionSource?(s.append(e.fixSeams?i.fixCubemapSeamsStretchPS:i.fixCubemapSeamsNonePS),s.append(i.envAtlasPS),s.append(i.reflectionEnvHQPS.replace(/\$DECODE_CUBEMAP/g,ml.decodeFunc(e.reflectionCubemapEncoding)).replace(/\$DECODE/g,ml.decodeFunc(e.reflectionEncoding)))):"envAtlas"===e.reflectionSource?(s.append(i.envAtlasPS),s.append(i.reflectionEnvPS.replace(/\$DECODE/g,ml.decodeFunc(e.reflectionEncoding)))):"cubeMap"===e.reflectionSource?(s.append(e.fixSeams?i.fixCubemapSeamsStretchPS:i.fixCubemapSeamsNonePS),s.append(i.reflectionCubePS.replace(/\$DECODE/g,ml.decodeFunc(e.reflectionEncoding)))):"sphereMap"===e.reflectionSource&&s.append(i.reflectionSpherePS.replace(/\$DECODE/g,ml.decodeFunc(e.reflectionEncoding))),this.reflections&&(e.useClearCoat&&s.append(i.reflectionCCPS),e.useSheen&&s.append(i.reflectionSheenPS)),e.useRefraction&&(e.useDynamicRefraction?(e.dispersion&&(n.append("uniform float material_dispersion;"),n.append("#define DISPERSION\n")),s.append(i.refractionDynamicPS)):this.reflections&&s.append(i.refractionCubePS)),e.useSheen&&s.append(i.lightSheenPS),e.clusteredLightingEnabled&&(s.append(i.clusteredLightUtilsPS),e.clusteredLightingCookiesEnabled&&s.append(i.clusteredLightCookiesPS),e.clusteredLightingShadowsEnabled&&!e.noShadow&&(o[0]=!0,o[4]=!0,o[6]=!0)),(h>0||e.clusteredLightingEnabled)&&(l&&s.append(i.shadowCascadesPS),(o[5]||o[0])&&s.append(i.shadowStandardPS),o[4]&&!t.isWebGL1&&s.append(i.shadowStandardGL2PS),c&&(s.append(i.shadowVSM_commonPS),o[1]&&s.append(i.shadowVSM8PS),o[2]&&s.append(t.extTextureHalfFloatLinear?i.shadowEVSMPS.replace(/\$/g,"16"):i.shadowEVSMnPS.replace(/\$/g,"16")),o[3]&&s.append(t.extTextureFloatLinear?i.shadowEVSMPS.replace(/\$/g,"32"):i.shadowEVSMnPS.replace(/\$/g,"32"))),u&&(s.append(i.linearizeDepthPS),s.append(i.shadowPCSSPS)),t.isWebGL2||t.isWebGPU||t.extStandardDerivatives||s.append(i.biasConstPS)),e.enableGGXSpecular&&s.append("uniform float material_anisotropy;"),this.lighting&&(s.append(i.lightDiffuseLambertPS),(d||e.clusteredLightingAreaLightsEnabled)&&s.append(i.ltcPS));var y=!1;e.useSpecular&&(this.lighting&&s.append(0===e.shadingModel?i.lightSpecularPhongPS:e.enableGGXSpecular?i.lightSpecularAnisoGGXPS:i.lightSpecularBlinnPS),e.fresnelModel||this.reflections||e.diffuseMapEnabled||(n.append("uniform vec3 material_ambient;"),n.append("#define LIT_OLD_AMBIENT"),y=!0)),s.append(i.combinePS),e.lightMapEnabled&&s.append(e.useSpecular&&e.dirLightMapEnabled?i.lightmapDirAddPS:i.lightmapAddPS);var x=!e.lightMapEnabled||e.lightMapWithoutAmbient;x&&("ambientSH"===e.ambientSource?s.append(i.ambientSHPS):"envAtlas"===e.ambientSource?("envAtlas"!==e.reflectionSource&&"envAtlasHQ"!==e.reflectionSource&&s.append(i.envAtlasPS),s.append(i.ambientEnvPS.replace(/\$DECODE/g,ml.decodeFunc(e.ambientEncoding)))):s.append(i.ambientConstantPS)),e.useAmbientTint&&!y&&n.append("uniform vec3 material_ambient;"),e.useMsdf&&(e.msdfTextAttribute||n.append("#define UNIFORM_TEXT_PARAMETERS"),s.append(i.msdfPS)),this.needsNormal&&(s.append(i.viewDirPS),e.useSpecular&&s.append(e.enableGGXSpecular?i.reflDirAnisoPS:i.reflDirPS));var S,b=!1,T=!1,w=!1,E=!1,A=!1;if(e.clusteredLightingEnabled&&this.lighting&&(E=!0,b=!0,T=!0,A=!0,s.append(i.floatUnpackingPS),e.lightMaskDynamic&&n.append("#define CLUSTER_MESH_DYNAMIC_LIGHTS"),e.clusteredLightingCookiesEnabled&&n.append("#define CLUSTER_COOKIES"),e.clusteredLightingShadowsEnabled&&!e.noShadow&&(n.append("#define CLUSTER_SHADOWS"),n.append("#define CLUSTER_SHADOW_TYPE_"+po[e.clusteredLightingShadowType])),e.clusteredLightingAreaLightsEnabled&&n.append("#define CLUSTER_AREALIGHTS"),n.append(Cl.getShaderDefines(t)),e.clusteredLightingShadowsEnabled&&!e.noShadow&&s.append(i.clusteredLightShadowsPS),s.append(i.clusteredLightPS)),a.append(this._fsGetStartCode(a,t,i,e)),this.needsNormal&&(a.append(" dVertexNormalW = normalize(vNormalW);"),(e.useHeights||e.useNormals)&&e.hasTangents&&(a.append(" dTangentW = vTangentW;"),a.append(" dBinormalW = vBinormalW;")),a.append(" getViewDir();"),g&&(a.append(" getTBN(dTangentW, dBinormalW, dVertexNormalW);"),e.twoSidedLighting&&a.append(" handleTwoSidedLighting();"))),a.append(this.frontendFunc),this.needsNormal&&(e.useSpecular&&r.append(" getReflDir(litArgs_worldNormal, dViewDirW, litArgs_gloss, dTBN);"),e.useClearCoat&&r.append(" ccReflDirW = normalize(-reflect(dViewDirW, litArgs_clearcoat_worldNormal));")),(this.lighting&&e.useSpecular||this.reflections)&&(e.useMetalness&&(r.append(" float f0 = 1.0 / litArgs_ior; f0 = (f0 - 1.0) / (f0 + 1.0); f0 *= f0;"),r.append(" litArgs_specularity = getSpecularModulate(litArgs_specularity, litArgs_albedo, litArgs_metalness, f0);"),r.append(" litArgs_albedo = getAlbedoModulate(litArgs_albedo, litArgs_metalness);")),e.useIridescence&&r.append(" vec3 iridescenceFresnel = getIridescence(saturate(dot(dViewDirW, litArgs_worldNormal)), litArgs_specularity, litArgs_iridescence_thickness);")),x&&(r.append(" addAmbient(litArgs_worldNormal);"),e.conserveEnergy&&e.useSpecular&&r.append(" dDiffuseLight = dDiffuseLight * (1.0 - litArgs_specularity);"),e.separateAmbient&&r.append("\n vec3 dAmbientLight = dDiffuseLight;\n dDiffuseLight = vec3(0);\n ")),e.useAmbientTint&&!y&&r.append(" dDiffuseLight *= material_ambient;"),e.useAo&&!e.occludeDirect&&r.append(" occludeDiffuse(litArgs_ao);"),e.lightMapEnabled&&r.append(" addLightMap(\n litArgs_lightmap, \n litArgs_lightmapDir, \n litArgs_worldNormal, \n dViewDirW, \n dReflDirW, \n litArgs_gloss, \n litArgs_specularity, \n dVertexNormalW,\n dTBN\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n );"),this.lighting||this.reflections){this.reflections&&(e.useClearCoat&&(r.append(" addReflectionCC(ccReflDirW, litArgs_clearcoat_gloss);"),e.fresnelModel>0?(r.append(" ccFresnel = getFresnelCC(dot(dViewDirW, litArgs_clearcoat_worldNormal));"),r.append(" ccReflection.rgb *= ccFresnel;")):r.append(" ccFresnel = 0.0;")),e.useSpecularityFactor&&r.append(" ccReflection.rgb *= litArgs_specularityFactor;"),e.useSheen&&r.append(" addReflectionSheen(litArgs_worldNormal, dViewDirW, litArgs_sheen_gloss);"),r.append(" addReflection(dReflDirW, litArgs_gloss);"),e.fresnelModel>0?r.append(" dReflection.rgb *= \n getFresnel(\n dot(dViewDirW, litArgs_worldNormal), \n litArgs_gloss, \n litArgs_specularity\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n );"):r.append(" dReflection.rgb *= litArgs_specularity;"),e.useSpecularityFactor&&r.append(" dReflection.rgb *= litArgs_specularityFactor;")),d&&(r.append(" dSpecularLight *= litArgs_specularity;"),e.useSpecular&&r.append(" calcLTCLightValues(litArgs_gloss, litArgs_worldNormal, dViewDirW, litArgs_specularity, litArgs_clearcoat_gloss, litArgs_clearcoat_worldNormal, litArgs_clearcoat_specularity);"));for(var C=0;C 0.00001) {"),2===P&&(S&&!M._cookieFalloff||(r.append(" dAtten *= getSpotEffect(light"+C+"_direction, light"+C+"_innerConeAngle, light"+C+"_outerConeAngle, dLightDirNormW);"),E=!0))),0!==R?0===P?r.append(" dAttenD = getLightDiffuse(litArgs_worldNormal, dViewDirW, dLightDirW, dLightDirNormW);"):r.append(" dAttenD = get"+I+"LightDiffuse(litArgs_worldNormal, dViewDirW, dLightDirW, dLightDirNormW) * 16.0;"):r.append(" dAtten *= getLightDiffuse(litArgs_worldNormal, dViewDirW, dLightDirW, dLightDirNormW);"),M.castShadows&&!e.noShadow){var D=6===M._shadowType,L=1===M._shadowType||2===M._shadowType||3===M._shadowType,k=5===M._shadowType||0===M._shadowType||4===M._shadowType,O=null,F=void 0;switch(M._shadowType){case 1:O="VSM8",F="0.0";break;case 2:O="VSM16",F="5.54";break;case 3:O="VSM32",F=t.textureFloatHighPrecision?"15.0":"5.54";break;case 5:O="PCF1x1";break;case 4:O="PCF5x5";break;case 6:O="PCSS";break;default:O="PCF3x3"}if(null!==O){M._normalOffsetBias&&!M._isVsm&&s.append("#define SHADOW_SAMPLE_NORMAL_OFFSET"),0===P&&s.append("#define SHADOW_SAMPLE_ORTHO"),((k||D)&&t.isWebGL2||t.isWebGPU||t.extStandardDerivatives)&&s.append("#define SHADOW_SAMPLE_SOURCE_ZBUFFER"),1===P&&s.append("#define SHADOW_SAMPLE_POINT");var B=i.shadowSampleCoordPS;s.append(B.replace("$LIGHT",C)),s.append("#undef SHADOW_SAMPLE_NORMAL_OFFSET"),s.append("#undef SHADOW_SAMPLE_ORTHO"),s.append("#undef SHADOW_SAMPLE_SOURCE_ZBUFFER"),s.append("#undef SHADOW_SAMPLE_POINT");var N="light"+C+"_shadowMatrix";0===P&&M.numCascades>1&&(r.append(" getShadowCascadeMatrix(light"+C+"_shadowMatrixPalette, light"+C+"_shadowCascadeDistances, light"+C+"_shadowCascadeCount);"),N="cascadeShadowMat"),r.append(" dShadowCoord = getShadowSampleCoord"+C+"("+N+", light"+C+"_shadowParams, vPositionW, dLightPosW, dLightDirW, dLightDirNormW, dVertexNormalW);"),0===P&&r.append(" fadeShadow(light"+C+"_shadowCascadeDistances);");var U="SHADOWMAP_PASS(light"+C+"_shadowMap), dShadowCoord, light"+C+"_shadowParams";if(L)U=U+", "+F+", dLightDirW";else if(D){var z="vec2(light"+C+"_shadowSearchArea)";0!==R&&(z="vec2(length(light"+C+"_halfWidth), length(light"+C+"_halfHeight)) * light"+C+"_shadowSearchArea"),U=U+", light"+C+"_cameraParams, "+z+", dLightDirW"}1===P?(O="Point"+O,D||(U+=", dLightDirW")):2===P&&(O="Spot"+O),r.append(" float shadow"+C+" = getShadow"+O+"("+U+");"),r.append(" dAtten *= mix(1.0, shadow"+C+", light"+C+"_shadowIntensity);")}}if(0!==R?e.conserveEnergy&&e.useSpecular?r.append(" dDiffuseLight += ((dAttenD * dAtten) * light"+C+"_color"+(S?" * dAtten3":"")+") * (1.0 - dLTCSpecFres);"):r.append(" dDiffuseLight += (dAttenD * dAtten) * light"+C+"_color"+(S?" * dAtten3":"")+";"):d&&e.conserveEnergy&&e.useSpecular?r.append(" dDiffuseLight += (dAtten * light"+C+"_color"+(S?" * dAtten3":"")+") * (1.0 - litArgs_specularity);"):r.append(" dDiffuseLight += dAtten * light"+C+"_color"+(S?" * dAtten3":"")+";"),e.useSpecular&&r.append(" dHalfDirW = normalize(-dLightDirNormW + dViewDirW);"),M.affectSpecularity)if(0!==R)e.useClearCoat&&r.append(" ccSpecularLight += ccLTCSpecFres * get"+I+"LightSpecular(litArgs_clearcoat_worldNormal, dViewDirW) * dAtten * light"+C+"_color"+(S?" * dAtten3":"")+";"),e.useSpecular&&r.append(" dSpecularLight += dLTCSpecFres * get"+I+"LightSpecular(litArgs_worldNormal, dViewDirW) * dAtten * light"+C+"_color"+(S?" * dAtten3":"")+";");else{var V=!1;0===P&&e.fresnelModel>0&&(V=!0),e.useClearCoat&&r.append(" ccSpecularLight += getLightSpecular(dHalfDirW, ccReflDirW, litArgs_clearcoat_worldNormal, dViewDirW, dLightDirNormW, litArgs_clearcoat_gloss, dTBN) * dAtten * light"+C+"_color"+(S?" * dAtten3":"")+(V?" * getFresnelCC(dot(dViewDirW, dHalfDirW));":";")),e.useSheen&&r.append(" sSpecularLight += getLightSpecularSheen(dHalfDirW, litArgs_worldNormal, dViewDirW, dLightDirNormW, litArgs_sheen_gloss) * dAtten * light"+C+"_color"+(S?" * dAtten3;":";")),e.useSpecular&&r.append(" dSpecularLight += getLightSpecular(dHalfDirW, dReflDirW, litArgs_worldNormal, dViewDirW, dLightDirNormW, litArgs_gloss, dTBN) * dAtten * light"+C+"_color"+(S?" * dAtten3":"")+(V?" \n * getFresnel(\n dot(dViewDirW, dHalfDirW), \n litArgs_gloss, \n litArgs_specularity\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel, \n litArgs_iridescence_intensity\n #endif\n );":"* litArgs_specularity;"))}0!==P&&r.append(" }")}}e.clusteredLightingEnabled&&this.lighting&&(T=!0,w=!0,b=!0,r.append(" addClusteredLights(\n litArgs_worldNormal, \n dViewDirW, \n dReflDirW,\n #if defined(LIT_CLEARCOAT)\n ccReflDirW,\n #endif\n litArgs_gloss, \n litArgs_specularity, \n dVertexNormalW, \n dTBN, \n #if defined(LIT_IRIDESCENCE)\n iridescenceFresnel,\n #endif\n litArgs_clearcoat_worldNormal, \n litArgs_clearcoat_gloss,\n litArgs_sheen_gloss,\n litArgs_iridescence_intensity\n );")),d&&(e.useClearCoat&&r.append(" litArgs_clearcoat_specularity = 1.0;"),e.useSpecular&&r.append(" litArgs_specularity = vec3(1);")),e.useRefraction&&r.append(" addRefraction(\n litArgs_worldNormal, \n dViewDirW, \n litArgs_thickness, \n litArgs_gloss, \n litArgs_specularity, \n litArgs_albedo, \n litArgs_transmission,\n litArgs_ior,\n litArgs_dispersion\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel, \n litArgs_iridescence_intensity\n #endif\n );")}e.useAo&&(e.occludeDirect&&r.append(" occludeDiffuse(litArgs_ao);"),1!==e.occludeSpecular&&2!==e.occludeSpecular||r.append(" occludeSpecular(litArgs_gloss, litArgs_ao, litArgs_worldNormal, dViewDirW);")),e.useSpecularityFactor&&r.append(" dSpecularLight *= litArgs_specularityFactor;"),!1===e.opacityFadesSpecular&&(2!==e.blendType&&4!==e.blendType||(r.append("float specLum = dot((dSpecularLight + dReflection.rgb * dReflection.a), vec3( 0.2126, 0.7152, 0.0722 ));"),r.append("#ifdef LIT_CLEARCOAT\n specLum += dot(ccSpecularLight * litArgs_clearcoat_specularity + ccReflection.rgb * litArgs_clearcoat_specularity, vec3( 0.2126, 0.7152, 0.0722 ));\n#endif"),r.append("litArgs_opacity = clamp(litArgs_opacity + gammaCorrectInput(specLum), 0.0, 1.0);")),r.append("litArgs_opacity *= material_alphaFade;")),r.append(i.endPS),2===e.blendType||6===e.blendType||e.alphaToCoverage?r.append(i.outputAlphaPS):4===e.blendType?r.append(i.outputAlphaPremulPS):r.append(i.outputAlphaOpaquePS),e.useMsdf&&r.append(" gl_FragColor = applyMsdf(gl_FragColor);"),r.append(i.outputPS),r.append(i.debugOutputPS),b&&s.prepend(i.lightDirPointPS),T&&s.prepend(i.falloffLinearPS),w&&s.prepend(i.falloffInvSquaredPS),E&&s.prepend(i.spotPS),A&&!e.clusteredLightingEnabled&&s.prepend(i.cookiePS);var G="",H="void evaluateBackend() {\n"+r.code+"\n}";s.append(H),a.append(i.debugProcessFrontendPS),a.append(" evaluateBackend();"),a.append(ko.end());var W=n.code+s.code+a.code;return W.includes("dTBN")&&(G+="mat3 dTBN;\n"),W.includes("dVertexNormalW")&&(G+="vec3 dVertexNormalW;\n"),W.includes("dTangentW")&&(G+="vec3 dTangentW;\n"),W.includes("dBinormalW")&&(G+="vec3 dBinormalW;\n"),W.includes("dViewDirW")&&(G+="vec3 dViewDirW;\n"),W.includes("dReflDirW")&&(G+="vec3 dReflDirW;\n"),W.includes("dHalfDirW")&&(G+="vec3 dHalfDirW;\n"),W.includes("ccReflDirW")&&(G+="vec3 ccReflDirW;\n"),W.includes("dLightDirNormW")&&(G+="vec3 dLightDirNormW;\n"),W.includes("dLightDirW")&&(G+="vec3 dLightDirW;\n"),W.includes("dLightPosW")&&(G+="vec3 dLightPosW;\n"),W.includes("dShadowCoord")&&(G+="vec3 dShadowCoord;\n"),W.includes("dReflection")&&(G+="vec4 dReflection;\n"),W.includes("dDiffuseLight")&&(G+="vec3 dDiffuseLight;\n"),W.includes("dSpecularLight")&&(G+="vec3 dSpecularLight;\n"),W.includes("dAtten")&&(G+="float dAtten;\n"),W.includes("dAttenD")&&(G+="float dAttenD;\n"),W.includes("dAtten3")&&(G+="vec3 dAtten3;\n"),W.includes("dMsdf")&&(G+="vec4 dMsdf;\n"),W.includes("ccFresnel")&&(G+="float ccFresnel;\n"),W.includes("ccReflection")&&(G+="vec3 ccReflection;\n"),W.includes("ccSpecularLight")&&(G+="vec3 ccSpecularLight;\n"),W.includes("ccSpecularityNoFres")&&(G+="float ccSpecularityNoFres;\n"),W.includes("sSpecularLight")&&(G+="vec3 sSpecularLight;\n"),W.includes("sReflection")&&(G+="vec3 sReflection;\n"),this._fsGetBeginCode()+this.varyings+this.varyingDefines+this._fsGetBaseCode()+G+this.frontendDecl+W},e.generateFragmentShader=function(t,e,i,n){var s,r=this.options;this.frontendDecl=t,this.frontendCode=e,this.frontendFunc=i,this.lightingUv=n,3===r.pass?this.fshader=this._fsGetPickPassCode():2===r.pass?this.fshader=this._fsGetDepthPassCode():5===r.pass?this.fshader=this._fsGetPrePassVelocityCode():this.shadowPass?this.fshader=this._fsGetShadowPassCode():r.customFragmentShader?this.fshader=this._fsGetBeginCode()+r.customFragmentShader:this.fshader=this._fsGetLitPassCode(),null==(s=this.handleCompatibility)||s.call(this)},e.getDefinition=function(){var t=Pr.createDefinition(this.device,{name:"LitShader",attributes:this.attributes,vertexCode:this.vshader,fragmentCode:this.fshader});return this.shaderPassInfo.isForward&&(t.tag=1),t},t}(),Il={generateKey:function(t){return"lit"+Object.keys(t).sort().map((function(e){return"chunks"===e?Il.generateChunksKey(t):"lights"===e?Il.generateLightsKey(t):e+t[e]})).join("\n")},generateLightsKey:function(t){return"lights:"+t.lights.map((function(e){return t.clusteredLightingEnabled&&0!==e._type?"":e.key+","})).join("")},generateChunksKey:function(t){var e;return"chunks:\n"+Object.keys(null!=(e=t.chunks)?e:{}).sort().map((function(e){return e+t.chunks[e]})).join("")}},Dl=[0,1,2,3,4,5,6,7],Ll=function(t){function e(){return t.apply(this,arguments)||this}x(e,t);var i=e.prototype;return i.generateKey=function(t){return"lit"+Dl.map((function(e,i){return t.usedUvs[i]?"1":"0"})).join("")+t.shaderChunk+Il.generateKey(t.litOptions)},i.createShaderDefinition=function(t,e){var i=new Rl(t,e.litOptions),n=new dl,s=new dl,r=new dl;n.append("uniform float textureBias;"),n.append(i.chunks.litShaderArgsPS),s.append(e.shaderChunk),r.code="evaluateFrontend();",r.code="\n"+r.code.split("\n").map((function(t){return" "+t})).join("\n")+"\n\n";var a=e.usedUvs||[!0];return i.generateVertexShader(a,a,[]),i.generateFragmentShader(n.code,s.code,r.code,"vUv0"),i.getDefinition()},e}(ko),kl=new Ll,Ol=new function(){this.usedUvs=void 0,this.shaderChunk=void 0,this.litOptions=new cl},Fl=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),s=0;s1?0:1),this.lightsBuffer.updateUniforms(),this._clusterWorldTextureId.setValue(this.clusterTexture),this._clusterMaxCellsId.setValue(this.maxCellLightCount);var t=this.boundsDelta;this._clusterCellsCountByBoundsSizeData[0]=this._cells.x/t.x,this._clusterCellsCountByBoundsSizeData[1]=this._cells.y/t.y,this._clusterCellsCountByBoundsSizeData[2]=this._cells.z/t.z,this._clusterCellsCountByBoundsSizeId.setValue(this._clusterCellsCountByBoundsSizeData),this._clusterBoundsMinData[0]=this.boundsMin.x,this._clusterBoundsMinData[1]=this.boundsMin.y,this._clusterBoundsMinData[2]=this.boundsMin.z,this._clusterBoundsDeltaData[0]=t.x,this._clusterBoundsDeltaData[1]=t.y,this._clusterBoundsDeltaData[2]=t.z,this._clusterCompressionLimit0Data[0]=this._maxAttenuation,this._clusterCompressionLimit0Data[1]=this._maxColorValue,this._clusterTextureSizeId.setValue(this._clusterTextureSizeData),this._clusterBoundsMinId.setValue(this._clusterBoundsMinData),this._clusterBoundsDeltaId.setValue(this._clusterBoundsDeltaData),this._clusterCellsDotId.setValue(this._clusterCellsDotData),this._clusterCellsMaxId.setValue(this._clusterCellsMaxData),this._clusterCompressionLimit0Id.setValue(this._clusterCompressionLimit0Data)},e.evalLightCellMinMax=function(t,e,i){e.copy(t.min),e.sub(this.boundsMin),e.div(this.boundsDelta),e.mul2(e,this.cells),e.floor(),i.copy(t.max),i.sub(this.boundsMin),i.div(this.boundsDelta),i.mul2(i,this.cells),i.ceil(),e.max(wt.ZERO),i.min(this._cellsLimit)},e.collectLights=function(t){var e=this.lightsBuffer.maxLights,i=this._usedLights,n=1;t.forEach((function(t){var s,r=!!(3&t.mask),a=2===t.type&&0===t._outerConeAngle;t.enabled&&0!==t.type&&t.visibleThisFrame&&t.intensity>0&&r&&!a&&(n1){e.copy(t[1].min),i.copy(t[1].max);for(var n=2;n>>16)>>>0;return 2.3283064365386963e-10*(e=((16711935&(e=((252645135&(e=((858993459&(e=((1431655765&e)<<1|(2863311530&e)>>>1)>>>0))<<2|(3435973836&e)>>>2)>>>0))<<4|(4042322160&e)>>>4)>>>0))<<8|(4278255360&e)>>>8)>>>0)},Yl=function(t){switch(t){case Si:return"Cubemap";case Ti:return"Octahedral";default:return"Equirect"}},Kl=function(t,e,i){if(t<=0)e[i+0]=0,e[i+1]=0,e[i+2]=0,e[i+3]=0;else if(t>=1)e[i+0]=255,e[i+1]=0,e[i+2]=0,e[i+3]=0;else{var n=1*t%1,s=255*t%1,r=65025*t%1,a=16581375*t%1;n-=s/255,s-=r/255,r-=a/255,e[i+0]=Math.min(255,Math.floor(256*n)),e[i+1]=Math.min(255,Math.floor(256*s)),e[i+2]=Math.min(255,Math.floor(256*r)),e[i+3]=Math.min(255,Math.floor(256*a))}},Zl=function(t,e,i,n){var s=2*i*Math.PI,r=Math.pow(1-e,1/(n+1)),a=Math.sqrt(1-r*r);t.set(Math.cos(s)*a,Math.sin(s)*a,r).normalize()},Ql=function(t,e,i){var n=2*i*Math.PI,s=Math.sqrt(1-e),r=Math.sqrt(e);t.set(Math.cos(n)*r,Math.sin(n)*r,s).normalize()},Jl=function(t,e,i,n){var s=2*i*Math.PI,r=Math.sqrt((1-e)/(1+(n*n-1)*e)),a=Math.sqrt(1-r*r);t.set(Math.cos(s)*a,Math.sin(s)*a,r).normalize()},$l=function(t,e){var i=t*e,n=e/(1-t*t+i*i);return n*n*(1/Math.PI)},tc={16:{2:26,8:20,32:17,128:16,512:16},32:{2:53,8:40,32:34,128:32,512:32},128:{2:214,8:163,32:139,128:130,512:128},1024:{2:1722,8:1310,32:1114,128:1041,512:1025}},ec=function(t,e,i){for(var n=i/t,s=1-Math.log2(e)/11,r=s*s,a=new wt,o=new wt,h=new wt(0,0,1),l=[],c=function(t,e){var i=tc[t];return i&&i[e]||t}(t,e),u=0;u0){var f=$l(Math.min(1,d),r)/4+.001,p=.5*Math.log2(n/f);l.push(o.x,o.y,o.z,p)}}for(;l.length<4*t;)l.push(0,0,0,0);return l},ic=function(t,e,i){var n=function(t){for(var e=t.length,i=Math.min(e,512),n=Math.ceil(e/i),s=new Uint8Array(i*n*4),r=0,a=0;a0?E.setValue([(l+2*h)/l,(c+2*h)/c,-h/l,-h/c]):E.setValue([1,1,0,0]);var A=[0,t.fixCubemapSeams?1/t.width:0,e.fixCubemapSeams?1/e.width:0];if(m){var C=t.width*t.height*(t.cubemap?6:1),M="ggx"===f?function(t,e,i,n){return ac(t,"ggx-samples-"+e+"-"+i+"-"+n,(function(){return ec(e,i,n)}))}(b,x,u,C):"lambert"===f?oc(b,x,C):hc(b,x,u);b.scope.resolve("samplesTex").setValue(M),b.scope.resolve("samplesTexInverseSize").setValue([1/M.width,1/M.height])}for(var P=0;P<(e.cubemap?6:1);P++)if(null===d||P===d){var R,I=new Cn({colorBuffer:e,face:P,depth:!1,flipY:b.isWebGPU});A[0]=P,w.setValue(A),Xo(b,I,T,null==(R=i)?void 0:R.rect),I.destroy()}return!0}var cc=function(t,e){return void 0===e&&(e=0),1+Math.floor(Math.log2(Math.max(t,e)))},uc=function(){function t(){}return t.generateSkyboxCubemap=function(t,e){var i=function(t,e,i,n){return new or(t,{name:"lighting-"+e,cubemap:!0,width:e,height:e,format:i,type:pi,addressU:1,addressV:1,fixCubemapSeams:!0,mipmaps:!!n})}(t.device,e||(t.cubemap?t.width:t.width/4),7,!1);return lc(t,i,{numSamples:1024}),i},t.generateLightingSource=function(t,e){var i=t.device,n=function(t){return function(t){return t.extTextureHalfFloat&&t.textureHalfFloatRenderable}(t)?me:function(t){return t.extTextureFloat&&t.textureFloatRenderable}(t)?ve:7}(i),s=(null==e?void 0:e.target)||new or(i,{name:"lighting-source",cubemap:!0,width:(null==e?void 0:e.size)||128,height:(null==e?void 0:e.size)||128,format:n,type:7===n?pi:ui,addressU:1,addressV:1,fixCubemapSeams:!1,mipmaps:!0});return lc(t,s,{numSamples:t.mipmaps?1:1024}),s},t.generateAtlas=function(t,e){for(var i=t.device,n=(null==e?void 0:e.target)||new or(i,{name:"envAtlas",width:(null==e?void 0:e.size)||512,height:(null==e?void 0:e.size)||512,format:7,type:pi,projection:bi,addressU:1,addressV:1,mipmaps:!1}),s=n.width/512,r=new Rt(0,0,512*s,256*s),a=cc(256)-cc(4),o=0;o>2*h),rect:r,seamPixels:s}),r.y+=r.w,r.z=Math.max(1,Math.floor(.5*r.z)),r.w=Math.max(1,Math.floor(.5*r.w));return r.set(128*s,384*s,64*s,32*s),lc(t,n,{numSamples:(null==e?void 0:e.numAmbientSamples)||2048,distribution:"lambert",rect:r,seamPixels:s}),n},t.generatePrefilteredAtlas=function(t,e){for(var i=t[0].device,n=t[0].format,s=t[0].type,r=(null==e?void 0:e.target)||new or(i,{name:"envPrefilteredAtlas",width:(null==e?void 0:e.size)||512,height:(null==e?void 0:e.size)||512,format:n,type:s,projection:bi,addressU:1,addressV:1,mipmaps:!1}),a=r.width/512,o=new Rt(0,0,512*a,256*a),h=cc(512),l=0;l0){if(i[t]e.length){for(var n=e,s=n.charAt(n.length-1),r=i[t]-n.length,a=0;a0,t.litOptions.blendType=i.blendType,t.litOptions.screenSpace=n&&!!(n&go),t.litOptions.skin=n&&!!(2&n),t.litOptions.useInstancing=n&&!!(n&_o),t.litOptions.useMorphPosition=n&&!!(n&xo),t.litOptions.useMorphNormal=n&&!!(n&So),t.litOptions.useMorphTextureBased=n&&!!(n&bo),t.litOptions.nineSlicedMode=i.nineSlicedMode||0,e.clusteredLightingEnabled&&i.useLighting?(t.litOptions.clusteredLightingEnabled=!0,t.litOptions.clusteredLightingCookiesEnabled=e.lighting.cookiesEnabled,t.litOptions.clusteredLightingShadowsEnabled=e.lighting.shadowsEnabled,t.litOptions.clusteredLightingShadowType=e.lighting.shadowType,t.litOptions.clusteredLightingAreaLightsEnabled=e.lighting.areaLightsEnabled):(t.litOptions.clusteredLightingEnabled=!1,t.litOptions.clusteredLightingCookiesEnabled=!1,t.litOptions.clusteredLightingShadowsEnabled=!1,t.litOptions.clusteredLightingAreaLightsEnabled=!1)},e._updateUVOptions=function(t,e,i,n){var s=!1,r=!1,a=!1;i&&(s=!!(4&i),r=!!(8&i),a=!!(16&i)),t.litOptions.vertexColors=!1,this._mapXForms=[];var o={};for(var h in fc)this._updateTexOptions(t,e,h,s,r,a,n,o);this._mapXForms=null,t.litOptions.lightMapEnabled=t.lightMap,t.litOptions.dirLightMapEnabled=t.dirLightMap,t.litOptions.useHeights=t.heightMap,t.litOptions.useNormals=t.normalMap,t.litOptions.useClearCoatNormals=t.clearCoatNormalMap,t.litOptions.useAo=t.aoMap||t.aoVertexColor,t.litOptions.diffuseMapEnabled=t.diffuseMap},e._updateTexOptions=function(t,e,i,n,s,r,a,o){var h="opacity"===i;if(!a||h){var l=i+"Map",c=i+"VertexColor",u=i+"VertexColorChannel",d=l+"Channel",f=l+"Transform",p=l+"Uv",m=l+"Identifier";if("light"!==i&&(t[l]=!1,t[m]=void 0,t[d]="",t[f]=0,t[p]=0),t[c]=!1,t[u]="",h&&3===e.blendType&&0===e.alphaTest&&!e.alphaToCoverage&&e.opacityDither===Ao)return;if("height"!==i&&e[c]&&r&&(t[c]=e[c],t[u]=e[u],t.litOptions.vertexColors=!0),e[l]){var _=!0;if(0!==e[p]||n||(_=!1),1!==e[p]||s||(_=!1),_){var v=e[l].id,g=o[v];void 0===g&&(o[v]=i,g=i),t[l]=!!e[l],t[m]=g,t[f]=this._getMapTransformID(e.getUniform(f),e[p]),t[d]=e[d],t[p]=e[p]}}}},e._updateMinOptions=function(t,e,i){t.opacityTint=3!==e.blendType||e.opacityShadowDither!==Ao;var n=5===i;t.litOptions.opacityShadowDither=n?e.opacityDither:e.opacityShadowDither,t.litOptions.lights=[]},e._updateMaterialOptions=function(t,e){var i,n,s,r,a,o=e.diffuseTint||!e.diffuseMap&&!e.diffuseVertexColor,h=!!(e.useMetalness||e.specularMap||e.sphereMap||e.cubeMap||(a=e.specular,0!==a.r||0!==a.g||0!==a.b)||e.specularityFactor>0&&e.useMetalness||e.enableGGXSpecular||e.clearCoat>0),l=!e.useMetalness||e.useMetalnessSpecularColor,c=h&&(e.specularTint||!e.specularMap&&!e.specularVertexColor)&&gc(e.specular),u=h&&e.useMetalnessSpecularColor&&(e.specularityFactorTint||e.specularityFactor<1&&!e.specularityFactorMap),d=!e.emissiveMap||gc(e.emissive)&&e.emissiveTint,f=1!==e.emissiveIntensity,p=!!e.normalMap&&(e.normalMap.format===fe||e.normalMap.type===mi);t.opacityTint=3!==e.blendType||e.alphaTest>0||e.opacityDither!==Ao?1:0,t.ambientTint=e.ambientTint,t.diffuseTint=o?2:0,t.specularTint=c?2:0,t.specularityFactorTint=u?1:0,t.metalnessTint=e.useMetalness&&e.metalness<1?1:0,t.glossTint=1,t.emissiveTint=(d?2:0)+(f?1:0),t.diffuseEncoding=null==(i=e.diffuseMap)?void 0:i.encoding,t.diffuseDetailEncoding=null==(n=e.diffuseDetailMap)?void 0:n.encoding,t.emissiveEncoding=null==(s=e.emissiveMap)?void 0:s.encoding,t.lightMapEncoding=null==(r=e.lightMap)?void 0:r.encoding,t.packedNormal=p,t.refractionTint=1!==e.refraction?1:0,t.refractionIndexTint=e.refractionIndex!==1/1.5?1:0,t.thicknessTint=e.useDynamicRefraction&&1!==e.thickness?1:0,t.specularEncoding=e.specularEncoding||"linear",t.sheenEncoding=e.sheenEncoding||"linear",t.aoMapUv=e.aoUvSet,t.aoDetail=!!e.aoMap,t.diffuseDetail=!!e.diffuseMap,t.normalDetail=!!e.normalMap,t.diffuseDetailMode=e.diffuseDetailMode,t.aoDetailMode=e.aoDetailMode,t.clearCoatTint=1!==e.clearCoat?1:0,t.clearCoatGloss=!!e.clearCoatGloss,t.clearCoatGlossTint=1!==e.clearCoatGloss?1:0,t.iorTint=e.refractionIndex!==1/1.5?1:0,t.iridescenceTint=1!==e.iridescence?1:0,t.sheenTint=e.useSheen&&gc(e.sheen)?2:0,t.sheenGlossTint=1,t.glossInvert=e.glossInvert,t.sheenGlossInvert=e.sheenGlossInvert,t.clearCoatGlossInvert=e.clearCoatGlossInvert,t.useSpecularColor=l,t.litOptions.separateAmbient=!1,t.litOptions.useAmbientTint=e.ambientTint,t.litOptions.customFragmentShader=e.customFragmentShader,t.litOptions.pixelSnap=e.pixelSnap,t.litOptions.shadingModel=e.shadingModel,t.litOptions.ambientSH=!!e.ambientSH,t.litOptions.fastTbn=e.fastTbn,t.litOptions.twoSidedLighting=e.twoSidedLighting,t.litOptions.occludeSpecular=e.occludeSpecular,t.litOptions.occludeSpecularFloat=1!==e.occludeSpecularIntensity,t.litOptions.useMsdf=!!e.msdfMap,t.litOptions.msdfTextAttribute=!!e.msdfTextAttribute,t.litOptions.alphaToCoverage=e.alphaToCoverage,t.litOptions.opacityFadesSpecular=e.opacityFadesSpecular,t.litOptions.opacityDither=e.opacityDither,t.litOptions.cubeMapProjection=e.cubeMapProjection,t.litOptions.occludeDirect=e.occludeDirect,t.litOptions.conserveEnergy=e.conserveEnergy&&0!==e.shadingModel,t.litOptions.useSpecular=h,t.litOptions.useSpecularityFactor=(u||!!e.specularityFactorMap)&&e.useMetalnessSpecularColor,t.litOptions.enableGGXSpecular=e.enableGGXSpecular,t.litOptions.fresnelModel=e.fresnelModel,t.litOptions.useRefraction=(e.refraction||!!e.refractionMap)&&(e.useDynamicRefraction||!!t.litOptions.reflectionSource),t.litOptions.useClearCoat=!!e.clearCoat,t.litOptions.useSheen=e.useSheen,t.litOptions.useIridescence=e.useIridescence&&0!==e.iridescence,t.litOptions.useMetalness=e.useMetalness,t.litOptions.useDynamicRefraction=e.useDynamicRefraction,t.litOptions.dispersion=e.dispersion>0},e._updateEnvOptions=function(t,e,i){t.litOptions.fog=e.useFog?i.fog:"none",t.litOptions.gamma=e.useGammaTonemap?i.gammaCorrection:0,t.litOptions.toneMap=e.useGammaTonemap?i.toneMapping:-1,t.litOptions.fixSeams=!!e.cubeMap&&e.cubeMap.fixCubemapSeams;var n=0===e.shadingModel,s=!1;if(e.envAtlas&&e.cubeMap&&!n?(t.litOptions.reflectionSource="envAtlasHQ",t.litOptions.reflectionEncoding=e.envAtlas.encoding,t.litOptions.reflectionCubemapEncoding=e.cubeMap.encoding):e.envAtlas&&!n?(t.litOptions.reflectionSource="envAtlas",t.litOptions.reflectionEncoding=e.envAtlas.encoding):e.cubeMap?(t.litOptions.reflectionSource="cubeMap",t.litOptions.reflectionEncoding=e.cubeMap.encoding):e.sphereMap?(t.litOptions.reflectionSource="sphereMap",t.litOptions.reflectionEncoding=e.sphereMap.encoding):e.useSkybox&&i.envAtlas&&i.skybox&&!n?(t.litOptions.reflectionSource="envAtlasHQ",t.litOptions.reflectionEncoding=i.envAtlas.encoding,t.litOptions.reflectionCubemapEncoding=i.skybox.encoding,s=!0):e.useSkybox&&i.envAtlas&&!n?(t.litOptions.reflectionSource="envAtlas",t.litOptions.reflectionEncoding=i.envAtlas.encoding,s=!0):e.useSkybox&&i.skybox?(t.litOptions.reflectionSource="cubeMap",t.litOptions.reflectionEncoding=i.skybox.encoding,s=!0):(t.litOptions.reflectionSource=null,t.litOptions.reflectionEncoding=null),e.ambientSH&&!n)t.litOptions.ambientSource="ambientSH",t.litOptions.ambientEncoding=null;else{var r=e.envAtlas||(e.useSkybox&&i.envAtlas?i.envAtlas:null);r&&!n?(t.litOptions.ambientSource="envAtlas",t.litOptions.ambientEncoding=r.encoding):(t.litOptions.ambientSource="constant",t.litOptions.ambientEncoding=null)}t.litOptions.skyboxIntensity=s,t.litOptions.useCubeMapRotation=s&&i._skyboxRotationShaderInclude},e._updateLightOptions=function(t,e,i,n,s){if(t.lightMap=!1,t.lightMapChannel="",t.lightMapUv=0,t.lightMapTransform=0,t.litOptions.lightMapWithoutAmbient=!1,t.dirLightMap=!1,n&&(t.litOptions.noShadow=!!(1&n),64&n&&(t.lightMapEncoding=7===e.lightmapPixelFormat?"rgbm":"linear",t.lightMap=!0,t.lightMapChannel="rgb",t.lightMapUv=1,t.lightMapTransform=0,t.litOptions.lightMapWithoutAmbient=!i.lightMap,n&vo&&(t.dirLightMap=!0),n&To&&(t.litOptions.lightMapWithoutAmbient=!1))),i.useLighting){var r=[],a=n?n>>16:1;t.litOptions.lightMaskDynamic=!!(1&a),s&&(ul.collectLights(0,s[0],r,a),ul.collectLights(1,s[1],r,a),ul.collectLights(2,s[2],r,a)),t.litOptions.lights=r}else t.litOptions.lights=[];0===t.litOptions.lights.length&&(t.litOptions.noShadow=!0)},e._getMapTransformID=function(t,e){if(!t)return 0;var i=this._mapXForms[e];i||(i=[],this._mapXForms[e]=i);for(var n=0;n0&&(this._setParameter("material_clearCoat",this.clearCoat),this._setParameter("material_clearCoatGloss",this.clearCoatGloss),this._setParameter("material_clearCoatBumpiness",this.clearCoatBumpiness)),this._setParameter("material_gloss",n("gloss")),this.emissiveMap&&!this.emissiveTint||this._setParameter("material_emissive",n("emissive")),1!==this.emissiveIntensity&&this._setParameter("material_emissiveIntensity",this.emissiveIntensity),this.refraction>0&&this._setParameter("material_refraction",this.refraction),this.dispersion>0&&this._setParameter("material_dispersion",this.dispersion),this.useDynamicRefraction&&(this._setParameter("material_thickness",this.thickness),this._setParameter("material_attenuation",n("attenuation")),this._setParameter("material_invAttenuationDistance",0===this.attenuationDistance?0:1/this.attenuationDistance)),this.useIridescence&&(this._setParameter("material_iridescence",this.iridescence),this._setParameter("material_iridescenceRefractionIndex",this.iridescenceRefractionIndex),this._setParameter("material_iridescenceThicknessMin",this.iridescenceThicknessMin),this._setParameter("material_iridescenceThicknessMax",this.iridescenceThicknessMax)),this._setParameter("material_opacity",this.opacity),!1===this.opacityFadesSpecular&&this._setParameter("material_alphaFade",this.alphaFade),this.occludeSpecular&&this._setParameter("material_occludeSpecularIntensity",this.occludeSpecularIntensity),1===this.cubeMapProjection&&this._setParameter(n("cubeMapProjectionBox")),fc)this._updateMap(s);this.ambientSH&&this._setParameter("ambientSH[0]",this.ambientSH),this.normalMap&&this._setParameter("material_bumpiness",this.bumpiness),this.normalMap&&this.normalDetailMap&&this._setParameter("material_normalDetailMapBumpiness",this.normalDetailMapBumpiness),this.heightMap&&this._setParameter("material_heightMapFactor",n("heightMapFactor"));var r=0===this.shadingModel;this.envAtlas&&this.cubeMap&&!r?(this._setParameter("texture_envAtlas",this.envAtlas),this._setParameter("texture_cubeMap",this.cubeMap)):this.envAtlas&&!r?this._setParameter("texture_envAtlas",this.envAtlas):this.cubeMap?this._setParameter("texture_cubeMap",this.cubeMap):this.sphereMap&&this._setParameter("texture_sphereMap",this.sphereMap),this._setParameter("material_reflectivity",this.reflectivity),this._processParameters("_activeParams"),this._dirtyShader&&this.clearVariants()},i.updateEnvUniforms=function(t,e){var i=0===this.shadingModel;!(this.envAtlas&&!i||this.cubeMap||this.sphereMap)&&this.useSkybox&&(e.envAtlas&&e.skybox&&!i?(this._setParameter("texture_envAtlas",e.envAtlas),this._setParameter("texture_cubeMap",e.skybox)):e.envAtlas&&!i?this._setParameter("texture_envAtlas",e.envAtlas):e.skybox&&this._setParameter("texture_cubeMap",e.skybox)),this._processParameters("_activeLightingParams")},i.getShaderVariant=function(t,e,i,n,s,r,a,o,h){this.updateEnvUniforms(t,e);var l=Yo.get(t).getByIndex(s),c=2===s||3===s||5===s||l.isShadow,u=c?_c.optionsContextMin:_c.optionsContext;c?this.shaderOptBuilder.updateMinRef(u,e,this,i,s,r):this.shaderOptBuilder.updateRef(u,e,this,i,s,r),this.onUpdateShader&&(u=this.onUpdateShader(u));var d=new Zr(a,o,h),f=Do(t);f.register("standard",_c);var p=f.getProgram("standard",u,d,this.userId);return this._dirtyShader=!1,p},i.destroy=function(){for(var e in this._assetReferences)this._assetReferences[e]._unbind();this._assetReferences=null,t.prototype.destroy.call(this)},v(e,[{key:"shader",get:function(){return null},set:function(t){}},{key:"chunks",get:function(){return this._dirtyShader=!0,this._chunks},set:function(t){this._dirtyShader=!0,this._chunks=t}}])}(eh);Lc.TEXTURE_PARAMETERS=Ec,Lc.CUBEMAP_PARAMETERS=Cc;var kc=function(t,e){Ic[t]=e},Oc=function(t,e,i,n){Object.defineProperty(Lc.prototype,t,{get:n||function(){return this["_"+t]},set:i}),Rc[t]={value:e}},Fc=function(t){return t.defaultValue&&t.defaultValue.clone?function(t){var e="_"+t.name,i=t.dirtyShaderFunc||function(){return!0};Oc(t.name,(function(){return t.defaultValue.clone()}),(function(t){var n=this[e];n.equals(t)||(this._dirtyShader=this._dirtyShader||i(n,t),this[e]=n.copy(t))}),t.getterFunc)}(t):function(t){var e="_"+t.name,i=t.dirtyShaderFunc||function(){return!0};Oc(t.name,(function(){return t.defaultValue}),(function(t){var n=this[e];n!==t&&(this._dirtyShader=this._dirtyShader||i(n,t),this[e]=t)}),t.getterFunc)}(t)};function Bc(t,e,i,n){void 0===e&&(e="rgb"),void 0===i&&(i=!0),void 0===n&&(n=0),fc[t]=e.length||-1,Fc({name:t+"Map",defaultValue:null,dirtyShaderFunc:function(t,e){return!!t!=!!e||t&&(t.type!==e.type||t.fixCubemapSeams!==e.fixCubemapSeams||t.format!==e.format)}}),Fc({name:t+"MapTiling",defaultValue:new Mt(1,1)}),Fc({name:t+"MapOffset",defaultValue:new Mt(0,0)}),Fc({name:t+"MapRotation",defaultValue:0}),Fc({name:t+"MapUv",defaultValue:n}),e&&(Fc({name:t+"MapChannel",defaultValue:e}),i&&(Fc({name:t+"VertexColor",defaultValue:!1}),Fc({name:t+"VertexColorChannel",defaultValue:e})));var s=t+"MapTiling",r=t+"MapOffset",a=t+"MapRotation",o=t+"MapTransform";kc(o,(function(t,e,i){var n=t[s],h=t[r],l=t[a];if(1===n.x&&1===n.y&&0===h.x&&0===h.y&&0===l)return null;var c=t._allocUniform(o,(function(){return[{name:"texture_"+o+"0",value:new Float32Array(3)},{name:"texture_"+o+"1",value:new Float32Array(3)}]})),u=Math.cos(l*ft.DEG_TO_RAD),d=Math.sin(l*ft.DEG_TO_RAD),f=c[0].value;f[0]=u*n.x,f[1]=-d*n.y,f[2]=h.x;var p=c[1].value;return p[0]=d*n.x,p[1]=u*n.y,p[2]=1-n.y-h.y,c}))}function Nc(t,e){Fc({name:t,defaultValue:e,getterFunc:function(){return this._dirtyShader=!0,this["_"+t]}}),kc(t,(function(e,i,n){var s=e._allocUniform(t,(function(){return new Float32Array(3)})),r=e[t];return e.useGammaTonemap&&n.gammaCorrection?(s[0]=Math.pow(r.r,2.2),s[1]=Math.pow(r.g,2.2),s[2]=Math.pow(r.b,2.2)):(s[0]=r.r,s[1]=r.g,s[2]=r.b),s}))}function Uc(t,e,i){Fc({name:t,defaultValue:e,dirtyShaderFunc:function(t,e){return(0===t||1===t)!=(0===e||1===e)}}),kc(t,i)}function zc(t,e){Fc({name:t,defaultValue:null,dirtyShaderFunc:function(t,e){return!!t==!!e}}),kc(t,e)}function Vc(t,e){Fc({name:t,defaultValue:e})}!function(){Nc("ambient",new pt(.7,.7,.7)),Nc("diffuse",new pt(1,1,1)),Nc("specular",new pt(0,0,0)),Nc("emissive",new pt(0,0,0)),Nc("sheen",new pt(1,1,1)),Nc("attenuation",new pt(1,1,1)),Uc("emissiveIntensity",1),Uc("specularityFactor",1),Uc("sheenGloss",0),Uc("gloss",.25,(function(t,e,i){return 0===t.shadingModel?Math.pow(2,11*t.gloss):t.gloss})),Uc("heightMapFactor",1,(function(t,e,i){return.025*t.heightMapFactor})),Uc("opacity",1),Uc("alphaFade",1),Uc("alphaTest",0),Uc("bumpiness",1),Uc("normalDetailMapBumpiness",1),Uc("reflectivity",1),Uc("occludeSpecularIntensity",1),Uc("refraction",0),Uc("refractionIndex",1/1.5),Uc("dispersion",0),Uc("thickness",0),Uc("attenuationDistance",0),Uc("metalness",1),Uc("anisotropy",0),Uc("clearCoat",0),Uc("clearCoatGloss",1),Uc("clearCoatBumpiness",1),Uc("aoUvSet",0,null),Uc("iridescence",0),Uc("iridescenceRefractionIndex",1/1.5),Uc("iridescenceThicknessMin",0),Uc("iridescenceThicknessMax",0),zc("ambientSH"),zc("cubeMapProjectionBox",(function(t,e,i){var n=t._allocUniform("cubeMapProjectionBox",(function(){return[{name:"envBoxMin",value:new Float32Array(3)},{name:"envBoxMax",value:new Float32Array(3)}]})),s=t.cubeMapProjectionBox.getMin(),r=n[0].value;r[0]=s.x,r[1]=s.y,r[2]=s.z;var a=t.cubeMapProjectionBox.getMax(),o=n[1].value;return o[0]=a.x,o[1]=a.y,o[2]=a.z,n})),Vc("ambientTint",!1),Vc("diffuseTint",!1),Vc("sheenTint",!1),Vc("specularTint",!1),Vc("specularityFactorTint",!1),Vc("emissiveTint",!1),Vc("fastTbn",!1),Vc("useMetalness",!1),Vc("useMetalnessSpecularColor",!1),Vc("useSheen",!1),Vc("enableGGXSpecular",!1),Vc("occludeDirect",!1),Vc("normalizeNormalMap",!0),Vc("conserveEnergy",!0),Vc("opacityFadesSpecular",!0),Vc("occludeSpecular",1),Vc("shadingModel",1),Vc("fresnelModel",2),Vc("useDynamicRefraction",!1),Vc("cubeMapProjection",0),Vc("customFragmentShader",null),Vc("useFog",!0),Vc("useLighting",!0),Vc("useGammaTonemap",!0),Vc("useSkybox",!0),Vc("forceUv1",!1),Vc("pixelSnap",!1),Vc("twoSidedLighting",!1),Vc("nineSlicedMode",void 0),Vc("msdfTextAttribute",!1),Vc("useIridescence",!1),Vc("glossInvert",!1),Vc("sheenGlossInvert",!1),Vc("clearCoatGlossInvert",!1),Vc("opacityDither",Ao),Vc("opacityShadowDither",Ao),Bc("diffuse"),Bc("specular"),Bc("emissive"),Bc("thickness","g"),Bc("specularityFactor","g"),Bc("normal",""),Bc("metalness","g"),Bc("gloss","g"),Bc("opacity","a"),Bc("refraction","g"),Bc("height","g",!1),Bc("ao","g"),Bc("light","rgb",!0,1),Bc("msdf",""),Bc("diffuseDetail","rgb",!1),Bc("normalDetail",""),Bc("aoDetail","g",!1),Bc("clearCoat","g"),Bc("clearCoatGloss","g"),Bc("clearCoatNormal",""),Bc("sheen","rgb"),Bc("sheenGloss","g"),Bc("iridescence","g"),Bc("iridescenceThickness","g"),Vc("diffuseDetailMode",mo),Vc("aoDetailMode",mo),zc("cubeMap"),zc("sphereMap"),zc("envAtlas");var t=[null,null,null,null,null,null];Oc("prefilteredCubemaps",(function(){return t.slice()}),(function(t){var e=this._prefilteredCubemaps;t=t||[];for(var i=!1,n=!0,s=0;s<6;++s){var r=t[s]||null;e[s]!==r&&(e[s]=r,i=!0),n=n&&!!e[s]}i&&(n?this.envAtlas=uc.generatePrefilteredAtlas(e,{target:this.envAtlas}):this.envAtlas&&(this.envAtlas.destroy(),this.envAtlas=null),this._dirtyShader=!0)}),(function(){return this._prefilteredCubemaps}))}();var Gc=function(){function t(t,e){this.texture=t,this.cached=!1,this.renderTargets=e}return t.prototype.destroy=function(){this.texture&&(this.texture.destroy(),this.texture=null);for(var t=this.renderTargets,e=0;e1)for(var h=1/o,l=0;l1)for(var f=0;f0){for(var n=this.slots,s=0;ss&&(s=a)}return ru.min=n,ru.max=s,ru}var ou=function(){function t(t,e){this.renderer=void 0,this.shadowRenderer=void 0,this.device=void 0,this.renderer=t,this.shadowRenderer=e,this.device=t.device}var e=t.prototype;return e.cull=function(t,e,i,n){void 0===n&&(n=null),t.visibleThisFrame=!0,t._shadowMap||(t._shadowMap=Gc.create(this.device,t));var s=i._nearClip;this.generateSplitDistances(t,s,Math.min(i._farClip,t.shadowDistance));for(var r=t.shadowUpdateOverrides,a=0;a_&&(_=g)}var y=l.right,x=l.up,S=l.forward,b=.25*t._shadowResolution/_,T=Math.ceil(iu.dot(x)*b)/b,w=Math.ceil(iu.dot(y)*b)/b,E=x.mulScalar(T),A=y.mulScalar(w),C=iu.dot(S),M=S.mulScalar(C);iu.add2(E,A).add(M),l.setPosition(iu),l.translateLocal(0,0,1e6),h.nearClip=.01,h.farClip=2e6,h.orthoHeight=_,this.renderer.updateCameraFrustum(h),this.shadowRenderer.cullShadowCasters(e,t,o.visibleCasters,h,n);for(var P=!0,R=o.visibleCasters,I=0;I=1&&e<=3?new pt(0,0,0,0):new pt(1,1,1,1),s.clearDepthBuffer=!0,s.clearStencilBuffer=!1,s},t.setShadowCameraSettings=function(t,e,i,n,s){var r=4===i||(5===i||0===i)&&e.supportsDepthShadow;1!==n||s||(r=!1),t.clearColorBuffer=!r};var e=t.prototype;return e._cullShadowCastersInternal=function(t,e,i){for(var n=t.length,s=0;s1&&(this.renderer.scene.clusteredLightingEnabled&&0!==t._type||this.applyVsmBlur(t,e))},e.getVsmBlurShader=function(t,e,i){var n=(t?this.blurPackedVsmShader:this.blurVsmShader)[e][i];if(!n){this.blurVsmWeights[i]=function(t){for(var e=(t-1)/6,i=.5*(t-1),n=new Array(t),s=0,r=0;r0},i.filter=function(t,e){for(var i=0;i1?this.quadRendererCube:this.quadRenderer2D;a>1&&this.initInvViewProjMatrices(),this.blitTextureId.setValue(r.cookie);for(var h=0;h1){var l=yu.z/3,c=i[h];yu.x+=l*c.x,yu.y+=l*c.y,yu.z=l,yu.w=l,this.invViewProjId.setValue(xu[h].data)}yu.mulScalar(e),o.render(yu)}}n.length=0},v(e,[{key:"quadRenderer2D",get:function(){if(!this._quadRenderer2D){var t=Fo(this.device,gu,"\n\tvarying vec2 uv0;\n\tuniform sampler2D blitTexture;\n\tvoid main(void) {\n\t\tgl_FragColor = texture2D(blitTexture, uv0);\n\t}","cookieRenderer2d");this._quadRenderer2D=new Go(t)}return this._quadRenderer2D}},{key:"quadRendererCube",get:function(){if(!this._quadRendererCube){var t=Fo(this.device,gu,"\n\tvarying vec2 uv0;\n\tuniform samplerCube blitTexture;\n\tuniform mat4 invViewProj;\n\tvoid main(void) {\n\t\tvec4 projPos = vec4(uv0 * 2.0 - 1.0, 0.5, 1.0);\n\t\tvec4 worldPos = invViewProj * projPos;\n\t\tgl_FragColor = textureCube(blitTexture, worldPos.xyz);\n\t}","cookieRendererCube");this._quadRendererCube=new Go(t)}return this._quadRendererCube}}])}(Kr),bu=function(t){function e(e,i,n){var s;return(s=t.call(this,e)||this).requiresCubemaps=!1,s.shadowRenderer=i,s.shadowRendererLocal=n,s}x(e,t);var i=e.prototype;return i.update=function(t){var e=this.shadowRendererLocal.shadowLights,i=this.shadowRendererLocal.prepareLights(e,t),n=e.length;this.enabled=n>0,n&&this.shadowRenderer.setupRenderPass(this,i,!1)},i.execute=function(){for(var t=this.shadowRendererLocal.shadowLights,e=t.length,i=0;i0){var p=e?e.width:this.device.width,m=e?e.height:this.device.height,_=zu[this.device.renderVersion%zu.length];d=u*(2*_.x-1)/p,f=u*(2*_.y-1)/m,(l=Xu.copy(l)).data[8]=d,l.data[9]=f,(c=ju.copy(c)).data[8]=d,c.data[9]=f,this.blueNoiseJitterVersion!==this.device.renderVersion&&(this.blueNoiseJitterVersion=this.device.renderVersion,this.blueNoise.vec4(this.blueNoiseJitterVec))}var v=u>0?this.blueNoiseJitterVec:Rt.ZERO;if(this.blueNoiseJitterData[0]=v.x,this.blueNoiseJitterData[1]=v.y,this.blueNoiseJitterData[2]=v.z,this.blueNoiseJitterData[3]=v.w,this.blueNoiseJitterId.setValue(this.blueNoiseJitterData),this.projId.setValue(l.data),this.projSkyboxId.setValue(c.data),t.calculateTransform)t.calculateTransform(Du,0);else{var g=t._node.getPosition(),y=t._node.getRotation();Du.setTRS(g,y,wt.ONE)}this.viewInvId.setValue(Du.data),Lu.copy(Du).invert(),this.viewId.setValue(Lu.data),ku.setFromMat4(Lu),this.viewId3.setValue(ku.data),Iu.mul2(l,Lu),this.viewProjId.setValue(Iu.data),t._storeShaderMatrices(Iu,d,f,this.device.renderVersion),this.flipYId.setValue(i?-1:1),this.dispatchViewPos(t._node.getPosition()),t.frustum.setFromMat4(Iu)}this.tbnBasis.setValue(i?-1:1);var x=t._nearClip,S=t._farClip;return this.nearClipId.setValue(x),this.farClipId.setValue(S),this.cameraParams[0]=1/S,this.cameraParams[1]=S,this.cameraParams[2]=x,this.cameraParams[3]=1===t.projection?1:0,this.cameraParamsId.setValue(this.cameraParams),this.exposureId.setValue(this.scene.physicalUnits?t.getExposure():this.scene.exposure),n},e.clear=function(t,e,i,n){var s=((null!=e?e:t._clearColorBuffer)?1:0)|((null!=i?i:t._clearDepthBuffer)?2:0)|((null!=n?n:t._clearStencilBuffer)?4:0);s&&this.device.clear({color:[t._clearColor.r,t._clearColor.g,t._clearColor.b,t._clearColor.a],depth:t._clearDepth,stencil:t._clearStencil,flags:s})},e.setCamera=function(t,e,i,n){this.setCameraUniforms(t,e),this.clearView(t,e,i,!1)},e.clearView=function(t,e,i,n){var s=this.device;if(s.setRenderTarget(e),s.updateBegin(),n&&(s.setColorWrite(!0,!0,!0,!0),s.setDepthWrite(!0)),this.setupViewport(t,e),i){var r=t._clearOptions;s.clear(r||{color:[t._clearColor.r,t._clearColor.g,t._clearColor.b,t._clearColor.a],depth:t._clearDepth,flags:(t._clearColorBuffer?1:0)|(t._clearDepthBuffer?2:0)|(t._clearStencilBuffer?4:0),stencil:t._clearStencil})}},e.setupCullMode=function(t,e,i){var n=i.material,s=0;if(t){var r=1;2!==n.cull&&1!==n.cull||(r=e*i.flipFacesFactor*i.node.worldScaleSign),s=r<0?2===n.cull?1:2:n.cull}this.device.setCullMode(s),0===s&&0===n.cull&&this.twoSidedLightingNegScaleFactorId.setValue(i.node.worldScaleSign)},e.updateCameraFrustum=function(t){if(t.xr&&t.xr.views.list.length){var e=t.xr.views.list[0];return Iu.mul2(e.projMat,e.viewOffMat),void t.frustum.setFromMat4(Iu)}var i=t.projectionMatrix;if(t.calculateProjection&&t.calculateProjection(i,0),t.calculateTransform)t.calculateTransform(Du,0);else{var n=t._node.getPosition(),s=t._node.getRotation();Du.setTRS(n,s,wt.ONE),this.viewInvId.setValue(Du.data)}Lu.copy(Du).invert(),Iu.mul2(i,Lu),t.frustum.setFromMat4(Iu)},e.setBaseConstants=function(t,e){t.setCullMode(e.cull),e.opacityMap&&this.opacityMapId.setValue(e.opacityMap),(e.opacityMap||e.alphaTest>0)&&this.alphaTestId.setValue(e.alphaTest)},e.updateCpuSkinMatrices=function(t){Ru++;var e=t.length;if(0!==e)for(var i=0;i0?(this._instancedDrawCalls++,t.setVertexBuffer(a.vertexBuffer),t.draw(i.primitive[n],a.count)):t.clearVertexBuffer():t.draw(i.primitive[n])},e.drawInstance2=function(t,e,i,n){var s=e.instancingData;s?s.count>0?(this._instancedDrawCalls++,t.draw(i.primitive[n],s.count,!0)):t.clearVertexBuffer():t.draw(i.primitive[n],void 0,!0)},e.cull=function(t,e,i){var n=i.opaque;n.length=0;var s=i.transparent;s.length=0;for(var r=t.frustumCulling,a=e.length,o=0;o0){var a=this._shaderVersion;od.forEach((function(t){a>=0&&t._shaderVersion!==a&&(t.getShaderVariant!==eh.prototype.getShaderVariant&&t.clearVariants(),t._shaderVersion=a)})),od.clear()}},e.removeMeshInstances=function(t,e){for(var i=this.meshInstances,n=this.meshInstancesSet,s=0;s=0&&i.splice(a,1)}}e||this.removeShadowCasters(t)},e.addShadowCasters=function(t){for(var e=this.shadowCasters,i=this.shadowCastersSet,n=0;n=0&&e.splice(r,1)}}},e.clearMeshInstances=function(t){void 0===t&&(t=!1),this.meshInstances.length=0,this.meshInstancesSet.clear(),t||(this.shadowCasters.length=0,this.shadowCastersSet.clear())},e.markLightsDirty=function(){this._lightHashDirty=!0,this._lightIdHashDirty=!0,this._splitLightsDirty=!0},e.addLight=function(t){var e=t.light;this._lightsSet.has(e)||(this._lightsSet.add(e),this._lights.push(e),this.markLightsDirty()),0!==e.type&&this._clusteredLightsSet.add(e)},e.removeLight=function(t){var e=t.light;this._lightsSet.has(e)&&(this._lightsSet.delete(e),this._lights.splice(this._lights.indexOf(e),1),this.markLightsDirty()),0!==e.type&&this._clusteredLightsSet.delete(e)},e.clearLights=function(){var t=this;this._lightsSet.forEach((function(e){return e.removeLayer(t)})),this._lightsSet.clear(),this._clusteredLightsSet.clear(),this._lights.length=0,this.markLightsDirty()},e.evaluateLightHash=function(t,e,i){for(var n=0,s=this._lights,r=0;r0&&(ad.sort(),n=_n(ad),ad.length=0),n},e.getLightHash=function(t){return this._lightHashDirty&&(this._lightHashDirty=!1,this._lightHash=this.evaluateLightHash(!t,!0,!1)),this._lightHash},e.getLightIdHash=function(){return this._lightIdHashDirty&&(this._lightIdHashDirty=!1,this._lightIdHash=this.evaluateLightHash(!0,!1,!0)),this._lightIdHash},e.addCamera=function(t){this.camerasSet.has(t.camera)||(this.camerasSet.add(t.camera),this.cameras.push(t),this._dirtyComposition=!0)},e.removeCamera=function(t){if(this.camerasSet.has(t.camera)){this.camerasSet.delete(t.camera);var e=this.cameras.indexOf(t);this.cameras.splice(e,1),this._dirtyComposition=!0}},e.clearCameras=function(){this.cameras.length=0,this.camerasSet.clear(),this._dirtyComposition=!0},e._calculateSortDistances=function(t,e,i,n){for(var s=0;s0}},{key:"clusteredLightsSet",get:function(){return this._clusteredLightsSet}},{key:"splitLights",get:function(){if(this._splitLightsDirty){this._splitLightsDirty=!1;for(var t=this._splitLights,e=0;e1&&ud(this.cameras),this.camerasMap.clear();for(var a=0;a0)this.addDummyRenderAction(h,c),h++;else{for(var u=!0,d=h,f=null,p=!1,m=0;m0&&c.layers.indexOf(_.id)>=0){o.push(_),p||_.id!==c.disablePostEffectsLayer||(p=!0,f&&(f.triggerPostprocess=!0));var v=this.subLayerList[m];f=this.addRenderAction(h,_,v,c,u,p),h++,u=!1}}d=0;l--)if(h[l].camera===n&&h[l].renderTarget===a){o=!0;break}r&&n.postEffectsEnabled&&(a=null);var c=this.getNextRenderAction(t);c.triggerPostprocess=!1,c.layer=e,c.transparent=i,c.camera=n,c.renderTarget=a,c.firstCameraUse=s,c.lastCameraUse=!1;var u=s||!o,d=e.clearColorBuffer||e.clearDepthBuffer||e.clearStencilBuffer;return(u||d)&&c.setupClears(u?n:void 0,e),c},i.propagateRenderTarget=function(t,e){for(var i=t;i>=0;i--){var n=this._renderActions[i],s=n.layer;if(n.renderTarget&&1!==s.id)break;if(1!==s.id){if(n.useCameraPasses)break;var r=null==n?void 0:n.camera.camera;if(r&&(!e.camera.rect.equals(r.rect)||!e.camera.scissorRect.equals(r.scissorRect)))break;n.renderTarget=e.renderTarget}}},i._logRenderActions=function(){},i._isLayerAdded=function(t){return this.layerIdMap.get(t.id)===t},i._isSublayerAdded=function(t,e){return void 0!==(e?this.layerTransparentIndexMap:this.layerOpaqueIndexMap).get(t)},i.push=function(t){this._isLayerAdded(t)||(this.layerList.push(t),this.layerList.push(t),this._opaqueOrder[t.id]=this.subLayerList.push(!1)-1,this._transparentOrder[t.id]=this.subLayerList.push(!0)-1,this.subLayerEnabled.push(!0),this.subLayerEnabled.push(!0),this._updateLayerMaps(),this._dirty=!0,this.fire("add",t))},i.insert=function(t,e){if(!this._isLayerAdded(t)){this.layerList.splice(e,0,t,t),this.subLayerList.splice(e,0,!1,!0);var i=this.layerList.length;this._updateOpaqueOrder(e,i-1),this._updateTransparentOrder(e,i-1),this.subLayerEnabled.splice(e,0,!0,!0),this._updateLayerMaps(),this._dirty=!0,this.fire("add",t)}},i.remove=function(t){var e=this.layerList.indexOf(t);for(delete this._opaqueOrder[e],delete this._transparentOrder[e];e>=0;)this.layerList.splice(e,1),this.subLayerList.splice(e,1),this.subLayerEnabled.splice(e,1),e=this.layerList.indexOf(t),this._dirty=!0,this.fire("remove",t);var i=this.layerList.length;this._updateOpaqueOrder(0,i-1),this._updateTransparentOrder(0,i-1),this._updateLayerMaps()},i.pushOpaque=function(t){this._isSublayerAdded(t,!1)||(this.layerList.push(t),this._opaqueOrder[t.id]=this.subLayerList.push(!1)-1,this.subLayerEnabled.push(!0),this._updateLayerMaps(),this._dirty=!0,this.fire("add",t))},i.insertOpaque=function(t,e){if(!this._isSublayerAdded(t,!1)){this.layerList.splice(e,0,t),this.subLayerList.splice(e,0,!1);var i=this.subLayerList.length;this._updateOpaqueOrder(e,i-1),this.subLayerEnabled.splice(e,0,!0),this._updateLayerMaps(),this._dirty=!0,this.fire("add",t)}},i.removeOpaque=function(t){for(var e=0,i=this.layerList.length;e45?(t.radius=e*this._outerConeAngleSin,fd.mulScalar(-e*n)):(t.radius=e/(2*n),fd.mulScalar(-t.radius)),t.center.add2(s.getPosition(),fd)}else 1===this._type&&(t.center=this._node.getPosition(),t.radius=this.attenuationEnd)},e.getBoundingBox=function(t){if(2===this._type){var e=this.attenuationEnd,i=this._outerConeAngle,n=this._node,s=Math.abs(Math.sin(i*ft.DEG_TO_RAD)*e);t.center.set(0,.5*-e,0),t.halfExtents.set(s,.5*e,s),t.setFromTransformedAabb(t,n.getWorldTransform(),!0)}else 1===this._type&&(t.center.copy(this._node.getPosition()),t.halfExtents.set(this.attenuationEnd,this.attenuationEnd,this.attenuationEnd))},e._updateShadowBias=function(){var t=this.device;if(t.isWebGL2||t.isWebGPU)if(1!==this._type||this.clusteredLighting){var e=-1e3*this.shadowBias;this.shadowDepthState.depthBias=e,this.shadowDepthState.depthBiasSlope=e}else this.shadowDepthState.depthBias=0,this.shadowDepthState.depthBiasSlope=0},e._updateFinalColor=function(){var e=this._color,i=e.r,n=e.g,s=e.b,r=this._intensity;this._usePhysicalUnits&&(r=this._luminance/t.getLightUnitConversion(this._type,this._outerConeAngle*ft.DEG_TO_RAD,this._innerConeAngle*ft.DEG_TO_RAD));var a=this._finalColor,o=this._linearFinalColor;a[0]=i*r,a[1]=n*r,a[2]=s*r,r>=1?(o[0]=Math.pow(i,2.2)*r,o[1]=Math.pow(n,2.2)*r,o[2]=Math.pow(s,2.2)*r):(o[0]=Math.pow(a[0],2.2),o[1]=Math.pow(a[1],2.2),o[2]=Math.pow(a[2],2.2))},e.setColor=function(){1===arguments.length?this._color.set(arguments[0].r,arguments[0].g,arguments[0].b):3===arguments.length&&this._color.set(arguments[0],arguments[1],arguments[2]),this._updateFinalColor()},e.layersDirty=function(){this.layers.forEach((function(t){t.markLightsDirty()}))},e.updateKey=function(){var t=this._type<<29|(this._castShadows?1:0)<<28|this._shadowType<<25|this._falloffMode<<23|(0!==this._normalOffsetBias?1:0)<<22|(this._cookie?1:0)<<21|(this._cookieFalloff?1:0)<<20|md[this._cookieChannel.charAt(0)]<<18|(this._cookieTransform?1:0)<<12|this._shape<<10|this.numCascades-1<<8|(this.affectSpecularity?1:0)<<7|this.mask<<6;3===this._cookieChannel.length&&(t|=md[this._cookieChannel.charAt(1)]<<16,t|=md[this._cookieChannel.charAt(2)]<<14),t!==this.key&&this.layersDirty(),this.key=t},v(t,[{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias!==t&&(this._shadowBias=t,this._updateShadowBias())}},{key:"numCascades",get:function(){return this.cascades.length},set:function(t){this.cascades&&this.numCascades===t||(this.cascades=vd[t-1],this._shadowMatrixPalette=new Float32Array(64),this._shadowCascadeDistances=new Float32Array(4),this._destroyShadowMap(),this.updateKey())}},{key:"shadowMap",get:function(){return this._shadowMap},set:function(t){this._shadowMap!==t&&(this._destroyShadowMap(),this._shadowMap=t)}},{key:"mask",get:function(){return this._mask},set:function(t){this._mask!==t&&(this._mask=t,this.updateKey())}},{key:"numShadowFaces",get:function(){var t=this._type;return 0===t?this.numCascades:1===t?6:1}},{key:"type",get:function(){return this._type},set:function(t){if(this._type!==t){this._type=t,this._destroyShadowMap(),this._updateShadowBias(),this.updateKey();var e=this._shadowType;this._shadowType=null,this.shadowUpdateOverrides=null,this.shadowType=e}}},{key:"shape",get:function(){return this._shape},set:function(t){if(this._shape!==t){this._shape=t,this._destroyShadowMap(),this.updateKey();var e=this._shadowType;this._shadowType=null,this.shadowType=e}}},{key:"usePhysicalUnits",get:function(){return this._usePhysicalUnits},set:function(t){this._usePhysicalUnits!==t&&(this._usePhysicalUnits=t,this._updateFinalColor())}},{key:"shadowType",get:function(){return this._shadowType},set:function(t){if(this._shadowType!==t){var e=this.device;1===this._type&&0!==t&&6!==t&&(t=0);var i=e.supportsDepthShadow;4!==t||i||(t=0),3!==t||e.textureFloatRenderable&&e.textureFloatFilterable||(t=2),2!==t||e.textureHalfFloatRenderable||(t=1),this._isVsm=t>=1&&t<=3,this._isPcf=5===t||0===t||4===t,this._shadowType=t,this._destroyShadowMap(),this.updateKey()}}},{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(this._enabled=t,this.layersDirty())}},{key:"castShadows",get:function(){return this._castShadows&&4!==this._mask&&0!==this._mask},set:function(t){this._castShadows!==t&&(this._castShadows=t,this._destroyShadowMap(),this.layersDirty(),this.updateKey())}},{key:"bakeShadows",get:function(){return this._castShadows&&4===this._mask}},{key:"shadowResolution",get:function(){return this._shadowResolution},set:function(t){this._shadowResolution!==t&&(t=1===this._type?Math.min(t,this.device.maxCubeMapSize):Math.min(t,this.device.maxTextureSize),this._shadowResolution=t,this._destroyShadowMap())}},{key:"vsmBlurSize",get:function(){return this._vsmBlurSize},set:function(t){this._vsmBlurSize!==t&&(t%2==0&&t++,this._vsmBlurSize=t)}},{key:"normalOffsetBias",get:function(){return this._normalOffsetBias},set:function(t){this._normalOffsetBias!==t&&((!this._normalOffsetBias&&t||this._normalOffsetBias&&!t)&&this.updateKey(),this._normalOffsetBias=t)}},{key:"falloffMode",get:function(){return this._falloffMode},set:function(t){this._falloffMode!==t&&(this._falloffMode=t,this.updateKey())}},{key:"innerConeAngle",get:function(){return this._innerConeAngle},set:function(t){this._innerConeAngle!==t&&(this._innerConeAngle=t,this._innerConeAngleCos=Math.cos(t*Math.PI/180),this._usePhysicalUnits&&this._updateFinalColor())}},{key:"outerConeAngle",get:function(){return this._outerConeAngle},set:function(t){this._outerConeAngle!==t&&(this._outerConeAngle=t,this._updateOuterAngle(t),this._usePhysicalUnits&&this._updateFinalColor())}},{key:"penumbraSize",get:function(){return this._penumbraSize},set:function(t){this._penumbraSize=t}},{key:"intensity",get:function(){return this._intensity},set:function(t){this._intensity!==t&&(this._intensity=t,this._updateFinalColor())}},{key:"affectSpecularity",get:function(){return this._affectSpecularity},set:function(t){0===this._type&&(this._affectSpecularity=t,this.updateKey())}},{key:"luminance",get:function(){return this._luminance},set:function(t){this._luminance!==t&&(this._luminance=t,this._updateFinalColor())}},{key:"cookieMatrix",get:function(){return this._cookieMatrix||(this._cookieMatrix=new Bt),this._cookieMatrix}},{key:"atlasViewport",get:function(){return this._atlasViewport||(this._atlasViewport=new Rt(0,0,1,1)),this._atlasViewport}},{key:"cookie",get:function(){return this._cookie},set:function(t){this._cookie!==t&&(this._cookie=t,this.updateKey())}},{key:"cookieFalloff",get:function(){return this._cookieFalloff},set:function(t){this._cookieFalloff!==t&&(this._cookieFalloff=t,this.updateKey())}},{key:"cookieChannel",get:function(){return this._cookieChannel},set:function(t){if(this._cookieChannel!==t){if(t.length<3)for(var e=t.charAt(t.length-1),i=3-t.length,n=0;n0&&(e+="varying vec2 uv0;\nuniform highp float morphFactor["+t+"];\n");for(var i=0;i=this.maxSubmitCount&&(s(r,a),r=0,a=!0))}(r>0||0===o&&!this.zeroTextures)&&s(r,a)},e._updateTextureMorph=function(){this.device,(this._activeTargets.length>0||!this.zeroTextures)&&(this.rtPositions&&this._updateTextureRenderTarget(this.rtPositions,"texturePositions"),this.rtNormals&&this._updateTextureRenderTarget(this.rtNormals,"textureNormals"),this.zeroTextures=0===this._activeTargets.length)},e._updateVertexMorph=function(){for(var t=this.maxSubmitCount,e=0;e1e-5){this._activeTargets.length<=e&&(this._activeTargets[e]={});var s=this._activeTargets[e++];s.absWeight=n,s.weight=this.getWeight(i),s.target=t[i]}}this._activeTargets.length=e;var r=this.morph.maxActiveTargets;this._activeTargets.length>r&&(this._activeTargets.sort((function(t,e){return t.absWeightl)return!1;this.morphTextureWidth=c,this.morphTextureHeight=u;var d=!1,f=3,p=Tt.float2Half;this._textureFormat===me&&(d=!0,f=4);for(var m=[],_=0;_0&&(s+=Ro.screenDepthPS),s+=Ro.particle_cpuVS,e.localSpace&&(s+=Ro.particle_localShiftVS),e.animTex&&(s+=this._animTex(e)),e.alignToMotion&&(s+=Ro.particle_pointAlongVS),s+=e.mesh?Ro.particle_meshVS:r,1===e.normal&&(s+=Ro.particle_normalVS),2===e.normal&&(s+=Ro.particle_TBNVS),e.stretch>0&&(s+=Ro.particle_stretchVS),s+=Ro.particle_cpu_endVS,e.soft>0&&(s+=Ro.particle_softVS)):(s+=Ro.particle_initVS,s+=e.pack8?Ro.particleInputRgba8PS:Ro.particleInputFloatPS,e.soft>0&&(s+=Ro.screenDepthPS),s+=Ro.particleVS,e.localSpace&&(s+=Ro.particle_localShiftVS),e.animTex&&(s+=this._animTex(e)),e.wrap&&(s+=Ro.particle_wrapVS),e.alignToMotion&&(s+=Ro.particle_pointAlongVS),s+=e.mesh?Ro.particle_meshVS:r,1===e.normal&&(s+=Ro.particle_normalVS),2===e.normal&&(s+=Ro.particle_TBNVS),e.stretch>0&&(s+=Ro.particle_stretchVS),s+=Ro.particle_endVS,e.soft>0&&(s+=Ro.particle_softVS)),s+="}\n",e.normal>0&&(1===e.normal?n+="\nvarying vec3 Normal;\n":2===e.normal&&(n+="\nvarying mat3 ParticleMat;\n"),n+="\nuniform vec3 lightCube[6];\n"),e.soft&&(n+="\nvarying float vDepth;\n"),0===e.normal&&"none"===e.fog&&(e.srgb=!1),n+=Ro.decodePS,n+=ko.gammaCode(e.gamma),n+=ko.tonemapCode(e.toneMap),"linear"===e.fog?n+=Ro.fogLinearPS:"exp"===e.fog?n+=Ro.fogExpPS:"exp2"===e.fog?n+=Ro.fogExp2PS:n+=Ro.fogNonePS,2===e.normal&&(n+="\nuniform sampler2D normalMap;\n"),e.soft>0&&(n+=Ro.screenDepthPS),n+=Ro.particlePS,e.soft>0&&(n+=Ro.particle_softPS),1===e.normal&&(n+="\nvec3 normal = Normal;\n"),2===e.normal&&(n+=Ro.particle_normalMapPS),e.normal>0&&(n+=e.halflambert?Ro.particle_halflambertPS:Ro.particle_lambertPS),e.normal>0&&(n+=Ro.particle_lightingPS),2===e.blend?n+=Ro.particle_blendNormalPS:1===e.blend?n+=Ro.particle_blendAddPS:5===e.blend&&(n+=Ro.particle_blendMultiplyPS),n+=Ro.particle_endPS,Pr.createDefinition(t,{name:"ParticleShader",vertexCode:s,fragmentCode:n})},e}(ko),Md=new Cd,Pd=1,Rd=new Bt,Id=new Bt,Dd=new wt,Ld=new wt,kd=new wt,Od=new wt,Fd=new wt,Bd=new wt,Nd=new wt,Ud=new wt,zd=new wt,Vd=new wt,Gd=new wt,Hd=new wt,Wd=new wt;function Xd(t){return t-Math.floor(t)}function jd(t){return Math.max(Math.min(t,1),0)}function qd(t,e){return t-e*Math.floor(t/e)}function Yd(t){var e=Xd(t),i=Xd(255*t);return[e-=i/255,i-=i/255]}var Kd=function(){function t(t){this._emitter=t}var e=t.prototype;return e.calcSpawnPosition=function(t,e,i,n,s){var r=this._emitter,a=Math.random(),o=Math.random(),h=Math.random(),l=Math.random();if(r.useCpu&&(t[4*s+0+2*r.numParticlesPot*4]=a,t[4*s+1+2*r.numParticlesPot*4]=o,t[4*s+2+2*r.numParticlesPot*4]=h),Ld.x=a-.5,Ld.y=o-.5,Ld.z=h-.5,0===r.emitterShape){var c=Math.max(Math.abs(Ld.x),Math.max(Math.abs(Ld.y),Math.abs(Ld.z))),u=c+(.5-c)*i[0],d=c+(.5-c)*i[1],f=c+(.5-c)*i[2];Ld.x=u*(c===Math.abs(Ld.x)?Math.sign(Ld.x):2*Ld.x),Ld.y=d*(c===Math.abs(Ld.y)?Math.sign(Ld.y):2*Ld.y),Ld.z=f*(c===Math.abs(Ld.z)?Math.sign(Ld.z):2*Ld.z),r.localSpace?Dd.copy(e.transformPoint(Ld)):Dd.copy(n).add(e.transformPoint(Ld))}else{Ld.normalize();var p=0===r.emitterRadius?0:r.emitterRadiusInner/r.emitterRadius,m=l*(1-p)+p;r.localSpace?Dd.copy(Ld.mulScalar(m*r.emitterRadius)):Dd.copy(n).add(Ld.mulScalar(m*r.emitterRadius))}var _,v,g,y,x,S=-ft.lerp(r.rate,r.rate2,a)*s;if(r.pack8){var b=(Dd.x-r.worldBounds.center.x)/r.worldBoundsSize.x+.5,T=(Dd.y-r.worldBounds.center.y)/r.worldBoundsSize.y+.5,w=(Dd.z-r.worldBounds.center.z)/r.worldBoundsSize.z+.5,E=ft.lerp(r.startAngle*ft.DEG_TO_RAD,r.startAngle2*ft.DEG_TO_RAD,a);E=E%(2*Math.PI)/(2*Math.PI);var A=Yd(b);t[4*s]=A[0],t[4*s+1]=A[1];var C=Yd(T);t[4*s+2]=C[0],t[4*s+3]=C[1];var M=Yd(w);t[4*s+0+4*r.numParticlesPot]=M[0],t[4*s+1+4*r.numParticlesPot]=M[1];var P=Yd(E);t[4*s+2+4*r.numParticlesPot]=P[0],t[4*s+3+4*r.numParticlesPot]=P[1];t[4*s+3+4*r.numParticlesPot*2]=1;var R=Math.max(r.lifetime,(r.numParticles-1)*Math.max(r.rate,r.rate2)),I=r.lifetime+1,D=(v=Xd(_=S=(S+R)/(R+I)),g=Xd(255*_),y=Xd(65025*_),x=Xd(160581375*_),[v-=g/255,g-=y/255,y-=x/255,x-=x/255]);t[4*s+0+4*r.numParticlesPot*3]=D[0],t[4*s+1+4*r.numParticlesPot*3]=D[1],t[4*s+2+4*r.numParticlesPot*3]=D[2],t[4*s+3+4*r.numParticlesPot*3]=D[3]}else t[4*s]=Dd.x,t[4*s+1]=Dd.y,t[4*s+2]=Dd.z,t[4*s+3]=ft.lerp(r.startAngle*ft.DEG_TO_RAD,r.startAngle2*ft.DEG_TO_RAD,a),t[4*s+3+4*r.numParticlesPot]=S},e.update=function(t,e,i,n,s,r,a,o){var h,l,c,u=this._emitter;if(u.meshInstance.node){for(var d=u.meshInstance.node.worldTransform,f=0;f<12;f++)Rd.data[f]=d.data[f];Id.copy(Rd),Id.invert(),nd=u.meshInstance.node.localScale,Pd=Math.max(Math.max(nd.x,nd.y),nd.z)}r=null===u.meshInstance.node||u.localSpace?wt.ZERO:u.meshInstance.node.getPosition();for(var p,m,_,v,g,y,x,S,b=u.camera?u.camera._node.getPosition():wt.ZERO,T=u.useMesh?17:15,w=u.precision-1,E=0;E=P)&&this.calcSpawnPosition(i,n,s,r,A);var k=R>0&&R0&&(1===u.emitterShape?(Ld.copy(kd).mulScalar(2).sub(wt.ONE).normalize(),Bd.add(Ld.mulScalar(u.initialVelocity))):Bd.add(wt.FORWARD.mulScalar(u.initialVelocity))),Fd.x+=(Nd.x-Fd.x)*kd.x,Fd.y+=(Nd.y-Fd.y)*kd.y,Fd.z+=(Nd.z-Fd.z)*kd.z,_+=(v-_)*kd.y,D=(D+1e4*C%1*(g-D))*Pd,L=1e3*C%1*(x-y),u.meshInstance.node&&(u.localSpace?(Bd.x/=nd.x,Bd.y/=nd.y,Bd.z/=nd.z):Rd.transformPoint(Bd,Bd)),u.localSpace?(Id.transformPoint(Fd,Fd),Bd.add(Fd).add(zd)):(Bd.add(Fd.mul(nd)),Bd.add(zd.mul(nd))),Hd.copy(Bd),Vd.copy(Od).add(Bd.mulScalar(a)),Gd.copy(Vd),i[4*A]=Gd.x,i[4*A+1]=Gd.y,i[4*A+2]=Gd.z,i[4*A+3]+=_*a,u.wrap&&u.wrapBounds&&(u.localSpace||Gd.sub(r),Gd.x=qd(Gd.x,u.wrapBounds.x)-.5*u.wrapBounds.x,Gd.y=qd(Gd.y,u.wrapBounds.y)-.5*u.wrapBounds.y,Gd.z=qd(Gd.z,u.wrapBounds.z)-.5*u.wrapBounds.z,u.localSpace||Gd.add(r)),u.sort>0&&(1===u.sort?(Wd.copy(Gd).sub(b),u.particleDistance[A]=-(Wd.x*Wd.x+Wd.y*Wd.y+Wd.z*Wd.z)):2===u.sort?u.particleDistance[A]=R:3===u.sort&&(u.particleDistance[A]=-R))),o?R<0&&(i[4*A+3+2*u.numParticlesPot*4]=-1):(R>=P&&(R-=Math.max(P,(u.numParticles-1)*M),i[4*A+3+2*u.numParticlesPot*4]=u.loop?1:-1),R<0&&u.loop&&(i[4*A+3+2*u.numParticlesPot*4]=1)),i[4*A+3+2*u.numParticlesPot*4]<0&&(k=!1),i[4*A+3+4*u.numParticlesPot]=R;for(var O=0;O0&&u.camera){for(var V=u.useMesh?6:4,G=u.particleDistance,H=0;Ht.maxTextureSize&&(this.numParticles=t.maxTextureSize),_f("rate",1),_f("rate2",this.rate),_f("lifetime",50),_f("emitterExtents",new wt(0,0,0)),_f("emitterExtentsInner",new wt(0,0,0)),_f("emitterRadius",0),_f("emitterRadiusInner",0),_f("emitterShape",0),_f("initialVelocity",1),_f("wrap",!1),_f("localSpace",!1),_f("screenSpace",!1),_f("wrapBounds",null),_f("colorMap",this.defaultParamTexture),_f("normalMap",null),_f("loop",!0),_f("preWarm",!1),_f("sort",0),_f("mode",0),_f("scene",null),_f("lighting",!1),_f("halfLambert",!1),_f("intensity",1),_f("stretch",0),_f("alignToMotion",!1),_f("depthSoftening",0),_f("mesh",null),_f("particleNormal",new wt(0,1,0)),_f("orientation",0),_f("depthWrite",!1),_f("noFog",!1),_f("blendType",2),_f("node",null),_f("startAngle",0),_f("startAngle2",this.startAngle),_f("animTilesX",1),_f("animTilesY",1),_f("animStartFrame",0),_f("animNumFrames",1),_f("animNumAnimations",1),_f("animIndex",0),_f("randomizeAnimIndex",!1),_f("animSpeed",1),_f("animLoop",!0),this._gpuUpdater=new $d(this,i),this._cpuUpdater=new Kd(this),this.emitterPosUniform=new Float32Array(3),this.wrapBoundsUniform=new Float32Array(3),this.emitterScaleUniform=new Float32Array([1,1,1]),_f("colorGraph",lf),_f("colorGraph2",this.colorGraph),_f("scaleGraph",of),_f("scaleGraph2",this.scaleGraph),_f("alphaGraph",of),_f("alphaGraph2",this.alphaGraph),_f("localVelocityGraph",hf),_f("localVelocityGraph2",this.localVelocityGraph),_f("velocityGraph",hf),_f("velocityGraph2",this.velocityGraph),_f("rotationSpeedGraph",af),_f("rotationSpeedGraph2",this.rotationSpeedGraph),_f("radialSpeedGraph",af),_f("radialSpeedGraph2",this.radialSpeedGraph),this.animTilesParams=new Float32Array(2),this.animParams=new Float32Array(4),this.animIndexParams=new Float32Array(2),this.internalTex0=null,this.internalTex1=null,this.internalTex2=null,this.colorParam=null,this.vbToSort=null,this.vbOld=null,this.particleDistance=null,this.camera=null,this.swapTex=!1,this.useMesh=!0,this.useCpu=!t.supportsGpuParticles,this.pack8=!0,this.localBounds=new Wt,this.worldBoundsNoTrail=new Wt,this.worldBoundsTrail=[new Wt,new Wt],this.worldBounds=new Wt,this.worldBoundsSize=new wt,this.prevWorldBoundsSize=new wt,this.prevWorldBoundsCenter=new wt,this.prevEmitterExtents=this.emitterExtents,this.prevEmitterRadius=this.emitterRadius,this.worldBoundsMul=new wt,this.worldBoundsAdd=new wt,this.timeToSwitchBounds=0,this.shaderParticleUpdateRespawn=null,this.shaderParticleUpdateNoRespawn=null,this.shaderParticleUpdateOnStop=null,this.numParticleVerts=0,this.numParticleIndices=0,this.material=null,this.meshInstance=null,this.drawOrder=0,this.seed=Math.random(),this.fixedTimeStep=1/60,this.maxSubSteps=10,this.simTime=0,this.simTimeTotal=0,this.beenReset=!1,this._layer=null,this.rebuild()}var e=t.prototype;return e.onChangeCamera=function(){this.regenShader(),this.resetMaterial()},e.calculateBoundsMad=function(){this.worldBoundsMul.x=1/this.worldBoundsSize.x,this.worldBoundsMul.y=1/this.worldBoundsSize.y,this.worldBoundsMul.z=1/this.worldBoundsSize.z,this.worldBoundsAdd.copy(this.worldBounds.center).mul(this.worldBoundsMul).mulScalar(-1),this.worldBoundsAdd.x+=.5,this.worldBoundsAdd.y+=.5,this.worldBoundsAdd.z+=.5},e.calculateWorldBounds=function(){if(this.node){if(this.prevWorldBoundsSize.copy(this.worldBoundsSize),this.prevWorldBoundsCenter.copy(this.worldBounds.center),!this.useCpu){(0===this.emitterShape?!this.emitterExtents.equals(this.prevEmitterExtents):!(this.emitterRadius===this.prevEmitterRadius))&&this.calculateLocalBounds()}var t=this.node.getWorldTransform();this.localSpace?this.worldBoundsNoTrail.copy(this.localBounds):this.worldBoundsNoTrail.setFromTransformedAabb(this.localBounds,t),this.worldBoundsTrail[0].add(this.worldBoundsNoTrail),this.worldBoundsTrail[1].add(this.worldBoundsNoTrail);var e=this.simTimeTotal;e>=this.timeToSwitchBounds&&(this.worldBoundsTrail[0].copy(this.worldBoundsTrail[1]),this.worldBoundsTrail[1].copy(this.worldBoundsNoTrail),this.timeToSwitchBounds=e+this.lifetime),this.worldBounds.copy(this.worldBoundsTrail[0]),this.worldBoundsSize.copy(this.worldBounds.halfExtents).mulScalar(2),this.localSpace?(this.meshInstance.aabb.setFromTransformedAabb(this.worldBounds,t),this.meshInstance.mesh.aabb.setFromTransformedAabb(this.worldBounds,t)):(this.meshInstance.aabb.copy(this.worldBounds),this.meshInstance.mesh.aabb.copy(this.worldBounds)),this.meshInstance._aabbVer=1-this.meshInstance._aabbVer,this.pack8&&this.calculateBoundsMad()}},e.resetWorldBounds=function(){this.node&&(this.worldBoundsNoTrail.setFromTransformedAabb(this.localBounds,this.localSpace?Bt.IDENTITY:this.node.getWorldTransform()),this.worldBoundsTrail[0].copy(this.worldBoundsNoTrail),this.worldBoundsTrail[1].copy(this.worldBoundsNoTrail),this.worldBounds.copy(this.worldBoundsTrail[0]),this.worldBoundsSize.copy(this.worldBounds.halfExtents).mulScalar(2),this.prevWorldBoundsSize.copy(this.worldBoundsSize),this.prevWorldBoundsCenter.copy(this.worldBounds.center),this.simTimeTotal=0,this.timeToSwitchBounds=0)},e.calculateLocalBounds=function(){for(var t,e,i,n=Number.MAX_VALUE,s=Number.MAX_VALUE,r=Number.MAX_VALUE,a=-Number.MAX_VALUE,o=-Number.MAX_VALUE,h=-Number.MAX_VALUE,l=0,c=0,u=this.lifetime/this.precision,d=[this.qVelocity,this.qVelocity2],f=[this.qLocalVelocity,this.qLocalVelocity2],p=[0,0],m=[0,0],_=[0,0],v=[0,0],g=[0,0],y=0;y0||t.maxVertexTextures<=1||t.fragmentUniformsCount<64||t.forceCpuParticles||!t.extTextureFloat,this._destroyResources(),this.pack8=(this.pack8||!t.textureFloatRenderable)&&!this.useCpu,cf=this.useCpu||this.pack8?4:2,this.useMesh=!1,this.mesh)&&(this.numParticles*this.mesh.vertexBuffer.numVertices>65535||(this.useMesh=!0));this.numParticlesPot=ft.nextPowerOfTwo(this.numParticles),this.rebuildGraphs(),this.calculateLocalBounds(),this.resetWorldBounds(),this.node&&(this.worldBounds.setFromTransformedAabb(this.localBounds,this.localSpace?Bt.IDENTITY:this.node.getWorldTransform()),this.worldBoundsTrail[0].copy(this.worldBounds),this.worldBoundsTrail[1].copy(this.worldBounds),this.worldBoundsSize.copy(this.worldBounds.halfExtents).mulScalar(2),this.prevWorldBoundsSize.copy(this.worldBoundsSize),this.prevWorldBoundsCenter.copy(this.worldBounds.center),this.pack8&&this.calculateBoundsMad()),this.vbToSort=new Array(this.numParticles);for(var e=0;e=1&&(this.animTilesX>1||this.animTilesY>1)&&(this.colorMap&&this.colorMap!==this.defaultParamTexture||this.normalMap)},e.rebuildGraphs=function(){var t=this.precision,e=this.graphicsDevice;this.qLocalVelocity=this.localVelocityGraph.quantize(t),this.qVelocity=this.velocityGraph.quantize(t),this.qColor=this.colorGraph.quantizeClamped(t,0,1),this.qRotSpeed=this.rotationSpeedGraph.quantize(t),this.qScale=this.scaleGraph.quantize(t),this.qAlpha=this.alphaGraph.quantize(t),this.qRadialSpeed=this.radialSpeedGraph.quantize(t),this.qLocalVelocity2=this.localVelocityGraph2.quantize(t),this.qVelocity2=this.velocityGraph2.quantize(t),this.qColor2=this.colorGraph2.quantizeClamped(t,0,1),this.qRotSpeed2=this.rotationSpeedGraph2.quantize(t),this.qScale2=this.scaleGraph2.quantize(t),this.qAlpha2=this.alphaGraph2.quantize(t),this.qRadialSpeed2=this.radialSpeedGraph2.quantize(t);for(var i=0;i0&&t.setParameter("softening",1/(this.depthSoftening*this.depthSoftening*100)),this.stretch>0&&(t.cull=0),this._compParticleFaceParams()},e._compParticleFaceParams=function(){var t,e;if(0===this.orientation)t=new Float32Array([1,0,0]),e=new Float32Array([0,0,1]);else{var i;if(1===this.orientation)i=this.particleNormal.normalize();else i=(null===this.node?Bt.IDENTITY:this.node.getWorldTransform()).transformVector(this.particleNormal).normalize();var n=new wt(1,0,0);1===Math.abs(n.dot(i))&&n.set(0,0,1);var s=(new wt).cross(i,n).normalize();n.cross(s,i).normalize(),t=new Float32Array([n.x,n.y,n.z]),e=new Float32Array([s.x,s.y,s.z])}this.material.setParameter("faceTangent",t),this.material.setParameter("faceBinorm",e)},e._allocate=function(t){var e=t*this.numParticleVerts,i=t*this.numParticleIndices;if(void 0===this.vertexBuffer||this.vertexBuffer.getNumVertices()!==e){if(this.useCpu){var n=[{semantic:Ke,components:4,type:6},{semantic:Ze,components:4,type:6},{semantic:Qe,components:4,type:6},{semantic:Je,components:1,type:6},{semantic:$e,components:this.useMesh?4:2,type:6}],s=new bn(this.graphicsDevice,n);this.vertexBuffer=new pn(this.graphicsDevice,s,e,{usage:1}),this.indexBuffer=new jr(this.graphicsDevice,1,i)}else{var r=[{semantic:Ke,components:4,type:6}];this.useMesh&&r.push({semantic:Ze,components:2,type:6});var a=new bn(this.graphicsDevice,r);this.vertexBuffer=new pn(this.graphicsDevice,a,e,{usage:1}),this.indexBuffer=new jr(this.graphicsDevice,1,i)}var o,h,l,c=new Float32Array(this.vertexBuffer.lock());if(this.useMesh){h=(o=new Float32Array(this.mesh.vertexBuffer.lock())).length/this.mesh.vertexBuffer.numVertices;for(var u=0;uthis.endTime&&(this.onFinished&&this.onFinished(),this.meshInstance.visible=!1),this.meshInstance&&(this.meshInstance.drawOrder=this.drawOrder)},e._destroyResources=function(){this.particleTexIN&&(this.particleTexIN.destroy(),this.particleTexIN=null),this.particleTexOUT&&(this.particleTexOUT.destroy(),this.particleTexOUT=null),this.particleTexStart&&this.particleTexStart.destroy&&(this.particleTexStart.destroy(),this.particleTexStart=null),this.rtParticleTexIN&&(this.rtParticleTexIN.destroy(),this.rtParticleTexIN=null),this.rtParticleTexOUT&&(this.rtParticleTexOUT.destroy(),this.rtParticleTexOUT=null),this.internalTex0&&(this.internalTex0.destroy(),this.internalTex0=null),this.internalTex1&&(this.internalTex1.destroy(),this.internalTex1=null),this.internalTex2&&(this.internalTex2.destroy(),this.internalTex2=null),this.internalTex3&&(this.internalTex3.destroy(),this.internalTex3=null),this.colorParam&&(this.colorParam.destroy(),this.colorParam=null),this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBuffer=void 0),this.indexBuffer&&(this.indexBuffer.destroy(),this.indexBuffer=void 0),this.material&&(this.material.destroy(),this.material=null)},e.destroy=function(){this.camera=null,this._destroyResources()},v(t,[{key:"defaultParamTexture",get:function(){var t=this;return Sf.get(this.graphicsDevice,(function(){for(var e=16,i=new Float32Array(1024),n=0;n0&&this.material.transparent===e&&(this.mesh.setPositions(this.positions),this.mesh.setColors(this.colors),this.mesh.update(1,!1),this.meshInstance||(this.meshInstance=new Vh(this.mesh,this.material,Ff)),t.push(this.meshInstance))},e.clear=function(){this.positions.length=0,this.colors.length=0},t}(),Nf=function(){function t(t){this.device=t,this.map=new Map}var e=t.prototype;return e.getBatch=function(t,e){var i=this.map.get(t);return i||(i=new Bf(this.device,t,e),this.map.set(t,i)),i},e.onPreRender=function(t,e){this.map.forEach((function(i){i.onPreRender(t,e)}))},e.clear=function(){this.map.forEach((function(t){return t.clear()}))},t}(),Uf=[],zf=new wt,Vf=function(){function t(t){this.device=t,this.quadMesh=null,this.textureShader=null,this.depthTextureShader=null,this.cubeLocalPos=null,this.cubeWorldPos=null,this.batchesMap=new Map,this.allBatches=new Set,this.updatedLayers=new Set,this._materialDepth=null,this._materialNoDepth=null,this.layerMeshInstances=new Map}var e=t.prototype;return e.createMaterial=function(t){var e=new ih;return e.vertexColors=!0,e.blendType=2,e.depthTest=t,e.update(),e},e.getBatch=function(t,e){var i=this.batchesMap.get(t);i||(i=new Nf(this.device),this.batchesMap.set(t,i)),this.allBatches.add(i);var n=e?this.materialDepth:this.materialNoDepth;return i.getBatch(n,t)},e.getShader=function(t,e){if(!this[t]){this[t]=Fo(this.device,"\n\t\t\t\tattribute vec2 vertex_position;\n\t\t\t\tuniform mat4 matrix_model;\n\t\t\t\tvarying vec2 uv0;\n\t\t\t\tvoid main(void) {\n\t\t\t\t\tgl_Position = matrix_model * vec4(vertex_position, 0, 1);\n\t\t\t\t\tuv0 = vertex_position.xy + 0.5;\n\t\t\t\t}\n\t\t\t",e,"DebugShader:"+t)}return this[t]},e.getTextureShader=function(){return this.getShader("textureShader","\n\t\t\tvarying vec2 uv0;\n\t\t\tuniform sampler2D colorMap;\n\t\t\tvoid main (void) {\n\t\t\t\tgl_FragColor = vec4(texture2D(colorMap, uv0).xyz, 1);\n\t\t\t}\n\t\t")},e.getUnfilterableTextureShader=function(){return this.getShader("textureShaderUnfilterable","\n\t\t\tvarying vec2 uv0;\n\t\t\tuniform highp sampler2D colorMap;\n\t\t\tvoid main (void) {\n\t\t\t\tivec2 uv = ivec2(uv0 * textureSize(colorMap, 0));\n\t\t\t\tgl_FragColor = vec4(texelFetch(colorMap, uv, 0).xyz, 1);\n\t\t\t}\n\t\t")},e.getDepthTextureShader=function(){return this.getShader("depthTextureShader","\n\t\t\t"+Ro.screenDepthPS+"\n\t\t\tvarying vec2 uv0;\n\t\t\tvoid main() {\n\t\t\t\tfloat depth = getLinearScreenDepth(getImageEffectUV(uv0)) * camera_params.x;\n\t\t\t\tgl_FragColor = vec4(vec3(depth), 1.0);\n\t\t\t}\n\t\t")},e.getQuadMesh=function(){return this.quadMesh||(this.quadMesh=new dh(this.device),this.quadMesh.setPositions([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),this.quadMesh.update(5)),this.quadMesh},e.drawMesh=function(t,e,i,n,s){if(!n){var r=this.getGraphNode(e);n=new Vh(i,t,r)}var a=this.layerMeshInstances.get(s);a||(a=[],this.layerMeshInstances.set(s,a)),a.push(n)},e.drawWireAlignedBox=function(t,e,i,n,s,r){if(r){var a=function(t,e,i){zf.set(t,e,i),r.transformPoint(zf,zf),Uf.push(zf.x,zf.y,zf.z)};a(t.x,t.y,t.z),a(t.x,e.y,t.z),a(t.x,e.y,t.z),a(e.x,e.y,t.z),a(e.x,e.y,t.z),a(e.x,t.y,t.z),a(e.x,t.y,t.z),a(t.x,t.y,t.z),a(t.x,t.y,e.z),a(t.x,e.y,e.z),a(t.x,e.y,e.z),a(e.x,e.y,e.z),a(e.x,e.y,e.z),a(e.x,t.y,e.z),a(e.x,t.y,e.z),a(t.x,t.y,e.z),a(t.x,t.y,t.z),a(t.x,t.y,e.z),a(t.x,e.y,t.z),a(t.x,e.y,e.z),a(e.x,e.y,t.z),a(e.x,e.y,e.z),a(e.x,t.y,t.z),a(e.x,t.y,e.z)}else Uf.push(t.x,t.y,t.z,t.x,e.y,t.z,t.x,e.y,t.z,e.x,e.y,t.z,e.x,e.y,t.z,e.x,t.y,t.z,e.x,t.y,t.z,t.x,t.y,t.z,t.x,t.y,e.z,t.x,e.y,e.z,t.x,e.y,e.z,e.x,e.y,e.z,e.x,e.y,e.z,e.x,t.y,e.z,e.x,t.y,e.z,t.x,t.y,e.z,t.x,t.y,t.z,t.x,t.y,e.z,t.x,e.y,t.z,t.x,e.y,e.z,e.x,e.y,t.z,e.x,e.y,e.z,e.x,t.y,t.z,e.x,t.y,e.z);this.getBatch(s,n).addLinesArrays(Uf,i),Uf.length=0},e.drawWireSphere=function(t,e,i,n,s,r){for(var a=2*Math.PI/n,o=0,h=0;hi){this._time=this.looping?0:i;for(var n=0;n=0?1:-1,l=0;l=0;m+=h){var _=d[m],v=d[m+1];if(_.time<=this._time&&v.time>=this._time){var g=(this._time-_.time)/(v.time-_.time);f._pos.lerp(_.position,v.position,g),f._quat.slerp(_.rotation,v.rotation,g),f._scale.lerp(_.scale,v.scale,g),f._written=!0,this._currKeyIndices[u]=m,p=!0;break}}(1===d.length||!p&&0===this._time&&this.looping)&&(f._pos.copy(d[0].position),f._quat.copy(d[0].rotation),f._scale.copy(d[0].scale),f._written=!0)}}}},e.blend=function(t,e,i){for(var n=this._interpolatedKeys.length,s=0;s0)for(var x=0;x<=s;x++)for(var S=0;S<=r;S++){var b=S/r*2*Math.PI-Math.PI,T=Math.sin(b),w=Math.cos(b);f.set(T*e,-n/2,w*e),d.set(T*i,n/2,w*i),l.lerp(f,d,x/s),c.sub2(d,f).normalize(),p.set(w,0,-T),u.cross(p,c).normalize(),m.push(l.x,l.y,l.z),_.push(u.x,u.y,u.z);var E=S/r,A=x/s;v.push(E,1-A);var C=A;if(A=E,E=(E=C)*rp+sp,A=A*rp+sp,E/=3,g.push(E,1-A),x0)for(var ft=0;ft1&&y.push(h,h+ft,h+ft-1)}if(h+=r,i>0)for(var xt=0;xt1&&y.push(h,h+xt-1,h+xt)}}return o.positions=m,o.normals=_,o.uvs=v,o.uvs1=g,o.indices=y,o}return x(e,t),e}(Mf),op=function(t){function e(e){var i,n,s,r,a;void 0===e&&(e={});var o=null!=(i=e.radius)?i:.3,h=null!=(n=e.height)?n:1,l=null!=(s=e.heightSegments)?s:1,c=null!=(r=e.sides)?r:20;return a=t.call(this,o,o,h-2*o,l,c,!0)||this,e.calculateTangents&&(a.tangents=Cf(a.positions,a.normals,a.uvs,a.indices)),a}return x(e,t),e}(ap),hp=function(t){function e(e){var i,n,s,r,a,o;void 0===e&&(e={});var h=null!=(i=e.baseRadius)?i:.5,l=null!=(n=e.peakRadius)?n:0,c=null!=(s=e.height)?s:1,u=null!=(r=e.heightSegments)?r:5,d=null!=(a=e.capSegments)?a:18;return o=t.call(this,h,l,c,u,d,!1)||this,e.calculateTangents&&(o.tangents=Cf(o.positions,o.normals,o.uvs,o.indices)),o}return x(e,t),e}(ap),lp=function(t){function e(e){var i,n,s,r,a;void 0===e&&(e={});var o=null!=(i=e.radius)?i:.5,h=null!=(n=e.height)?n:1,l=null!=(s=e.heightSegments)?s:5,c=null!=(r=e.capSegments)?r:20;return a=t.call(this,o,o,h,l,c,!1)||this,e.calculateTangents&&(a.tangents=Cf(a.positions,a.normals,a.uvs,a.indices)),a}return x(e,t),e}(ap),cp=function(t){function e(e){var i,n,s,r;void 0===e&&(e={}),r=t.call(this)||this;for(var a=null!=(i=e.halfExtents)?i:new Mt(.5,.5),o=null!=(n=e.widthSegments)?n:5,h=null!=(s=e.lengthSegments)?s:5,l=[],c=[],u=[],d=[],f=0,p=0;p<=o;p++)for(var m=0;m<=h;m++){var _=-a.x+2*a.x*p/o,v=-(-a.y+2*a.y*m/h),g=p/o,y=m/h;l.push(_,0,v),c.push(0,1,0),u.push(g,1-y),p 0.5) {\n\t\tif (dAtten > 0.00001) {\n\t\t\tdirLm.xyz = dirLm.xyz * 2.0 - vec3(1.0);\n\t\t\tdAtten = saturate(dAtten);\n\t\t\tgl_FragColor.rgb = normalize(dLightDirNormW.xyz*dAtten + dirLm.xyz*dirLm.w) * 0.5 + vec3(0.5);\n\t\t\tgl_FragColor.a = dirLm.w + dAtten;\n\t\t\tgl_FragColor.a = max(gl_FragColor.a, 1.0 / 255.0);\n\t\t} else {\n\t\t\tgl_FragColor = dirLm;\n\t\t}\n\t} else {\n\t\tgl_FragColor.rgb = dirLm.xyz;\n\t\tgl_FragColor.a = max(dirLm.w, dAtten > 0.00001? (1.0/255.0) : 0.0);\n\t}\n",bakeLmEndPS:"\n#ifdef LIGHTMAP_RGBM\n\tgl_FragColor.rgb = dDiffuseLight;\n\tgl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.5));\n\tgl_FragColor.rgb /= 8.0;\n\tgl_FragColor.a = clamp( max( max( gl_FragColor.r, gl_FragColor.g ), max( gl_FragColor.b, 1.0 / 255.0 ) ), 0.0,1.0 );\n\tgl_FragColor.a = ceil(gl_FragColor.a * 255.0) / 255.0;\n\tgl_FragColor.rgb /= gl_FragColor.a;\n#else\n\tgl_FragColor = vec4(dDiffuseLight, 1.0);\n#endif\n",dilatePS:"\nvarying vec2 vUv0;\nuniform sampler2D source;\nuniform vec2 pixelOffset;\nvoid main(void) {\n\tvec4 c = texture2DLodEXT(source, vUv0, 0.0);\n\tc = c.a>0.0? c : texture2DLodEXT(source, vUv0 - pixelOffset, 0.0);\n\tc = c.a>0.0? c : texture2DLodEXT(source, vUv0 + vec2(0, -pixelOffset.y), 0.0);\n\tc = c.a>0.0? c : texture2DLodEXT(source, vUv0 + vec2(pixelOffset.x, -pixelOffset.y), 0.0);\n\tc = c.a>0.0? c : texture2DLodEXT(source, vUv0 + vec2(-pixelOffset.x, 0), 0.0);\n\tc = c.a>0.0? c : texture2DLodEXT(source, vUv0 + vec2(pixelOffset.x, 0), 0.0);\n\tc = c.a>0.0? c : texture2DLodEXT(source, vUv0 + vec2(-pixelOffset.x, pixelOffset.y), 0.0);\n\tc = c.a>0.0? c : texture2DLodEXT(source, vUv0 + vec2(0, pixelOffset.y), 0.0);\n\tc = c.a>0.0? c : texture2DLodEXT(source, vUv0 + pixelOffset, 0.0);\n\tgl_FragColor = c;\n}\n",bilateralDeNoisePS:"\nfloat normpdf3(in vec3 v, in float sigma) {\n\treturn 0.39894 * exp(-0.5 * dot(v, v) / (sigma * sigma)) / sigma;\n}\nvec3 decodeRGBM(vec4 rgbm) {\n\tvec3 color = (8.0 * rgbm.a) * rgbm.rgb;\n\treturn color * color;\n}\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\nvec4 encodeRGBM(vec3 color) {\n\tvec4 encoded;\n\tencoded.rgb = pow(color.rgb, vec3(0.5));\n\tencoded.rgb *= 1.0 / 8.0;\n\tencoded.a = saturate( max( max( encoded.r, encoded.g ), max( encoded.b, 1.0 / 255.0 ) ) );\n\tencoded.a = ceil(encoded.a * 255.0) / 255.0;\n\tencoded.rgb /= encoded.a;\n\treturn encoded;\n}\n#define MSIZE 15\nvarying vec2 vUv0;\nuniform sampler2D source;\nuniform vec2 pixelOffset;\nuniform vec2 sigmas;\nuniform float bZnorm;\nuniform float kernel[MSIZE];\nvoid main(void) {\n\t\n\tvec4 pixelRgbm = texture2DLodEXT(source, vUv0, 0.0);\n\tif (pixelRgbm.a <= 0.0) {\n\t\tgl_FragColor = pixelRgbm;\n\t\treturn ;\n\t}\n\tfloat sigma = sigmas.x;\n\tfloat bSigma = sigmas.y;\n\tvec3 pixelHdr = decodeRGBM(pixelRgbm);\n\tvec3 accumulatedHdr = vec3(0.0);\n\tfloat accumulatedFactor = 0.0;\n\tconst int kSize = (MSIZE-1)/2;\n\tfor (int i = -kSize; i <= kSize; ++i) {\n\t\tfor (int j = -kSize; j <= kSize; ++j) {\n\t\t\t\n\t\t\tvec2 coord = vUv0 + vec2(float(i), float(j)) * pixelOffset;\n\t\t\tvec4 rgbm = texture2DLodEXT(source, coord, 0.0);\n\t\t\tif (rgbm.a > 0.0) {\n\t\t\t\tvec3 hdr = decodeRGBM(rgbm);\n\t\t\t\tfloat factor = kernel[kSize + j] * kernel[kSize + i];\n\t\t\t\tfactor *= normpdf3(hdr - pixelHdr, bSigma) * bZnorm;\n\t\t\t\taccumulatedHdr += factor * hdr;\n\t\t\t\taccumulatedFactor += factor;\n\t\t\t}\n\t\t}\n\t}\n\tgl_FragColor = encodeRGBM(accumulatedHdr / accumulatedFactor);\n}\n"},pp=new Bt,mp=new Nt,_p=new Wt,vp=new Wt,gp=new pt(1,1,0,.4),yp=.28209479177387814,xp=function(t,e,i,n,s){var r=t.getProp("x"),a=t.getProp("y"),o=t.getProp("z"),h=t.getProp("rot_1"),l=t.getProp("rot_2"),c=t.getProp("rot_3"),u=t.getProp("rot_0"),d=t.getProp("scale_0"),f=t.getProp("scale_1"),p=t.getProp("scale_2"),m=t.getProp("f_dc_0"),_=t.getProp("f_dc_1"),v=t.getProp("f_dc_2"),g=t.getProp("opacity");this.read=function(t){e&&(e.x=r[t],e.y=a[t],e.z=o[t]),i&&i.set(h[t],l[t],c[t],u[t]),n&&n.set(Math.exp(d[t]),Math.exp(f[t]),Math.exp(p[t])),s&&s.set(.5+m[t]*yp,.5+_[t]*yp,.5+v[t]*yp,function(t){if(t>0)return 1/(1+Math.exp(-t));var e=Math.exp(t);return e/(1+e)}(g[t]))}},Sp=function(t,e,i){mp.set(i.x,i.y,i.z,i.w).normalize(),t.setTRS(e,mp,wt.ONE)},bp=function(){function t(t){this.elements=void 0,this.numSplats=void 0,this.elements=t,this.numSplats=this.getElement("vertex").count}t.calcSplatAabb=function(t,e,i,n){Sp(pp,e,i),_p.center.set(0,0,0),_p.halfExtents.set(2*n.x,2*n.y,2*n.z),t.setFromTransformedAabb(_p,pp)};var e=t.prototype;return e.getProp=function(t,e){var i;return void 0===e&&(e="vertex"),null==(i=this.getElement(e))||null==(i=i.properties.find((function(e){return e.name===t})))?void 0:i.storage},e.getElement=function(t){return this.elements.find((function(e){return e.name===t}))},e.addProp=function(t,e){this.getElement("vertex").properties.push({type:"float",name:t,storage:e,byteSize:4})},e.createIter=function(t,e,i,n){return new xp(this,t,e,i,n)},e.calcAabb=function(t,e){for(var i,n,s,r,a,o,h=!0,l=this.getProp("x"),c=this.getProp("y"),u=this.getProp("z"),d=this.getProp("scale_0"),f=this.getProp("scale_1"),p=this.getProp("scale_2"),m=0;mi&&(i=t[n]);return{min:e,max:i}},e=function(t,e,i){var n=function(t){return t=153391689&((t=51130563&((t=50393103&((t=4278190335&((t&=1023)^t<<16))^t<<8))^t<<4))^t<<2)};return(n(i)<<2)+(n(e)<<1)+n(t)},i=this.getProp("x"),n=this.getProp("y"),s=this.getProp("z"),r=t(i),a=r.min,o=r.max,h=t(n),l=h.min,c=h.max,u=t(s),d=u.min,f=u.max,p=a===o?0:1024/(o-a),m=l===c?0:1024/(c-l),_=d===f?0:1024/(f-d),v=new Map,g=0;g= numSplats) {\n\t\t\treturn false;\n\t\t}\n\t\tivec2 orderUV = ivec2(\n\t\t\tint(orderId % textureWidth),\n\t\t\tint(orderId / textureWidth)\n\t\t);\n\t\tsplatId = texelFetch(splatOrder, orderUV, 0).r;\n\t\tsplatUV = ivec2(\n\t\t\tint(splatId % textureWidth),\n\t\t\tint(splatId / textureWidth)\n\t\t);\n\t\treturn true;\n\t}\n\tuvec4 tA;\n\tvec3 getCenter() {\n\t\ttA = texelFetch(transformA, splatUV, 0);\n\t\treturn uintBitsToFloat(tA.xyz);\n\t}\n\tvoid getCovariance(out vec3 covA, out vec3 covB) {\n\t\tvec4 tB = texelFetch(transformB, splatUV, 0);\n\t\tvec2 tC = unpackHalf2x16(tA.w);\n\t\tcovA = tB.xyz;\n\t\tcovB = vec3(tC.x, tC.y, tB.w);\n\t}\n\tvec4 calcV1V2(in vec3 splat_cam, in vec3 covA, in vec3 covB, mat3 W) {\n\t\tmat3 Vrk = mat3(\n\t\t\tcovA.x, covA.y, covA.z, \n\t\t\tcovA.y, covB.x, covB.y,\n\t\t\tcovA.z, covB.y, covB.z\n\t\t);\n\t\tfloat focal = viewport.x * matrix_projection[0][0];\n\t\tfloat J1 = focal / splat_cam.z;\n\t\tvec2 J2 = -J1 / splat_cam.z * splat_cam.xy;\n\t\tmat3 J = mat3(\n\t\t\tJ1, 0.0, J2.x, \n\t\t\t0.0, J1, J2.y, \n\t\t\t0.0, 0.0, 0.0\n\t\t);\n\t\tmat3 T = W * J;\n\t\tmat3 cov = transpose(T) * Vrk * T;\n\t\tfloat diagonal1 = cov[0][0] + 0.3;\n\t\tfloat offDiagonal = cov[0][1];\n\t\tfloat diagonal2 = cov[1][1] + 0.3;\n\t\tfloat mid = 0.5 * (diagonal1 + diagonal2);\n\t\tfloat radius = length(vec2((diagonal1 - diagonal2) / 2.0, offDiagonal));\n\t\tfloat lambda1 = mid + radius;\n\t\tfloat lambda2 = max(mid - radius, 0.1);\n\t\tvec2 diagonalVector = normalize(vec2(offDiagonal, lambda1 - diagonal1));\n\t\tvec2 v1 = min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector;\n\t\tvec2 v2 = min(sqrt(2.0 * lambda2), 1024.0) * vec2(diagonalVector.y, -diagonalVector.x);\n\t\treturn vec4(v1, v2);\n\t}\n\tvec3 unpack111011(uint bits) {\n\t\treturn vec3(\n\t\t\tfloat(bits >> 21u) / 2047.0,\n\t\t\tfloat((bits >> 11u) & 0x3ffu) / 1023.0,\n\t\t\tfloat(bits & 0x7ffu) / 2047.0\n\t\t);\n\t}\n\tvoid fetchScale(in uvec4 t, out float scale, out vec3 a, out vec3 b, out vec3 c) {\n\t\tscale = uintBitsToFloat(t.x);\n\t\ta = unpack111011(t.y) * 2.0 - 1.0;\n\t\tb = unpack111011(t.z) * 2.0 - 1.0;\n\t\tc = unpack111011(t.w) * 2.0 - 1.0;\n\t}\n\tvoid fetch(in uvec4 t, out vec3 a, out vec3 b, out vec3 c, out vec3 d) {\n\t\ta = unpack111011(t.x) * 2.0 - 1.0;\n\t\tb = unpack111011(t.y) * 2.0 - 1.0;\n\t\tc = unpack111011(t.z) * 2.0 - 1.0;\n\t\td = unpack111011(t.w) * 2.0 - 1.0;\n\t}\n\t#if defined(USE_SH1)\n\t\t#define SH_C1 0.4886025119029199f\n\t\tuniform highp usampler2D splatSH_1to3;\n\t#if defined(USE_SH2)\n\t\t#define SH_C2_0 1.0925484305920792f\n\t\t#define SH_C2_1 -1.0925484305920792f\n\t\t#define SH_C2_2 0.31539156525252005f\n\t\t#define SH_C2_3 -1.0925484305920792f\n\t\t#define SH_C2_4 0.5462742152960396f\n\t\tuniform highp usampler2D splatSH_4to7;\n\t\tuniform highp usampler2D splatSH_8to11;\n\t#if defined(USE_SH3)\n\t\t#define SH_C3_0 -0.5900435899266435f\n\t\t#define SH_C3_1 2.890611442640554f\n\t\t#define SH_C3_2 -0.4570457994644658f\n\t\t#define SH_C3_3 0.3731763325901154f\n\t\t#define SH_C3_4 -0.4570457994644658f\n\t\t#define SH_C3_5 1.445305721320277f\n\t\t#define SH_C3_6 -0.5900435899266435f\n\t\tuniform highp usampler2D splatSH_12to15;\n\t#endif\n\t#endif\n\t#endif\n\tvec3 evalSH(in vec3 dir) {\n\t\tvec3 result = vec3(0.0);\n\t#if defined(USE_SH1)\n\t\tfloat x = dir.x;\n\t\tfloat y = dir.y;\n\t\tfloat z = dir.z;\n\t\tfloat scale;\n\t\tvec3 sh1, sh2, sh3;\n\t\tfetchScale(texelFetch(splatSH_1to3, splatUV, 0), scale, sh1, sh2, sh3);\n\t\tresult += SH_C1 * (-sh1 * y + sh2 * z - sh3 * x);\n\t#if defined(USE_SH2)\n\t\tfloat xx = x * x;\n\t\tfloat yy = y * y;\n\t\tfloat zz = z * z;\n\t\tfloat xy = x * y;\n\t\tfloat yz = y * z;\n\t\tfloat xz = x * z;\n\t\tvec3 sh4, sh5, sh6, sh7;\n\t\tvec3 sh8, sh9, sh10, sh11;\n\t\tfetch(texelFetch(splatSH_4to7, splatUV, 0), sh4, sh5, sh6, sh7);\n\t\tfetch(texelFetch(splatSH_8to11, splatUV, 0), sh8, sh9, sh10, sh11);\n\t\tresult +=\n\t\t\tsh4 * (SH_C2_0 * xy) * +\n\t\t\tsh5 * (SH_C2_1 * yz) +\n\t\t\tsh6 * (SH_C2_2 * (2.0 * zz - xx - yy)) +\n\t\t\tsh7 * (SH_C2_3 * xz) +\n\t\t\tsh8 * (SH_C2_4 * (xx - yy));\n\t#if defined(USE_SH3)\n\t\tvec3 sh12, sh13, sh14, sh15;\n\t\tfetch(texelFetch(splatSH_12to15, splatUV, 0), sh12, sh13, sh14, sh15);\n\t\tresult +=\n\t\t\tsh9 * (SH_C3_0 * y * (3.0 * xx - yy)) +\n\t\t\tsh10 * (SH_C3_1 * xy * z) +\n\t\t\tsh11 * (SH_C3_2 * y * (4.0 * zz - xx - yy)) +\n\t\t\tsh12 * (SH_C3_3 * z * (2.0 * zz - 3.0 * xx - 3.0 * yy)) +\n\t\t\tsh13 * (SH_C3_4 * x * (4.0 * zz - xx - yy)) +\n\t\t\tsh14 * (SH_C3_5 * z * (xx - yy)) +\n\t\t\tsh15 * (SH_C3_6 * x * (xx - 3.0 * yy));\n\t#endif\n\t#endif\n\t\tresult *= scale;\n\t#endif\n\t\treturn result;\n\t}\n"+e.vertex,r=n+Ro.decodePS+(e.dither===Ao?"":Ro.bayerPS+Ro.opacityDitherPS)+ko.tonemapCode(e.toneMapping)+ko.gammaCode(e.gamma)+"\n\t#ifndef DITHER_NONE\n\t\tvarying float id;\n\t#endif\n\t#ifdef PICK_PASS\n\t\tuniform vec4 uColor;\n\t#endif\n\tvec4 evalSplat(vec2 texCoord, vec4 color) {\n\t\tmediump float A = dot(texCoord, texCoord);\n\t\tif (A > 1.0) {\n\t\t\tdiscard;\n\t\t}\n\t\tmediump float B = exp(-A * 4.0) * color.a;\n\t\tif (B < 1.0 / 255.0) {\n\t\t\tdiscard;\n\t\t}\n\t\t#ifdef PICK_PASS\n\t\t\tif (B < 0.3) {\n\t\t\t\tdiscard;\n\t\t\t}\n\t\t\treturn uColor;\n\t\t#endif\n\t\t#ifndef DITHER_NONE\n\t\t\topacityDither(B, id * 0.013);\n\t\t#endif\n\t\t#ifdef TONEMAP_ENABLED\n\t\t\treturn vec4(gammaCorrectOutput(toneMap(decodeGamma(color.rgb))), B);\n\t\t#else\n\t\t\treturn vec4(color.rgb, B);\n\t\t#endif\n\t}\n"+e.fragment;return Pr.createDefinition(t,{name:"SplatShader",attributes:{vertex_position:Le,vertex_id_attrib:hi},vertexCode:s,fragmentCode:r})},t}(),wp=new Tp,Ep=function(){function t(t,e){this.device=void 0,this.numSplats=void 0,this.centers=void 0,this.aabb=void 0,this.colorTexture=void 0,this.transformATexture=void 0,this.transformBTexture=void 0,this.hasSH=void 0,this.sh1to3Texture=void 0,this.sh4to7Texture=void 0,this.sh8to11Texture=void 0,this.sh12to15Texture=void 0;var i=e.numSplats;this.device=t,this.numSplats=i,this.centers=new Float32Array(3*e.numSplats),e.getCenters(this.centers),this.aabb=new Wt,e.calcAabb(this.aabb);var n=this.evalTextureSize(i);this.colorTexture=this.createTexture("splatColor",7,n),this.transformATexture=this.createTexture("transformA",Me,n),this.transformBTexture=this.createTexture("transformB",me,n),this.updateColorData(e),this.updateTransformData(e),this.hasSH=e.hasSHData,this.hasSH&&(this.sh1to3Texture=this.createTexture("splatSH_1to3",Me,n),this.sh4to7Texture=this.createTexture("splatSH_4to7",Me,n),this.sh8to11Texture=this.createTexture("splatSH_8to11",Me,n),this.sh12to15Texture=this.createTexture("splatSH_12to15",Me,n),this.updateSHData(e))}var e=t.prototype;return e.destroy=function(){var t,e,i,n,s,r,a;null==(t=this.colorTexture)||t.destroy(),null==(e=this.transformATexture)||e.destroy(),null==(i=this.transformBTexture)||i.destroy(),null==(n=this.sh1to3Texture)||n.destroy(),null==(s=this.sh4to7Texture)||s.destroy(),null==(r=this.sh8to11Texture)||r.destroy(),null==(a=this.sh12to15Texture)||a.destroy()},e.createMaterial=function(t){var e=function(t){var e;void 0===t&&(t={});var i=null!=(e=t.dither)?e:Ao,n=i!==Ao,s=new eh;return s.name="splatMaterial",s.cull=0,s.blendType=n?3:2,s.depthWrite=n,s.getShaderVariant=function(e,n,s,r,a,o,h,l){var c,u,d={pass:a,gamma:1===a?n.gammaCorrection?3:0:n.gammaCorrection,toneMapping:1===a?0:n.toneMapping,vertex:null!=(c=t.vertex)?c:"\n\tuniform vec3 view_position;\n\tuniform sampler2D splatColor;\n\tvarying mediump vec2 texCoord;\n\tvarying mediump vec4 color;\n\tmediump vec4 discardVec = vec4(0.0, 0.0, 2.0, 1.0);\n\tvoid main(void)\n\t{\n\t\tif (!calcSplatUV()) {\n\t\t\tgl_Position = discardVec;\n\t\t\treturn;\n\t\t}\n\t\tvec3 center = getCenter();\n\t\tmat4 model_view = matrix_view * matrix_model;\n\t\tvec4 splat_cam = model_view * vec4(center, 1.0);\n\t\tif (splat_cam.z > 0.0) {\n\t\t\tgl_Position = discardVec;\n\t\t\treturn;\n\t\t}\n\t\tvec4 splat_proj = matrix_projection * splat_cam;\n\t\tsplat_proj.z = clamp(splat_proj.z, -abs(splat_proj.w), abs(splat_proj.w));\n\t\tvec3 covA, covB;\n\t\tgetCovariance(covA, covB);\n\t\tvec4 v1v2 = calcV1V2(splat_cam.xyz, covA, covB, transpose(mat3(model_view)));\n\t\tcolor = texelFetch(splatColor, splatUV, 0);\n\t\tfloat scale = min(1.0, sqrt(-log(1.0 / 255.0 / color.a)) / 2.0);\n\t\tv1v2 *= scale;\n\t\tif (dot(v1v2.xy, v1v2.xy) < 4.0 && dot(v1v2.zw, v1v2.zw) < 4.0) {\n\t\t\tgl_Position = discardVec;\n\t\t\treturn;\n\t\t}\n\t\tgl_Position = splat_proj + vec4((vertex_position.x * v1v2.xy + vertex_position.y * v1v2.zw) / viewport * splat_proj.w, 0, 0);\n\t\ttexCoord = vertex_position.xy * scale / 2.0;\n\t\t#ifdef USE_SH1\n\t\t\tvec4 worldCenter = matrix_model * vec4(center, 1.0);\n\t\t\tvec3 viewDir = normalize((worldCenter.xyz / worldCenter.w - view_position) * mat3(matrix_model));\n\t\t\tcolor.xyz = max(color.xyz + evalSH(viewDir), 0.0);\n\t\t#endif\n\t\t#ifndef DITHER_NONE\n\t\t\tid = float(splatId);\n\t\t#endif\n\t}\n",fragment:null!=(u=t.fragment)?u:"\n\tvarying mediump vec2 texCoord;\n\tvarying mediump vec4 color;\n\tvoid main(void)\n\t{\n\t\tgl_FragColor = evalSplat(texCoord, color);\n\t}\n",dither:i,defines:t.defines},f=new Zr(h,l),p=Do(e);return p.register("splat",wp),p.getProgram("splat",d,f)},s.update(),s}(y({},this.hasSH?{defines:["USE_SH1","USE_SH2","USE_SH3"]}:{},t));return e.setParameter("splatColor",this.colorTexture),e.setParameter("transformA",this.transformATexture),e.setParameter("transformB",this.transformBTexture),e.setParameter("tex_params",new Float32Array([this.numSplats,this.colorTexture.width,0,0])),this.hasSH&&(e.setParameter("splatSH_1to3",this.sh1to3Texture),e.setParameter("splatSH_4to7",this.sh4to7Texture),e.setParameter("splatSH_8to11",this.sh8to11Texture),e.setParameter("splatSH_12to15",this.sh12to15Texture)),e},e.evalTextureSize=function(t){var e=Math.ceil(Math.sqrt(t)),i=Math.ceil(t/e);return new Mt(e,i)},e.createTexture=function(t,e,i){return new or(this.device,{name:t,width:i.x,height:i.y,format:e,cubemap:!1,mipmaps:!1,minFilter:0,magFilter:0,addressU:1,addressV:1})},e.getTextureFormat=function(t,e){t.isWebGL1&&(e=!1);var i,n=t.extTextureHalfFloat&&t.textureHalfFloatUpdatable,s=t.extTextureFloat;return e?s?i=!1:n&&(i=!0):n?i=!0:s&&(i=!1),i},e.updateColorData=function(t){var e=this.colorTexture;if(e){for(var i=e.lock(),n=t.getProp("f_dc_0"),s=t.getProp("f_dc_1"),r=t.getProp("f_dc_2"),a=t.getProp("opacity"),o=.28209479177387814,h=0;h255?255:l,i[4*h+1]=c<0?0:c>255?255:c,i[4*h+2]=u<0?0:u>255?255:u,i[4*h+3]=d<0?0:d>255?255:d}e.unlock()}},e.updateTransformData=function(t){var e=Tt.float2Half;if(this.transformATexture){for(var i=this.transformATexture.lock(),n=new Float32Array(i.buffer),s=this.transformBTexture.lock(),r=new wt,a=new Nt,o=new wt,h=t.createIter(r,a,o),l=new At,c=new wt,u=new wt,d=0;da?a:n)<<21|(s<0?0:s>o?o:s)<<11|(r<0?0:r>a?a:r)},l=new Float32Array(1),c=new Uint32Array(l.buffer),u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d=0;dp&&(p=_)}if(0!==p){for(var v=0;v<45;++v)u[v]=u[v]/p*.5+.5;l[0]=p,e[4*d+0]=c[0],e[4*d+1]=h(u[0],u[15],u[30]),e[4*d+2]=h(u[1],u[16],u[31]),e[4*d+3]=h(u[2],u[17],u[32]),i[4*d+0]=h(u[3],u[18],u[33]),i[4*d+1]=h(u[4],u[19],u[34]),i[4*d+2]=h(u[5],u[20],u[35]),i[4*d+3]=h(u[6],u[21],u[36]),n[4*d+0]=h(u[7],u[22],u[37]),n[4*d+1]=h(u[8],u[23],u[38]),n[4*d+2]=h(u[9],u[24],u[39]),n[4*d+3]=h(u[10],u[25],u[40]),s[4*d+0]=h(u[11],u[26],u[41]),s[4*d+1]=h(u[12],u[27],u[42]),s[4*d+2]=h(u[13],u[28],u[43]),s[4*d+3]=h(u[14],u[29],u[44])}}this.sh1to3Texture.unlock(),this.sh4to7Texture.unlock(),this.sh8to11Texture.unlock(),this.sh12to15Texture.unlock()},t}();function Ap(){var t,e,i,n,s,r,a,o=!1,h={x:0,y:0,z:0},l={x:0,y:0,z:0},c={x:0,y:0,z:0},u={x:0,y:0,z:0};self.onmessage=function(d){if(d.data.order&&(t=new Uint32Array(d.data.order)),d.data.centers){e=new Float32Array(d.data.centers),c.x=u.x=e[0],c.y=u.y=e[1],c.z=u.z=e[2];for(var f=e.length/3,p=1;p=0?function(){var t=function(t,e,i){for(;t<=e;){var n=e+t>>1,s=i(n);if(s>0)t=n+1;else{if(!(s<0))return n;e=n-1}}return~t}(0,w-1,(function(t){return-B(t)}));return Math.min(w,Math.abs(t))}():w;if(i)for(var U=0;U0){var e=this.cameras[0].xr;e&&e.active&&2===e.views.list.length&&(Dp[0]/=2)}this.material.setParameter("viewport",Dp)},e.sort=function(t){if(this.sorter){var e=t.getWorldTransform();e.getTranslation(Rp),e.getZ(Ip);var i=this.meshInstance.node.getWorldTransform(),n=Pp.invert(i);n.transformPoint(Rp,Rp),n.transformVector(Ip,Ip),Rp.equalsApprox(this.lastCameraPosition)&&Ip.equalsApprox(this.lastCameraDirection)||(this.lastCameraPosition.copy(Rp),this.lastCameraDirection.copy(Ip),this.sorter.setCamera(Rp,Ip))}this.updateViewport()},e.update=function(){if(this.cameras.length>0){var t=this.cameras[0];this.sort(t._node),this.cameras.length=0}},t}(),kp="FILL_WINDOW",Op="KEEP_ASPECT",Fp="AUTO",Bp="FIXED";function Np(){return Cp}function Up(t){Cp=t}var zp=function(){function t(){}return t.push=function(e,i){i&&t._types.length>0?console.assert("Script Ordering Error. Contact support@playcanvas.com"):t._types.push(e)},t}();zp._types=[];var Vp=!1,Gp=!1,Hp={app:null,create:function(t,e){if(Vp){var i=e(Hp.app);i._pcScriptName=t,zp.push(i,Vp),this.fire("created",t,e)}},attribute:function(t,e,i,n){},createLoadingScreen:function(t){Gp||(Gp=!0,t(Np()))}};Object.defineProperty(Hp,"legacy",{get:function(){return Vp},set:function(t){Vp=t}}),R.attach(Hp);var Wp=function(){function t(){this.renderPasses=[],this.renderTargetMap=new Map}var e=t.prototype;return e.addRenderPass=function(t){t.frameUpdate();for(var e=t.beforePasses,i=0;i=0&&t<=1?0:1})),Qp(["fr","pt"],(function(t){return t>=0&&t<2?0:1})),Qp(["da"],(function(t){return 1===t||!Number.isInteger(t)&&t>=0&&t<=1?0:1})),Qp(["de","en","it","el","es","tr","fi","sv","nb","no","ur"],(function(t){return 1===t?0:1})),Qp(["ru","uk"],(function(t){if(Number.isInteger(t)){var e=t%10,i=t%100;if(1===e&&11!==i)return 0;if(e>=2&&e<=4&&(i<12||i>14))return 1;if(0===e||e>=5&&e<=9||i>=11&&i<=14)return 2}return 3})),Qp(["pl"],(function(t){if(Number.isInteger(t)){if(1===t)return 0;var e=t%10,i=t%100;if(e>=2&&e<=4&&(i<12||i>14))return 1;if(e>=0&&e<=1||e>=5&&e<=9||i>=12&&i<=14)return 2}return 3})),Qp(["ar"],(function(t){if(0===t)return 0;if(1===t)return 1;if(2===t)return 2;if(Number.isInteger(t)){var e=t%100;if(e>=3&&e<=10)return 3;if(e>=11&&e<=99)return 4}return 5}));var tm=Zp[Jp(Yp)];function em(t){return Zp[t]||tm}var im=new RegExp("^\\s*(?:(?:[a-z]+[a-z0-9\\-+.]*:)?//|data:|blob:)","i"),nm=function(){function t(t,e,i,n,s,r){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=null),void 0===r&&(r=null),this.url=t,this.filename=e,this.hash=i,this.size=n,this.opt=s,this.contents=r}return t.prototype.equals=function(t){return this.url===t.url&&this.filename===t.filename&&this.hash===t.hash&&this.size===t.size&&this.opt===t.opt&&this.contents===t.contents},t}(),sm=-1,rm={pvr:"extCompressedTexturePVRTC",dxt:"extCompressedTextureS3TC",etc2:"extCompressedTextureETC",etc1:"extCompressedTextureETC1",basis:"canvas"},am=["pvr","dxt","etc2","etc1","basis"],om=function(t){function e(e,i,n,s,r){var a;return(a=t.call(this)||this)._id=sm--,a._name=e||"",a.type=i,a.tags=new ht(a),a._preload=!1,a._file=null,a._data=s||{},a.options=r||{},a._resources=[],a.urlObject=null,a._i18n={},a.loaded=!1,a.loading=!1,a.registry=null,n&&(a.file=n),a}x(e,t);var i=e.prototype;return i.getFileUrl=function(){var t=this.file;if(!t||!t.url)return null;var e=t.url;if(this.registry&&this.registry.prefix&&!im.test(e)&&(e=this.registry.prefix+e),"script"!==this.type&&t.hash){var i=-1!==e.indexOf("?")?"&":"?";e+=i+"t="+t.hash}return e},i.getAbsoluteUrl=function(t){if(t.startsWith("blob:")||t.startsWith("data:"))return t;var e=D.getDirectory(this.file.url);return D.join(e,t)},i.getLocalizedAssetId=function(t){return t=$p(t,this._i18n),this._i18n[t]||null},i.addLocalizedAssetId=function(t,e){this._i18n[t]=e,this.fire("add:localized",t,e)},i.removeLocalizedAssetId=function(t){var e=this._i18n[t];e&&(delete this._i18n[t],this.fire("remove:localized",t,e))},i.ready=function(t,e){e=e||this,this.loaded?t.call(e,this):this.once("load",(function(i){t.call(e,i)}))},i.reload=function(){this.loaded&&(this.loaded=!1,this.registry.load(this))},i.unload=function(){if(this.loaded||0!==this._resources.length){this.fire("unload",this),this.registry.fire("unload:"+this.id,this);var t=this._resources;this.urlObject&&(URL.revokeObjectURL(this.urlObject),this.urlObject=null),this.resources=[],this.loaded=!1,this.file&&this.registry._loader.clearCache(this.getFileUrl(),this.type);for(var e=0;e0,maxRetries:n},e)},v(e,[{key:"id",get:function(){return this._id},set:function(t){this._id=t}},{key:"name",get:function(){return this._name},set:function(t){if(this._name!==t){var e=this._name;this._name=t,this.fire("name",this,this._name,e)}}},{key:"file",get:function(){return this._file},set:function(t){var e=this;if(t&&t.variants&&-1!==["texture","textureatlas","bundle"].indexOf(this.type)){var i,n=(null==(i=this.registry)||null==(i=i._loader)?void 0:i._app)||Np(),s=null==n?void 0:n.graphicsDevice;if(s)for(var r=function(){var i=am[a];if(t.variants[i]&&s[rm[i]])return t=t.variants[i],0;if(n.enableBundles){var r=n.bundles.listBundlesForAsset(e);if(r&&r.find((function(t){var e;return null==t||null==(e=t.file)?void 0:e.variants[i]})))return 0}},a=0,o=am.length;athis.bytesRead+this.headerSize){this.headerRead=!0;var t=new DataView(this.data.buffer,this.bytesRead,this.headerSize);null!=this.decoder||(this.decoder=new TextDecoder("windows-1252"));var e=this.decoder.decode(t);if(this.fileName=e.substring(0,100).replace(/\0/g,""),this.fileSize=parseInt(e.substring(124,136),8),this.fileType=e.substring(156,157),this.ustarFormat=e.substring(257,263),-1!==this.ustarFormat.indexOf("ustar")){var i=e.substring(345,500).replace(/\0/g,"");i.length>0&&(this.fileName=i.trim()+this.fileName.trim())}this.bytesRead+=512}if(this.headerRead){if(this.bytesReceived0&&this.loader.enableRetry(t.maxAssetRetries),t.useDevicePixelRatio||(t.useDevicePixelRatio=t.use_device_pixel_ratio),t.resolutionMode||(t.resolutionMode=t.resolution_mode),t.fillMode||(t.fillMode=t.fill_mode),this._width=t.width,this._height=t.height,t.useDevicePixelRatio&&(this.graphicsDevice.maxPixelRatio=window.devicePixelRatio),this.setCanvasResolution(t.resolutionMode,this._width,this._height),this.setCanvasFillMode(t.fillMode,this._width,this._height),t.layers&&t.layerOrder){var i=new dd("application"),n={};for(var s in t.layers){var r=t.layers[s];r.id=parseInt(s,10),r.enabled=1!==r.id,n[s]=new ld(r)}for(var a=0,o=t.layerOrder.length;a0,d.tags.add(u.tags),u.i18n)for(var f in u.i18n)d.addLocalizedAssetId(f,u.i18n[f]);this.assets.add(d)}},n._getScriptReferences=function(t){var e=[];t.settings.priority_scripts&&(e=t.settings.priority_scripts);for(var i=[],n={},s=0;sn._timeToCountFrames?(n.fps=n._fpsAccum,n._fpsAccum=0,n._timeToCountFrames=t+1e3):n._fpsAccum++,this.stats.drawCalls.total=this.graphicsDevice._drawCallsPerFrame,this.graphicsDevice._drawCallsPerFrame=0},n._fillFrameStats=function(){var t=this.stats.frame;t.cameras=this.renderer._camerasRendered,t.materials=this.renderer._materialSwitches,t.shaders=this.graphicsDevice._shaderSwitchesPerFrame,t.shadowMapUpdates=this.renderer._shadowMapUpdates,t.shadowMapTime=this.renderer._shadowMapTime,t.depthMapTime=this.renderer._depthMapTime,t.forwardTime=this.renderer._forwardTime;var e=this.graphicsDevice._primsPerFrame;t.triangles=e[4]/3+Math.max(e[5]-2,0)+Math.max(e[6]-2,0),t.cullTime=this.renderer._cullTime,t.sortTime=this.renderer._sortTime,t.skinTime=this.renderer._skinTime,t.morphTime=this.renderer._morphTime,t.lightClusters=this.renderer._lightClusters,t.lightClustersTime=this.renderer._lightClustersTime,t.otherPrimitives=0;for(var i=0;ii/n?e=(t=i)/s:t=(e=n)*s}else this._fillMode===kp&&(t=i,e=n);return this.graphicsDevice.canvas.style.width=t+"px",this.graphicsDevice.canvas.style.height=e+"px",this.updateCanvasSize(),{width:t,height:e}}},n.updateCanvasSize=function(){var t;if(this._allowResize&&(null==(t=this.xr)||!t.active)&&this._resolutionMode===Fp){var e=this.graphicsDevice.canvas;this.graphicsDevice.resizeCanvas(e.clientWidth,e.clientHeight)}},n.onLibrariesLoaded=function(){this._librariesLoaded=!0,this.systems.rigidbody&&this.systems.rigidbody.onLibraryLoaded()},n.applySceneSettings=function(t){var e;if(this.systems.rigidbody&&"undefined"!=typeof Ammo){var i=t.physics.gravity;this.systems.rigidbody.gravity.set(i[0],i[1],i[2])}this.scene.applySettings(t),t.render.hasOwnProperty("skybox")&&(t.render.skybox?(e=this.assets.get(t.render.skybox))?this.setSkybox(e):this.assets.once("add:"+t.render.skybox,this.setSkybox,this):this.setSkybox(null))},n.setAreaLightLuts=function(t,e){t&&e&&qp.set(this.graphicsDevice,t,e)},n.setSkybox=function(t){var e=this;if(t!==this._skyboxAsset){var i=function(){e.setSkybox(null)},n=function(){e.scene.setSkybox(e._skyboxAsset?e._skyboxAsset.resources:null)};this._skyboxAsset&&(this.assets.off("load:"+this._skyboxAsset.id,n,this),this.assets.off("remove:"+this._skyboxAsset.id,i,this),this._skyboxAsset.off("change",n,this)),this._skyboxAsset=t,this._skyboxAsset&&(this.assets.on("load:"+this._skyboxAsset.id,n,this),this.assets.once("remove:"+this._skyboxAsset.id,i,this),this._skyboxAsset.on("change",n,this),0!==this.scene.skyboxMip||this._skyboxAsset.loadFaces||(this._skyboxAsset.loadFaces=!0),this.assets.load(this._skyboxAsset)),n()}},n._firstBake=function(){var t;null==(t=this.lightmapper)||t.bake(null,this.scene.lightmapMode)},n._firstBatch=function(){var t;null==(t=this.batcher)||t.generate()},n._processTimestamp=function(t){return t},n.drawLine=function(t,e,i,n,s){this.scene.drawLine(t,e,i,n,s)},n.drawLines=function(t,e,i,n){void 0===i&&(i=!0),void 0===n&&(n=this.scene.defaultDrawLayer),this.scene.drawLines(t,e,i,n)},n.drawLineArrays=function(t,e,i,n){void 0===i&&(i=!0),void 0===n&&(n=this.scene.defaultDrawLayer),this.scene.drawLineArrays(t,e,i,n)},n.drawWireSphere=function(t,e,i,n,s,r){void 0===i&&(i=pt.WHITE),void 0===n&&(n=20),void 0===s&&(s=!0),void 0===r&&(r=this.scene.defaultDrawLayer),this.scene.immediate.drawWireSphere(t,e,i,n,s,r)},n.drawWireAlignedBox=function(t,e,i,n,s,r){void 0===i&&(i=pt.WHITE),void 0===n&&(n=!0),void 0===s&&(s=this.scene.defaultDrawLayer),this.scene.immediate.drawWireAlignedBox(t,e,i,n,s,r)},n.drawMeshInstance=function(t,e){void 0===e&&(e=this.scene.defaultDrawLayer),this.scene.immediate.drawMesh(null,null,null,t,e)},n.drawMesh=function(t,e,i,n){void 0===n&&(n=this.scene.defaultDrawLayer),this.scene.immediate.drawMesh(e,i,t,null,n)},n.drawQuad=function(t,e,i){void 0===i&&(i=this.scene.defaultDrawLayer),this.scene.immediate.drawMesh(e,t,this.scene.immediate.getQuadMesh(),null,i)},n.drawTexture=function(t,e,i,n,s,r,a,o){if(void 0===a&&(a=this.scene.defaultDrawLayer),void 0===o&&(o=!0),!1!==o||this.graphicsDevice.isWebGPU){var h=new Bt;h.setTRS(new wt(t,e,0),Nt.IDENTITY,new wt(i,-n,0)),r||((r=new eh).cull=0,r.setParameter("colorMap",s),r.shader=o?this.scene.immediate.getTextureShader():this.scene.immediate.getUnfilterableTextureShader(),r.update()),this.drawQuad(h,r,a)}},n.drawDepthTexture=function(t,e,i,n,s){void 0===s&&(s=this.scene.defaultDrawLayer);var r=new eh;r.cull=0,r.shader=this.scene.immediate.getDepthTextureShader(),r.update(),this.drawTexture(t,e,i,n,null,r,s)},n.destroy=function(){var t,e,n,s;if(this._inFrameUpdate)this._destroyRequested=!0;else{var r=this.graphicsDevice.canvas.id;this.fire("destroy",this),this.off("librariesloaded"),"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this._visibilityChangeHandler,!1),document.removeEventListener("mozvisibilitychange",this._visibilityChangeHandler,!1),document.removeEventListener("msvisibilitychange",this._visibilityChangeHandler,!1),document.removeEventListener("webkitvisibilitychange",this._visibilityChangeHandler,!1)),this._visibilityChangeHandler=null,this.root.destroy(),this.root=null,this.mouse&&(this.mouse.off(),this.mouse.detach(),this.mouse=null),this.keyboard&&(this.keyboard.off(),this.keyboard.detach(),this.keyboard=null),this.touch&&(this.touch.off(),this.touch.detach(),this.touch=null),this.elementInput&&(this.elementInput.detach(),this.elementInput=null),this.gamepads&&(this.gamepads.destroy(),this.gamepads=null),this.controller&&(this.controller=null),this.systems.destroy(),this.scene.layers&&this.scene.layers.destroy();for(var a=this.assets.list(),o=0;o0){var n=i.bakeArea;Xl(Lm,t,e),Lm.mulScalar(.5*n),i._node.rotateLocal(Lm.x,0,Lm.y)}i._node.getWorldTransform();var s=this.scene.gammaCorrection?2.2:1,r=Math.pow(this.intensity,s);i.intensity=Math.pow(r/e,1/s)},v(e,[{key:"numVirtualLights",get:function(){return 0===this.light.type?this.light.bakeNumSamples:1}}])}(Dm),Om=new wt,Fm=function(t){function e(e){var i=e.scene,n=new Sm("AmbientLight");return n.addComponent("light",{type:"directional",affectDynamic:!0,affectLightmapped:!1,bake:!0,bakeNumSamples:i.ambientBakeNumSamples,castShadows:!0,normalOffsetBias:.05,shadowBias:.2,shadowDistance:1,shadowResolution:2048,shadowType:0,color:pt.WHITE,intensity:1,bakeDir:!1}),t.call(this,i,n.light.light,e.lightingParams)||this}return x(e,t),e.prototype.prepareVirtualLight=function(t,e){jl(Om,t,e,0,this.scene.ambientBakeSpherePart),this.light._node.lookAt(Om.mulScalar(-1)),this.light._node.rotateLocal(90,0,0);var i=this.scene.gammaCorrection?2.2:1,n=2*Math.PI*this.scene.ambientBakeSpherePart,s=Math.pow(n,i);this.light.intensity=Math.pow(s/e,1/i)},v(e,[{key:"numVirtualLights",get:function(){return this.light.bakeNumSamples}}])}(Dm),Bm=function(){function t(t,e){void 0===e&&(e=null),this.node=t,this.component=t.render||t.model,e=e||this.component.meshInstances,this.store(),this.meshInstances=e,this.bounds=null,this.renderTargets=[]}var e=t.prototype;return e.store=function(){this.castShadows=this.component.castShadows},e.restore=function(){this.component.castShadows=this.castShadows},t}(),Nm=function(){function t(t){this.device=t,this.shaderDilate=Fo(t,Ro.fullscreenQuadVS,fp.dilatePS,"lmDilate"),this.constantTexSource=t.scope.resolve("source"),this.constantPixelOffset=t.scope.resolve("pixelOffset"),this.pixelOffset=new Float32Array(2),this.shaderDenoise=null,this.sigmas=null,this.constantSigmas=null,this.kernel=null}var e=t.prototype;return e.setSourceTexture=function(t){this.constantTexSource.setValue(t)},e.prepare=function(t,e){this.pixelOffset[0]=1/t,this.pixelOffset[1]=1/e,this.constantPixelOffset.setValue(this.pixelOffset)},e.prepareDenoise=function(t,e){this.shaderDenoise||(this.shaderDenoise=Fo(this.device,Ro.fullscreenQuadVS,fp.bilateralDeNoisePS,"lmBilateralDeNoise"),this.sigmas=new Float32Array(2),this.constantSigmas=this.device.scope.resolve("sigmas"),this.constantKernel=this.device.scope.resolve("kernel[0]"),this.bZnorm=this.device.scope.resolve("bZnorm")),this.sigmas[0]=t,this.sigmas[1]=e,this.constantSigmas.setValue(this.sigmas),this.evaluateDenoiseUniforms(t,e)},e.evaluateDenoiseUniforms=function(t,e){function i(t,e){return.39894*Math.exp(-.5*t*t/(e*e))/e}this.kernel=this.kernel||new Float32Array(15);for(var n=this.kernel,s=Math.floor(7),r=0;r<=s;++r){var a=i(r,t);n[s+r]=a,n[s-r]=a}this.constantKernel.setValue(this.kernel);var o=1/i(0,e);this.bZnorm.setValue(o)},t}(),Um=function(t){function e(e,i,n,s,r,a){var o;return(o=t.call(this,e)||this).viewBindGroups=[],o.renderer=i,o.camera=n,o.worldClusters=s,o.receivers=r,o.lightArray=a,o}x(e,t);var i=e.prototype;return i.destroy=function(){this.viewBindGroups.forEach((function(t){t.defaultUniformBuffer.destroy(),t.destroy()})),this.viewBindGroups.length=0},i.execute=function(){this.device;var t=this.renderer,e=this.camera,i=this.receivers,n=this.renderTarget,s=this.worldClusters,r=this.lightArray;t.renderForwardLayer(e,n,null,void 0,1,this.viewBindGroups,{meshInstances:i,splitLights:r,lightClusters:s})},e}(Kr),zm=new wt,Vm=function(){function t(t,e,i,n,s){this.device=t,this.root=e,this.scene=i,this.renderer=n,this.assets=s,this.shadowMapCache=n.shadowMapCache,this._tempSet=new Set,this._initCalled=!1,this.passMaterials=[],this.ambientAOMaterial=null,this.fog="",this.ambientLight=new pt,this.renderTargets=new Map,this.stats={renderPasses:0,lightmapCount:0,totalRenderTime:0,forwardTime:0,fboTime:0,shadowMapTime:0,compileTime:0,shadersLinked:0}}var e=t.prototype;return e.destroy=function(){var t;Dh.decRef(this.blackTex),this.blackTex=null,Dh.destroy(),this.device=null,this.root=null,this.scene=null,this.renderer=null,this.assets=null,null==(t=this.camera)||t.destroy(),this.camera=null},e.initBake=function(t){if(!this._initCalled){this._initCalled=!0,this.lightmapFilters=new Nm(t),this.constantBakeDir=t.scope.resolve("bakeDir"),this.materials=[],this.blackTex=new or(this.device,{width:4,height:4,format:7,type:di,name:"lightmapBlack"}),Dh.incRef(this.blackTex);var e=new ll;e.clearColor.set(0,0,0,0),e.clearColorBuffer=!0,e.clearDepthBuffer=!1,e.clearStencilBuffer=!1,e.frustumCulling=!1,e.projection=1,e.aspectRatio=1,e.node=new Rh,this.camera=e}if(this.scene.clusteredLightingEnabled){var i=new Sd(t.supportsAreaLights,t.maxTextureSize,(function(){}));this.lightingParams=i;var n=this.scene.lighting;i.shadowsEnabled=n.shadowsEnabled,i.shadowAtlasResolution=n.shadowAtlasResolution,i.cookiesEnabled=n.cookiesEnabled,i.cookieAtlasResolution=n.cookieAtlasResolution,i.areaLightsEnabled=n.areaLightsEnabled,i.cells=new wt(3,3,3),i.maxLightsPerCell=4,this.worldClusters=new Hl(t),this.worldClusters.name="ClusterLightmapper"}},e.finishBake=function(t){function e(t){Dh.decRef(t.colorBuffer),t.destroy()}this.materials=[],this.renderTargets.forEach((function(t){e(t)})),this.renderTargets.clear(),t.forEach((function(t){t.renderTargets.forEach((function(t){e(t)})),t.renderTargets.length=0})),this.ambientAOMaterial=null,this.worldClusters&&(this.worldClusters.destroy(),this.worldClusters=null)},e.createMaterialForPass=function(t,e,i,n){var s=new Lc;s.name="lmMaterial-pass:"+i+"-ambient:"+n,s.chunks.APIVersion=Qi;if(s.chunks.transformVS="#define UV1LAYOUT\n"+Ro.transformVS,0===i){var r=fp.bakeLmEndPS;n?r="\n dDiffuseLight = ((dDiffuseLight - 0.5) * max("+e.ambientBakeOcclusionContrast.toFixed(1)+" + 1.0, 0.0)) + 0.5;\n dDiffuseLight += vec3("+e.ambientBakeOcclusionBrightness.toFixed(1)+");\n dDiffuseLight = saturate(dDiffuseLight);\n dDiffuseLight *= dAmbientLight;\n "+r:(s.ambient=new pt(0,0,0),s.ambientTint=!0),s.chunks.basePS=Ro.basePS+(7===e.lightmapPixelFormat?"\n#define LIGHTMAP_RGBM\n":""),s.chunks.endPS=r,s.lightMap=this.blackTex}else s.chunks.basePS=Ro.basePS+"\nuniform sampler2D texture_dirLightMap;\nuniform float bakeDir;\n",s.chunks.endPS=fp.bakeDirLmEndPS;return s.chunks.outputAlphaPS="\n",s.chunks.outputAlphaOpaquePS="\n",s.chunks.outputAlphaPremulPS="\n",s.cull=0,s.forceUv1=!0,s.update(),s},e.createMaterials=function(t,e,i){for(var n=0;n0&&e.push(new Bm(t,l))}}for(var d=0;d0){this.renderer.shadowRenderer.frameUpdate();var c=1===e?2:1;this.setLightmapping(o,!1,c),this.initBake(i),this.bakeInternal(c,o,h);var u=64;1===e&&(u|=vo),this.scene.ambientBake&&(u|=To),this.setLightmapping(o,!0,c,u),this.finishBake(o)}var d=lt();this.stats.totalRenderTime=d-n,this.stats.shadersLinked=i._shaderStats.linked-s,this.stats.compileTime=i._shaderStats.compileTime-a,this.stats.fboTime=i._renderTargetCreationTime-r,this.stats.lightmapCount=o.length},e.allocateTextures=function(t,e){for(var i=0;i0){e.copy(t[0].aabb);for(var i=1;i1&&b>1&&y.light.bakeDir&&(b=1);for(var T=0;T1&&y.prepareVirtualLight(T,b),y.startBake();var w=!1,E=this.lightCameraPrepare(r,y);for(_=0;_0&&T>0)&&!(x&&m>0);m++){var M=A.renderTargets[m],P=A.renderTargets[m].colorBuffer.width,R=this.renderTargets.get(P),I=R.colorBuffer;0===m?g=n.updateShaders:g&&(n.updateShaders=!0);var D=this.passMaterials[m];for(x&&T+1===b&&0===m&&(D=this.ambientAOMaterial),u=0;u=this._right){var i=e.length;if(i)if(t=e[i-1])this._left=e[i-1],this._right=1/0,this._len=0,this._recip=0,this._p0=this._p1=i-1;else{var n=this._findKey(t,e);this._left=e[n],this._right=e[n+1],this._len=this._right-this._left;var s=1/this._len;this._recip=isFinite(s)?s:0,this._p0=n,this._p1=n+1}else this._left=-1/0,this._right=1/0,this._len=0,this._recip=0,this._p0=this._p1=0}this._t=0===this._recip?0:(t-this._left)*this._recip,this._hermite.valid=!1},e._findKey=function(t,e){for(var i=0;t>=e[i+1];)i++;return i},e.eval=function(t,e,i){var n=i._data,s=i._components,r=this._p0*s;if(0===e)for(var a=0;a=t)},e.nextEventBehindTime=function(t){return!!this.nextEvent&&(t===this.track.duration?this.isReverse?this.nextEvent.time>=t:this.nextEvent.time<=t:this.isReverse?this.nextEvent.time>t:this.nextEvent.time=this.track.events.length?this._eventCursor=0:this._eventCursor<0&&(this._eventCursor=this.track.events.length-1)},e.clipFrameTime=function(e){var i=t.eventFrame;i.start=0,i.end=e,i.residual=0,this.isReverse?e<0&&(i.start=this.track.duration,i.end=0,i.residual=e+this.track.duration):e>this.track.duration&&(i.start=0,i.end=this.track.duration,i.residual=e-this.track.duration)},e.alignCursorToCurrentTime=function(){for(this.resetEventCursor();this.nextEventBehindTime(this._time)&&this._eventCursor!==this.eventCursorEnd;)this.moveEventCursor()},e.fireNextEvent=function(){this._eventHandler.fire(this.nextEvent.name,y({track:this.track},this.nextEvent)),this.moveEventCursor()},e.fireNextEventInFrame=function(t,e){return!(!this.nextEventAheadOfTime(t)||!this.nextEventBehindTime(e))&&(this.fireNextEvent(),!0)},e.activeEventsForFrame=function(e,i){var n=t.eventFrame;this.clipFrameTime(i);for(var s=this.eventCursor;this.fireNextEventInFrame(e,n.end)&&s!==this.eventCursor;);this.loop&&Math.abs(n.residual)>0&&this.activeEventsForFrame(n.start,n.residual)},e.progressForTime=function(t){return t*this._speed/this._track.duration},e._update=function(t){if(this._playing){var e=this._time,i=this._track.duration,n=this._speed,s=this._loop;this._track.events.length>0&&i>0&&this.activeEventsForFrame(e,e+n*t),e+=n*t,n>=0?e>i&&(s?e=e%i||0:(e=this._track.duration,this.pause())):e<0&&(s?e=i+(e%i||0):(e=0,this.pause())),this._time=e}this._time!==this._snapshot._time&&this._track.eval(this._time,this._snapshot)},e.play=function(){this._playing=!0,this._time=0},e.stop=function(){this._playing=!1,this._time=0},e.pause=function(){this._playing=!1},e.resume=function(){this._playing=!0},e.reset=function(){this._time=0},v(t,[{key:"name",get:function(){return this._name},set:function(t){this._name=t}},{key:"track",get:function(){return this._track},set:function(t){this._track=t,this._snapshot=new jm(t)}},{key:"snapshot",get:function(){return this._snapshot}},{key:"time",get:function(){return this._time},set:function(t){this._time=t,this.alignCursorToCurrentTime()}},{key:"speed",get:function(){return this._speed},set:function(t){var e=Math.sign(t)!==Math.sign(this._speed);this._speed=t,e&&this.alignCursorToCurrentTime()}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t}},{key:"blendWeight",get:function(){return this._blendWeight},set:function(t){this._blendWeight=t}},{key:"blendOrder",get:function(){return this._blendOrder},set:function(t){this._blendOrder=t}},{key:"eventCursor",get:function(){return this._eventCursor},set:function(t){this._eventCursor=t}},{key:"eventCursorEnd",get:function(){return this.isReverse?0:this._track.events.length-1}},{key:"nextEvent",get:function(){return this._track.events[this._eventCursor]}},{key:"isReverse",get:function(){return this._speed<0}}])}();qm.eventFrame={start:0,end:0,residual:0};var Ym="NONE",Km="PREV_STATE",Zm="NEXT_STATE",Qm="PREV_STATE_NEXT_STATE",Jm="NEXT_STATE_PREV_STATE",$m="GREATER_THAN",t_="LESS_THAN",e_="GREATER_THAN_EQUAL_TO",i_="LESS_THAN_EQUAL_TO",n_="EQUAL_TO",s_="NOT_EQUAL_TO",r_="INTEGER",a_="FLOAT",o_="BOOLEAN",h_="TRIGGER",l_="2D_DIRECTIONAL",c_="2D_CARTESIAN",u_="DIRECT",d_="START",f_="END",p_="ANY",m_=[d_,f_,p_],__="OVERWRITE",v_="ADDITIVE",g_=function(){function t(){}return t.dot=function(t,e){for(var i=t.length,n=0,s=0;s0){i=1/Math.sqrt(i);for(var n=e.length,s=0;s0&&(r=1/Math.sqrt(r));for(var a=0;a0;)this.removeClip(0)},e.updateClipTrack=function(t,e){this._clips.forEach((function(i){i.name.includes(t)&&(i.track=e)})),this.rebind()},e.findClip=function(t){for(var e=this._clips,i=0;i0&&a._update(t),!e)break;var c=void 0,u=void 0,d=void 0;if(l>=1)for(var f=0;f0)for(var p=0;p0&&i.push(n),i},t.encode=function(t,e,i){return(Array.isArray(t)?t.join("/"):t)+"/"+e+"/"+(Array.isArray(i)?i.join("/"):i)};var e=t.prototype;return e.resolve=function(t){return null},e.unresolve=function(t){},e.update=function(t){},t}(),E_=v((function(t,e,i,n){t.set?(this._set=t.set,this._get=t.get):this._set=t,this._type=e,this._components=i,this._targetPath=n,this._isTransform="localRotation"===this._targetPath.substring(this._targetPath.length-13)||"localPosition"===this._targetPath.substring(this._targetPath.length-13)||"localScale"===this._targetPath.substring(this._targetPath.length-10)}),[{key:"set",get:function(){return this._set}},{key:"get",get:function(){return this._get}},{key:"type",get:function(){return this._type}},{key:"components",get:function(){return this._components}},{key:"targetPath",get:function(){return this._targetPath}},{key:"isTransform",get:function(){return this._isTransform}}]),A_=function(){function t(e){var i=this;if(this._isPathInMask=function(t,e){var n=i._mask[t];return!!n&&!!(n.children||e&&!1!==n.value)},this.graph=e,e){this._mask=null;var n={},s=function(t){n[t.name]=t;for(var e=0;e0&&!!this.prevAnim,this.blending&&(this.blend=0,this.blendSpeed=1/e),this.skeleton&&(this.blending?(this.fromSkel.animation=i,this.fromSkel.addTime(this.skeleton._time),this.toSkel.animation=n):this.skeleton.animation=n),this.animEvaluator){var s=this.animEvaluator;if(this.blending)for(;s.clips.length>1;)s.removeClip(0);else this.animEvaluator.removeClips();var r=new qm(this.animations[this.currAnim],0,1,!0,this.loop);r.name=this.currAnim,r.blendWeight=this.blending?0:1,r.reset(),this.animEvaluator.addClip(r)}}this.playing=!0}},i.getAnimation=function(t){return this.animations[t]},i.setModel=function(t){t!==this.model&&(this._resetAnimationController(),this.model=t,this.animations&&this.currAnim&&this.animations[this.currAnim]&&this.play(this.currAnim))},i.onSetAnimations=function(){var t=this.entity.model;if(t){var e=t.model;e&&e!==this.model&&this.setModel(e)}if(!this.currAnim&&this.activate&&this.enabled&&this.entity.enabled){var i=Object.keys(this._animations);i.length>0&&this.play(i[0])}},i._resetAnimationController=function(){this.skeleton=null,this.fromSkel=null,this.toSkel=null,this.animEvaluator=null},i._createAnimationController=function(){var t=this.model,e=this.animations,i=!1,n=!1;for(var s in e){if(e.hasOwnProperty(s))e[s].constructor===T_?n=!0:i=!0}var r=t.getGraph();i?(this.fromSkel=new Jf(r),this.toSkel=new Jf(r),this.skeleton=new Jf(r),this.skeleton.looping=this.loop,this.skeleton.setGraph(r)):n&&(this.animEvaluator=new S_(new A_(this.entity)))},i.loadAnimationAssets=function(t){var e=this;if(t&&t.length)for(var i=this.system.app.assets,n=function(t){if(t.resources.length>1)for(var i=0;i1){if(n&&n.length>1)for(var r=0;r1)for(var o=0;o1)for(var h=0;h1)for(var e=0;e0&&this.play(a[0])}},i.onBeforeRemove=function(){for(var t=0;t=1&&(this.blend=1)),this.playing){var e=this.skeleton;if(null!==e&&null!==this.model){if(this.blending)e.blend(this.fromSkel,this.toSkel,this.blend);else{var i=t*this.speed;e.addTime(i),(this.speed>0&&e._time===e.animation.duration&&!this.loop||this.speed<0&&0===e._time&&!this.loop)&&(this.playing=!1)}this.blending&&1===this.blend&&(e.animation=this.toSkel.animation),e.updateGraph()}}var n=this.animEvaluator;if(n){for(var s=0;s1&&(n.clips[1].blendWeight=this.blend),n.update(t)}this.blending&&1===this.blend&&(this.blending=!1)},v(e,[{key:"animations",get:function(){return this._animations},set:function(t){this._animations=t,this.onSetAnimations()}},{key:"assets",get:function(){return this._assets},set:function(t){var e=this._assets;if(e&&e.length)for(var i=0;i0)return t[t.length-1].time}return 0},set:function(t){if(this.skeleton&&(this.skeleton.currentTime=t,this.skeleton.addTime(0),this.skeleton.updateGraph()),this.animEvaluator)for(var e=this.animEvaluator.clips,i=0;i=0)this._animationList[n].animTrack=e;else{var s=this._getNodeFromPath(t);s.animTrack=e,this._animationList.push(s)}this._updateHasAnimations()},e._updateHasAnimations=function(){this._hasAnimations=this._animationList.length>0&&this._animationList.every((function(t){return t.animTrack&&t.animTrack!==T_.EMPTY}))},v(t,[{key:"name",get:function(){return this._name}},{key:"animations",get:function(){return this._animationList},set:function(t){this._animationList=t,this._updateHasAnimations()}},{key:"hasAnimations",get:function(){return this._hasAnimations}},{key:"speed",get:function(){return this._speed},set:function(t){this._speed=t}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t}},{key:"nodeCount",get:function(){return this._blendTree&&this._blendTree.constructor!==I_?this._blendTree.getNodeCount():1}},{key:"playable",get:function(){return-1!==m_.indexOf(this.name)||this.animations.length===this.nodeCount}},{key:"looping",get:function(){if(this.animations.length>0){var t=this.name+"."+this.animations[0].animTrack.name,e=this._controller.animEvaluator.findClip(t);if(e)return e.loop}return!1}},{key:"totalWeight",get:function(){for(var t=0,e=0;et&&(t=i.animTrack.duration)}return t}}])}(),N_=v((function(t){var e=t.from,i=t.to,n=t.time,s=void 0===n?0:n,r=t.priority,a=void 0===r?0:r,o=t.conditions,h=void 0===o?[]:o,l=t.exitTime,c=void 0===l?null:l,u=t.transitionOffset,d=void 0===u?null:u,f=t.interruptionSource,p=void 0===f?Ym:f;this._from=e,this._to=i,this._time=s,this._priority=a,this._conditions=h,this._exitTime=c,this._transitionOffset=d,this._interruptionSource=p}),[{key:"from",get:function(){return this._from}},{key:"to",get:function(){return this._to},set:function(t){this._to=t}},{key:"time",get:function(){return this._time}},{key:"priority",get:function(){return this._priority}},{key:"conditions",get:function(){return this._conditions}},{key:"exitTime",get:function(){return this._exitTime}},{key:"transitionOffset",get:function(){return this._transitionOffset}},{key:"interruptionSource",get:function(){return this._interruptionSource}},{key:"hasExitTime",get:function(){return!!this.exitTime}}]),U_=function(){function t(t,e,i,n,s,r,a){var o=this;this._states={},this._stateNames=[],this._findTransitionsFromStateCache={},this._findTransitionsBetweenStatesCache={},this._previousStateName=null,this._activeStateName=d_,this._activeStateDuration=0,this._activeStateDurationDirty=!0,this._playing=!1,this._activate=void 0,this._transitions=void 0,this._currTransitionTime=1,this._totalTransitionTime=1,this._isTransitioning=!1,this._transitionInterruptionSource=Ym,this._transitionPreviousStates=[],this._timeInState=0,this._timeInStateBefore=0,this.findParameter=function(t){return o._findParameter(t)},this._animEvaluator=t,this._eventHandler=s,this._findParameter=r,this._consumeTrigger=a;for(var h=0;h"+e];return i||(i=this._transitions.filter((function(i){return i.from===t&&i.to===e})),ud(i),this._findTransitionsBetweenStatesCache[t+"->"+e]=i),i},e._transitionHasConditionsMet=function(t){for(var e=t.conditions,i=0;in.value))return!1;break;case t_:if(!(s.value=n.value))return!1;break;case i_:if(!(s.value<=n.value))return!1;break;case n_:if(s.value!==n.value)return!1;break;case s_:if(s.value===n.value)return!1}}return!0},e._findTransition=function(t,e){var i=this,n=[];if(t&&e)n=n.concat(this._findTransitionsBetweenStates(t,e));else if(this._isTransitioning)switch(this._transitionInterruptionSource){case Km:n=(n=n.concat(this._findTransitionsFromState(this._previousStateName))).concat(this._findTransitionsFromState(p_));break;case Zm:n=(n=n.concat(this._findTransitionsFromState(this._activeStateName))).concat(this._findTransitionsFromState(p_));break;case Qm:n=(n=(n=n.concat(this._findTransitionsFromState(this._previousStateName))).concat(this._findTransitionsFromState(this._activeStateName))).concat(this._findTransitionsFromState(p_));break;case Jm:n=(n=(n=n.concat(this._findTransitionsFromState(this._activeStateName))).concat(this._findTransitionsFromState(this._previousStateName))).concat(this._findTransitionsFromState(p_))}else n=(n=n.concat(this._findTransitionsFromState(this._activeStateName))).concat(this._findTransitionsFromState(p_));if(n=n.filter((function(t){if(t.to===i.activeStateName)return!1;if(t.hasExitTime){var e=i._getActiveStateProgressForTime(i._timeInStateBefore),n=i._getActiveStateProgressForTime(i._timeInState);if(t.exitTime<1&&i.activeState.loop&&(e-=Math.floor(e),n-=Math.floor(n)),n===e){if(n!==t.exitTime)return null}else if(!(t.exitTime>e&&t.exitTime<=n))return null}return i._transitionHasConditionsMet(t)})),n.length>0){var s=n[0];if(s.to===f_){var r=this._findTransitionsFromState(d_)[0];s.to=r.to}return s}return null},e.updateStateFromTransition=function(t){var e,i,n;this.previousState=t.from?this.activeStateName:null,this.activeState=t.to,this._activeStateDurationDirty=!0;for(var s=0;s0&&t.transitionOffset<1,u=0,d=0;if(c){var f=l.timelineDuration*t.transitionOffset;u=f,d=f}this._timeInState=u,this._timeInStateBefore=d;for(var p=0;p0?n.blendWeight=0:n.blendWeight=l.animations[p].normalizedWeight,n.play(),c)n.time=l.timelineDuration*t.transitionOffset;else{var _=l.speed>=0?0:this.activeStateDuration;n.time=_}}},e._transitionToState=function(t){if(this._findState(t)){var e=this._findTransition(this._activeStateName,t);e||(this._animEvaluator.removeClips(),e=new N_({from:null,to:t})),this.updateStateFromTransition(e)}},e.assignAnimation=function(t,e,i,n){var s=t.split("."),r=this._findState(s[0]);r||(r=new B_(this,s[0],i),this._states[s[0]]=r,this._stateNames.push(s[0])),r.addAnimation(s,e),this._animEvaluator.updateClipTrack(r.name,e),void 0!==i&&(r.speed=i),void 0!==n&&(r.loop=n),!this._playing&&this._activate&&this.playable&&this.play(),this._activeStateDurationDirty=!0},e.removeNodeAnimations=function(t){if(-1!==m_.indexOf(t))return!1;var e=this._findState(t);return!!e&&(e.animations=[],!0)},e.play=function(t){t&&this._transitionToState(t),this._playing=!0},e.pause=function(){this._playing=!1},e.reset=function(){this._previousStateName=null,this._activeStateName=d_,this._playing=!1,this._currTransitionTime=1,this._totalTransitionTime=1,this._isTransitioning=!1,this._timeInState=0,this._timeInStateBefore=0,this._animEvaluator.removeClips()},e.rebind=function(){this._animEvaluator.rebind()},e.update=function(t){if(this._playing){var e,i,n;(this.activeState.loop||this._timeInStatethis.activeStateDuration&&(this._timeInState=this.activeStateDuration,t=this.activeStateDuration-this._timeInStateBefore));var s=this._findTransition(this._activeStateName);if(s&&this.updateStateFromTransition(s),this._isTransitioning)if(this._currTransitionTime+=t,this._currTransitionTime<=this._totalTransitionTime){for(var r=0!==this._totalTransitionTime?this._currTransitionTime/this._totalTransitionTime:1,a=0;a1){var l=e.length>2?this._resolvePath(t,e.slice(0,-1)):t,c=e[e.length-2];return function(t){n[s]=i(t),l[c]=n}}return function(t){n[s]=i(t)}},i._createAnimTargetForProperty=function(t,i,n){if(this.handlers&&i[0].startsWith("weight."))return this.handlers.weight(t,i[0].replace("weight.",""));if(this.handlers&&"material"===i[0]&&2===i.length){var s=i[1];if(s.endsWith("Map"))return this.handlers.materialTexture(t,s)}var r,a,o,h=this._resolvePath(t,i,!0);if(void 0===h)return null;if("number"==typeof h)r=this._setter(t,i,e._packFloat),a="vector",o=1;else if("boolean"==typeof h)r=this._setter(t,i,e._packBoolean),a="vector",o=1;else if("object"==typeof h)switch(h.constructor){case Mt:r=this._setter(t,i,e._packVec2),a="vector",o=2;break;case wt:r=this._setter(t,i,e._packVec3),a="vector",o=3;break;case Rt:r=this._setter(t,i,e._packVec4),a="vector",o=4;break;case pt:r=this._setter(t,i,e._packColor),a="vector",o=4;break;case Nt:r=this._setter(t,i,e._packQuat),a="quaternion",o=4;break;default:return null}return-1!==i.indexOf("material")?new E_((function(e){r(e),t.material.update()}),a,o,n):new E_(r,a,o,n)},i.rebind=function(){this.targetCache={},this.animComponent.rootBone?this.graph=this.animComponent.rootBone:this.graph=this.animComponent.entity;var t={},e=function(i){t[i.name]=i;for(var n=0;n0?this._layers[0]:null}}])}(Gm),K_=function(){this.enabled=!0},Z_=["enabled"],Q_=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="anim",i.ComponentType=Y_,i.DataType=K_,i.schema=Z_,i.on("beforeremove",i.onBeforeRemove,i),i.app.systems.on("animationUpdate",i.onAnimationUpdate,i),i}x(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){var s=this;t.prototype.initializeComponentData.call(this,e,i,Z_);var r=["animationAssets","stateGraph","layers","masks"];Object.keys(i).forEach((function(t){r.includes(t)||(e[t]=i[t])})),i.stateGraph&&(e.stateGraph=i.stateGraph,e.loadStateGraph(e.stateGraph)),i.layers&&i.layers.forEach((function(t,i){t._controller.states.forEach((function(n){t._controller._states[n]._animationList.forEach((function(n){if(n.animTrack&&n.animTrack!==T_.EMPTY)e.layers[i].assignAnimation(n.name,n.animTrack);else{var r=s.app.assets.get(t._component._animationAssets[t.name+":"+n.name].asset);r&&!r.loaded&&r.once("load",(function(){e.layers[i].assignAnimation(n.name,r.resource)}))}}))}))})),i.animationAssets&&(e.animationAssets=Object.assign(e.animationAssets,i.animationAssets)),i.masks&&Object.keys(i.masks).forEach((function(t){if(e.layers[t]){var n=i.masks[t].mask,s={};Object.keys(n).forEach((function(t){s[decodeURI(t)]=n[t]})),e.layers[t].mask=s}}))},i.onAnimationUpdate=function(t){var e=this.store;for(var i in e)if(e.hasOwnProperty(i)){var n=e[i].entity.anim;n.data.enabled&&n.entity.enabled&&n.playing&&n.update(t)}},i.cloneComponent=function(t,e){var i;t.anim.rootBone&&t.anim.rootBone!==t||(i={},t.anim.layers.forEach((function(t,n){if(t.mask){var s={};Object.keys(t.mask).forEach((function(i){var n=i.split("/");n.shift();var r=[e.name].concat(n).join("/");s[r]=t.mask[i]})),i[n]={mask:s}}})));var n={stateGraphAsset:t.anim.stateGraphAsset,animationAssets:t.anim.animationAssets,speed:t.anim.speed,activate:t.anim.activate,playing:t.anim.playing,rootBone:t.anim.rootBone,stateGraph:t.anim.stateGraph,layers:t.anim.layers,layerIndices:t.anim.layerIndices,parameters:t.anim.parameters,normalizeWeights:t.anim.normalizeWeights,masks:i};return this.addComponent(e,n)},i.onBeforeRemove=function(t,e){e.onBeforeRemove()},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("animationUpdate",this.onAnimationUpdate,this)},e}(Hm);Gm._buildAccessors(Y_.prototype,Z_);var J_=function(t){function e(e,i){return t.call(this,e,i)||this}x(e,t);var i=e.prototype;return i.setCurrentListener=function(){if(this.enabled&&this.entity.audiolistener&&this.entity.enabled){this.system.current=this.entity;var t=this.system.current.getPosition();this.system.manager.listener.setPosition(t)}},i.onEnable=function(){this.setCurrentListener()},i.onDisable=function(){this.system.current===this.entity&&(this.system.current=null)},e}(Gm),$_=function(){this.enabled=!0},tv=["enabled"],ev=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="audiolistener",i.ComponentType=J_,i.DataType=$_,i.schema=tv,i.manager=e.soundManager,i.current=null,i.app.systems.on("update",i.onUpdate,i),i}x(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){n=["enabled"],t.prototype.initializeComponentData.call(this,e,i,n)},i.onUpdate=function(t){if(this.current){var e=this.current.getPosition();this.manager.listener.setPosition(e);var i=this.current.getWorldTransform();this.manager.listener.setOrientation(i)}},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("update",this.onUpdate,this)},e}(Hm);Gm._buildAccessors(J_.prototype,tv);var iv=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this).on("set_assets",n.onSetAssets,n),n.on("set_loop",n.onSetLoop,n),n.on("set_volume",n.onSetVolume,n),n.on("set_pitch",n.onSetPitch,n),n.on("set_minDistance",n.onSetMinDistance,n),n.on("set_maxDistance",n.onSetMaxDistance,n),n.on("set_rollOffFactor",n.onSetRollOffFactor,n),n.on("set_distanceModel",n.onSetDistanceModel,n),n.on("set_3d",n.onSet3d,n),n}x(e,t);var i=e.prototype;return i.play=function(t){if(this.enabled&&this.entity.enabled){var e;this.channel&&this.stop();var i=this.data;if(i.sources[t])if(i["3d"]){var n=this.entity.getPosition();e=this.system.manager.playSound3d(i.sources[t],n,i),i.currentSource=t,i.channel=e}else e=this.system.manager.playSound(i.sources[t],i),i.currentSource=t,i.channel=e}},i.pause=function(){this.channel&&this.channel.pause()},i.unpause=function(){this.channel&&this.channel.paused&&this.channel.unpause()},i.stop=function(){this.channel&&(this.channel.stop(),this.channel=null)},i.onSetAssets=function(t,e,i){var n=[],s=i.length;if(e&&e.length)for(var r=0;r1e-5){var i=this._tweenInfo.lerpColor;i.lerp(this._tweenInfo.from,this._tweenInfo.to,e),this._applyTintImmediately(new pt(i.r,i.g,i.b,i.a))}else this._applyTintImmediately(this._tweenInfo.to),this._cancelTween()},i._cancelTween=function(){delete this._tweenInfo},i.onUpdate=function(){this._tweenInfo&&this._updateTintTween()},i.onEnable=function(){this._isHovering=!1,this._hoveringCounter=0,this._isPressed=!1,this._imageReference.onParentComponentEnable(),this._toggleHitElementListeners("on"),this._forceReapplyVisualState()},i.onDisable=function(){this._toggleHitElementListeners("off"),this._resetToDefaultVisualState(this.transitionMode)},i.onRemove=function(){this._toggleLifecycleListeners("off",this.system),this.onDisable()},v(e,[{key:"data",get:function(){var t=this.system.store[this.entity.getGuid()];return t?t.data:null}},{key:"enabled",get:function(){return this.data.enabled},set:function(t){this._setValue("enabled",t)}},{key:"active",get:function(){return this.data.active},set:function(t){this._setValue("active",t)}},{key:"imageEntity",get:function(){return this.data.imageEntity},set:function(t){this._setValue("imageEntity",t)}},{key:"hitPadding",get:function(){return this.data.hitPadding},set:function(t){this._setValue("hitPadding",t)}},{key:"transitionMode",get:function(){return this.data.transitionMode},set:function(t){this._setValue("transitionMode",t)}},{key:"hoverTint",get:function(){return this.data.hoverTint},set:function(t){this._setValue("hoverTint",t)}},{key:"pressedTint",get:function(){return this.data.pressedTint},set:function(t){this._setValue("pressedTint",t)}},{key:"inactiveTint",get:function(){return this.data.inactiveTint},set:function(t){this._setValue("inactiveTint",t)}},{key:"fadeDuration",get:function(){return this.data.fadeDuration},set:function(t){this._setValue("fadeDuration",t)}},{key:"hoverSpriteAsset",get:function(){return this.data.hoverSpriteAsset},set:function(t){this._setValue("hoverSpriteAsset",t)}},{key:"hoverSpriteFrame",get:function(){return this.data.hoverSpriteFrame},set:function(t){this._setValue("hoverSpriteFrame",t)}},{key:"pressedSpriteAsset",get:function(){return this.data.pressedSpriteAsset},set:function(t){this._setValue("pressedSpriteAsset",t)}},{key:"pressedSpriteFrame",get:function(){return this.data.pressedSpriteFrame},set:function(t){this._setValue("pressedSpriteFrame",t)}},{key:"inactiveSpriteAsset",get:function(){return this.data.inactiveSpriteAsset},set:function(t){this._setValue("inactiveSpriteAsset",t)}},{key:"inactiveSpriteFrame",get:function(){return this.data.inactiveSpriteFrame},set:function(t){this._setValue("inactiveSpriteFrame",t)}}])}(Gm);function Sv(t){return new pt(t.r,t.g,t.b)}xv.EVENT_MOUSEDOWN="mousedown",xv.EVENT_MOUSEUP="mouseup",xv.EVENT_MOUSEENTER="mouseenter",xv.EVENT_MOUSELEAVE="mouseleave",xv.EVENT_CLICK="click",xv.EVENT_TOUCHSTART="touchstart",xv.EVENT_TOUCHEND="touchend",xv.EVENT_TOUCHCANCEL="touchcancel",xv.EVENT_TOUCHLEAVE="touchleave",xv.EVENT_SELECTSTART="selectstart",xv.EVENT_SELECTEND="selectend",xv.EVENT_SELECTENTER="selectenter",xv.EVENT_SELECTLEAVE="selectleave",xv.EVENT_HOVERSTART="hoverstart",xv.EVENT_HOVEREND="hoverend",xv.EVENT_PRESSEDSTART="pressedstart",xv.EVENT_PRESSEDEND="pressedend";var bv=function(){this.enabled=!0,this.active=!0,this.imageEntity=null,this.hitPadding=new Rt,this.transitionMode=0,this.hoverTint=new pt(.75,.75,.75),this.pressedTint=new pt(.5,.5,.5),this.inactiveTint=new pt(.25,.25,.25),this.fadeDuration=0,this.hoverSpriteAsset=null,this.hoverSpriteFrame=0,this.pressedSpriteAsset=null,this.pressedSpriteFrame=0,this.inactiveSpriteAsset=null,this.inactiveSpriteFrame=0},Tv=["enabled","active",{name:"imageEntity",type:"entity"},{name:"hitPadding",type:"vec4"},"transitionMode",{name:"hoverTint",type:"rgba"},{name:"pressedTint",type:"rgba"},{name:"inactiveTint",type:"rgba"},"fadeDuration","hoverSpriteAsset","hoverSpriteFrame","pressedSpriteAsset","pressedSpriteFrame","inactiveSpriteAsset","inactiveSpriteFrame"],wv=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="button",i.ComponentType=xv,i.DataType=bv,i.schema=Tv,i.on("beforeremove",i._onRemoveComponent,i),i.app.systems.on("update",i.onUpdate,i),i}x(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){t.prototype.initializeComponentData.call(this,e,i,Tv)},i.onUpdate=function(t){var e=this.store;for(var i in e){var n=e[i].entity,s=n.button;s.enabled&&n.enabled&&s.onUpdate()}},i._onRemoveComponent=function(t,e){e.onRemove()},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("update",this.onUpdate,this)},e}(Hm),Ev=new wt,Av=new Nt,Cv=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._compoundParent=null,n._hasOffset=!1,n.entity.on("insert",n._onInsert,n),n.on("set_type",n.onSetType,n),n.on("set_convexHull",n.onSetModel,n),n.on("set_halfExtents",n.onSetHalfExtents,n),n.on("set_linearOffset",n.onSetOffset,n),n.on("set_angularOffset",n.onSetOffset,n),n.on("set_radius",n.onSetRadius,n),n.on("set_height",n.onSetHeight,n),n.on("set_axis",n.onSetAxis,n),n.on("set_asset",n.onSetAsset,n),n.on("set_renderAsset",n.onSetRenderAsset,n),n.on("set_model",n.onSetModel,n),n.on("set_render",n.onSetRender,n),n}x(e,t);var i=e.prototype;return i._setValue=function(t,e){var i=this.data,n=i[t];i[t]=e,this.fire("set",t,n,e)},i.onSetType=function(t,e,i){e!==i&&this.system.changeType(this,e,i)},i.onSetHalfExtents=function(t,e,i){var n=this.data.type;this.data.initialized&&"box"===n&&this.system.recreatePhysicalShapes(this)},i.onSetOffset=function(t,e,i){this._hasOffset=!this.data.linearOffset.equals(wt.ZERO)||!this.data.angularOffset.equals(Nt.IDENTITY),this.data.initialized&&this.system.recreatePhysicalShapes(this)},i.onSetRadius=function(t,e,i){var n=this.data.type;!this.data.initialized||"sphere"!==n&&"capsule"!==n&&"cylinder"!==n&&"cone"!==n||this.system.recreatePhysicalShapes(this)},i.onSetHeight=function(t,e,i){var n=this.data.type;!this.data.initialized||"capsule"!==n&&"cylinder"!==n&&"cone"!==n||this.system.recreatePhysicalShapes(this)},i.onSetAxis=function(t,e,i){var n=this.data.type;!this.data.initialized||"capsule"!==n&&"cylinder"!==n&&"cone"!==n||this.system.recreatePhysicalShapes(this)},i.onSetAsset=function(t,e,i){var n=this.system.app.assets;if(e){var s=n.get(e);s&&s.off("remove",this.onAssetRemoved,this)}if(i){i instanceof om&&(this.data.asset=i.id);var r=n.get(this.data.asset);r&&(r.off("remove",this.onAssetRemoved,this),r.on("remove",this.onAssetRemoved,this))}this.data.initialized&&"mesh"===this.data.type&&(i||(this.data.model=null),this.system.recreatePhysicalShapes(this))},i.onSetRenderAsset=function(t,e,i){var n=this.system.app.assets;if(e){var s=n.get(e);s&&s.off("remove",this.onRenderAssetRemoved,this)}if(i){i instanceof om&&(this.data.renderAsset=i.id);var r=n.get(this.data.renderAsset);r&&(r.off("remove",this.onRenderAssetRemoved,this),r.on("remove",this.onRenderAssetRemoved,this))}this.data.initialized&&"mesh"===this.data.type&&(i||(this.data.render=null),this.system.recreatePhysicalShapes(this))},i.onSetModel=function(t,e,i){this.data.initialized&&"mesh"===this.data.type&&this.system.implementations.mesh.doRecreatePhysicalShape(this)},i.onSetRender=function(t,e,i){this.onSetModel(t,e,i)},i.onAssetRemoved=function(t){t.off("remove",this.onAssetRemoved,this),this.data.asset===t.id&&(this.asset=null)},i.onRenderAssetRemoved=function(t){t.off("remove",this.onRenderAssetRemoved,this),this.data.renderAsset===t.id&&(this.renderAsset=null)},i.getCompoundChildShapeIndex=function(t){for(var e=this.data.shape,i=e.getNumChildShapes(),n=0;n-1&&e.rigidbody._triggers.splice(i,1),e.rigidbody.removeBody(t),t.forceActivationState(5)}},t}(),Nv=new Bt,Uv=new wt,zv=new wt,Vv=new Nt,Gv=new Rh,Hv=["enabled","type","halfExtents","linearOffset","angularOffset","radius","axis","height","convexHull","asset","renderAsset","shape","model","render","checkVertexDuplicates"],Wv=function(){function t(t){this.system=t}var e=t.prototype;return e.beforeInitialize=function(t,e){e.shape=null,e.model=new wd,e.model.graph=new Rh},e.afterInitialize=function(t,e){this.recreatePhysicalShapes(t),t.data.initialized=!0},e.reset=function(t,e){this.beforeInitialize(t,e),this.afterInitialize(t,e)},e.recreatePhysicalShapes=function(t){var e=t.entity,i=t.data;if("undefined"!=typeof Ammo){e.trigger&&(e.trigger.destroy(),delete e.trigger),i.shape&&(t._compoundParent&&(t!==t._compoundParent&&this.system._removeCompoundChild(t._compoundParent,i.shape),t._compoundParent.entity.rigidbody&&t._compoundParent.entity.rigidbody.activate()),this.destroyShape(i)),i.shape=this.createPhysicalShape(t.entity,i);var n=!t._compoundParent;if("compound"!==i.type||t._compoundParent&&t!==t._compoundParent){if("compound"!==i.type&&!t.rigidbody){t._compoundParent=null;for(var s=e.parent;s;){if(s.collision&&"compound"===s.collision.type){t._compoundParent=s.collision;break}s=s.parent}}}else t._compoundParent=t,e.forEach(this._addEachDescendant,t);t._compoundParent&&t!==t._compoundParent&&(n&&0===t._compoundParent.shape.getNumChildShapes()?this.system.recreatePhysicalShapes(t._compoundParent):(this.system.updateCompoundChildTransform(e,!0),t._compoundParent.entity.rigidbody&&t._compoundParent.entity.rigidbody.activate())),e.rigidbody?(e.rigidbody.disableSimulation(),e.rigidbody.createBody(),e.enabled&&e.rigidbody.enabled&&e.rigidbody.enableSimulation()):t._compoundParent||(e.trigger?e.trigger.initialize(i):e.trigger=new Bv(this.system.app,t,i))}},e.createPhysicalShape=function(t,e){},e.updateTransform=function(t,e,i,n){t.entity.trigger&&t.entity.trigger.updateTransform()},e.destroyShape=function(t){t.shape&&(Ammo.destroy(t.shape),t.shape=null)},e.beforeRemove=function(t,e){e.data.shape&&(e._compoundParent&&!e._compoundParent.entity._destroying&&(this.system._removeCompoundChild(e._compoundParent,e.data.shape),e._compoundParent.entity.rigidbody&&e._compoundParent.entity.rigidbody.activate()),e._compoundParent=null,this.destroyShape(e.data))},e.remove=function(t,e){t.rigidbody&&t.rigidbody.body&&t.rigidbody.disableSimulation(),t.trigger&&(t.trigger.destroy(),delete t.trigger)},e.clone=function(t,e){var i=this.system.store[t.getGuid()],n={enabled:i.data.enabled,type:i.data.type,halfExtents:[i.data.halfExtents.x,i.data.halfExtents.y,i.data.halfExtents.z],linearOffset:[i.data.linearOffset.x,i.data.linearOffset.y,i.data.linearOffset.z],angularOffset:[i.data.angularOffset.x,i.data.angularOffset.y,i.data.angularOffset.z,i.data.angularOffset.w],radius:i.data.radius,axis:i.data.axis,height:i.data.height,convexHull:i.data.convexHull,asset:i.data.asset,renderAsset:i.data.renderAsset,model:i.data.model,render:i.data.render,checkVertexDuplicates:i.data.checkVertexDuplicates};return this.system.addComponent(e,n)},t}(),Xv=function(t){function e(){return t.apply(this,arguments)||this}return x(e,t),e.prototype.createPhysicalShape=function(t,e){if("undefined"!=typeof Ammo){var i=e.halfExtents,n=new Ammo.btVector3(i?i.x:.5,i?i.y:.5,i?i.z:.5),s=new Ammo.btBoxShape(n);return Ammo.destroy(n),s}},e}(Wv),jv=function(t){function e(){return t.apply(this,arguments)||this}return x(e,t),e.prototype.createPhysicalShape=function(t,e){if("undefined"!=typeof Ammo)return new Ammo.btSphereShape(e.radius)},e}(Wv),qv=function(t){function e(){return t.apply(this,arguments)||this}return x(e,t),e.prototype.createPhysicalShape=function(t,e){var i,n,s,r=null!=(i=e.axis)?i:1,a=null!=(n=e.radius)?n:.5,o=Math.max((null!=(s=e.height)?s:2)-2*a,0),h=null;if("undefined"!=typeof Ammo)switch(r){case 0:h=new Ammo.btCapsuleShapeX(a,o);break;case 1:h=new Ammo.btCapsuleShape(a,o);break;case 2:h=new Ammo.btCapsuleShapeZ(a,o)}return h},e}(Wv),Yv=function(t){function e(){return t.apply(this,arguments)||this}return x(e,t),e.prototype.createPhysicalShape=function(t,e){var i,n,s,r=null!=(i=e.axis)?i:1,a=null!=(n=e.radius)?n:.5,o=null!=(s=e.height)?s:1,h=null,l=null;if("undefined"!=typeof Ammo)switch(r){case 0:h=new Ammo.btVector3(.5*o,a,a),l=new Ammo.btCylinderShapeX(h);break;case 1:h=new Ammo.btVector3(a,.5*o,a),l=new Ammo.btCylinderShape(h);break;case 2:h=new Ammo.btVector3(a,a,.5*o),l=new Ammo.btCylinderShapeZ(h)}return h&&Ammo.destroy(h),l},e}(Wv),Kv=function(t){function e(){return t.apply(this,arguments)||this}return x(e,t),e.prototype.createPhysicalShape=function(t,e){var i,n,s,r=null!=(i=e.axis)?i:1,a=null!=(n=e.radius)?n:.5,o=null!=(s=e.height)?s:1,h=null;if("undefined"!=typeof Ammo)switch(r){case 0:h=new Ammo.btConeShapeX(a,o);break;case 1:h=new Ammo.btConeShape(a,o);break;case 2:h=new Ammo.btConeShapeZ(a,o)}return h},e}(Wv),Zv=function(t){function e(){return t.apply(this,arguments)||this}x(e,t);var i=e.prototype;return i.beforeInitialize=function(t,e){},i.createAmmoHull=function(t,e,i,n){var s=new Ammo.btConvexHullShape,r=new Ammo.btVector3,a=[];t.getPositions(a);for(var o=0;o=0&&this.model.meshInstances.splice(i,1),this.unmaskMeshInstance=null}this._entity.enabled&&this._element.enabled&&(this._element.removeModelFromLayers(this.model),this._element.addModelToLayers(this.model))}},e.setMaterial=function(t){this.meshInstance&&(this.meshInstance.material=t,this.unmaskMeshInstance&&(this.unmaskMeshInstance.material=t))},e.setParameter=function(t,e){this.meshInstance&&(this.meshInstance.setParameter(t,e),this.unmaskMeshInstance&&this.unmaskMeshInstance.setParameter(t,e))},e.deleteParameter=function(t){this.meshInstance&&(this.meshInstance.deleteParameter(t),this.unmaskMeshInstance&&this.unmaskMeshInstance.deleteParameter(t))},e.setUnmaskDrawOrder=function(){if(this.meshInstance){var t=function(e){var i,n=e.children,s=n.length;if(s){for(var r=0;r0){var s=e.calculatedWidth/e.calculatedHeight;e.fitMode===uv&&s>this._targetAspectRatio||e.fitMode===dv&&s0&&(this._targetAspectRatio=i.rect.z/i.rect.w)}this.mesh=t?e:this._defaultMesh,this.refreshMesh()},e.refreshMesh=function(){this.mesh&&(this._element._beingInitialized?this._meshDirty=!0:this._updateMesh(this.mesh))},e._updateAabb=function(t){return t.center.set(0,0,0),t.halfExtents.set(.5*this._outerScale.x,.5*this._outerScale.y,.001),t.setFromTransformedAabb(t,this._renderable.node.getWorldTransform()),t},e._toggleMask=function(){this._element._dirtifyMask();var t=this._element._isScreenSpace();this._updateMaterial(t),this._renderable.setMask(!!this._mask)},e._onMaterialLoad=function(t){this.material=t.resource},e._onMaterialAdded=function(t){this._system.app.assets.off("add:"+t.id,this._onMaterialAdded,this),this._materialAsset===t.id&&this._bindMaterialAsset(t)},e._bindMaterialAsset=function(t){this._entity.enabled&&(t.on("load",this._onMaterialLoad,this),t.on("change",this._onMaterialChange,this),t.on("remove",this._onMaterialRemove,this),t.resource?this._onMaterialLoad(t):this._system.app.assets.load(t))},e._unbindMaterialAsset=function(t){t.off("load",this._onMaterialLoad,this),t.off("change",this._onMaterialChange,this),t.off("remove",this._onMaterialRemove,this)},e._onMaterialChange=function(){},e._onMaterialRemove=function(){},e._onTextureAdded=function(t){this._system.app.assets.off("add:"+t.id,this._onTextureAdded,this),this._textureAsset===t.id&&this._bindTextureAsset(t)},e._bindTextureAsset=function(t){this._entity.enabled&&(t.on("load",this._onTextureLoad,this),t.on("change",this._onTextureChange,this),t.on("remove",this._onTextureRemove,this),t.resource?this._onTextureLoad(t):this._system.app.assets.load(t))},e._unbindTextureAsset=function(t){t.off("load",this._onTextureLoad,this),t.off("change",this._onTextureChange,this),t.off("remove",this._onTextureRemove,this)},e._onTextureLoad=function(t){this.texture=t.resource},e._onTextureChange=function(t){},e._onTextureRemove=function(t){},e._onSpriteAssetAdded=function(t){this._system.app.assets.off("add:"+t.id,this._onSpriteAssetAdded,this),this._spriteAsset===t.id&&this._bindSpriteAsset(t)},e._bindSpriteAsset=function(t){this._entity.enabled&&(t.on("load",this._onSpriteAssetLoad,this),t.on("change",this._onSpriteAssetChange,this),t.on("remove",this._onSpriteAssetRemove,this),t.resource?this._onSpriteAssetLoad(t):this._system.app.assets.load(t))},e._unbindSpriteAsset=function(t){t.off("load",this._onSpriteAssetLoad,this),t.off("change",this._onSpriteAssetChange,this),t.off("remove",this._onSpriteAssetRemove,this),t.data.textureAtlasAsset&&this._system.app.assets.off("load:"+t.data.textureAtlasAsset,this._onTextureAtlasLoad,this)},e._onSpriteAssetLoad=function(t){if(t&&t.resource)if(t.resource.atlas)this.sprite=t.resource;else{var e=t.data.textureAtlasAsset;if(e){var i=this._system.app.assets;i.off("load:"+e,this._onTextureAtlasLoad,this),i.once("load:"+e,this._onTextureAtlasLoad,this)}}else this.sprite=null},e._onSpriteAssetChange=function(t){this._onSpriteAssetLoad(t)},e._onSpriteAssetRemove=function(t){},e._bindSprite=function(t){this._evtSetMeshes=t.on("set:meshes",this._onSpriteMeshesChange,this),t.on("set:pixelsPerUnit",this._onSpritePpuChange,this),t.on("set:atlas",this._onAtlasTextureChange,this),t.atlas&&t.atlas.on("set:texture",this._onAtlasTextureChange,this)},e._unbindSprite=function(t){var e;null==(e=this._evtSetMeshes)||e.off(),this._evtSetMeshes=null,t.off("set:pixelsPerUnit",this._onSpritePpuChange,this),t.off("set:atlas",this._onAtlasTextureChange,this),t.atlas&&t.atlas.off("set:texture",this._onAtlasTextureChange,this)},e._onSpriteMeshesChange=function(){this._sprite&&(this._spriteFrame=ft.clamp(this._spriteFrame,0,this._sprite.frameKeys.length-1)),this._updateSprite()},e._onSpritePpuChange=function(){0!==this.sprite.renderMode&&null===this._pixelsPerUnit&&this._updateSprite()},e._onAtlasTextureChange=function(){this.sprite&&this.sprite.atlas&&this.sprite.atlas.texture?(this._renderable.setParameter("texture_emissiveMap",this._sprite.atlas.texture),this._renderable.setParameter("texture_opacityMap",this._sprite.atlas.texture)):(this._renderable.deleteParameter("texture_emissiveMap"),this._renderable.deleteParameter("texture_opacityMap"))},e._onTextureAtlasLoad=function(t){var e=this._spriteAsset;e instanceof om?this._onSpriteAssetLoad(e):this._onSpriteAssetLoad(this._system.app.assets.get(e))},e.onEnable=function(){if(this._materialAsset){var t=this._system.app.assets.get(this._materialAsset);t&&t.resource!==this._material&&this._bindMaterialAsset(t)}if(this._textureAsset){var e=this._system.app.assets.get(this._textureAsset);e&&e.resource!==this._texture&&this._bindTextureAsset(e)}if(this._spriteAsset){var i=this._system.app.assets.get(this._spriteAsset);i&&i.resource!==this._sprite&&this._bindSpriteAsset(i)}this._element.addModelToLayers(this._renderable.model)},e.onDisable=function(){this._element.removeModelFromLayers(this._renderable.model)},e._setStencil=function(t){this._renderable.meshInstance.stencilFront=t,this._renderable.meshInstance.stencilBack=t;var e=0;if(this._element.maskedBy&&(e=this._element.maskedBy.element._image._maskRef),this._renderable.unmaskMeshInstance){var i=new wn({ref:e+1,func:2,zpass:5});this._renderable.unmaskMeshInstance.stencilFront=i,this._renderable.unmaskMeshInstance.stencilBack=i}},e._removeMaterialAssetEvents=function(){if(this._materialAsset){var t=this._system.app.assets;t.off("add:"+this._materialAsset,this._onMaterialAdded,this);var e=t.get(this._materialAsset);e&&(e.off("load",this._onMaterialLoad,this),e.off("change",this._onMaterialChange,this),e.off("remove",this._onMaterialRemove,this))}},v(t,[{key:"color",get:function(){return this._color},set:function(t){var e=t.r,i=t.g,n=t.b;this._color.r===e&&this._color.g===i&&this._color.b===n||(this._color.r=e,this._color.g=i,this._color.b=n,this._colorUniform[0]=e,this._colorUniform[1]=i,this._colorUniform[2]=n,this._renderable.setParameter("material_emissive",this._colorUniform)),this._element&&this._element.fire("set:color",this._color)}},{key:"opacity",get:function(){return this._color.a},set:function(t){t!==this._color.a&&(this._color.a=t,this._renderable.setParameter("material_opacity",t)),this._element&&this._element.fire("set:opacity",t)}},{key:"rect",get:function(){return this._rect},set:function(t){var e,i,n,s;t instanceof Rt?(e=t.x,i=t.y,n=t.z,s=t.w):(e=t[0],i=t[1],n=t[2],s=t[3]),e===this._rect.x&&i===this._rect.y&&n===this._rect.z&&s===this._rect.w||(this._rect.set(e,i,n,s),this._renderable.mesh&&(this._element._beingInitialized?this._meshDirty=!0:this._updateMesh(this._renderable.mesh)))}},{key:"material",get:function(){return this._material},set:function(t){if(this._material!==t){if(!t){var e=this._element._isScreenSpace();t=this.mask?e?this._system.defaultScreenSpaceImageMaskMaterial:this._system.defaultImageMaskMaterial:e?this._system.defaultScreenSpaceImageMaterial:this._system.defaultImageMaterial}if(this._material=t,this._materialAsset){var i=this._system.app.assets.get(this._materialAsset);i&&i.resource===t||(this._removeMaterialAssetEvents(),this._materialAsset=null)}t&&(this._renderable.setMaterial(t),this._hasUserMaterial()?(this._renderable.deleteParameter("material_opacity"),this._renderable.deleteParameter("material_emissive")):(this._colorUniform[0]=this._color.r,this._colorUniform[1]=this._color.g,this._colorUniform[2]=this._color.b,this._renderable.setParameter("material_emissive",this._colorUniform),this._renderable.setParameter("material_opacity",this._color.a)))}}},{key:"materialAsset",get:function(){return this._materialAsset},set:function(t){var e=this._system.app.assets,i=t;if(t instanceof om&&(i=t.id),this._materialAsset!==i)if(this._removeMaterialAssetEvents(),this._materialAsset=i,this._materialAsset){var n=e.get(this._materialAsset);n?this._bindMaterialAsset(n):(this._materialAsset=null,this.material=null,this._materialAsset=i,e.on("add:"+this._materialAsset,this._onMaterialAdded,this))}else this._materialAsset=null,this.material=null,this._materialAsset=i}},{key:"texture",get:function(){return this._texture},set:function(t){if(this._texture!==t){if(this._textureAsset){var e=this._system.app.assets.get(this._textureAsset);e&&e.resource!==t&&(this.textureAsset=null)}if(this._texture=t,t){this._spriteAsset&&(this.spriteAsset=null),this._renderable.setParameter("texture_emissiveMap",this._texture),this._renderable.setParameter("texture_opacityMap",this._texture),this._colorUniform[0]=this._color.r,this._colorUniform[1]=this._color.g,this._colorUniform[2]=this._color.b,this._renderable.setParameter("material_emissive",this._colorUniform),this._renderable.setParameter("material_opacity",this._color.a);var i=this._texture.width/this._texture.height;i!==this._targetAspectRatio&&(this._targetAspectRatio=i,this._element.fitMode!==cv&&this.refreshMesh())}else this._renderable.deleteParameter("texture_emissiveMap"),this._renderable.deleteParameter("texture_opacityMap"),this._targetAspectRatio=-1,this._element.fitMode!==cv&&this.refreshMesh()}}},{key:"textureAsset",get:function(){return this._textureAsset},set:function(t){var e=this._system.app.assets,i=t;if(t instanceof om&&(i=t.id),this._textureAsset!==i){if(this._textureAsset){e.off("add:"+this._textureAsset,this._onTextureAdded,this);var n=e.get(this._textureAsset);n&&(n.off("load",this._onTextureLoad,this),n.off("change",this._onTextureChange,this),n.off("remove",this._onTextureRemove,this))}if(this._textureAsset=i,this._textureAsset){var s=e.get(this._textureAsset);s?this._bindTextureAsset(s):(this.texture=null,e.on("add:"+this._textureAsset,this._onTextureAdded,this))}else this.texture=null}}},{key:"spriteAsset",get:function(){return this._spriteAsset},set:function(t){var e=this._system.app.assets,i=t;if(t instanceof om&&(i=t.id),this._spriteAsset!==i){if(this._spriteAsset){e.off("add:"+this._spriteAsset,this._onSpriteAssetAdded,this);var n=e.get(this._spriteAsset);n&&this._unbindSpriteAsset(n)}if(this._spriteAsset=i,this._spriteAsset){var s=e.get(this._spriteAsset);s?this._bindSpriteAsset(s):(this.sprite=null,e.on("add:"+this._spriteAsset,this._onSpriteAssetAdded,this))}else this.sprite=null}this._element&&this._element.fire("set:spriteAsset",i)}},{key:"sprite",get:function(){return this._sprite},set:function(t){if(this._sprite!==t){if(this._sprite&&this._unbindSprite(this._sprite),this._spriteAsset){var e=this._system.app.assets.get(this._spriteAsset);e&&e.resource!==t&&(this.spriteAsset=null)}this._sprite=t,this._sprite&&(this._bindSprite(this._sprite),this._textureAsset&&(this.textureAsset=null)),this._sprite&&this._sprite.atlas&&this._sprite.atlas.texture?(this._renderable.setParameter("texture_emissiveMap",this._sprite.atlas.texture),this._renderable.setParameter("texture_opacityMap",this._sprite.atlas.texture)):(this._renderable.deleteParameter("texture_emissiveMap"),this._renderable.deleteParameter("texture_opacityMap")),this._sprite&&(this._spriteFrame=ft.clamp(this._spriteFrame,0,this._sprite.frameKeys.length-1)),this._updateSprite()}}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){var e=this._spriteFrame;this._sprite?this._spriteFrame=ft.clamp(t,0,this._sprite.frameKeys.length-1):this._spriteFrame=t,this._spriteFrame!==e&&this._updateSprite(),this._element&&this._element.fire("set:spriteFrame",t)}},{key:"mesh",get:function(){return this._renderable.mesh},set:function(t){this._renderable.setMesh(t),this._defaultMesh===t?this._renderable.setAabbFunc(null):this._renderable.setAabbFunc(this._updateAabbFunc)}},{key:"mask",get:function(){return this._mask},set:function(t){this._mask!==t&&(this._mask=t,this._toggleMask())}},{key:"pixelsPerUnit",get:function(){return this._pixelsPerUnit},set:function(t){this._pixelsPerUnit!==t&&(this._pixelsPerUnit=t,!this._sprite||1!==this._sprite.renderMode&&2!==this._sprite.renderMode||this._updateSprite())}},{key:"aabb",get:function(){return this._renderable.meshInstance?this._renderable.meshInstance.aabb:null}}])}(),ig=function(t){function e(e){var i;return(i=t.call(this)||this)._app=e,e.i18n.on("set:locale",i._onSetLocale,i),i._autoLoad=!1,i._disableLocalization=!1,i._defaultAsset=null,i._localizedAsset=null,i}x(e,t);var i=e.prototype;return i._bindDefaultAsset=function(){var t=this._app.assets.get(this._defaultAsset);t?this._onDefaultAssetAdd(t):this._app.assets.once("add:"+this._defaultAsset,this._onDefaultAssetAdd,this)},i._unbindDefaultAsset=function(){if(this._defaultAsset){this._app.assets.off("add:"+this._defaultAsset,this._onDefaultAssetAdd,this);var t=this._app.assets.get(this._defaultAsset);t&&(t.off("add:localized",this._onLocaleAdd,this),t.off("remove:localized",this._onLocaleRemove,this),t.off("remove",this._onDefaultAssetRemove,this))}},i._onDefaultAssetAdd=function(t){this._defaultAsset===t.id&&(t.on("add:localized",this._onLocaleAdd,this),t.on("remove:localized",this._onLocaleRemove,this),t.once("remove",this._onDefaultAssetRemove,this))},i._onDefaultAssetRemove=function(t){this._defaultAsset===t.id&&(t.off("add:localized",this._onLocaleAdd,this),t.off("remove:localized",this._onLocaleAdd,this),this._app.assets.once("add:"+this._defaultAsset,this._onDefaultAssetAdd,this))},i._bindLocalizedAsset=function(){if(this._autoLoad){var t=this._app.assets.get(this._localizedAsset);t&&(t.on("load",this._onLocalizedAssetLoad,this),t.on("change",this._onLocalizedAssetChange,this),t.on("remove",this._onLocalizedAssetRemove,this),t.resource?this._onLocalizedAssetLoad(t):this._app.assets.load(t))}},i._unbindLocalizedAsset=function(){var t=this._app.assets.get(this._localizedAsset);t&&(t.off("load",this._onLocalizedAssetLoad,this),t.off("change",this._onLocalizedAssetChange,this),t.off("remove",this._onLocalizedAssetRemove,this))},i._onLocalizedAssetAdd=function(t){this._localizedAsset===t.id&&this._bindLocalizedAsset()},i._onLocalizedAssetLoad=function(t){this.fire("load",t)},i._onLocalizedAssetChange=function(t,e,i,n){this.fire("change",t,e,i,n)},i._onLocalizedAssetRemove=function(t){this._localizedAsset===t.id&&(this.localizedAsset=this._defaultAsset),this.fire("remove",t)},i._onLocaleAdd=function(t,e){this._app.i18n.locale===t&&this._onSetLocale(t)},i._onLocaleRemove=function(t,e){this._app.i18n.locale===t&&this._onSetLocale(t)},i._onSetLocale=function(t){if(this._defaultAsset){var e=this._app.assets.get(this._defaultAsset);if(e&&!this._disableLocalization){var i=e.getLocalizedAssetId(t);this.localizedAsset=i||this._defaultAsset}else this.localizedAsset=this._defaultAsset}else this.localizedAsset=null},i.destroy=function(){this.defaultAsset=null,this._app.i18n.off("set:locale",this._onSetLocale,this),this.off()},v(e,[{key:"defaultAsset",get:function(){return this._defaultAsset},set:function(t){var e=t instanceof om?t.id:t;this._defaultAsset!==e&&(this._defaultAsset&&this._unbindDefaultAsset(),this._defaultAsset=e,this._defaultAsset&&this._bindDefaultAsset(),this._onSetLocale(this._app.i18n.locale))}},{key:"localizedAsset",get:function(){return this._localizedAsset},set:function(t){var e=t instanceof om?t.id:t;this._localizedAsset!==e&&(this._localizedAsset&&(this._app.assets.off("add:"+this._localizedAsset,this._onLocalizedAssetAdd,this),this._unbindLocalizedAsset()),this._localizedAsset=e,this._localizedAsset&&(this._app.assets.get(this._localizedAsset)?this._bindLocalizedAsset():this._app.assets.once("add:"+this._localizedAsset,this._onLocalizedAssetAdd,this)))}},{key:"autoLoad",get:function(){return this._autoLoad},set:function(t){this._autoLoad!==t&&(this._autoLoad=t,this._autoLoad&&this._localizedAsset&&(this._unbindLocalizedAsset(),this._bindLocalizedAsset()))}},{key:"disableLocalization",get:function(){return this._disableLocalization},set:function(t){this._disableLocalization!==t&&(this._disableLocalization=t,this._onSetLocale(this._app.i18n.locale))}}])}(P),ng="msdf",sg="bitmap",rg=/[\w|/]/,ag=function(){function t(t){this._symbols=t,this._index=0,this._last=0,this._cur=this._symbols.length>0?this._symbols[0]:null,this._buf=[],this._mode="text",this._error=null}var e=t.prototype;return e.read=function(){for(var t=this._read();8===t;)t=this._read();return 0!==t&&1!==t&&(this._last=this._index),t},e.buf=function(){return this._buf},e.last=function(){return this._last},e.error=function(){return this._error},e.debugPrint=function(){for(var t=["EOF","ERROR","TEXT","OPEN_BRACKET","CLOSE_BRACKET","EQUALS","STRING","IDENTIFIER","WHITESPACE"],e=this.read(),i="";i+=(i.length>0?"\n":"")+t[e]+" '"+this.buf().join("")+"'",0!==e&&1!==e;)e=this.read();return i},e._read=function(){return this._buf=[],this._eof()?0:"text"===this._mode?this._text():this._tag()},e._text=function(){for(;;)switch(this._cur){case null:return this._buf.length>0?2:0;case"[":return this._mode="tag",this._buf.length>0?2:this._tag();case"\\":if(this._next(),"["===this._cur)this._store();else this._output("\\");break;default:this._store()}},e._tag=function(){switch(this._cur){case null:return this._error="unexpected end of input reading tag",1;case"[":return this._store(),3;case"]":return this._store(),this._mode="text",4;case"=":return this._store(),5;case" ":case"\t":case"\n":case"\r":case"\v":case"\f":return this._whitespace();case'"':return this._string();default:return this._isIdentifierSymbol(this._cur)?this._identifier():(this._error="unrecognized character",1)}},e._whitespace=function(){for(this._store();-1!==" \t\n\r\v\f".indexOf(this._cur);)this._store();return 8},e._string=function(){for(this._next();;)switch(this._cur){case null:return this._error="unexpected end of input reading string",1;case'"':return this._next(),6;default:this._store()}},e._identifier=function(){for(this._store();null!==this._cur&&this._isIdentifierSymbol(this._cur);)this._store();return 7},e._isIdentifierSymbol=function(t){return 1===t.length&&null!==t.match(rg)},e._eof=function(){return null===this._cur},e._next=function(){return this._eof()||(this._index++,this._cur=this._index=0;--s)if(n==="/"+e[s].name&&null===e[s].end)return e[s].end=t.length,4===(i=this._scanner.read())||(this._error="expected close bracket",!1);return this._error="failed to find matching tag",!1}var r={name:n,value:null,attributes:{},start:t.length,end:null};if(5===(i=this._scanner.read())){if(6!==(i=this._scanner.read()))return this._error="expected string",!1;r.value=this._scanner.buf().join(""),i=this._scanner.read()}for(;;){switch(i){case 4:return e.push(r),!0;case 7:var a=this._scanner.buf().join("");if(5!==(i=this._scanner.read()))return this._error="expected equals",!1;if(6!==(i=this._scanner.read()))return this._error="expected string",!1;var o=this._scanner.buf().join("");r.attributes[a]=o;break;default:return this._error="expected close bracket or identifier",!1}i=this._scanner.read()}},t}();function hg(t,e){for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];n instanceof Object?(t.hasOwnProperty(i)||(t[i]={}),hg(t[i],e[i])):t[i]=n}}function lg(t){if(0===t.length)return null;for(var e={},i=0;i=1e-4,g=this._element.calculatedWidth;(this.autoWidth&&!v||!this._wrapLines)&&(g=Number.POSITIVE_INFINITY);var y,x,S,b,T=0,w=0;function E(t,i,n){e._lineWidths.push(Math.abs(n));var s=f>i?i+1:f,r=f>i?f+1:i,h=t.slice(s,r);if(_)for(var l=h.length;l--&&_>0;)pg.test(h[l])&&(h.splice(l,1),_--);e._lineContents.push(h.join("")),a=0,o-=e._scaledLineHeight,c++,p=0,m=0,_=0,u=0,f=i}for(var A=!0;A;){A=!1,this._scaledLineHeight=s?this._lineHeight*this._fontSize/(this._maxFontSize||1e-4):this._lineHeight,this.width=0,this.height=0,this._lineWidths=[],this._lineContents=[],a=0,o=0,h=0,l=0,c=1,u=0,d=0,f=0,p=0,m=0,_=0;var C=this._fontSize/32;T=this._fontMinY*C,w=this._fontMaxY*C;for(var M=0;M=r?null:this._symbols[N+1],pg.test(y))_++,(!this._wrapLines||this._maxLines<0||c0){var j=this._font.data.kerning;if(j){var q=j[it.getCodePoint(this._symbols[N-1])||0];q&&(X=q[it.getCodePoint(this._symbols[N])||0]||0)}}H=x.scale||1,G=C*((x.width+x.height)/2)/H,V=(x.xadvance+X)*C,U=(x.xoffset-X)*C,z=x.yoffset*C}else console.error("Couldn't substitute missing character: '"+y+"'");var Y=mg.test(y),K=x&&x.map||0,Z=-this._font.data.info.maps[K].width/this._font.data.info.maps[K].height,Q=this._meshInfo[K],J=a+this._spacing*V;if(J>g&&m>0&&!Y&&(this._maxLines<0||cthis._element.calculatedWidth&&(ut=Math.floor(this._element.fontSize*this._element.calculatedWidth/(this.width||1e-4)),(ut=ft.clamp(ut,i,n))!==this._element.fontSize)){this._fontSize=ut,A=!0;break}if(this.height=Math.max(this.height,w-(o+T)),this._shouldAutoFitHeight()&&this.height>this._element.calculatedHeight&&(ut=ft.clamp(this._fontSize-1,i,n))!==this._element.fontSize){this._fontSize=ut,A=!0;break}a+=this._spacing*V,Y||(l=a),(this._isWordBoundary(y)||this._isValidNextChar(b)&&(this._isNextCJKBoundary(y,b)||this._isNextCJKWholeWord(b)))&&(p++,u=l,d=N+1),m++;var dt=this._getUv(y);if(Q.uvs[4*S*2+0]=dt[0],Q.uvs[4*S*2+1]=1-dt[1],Q.uvs[4*S*2+2]=dt[2],Q.uvs[4*S*2+3]=1-dt[1],Q.uvs[4*S*2+4]=dt[2],Q.uvs[4*S*2+5]=1-dt[3],Q.uvs[4*S*2+6]=dt[0],Q.uvs[4*S*2+7]=1-dt[3],this._symbolColors){var pt=3*this._symbolColors[N];P=this._colorPalette[pt],R=this._colorPalette[pt+1],I=this._colorPalette[pt+2]}if(Q.colors[4*S*4+0]=P,Q.colors[4*S*4+1]=R,Q.colors[4*S*4+2]=I,Q.colors[4*S*4+3]=255,Q.colors[4*S*4+4]=P,Q.colors[4*S*4+5]=R,Q.colors[4*S*4+6]=I,Q.colors[4*S*4+7]=255,Q.colors[4*S*4+8]=P,Q.colors[4*S*4+9]=R,Q.colors[4*S*4+10]=I,Q.colors[4*S*4+11]=255,Q.colors[4*S*4+12]=P,Q.colors[4*S*4+13]=R,Q.colors[4*S*4+14]=I,Q.colors[4*S*4+15]=255,this._symbolOutlineParams){var mt=5*this._symbolOutlineParams[N];D=this._outlinePalette[mt]+256*this._outlinePalette[mt+1],L=this._outlinePalette[mt+2]+256*this._outlinePalette[mt+3],k=this._outlinePalette[mt+4]}if(Q.outlines[4*S*3+0]=D,Q.outlines[4*S*3+1]=L,Q.outlines[4*S*3+2]=k,Q.outlines[4*S*3+3]=D,Q.outlines[4*S*3+4]=L,Q.outlines[4*S*3+5]=k,Q.outlines[4*S*3+6]=D,Q.outlines[4*S*3+7]=L,Q.outlines[4*S*3+8]=k,Q.outlines[4*S*3+9]=D,Q.outlines[4*S*3+10]=L,Q.outlines[4*S*3+11]=k,this._symbolShadowParams){var _t=6*this._symbolShadowParams[N];O=this._shadowPalette[_t]+256*this._shadowPalette[_t+1],F=this._shadowPalette[_t+2]+256*this._shadowPalette[_t+3],B=this._shadowPalette[_t+4]+127+256*Math.round(Z*this._shadowPalette[_t+5]+127)}Q.shadows[4*S*3+0]=O,Q.shadows[4*S*3+1]=F,Q.shadows[4*S*3+2]=B,Q.shadows[4*S*3+3]=O,Q.shadows[4*S*3+4]=F,Q.shadows[4*S*3+5]=B,Q.shadows[4*S*3+6]=O,Q.shadows[4*S*3+7]=F,Q.shadows[4*S*3+8]=B,Q.shadows[4*S*3+9]=O,Q.shadows[4*S*3+10]=F,Q.shadows[4*S*3+11]=B,Q.quad++}}A||f=Ot?(Ft.element[Le].set(0,0,0),Ft.element[ze].set(0,0),Ft.element[Ne].set(0,0,0,0),Ft.element[ni].set(0,0,0,0),Ft.element[si].set(0,0,0,0)):(Ft.element[Le].set(this._meshInfo[St].positions[3*Bt+0],this._meshInfo[St].positions[3*Bt+1],this._meshInfo[St].positions[3*Bt+2]),Ft.element[ze].set(this._meshInfo[St].uvs[2*Bt+0],this._meshInfo[St].uvs[2*Bt+1]),Ft.element[Ne].set(this._meshInfo[St].colors[4*Bt+0],this._meshInfo[St].colors[4*Bt+1],this._meshInfo[St].colors[4*Bt+2],this._meshInfo[St].colors[4*Bt+3]),Ft.element[ni].set(this._meshInfo[St].outlines[3*Bt+0],this._meshInfo[St].outlines[3*Bt+1],this._meshInfo[St].outlines[3*Bt+2]),Ft.element[si].set(this._meshInfo[St].shadows[3*Bt+0],this._meshInfo[St].shadows[3*Bt+1],this._meshInfo[St].shadows[3*Bt+2])),Ft.next();Ft.end(),this._meshInfo[St].meshInstance.mesh.aabb.compute(this._meshInfo[St].positions),this._meshInfo[St].meshInstance._aabbVer=-1}this._aabbDirty=!0},e._onFontRender=function(){this.font=this._font},e._onFontLoad=function(t){this.font!==t.resource&&(this.font=t.resource)},e._onFontChange=function(t,e,i,n){if("data"===e){this._font.data=i;for(var s=this._font.data.info.maps.length,r=0;rthis._font.textures.length&&(this._meshInfo.length=this._font.textures.length),this._updateText()}}},{key:"alignment",get:function(){return this._alignment},set:function(t){t instanceof Mt?this._alignment.set(t.x,t.y):this._alignment.set(t[0],t[1]),this._font&&this._updateText()}},{key:"autoWidth",get:function(){return this._autoWidth},set:function(t){var e=this._autoWidth;if(this._autoWidth=t,t&&Math.abs(this._element.anchor.x-this._element.anchor.z)<1e-4&&(this._element.width=this.width),e!==t){var i=this._shouldAutoFit()?this._maxFontSize:this._originalFontSize;i!==this._fontSize&&(this._fontSize=i,this._font&&this._updateText())}}},{key:"autoHeight",get:function(){return this._autoHeight},set:function(t){var e=this._autoHeight;if(this._autoHeight=t,t&&Math.abs(this._element.anchor.y-this._element.anchor.w)<1e-4&&(this._element.height=this.height),e!==t){var i=this._shouldAutoFit()?this._maxFontSize:this._originalFontSize;i!==this._fontSize&&(this._fontSize=i,this._font&&this._updateText())}}},{key:"rtlReorder",get:function(){return this._rtlReorder},set:function(t){this._rtlReorder!==t&&(this._rtlReorder=t,this._font&&this._updateText())}},{key:"unicodeConverter",get:function(){return this._unicodeConverter},set:function(t){this._unicodeConverter!==t&&(this._unicodeConverter=t,this._setText(this._text))}},{key:"aabb",get:function(){if(this._aabbDirty){for(var t=!1,e=0;e=0&&this.system._prerender.splice(i,1),this.system._prerender.indexOf(t)<0&&this.system._prerender.push(t)}t=e}},i._onPrerender=function(){for(var t=0;t=0)&&(null==(t=this.system.app.batcher)||t.insert(sh.ELEMENT,this.batchGroupId,this.entity));this.fire("enableelement")},i.onDisable=function(){var t,e,i,n,s=this.system.app.scene.layers;(null==(t=this._evtLayersChanged)||t.off(),this._evtLayersChanged=null,s)&&(null==(e=this._evtLayerAdded)||e.off(),this._evtLayerAdded=null,null==(i=this._evtLayerRemoved)||i.off(),this._evtLayerRemoved=null);(this._image&&this._image.onDisable(),this._text&&this._text.onDisable(),this._group&&this._group.onDisable(),this.system.app.elementInput&&this.useInput&&this.system.app.elementInput.removeElement(this),this._batchGroupId>=0)&&(null==(n=this.system.app.batcher)||n.remove(sh.ELEMENT,this.batchGroupId,this.entity));this.fire("disableelement")},i.onRemove=function(){this.entity.off("insert",this._onInsert,this),this._unpatch(),this._image&&this._image.destroy(),this._text&&this._text.destroy(),this.system.app.elementInput&&this.useInput&&this.system.app.elementInput.removeElement(this),this.screen&&this.screen.screen&&(this._unbindScreen(this.screen.screen),this.screen.screen.syncDrawOrder()),this.off()},i._calculateSize=function(t,e){if(this.entity._parent||this.screen){this._calculateLocalAnchors();var i=this._absRight-this._absLeft,n=this._absTop-this._absBottom;t?this._setWidth(i):this._setCalculatedWidth(i,!1),e?this._setHeight(n):this._setCalculatedHeight(n,!1);var s=this.entity.getLocalPosition();s.x=this._margin.x+this._calculatedWidth*this._pivot.x,s.y=this._margin.y+this._calculatedHeight*this._pivot.y,this.entity.setLocalPosition(s),this._sizeDirty=!1}},i._setWidth=function(t){this._width=t,this._setCalculatedWidth(t,!1),this.fire("set:width",this._width)},i._setHeight=function(t){this._height=t,this._setCalculatedHeight(t,!1),this.fire("set:height",this._height)},i._setCalculatedWidth=function(t,e){if(!(Math.abs(t-this._calculatedWidth)<=1e-4)){if(this._calculatedWidth=t,this.entity._dirtifyLocal(),e){var i=this.entity.getLocalPosition(),n=this._pivot;this._margin.x=i.x-this._calculatedWidth*n.x,this._margin.z=this._localAnchor.z-this._localAnchor.x-this._calculatedWidth-this._margin.x}this._flagChildrenAsDirty(),this.fire("set:calculatedWidth",this._calculatedWidth),this.fire("resize",this._calculatedWidth,this._calculatedHeight)}},i._setCalculatedHeight=function(t,e){if(!(Math.abs(t-this._calculatedHeight)<=1e-4)){if(this._calculatedHeight=t,this.entity._dirtifyLocal(),e){var i=this.entity.getLocalPosition(),n=this._pivot;this._margin.y=i.y-this._calculatedHeight*n.y,this._margin.w=this._localAnchor.w-this._localAnchor.y-this._calculatedHeight-this._margin.y}this._flagChildrenAsDirty(),this.fire("set:calculatedHeight",this._calculatedHeight),this.fire("resize",this._calculatedWidth,this._calculatedHeight)}},i._flagChildrenAsDirty=function(){for(var t=this.entity._children,e=0,i=t.length;e=0&&this._addedModels.splice(e,1);for(var i=0;ii||f>n||p.001}},{key:"_hasSplitAnchorsY",get:function(){return Math.abs(this._anchor.y-this._anchor.w)>.001}},{key:"aabb",get:function(){return this._image?this._image.aabb:this._text?this._text.aabb:null}},{key:"anchor",get:function(){return this._anchor},set:function(t){var e;t instanceof Rt?this._anchor.copy(t):(e=this._anchor).set.apply(e,t);this.entity._parent||this.screen?this._calculateSize(this._hasSplitAnchorsX,this._hasSplitAnchorsY):this._calculateLocalAnchors(),this._anchorDirty=!0,this.entity._dirtyLocal||this.entity._dirtifyLocal(),this.fire("set:anchor",this._anchor)}},{key:"batchGroupId",get:function(){return this._batchGroupId},set:function(t){if(this._batchGroupId!==t){var e,i;if(this.entity.enabled&&this._batchGroupId>=0)null==(e=this.system.app.batcher)||e.remove(sh.ELEMENT,this.batchGroupId,this.entity);if(this.entity.enabled&&t>=0)null==(i=this.system.app.batcher)||i.insert(sh.ELEMENT,t,this.entity);t<0&&this._batchGroupId>=0&&this.enabled&&this.entity.enabled&&(this._image&&this._image._renderable.model?this.addModelToLayers(this._image._renderable.model):this._text&&this._text._model&&this.addModelToLayers(this._text._model)),this._batchGroupId=t}}},{key:"bottom",get:function(){return this._margin.y},set:function(t){this._margin.y=t;var e=this.entity.getLocalPosition(),i=this._absTop,n=this._localAnchor.y+t;this._setHeight(i-n),e.y=t+this._calculatedHeight*this._pivot.y,this.entity.setLocalPosition(e)}},{key:"calculatedWidth",get:function(){return this._calculatedWidth},set:function(t){this._setCalculatedWidth(t,!0)}},{key:"calculatedHeight",get:function(){return this._calculatedHeight},set:function(t){this._setCalculatedHeight(t,!0)}},{key:"canvasCorners",get:function(){if(!this._canvasCornersDirty||!this.screen||!this.screen.screen.screenSpace)return this._canvasCorners;for(var t=this.system.app.graphicsDevice,e=this.screenCorners,i=t.canvas.clientWidth/t.width,n=t.canvas.clientHeight/t.height,s=0;s<4;s++)this._canvasCorners[s].set(e[s].x*i,(t.height-e[s].y)*n);return this._canvasCornersDirty=!1,this._canvasCorners}},{key:"drawOrder",get:function(){return this._drawOrder},set:function(t){var e=0;this.screen&&(e=this.screen.screen.priority),t>16777215&&(t=16777215),this._drawOrder=(e<<24)+t,this.fire("set:draworder",this._drawOrder)}},{key:"height",get:function(){return this._height},set:function(t){this._height=t,this._hasSplitAnchorsY||this._setCalculatedHeight(t,!0),this.fire("set:height",this._height)}},{key:"layers",get:function(){return this._layers},set:function(t){if(this._addedModels.length)for(var e=0;e.001,a=Math.abs(e.anchor.y-e.anchor.w)>.001,o=!1;void 0!==i.margin&&(i.margin instanceof Rt?e.margin.copy(i.margin):e._margin.set(i.margin[0],i.margin[1],i.margin[2],i.margin[3]),o=!0),void 0!==i.left&&(e._margin.x=i.left,o=!0),void 0!==i.bottom&&(e._margin.y=i.bottom,o=!0),void 0!==i.right&&(e._margin.z=i.right,o=!0),void 0!==i.top&&(e._margin.w=i.top,o=!0),o&&(e.margin=e._margin);var h=!1;void 0===i.width||r?r&&(h=!0):e.width=i.width,void 0===i.height||a?a&&(h=!0):e.height=i.height,h&&(e.anchor=e.anchor),void 0!==i.enabled&&(e.enabled=i.enabled),void 0!==i.useInput&&(e.useInput=i.useInput),void 0!==i.fitMode&&(e.fitMode=i.fitMode),e.batchGroupId=void 0===i.batchGroupId||null===i.batchGroupId?-1:i.batchGroupId,i.layers&&Array.isArray(i.layers)&&(e.layers=i.layers.slice(0)),void 0!==i.type&&(e.type=i.type),e.type===hv?(void 0!==i.rect&&(e.rect=i.rect),void 0!==i.color&&((s=i.color)instanceof pt||(s=new pt(i.color[0],i.color[1],i.color[2])),e.color=s),void 0!==i.opacity&&(e.opacity=i.opacity),void 0!==i.textureAsset&&(e.textureAsset=i.textureAsset),i.texture&&(e.texture=i.texture),void 0!==i.spriteAsset&&(e.spriteAsset=i.spriteAsset),i.sprite&&(e.sprite=i.sprite),void 0!==i.spriteFrame&&(e.spriteFrame=i.spriteFrame),void 0!==i.pixelsPerUnit&&null!==i.pixelsPerUnit&&(e.pixelsPerUnit=i.pixelsPerUnit),void 0!==i.materialAsset&&(e.materialAsset=i.materialAsset),i.material&&(e.material=i.material),void 0!==i.mask&&(e.mask=i.mask)):e.type===lv&&(void 0!==i.autoWidth&&(e.autoWidth=i.autoWidth),void 0!==i.autoHeight&&(e.autoHeight=i.autoHeight),void 0!==i.rtlReorder&&(e.rtlReorder=i.rtlReorder),void 0!==i.unicodeConverter&&(e.unicodeConverter=i.unicodeConverter),null!==i.text&&void 0!==i.text?e.text=i.text:null!==i.key&&void 0!==i.key&&(e.key=i.key),void 0!==i.color&&((s=i.color)instanceof pt||(s=new pt(s[0],s[1],s[2])),e.color=s),void 0!==i.opacity&&(e.opacity=i.opacity),void 0!==i.spacing&&(e.spacing=i.spacing),void 0!==i.fontSize&&(e.fontSize=i.fontSize,i.lineHeight||(e.lineHeight=i.fontSize)),void 0!==i.lineHeight&&(e.lineHeight=i.lineHeight),void 0!==i.maxLines&&(e.maxLines=i.maxLines),void 0!==i.wrapLines&&(e.wrapLines=i.wrapLines),void 0!==i.minFontSize&&(e.minFontSize=i.minFontSize),void 0!==i.maxFontSize&&(e.maxFontSize=i.maxFontSize),i.autoFitWidth&&(e.autoFitWidth=i.autoFitWidth),i.autoFitHeight&&(e.autoFitHeight=i.autoFitHeight),void 0!==i.fontAsset&&(e.fontAsset=i.fontAsset),void 0!==i.font&&(e.font=i.font),void 0!==i.alignment&&(e.alignment=i.alignment),void 0!==i.outlineColor&&(e.outlineColor=i.outlineColor),void 0!==i.outlineThickness&&(e.outlineThickness=i.outlineThickness),void 0!==i.shadowColor&&(e.shadowColor=i.shadowColor),void 0!==i.shadowOffset&&(e.shadowOffset=i.shadowOffset),void 0!==i.enableMarkup&&(e.enableMarkup=i.enableMarkup));var l=e._parseUpToScreen();l.screen&&e._updateScreen(l.screen),t.prototype.initializeComponentData.call(this,e,i,n),e._beingInitialized=!1,e.type===hv&&e._image._meshDirty&&e._image._updateMesh(e._image.mesh)},i.onRemoveComponent=function(t,e){e.onRemove()},i.cloneComponent=function(t,e){var i=t.element,n={enabled:i.enabled,width:i.width,height:i.height,anchor:i.anchor.clone(),pivot:i.pivot.clone(),margin:i.margin.clone(),alignment:i.alignment&&i.alignment.clone()||i.alignment,autoWidth:i.autoWidth,autoHeight:i.autoHeight,type:i.type,rect:i.rect&&i.rect.clone()||i.rect,rtlReorder:i.rtlReorder,unicodeConverter:i.unicodeConverter,materialAsset:i.materialAsset,material:i.material,color:i.color&&i.color.clone()||i.color,opacity:i.opacity,textureAsset:i.textureAsset,texture:i.texture,spriteAsset:i.spriteAsset,sprite:i.sprite,spriteFrame:i.spriteFrame,pixelsPerUnit:i.pixelsPerUnit,spacing:i.spacing,lineHeight:i.lineHeight,wrapLines:i.wrapLines,layers:i.layers,fontSize:i.fontSize,minFontSize:i.minFontSize,maxFontSize:i.maxFontSize,autoFitWidth:i.autoFitWidth,autoFitHeight:i.autoFitHeight,maxLines:i.maxLines,fontAsset:i.fontAsset,font:i.font,useInput:i.useInput,fitMode:i.fitMode,batchGroupId:i.batchGroupId,mask:i.mask,outlineColor:i.outlineColor&&i.outlineColor.clone()||i.outlineColor,outlineThickness:i.outlineThickness,shadowColor:i.shadowColor&&i.shadowColor.clone()||i.shadowColor,shadowOffset:i.shadowOffset&&i.shadowOffset.clone()||i.shadowOffset,enableMarkup:i.enableMarkup};return void 0!==i.key&&null!==i.key?n.key=i.key:n.text=i.text,this.addComponent(e,n)},i.getTextElementMaterial=function(t,e,i){var n=(t&&1)|(e&&2)|(i&&4),s=this._defaultTextMaterials[n];if(s)return s;var r="TextMaterial";return s=new Lc,e?(s.msdfMap=this._defaultTexture,s.msdfTextAttribute=i,s.emissive.set(1,1,1)):(r="Bitmap"+r,s.emissive.set(.5,.5,.5),s.emissiveMap=this._defaultTexture,s.emissiveTint=!0,s.opacityMap=this._defaultTexture,s.opacityMapChannel="a"),t&&(r="ScreenSpace"+r,s.depthTest=!1),s.name="default"+r,s.useLighting=!1,s.useGammaTonemap=!1,s.useFog=!1,s.useSkybox=!1,s.diffuse.set(0,0,0),s.opacity=.5,s.blendType=4,s.depthWrite=!1,s.emissiveVertexColor=!0,s.update(),this._defaultTextMaterials[n]=s,s},i._createBaseImageMaterial=function(){var t=new Lc;return t.diffuse.set(0,0,0),t.emissive.set(.5,.5,.5),t.emissiveMap=this._defaultTexture,t.emissiveTint=!0,t.opacityMap=this._defaultTexture,t.opacityMapChannel="a",t.opacityTint=!0,t.opacity=0,t.useLighting=!1,t.useGammaTonemap=!1,t.useFog=!1,t.useSkybox=!1,t.blendType=4,t.depthWrite=!1,t},i.getImageElementMaterial=function(t,e,i,n){return t?e?i?(this.defaultScreenSpaceImageMask9SlicedMaterial||(this.defaultScreenSpaceImageMask9SlicedMaterial=this._createBaseImageMaterial(),this.defaultScreenSpaceImageMask9SlicedMaterial.name="defaultScreenSpaceImageMask9SlicedMaterial",this.defaultScreenSpaceImageMask9SlicedMaterial.nineSlicedMode=1,this.defaultScreenSpaceImageMask9SlicedMaterial.depthTest=!1,this.defaultScreenSpaceImageMask9SlicedMaterial.alphaTest=1,this.defaultScreenSpaceImageMask9SlicedMaterial.redWrite=!1,this.defaultScreenSpaceImageMask9SlicedMaterial.greenWrite=!1,this.defaultScreenSpaceImageMask9SlicedMaterial.blueWrite=!1,this.defaultScreenSpaceImageMask9SlicedMaterial.alphaWrite=!1,this.defaultScreenSpaceImageMask9SlicedMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImageMask9SlicedMaterial)),this.defaultScreenSpaceImageMask9SlicedMaterial):n?(this.defaultScreenSpaceImageMask9TiledMaterial||(this.defaultScreenSpaceImageMask9TiledMaterial=this.defaultScreenSpaceImage9TiledMaterial.clone(),this.defaultScreenSpaceImageMask9TiledMaterial.name="defaultScreenSpaceImageMask9TiledMaterial",this.defaultScreenSpaceImageMask9TiledMaterial.nineSlicedMode=2,this.defaultScreenSpaceImageMask9TiledMaterial.depthTest=!1,this.defaultScreenSpaceImageMask9TiledMaterial.alphaTest=1,this.defaultScreenSpaceImageMask9TiledMaterial.redWrite=!1,this.defaultScreenSpaceImageMask9TiledMaterial.greenWrite=!1,this.defaultScreenSpaceImageMask9TiledMaterial.blueWrite=!1,this.defaultScreenSpaceImageMask9TiledMaterial.alphaWrite=!1,this.defaultScreenSpaceImageMask9TiledMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImageMask9TiledMaterial)),this.defaultScreenSpaceImageMask9TiledMaterial):(this.defaultScreenSpaceImageMaskMaterial||(this.defaultScreenSpaceImageMaskMaterial=this._createBaseImageMaterial(),this.defaultScreenSpaceImageMaskMaterial.name="defaultScreenSpaceImageMaskMaterial",this.defaultScreenSpaceImageMaskMaterial.depthTest=!1,this.defaultScreenSpaceImageMaskMaterial.alphaTest=1,this.defaultScreenSpaceImageMaskMaterial.redWrite=!1,this.defaultScreenSpaceImageMaskMaterial.greenWrite=!1,this.defaultScreenSpaceImageMaskMaterial.blueWrite=!1,this.defaultScreenSpaceImageMaskMaterial.alphaWrite=!1,this.defaultScreenSpaceImageMaskMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImageMaskMaterial)),this.defaultScreenSpaceImageMaskMaterial):i?(this.defaultScreenSpaceImage9SlicedMaterial||(this.defaultScreenSpaceImage9SlicedMaterial=this._createBaseImageMaterial(),this.defaultScreenSpaceImage9SlicedMaterial.name="defaultScreenSpaceImage9SlicedMaterial",this.defaultScreenSpaceImage9SlicedMaterial.nineSlicedMode=1,this.defaultScreenSpaceImage9SlicedMaterial.depthTest=!1,this.defaultScreenSpaceImage9SlicedMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImage9SlicedMaterial)),this.defaultScreenSpaceImage9SlicedMaterial):n?(this.defaultScreenSpaceImage9TiledMaterial||(this.defaultScreenSpaceImage9TiledMaterial=this._createBaseImageMaterial(),this.defaultScreenSpaceImage9TiledMaterial.name="defaultScreenSpaceImage9TiledMaterial",this.defaultScreenSpaceImage9TiledMaterial.nineSlicedMode=2,this.defaultScreenSpaceImage9TiledMaterial.depthTest=!1,this.defaultScreenSpaceImage9TiledMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImage9TiledMaterial)),this.defaultScreenSpaceImage9TiledMaterial):(this.defaultScreenSpaceImageMaterial||(this.defaultScreenSpaceImageMaterial=this._createBaseImageMaterial(),this.defaultScreenSpaceImageMaterial.name="defaultScreenSpaceImageMaterial",this.defaultScreenSpaceImageMaterial.depthTest=!1,this.defaultScreenSpaceImageMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImageMaterial)),this.defaultScreenSpaceImageMaterial):e?i?(this.defaultImage9SlicedMaskMaterial||(this.defaultImage9SlicedMaskMaterial=this._createBaseImageMaterial(),this.defaultImage9SlicedMaskMaterial.name="defaultImage9SlicedMaskMaterial",this.defaultImage9SlicedMaskMaterial.nineSlicedMode=1,this.defaultImage9SlicedMaskMaterial.alphaTest=1,this.defaultImage9SlicedMaskMaterial.redWrite=!1,this.defaultImage9SlicedMaskMaterial.greenWrite=!1,this.defaultImage9SlicedMaskMaterial.blueWrite=!1,this.defaultImage9SlicedMaskMaterial.alphaWrite=!1,this.defaultImage9SlicedMaskMaterial.update(),this.defaultImageMaterials.push(this.defaultImage9SlicedMaskMaterial)),this.defaultImage9SlicedMaskMaterial):n?(this.defaultImage9TiledMaskMaterial||(this.defaultImage9TiledMaskMaterial=this._createBaseImageMaterial(),this.defaultImage9TiledMaskMaterial.name="defaultImage9TiledMaskMaterial",this.defaultImage9TiledMaskMaterial.nineSlicedMode=2,this.defaultImage9TiledMaskMaterial.alphaTest=1,this.defaultImage9TiledMaskMaterial.redWrite=!1,this.defaultImage9TiledMaskMaterial.greenWrite=!1,this.defaultImage9TiledMaskMaterial.blueWrite=!1,this.defaultImage9TiledMaskMaterial.alphaWrite=!1,this.defaultImage9TiledMaskMaterial.update(),this.defaultImageMaterials.push(this.defaultImage9TiledMaskMaterial)),this.defaultImage9TiledMaskMaterial):(this.defaultImageMaskMaterial||(this.defaultImageMaskMaterial=this._createBaseImageMaterial(),this.defaultImageMaskMaterial.name="defaultImageMaskMaterial",this.defaultImageMaskMaterial.alphaTest=1,this.defaultImageMaskMaterial.redWrite=!1,this.defaultImageMaskMaterial.greenWrite=!1,this.defaultImageMaskMaterial.blueWrite=!1,this.defaultImageMaskMaterial.alphaWrite=!1,this.defaultImageMaskMaterial.update(),this.defaultImageMaterials.push(this.defaultImageMaskMaterial)),this.defaultImageMaskMaterial):i?(this.defaultImage9SlicedMaterial||(this.defaultImage9SlicedMaterial=this._createBaseImageMaterial(),this.defaultImage9SlicedMaterial.name="defaultImage9SlicedMaterial",this.defaultImage9SlicedMaterial.nineSlicedMode=1,this.defaultImage9SlicedMaterial.update(),this.defaultImageMaterials.push(this.defaultImage9SlicedMaterial)),this.defaultImage9SlicedMaterial):n?(this.defaultImage9TiledMaterial||(this.defaultImage9TiledMaterial=this._createBaseImageMaterial(),this.defaultImage9TiledMaterial.name="defaultImage9TiledMaterial",this.defaultImage9TiledMaterial.nineSlicedMode=2,this.defaultImage9TiledMaterial.update(),this.defaultImageMaterials.push(this.defaultImage9TiledMaterial)),this.defaultImage9TiledMaterial):(this.defaultImageMaterial||(this.defaultImageMaterial=this._createBaseImageMaterial(),this.defaultImageMaterial.name="defaultImageMaterial",this.defaultImageMaterial.update(),this.defaultImageMaterials.push(this.defaultImageMaterial)),this.defaultImageMaterial)},i.registerUnicodeConverter=function(t){this._unicodeConverter=t},i.registerRtlReorder=function(t){this._rtlReorder=t},i.getUnicodeConverter=function(){return this._unicodeConverter},i.getRtlReorder=function(){return this._rtlReorder},e}(Hm),Bg="free",Ng="limited",Ug="locked",zg=["angularDampingX","angularDampingY","angularDampingZ","angularEquilibriumX","angularEquilibriumY","angularEquilibriumZ","angularLimitsX","angularLimitsY","angularLimitsZ","angularMotionX","angularMotionY","angularMotionZ","angularSpringX","angularSpringY","angularSpringZ","angularStiffnessX","angularStiffnessY","angularStiffnessZ","breakForce","enableCollision","enabled","entityA","entityB","linearDampingX","linearDampingY","linearDampingZ","linearEquilibriumX","linearEquilibriumY","linearEquilibriumZ","linearLimitsX","linearLimitsY","linearLimitsZ","linearMotionX","linearMotionY","linearMotionZ","linearSpringX","linearSpringY","linearSpringZ","linearStiffnessX","linearStiffnessY","linearStiffnessZ"],Vg=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._constraint=null,n._entityA=null,n._entityB=null,n._breakForce=34e37,n._enableCollision=!0,n._linearMotionX=Ug,n._linearLimitsX=new Mt(0,0),n._linearSpringX=!1,n._linearStiffnessX=0,n._linearDampingX=1,n._linearEquilibriumX=0,n._linearMotionY=Ug,n._linearLimitsY=new Mt(0,0),n._linearSpringY=!1,n._linearStiffnessY=0,n._linearDampingY=1,n._linearEquilibriumY=0,n._linearMotionZ=Ug,n._linearLimitsZ=new Mt(0,0),n._linearSpringZ=!1,n._linearStiffnessZ=0,n._linearDampingZ=1,n._linearEquilibriumZ=0,n._angularMotionX=Ug,n._angularLimitsX=new Mt(0,0),n._angularSpringX=!1,n._angularStiffnessX=0,n._angularDampingX=1,n._angularEquilibriumX=0,n._angularMotionY=Ug,n._angularLimitsY=new Mt(0,0),n._angularSpringY=!1,n._angularStiffnessY=0,n._angularDampingY=1,n._angularEquilibriumY=0,n._angularMotionZ=Ug,n._angularLimitsZ=new Mt(0,0),n._angularSpringZ=!1,n._angularEquilibriumZ=0,n._angularDampingZ=1,n._angularStiffnessZ=0,n.on("set_enabled",n._onSetEnabled,n),n}x(e,t);var i=e.prototype;return i._convertTransform=function(t,e){var i=t.getTranslation(),n=new Nt;n.setFromMat4(t);var s=new Ammo.btVector3(i.x,i.y,i.z),r=new Ammo.btQuaternion(n.x,n.y,n.z,n.w);e.setOrigin(s),e.setRotation(r),Ammo.destroy(s),Ammo.destroy(r)},i._updateAngularLimits=function(){var t=this._constraint;if(t){var e,i,n,s,r,a;this._angularMotionX===Ng?(e=this._angularLimitsX.x*ft.DEG_TO_RAD,s=this._angularLimitsX.y*ft.DEG_TO_RAD):this._angularMotionX===Bg?(e=1,s=0):e=s=0,this._angularMotionY===Ng?(i=this._angularLimitsY.x*ft.DEG_TO_RAD,r=this._angularLimitsY.y*ft.DEG_TO_RAD):this._angularMotionY===Bg?(i=1,r=0):i=r=0,this._angularMotionZ===Ng?(n=this._angularLimitsZ.x*ft.DEG_TO_RAD,a=this._angularLimitsZ.y*ft.DEG_TO_RAD):this._angularMotionZ===Bg?(n=1,a=0):n=a=0;var o=new Ammo.btVector3(e,i,n);t.setAngularLowerLimit(o),o.setValue(s,r,a),t.setAngularUpperLimit(o),Ammo.destroy(o)}},i._updateLinearLimits=function(){var t=this._constraint;if(t){var e,i,n,s,r,a;this._linearMotionX===Ng?(e=this._linearLimitsX.x,s=this._linearLimitsX.y):this._linearMotionX===Bg?(e=1,s=0):e=s=0,this._linearMotionY===Ng?(i=this._linearLimitsY.x,r=this._linearLimitsY.y):this._linearMotionY===Bg?(i=1,r=0):i=r=0,this._linearMotionZ===Ng?(n=this._linearLimitsZ.x,a=this._linearLimitsZ.y):this._linearMotionZ===Bg?(n=1,a=0):n=a=0;var o=new Ammo.btVector3(e,i,n);t.setLinearLowerLimit(o),o.setValue(s,r,a),t.setLinearUpperLimit(o),Ammo.destroy(o)}},i._createConstraint=function(){if(this._entityA&&this._entityA.rigidbody){this._destroyConstraint();var t=new Bt,e=this._entityA.rigidbody.body;e.activate();var i=this.entity.getWorldTransform(),n=this._entityA.getWorldTransform().clone().invert();t.mul2(n,i);var s=new Ammo.btTransform;if(this._convertTransform(t,s),this._entityB&&this._entityB.rigidbody){var r=this._entityB.rigidbody.body;r.activate();var a=this._entityB.getWorldTransform().clone().invert();t.mul2(a,i);var o=new Ammo.btTransform;this._convertTransform(t,o),this._constraint=new Ammo.btGeneric6DofSpringConstraint(e,r,s,o,!this._enableCollision),Ammo.destroy(o)}else this._constraint=new Ammo.btGeneric6DofSpringConstraint(e,s,!this._enableCollision);Ammo.destroy(s);for(var h=["X","Y","Z","X","Y","Z"],l=0;l<6;l++){var c=l<3?"_linear":"_angular";this._constraint.enableSpring(l,this[c+"Spring"+h[l]]),this._constraint.setDamping(l,this[c+"Damping"+h[l]]),this._constraint.setEquilibriumPoint(l,this[c+"Equilibrium"+h[l]]),this._constraint.setStiffness(l,this[c+"Stiffness"+h[l]])}this._constraint.setBreakingImpulseThreshold(this._breakForce),this._updateLinearLimits(),this._updateAngularLimits(),this.system.app.systems.rigidbody.dynamicsWorld.addConstraint(this._constraint,!this._enableCollision)}},i._destroyConstraint=function(){this._constraint&&(this.system.app.systems.rigidbody.dynamicsWorld.removeConstraint(this._constraint),Ammo.destroy(this._constraint),this._constraint=null)},i.initFromData=function(t){for(var e=0,i=zg;e=i?ey:$g;case 3:return e=0;--n)i[e[n]]=i[e[n+1]]+t[e[n]];return i}return function(t,d){t=t.filter(o),e=d,iy.x=e.containerSize.x-e.padding.x-e.padding.z,iy.y=e.containerSize.y-e.padding.y-e.padding.w,function(t){for(var e=0;e0&&(r+=e.spacing[i.axis]);var h=s[o][i.size];r+=h,!a&&r>iy[i.axis]&&0!==n[n.length-1].length&&(r=h,n.push([])),n[n.length-1].push(t[o]),a&&r>iy[i.axis]&&o!==t.length-1&&(r=0,n.push([]))}return n}(t)),m=function(t,i){for(var s=[],r=[],a=0;ao.largestSize[n.size]&&(o.largestElement=o[d],o.largestSize=f)}s.push(o.largestElement),r.push(o.largestSize)}var p=l(r,n),m=h(e[n.fitting],p,iy[n.axis]);m===ty?c(r,p,n):m===ey&&u(r,p,n);for(var _=0;_0;){var e=this._reflowQueue.slice();this._reflowQueue.length=0,e.sort((function(t,e){return t.entity.graphDepth-e.entity.graphDepth}));for(var i=0;i=100){console.warn("Max reflow iterations limit reached, bailing.");break}}},i._onRemoveComponent=function(t,e){e.onRemove()},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("postUpdate",this._onPostUpdate,this)},e}(Hm);Gm._buildAccessors(hy.prototype,cy);var dy=[];function fy(t,e){for(var i=null,n=0;n=0&&(null==(s=t.batcher)||s.insert(sh.MODEL,this.batchGroupId,this.entity))},i.onDisable=function(){var t,e,i,n,s=this.system.app,r=s.scene.layers;(null==(t=this._evtLayersChanged)||t.off(),this._evtLayersChanged=null,r)&&(null==(e=this._evtLayerAdded)||e.off(),this._evtLayerAdded=null,null==(i=this._evtLayerRemoved)||i.off(),this._evtLayerRemoved=null);this._batchGroupId>=0&&(null==(n=s.batcher)||n.remove(sh.MODEL,this.batchGroupId,this.entity));this._model&&this.removeModelFromLayers()},i.hide=function(){if(this._model)for(var t=this._model.meshInstances,e=0,i=t.length;e=0)null==(e=this.system.app.batcher)||e.remove(sh.MODEL,this.batchGroupId,this.entity);if(this.entity.enabled&&t>=0)null==(i=this.system.app.batcher)||i.insert(sh.MODEL,t,this.entity);t<0&&this._batchGroupId>=0&&this.enabled&&this.entity.enabled&&this.addModelToLayers(),this._batchGroupId=t}}},{key:"materialAsset",get:function(){return this._materialAsset},set:function(t){var e=t;t instanceof om&&(e=t.id);var i=this.system.app.assets;if(e!==this._materialAsset){if(this._materialAsset){i.off("add:"+this._materialAsset,this._onMaterialAssetAdd,this);var n=i.get(this._materialAsset);n&&this._unbindMaterialAsset(n)}if(this._materialAsset=e,this._materialAsset){var s=i.get(this._materialAsset);s?this._bindMaterialAsset(s):(this._setMaterial(this.system.defaultMaterial),i.on("add:"+this._materialAsset,this._onMaterialAssetAdd,this))}else this._setMaterial(this.system.defaultMaterial)}}},{key:"material",get:function(){return this._material},set:function(t){this._material!==t&&(this.materialAsset=null,this._setMaterial(t))}},{key:"mapping",get:function(){return this._mapping},set:function(t){if("asset"===this._type&&(this._unsetMaterialEvents(),t||(t={}),this._mapping=t,this._model))for(var e=this._model.meshInstances,i=this.asset?this.system.app.assets.get(this.asset):null,n=i?i.data.mapping:null,s=null,r=0,a=e.length;r=0))continue;r=this.system.app.assets.get(r)}r&&!r.resource&&this.system.app.assets.load(r)}}if(!this.system.app.graphicsDevice.disableParticleSystem){if(!this.emitter){var a=i.mesh;a instanceof dh||(a=null),this.emitter=new bf(this.system.app.graphicsDevice,{numParticles:i.numParticles,emitterExtents:i.emitterExtents,emitterExtentsInner:i.emitterExtentsInner,emitterRadius:i.emitterRadius,emitterRadiusInner:i.emitterRadiusInner,emitterShape:i.emitterShape,initialVelocity:i.initialVelocity,wrap:i.wrap,localSpace:i.localSpace,screenSpace:i.screenSpace,wrapBounds:i.wrapBounds,lifetime:i.lifetime,rate:i.rate,rate2:i.rate2,orientation:i.orientation,particleNormal:i.particleNormal,animTilesX:i.animTilesX,animTilesY:i.animTilesY,animStartFrame:i.animStartFrame,animNumFrames:i.animNumFrames,animNumAnimations:i.animNumAnimations,animIndex:i.animIndex,randomizeAnimIndex:i.randomizeAnimIndex,animSpeed:i.animSpeed,animLoop:i.animLoop,startAngle:i.startAngle,startAngle2:i.startAngle2,scaleGraph:i.scaleGraph,scaleGraph2:i.scaleGraph2,colorGraph:i.colorGraph,colorGraph2:i.colorGraph2,alphaGraph:i.alphaGraph,alphaGraph2:i.alphaGraph2,localVelocityGraph:i.localVelocityGraph,localVelocityGraph2:i.localVelocityGraph2,velocityGraph:i.velocityGraph,velocityGraph2:i.velocityGraph2,rotationSpeedGraph:i.rotationSpeedGraph,rotationSpeedGraph2:i.rotationSpeedGraph2,radialSpeedGraph:i.radialSpeedGraph,radialSpeedGraph2:i.radialSpeedGraph2,colorMap:i.colorMap,normalMap:i.normalMap,loop:i.loop,preWarm:i.preWarm,sort:i.sort,stretch:i.stretch,alignToMotion:i.alignToMotion,lighting:i.lighting,halfLambert:i.halfLambert,intensity:i.intensity,depthSoftening:i.depthSoftening,scene:this.system.app.scene,mesh:a,depthWrite:i.depthWrite,noFog:i.noFog,node:this.entity,blendType:i.blendType}),this.emitter.meshInstance.node=this.entity,this.emitter.drawOrder=this.drawOrder,i.autoPlay||(this.pause(),this.emitter.meshInstance.visible=!1)}this.emitter.colorMap&&this.addMeshInstanceToLayers(),this._evtLayersChanged=t.on("set:layers",this.onLayersChanged,this),e&&(this._evtLayerAdded=e.on("add",this.onLayerAdded,this),this._evtLayerRemoved=e.on("remove",this.onLayerRemoved,this)),this.enabled&&this.entity.enabled&&i.depthSoftening&&this._requestDepth()}},i.onDisable=function(){var t,e,i,n=this.system.app.scene.layers;(null==(t=this._evtLayersChanged)||t.off(),this._evtLayersChanged=null,n)&&(null==(e=this._evtLayerAdded)||e.off(),this._evtLayerAdded=null,null==(i=this._evtLayerRemoved)||i.off(),this._evtLayerRemoved=null);this.emitter&&(this.removeMeshInstanceFromLayers(),this.data.depthSoftening&&this._releaseDepth(),this.emitter.camera=null)},i.onBeforeRemove=function(){this.enabled&&(this.enabled=!1),this.emitter&&(this.emitter.destroy(),this.emitter=null);for(var t=0;tc.fixedTimeStep&&(e=Math.floor(c.simTime/c.fixedTimeStep),c.simTime-=e*c.fixedTimeStep),e){e=Math.min(e,c.maxSubSteps);for(var p=0;p=0){var r=n[s];r.decRefCount(),0===r.refCount&&(n.splice(s,1),n.length||t._skinInstanceCache.delete(i),e&&(e.destroy(),r.skinInstance=null))}}}}},t}();My._skinInstanceCache=new Map;var Py=function(){function t(t,e,i,n,s){this._evtLoadById=null,this._evtUnloadById=null,this._evtAddById=null,this._evtRemoveById=null,this._evtLoadByUrl=null,this._evtAddByUrl=null,this._evtRemoveByUrl=null,this.propertyName=t,this.parent=e,this._scope=s,this._registry=i,this.id=null,this.url=null,this.asset=null,this._onAssetLoad=n.load,this._onAssetAdd=n.add,this._onAssetRemove=n.remove,this._onAssetUnload=n.unload}var e=t.prototype;return e._bind=function(){this.id&&(this._onAssetLoad&&(this._evtLoadById=this._registry.on("load:"+this.id,this._onLoad,this)),this._onAssetAdd&&(this._evtAddById=this._registry.once("add:"+this.id,this._onAdd,this)),this._onAssetRemove&&(this._evtRemoveById=this._registry.on("remove:"+this.id,this._onRemove,this)),this._onAssetUnload&&(this._evtUnloadById=this._registry.on("unload:"+this.id,this._onUnload,this))),this.url&&(this._onAssetLoad&&(this._evtLoadByUrl=this._registry.on("load:url:"+this.url,this._onLoad,this)),this._onAssetAdd&&(this._evtAddByUrl=this._registry.once("add:url:"+this.url,this._onAdd,this)),this._onAssetRemove&&(this._evtRemoveByUrl=this._registry.on("remove:url:"+this.url,this._onRemove,this)))},e._unbind=function(){var t,e,i,n,s,r,a;this.id&&(null==(t=this._evtLoadById)||t.off(),this._evtLoadById=null,null==(e=this._evtAddById)||e.off(),this._evtAddById=null,null==(i=this._evtRemoveById)||i.off(),this._evtRemoveById=null,null==(n=this._evtUnloadById)||n.off(),this._evtUnloadById=null);this.url&&(null==(s=this._evtLoadByUrl)||s.off(),this._evtLoadByUrl=null,null==(r=this._evtAddByUrl)||r.off(),this._evtAddByUrl=null,null==(a=this._evtRemoveByUrl)||a.off(),this._evtRemoveByUrl=null)},e._onLoad=function(t){this._onAssetLoad.call(this._scope,this.propertyName,this.parent,t)},e._onAdd=function(t){this.asset=t,this._onAssetAdd.call(this._scope,this.propertyName,this.parent,t)},e._onRemove=function(t){this._onAssetRemove.call(this._scope,this.propertyName,this.parent,t),this.asset=null},e._onUnload=function(t){this._onAssetUnload.call(this._scope,this.propertyName,this.parent,t)},v(t,[{key:"id",get:function(){return this._id},set:function(t){if(this.url)throw Error("Can't set id and url");this._unbind(),this._id=t,this.asset=this._registry.get(this._id),this._bind()}},{key:"url",get:function(){return this._url},set:function(t){if(this.id)throw Error("Can't set id and url");this._unbind(),this._url=t,this.asset=this._registry.getByUrl(this._url),this._bind()}}])}(),Ry=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._type="asset",n._castShadows=!0,n._receiveShadows=!0,n._castShadowsLightmap=!0,n._lightmapped=!1,n._lightmapSizeMultiplier=1,n.isStatic=!1,n._batchGroupId=-1,n._layers=[0],n._renderStyle=0,n._meshInstances=[],n._customAabb=null,n._area=null,n._assetReference=void 0,n._materialReferences=[],n._material=void 0,n._rootBone=void 0,n._evtLayersChanged=null,n._evtLayerAdded=null,n._evtLayerRemoved=null,n._evtSetMeshes=null,n._rootBone=new av(n,"rootBone"),n._rootBone.on("set:entity",n._onSetRootBone,n),n._assetReference=new Py("asset",n,e.app.assets,{add:n._onRenderAssetAdded,load:n._onRenderAssetLoad,remove:n._onRenderAssetRemove,unload:n._onRenderAssetUnload},n),n._material=e.defaultMaterial,i.on("remove",n.onRemoveChild,n),i.on("removehierarchy",n.onRemoveChild,n),i.on("insert",n.onInsertChild,n),i.on("inserthierarchy",n.onInsertChild,n),n}x(e,t);var i=e.prototype;return i.assignAsset=function(t){var e=t instanceof om?t.id:t;this._assetReference.id=e},i._onSetRootBone=function(t){t&&this._onRootBoneChanged()},i._onRootBoneChanged=function(){this._clearSkinInstances(),this.enabled&&this.entity.enabled&&this._cloneSkinInstances()},i.destroyMeshInstances=function(){var t=this._meshInstances;if(t){this.removeFromLayers(),this._clearSkinInstances();for(var e=0;e=0&&(null==(n=t.batcher)||n.insert(sh.RENDER,this.batchGroupId,this.entity))},i.onDisable=function(){var t,e,i,n,s=this.system.app,r=s.scene.layers;(null==(t=this._evtLayersChanged)||t.off(),this._evtLayersChanged=null,r)&&(null==(e=this._evtLayerAdded)||e.off(),this._evtLayerAdded=null,null==(i=this._evtLayerRemoved)||i.off(),this._evtLayerRemoved=null);this._batchGroupId>=0&&(null==(n=s.batcher)||n.remove(sh.RENDER,this.batchGroupId,this.entity));this.removeFromLayers()},i.hide=function(){if(this._meshInstances)for(var t=0;t=0)null==(e=this.system.app.batcher)||e.remove(sh.RENDER,this.batchGroupId,this.entity);if(this.entity.enabled&&t>=0)null==(i=this.system.app.batcher)||i.insert(sh.RENDER,t,this.entity);t<0&&this._batchGroupId>=0&&this.enabled&&this.entity.enabled&&this.addToLayers(),this._batchGroupId=t}}},{key:"material",get:function(){return this._material},set:function(t){if(this._material!==t&&(this._material=t,this._meshInstances&&"asset"!==this._type))for(var e=0;et.length){for(var e=t.length;ethis._pool.length)for(var e=this._pool.length;e=this._pool.length&&this._resize(2*this._pool.length),this._pool[this._count++]},e.freeAll=function(){this._count=0},t}(),zy=new Nt,Vy=new Nt,Gy=new wt,Hy=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._angularDamping=0,n._angularFactor=new wt(1,1,1),n._angularVelocity=new wt,n._body=null,n._friction=.5,n._group=2,n._linearDamping=0,n._linearFactor=new wt(1,1,1),n._linearVelocity=new wt,n._mask=Fv,n._mass=1,n._restitution=0,n._rollingFriction=0,n._simulationEnabled=!1,n._type=Dv,n}x(e,t),e.onLibraryLoaded=function(){"undefined"!=typeof Ammo&&(Oy=new Ammo.btTransform,Fy=new Ammo.btVector3,By=new Ammo.btVector3,Ny=new Ammo.btQuaternion)},e.onAppDestroy=function(){Ammo.destroy(Oy),Ammo.destroy(Fy),Ammo.destroy(By),Ammo.destroy(Ny),Oy=null,Fy=null,By=null,Ny=null};var i=e.prototype;return i.createBody=function(){var t,e=this.entity;if(e.collision&&(t=e.collision.shape,e.trigger&&(e.trigger.destroy(),delete e.trigger)),t){this._body&&(this.system.removeBody(this._body),this.system.destroyBody(this._body),this._body=null);var i=this._type===Lv?this._mass:0;this._getEntityTransform(Oy);var n=this.system.createBody(i,t,Oy);if(n.setRestitution(this._restitution),n.setFriction(this._friction),n.setRollingFriction(this._rollingFriction),n.setDamping(this._linearDamping,this._angularDamping),this._type===Lv){var s=this._linearFactor;Fy.setValue(s.x,s.y,s.z),n.setLinearFactor(Fy);var r=this._angularFactor;Fy.setValue(r.x,r.y,r.z),n.setAngularFactor(Fy)}else this._type===kv&&(n.setCollisionFlags(2|n.getCollisionFlags()),n.setActivationState(4));n.entity=e,this.body=n,this.enabled&&e.enabled&&this.enableSimulation()}},i.isActive=function(){return!!this._body&&this._body.isActive()},i.activate=function(){this._body&&this._body.activate()},i.enableSimulation=function(){var t=this.entity;if(t.collision&&t.collision.enabled&&!this._simulationEnabled){var e=this._body;if(e){switch(this.system.addBody(e,this._group,this._mask),this._type){case Lv:this.system._dynamic.push(this),e.forceActivationState(1),this.syncEntityToBody();break;case kv:this.system._kinematic.push(this),e.forceActivationState(4);break;case Dv:e.forceActivationState(1),this.syncEntityToBody()}"compound"===t.collision.type&&this.system._compounds.push(t.collision),e.activate(),this._simulationEnabled=!0}}},i.disableSimulation=function(){var t=this._body;if(t&&this._simulationEnabled){var e=this.system,i=e._compounds.indexOf(this.entity.collision);i>-1&&e._compounds.splice(i,1),(i=e._dynamic.indexOf(this))>-1&&e._dynamic.splice(i,1),(i=e._kinematic.indexOf(this))>-1&&e._kinematic.splice(i,1),e.removeBody(t),t.forceActivationState(5),this._simulationEnabled=!1}},i.applyForce=function(t,e,i,n,s,r){var a=this._body;a&&(a.activate(),t instanceof wt?Fy.setValue(t.x,t.y,t.z):Fy.setValue(t,e,i),e instanceof wt?By.setValue(e.x,e.y,e.z):void 0!==n?By.setValue(n,s,r):By.setValue(0,0,0),a.applyForce(Fy,By))},i.applyTorque=function(t,e,i){var n=this._body;n&&(n.activate(),t instanceof wt?Fy.setValue(t.x,t.y,t.z):Fy.setValue(t,e,i),n.applyTorque(Fy))},i.applyImpulse=function(t,e,i,n,s,r){var a=this._body;a&&(a.activate(),t instanceof wt?Fy.setValue(t.x,t.y,t.z):Fy.setValue(t,e,i),e instanceof wt?By.setValue(e.x,e.y,e.z):void 0!==n?By.setValue(n,s,r):By.setValue(0,0,0),a.applyImpulse(Fy,By))},i.applyTorqueImpulse=function(t,e,i){var n=this._body;n&&(n.activate(),t instanceof wt?Fy.setValue(t.x,t.y,t.z):Fy.setValue(t,e,i),n.applyTorqueImpulse(Fy))},i.isStatic=function(){return this._type===Dv},i.isStaticOrKinematic=function(){return this._type===Dv||this._type===kv},i.isKinematic=function(){return this._type===kv},i._getEntityTransform=function(t){var e=this.entity,i=e.collision;if(i){var n=i.getShapePosition(),s=i.getShapeRotation();Fy.setValue(n.x,n.y,n.z),Ny.setValue(s.x,s.y,s.z,s.w)}else{var r=e.getPosition(),a=e.getRotation();Fy.setValue(r.x,r.y,r.z),Ny.setValue(a.x,a.y,a.z,a.w)}t.setOrigin(Fy),t.setRotation(Ny)},i.syncEntityToBody=function(){var t=this._body;if(t){if(this._getEntityTransform(Oy),t.setWorldTransform(Oy),this._type===kv){var e=t.getMotionState();e&&e.setWorldTransform(Oy)}t.activate()}},i._updateDynamic=function(){var t=this._body;if(t.isActive()){var e=t.getMotionState();if(e){var i=this.entity;e.getWorldTransform(Oy);var n=Oy.getOrigin(),s=Oy.getRotation(),r=i.collision;if(r&&r._hasOffset){var a=r.data.linearOffset,o=r.data.angularOffset,h=Vy.copy(o).invert(),l=zy.set(s.x(),s.y(),s.z(),s.w()).mul(h);l.transformVector(a,Gy),i.setPosition(n.x()-Gy.x,n.y()-Gy.y,n.z()-Gy.z),i.setRotation(l)}else i.setPosition(n.x(),n.y(),n.z()),i.setRotation(s.x(),s.y(),s.z(),s.w())}}},i._updateKinematic=function(){var t=this._body.getMotionState();t&&(this._getEntityTransform(Oy),t.setWorldTransform(Oy))},i.teleport=function(t,e,i,n,s,r){t instanceof wt?this.entity.setPosition(t):this.entity.setPosition(t,e,i),e instanceof Nt?this.entity.setRotation(e):e instanceof wt?this.entity.setEulerAngles(e):void 0!==n&&this.entity.setEulerAngles(n,s,r),this.syncEntityToBody()},i.onEnable=function(){this._body||this.createBody(),this.enableSimulation()},i.onDisable=function(){this.disableSimulation()},v(e,[{key:"angularDamping",get:function(){return this._angularDamping},set:function(t){this._angularDamping!==t&&(this._angularDamping=t,this._body&&this._body.setDamping(this._linearDamping,t))}},{key:"angularFactor",get:function(){return this._angularFactor},set:function(t){this._angularFactor.equals(t)||(this._angularFactor.copy(t),this._body&&this._type===Lv&&(Fy.setValue(t.x,t.y,t.z),this._body.setAngularFactor(Fy)))}},{key:"angularVelocity",get:function(){if(this._body&&this._type===Lv){var t=this._body.getAngularVelocity();this._angularVelocity.set(t.x(),t.y(),t.z())}return this._angularVelocity},set:function(t){this._body&&this._type===Lv&&(this._body.activate(),Fy.setValue(t.x,t.y,t.z),this._body.setAngularVelocity(Fy),this._angularVelocity.copy(t))}},{key:"body",get:function(){return this._body},set:function(t){this._body!==t&&(this._body=t,t&&this._simulationEnabled&&t.activate())}},{key:"friction",get:function(){return this._friction},set:function(t){this._friction!==t&&(this._friction=t,this._body&&this._body.setFriction(t))}},{key:"group",get:function(){return this._group},set:function(t){this._group!==t&&(this._group=t,this.enabled&&this.entity.enabled&&(this.disableSimulation(),this.enableSimulation()))}},{key:"linearDamping",get:function(){return this._linearDamping},set:function(t){this._linearDamping!==t&&(this._linearDamping=t,this._body&&this._body.setDamping(t,this._angularDamping))}},{key:"linearFactor",get:function(){return this._linearFactor},set:function(t){this._linearFactor.equals(t)||(this._linearFactor.copy(t),this._body&&this._type===Lv&&(Fy.setValue(t.x,t.y,t.z),this._body.setLinearFactor(Fy)))}},{key:"linearVelocity",get:function(){if(this._body&&this._type===Lv){var t=this._body.getLinearVelocity();this._linearVelocity.set(t.x(),t.y(),t.z())}return this._linearVelocity},set:function(t){this._body&&this._type===Lv&&(this._body.activate(),Fy.setValue(t.x,t.y,t.z),this._body.setLinearVelocity(Fy),this._linearVelocity.copy(t))}},{key:"mask",get:function(){return this._mask},set:function(t){this._mask!==t&&(this._mask=t,this.enabled&&this.entity.enabled&&(this.disableSimulation(),this.enableSimulation()))}},{key:"mass",get:function(){return this._mass},set:function(t){if(this._mass!==t&&(this._mass=t,this._body&&this._type===Lv)){var e=this.enabled&&this.entity.enabled;e&&this.disableSimulation(),this._body.getCollisionShape().calculateLocalInertia(t,Fy),this._body.setMassProps(t,Fy),this._body.updateInertiaTensor(),e&&this.enableSimulation()}}},{key:"restitution",get:function(){return this._restitution},set:function(t){this._restitution!==t&&(this._restitution=t,this._body&&this._body.setRestitution(t))}},{key:"rollingFriction",get:function(){return this._rollingFriction},set:function(t){this._rollingFriction!==t&&(this._rollingFriction=t,this._body&&this._body.setRollingFriction(t))}},{key:"type",get:function(){return this._type},set:function(t){if(this._type!==t){switch(this._type=t,this.disableSimulation(),t){case Lv:this._group=1,this._mask=Ov;break;case kv:this._group=4,this._mask=Ov;break;default:this._group=2,this._mask=Fv}this.createBody()}}}])}(Gm);Hy.EVENT_CONTACT="contact",Hy.EVENT_COLLISIONSTART="collisionstart",Hy.EVENT_COLLISIONEND="collisionend",Hy.EVENT_TRIGGERENTER="triggerenter",Hy.EVENT_TRIGGERLEAVE="triggerleave";var Wy,Xy,jy=function(){this.enabled=!0},qy=function(t,e,i,n){this.entity=void 0,this.point=void 0,this.normal=void 0,this.hitFraction=void 0,this.entity=t,this.point=e,this.normal=i,this.hitFraction=n},Yy=function(t,e,i){this.a=void 0,this.b=void 0,this.impulse=void 0,this.localPointA=void 0,this.localPointB=void 0,this.pointA=void 0,this.pointB=void 0,this.normal=void 0,0!==arguments.length?(this.a=t,this.b=e,this.impulse=i.impulse,this.localPointA=i.localPoint,this.localPointB=i.localPointOther,this.pointA=i.point,this.pointB=i.pointOther,this.normal=i.normal):(this.a=null,this.b=null,this.impulse=0,this.localPointA=new wt,this.localPointB=new wt,this.pointA=new wt,this.pointB=new wt,this.normal=new wt)},Ky=function(t,e,i,n,s,r){void 0===t&&(t=new wt),void 0===e&&(e=new wt),void 0===i&&(i=new wt),void 0===n&&(n=new wt),void 0===s&&(s=new wt),void 0===r&&(r=0),this.localPoint=void 0,this.localPointOther=void 0,this.point=void 0,this.pointOther=void 0,this.normal=void 0,this.impulse=void 0,this.localPoint=t,this.localPointOther=e,this.point=i,this.pointOther=n,this.normal=s,this.impulse=r},Zy=function(t,e){this.other=void 0,this.contacts=void 0,this.other=t,this.contacts=e},Qy=["enabled"],Jy=function(t){function e(e){var i;return(i=t.call(this,e)||this).maxSubSteps=10,i.fixedTimeStep=1/60,i.gravity=new wt(0,-9.81,0),i._gravityFloat32=new Float32Array(3),i._dynamic=[],i._kinematic=[],i._triggers=[],i._compounds=[],i.id="rigidbody",i._stats=e.stats.frame,i.ComponentType=Hy,i.DataType=jy,i.contactPointPool=null,i.contactResultPool=null,i.singleContactResultPool=null,i.schema=Qy,i.collisions={},i.frameCollisions={},i.on("beforeremove",i.onBeforeRemove,i),i}x(e,t);var i=e.prototype;return i.onLibraryLoaded=function(){if("undefined"!=typeof Ammo){if(this.collisionConfiguration=new Ammo.btDefaultCollisionConfiguration,this.dispatcher=new Ammo.btCollisionDispatcher(this.collisionConfiguration),this.overlappingPairCache=new Ammo.btDbvtBroadphase,this.solver=new Ammo.btSequentialImpulseConstraintSolver,this.dynamicsWorld=new Ammo.btDiscreteDynamicsWorld(this.dispatcher,this.overlappingPairCache,this.solver,this.collisionConfiguration),this.dynamicsWorld.setInternalTickCallback){var t=Ammo.addFunction(this._checkForCollisions.bind(this),"vif");this.dynamicsWorld.setInternalTickCallback(t)}Wy=new Ammo.btVector3,Xy=new Ammo.btVector3,Hy.onLibraryLoaded(),this.contactPointPool=new Uy(Ky,1),this.contactResultPool=new Uy(Zy,1),this.singleContactResultPool=new Uy(Yy,1),this.app.systems.on("update",this.onUpdate,this)}else this.app.systems.off("update",this.onUpdate,this)},i.initializeComponentData=function(e,i,n){for(var s=0,r=["mass","linearDamping","angularDamping","linearFactor","angularFactor","friction","rollingFriction","restitution","type","group","mask"];s0)if(4&d||4&f){var g=c.collision&&(c.collision.hasEvent("triggerenter")||c.collision.hasEvent("triggerleave")),y=u.collision&&(u.collision.hasEvent("triggerenter")||u.collision.hasEvent("triggerleave")),x=c.rigidbody&&(c.rigidbody.hasEvent("triggerenter")||c.rigidbody.hasEvent("triggerleave")),S=u.rigidbody&&(u.rigidbody.hasEvent("triggerenter")||u.rigidbody.hasEvent("triggerleave"));g&&(!(v=this._storeCollision(c,u))||4&f||c.collision.fire("triggerenter",u)),y&&(!(v=this._storeCollision(u,c))||4&d||u.collision.fire("triggerenter",c)),x&&(v||(v=this._storeCollision(u,c)),v&&c.rigidbody.fire("triggerenter",u)),S&&(v||(v=this._storeCollision(c,u)),v&&u.rigidbody.fire("triggerenter",c))}else{var b=this._hasContactEvent(c),T=this._hasContactEvent(u),w=this.hasEvent("contact");if(w||b||T){for(var E=0;E=0&&n!==t.element.drawOrder)null==(i=this.system.app.batcher)||i.markGroupDirty(t.element._batchGroupId)}t.particlesystem&&(t.particlesystem.drawOrder=e++);for(var s=t.children,r=0;r255&&(t=255),this._priority!==t&&(this._priority=t,this.syncDrawOrder())}}])}(Gm),nx=function(){this.enabled=!0},sx=["enabled"],rx=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="screen",i.ComponentType=ix,i.DataType=nx,i.schema=sx,i.windowResolution=new Mt,i._drawOrderSyncQueue=new nt,i.app.graphicsDevice.on("resizecanvas",i._onResize,i),i.app.systems.on("update",i._onUpdate,i),i.on("beforeremove",i.onRemoveComponent,i),i}x(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){void 0!==i.priority&&(e.priority=i.priority),void 0!==i.screenSpace&&(e.screenSpace=i.screenSpace),e.cull=e.screenSpace,void 0!==i.scaleMode&&(e.scaleMode=i.scaleMode),void 0!==i.scaleBlend&&(e.scaleBlend=i.scaleBlend),void 0!==i.resolution&&(i.resolution instanceof Mt?e._resolution.copy(i.resolution):e._resolution.set(i.resolution[0],i.resolution[1]),e.resolution=e._resolution),void 0!==i.referenceResolution&&(i.referenceResolution instanceof Mt?e._referenceResolution.copy(i.referenceResolution):e._referenceResolution.set(i.referenceResolution[0],i.referenceResolution[1]),e.referenceResolution=e._referenceResolution),e.syncDrawOrder(),t.prototype.initializeComponentData.call(this,e,i,n)},i.destroy=function(){t.prototype.destroy.call(this),this.app.graphicsDevice.off("resizecanvas",this._onResize,this),this.app.systems.off("update",this._onUpdate,this)},i._onUpdate=function(t){var e=this.store;for(var i in e)e[i].entity.screen.update&&e[i].entity.screen.update(t)},i._onResize=function(t,e){this.windowResolution.x=t,this.windowResolution.y=e},i.cloneComponent=function(t,e){var i=t.screen;return this.addComponent(e,{enabled:i.enabled,screenSpace:i.screenSpace,scaleMode:i.scaleMode,resolution:i.resolution.clone(),referenceResolution:i.referenceResolution.clone()})},i.onRemoveComponent=function(t,e){e.onRemove()},i.processDrawOrderSyncQueue=function(){for(var t=this._drawOrderSyncQueue.list(),e=0;e=0&&this.instancesWithUpdate.splice(s,1)}if(n.fixedUpdate){var r=this.instancesWithFixedUpdate.indexOf(n);r>=0&&this.instancesWithFixedUpdate.splice(r,1)}if(n.postUpdate){var a=this.instancesWithPostUpdate.indexOf(n);a>=0&&this.instancesWithPostUpdate.splice(a,1)}if(n.toolsUpdate){var o=this.instancesWithToolsUpdate.indexOf(n);o>=0&&this.instancesWithToolsUpdate.splice(o,1)}t.instances[i].instance===t[i]&&delete t[i],delete t.instances[i]}},i._postInitializeScriptComponent=function(t){this._callInstancesMethod(t,cx),t.data.postInitialized=!0},i._updateInstances=function(t,e,i){for(var n=0,s=e.length;nthis.dragThreshold||Math.abs(i)>this.dragThreshold)&&this._disableContentInput()}},i._onSetContentOrViewportSize=function(){this._syncAll()},i._onSetHorizontalScrollbarValue=function(t){!this._scrollbarUpdateFlags[0]&&this.enabled&&this.entity.enabled&&this._onSetScroll(t,null)},i._onSetVerticalScrollbarValue=function(t){!this._scrollbarUpdateFlags[1]&&this.enabled&&this.entity.enabled&&this._onSetScroll(null,t)},i._onSetHorizontalScrollingEnabled=function(){this._syncScrollbarEnabledState(0)},i._onSetVerticalScrollingEnabled=function(){this._syncScrollbarEnabledState(1)},i._onHorizontalScrollbarGain=function(){this._syncScrollbarEnabledState(0),this._syncScrollbarPosition(0)},i._onVerticalScrollbarGain=function(){this._syncScrollbarEnabledState(1),this._syncScrollbarPosition(1)},i._onSetScroll=function(t,e,i){!1!==i&&this._velocity.set(0,0,0);var n=this._updateAxis(t,"x",0),s=this._updateAxis(e,"y",1);(n||s)&&this.fire("set:scroll",this._scroll)},i._updateAxis=function(t,e,i){var n=null!==t&&Math.abs(t-this._scroll[e])>1e-5;return(n||this._isDragging()||0===t)&&(this._scroll[e]=this._determineNewScrollValue(t,e,i),this._syncContentPosition(i),this._syncScrollbarPosition(i)),n},i._determineNewScrollValue=function(t,e,i){if(!this._getScrollingEnabled(i))return this._scroll[e];switch(this.scrollMode){case 0:return ft.clamp(t,0,this._getMaxScrollValue(i));case 1:return this._setVelocityFromOvershoot(t,e,i),t;case 2:return t;default:return console.warn("Unhandled scroll mode:"+this.scrollMode),t}},i._syncAll=function(){this._syncContentPosition(0),this._syncContentPosition(1),this._syncScrollbarPosition(0),this._syncScrollbarPosition(1),this._syncScrollbarEnabledState(0),this._syncScrollbarEnabledState(1)},i._syncContentPosition=function(t){var e=this._getAxis(t),i=this._getSign(t),n=this._contentReference.entity;if(n){var s=this._prevContentSizes[t],r=this._getContentSize(t);if(null!==s&&Math.abs(s-r)>1e-4){var a=this._getMaxOffset(t,s),o=this._getMaxOffset(t,r);this._scroll[e]=0===o?1:ft.clamp(this._scroll[e]*a/o,0,1)}var h=this._scroll[e]*this._getMaxOffset(t),l=n.getLocalPosition();l[e]=h*i,n.setLocalPosition(l),this._prevContentSizes[t]=r}},i._syncScrollbarPosition=function(t){var e=this._getAxis(t),i=this._scrollbarReferences[t].entity;i&&i.scrollbar&&(this._scrollbarUpdateFlags[t]=!0,i.scrollbar.value=this._scroll[e],i.scrollbar.handleSize=this._getScrollbarHandleSize(e,t),this._scrollbarUpdateFlags[t]=!1)},i._syncScrollbarEnabledState=function(t){var e=this._scrollbarReferences[t].entity;if(e){var i=this._getScrollingEnabled(t),n=this._getScrollbarVisibility(t);switch(n){case 0:return void(e.enabled=i);case 1:return void(e.enabled=i&&this._contentIsLargerThanViewport(t));default:console.warn("Unhandled scrollbar visibility:"+n),e.enabled=i}}},i._contentIsLargerThanViewport=function(t){return this._getContentSize(t)>this._getViewportSize(t)},i._contentPositionToScrollValue=function(t){var e=this._getMaxOffset(0),i=this._getMaxOffset(1);return Ex.x=0===e?0:t.x/e,Ex.y=0===i?0:t.y/-i,Ex},i._getMaxOffset=function(t,e){e=void 0===e?this._getContentSize(t):e;var i=this._getViewportSize(t);return e1e-4||Math.abs(this._velocity.y)>1e-4){var t=this._contentReference.entity.getLocalPosition();t.x+=this._velocity.x,t.y+=this._velocity.y,this._contentReference.entity.setLocalPosition(t),this._setScrollFromContentPosition(t)}this._velocity.x*=1-this.friction,this._velocity.y*=1-this.friction}},i._hasOvershoot=function(t,e){return Math.abs(this._toOvershoot(this.scroll[t],e))>.001},i._toOvershoot=function(t,e){var i=this._getMaxScrollValue(e);return t<0?t:t>i?t-i:0},i._setVelocityFromOvershoot=function(t,e,i){var n=this._toOvershoot(t,i)*this._getMaxOffset(i)*this._getSign(i);Math.abs(n)>0&&(this._velocity[e]=-n/(50*this.bounceAmount+1))},i._setVelocityFromContentPositionDelta=function(t){this._prevContentDragPosition?(this._velocity.sub2(t,this._prevContentDragPosition),this._prevContentDragPosition.copy(t)):(this._velocity.set(0,0,0),this._prevContentDragPosition=t.clone())},i._setScrollFromContentPosition=function(t){var e=this._contentPositionToScrollValue(t);this._isDragging()&&(e=this._applyScrollValueTension(e)),this._onSetScroll(e.x,e.y,!1)},i._applyScrollValueTension=function(t){var e=this._getMaxScrollValue(0),i=this._toOvershoot(t.x,0);return i>0?t.x=e+1*Math.log10(1+i):i<0&&(t.x=-1*Math.log10(1-i)),e=this._getMaxScrollValue(1),(i=this._toOvershoot(t.y,1))>0?t.y=e+1*Math.log10(1+i):i<0&&(t.y=-1*Math.log10(1-i)),t},i._isDragging=function(){return this._contentDragHelper&&this._contentDragHelper.isDragging},i._setScrollbarComponentsEnabled=function(t){this._scrollbarReferences[0].hasComponent("scrollbar")&&(this._scrollbarReferences[0].entity.scrollbar.enabled=t),this._scrollbarReferences[1].hasComponent("scrollbar")&&(this._scrollbarReferences[1].entity.scrollbar.enabled=t)},i._setContentDraggingEnabled=function(t){this._contentDragHelper&&(this._contentDragHelper.enabled=t)},i._onMouseWheel=function(t){if(this.useMouseWheel){var e=t.event,i=e.deltaX/this._contentReference.entity.element.calculatedWidth*this.mouseWheelSensitivity.x,n=e.deltaY/this._contentReference.entity.element.calculatedHeight*this.mouseWheelSensitivity.y,s=ft.clamp(this._scroll.x+i,0,this._getMaxScrollValue(0)),r=ft.clamp(this._scroll.y+n,0,this._getMaxScrollValue(1));this.scroll=new Mt(s,r)}},i._enableContentInput=function(){for(;this._disabledContentInputEntities.length;){var t=this._disabledContentInputEntities.pop();t.element&&(t.element.useInput=!0)}this._disabledContentInput=!1},i._disableContentInput=function(){var t=this,e=function(i){i.element&&i.element.useInput&&(t._disabledContentInputEntities.push(i),i.element.useInput=!1);for(var n=i.children,s=0,r=n.length;s1e-5&&(this.data.value=ft.clamp(i,0,1),this._updateHandlePositionAndSize(),this.fire("set:value",this.data.value))},i._onSetHandleSize=function(t,e,i){Math.abs(i-e)>1e-5&&(this.data.handleSize=ft.clamp(i,0,1),this._updateHandlePositionAndSize())},i._onSetHandleAlignment=function(){this._updateHandlePositionAndSize()},i._onSetOrientation=function(t,e,i){i!==e&&this._handleReference.hasComponent("element")&&(this._handleReference.entity.element[this._getOppositeDimension()]=0)},i._updateHandlePositionAndSize=function(){var t=this._handleReference.entity,e=t&&t.element;if(t){var i=t.getLocalPosition();i[this._getAxis()]=this._getHandlePosition(),this._handleReference.entity.setLocalPosition(i)}e&&(e[this._getDimension()]=this._getHandleLength())},i._handlePositionToScrollValue=function(t){return t*this._getSign()/this._getUsableTrackLength()},i._scrollValueToHandlePosition=function(t){return t*this._getSign()*this._getUsableTrackLength()},i._getUsableTrackLength=function(){return Math.max(this._getTrackLength()-this._getHandleLength(),.001)},i._getTrackLength=function(){return this.entity.element?0===this.orientation?this.entity.element.calculatedWidth:this.entity.element.calculatedHeight:0},i._getHandleLength=function(){return this._getTrackLength()*this.handleSize},i._getHandlePosition=function(){return this._scrollValueToHandlePosition(this.value)},i._getSign=function(){return 0===this.orientation?1:-1},i._getAxis=function(){return 0===this.orientation?"x":"y"},i._getDimension=function(){return 0===this.orientation?"width":"height"},i._getOppositeDimension=function(){return 0===this.orientation?"height":"width"},i._destroyDragHelper=function(){this._handleDragHelper&&this._handleDragHelper.destroy()},i._setHandleDraggingEnabled=function(t){this._handleDragHelper&&(this._handleDragHelper.enabled=t)},i.onEnable=function(){this._handleReference.onParentComponentEnable(),this._setHandleDraggingEnabled(!0)},i.onDisable=function(){this._setHandleDraggingEnabled(!1)},i.onRemove=function(){this._destroyDragHelper(),this._toggleLifecycleListeners("off")},v(e,[{key:"data",get:function(){var t=this.system.store[this.entity.getGuid()];return t?t.data:null}},{key:"enabled",get:function(){return this.data.enabled},set:function(t){this._setValue("enabled",t)}},{key:"orientation",get:function(){return this.data.orientation},set:function(t){this._setValue("orientation",t)}},{key:"value",get:function(){return this.data.value},set:function(t){this._setValue("value",t)}},{key:"handleSize",get:function(){return this.data.handleSize},set:function(t){this._setValue("handleSize",t)}},{key:"handleEntity",get:function(){return this.data.handleEntity},set:function(t){this._setValue("handleEntity",t)}}])}(Gm);Rx.EVENT_SETVALUE="set:value";var Ix=function(){this.enabled=!0,this.orientation=0,this.value=0,this.handleSize=void 0,this.handleEntity=void 0},Dx=[{name:"enabled",type:"boolean"},{name:"orientation",type:"number"},{name:"value",type:"number"},{name:"handleSize",type:"number"},{name:"handleEntity",type:"entity"}],Lx=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="scrollbar",i.ComponentType=Rx,i.DataType=Ix,i.schema=Dx,i.on("beforeremove",i._onRemoveComponent,i),i}x(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){t.prototype.initializeComponentData.call(this,e,i,Dx)},i._onRemoveComponent=function(t,e){e.onRemove()},e}(Hm),kx={volume:0,pitch:0,loop:!1,startTime:0,duration:0,position:new wt,maxDistance:0,refDistance:0,rollOffFactor:0,distanceModel:0,onPlay:null,onPause:null,onResume:null,onStop:null,onEnd:null},Ox=function(t){function e(e,i,n){var s;return void 0===i&&(i="Untitled"),void 0===n&&(n={}),(s=t.call(this)||this).name=void 0,s.instances=[],s._component=e,s._assets=e.system.app.assets,s._manager=e.system.manager,s.name=i,s._volume=void 0!==n.volume?ft.clamp(Number(n.volume)||0,0,1):1,s._pitch=void 0!==n.pitch?Math.max(.01,Number(n.pitch)||0):1,s._loop=!(void 0===n.loop||!n.loop),s._duration=n.duration>0?n.duration:null,s._startTime=Math.max(0,Number(n.startTime)||0),s._overlap=!!n.overlap,s._autoPlay=!!n.autoPlay,s._firstNode=null,s._lastNode=null,s._asset=n.asset,s._asset instanceof om&&(s._asset=s._asset.id),s._onInstancePlayHandler=s._onInstancePlay.bind(s),s._onInstancePauseHandler=s._onInstancePause.bind(s),s._onInstanceResumeHandler=s._onInstanceResume.bind(s),s._onInstanceStopHandler=s._onInstanceStop.bind(s),s._onInstanceEndHandler=s._onInstanceEnd.bind(s),s}x(e,t);var i=e.prototype;return i.play=function(){if(this.overlap||this.stop(),this.isLoaded||this._hasAsset()){var t=this._createInstance();if(this.instances.push(t),this.isLoaded)t.play();else{var e=function(e){var i=t._playWhenLoaded;t.sound=e,i&&t.play()};this.off("load",e),this.once("load",e),this.load()}return t}},i.pause=function(){for(var t=!1,e=this.instances,i=0,n=e.length;i=0;r--){var a=s[r].isPlaying||s[r].isSuspended,o=s[r].currentTime;a&&s[r].stop();var h=n._createInstance();a&&(h.play(),h.currentTime=o),s.push(h)}}}},{key:"slots",get:function(){return this._slots},set:function(t){var e=this._slots;if(e)for(var i in e)e[i].stop();var n={};for(var s in t)t[s]instanceof Ox?n[t[s].name]=t[s]:t[s].name&&(n[t[s].name]=new Ox(this,t[s].name,t[s]));this._slots=n,this.enabled&&this.entity.enabled&&this.onEnable()}}])}(Gm);Fx.EVENT_PLAY="play",Fx.EVENT_PAUSE="pause",Fx.EVENT_RESUME="resume",Fx.EVENT_STOP="stop",Fx.EVENT_END="end";var Bx=function(){this.enabled=!0},Nx=["enabled"],Ux=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="sound",i.ComponentType=Fx,i.DataType=Bx,i.schema=Nx,i.manager=e.soundManager,i.app.systems.on("update",i.onUpdate,i),i.on("beforeremove",i.onBeforeRemove,i),i}x(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){n=["volume","pitch","positional","refDistance","maxDistance","rollOffFactor","distanceModel","slots"];for(var s=0;sn||i<0;this._setTime(i);var r=this.frame;(r=this._sprite?Math.floor(this._sprite.frameKeys.length*this._time/n):0)!==this._frame&&this._setFrame(r),s&&(this.loop?(this.fire("loop"),this._component.fire("loop",this)):(this._playing=!1,this._paused=!1,this.fire("end"),this._component.fire("end",this)))}},i._setTime=function(t){this._time=t;var e=this.duration;this._time<0?this.loop?this._time=this._time%e+e:this._time=0:this._time>e&&(this.loop?this._time%=e:this._time=e)},i._setFrame=function(t){this._sprite?this._frame=ft.clamp(t,0,this._sprite.frameKeys.length-1):this._frame=t,this._component.currentClip===this&&this._component._showFrame(this._frame)},i._destroy=function(){if(this._spriteAsset){var t=this._component.system.app.assets;this._unbindSpriteAsset(t.get(this._spriteAsset))}this._sprite&&(this.sprite=null),this._spriteAsset&&(this.spriteAsset=null)},i.play=function(){this._playing||(this._playing=!0,this._paused=!1,this.frame=0,this.fire("play"),this._component.fire("play",this))},i.pause=function(){this._playing&&!this._paused&&(this._paused=!0,this.fire("pause"),this._component.fire("pause",this))},i.resume=function(){this._paused&&(this._paused=!1,this.fire("resume"),this._component.fire("resume",this))},i.stop=function(){this._playing&&(this._playing=!1,this._paused=!1,this._time=0,this.frame=0,this.fire("stop"),this._component.fire("stop",this))},v(e,[{key:"duration",get:function(){if(this._sprite){var t=this.fps||Number.MIN_VALUE;return this._sprite.frameKeys.length/Math.abs(t)}return 0}},{key:"frame",get:function(){return this._frame},set:function(t){this._setFrame(t);var e=this.fps||Number.MIN_VALUE;this._setTime(this._frame/e)}},{key:"isPaused",get:function(){return this._paused}},{key:"isPlaying",get:function(){return this._playing}},{key:"sprite",get:function(){return this._sprite},set:function(t){var e,i;this._sprite&&(null==(e=this._evtSetMeshes)||e.off(),this._evtSetMeshes=null,this._sprite.off("set:pixelsPerUnit",this._onSpritePpuChanged,this),this._sprite.off("set:atlas",this._onSpriteMeshesChange,this),this._sprite.atlas&&this._sprite.atlas.off("set:texture",this._onSpriteMeshesChange,this));(this._sprite=t,this._sprite&&(this._evtSetMeshes=this._sprite.on("set:meshes",this._onSpriteMeshesChange,this),this._sprite.on("set:pixelsPerUnit",this._onSpritePpuChanged,this),this._sprite.on("set:atlas",this._onSpriteMeshesChange,this),this._sprite.atlas&&this._sprite.atlas.on("set:texture",this._onSpriteMeshesChange,this)),this._component.currentClip===this)&&(t&&t.atlas?(t.atlas.texture&&((i=this._component._meshInstance)&&(i.setParameter("texture_emissiveMap",t.atlas.texture),i.setParameter("texture_opacityMap",t.atlas.texture)),this._component.enabled&&this._component.entity.enabled&&this._component._showModel()),this.time&&this.fps?this.time=this.time:this.frame=this.frame):((i=this._component._meshInstance)&&(i.deleteParameter("texture_emissiveMap"),i.deleteParameter("texture_opacityMap")),this._component._hideModel()))}},{key:"spriteAsset",get:function(){return this._spriteAsset},set:function(t){var e=this._component.system.app.assets,i=t;if(t instanceof om&&(i=t.id),this._spriteAsset!==i){if(this._spriteAsset){var n=e.get(this._spriteAsset);n&&this._unbindSpriteAsset(n)}if(this._spriteAsset=i,this._spriteAsset){var s=e.get(this._spriteAsset);s?this._bindSpriteAsset(s):(this.sprite=null,e.on("add:"+this._spriteAsset,this._onSpriteAssetAdded,this))}else this.sprite=null}}},{key:"time",get:function(){return this._time},set:function(t){this._setTime(t),this._sprite?this.frame=Math.min(this._sprite.frameKeys.length-1,Math.floor(this._time*Math.abs(this.fps))):this.frame=0}}])}(P);Gx.EVENT_PLAY="play",Gx.EVENT_PAUSE="pause",Gx.EVENT_RESUME="resume",Gx.EVENT_STOP="stop",Gx.EVENT_END="end",Gx.EVENT_LOOP="loop";var Hx="texture_emissiveMap",Wx="texture_opacityMap",Xx="material_emissive",jx="material_opacity",qx=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._evtLayersChanged=null,n._evtLayerAdded=null,n._evtLayerRemoved=null,n._type=zx,n._material=e.defaultMaterial,n._color=new pt(1,1,1,1),n._colorUniform=new Float32Array(3),n._speed=1,n._flipX=!1,n._flipY=!1,n._width=1,n._height=1,n._drawOrder=0,n._layers=[0],n._outerScale=new Mt(1,1),n._outerScaleUniform=new Float32Array(2),n._innerOffset=new Rt,n._innerOffsetUniform=new Float32Array(4),n._atlasRect=new Rt,n._atlasRectUniform=new Float32Array(4),n._batchGroupId=-1,n._batchGroup=null,n._node=new Rh,n._model=new wd,n._model.graph=n._node,n._meshInstance=null,i.addChild(n._model.graph),n._model._entity=i,n._updateAabbFunc=n._updateAabb.bind(n),n._addedModel=!1,n._autoPlayClip=null,n._clips={},n._defaultClip=new Gx(n,{name:n.entity.name,fps:0,loop:!1,spriteAsset:null}),n._currentClip=n._defaultClip,n}x(e,t);var i=e.prototype;return i.onEnable=function(){var t,e=this.system.app,i=e.scene,n=i.layers;(this._evtLayersChanged=i.on("set:layers",this._onLayersChanged,this),n&&(this._evtLayerAdded=n.on("add",this._onLayerAdded,this),this._evtLayerRemoved=n.on("remove",this._onLayerRemoved,this)),this._showModel(),this._autoPlayClip&&this._tryAutoPlay(),this._batchGroupId>=0)&&(null==(t=e.batcher)||t.insert(sh.SPRITE,this._batchGroupId,this.entity))},i.onDisable=function(){var t,e,i,n,s=this.system.app,r=s.scene.layers;(null==(t=this._evtLayersChanged)||t.off(),this._evtLayersChanged=null,r)&&(null==(e=this._evtLayerAdded)||e.off(),this._evtLayerAdded=null,null==(i=this._evtLayerRemoved)||i.off(),this._evtLayerRemoved=null);(this.stop(),this._hideModel(),this._batchGroupId>=0)&&(null==(n=s.batcher)||n.remove(sh.SPRITE,this._batchGroupId,this.entity))},i.onDestroy=function(){var t;for(var e in this._currentClip=null,this._defaultClip&&(this._defaultClip._destroy(),this._defaultClip=null),this._clips)this._clips[e]._destroy();this._clips=null,this._hideModel(),this._model=null,null==(t=this._node)||t.remove(),this._node=null,this._meshInstance&&(this._meshInstance.material=null,this._meshInstance.mesh=null,this._meshInstance=null)},i._showModel=function(){if(!this._addedModel&&this._meshInstance){for(var t=[this._meshInstance],e=0,i=this._layers.length;e=0)null==(e=this.system.app.batcher)||e.remove(sh.SPRITE,n,this.entity);if(this.entity.enabled&&t>=0)null==(i=this.system.app.batcher)||i.insert(sh.SPRITE,t,this.entity);else n>=0&&this._currentClip&&this._currentClip.sprite&&this.enabled&&this.entity.enabled&&this._showModel()}}},{key:"autoPlayClip",get:function(){return this._autoPlayClip},set:function(t){this._autoPlayClip=t instanceof Gx?t.name:t,this._tryAutoPlay()}},{key:"drawOrder",get:function(){return this._drawOrder},set:function(t){this._drawOrder=t,this._meshInstance&&(this._meshInstance.drawOrder=t)}},{key:"layers",get:function(){return this._layers},set:function(t){this._addedModel&&this._hideModel(),this._layers=t,this._meshInstance&&this.enabled&&this.entity.enabled&&this._showModel()}},{key:"aabb",get:function(){return this._meshInstance?this._meshInstance.aabb:null}}])}(Gm);qx.EVENT_PLAY="play",qx.EVENT_PAUSE="pause",qx.EVENT_RESUME="resume",qx.EVENT_STOP="stop",qx.EVENT_END="end",qx.EVENT_LOOP="loop";var Yx=function(){this.enabled=!0},Kx=["enabled"],Zx=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="sprite",i.ComponentType=qx,i.DataType=Yx,i.schema=Kx,i._defaultTexture=null,i._defaultMaterial=null,i._default9SlicedMaterialSlicedMode=null,i._default9SlicedMaterialTiledMode=null,i.app.systems.on("update",i.onUpdate,i),i.on("beforeremove",i.onBeforeRemove,i),i}x(e,t);var i=e.prototype;return i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("update",this.onUpdate,this),this._defaultTexture&&(this._defaultTexture.destroy(),this._defaultTexture=null)},i.initializeComponentData=function(e,i,n){if(void 0!==i.enabled&&(e.enabled=i.enabled),e.type=i.type,i.layers&&Array.isArray(i.layers)&&(e.layers=i.layers.slice(0)),void 0!==i.drawOrder&&(e.drawOrder=i.drawOrder),void 0!==i.color){var s,r;if(i.color instanceof pt)e.color.set(i.color.r,i.color.g,i.color.b,null!=(s=i.opacity)?s:1);else e.color.set(i.color[0],i.color[1],i.color[2],null!=(r=i.opacity)?r:1);e.color=e.color}if(void 0!==i.opacity&&(e.opacity=i.opacity),void 0!==i.flipX&&(e.flipX=i.flipX),void 0!==i.flipY&&(e.flipY=i.flipY),void 0!==i.width&&(e.width=i.width),void 0!==i.height&&(e.height=i.height),void 0!==i.spriteAsset&&(e.spriteAsset=i.spriteAsset),i.sprite&&(e.sprite=i.sprite),void 0!==i.frame&&(e.frame=i.frame),i.clips)for(var a in i.clips)e.addClip(i.clips[a]);void 0!==i.speed&&(e.speed=i.speed),i.autoPlayClip&&(e.autoPlayClip=i.autoPlayClip),e.batchGroupId=void 0===i.batchGroupId||null===i.batchGroupId?-1:i.batchGroupId,t.prototype.initializeComponentData.call(this,e,i,n)},i.cloneComponent=function(t,e){var i=t.sprite;return this.addComponent(e,{enabled:i.enabled,type:i.type,spriteAsset:i.spriteAsset,sprite:i.sprite,width:i.width,height:i.height,frame:i.frame,color:i.color.clone(),opacity:i.opacity,flipX:i.flipX,flipY:i.flipY,speed:i.speed,clips:i.clips,autoPlayClip:i.autoPlayClip,batchGroupId:i.batchGroupId,drawOrder:i.drawOrder,layers:i.layers.slice(0)})},i.onUpdate=function(t){var e=this.store;for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];if(n.data.enabled&&n.entity.enabled){var s=n.entity.sprite;s._currentClip&&s._currentClip._update(t)}}},i.onBeforeRemove=function(t,e){e.onDestroy()},v(e,[{key:"defaultMaterial",get:function(){if(!this._defaultMaterial){var t=new or(this.app.graphicsDevice,{width:1,height:1,format:7,name:"sprite"}),e=new Uint8Array(t.lock());e[0]=e[1]=e[2]=e[3]=255,t.unlock();var i=new Lc;i.diffuse.set(0,0,0),i.emissive.set(.5,.5,.5),i.emissiveMap=t,i.emissiveTint=!0,i.opacityMap=t,i.opacityMapChannel="a",i.opacityTint=!0,i.opacity=0,i.useLighting=!1,i.useGammaTonemap=!1,i.useFog=!1,i.useSkybox=!1,i.blendType=4,i.depthWrite=!1,i.pixelSnap=!1,i.cull=0,i.update(),this._defaultTexture=t,this._defaultMaterial=i}return this._defaultMaterial},set:function(t){this._defaultMaterial=t}},{key:"default9SlicedMaterialSlicedMode",get:function(){if(!this._default9SlicedMaterialSlicedMode){var t=this.defaultMaterial.clone();t.nineSlicedMode=1,t.update(),this._default9SlicedMaterialSlicedMode=t}return this._default9SlicedMaterialSlicedMode},set:function(t){this._default9SlicedMaterialSlicedMode=t}},{key:"default9SlicedMaterialTiledMode",get:function(){if(!this._default9SlicedMaterialTiledMode){var t=this.defaultMaterial.clone();t.nineSlicedMode=2,t.update(),this._default9SlicedMaterialTiledMode=t}return this._default9SlicedMaterialTiledMode},set:function(t){this._default9SlicedMaterialTiledMode=t}}])}(Hm);Gm._buildAccessors(qx.prototype,Kx);var Qx=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._oldState=!0,n._size=new wt,n.on("set_enabled",n._onSetEnabled,n),n}x(e,t);var i=e.prototype;return i.onEnable=function(){this._checkState()},i.onDisable=function(){this._checkState()},i._onSetEnabled=function(t,e,i){this._checkState()},i._checkState=function(){var t=this.enabled&&this.entity.enabled;t!==this._oldState&&(this._oldState=t,this.fire("enable"),this.fire("state",this.enabled))},i._onBeforeRemove=function(){this.fire("remove")},v(e,[{key:"size",get:function(){return this._size},set:function(t){t instanceof wt?this._size.copy(t):t instanceof Array&&t.length>=3&&this.size.set(t[0],t[1],t[2])}}])}(Gm);Qx.EVENT_ENABLE="enable",Qx.EVENT_DISABLE="disable",Qx.EVENT_STATE="state",Qx.EVENT_REMOVE="remove";var Jx=function(){this.enabled=!0},$x=["enabled"],tS=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="zone",i.ComponentType=Qx,i.DataType=Jx,i.schema=$x,i.on("beforeremove",i._onBeforeRemove,i),i}x(e,t);var i=e.prototype;return i.initializeComponentData=function(t,e,i){t.enabled=!e.hasOwnProperty("enabled")||!!e.enabled,e.size&&(e.size instanceof wt?t.size.copy(e.size):e.size instanceof Array&&e.size.length>=3&&t.size.set(e.size[0],e.size[1],e.size[2]))},i.cloneComponent=function(t,e){var i={size:t.zone.size};return this.addComponent(e,i)},i._onBeforeRemove=function(t,e){e._onBeforeRemove()},e}(Hm);Gm._buildAccessors(Qx.prototype,$x);var eS=function(t,e){this.effect=t,this.inputTarget=e,this.outputTarget=null,this.name=t.constructor.name},iS=function(){function t(t,e){this.app=t,this.camera=e,this.destinationRenderTarget=null,this.effects=[],this.enabled=!1,this.depthTarget=null,e.on("set:rect",this.onCameraRectChanged,this)}var e=t.prototype;return e._allocateColorBuffer=function(t,e){var i,n,s=this.camera.rect,r=this.destinationRenderTarget,a=this.app.graphicsDevice,o=Math.floor(s.z*(null!=(i=null==r?void 0:r.width)?i:a.width)),h=Math.floor(s.w*(null!=(n=null==r?void 0:r.height)?n:a.height));return new or(a,{name:e,format:t,width:o,height:h,mipmaps:!1,minFilter:0,magFilter:0,addressU:1,addressV:1})},e._createOffscreenTarget=function(t,e){var i=this.app.graphicsDevice,n=e&&i.getRenderableHdrFormat([me,ve],!0)||7,s=this.camera.entity.name+"-posteffect-"+this.effects.length,r=this._allocateColorBuffer(n,s);return new Cn({colorBuffer:r,depth:t,stencil:t&&this.app.graphicsDevice.supportsStencil,samples:t?i.samples:1})},e._resizeOffscreenTarget=function(t){var e=t.colorBuffer.format,i=t.colorBuffer.name;t.destroyFrameBuffers(),t.destroyTextureBuffers(),t._colorBuffer=this._allocateColorBuffer(e,i),t._colorBuffers=[t._colorBuffer]},e._destroyOffscreenTarget=function(t){t.destroyTextureBuffers(),t.destroy()},e.addEffect=function(t){var e=this.effects,i=0===e.length,n=this._createOffscreenTarget(i,t.hdr),s=new eS(t,n);e.push(s),this._sourceTarget=s.inputTarget,e.length>1&&(e[e.length-2].outputTarget=s.inputTarget),this._newPostEffect=t,t.needsDepthBuffer&&this._requestDepthMap(),this.enable(),this._newPostEffect=void 0},e.removeEffect=function(t){for(var e=-1,i=0,n=this.effects.length;i=0&&(e>0?this.effects[e-1].outputTarget=e+11&&(this.effects[1].inputTarget._depth||(this._destroyOffscreenTarget(this.effects[1].inputTarget),this.effects[1].inputTarget=this._createOffscreenTarget(!0,this.effects[1].hdr),this._sourceTarget=this.effects[1].inputTarget),this.camera.renderTarget=this.effects[1].inputTarget),this._destroyOffscreenTarget(this.effects[e].inputTarget),this.effects.splice(e,1)),this.enabled&&t.needsDepthBuffer&&this._releaseDepthMap(),0===this.effects.length&&this.disable()},e._requestDepthMaps=function(){for(var t=0,e=this.effects.length;t0},set:function(t){t&&!this._sceneColorMapRequested?(this.requestSceneColorMap(!0),this._sceneColorMapRequested=!0):this._sceneColorMapRequested&&(this.requestSceneColorMap(!1),this._sceneColorMapRequested=!1)}},{key:"renderSceneDepthMap",get:function(){return this._renderSceneDepthMap>0},set:function(t){t&&!this._sceneDepthMapRequested?(this.requestSceneDepthMap(!0),this._sceneDepthMapRequested=!0):this._sceneDepthMapRequested&&(this.requestSceneDepthMap(!1),this._sceneDepthMapRequested=!1)}},{key:"renderTarget",get:function(){return this._camera.renderTarget},set:function(t){this._camera.renderTarget=t,this.dirtyLayerCompositionCameras()}},{key:"scissorRect",get:function(){return this._camera.scissorRect},set:function(t){this._camera.scissorRect=t}},{key:"sensitivity",get:function(){return this._camera.sensitivity},set:function(t){this._camera.sensitivity=t}},{key:"shutter",get:function(){return this._camera.shutter},set:function(t){this._camera.shutter=t}},{key:"viewMatrix",get:function(){return this._camera.viewMatrix}}])}(Gm),sS=function(){this.enabled=!0},rS=["enabled"],aS=function(t){function e(e){var i;return(i=t.call(this,e)||this).cameras=[],i.id="camera",i.ComponentType=nS,i.DataType=sS,i.schema=rS,i.on("beforeremove",i.onBeforeRemove,i),i.app.on("prerender",i.onAppPrerender,i),i.app.systems.on("update",i.onUpdate,i),i}x(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){n=["aspectRatio","aspectRatioMode","calculateProjection","calculateTransform","clearColor","clearColorBuffer","clearDepthBuffer","clearStencilBuffer","renderSceneColorMap","renderSceneDepthMap","cullFaces","farClip","flipFaces","fov","frustumCulling","horizontalFov","layers","renderTarget","nearClip","orthoHeight","projection","priority","rect","scissorRect","aperture","shutter","sensitivity"];for(var s=0;s=0&&(this.cameras.splice(e,1),ud(this.cameras))},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("update",this.onUpdate,this)},e}(Hm);Gm._buildAccessors(nS.prototype,rS);var oS=function(){this.enabled=!0,this.light=void 0,this.type="directional",this.color=new pt(1,1,1),this.intensity=1,this.luminance=0,this.shape=0,this.affectSpecularity=!0,this.castShadows=!1,this.shadowDistance=40,this.shadowIntensity=1,this.shadowResolution=1024,this.shadowBias=.05,this.numCascades=1,this.bakeNumSamples=1,this.bakeArea=0,this.cascadeDistribution=.5,this.normalOffsetBias=0,this.range=10,this.innerConeAngle=40,this.outerConeAngle=45,this.falloffMode=0,this.shadowType=0,this.vsmBlurSize=11,this.vsmBlurMode=1,this.vsmBias=.0025,this.cookieAsset=null,this.cookie=null,this.cookieIntensity=1,this.cookieFalloff=!0,this.cookieChannel="rgb",this.cookieAngle=0,this.cookieScale=null,this.cookieOffset=null,this.shadowUpdateMode=2,this.mask=1,this.affectDynamic=!0,this.affectLightmapped=!1,this.bake=!1,this.bakeDir=!0,this.isStatic=!1,this.layers=[0],this.penumbraSize=1},hS=Object.keys(new oS),lS=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._evtLayersChanged=null,n._evtLayerAdded=null,n._evtLayerRemoved=null,n._cookieAsset=null,n._cookieAssetId=null,n._cookieAssetAdd=!1,n._cookieMatrix=null,n}x(e,t);var i=e.prototype;return i._setValue=function(t,e,i,n){var s=this.data,r=s[t];(n||r!==e)&&(s[t]=e,i&&i.call(this,e,r))},i.addLightToLayers=function(){for(var t=0;t=0&&this.enabled&&this.entity.enabled&&(t.addLight(this),this.light.addLayer(t))},i.onLayerRemoved=function(t){this.layers.indexOf(t.id)>=0&&(t.removeLight(this),this.light.removeLayer(t))},i.refreshProperties=function(){for(var t=0;t=3&&i.length<=4){for(var u=0;ue.ind&&(l=e.ind),this._insertScriptInstance(o,l,h),this._scriptsIndex[r]={instance:o,onSwap:function(){n.swap(r)}},this[r]=o,e.preloading||this.initializeAttributes(o),this.fire("create",r,o),this.fire("create:"+r,o),this.system.app.scripts.on("swap:"+r,this._scriptsIndex[r].onSwap),e.preloading||(o.enabled&&!o._initialized&&(o._initialized=!0,o.initialize&&this._scriptMethod(o,vS)),o.enabled&&!o._postInitialized&&(o._postInitialized=!0,o.postInitialize&&this._scriptMethod(o,gS))),o}}else this._scriptsIndex[r]={awaiting:!0,ind:this._scripts.length};return null},i.destroy=function(t){var e=t,i=t;"string"==typeof i?i=this.system.app.scripts.get(i):i&&(e=i.__name);var n=this._scriptsIndex[e];if(delete this._scriptsIndex[e],!n)return!1;this._attributeDataMap.delete(e);var s=n.instance;if(s&&!s._destroyed)if(s.enabled=!1,s._destroyed=!0,this._isLoopingThroughScripts)this._destroyedScripts.push(s);else{var r=this._removeScriptInstance(s);r>=0&&this._resetExecutionOrder(r,this._scripts.length)}return this.system.app.scripts.off("swap:"+e,n.onSwap),delete this[e],this.fire("destroy",e,s||null),this.fire("destroy:"+e,s||null),s&&s.fire("destroy"),!0},i.swap=function(t){var e=t,i=t;"string"==typeof i?i=this.system.app.scripts.get(i):i&&(e=i.__name);var n=this._scriptsIndex[e];if(!n||!n.instance)return!1;var s=n.instance,r=this._scripts.indexOf(s),a=new i({app:this.system.app,entity:this.entity,enabled:s.enabled,attributes:s.__attributes});return!!a.swap&&(this.initializeAttributes(a),this._scripts[r]=a,this._scriptsIndex[e].instance=a,this[e]=a,a.__executionOrder=r,s.update&&this._updateList.remove(s),s.postUpdate&&this._postUpdateList.remove(s),a.update&&this._updateList.insert(a),a.postUpdate&&this._postUpdateList.insert(a),this._scriptMethod(a,"swap",s),this.fire("swap",e,a),this.fire("swap:"+e,a),!0)},i.resolveDuplicatedEntityReferenceProperties=function(t,e){var i=this.entity.script;for(var n in t._scriptsIndex){var s=this.system.app.scripts.get(n);if(s){var r=t._scriptsIndex[n];if(r&&r.instance){var a=i[n].__attributesRaw,o=i[n].__attributes;if(a||o){var h=!!a,l=r.instance.__attributes;for(var c in l)if(l[c]){var u=s.attributes.get(c);if(u)if("entity"===u.type)this._resolveEntityScriptAttribute(u,c,l[c],h,a||o,e);else if("json"===u.type&&Array.isArray(u.schema))for(var d=l[c],f=a?a[c]:o[c],p=0;p=i||e<0)return!1;var n=t,s=t;"string"!=typeof s?s=t.__name:n=null;var r=this._scriptsIndex[s];if(!r||!r.instance)return!1;var a=r.instance;if(n&&!(a instanceof n))return!1;var o=this._scripts.indexOf(a);return-1!==o&&o!==e&&(this._scripts.splice(e,0,this._scripts.splice(o,1)[0]),this._resetExecutionOrder(0,i),this._updateList.sort(),this._postUpdateList.sort(),this.fire("move",s,a,e,o),this.fire("move:"+s,a,e,o),!0)},v(e,[{key:"scripts",get:function(){return this._scripts},set:function(t){var e=this;this._scriptsData=t;var i=function(){if(!t.hasOwnProperty(n))return 1;var i=e._scriptsIndex[n];if(i){if("boolean"==typeof t[n].enabled&&(i.once("preInitialize",(function(){e.initializeAttributes(i)})),i.enabled=!!t[n].enabled),"object"==typeof t[n].attributes)for(var s in t[n].attributes)if(!_S.reservedNames.has(s)){if(!i.__attributes.hasOwnProperty(s)){var r=e.system.app.scripts.get(n);r&&r.attributes.add(s,{})}i[s]=t[n].attributes[s]}}else console.log(e.order)};for(var n in t)i()}},{key:"enabled",get:function(){return this._enabled},set:function(t){var e=this._enabled;this._enabled=t,this.fire("set","enabled",e,t)}}])}(Gm);TS.EVENT_CREATE="create",TS.EVENT_DESTROY="destroy",TS.EVENT_ENABLE="enable",TS.EVENT_DISABLE="disable",TS.EVENT_REMOVE="remove",TS.EVENT_STATE="state",TS.EVENT_MOVE="move",TS.EVENT_ERROR="error";var wS=function(){this.enabled=!0},ES=0,AS=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="script",i.ComponentType=TS,i.DataType=wS,i._components=new ot({sortBy:"_executionOrder"}),i._enabledComponents=new ot({sortBy:"_executionOrder"}),i.preloading=!0,i.on("beforeremove",i._onBeforeRemove,i),i.app.systems.on("initialize",i._onInitialize,i),i.app.systems.on("postInitialize",i._onPostInitialize,i),i.app.systems.on("update",i._onUpdate,i),i.app.systems.on("postUpdate",i._onPostUpdate,i),i}x(e,t);var i=e.prototype;return i.initializeComponentData=function(t,e){if(t._executionOrder=ES++,this._components.append(t),ES>Number.MAX_SAFE_INTEGER&&this._resetExecutionOrder(),t.enabled=!e.hasOwnProperty("enabled")||!!e.enabled,t.enabled&&t.entity.enabled&&this._enabledComponents.append(t),e.hasOwnProperty("order")&&e.hasOwnProperty("scripts")){t._scriptsData=e.scripts;for(var i=0;i=0&&e._onBeforeRemove(),this._removeComponentFromEnabled(e),this._components.remove(e)},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("initialize",this._onInitialize,this),this.app.systems.off("postInitialize",this._onPostInitialize,this),this.app.systems.off("update",this._onUpdate,this),this.app.systems.off("postUpdate",this._onPostUpdate,this)},e}(Hm),CS=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._layers=[0],n._instance=null,n._customAabb=null,n._assetReference=void 0,n._materialOptions=null,n._evtLayersChanged=null,n._evtLayerAdded=null,n._evtLayerRemoved=null,n._assetReference=new Py("asset",n,e.app.assets,{add:n._onGSplatAssetAdded,load:n._onGSplatAssetLoad,remove:n._onGSplatAssetRemove,unload:n._onGSplatAssetUnload},n),i.on("remove",n.onRemoveChild,n),i.on("removehierarchy",n.onRemoveChild,n),i.on("insert",n.onInsertChild,n),i.on("inserthierarchy",n.onInsertChild,n),n}x(e,t);var i=e.prototype;return i.assignAsset=function(t){var e=t instanceof om?t.id:t;this._assetReference.id=e},i.destroyInstance=function(){var t;this._instance&&(this.removeFromLayers(),null==(t=this._instance)||t.destroy(),this._instance=null)},i.addToLayers=function(){var t,e=null==(t=this.instance)?void 0:t.meshInstance;if(e)for(var i=this.system.app.scene.layers,n=0;n0){var r=e.jobQueue.shift();e.run(t,r)}else{var a=e.workers[2].indexOf(t);if(-1!==a)e.workers[2].splice(a,1),e.workers[1].push(t);else{var o=e.workers[1].indexOf(t);-1!==o&&(e.workers[1].splice(o,1),e.workers[0].push(t))}}}))})),this.workers[0]=t;this.jobQueue.length&&(this.workers[0].length||this.workers[1].length);){var i=this.jobQueue.shift();if(this.workers[0].length>0){var n=this.workers[0].shift();this.workers[1].push(n),this.run(n,i)}else{var s=this.workers[1].shift();this.workers[2].push(s),this.run(s,i)}}},e.enqueueJob=function(t,e){var i={jobId:this.jobId++,buffer:t};if(this.jobCallbacks.set(i.jobId,e),this.workers[0].length>0){var n=this.workers[0].shift();this.workers[1].push(n),this.run(n,i)}else if(this.workers[1].length>0){var s=this.workers[1].shift();this.workers[2].push(s),this.run(s,i)}else this.jobQueue.push(i)},t}(),WS=function(t){var e=function(){return fetch(t).then((function(t){return t.arrayBuffer()})).then((function(t){return WebAssembly.compile(t)}))};return WebAssembly.compileStreaming?WebAssembly.compileStreaming(fetch(t)).catch((function(t){return e()})):e()},XS=function(t){if(zS)return!0;if(!t)if(VS)t=VS;else{var e=rt.getConfig("DracoDecoderModule");t=e?{jsUrl:e.glueUrl,wasmUrl:e.wasmUrl,numWorkers:e.numWorkers}:{jsUrl:"draco.wasm.js",wasmUrl:"draco.wasm.wasm",numWorkers:1}}return!(!t.jsUrl||!t.wasmUrl)&&(zS=new HS,Promise.all([(i=t.jsUrl,new Promise((function(t,e){var n={cache:!0,responseType:"text",retry:!0,maxRetries:3};Qa.get(i,n,(function(i,n){i?e(i):t(n)}))}))),WS(t.wasmUrl)]).then((function(e){for(var i=e[0],n=e[1],s=["/* draco */",i,"/* worker */","(\n"+US.toString()+"\n)()\n\n"].join("\n"),r=new Blob([s],{type:"application/javascript"}),a=URL.createObjectURL(r),o=Math.max(1,Math.min(16,t.numWorkers||1)),h=[],l=0;l0&&o(n,Float32Array,1),s.length>0&&o(s,Uint16Array,65535),r.length>0&&o(r,Uint8Array,255)}(y),y.unlock(),y},ob=function(t,e,i,n,s,r,a){var o,h=new dh(t);h.aabb=ib(i[e.attributes.POSITION]);for(var l=[],c=0,u=Object.entries(e.attributes);c0?i.name=t.name:i.name="node_"+e,t.hasOwnProperty("matrix")&&(bb.data.set(t.matrix),bb.getTranslation(Tb),i.setLocalPosition(Tb),bb.getEulerAngles(Tb),i.setLocalEulerAngles(Tb),bb.getScale(Tb),i.setLocalScale(Tb)),t.hasOwnProperty("rotation")){var n=t.rotation;i.setLocalRotation(n[0],n[1],n[2],n[3])}if(t.hasOwnProperty("translation")){var s=t.translation;i.setLocalPosition(s[0],s[1],s[2])}if(t.hasOwnProperty("scale")){var r=t.scale;i.setLocalScale(r[0],r[1],r[2])}return i},Eb=function(t,e){var i="orthographic"===t.type?1:0,n=1===i?t.orthographic:t.perspective,s={enabled:!1,projection:i,nearClip:n.znear,aspectRatioMode:0};n.zfar&&(s.farClip=n.zfar),1===i?(s.orthoHeight=.5*n.ymag,n.ymag&&(s.aspectRatioMode=1,s.aspectRatio=n.xmag/n.ymag)):(s.fov=n.yfov*ft.RAD_TO_DEG,n.aspectRatio&&(s.aspectRatioMode=1,s.aspectRatio=n.aspectRatio));var r=new Sm(t.name);return r.addComponent("camera",s),r},Ab=function(t,e){var i={enabled:!1,type:"point"===t.type?"omni":t.type,color:t.hasOwnProperty("color")?new pt(t.color):pt.WHITE,range:t.hasOwnProperty("range")?t.range:9999,falloffMode:1,intensity:t.hasOwnProperty("intensity")?ft.clamp(t.intensity,0,2):1};t.hasOwnProperty("spot")&&(i.innerConeAngle=t.spot.hasOwnProperty("innerConeAngle")?t.spot.innerConeAngle*ft.RAD_TO_DEG:0,i.outerConeAngle=t.spot.hasOwnProperty("outerConeAngle")?t.spot.outerConeAngle*ft.RAD_TO_DEG:Math.PI/4),t.hasOwnProperty("intensity")&&(i.luminance=t.intensity*xd.getLightUnitConversion(_d[i.type],i.outerConeAngle,i.innerConeAngle));var n=new Sm(e.name);return n.rotateLocal(90,0,0),n.addComponent("light",i),n},Cb=function(t,e,i,n){if(!e.hasOwnProperty("skins")||0===e.skins.length)return[];var s=new Map;return e.skins.map((function(r){return function(t,e,i,n,s,r){var a,o,h,l=e.joints,c=l.length,u=[];if(e.hasOwnProperty("inverseBindMatrices")){var d=e.inverseBindMatrices,f=tb(i[d],n,!0),p=[];for(a=0;a0&&"localRotation"===L.paths[0].propertyPath[0]&&2!==L.interpolation&&v.push(P[P.length-1].output))}v.sort();var k,O=null;for(o=0;o0){var s,r,a,o,h=null==i||null==(s=i.camera)?void 0:s.preprocess,l=null!=(r=null==i||null==(a=i.camera)?void 0:a.process)?r:Eb,c=null==i||null==(o=i.camera)?void 0:o.postprocess;t.nodes.forEach((function(i,s){if(i.hasOwnProperty("camera")){var r=t.cameras[i.camera];if(r){h&&h(r);var a=l(r,e[s]);c&&c(r,a),a&&(n||(n=new Map),n.set(i,a))}}}))}return n},Ob=function(t,e,i){var n=null;if(t.hasOwnProperty("nodes")&&t.hasOwnProperty("extensions")&&t.extensions.hasOwnProperty("KHR_lights_punctual")&&t.extensions.KHR_lights_punctual.hasOwnProperty("lights")){var s=t.extensions.KHR_lights_punctual.lights;if(s.length){var r,a,o,h,l=null==i||null==(r=i.light)?void 0:r.preprocess,c=null!=(a=null==i||null==(o=i.light)?void 0:o.process)?a:Ab,u=null==i||null==(h=i.light)?void 0:h.postprocess;t.nodes.forEach((function(t,i){if(t.hasOwnProperty("extensions")&&t.extensions.hasOwnProperty("KHR_lights_punctual")&&t.extensions.KHR_lights_punctual.hasOwnProperty("light")){var r=t.extensions.KHR_lights_punctual.light,a=s[r];if(a){l&&l(a);var o=c(a,e[i]);u&&u(a,o),o&&(n||(n=new Map),n.set(t,o))}}}))}}return n},Fb=function(t,e,i){t.nodes.forEach((function(t){t.hasOwnProperty("mesh")&&t.hasOwnProperty("skin")&&e[t.mesh].meshes.forEach((function(e){e.skin=i[t.skin]}))}))},Bb=function(){var t=m(S().mark((function t(e,i,n,s,r){var a,o,h,l,c,u,d,f,p,m,_,v,g,y,x,b,T,w,E,A,C,M,P,R;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return h=null==r||null==(a=r.global)?void 0:a.preprocess,l=null==r||null==(o=r.global)?void 0:o.postprocess,h&&h(i),c=i.asset&&"PlayCanvas"===i.asset.generator,u=Db(i,r),d=Lb(i,u),f=Ob(i,u,r),p=kb(i,u,r),m=Rb(i),t.next=12,Promise.all(n);case 12:return _=t.sent,v=Mb(e,i,_,c,r),g=v.meshes,y=v.meshVariants,x=v.meshDefaultMaterials,b=v.promises,T=Ib(i,u,_,r),t.next=17,Promise.all(s);case 17:for(w=t.sent,E=w.map((function(t){return t.resource})),A=Pb(i,E,r,c),C=Cb(e,i,u,_),M=[],P=0;Pi.byteLength)e("Invalid length found in glb header. Found "+r);else{for(var a=[],o=12;oi.byteLength&&e("Invalid chunk length found in glb. Found "+h);var l=i.getUint32(o+4,!0),c=new Uint8Array(i.buffer,i.byteOffset+o+8,h);a.push({length:h,type:l,data:c}),o+=h+8}1===a.length||2===a.length?1313821514===a[0].type?a.length>1&&5130562!==a[1].type?e("Invalid chunk type found in glb file. Expected 0x004E4942, found 0x"+a[1].type.toString(16)):e(null,{gltfChunk:a[0].data,binaryChunk:2===a.length?a[1].data:null}):e("Invalid chunk type found in glb file. Expected 0x4E4F534A, found 0x"+a[0].type.toString(16)):e("Invalid number of chunks found in glb file.")}else e("Invalid version number found in glb header. Expected 2, found "+s);else e("Invalid magic number found in glb header. Expected 0x46546C67, found 0x"+n.toString(16))}(e,i):i(null,{gltfChunk:e,binaryChunk:null})},zb=function(){function t(){}return t.parse=function(t,e,i,n,s,r,a){Ub(t,i,(function(t,i){t?a(t):function(t,e){var i=JSON.parse(function(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);for(var e="",i=0;i0,maxRetries:this.maxRetries};(t.load.startsWith("blob:")||t.load.startsWith("data:"))&&(".glb"===D.getExtension(t.original).toLowerCase()?s.responseType=Za.ResponseType.ARRAY_BUFFER:s.responseType=Za.ResponseType.JSON),Qa.get(t.load,s,(function(s,r){var a;s?e("Error loading animation resource: "+t.original+" ["+s+"]"):".glb"===D.getExtension(t.original).toLowerCase()?zb.parse("filename.glb","",r,n.device,n.assets,null!=(a=null==i?void 0:i.options)?a:{},(function(t,n){if(t)e(t);else{var s,r=n.animations;if(null!=i&&null!=(s=i.data)&&s.events)for(var a=0;a0,maxRetries:this.maxRetries};t.load.startsWith("blob:")&&(i.responseType=Za.ResponseType.JSON),Qa.get(t.load,i,(function(i,n){i?e("Error loading animation clip resource: "+t.original+" ["+i+"]"):e(null,n)}))},i.open=function(t,e){var i=e.name,n=e.duration,s=e.inputs.map((function(t){return new NS(1,t)})),r=e.outputs.map((function(t){return new NS(t.components,t.data)})),a=e.curves.map((function(t){return new BS([t.path],t.inputIndex,t.outputIndex,t.interpolation)}));return new T_(i,n,s,r,a)},e}(pm),Hb=function(t){function e(e){return t.call(this,e,"animstategraph")||this}x(e,t);var i=e.prototype;return i.load=function(t,e){"string"==typeof t&&(t={load:t,original:t});var i={retry:this.maxRetries>0,maxRetries:this.maxRetries};t.load.startsWith("blob:")&&(i.responseType=Za.ResponseType.JSON),Qa.get(t.load,i,(function(i,n){i?e("Error loading animation state graph resource: "+t.original+" ["+i+"]"):e(null,n)}))},i.open=function(t,e){return new q_(e)},e}(pm),Wb=function(){if("undefined"==typeof window)return!1;var t=window.navigator.userAgent,e=t.indexOf("MSIE ");if(e>0)return parseInt(t.substring(e+5,t.indexOf(".",e)),10);if(t.indexOf("Trident/")>0){var i=t.indexOf("rv:");return parseInt(t.substring(i+3,t.indexOf(".",i)),10)}return!1}(),Xb=[".ogg",".mp3",".wav",".mp4a",".m4a",".mp4",".aac",".opus"],jb=function(t){function e(e){var i;return(i=t.call(this,e,"audio")||this).manager=e.soundManager,i}x(e,t);var i=e.prototype;return i._isSupported=function(t){var e=D.getExtension(t);return Xb.indexOf(e)>-1},i.load=function(t,e){"string"==typeof t&&(t={load:t,original:t});var i=function(i){var n="Error loading audio url: "+t.original;i&&(n+=": "+(i.message||i)),console.warn(n),e(n)};if(this._createSound){if(!this._isSupported(t.original))return void i("Audio format for "+t.original+" not supported");this._createSound(t.load,(function(t){e(null,new ao(t))}),i)}else i(null)},i._createSound=function(t,e,i){if(Ja()){var n=this.manager;if(!n.context)return void i("Audio manager has no audio context");var s={retry:this.maxRetries>0,maxRetries:this.maxRetries};(t.startsWith("blob:")||t.startsWith("data:"))&&(s.responseType=Za.ResponseType.ARRAY_BUFFER),Qa.get(t,s,(function(t,s){t?i(t):n.context.decodeAudioData(s,e,i)}))}else{var r=null;try{r=new Audio}catch(t){return void i("No support for Audio element")}Wb&&document.body.appendChild(r);var a=function(){r.removeEventListener("canplaythrough",a),Wb&&document.body.removeChild(r),e(r)};r.onerror=function(){r.onerror=null,Wb&&document.body.removeChild(r),i()},r.addEventListener("canplaythrough",a),r.src=t}},e}(pm),qb=function(t){function e(e){return t.call(this,e,"binary")||this}x(e,t);var i=e.prototype;return i.load=function(t,e){"string"==typeof t&&(t={load:t,original:t}),Qa.get(t.load,{responseType:Za.ResponseType.ARRAY_BUFFER,retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(i,n){i?e("Error loading binary resource: "+t.original+" ["+i+"]"):e(null,n)}))},i.openBinary=function(t){return t.buffer},e}(pm),Yb=function(){function t(e,i,n,s){for(var r=function(e,s,r){var a=t.createAsset(i.name,e,s,r);return n.add(a),a},a=[],o=0;o=0?t.split("?")[0]:t},e.load=function(t,e,i){var n=this;om.fetchArrayBuffer(t.load,(function(s,r){s?e(s):zb.parse(n._getUrlWithoutParams(t.original),D.extractPath(t.load),r,n._device,i.registry,i.options,(function(t,s){t?e(t):e(null,new Yb(s,i,n._assets,n._defaultMaterial))}))}),i,this.maxRetries)},e.open=function(t,e,i){return e},e.patch=function(t,e){},t}(),Zb=function(){function t(){}var e=t.prototype;return e.instantiateModelEntity=function(t){return null},e.instantiateRenderEntity=function(t){return null},e.getMaterialVariants=function(){return null},e.applyMaterialVariant=function(t,e){},e.applyMaterialVariantInstances=function(t,e){},t}(),Qb=function(t){function e(e){var i;return(i=t.call(this,e,"container")||this).glbContainerParser=new Kb(e.graphicsDevice,e.assets,0),i.parsers={},i}x(e,t);var i=e.prototype;return i._getUrlWithoutParams=function(t){return t.indexOf("?")>=0?t.split("?")[0]:t},i._getParser=function(t){var e=t?D.getExtension(this._getUrlWithoutParams(t)).toLowerCase().replace(".",""):null;return this.parsers[e]||this.glbContainerParser},i.load=function(t,e,i){"string"==typeof t&&(t={load:t,original:t}),this._getParser(t.original).load(t,e,i)},i.open=function(t,e,i){return this._getParser(t).open(t,e,i)},v(e,[{key:"maxRetries",get:function(){return this.glbContainerParser.maxRetries},set:function(t){for(var e in this.glbContainerParser.maxRetries=t,this.parsers)this.parsers.hasOwnProperty(e)&&(this.parsers[e].maxRetries=t)}}])}(pm),Jb=function(t){function e(e){var i;return(i=t.call(this,e,"css")||this).decoder=null,i}x(e,t);var i=e.prototype;return i.load=function(t,e){"string"==typeof t&&(t={load:t,original:t}),Qa.get(t.load,{retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(i,n){i?e("Error loading css resource: "+t.original+" ["+i+"]"):e(null,n)}))},i.openBinary=function(t){return null!=this.decoder||(this.decoder=new TextDecoder("utf-8")),this.decoder.decode(t)},e}(pm),$b=function(t){function e(e){var i;return(i=t.call(this,e,"cubemap")||this)._device=e.graphicsDevice,i._registry=e.assets,i._loader=e.loader,i}x(e,t);var i=e.prototype;return i.load=function(t,e,i){this.loadAssets(i,e)},i.open=function(t,e,i){return i?i.resource:null},i.patch=function(t,e){this.loadAssets(t,(function(i,n){i&&(e.fire("error",t),e.fire("error:"+t.id,i,t),t.fire("error",t))}))},i.getAssetIds=function(t){var e=[];if(e[0]=t.file,(t.loadFaces||!t.file)&&t.data&&t.data.textures)for(var i=0;i<6;++i)e[i+1]=t.data.textures[i];else e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=null;return e},i.compareAssetIds=function(t,e){return t&&e?parseInt(t,10)===t||"string"==typeof t?t===e:t.url===e.url:null!==t==(null!==e)},i.update=function(t,e,i){var n,s,r,a=t.data||{},o=t._handlerState.assets,h=t._resources,l=[null,null,null,null,null,null,null],c=function(){return a.hasOwnProperty("type")?a.type:a.hasOwnProperty("rgbm")?a.rgbm?di:ui:null};if(t.loaded&&i[0]===o[0])l[1]=h[1]||null,l[2]=h[2]||null,l[3]=h[3]||null,l[4]=h[4]||null,l[5]=h[5]||null,l[6]=h[6]||null;else if(i[0])if((n=i[0].resource).cubemap)for(r=0;r<6;++r)l[r+1]=new or(this._device,{name:t.name+"_prelitCubemap"+(n.width>>r),cubemap:!0,type:c()||n.type,width:n.width>>r,height:n.height>>r,format:n.format,levels:[n._levels[r]],fixCubemapSeams:!0,addressU:1,addressV:1,mipmaps:0===r});else n.type=pi,n.addressU=1,n.addressV=1,n.mipmaps=!1,l[1]=n;var u=i.slice(1);if(t.loaded&&this.cmpArrays(u,o.slice(1)))l[0]=h[0]||null;else if(-1===u.indexOf(null)){var d,f=u.map((function(t){return t.resource})),p=[];for(s=0;s0,maxRetries:this.maxRetries},(function(i,s){if(i)e("Error loading font resource: "+t.original+" ["+i+"]");else{var r=iT(s);n._loadTextures(t.load.replace(".json",".png"),r,(function(t,i){t?e(t):e(null,{data:r,textures:i})}))}})):(i&&i.data&&(i.data=iT(i.data)),this._loadTextures(t.load,i&&i.data,e))},i._loadTextures=function(t,e,i){for(var n=e.info.maps.length,s=0,r=null,a=new Array(n),o=this._loader,h=function(e){var h=function(t,o){if(!r){if(t)return r=t,void i(t);o.upload(),a[e]=o,++s===n&&i(null,a)}};0===e?o.load(t,"texture",h):o.load(t.replace(".png",e+".png"),"texture",h)},l=0;l>>21,11),t.y=a(e>>>11,10),t.z=a(e,11)},h=function(t,e,i){return t===e?t:t*(1-i)+e*i},l=t.chunkData,c=t.chunkSize,u=t.vertexData,d=t.shData,f=t.shBands,p=[3,8,15][f-1];this.read=function(t){var m=Math.floor(t/256)*c;if(e&&(o(e,u[4*t+0]),e.x=h(l[m+0],l[m+3],e.x),e.y=h(l[m+1],l[m+4],e.y),e.z=h(l[m+2],l[m+5],e.z)),i&&function(t,e){var i=1/(.5*Math.sqrt(2)),n=(a(e>>>20,10)-.5)*i,s=(a(e>>>10,10)-.5)*i,r=(a(e,10)-.5)*i,o=Math.sqrt(1-(n*n+s*s+r*r));switch(e>>>30){case 0:t.set(n,s,r,o);break;case 1:t.set(o,s,r,n);break;case 2:t.set(s,o,r,n);break;case 3:t.set(s,r,o,n)}}(i,u[4*t+1]),n&&(o(n,u[4*t+2]),n.x=h(l[m+6],l[m+9],n.x),n.y=h(l[m+7],l[m+10],n.y),n.z=h(l[m+8],l[m+11],n.z)),s&&(!function(t,e){t.x=a(e>>>24,8),t.y=a(e>>>16,8),t.z=a(e>>>8,8),t.w=a(e,8)}(s,u[4*t+3]),c>12&&(s.x=h(l[m+12],l[m+15],s.x),s.y=h(l[m+13],l[m+16],s.y),s.z=h(l[m+14],l[m+17],s.z))),r&&f>0)for(var _=0;_<3;++_)for(var v=0;v<15;++v)r[15*_+v]=v>>21)/2047,v=(m>>>11&1023)/1023,g=(2047&m)/2047;t[3*p+0]=(1-_)*e+_*s,t[3*p+1]=(1-v)*i+v*r,t[3*p+2]=(1-g)*n+g*a}}},e.calcFocalPoint=function(t){var e=this.chunkData,i=this.numChunks,n=this.chunkSize;t.x=0,t.y=0,t.z=0;for(var s=0;s0){for(var n=[],s=0;s<45;++s)n.push("f_rest_"+s);e.splice.apply(e,[e.indexOf("f_dc_0")+1,0].concat(n))}var r={};e.forEach((function(e){r[e]=new Float32Array(t.numSplats)}));for(var a=new wt,o=new Nt,h=new wt,l=new Rt,c=i>0?new Float32Array(45):null,u=this.createIter(a,o,h,l,c),d=0;d=1?40:-Math.log(1/l.w-1),c)for(var f=0;f<45;++f)r["f_rest_"+f][d]=c[f];return new bp([{name:"vertex",count:this.numSplats,properties:e.map((function(t){return{name:t,type:"float",byteSize:4,storage:r[t]}}))}])},v(t,[{key:"isCompressed",get:function(){return!0}},{key:"numChunks",get:function(){return Math.ceil(this.numSplats/256)}},{key:"chunkSize",get:function(){return this.chunkData.length/this.numChunks}},{key:"shBands",get:function(){var t,e;return null!=(t={3:1,8:2,15:3}[(null==(e=this.shData)?void 0:e.length)/this.numSplats/3])?t:0}}])}(),lT=function(){function t(){}var e=t.prototype;return e.generateKey=function(t){var e,i,n=mn(t.vertex),s=mn(t.fragment),r=null!=(e=null==(i=t.defines)?void 0:i.sort().join("-"))?e:"";return"splat-"+t.pass+"-"+t.gamma+"-"+t.toneMapping+"-"+n+"-"+s+"-"+t.dither+"-"+r},e.createShaderDefinition=function(t,e){var i,n=Yo.get(t).getByIndex(e.pass).shaderDefines+"\n"+(null!=(i=e.defines)?i:[]).map((function(t){return"#define "+t})).join("\n")+"\n#define DITHER_"+e.dither.toUpperCase()+"\n#define TONEMAP_"+(0===e.toneMapping?"DISABLED":"ENABLED")+"\n",s=n+"\n\tuniform mat4 matrix_model;\n\tuniform mat4 matrix_view;\n\tuniform mat4 matrix_projection;\n\tuniform vec2 viewport;\n\tuniform vec4 tex_params;\n\tuniform highp usampler2D splatOrder;\n\tuniform highp usampler2D packedTexture;\n\tuniform highp sampler2D chunkTexture;\n\tattribute vec3 vertex_position;\n\tattribute uint vertex_id_attrib;\n\t#ifndef DITHER_NONE\n\t\tvarying float id;\n\t#endif\n\tuint orderId;\n\tuint splatId;\n\tivec2 packedUV;\n\tivec2 chunkUV;\n\tvec4 chunkDataA;\n\tvec4 chunkDataB;\n\tvec4 chunkDataC;\n\tvec4 chunkDataD;\n\tvec4 chunkDataE;\n\tuvec4 packedData;\n\tbool calcSplatUV() {\n\t\tuint numSplats = uint(tex_params.x);\n\t\tuint packedWidth = uint(tex_params.y);\n\t\tuint chunkWidth = uint(tex_params.z);\n\t\torderId = vertex_id_attrib + uint(vertex_position.z);\n\t\tif (orderId >= numSplats) {\n\t\t\treturn false;\n\t\t}\n\t\tivec2 orderUV = ivec2(\n\t\t\tint(orderId % packedWidth),\n\t\t\tint(orderId / packedWidth)\n\t\t);\n\t\tsplatId = texelFetch(splatOrder, orderUV, 0).r;\n\t\tpackedUV = ivec2(\n\t\t\tint(splatId % packedWidth),\n\t\t\tint(splatId / packedWidth)\n\t\t);\n\t\tuint chunkId = splatId / 256u;\n\t\tchunkUV = ivec2(\n\t\t\tint((chunkId % chunkWidth) * 5u),\n\t\t\tint(chunkId / chunkWidth)\n\t\t);\n\t\treturn true;\n\t}\n\tvoid readData() {\n\t\tchunkDataA = texelFetch(chunkTexture, chunkUV, 0);\n\t\tchunkDataB = texelFetch(chunkTexture, ivec2(chunkUV.x + 1, chunkUV.y), 0);\n\t\tchunkDataC = texelFetch(chunkTexture, ivec2(chunkUV.x + 2, chunkUV.y), 0);\n\t\tchunkDataD = texelFetch(chunkTexture, ivec2(chunkUV.x + 3, chunkUV.y), 0);\n\t\tchunkDataE = texelFetch(chunkTexture, ivec2(chunkUV.x + 4, chunkUV.y), 0);\n\t\tpackedData = texelFetch(packedTexture, packedUV, 0);\n\t}\n\tvec3 unpack111011(uint bits) {\n\t\treturn vec3(\n\t\t\tfloat(bits >> 21u) / 2047.0,\n\t\t\tfloat((bits >> 11u) & 0x3ffu) / 1023.0,\n\t\t\tfloat(bits & 0x7ffu) / 2047.0\n\t\t);\n\t}\n\tvec4 unpack8888(uint bits) {\n\t\treturn vec4(\n\t\t\tfloat(bits >> 24u) / 255.0,\n\t\t\tfloat((bits >> 16u) & 0xffu) / 255.0,\n\t\t\tfloat((bits >> 8u) & 0xffu) / 255.0,\n\t\t\tfloat(bits & 0xffu) / 255.0\n\t\t);\n\t}\n\tfloat norm = 1.0 / (sqrt(2.0) * 0.5);\n\tvec4 unpackRotation(uint bits) {\n\t\tfloat a = (float((bits >> 20u) & 0x3ffu) / 1023.0 - 0.5) * norm;\n\t\tfloat b = (float((bits >> 10u) & 0x3ffu) / 1023.0 - 0.5) * norm;\n\t\tfloat c = (float(bits & 0x3ffu) / 1023.0 - 0.5) * norm;\n\t\tfloat m = sqrt(1.0 - (a * a + b * b + c * c));\n\t\tuint mode = bits >> 30u;\n\t\tif (mode == 0u) return vec4(m, a, b, c);\n\t\tif (mode == 1u) return vec4(a, m, b, c);\n\t\tif (mode == 2u) return vec4(a, b, m, c);\n\t\treturn vec4(a, b, c, m);\n\t}\n\tvec3 getCenter() {\n\t\treturn mix(chunkDataA.xyz, vec3(chunkDataA.w, chunkDataB.xy), unpack111011(packedData.x));\n\t}\n\tvec4 getRotation() {\n\t\treturn unpackRotation(packedData.y);\n\t}\n\tvec3 getScale() {\n\t\treturn exp(mix(vec3(chunkDataB.zw, chunkDataC.x), chunkDataC.yzw, unpack111011(packedData.z)));\n\t}\n\tvec4 getColor() {\n\t\tvec4 r = unpack8888(packedData.w);\n\t\treturn vec4(mix(chunkDataD.xyz, vec3(chunkDataD.w, chunkDataE.xy), r.rgb), r.w);\n\t}\n\tmat3 quatToMat3(vec4 R) {\n\t\tfloat x = R.x;\n\t\tfloat y = R.y;\n\t\tfloat z = R.z;\n\t\tfloat w = R.w;\n\t\treturn mat3(\n\t\t\t1.0 - 2.0 * (z * z + w * w),\n\t\t\t\t 2.0 * (y * z + x * w),\n\t\t\t\t 2.0 * (y * w - x * z),\n\t\t\t\t 2.0 * (y * z - x * w),\n\t\t\t1.0 - 2.0 * (y * y + w * w),\n\t\t\t\t 2.0 * (z * w + x * y),\n\t\t\t\t 2.0 * (y * w + x * z),\n\t\t\t\t 2.0 * (z * w - x * y),\n\t\t\t1.0 - 2.0 * (y * y + z * z)\n\t\t);\n\t}\n\tvoid getCovariance(out vec3 covA, out vec3 covB) {\n\t\tmat3 rot = quatToMat3(getRotation());\n\t\tvec3 scale = getScale();\n\t\tmat3 M = transpose(mat3(\n\t\t\tscale.x * rot[0],\n\t\t\tscale.y * rot[1],\n\t\t\tscale.z * rot[2]\n\t\t));\n\t\tcovA = vec3(dot(M[0], M[0]), dot(M[0], M[1]), dot(M[0], M[2]));\n\t\tcovB = vec3(dot(M[1], M[1]), dot(M[1], M[2]), dot(M[2], M[2]));\n\t}\n\tvec4 calcV1V2(in vec3 splat_cam, in vec3 covA, in vec3 covB, mat3 W) {\n\t\tmat3 Vrk = mat3(\n\t\t\tcovA.x, covA.y, covA.z, \n\t\t\tcovA.y, covB.x, covB.y,\n\t\t\tcovA.z, covB.y, covB.z\n\t\t);\n\t\tfloat focal = viewport.x * matrix_projection[0][0];\n\t\tfloat J1 = focal / splat_cam.z;\n\t\tvec2 J2 = -J1 / splat_cam.z * splat_cam.xy;\n\t\tmat3 J = mat3(\n\t\t\tJ1, 0.0, J2.x, \n\t\t\t0.0, J1, J2.y, \n\t\t\t0.0, 0.0, 0.0\n\t\t);\n\t\tmat3 T = W * J;\n\t\tmat3 cov = transpose(T) * Vrk * T;\n\t\tfloat diagonal1 = cov[0][0] + 0.3;\n\t\tfloat offDiagonal = cov[0][1];\n\t\tfloat diagonal2 = cov[1][1] + 0.3;\n\t\tfloat mid = 0.5 * (diagonal1 + diagonal2);\n\t\tfloat radius = length(vec2((diagonal1 - diagonal2) / 2.0, offDiagonal));\n\t\tfloat lambda1 = mid + radius;\n\t\tfloat lambda2 = max(mid - radius, 0.1);\n\t\tvec2 diagonalVector = normalize(vec2(offDiagonal, lambda1 - diagonal1));\n\t\tvec2 v1 = min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector;\n\t\tvec2 v2 = min(sqrt(2.0 * lambda2), 1024.0) * vec2(diagonalVector.y, -diagonalVector.x);\n\t\treturn vec4(v1, v2);\n\t}\n#if defined(USE_SH)\n\t#define SH_C1 0.4886025119029199f\n\t#define SH_C2_0 1.0925484305920792f\n\t#define SH_C2_1 -1.0925484305920792f\n\t#define SH_C2_2 0.31539156525252005f\n\t#define SH_C2_3 -1.0925484305920792f\n\t#define SH_C2_4 0.5462742152960396f\n\t#define SH_C3_0 -0.5900435899266435f\n\t#define SH_C3_1 2.890611442640554f\n\t#define SH_C3_2 -0.4570457994644658f\n\t#define SH_C3_3 0.3731763325901154f\n\t#define SH_C3_4 -0.4570457994644658f\n\t#define SH_C3_5 1.445305721320277f\n\t#define SH_C3_6 -0.5900435899266435f\n\tuniform highp usampler2D shTexture0;\n\tuniform highp usampler2D shTexture1;\n\tuniform highp usampler2D shTexture2;\n\tvec4 sunpack8888(in uint bits) {\n\t\treturn vec4((uvec4(bits) >> uvec4(0u, 8u, 16u, 24u)) & 0xffu) * (8.0 / 255.0) - 4.0;\n\t}\n\tvoid readSHData(out vec3 sh[15]) {\n\t\tuvec4 shData0 = texelFetch(shTexture0, packedUV, 0);\n\t\tuvec4 shData1 = texelFetch(shTexture1, packedUV, 0);\n\t\tuvec4 shData2 = texelFetch(shTexture2, packedUV, 0);\n\t\tvec4 r0 = sunpack8888(shData0.x);\n\t\tvec4 r1 = sunpack8888(shData0.y);\n\t\tvec4 r2 = sunpack8888(shData0.z);\n\t\tvec4 r3 = sunpack8888(shData0.w);\n\t\tvec4 g0 = sunpack8888(shData1.x);\n\t\tvec4 g1 = sunpack8888(shData1.y);\n\t\tvec4 g2 = sunpack8888(shData1.z);\n\t\tvec4 g3 = sunpack8888(shData1.w);\n\t\tvec4 b0 = sunpack8888(shData2.x);\n\t\tvec4 b1 = sunpack8888(shData2.y);\n\t\tvec4 b2 = sunpack8888(shData2.z);\n\t\tvec4 b3 = sunpack8888(shData2.w);\n\t\tsh[0] = vec3(r0.x, g0.x, b0.x);\n\t\tsh[1] = vec3(r0.y, g0.y, b0.y);\n\t\tsh[2] = vec3(r0.z, g0.z, b0.z);\n\t\tsh[3] = vec3(r0.w, g0.w, b0.w);\n\t\tsh[4] = vec3(r1.x, g1.x, b1.x);\n\t\tsh[5] = vec3(r1.y, g1.y, b1.y);\n\t\tsh[6] = vec3(r1.z, g1.z, b1.z);\n\t\tsh[7] = vec3(r1.w, g1.w, b1.w);\n\t\tsh[8] = vec3(r2.x, g2.x, b2.x);\n\t\tsh[9] = vec3(r2.y, g2.y, b2.y);\n\t\tsh[10] = vec3(r2.z, g2.z, b2.z);\n\t\tsh[11] = vec3(r2.w, g2.w, b2.w);\n\t\tsh[12] = vec3(r3.x, g3.x, b3.x);\n\t\tsh[13] = vec3(r3.y, g3.y, b3.y);\n\t\tsh[14] = vec3(r3.z, g3.z, b3.z);\n\t}\n\tvec3 evalSH(in vec3 dir) {\n\t\tvec3 sh[15];\n\t\treadSHData(sh);\n\t\tvec3 result = vec3(0.0);\n\t\tfloat x = dir.x;\n\t\tfloat y = dir.y;\n\t\tfloat z = dir.z;\n\t\tresult += SH_C1 * (-sh[0] * y + sh[1] * z - sh[2] * x);\n\t\tfloat xx = x * x;\n\t\tfloat yy = y * y;\n\t\tfloat zz = z * z;\n\t\tfloat xy = x * y;\n\t\tfloat yz = y * z;\n\t\tfloat xz = x * z;\n\t\tresult +=\n\t\t\tsh[3] * (SH_C2_0 * xy) * +\n\t\t\tsh[4] * (SH_C2_1 * yz) +\n\t\t\tsh[5] * (SH_C2_2 * (2.0 * zz - xx - yy)) +\n\t\t\tsh[6] * (SH_C2_3 * xz) +\n\t\t\tsh[7] * (SH_C2_4 * (xx - yy));\n\t\tresult +=\n\t\t\tsh[8] * (SH_C3_0 * y * (3.0 * xx - yy)) +\n\t\t\tsh[9] * (SH_C3_1 * xy * z) +\n\t\t\tsh[10] * (SH_C3_2 * y * (4.0 * zz - xx - yy)) +\n\t\t\tsh[11] * (SH_C3_3 * z * (2.0 * zz - 3.0 * xx - 3.0 * yy)) +\n\t\t\tsh[12] * (SH_C3_4 * x * (4.0 * zz - xx - yy)) +\n\t\t\tsh[13] * (SH_C3_5 * z * (xx - yy)) +\n\t\t\tsh[14] * (SH_C3_6 * x * (xx - 3.0 * yy));\n\t\treturn result;\n\t}\n#else\n\tvec3 evalSH(in vec3 dir) {\n\t\treturn vec3(0.0);\n\t}\n#endif\n"+e.vertex,r=n+Ro.decodePS+(e.dither===Ao?"":Ro.bayerPS+Ro.opacityDitherPS)+ko.tonemapCode(e.toneMapping)+ko.gammaCode(e.gamma)+"\n\t#ifndef DITHER_NONE\n\t\tvarying float id;\n\t#endif\n\t#ifdef PICK_PASS\n\t\tuniform vec4 uColor;\n\t#endif\n\tvec4 evalSplat(vec2 texCoord, vec4 color) {\n\t\tmediump float A = dot(texCoord, texCoord);\n\t\tif (A > 1.0) {\n\t\t\tdiscard;\n\t\t}\n\t\tmediump float B = exp(-A * 4.0) * color.a;\n\t\tif (B < 1.0 / 255.0) {\n\t\t\tdiscard;\n\t\t}\n\t\t#ifdef PICK_PASS\n\t\t\tif (B < 0.3) {\n\t\t\t\tdiscard;\n\t\t\t}\n\t\t\treturn uColor;\n\t\t#endif\n\t\t#ifndef DITHER_NONE\n\t\t\topacityDither(B, id * 0.013);\n\t\t#endif\n\t\t#ifdef TONEMAP_ENABLED\n\t\t\treturn vec4(gammaCorrectOutput(toneMap(decodeGamma(color.rgb))), B);\n\t\t#else\n\t\t\treturn vec4(color.rgb, B);\n\t\t#endif\n\t}\n"+e.fragment;return Pr.createDefinition(t,{name:"SplatShader",attributes:{vertex_position:Le,vertex_id_attrib:hi},vertexCode:s,fragmentCode:r})},t}(),cT=new lT,uT=function(){function t(t,e){this.device=void 0,this.numSplats=void 0,this.aabb=void 0,this.centers=void 0,this.packedTexture=void 0,this.chunkTexture=void 0,this.shTexture0=void 0,this.shTexture1=void 0,this.shTexture2=void 0;var i=e.chunkData,n=e.chunkSize,s=e.numChunks,r=e.numSplats,a=e.vertexData,o=e.shBands;this.device=t,this.numSplats=r,this.aabb=new Wt,e.calcAabb(this.aabb),this.centers=new Float32Array(3*r),e.getCenters(this.centers),this.packedTexture=this.createTexture("packedData",Me,this.evalTextureSize(r),a);var h=this.evalTextureSize(s);h.x*=5,this.chunkTexture=this.createTexture("chunkData",ve,h);var l=this.chunkTexture.lock();if(function(t,e,i,n,s){for(var r=0;r0){for(var u=e.shData,d=this.evalTextureSize(r),f=this.createTexture("shTexture0",Me,d),p=this.createTexture("shTexture1",Me,d),m=this.createTexture("shTexture2",Me,d),_=f.lock(),v=p.lock(),g=m.lock(),y=new Uint8Array(_.buffer),x=new Uint8Array(v.buffer),S=new Uint8Array(g.buffer),b=[3,8,15][o-1],T=0;T=i)this.head>0?(this.data.copyWithin(0,this.head,this.tail),this.data.set(t,e),this.head=0,this.tail=i):(this.data.set(t,this.tail),this.tail+=t.length);else{var n=new Uint8Array(i);this.head>0||this.tail0&&(this.data.copyWithin(0,this.head,this.tail),this.tail-=this.head,this.head=0)},i.getInt8=function(){var t=this.view.getInt8(this.head);return this.head++,t},i.getUint8=function(){var t=this.view.getUint8(this.head);return this.head++,t},i.getInt16=function(){var t=this.view.getInt16(this.head,!0);return this.head+=2,t},i.getUint16=function(){var t=this.view.getUint16(this.head,!0);return this.head+=2,t},i.getInt32=function(){var t=this.view.getInt32(this.head,!0);return this.head+=4,t},i.getUint32=function(){var t=this.view.getUint32(this.head,!0);return this.head+=4,t},i.getFloat32=function(){var t=this.view.getFloat32(this.head,!0);return this.head+=4,t},i.getFloat64=function(){var t=this.view.getFloat64(this.head,!0);return this.head+=8,t},v(t,[{key:"remaining",get:function(){return this.tail-this.head}}])}(),vT=function(t){for(var e,i=[],n=1;n=fT.length)||s(r.data,fT)){t.next=9;break}throw new Error("Invalid ply header");case 9:if(-1===(a=n(r.data,pT))){t.next=12;break}return t.abrupt("break",14);case 12:t.next=4;break;case 14:if(o=new TextDecoder("ascii").decode(r.data.subarray(0,a)).split("\n").filter((function(t){return!t.startsWith("comment ")})),h=vT(o),l=h.elements,"binary_little_endian"===(c=h.format)||"binary_big_endian"===c){t.next=18;break}throw new Error("Unsupported ply format");case 18:if(r.head=a+pT.length,r.compact(),!gT(l)){t.next=24;break}return t.next=23,xT(r,l,"binary_little_endian"===c);case 23:return t.abrupt("return",t.sent);case 24:if(l.forEach((function(t){t.properties.forEach((function(e){var n=mT.get(e.type);if(n){var s=!i||i(e.name)?new n(t.count):null;e.storage=s}}))})),!yT(l)){t.next=29;break}return t.next=28,ST(r,l,"binary_little_endian"===c);case 28:return t.abrupt("return",t.sent);case 29:return t.next=31,bT(r,l,"binary_little_endian"===c);case 31:return t.abrupt("return",t.sent);case 32:case"end":return t.stop()}}),t)}))),function(t,e){return sT.apply(this,arguments)}),wT=function(t){return!0},ET=function(){function t(t,e,i){this.device=void 0,this.assets=void 0,this.maxRetries=void 0,this.device=t,this.assets=e,this.maxRetries=i}var e,i=t.prototype;return i.load=(e=m(S().mark((function t(e,i,n){var s,r,a=this;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(e.load);case 2:(s=t.sent)&&s.body?TT(s.body.getReader(),null!=(r=n.data.elementFilter)?r:wT).then((function(t){var e;t.isCompressed||(null==(e=n.data.reorder)||e)&&t.reorderData();var s=new dT(a.device,t.isCompressed&&n.data.decompress?t.decompress():t);i(null,s)})).catch((function(t){i(t,null)})):i("Error loading resource",null);case 4:case"end":return t.stop()}}),t)}))),function(t,i,n){return e.apply(this,arguments)}),i.open=function(t,e){return e},t}(),AT=function(t){function e(e){var i;return(i=t.call(this,e,"gsplat")||this).parser=new ET(e.graphicsDevice,e.assets,3),i}x(e,t);var i=e.prototype;return i.load=function(t,e,i){"string"==typeof t&&(t={load:t,original:t}),this.parser.load(t,e,i)},i.open=function(t,e,i){return this.parser.open(t,e,i)},e}(pm),CT=function(){function t(){}return t.setCompressedPRS=function(t,e,i){var n,s,r=i.singleVecs,a=e.___1;a||(n=i.tripleVecs,s=e.___2);var o=a?a[0]:n[s];t.setLocalPosition(r[o],r[o+1],r[o+2]),o=a?a[1]:n[s+1],t.setLocalEulerAngles(r[o],r[o+1],r[o+2]),o=a?a[2]:n[s+2],t.setLocalScale(r[o],r[o+1],r[o+2])},t.oneCharToKey=function(t,e){var i=t.charCodeAt(0)-e.fieldFirstCode;return e.fieldArray[i]},t.multCharToKey=function(t,e){for(var i=0,n=0;n0,maxRetries:e},(function(e,n){if(e){var s="Error while loading scene JSON "+t.original;e.message?(s+=": "+e.message,e.stack&&(s+="\n"+e.stack)):s+=": "+e,i(s)}else i(e,n)}))},t}(),IT=function(t){function e(e){return t.call(this,e,"hierarchy")||this}x(e,t);var i=e.prototype;return i.load=function(t,e){RT.load(t,this.maxRetries,e)},i.open=function(t,e){this._app.systems.script.preloading=!0;var i=new PT(this._app,!1).parse(e);return this._app.systems.script.preloading=!1,i},e}(pm),DT=function(t){function e(e){var i;return(i=t.call(this,e,"html")||this).decoder=null,i}x(e,t);var i=e.prototype;return i.load=function(t,e){"string"==typeof t&&(t={load:t,original:t}),Qa.get(t.load,{retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(i,n){i?e("Error loading html resource: "+t.original+" ["+i+"]"):e(null,n)}))},i.openBinary=function(t){return null!=this.decoder||(this.decoder=new TextDecoder("utf-8")),this.decoder.decode(t)},e}(pm),LT=function(t){function e(e){var i;return(i=t.call(this,e,"json")||this).decoder=null,i}x(e,t);var i=e.prototype;return i.load=function(t,e){"string"==typeof t&&(t={load:t,original:t});var i={retry:this.maxRetries>0,maxRetries:this.maxRetries};t.load.startsWith("blob:")&&(i.responseType=Za.ResponseType.JSON),Qa.get(t.load,i,(function(i,n){i?e("Error loading JSON resource: "+t.original+" ["+i+"]"):e(null,n)}))},i.openBinary=function(t){return null!=this.decoder||(this.decoder=new TextDecoder("utf-8")),JSON.parse(this.decoder.decode(t))},e}(pm),kT=function(){function t(){this.removeInvalid=!0,this.valid=!0,this.enumValidators={occludeSpecular:this._createEnumValidator([0,1,2]),cull:this._createEnumValidator([0,1,2,3]),blendType:this._createEnumValidator([0,1,2,3,4,5,6,7,8,9,10]),depthFunc:this._createEnumValidator([0,1,2,3,4,5,6,7]),shadingModel:this._createEnumValidator([0,1])}}var e=t.prototype;return e.setInvalid=function(t,e){this.valid=!1,this.removeInvalid&&delete e[t]},e.validate=function(t){var e=wc,i=Pc,n="path"===t.mappingFormat;for(var s in t){var r=e[s];if(r)if(r.startsWith("enum")){var a=r.split(":")[1];this.enumValidators[a]&&(this.enumValidators[a](t[s])||this.setInvalid(s,t))}else if("number"===r)"number"!=typeof t[s]&&this.setInvalid(s,t);else if("boolean"===r)"boolean"!=typeof t[s]&&this.setInvalid(s,t);else if("string"===r)"string"!=typeof t[s]&&this.setInvalid(s,t);else if("vec2"===r)t[s]instanceof Array&&2===t[s].length||this.setInvalid(s,t);else if("rgb"===r)t[s]instanceof Array&&3===t[s].length||this.setInvalid(s,t);else if("texture"===r)n?"string"!=typeof t[s]&&null!==t[s]&&(t[s]instanceof or||this.setInvalid(s,t)):"number"!=typeof t[s]&&null!==t[s]&&(t[s]instanceof or||this.setInvalid(s,t));else if("boundingbox"===r)t[s].center&&t[s].center instanceof Array&&3===t[s].center.length||this.setInvalid(s,t),t[s].halfExtents&&t[s].halfExtents instanceof Array&&3===t[s].halfExtents.length||this.setInvalid(s,t);else if("cubemap"===r)"number"!=typeof t[s]&&null!==t[s]&&void 0!==t[s]&&(t[s]instanceof or&&t[s].cubemap||this.setInvalid(s,t));else if("chunks"===r)for(var o=Object.keys(t[s]),h=0;h=0}},t}(),OT=function(){function t(){this._validator=null}var e=t.prototype;return e.parse=function(t){var e=this.migrate(t),i=this._validate(e),n=new Lc;return this.initialize(n,i),n},e.initialize=function(t,e){for(var i in e.validated||(e=this._validate(e)),e.chunks&&(t.chunks=y({},e.chunks)),e){var n=wc[i],s=e[i];if("vec2"===n)t[i]=new Mt(s[0],s[1]);else if("rgb"===n)t[i]=new pt(s[0],s[1],s[2]);else if("texture"===n)s instanceof or?t[i]=s:t[i]instanceof or&&"number"==typeof s&&s>0||(t[i]=null);else if("cubemap"===n)s instanceof or?t[i]=s:t[i]instanceof or&&"number"==typeof s&&s>0||(t[i]=null),"cubeMap"!==i||s||(t.prefilteredCubemaps=null);else if("boundingbox"===n){var r=new wt(s.center[0],s.center[1],s.center[2]),a=new wt(s.halfExtents[0],s.halfExtents[1],s.halfExtents[2]);t[i]=new Wt(r,a)}else t[i]=e[i]}t.update()},e.migrate=function(t){var e;t.shader?(t.shadingModel="blinn"===t.shader?1:0,delete t.shader):void 0===t.shadingModel&&(t.shadingModel=1),t.mapping_format&&(t.mappingFormat=t.mapping_format,delete t.mapping_format);var i=[["bumpMapFactor","bumpiness"],["aoUvSet","aoMapUv"],["aoMapVertexColor","aoVertexColor"],["diffuseMapVertexColor","diffuseVertexColor"],["emissiveMapVertexColor","emissiveVertexColor"],["specularMapVertexColor","specularVertexColor"],["metalnessMapVertexColor","metalnessVertexColor"],["opacityMapVertexColor","opacityVertexColor"],["glossMapVertexColor","glossVertexColor"],["lightMapVertexColor","lightVertexColor"],["diffuseMapTint","diffuseTint"],["specularMapTint","specularTint"],["emissiveMapTint","emissiveTint"],["metalnessMapTint","metalnessTint"],["clearCoatGlossiness","clearCoatGloss"]];for(e=0;e0,maxRetries:this.maxRetries},(function(i,n){i?e&&e("Error loading material: "+t.original+" ["+i+"]"):e&&(n._engine=!0,e(null,n))}))},i.open=function(t,e){var i=this._parser.parse(e);return e._engine&&(i._data=e,delete e._engine),i},i._createPlaceholders=function(){this._placeholderTextures={};var t={white:[255,255,255,255],gray:[128,128,128,255],black:[0,0,0,255],normal:[128,128,255,255]};for(var e in t)if(t.hasOwnProperty(e)){this._placeholderTextures[e]=new or(this._device,{width:2,height:2,format:7,name:"material_placeholder"});for(var i=this._placeholderTextures[e].lock(),n=0;n<4;n++)for(var s=0;s<4;s++)i[4*n+s]=t[e][s];this._placeholderTextures[e].unlock()}},i.patch=function(t,e){t.resource._data&&(t._data=t.resource._data,delete t.resource._data),t.data.name=t.name,t.resource.name=t.name,this._bindAndAssignAssets(t,e),t.off("unload",this._onAssetUnload,this),t.on("unload",this._onAssetUnload,this)},i._onAssetUnload=function(t){delete t.data.parameters,delete t.data.chunks,delete t.data.name},i._assignTexture=function(t,e,i){e.resource[t]=i},i._getPlaceholderTexture=function(t){this._placeholderTextures||this._createPlaceholders();var e=FT[t];return this._placeholderTextures[e]},i._assignPlaceholderTexture=function(t,e){e.resource[t]=this._getPlaceholderTexture(t)},i._onTextureLoad=function(t,e,i){this._assignTexture(t,e,i.resource),e.resource.update()},i._onTextureAdd=function(t,e,i){this._assets.load(i)},i._onTextureRemoveOrUnload=function(t,e,i){var n=e.resource;n&&e.resource[t]===i.resource&&(this._assignPlaceholderTexture(t,e),n.update())},i._assignCubemap=function(t,e,i){if(e.resource[t]=i[0],"cubeMap"===t){var n=i.slice(1);n.every((function(t){return t}))?e.resource.prefilteredCubemaps=n:n[0]&&(e.resource.envAtlas=n[0])}},i._onCubemapLoad=function(t,e,i){this._assignCubemap(t,e,i.resources),this._parser.initialize(e.resource,e.data)},i._onCubemapAdd=function(t,e,i){0===e.data.shadingModel&&(e.loadFaces=!0),this._assets.load(i)},i._onCubemapRemoveOrUnload=function(t,e,i){var n=e.resource;e.data.prefilteredCubeMap128===i.resources[1]&&(this._assignCubemap(t,e,[null,null,null,null,null,null,null]),n.update())},i._bindAndAssignAssets=function(t,e){var i,n,s,r=this._parser.migrate(t.data),a=t.resource,o="path"===r.mappingFormat,h=Ec;for(i=0;i0&&(h>65535&&this._device.extUintElement?(s=new jr(this._device,2,a),r=new Uint32Array(s.lock())):(s=new jr(this._device,1,a),r=new Uint16Array(s.lock()))),{buffer:s,data:r}},e._parseMeshes=function(t,e,i,n,s,r){for(var a=t.model,o=[],h=0,l=0;l0,maxRetries:this.maxRetries};(t.load.startsWith("blob:")||t.load.startsWith("data:"))&&(".glb"===D.getExtension(t.original).toLowerCase()?s.responseType=Za.ResponseType.ARRAY_BUFFER:s.responseType=Za.ResponseType.JSON),Qa.get(t.load,s,(function(s,r){if(e)if(s)e("Error loading model: "+t.original+" ["+s+"]");else{for(var a=0;a0,maxRetries:this.maxRetries},(function(i,n){i?e("Error loading shader resource: "+t.original+" ["+i+"]"):e(null,n)}))},i.openBinary=function(t){return null!=this.decoder||(this.decoder=new TextDecoder("utf-8")),this.decoder.decode(t)},e}(pm);function ZT(t){this.resource&&(this.resource.atlas=t.resource)}function QT(t){this.registry.load(t)}var JT=function(t){function e(e){var i;return(i=t.call(this,e,"sprite")||this)._assets=e.assets,i._device=e.graphicsDevice,i}x(e,t);var i=e.prototype;return i.load=function(t,e){"string"==typeof t&&(t={load:t,original:t}),".json"===D.getExtension(t.original)&&Qa.get(t.load,{retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(t,i){t?e(t):e(null,i)}))},i.open=function(t,e){var i=new jf(this._device);return t&&(i.__data=e),i},i.patch=function(t,e){var i=t.resource;if(i.__data&&(t.data.pixelsPerUnit=i.__data.pixelsPerUnit,t.data.renderMode=i.__data.renderMode,t.data.frameKeys=i.__data.frameKeys,i.__data.textureAtlasAsset)){var n=e.getByUrl(i.__data.textureAtlasAsset);n?t.data.textureAtlasAsset=n.id:console.warn("Could not find textureatlas with url: "+i.__data.textureAtlasAsset)}i.startUpdate(),i.renderMode=t.data.renderMode,i.pixelsPerUnit=t.data.pixelsPerUnit,i.frameKeys=t.data.frameKeys,this._updateAtlas(t),i.endUpdate(),t.off("change",this._onAssetChange,this),t.on("change",this._onAssetChange,this)},i._updateAtlas=function(t){var e=t.resource;if(t.data.textureAtlasAsset){this._assets.off("load:"+t.data.textureAtlasAsset,ZT,t),this._assets.on("load:"+t.data.textureAtlasAsset,ZT,t);var i=this._assets.get(t.data.textureAtlasAsset);i&&i.resource?e.atlas=i.resource:i?this._assets.load(i):(this._assets.off("add:"+t.data.textureAtlasAsset,QT,t),this._assets.on("add:"+t.data.textureAtlasAsset,QT,t))}else e.atlas=null},i._onAssetChange=function(t,e,i,n){"data"===e&&i&&i.textureAtlasAsset&&n&&i.textureAtlasAsset!==n.textureAtlasAsset&&(this._assets.off("load:"+n.textureAtlasAsset,ZT,t),this._assets.off("add:"+n.textureAtlasAsset,QT,t))},e}(pm),$T=function(){function t(t,e){this._app=void 0,this._data=void 0,this._templateRoot=null,this._app=t,this._data=e}var e=t.prototype;return e.instantiate=function(){return this._templateRoot||this._parseTemplate(),this._templateRoot.clone()},e._parseTemplate=function(){var t=new PT(this._app,!0);this._templateRoot=t.parse(this._data)},t}(),tw=function(t){function e(e){var i;return(i=t.call(this,e,"template")||this).decoder=null,i}x(e,t);var i=e.prototype;return i.load=function(t,e){"string"==typeof t&&(t={load:t,original:t});var i={retry:this.maxRetries>0,maxRetries:this.maxRetries};Qa.get(t.load,i,(function(i,n){i?e("Error requesting template: "+t.original):e(i,n)}))},i.open=function(t,e){return new $T(this._app,e)},i.openBinary=function(t){return null!=this.decoder||(this.decoder=new TextDecoder("utf-8")),new $T(this._app,JSON.parse(this.decoder.decode(t)))},e}(pm),ew=function(t){function e(e){var i;return(i=t.call(this,e,"text")||this).decoder=null,i}x(e,t);var i=e.prototype;return i.load=function(t,e){"string"==typeof t&&(t={load:t,original:t}),Qa.get(t.load,{retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(i,n){i?e("Error loading text resource: "+t.original+" ["+i+"]"):e(null,n)}))},i.openBinary=function(t){return null!=this.decoder||(this.decoder=new TextDecoder("utf-8")),this.decoder.decode(t)},e}(pm),iw={repeat:0,clamp:1,mirror:2},nw={nearest:0,linear:1,nearest_mip_nearest:2,linear_mip_nearest:4,nearest_mip_linear:3,linear_mip_linear:5},sw=/^data\.frames\.(\d+)$/,rw=function(t){function e(e){var i;return(i=t.call(this,e,"textureatlas")||this)._loader=e.loader,i}x(e,t);var i=e.prototype;return i.load=function(t,e){"string"==typeof t&&(t={load:t,original:t});var i=this,n=this._loader.getHandler("texture");".json"===D.getExtension(t.original)?Qa.get(t.load,{retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(n,s){if(n)e(n);else{var r=t.original.replace(".json",".png");i._loader.load(r,"texture",(function(t,i){t?e(t):e(null,{data:s,texture:i})}))}})):n.load(t,e)},i.open=function(t,e){var i=new qf;if(e.texture&&e.data)i.texture=e.texture,i.__data=e.data;else{var n=this._loader.getHandler("texture").open(t,e);if(!n)return null;i.texture=n}return i},i.patch=function(t,e){if(t.resource){t.resource.__data&&(void 0!==t.resource.__data.minfilter&&(t.data.minfilter=t.resource.__data.minfilter),void 0!==t.resource.__data.magfilter&&(t.data.magfilter=t.resource.__data.magfilter),void 0!==t.resource.__data.addressu&&(t.data.addressu=t.resource.__data.addressu),void 0!==t.resource.__data.addressv&&(t.data.addressv=t.resource.__data.addressv),void 0!==t.resource.__data.mipmaps&&(t.data.mipmaps=t.resource.__data.mipmaps),void 0!==t.resource.__data.anisotropy&&(t.data.anisotropy=t.resource.__data.anisotropy),void 0!==t.resource.__data.rgbm&&(t.data.rgbm=!!t.resource.__data.rgbm),t.data.frames=t.resource.__data.frames,delete t.resource.__data);var i=t.resource.texture;if(i&&(i.name=t.name,t.data.hasOwnProperty("minfilter")&&i.minFilter!==nw[t.data.minfilter]&&(i.minFilter=nw[t.data.minfilter]),t.data.hasOwnProperty("magfilter")&&i.magFilter!==nw[t.data.magfilter]&&(i.magFilter=nw[t.data.magfilter]),t.data.hasOwnProperty("addressu")&&i.addressU!==iw[t.data.addressu]&&(i.addressU=iw[t.data.addressu]),t.data.hasOwnProperty("addressv")&&i.addressV!==iw[t.data.addressv]&&(i.addressV=iw[t.data.addressv]),t.data.hasOwnProperty("mipmaps")&&i.mipmaps!==t.data.mipmaps&&(i.mipmaps=t.data.mipmaps),t.data.hasOwnProperty("anisotropy")&&i.anisotropy!==t.data.anisotropy&&(i.anisotropy=t.data.anisotropy),t.data.hasOwnProperty("rgbm"))){var n=t.data.rgbm?di:ui;i.type!==n&&(i.type=n)}t.resource.texture=i;var s={};for(var r in t.data.frames){var a=t.data.frames[r];s[r]={rect:new Rt(a.rect),pivot:new Mt(a.pivot),border:new Rt(a.border)}}t.resource.frames=s,t.off("change",this._onAssetChange,this),t.on("change",this._onAssetChange,this)}},i._onAssetChange=function(t,e,i){var n;if("data"===e||"data.frames"===e){var s={};for(var r in i.frames)n=i.frames[r],s[r]={rect:new Rt(n.rect),pivot:new Mt(n.pivot),border:new Rt(n.border)};t.resource.frames=s}else{var a=e.match(sw);if(a){var o=a[1];i?(t.resource.frames[o]?((n=t.resource.frames[o]).rect.set(i.rect[0],i.rect[1],i.rect[2],i.rect[3]),n.pivot.set(i.pivot[0],i.pivot[1]),n.border.set(i.border[0],i.border[1],i.border[2],i.border[3])):t.resource.frames[o]={rect:new Rt(i.rect),pivot:new Mt(i.pivot),border:new Rt(i.border)},t.resource.fire("set:frame",o,t.resource.frames[o])):t.resource.frames[o]&&(delete t.resource.frames[o],t.resource.fire("remove:frame",o))}}},e}(pm);function aw(){var t,e,i,n=0,s=1,r=2,a=3,o=8,h=9,l=10,c=11,u=12,d=13,f=14,p=16,m={astc:l,dxt:r,etc1:n,etc2:n,pvr:o,atc:c,none:f},_={astc:l,dxt:a,etc1:p,etc2:s,pvr:h,atc:u,none:p},v=21,g=22,y=23,x=8,S=10,b=26,T=27,w=28,E=29,A=30,C=7,M=3,P=5,R=function(t,e){switch(t){case n:return e.formats.etc1?v:g;case s:return y;case r:return x;case a:return S;case o:return b;case h:return T;case l:return w;case c:return E;case u:return A;case d:return C;case f:return M;case p:return P}},I=function(t){for(var e=function(t,e){var i=t*(2/255)-1,n=e*(2/255)-1,s=Math.sqrt(1-Math.min(1,i*i+n*n));return Math.max(0,Math.min(255,Math.floor(.5*(s+1)*255)))},i=0;i>3}return e},L=function(){return"undefined"!=typeof performance?performance.now():0},k=function(t,n,s){if(s){if(t.formats.astc)return"astc"}else if(n){if(t.formats.etc2)return"etc2"}else if(t.formats.etc1||t.formats.etc2)return"etc1";return function(e){for(var i=0;i0?this.clients.shift().run(s):this.queue.push(s)}},e.enqueueClient=function(t){this.queue.length>0?t.run(this.queue.shift()):this.clients.push(t)},e.handleResponse=function(t,e,i){var n=this.callbacks[t];if(e)for(var s=0;s0,maxRetries:t.maxRetries};if(t.glueUrl&&t.wasmUrl&&function(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){var t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1}()){var r=null,a=null;Qa.get(t.glueUrl,s,(function(t,i){t?e(t):a?n(i,a):r=i}));var o=fetch(t.wasmUrl),h=function(){o.then((function(t){return t.arrayBuffer()})).then((function(t){return WebAssembly.compile(t)})).then((function(t){r?n(r,t):a=t})).catch((function(t){e(t,null)}))};WebAssembly.compileStreaming?WebAssembly.compileStreaming(o).then((function(t){r?n(r,t):a=t})).catch((function(t){h()})):h()}else Qa.get(t.fallbackUrl,s,(function(t,i){t?e(t,null):n(i,null)}))}(t,(function(t,e){if(t)console.error("failed to initialize basis worker: "+t);else for(var s=0;s0&&++a<=o){var i=100*Math.pow(2,a);console.log("Error loading Texture from: '"+e+"' - Retrying in "+i+"ms...");var h=t.indexOf("?")>=0?"&":"?";r=setTimeout((function(){s.src=t+h+"retry="+Date.now(),r=null}),i)}else n("Error loading Texture from: '"+e+"'")},s.src=t},i._loadImageBitmap=function(t,e,i,n){var s=this,r={cache:!0,responseType:"blob",retry:this.maxRetries>0,maxRetries:this.maxRetries};Qa.get(t,r,(function(t,e){t?n(t):s._loadImageBitmapFromBlob(e,n)}))},i._loadImageBitmapFromBlob=function(t,e){createImageBitmap(t,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then((function(t){return e(null,t)})).catch((function(t){return e(t)}))},e}(gw),Sw=[1481919403,3140563232,169478669],bw={33776:8,33778:9,33779:fe,36196:be,37492:22,37496:23,35840:Ee,35841:Te,35842:Ae,35843:we,32849:6,32856:7,35905:19,35907:20,35898:Se,34843:pe,34842:me};var Tw=function(t){function e(e){var i;return(i=t.call(this)||this).maxRetries=0,i}x(e,t);var i=e.prototype;return i.load=function(t,e,i){om.fetchArrayBuffer(t.load,e,i,this.maxRetries)},i.open=function(t,e,i,n){void 0===n&&(n={});var s=this.parse(e);if(!s)return null;var r=new or(i,y({name:t,addressU:s.cubemap?1:0,addressV:s.cubemap?1:0,width:s.width,height:s.height,format:s.format,cubemap:s.cubemap,levels:s.levels},n));return r.upload(),r},i.parse=function(t){var e=new Uint32Array(t);if(Sw[0]!==e[0]||Sw[1]!==e[1]||Sw[2]!==e[2])return null;var i={endianness:e[3],glType:e[4],glTypeSize:e[5],glFormat:e[6],glInternalFormat:e[7],glBaseInternalFormat:e[8],pixelWidth:e[9],pixelHeight:e[10],pixelDepth:e[11],numberOfArrayElements:e[12],numberOfFaces:e[13],numberOfMipmapLevels:e[14],bytesOfKeyValueData:e[15]};if(i.pixelDepth>1)return null;if(0!==i.numberOfArrayElements)return null;var n=bw[i.glInternalFormat];if(void 0===n)return null;for(var s,r,a,o=16+i.bytesOfKeyValueData/4,h=i.numberOfFaces>1,l=[],c=0;c<(i.numberOfMipmapLevels||1);c++){var u=e[o++];h&&l.push([]);for(var d=h?l[c]:l,f=0;f<(h?6:1);++f)d.push((s=t,r=4*o,a=u,n===Se?new Uint32Array(s,r,a/4):new Uint8Array(s,r,a))),o+=u+3>>2}return{format:n,width:i.pixelWidth,height:i.pixelHeight,levels:l,cubemap:h}},e}(gw),ww=166,Ew=function(t){function e(e,i){var n;return(n=t.call(this)||this).maxRetries=0,n.device=i,n}x(e,t);var i=e.prototype;return i.load=function(t,e,i){var n=this;om.fetchArrayBuffer(t.load,(function(s,r){s?e(s,r):n.parse(r,t,e,i)}),i,this.maxRetries)},i.open=function(t,e,i,n){void 0===n&&(n={});var s=new or(i,y({name:t,addressU:e.cubemap?1:0,addressV:e.cubemap?1:0,width:e.width,height:e.height,format:e.format,cubemap:e.cubemap,levels:e.levels},n));return s.upload(),s},i.parse=function(t,e,i,n){var s=new at(t),r=[s.readU32be(),s.readU32be(),s.readU32be()];if(2873840728!==r[0]||540160187!==r[1]||218765834!==r[2])return null;for(var a={vkFormat:s.readU32(),typeSize:s.readU32(),pixelWidth:s.readU32(),pixelHeight:s.readU32(),pixelDepth:s.readU32(),layerCount:s.readU32(),faceCount:s.readU32(),levelCount:s.readU32(),supercompressionScheme:s.readU32()},o={dfdByteOffset:s.readU32(),dfdByteLength:s.readU32(),kvdByteOffset:s.readU32(),kvdByteLength:s.readU32(),sgdByteOffset:s.readU64(),sgdByteLength:s.readU64()},h=[],l=0;l1},n));for(var T,w=128,E=d?6:1,A=c===f?8:16,C=0;C32767)return this._readPixelsFlat(t,e,i);var s=[0,0,0,0];if(t.readArray(s),2!==s[0]||2!==s[1]||128&s[2])return t.skip(-4),this._readPixelsFlat(t,e,i);var r,a,o,h,l,c,u=new ArrayBuffer(e*i*4),d=new Uint8Array(u),f=n?0:4*e*(i-1);for(a=0;a128){if(r+(l-=128)>e)return null;for(c=t.readU8(),o=0;oe)return null;for(o=0;o=0?t.split("?")[0]:t},i._getParser=function(t){var e=D.getExtension(this._getUrlWithoutParams(t)).toLowerCase().replace(".","");return this.parsers[e]||this.imgParser},i._getTextureOptions=function(t){var e={};if(t){var i;(null==(i=t.name)?void 0:i.length)>0&&(e.name=t.name);var n=t.data;n.hasOwnProperty("minfilter")&&(e.minFilter=Pw[n.minfilter]),n.hasOwnProperty("magfilter")&&(e.magFilter=Pw[n.magfilter]),n.hasOwnProperty("addressu")&&(e.addressU=Mw[n.addressu]),n.hasOwnProperty("addressv")&&(e.addressV=Mw[n.addressv]),n.hasOwnProperty("mipmaps")&&(e.mipmaps=n.mipmaps),n.hasOwnProperty("anisotropy")&&(e.anisotropy=n.anisotropy),n.hasOwnProperty("flipY")&&(e.flipY=!!n.flipY),n.hasOwnProperty("type")?e.type=Rw[n.type]:n.hasOwnProperty("rgbm")&&n.rgbm?e.type=di:t.file&&8&t.file.opt&&(e.type=mi)}return e},i.load=function(t,e,i){"string"==typeof t&&(t={load:t,original:t}),this._getParser(t.original).load(t,e,i)},i.open=function(t,e,i){if(t){var n=this._getTextureOptions(i),s=this._getParser(t).open(t,e,this._device,n);return null===s?s=new or(this._device,{width:4,height:4,format:6}):(!function(t){var e=bs.calcMipLevelsCount(t._width,t._height);if(!(7!==t._format&&t._format!==ve||t._volume||t._compressed||1===t._levels.length||t._levels.length===e||(i=t._cubemap?t._levels[0][0]:t._levels[0],i instanceof HTMLCanvasElement||i instanceof HTMLImageElement||i instanceof HTMLVideoElement))){for(var i,n=function(t,e,i){for(var n=Math.max(1,t>>1),s=Math.max(1,e>>1),r=new i.constructor(n*s*4),a=Math.floor(t/n),o=Math.floor(e/s),h=a*o,l=0;l>s-1),a=Math.max(1,t._height>>s-1);if(t._cubemap){for(var o=[],h=0;h<6;++h)o.push(n(r,a,t._levels[s-1][h]));t._levels.push(o)}else t._levels.push(n(r,a,t._levels[s-1]))}t._levelsUpdated=t._cubemap?[[!0,!0,!0,!0,!0,!0]]:[!0]}}(s),e.unswizzledGGGR&&(i.file.variants.basis.opt&=-9)),s}},i.patch=function(t,e){var i=t.resource;if(i)for(var n=this._getTextureOptions(t),s=0,r=Object.keys(n);s=a||(a=d,o=t[c],h.copy(u.transform.position),l.copy(u.transform.orientation))}this.fire("result",h,l,e||this._inputSource,o),this.manager.hitTest.fire("result",this,h,l,e||this._inputSource,o),Hw.push(r),Hw.push(h),Ww.push(l)}},e}(P);Xw.EVENT_REMOVE="remove",Xw.EVENT_RESULT="result";var jw=function(t){function e(e){var i;return(i=t.call(this)||this).manager=void 0,i._supported=G.browser&&!(!window.XRSession||!window.XRSession.prototype.requestHitTestSource),i._available=!1,i._checkingAvailability=!1,i.sources=[],i.manager=e,i._supported&&(i.manager.on("start",i._onSessionStart,i),i.manager.on("end",i._onSessionEnd,i)),i}x(e,t);var i=e.prototype;return i._onSessionStart=function(){var t=this;if(this.manager.session.enabledFeatures){var e=-1!==this.manager.session.enabledFeatures.indexOf("hit-test");if(!e)return;this._available=e,this.fire("available")}else this._checkingAvailability||(this._checkingAvailability=!0,this.manager.session.requestReferenceSpace(Ow).then((function(e){t.manager.session.requestHitTestSource({space:e}).then((function(e){e.cancel(),t.manager.active&&(t._available=!0,t.fire("available"))})).catch((function(){}))})).catch((function(){})))},i._onSessionEnd=function(){if(this._available){this._available=!1;for(var t=0;t0&&(rE.sub2(this._localPosition,this._localPositionLast).divScalar(s),this._linearVelocity.lerp(this._linearVelocity,rE,.15))}else this._velocitiesAvailable=!1}var r=t.getPose(this._xrInputSource.targetRaySpace,this._manager._referenceSpace);r&&(this._dirtyRay=!0,this._rayLocal.origin.copy(r.transform.position),this._rayLocal.direction.set(0,0,-1),aE.copy(r.transform.orientation),aE.transformVector(this._rayLocal.direction,this._rayLocal.direction))}},i._updateTransforms=function(){this._dirtyLocal&&(this._dirtyLocal=!1,this._localTransform.setTRS(this._localPosition,this._localRotation,wt.ONE));var t=this._manager.camera.parent;t?this._worldTransform.mul2(t.getWorldTransform(),this._localTransform):this._worldTransform.copy(this._localTransform)},i._updateRayTransforms=function(){var t=this._dirtyRay;if(this._dirtyRay=!1,this._manager.camera.parent){var e=this._manager.camera.parent.getWorldTransform();e.getTranslation(this._position),this._rotation.setFromMat4(e),this._rotation.transformVector(this._rayLocal.origin,this._ray.origin),this._ray.origin.add(this._position),this._rotation.transformVector(this._rayLocal.direction,this._ray.direction)}else t&&(this._ray.origin.copy(this._rayLocal.origin),this._ray.direction.copy(this._rayLocal.direction))},i.getPosition=function(){return this._position?(this._updateTransforms(),this._worldTransform.getTranslation(this._position),this._position):null},i.getLocalPosition=function(){return this._localPosition},i.getRotation=function(){return this._rotation?(this._updateTransforms(),this._rotation.setFromMat4(this._worldTransform),this._rotation):null},i.getLocalRotation=function(){return this._localRotation},i.getLinearVelocity=function(){return this._velocitiesAvailable?this._linearVelocity:null},i.getOrigin=function(){return this._updateRayTransforms(),this._ray.origin},i.getDirection=function(){return this._updateRayTransforms(),this._ray.direction},i.hitTestStart=function(t){var e=this;void 0===t&&(t={}),t.inputSource=this,t.profile=this._xrInputSource.profiles[0];var i=t.callback;t.callback=function(t,n){n&&e.onHitTestSourceAdd(n),i&&i(t,n)},this._manager.hitTest.start(t)},i.onHitTestSourceAdd=function(t){var e=this;this._hitTestSources.push(t),this.fire("hittest:add",t),t.on("result",(function(i,n,s,r){s===e&&e.fire("hittest:result",t,i,n,r)})),t.once("remove",(function(){e.onHitTestSourceRemove(t),e.fire("hittest:remove",t)}))},i.onHitTestSourceRemove=function(t){var e=this._hitTestSources.indexOf(t);-1!==e&&this._hitTestSources.splice(e,1)},v(e,[{key:"id",get:function(){return this._id}},{key:"inputSource",get:function(){return this._xrInputSource}},{key:"targetRayMode",get:function(){return this._xrInputSource.targetRayMode}},{key:"handedness",get:function(){return this._xrInputSource.handedness}},{key:"profiles",get:function(){return this._xrInputSource.profiles}},{key:"grip",get:function(){return this._grip}},{key:"hand",get:function(){return this._hand}},{key:"gamepad",get:function(){return this._xrInputSource.gamepad||null}},{key:"selecting",get:function(){return this._selecting}},{key:"squeezing",get:function(){return this._squeezing}},{key:"elementInput",get:function(){return this._elementInput},set:function(t){this._elementInput!==t&&(this._elementInput=t,this._elementInput||(this._elementEntity=null))}},{key:"elementEntity",get:function(){return this._elementEntity}},{key:"hitTestSources",get:function(){return this._hitTestSources}}])}(P);hE.EVENT_REMOVE="remove",hE.EVENT_SELECT="select",hE.EVENT_SELECTSTART="selectstart",hE.EVENT_SELECTEND="selectend",hE.EVENT_SQUEEZE="squeeze",hE.EVENT_SQUEEZESTART="squeezestart",hE.EVENT_SQUEEZEEND="squeezeend",hE.EVENT_HITTESTADD="hittest:add",hE.EVENT_HITTESTREMOVE="hittest:remove",hE.EVENT_HITTESTRESULT="hittest:result";var lE=function(t){function e(e){var i,n;return(n=t.call(this)||this).manager=void 0,n._inputSources=[],n._onInputSourcesChangeEvt=void 0,n.velocitiesSupported=!1,n.manager=e,n.velocitiesSupported=!(!G.browser||null==(i=window.XRPose)||null==(i=i.prototype)||!i.hasOwnProperty("linearVelocity")),n._onInputSourcesChangeEvt=function(t){n._onInputSourcesChange(t)},n.manager.on("start",n._onSessionStart,n),n.manager.on("end",n._onSessionEnd,n),n}x(e,t);var i=e.prototype;return i._onSessionStart=function(){var t=this,e=this.manager.session;e.addEventListener("inputsourceschange",this._onInputSourcesChangeEvt),e.addEventListener("select",(function(e){var i=t._getByInputSource(e.inputSource);i.update(e.frame),i.fire("select",e),t.fire("select",i,e)})),e.addEventListener("selectstart",(function(e){var i=t._getByInputSource(e.inputSource);i.update(e.frame),i._selecting=!0,i.fire("selectstart",e),t.fire("selectstart",i,e)})),e.addEventListener("selectend",(function(e){var i=t._getByInputSource(e.inputSource);i.update(e.frame),i._selecting=!1,i.fire("selectend",e),t.fire("selectend",i,e)})),e.addEventListener("squeeze",(function(e){var i=t._getByInputSource(e.inputSource);i.update(e.frame),i.fire("squeeze",e),t.fire("squeeze",i,e)})),e.addEventListener("squeezestart",(function(e){var i=t._getByInputSource(e.inputSource);i.update(e.frame),i._squeezing=!0,i.fire("squeezestart",e),t.fire("squeezestart",i,e)})),e.addEventListener("squeezeend",(function(e){var i=t._getByInputSource(e.inputSource);i.update(e.frame),i._squeezing=!1,i.fire("squeezeend",e),t.fire("squeezeend",i,e)}));for(var i=e.inputSources,n=0;n0){var o=new Bt,h=this.views.list[0];o.copy(h.projMat);var l=o.data,c=2*Math.atan(1/l[5])*180/Math.PI,u=l[5]/l[0],d=l[14]/(l[10]+1),f=l[14]/(l[10]-1);this._camera.camera.setXrProperties({aspectRatio:u,farClip:d,fov:c,horizontalFov:!1,nearClip:f})}return this._camera.camera._node.setLocalPosition(this._localPosition),this._camera.camera._node.setLocalRotation(this._localRotation),this.input.update(t),this._type===kw&&(this.hitTest.supported&&this.hitTest.update(t),this.lightEstimation.supported&&this.lightEstimation.update(t),this.imageTracking.supported&&this.imageTracking.update(t),this.anchors.supported&&this.anchors.update(t),this.planeDetection.supported&&this.planeDetection.update(t),this.depthSensing.supported&&this.depthSensing.update(),this.meshDetection.supported&&this.meshDetection.update(t)),this.fire("update",t),!0},v(e,[{key:"supported",get:function(){return this._supported}},{key:"active",get:function(){return!!this._session}},{key:"type",get:function(){return this._type}},{key:"spaceType",get:function(){return this._spaceType}},{key:"session",get:function(){return this._session}},{key:"frameRate",get:function(){var t,e;return null!=(t=null==(e=this._session)?void 0:e.frameRate)?t:null}},{key:"supportedFrameRates",get:function(){return this._supportedFrameRates}},{key:"framebufferScaleFactor",get:function(){return this._framebufferScaleFactor}},{key:"fixedFoveation",get:function(){var t,e;return null!=(t=null==(e=this._baseLayer)?void 0:e.fixedFoveation)?t:null},set:function(t){var e,i;null!==(null!=(e=null==(i=this._baseLayer)?void 0:i.fixedFoveation)?e:null)&&(this.app.graphicsDevice.samples,this._baseLayer.fixedFoveation=t)}},{key:"camera",get:function(){return this._camera?this._camera.entity:null}},{key:"visibilityState",get:function(){return this._session?this._session.visibilityState:null}}])}(P);wE.EVENT_AVAILABLE="available",wE.EVENT_START="start",wE.EVENT_END="end",wE.EVENT_UPDATE="update",wE.EVENT_ERROR="error";var EE,AE,CE=function(t){function e(e,i){var n,s;void 0===i&&(i={}),s=t.call(this,e)||this;var r=new Rm;return r.graphicsDevice=null!=(n=i.graphicsDevice)?n:s.createDevice(e,i),s.addComponentSystems(r),s.addResourceHandles(r),r.elementInput=i.elementInput,r.keyboard=i.keyboard,r.mouse=i.mouse,r.touch=i.touch,r.gamepads=i.gamepads,r.scriptPrefix=i.scriptPrefix,r.assetPrefix=i.assetPrefix,r.scriptsOrder=i.scriptsOrder,r.soundManager=new ro,r.lightmapper=Vm,r.batchManager=Yh,r.xr=wE,s.init(r),s}x(e,t);var i=e.prototype;return i.createDevice=function(t,e){return e.graphicsDeviceOptions||(e.graphicsDeviceOptions={}),G.browser&&navigator.xr&&(e.graphicsDeviceOptions.xrCompatible=!0),e.graphicsDeviceOptions.alpha=e.graphicsDeviceOptions.alpha||!1,new Fr(t,e.graphicsDeviceOptions)},i.addComponentSystems=function(t){t.componentSystems=[Jy,Jv,Xg,R_,Q_,vy,ky,aS,cS,Hp.legacy?mx:AS,rv,Ux,ev,Ay,rx,Fg,wv,Px,Lx,Zx,uy,Kg,tS,IS]},i.addResourceHandles=function(t){t.resourceHandlers=[FS,Vb,Gb,Hb,GT,BT,Iw,ew,LT,jb,YT,HT,$b,DT,Jb,KT,IT,tT,rT,qb,rw,JT,tw,Qb,AT]},e}(Cm),ME=function(t){function e(e,i){var n;return(n=t.call(this)||this)._assets=new Set,n._loadingAssets=new Set,n._waitingAssets=new Set,n._registry=i,n._loading=!1,n._loaded=!1,n._failed=[],e.forEach((function(t){if(t instanceof om)t.registry||(t.registry=i),n._assets.add(t);else{var e=i.get(t);e?n._assets.add(e):n._waitForAsset(t)}})),n}x(e,t);var i=e.prototype;return i.destroy=function(){var t=this;this._registry.off("load",this._onLoad),this._registry.off("error",this._onError),this._waitingAssets.forEach((function(e){t._registry.off("add:"+e,this._onAddAsset)})),this.off("progress"),this.off("load")},i._assetHasDependencies=function(t){var e;return"model"===t.type&&(null==(e=t.file)?void 0:e.url)&&t.file.url&&t.file.url.match(/.json$/g)},i.load=function(t,e){var i=this;if(!this._loading){this._loading=!0,this._callback=t,this._scope=e,this._registry.on("load",this._onLoad,this),this._registry.on("error",this._onError,this);var n=!1;this._assets.forEach((function(t){t.loaded||(n=!0,i._assetHasDependencies(t)&&i._registry.loadFromUrl(t.file.url,t.type,(function(e,n){e?i._onError(e,t):i._onLoad(t)})),i._loadingAssets.add(t),i._registry.add(t))})),this._loadingAssets.forEach((function(t){i._assetHasDependencies(t)||i._registry.load(t)})),n||0!==this._waitingAssets.size||this._loadingComplete()}},i.ready=function(t,e){void 0===e&&(e=this),this._loaded?t.call(e,Array.from(this._assets)):this.once("load",(function(i){t.call(e,i)}))},i._loadingComplete=function(){this._loaded||(this._loaded=!0,this._registry.off("load",this._onLoad,this),this._registry.off("error",this._onError,this),this._failed.length?(this._callback&&this._callback.call(this._scope,"Failed to load some assets",this._failed),this.fire("error",this._failed)):(this._callback&&this._callback.call(this._scope),this.fire("load",Array.from(this._assets))))},i._onLoad=function(t){var e=this;this._loadingAssets.has(t)&&(this.fire("progress",t),this._loadingAssets.delete(t)),0===this._loadingAssets.size&&setTimeout((function(){e._loadingComplete(e._failed)}),0)},i._onError=function(t,e){var i=this;this._loadingAssets.has(e)&&(this._failed.push(e),this._loadingAssets.delete(e)),0===this._loadingAssets.size&&setTimeout((function(){i._loadingComplete(i._failed)}),0)},i._onAddAsset=function(t){this._waitingAssets.delete(t),this._assets.add(t),t.loaded||(this._loadingAssets.add(t),this._registry.load(t))},i._waitForAsset=function(t){this._waitingAssets.add(t),this._registry.once("add:"+t,this._onAddAsset,this)},e}(P),PE=function(){function t(t,e,i,n){this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=i,this.texture=new or(t,{name:n,format:7,width:e,height:i,mipmaps:!0,minFilter:5,magFilter:1,addressU:1,addressV:1,levels:[this.canvas]}),this.ctx=this.canvas.getContext("2d",{alpha:!0})}var e=t.prototype;return e.destroy=function(){this.texture.destroy()},e.clear=function(t){var e=this.canvas,i=e.width,n=e.height;this.ctx.clearRect(0,0,i,n),this.ctx.fillStyle=t,this.ctx.fillRect(0,0,i,n)},t}(),RE=function(t){function e(e,i){var n;return void 0===i&&(i={}),(n=t.call(this)||this).type="bitmap",n.app=e,n.intensity=0,n.fontWeight=i.fontWeight||"normal",n.fontSize=parseInt(i.fontSize,10),n.glyphSize=n.fontSize,n.fontName=i.fontName||"Arial",n.color=i.color||new pt(1,1,1),n.padding=i.padding||0,n.width=Math.min(4096,i.width||512),n.height=Math.min(4096,i.height||512),n.atlases=[],n.chars="",n.data={},n}x(e,t);var i=e.prototype;return i.createTextures=function(t){var e=this._normalizeCharsSet(t);if(e.length===this.chars.length){for(var i=0;i0&&this._renderAtlas(this.chars.concat(i))},i.destroy=function(){this.atlases.forEach((function(t){return t.destroy()})),this.chars=null,this.color=null,this.data=null,this.fontName=null,this.fontSize=null,this.glyphSize=null,this.intensity=null,this.atlases=null,this.type=null,this.fontWeight=null},i._colorToRgbString=function(t,e){var i=Math.round(255*t.r),n=Math.round(255*t.g),s=Math.round(255*t.b);return e?"rgba("+i+", "+n+", "+s+", "+t.a+")":"rgb("+i+", "+n+", "+s+")"},i.renderCharacter=function(t,e,i,n,s){t.fillStyle=s,t.fillText(e,i,n)},i._getAtlas=function(t){return t>=this.atlases.length&&(this.atlases[t]=new PE(this.app.graphicsDevice,this.width,this.height,"font-atlas-"+this.fontName+"-"+t)),this.atlases[t]},i._renderAtlas=function(t){this.chars=t;var e=this.width,i=this.height,n=this._colorToRgbString(this.color,!1),s=this.color.a;this.color.a=1/255;var r=this._colorToRgbString(this.color,!0);this.color.a=s;var a=0,o=this._getAtlas(a++);o.clear(r),this.data=this._createJson(this.chars,this.fontName,e,i);for(var h=it.getSymbols(this.chars.join("")),l=0,c=0,u={},d=0;dT&&(T=this.fontSize*this.fontSize/w,o.ctx.font=this.fontWeight+" "+T.toString()+"px "+this.fontName,w=this.fontSize),this.renderCharacter(o.ctx,S,g+_,y+v,n);var E=this.padding+(this.glyphSize-w)/2,A=-this.padding+u[S].descent-c,C=w;this._addChar(this.data,S,b,g,y,p,m,E,A,C,a-1,e,i),(g+=p)+p>e&&(g=0,(y+=m)+m>i&&((o=this._getAtlas(a++)).clear(r),y=0))}this.atlases.splice(a).forEach((function(t){return t.destroy()})),this.atlases.forEach((function(t){return t.texture.upload()})),this.fire("render")},i._createJson=function(t,e,i,n){return{version:3,intensity:this.intensity,info:{face:e,width:i,height:n,maps:[{width:i,height:n}]},chars:{}}},i._addChar=function(t,e,i,n,s,r,a,o,h,l,c,u,d){t.info.maps.length0&&(e.setCameraUniforms(i.camera,a),e.renderForward(i.camera,IE,DE,3,(function(e){var i=e.id;u[0]=(i>>16&255)/255,u[1]=(i>>8&255)/255,u[2]=(255&i)/255,u[3]=(i>>24&255)/255,c.setValue(u),t.setBlendState(nn.NOBLEND)})),IE.length=0)}}},e}(Kr),kE=new Set,OE=function(){function t(t,e,i){this.renderTarget=null,this.mapping=new Map,t instanceof En&&(t=Np()),this.renderer=t.renderer,this.device=t.graphicsDevice,this.renderPass=new LE(this.device,t.renderer),this.width=0,this.height=0,this.resize(e,i)}var e=t.prototype;return e.getSelection=function(t,e,i,n){void 0===i&&(i=1),void 0===n&&(n=1);var s=this.device;e=this.renderTarget.height-(e+n),t=Math.floor(t),e=Math.floor(e),i=Math.floor(Math.max(i,1)),n=Math.floor(Math.max(n,1)),s.setRenderTarget(this.renderTarget),s.updateBegin();var r=new Uint8Array(4*i*n);s.readPixels(t,e,i,n,r),s.updateEnd();for(var a=this.mapping,o=0;o0?h.wheelDelta=1:e.deltaY<0&&(h.wheelDelta=-1)),h}return x(e,t),e}(cA),dA=function(t){function e(e,i,n,s,r,a){var o;return(o=t.call(this,e,i,n)||this).touches=e.touches,o.changedTouches=e.changedTouches,o.x=s,o.y=r,o.touch=a,o}return x(e,t),e}(cA),fA=function(t){function e(e,i,n,s){var r;return(r=t.call(this,e,i,n)||this).inputSource=s,r}return x(e,t),e}(cA),pA=function(){function t(t,e){this._app=null,this._attached=!1,this._target=null,this._enabled=!0,this._lastX=0,this._lastY=0,this._upHandler=this._handleUp.bind(this),this._downHandler=this._handleDown.bind(this),this._moveHandler=this._handleMove.bind(this),this._wheelHandler=this._handleWheel.bind(this),this._touchstartHandler=this._handleTouchStart.bind(this),this._touchendHandler=this._handleTouchEnd.bind(this),this._touchcancelHandler=this._touchendHandler,this._touchmoveHandler=this._handleTouchMove.bind(this),this._sortHandler=this._sortElements.bind(this),this._elements=[],this._hoveredElement=null,this._pressedElement=null,this._touchedElements={},this._touchesForWhichTouchLeaveHasFired={},this._selectedElements={},this._selectedPressedElements={},this._useMouse=!e||!1!==e.useMouse,this._useTouch=!e||!1!==e.useTouch,this._useXr=!e||!1!==e.useXr,this._selectEventsAttached=!1,G.touch&&(this._clickedEntities={}),this.attach(t)}var e=t.prototype;return e.attach=function(t){this._attached&&(this._attached=!1,this.detach()),this._target=t,this._attached=!0;var e=!!G.passiveEvents&&{passive:!0};this._useMouse&&(window.addEventListener("mouseup",this._upHandler,e),window.addEventListener("mousedown",this._downHandler,e),window.addEventListener("mousemove",this._moveHandler,e),window.addEventListener("wheel",this._wheelHandler,e)),this._useTouch&&G.touch&&(this._target.addEventListener("touchstart",this._touchstartHandler,e),this._target.addEventListener("touchend",this._touchendHandler,!1),this._target.addEventListener("touchmove",this._touchmoveHandler,!1),this._target.addEventListener("touchcancel",this._touchcancelHandler,!1)),this.attachSelectEvents()},e.attachSelectEvents=function(){!this._selectEventsAttached&&this._useXr&&this.app&&this.app.xr&&this.app.xr.supported&&(this._clickedEntities||(this._clickedEntities={}),this._selectEventsAttached=!0,this.app.xr.on("start",this._onXrStart,this))},e.detach=function(){if(this._attached){this._attached=!1;var t=!!G.passiveEvents&&{passive:!0};this._useMouse&&(window.removeEventListener("mouseup",this._upHandler,t),window.removeEventListener("mousedown",this._downHandler,t),window.removeEventListener("mousemove",this._moveHandler,t),window.removeEventListener("wheel",this._wheelHandler,t)),this._useTouch&&(this._target.removeEventListener("touchstart",this._touchstartHandler,t),this._target.removeEventListener("touchend",this._touchendHandler,!1),this._target.removeEventListener("touchmove",this._touchmoveHandler,!1),this._target.removeEventListener("touchcancel",this._touchcancelHandler,!1)),this._selectEventsAttached&&(this._selectEventsAttached=!1,this.app.xr.off("start",this._onXrStart,this),this.app.xr.off("end",this._onXrEnd,this),this.app.xr.off("update",this._onXrUpdate,this),this.app.xr.input.off("selectstart",this._onSelectStart,this),this.app.xr.input.off("selectend",this._onSelectEnd,this),this.app.xr.input.off("remove",this._onXrInputRemove,this)),this._target=null}},e.addElement=function(t){-1===this._elements.indexOf(t)&&this._elements.push(t)},e.removeElement=function(t){var e=this._elements.indexOf(t);-1!==e&&this._elements.splice(e,1)},e._handleUp=function(t){this._enabled&&(Ia.isPointerLocked()||(this._calcMouseCoords(t),this._onElementMouseEvent("mouseup",t)))},e._handleDown=function(t){this._enabled&&(Ia.isPointerLocked()||(this._calcMouseCoords(t),this._onElementMouseEvent("mousedown",t)))},e._handleMove=function(t){this._enabled&&(this._calcMouseCoords(t),this._onElementMouseEvent("mousemove",t),this._lastX=EE,this._lastY=AE)},e._handleWheel=function(t){this._enabled&&(this._calcMouseCoords(t),this._onElementMouseEvent("mousewheel",t))},e._determineTouchedElements=function(t){for(var e={},i=this.app.systems.camera.cameras,n=i.length-1;n>=0;n--){for(var s=i[n],r=0,a=t.changedTouches.length,o=0;o=0;d--){this._getTargetElementByCoords(e[d],u.x,u.y)===o&&(this._clickedEntities[o.entity.getGuid()]||(this._fireEvent("click",new dA(t,o,h,l,c,r)),this._clickedEntities[o.entity.getGuid()]=Date.now()))}this._fireEvent(t.type,new dA(t,o,h,l,c,r))}}}},e._handleTouchMove=function(t){if(t.preventDefault(),this._enabled)for(var e=this._determineTouchedElements(t),i=0,n=t.changedTouches.length;i=0&&(s=r[a],!(i=this._getTargetElementByCoords(s,EE,AE)));a--);if(this._hoveredElement=i,"mousemove"!==t&&"mouseup"!==t||!this._pressedElement?i&&(this._fireEvent(t,new uA(e,i,s,EE,AE,this._lastX,this._lastY)),"mousedown"===t&&(this._pressedElement=i)):this._fireEvent(t,new uA(e,this._pressedElement,s,EE,AE,this._lastX,this._lastY)),n!==this._hoveredElement&&(n&&this._fireEvent("mouseleave",new uA(e,n,s,EE,AE,this._lastX,this._lastY)),this._hoveredElement&&this._fireEvent("mouseenter",new uA(e,this._hoveredElement,s,EE,AE,this._lastX,this._lastY))),"mouseup"===t&&this._pressedElement){if(this._pressedElement===this._hoveredElement){var o=this._hoveredElement.entity.getGuid(),h=!this._clickedEntities;if(this._clickedEntities){var l=this._clickedEntities[o]||0;h=Date.now()-l>300,delete this._clickedEntities[o]}h&&this._fireEvent("click",new uA(e,this._hoveredElement,s,EE,AE,this._lastX,this._lastY))}this._pressedElement=null}},e._onXrStart=function(){this.app.xr.on("end",this._onXrEnd,this),this.app.xr.on("update",this._onXrUpdate,this),this.app.xr.input.on("selectstart",this._onSelectStart,this),this.app.xr.input.on("selectend",this._onSelectEnd,this),this.app.xr.input.on("remove",this._onXrInputRemove,this)},e._onXrEnd=function(){this.app.xr.off("update",this._onXrUpdate,this),this.app.xr.input.off("selectstart",this._onSelectStart,this),this.app.xr.input.off("selectend",this._onSelectEnd,this),this.app.xr.input.off("remove",this._onXrInputRemove,this)},e._onXrUpdate=function(){if(this._enabled)for(var t=this.app.xr.input.inputSources,e=0;e=0&&(r=o[h],!(n=this._getTargetElementByRay(VE,r)));h--);}e._elementEntity=n||null,n?(this._selectedElements[e.id]=n,s=n):delete this._selectedElements[e.id],a!==s&&(a&&this._fireEvent("selectleave",new fA(i,a,r,e)),s&&this._fireEvent("selectenter",new fA(i,s,r,e)));var l=this._selectedPressedElements[e.id];"selectmove"===t&&l&&this._fireEvent("selectmove",new fA(i,l,r,e)),"selectstart"===t&&(this._selectedPressedElements[e.id]=s,s&&this._fireEvent("selectstart",new fA(i,s,r,e))),!e.elementInput&&l&&(delete this._selectedPressedElements[e.id],a&&this._fireEvent("selectend",new fA(i,l,r,e))),"selectend"===t&&e.elementInput&&(delete this._selectedPressedElements[e.id],l&&this._fireEvent("selectend",new fA(i,l,r,e)),l&&l===a&&this._fireEvent("click",new fA(i,l,r,e)))},e._fireEvent=function(t,e){for(var i=e.element;i.fire(t,e),!e._stopPropagation&&i.entity.parent&&(i=i.entity.parent.element););},e._calcMouseCoords=function(t){var e=this._target.getBoundingClientRect(),i=Math.floor(e.left),n=Math.floor(e.top);EE=t.clientX-i,AE=t.clientY-n},e._sortElements=function(t,e){var i=this.app.scene.layers.sortTransparentLayers(t.layers,e.layers);return 0!==i?i:t.screen&&!e.screen?-1:!t.screen&&e.screen?1:t.screen||e.screen?t.screen.screen.screenSpace&&!e.screen.screen.screenSpace?-1:e.screen.screen.screenSpace&&!t.screen.screen.screenSpace?1:e.drawOrder-t.drawOrder:0},e._getTargetElementByCoords=function(t,e,i){var n=this._calculateRayScreen(e,i,t,UE)?UE:null,s=this._calculateRay3d(e,i,t,zE)?zE:null;return this._getTargetElement(t,n,s)},e._getTargetElementByRay=function(t,e){UE.origin.copy(t.origin),UE.direction.copy(t.direction),UE.end.copy(UE.direction).mulScalar(2*e.farClip).add(UE.origin);var i=UE,n=e.worldToScreen(i.origin,BE),s=this._calculateRayScreen(n.x,n.y,e,zE)?zE:null;return this._getTargetElement(e,s,i)},e._getTargetElement=function(t,e,i){var n=null,s=1/0;this._elements.sort(this._sortHandler);for(var r=0,a=this._elements.length;r=0){n=o;break}}else{if(!i)continue;var h=this._checkElement(i,o,!1);if(h>=0&&(h=h&&d<=l&&f<=c&&f>=u&&(d=s*(d-h)/a,f=r-(f=r*(f-u)/o),n.origin.set(d,f,1),n.direction.set(0,0,-1),n.end.copy(n.direction).mulScalar(2).add(n.origin),!0)},e._calculateRay3d=function(t,e,i,n){var s=this._target.clientWidth,r=this._target.clientHeight,a=i.rect.z*s,o=i.rect.w*r,h=i.rect.x*s,l=h+a,c=(1-i.rect.y)*r,u=c-o,d=t,f=e;return t>=h&&t<=l&&e<=c&&f>=u&&(d=s*(d-h)/a,f=r*(f-u)/o,i.screenToWorld(d,f,i.nearClip,BE),i.screenToWorld(d,f,i.farClip,NE),n.origin.copy(BE),n.direction.set(0,0,-1),n.end.copy(NE),!0)},e._checkElement=function(e,i,n){if(i.maskedBy&&this._checkElement(e,i.maskedBy.element,n)<0)return-1;var s;s=n?t.calculateScaleToScreen(i):t.calculateScaleToWorld(i);var r=t.buildHitCorners(i,n?i.screenCorners:i.worldCorners,s);return function(t,e,i){GE.sub2(e,t),HE.sub2(i[0],t),WE.sub2(i[1],t),XE.sub2(i[2],t),qE.cross(XE,GE);var n,s,r=HE.dot(qE);if(r>=0){if((n=-WE.dot(qE))<0)return-1;if((s=lA(GE,WE,HE))<0)return-1;var a=1/(n+r+s);YE.copy(i[0]).mulScalar(n*a),KE.copy(i[1]).mulScalar(r*a),ZE.copy(i[2]).mulScalar(s*a),QE.copy(YE).add(KE).add(ZE)}else{if(jE.sub2(i[3],t),(n=jE.dot(qE))<0)return-1;if((s=lA(GE,HE,jE))<0)return-1;var o=1/(n+(r=-r)+s);YE.copy(i[0]).mulScalar(n*o),KE.copy(i[3]).mulScalar(r*o),ZE.copy(i[2]).mulScalar(s*o),QE.copy(YE).add(KE).add(ZE)}return GE.sub2(i[0],i[2]).lengthSq()<1e-8||GE.sub2(i[1],i[3]).lengthSq()<1e-8?-1:QE.sub(t).lengthSq()}(e.origin,e.end,r)},t.buildHitCorners=function(t,e,i){var n=e;if(t.entity&&t.entity.button){var s=t.entity.button.hitPadding||hA;tA.copy(t.entity.up),eA.copy(tA).mulScalar(-1),nA.copy(t.entity.right),iA.copy(nA).mulScalar(-1),tA.mulScalar(s.w*i.y),eA.mulScalar(s.y*i.y),nA.mulScalar(s.z*i.x),iA.mulScalar(s.x*i.x),sA.copy(n[0]).add(eA).add(iA),rA.copy(n[1]).add(eA).add(nA),aA.copy(n[2]).add(tA).add(nA),oA.copy(n[3]).add(tA).add(iA),n=[sA,rA,aA,oA]}if(i.x<0){var r=n[2].x,a=n[0].x;n[0].x=r,n[1].x=a,n[2].x=a,n[3].x=r}if(i.y<0){var o=n[2].y,h=n[0].y;n[0].y=o,n[1].y=o,n[2].y=h,n[3].y=h}if(i.z<0){var l=n[2].x,c=n[2].y,u=n[2].z;n[2].x=n[0].x,n[2].y=n[0].y,n[2].z=n[0].z,n[0].x=l,n[0].y=c,n[0].z=u}return n},t.calculateScaleToScreen=function(t){var e=t.entity,i=t.screen.screen.scale;for($E.set(i,i,i);e&&!e.screen;)$E.mul(e.getLocalScale()),e=e.parent;return $E},t.calculateScaleToWorld=function(t){var e=t.entity;for($E.set(1,1,1);e;)$E.mul(e.getLocalScale()),e=e.parent;return $E},v(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"app",get:function(){return this._app||Np()},set:function(t){this._app=t}}])}(),mA={write:function(t){console.log(t)},open:function(){mA.write("Powered by PlayCanvas "+o+" "+h)},info:function(t){console.info("INFO: "+t)},debug:function(t){console.debug("DEBUG: "+t)},error:function(t){console.error("ERROR: "+t)},warning:function(t){console.warn("WARNING: "+t)},alert:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t){mA.write("ALERT: "+t),alert(t)})),assert:function(t,e){!1===t&&mA.write("ASSERT: "+e)}};it.endsWith=function(t,e){return t.endsWith(e)},it.startsWith=function(t,e){return t.startsWith(e)};var _A=function(){function t(){this._isRunning=!1,this._a=0,this._b=0}var e=t.prototype;return e.start=function(){this._isRunning=!0,this._a=lt()},e.stop=function(){this._isRunning=!1,this._b=lt()},e.getMilliseconds=function(){return this._b-this._a},t}(),vA={now:lt,Timer:_A};Object.defineProperty(pt.prototype,"data",{get:function(){return this._data||(this._data=new Float32Array(4)),this._data[0]=this.r,this._data[1]=this.g,this._data[2]=this.b,this._data[3]=this.a,this._data}}),Object.defineProperty(pt.prototype,"data3",{get:function(){return this._data3||(this._data3=new Float32Array(3)),this._data3[0]=this.r,this._data3[1]=this.g,this._data3[2]=this.b,this._data3}}),ft.INV_LOG2=Math.LOG2E,ft.intToBytes=ft.intToBytes32,ft.bytesToInt=ft.bytesToInt32,Object.defineProperty(Mt.prototype,"data",{get:function(){return this._data||(this._data=new Float32Array(2)),this._data[0]=this.x,this._data[1]=this.y,this._data}}),Mt.prototype.scale=Mt.prototype.mulScalar,Object.defineProperty(wt.prototype,"data",{get:function(){return this._data||(this._data=new Float32Array(3)),this._data[0]=this.x,this._data[1]=this.y,this._data[2]=this.z,this._data}}),wt.prototype.scale=wt.prototype.mulScalar,Object.defineProperty(Rt.prototype,"data",{get:function(){return this._data||(this._data=new Float32Array(4)),this._data[0]=this.x,this._data[1]=this.y,this._data[2]=this.z,this._data[3]=this.w,this._data}}),Rt.prototype.scale=Rt.prototype.mulScalar;var gA={Aabb:Wt,Sphere:qt,Plane:ee};qt.prototype.intersectRay=qt.prototype.intersectsRay,Yt.prototype.update=function(t,e){var i=new Bt;i.mul2(t,e),this.setFromMat4(i)};function yA(t){this.name="UnsupportedBrowserError",this.message=t||""}function xA(t){this.name="ContextCreationError",this.message=t||""}yA.prototype=Error.prototype,xA.prototype=Error.prototype;var SA={begin:ko.begin,dummyFragmentCode:Pr.dummyFragmentCode,end:ko.end,fogCode:ko.fogCode,gammaCode:ko.gammaCode,precisionCode:Pr.precisionCode,skinCode:ko.skinCode,tonemapCode:ko.tonemapCode,versionCode:Pr.versionCode},bA={ADDRESS_CLAMP_TO_EDGE:1,ADDRESS_MIRRORED_REPEAT:2,ADDRESS_REPEAT:0,BLENDMODE_ZERO:0,BLENDMODE_ONE:1,BLENDMODE_SRC_COLOR:2,BLENDMODE_ONE_MINUS_SRC_COLOR:3,BLENDMODE_DST_COLOR:4,BLENDMODE_ONE_MINUS_DST_COLOR:5,BLENDMODE_SRC_ALPHA:6,BLENDMODE_SRC_ALPHA_SATURATE:7,BLENDMODE_ONE_MINUS_SRC_ALPHA:8,BLENDMODE_DST_ALPHA:9,BLENDMODE_ONE_MINUS_DST_ALPHA:10,BUFFER_STATIC:0,BUFFER_DYNAMIC:1,BUFFER_STREAM:2,CULLFACE_NONE:0,CULLFACE_BACK:1,CULLFACE_FRONT:2,CULLFACE_FRONTANDBACK:3,ELEMENTTYPE_INT8:0,ELEMENTTYPE_UINT8:1,ELEMENTTYPE_INT16:2,ELEMENTTYPE_UINT16:3,ELEMENTTYPE_INT32:4,ELEMENTTYPE_UINT32:5,ELEMENTTYPE_FLOAT32:6,FILTER_NEAREST:0,FILTER_LINEAR:1,FILTER_NEAREST_MIPMAP_NEAREST:2,FILTER_NEAREST_MIPMAP_LINEAR:3,FILTER_LINEAR_MIPMAP_NEAREST:4,FILTER_LINEAR_MIPMAP_LINEAR:5,INDEXFORMAT_UINT8:0,INDEXFORMAT_UINT16:1,INDEXFORMAT_UINT32:2,PIXELFORMAT_RGB565:3,PIXELFORMAT_RGB8:6,PIXELFORMAT_RGBA8:7,PRIMITIVE_POINTS:0,PRIMITIVE_LINES:1,PRIMITIVE_LINELOOP:2,PRIMITIVE_LINESTRIP:3,PRIMITIVE_TRIANGLES:4,PRIMITIVE_TRISTRIP:5,PRIMITIVE_TRIFAN:6,SEMANTIC_POSITION:Le,SEMANTIC_NORMAL:ke,SEMANTIC_COLOR:Ne,SEMANTIC_TEXCOORD:Ue,SEMANTIC_TEXCOORD0:ze,SEMANTIC_TEXCOORD1:Ve,SEMANTIC_ATTR0:Ke,SEMANTIC_ATTR1:Ze,SEMANTIC_ATTR2:Qe,SEMANTIC_ATTR3:Je,TEXTURELOCK_READ:1,TEXTURELOCK_WRITE:2,drawQuadWithShader:Xo,programlib:SA,shaderChunks:Ro,ContextCreationError:xA,Device:En,IndexBuffer:jr,ProgramLibrary:dp,RenderTarget:Cn,ScopeId:un,Shader:zs,ShaderInput:ur,Texture:or,UnsupportedBrowserError:yA,VertexBuffer:pn,VertexFormat:bn,VertexIterator:fa},TA=new Rt;function wA(t,e){return dh.fromGeometry(t,new If(e))}function EA(t,e){return dh.fromGeometry(t,new cp(e))}function AA(t,e){return dh.fromGeometry(t,new Rf(e))}function CA(t,e){return dh.fromGeometry(t,new up(e))}function MA(t,e){return dh.fromGeometry(t,new op(e))}function PA(t,e){return dh.fromGeometry(t,new hp(e))}function RA(t,e){return dh.fromGeometry(t,new lp(e))}function IA(t,e,i){void 0===i&&(i={});var n=new Mf;return n.positions=e,n.normals=i.normals,n.tangents=i.tangents,n.colors=i.colors,n.uvs=i.uvs,n.uvs1=i.uvs1,n.blendIndices=i.blendIndices,n.blendWeights=i.blendWeights,n.indices=i.indices,dh.fromGeometry(t,n,i)}function DA(t,e,i,n,s){var r;if(s){var a=e?e.width:t.width,o=e?e.height:t.height;r=TA.set(s.x*a,s.y*o,s.z*a,s.w*o)}Xo(t,e,n,r)}var LA={createFullscreenQuad:function(t){return t.quadVertexBuffer},drawFullscreenQuad:DA,PostEffect:tp,PostEffectQueue:iS};Object.defineProperty(Ro,"transformSkinnedVS",{get:function(){return"#define SKIN\n"+Ro.transformVS}});Object.keys({"ambientPrefilteredCube.frag":"ambientEnv.frag","ambientPrefilteredCubeLod.frag":"ambientEnv.frag","dpAtlasQuad.frag":null,"genParaboloid.frag":null,"prefilterCubemap.frag":null,"reflectionDpAtlas.frag":"reflectionEnv.frag","reflectionPrefilteredCube.frag":"reflectionEnv.frag","reflectionPrefilteredCubeLod.frag":"reflectionEnv.frag"}).forEach((function(t){Object.defineProperty(Ro,t,{get:function(){return null},set:function(){}})})),Object.defineProperties(Cn.prototype,{_glFrameBuffer:{get:function(){return this.impl._glFrameBuffer},set:function(t){}}}),Object.defineProperty(bn,"defaultInstancingFormat",{get:function(){return null}}),Object.defineProperties(or.prototype,{rgbm:{get:function(){return this.type===di},set:function(t){this.type=t?di:ui}},swizzleGGGR:{get:function(){return this.type===mi},set:function(t){this.type=t?mi:ui}},_glTexture:{get:function(){return this.impl._glTexture}},autoMipmap:{get:function(){return this._mipmaps},set:function(t){this._mipmaps=t}}}),Object.defineProperty(En.prototype,"webgl2",{get:function(){return this.isWebGL2}}),En.prototype.getProgramLibrary=function(){return Do(this)},En.prototype.setProgramLibrary=function(t){Lo(this,t)},En.prototype.removeShaderFromCache=function(t){Do(this).removeFromCache(t)},nn.DEFAULT=Object.freeze(new nn);var kA=new nn,OA=new on;En.prototype.setBlendFunction=function(t,e){var i=this.blendState;kA.copy(i),kA.setColorBlend(i.colorOp,t,e),kA.setAlphaBlend(i.alphaOp,t,e),this.setBlendState(kA)},En.prototype.setBlendFunctionSeparate=function(t,e,i,n){var s=this.blendState;kA.copy(s),kA.setColorBlend(s.colorOp,t,e),kA.setAlphaBlend(s.alphaOp,i,n),this.setBlendState(kA)},En.prototype.setBlendEquation=function(t){var e=this.blendState;kA.copy(e),kA.setColorBlend(t,e.colorSrcFactor,e.colorDstFactor),kA.setAlphaBlend(t,e.alphaSrcFactor,e.alphaDstFactor),this.setBlendState(kA)},En.prototype.setBlendEquationSeparate=function(t,e){var i=this.blendState;kA.copy(i),kA.setColorBlend(t,i.colorSrcFactor,i.colorDstFactor),kA.setAlphaBlend(e,i.alphaSrcFactor,i.alphaDstFactor),this.setBlendState(kA)},En.prototype.setColorWrite=function(t,e,i,n){var s=this.blendState;kA.copy(s),kA.setColorWrite(t,e,i,n),this.setBlendState(kA)},En.prototype.getBlending=function(){return this.blendState.blend},En.prototype.setBlending=function(t){kA.copy(this.blendState),kA.blend=t,this.setBlendState(kA)},En.prototype.setDepthWrite=function(t){OA.copy(this.depthState),OA.write=t,this.setDepthState(OA)},En.prototype.setDepthFunc=function(t){OA.copy(this.depthState),OA.func=t,this.setDepthState(OA)},En.prototype.setDepthTest=function(t){OA.copy(this.depthState),OA.test=t,this.setDepthState(OA)},En.prototype.getCullMode=function(){return this.cullMode};var FA=Lc,BA=cl,NA={procedural:{calculateTangents:Cf,createMesh:IA,createTorus:CA,createCylinder:RA,createCapsule:MA,createCone:PA,createSphere:wA,createPlane:EA,createBox:AA},BasicMaterial:ih,ForwardRenderer:id,GraphNode:Rh,Material:eh,Mesh:dh,MeshInstance:Vh,Model:wd,ParticleEmitter:bf,PhongMaterial:Lc,Picker:OE,Projection:{ORTHOGRAPHIC:1,PERSPECTIVE:0},Scene:Gf,Skin:Hf,SkinInstance:ah};function UA(t,e){Object.defineProperty(Lc.prototype,e,{get:function(){return this[t]},set:function(e){this[t]=e}})}function zA(t,e){"pass"!==t&&Object.defineProperty(dc.prototype,t,{get:function(){return this.litOptions[e||t]},set:function(i){this.litOptions[e||t]=i}})}Object.defineProperty(Gf.prototype,"defaultMaterial",{get:function(){return Jo(Np().graphicsDevice)}}),Object.defineProperty(dd.prototype,"_meshInstances",{get:function(){return null}}),Object.defineProperty(Gf.prototype,"drawCalls",{get:function(){return null}}),["128","64","32","16","8","4"].forEach((function(t,e){Object.defineProperty(Gf.prototype,"skyboxPrefiltered"+t,{get:function(){return this._prefilteredCubemaps[e]},set:function(t){this._prefilteredCubemaps[e]=t,this.updateShaders=!0}})})),Object.defineProperty(Gf.prototype,"models",{get:function(){return this._models||(this._models=[]),this._models}}),Object.defineProperty(ld.prototype,"renderTarget",{set:function(t){this._renderTarget=t,this._dirtyComposition=!0},get:function(){return this._renderTarget}}),Gf.prototype.addModel=function(t){if(!this.containsModel(t)){var e=this.layers.getLayerById(0);e&&(e.addMeshInstances(t.meshInstances),this.models.push(t))}},Gf.prototype.addShadowCaster=function(t){var e=this.layers.getLayerById(0);e&&e.addShadowCasters(t.meshInstances)},Gf.prototype.removeModel=function(t){var e=this.models.indexOf(t);if(-1!==e){var i=this.layers.getLayerById(0);if(!i)return;i.removeMeshInstances(t.meshInstances),this.models.splice(e,1)}},Gf.prototype.removeShadowCasters=function(t){var e=this.layers.getLayerById(0);e&&e.removeShadowCasters(t.meshInstances)},Gf.prototype.containsModel=function(t){return this.models.indexOf(t)>=0},Gf.prototype.getModels=function(t){return this.models},Object.defineProperty(nh.prototype,"model",{get:function(){return null}}),id.prototype.renderComposition=function(t){Np().renderComposition(t)},Vh.prototype.syncAabb=function(){},Ed.prototype.getTarget=function(t){return this.targets[t]},Rh.prototype._dirtify=function(t){t?this._dirtifyLocal():this._dirtifyWorld()},Rh.prototype.addLabel=function(t){this._labels[t]=!0},Rh.prototype.getLabels=function(){return Object.keys(this._labels)},Rh.prototype.hasLabel=function(t){return!!this._labels[t]},Rh.prototype.removeLabel=function(t){delete this._labels[t]},Rh.prototype.findByLabel=function(t,e){void 0===e&&(e=[]),this.hasLabel(t)&&e.push(this);for(var i=0;i0){var i=this._frameTimings[this._frameIndex-1];i[1]=e-i[1]}else if(this._timings.length>0){var n=this._timings[this._timings.length-1];n[1]=e-n[1]}if(this._frameIndex>=this._frameTimings.length)this._frameTimings.push([t,e]);else{var s=this._frameTimings[this._frameIndex];s[0]=t,s[1]=e}this._frameIndex++}},v(t,[{key:"timings",get:function(){return this._timings.slice(0,-1).map((function(t){return t[1]}))}}])}(),QA=v((function(t){this.device=t,t.gpuProfiler.enabled=!0,this.enabled=!0,this.unitsName="ms",this.decimalPlaces=1,this._timings=[]}),[{key:"timings",get:function(){return this._timings[0]=this.device.gpuProfiler._frameTime,this._timings}}]),JA=v((function(t,e,i,n,s){var r=this;this.app=t,this.values=[],this.statNames=e,this.statNames.length>3&&(this.statNames.length=3),this.unitsName=n,this.decimalPlaces=i,this.multiplier=s||1;var a=function(t,e){return t.split(".").reduce((function(t,e){return t?t[e]:null}),e||r)};t.on("frameupdate",(function(t){for(var e=0;ethis.textRefreshRate&&(this.timingText=(this.avgTotal/this.avgCount).toFixed(this.timer.decimalPlaces),this.avgTimer=0,this.avgTotal=0,this.avgCount=0),this.enabled){for(var n=0,s=1.5*this.watermark,r=0;r=512&&(a=5,o+=16),r.set(t,{l:i,r:n,a:h,d:l,w:c,h:u,x:a,y:o}),a+=c+5})),n.width=512,n.height=ft.nextPowerOfTwo(o+16+5),i(s),s.fillStyle="rgb(0, 0, 0)",s.fillRect(0,0,n.width,n.height),r.forEach((function(t,e){s.fillStyle=function(t){return"."===t||1===t.length&&t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57}(e)?"rgb(255, 255, 255)":"rgb(170, 170, 170)",s.fillText(e,t.x-t.l,t.y+t.a)})),this.placements=r;for(var h=s.getImageData(0,0,n.width,n.height).data,l=0;lt?e.width:t}),0);this.texture=new or(e,{name:"mini-stats-graph-texture",width:ft.nextPowerOfTwo(h),height:ft.nextPowerOfTwo(this.graphs.length),mipmaps:!1,minFilter:0,magFilter:0,addressU:0,addressV:0}),this.graphs.forEach((function(t,e){t.texture=n.texture,t.yOffset=e}))},e.render=function(){var t=this.graphs,e=this.wordAtlas,i=this.render2d,n=this.width,s=this.height,r=this.gspacing;i.startFrame();for(var a=0;a>1|(21845&_C)<<1;vC=(61680&(vC=(52428&vC)>>2|(13107&vC)<<2))>>4|(3855&vC)<<4,mC[_C]=((65280&vC)>>8|(255&vC)<<8)>>1}var gC=function(t,e,i){for(var n=t.length,s=0,r=new rC(e);s>h]=l}else for(a=new rC(n),s=0;s>15-t[s]);return a},yC=new sC(288);for(_C=0;_C<144;++_C)yC[_C]=8;for(_C=144;_C<256;++_C)yC[_C]=9;for(_C=256;_C<280;++_C)yC[_C]=7;for(_C=280;_C<288;++_C)yC[_C]=8;var xC=new sC(32);for(_C=0;_C<32;++_C)xC[_C]=5;var SC=gC(yC,9,0);gC(yC,9,1);var bC=gC(xC,5,0);gC(xC,5,1);var TC=function(t){return(t+7)/8|0},wC=function(t,e,i){return(null==i||i>t.length)&&(i=t.length),new sC(t.subarray(e,i))},EC=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],AC=function(t,e,i){var n=new Error(e||EC[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,AC),!i)throw n;return n},CC=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>8},MC=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>8,t[n+2]|=i>>16},PC=function(t,e){for(var i=[],n=0;nd&&(d=r[n].s);var f=new rC(d+1),p=RC(i[c-1],f,0);if(p>e){n=0;var m=0,_=p-e,v=1<<_;for(r.sort((function(t,e){return f[e.s]-f[t.s]||t.f-e.f}));ne))break;m+=v-(1<>=_;m>0;){var y=r[n].s;f[y]=0&&m;--n){var x=r[n].s;f[x]==e&&(--f[x],++m)}p=e}return{t:new sC(f),l:p}},RC=function(t,e,i){return-1==t.s?Math.max(RC(t.l,e,i+1),RC(t.r,e,i+1)):e[t.s]=i},IC=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new rC(++e),n=0,s=t[0],r=1,a=function(t){i[n++]=t},o=1;o<=e;++o)if(t[o]==s&&o!=e)++r;else{if(!s&&r>2){for(;r>138;r-=138)a(32754);r>2&&(a(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(a(s),--r;r>6;r-=6)a(8304);r>2&&(a(r-3<<5|8208),r=0)}for(;r--;)a(s);r=1,s=t[o]}return{c:i.subarray(0,n),n:e}},DC=function(t,e){for(var i=0,n=0;n>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var r=0;r4&&!A[lC[M-1]];--M);var P,R,I,D,L=l+5<<3,k=DC(s,yC)+DC(r,xC)+a,O=DC(s,d)+DC(r,m)+a+14+3*M+DC(T,A)+2*T[16]+3*T[17]+7*T[18];if(h>=0&&L<=k&&L<=O)return LC(e,c,t.subarray(h,h+l));if(CC(e,c,1+(O15&&(CC(e,c,U[w]>>5&127),c+=U[w]>>12)}}}else P=SC,R=yC,I=bC,D=xC;for(w=0;w255){MC(e,c,P[(z=V>>18&31)+257]),c+=R[z+257],z>7&&(CC(e,c,V>>23&31),c+=oC[z]);var G=31&V;MC(e,c,I[G]),c+=D[G],G>3&&(MC(e,c,V>>5&8191),c+=hC[G])}else MC(e,c,P[V]),c+=R[V]}return MC(e,c,P[256]),c+R[256]},OC=new aC([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),FC=new sC(0),BC=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var i=e,n=9;--n;)i=(1&i&&-306674912)^i>>>1;t[e]=i}return t}(),NC=function(){var t=-1;return{p:function(e){for(var i=t,n=0;n>>8;t=i},d:function(){return~t}}},UC=function(t,e,i,n,s){if(!s&&(s={l:1},e.dictionary)){var r=e.dictionary.subarray(-32768),a=new sC(r.length+t.length);a.set(r),a.set(t,r.length),t=a,s.w=r.length}return function(t,e,i,n,s,r){var a=r.z||t.length,o=new sC(n+a+5*(1+Math.ceil(a/7e3))+s),h=o.subarray(n,o.length-s),l=r.l,c=7&(r.r||0);if(e){c&&(h[0]=r.r>>3);for(var u=OC[e-1],d=u>>13,f=8191&u,p=(1<7e3||A>24576)&&(D>423||!l)){c=kC(t,h,0,x,S,b,w,A,M,E-M,c),A=T=w=0,M=E;for(var L=0;L<286;++L)S[L]=0;for(L=0;L<30;++L)b[L]=0}var k=2,O=0,F=f,B=R-I&32767;if(D>2&&P==y(E-B))for(var N=Math.min(d,D)-1,U=Math.min(32767,E),z=Math.min(258,D);B<=U&&--F&&R!=I;){if(t[E+k]==t[E+k-B]){for(var V=0;Vk){if(k=V,O=B,V>N)break;var G=Math.min(B,V-2),H=0;for(L=0;LH&&(H=X,I=W)}}}B+=(R=I)-(I=m[R])&32767}if(O){x[A++]=268435456|fC[k]<<18|pC[O];var j=31&fC[k],q=31&pC[O];w+=oC[j]+hC[q],++S[257+j],++b[q],C=E+k,++T}else x[A++]=t[E],++S[t[E]]}}for(E=Math.max(E,C);E=a&&(h[c/8|0]=l,Y=a),c=LC(h,c+1,t.subarray(E,Y))}r.i=a}return wC(o,0,n+TC(c)+s)}(t,null==e.level?6:e.level,null==e.mem?s.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,i,n,s)},zC=function(t,e){var i={};for(var n in t)i[n]=t[n];for(var n in e)i[n]=e[n];return i},VC=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};function GC(t,e){return UC(t,e||{},0,0)}var HC=function(t,e,i,n){for(var s in t){var r=t[s],a=e+s,o=n;Array.isArray(r)&&(o=zC(n,r[1]),r=r[0]),r instanceof sC?i[a]=[r,o]:(i[a+="/"]=[new sC(0),o],HC(r,a,i,n))}},WC="undefined"!=typeof TextEncoder&&new TextEncoder,XC="undefined"!=typeof TextDecoder&&new TextDecoder;try{XC.decode(FC,{stream:!0})}catch(t){}function jC(t,e){if(WC)return WC.encode(t);for(var i=t.length,n=new sC(t.length+(t.length>>1)),s=0,r=function(t){n[s++]=t},a=0;an.length){var o=new sC(s+8+(i-a<<1));o.set(n),n=o}var h=t.charCodeAt(a);h<128||e?r(h):h<2048?(r(192|h>>6),r(128|63&h)):h>55295&&h<57344?(r(240|(h=65536+(1047552&h)|1023&t.charCodeAt(++a))>>18),r(128|h>>12&63),r(128|h>>6&63),r(128|63&h)):(r(224|h>>12),r(128|h>>6&63),r(128|63&h))}return wC(n,0,s)}var qC=function(t){var e=0;if(t)for(var i in t){var n=t[i].length;n>65535&&AC(9),e+=n+4}return e},YC=function(t,e,i,n,s,r,a,o){var h=n.length,l=i.extra,c=o&&o.length,u=qC(l);VC(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=i.os),t[e]=20,e+=2,t[e++]=i.flag<<1|(r<0&&8),t[e++]=s&&8,t[e++]=255&i.compression,t[e++]=i.compression>>8;var d=new Date(null==i.mtime?Date.now():i.mtime),f=d.getFullYear()-1980;if((f<0||f>119)&&AC(10),VC(t,e,f<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>1),e+=4,-1!=r&&(VC(t,e,i.crc),VC(t,e+4,r<0?-r-2:r),VC(t,e+8,i.size)),VC(t,e+12,h),VC(t,e+14,u),e+=16,null!=a&&(VC(t,e,c),VC(t,e+6,i.attrs),VC(t,e+10,a),e+=14),t.set(n,e),e+=h,u)for(var p in l){var m=l[p],_=m.length;VC(t,e,+p),VC(t,e+2,_),t.set(m,e+4),e+=4+_}return c&&(t.set(o,e),e+=c),e};function KC(t,e){e||(e={});var i={},n=[];HC(t,"",i,e);var s=0,r=0;for(var a in i){var o=i[a],h=o[0],l=o[1],c=0==l.level?0:8,u=(T=jC(a)).length,d=l.comment,f=d&&jC(d),p=f&&f.length,m=qC(l.extra);u>65535&&AC(11);var _=c?GC(h,l):h,v=_.length,g=NC();g.p(h),n.push(zC(l,{size:h.length,crc:g.d(),c:_,f:T,m:f,u:u!=a.length||f&&d.length!=p,o:s,compression:c})),s+=30+u+m+v,r+=76+2*(u+m)+(p||0)+v}for(var y=new sC(r+22),x=s,S=r-s,b=0;b"}},i.getTextureFileIds=function(t){return this.getFileIds("texture","Texture_"+t.id,"Texture","png")},i.addFile=function(t,e,i,n){void 0===i&&(i=""),void 0===n&&(n="");var s=null;n&&(s=jC(n='#usda 1.0\n(\n customLayerData = {\n string creator = "PlayCanvas UsdzExporter"\n }\n metersPerUnit = 1\n upAxis = "Y"\n)\n\n'+n));var r=this.getFileIds(t,e,i);return this.files[r.fileName]=s,r.refName},i.getMaterialRef=function(t){var e=this.materialMap.get(t);return e||(e=this.buildMaterial(t),this.materialMap.set(t,e)),e},i.getMeshRef=function(t){var e=this.meshMap.get(t);return e||(e=this.buildMesh(t),this.meshMap.set(t,e)),e},i.buildArray2=function(t){for(var e=[],i=t.length,n=0;n"},r=[],a=[],o=function(i,n,o,h,l,c,u){void 0===c&&(c=!1),void 0===u&&(u=!1);var d=t[i];if(d){var f=e.getTextureFileIds(d);e.textureMap.set(d,f.refName);var p=t[i+"Channel"]||"rgb",m=s("/"+f.name+"_"+l+".outputs:"+p);r.push(QC(o,h+".connect",m)),c&&t.alphaTest;var _=t[i+"Tiling"],v=t[i+"Offset"],g=t[i+"Rotation"],y=1===t[i+"Uv"]?"st1":"st",x=u&&n?n:pt.WHITE;a.push(function(t,e,i,n,r,a,o,h){return'\n def Shader "Transform2d_'+i+'" (\n sdrMetadata = {\n string role = "math"\n }\n )\n {\n uniform token info:id = "UsdTransform2d"\n float2 inputs:in.connect = '+s("/uvReader_"+n+".outputs:result")+"\n float inputs:rotation = "+o+"\n float2 inputs:scale = ("+r.x+", "+r.y+")\n float2 inputs:translation = ("+a.x+", "+a.y+')\n float2 outputs:result\n }\n\n def Shader "Texture_'+t.id+"_"+i+'"\n {\n uniform token info:id = "UsdUVTexture"\n asset inputs:file = @'+e.fileName+"@\n float2 inputs:st.connect = "+s("/Transform2d_"+i+".outputs:result")+'\n token inputs:wrapS = "repeat"\n token inputs:wrapT = "repeat"\n float4 inputs:scale = ('+h.r+", "+h.g+", "+h.b+", "+h.a+")\n float outputs:r\n float outputs:g\n float outputs:b\n float3 outputs:rgb\n float outputs:a\n }\n "}(d,f,l,y,_,v,g,x))}else if(n){var S="float"===o?""+n:"("+n.r+", "+n.g+", "+n.b+")";r.push(QC(o,h,S))}};o("diffuseMap",t.diffuse,"color3f","diffuseColor","diffuse",!1,!0),(t.transparent||t.alphaTest>0)&&o("opacityMap",t.opacity,"float","opacity","opacity",!0),o("normalMap",null,"normal3f","normal","normal"),o("emissiveMap",t.emissive,"color3f","emissiveColor","emissive",!1,!0),o("aoMap",null,"float","occlusion","occlusion"),o("metalnessMap",t.metalness,"float","metallic","metallic"),o("glossMap",t.gloss,"float","roughness","roughness");var h='\n def Material "'+i+'"\n {\n def Shader "PreviewSurface"\n {\n uniform token info:id = "UsdPreviewSurface"\n'+r.join("\n")+"\n int inputs:useSpecularWorkflow = 0\n token outputs:surface\n }\n\n token outputs:surface.connect = "+s("/PreviewSurface.outputs:surface")+'\n\n def Shader "uvReader_st"\n {\n uniform token info:id = "UsdPrimvarReader_float2"\n token inputs:varname = "st"\n float2 inputs:fallback = (0.0, 0.0)\n float2 outputs:result\n }\n\n def Shader "uvReader_st1"\n {\n uniform token info:id = "UsdPrimvarReader_float2"\n token inputs:varname = "st1"\n float2 inputs:fallback = (0.0, 0.0)\n float2 outputs:result\n }\n\n '+a.join("\n")+"\n }\n ";return this.materials.push(h),s("")},i.buildMesh=function(t){var e=[],i=[],n=[],s=[],r=[];t.getVertexStream(Le,e),t.getVertexStream(ke,n),t.getVertexStream(ze,s),t.getVertexStream(Ve,r),t.getIndices(i);var a=i.length||e.length,o=Array(a/3).fill(3).join(", ");if(!i.length)for(var h=0;h0&&(e.materials=t.materials.map((function(n){var s=n.name,r=n.blendType,a=n.cull,o=n.alphaTest,h={pbrMetallicRoughness:{}};return s&&s.length>0&&(h.name=s),n instanceof Lc&&i.writeStandardMaterial(t,n,h,e),n instanceof ih&&i.writeBasicMaterial(t,n,h,e),2===r?h.alphaMode="BLEND":3===r&&0!==o&&(h.alphaMode="MASK",h.alphaCutoff=o),0===a&&(h.doubleSided=!0),i.attachTexture(t,n,h,"normalTexture","normalMap",e),i.attachTexture(t,n,h,"occlusionTexture","aoMap",e),i.attachTexture(t,n,h,"emissiveTexture","emissiveMap",e),h})))},i.writeNodes=function(t,e){t.entities.length>0&&(e.nodes=t.entities.map((function(e){var i=e.name,n=e.getLocalPosition(),s=e.getLocalRotation(),r=e.getLocalScale(),a={};i&&i.length>0&&(a.name=i),n.equals(wt.ZERO)||(a.translation=[n.x,n.y,n.z]),s.equals(Nt.IDENTITY)||(a.rotation=[s.x,s.y,s.z,s.w]),r.equals(wt.ONE)||(a.scale=[r.x,r.y,r.z]),e.camera&&e.camera.enabled&&(a.camera=t.cameras.indexOf(e.camera));var o=t.entityMeshInstances.find((function(t){return t.node===e}));return o&&(a.mesh=t.entityMeshInstances.indexOf(o)),e.children.length>0&&(a.children=[],e.children.forEach((function(e){a.children.push(t.entities.indexOf(e))}))),a})))},i.writeMeshes=function(t,i){t.entityMeshInstances.length>0&&(i.accessors=[],i.meshes=[],t.entityMeshInstances.forEach((function(n){var s={primitives:[]};n.meshInstances.forEach((function(n){var r=e.createPrimitive(t,i,n.mesh);r.material=t.materials.indexOf(n.material),s.primitives.push(r)})),i.meshes.push(s)})))},e.createPrimitive=function(t,i,n){var s={attributes:{}},r=n.vertexBuffer,a=r.format,o=a.interleaved,h=a.elements,l=r.getNumVertices();h.forEach((function(a,h){var c=t.bufferViewMap.get(r);c||(e.writeBufferView(t,i,r),t.buffers.push(r),c=t.bufferViewMap.get(r));var u={bufferView:c[o?0:h],byteOffset:o?a.offset:0,componentType:eM(a.dataType),type:iM(a.numComponents),count:l},d=i.accessors.push(u)-1;if(s.attributes[function(t){switch(t){case Le:return"POSITION";case ke:return"NORMAL";case Oe:return"TANGENT";case Ne:return"COLOR_0";case Be:return"JOINTS_0";case Fe:return"WEIGHTS_0";case ze:return"TEXCOORD_0";case Ve:return"TEXCOORD_1";case Ge:return"TEXCOORD_2";case He:return"TEXCOORD_3";case We:return"TEXCOORD_4";case Xe:return"TEXCOORD_5";case je:return"TEXCOORD_6";case qe:return"TEXCOORD_7"}return""}(a.name)]=d,a.name===Le){var f=[];n.getPositions(f);var p=new wt,m=new wt;Wt.computeMinMax(f,p,m),u.min=[p.x,p.y,p.z],u.max=[m.x,m.y,m.z]}}));var c=n.indexBuffer[0];if(c){var u=t.bufferViewMap.get(c);u||(e.writeBufferView(t,i,c),t.buffers.push(c),u=t.bufferViewMap.get(c));var d={bufferView:u[0],componentType:tM(c.getFormat()),count:c.getNumIndices(),type:"SCALAR"},f=i.accessors.push(d)-1;s.indices=f}return s},i.convertTextures=function(t,e){var i=this,n={maxTextureSize:e.maxTextureSize},s=[];return t.forEach((function(t){var e=i.textureToCanvas(t,n);e.then((function(t){return new Promise((function(e){return e(t)}))})),s.push(e)})),s},i.writeTextures=function(t,i,n,s){for(var r=this,a=t.textures,o=[],h=function(s){var h=a[s],l=i[s],c=function(t){for(var e=t.getContext("2d").getImageData(0,0,t.width,t.height).data,i=3;i0&&(a+=8+r);var o=new ArrayBuffer(a),h=new DataView(o);h.setUint32(0,1179937895,!0),h.setUint32(4,2,!0),h.setUint32(8,a,!0),h.setUint32(12,n+s,!0),h.setUint32(16,1313821514,!0);var l=20;new Uint8Array(o,l,n).set(e),l+=n;for(var c=0;c0&&(h.setUint32(l,r,!0),h.setUint32(l+4,5130562,!0),l+=8,i.buffers.forEach((function(e){var n,s=i.bufferViewMap.get(e)[0],r=t.bufferViews[s].byteOffset;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else{var a=e.lock();n=a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a.buffer,a.byteOffset,a.byteLength)}new Uint8Array(o,l+r,n.byteLength).set(n)}))),Promise.resolve(o)}))},e}(nC),oM=function(t){function e(e,i){var n;return(n=t.call(this,e)||this).sourceTexture=i,n.shader=n.createQuadShader("DownSampleShader","\n\t\t\tuniform sampler2D sourceTexture;\n\t\t\tuniform vec2 sourceInvResolution;\n\t\t\tvarying vec2 uv0;\n\t\t\tvoid main()\n\t\t\t{\n\t\t\t\tfloat x = sourceInvResolution.x;\n\t\t\t\tfloat y = sourceInvResolution.y;\n\t\t\t\tvec3 a = texture2D (sourceTexture, vec2 (uv0.x - 2.0 * x, uv0.y + 2.0 * y)).rgb;\n\t\t\t\tvec3 b = texture2D (sourceTexture, vec2 (uv0.x,\t\t uv0.y + 2.0 * y)).rgb;\n\t\t\t\tvec3 c = texture2D (sourceTexture, vec2 (uv0.x + 2.0 * x, uv0.y + 2.0 * y)).rgb;\n\t\t\t\tvec3 d = texture2D (sourceTexture, vec2 (uv0.x - 2.0 * x, uv0.y)).rgb;\n\t\t\t\tvec3 e = texture2D (sourceTexture, vec2 (uv0.x,\t\t uv0.y)).rgb;\n\t\t\t\tvec3 f = texture2D (sourceTexture, vec2 (uv0.x + 2.0 * x, uv0.y)).rgb;\n\t\t\t\tvec3 g = texture2D (sourceTexture, vec2 (uv0.x - 2.0 * x, uv0.y - 2.0 * y)).rgb;\n\t\t\t\tvec3 h = texture2D (sourceTexture, vec2 (uv0.x,\t\t uv0.y - 2.0 * y)).rgb;\n\t\t\t\tvec3 i = texture2D (sourceTexture, vec2 (uv0.x + 2.0 * x, uv0.y - 2.0 * y)).rgb;\n\t\t\t\tvec3 j = texture2D (sourceTexture, vec2 (uv0.x - x, uv0.y + y)).rgb;\n\t\t\t\tvec3 k = texture2D (sourceTexture, vec2 (uv0.x + x, uv0.y + y)).rgb;\n\t\t\t\tvec3 l = texture2D (sourceTexture, vec2 (uv0.x - x, uv0.y - y)).rgb;\n\t\t\t\tvec3 m = texture2D (sourceTexture, vec2 (uv0.x + x, uv0.y - y)).rgb;\n\t\t\t\tvec3 value = e * 0.125;\n\t\t\t\tvalue += (a + c + g + i) * 0.03125;\n\t\t\t\tvalue += (b + d + f + h) * 0.0625;\n\t\t\t\tvalue += (j + k + l + m) * 0.125;\n\t\t\t\tgl_FragColor = vec4(value, 1.0);\n\t\t\t}"),n.sourceTextureId=e.scope.resolve("sourceTexture"),n.sourceInvResolutionId=e.scope.resolve("sourceInvResolution"),n.sourceInvResolutionValue=new Float32Array(2),n}return x(e,t),e.prototype.execute=function(){this.sourceTextureId.setValue(this.sourceTexture),this.sourceInvResolutionValue[0]=1/this.sourceTexture.width,this.sourceInvResolutionValue[1]=1/this.sourceTexture.height,this.sourceInvResolutionId.setValue(this.sourceInvResolutionValue),t.prototype.execute.call(this)},e}(ep),hM=function(t){function e(e,i){var n;return(n=t.call(this,e)||this).sourceTexture=i,n.shader=n.createQuadShader("UpSampleShader","\n\t\t\tuniform sampler2D sourceTexture;\n\t\t\tuniform vec2 sourceInvResolution;\n\t\t\tvarying vec2 uv0;\n\t\t\tvoid main()\n\t\t\t{\n\t\t\t\tfloat x = sourceInvResolution.x;\n\t\t\t\tfloat y = sourceInvResolution.y;\n\t\t\t\tvec3 a = texture2D (sourceTexture, vec2 (uv0.x - x, uv0.y + y)).rgb;\n\t\t\t\tvec3 b = texture2D (sourceTexture, vec2 (uv0.x,\t uv0.y + y)).rgb;\n\t\t\t\tvec3 c = texture2D (sourceTexture, vec2 (uv0.x + x, uv0.y + y)).rgb;\n\t\t\t\tvec3 d = texture2D (sourceTexture, vec2 (uv0.x - x, uv0.y)).rgb;\n\t\t\t\tvec3 e = texture2D (sourceTexture, vec2 (uv0.x,\t uv0.y)).rgb;\n\t\t\t\tvec3 f = texture2D (sourceTexture, vec2 (uv0.x + x, uv0.y)).rgb;\n\t\t\t\tvec3 g = texture2D (sourceTexture, vec2 (uv0.x - x, uv0.y - y)).rgb;\n\t\t\t\tvec3 h = texture2D (sourceTexture, vec2 (uv0.x,\t uv0.y - y)).rgb;\n\t\t\t\tvec3 i = texture2D (sourceTexture, vec2 (uv0.x + x, uv0.y - y)).rgb;\n\t\t\t\tvec3 value = e * 4.0;\n\t\t\t\tvalue += (b + d + f + h) * 2.0;\n\t\t\t\tvalue += (a + c + g + i);\n\t\t\t\tvalue *= 1.0 / 16.0;\n\t\t\t\tgl_FragColor = vec4(value, 1.0);\n\t\t\t}"),n.sourceTextureId=e.scope.resolve("sourceTexture"),n.sourceInvResolutionId=e.scope.resolve("sourceInvResolution"),n.sourceInvResolutionValue=new Float32Array(2),n}return x(e,t),e.prototype.execute=function(){this.sourceTextureId.setValue(this.sourceTexture),this.sourceInvResolutionValue[0]=1/this.sourceTexture.width,this.sourceInvResolutionValue[1]=1/this.sourceTexture.height,this.sourceInvResolutionId.setValue(this.sourceInvResolutionValue),t.prototype.execute.call(this)},e}(ep),lM=function(t){function e(e,i,n){var s;return(s=t.call(this,e)||this).bloomTexture=void 0,s.lastMipLevel=1,s.bloomRenderTarget=void 0,s.textureFormat=void 0,s.renderTargets=[],s._sourceTexture=i,s.textureFormat=n,s.bloomRenderTarget=s.createRenderTarget(0),s.bloomTexture=s.bloomRenderTarget.colorBuffer,s}x(e,t);var i=e.prototype;return i.destroy=function(){this.destroyRenderPasses(),this.destroyRenderTargets()},i.destroyRenderTargets=function(t){void 0===t&&(t=0);for(var e=t;e=0;a--){var o=new hM(e,i),h=this.renderTargets[a];o.init(h),o.blendState=nn.ADDBLEND,this.beforePasses.push(o),i=h.colorBuffer}},i.onDisable=function(){var t;null==(t=this.renderTargets[0])||t.resize(1,1),this.destroyRenderPasses(),this.destroyRenderTargets(1)},i.frameUpdate=function(){t.prototype.frameUpdate.call(this);var e=this.calcMipLevels(this._sourceTexture.width,this._sourceTexture.height,Math.pow(2,this.lastMipLevel));e=Math.max(1,e),this.renderTargets.length!==e&&(this.destroyRenderPasses(),this.destroyRenderTargets(1),this.createRenderTargets(e),this.createRenderPasses(e))},v(e,[{key:"sourceTexture",get:function(){return this._sourceTexture},set:function(t){if(this._sourceTexture=t,this.beforePasses.length>0){var e=this.beforePasses[0];e.options.resizeSource=t,e.sourceTexture=t}}}])}(Kr),cM=function(t){function e(e){var i;(i=t.call(this,e)||this).sceneTexture=null,i.bloomIntensity=.01,i._bloomTexture=null,i._toneMapping=4,i._gradingEnabled=!1,i.gradingSaturation=1,i.gradingContrast=1,i.gradingBrightness=1,i._shaderDirty=!0,i._vignetteEnabled=!1,i.vignetteInner=.5,i.vignetteOuter=1,i.vignetteCurvature=.5,i.vignetteIntensity=.3,i._fringingEnabled=!1,i.fringingIntensity=10,i._taaEnabled=!1,i._sharpness=.5,i._key="";var n=e.scope;return i.sceneTextureId=n.resolve("sceneTexture"),i.bloomTextureId=n.resolve("bloomTexture"),i.bloomIntensityId=n.resolve("bloomIntensity"),i.bcsId=n.resolve("brightnessContrastSaturation"),i.vignetterParamsId=n.resolve("vignetterParams"),i.fringingIntensityId=n.resolve("fringingIntensity"),i.sceneTextureInvResId=n.resolve("sceneTextureInvRes"),i.sceneTextureInvResValue=new Float32Array(2),i.sharpnessId=n.resolve("sharpness"),i}x(e,t);var i=e.prototype;return i.postInit=function(){this.setClearColor(pt.BLACK),this.setClearDepth(1),this.setClearStencil(0)},i.frameUpdate=function(){if(this._shaderDirty){this._shaderDirty=!1;var t=this.toneMapping+("-"+(this.bloomTexture?"bloom":"nobloom"))+"-"+(this.gradingEnabled?"grading":"nograding")+"-"+(this.vignetteEnabled?"vignette":"novignette")+"-"+(this.fringingEnabled?"fringing":"nofringing")+"-"+(this.taaEnabled?"taa":"notaa")+"-"+(this.isSharpnessEnabled?"cas":"nocas");if(this._key!==t){this._key=t;var e=(this.bloomTexture?"#define BLOOM\n":"")+(this.gradingEnabled?"#define GRADING\n":"")+(this.vignetteEnabled?"#define VIGNETTE\n":"")+(this.fringingEnabled?"#define FRINGING\n":"")+(this.taaEnabled?"#define TAA\n":"")+(this.isSharpnessEnabled?"#define CAS\n":""),i=Ro.decodePS+Ro.gamma2_2PS+this.toneMapChunk;this.shader=this.createQuadShader("ComposeShader-"+t,e+i+"\n\tvarying vec2 uv0;\n\tuniform sampler2D sceneTexture;\n\tuniform vec2 sceneTextureInvRes;\n\t#ifdef BLOOM\n\t\tuniform sampler2D bloomTexture;\n\t\tuniform float bloomIntensity;\n\t#endif\n\t#ifdef GRADING\n\t\tuniform vec3 brightnessContrastSaturation;\n\t\tvec3 contrastSaturationBrightness(vec3 color, float brt, float sat, float con)\n\t\t{\n\t\t\tcolor = color * brt;\n\t\t\tfloat grey = dot(color, vec3(0.3, 0.59, 0.11));\n\t\t\tcolor = mix(vec3(grey), color, sat);\n\t\t\treturn max(mix(vec3(0.5), color, con), 0.0);\n\t\t}\n\t\n\t#endif\n\t#ifdef VIGNETTE\n\t\tuniform vec4 vignetterParams;\n\t\tfloat vignette(vec2 uv) {\n\t\t\tfloat inner = vignetterParams.x;\n\t\t\tfloat outer = vignetterParams.y;\n\t\t\tfloat curvature = vignetterParams.z;\n\t\t\tfloat intensity = vignetterParams.w;\n\t\t\tvec2 curve = pow(abs(uv * 2.0 -1.0), vec2(1.0 / curvature));\n\t\t\tfloat edge = pow(length(curve), curvature);\n\t\t\treturn 1.0 - intensity * smoothstep(inner, outer, edge);\n\t\t}\t\t\n\t#endif\n\t#ifdef FRINGING\n\t\tuniform float fringingIntensity;\n\t\tvec3 fringing(vec2 uv, vec3 color) {\n\t\t\tvec2 centerDistance = uv0 - 0.5;\n\t\t\tvec2 offset = fringingIntensity * pow(centerDistance, vec2(2.0, 2.0));\n\t\t\tcolor.r = texture2D(sceneTexture, uv0 - offset).r;\n\t\t\tcolor.b = texture2D(sceneTexture, uv0 + offset).b;\n\t\t\treturn color;\n\t\t}\n\t#endif\n\t#ifdef CAS\n\t\tuniform float sharpness;\n\t\tfloat maxComponent(float x, float y, float z) { return max(x, max(y, z)); }\n\t\tvec3 toSDR(vec3 c) { return c / (1.0 + maxComponent(c.r, c.g, c.b)); }\n\t\tvec3 toHDR(vec3 c) { return c / (1.0 - maxComponent(c.r, c.g, c.b)); }\n\t\tvec3 cas(vec3 color, vec2 uv, float sharpness) {\n\t\t\tfloat x = sceneTextureInvRes.x;\n\t\t\tfloat y = sceneTextureInvRes.y;\n\t\t\tvec3 a = toSDR(texture2DLodEXT(sceneTexture, uv + vec2(0.0, -y), 0.0).rgb);\n\t\t\tvec3 b = toSDR(texture2DLodEXT(sceneTexture, uv + vec2(-x, 0.0), 0.0).rgb);\n\t\t\tvec3 c = toSDR(color.rgb);\n\t\t\tvec3 d = toSDR(texture2DLodEXT(sceneTexture, uv + vec2(x, 0.0), 0.0).rgb);\n\t\t\tvec3 e = toSDR(texture2DLodEXT(sceneTexture, uv + vec2(0.0, y), 0.0).rgb);\n\t\t\tfloat min_g = min(a.g, min(b.g, min(c.g, min(d.g, e.g))));\n\t\t\tfloat max_g = max(a.g, max(b.g, max(c.g, max(d.g, e.g))));\n\t\t\tfloat sharpening_amount = sqrt(min(1.0 - max_g, min_g) / max_g);\n\t\t\tfloat w = sharpening_amount * sharpness;\n\t\t\tvec3 res = (w * (a + b + d + e) + c) / (4.0 * w + 1.0);\n\t\t\treturn toHDR(res);\n\t\t}\n\t#endif\n\tvoid main() {\n\t\tvec2 uv = uv0;\n\t\t#ifdef TAA\n\t\t#ifdef WEBGPU\n\t\t\tuv.y = 1.0 - uv.y;\n\t\t#endif\n\t\t#endif\n\t\tvec4 scene = texture2DLodEXT(sceneTexture, uv, 0.0);\n\t\tvec3 result = scene.rgb;\n\t\t#ifdef CAS\n\t\t\tresult = cas(result, uv, sharpness);\n\t\t#endif\n\t\t#ifdef FRINGING\n\t\t\tresult = fringing(uv, result);\n\t\t#endif\n\t\t#ifdef BLOOM\n\t\t\tvec3 bloom = texture2DLodEXT(bloomTexture, uv, 0.0).rgb;\n\t\t\tresult += bloom * bloomIntensity;\n\t\t#endif\n\t\t#ifdef GRADING\n\t\t\tresult = contrastSaturationBrightness(result, brightnessContrastSaturation.x, brightnessContrastSaturation.z, brightnessContrastSaturation.y);\n\t\t#endif\n\t\tresult = toneMap(result);\n\t\t#ifdef VIGNETTE\n\t\t\tresult *= vignette(uv);\n\t\t#endif\n\t\tresult = gammaCorrectOutput(result);\n\t\tgl_FragColor = vec4(result, scene.a);\n\t}\n")}}},i.execute=function(){this.sceneTextureId.setValue(this.sceneTexture),this.sceneTextureInvResValue[0]=1/this.sceneTexture.width,this.sceneTextureInvResValue[1]=1/this.sceneTexture.height,this.sceneTextureInvResId.setValue(this.sceneTextureInvResValue),this._bloomTexture&&(this.bloomTextureId.setValue(this._bloomTexture),this.bloomIntensityId.setValue(this.bloomIntensity)),this._gradingEnabled&&this.bcsId.setValue([this.gradingBrightness,this.gradingContrast,this.gradingSaturation]),this._vignetteEnabled&&this.vignetterParamsId.setValue([this.vignetteInner,this.vignetteOuter,this.vignetteCurvature,this.vignetteIntensity]),this._fringingEnabled&&this.fringingIntensityId.setValue(this.fringingIntensity/1024),this.isSharpnessEnabled&&this.sharpnessId.setValue(ft.lerp(-.125,-.2,this.sharpness)),t.prototype.execute.call(this)},v(e,[{key:"bloomTexture",get:function(){return this._bloomTexture},set:function(t){this._bloomTexture!==t&&(this._bloomTexture=t,this._shaderDirty=!0)}},{key:"taaEnabled",get:function(){return this._taaEnabled},set:function(t){this._taaEnabled!==t&&(this._taaEnabled=t,this._shaderDirty=!0)}},{key:"gradingEnabled",get:function(){return this._gradingEnabled},set:function(t){this._gradingEnabled!==t&&(this._gradingEnabled=t,this._shaderDirty=!0)}},{key:"vignetteEnabled",get:function(){return this._vignetteEnabled},set:function(t){this._vignetteEnabled!==t&&(this._vignetteEnabled=t,this._shaderDirty=!0)}},{key:"fringingEnabled",get:function(){return this._fringingEnabled},set:function(t){this._fringingEnabled!==t&&(this._fringingEnabled=t,this._shaderDirty=!0)}},{key:"toneMapping",get:function(){return this._toneMapping},set:function(t){this._toneMapping!==t&&(this._toneMapping=t,this._shaderDirty=!0)}},{key:"toneMapChunk",get:function(){switch(this.toneMapping){case 0:return Ro.tonemappingLinearPS;case 1:return Ro.tonemappingFilmicPS;case 2:return Ro.tonemappingHejlPS;case 3:return Ro.tonemappingAcesPS;case 4:return Ro.tonemappingAces2PS;case 5:return Ro.tonemappingNeutralPS}return Ro.tonemappingNonePS}},{key:"sharpness",get:function(){return this._sharpness},set:function(t){this._sharpness!==t&&(this._sharpness=t,this._shaderDirty=!0)}},{key:"isSharpnessEnabled",get:function(){return this._sharpness>0}}])}(ep),uM=function(t){function e(e,i,n){var s;(s=t.call(this,e)||this).historyIndex=0,s.historyTexture=null,s.historyTextures=[],s.historyRenderTargets=[],s.sourceTexture=i,s.cameraComponent=n;var r=Ro.sampleCatmullRomPS;s.shader=s.createQuadShader("TaaResolveShader","\n\t\t\t#define QUALITY_HIGH\n\t\t"+r+"\n\tuniform highp sampler2D uSceneDepthMap;\n\tuniform sampler2D sourceTexture;\n\tuniform sampler2D historyTexture;\n\tuniform mat4 matrix_viewProjectionPrevious;\n\tuniform mat4 matrix_viewProjectionInverse;\n\tuniform vec4 jitters;\n\tuniform vec2 textureSize;\n\tvarying vec2 uv0;\n\tvec2 reproject(vec2 uv, float depth) {\n\t\t#ifndef WEBGPU\n\t\t\tdepth = depth * 2.0 - 1.0;\n\t\t#endif\n\t\tvec4 ndc = vec4(uv * 2.0 - 1.0, depth, 1.0);\n\t\tndc.xy -= jitters.xy;\n\t\tvec4 worldPosition = matrix_viewProjectionInverse * ndc;\n\t\tworldPosition /= worldPosition.w;\n\t\n\t\tvec4 screenPrevious = matrix_viewProjectionPrevious * worldPosition;\n\t\treturn (screenPrevious.xy / screenPrevious.w) * 0.5 + 0.5;\n\t}\n\tvec4 colorClamp(vec2 uv, vec4 historyColor) {\n\t\tvec3 minColor = vec3(9999.0);\n\t\tvec3 maxColor = vec3(-9999.0);\n \n\t\tfor(float x = -1.0; x <= 1.0; ++x)\n\t\t{\n\t\t\tfor(float y = -1.0; y <= 1.0; ++y)\n\t\t\t{\n\t\t\t\tvec3 color = texture2D(sourceTexture, uv + vec2(x, y) / textureSize).rgb;\n\t\t\t\tminColor = min(minColor, color);\n\t\t\t\tmaxColor = max(maxColor, color);\n\t\t\t}\n\t\t}\n \n\t\tvec3 clamped = clamp(historyColor.rgb, minColor, maxColor);\n\t\treturn vec4(clamped, historyColor.a);\n\t}\n\tvoid main()\n\t{\n\t\tvec2 uv = uv0;\n\t\t#ifdef WEBGPU\n\t\t\tuv.y = 1.0 - uv.y;\n\t\t#endif\n\t\tvec4 srcColor = texture2D(sourceTexture, uv);\n\t\tfloat depth = texture2DLodEXT(uSceneDepthMap, uv, 0.0).r;\n\t\tvec2 historyUv = reproject(uv0, depth);\n\t\t#ifdef QUALITY_HIGH\n\t\t\tvec4 historyColor = SampleTextureCatmullRom(TEXTURE_PASS(historyTexture), historyUv, textureSize);\n\t\t#else\n\t\t\tvec4 historyColor = texture2D(historyTexture, historyUv);\n\t\t#endif\n\t\tvec4 historyColorClamped = colorClamp(uv, historyColor);\n\t\tfloat mixFactor = (historyUv.x < 0.0 || historyUv.x > 1.0 || historyUv.y < 0.0 || historyUv.y > 1.0) ?\n\t\t\t1.0 : 0.05;\n\t\tgl_FragColor = mix(historyColorClamped, srcColor, mixFactor);\n\t}\n");var a=e.scope;return s.sourceTextureId=a.resolve("sourceTexture"),s.textureSizeId=a.resolve("textureSize"),s.textureSize=new Float32Array(2),s.historyTextureId=a.resolve("historyTexture"),s.viewProjPrevId=a.resolve("matrix_viewProjectionPrevious"),s.viewProjInvId=a.resolve("matrix_viewProjectionInverse"),s.jittersId=a.resolve("jitters"),s.setup(),s}x(e,t);var i=e.prototype;return i.destroy=function(){this.renderTarget&&(this.renderTarget.destroyTextureBuffers(),this.renderTarget.destroy(),this.renderTarget=null)},i.setup=function(){for(var t=0;t<2;++t)this.historyTextures[t]=new or(this.device,{name:"TAA-History-"+t,width:4,height:4,format:this.sourceTexture.format,mipmaps:!1,minFilter:1,magFilter:1,addressU:1,addressV:1}),this.historyRenderTargets[t]=new Cn({colorBuffer:this.historyTextures[t],depth:!1});this.historyTexture=this.historyTextures[0],this.init(this.historyRenderTargets[0],{resizeSource:this.sourceTexture})},i.before=function(){this.sourceTextureId.setValue(this.sourceTexture),this.historyTextureId.setValue(this.historyTextures[1-this.historyIndex]),this.textureSize[0]=this.sourceTexture.width,this.textureSize[1]=this.sourceTexture.height,this.textureSizeId.setValue(this.textureSize);var t=this.cameraComponent.camera;this.viewProjPrevId.setValue(t._viewProjPrevious.data),this.viewProjInvId.setValue(t._viewProjInverse.data),this.jittersId.setValue(t._jitters)},i.update=function(){return this.historyIndex=1-this.historyIndex,this.historyTexture=this.historyTextures[this.historyIndex],this.renderTarget=this.historyRenderTargets[this.historyIndex],this.historyTexture},e}(ep),dM=[],fM=function(t){function e(e,i,n,s,r,a){var o;return(o=t.call(this,e)||this).viewBindGroups=[],o.velocityTexture=void 0,o.scene=i,o.renderer=n,o.camera=s,o.setupRenderTarget(r,a),o}x(e,t);var i=e.prototype;return i.destroy=function(){var e,i;t.prototype.destroy.call(this),null==(e=this.renderTarget)||e.destroy(),this.renderTarget=null,null==(i=this.velocityTexture)||i.destroy(),this.velocityTexture=null,this.viewBindGroups.forEach((function(t){t.defaultUniformBuffer.destroy(),t.destroy()})),this.viewBindGroups.length=0},i.setupRenderTarget=function(t,e){var i=this.device,n=i.getRenderableHdrFormat([ve,me]);this.velocityTexture=new or(i,{name:"VelocityTexture",width:4,height:4,format:n,mipmaps:!1,minFilter:0,magFilter:0,addressU:1,addressV:1});var s=new Cn({name:"PrepassRT",depthBuffer:t});this.init(s,e),this.depthStencilOps.storeDepth=!0},i.after=function(){this.device.scope.resolve("uSceneDepthMap").setValue(this.renderTarget.depthBuffer),this.device.scope.resolve("uSceneVelocityMap").setValue(this.velocityTexture)},i.execute=function(){for(var t=this.renderer,e=this.scene,i=this.renderTarget,n=this.camera.camera,s=e.layers.layerList,r=e.layers.subLayerEnabled,a=e.layers.subLayerList,o=0;o0),cP.cross(t,this.root.right),this._shapes.yz.entity.enabled=cP.length()0),0)),cP.cross(t,this.root.up),this._shapes.xz.entity.enabled=cP.length()0),0,+(cP.dot(this.root.right)>0)))},i._storeNodePositions=function(){for(var t=0;t.9?(_P.sub2(o,i),SP.copy(this._camera.entity.getRotation()).invert().transformVector(_P,_P),h=Math.sign(c)*Math.atan2(_P.y,_P.x)*ft.RAD_TO_DEG):(_P.copy(i),vP.cross(a.normal,l).normalize().add(i),this._camera.worldToScreen(_P,gP),this._camera.worldToScreen(vP,yP),_P.sub2(yP,gP).normalize(),vP.set(t,e,0),h=_P.dot(vP)),{point:o,angle:h}},v(e,[{key:"xyzTubeRadius",get:function(){return this._shapes.x.tubeRadius},set:function(t){this._setDiskProp("tubeRadius",t)}},{key:"xyzRingRadius",get:function(){return this._shapes.x.ringRadius},set:function(t){this._setDiskProp("ringRadius",t)}},{key:"faceTubeRadius",get:function(){return this._shapes.face.tubeRadius},set:function(t){this._shapes.face.tubeRadius=t}},{key:"faceRingRadius",get:function(){return this._shapes.face.ringRadius},set:function(t){this._shapes.face.ringRadius=t}},{key:"ringTolerance",get:function(){return this._shapes.x.tolerance},set:function(t){this._setDiskProp("tolerance",t),this._shapes.face.tolerance=t}}])}(zM),EP=function(t){function e(e,i){var n;return void 0===i&&(i={}),(n=t.call(this,e,i)||this)._size=.12,n._tolerance=.05,n.triData=[new WM(new Rf,2)],n._createCenter(),n}x(e,t);var i=e.prototype;return i._createCenter=function(){this._createRoot("boxCenter"),this._updateTransform(),this._addRenderMesh(this.entity,"box",this._shading)},i._updateTransform=function(){this.entity.setLocalScale(this._size,this._size,this._size)},v(e,[{key:"size",get:function(){return this._size},set:function(t){this._size=null!=t?t:1,this._updateTransform()}},{key:"tolerance",get:function(){return this._tolerance},set:function(t){this._tolerance=t,this._updateTransform()}}])}(nP),AP=new wt,CP=new wt,MP=new Nt,PP=function(t){function e(e,i){var n;return void 0===i&&(i={}),(n=t.call(this,e,i)||this)._gap=0,n._lineThickness=.02,n._lineLength=.5,n._boxSize=.12,n._tolerance=.1,n._box=void 0,n._line=void 0,n._flipped=!1,n.triData=[new WM(new Rf),new WM(new lp,1)],n._createBoxLine(),n}x(e,t);var i=e.prototype;return i._createBoxLine=function(){this._createRoot("boxLine"),this._box=new Sm("box:"+this.axis),this.entity.addChild(this._box),this._updateBox(),this._addRenderMesh(this._box,"box",this._shading),this._line=new Sm("line:"+this.axis),this.entity.addChild(this._line),this._updateLine(),this._addRenderMesh(this._line,"cylinder",this._shading)},i._updateBox=function(){AP.set(0,this._gap+.5*this._boxSize+this._lineLength,0),MP.set(0,0,0,1),CP.set(this._boxSize,this._boxSize,this._boxSize),this.triData[0].setTransform(AP,MP,CP),this._box.setLocalPosition(0,this._gap+.5*this._boxSize+this._lineLength,0),this._box.setLocalScale(this._boxSize,this._boxSize,this._boxSize)},i._updateLine=function(){AP.set(0,this._gap+.5*this._lineLength,0),MP.set(0,0,0,1),CP.set(this._lineThickness+this._tolerance,this._lineLength,this._lineThickness+this._tolerance),this.triData[1].setTransform(AP,MP,CP),this._line.setLocalPosition(0,this._gap+.5*this._lineLength,0),this._line.setLocalScale(this._lineThickness,this._lineLength,this._lineThickness)},v(e,[{key:"gap",get:function(){return this._gap},set:function(t){this._gap=null!=t?t:0,this._updateLine(),this._updateBox()}},{key:"lineThickness",get:function(){return this._lineThickness},set:function(t){this._lineThickness=null!=t?t:1,this._updateLine(),this._updateBox()}},{key:"lineLength",get:function(){return this._lineLength},set:function(t){this._lineLength=null!=t?t:1,this._updateLine(),this._updateBox()}},{key:"boxSize",get:function(){return this._boxSize},set:function(t){this._boxSize=null!=t?t:1,this._updateBox()}},{key:"tolerance",get:function(){return this._tolerance},set:function(t){this._tolerance=t,this._updateLine()}},{key:"flipped",get:function(){return this._flipped},set:function(t){this._flipped!==t&&(this._flipped=t,this._rotation.equals(wt.ZERO)?AP.set(0,0,this._flipped?180:0):AP.copy(this._rotation).mulScalar(this._flipped?-1:1),this._line.enabled=!this._flipped,this.entity.setLocalEulerAngles(AP))}}])}(nP),RP=new wt,IP=new wt,DP=new Nt,LP=.98,kP=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._shapes={xyz:new EP(n._device,{axis:xM,layers:[n._layer.id],shading:n._shading,defaultColor:n._meshColors.axis.xyz,hoverColor:n._meshColors.hover.xyz}),yz:new sP(n._device,{axis:vM,layers:[n._layer.id],shading:n._shading,rotation:new wt(0,0,-90),defaultColor:n._meshColors.axis.x,hoverColor:n._meshColors.hover.x}),xz:new sP(n._device,{axis:gM,layers:[n._layer.id],shading:n._shading,rotation:new wt(0,0,0),defaultColor:n._meshColors.axis.y,hoverColor:n._meshColors.hover.y}),xy:new sP(n._device,{axis:yM,layers:[n._layer.id],shading:n._shading,rotation:new wt(90,0,0),defaultColor:n._meshColors.axis.z,hoverColor:n._meshColors.hover.z}),x:new PP(n._device,{axis:vM,layers:[n._layer.id],shading:n._shading,rotation:new wt(0,0,-90),defaultColor:n._meshColors.axis.x,hoverColor:n._meshColors.hover.x}),y:new PP(n._device,{axis:gM,layers:[n._layer.id],shading:n._shading,rotation:new wt(0,0,0),defaultColor:n._meshColors.axis.y,hoverColor:n._meshColors.hover.y}),z:new PP(n._device,{axis:yM,layers:[n._layer.id],shading:n._shading,rotation:new wt(90,0,0),defaultColor:n._meshColors.axis.z,hoverColor:n._meshColors.hover.z})},n._coordSpace=mM,n._nodeScales=new Map,n._forward=new wt,n._useUniformScaling=!1,n.snapIncrement=1,n.flipShapes=!0,n.lowerBoundScale=new wt(-1/0,-1/0,-1/0),n._createTransform(),n.on(zM.EVENT_TRANSFORMSTART,(function(){n._storeNodeScales()})),n.on(zM.EVENT_TRANSFORMMOVE,(function(t){n.snap&&(t.mulScalar(1/n.snapIncrement),t.round(),t.mulScalar(n.snapIncrement)),t.mulScalar(1/n._scale),n._setNodeScales(t.add(wt.ONE))})),n.on(zM.EVENT_NODESDETACH,(function(){n._nodeScales.clear()})),n._app.on("prerender",(function(){n._shapesLookAtCamera()})),n}x(e,t);var i=e.prototype;return i._setArrowProp=function(t,e){this._shapes.x[t]=e,this._shapes.y[t]=e,this._shapes.z[t]=e},i._setPlaneProp=function(t,e){this._shapes.yz[t]=e,this._shapes.xz[t]=e,this._shapes.xy[t]=e},i._shapesLookAtCamera=function(){var t=this.facing,e=t.dot(this.root.right);this._shapes.x.entity.enabled=Math.abs(e)0),RP.cross(t,this.root.right),this._shapes.yz.entity.enabled=RP.length()0),0)),RP.cross(t,this.root.up),this._shapes.xz.entity.enabled=RP.length()0),0,+(RP.dot(this.root.right)>0)))},i._storeNodeScales=function(){for(var t=0;t=r.length?e(new Error("Failed to create a graphics device")):Promise.resolve(r[i++]()).then((function(e){e?t(e):n()})).catch((function(t){console.log(t),n()}))};n()}))},t.createMesh=IA,t.createPlane=EA,t.createScript=XT,t.createShader=Oo,t.createShaderFromCode=Fo,t.createSphere=wA,t.createStyle=function(t){var e=document.createElement("style");return e.type="text/css",e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t)),e},t.createTorus=CA,t.createURI=function(t){var e="";if((t.authority||t.scheme)&&(t.host||t.hostpath))throw new Error("Can't have 'scheme' or 'authority' and 'host' or 'hostpath' option");if(t.host&&t.hostpath)throw new Error("Can't have 'host' and 'hostpath' option");if(t.path&&t.hostpath)throw new Error("Can't have 'path' and 'hostpath' option");return t.scheme&&(e+=t.scheme+":"),t.authority&&(e+="//"+t.authority),t.host&&(e+=t.host),t.path&&(e+=t.path),t.hostpath&&(e+=t.hostpath),t.query&&(e+="?"+t.query),t.fragment&&(e+="#"+t.fragment),e},t.data={},t.dracoInitialize=function(t){null!=t&&t.lazyInit?VS=t:XS(t)},t.drawFullscreenQuad=DA,t.drawQuadWithShader=Xo,t.drawTexture=function(t,e,i,n,s,r){n=n||t.getCopyShader(),t.constantTexSource.setValue(e),Xo(t,i,n,s,r)},t.events=R,t.extend=d,t.getPixelFormatArrayType=De,t.getProgramLibrary=Do,t.getReservedScriptNames=function(){return WT},t.getTouchTargetCoords=ja,t.gfx=bA,t.guid=I,t.http=Qa,t.inherits=function(t,e){var i=function(){},n=function(i,n,s,r,a,o,h,l){e.call(this,i,n,s,r,a,o,h,l),t.call(this,i,n,s,r,a,o,h,l)};return n._super=e.prototype,i.prototype=e.prototype,n.prototype=new i,n},t.input=jA,t.isCompressedPixelFormat=Re,t.isIntegerPixelFormat=Ie,t.log=mA,t.makeArray=function(t){return Array.prototype.slice.call(t)},t.math=ft,t.now=lt,t.path=D,t.pixelFormatInfo=Pe,t.platform=G,t.posteffect=LA,t.prefilterCubemap=function(t){},t.programlib=SA,t.registerScript=qT,t.reprojectTexture=lc,t.revision=h,t.scene=NA,t.script=Hp,t.semanticToLocation=Ki,t.shFromCubemap=function(t,e,i){if(7!==e.format)return null;if(!e._levels[0]||!e._levels[0][0])return null;var n=e.width;if(!e._levels[0][0].length){if(!(e._levels[0][0]instanceof HTMLImageElement))return null;for(var s=Fo(t,Ro.fullscreenQuadVS,Ro.fullscreenQuadPS,"fsQuadSimple"),r=t.scope.resolve("source"),a=0;a<6;a++){var o=e._levels[0][a],h=new or(t,{name:"prefiltered-cube",cubemap:!1,type:ui,format:e.format,width:n,height:n,mipmaps:!1});h._levels[0]=o,h.upload();var l=new or(t,{name:"prefiltered-cube",cubemap:!1,type:ui,format:e.format,width:n,height:n,mipmaps:!1}),c=new Cn({colorBuffer:l,depth:!1});r.setValue(h),t.setBlendState(nn.NOBLEND),Xo(t,c,s);var u=t.gl;u.bindFramebuffer(u.FRAMEBUFFER,c.impl._glFrameBuffer);var d=new Uint8Array(n*n*4);u.readPixels(0,0,h.width,h.height,u.RGBA,u.UNSIGNED_BYTE,d),e._levels[0][a]=d}}for(var f=[],p=0;p-1||this._tweens.push(this._add[t]);this._add.length=0}}};var Tween=function(t,i,e){pc.events.attach(this),this.manager=i,e&&(this.entity=null),this.time=0,this.complete=!1,this.playing=!1,this.stopped=!0,this.pending=!1,this.target=t,this.duration=0,this._currentDelay=0,this.timeScale=1,this._reverse=!1,this._delay=0,this._yoyo=!1,this._count=0,this._numRepeats=0,this._repeatDelay=0,this._from=!1,this._slerp=!1,this._fromQuat=new pc.Quat,this._toQuat=new pc.Quat,this._quat=new pc.Quat,this.easing=pc.Linear,this._sv={},this._ev={}},_parseProperties=function(t){var i;return t instanceof pc.Vec2?i={x:t.x,y:t.y}:t instanceof pc.Vec3?i={x:t.x,y:t.y,z:t.z}:t instanceof pc.Vec4||t instanceof pc.Quat?i={x:t.x,y:t.y,z:t.z,w:t.w}:t instanceof pc.Color?(i={r:t.r,g:t.g,b:t.b},void 0!==t.a&&(i.a=t.a)):i=t,i};Tween.prototype={to:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this},from:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this._from=!0,this},rotate:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this._slerp=!0,this},start:function(){var t,i,e,s;if(this.playing=!0,this.complete=!1,this.stopped=!1,this._count=0,this.pending=this._delay>0,this._reverse&&!this.pending?this.time=this.duration:this.time=0,this._from){for(t in this._properties)this._properties.hasOwnProperty(t)&&(this._sv[t]=this._properties[t],this._ev[t]=this.target[t]);this._slerp&&(this._toQuat.setFromEulerAngles(this.target.x,this.target.y,this.target.z),i=void 0!==this._properties.x?this._properties.x:this.target.x,e=void 0!==this._properties.y?this._properties.y:this.target.y,s=void 0!==this._properties.z?this._properties.z:this.target.z,this._fromQuat.setFromEulerAngles(i,e,s))}else{for(t in this._properties)this._properties.hasOwnProperty(t)&&(this._sv[t]=this.target[t],this._ev[t]=this._properties[t]);this._slerp&&(i=void 0!==this._properties.x?this._properties.x:this.target.x,e=void 0!==this._properties.y?this._properties.y:this.target.y,s=void 0!==this._properties.z?this._properties.z:this.target.z,void 0!==this._properties.w?(this._fromQuat.copy(this.target),this._toQuat.set(i,e,s,this._properties.w)):(this._fromQuat.setFromEulerAngles(this.target.x,this.target.y,this.target.z),this._toQuat.setFromEulerAngles(i,e,s)))}return this._currentDelay=this._delay,this.manager.add(this),this},pause:function(){this.playing=!1},resume:function(){this.playing=!0},stop:function(){this.playing=!1,this.stopped=!0},delay:function(t){return this._delay=t,this.pending=!0,this},repeat:function(t,i){return this._count=0,this._numRepeats=t,this._repeatDelay=i||0,this},loop:function(t){return t?(this._count=0,this._numRepeats=1/0):this._numRepeats=0,this},yoyo:function(t){return this._yoyo=t,this},reverse:function(){return this._reverse=!this._reverse,this},chain:function(){for(var t=arguments.length;t--;)t>0?arguments[t-1]._chained=arguments[t]:this._chained=arguments[t];return this},onUpdate:function(t){return this.on("update",t),this},onComplete:function(t){return this.on("complete",t),this},onLoop:function(t){return this.on("loop",t),this},update:function(t){if(this.stopped)return!1;if(!this.playing)return!0;if(!this._reverse||this.pending?this.time+=t*this.timeScale:this.time-=t*this.timeScale,this.pending){if(!(this.time>this._currentDelay))return!0;this._reverse?this.time=this.duration-(this.time-this._currentDelay):this.time-=this._currentDelay,this.pending=!1}var i=0;(!this._reverse&&this.time>this.duration||this._reverse&&this.time<0)&&(this._count++,this.complete=!0,this.playing=!1,this._reverse?(i=this.duration-this.time,this.time=0):(i=this.time-this.duration,this.time=this.duration));var e,s,n=0===this.duration?1:this.time/this.duration,r=this.easing(n);for(var h in this._properties)this._properties.hasOwnProperty(h)&&(e=this._sv[h],s=this._ev[h],this.target[h]=e+(s-e)*r);if(this._slerp&&this._quat.slerp(this._fromQuat,this._toQuat,r),this.entity&&(this.entity._dirtifyLocal(),this.element&&this.entity.element&&(this.entity.element[this.element]=this.target),this._slerp&&this.entity.setLocalRotation(this._quat)),this.fire("update",t),this.complete){var o=this._repeat(i);return o?this.fire("loop"):(this.fire("complete",i),this.entity&&this.entity.off("destroy",this.stop,this),this._chained&&this._chained.start()),o}return!0},_repeat:function(t){if(this._count{this.setOpacityCascade(s.v)})).start()},pc.Entity.prototype.opacityTo=function(t,i,e){if(!this.element.material)return;let s={v:t};return this.setOpacity(t),this.tween(s).to({v:i},e,pc.SineOut).on("update",(()=>{this.setOpacity(s.v)})).start()},pc.Entity.prototype.setTextureFromURL=function(t){let i="t_"+t,e=pc.app.assets.find(i,"texture");if(null===e){pc.app.loader.getHandler("texture").crossOrigin="anonymous";var s=new pc.Asset(i,"texture",{url:t});pc.app.assets.add(s),s.on("load",(t=>{this.element.texture=t.resource})),pc.app.assets.load(s)}else this.element.texture=e.resource},pc.Entity.prototype.blink=function(t,i,e,s){for(let n=0;n{this.setOpacity(t)}),e*n*2),setTimeout((()=>{this.setOpacity(i)}),e*(2*n+1))};var t=pc.AppBase.getApplication();t&&t.addTweenManager()}();var Background=pc.createScript("background");Background.attributes.add("startPosX",{type:"number",default:1}),Background.attributes.add("endPosX",{type:"number",default:1}),Background.attributes.add("durationTime",{type:"number",default:1}),Background.prototype.initialize=function(){this.entity.setLocalPosition(this.startPosX,0,0),this.tween=this.entity.tween(this.entity.getLocalPosition()).to(new pc.Vec3(this.endPosX,0,0),this.durationTime,pc.Linear).loop(!0).yoyo(!0),this.tween.start()};var UserBalance=pc.createScript("userBalance");UserBalance.attributes.add("userBalanceText",{type:"entity"}),UserBalance.attributes.add("userName",{type:"entity"}),UserBalance.prototype.initialize=function(){UserBalance.instance=this,this.userBalance=0},UserBalance.prototype.setUserName=function(e){this.userName.element.text=e},UserBalance.prototype.getUserBalance=function(){return this.userBalance},UserBalance.prototype.setBalance=function(e){this.userBalance=e;let t={value:Number(this.userBalanceText.element.text)},a=this.userBalanceText.element,n=this.entity.tween(t).to({value:e},.3,pc.Linear);n.on("update",(function(e){let n=parseFloat(t.value.toFixed(0));a.text=`${n}`})),n.start()},UserBalance.prototype.update=function(e){};var DummyServer=pc.createScript("dummyServer");DummyServer.prototype.initialize=function(){DummyServer.instance=this,this.betAmount=-1,this.userBalance=0},DummyServer.prototype.login=async function(){return this.userBalance=getRandomInt(1e3,5e3),{id:"userName",balance:this.userBalance}},DummyServer.prototype.testCode=function(){let e=Array.from({length:40},((e,t)=>t+1)),t=shuffle(e).splice(0,10);console.log(e),console.log(t)},DummyServer.prototype.testCode=function(){let e=Array.from({length:40},((e,t)=>t+1)),t=shuffle(e).splice(0,10);console.log(e),console.log(t)},DummyServer.prototype.startGame=function(e,t){if(e<0)return;if(t.length<1)return;let r=Array.from({length:40},((e,t)=>t+1)),n=shuffle(r).splice(0,10),s=findIntersection(t,n),o=winRate[t.length-1][s.length];this.userBalance=this.userBalance-e,this.betAmount=e;let l=o*e;return this.userBalance=this.userBalance+l,{balance:this.userBalance,betAmount:this.betAmount,profit:l,multiplier:o,winNumbers:n,userNumbers:t,matchResult:s}};var GlobalFunction=pc.createScript("globalFunction");function getRandomInt(n,o){return n=Math.ceil(n),o=Math.floor(o),Math.floor(Math.random()*(o-n))+n}function findIntersection(n,o){const e=new Set(n),t=new Set(o);let r=[];return r=[...e].filter((n=>t.has(n))),r}function generateRandomNumbersInRange(n,o,e,t){const r=[];for(;r.length0;t--)o=Math.floor(Math.random()*(t+1)),e=n[t],n[t]=n[o],n[o]=e;return n}function getTable(n,o){let e=[];for(let t=0;t{this.loadJsonFromRemote(n,(function(n){console.log(n);let o=JSON.stringify(n),s=JSON.parse(o);e(s)}))}))}async function delay(n){return new Promise((e=>setTimeout((()=>{e(n)}),n)))}async function loadJsonFromRemote(n,e){var o=new XMLHttpRequest;o.addEventListener("load",(function(){e(JSON.parse(this.response))})),o.open("GET",n),o.send()}var Middle=pc.createScript("middle");Middle.attributes.add("boxButton",{type:"entity",array:!0}),Middle.attributes.add("resultText",{type:"entity"}),Middle.prototype.initialize=function(){Middle.instance=this,this.idleTimer=null,this.buttons=[],this.entity.forEach((t=>{"Button"===t.name&&this.buttons.push(t)})),this.selectedIdx=-1};var GameController=pc.createScript("gameController");GameController.prototype.initialize=function(){GameController.instance=this},GameController.prototype.postInitialize=function(){this.init(),this.setIdle()},GameController.prototype.init=async function(){let e=await DummyServer.instance.login();console.log(e),UserBalance.instance.setBalance(e.balance),UserBalance.instance.setUserName(e.id)},GameController.prototype.update=function(e){},GameController.prototype.betStart=function(){BetController.instance.reset(),Middle.instance.setReady(),Bottom.instance.setBet()},GameController.prototype.startGame=function(e){Middle.instance.setStartGame(),Bottom.instance.setStartGame()},GameController.prototype.betGame=async function(e,t){let n=DummyServer.instance.startGame(e,t);console.log(n),ButtonController.instance.setFreeze(!0),UserBalance.instance.setBalance(UserBalance.instance.getUserBalance()-e),await delay(1e3);for(let e=0;e0,n.multiplier,n.profit),await delay(500),UserBalance.instance.setBalance(n.balance),Bottom.instance.resetMultiplierColor(),ButtonController.instance.setFreeze(!1)},GameController.prototype.setIdle=function(){};var Bottom=pc.createScript("bottom");Bottom.attributes.add("startButton",{type:"entity"}),Bottom.attributes.add("clearButton",{type:"entity"}),Bottom.attributes.add("randomButton",{type:"entity"}),Bottom.attributes.add("betEditButton",{type:"entity"}),Bottom.attributes.add("winResult",{type:"entity"}),Bottom.attributes.add("multiplier",{type:"entity"}),Bottom.attributes.add("profit",{type:"entity"}),Bottom.attributes.add("loseResult",{type:"entity"}),Bottom.attributes.add("betAmountText",{type:"entity"}),Bottom.attributes.add("betUi",{type:"entity"}),Bottom.prototype.initialize=function(){Bottom.instance=this,this.setButton(this.startButton,this.onClickStart),this.setButton(this.clearButton,this.onClickClear),this.setButton(this.randomButton,this.onClickRandom),this.setButton(this.betEditButton,this.onClickBetEdit),this.disableButton(!1),this.winEffectTimer=null,this.bellToggle=!1,this.betAmount=0,console.log(winRate)},Bottom.prototype.setButton=function(t,o){t.button.on("touchend",o,this),t.button.on("mouseup",o,this)},Bottom.prototype.onClickStart=async function(){AudioController.instance.playSound("Click"),0!==ButtonController.instance.userNumber.length&&(this.disableButton(!0),UserBalance.instance.userBalance{this.changeButtonState(this.startButton,!0),this.changeTexture(this.startButton,this.start_inactive)}),1e3)},Bottom.prototype.setBetAmount=function(t){this.betAmountText.element.text=`${t}`,this.betAmount=t},Bottom.prototype.resetMultiplierColor=function(){ResultController.instance.resetColor(),this.disableButton(!1)},Bottom.prototype.setResultGame=async function(t,o,e){t?(AudioController.instance.playSound("Win"),this.multiplier.element.text=`${o}x`,this.profit.element.text=`+${e}`):AudioController.instance.playSound("Lose"),this.winResult.enabled=t,this.loseResult.enabled=!t,await delay(1500),this.winResult.enabled=!1,this.loseResult.enabled=!1},Bottom.prototype.betAmountErr=function(){var t=new pc.Color(0,0,0),o=this.entity.tween(t).yoyo(!0).repeat(4).to(new pc.Color(1,0,0),.2,pc.Linear);o.onUpdate((o=>{this.betAmountText.element.color=t})),o.start()};var AudioController=pc.createScript("audioController");AudioController.attributes.add("soundSource",{type:"entity"}),AudioController.prototype.initialize=function(){AudioController.instance=this,this.isMute=!0,this.soundSource.sound.volume=0},AudioController.prototype.setMute=function(o){this.isMute=o,this.isMute?this.soundSource.sound.volume=0:this.soundSource.sound.volume=.55},AudioController.prototype.playSound=function(o){!0!==this.isMute&&this.soundSource.sound.play(o)};var BetController=pc.createScript("betController");BetController.attributes.add("betUi",{type:"entity"}),BetController.attributes.add("betButton",{type:"entity",array:!0}),BetController.attributes.add("okButton",{type:"entity"}),BetController.attributes.add("cancelButton",{type:"entity"}),BetController.attributes.add("clearButton",{type:"entity"}),BetController.attributes.add("betAmountText",{type:"entity"}),BetController.attributes.add("errorText",{type:"entity"}),BetController.prototype.initialize=function(){BetController.instance=this,this.timer=null,this.betAmount=0,this.errorText.enabled=!1,setButton(this.cancelButton,this.onBetCancel,this),setButton(this.okButton,this.onBetOk,this),setButton(this.clearButton,this.onBetClear,this)},BetController.prototype.reset=function(){this.betAmount=0,this.updateText(),this.resetAllButton()},BetController.prototype.resetAllButton=function(){this.betButton.forEach((t=>t.element.color=new pc.Color(.5,.5,.5,1)))},BetController.prototype.betChange=function(t){let e=this.betAmount+t;return e>UserBalance.instance.getUserBalance()?(this.showErrorMsg(),!1):(this.errorText.enabled=!1,this.betAmount=e,this.updateText(),!0)},BetController.prototype.updateText=function(){let t=getCommaText(this.betAmount);this.betAmountText.element.text=`${t}`},BetController.prototype.onBetClear=function(){AudioController.instance.playSound("Click"),console.log("BetController.prototype.betOk"),this.betAmount=0,this.updateText()},BetController.prototype.onBetOk=function(){AudioController.instance.playSound("Click"),console.log("BetController.prototype.betOk"),this.betUi.enabled=!1,Bottom.instance.setBetAmount(this.betAmount)},BetController.prototype.onBetCancel=function(){AudioController.instance.playSound("Click"),this.betUi.enabled=!1},BetController.prototype.showErrorMsg=function(){this.errorText.enabled=!0,clearTimeout(this.timer),this.timer=setTimeout((()=>{this.errorText.enabled=!1}),1e3)};var NumButton=pc.createScript("numButton");NumButton.attributes.add("betAmount",{type:"number"}),NumButton.prototype.initialize=function(){let t=this.entity.children[0],n=this.betAmount,e=getCommaText(n);t.element.text=`+${e}`,setButton(this.entity,this.onClick,this)},NumButton.prototype.onClick=function(){AudioController.instance.playSound("Click");BetController.instance.betChange(this.betAmount)};var SoundButton=pc.createScript("soundButton");SoundButton.attributes.add("onImg",{type:"entity"}),SoundButton.attributes.add("offImg",{type:"entity"}),SoundButton.prototype.initialize=function(){SoundButton.instance=this,this.isMute=!0,this.setButton(this.entity,this.onClick)},SoundButton.prototype.onClick=function(){this.isMute=!this.isMute,this.onImg.enabled=!1,this.offImg.enabled=!1,this.isMute?this.offImg.enabled=!0:this.onImg.enabled=!0,AudioController.instance.setMute(this.isMute)},SoundButton.prototype.setButton=function(t,n){t.element.on("touchend",n,this),t.element.on("mouseup",n,this)};var BoxButton=pc.createScript("boxButton");BoxButton.attributes.add("boxIndex",{type:"number"}),BoxButton.attributes.add("bottom",{type:"entity"}),BoxButton.attributes.add("top",{type:"entity"}),BoxButton.attributes.add("win",{type:"entity"}),BoxButton.attributes.add("numberText",{type:"entity"});const ButtonState={NON:"non",SELECTED:"sel",WIN:"win",LOSE:"lose",DISABLE:"disable"};BoxButton.prototype.initialize=function(){this.entity.button.on("mouseenter",this.onEnter,this),this.entity.button.on("mouseleave",this.onLeave,this),this.entity.button.on("mousedown",this.onPress,this),this.entity.button.on("mouseup",this.onRelease,this),this.entity.button.on("touchstart",this.onPress,this),this.entity.button.on("touchend",this.onRelease,this),this.setInit()},BoxButton.prototype.setInit=function(){this.isSelected=!1,this.win.enabled=!1,this.btnState=ButtonState.NON,this.entity.button.active=!0,this.top.setLocalPosition(0,10,0),this.bottom.element.color=rgbToColor(50,50,50,255),this.top.element.color=rgbToColor(110,110,110,255)},BoxButton.prototype.setButtonNumber=function(t){this.boxIndex=t,this.numberText.element.color=pc.Color.WHITE,this.numberText.element.text=`${t}`},BoxButton.prototype.onEnter=function(t){this.btnState!==ButtonState.WIN&&this.btnState!==ButtonState.LOSE&&this.btnState!==ButtonState.DISABLE&&(this.hovered=!0,this.top.setLocalPosition(0,15,0),this.btnState===ButtonState.NON?(this.bottom.element.color=rgbToColor(110,110,110,255),this.top.element.color=rgbToColor(202,202,202,255)):(this.bottom.element.color=rgbToColor(135,205,255,255),this.top.element.color=rgbToColor(182,225,255,255)))},BoxButton.prototype.onLeave=function(t){this.btnState!==ButtonState.DISABLE&&(this.btnState!==ButtonState.NON&&this.btnState!==ButtonState.SELECTED||this.top.setLocalPosition(0,10,0),this.hovered=!1,this.btnState===ButtonState.NON?(this.bottom.element.color=rgbToColor(50,50,50,255),this.top.element.color=rgbToColor(110,110,110,255)):(this.bottom.element.color=rgbToColor(39,165,255,255),this.top.element.color=rgbToColor(113,196,255,255)))},BoxButton.prototype.setDisable=function(t){!0===t?(console.log(this.boxIndex+" / "+this.btnState),this.btnState===ButtonState.NON&&(this.bottom.element.color=rgbToColor(32,32,32,255),this.top.element.color=rgbToColor(50,50,50,255),this.btnState=ButtonState.DISABLE,this.entity.button.active=!1)):this.btnState===ButtonState.DISABLE&&(this.bottom.element.color=rgbToColor(50,50,50,255),this.top.element.color=rgbToColor(110,110,110,255),this.btnState=ButtonState.NON,this.entity.button.active=!0)},BoxButton.prototype.setLose=function(){this.numberText.element.color=pc.Color.RED,this.bottom.element.color=rgbToColor(0,0,0,255),this.top.element.color=rgbToColor(20,20,20,255)},BoxButton.prototype.onPress=function(){this.btnState!==ButtonState.DISABLE&&(this.btnState===ButtonState.NON?!0===ButtonController.instance.isSelectable()&&(this.btnState=ButtonState.SELECTED,ButtonController.instance.selectNumber(this.boxIndex)):(this.btnState=ButtonState.NON,ButtonController.instance.deselectNumber(this.boxIndex)),this.onEnter())},BoxButton.prototype.setFreeze=function(t){this.numberText.element.color=pc.Color.WHITE,this.entity.button.active=!t,!1===t&&(this.btnState===ButtonState.SELECTED?this.win.enabled=!1:this.btnState===ButtonState.DISABLE?(this.bottom.element.color=rgbToColor(32,32,32,255),this.top.element.color=rgbToColor(50,50,50,255),this.entity.button.active=!1):(this.top.setLocalPosition(0,10,0),this.bottom.element.color=rgbToColor(50,50,50,255),this.top.element.color=rgbToColor(110,110,110,255)))},BoxButton.prototype.setWin=function(){this.btnState===ButtonState.SELECTED?this.win.enabled=!0:this.setLose()};var ButtonController=pc.createScript("buttonController");ButtonController.prototype.initialize=function(){ButtonController.instance=this,this.userNumber=[]},ButtonController.prototype.postInitialize=function(){this.buttons=[];let t=0;this.entity.children.forEach((e=>{e.children.forEach((e=>{this.buttons.push(e.script.boxButton),t++,e.script.boxButton.setButtonNumber(t)}))}))},ButtonController.prototype.setFreeze=function(t){this.buttons.forEach((e=>{e.setFreeze(t)}))},ButtonController.prototype.random=async function(){let t=10-this.userNumber.length;for(let e=0;e{t.setInit()})),ResultController.instance.changeUserButton(this.userNumber.length)},ButtonController.prototype.isSelectable=function(){return this.userNumber.length<10},ButtonController.prototype.selectNumber=function(t){this.userNumber.length>=10||(this.userNumber.push(t),10===this.userNumber.length&&!1===this.isSelectable()&&this.buttons.forEach((t=>{t.setDisable(!0)})),ResultController.instance.changeUserButton(this.userNumber.length))},ButtonController.prototype.deselectNumber=function(t){const e=this.userNumber.indexOf(t);-1!==e&&(this.userNumber.splice(e,1),9===this.userNumber.length&&this.buttons.forEach((t=>{t.setDisable(!1)}))),ResultController.instance.changeUserButton(this.userNumber.length)},ButtonController.prototype.setWinNumber=function(t){this.buttons[t-1].setWin()};var ResultController=pc.createScript("resultController");ResultController.prototype.initialize=function(){ResultController.instance=this},ResultController.prototype.postInitialize=function(){this.resultBox=[],this.entity.children.forEach((t=>{this.resultBox.push(t.script.resultBox)})),this.resultBox.forEach((t=>{t.entity.enabled=!1}))},ResultController.prototype.winCount=function(t){for(let e=0;e{t.setNormalColor()}))},ResultController.prototype.changeUserButton=function(t){if(t<=0)this.resultBox.forEach((t=>{t.entity.enabled=!1}));else{const e=winRate[t-1];let o=0;this.resultBox.forEach((t=>{e.length<=o?t.entity.enabled=!1:(t.entity.enabled=!0,t.setText(o,e[o]),t.setNormalColor()),o++}))}};var ResultBox=pc.createScript("resultBox");ResultBox.attributes.add("numberText",{type:"entity"}),ResultBox.prototype.initialize=function(){},ResultBox.prototype.setText=function(t,e){this.numberText.element.text=`${e}x\n${t}`},ResultBox.prototype.setWinColor=function(){this.entity.element.color=rgbToColor(96,255,0,255)},ResultBox.prototype.setNormalColor=function(){this.entity.element.color=rgbToColor(255,255,255,255)}; \ No newline at end of file diff --git a/Keno/Keno/__loading__.js b/Keno/Keno/__loading__.js new file mode 100644 index 0000000..627a013 --- /dev/null +++ b/Keno/Keno/__loading__.js @@ -0,0 +1,112 @@ +pc.script.createLoadingScreen(function (app) { + var showSplash = function () { + // splash wrapper + var wrapper = document.createElement('div'); + wrapper.id = 'application-splash-wrapper'; + document.body.appendChild(wrapper); + + // splash + var splash = document.createElement('div'); + splash.id = 'application-splash'; + wrapper.appendChild(splash); + splash.style.display = 'none'; + + var logo = document.createElement('img'); + logo.src = ASSET_PREFIX + 'logo.png'; + splash.appendChild(logo); + logo.onload = function () { + splash.style.display = 'block'; + }; + + var container = document.createElement('div'); + container.id = 'progress-bar-container'; + splash.appendChild(container); + + var bar = document.createElement('div'); + bar.id = 'progress-bar'; + container.appendChild(bar); + + }; + + var hideSplash = function () { + var splash = document.getElementById('application-splash-wrapper'); + splash.parentElement.removeChild(splash); + }; + + var setProgress = function (value) { + var bar = document.getElementById('progress-bar'); + if (bar) { + value = Math.min(1, Math.max(0, value)); + bar.style.width = value * 100 + '%'; + } + }; + + var createCss = function () { + var css = [ + 'body {', + ' background-color: #283538;', + '}', + + '#application-splash-wrapper {', + ' position: absolute;', + ' top: 0;', + ' left: 0;', + ' height: 100%;', + ' width: 100%;', + ' background-color: #283538;', + '}', + + '#application-splash {', + ' position: absolute;', + ' top: calc(50% - 28px);', + ' width: 264px;', + ' left: calc(50% - 132px);', + '}', + + '#application-splash img {', + ' width: 100%;', + '}', + + '#progress-bar-container {', + ' margin: 20px auto 0 auto;', + ' height: 2px;', + ' width: 100%;', + ' background-color: #1d292c;', + '}', + + '#progress-bar {', + ' width: 0%;', + ' height: 100%;', + ' background-color: #f60;', + '}', + '@media (max-width: 480px) {', + ' #application-splash {', + ' width: 170px;', + ' left: calc(50% - 85px);', + ' }', + '}' + + ].join('\n'); + + var style = document.createElement('style'); + style.type = 'text/css'; + if (style.styleSheet) { + style.styleSheet.cssText = css; + } else { + style.appendChild(document.createTextNode(css)); + } + + document.head.appendChild(style); + }; + + + createCss(); + + showSplash(); + + app.on('preload:end', function () { + app.off('preload:progress'); + }); + app.on('preload:progress', setProgress); + app.on('start', hideSplash); +}); diff --git a/OneTwoThree/__modules__.js b/Keno/Keno/__modules__.js similarity index 100% rename from OneTwoThree/__modules__.js rename to Keno/Keno/__modules__.js diff --git a/Keno/Keno/__settings__.js b/Keno/Keno/__settings__.js new file mode 100644 index 0000000..833810b --- /dev/null +++ b/Keno/Keno/__settings__.js @@ -0,0 +1,21 @@ +window.ASSET_PREFIX = ""; +window.SCRIPT_PREFIX = ""; +window.SCENE_PATH = "1894621.json"; +window.CONTEXT_OPTIONS = { + 'antialias': true, + 'alpha': false, + 'preserveDrawingBuffer': false, + 'preferWebGl2': true, + 'powerPreference': "high-performance" +}; +window.SCRIPTS = [ 156355258, 156355278, 156355291, 156355300, 156355302, 156355296, 156355301, 156355276, 156355255, 156355283, 156355263, 156355262, 156355292, 156355242, 156695810, 157755502, 157755549 ]; +window.CONFIG_FILENAME = "config.json"; +window.INPUT_SETTINGS = { + useKeyboard: true, + useMouse: true, + useGamepads: false, + useTouch: true +}; +pc.script.legacy = false; +window.PRELOAD_MODULES = [ +]; diff --git a/OneTwoThree/__start__.js b/Keno/Keno/__start__.js similarity index 100% rename from OneTwoThree/__start__.js rename to Keno/Keno/__start__.js diff --git a/Keno/Keno/files/assets/156355260/1/Jalnan.png b/Keno/Keno/files/assets/156355260/1/Jalnan.png new file mode 100644 index 0000000..685488a Binary files /dev/null and b/Keno/Keno/files/assets/156355260/1/Jalnan.png differ diff --git a/OneTwoThree/files/assets/154122876/1/SoundOn.png b/Keno/Keno/files/assets/156355265/1/SoundOn.png similarity index 100% rename from OneTwoThree/files/assets/154122876/1/SoundOn.png rename to Keno/Keno/files/assets/156355265/1/SoundOn.png diff --git a/OneTwoThree/files/assets/154122816/1/click3.mp3 b/Keno/Keno/files/assets/156355268/1/click3.mp3 similarity index 100% rename from OneTwoThree/files/assets/154122816/1/click3.mp3 rename to Keno/Keno/files/assets/156355268/1/click3.mp3 diff --git a/Keno/Keno/files/assets/156355270/1/UI_Card.png b/Keno/Keno/files/assets/156355270/1/UI_Card.png new file mode 100644 index 0000000..1f7be1f Binary files /dev/null and b/Keno/Keno/files/assets/156355270/1/UI_Card.png differ diff --git a/OneTwoThree/files/assets/154122851/1/circle.png b/Keno/Keno/files/assets/156355280/1/circle.png similarity index 100% rename from OneTwoThree/files/assets/154122851/1/circle.png rename to Keno/Keno/files/assets/156355280/1/circle.png diff --git a/OneTwoThree/files/assets/154122822/1/SoundOff.png b/Keno/Keno/files/assets/156355281/1/SoundOff.png similarity index 100% rename from OneTwoThree/files/assets/154122822/1/SoundOff.png rename to Keno/Keno/files/assets/156355281/1/SoundOff.png diff --git a/OneTwoThree/files/assets/154122872/1/rect.png b/Keno/Keno/files/assets/156355284/1/rect.png similarity index 100% rename from OneTwoThree/files/assets/154122872/1/rect.png rename to Keno/Keno/files/assets/156355284/1/rect.png diff --git a/OneTwoThree/files/assets/154122818/1/lose.mp3 b/Keno/Keno/files/assets/156355285/1/lose.mp3 similarity index 100% rename from OneTwoThree/files/assets/154122818/1/lose.mp3 rename to Keno/Keno/files/assets/156355285/1/lose.mp3 diff --git a/OneTwoThree/files/assets/154122852/1/open.mp3 b/Keno/Keno/files/assets/156355290/1/open.mp3 similarity index 100% rename from OneTwoThree/files/assets/154122852/1/open.mp3 rename to Keno/Keno/files/assets/156355290/1/open.mp3 diff --git a/OneTwoThree/files/assets/154122850/1/cardFront.png b/Keno/Keno/files/assets/156355295/1/cardFront.png similarity index 100% rename from OneTwoThree/files/assets/154122850/1/cardFront.png rename to Keno/Keno/files/assets/156355295/1/cardFront.png diff --git a/OneTwoThree/files/assets/154122830/1/win.mp3 b/Keno/Keno/files/assets/156355298/1/win.mp3 similarity index 100% rename from OneTwoThree/files/assets/154122830/1/win.mp3 rename to Keno/Keno/files/assets/156355298/1/win.mp3 diff --git a/Keno/Keno/files/assets/156505056/1/dia_2.png b/Keno/Keno/files/assets/156505056/1/dia_2.png new file mode 100644 index 0000000..5a5df27 Binary files /dev/null and b/Keno/Keno/files/assets/156505056/1/dia_2.png differ diff --git a/Keno/Keno/files/assets/156525288/1/Cancel.png b/Keno/Keno/files/assets/156525288/1/Cancel.png new file mode 100644 index 0000000..5c9d16d Binary files /dev/null and b/Keno/Keno/files/assets/156525288/1/Cancel.png differ diff --git a/OneTwoThree/files/assets/154122847/1/Clear_copy.png b/Keno/Keno/files/assets/156525289/1/Clear_copy.png similarity index 100% rename from OneTwoThree/files/assets/154122847/1/Clear_copy.png rename to Keno/Keno/files/assets/156525289/1/Clear_copy.png diff --git a/Keno/Keno/files/assets/156525291/1/Ok.png b/Keno/Keno/files/assets/156525291/1/Ok.png new file mode 100644 index 0000000..1c8e6a7 Binary files /dev/null and b/Keno/Keno/files/assets/156525291/1/Ok.png differ diff --git a/Keno/Keno/files/assets/156633138/1/Clear.png b/Keno/Keno/files/assets/156633138/1/Clear.png new file mode 100644 index 0000000..bad0c34 Binary files /dev/null and b/Keno/Keno/files/assets/156633138/1/Clear.png differ diff --git a/OneTwoThree/files/assets/154122889/1/Layer_5_copy_5.png b/Keno/Keno/files/assets/156633139/1/Layer_5_copy_5.png similarity index 100% rename from OneTwoThree/files/assets/154122889/1/Layer_5_copy_5.png rename to Keno/Keno/files/assets/156633139/1/Layer_5_copy_5.png diff --git a/OneTwoThree/files/assets/154122845/1/up_Money.png b/Keno/Keno/files/assets/156633140/1/up_Money.png similarity index 100% rename from OneTwoThree/files/assets/154122845/1/up_Money.png rename to Keno/Keno/files/assets/156633140/1/up_Money.png diff --git a/Keno/Keno/files/assets/156633189/1/superstar_memesbruh03 (1).png b/Keno/Keno/files/assets/156633189/1/superstar_memesbruh03 (1).png new file mode 100644 index 0000000..dffcb7d Binary files /dev/null and b/Keno/Keno/files/assets/156633189/1/superstar_memesbruh03 (1).png differ diff --git a/Keno/Keno/files/assets/156661776/1/edit.png b/Keno/Keno/files/assets/156661776/1/edit.png new file mode 100644 index 0000000..8f455aa Binary files /dev/null and b/Keno/Keno/files/assets/156661776/1/edit.png differ diff --git a/Keno/Keno/index.html b/Keno/Keno/index.html new file mode 100644 index 0000000..a00f485 --- /dev/null +++ b/Keno/Keno/index.html @@ -0,0 +1,17 @@ + + + + + + + + + Keno + + + + + + + + diff --git a/Keno/Keno/logo.png b/Keno/Keno/logo.png new file mode 100644 index 0000000..bb25c22 Binary files /dev/null and b/Keno/Keno/logo.png differ diff --git a/Keno/Keno/manifest.json b/Keno/Keno/manifest.json new file mode 100644 index 0000000..6dd4db8 --- /dev/null +++ b/Keno/Keno/manifest.json @@ -0,0 +1 @@ +{"short_name":"Keno","name":"Keno","start_url":"","display":"fullscreen","icons":[{"src":"thumbs/180.jpg","sizes":"180x180","type":"image/jpeg"},{"src":"thumbs/360.jpg","sizes":"360x360","type":"image/jpeg"},{"src":"thumbs/540.jpg","sizes":"540x540","type":"image/jpeg"},{"src":"thumbs/720.jpg","sizes":"720x720","type":"image/jpeg"}]} \ No newline at end of file diff --git a/Keno/Keno/playcanvas-stable.min.js b/Keno/Keno/playcanvas-stable.min.js new file mode 100644 index 0000000..5c3b2c8 --- /dev/null +++ b/Keno/Keno/playcanvas-stable.min.js @@ -0,0 +1,6 @@ +/** + * @license + * PlayCanvas Engine v1.67.3 revision 5c05b47f6 (RELEASE) + * Copyright 2011-2023 PlayCanvas Ltd. All rights reserved. + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).pc={})}(this,(function(t){"use strict";function e(t,e,i){t.prototype[e]||Object.defineProperty(t.prototype,e,{value:i,configurable:!0,enumerable:!1,writable:!0})}e(Array,"fill",(function(t){if(null==this)throw new TypeError("this is null or not defined");for(var e=Object(this),i=e.length>>>0,n=arguments[1]>>0,s=n<0?Math.max(i+n,0):Math.min(n,i),r=arguments[2],a=void 0===r?i:r>>0,o=a<0?Math.max(i+a,0):Math.min(a,i);s>>0;if("function"!=typeof t)throw TypeError("predicate must be a function");for(var n=arguments[1],s=0;s>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],s=0;s0)-(t<0)||+t}),void 0===Number.isFinite&&(Number.isFinite=function(t){return"number"==typeof t&&isFinite(t)}),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),n=1;nthis.length)&&(e=this.length),this.substring(e-t.length,e)===t})),e(String,"includes",(function(t,e){return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)})),e(String,"startsWith",(function(t,e){var i=e>0?0|e:0;return this.substring(i,i+t.length)===t})),e(String,"trimEnd",(function(){return this.replace(new RegExp(/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/.source+"$","g"),"")}));for(var i=0,n=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array];i=0;--r){var a=this.tryEntries[r],o=a.completion;if("root"===a.tryLoc)return s("end");if(a.tryLoc<=this.prev){var h=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(h&&l){if(this.prev=0;--i){var s=this.tryEntries[i];if(s.tryLoc<=this.prev&&n.call(s,"finallyLoc")&&this.prev=0;--e){var i=this.tryEntries[e];if(i.finallyLoc===t)return this.complete(i.completion,i.afterLoc),R(i),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var i=this.tryEntries[e];if(i.tryLoc===t){var n=i.completion;if("throw"===n.type){var s=n.arg;R(i)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(e,i,n){return this.delegate={iterator:L(e),resultName:i,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function _(t,e,i,n,s,r,a){try{var o=t[r](a),h=o.value}catch(t){return void i(t)}o.done?e(h):Promise.resolve(h).then(n,s)}function g(t){return function(){var e=this,i=arguments;return new Promise((function(n,s){var r=t.apply(e,i);function a(t){_(r,n,s,a,o,"next",t)}function o(t){_(r,n,s,a,o,"throw",t)}a(void 0)}))}}function v(t,e){for(var i=0;it.length)&&(e=t.length);for(var i=0,n=new Array(e);i=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function C(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var E=function(){function t(){}return t.set=function(t,e){},t.get=function(e){return t._traceChannels.has(e)},t}();E._traceChannels=new Set,E.stack=!1;var M=function(){function t(t,e,i,n,s){void 0===s&&(s=!1),this.handler=void 0,this.name=void 0,this.callback=void 0,this.scope=void 0,this._once=void 0,this._removed=!1,this.handler=t,this.name=e,this.callback=i,this.scope=n,this._once=s}var e=t.prototype;return e.off=function(){this._removed||this.handler.off(this.name,this.callback,this.scope)},e.on=function(t,e,i){return void 0===i&&(i=this),this.handler._addCallback(t,e,i,!1)},e.once=function(t,e,i){return void 0===i&&(i=this),this.handler._addCallback(t,e,i,!0)},y(t,[{key:"removed",get:function(){return this._removed},set:function(t){t&&(this._removed=!0)}}]),t}(),P=function(){function t(){this._callbacks=new Map,this._callbackActive=new Map}var e=t.prototype;return e.initEventHandler=function(){this._callbacks=new Map,this._callbackActive=new Map},e._addCallback=function(t,e,i,n){if(this._callbacks.has(t)||this._callbacks.set(t,[]),this._callbackActive.has(t)){var s=this._callbackActive.get(t);s&&s===this._callbacks.get(t)&&this._callbackActive.set(t,s.slice())}var r=new M(this,t,e,i,n);return this._callbacks.get(t).push(r),r},e.on=function(t,e,i){return void 0===i&&(i=this),this._addCallback(t,e,i,!1)},e.once=function(t,e,i){return void 0===i&&(i=this),this._addCallback(t,e,i,!0)},e.off=function(t,e,i){if(t)this._callbackActive.has(t)&&this._callbackActive.get(t)===this._callbacks.get(t)&&this._callbackActive.set(t,this._callbackActive.get(t).slice());else for(var n,s=A(this._callbackActive);!(n=s()).done;){var r=n.value,a=r[0],o=r[1];this._callbacks.has(a)&&(this._callbacks.get(a)===o&&this._callbackActive.set(a,o.slice()))}if(t)if(e){var h=this._callbacks.get(t);if(!h)return this;for(var l=0;l0?r=r.slice(0,r.length-2):(a>0&&r.push(L.delimiter),r.push(n[a])));return s=r.join(""),e||s[0]!==L.delimiter||(s=s.slice(1)),i&&s[s.length-1]!==L.delimiter&&(s+=L.delimiter),s},split:function(t){var e=t.lastIndexOf(L.delimiter);return-1!==e?[t.substring(0,e),t.substring(e+1)]:["",t]},getBasename:function(t){return L.split(t)[1]},getDirectory:function(t){return L.split(t)[0]},getExtension:function(t){var e=t.split("?")[0].split(".").pop();return e!==t?"."+e:""},isRelativePath:function(t){return"/"!==t.charAt(0)&&null===t.match(/:\/\//)},extractPath:function(t){var e="",i=t.split("/"),n=0;if(i.length>1)if(L.isRelativePath(t))if("."===i[0])for(n=0;n0),N=!("browser"!==O||!navigator.getGamepads&&!navigator.webkitGetGamepads),z="undefined"!=typeof Worker,V=function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){return t=!0,!1}});window.addEventListener("testpassive",null,e),window.removeEventListener("testpassive",null,e)}catch(t){}return t}(),G={name:k,environment:O,global:"browser"===O?window:global,browser:"browser"===O,desktop:["windows","osx","linux","cros"].includes(k),mobile:["android","ios"].includes(k),ios:"ios"===k,android:"android"===k,xbox:B,gamepads:N,touch:U,workers:z,passiveEvents:V,browserName:F},H="abcdefghijklmnopqrstuvwxyz",W="ABCDEFGHIJKLMNOPQRSTUVWXYZ",X=55296,q=56319,j=56320,Y=57343,K=127462,Z=127487,Q=65024,$=65039;function J(t,e){void 0===e&&(e=0);var i=t.length;if(e<0||e>=i)return null;var n=t.charCodeAt(e);if(i>1&&n>=X&&n<=q){var s=t.charCodeAt(e+1);if(s>=j&&s<=Y)return{code:1024*(n-X)+s-j+65536,long:!0}}return{code:n,long:!1}}function tt(t,e,i){if(!t)return!1;var n=J(t);if(n){var s=n.code;return s>=e&&s<=i}return!1}function et(t,e){if(e===t.length-1)return 1;if(tt(t[e],X,q)){var i=t.substring(e,e+2),n=t.substring(e+2,e+4);return tt(n,127995,127999)||tt(i,K,Z)&&tt(n,K,Z)?4:tt(n,Q,$)?3:2}return tt(t[e+1],Q,$)?2:1}var it,nt,st,rt={ASCII_LOWERCASE:H,ASCII_UPPERCASE:W,ASCII_LETTERS:H+W,format:function(t){for(var e=0;e<(arguments.length<=1?0:arguments.length-1);e++)t=t.replace("{"+e+"}",e+1<1||arguments.length<=e+1?void 0:arguments[e+1]);return t},getCodePoint:function(t,e){var i=J(t,e);return i&&i.code},getCodePoints:function(t){if("string"!=typeof t)throw new TypeError("Not a string");for(var e,i=0,n=[];e=J(t,i);)n.push(e.code),i+=e.long?2:1;return n},getSymbols:function(t){if("string"!=typeof t)throw new TypeError("Not a string");for(var e,i=0,n=t.length,s=[],r=0;i65535?[55296+(e>>10),e%1024+56320]:[t],n.push(String.fromCharCode.apply(null,i));return n.join("")}},at=function(){function t(){this._list=[],this._index={}}var e=t.prototype;return e.push=function(t,e){if(this._index[t])throw Error("Key already in index "+t);var i=this._list.push(e)-1;this._index[t]=i},e.has=function(t){return void 0!==this._index[t]},e.get=function(t){var e=this._index[t];return void 0!==e?this._list[e]:null},e.remove=function(t){var e=this._index[t];if(void 0!==e){for(t in this._list.splice(e,1),delete this._index[t],this._index){var i=this._index[t];i>e&&(this._index[t]=i-1)}return!0}return!1},e.list=function(){return this._list},e.clear=function(){for(var t in this._list.length=0,this._index)delete this._index[t]},t}(),ot=function(){function t(){}return t.loadScript=function(t,e){var i=document.createElement("script");i.setAttribute("src",t),i.onload=function(){e(null)},i.onerror=function(){e("Failed to load script='"+t+"'")},document.body.appendChild(i)},t.loadWasm=function(e,i,n){var s=t.wasmSupported()&&i.glueUrl&&i.wasmUrl?i.glueUrl:i.fallbackUrl;s?t.loadScript(s,(function(t){if(t)n(t,null);else{var s=window[e];window[e]=void 0,s({locateFile:function(){return i.wasmUrl},onAbort:function(){n("wasm module aborted.")}}).then((function(t){n(null,t)}))}})):n("No supported wasm modules found.",null)},t.getModule=function(e){return t.modules.hasOwnProperty(e)||(t.modules[e]={config:null,initializing:!1,instance:null,callbacks:[]}),t.modules[e]},t.initialize=function(e,i){if(!i.initializing){var n=i.config;(n.glueUrl||n.wasmUrl||n.fallbackUrl)&&(i.initializing=!0,t.loadWasm(e,n,(function(t,s){t?n.errorHandler?n.errorHandler(t):console.error("failed to initialize module="+e+" error="+t):(i.instance=s,i.callbacks.forEach((function(t){t(s)})))})))}},t}();ot.modules={},ot.wasmSupported=(it=function(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){var t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1},st=nt={},function(){return st===nt&&(st=it()),st});var ht=function(){function t(){}return t.setConfig=function(t,e){var i=ot.getModule(t);i.config=e,i.callbacks.length>0&&ot.initialize(t,i)},t.getConfig=function(t){var e;return null==(e=ot.modules)||null==(e=e[t])?void 0:e.config},t.getInstance=function(t,e){var i=ot.getModule(t);i.instance?e(i.instance):(i.callbacks.push(e),i.config&&ot.initialize(t,i))},t}(),lt=function(){function t(t){this.arraybuffer=t,this.dataView=new DataView(t),this.offset=0,this.stack=[]}var e=t.prototype;return e.reset=function(t){void 0===t&&(t=0),this.offset=t},e.skip=function(t){this.offset+=t},e.align=function(t){this.offset=this.offset+t-1&~(t-1)},e._inc=function(t){return this.offset+=t,this.offset-t},e.readChar=function(){return String.fromCharCode(this.dataView.getUint8(this.offset++))},e.readChars=function(t){for(var e="",i=0;i=t.byteLength);){var i=String.fromCharCode(this.readU8());if("\n"===i)break;e+=i}return e},y(t,[{key:"remainingBytes",get:function(){return this.dataView.byteLength-this.offset}}]),t}(),ct=function(){function t(t){this.items=[],this.length=0,this.loopIndex=-1,this._sortBy=void 0,this._sortHandler=void 0,this._sortBy=t.sortBy,this._sortHandler=this._doSort.bind(this)}var e=t.prototype;return e._binarySearch=function(t){for(var e,i,n=0,s=this.items.length-1,r=t[this._sortBy];n<=s;)e=Math.floor((n+s)/2),(i=this.items[e][this._sortBy])<=r?n=e+1:i>r&&(s=e-1);return n},e._doSort=function(t,e){var i=this._sortBy;return t[i]-e[i]},e.insert=function(t){var e=this._binarySearch(t);this.items.splice(e,0,t),this.length++,this.loopIndex>=e&&this.loopIndex++},e.append=function(t){this.items.push(t),this.length++},e.remove=function(t){var e=this.items.indexOf(t);e<0||(this.items.splice(e,1),this.length--,this.loopIndex>=e&&this.loopIndex--)},e.sort=function(){var t=this.loopIndex>=0?this.items[this.loopIndex]:null;this.items.sort(this._sortHandler),null!==t&&(this.loopIndex=this.items.indexOf(t))},t}(),ut=function(t){function e(e){var i;return(i=t.call(this)||this)._index={},i._list=[],i._parent=e,i}S(e,t);var i=e.prototype;return i.add=function(){var t=!1,e=this._processArguments(arguments,!0);if(!e.length)return t;for(var i=0;i=i?i:t<=e?e:t},intToBytes24:function(t){return[t>>16&255,t>>8&255,255&t]},intToBytes32:function(t){return[t>>24&255,t>>16&255,t>>8&255,255&t]},bytesToInt24:function(t,e,i){return t.length&&(i=t[2],e=t[1],t=t[0]),t<<16|e<<8|i},bytesToInt32:function(t,e,i,n){return t.length&&(n=t[3],i=t[2],e=t[1],t=t[0]),(t<<24|e<<16|i<<8|n)>>>0},lerp:function(t,e,i){return t+(e-t)*_t.clamp(i,0,1)},lerpAngle:function(t,e,i){return e-t>180&&(e-=360),e-t<-180&&(e+=360),_t.lerp(t,e,_t.clamp(i,0,1))},powerOfTwo:function(t){return 0!==t&&!(t&t-1)},nextPowerOfTwo:function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,++t},nearestPowerOfTwo:function(t){return Math.pow(2,Math.round(Math.log(t)/Math.log(2)))},random:function(t,e){var i=e-t;return Math.random()*i+t},smoothstep:function(t,e,i){return i<=t?0:i>=e?1:(i=(i-t)/(e-t))*i*(3-2*i)},smootherstep:function(t,e,i){return i<=t?0:i>=e?1:(i=(i-t)/(e-t))*i*i*(i*(6*i-15)+10)},roundUp:function(t,e){return 0===e?t:Math.ceil(t/e)*e},between:function(t,e,i,n){var s=Math.min(e,i),r=Math.max(e,i);return n?t>=s&&t<=r:t>s&&t7?e=_t.intToBytes32(i):(e=_t.intToBytes24(i))[3]=255,this.set(e[0]/255,e[1]/255,e[2]/255,e[3]/255),this},e.toString=function(t){var e="#"+((1<<24)+(Math.round(255*this.r)<<16)+(Math.round(255*this.g)<<8)+Math.round(255*this.b)).toString(16).slice(1);if(!0===t){var i=Math.round(255*this.a).toString(16);this.a<16/255?e+="0"+i:e+=i}return e},t}();ft=gt,gt.BLACK=Object.freeze(new ft(0,0,0,1)),gt.BLUE=Object.freeze(new ft(0,0,1,1)),gt.CYAN=Object.freeze(new ft(0,1,1,1)),gt.GRAY=Object.freeze(new ft(.5,.5,.5,1)),gt.GREEN=Object.freeze(new ft(0,1,0,1)),gt.MAGENTA=Object.freeze(new ft(1,0,1,1)),gt.RED=Object.freeze(new ft(1,0,0,1)),gt.WHITE=Object.freeze(new ft(1,1,1,1)),gt.YELLOW=Object.freeze(new ft(1,1,0,1));var vt,yt,xt=function(){function t(t,e){void 0===e&&(e=0),this._curve=void 0,this._left=-1/0,this._right=1/0,this._recip=0,this._p0=0,this._p1=0,this._m0=0,this._m1=0,this._curve=t,this._reset(e)}var e=t.prototype;return e.evaluate=function(t,e){var i;void 0===e&&(e=!1),(e||t=this._right)&&this._reset(t);var n=this._curve.type;if(5===n)i=this._p0;else{var s=0===this._recip?0:(t-this._left)*this._recip;i=0===n?_t.lerp(this._p0,this._p1,s):1===n?_t.lerp(this._p0,this._p1,s*s*(3-2*s)):this._evaluateHermite(this._p0,this._p1,this._m0,this._m1,s)}return i},e._reset=function(t){var e=this._curve.keys,i=e.length;if(i)if(t=e[i-1][0])this._left=e[i-1][0],this._right=1/0,this._recip=0,this._p0=this._p1=e[i-1][1],this._m0=this._m1=0;else{for(var n=0;t>=e[n+1][0];)n++;this._left=e[n][0],this._right=e[n+1][0];var s=1/(this._right-this._left);this._recip=isFinite(s)?s:0,this._p0=e[n][1],this._p1=e[n+1][1],this._isHermite()&&this._calcTangents(e,n)}else this._left=-1/0,this._right=1/0,this._recip=0,this._p0=this._p1=this._m0=this._m1=0},e._isHermite=function(){return 2===this._curve.type||3===this._curve.type||4===this._curve.type},e._calcTangents=function(t,e){var i,n,s=t[e],r=t[e+1];if(i=0===e?[t[0][0]+(t[0][0]-t[1][0]),t[0][1]+(t[0][1]-t[1][1])]:t[e-1],n=e===t.length-2?[t[e+1][0]+(t[e+1][0]-t[e][0]),t[e+1][1]+(t[e+1][1]-t[e][1])]:t[e+2],4===this._curve.type){var a=2*(r[0]-s[0])/(r[0]-i[0]),o=2*(r[0]-s[0])/(n[0]-s[0]);this._m0=this._curve.tension*(isFinite(a)?a:0)*(r[1]-i[1]),this._m1=this._curve.tension*(isFinite(o)?o:0)*(n[1]-s[1])}else{var h=(r[0]-s[0])/(s[0]-i[0]),l=(r[0]-s[0])/(n[0]-r[0]),c=s[1]+(i[1]-s[1])*(isFinite(h)?h:0),u=r[1]+(n[1]-r[1])*(isFinite(l)?l:0),d=2===this._curve.type?.5:this._curve.tension;this._m0=d*(r[1]-c),this._m1=d*(u-s[1])}},e._evaluateHermite=function(t,e,i,n,s){var r=s*s,a=s+s,o=1-s,h=o*o;return t*((1+a)*h)+i*(s*h)+e*(r*(3-a))+n*(r*(s-1))},t}(),St=function(){function t(t){if(this.keys=[],this.type=1,this.tension=.5,this._eval=new xt(this),t)for(var e=0;et);s++);var r=[t,e];return this.keys.splice(s,0,r),r},e.get=function(t){return this.keys[t]},e.sort=function(){this.keys.sort((function(t,e){return t[0]-e[0]}))},e.value=function(t){return this._eval.evaluate(t,!0)},e.closest=function(t){for(var e=this.keys,i=e.length,n=2,s=null,r=0;r=a))break;n=a,s=e[r]}return s},e.clone=function(){var t=new this.constructor;return t.keys=p(t.keys,this.keys),t.type=this.type,t.tension=this.tension,t},e.quantize=function(t){t=Math.max(t,2);var e=new Float32Array(t),i=1/(t-1);e[0]=this._eval.evaluate(0,!0);for(var n=1;n1)for(var t=0;t>16&32768,n=e>>12&2047,s=e>>23&255;return s<103?i:s>142?(i|=31744,i|=(255===s?0:1)&&8388607&e):s<113?i|=((n|=2048)>>114-s)+(n>>113-s&1):(i|=s-112<<10|n>>1,i+=1&n)},t.float2Bytes=function(t,e,i,n){var s=255*t%1;if(e[i+0]=Math.round(255*(t%1-wt*s)),n>1){var r=65025*t%1;if(e[i+1]=Math.round(255*(s-wt*r)),n>2){var a=16581375*t%1;e[i+2]=Math.round(255*(r-wt*a)),n>3&&(e[i+3]=Math.round(255*a))}}},t.float2BytesRange=function(e,i,n,s,r,a){e=_t.clamp((e-s)/(r-s),0,1),t.float2Bytes(e,i,n,a)},t.float2MantissaExponent=function(e,i,n,s){var r=Math.floor(Math.log2(Math.abs(e)))+1;e/=Math.pow(2,r),t.float2BytesRange(e,i,n,-1,1,s-1),i[n+s-1]=Math.round(r+127)},t}(),Et=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=void 0,this.y=void 0,this.z=void 0,3===t.length?(this.x=t[0],this.y=t[1],this.z=t[2]):(this.x=t,this.y=e,this.z=i)}var e=t.prototype;return e.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},e.add2=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},e.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},e.addScaled=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},e.clone=function(){return new(0,this.constructor)(this.x,this.y,this.z)},e.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},e.cross=function(t,e){var i=t.x,n=t.y,s=t.z,r=e.x,a=e.y,o=e.z;return this.x=n*o-a*s,this.y=s*r-o*i,this.z=i*a-r*n,this},e.distance=function(t){var e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return Math.sqrt(e*e+i*i+n*n)},e.div=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},e.div2=function(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this.z=t.z/e.z,this},e.divScalar=function(t){return this.x/=t,this.y/=t,this.z/=t,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},e.equals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},e.equalsApprox=function(t,e){return void 0===e&&(e=1e-6),Math.abs(this.x-t.x)0){var i=1/Math.sqrt(e);this.x=t.x*i,this.y=t.y*i,this.z=t.z*i}return this},e.floor=function(t){return void 0===t&&(t=this),this.x=Math.floor(t.x),this.y=Math.floor(t.y),this.z=Math.floor(t.z),this},e.ceil=function(t){return void 0===t&&(t=this),this.x=Math.ceil(t.x),this.y=Math.ceil(t.y),this.z=Math.ceil(t.z),this},e.round=function(t){return void 0===t&&(t=this),this.x=Math.round(t.x),this.y=Math.round(t.y),this.z=Math.round(t.z),this},e.min=function(t){return t.xthis.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),this},e.project=function(t){var e=(this.x*t.x+this.y*t.y+this.z*t.z)/(t.x*t.x+t.y*t.y+t.z*t.z);return this.x=t.x*e,this.y=t.y*e,this.z=t.z*e,this},e.set=function(t,e,i){return this.x=t,this.y=e,this.z=i,this},e.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},e.sub2=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},e.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},e.toString=function(){return"["+this.x+", "+this.y+", "+this.z+"]"},t}();vt=Et,Et.ZERO=Object.freeze(new vt(0,0,0)),Et.ONE=Object.freeze(new vt(1,1,1)),Et.UP=Object.freeze(new vt(0,1,0)),Et.DOWN=Object.freeze(new vt(0,-1,0)),Et.RIGHT=Object.freeze(new vt(1,0,0)),Et.LEFT=Object.freeze(new vt(-1,0,0)),Et.FORWARD=Object.freeze(new vt(0,0,-1)),Et.BACK=Object.freeze(new vt(0,0,1));var Mt,Pt=function(){function t(){this.data=new Float32Array(9),this.data[0]=this.data[4]=this.data[8]=1}var e=t.prototype;return e.clone=function(){return(new(0,this.constructor)).copy(this)},e.copy=function(t){var e=t.data,i=this.data;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],this},e.set=function(t){var e=this.data;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],this},e.equals=function(t){var e=this.data,i=t.data;return e[0]===i[0]&&e[1]===i[1]&&e[2]===i[2]&&e[3]===i[3]&&e[4]===i[4]&&e[5]===i[5]&&e[6]===i[6]&&e[7]===i[7]&&e[8]===i[8]},e.isIdentity=function(){var t=this.data;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&1===t[4]&&0===t[5]&&0===t[6]&&0===t[7]&&1===t[8]},e.setIdentity=function(){var t=this.data;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},e.toString=function(){return"["+this.data.join(", ")+"]"},e.transpose=function(t){void 0===t&&(t=this);var e,i=t.data,n=this.data;i===n?(e=i[1],n[1]=i[3],n[3]=e,e=i[2],n[2]=i[6],n[6]=e,e=i[5],n[5]=i[7],n[7]=e):(n[0]=i[0],n[1]=i[3],n[2]=i[6],n[3]=i[1],n[4]=i[4],n[5]=i[7],n[6]=i[2],n[7]=i[5],n[8]=i[8]);return this},e.setFromMat4=function(t){var e=t.data,i=this.data;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},e.invertMat4=function(t){var e=t.data,i=e[0],n=e[1],s=e[2],r=e[4],a=e[5],o=e[6],h=e[8],l=e[9],c=e[10],u=c*a-o*l,d=-c*n+s*l,f=o*n-s*a,p=-c*r+o*h,m=c*i-s*h,_=-o*i+s*r,g=l*r-a*h,v=-l*i+n*h,y=a*i-n*r,x=i*u+n*p+s*g;if(0===x)this.setIdentity();else{var S=1/x,b=this.data;b[0]=u*S,b[1]=d*S,b[2]=f*S,b[3]=p*S,b[4]=m*S,b[5]=_*S,b[6]=g*S,b[7]=v*S,b[8]=y*S}return this},e.transformVector=function(t,e){void 0===e&&(e=new Et);var i=this.data,n=t.x,s=t.y,r=t.z;return e.x=n*i[0]+s*i[3]+r*i[6],e.y=n*i[1]+s*i[4]+r*i[7],e.z=n*i[2]+s*i[5]+r*i[8],e},t}();yt=Pt,Pt.IDENTITY=Object.freeze(new yt),Pt.ZERO=Object.freeze((new yt).set([0,0,0,0,0,0,0,0,0]));var Rt,It=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=void 0,this.y=void 0,2===t.length?(this.x=t[0],this.y=t[1]):(this.x=t,this.y=e)}var e=t.prototype;return e.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.add2=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},e.addScalar=function(t){return this.x+=t,this.y+=t,this},e.addScaled=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},e.clone=function(){return new(0,this.constructor)(this.x,this.y)},e.copy=function(t){return this.x=t.x,this.y=t.y,this},e.cross=function(t){return this.x*t.y-this.y*t.x},e.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},e.div=function(t){return this.x/=t.x,this.y/=t.y,this},e.div2=function(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this},e.divScalar=function(t){return this.x/=t,this.y/=t,this},e.dot=function(t){return this.x*t.x+this.y*t.y},e.equals=function(t){return this.x===t.x&&this.y===t.y},e.equalsApprox=function(t,e){return void 0===e&&(e=1e-6),Math.abs(this.x-t.x)0){var i=1/Math.sqrt(e);this.x=t.x*i,this.y=t.y*i}return this},e.rotate=function(t){var e=Math.atan2(this.x,this.y)+t*_t.DEG_TO_RAD,i=Math.sqrt(this.x*this.x+this.y*this.y);return this.x=Math.sin(e)*i,this.y=Math.cos(e)*i,this},e.angle=function(){return Math.atan2(this.x,this.y)*_t.RAD_TO_DEG},e.angleTo=function(t){return Math.atan2(this.x*t.y+this.y*t.x,this.x*t.x+this.y*t.y)*_t.RAD_TO_DEG},e.floor=function(t){return void 0===t&&(t=this),this.x=Math.floor(t.x),this.y=Math.floor(t.y),this},e.ceil=function(t){return void 0===t&&(t=this),this.x=Math.ceil(t.x),this.y=Math.ceil(t.y),this},e.round=function(t){return void 0===t&&(t=this),this.x=Math.round(t.x),this.y=Math.round(t.y),this},e.min=function(t){return t.xthis.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),this},e.set=function(t,e){return this.x=t,this.y=e,this},e.sub=function(t){return this.x-=t.x,this.y-=t.y,this},e.sub2=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},e.subScalar=function(t){return this.x-=t,this.y-=t,this},e.toString=function(){return"["+this.x+", "+this.y+"]"},t.angleRad=function(t,e){return Math.atan2(t.x*e.y-t.y*e.x,t.x*e.x+t.y*e.y)},t}();Mt=It,It.ZERO=Object.freeze(new Mt(0,0)),It.ONE=Object.freeze(new Mt(1,1)),It.UP=Object.freeze(new Mt(0,1)),It.DOWN=Object.freeze(new Mt(0,-1)),It.RIGHT=Object.freeze(new Mt(1,0)),It.LEFT=Object.freeze(new Mt(-1,0));var Lt,Dt=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=void 0,this.y=void 0,this.z=void 0,this.w=void 0,4===t.length?(this.x=t[0],this.y=t[1],this.z=t[2],this.w=t[3]):(this.x=t,this.y=e,this.z=i,this.w=n)}var e=t.prototype;return e.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},e.add2=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},e.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},e.addScaled=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},e.clone=function(){return new(0,this.constructor)(this.x,this.y,this.z,this.w)},e.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},e.div=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this},e.div2=function(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this.z=t.z/e.z,this.w=t.w/e.w,this},e.divScalar=function(t){return this.x/=t,this.y/=t,this.z/=t,this.w/=t,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},e.equals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},e.equalsApprox=function(t,e){return void 0===e&&(e=1e-6),Math.abs(this.x-t.x)0){var i=1/Math.sqrt(e);this.x=t.x*i,this.y=t.y*i,this.z=t.z*i,this.w=t.w*i}return this},e.floor=function(t){return void 0===t&&(t=this),this.x=Math.floor(t.x),this.y=Math.floor(t.y),this.z=Math.floor(t.z),this.w=Math.floor(t.w),this},e.ceil=function(t){return void 0===t&&(t=this),this.x=Math.ceil(t.x),this.y=Math.ceil(t.y),this.z=Math.ceil(t.z),this.w=Math.ceil(t.w),this},e.round=function(t){return void 0===t&&(t=this),this.x=Math.round(t.x),this.y=Math.round(t.y),this.z=Math.round(t.z),this.w=Math.round(t.w),this},e.min=function(t){return t.xthis.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),t.w>this.w&&(this.w=t.w),this},e.set=function(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this},e.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},e.sub2=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},e.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},e.toString=function(){return"["+this.x+", "+this.y+", "+this.z+", "+this.w+"]"},t}();Rt=Dt,Dt.ZERO=Object.freeze(new Rt(0,0,0,0)),Dt.ONE=Object.freeze(new Rt(1,1,1,1));var Ot,kt=new It,Ft=new Et,Bt=new Et,Ut=new Et,Nt=new Et,zt=function(){function t(){this.data=new Float32Array(16),this.data[0]=this.data[5]=this.data[10]=this.data[15]=1}t._getPerspectiveHalfSize=function(t,e,i,n,s){s?(t.x=n*Math.tan(e*Math.PI/360),t.y=t.x/i):(t.y=n*Math.tan(e*Math.PI/360),t.x=t.y*i)};var e=t.prototype;return e.add2=function(t,e){var i=t.data,n=e.data,s=this.data;return s[0]=i[0]+n[0],s[1]=i[1]+n[1],s[2]=i[2]+n[2],s[3]=i[3]+n[3],s[4]=i[4]+n[4],s[5]=i[5]+n[5],s[6]=i[6]+n[6],s[7]=i[7]+n[7],s[8]=i[8]+n[8],s[9]=i[9]+n[9],s[10]=i[10]+n[10],s[11]=i[11]+n[11],s[12]=i[12]+n[12],s[13]=i[13]+n[13],s[14]=i[14]+n[14],s[15]=i[15]+n[15],this},e.add=function(t){return this.add2(this,t)},e.clone=function(){return(new(0,this.constructor)).copy(this)},e.copy=function(t){var e=t.data,i=this.data;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],this},e.equals=function(t){var e=this.data,i=t.data;return e[0]===i[0]&&e[1]===i[1]&&e[2]===i[2]&&e[3]===i[3]&&e[4]===i[4]&&e[5]===i[5]&&e[6]===i[6]&&e[7]===i[7]&&e[8]===i[8]&&e[9]===i[9]&&e[10]===i[10]&&e[11]===i[11]&&e[12]===i[12]&&e[13]===i[13]&&e[14]===i[14]&&e[15]===i[15]},e.isIdentity=function(){var t=this.data;return 1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&0===t[4]&&1===t[5]&&0===t[6]&&0===t[7]&&0===t[8]&&0===t[9]&&1===t[10]&&0===t[11]&&0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]},e.mul2=function(t,e){var i,n,s,r,a=t.data,o=e.data,h=this.data,l=a[0],c=a[1],u=a[2],d=a[3],f=a[4],p=a[5],m=a[6],_=a[7],g=a[8],v=a[9],y=a[10],x=a[11],S=a[12],b=a[13],w=a[14],T=a[15];return i=o[0],n=o[1],s=o[2],r=o[3],h[0]=l*i+f*n+g*s+S*r,h[1]=c*i+p*n+v*s+b*r,h[2]=u*i+m*n+y*s+w*r,h[3]=d*i+_*n+x*s+T*r,i=o[4],n=o[5],s=o[6],r=o[7],h[4]=l*i+f*n+g*s+S*r,h[5]=c*i+p*n+v*s+b*r,h[6]=u*i+m*n+y*s+w*r,h[7]=d*i+_*n+x*s+T*r,i=o[8],n=o[9],s=o[10],r=o[11],h[8]=l*i+f*n+g*s+S*r,h[9]=c*i+p*n+v*s+b*r,h[10]=u*i+m*n+y*s+w*r,h[11]=d*i+_*n+x*s+T*r,i=o[12],n=o[13],s=o[14],r=o[15],h[12]=l*i+f*n+g*s+S*r,h[13]=c*i+p*n+v*s+b*r,h[14]=u*i+m*n+y*s+w*r,h[15]=d*i+_*n+x*s+T*r,this},e.mulAffine2=function(t,e){var i,n,s,r=t.data,a=e.data,o=this.data,h=r[0],l=r[1],c=r[2],u=r[4],d=r[5],f=r[6],p=r[8],m=r[9],_=r[10],g=r[12],v=r[13],y=r[14];return i=a[0],n=a[1],s=a[2],o[0]=h*i+u*n+p*s,o[1]=l*i+d*n+m*s,o[2]=c*i+f*n+_*s,o[3]=0,i=a[4],n=a[5],s=a[6],o[4]=h*i+u*n+p*s,o[5]=l*i+d*n+m*s,o[6]=c*i+f*n+_*s,o[7]=0,i=a[8],n=a[9],s=a[10],o[8]=h*i+u*n+p*s,o[9]=l*i+d*n+m*s,o[10]=c*i+f*n+_*s,o[11]=0,i=a[12],n=a[13],s=a[14],o[12]=h*i+u*n+p*s+g,o[13]=l*i+d*n+m*s+v,o[14]=c*i+f*n+_*s+y,o[15]=1,this},e.mul=function(t){return this.mul2(this,t)},e.transformPoint=function(t,e){void 0===e&&(e=new Et);var i=this.data,n=t.x,s=t.y,r=t.z;return e.x=n*i[0]+s*i[4]+r*i[8]+i[12],e.y=n*i[1]+s*i[5]+r*i[9]+i[13],e.z=n*i[2]+s*i[6]+r*i[10]+i[14],e},e.transformVector=function(t,e){void 0===e&&(e=new Et);var i=this.data,n=t.x,s=t.y,r=t.z;return e.x=n*i[0]+s*i[4]+r*i[8],e.y=n*i[1]+s*i[5]+r*i[9],e.z=n*i[2]+s*i[6]+r*i[10],e},e.transformVec4=function(t,e){void 0===e&&(e=new Dt);var i=this.data,n=t.x,s=t.y,r=t.z,a=t.w;return e.x=n*i[0]+s*i[4]+r*i[8]+a*i[12],e.y=n*i[1]+s*i[5]+r*i[9]+a*i[13],e.z=n*i[2]+s*i[6]+r*i[10]+a*i[14],e.w=n*i[3]+s*i[7]+r*i[11]+a*i[15],e},e.setLookAt=function(t,e,i){Ut.sub2(t,e).normalize(),Bt.copy(i).normalize(),Ft.cross(Bt,Ut).normalize(),Bt.cross(Ut,Ft);var n=this.data;return n[0]=Ft.x,n[1]=Ft.y,n[2]=Ft.z,n[3]=0,n[4]=Bt.x,n[5]=Bt.y,n[6]=Bt.z,n[7]=0,n[8]=Ut.x,n[9]=Ut.y,n[10]=Ut.z,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this},e.setFrustum=function(t,e,i,n,s,r){var a=2*s,o=e-t,h=n-i,l=r-s,c=this.data;return c[0]=a/o,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=a/h,c[6]=0,c[7]=0,c[8]=(e+t)/o,c[9]=(n+i)/h,c[10]=(-r-s)/l,c[11]=-1,c[12]=0,c[13]=0,c[14]=-a*r/l,c[15]=0,this},e.setPerspective=function(e,i,n,s,r){return t._getPerspectiveHalfSize(kt,e,i,n,r),this.setFrustum(-kt.x,kt.x,-kt.y,kt.y,n,s)},e.setOrtho=function(t,e,i,n,s,r){var a=this.data;return a[0]=2/(e-t),a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=2/(n-i),a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=-2/(r-s),a[11]=0,a[12]=-(e+t)/(e-t),a[13]=-(n+i)/(n-i),a[14]=-(r+s)/(r-s),a[15]=1,this},e.setFromAxisAngle=function(t,e){e*=_t.DEG_TO_RAD;var i=t.x,n=t.y,s=t.z,r=Math.cos(e),a=Math.sin(e),o=1-r,h=o*i,l=o*n,c=this.data;return c[0]=h*i+r,c[1]=h*n+a*s,c[2]=h*s-a*n,c[3]=0,c[4]=h*n-a*s,c[5]=l*n+r,c[6]=l*s+a*i,c[7]=0,c[8]=h*s+a*n,c[9]=l*s-i*a,c[10]=o*s*s+r,c[11]=0,c[12]=0,c[13]=0,c[14]=0,c[15]=1,this},e.setTranslate=function(t,e,i){var n=this.data;return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=t,n[13]=e,n[14]=i,n[15]=1,this},e.setScale=function(t,e,i){var n=this.data;return n[0]=t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this},e.setViewport=function(t,e,i,n){var s=this.data;return s[0]=.5*i,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=.5*n,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=.5,s[11]=0,s[12]=t+.5*i,s[13]=e+.5*n,s[14]=.5,s[15]=1,this},e.setReflection=function(t,e){var i=t.x,n=t.y,s=t.z,r=this.data;return r[0]=1-2*i*i,r[1]=-2*i*n,r[2]=-2*i*s,r[3]=0,r[4]=-2*i*n,r[5]=1-2*n*n,r[6]=-2*n*s,r[7]=0,r[8]=-2*i*s,r[9]=-2*n*s,r[10]=1-2*s*s,r[11]=0,r[12]=-2*i*e,r[13]=-2*n*e,r[14]=-2*s*e,r[15]=1,this},e.invert=function(t){void 0===t&&(t=this);var e=t.data,i=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],h=e[6],l=e[7],c=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],_=e[14],g=e[15],v=i*o-n*a,y=i*h-s*a,x=i*l-r*a,S=n*h-s*o,b=n*l-r*o,w=s*l-r*h,T=c*m-u*p,A=c*_-d*p,C=c*g-f*p,E=u*_-d*m,M=u*g-f*m,P=d*g-f*_,R=v*P-y*M+x*E+S*C-b*A+w*T;if(0===R)this.setIdentity();else{var I=1/R,L=this.data;L[0]=(o*P-h*M+l*E)*I,L[1]=(-n*P+s*M-r*E)*I,L[2]=(m*w-_*b+g*S)*I,L[3]=(-u*w+d*b-f*S)*I,L[4]=(-a*P+h*C-l*A)*I,L[5]=(i*P-s*C+r*A)*I,L[6]=(-p*w+_*x-g*y)*I,L[7]=(c*w-d*x+f*y)*I,L[8]=(a*M-o*C+l*T)*I,L[9]=(-i*M+n*C-r*T)*I,L[10]=(p*b-m*x+g*v)*I,L[11]=(-c*b+u*x-f*v)*I,L[12]=(-a*E+o*A-h*T)*I,L[13]=(i*E-n*A+s*T)*I,L[14]=(-p*S+m*y-_*v)*I,L[15]=(c*S-u*y+d*v)*I}return this},e.set=function(t){var e=this.data;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],this},e.setIdentity=function(){var t=this.data;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},e.setTRS=function(t,e,i){var n=e.x,s=e.y,r=e.z,a=e.w,o=i.x,h=i.y,l=i.z,c=n+n,u=s+s,d=r+r,f=n*c,p=n*u,m=n*d,_=s*u,g=s*d,v=r*d,y=a*c,x=a*u,S=a*d,b=this.data;return b[0]=(1-(_+v))*o,b[1]=(p+S)*o,b[2]=(m-x)*o,b[3]=0,b[4]=(p-S)*h,b[5]=(1-(f+v))*h,b[6]=(g+y)*h,b[7]=0,b[8]=(m+x)*l,b[9]=(g-y)*l,b[10]=(1-(f+_))*l,b[11]=0,b[12]=t.x,b[13]=t.y,b[14]=t.z,b[15]=1,this},e.transpose=function(t){void 0===t&&(t=this);var e,i=t.data,n=this.data;i===n?(e=i[1],n[1]=i[4],n[4]=e,e=i[2],n[2]=i[8],n[8]=e,e=i[3],n[3]=i[12],n[12]=e,e=i[6],n[6]=i[9],n[9]=e,e=i[7],n[7]=i[13],n[13]=e,e=i[11],n[11]=i[14],n[14]=e):(n[0]=i[0],n[1]=i[4],n[2]=i[8],n[3]=i[12],n[4]=i[1],n[5]=i[5],n[6]=i[9],n[7]=i[13],n[8]=i[2],n[9]=i[6],n[10]=i[10],n[11]=i[14],n[12]=i[3],n[13]=i[7],n[14]=i[11],n[15]=i[15]);return this},e.getTranslation=function(t){return void 0===t&&(t=new Et),t.set(this.data[12],this.data[13],this.data[14])},e.getX=function(t){return void 0===t&&(t=new Et),t.set(this.data[0],this.data[1],this.data[2])},e.getY=function(t){return void 0===t&&(t=new Et),t.set(this.data[4],this.data[5],this.data[6])},e.getZ=function(t){return void 0===t&&(t=new Et),t.set(this.data[8],this.data[9],this.data[10])},e.getScale=function(t){return void 0===t&&(t=new Et),this.getX(Ft),this.getY(Bt),this.getZ(Ut),t.set(Ft.length(),Bt.length(),Ut.length()),t},e.setFromEulerAngles=function(t,e,i){t*=_t.DEG_TO_RAD,e*=_t.DEG_TO_RAD,i*=_t.DEG_TO_RAD;var n=Math.sin(-t),s=Math.cos(-t),r=Math.sin(-e),a=Math.cos(-e),o=Math.sin(-i),h=Math.cos(-i),l=this.data;return l[0]=a*h,l[1]=-a*o,l[2]=r,l[3]=0,l[4]=s*o+h*n*r,l[5]=s*h-n*r*o,l[6]=-a*n,l[7]=0,l[8]=n*o-s*h*r,l[9]=h*n+s*r*o,l[10]=s*a,l[11]=0,l[12]=0,l[13]=0,l[14]=0,l[15]=1,this},e.getEulerAngles=function(t){void 0===t&&(t=new Et),this.getScale(Nt);var e=Nt.x,i=Nt.y,n=Nt.z;if(0===e||0===i||0===n)return t.set(0,0,0);var s,r,a=this.data,o=Math.asin(-a[2]/e),h=.5*Math.PI;return o-h?(s=Math.atan2(a[6]/i,a[10]/n),r=Math.atan2(a[1]/e,a[0]/e)):(r=0,s=-Math.atan2(a[4]/i,a[5]/i)):(r=0,s=Math.atan2(a[4]/i,a[5]/i)),t.set(s,o,r).mulScalar(_t.RAD_TO_DEG)},e.toString=function(){return"["+this.data.join(", ")+"]"},y(t,[{key:"scaleSign",get:function(){return this.getX(Ft),this.getY(Bt),this.getZ(Ut),Ft.cross(Ft,Bt),Ft.dot(Ut)<0?-1:1}}]),t}();Lt=zt,zt.IDENTITY=Object.freeze(new Lt),zt.ZERO=Object.freeze((new Lt).set([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]));var Vt=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),this.x=void 0,this.y=void 0,this.z=void 0,this.w=void 0,4===t.length?(this.x=t[0],this.y=t[1],this.z=t[2],this.w=t[3]):(this.x=t,this.y=e,this.z=i,this.w=n)}var e=t.prototype;return e.clone=function(){return new(0,this.constructor)(this.x,this.y,this.z,this.w)},e.conjugate=function(t){return void 0===t&&(t=this),this.x=-1*t.x,this.y=-1*t.y,this.z=-1*t.z,this.w=t.w,this},e.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},e.equals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},e.equalsApprox=function(t,e){return void 0===e&&(e=1e-6),Math.abs(this.x-t.x)=.99999?(e=2*Math.atan2(s,o),i=Math.PI/2,n=0):(e=Math.atan2(2*(o*s+r*a),1-2*(s*s+r*r)),i=Math.asin(h),n=Math.atan2(2*(o*a+s*r),1-2*(r*r+a*a))),t.set(e,i,n).mulScalar(_t.RAD_TO_DEG)},e.invert=function(t){return void 0===t&&(t=this),this.conjugate(t).normalize()},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.mul=function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.x,a=t.y,o=t.z,h=t.w;return this.x=s*r+e*h+i*o-n*a,this.y=s*a+i*h+n*r-e*o,this.z=s*o+n*h+e*a-i*r,this.w=s*h-e*r-i*a-n*o,this},e.mul2=function(t,e){var i=t.x,n=t.y,s=t.z,r=t.w,a=e.x,o=e.y,h=e.z,l=e.w;return this.x=r*a+i*l+n*h-s*o,this.y=r*o+n*l+s*a-i*h,this.z=r*h+s*l+i*o-n*a,this.w=r*l-i*a-n*o-s*h,this},e.normalize=function(t){void 0===t&&(t=this);var e=t.length();return 0===e?(this.x=this.y=this.z=0,this.w=1):(e=1/e,this.x=t.x*e,this.y=t.y*e,this.z=t.z*e,this.w=t.w*e),this},e.set=function(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this},e.setFromAxisAngle=function(t,e){e*=.5*_t.DEG_TO_RAD;var i=Math.sin(e),n=Math.cos(e);return this.x=i*t.x,this.y=i*t.y,this.z=i*t.z,this.w=n,this},e.setFromEulerAngles=function(t,e,i){if(t instanceof Et){var n=t;t=n.x,e=n.y,i=n.z}var s=.5*_t.DEG_TO_RAD;t*=s,e*=s,i*=s;var r=Math.sin(t),a=Math.cos(t),o=Math.sin(e),h=Math.cos(e),l=Math.sin(i),c=Math.cos(i);return this.x=r*h*c-a*o*l,this.y=a*o*c+r*h*l,this.z=a*h*l-r*o*c,this.w=a*h*c+r*o*l,this},e.setFromMat4=function(t){var e,i,n,s,r,a,o,h,l,c,u,d,f,p;if(e=(t=t.data)[0],i=t[1],n=t[2],s=t[4],r=t[5],a=t[6],o=t[8],h=t[9],l=t[10],0===(d=e*e+i*i+n*n))return this;if(d=1/Math.sqrt(d),0===(f=s*s+r*r+a*a))return this;if(f=1/Math.sqrt(f),0===(p=o*o+h*h+l*l))return this;i*=d,n*=d,s*=f,a*=f,o*=p=1/Math.sqrt(p),h*=p;var m=(e*=d)+(r*=f)+(l*=p);return m>=0?(c=Math.sqrt(m+1),this.w=.5*c,c=.5/c,this.x=(a-h)*c,this.y=(o-n)*c,this.z=(i-s)*c):e>r?e>l?(u=e-(r+l)+1,u=Math.sqrt(u),this.x=.5*u,u=.5/u,this.w=(a-h)*u,this.y=(i+s)*u,this.z=(n+o)*u):(u=l-(e+r)+1,u=Math.sqrt(u),this.z=.5*u,u=.5/u,this.w=(i-s)*u,this.x=(o+n)*u,this.y=(h+a)*u):r>l?(u=r-(l+e)+1,u=Math.sqrt(u),this.y=.5*u,u=.5/u,this.w=(o-n)*u,this.z=(a+h)*u,this.x=(s+i)*u):(u=l-(e+r)+1,u=Math.sqrt(u),this.z=.5*u,u=.5/u,this.w=(i-s)*u,this.x=(o+n)*u,this.y=(h+a)*u),this},e.setFromDirections=function(t,e){var i=1+t.dot(e);return iMath.abs(t.y)?(this.x=-t.z,this.y=0,this.z=t.x,this.w=0):(this.x=0,this.y=-t.z,this.z=t.y,this.w=0):(this.x=t.y*e.z-t.z*e.y,this.y=t.z*e.x-t.x*e.z,this.z=t.x*e.y-t.y*e.x,this.w=i),this.normalize()},e.slerp=function(t,e,i){var n=t.x,s=t.y,r=t.z,a=t.w,o=e.x,h=e.y,l=e.z,c=e.w,u=a*c+n*o+s*h+r*l;if(u<0&&(c=-c,o=-o,h=-h,l=-l,u=-u),Math.abs(u)>=1)return this.w=a,this.x=n,this.y=s,this.z=r,this;var d=Math.acos(u),f=Math.sqrt(1-u*u);if(Math.abs(f)<.001)return this.w=.5*a+.5*c,this.x=.5*n+.5*o,this.y=.5*s+.5*h,this.z=.5*r+.5*l,this;var p=Math.sin((1-i)*d)/f,m=Math.sin(i*d)/f;return this.w=a*p+c*m,this.x=n*p+o*m,this.y=s*p+h*m,this.z=r*p+l*m,this},e.transformVector=function(t,e){void 0===e&&(e=new Et);var i=t.x,n=t.y,s=t.z,r=this.x,a=this.y,o=this.z,h=this.w,l=h*i+a*s-o*n,c=h*n+o*i-r*s,u=h*s+r*n-a*i,d=-r*i-a*n-o*s;return e.x=l*h+d*-r+c*-o-u*-a,e.y=c*h+d*-a+u*-r-l*-o,e.z=u*h+d*-o+l*-a-c*-r,e},e.toString=function(){return"["+this.x+", "+this.y+", "+this.z+", "+this.w+"]"},t}();Ot=Vt,Vt.IDENTITY=Object.freeze(new Ot(0,0,0,1)),Vt.ZERO=Object.freeze(new Ot(0,0,0,0));var Gt=new Et,Ht=new Et,Wt=new Et,Xt=new Et,qt=new Et,jt=function(){function t(t,e){void 0===t&&(t=new Et),void 0===e&&(e=new Et(.5,.5,.5)),this.center=void 0,this.halfExtents=void 0,this._min=new Et,this._max=new Et,this.center=t,this.halfExtents=e}var e=t.prototype;return e.add=function(t){var e=this.center,i=e.x,n=e.y,s=e.z,r=this.halfExtents,a=r.x,o=r.y,h=r.z,l=i-a,c=i+a,u=n-o,d=n+o,f=s-h,p=s+h,m=t.center,_=m.x,g=m.y,v=m.z,y=t.halfExtents,x=y.x,S=y.y,b=y.z,w=_-x,T=_+x,A=g-S,C=g+S,E=v-b,M=v+b;wc&&(c=T),Ad&&(d=C),Ep&&(p=M),e.x=.5*(l+c),e.y=.5*(u+d),e.z=.5*(f+p),r.x=.5*(c-l),r.y=.5*(d-u),r.z=.5*(p-f)},e.copy=function(t){this.center.copy(t.center),this.halfExtents.copy(t.halfExtents)},e.clone=function(){return new t(this.center.clone(),this.halfExtents.clone())},e.intersects=function(t){var e=this.getMax(),i=this.getMin(),n=t.getMax(),s=t.getMin();return i.x<=n.x&&e.x>=s.x&&i.y<=n.y&&e.y>=s.y&&i.z<=n.z&&e.z>=s.z},e._intersectsRay=function(t,e){var i=Gt.copy(this.getMin()).sub(t.origin),n=Ht.copy(this.getMax()).sub(t.origin),s=t.direction;0===s.x?(i.x=i.x<0?-Number.MAX_VALUE:Number.MAX_VALUE,n.x=n.x<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.x/=s.x,n.x/=s.x),0===s.y?(i.y=i.y<0?-Number.MAX_VALUE:Number.MAX_VALUE,n.y=n.y<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.y/=s.y,n.y/=s.y),0===s.z?(i.z=i.z<0?-Number.MAX_VALUE:Number.MAX_VALUE,n.z=n.z<0?-Number.MAX_VALUE:Number.MAX_VALUE):(i.z/=s.z,n.z/=s.z);var r=Wt.set(Math.min(i.x,n.x),Math.min(i.y,n.y),Math.min(i.z,n.z)),a=Xt.set(Math.max(i.x,n.x),Math.max(i.y,n.y),Math.max(i.z,n.z)),o=Math.min(Math.min(a.x,a.y),a.z),h=Math.max(Math.max(r.x,r.y),r.z),l=o>=h&&h>=0;return l&&e.copy(t.direction).mulScalar(h).add(t.origin),l},e._fastIntersectsRay=function(t){var e=Gt,i=Ht,n=Wt,s=Xt,r=qt,a=t.direction;return e.sub2(t.origin,this.center),s.set(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z)),n.mul2(e,a),!(s.x>this.halfExtents.x&&n.x>=0)&&(!(s.y>this.halfExtents.y&&n.y>=0)&&(!(s.z>this.halfExtents.z&&n.z>=0)&&(r.set(Math.abs(a.x),Math.abs(a.y),Math.abs(a.z)),i.cross(a,e),i.set(Math.abs(i.x),Math.abs(i.y),Math.abs(i.z)),!(i.x>this.halfExtents.y*r.z+this.halfExtents.z*r.y)&&(!(i.y>this.halfExtents.x*r.z+this.halfExtents.z*r.x)&&!(i.z>this.halfExtents.x*r.y+this.halfExtents.y*r.x)))))},e.intersectsRay=function(t,e){return e?this._intersectsRay(t,e):this._fastIntersectsRay(t)},e.setMinMax=function(t,e){this.center.add2(e,t).mulScalar(.5),this.halfExtents.sub2(e,t).mulScalar(.5)},e.getMin=function(){return this._min.copy(this.center).sub(this.halfExtents)},e.getMax=function(){return this._max.copy(this.center).add(this.halfExtents)},e.containsPoint=function(t){var e=this.getMin(),i=this.getMax();return!(t.xi.x||t.yi.y||t.zi.z)},e.setFromTransformedAabb=function(t,e,i){void 0===i&&(i=!1);var n=t.center,s=t.halfExtents,r=e.data,a=r[0],o=r[4],h=r[8],l=r[1],c=r[5],u=r[9],d=r[2],f=r[6],p=r[10];if(i){var m=a*a+o*o+h*h;if(m>0){var _=1/Math.sqrt(m);a*=_,o*=_,h*=_}if((m=l*l+c*c+u*u)>0){var g=1/Math.sqrt(m);l*=g,c*=g,u*=g}if((m=d*d+f*f+p*p)>0){var v=1/Math.sqrt(m);d*=v,f*=v,p*=v}}this.center.set(r[12]+a*n.x+o*n.y+h*n.z,r[13]+l*n.x+c*n.y+u*n.z,r[14]+d*n.x+f*n.y+p*n.z),this.halfExtents.set(Math.abs(a)*s.x+Math.abs(o)*s.y+Math.abs(h)*s.z,Math.abs(l)*s.x+Math.abs(c)*s.y+Math.abs(u)*s.z,Math.abs(d)*s.x+Math.abs(f)*s.y+Math.abs(p)*s.z)},t.computeMinMax=function(t,e,i,n){if(void 0===n&&(n=t.length/3),n>0){for(var s=t[0],r=t[1],a=t[2],o=s,h=r,l=a,c=3*n,u=3;uo&&(o=d),f>h&&(h=f),p>l&&(l=p)}e.set(s,r,a),i.set(o,h,l)}},e.compute=function(e,i){t.computeMinMax(e,Gt,Ht,i),this.setMinMax(Gt,Ht)},e.intersectsBoundingSphere=function(t){return this._distanceToBoundingSphereSq(t)<=t.radius*t.radius},e._distanceToBoundingSphereSq=function(t){for(var e=this.getMin(),i=this.getMax(),n=0,s=["x","y","z"],r=0;r<3;++r){var a=0,o=t.center[s[r]],h=e[s[r]],l=i[s[r]],c=0;ol&&(a+=(c=o-l)*c),n+=a}return n},e._expand=function(t,e){Gt.add2(this.getMin(),t),Ht.add2(this.getMax(),e),this.setMinMax(Gt,Ht)},t}(),Yt=new Et,Kt=new Et,Zt=function(){function t(t,e){void 0===t&&(t=new Et),void 0===e&&(e=.5),this.center=void 0,this.radius=void 0,this.center=t,this.radius=e}var e=t.prototype;return e.containsPoint=function(t){var e=Yt.sub2(t,this.center).lengthSq(),i=this.radius;return e0&&n>0)return!1;var r=n*n-s;if(r<0)return!1;var a=Math.abs(-n-Math.sqrt(r));return e&&e.copy(t.direction).mulScalar(a).add(t.origin),!0},e.intersectsBoundingSphere=function(t){Yt.sub2(t.center,this.center);var e=t.radius+this.radius;return Yt.lengthSq()<=e*e},t}(),Qt=function(){function t(){this.planes=[];for(var t=0;t<6;t++)this.planes[t]=[]}var e=t.prototype;return e.setFromMat4=function(t){var e,i=t.data,n=this.planes;(e=n[0])[0]=i[3]-i[0],e[1]=i[7]-i[4],e[2]=i[11]-i[8],e[3]=i[15]-i[12];var s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s,(e=n[1])[0]=i[3]+i[0],e[1]=i[7]+i[4],e[2]=i[11]+i[8],e[3]=i[15]+i[12],s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s,(e=n[2])[0]=i[3]+i[1],e[1]=i[7]+i[5],e[2]=i[11]+i[9],e[3]=i[15]+i[13],s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s,(e=n[3])[0]=i[3]-i[1],e[1]=i[7]-i[5],e[2]=i[11]-i[9],e[3]=i[15]-i[13],s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s,(e=n[4])[0]=i[3]-i[2],e[1]=i[7]-i[6],e[2]=i[11]-i[10],e[3]=i[15]-i[14],s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s,(e=n[5])[0]=i[3]+i[2],e[1]=i[7]+i[6],e[2]=i[11]+i[10],e[3]=i[15]+i[14],s=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),e[0]/=s,e[1]/=s,e[2]/=s,e[3]/=s},e.containsPoint=function(t){var e,i;for(e=0;e<6;e++)if((i=this.planes[e])[0]*t.x+i[1]*t.y+i[2]*t.z+i[3]<=0)return!1;return!0},e.containsSphere=function(t){var e,i,n,s=0,r=t.radius,a=t.center,o=a.x,h=a.y,l=a.z,c=this.planes;for(i=0;i<6;i++){if((e=(n=c[i])[0]*o+n[1]*h+n[2]*l+n[3])<=-r)return 0;e>r&&s++}return 6===s?2:1},t}(),$t=function(){function t(t,e){this.origin=new Et,this.direction=Et.FORWARD.clone(),t&&this.origin.copy(t),e&&this.direction.copy(e)}var e=t.prototype;return e.set=function(t,e){return this.origin.copy(t),this.direction.copy(e),this},e.copy=function(t){return this.set(t.origin,t.direction)},e.clone=function(){return new this.constructor(this.origin,this.direction)},t}(),Jt=new $t,te=new Et,ee=new Zt,ie=new zt,ne=function(){function t(t,e){void 0===t&&(t=new zt),void 0===e&&(e=new Et(.5,.5,.5)),this.halfExtents=void 0,this._modelTransform=void 0,this._worldTransform=void 0,this._aabb=void 0,this.halfExtents=e,this._modelTransform=t.clone().invert(),this._worldTransform=t.clone(),this._aabb=new jt(new Et,this.halfExtents)}var e=t.prototype;return e.intersectsRay=function(t,e){if(this._modelTransform.transformPoint(t.origin,Jt.origin),this._modelTransform.transformVector(t.direction,Jt.direction),e){var i=this._aabb._intersectsRay(Jt,e);return ie.copy(this._modelTransform).invert().transformPoint(e,e),i}return this._aabb._fastIntersectsRay(Jt)},e.containsPoint=function(t){return this._modelTransform.transformPoint(t,te),this._aabb.containsPoint(te)},e.intersectsBoundingSphere=function(t){return this._modelTransform.transformPoint(t.center,ee.center),ee.radius=t.radius,!!this._aabb.intersectsBoundingSphere(ee)},y(t,[{key:"worldTransform",get:function(){return this._worldTransform},set:function(t){this._worldTransform.copy(t),this._modelTransform.copy(t).invert()}}]),t}(),se=function(){function t(t,e){void 0===t&&(t=Et.UP),void 0===e&&(e=0),this.normal=new Et,this.distance=void 0,this.normal.copy(t),this.distance=e}var e=t.prototype;return e.setFromPointNormal=function(t,e){return this.normal.copy(e),this.distance=-this.normal.dot(t),this},e.intersectsLine=function(t,e,i){var n=this.distance,s=this.normal.dot(t)+n,r=s/(s-(this.normal.dot(e)+n)),a=r>=0&&r<=1;return a&&i&&i.lerp(t,e,r),a},e.intersectsRay=function(t,e){var i=this.normal.dot(t.direction);if(0===i)return!1;var n=-(this.normal.dot(t.origin)+this.distance)/i;return n>=0&&e&&e.copy(t.direction).mulScalar(n).add(t.origin),n>=0},e.copy=function(t){return this.normal.copy(t.normal),this.distance=t.distance,this},e.clone=function(){return(new(0,this.constructor)).copy(this)},t}(),re="linear",ae="inverse",oe="exponential",he=0,le=10,ce=11,ue=12,de=13,fe=14,pe=15,me=16,_e=17,ge=18,ve=21,ye=24,xe=25,Se=26,be=27,we=new Map([[0,{name:"A8",size:1}],[1,{name:"L8",size:1}],[2,{name:"LA8",size:2}],[3,{name:"RGB565",size:2}],[4,{name:"RGBA5551",size:2}],[5,{name:"RGBA4",size:2}],[6,{name:"RGB8",size:4}],[7,{name:"RGBA8",size:4}],[ce,{name:"RGB16F",size:8}],[ue,{name:"RGBA16F",size:8}],[de,{name:"RGB32F",size:16}],[fe,{name:"RGBA32F",size:16}],[pe,{name:"R32F",size:4}],[me,{name:"DEPTH",size:4}],[_e,{name:"DEPTHSTENCIL",size:4}],[ge,{name:"111110F",size:4}],[19,{name:"SRGB",size:4}],[20,{name:"SRGBA",size:4}],[31,{name:"BGRA8",size:4}],[8,{name:"DXT1",blockSize:8}],[9,{name:"DXT3",blockSize:16}],[le,{name:"DXT5",blockSize:16}],[ve,{name:"ETC1",blockSize:8}],[22,{name:"ETC2_RGB",blockSize:8}],[23,{name:"ETC2_RGBA",blockSize:16}],[ye,{name:"PVRTC_2BPP_RGB_1",blockSize:8}],[xe,{name:"PVRTC_2BPP_RGBA_1",blockSize:8}],[Se,{name:"PVRTC_4BPP_RGB_1",blockSize:8}],[be,{name:"PVRTC_4BPP_RGBA_1",blockSize:8}],[28,{name:"ASTC_4x4",blockSize:16}],[29,{name:"ATC_RGB",blockSize:8}],[30,{name:"ATC_RGBA",blockSize:16}]]),Te=function(t){return void 0!==we.get(t).blockSize},Ae=function(t){switch(t){case de:case fe:return Float32Array;case 3:case 4:case 5:case ce:case ue:return Uint16Array;default:return Uint8Array}},Ce=5,Ee="POSITION",Me="NORMAL",Pe="TANGENT",Re="BLENDWEIGHT",Ie="BLENDINDICES",Le="COLOR",De="TEXCOORD",Oe="TEXCOORD0",ke="TEXCOORD1",Fe="TEXCOORD2",Be="TEXCOORD3",Ue="TEXCOORD4",Ne="TEXCOORD5",ze="TEXCOORD6",Ve="TEXCOORD7",Ge="ATTR",He="ATTR0",We="ATTR1",Xe="ATTR2",qe="ATTR3",je="ATTR4",Ye="ATTR5",Ke="ATTR6",Ze="ATTR7",Qe="ATTR8",$e="ATTR9",Je="ATTR10",ti="ATTR11",ei="ATTR12",ii="ATTR13",ni="ATTR14",si="ATTR15",ri="default",ai="rgbm",oi="rgbe",hi="rgbp",li="swizzleGGGR",ci="2d",ui="2d-array",di="cube",fi="3d",pi="none",mi="cube",_i="equirect",gi="octahedral",vi="wgsl",yi=1,xi=13,Si=14,bi=["bool","int","float","vec2","vec3","vec4","ivec2","ivec3","ivec4","bec2","bec3","bec4","mat2","mat3","mat4","sampler2D","samplerCube","","sampler2DShadow","samplerCubeShadow","sampler3D","","",""],wi="webgl1",Ti="webgl2",Ai="webgpu",Ci="null",Ei=["mesh","view"],Mi="default",Pi=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Uint16Array],Ri=[1,1,2,2,4,4,4,2],Ii={Int8Array:0,Uint8Array:yi,Int16Array:2,Uint16Array:3,Int32Array:4,Uint32Array:5,Float32Array:6},Li=[Uint8Array,Uint16Array,Uint32Array],Di=[1,2,4],Oi={};Oi[Ee]=0,Oi[Me]=1,Oi[Re]=2,Oi[Ie]=3,Oi[Le]=4,Oi[Oe]=5,Oi[ke]=6,Oi[Fe]=7,Oi[Be]=8,Oi[Ue]=9,Oi[Ne]=10,Oi[ze]=11,Oi[Ve]=12,Oi[Pe]=13,Oi[He]=0,Oi[We]=1,Oi[Xe]=2,Oi[qe]=3,Oi[je]=4,Oi[Ye]=5,Oi[Ke]=6,Oi[Ze]=7,Oi[Qe]=8,Oi[$e]=9,Oi[Je]=10,Oi[ti]=11,Oi[ei]=12,Oi[ii]=13,Oi[ni]=14,Oi[si]=15;var ki,Fi,Bi="1.65",Ui=function(t,e,i,n){return void 0===n&&(n=1),t&~(n<>e&i},zi=function(t,e,i){void 0===i&&(i=1);var n=i<>>0}var Ji,tn=function(){function t(){this.map=new Map,this.id=0}return t.prototype.get=function(t){var e=this.map.get(t);return void 0===e&&(e=this.id++,this.map.set(t,e)),e},t}(),en=new tn,nn=[2,4,8,12,16],sn=function(){function t(t,e,i){this.device=t,this._elements=[],this.hasUv0=!1,this.hasUv1=!1,this.hasColor=!1,this.hasTangents=!1,this.verticesByteSize=0,this.vertexCount=i,this.interleaved=void 0===i,this.instancing=!1,this.size=e.reduce((function(t,e){return t+4*Math.ceil(e.components*Ri[e.type]/4)}),0);for(var n,s=0,r=0,a=e.length;r1?_:1),this.autoResolve=null==(a=t.autoResolve)||a,this.name=t.name,this.name)||(this.name=null==(p=this._colorBuffer)?void 0:p.name);this.name||(this.name=null==(m=this._depthBuffer)?void 0:m.name);this.name||(this.name="Untitled"),this.flipY=null!=(o=t.flipY)&&o,this.validateMrt(),this.impl=f.createRenderTargetImpl(this)}var e=t.prototype;return e.destroy=function(){var t=this._device;t&&(t.targets.delete(this),t.renderTarget===this&&t.setRenderTarget(null),this.destroyFrameBuffers())},e.destroyFrameBuffers=function(){var t=this._device;t&&this.impl.destroy(t)},e.destroyTextureBuffers=function(){var t,e;null==(t=this._depthBuffer)||t.destroy(),this._depthBuffer=null,null==(e=this._colorBuffers)||e.forEach((function(t){t.destroy()})),this._colorBuffers=null,this._colorBuffer=null},e.resize=function(t,e){if(this.width!==t||this.height!==e){var i,n,s=this._device;this.destroyFrameBuffers(),s.renderTarget===this&&s.setRenderTarget(null),null==(i=this._depthBuffer)||i.resize(t,e),null==(n=this._colorBuffers)||n.forEach((function(i){i.resize(t,e)})),this.validateMrt(),this.impl=s.createRenderTargetImpl(this)}},e.validateMrt=function(){},e.init=function(){this.impl.init(this._device,this)},e.loseContext=function(){this.impl.loseContext()},e.resolve=function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!!this._depthBuffer),this._device&&this._samples>1&&this.impl.resolve(this._device,this,t,e)},e.copy=function(t,e,i){if(!this._device){if(!t._device)return!1;this._device=t._device}return this._device.copyRenderTarget(t,this,e,i)},e.getColorBuffer=function(t){var e;return null==(e=this._colorBuffers)?void 0:e[t]},y(t,[{key:"initialized",get:function(){return this.impl.initialized}},{key:"device",get:function(){return this._device}},{key:"samples",get:function(){return this._samples}},{key:"depth",get:function(){return this._depth}},{key:"stencil",get:function(){return this._stencil}},{key:"colorBuffer",get:function(){return this._colorBuffer}},{key:"depthBuffer",get:function(){return this._depthBuffer}},{key:"face",get:function(){return this._face}},{key:"width",get:function(){var t,e;return(null==(t=this._colorBuffer)?void 0:t.width)||(null==(e=this._depthBuffer)?void 0:e.width)||this._device.width}},{key:"height",get:function(){var t,e;return(null==(t=this._colorBuffer)?void 0:t.height)||(null==(e=this._depthBuffer)?void 0:e.height)||this._device.height}}]),t}(),cn=function(){function t(){this.bindGroup=void 0}var e=t.prototype;return e.update=function(t){this.destroy();var e=t.device,i=this.createDescriptor(e,t);this.bindGroup=e.wgpu.createBindGroup(i)},e.destroy=function(){this.bindGroup=null},e.createDescriptor=function(t,e){var i=[],n=e.format,s=0;return e.uniformBuffers.forEach((function(t){var e=t.persistent?t.impl.buffer:t.allocation.gpuBuffer.buffer;i.push({binding:s++,resource:{buffer:e,offset:0,size:t.format.byteSize}})})),e.textures.forEach((function(e,r){var a=e.impl,o=n.textureFormats[r],h=a.getView(t);i.push({binding:s++,resource:h});var l=a.getSampler(t,o.sampleType);i.push({binding:s++,resource:l})})),e.storageTextures.forEach((function(e,n){var r=e.impl.getView(t);i.push({binding:s++,resource:r})})),{layout:e.format.impl.bindGroupLayout,entries:i}},t}(),un=function(){function t(){}return t.shaderStage=function(t){var e=0;return 1&t&&(e|=GPUShaderStage.VERTEX),2&t&&(e|=GPUShaderStage.FRAGMENT),4&t&&(e|=GPUShaderStage.COMPUTE),e},t}(),dn=[];dn[0]="",dn[1]="r8unorm",dn[2]="rg8unorm",dn[3]="",dn[4]="",dn[5]="",dn[6]="rgba8unorm",dn[7]="rgba8unorm",dn[8]="bc1-rgba-unorm",dn[9]="bc2-rgba-unorm",dn[10]="bc3-rgba-unorm",dn[11]="",dn[12]="rgba16float",dn[13]="",dn[14]="rgba32float",dn[15]="r32float",dn[16]="depth32float",dn[17]="depth24plus-stencil8",dn[18]="rg11b10ufloat",dn[19]="",dn[20]="",dn[21]="",dn[22]="etc2-rgb8unorm",dn[23]="etc2-rgba8unorm",dn[24]="",dn[25]="",dn[26]="",dn[27]="",dn[28]="astc-4x4-unorm",dn[29]="",dn[30]="",dn[31]="bgra8unorm";var fn=[];fn[0]="filtering",fn[1]="non-filtering",fn[2]="comparison";var pn=[];pn[0]="float",pn[1]="unfilterable-float",pn[2]="depth";var mn=new tn,_n=function(){function t(t){var e=t.device,i=this.createDescriptor(t),n=i.key,s=i.descr;this.key=mn.get(n),this.bindGroupLayout=e.wgpu.createBindGroupLayout(s)}var e=t.prototype;return e.destroy=function(){this.bindGroupLayout=null},e.loseContext=function(){},e.getTextureSlot=function(t,e){return t.bufferFormats.length+2*e},e.createDescriptor=function(t){var e=[],i="",n=0;return t.bufferFormats.forEach((function(t){var s=un.shaderStage(t.visibility);i+="#"+n+"U:"+s,e.push({binding:n++,visibility:s,buffer:{type:"uniform",hasDynamicOffset:!0}})})),t.textureFormats.forEach((function(t){var s=un.shaderStage(t.visibility),r=t.sampleType,a=t.textureDimension,o=pn[r];i+="#"+n+"T:"+s+"-"+o+"-"+a+"-false",e.push({binding:n++,visibility:s,texture:{sampleType:o,viewDimension:a,multisampled:false}});var h=fn[r];i+="#"+n+"S:"+s+"-"+h,e.push({binding:n++,visibility:s,sampler:{type:h}})})),t.storageTextureFormats.forEach((function(t){var s=t.format,r=t.textureDimension;i+="#"+n+"ST:"+s+"-"+r,e.push({binding:n++,visibility:GPUShaderStage.COMPUTE,storageTexture:{access:"write-only",format:dn[s],viewDimension:r}})})),{key:i,descr:{entries:e}}},t}(),gn=function(){function t(){this.buffer=null}var e=t.prototype;return e.destroy=function(t){this.buffer&&(this.buffer.destroy(),this.buffer=null)},e.loseContext=function(){},e.unlock=function(t,e,i,n){var s,r,a=t.wgpu;if(!this.buffer){var o=n.byteLength+3&-4;this.buffer=t.wgpu.createBuffer({size:o,usage:i|GPUBufferUsage.COPY_DST})}var h=null!=(s=n.byteOffset)?s:0,l=new Uint8Array(null!=(r=n.buffer)?r:n,h,n.byteLength),c=new Uint8Array(this.buffer.size);c.set(l),a.queue.writeBuffer(this.buffer,0,c,0,c.length)},y(t,[{key:"initialized",get:function(){return!!this.buffer}}]),t}(),vn=function(t){function e(e){var i;return(i=t.call(this)||this).format=null,i.format=1===e.format?"uint16":"uint32",i}return S(e,t),e.prototype.unlock=function(e){var i=e.device;t.prototype.unlock.call(this,i,e.usage,GPUBufferUsage.INDEX,e.storage)},e}(gn),yn=function(t,e){if(t.size!==e.size)return!1;for(var i=0;i1?"x"+o.numComponents:"")}),e&&a!==r-1||(i.push({attributes:s,arrayStride:o.stride,stepMode:n}),s=[])}};return t&&n(t),e&&n(e),i},t}(),wn=function(){function t(t){this.device=t}return t.prototype.getPipelineLayout=function(t){var e=[];t.forEach((function(t){e.push(t.bindGroupLayout)}));var i={bindGroupLayouts:e};return this.device.wgpu.createPipelineLayout(i)},t}(),Tn=["point-list","line-list",void 0,"line-strip","triangle-list","triangle-strip",void 0],An=["add","subtract","reverse-subtract","min","max"],Cn=["zero","one","src","one-minus-src","dst","one-minus-dst","src-alpha","src-alpha-saturated","one-minus-src-alpha","dst-alpha","one-minus-dst-alpha","constant","one-minus-constant"],En=["never","less","equal","less-equal","greater","not-equal","greater-equal","always"],Mn=["none","back","front"],Pn=["keep","zero","replace","increment-clamp","increment-wrap","decrement-clamp","decrement-wrap","invert"],Rn=function(){this.pipeline=void 0,this.hashes=void 0},In=function(t){function e(e){var i;return(i=t.call(this,e)||this).lookupHashes=new Uint32Array(13),i.vertexBufferLayout=new bn,i.cache=new Map,i}S(e,t);var i=e.prototype;return i.get=function(t,e,i,n,s,r,a,o,h,l,c,u){var d,f,p,m,_,g,v,y,x=this.lookupHashes;x[0]=t.type,x[1]=n.id,x[2]=h,x[3]=o.key,x[4]=a.key,x[5]=null!=(d=null==e?void 0:e.renderingHash)?d:0,x[6]=null!=(f=null==i?void 0:i.renderingHash)?f:0,x[7]=s.impl.key,x[8]=null!=(p=null==(m=r[0])?void 0:m.key)?p:0,x[9]=null!=(_=null==(g=r[1])?void 0:g.key)?_:0,x[10]=null!=(v=null==(y=r[2])?void 0:y.key)?v:0,x[11]=l?c.key:0,x[12]=l?u.key:0;var S=$i(x),b=this.cache.get(S);if(b)for(var w=0;w0){f.fragment={module:d.getFragmentShaderModule(),entryPoint:d.fragmentEntryPoint,targets:[]};var m=0;s.redWrite&&(m|=GPUColorWrite.RED),s.greenWrite&&(m|=GPUColorWrite.GREEN),s.blueWrite&&(m|=GPUColorWrite.BLUE),s.alphaWrite&&(m|=GPUColorWrite.ALPHA);var _=this.getBlend(s);p.forEach((function(t){f.fragment.targets.push({format:t.format,writeMask:m,blend:_})}))}return u.createRenderPipeline(f)},e}(wn),Ln=function(t){function e(){return t.apply(this,arguments)||this}S(e,t);var i=e.prototype;return i.get=function(t,e){var i=this.getPipelineLayout([e.impl]);return this.create(t,i)},i.create=function(t,e){var i=this.device.wgpu,n=t.impl,s={compute:{module:n.getComputeShaderModule(),entryPoint:n.computeEntryPoint},layout:e};return i.createComputePipeline(s)},e}(wn),Dn=new tn,On=function(){function t(){this.format=void 0,this.multisampledBuffer=void 0}return t.prototype.destroy=function(){var t;null==(t=this.multisampledBuffer)||t.destroy(),this.multisampledBuffer=null},t}(),kn=function(){function t(t){var e=this;this.initialized=!1,this.key=void 0,this.colorAttachments=[],this.depthFormat=void 0,this.hasStencil=void 0,this.depthTexture=null,this.depthTextureInternal=!1,this.assignedColorTexture=null,this.renderPassDescriptor={},this.renderTarget=t,t._colorBuffers&&t._colorBuffers.forEach((function(t,i){e.setColorAttachment(i,void 0,t.impl.format)})),this.updateKey()}var e=t.prototype;return e.destroy=function(t){var e;(this.initialized=!1,this.depthTextureInternal)&&(null==(e=this.depthTexture)||e.destroy(),this.depthTexture=null);this.assignedColorTexture=null,this.colorAttachments.forEach((function(t){t.destroy()})),this.colorAttachments.length=0},e.updateKey=function(){var t=this.renderTarget,e=t.samples+":"+(t.depth?this.depthFormat:"nodepth");this.colorAttachments.forEach((function(t){e+=":"+t.format})),this.key=Dn.get(e)},e.setDepthFormat=function(t){this.depthFormat=t,this.hasStencil="depth24plus-stencil8"===t},e.assignColorTexture=function(t){this.assignedColorTexture=t;var e=t.createView(),i=this.renderPassDescriptor.colorAttachments[0];this.renderTarget.samples>1?i.resolveTarget=e:i.view=e,this.setColorAttachment(0,void 0,t.format),this.updateKey()},e.setColorAttachment=function(t,e,i){this.colorAttachments[t]||(this.colorAttachments[t]=new On),e&&(this.colorAttachments[t].multisampledBuffer=e),i&&(this.colorAttachments[t].format=i)},e.init=function(t,e){var i,n,s=t.wgpu;this.initDepthStencil(s,e),this.renderPassDescriptor.colorAttachments=[];for(var r=null!=(i=null==(n=e._colorBuffers)?void 0:n.length)?i:1,a=0;a1?GPUTextureUsage.TEXTURE_BINDING:GPUTextureUsage.COPY_SRC,this.depthTexture=t.createTexture(o),this.depthTextureInternal=!0}this.renderPassDescriptor.depthStencilAttachment={view:this.depthTexture.createView()}}},e.initColor=function(t,e,i){var n={},s=e.samples,r=e.width,a=e.height,o=e.getColorBuffer(i),h=null;if(o){h=o.cubemap?o.impl.createView({dimension:"2d",baseArrayLayer:e.face,arrayLayerCount:1,mipLevelCount:1}):o.impl.createView({mipLevelCount:1})}if(s>1){var l,c,u={size:[r,a,1],dimension:"2d",sampleCount:s,format:null!=(l=null==(c=this.colorAttachments[i])?void 0:c.format)?l:o.impl.format,usage:GPUTextureUsage.RENDER_ATTACHMENT},d=t.createTexture(u);this.setColorAttachment(i,d,u.format),n.view=d.createView(),n.resolveTarget=h}else n.view=h;return n},e.setupForRenderPass=function(t){for(var e,i,n=null!=(e=null==(i=this.renderPassDescriptor.colorAttachments)?void 0:i.length)?e:0,s=0;s>e,1)},t.calcMipLevelsCount=function(t,e,i){return void 0===i&&(i=1),1+Math.floor(Math.log2(Math.max(t,e,i)))},t.calcLevelGpuSize=function(t,e,i,n){var s,r,a,o=we.get(n),h=null!=(s=null==(r=we.get(n))?void 0:r.size)?s:0;if(h>0)return t*e*i*h;var l=null!=(a=o.blockSize)?a:0,c=Math.floor((t+3)/4),u=Math.floor((e+3)/4),d=Math.floor((i+3)/4);return n!==ye&&n!==xe||(c=Math.max(Math.floor(c/2),1)),c*u*d*l},t.calcGpuSize=function(e,i,n,s,r,a){for(var o=0;o+=t.calcLevelGpuSize(e,i,n,s),r&&(1!==e||1!==i||1!==n);)e=Math.max(e>>1,1),i=Math.max(i>>1,1),n=Math.max(n>>1,1);return o*(a?6:1)},t}(),is=[];is[0]="repeat",is[1]="clamp-to-edge",is[2]="mirror-repeat";var ns=[];ns[0]={level:"nearest",mip:"nearest"},ns[1]={level:"linear",mip:"nearest"},ns[2]={level:"nearest",mip:"nearest"},ns[3]={level:"nearest",mip:"linear"},ns[4]={level:"linear",mip:"nearest"},ns[5]={level:"linear",mip:"linear"};var ss=function(){function t(t){this.gpuTexture=void 0,this.view=void 0,this.samplers=[],this.descr=void 0,this.format=void 0,this.texture=t,this.format=dn[t.format],this.create(t.device)}var e=t.prototype;return e.create=function(t){var e,i=this.texture,n=t.wgpu,s=i.requiredMipLevels;this.descr={size:{width:i.width,height:i.height,depthOrArrayLayers:i.cubemap?6:1},format:this.format,mipLevelCount:s,sampleCount:1,dimension:i.volume?"3d":"2d",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|(Te(i.format)?0:GPUTextureUsage.RENDER_ATTACHMENT)|(i.storage?GPUTextureUsage.STORAGE_BINDING:0)},this.gpuTexture=n.createTexture(this.descr),this.texture.format===_e&&(e={format:"depth24plus",aspect:"depth-only"}),this.view=this.createView(e)},e.destroy=function(t){},e.propertyChanged=function(t){this.samplers.length=0},e.getView=function(t){return this.uploadImmediate(t,this.texture),this.view},e.createView=function(t){var e,i,n,s,r,a,o,h=null!=t?t:{},l=this.descr,c=this.texture,u={format:null!=(e=h.format)?e:l.format,dimension:null!=(i=h.dimension)?i:c.cubemap?"cube":c.volume?"3d":"2d",aspect:null!=(n=h.aspect)?n:"all",baseMipLevel:null!=(s=h.baseMipLevel)?s:0,mipLevelCount:null!=(r=h.mipLevelCount)?r:l.mipLevelCount,baseArrayLayer:null!=(a=h.baseArrayLayer)?a:0,arrayLayerCount:null!=(o=h.arrayLayerCount)?o:l.depthOrArrayLayers};return this.gpuTexture.createView(u)},e.getSampler=function(t,e){var i=this.samplers[e];if(!i){var n=this.texture,s={addressModeU:is[n.addressU],addressModeV:is[n.addressV],addressModeW:is[n.addressW]};!e&&n.compareOnRead&&(e=2),2===e?(s.compare="less",s.magFilter="linear",s.minFilter="linear"):1===e||this.texture.format===fe||this.texture.format===_e||this.texture.format===ue?(s.magFilter="nearest",s.minFilter="nearest",s.mipmapFilter="nearest"):(s.magFilter=ns[n.magFilter].level,s.minFilter=ns[n.minFilter].level,s.mipmapFilter=ns[n.minFilter].mip);var r="linear"===s.minFilter&&"linear"===s.magFilter&&"linear"===s.mipmapFilter;s.maxAnisotropy=r?_t.clamp(Math.round(n._anisotropy),1,t.maxTextureAnisotropy):1,i=t.wgpu.createSampler(s),this.samplers[e]=i}return i},e.loseContext=function(){},e.uploadImmediate=function(t,e){(e._needsUpload||e._needsMipmapsUpload)&&(this.uploadData(t),e._needsUpload=!1,e._needsMipmapsUpload=!1)},e.uploadData=function(t){var e=this.texture;if(e._levels){for(var i=!1,n=e.requiredMipLevels,s=0;s<=|&+-]/g,_s=function(){function t(){}return t.run=function(t,e){void 0===e&&(e=!1),t=(t=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1")).split(/\r?\n/).map((function(t){return t.trimEnd()})).join("\n");var i=new Map;if(e){var n=new Map,s=t.match(/(pcFragColor[1-8])\b/g);null==s||s.forEach((function(t){var e,i=parseInt(t.charAt(t.length-1),10);n.set(i,(null!=(e=n.get(i))?e:0)+1)})),n.forEach((function(t,e){1===t&&i.set("REMOVE_COLOR_ATTACHMENT_"+e,"")}))}t=this._preprocess(t,i);var r=new Map;return i.forEach((function(t,e){Number.isInteger(parseFloat(t))&&!t.includes(".")&&r.set(e,t)})),null!==t&&(t=t.split(/\r?\n/).map((function(t){return""===t.trim()?"":t})).map((function(t){return r.forEach((function(e,i){t=t.replace(new RegExp("\\["+i+"\\]","g"),"["+e+"]")})),t})).join("\n"),t=t.replace(/(\n\n){3,}/gm,"\n\n")),t},t._preprocess=function(e,i){void 0===i&&(i=new Map);for(var n,s=e,r=[],a=!1;null!==(n=os.exec(e));){var o=n[1];switch(o){case"define":hs.lastIndex=n.index;var h=hs.exec(e);a||(a=null===h);var l=h[1];fs.lastIndex=h.index;var c=fs.exec(l)[1],u=l.substring(c.length).trim();""===u&&(u="true"),t._keep(r)&&i.set(c,u),os.lastIndex=h.index+h[0].length;break;case"undef":cs.lastIndex=n.index;var d=cs.exec(e),f=d[1].trim();t._keep(r)&&i.delete(f),os.lastIndex=d.index+d[0].length;break;case"extension":ls.lastIndex=n.index;var p=ls.exec(e);if(a||(a=null===p),p){var m=p[1];t._keep(r)&&i.set(m,"true")}os.lastIndex=p.index+p[0].length;break;case"ifdef":case"ifndef":case"if":us.lastIndex=n.index;var _=us.exec(e),g=_[2],v=t.evaluate(g,i);a||(a=v.error);var y=v.result;"ifndef"===o&&(y=!y),r.push({anyKeep:y,keep:y,start:n.index,end:us.lastIndex}),os.lastIndex=_.index+_[0].length;break;case"endif":case"else":case"elif":ds.lastIndex=n.index;var x=ds.exec(e),S=r.pop(),b=S.keep?e.substring(S.end,n.index):"";e=e.substring(0,S.start)+b+e.substring(ds.lastIndex),os.lastIndex=S.start+b.length;var w=x[1];if("else"===w||"elif"===w){var T=!1;if(!S.anyKeep)if("else"===w)T=!S.keep;else{var A=t.evaluate(x[2],i);T=A.result,a||(a=A.error)}r.push({anyKeep:S.anyKeep||T,keep:T,start:os.lastIndex,end:os.lastIndex})}}}return a?(console.warn("Failed to preprocess shader: ",{source:s}),s):e},t._keep=function(t){for(var e=0;e=0;r--){var a=this.usedBuffers[r],o=a.stagingBuffer,h=a.gpuBuffer,l=a.offset,c=a.size,u=o.buffer;u.unmap(),s.copyBufferToBuffer(u,l,h.buffer,l,c),n.push(h)}var d=s.finish();i.addCommandBuffer(d,!0);for(var f=0;f0&&(this._frameTime=e[0]),E.get(l))for(var n=0;n0&&(this.dynamicBuffers.submit(),this.wgpu.queue.submit(this.commandBuffers),this.commandBuffers.length=0,this.dynamicBuffers.onCommandBuffersSubmitted())},n.clear=function(t){t.flags&&this.clearRenderer.clear(this,this.renderTarget,t,this.defaultClearOptions)},n.setDepthBias=function(t){},n.setDepthBiasValues=function(t,e){},n.setViewport=function(t,e,i,n){this.passEncoder&&(this.renderTarget.flipY||(e=this.renderTarget.height-e-n),this.vx=t,this.vy=e,this.vw=i,this.vh=n,this.passEncoder.setViewport(t,e,i,n,0,1))},n.setScissor=function(t,e,i,n){this.passEncoder&&(this.renderTarget.flipY||(e=this.renderTarget.height-e-n),this.sx=t,this.sy=e,this.sw=i,this.sh=n,this.passEncoder.setScissorRect(t,e,i,n))},n.copyRenderTarget=function(t,e,i,n){var s,r={width:t?t.width:e.width,height:t?t.height:e.height,depthOrArrayLayers:1},a=null!=(s=this.commandEncoder)?s:this.wgpu.createCommandEncoder();if(i){var o={texture:t?t.colorBuffer.impl.gpuTexture:this.renderTarget.impl.assignedColorTexture,mipLevel:0},h={texture:e?e.colorBuffer.impl.gpuTexture:this.renderTarget.impl.assignedColorTexture,mipLevel:0};a.copyTextureToTexture(o,h,r)}if(n){var l=(t||this.renderTarget).impl.depthTexture;if(t.samples>1){var c=e.colorBuffer.impl.gpuTexture;this.resolver.resolveDepth(a,l,c)}else{var u={texture:l,mipLevel:0},d={texture:e?e.depthBuffer.impl.gpuTexture:this.renderTarget.impl.depthTexture,mipLevel:0};a.copyTextureToTexture(u,d,r)}}if(!this.commandEncoder){var f=a.finish();this.addCommandBuffer(f)}return!0},e}(on),Bs=0,Us=function(){function t(t,e){var i,n,s,r,a,o,h,l,c,u,d,f,p,m,_,g,v,y,x,S,b,w;(void 0===e&&(e={}),this.name=void 0,this._isRenderTarget=!1,this._gpuSize=0,this.id=Bs++,this._invalid=!1,this._lockedLevel=-1,this.renderVersionDirty=0,this._storage=!1,this.device=t,this.name=null!=(i=e.name)?i:"",this._width=Math.floor(null!=(n=e.width)?n:4),this._height=Math.floor(null!=(s=e.height)?s:4),this._format=null!=(r=e.format)?r:7,this._compressed=Te(this._format),t.supportsVolumeTextures)?(this._volume=null!=(S=e.volume)&&S,this._depth=Math.floor(null!=(b=e.depth)?b:1),this._arrayLength=Math.floor(null!=(w=e.arrayLength)?w:0)):(this._volume=!1,this._depth=1,this._arrayLength=0);this._storage=null!=(a=e.storage)&&a,this._cubemap=null!=(o=e.cubemap)&&o,this.fixCubemapSeams=null!=(h=e.fixCubemapSeams)&&h,this._flipY=null!=(l=e.flipY)&&l,this._premultiplyAlpha=null!=(c=e.premultiplyAlpha)&&c,this._mipmaps=null==(u=null!=(d=e.mipmaps)?d:e.autoMipmap)||u,this._minFilter=null!=(f=e.minFilter)?f:5,this._magFilter=null!=(p=e.magFilter)?p:1,this._anisotropy=null!=(m=e.anisotropy)?m:1,this._addressU=null!=(_=e.addressU)?_:0,this._addressV=null!=(g=e.addressV)?g:0,this._addressW=null!=(v=e.addressW)?v:0,this._compareOnRead=null!=(y=e.compareOnRead)&&y,this._compareFunc=null!=(x=e.compareFunc)?x:1,this.type=ri,e.hasOwnProperty("type")?this.type=e.type:e.hasOwnProperty("rgbm")?this.type=e.rgbm?ai:ri:e.hasOwnProperty("swizzleGGGR")&&(this.type=e.swizzleGGGR?li:ri),this.projection=pi,this._cubemap?this.projection=mi:e.projection&&e.projection!==mi&&(this.projection=e.projection),this.impl=t.createTextureImpl(this),this.dirtyAll(),this._levels=e.levels,this._levels?this.upload():this._levels=this._cubemap?[[null,null,null,null,null,null]]:[null],t.textures.push(this)}var e,i=t.prototype;return i.destroy=function(){var t=this.device;if(t){var e=t.textures.indexOf(this);-1!==e&&t.textures.splice(e,1),t.scope.removeValue(this),this.impl.destroy(t),this.adjustVramSizeTracking(t._vram,-this._gpuSize),this._levels=null,this.device=null}},i.resize=function(t,e,i){void 0===i&&(i=1);var n=this.device;this.adjustVramSizeTracking(n._vram,-this._gpuSize),this.impl.destroy(n),this._width=Math.floor(t),this._height=Math.floor(e),this._depth=Math.floor(i),this.impl=n.createTextureImpl(this),this.dirtyAll()},i.loseContext=function(){this.impl.loseContext(),this.dirtyAll()},i.adjustVramSizeTracking=function(t,e){t.tex+=e},i.propertyChanged=function(t){this.impl.propertyChanged(t),this.renderVersionDirty=this.device.renderVersion},i.dirtyAll=function(){this._levelsUpdated=this._cubemap?[[!0,!0,!0,!0,!0,!0]]:[!0],this._needsUpload=!0,this._needsMipmapsUpload=this._mipmaps,this._mipmapsUploaded=!1,this.propertyChanged(255)},i.lock=function(t){void 0===t&&(t={}),void 0===t.level&&(t.level=0),void 0===t.face&&(t.face=0),void 0===t.mode&&(t.mode=2),this._lockedLevel=t.level;var e=this.cubemap?this._levels[t.face]:this._levels;if(null===e[t.level]){var i=Math.max(1,this._width>>t.level),n=Math.max(1,this._height>>t.level),s=Math.max(1,this._depth>>t.level),r=new ArrayBuffer(es.calcLevelGpuSize(i,n,s,this._format));e[t.level]=new(Ae(this._format))(r)}return e[t.level]},i.setSource=function(t,e){void 0===e&&(e=0);var i,n,s=!1;if(this._cubemap){if(t[0]){i=t[0].width||0,n=t[0].height||0;for(var r=0;r<6;r++){var a=t[r];if(!a||a.width!==i||a.height!==n||!this.device._isBrowserInterface(a)){s=!0;break}}}else s=!0;if(!s)for(var o=0;o<6;o++)this._levels[e][o]!==t[o]&&(this._levelsUpdated[e][o]=!0)}else this.device._isBrowserInterface(t)||(s=!0),s||(t!==this._levels[e]&&(this._levelsUpdated[e]=!0),i=t.width,n=t.height);if(s)if(this._width=4,this._height=4,this._cubemap)for(var h=0;h<6;h++)this._levels[e][h]=null,this._levelsUpdated[e][h]=!0;else this._levels[e]=null,this._levelsUpdated[e]=!0;else 0===e&&(this._width=i,this._height=n),this._levels[e]=t;this._invalid===s&&s||(this._invalid=s,this.upload())},i.getSource=function(t){return void 0===t&&(t=0),this._levels[t]},i.unlock=function(){this._lockedLevel,this.upload(),this._lockedLevel=-1},i.upload=function(){var t,e;this._needsUpload=!0,this._needsMipmapsUpload=this._mipmaps,null==(t=(e=this.impl).uploadImmediate)||t.call(e,this.device,this)},i.downloadAsync=(e=g(m().mark((function t(){var e,i,n,s=this;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e=[],i=m().mark((function t(){var i,r,a,o;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=new ln({colorBuffer:s,depth:!1,face:n}),s.device.setRenderTarget(i),s.device.initRenderTarget(i),(r=s.cubemap?s._levels[n]:s._levels)[0],r[0]&&s.device._isBrowserInterface(r[0])&&(r[0]=null),a=s.lock({face:n}),o=null==s.device.readPixelsAsync?void 0:s.device.readPixelsAsync(0,0,s.width,s.height,a).then((function(){return i.destroy()})),e.push(o);case 9:case"end":return t.stop()}}),t)})),n=0;case 3:if(!(n<(this.cubemap?6:1))){t.next=8;break}return t.delegateYield(i(),"t0",5);case 5:n++,t.next=3;break;case 8:return t.next=10,Promise.all(e);case 10:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)}),y(t,[{key:"requiredMipLevels",get:function(){return this.mipmaps?es.calcMipLevelsCount(this.width,this.height):1}},{key:"minFilter",get:function(){return this._minFilter},set:function(t){this._minFilter!==t&&(this._minFilter=t,this.propertyChanged(1))}},{key:"magFilter",get:function(){return this._magFilter},set:function(t){this._magFilter!==t&&(this._magFilter=t,this.propertyChanged(2))}},{key:"addressU",get:function(){return this._addressU},set:function(t){this._addressU!==t&&(this._addressU=t,this.propertyChanged(4))}},{key:"addressV",get:function(){return this._addressV},set:function(t){this._addressV!==t&&(this._addressV=t,this.propertyChanged(8))}},{key:"addressW",get:function(){return this._addressW},set:function(t){this.device.supportsVolumeTextures&&this._volume&&t!==this._addressW&&(this._addressW=t,this.propertyChanged(16))}},{key:"compareOnRead",get:function(){return this._compareOnRead},set:function(t){this._compareOnRead!==t&&(this._compareOnRead=t,this.propertyChanged(32))}},{key:"compareFunc",get:function(){return this._compareFunc},set:function(t){this._compareFunc!==t&&(this._compareFunc=t,this.propertyChanged(64))}},{key:"anisotropy",get:function(){return this._anisotropy},set:function(t){this._anisotropy!==t&&(this._anisotropy=t,this.propertyChanged(128))}},{key:"mipmaps",get:function(){return this._mipmaps},set:function(t){this._mipmaps!==t&&(this._mipmaps=t,this.device.isWebGPU,t&&(this._needsMipmapsUpload=!0))}},{key:"storage",get:function(){return this._storage}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"depth",get:function(){return this._depth}},{key:"format",get:function(){return this._format}},{key:"cubemap",get:function(){return this._cubemap}},{key:"gpuSize",get:function(){var t=this.pot&&this._mipmaps&&!(this._compressed&&1===this._levels.length);return es.calcGpuSize(this._width,this._height,this._depth,this._format,t,this._cubemap)}},{key:"array",get:function(){return this._arrayLength>0}},{key:"arrayLength",get:function(){return this._arrayLength}},{key:"volume",get:function(){return this._volume}},{key:"flipY",get:function(){return this._flipY},set:function(t){this._flipY!==t&&(this._flipY=t,this._needsUpload=!0)}},{key:"premultiplyAlpha",get:function(){return this._premultiplyAlpha},set:function(t){this._premultiplyAlpha!==t&&(this._premultiplyAlpha=t,this._needsUpload=!0)}},{key:"pot",get:function(){return _t.powerOfTwo(this._width)&&_t.powerOfTwo(this._height)}},{key:"encoding",get:function(){switch(this.type){case ai:return"rgbm";case oi:return"rgbe";case hi:return"rgbp";default:return this.format===ce||this.format===de||this.format===ue||this.format===fe?"linear":"srgb"}}}]),t}(),Ns=function(){function t(){this.bufferId=null}var e=t.prototype;return e.destroy=function(t){this.bufferId&&(t.gl.deleteBuffer(this.bufferId),this.bufferId=null)},e.loseContext=function(){this.bufferId=null},e.unlock=function(t,e,i,n){var s=t.gl;if(this.bufferId)s.bindBuffer(i,this.bufferId),s.bufferSubData(i,0,n);else{var r;switch(e){case 0:r=s.STATIC_DRAW;break;case 1:r=s.DYNAMIC_DRAW;break;case 2:r=s.STREAM_DRAW;break;case 3:r=t.isWebGL2?s.DYNAMIC_COPY:s.STATIC_DRAW}this.bufferId=s.createBuffer(),s.bindBuffer(i,this.bufferId),s.bufferData(i,n,r)}},y(t,[{key:"initialized",get:function(){return!!this.bufferId}}]),t}(),zs=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),s=0;se||n>e){var s=e/Math.max(i,n),r=Math.floor(i*s),a=Math.floor(n*s),o=document.createElement("canvas");return o.width=r,o.height=a,o.getContext("2d").drawImage(t,0,0,i,n,0,0,r,a),o}return t}var $s=function(){function t(){this._glTexture=null,this._glTarget=void 0,this._glFormat=void 0,this._glInternalFormat=void 0,this._glPixelType=void 0,this._glCreated=void 0,this.dirtyParameterFlags=0}var e=t.prototype;return e.destroy=function(t){if(this._glTexture){for(var e=0;et.maxCubeMapSize||h.height>t.maxCubeMapSize)&&(h=Qs(h,t.maxCubeMapSize),0===r&&(e._width=h.width,e._height=h.height)),t.setUnpackFlipY(!1),t.setUnpackPremultiplyAlpha(e._premultiplyAlpha),this._glCreated?i.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,0,0,this._glFormat,this._glPixelType,h):i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,this._glInternalFormat,this._glFormat,this._glPixelType,h)}}else for(s=1/Math.pow(2,r),o=0;o<6;o++)if(e._levelsUpdated[0][o]){var l=n[o];e._compressed?this._glCreated&&l?i.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,0,0,Math.max(e._width*s,1),Math.max(e._height*s,1),this._glInternalFormat,l):i.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,this._glInternalFormat,Math.max(e._width*s,1),Math.max(e._height*s,1),0,l):(t.setUnpackFlipY(!1),t.setUnpackPremultiplyAlpha(e._premultiplyAlpha),this._glCreated&&l?i.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,0,0,Math.max(e._width*s,1),Math.max(e._height*s,1),this._glFormat,this._glPixelType,l):i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+o,r,this._glInternalFormat,Math.max(e._width*s,1),Math.max(e._height*s,1),0,this._glFormat,this._glPixelType,l))}}else if(e._volume)e._compressed?i.compressedTexImage3D(i.TEXTURE_3D,r,this._glInternalFormat,Math.max(e._width*s,1),Math.max(e._height*s,1),Math.max(e._depth*s,1),0,n):(t.setUnpackFlipY(!1),t.setUnpackPremultiplyAlpha(e._premultiplyAlpha),i.texImage3D(i.TEXTURE_3D,r,this._glInternalFormat,Math.max(e._width*s,1),Math.max(e._height*s,1),Math.max(e._depth*s,1),0,this._glFormat,this._glPixelType,n));else if(e.array&&"object"==typeof n){if(e._arrayLength===n.length)if(e._compressed)for(var c=0;ct.maxTextureSize||n.height>t.maxTextureSize)&&(n=Qs(n,t.maxTextureSize),0===r&&(e._width=n.width,e._height=n.height));var d=n.width||n.videoWidth,f=n.height||n.videoHeight;t.setUnpackFlipY(e._flipY),t.setUnpackPremultiplyAlpha(e._premultiplyAlpha),this._glCreated&&e._width===d&&e._height===f?i.texSubImage2D(i.TEXTURE_2D,r,0,0,this._glFormat,this._glPixelType,n):(i.texImage2D(i.TEXTURE_2D,r,this._glInternalFormat,this._glFormat,this._glPixelType,n),0===r&&(e._width=d,e._height=f))}else s=1/Math.pow(2,r),e._compressed?this._glCreated&&n?i.compressedTexSubImage2D(i.TEXTURE_2D,r,0,0,Math.max(Math.floor(e._width*s),1),Math.max(Math.floor(e._height*s),1),this._glInternalFormat,n):i.compressedTexImage2D(i.TEXTURE_2D,r,this._glInternalFormat,Math.max(Math.floor(e._width*s),1),Math.max(Math.floor(e._height*s),1),0,n):(t.setUnpackFlipY(!1),t.setUnpackPremultiplyAlpha(e._premultiplyAlpha),this._glCreated&&n?i.texSubImage2D(i.TEXTURE_2D,r,0,0,Math.max(e._width*s,1),Math.max(e._height*s,1),this._glFormat,this._glPixelType,n):i.texImage2D(i.TEXTURE_2D,r,this._glInternalFormat,Math.max(e._width*s,1),Math.max(e._height*s,1),0,this._glFormat,this._glPixelType,n));e._mipmapsUploaded=0!==r}r++}else r++;if(e._needsUpload)if(e._cubemap)for(var p=0;p<6;p++)e._levelsUpdated[0][p]=!1;else e._levelsUpdated[0]=!1;!e._compressed&&e._mipmaps&&e._needsMipmapsUpload&&(e.pot||t.isWebGL2)&&1===e._levels.length&&(i.generateMipmap(this._glTarget),e._mipmapsUploaded=!0),e._gpuSize&&e.adjustVramSizeTracking(t._vram,-e._gpuSize),e._gpuSize=e.gpuSize,e.adjustVramSizeTracking(t._vram,e._gpuSize),this._glCreated=!0}},t}(),Js=function(){function t(t,e){this.msaaFB=void 0,this.resolveFB=void 0,this.msaaFB=t,this.resolveFB=e}return t.prototype.destroy=function(t){this.msaaFB&&(t.deleteRenderbuffer(this.msaaFB),this.msaaFB=null),this.resolveFB&&(t.deleteRenderbuffer(this.resolveFB),this.resolveFB=null)},t}(),tr=function(){function t(){this._glFrameBuffer=null,this._glDepthBuffer=null,this._glResolveFrameBuffer=null,this.colorMrtFramebuffers=null,this._glMsaaColorBuffers=[],this._glMsaaDepthBuffer=null,this.suppliedColorFramebuffer=void 0,this._isInitialized=!1}var e=t.prototype;return e.destroy=function(t){var e,i=t.gl;this._isInitialized=!1,this._glFrameBuffer&&(this._glFrameBuffer!==this.suppliedColorFramebuffer&&i.deleteFramebuffer(this._glFrameBuffer),this._glFrameBuffer=null),this._glDepthBuffer&&(i.deleteRenderbuffer(this._glDepthBuffer),this._glDepthBuffer=null),this._glResolveFrameBuffer&&(this._glResolveFrameBuffer!==this.suppliedColorFramebuffer&&i.deleteFramebuffer(this._glResolveFrameBuffer),this._glResolveFrameBuffer=null),this._glMsaaColorBuffers.forEach((function(t){i.deleteRenderbuffer(t)})),this._glMsaaColorBuffers.length=0,null==(e=this.colorMrtFramebuffers)||e.forEach((function(t){t.destroy(i)})),this.colorMrtFramebuffers=null,this._glMsaaDepthBuffer&&(i.deleteRenderbuffer(this._glMsaaDepthBuffer),this._glMsaaDepthBuffer=null),this.suppliedColorFramebuffer=void 0},e.init=function(t,e){var i=t.gl;this._isInitialized=!0;var n=[];if(void 0!==this.suppliedColorFramebuffer)this._glFrameBuffer=this.suppliedColorFramebuffer;else{var s,r,a,o;this._glFrameBuffer=i.createFramebuffer(),t.setFramebuffer(this._glFrameBuffer);for(var h=null!=(s=null==(r=e._colorBuffers)?void 0:r.length)?s:0,l=t.isWebGL2?i.COLOR_ATTACHMENT0:null!=(a=null==(o=t.extDrawBuffers)?void 0:o.COLOR_ATTACHMENT0_WEBGL)?a:i.COLOR_ATTACHMENT0,c=0;c1&&t.isWebGL2)){if(this._glDepthBuffer||(this._glDepthBuffer=i.createRenderbuffer()),i.bindRenderbuffer(i.RENDERBUFFER,this._glDepthBuffer),e._stencil)i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,this._glDepthBuffer);else{var f=t.isWebGL2?i.DEPTH_COMPONENT32F:i.DEPTH_COMPONENT16;i.renderbufferStorage(i.RENDERBUFFER,f,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,this._glDepthBuffer)}i.bindRenderbuffer(i.RENDERBUFFER,null)}}}if(t.isWebGL2&&e._samples>1){var p,m;this._glResolveFrameBuffer=this._glFrameBuffer,this._glFrameBuffer=i.createFramebuffer(),t.setFramebuffer(this._glFrameBuffer);var _=null!=(p=null==(m=e._colorBuffers)?void 0:m.length)?p:0;if(void 0!==this.suppliedColorFramebuffer){var g=i.createRenderbuffer();this._glMsaaColorBuffers.push(g);var v=7===t.backBufferFormat?i.RGBA8:i.RGB8;i.bindRenderbuffer(i.RENDERBUFFER,g),i.renderbufferStorageMultisample(i.RENDERBUFFER,e._samples,v,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,g)}else for(var y=0;y<_;++y){var x=e.getColorBuffer(y);if(x){var S=i.createRenderbuffer();this._glMsaaColorBuffers.push(S),i.bindRenderbuffer(i.RENDERBUFFER,S),i.renderbufferStorageMultisample(i.RENDERBUFFER,e._samples,x.impl._glInternalFormat,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+y,i.RENDERBUFFER,S)}}e._depth&&(this._glMsaaDepthBuffer||(this._glMsaaDepthBuffer=i.createRenderbuffer()),i.bindRenderbuffer(i.RENDERBUFFER,this._glMsaaDepthBuffer),e._stencil?(i.renderbufferStorageMultisample(i.RENDERBUFFER,e._samples,i.DEPTH24_STENCIL8,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,this._glMsaaDepthBuffer)):(i.renderbufferStorageMultisample(i.RENDERBUFFER,e._samples,i.DEPTH_COMPONENT32F,e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,this._glMsaaDepthBuffer))),_>1&&(this._createMsaaMrtFramebuffers(t,e,_),t.setFramebuffer(this._glFrameBuffer),t.drawBuffers(n))}},e._createMsaaMrtFramebuffers=function(t,e,i){var n=t.gl;this.colorMrtFramebuffers=[];for(var s=0;s=0&&!(n>0&&"/"===t[n-1]);){var s=t.indexOf(";",n),r=t.lastIndexOf(" ",s),a=t.substring(r+1,s),o=or[a];void 0!==o?e[a]=o:(e[a]="ATTR"+i,i++),n=t.indexOf("attribute",n+1)}return e},t}(),lr=function(){function t(){this.renderVersion=void 0,this.queries=[]}return t.prototype.destroy=function(t){this.queries.forEach((function(e){return t.deleteQuery(e)})),this.queries=null},t}(),cr=function(t){function e(e){var i;return(i=t.call(this)||this).device=void 0,i.freeQueries=[],i.frameQueries=[],i.previousFrameQueries=[],i.timings=[],i.device=e,i.ext=e.extDisjointTimerQuery,i}S(e,t);var i=e.prototype;return i.destroy=function(){var t=this;this.freeQueries.forEach((function(e){return t.device.gl.deleteQuery(e)})),this.frameQueries.forEach((function(e){return t.device.gl.deleteQuery(e)})),this.previousFrameQueries.forEach((function(e){return e.destroy(t.device.gl)})),this.freeQueries=null,this.frameQueries=null,this.previousFrameQueries=null},i.loseContext=function(){t.prototype.loseContext.call(this),this.freeQueries=[],this.frameQueries=[],this.previousFrameQueries=[]},i.restoreContext=function(){this.ext=this.device.extDisjointTimerQuery},i.getQuery=function(){var t;return null!=(t=this.freeQueries.pop())?t:this.device.gl.createQuery()},i.start=function(t){if(this.ext){var e=this.getSlot(t),i=this.getQuery();return this.frameQueries[e]=i,this.device.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,i),e}},i.end=function(t){void 0!==t&&this.device.gl.endQuery(this.ext.TIME_ELAPSED_EXT)},i.frameStart=function(){this.processEnableRequest(),this._enabled&&(this.frameGPUMarkerSlot=this.start("GpuFrame"))},i.frameEnd=function(){this._enabled&&this.end(this.frameGPUMarkerSlot)},i.request=function(){var e=this;if(this._enabled){var i=this.ext,n=this.device.gl,s=this.device.renderVersion,r=this.frameQueries;if(r.length>0){this.frameQueries=[];var a=new lr;a.queries=r,a.renderVersion=s,this.previousFrameQueries.push(a)}if(this.previousFrameQueries.length>0){var o=this.previousFrameQueries[0],h=o.queries,l=h[h.length-1],c=n.getQueryParameter(l,n.QUERY_RESULT_AVAILABLE),u=n.getParameter(i.GPU_DISJOINT_EXT);if(c&&!u){this.previousFrameQueries.shift();var d=this.timings;d.length=0;for(var f=0;f=120||115===l)&&(i.antialias=!1)}}var c=null;if(s.backBufferAntialias=null!=(n=i.antialias)&&n,i.antialias=!1,i.gl)c=i.gl;else for(var u=void 0===i.preferWebGl2||i.preferWebGl2?["webgl2","webgl","experimental-webgl"]:["webgl","experimental-webgl"],d=0;d0;var S=s.vertexUniformsCount;return S-=16,S-=8,S-=1,S-=16,s.boneLimit=Math.floor(S/3),s.boneLimit=Math.min(s.boneLimit,128),"Mali-450 MP"===s.unmaskedRenderer&&(s.boneLimit=34),s.constantTexSource=s.scope.resolve("source"),s.extTextureFloat?s.isWebGL2?s.textureFloatRenderable=!!s.extColorBufferFloat:s.textureFloatRenderable=pr(c,c.FLOAT):s.textureFloatRenderable=!1,s.extColorBufferHalfFloat?s.textureHalfFloatRenderable=!!s.extColorBufferHalfFloat:s.extTextureHalfFloat?s.isWebGL2?s.textureHalfFloatRenderable=!!s.extColorBufferFloat:s.textureHalfFloatRenderable=pr(c,s.extTextureHalfFloat.HALF_FLOAT_OES):s.textureHalfFloatRenderable=!1,s.supportsMorphTargetTexturesCore="highp"===s.maxPrecision&&s.maxVertexTextures>=2,s.supportsDepthShadow=s.isWebGL2,s._textureFloatHighPrecision=void 0,s._textureHalfFloatUpdatable=void 0,s.areaLightLutFormat=7,s.extTextureHalfFloat&&s.textureHalfFloatUpdatable&&s.extTextureHalfFloatLinear?s.areaLightLutFormat=ue:s.extTextureFloat&&s.extTextureFloatLinear&&(s.areaLightLutFormat=fe),s.postInit(),s}S(e,t);var i,n=e.prototype;return n.postInit=function(){t.prototype.postInit.call(this),this.gpuProfiler=new cr(this)},n.destroy=function(){t.prototype.destroy.call(this);var e=this.gl;this.isWebGL2&&this.feedback&&e.deleteTransformFeedback(this.feedback),this.clearVertexArrayObjectCache(),this.canvas.removeEventListener("webglcontextlost",this._contextLostHandler,!1),this.canvas.removeEventListener("webglcontextrestored",this._contextRestoredHandler,!1),this._contextLostHandler=null,this._contextRestoredHandler=null,this.gl=null,t.prototype.postDestroy.call(this)},n.createBackbuffer=function(t){this.supportsStencil=this.initOptions.stencil,this.backBuffer=new ln({name:"WebglFramebuffer",graphicsDevice:this,depth:this.initOptions.depth,stencil:this.supportsStencil,samples:this.samples}),this.backBuffer.impl.suppliedColorFramebuffer=t},n.updateBackbufferFormat=function(t){var e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t);var i=this.gl.getParameter(this.gl.ALPHA_BITS);this.backBufferFormat=i?7:6},n.updateBackbuffer=function(){var t=this.canvas.width!==this.backBufferSize.x||this.canvas.height!==this.backBufferSize.y;(this._defaultFramebufferChanged||t)&&(this._defaultFramebufferChanged&&this.updateBackbufferFormat(this._defaultFramebuffer),this._defaultFramebufferChanged=!1,this.backBufferSize.set(this.canvas.width,this.canvas.height),this.backBuffer.destroy(),this.createBackbuffer(this._defaultFramebuffer))},n.createVertexBufferImpl=function(t,e){return new zs},n.createIndexBufferImpl=function(t){return new Vs(t)},n.createShaderImpl=function(t){return new Zs(t)},n.createTextureImpl=function(t){return new $s},n.createRenderTargetImpl=function(t){return new tr},n.getPrecision=function(){var t=this.gl,e="highp";if(t.getShaderPrecisionFormat){var i=t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT),n=t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT),s=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT),r=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT);if(i&&n&&s&&r){var a=i.precision>0&&s.precision>0,o=n.precision>0&&r.precision>0;a||(e=o?"mediump":"lowp")}}return e},n.getExtension=function(){for(var t=0;t0&&t.fullSizeClearRect&&s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,ur)}null!=(n=t.colorOps)&&n.resolve&&this.isWebGL2&&t.samples>1&&e.autoResolve&&e.resolve(!0,!1);for(var o=0;o1&&t.autoResolve&&t.resolve();var e=t._colorBuffer;e&&e.impl._glTexture&&e.mipmaps&&(e.pot||this.isWebGL2)&&(this.activeTexture(this.maxCombinedTextures-1),this.bindTexture(e),this.gl.generateMipmap(e.impl._glTarget))}},n.setUnpackFlipY=function(t){if(this.unpackFlipY!==t){this.unpackFlipY=t;var e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t)}},n.setUnpackPremultiplyAlpha=function(t){if(this.unpackPremultiplyAlpha!==t){this.unpackPremultiplyAlpha=t;var e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t)}},n.activeTexture=function(t){this.textureUnit!==t&&(this.gl.activeTexture(this.gl.TEXTURE0+t),this.textureUnit=t)},n.bindTexture=function(t){var e=t.impl,i=e._glTarget,n=e._glTexture,s=this.textureUnit,r=this.targetToSlot[i];this.textureUnits[s][r]!==n&&(this.gl.bindTexture(i,n),this.textureUnits[s][r]=n)},n.bindTextureOnUnit=function(t,e){var i=t.impl,n=i._glTarget,s=i._glTexture,r=this.targetToSlot[n];this.textureUnits[e][r]!==s&&(this.activeTexture(e),this.gl.bindTexture(n,s),this.textureUnits[e][r]=s)},n.setTextureParameters=function(t){var e=this.gl,i=t.impl.dirtyParameterFlags,n=t.impl._glTarget;if(1&i){var s=t._minFilter;(!t.pot&&!this.isWebGL2||!t._mipmaps||t._compressed&&1===t._levels.length)&&(2===s||3===s?s=0:4!==s&&5!==s||(s=1)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,this.glFilter[s])}if(2&i&&e.texParameteri(n,e.TEXTURE_MAG_FILTER,this.glFilter[t._magFilter]),4&i&&(this.isWebGL2?e.texParameteri(n,e.TEXTURE_WRAP_S,this.glAddress[t._addressU]):e.texParameteri(n,e.TEXTURE_WRAP_S,this.glAddress[t.pot?t._addressU:1])),8&i&&(this.isWebGL2?e.texParameteri(n,e.TEXTURE_WRAP_T,this.glAddress[t._addressV]):e.texParameteri(n,e.TEXTURE_WRAP_T,this.glAddress[t.pot?t._addressV:1])),16&i&&this.isWebGL2&&e.texParameteri(n,e.TEXTURE_WRAP_R,this.glAddress[t._addressW]),32&i&&this.isWebGL2&&e.texParameteri(n,e.TEXTURE_COMPARE_MODE,t._compareOnRead?e.COMPARE_REF_TO_TEXTURE:e.NONE),64&i&&this.isWebGL2&&e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,this.glComparison[t._compareFunc]),128&i){var r=this.extTextureFilterAnisotropic;r&&e.texParameterf(n,r.TEXTURE_MAX_ANISOTROPY_EXT,_t.clamp(Math.round(t._anisotropy),1,this.maxAnisotropy))}},n.setTexture=function(t,e){var i=t.impl;i._glTexture||i.initialize(this,t),i.dirtyParameterFlags>0||t._needsUpload||t._needsMipmapsUpload?(this.activeTexture(e),this.bindTexture(t),i.dirtyParameterFlags&&(this.setTextureParameters(t),i.dirtyParameterFlags=0),(t._needsUpload||t._needsMipmapsUpload)&&(i.upload(this,t),t._needsUpload=!1,t._needsMipmapsUpload=!1)):this.bindTextureOnUnit(t,e)},n.createVertexArray=function(t){var e,i,n=t.length>1;if(n){e="";for(var s=0;s0?u.drawElementsInstanced(S,b,T,A,e):u.drawElements(S,b,T,A)}else{var C=t.base;e>0?u.drawArraysInstanced(S,C,b,e):u.drawArrays(S,C,b)}this.isWebGL2&&this.transformFeedbackBuffer&&(u.endTransformFeedback(),u.bindBufferBase(u.TRANSFORM_FEEDBACK_BUFFER,0,null)),this._drawCallsPerFrame++}},n.clear=function(t){var e,i=this.defaultClearOptions,n=null!=(e=(t=t||i).flags)?e:i.flags;if(0!==n){var s=this.gl;if(1&n){var r,a=null!=(r=t.color)?r:i.color,o=a[0],h=a[1],l=a[2],c=a[3],u=this.clearColor;o===u.r&&h===u.g&&l===u.b&&c===u.a||(this.gl.clearColor(o,h,l,c),this.clearColor.set(o,h,l,c)),this.setBlendState(Gi.NOBLEND)}if(2&n){var d,f=null!=(d=t.depth)?d:i.depth;f!==this.clearDepth&&(this.gl.clearDepth(f),this.clearDepth=f),this.setDepthState(Hi.WRITEDEPTH)}if(4&n){var p,m=null!=(p=t.stencil)?p:i.stencil;m!==this.clearStencil&&(this.gl.clearStencil(m),this.clearStencil=m)}s.clear(this.glClearFlag[n])}},n.submit=function(){this.gl.flush()},n.readPixels=function(t,e,i,n,s){var r=this.gl;r.readPixels(t,e,i,n,r.RGBA,r.UNSIGNED_BYTE,s)},n.readPixelsAsync=(i=g(m().mark((function t(e,i,n,s,r){var a,o,h,l,c,u,d,f,p,_=this;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(l=this.gl,this.isWebGL2){t.next=4;break}return this.readPixels(e,i,n,s,r),t.abrupt("return");case 4:return c=function(t,e){var i=l.fenceSync(l.SYNC_GPU_COMMANDS_COMPLETE,0);return _.submit(),new Promise((function(n,s){!function r(){var a=l.clientWaitSync(i,t,0);a===l.WAIT_FAILED?(l.deleteSync(i),s(new Error("webgl clientWaitSync sync failed"))):a===l.TIMEOUT_EXPIRED?setTimeout(r,e):(l.deleteSync(i),n())}()}))},u=null==(a=this.renderTarget.colorBuffer)?void 0:a.impl,d=null!=(o=null==u?void 0:u._glFormat)?o:l.RGBA,f=null!=(h=null==u?void 0:u._glPixelType)?h:l.UNSIGNED_BYTE,p=l.createBuffer(),l.bindBuffer(l.PIXEL_PACK_BUFFER,p),l.bufferData(l.PIXEL_PACK_BUFFER,r.byteLength,l.STREAM_READ),l.readPixels(e,i,n,s,d,f,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),t.next=15,c(0,20);case 15:l.bindBuffer(l.PIXEL_PACK_BUFFER,p),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,r),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),l.deleteBuffer(p);case 19:case"end":return t.stop()}}),t,this)}))),function(t,e,n,s,r){return i.apply(this,arguments)}),n.setAlphaToCoverage=function(t){this.isWebGL1||this.alphaToCoverage!==t&&(this.alphaToCoverage=t,t?this.gl.enable(this.gl.SAMPLE_ALPHA_TO_COVERAGE):this.gl.disable(this.gl.SAMPLE_ALPHA_TO_COVERAGE))},n.setTransformFeedbackBuffer=function(t){if(this.transformFeedbackBuffer!==t&&(this.transformFeedbackBuffer=t,this.isWebGL2)){var e=this.gl;t?(this.feedback||(this.feedback=e.createTransformFeedback()),e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,this.feedback)):e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null)}},n.setRaster=function(t){this.raster!==t&&(this.raster=t,this.isWebGL2&&(t?this.gl.disable(this.gl.RASTERIZER_DISCARD):this.gl.enable(this.gl.RASTERIZER_DISCARD)))},n.setDepthBias=function(t){this.depthBiasEnabled!==t&&(this.depthBiasEnabled=t,t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL))},n.setDepthBiasValues=function(t,e){this.gl.polygonOffset(e,t)},n.setStencilTest=function(t){if(this.stencil!==t){var e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.stencil=t}},n.setStencilFunc=function(t,e,i){this.stencilFuncFront===t&&this.stencilRefFront===e&&this.stencilMaskFront===i&&this.stencilFuncBack===t&&this.stencilRefBack===e&&this.stencilMaskBack===i||(this.gl.stencilFunc(this.glComparison[t],e,i),this.stencilFuncFront=this.stencilFuncBack=t,this.stencilRefFront=this.stencilRefBack=e,this.stencilMaskFront=this.stencilMaskBack=i)},n.setStencilFuncFront=function(t,e,i){if(this.stencilFuncFront!==t||this.stencilRefFront!==e||this.stencilMaskFront!==i){var n=this.gl;n.stencilFuncSeparate(n.FRONT,this.glComparison[t],e,i),this.stencilFuncFront=t,this.stencilRefFront=e,this.stencilMaskFront=i}},n.setStencilFuncBack=function(t,e,i){if(this.stencilFuncBack!==t||this.stencilRefBack!==e||this.stencilMaskBack!==i){var n=this.gl;n.stencilFuncSeparate(n.BACK,this.glComparison[t],e,i),this.stencilFuncBack=t,this.stencilRefBack=e,this.stencilMaskBack=i}},n.setStencilOperation=function(t,e,i,n){this.stencilFailFront===t&&this.stencilZfailFront===e&&this.stencilZpassFront===i&&this.stencilFailBack===t&&this.stencilZfailBack===e&&this.stencilZpassBack===i||(this.gl.stencilOp(this.glStencilOp[t],this.glStencilOp[e],this.glStencilOp[i]),this.stencilFailFront=this.stencilFailBack=t,this.stencilZfailFront=this.stencilZfailBack=e,this.stencilZpassFront=this.stencilZpassBack=i),this.stencilWriteMaskFront===n&&this.stencilWriteMaskBack===n||(this.gl.stencilMask(n),this.stencilWriteMaskFront=n,this.stencilWriteMaskBack=n)},n.setStencilOperationFront=function(t,e,i,n){this.stencilFailFront===t&&this.stencilZfailFront===e&&this.stencilZpassFront===i||(this.gl.stencilOpSeparate(this.gl.FRONT,this.glStencilOp[t],this.glStencilOp[e],this.glStencilOp[i]),this.stencilFailFront=t,this.stencilZfailFront=e,this.stencilZpassFront=i),this.stencilWriteMaskFront!==n&&(this.gl.stencilMaskSeparate(this.gl.FRONT,n),this.stencilWriteMaskFront=n)},n.setStencilOperationBack=function(t,e,i,n){this.stencilFailBack===t&&this.stencilZfailBack===e&&this.stencilZpassBack===i||(this.gl.stencilOpSeparate(this.gl.BACK,this.glStencilOp[t],this.glStencilOp[e],this.glStencilOp[i]),this.stencilFailBack=t,this.stencilZfailBack=e,this.stencilZpassBack=i),this.stencilWriteMaskBack!==n&&(this.gl.stencilMaskSeparate(this.gl.BACK,n),this.stencilWriteMaskBack=n)},n.setBlendState=function(t){var e=this.blendState;if(!e.equals(t)){var i=this.gl,n=t.blend,s=t.colorOp,r=t.alphaOp,a=t.colorSrcFactor,o=t.colorDstFactor,h=t.alphaSrcFactor,l=t.alphaDstFactor;if(e.blend!==n&&(n?i.enable(i.BLEND):i.disable(i.BLEND)),e.colorOp!==s||e.alphaOp!==r){var c=this.glBlendEquation;i.blendEquationSeparate(c[s],c[r])}e.colorSrcFactor===a&&e.colorDstFactor===o&&e.alphaSrcFactor===h&&e.alphaDstFactor===l||i.blendFuncSeparate(this.glBlendFunctionColor[a],this.glBlendFunctionColor[o],this.glBlendFunctionAlpha[h],this.glBlendFunctionAlpha[l]),e.allWrite!==t.allWrite&&this.gl.colorMask(t.redWrite,t.greenWrite,t.blueWrite,t.alphaWrite),e.copy(t)}},n.setBlendColor=function(t,e,i,n){var s=this.blendColor;t===s.r&&e===s.g&&i===s.b&&n===s.a||(this.gl.blendColor(t,e,i,n),s.set(t,e,i,n))},n.setStencilState=function(t,e){t||e?(this.setStencilTest(!0),t===e?(this.setStencilFunc(t.func,t.ref,t.readMask),this.setStencilOperation(t.fail,t.zfail,t.zpass,t.writeMask)):(null!=t||(t=an.DEFAULT),this.setStencilFuncFront(t.func,t.ref,t.readMask),this.setStencilOperationFront(t.fail,t.zfail,t.zpass,t.writeMask),null!=e||(e=an.DEFAULT),this.setStencilFuncBack(e.func,e.ref,e.readMask),this.setStencilOperationBack(e.fail,e.zfail,e.zpass,e.writeMask))):this.setStencilTest(!1)},n.setDepthState=function(t){var e=this.depthState;if(!e.equals(t)){var i=this.gl,n=t.write;e.write!==n&&i.depthMask(n);var s=t.func,r=t.test;!r&&n&&(r=!0,s=7),e.func!==s&&i.depthFunc(this.glComparison[s]),e.test!==r&&(r?i.enable(i.DEPTH_TEST):i.disable(i.DEPTH_TEST)),e.copy(t)}},n.setCullMode=function(t){if(this.cullMode!==t){if(t===he)this.gl.disable(this.gl.CULL_FACE);else{this.cullMode===he&&this.gl.enable(this.gl.CULL_FACE);var e=this.glCull[t];this.cullFace!==e&&(this.gl.cullFace(e),this.cullFace=e)}this.cullMode=t}},n.setShader=function(t){if(t!==this.shader){if(t.failed)return!1;if(!t.ready&&!t.impl.finalize(this,t))return t.failed=!0,!1;this.shader=t,this.gl.useProgram(t.impl.glProgram),this.attributesInvalidated=!0}return!0},n.clearVertexArrayObjectCache=function(){var t=this.gl;this._vaoMap.forEach((function(e,i,n){t.deleteVertexArray(e)})),this._vaoMap.clear()},y(e,[{key:"extDisjointTimerQuery",get:function(){return this._extDisjointTimerQuery||this.isWebGL2&&(this._extDisjointTimerQuery=this.getExtension("EXT_disjoint_timer_query_webgl2","EXT_disjoint_timer_query")),this._extDisjointTimerQuery}},{key:"defaultFramebuffer",get:function(){return this._defaultFramebuffer},set:function(t){this._defaultFramebuffer!==t&&(this._defaultFramebuffer=t,this._defaultFramebufferChanged=!0)}},{key:"fullscreen",get:function(){return!!document.fullscreenElement},set:function(t){t?this.gl.canvas.requestFullscreen():document.exitFullscreen()}},{key:"textureFloatHighPrecision",get:function(){return void 0===this._textureFloatHighPrecision&&(this._textureFloatHighPrecision=function(t){if(!t.textureFloatRenderable)return!1;var e=new vs(t,hr.createDefinition(t,{name:"ptest1",vertexCode:dr,fragmentCode:"\nvoid main(void) { \n\tgl_FragColor = vec4(2147483648.0);\n}\n"})),i=new vs(t,hr.createDefinition(t,{name:"ptest2",vertexCode:dr,fragmentCode:"\nuniform sampler2D source;\nvec4 packFloat(float depth) {\n\tconst vec4 bit_shift = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0);\n\tconst vec4 bit_mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);\n\tvec4 res = mod(depth * bit_shift * vec4(255), vec4(256) ) / vec4(255);\n\tres -= res.xxyz * bit_mask;\n\treturn res;\n}\nvoid main(void) {\n\tfloat c = texture2D(source, vec2(0.0)).r;\n\tfloat diff = abs(c - 2147483648.0) / 2147483648.0;\n\tgl_FragColor = packFloat(diff);\n}\n"})),n={format:fe,width:1,height:1,mipmaps:!1,minFilter:0,magFilter:0,name:"testFHP"},s=new Us(t,n),r=new ln({colorBuffer:s,depth:!1});fr(t,r,e),n.format=7;var a=new Us(t,n),o=new ln({colorBuffer:a,depth:!1});t.constantTexSource.setValue(s),fr(t,o,i);var h=t.activeFramebuffer;t.setFramebuffer(o.impl._glFrameBuffer);var l=new Uint8Array(4);t.readPixels(0,0,1,1,l),t.setFramebuffer(h);var c=l[0]/255/16777216+l[1]/255/65536+l[2]/255/256+l[3]/255;return s.destroy(),r.destroy(),a.destroy(),o.destroy(),e.destroy(),i.destroy(),0===c}(this)),this._textureFloatHighPrecision}},{key:"textureHalfFloatUpdatable",get:function(){return void 0===this._textureHalfFloatUpdatable&&(this.isWebGL2?this._textureHalfFloatUpdatable=!0:this._textureHalfFloatUpdatable=function(t,e){var i=!0,n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE);var s=new Uint16Array(16);return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,2,2,0,t.RGBA,e,s),t.getError()!==t.NO_ERROR&&(i=!1,console.log("Above error related to HALF_FLOAT_OES can be ignored, it was triggered by testing half float texture support")),t.bindTexture(t.TEXTURE_2D,null),t.deleteTexture(n),i}(this.gl,this.extTextureHalfFloat.HALF_FLOAT_OES)),this._textureHalfFloatUpdatable}}]),e}(on),_r=function(){function t(){}return t.prototype.unlock=function(t){},t}(),gr=function(){function t(){}var e=t.prototype;return e.destroy=function(t){},e.init=function(t,e){},e.loseContext=function(){},e.resolve=function(t,e,i,n){},t}(),vr=function(){function t(){}var e=t.prototype;return e.destroy=function(t){},e.loseContext=function(){},e.restoreContext=function(t,e){},t}(),yr=function(){function t(){}var e=t.prototype;return e.destroy=function(t){},e.propertyChanged=function(t){},e.loseContext=function(){},t}(),xr=function(){function t(){}var e=t.prototype;return e.destroy=function(t){},e.unlock=function(t){},t}(),Sr=function(t){function e(e,i){var n;return void 0===i&&(i={}),i=(n=t.call(this,e,i)||this).initOptions,n.isNull=!0,n._deviceType=Ci,n.samples=1,n}S(e,t);var i=e.prototype;return i.destroy=function(){t.prototype.destroy.call(this)},i.initDeviceCaps=function(){this.disableParticleSystem=!0,this.precision="highp",this.maxPrecision="highp",this.maxSamples=4,this.maxTextures=16,this.maxTextureSize=4096,this.maxCubeMapSize=4096,this.maxVolumeSize=4096,this.maxColorAttachments=8,this.maxPixelRatio=1,this.maxAnisotropy=16,this.supportsInstancing=!0,this.supportsUniformBuffers=!1,this.supportsVolumeTextures=!0,this.supportsBoneTextures=!0,this.supportsMorphTargetTexturesCore=!0,this.supportsAreaLights=!0,this.supportsDepthShadow=!0,this.supportsGpuParticles=!1,this.supportsMrt=!0,this.extUintElement=!0,this.extTextureFloat=!0,this.textureFloatRenderable=!0,this.extTextureHalfFloat=!0,this.textureHalfFloatRenderable=!0,this.textureHalfFloatUpdatable=!0,this.boneLimit=1024,this.supportsImageBitmap=!0,this.extStandardDerivatives=!0,this.extBlendMinmax=!0,this.areaLightLutFormat=7,this.supportsTextureFetch=!0},i.postInit=function(){t.prototype.postInit.call(this)},i.frameStart=function(){t.prototype.frameStart.call(this)},i.frameEnd=function(){t.prototype.frameEnd.call(this)},i.createVertexBufferImpl=function(t,e){return new xr(t,e)},i.createIndexBufferImpl=function(t){return new _r(t)},i.createShaderImpl=function(t){return new vr(t)},i.createTextureImpl=function(t){return new yr(t)},i.createRenderTargetImpl=function(t){return new gr(t)},i.draw=function(t,e,i){},i.setShader=function(t){return!0},i.setBlendState=function(t){},i.setDepthState=function(t){},i.setStencilState=function(t,e){},i.setBlendColor=function(t,e,i,n){},i.setCullMode=function(t){},i.setAlphaToCoverage=function(t){},i.initializeContextCaches=function(){t.prototype.initializeContextCaches.call(this)},i.clear=function(t){},i.setDepthBias=function(t){},i.setDepthBiasValues=function(t,e){},i.setViewport=function(t,e,i,n){},i.setScissor=function(t,e,i,n){},i.copyRenderTarget=function(t,e,i,n){return!0},e}(on);var br=function(){function t(t,e){this.shader=null,this.device=t,this.shader=e,t.supportsCompute&&(this.impl=t.createComputeImpl(this))}return t.prototype.dispatch=function(t,e,i){var n;null==(n=this.impl)||n.dispatch(t,e,i)},t}(),wr=0,Tr=function(){function t(t,e,i,n,s){void 0===n&&(n=0),this.device=t,this.format=e,this.numIndices=i,this.usage=n,this.id=wr++,this.impl=t.createIndexBufferImpl(this);var r=Di[e];this.bytesPerIndex=r,this.numBytes=this.numIndices*r,s?this.setData(s):this.storage=new ArrayBuffer(this.numBytes),this.adjustVramSizeTracking(t._vram,this.numBytes),this.device.buffers.push(this)}var e=t.prototype;return e.destroy=function(){var t=this.device,e=t.buffers.indexOf(this);-1!==e&&t.buffers.splice(e,1),this.device.indexBuffer===this&&(this.device.indexBuffer=null),this.impl.initialized&&(this.impl.destroy(t),this.adjustVramSizeTracking(t._vram,-this.storage.byteLength))},e.adjustVramSizeTracking=function(t,e){t.ib+=e},e.loseContext=function(){this.impl.loseContext()},e.getFormat=function(){return this.format},e.getNumIndices=function(){return this.numIndices},e.lock=function(){return this.storage},e.unlock=function(){this.impl.unlock(this)},e.setData=function(t){return t.byteLength===this.numBytes&&(this.storage=t,this.unlock(),!0)},e._lockTypedArray=function(){var t=this.lock();return 2===this.format?new Uint32Array(t):1===this.format?new Uint16Array(t):new Uint8Array(t)},e.writeData=function(t,e){var i=this._lockTypedArray();if(t.length>e)if(ArrayBuffer.isView(t))t=t.subarray(0,e),i.set(t);else for(var n=0;nthis.vertexBuffer.numVertices&&(i=this.vertexBuffer.numVertices);var s=n.numComponents;if(this.vertexBuffer.getFormat().interleaved)for(var r=0,a=0;ai*s){var o=i*s;if(ArrayBuffer.isView(e))e=e.subarray(0,o),n.array.set(e);else for(var h=0;h0?this.wheelDelta=1:i.deltaY<0&&(this.wheelDelta=-1)),sa()?(this.dx=i.movementX||i.webkitMovementX||i.mozMovementX||0,this.dy=i.movementY||i.webkitMovementY||i.mozMovementY||0):(this.dx=this.x-e._lastX,this.dy=this.y-e._lastY),"mousedown"===i.type||"mouseup"===i.type?this.button=i.button:this.button=-1,this.buttons=e._buttons.slice(0),this.element=i.target,this.ctrlKey=i.ctrlKey||!1,this.altKey=i.altKey||!1,this.shiftKey=i.shiftKey||!1,this.metaKey=i.metaKey||!1,this.event=i},aa=function(t){function e(e){var i;return(i=t.call(this)||this)._lastX=0,i._lastY=0,i._buttons=[!1,!1,!1],i._lastbuttons=[!1,!1,!1],i._upHandler=i._handleUp.bind(w(i)),i._downHandler=i._handleDown.bind(w(i)),i._moveHandler=i._handleMove.bind(w(i)),i._wheelHandler=i._handleWheel.bind(w(i)),i._contextMenuHandler=function(t){t.preventDefault()},i._target=null,i._attached=!1,i.attach(e),i}S(e,t),e.isPointerLocked=function(){return sa()};var i=e.prototype;return i.attach=function(t){if(this._target=t,!this._attached){this._attached=!0;var e=!!G.passiveEvents&&{passive:!1};window.addEventListener("mouseup",this._upHandler,e),window.addEventListener("mousedown",this._downHandler,e),window.addEventListener("mousemove",this._moveHandler,e),window.addEventListener("wheel",this._wheelHandler,e)}},i.detach=function(){if(this._attached){this._attached=!1,this._target=null;var t=!!G.passiveEvents&&{passive:!1};window.removeEventListener("mouseup",this._upHandler,t),window.removeEventListener("mousedown",this._downHandler,t),window.removeEventListener("mousemove",this._moveHandler,t),window.removeEventListener("wheel",this._wheelHandler,t)}},i.disableContextMenu=function(){this._target&&this._target.addEventListener("contextmenu",this._contextMenuHandler)},i.enableContextMenu=function(){this._target&&this._target.removeEventListener("contextmenu",this._contextMenuHandler)},i.enablePointerLock=function(t,e){if(document.body.requestPointerLock){t&&document.addEventListener("pointerlockchange",(function e(){t(),document.removeEventListener("pointerlockchange",e)}),!1),e&&document.addEventListener("pointerlockerror",(function t(){e(),document.removeEventListener("pointerlockerror",t)}),!1),document.body.requestPointerLock()}else e&&e()},i.disablePointerLock=function(t){if(document.exitPointerLock){t&&document.addEventListener("pointerlockchange",(function e(){t(),document.removeEventListener("pointerlockchange",e)}),!1),document.exitPointerLock()}},i.update=function(){this._lastbuttons[0]=this._buttons[0],this._lastbuttons[1]=this._buttons[1],this._lastbuttons[2]=this._buttons[2]},i.isPressed=function(t){return this._buttons[t]},i.wasPressed=function(t){return this._buttons[t]&&!this._lastbuttons[t]},i.wasReleased=function(t){return!this._buttons[t]&&this._lastbuttons[t]},i._handleUp=function(t){this._buttons[t.button]=!1;var e=new ra(this,t);e.event&&this.fire(Yr,e)},i._handleDown=function(t){this._buttons[t.button]=!0;var e=new ra(this,t);e.event&&this.fire(qr,e)},i._handleMove=function(t){var e=new ra(this,t);e.event&&(this.fire(jr,e),this._lastX=e.x,this._lastY=e.y)},i._handleWheel=function(t){var e=new ra(this,t);e.event&&this.fire(Kr,e)},i._getTargetCoords=function(t){var e=this._target.getBoundingClientRect(),i=Math.floor(e.left),n=Math.floor(e.top);return t.clientX=i+this._target.clientWidth||t.clientY=n+this._target.clientHeight?null:{x:t.clientX-i,y:t.clientY-n}},e}(P),oa=function(){function t(t,e){void 0===e&&(e={}),this._keyboard=e.keyboard||null,this._mouse=e.mouse||null,this._gamepads=e.gamepads||null,this._element=null,this._actions={},this._axes={},this._axesValues={},t&&this.attach(t)}var e=t.prototype;return e.attach=function(t){this._element=t,this._keyboard&&this._keyboard.attach(t),this._mouse&&this._mouse.attach(t)},e.detach=function(){this._keyboard&&this._keyboard.detach(),this._mouse&&this._mouse.detach(),this._element=null},e.disableContextMenu=function(){this._mouse||this._enableMouse(),this._mouse.disableContextMenu()},e.enableContextMenu=function(){this._mouse||this._enableMouse(),this._mouse.enableContextMenu()},e.update=function(t){for(var e in this._keyboard&&this._keyboard.update(),this._mouse&&this._mouse.update(),this._gamepads&&this._gamepads.update(),this._axesValues={},this._axes)this._axesValues[e]=[]},e.appendAction=function(t,e){this._actions[t]=this._actions[t]||[],this._actions[t].push(e)},e.registerKeys=function(t,e){if(this._keyboard||this._enableKeyboard(),this._actions[t])throw new Error("Action: "+t+" already registered");if(void 0===e)throw new Error("Invalid button");e.length||(e=[e]),this.appendAction(t,{type:Wr,keys:e})},e.registerMouse=function(t,e){if(this._mouse||this._enableMouse(),void 0===e)throw new Error("Invalid button");this.appendAction(t,{type:Hr,button:e})},e.registerPadButton=function(t,e,i){if(void 0===i)throw new Error("Invalid button");this.appendAction(t,{type:Xr,button:i,pad:e})},e.registerAxis=function(t){var e=t.name;this._axes[e]||(this._axes[e]=[]);var i=this._axes[e].push(e);(t=t||{}).pad=t.pad||0;var n=function(n,s,r,a){switch(s){case"mousex":n._mouse.on(jr,(function(t){n._axesValues[e][i]=t.dx/10}));break;case"mousey":n._mouse.on(jr,(function(t){n._axesValues[e][i]=t.dy/10}));break;case"key":n._axes[e].push((function(){return n._keyboard.isPressed(a)?r:0}));break;case"padrx":n._axes[e].push((function(){return n._gamepads.getAxis(t.pad,2)}));break;case"padry":n._axes[e].push((function(){return n._gamepads.getAxis(t.pad,3)}));break;case"padlx":n._axes[e].push((function(){return n._gamepads.getAxis(t.pad,0)}));break;case"padly":n._axes[e].push((function(){return n._gamepads.getAxis(t.pad,1)}));break;default:throw new Error("Unknown axis")}};n(this,t.positive,1,t.positiveKey),(t.negativeKey||t.negative!==t.positive)&&n(this,t.negative,-1,t.negativeKey)},e.isPressed=function(t){if(!this._actions[t])return!1;for(var e=this._actions[t].length,i=0;iMath.abs(e)&&(e=s)}else this._axesValues[t]&&Math.abs(this._axesValues[t][n])>Math.abs(e)&&(e=this._axesValues[t][n]);return e},e._enableMouse=function(){if(this._mouse=new aa,!this._element)throw new Error("Controller must be attached to an Element");this._mouse.attach(this._element)},e._enableKeyboard=function(){if(this._keyboard=new na,!this._element)throw new Error("Controller must be attached to an Element");this._keyboard.attach(this._element)},t}(),ha=Object.freeze([]),la=function(){return ha};"undefined"!=typeof navigator&&(la=(navigator.getGamepads||navigator.webkitGetGamepads||la).bind(navigator));var ca={buttons:{PAD_FACE_1:0,PAD_FACE_2:1,PAD_FACE_3:2,PAD_FACE_4:3,PAD_L_SHOULDER_1:4,PAD_R_SHOULDER_1:5,PAD_L_SHOULDER_2:6,PAD_R_SHOULDER_2:7,PAD_SELECT:8,PAD_START:9,PAD_L_STICK_BUTTON:10,PAD_R_STICK_BUTTON:11,PAD_UP:12,PAD_DOWN:13,PAD_LEFT:14,PAD_RIGHT:15,PAD_VENDOR:16,XRPAD_TRIGGER:0,XRPAD_SQUEEZE:1,XRPAD_TOUCHPAD_BUTTON:2,XRPAD_STICK_BUTTON:3,XRPAD_A:4,XRPAD_B:5},axes:{PAD_L_STICK_X:0,PAD_L_STICK_Y:1,PAD_R_STICK_X:2,PAD_R_STICK_Y:3,XRPAD_TOUCHPAD_X:0,XRPAD_TOUCHPAD_Y:1,XRPAD_STICK_X:2,XRPAD_STICK_Y:3}},ua={DEFAULT:{buttons:["PAD_FACE_1","PAD_FACE_2","PAD_FACE_3","PAD_FACE_4","PAD_L_SHOULDER_1","PAD_R_SHOULDER_1","PAD_L_SHOULDER_2","PAD_R_SHOULDER_2","PAD_SELECT","PAD_START","PAD_L_STICK_BUTTON","PAD_R_STICK_BUTTON","PAD_UP","PAD_DOWN","PAD_LEFT","PAD_RIGHT","PAD_VENDOR"],axes:["PAD_L_STICK_X","PAD_L_STICK_Y","PAD_R_STICK_X","PAD_R_STICK_Y"]},DEFAULT_DUAL:{buttons:["PAD_FACE_1","PAD_FACE_2","PAD_FACE_3","PAD_FACE_4","PAD_L_SHOULDER_1","PAD_R_SHOULDER_1","PAD_L_SHOULDER_2","PAD_R_SHOULDER_2","PAD_SELECT","PAD_START","PAD_L_STICK_BUTTON","PAD_R_STICK_BUTTON","PAD_VENDOR"],axes:["PAD_L_STICK_X","PAD_L_STICK_Y","PAD_R_STICK_X","PAD_R_STICK_Y"],synthesizedButtons:{PAD_UP:{axis:0,min:0,max:1},PAD_DOWN:{axis:0,min:-1,max:0},PAD_LEFT:{axis:0,min:-1,max:0},PAD_RIGHT:{axis:0,min:0,max:1}}},PS3:{buttons:["PAD_FACE_1","PAD_FACE_2","PAD_FACE_4","PAD_FACE_3","PAD_L_SHOULDER_1","PAD_R_SHOULDER_1","PAD_L_SHOULDER_2","PAD_R_SHOULDER_2","PAD_SELECT","PAD_START","PAD_L_STICK_BUTTON","PAD_R_STICK_BUTTON","PAD_UP","PAD_DOWN","PAD_LEFT","PAD_RIGHT","PAD_VENDOR"],axes:["PAD_L_STICK_X","PAD_L_STICK_Y","PAD_R_STICK_X","PAD_R_STICK_Y"],mapping:"standard"},DEFAULT_XR:{buttons:["XRPAD_TRIGGER","XRPAD_SQUEEZE","XRPAD_TOUCHPAD_BUTTON","XRPAD_STICK_BUTTON","XRPAD_A","XRPAD_B"],axes:["XRPAD_TOUCHPAD_X","XRPAD_TOUCHPAD_Y","XRPAD_STICK_X","XRPAD_STICK_Y"],mapping:"xr-standard"}},da={"Product: 0268":"PS3"},fa={};function pa(t){var e=fa[t.id];if(e)return e;for(var i in da)if(-1!==t.id.indexOf(i)){var n=da[i];if(!t.mapping){var s=ua["RAW_"+n];if(s)return s}return ua[n]}if("xr-standard"===t.mapping)return ua.DEFAULT_XR;var r=ua.DEFAULT,a=t.buttons.length0):(this.value=t.value,this.pressed=t.pressed,this.touched=null!=(i=t.touched)?i:t.value>0);e&&("number"==typeof e?(this.wasPressed=1!==e&&this.pressed,this.wasReleased=1===e&&!this.pressed,this.wasTouched=0===e&&this.touched):(this.wasPressed=!e.pressed&&this.pressed,this.wasReleased=e.pressed&&!this.pressed,this.wasTouched=!(null!=(n=e.touched)?n:e.value>0)&&this.touched))}return t.prototype.update=function(t){var e,i=t.value,n=t.pressed,s=null!=(e=t.touched)?e:i>0;this.wasPressed=!this.pressed&&n,this.wasReleased=this.pressed&&!n,this.wasTouched=!this.touched&&s,this.value=i,this.pressed=n,this.touched=s},t}(),va=Object.freeze(new ga(0)),ya=function(){function t(t,e){this._compiledMapping={buttons:[],axes:[]},this.id=t.id,this.index=t.index,this._buttons=t.buttons.map((function(t){return new ga(t)})),this._axes=[].concat(t.axes),this._previousAxes=[].concat(t.axes),this.mapping=e.mapping,this.map=e,this.hand=t.hand||"none",this.pad=t,this._compileMapping()}var e,i=t.prototype;return i._compileMapping=function(){var t=this,e=this._compiledMapping,i=e.axes,n=e.buttons,s=ca.axes,r=ca.buttons;i.length=0,n.length=0,this.map.axes&&this.map.axes.forEach((function(e,n){i[s[e]]=function(){return t.pad.axes[n]||0}}));for(var a=0,o=i.length;ama?e:0},y(t,[{key:"connected",get:function(){return this.pad.connected}},{key:"axes",get:function(){return this._compiledMapping.axes.map((function(t){return t()}))}},{key:"buttons",get:function(){return this._compiledMapping.buttons.map((function(t){return t()}))}}]),t}(),xa=function(t){function e(){var e;return(e=t.call(this)||this).gamepadsSupported=G.gamepads,e.current=[],e._previous=[],e._ongamepadconnectedHandler=e._ongamepadconnected.bind(w(e)),e._ongamepaddisconnectedHandler=e._ongamepaddisconnected.bind(w(e)),window.addEventListener("gamepadconnected",e._ongamepadconnectedHandler,!1),window.addEventListener("gamepaddisconnected",e._ongamepaddisconnectedHandler,!1),e.poll(),e}S(e,t);var i=e.prototype;return i._ongamepadconnected=function(t){for(var e=new ya(t.gamepad,this.getMap(t.gamepad)),i=this.current,n=i.findIndex((function(t){return t.index===e.index}));-1!==n;)i.splice(n,1),n=i.findIndex((function(t){return t.index===e.index}));i.push(e),this.fire(Zr,e)},i._ongamepaddisconnected=function(t){var e=this.current,i=e.findIndex((function(e){return e.index===t.gamepad.index}));-1!==i&&(this.fire(Qr,e[i]),e.splice(i,1))},i.update=function(){this.poll()},i.poll=function(t){void 0===t&&(t=[]),t.length>0&&(t.length=0);for(var e=la(),i=0,n=e.length;i=0?t.ResponseType.ARRAY_BUFFER:".json"===n?t.ResponseType.JSON:".xml"===n?t.ResponseType.DOCUMENT:t.ResponseType.TEXT},e._isBinaryContentType=function(e){return[t.ContentType.BASIS,t.ContentType.BIN,t.ContentType.DDS,t.ContentType.GLB,t.ContentType.MP3,t.ContentType.MP4,t.ContentType.OGG,t.ContentType.OPUS,t.ContentType.WAV].indexOf(e)>=0},e._isBinaryResponseType=function(e){return e===t.ResponseType.ARRAY_BUFFER||e===t.ResponseType.BLOB||e===t.ResponseType.JSON},e._onReadyStateChange=function(t,e,i,n){if(4===n.readyState)switch(n.status){case 0:n.responseURL&&n.responseURL.startsWith("file:///")?this._onSuccess(t,e,i,n):this._onError(t,e,i,n);break;case 200:case 201:case 206:case 304:this._onSuccess(t,e,i,n);break;default:this._onError(t,e,i,n)}},e._onSuccess=function(e,i,n,s){var r,a,o=s.getResponseHeader("Content-Type");o&&(a=o.split(";")[0].trim());try{r=this._isBinaryContentType(a)||this._isBinaryResponseType(s.responseType)?s.response:a===t.ContentType.JSON||i.split("?")[0].endsWith(".json")?JSON.parse(s.responseText):s.responseType===t.ResponseType.DOCUMENT||a===t.ContentType.XML?s.responseXML:s.responseText,n.callback(null,r)}catch(t){n.callback(t)}},e._onError=function(e,i,n,s){var r=this;if(!n.retrying)if(n.retry&&n.retriesn)return 0;var o=0;return r===re?o=1-s*(a-i)/(n-i):r===ae?o=i/(i+s*(a-i)):r===oe&&(o=Math.pow(a/i,-s)),_t.clamp(o,0,1)}(this.manager.listener.getPosition(),this.position,this.minDistance,this.maxDistance,this.rollOffFactor,this.distanceModel),i=this.getVolume();this.source.volume=i*e}},getMaxDistance:function(){return this.maxDistance},setMaxDistance:function(t){this.maxDistance=t},getMinDistance:function(){return this.minDistance},setMinDistance:function(t){this.minDistance=t},getRollOffFactor:function(){return this.rollOffFactor},setRollOffFactor:function(t){this.rollOffFactor=t},getDistanceModel:function(){return this.distanceModel},setDistanceModel:function(t){this.distanceModel=t}})}var Ia=function(){function t(t){this._manager=t,this.position=new Et,this.velocity=new Et,this.orientation=new zt}var e=t.prototype;return e.getPosition=function(){return this.position},e.setPosition=function(t){this.position.copy(t);var e=this.listener;e&&("positionX"in e?(e.positionX.value=t.x,e.positionY.value=t.y,e.positionZ.value=t.z):e.setPosition&&e.setPosition(t.x,t.y,t.z))},e.getVelocity=function(){return this.velocity},e.setVelocity=function(t){},e.setOrientation=function(t){this.orientation.copy(t);var e=this.listener;if(e){var i=t.data;"forwardX"in e?(e.forwardX.value=-i[8],e.forwardY.value=-i[9],e.forwardZ.value=-i[10],e.upX.value=i[4],e.upY.value=i[5],e.upZ.value=i[6]):e.setOrientation&&e.setOrientation(-i[8],-i[9],-i[10],i[4],i[5],i[6])}},e.getOrientation=function(){return this.orientation},y(t,[{key:"listener",get:function(){var t=this._manager.context;return t?t.listener:null}}]),t}(),La="running",Da=["click","touchstart","mousedown"],Oa=function(t){function e(){var e;return(e=t.call(this)||this)._context=null,e.AudioContext="undefined"!=typeof AudioContext&&AudioContext||"undefined"!=typeof webkitAudioContext&&webkitAudioContext,e.AudioContext,e._unlockHandlerFunc=e._unlockHandler.bind(w(e)),e._userSuspended=!1,e.listener=new Ia(w(e)),e._volume=1,e}S(e,t);var i=e.prototype;return i.suspend=function(){this._userSuspended||(this._userSuspended=!0,this._context&&this._context.state===La&&this._suspend())},i.resume=function(){this._userSuspended&&(this._userSuspended=!1,this._context&&this._context.state!==La&&this._resume())},i.destroy=function(){var t;(this.fire("destroy"),this._context)&&(this._removeUnlockListeners(),null==(t=this._context)||t.close(),this._context=null)},i.playSound=function(t,e){void 0===e&&(e={});var i=null;return Ma&&(i=new Ma(this,t,e)).play(),i},i.playSound3d=function(t,e,i){void 0===i&&(i={});var n=null;return Pa&&((n=new Pa(this,t,i)).setPosition(e),i.volume&&n.setVolume(i.volume),i.loop&&n.setLoop(i.loop),i.maxDistance&&n.setMaxDistance(i.maxDistance),i.minDistance&&n.setMinDistance(i.minDistance),i.rollOffFactor&&n.setRollOffFactor(i.rollOffFactor),i.distanceModel&&n.setDistanceModel(i.distanceModel),n.play()),n},i._resume=function(){var t=this;this._context.resume().then((function(){var e=t._context.createBufferSource();e.buffer=t._context.createBuffer(1,1,t._context.sampleRate),e.connect(t._context.destination),e.start(0),e.onended=function(i){e.disconnect(0),t.fire("resume")}}),(function(t){})).catch((function(t){}))},i._suspend=function(){var t=this;this._context.suspend().then((function(){t.fire("suspend")}),(function(t){})).catch((function(t){}))},i._unlockHandler=function(){this._removeUnlockListeners(),this._userSuspended||this._context.state===La||this._resume()},i._registerUnlockListeners=function(){var t=this;Da.forEach((function(e){window.addEventListener(e,t._unlockHandlerFunc,!1)}))},i._removeUnlockListeners=function(){var t=this;Da.forEach((function(e){window.removeEventListener(e,t._unlockHandlerFunc,!1)}))},y(e,[{key:"volume",get:function(){return this._volume},set:function(t){t=_t.clamp(t,0,1),this._volume=t,this.fire("volumechange",t)}},{key:"suspended",get:function(){return this._userSuspended}},{key:"context",get:function(){return!this._context&&this.AudioContext&&(this._context=new this.AudioContext,this._context.state!==La&&this._registerUnlockListeners()),this._context}}]),e}(P),ka=function(){function t(t){this.audio=void 0,this.buffer=void 0,t instanceof Audio?this.audio=t:this.buffer=t}return y(t,[{key:"duration",get:function(){var t=0;return this.buffer?t=this.buffer.duration:this.audio&&(t=this.audio.duration),t||0}}]),t}();function Fa(t,e){return t%e||0}var Ba=function(t){function e(e,i,n){var s;return(s=t.call(this)||this).source=null,s._manager=e,s._volume=void 0!==n.volume?_t.clamp(Number(n.volume)||0,0,1):1,s._pitch=void 0!==n.pitch?Math.max(.01,Number(n.pitch)||0):1,s._loop=!(void 0===n.loop||!n.loop),s._sound=i,s._state=2,s._suspended=!1,s._suspendEndEvent=0,s._suspendInstanceEvents=!1,s._playWhenLoaded=!0,s._startTime=Math.max(0,Number(n.startTime)||0),s._duration=Math.max(0,Number(n.duration)||0),s._startOffset=null,s._onPlayCallback=n.onPlay,s._onPauseCallback=n.onPause,s._onResumeCallback=n.onResume,s._onStopCallback=n.onStop,s._onEndCallback=n.onEnd,Ea()?(s._startedAt=0,s._currentTime=0,s._currentOffset=0,s._inputNode=null,s._connectorNode=null,s._firstNode=null,s._lastNode=null,s._waitingContextSuspension=!1,s._initializeNodes(),s._endedHandler=s._onEnded.bind(w(s))):(s._isReady=!1,s._loadedMetadataHandler=s._onLoadedMetadata.bind(w(s)),s._timeUpdateHandler=s._onTimeUpdate.bind(w(s)),s._endedHandler=s._onEnded.bind(w(s)),s._createSource()),s}S(e,t);var i=e.prototype;return i._onPlay=function(){this.fire("play"),this._onPlayCallback&&this._onPlayCallback(this)},i._onPause=function(){this.fire("pause"),this._onPauseCallback&&this._onPauseCallback(this)},i._onResume=function(){this.fire("resume"),this._onResumeCallback&&this._onResumeCallback(this)},i._onStop=function(){this.fire("stop"),this._onStopCallback&&this._onStopCallback(this)},i._onEnded=function(){this._suspendEndEvent>0?this._suspendEndEvent--:(this.fire("end"),this._onEndCallback&&this._onEndCallback(this),this.stop())},i._onManagerVolumeChange=function(){this.volume=this._volume},i._onManagerSuspend=function(){0!==this._state||this._suspended||(this._suspended=!0,this.pause())},i._onManagerResume=function(){this._suspended&&(this._suspended=!1,this.resume())},i._initializeNodes=function(){this.gain=this._manager.context.createGain(),this._inputNode=this.gain,this._connectorNode=this.gain,this._connectorNode.connect(this._manager.context.destination)},i.play=function(){return 2!==this._state&&this.stop(),this._state=0,this._playWhenLoaded=!1,!this._waitingContextSuspension&&(this._manager.suspended?(this._manager.once("resume",this._playAudioImmediate,this),this._waitingContextSuspension=!0,!1):(this._playAudioImmediate(),!0))},i._playAudioImmediate=function(){if(this._waitingContextSuspension=!1,0===this._state){this.source||this._createSource();var t=Fa(this._startOffset,this.duration);t=Fa(this._startTime+t,this._sound.duration),this._startOffset=null,this._duration?this.source.start(0,t,this._duration):this.source.start(0,t),this._startedAt=this._manager.context.currentTime,this._currentTime=0,this._currentOffset=t,this.volume=this._volume,this.loop=this._loop,this.pitch=this._pitch,this._manager.on("volumechange",this._onManagerVolumeChange,this),this._manager.on("suspend",this._onManagerSuspend,this),this._manager.on("resume",this._onManagerResume,this),this._manager.on("destroy",this._onManagerDestroy,this),this._suspendInstanceEvents||this._onPlay()}},i.pause=function(){return this._playWhenLoaded=!1,0===this._state&&(this._state=1,this._waitingContextSuspension||(this._updateCurrentTime(),this._suspendEndEvent++,this.source.stop(0),this.source=null,this._startOffset=null,this._suspendInstanceEvents||this._onPause()),!0)},i.resume=function(){if(1!==this._state)return!1;var t=this.currentTime;return this._state=0,this._waitingContextSuspension||(this.source||this._createSource(),null!==this._startOffset&&(t=Fa(this._startOffset,this.duration),t=Fa(this._startTime+t,this._sound.duration),this._startOffset=null),this._duration?this.source.start(0,t,this._duration):this.source.start(0,t),this._startedAt=this._manager.context.currentTime,this._currentOffset=t,this.volume=this._volume,this.loop=this._loop,this.pitch=this._pitch,this._playWhenLoaded=!1,this._suspendInstanceEvents||this._onResume()),!0},i.stop=function(){if(this._playWhenLoaded=!1,2===this._state)return!1;var t=0===this._state;return this._state=2,this._waitingContextSuspension||(this._manager.off("volumechange",this._onManagerVolumeChange,this),this._manager.off("suspend",this._onManagerSuspend,this),this._manager.off("resume",this._onManagerResume,this),this._manager.off("destroy",this._onManagerDestroy,this),this._startedAt=0,this._currentTime=0,this._currentOffset=0,this._startOffset=null,this._suspendEndEvent++,t&&this.source&&this.source.stop(0),this.source=null,this._suspendInstanceEvents||this._onStop()),!0},i.setExternalNodes=function(t,e){if(t){e||(e=t);var i=this._manager.context.destination;this._firstNode!==t&&(this._firstNode?this._connectorNode.disconnect(this._firstNode):this._connectorNode.disconnect(i),this._firstNode=t,this._connectorNode.connect(t)),this._lastNode!==e&&(this._lastNode&&this._lastNode.disconnect(i),this._lastNode=e,this._lastNode.connect(i))}else console.error("The firstNode must be a valid Audio Node")},i.clearExternalNodes=function(){var t=this._manager.context.destination;this._firstNode&&(this._connectorNode.disconnect(this._firstNode),this._firstNode=null),this._lastNode&&(this._lastNode.disconnect(t),this._lastNode=null),this._connectorNode.connect(t)},i.getExternalNodes=function(){return[this._firstNode,this._lastNode]},i._createSource=function(){if(!this._sound)return null;var t=this._manager.context;return this._sound.buffer&&(this.source=t.createBufferSource(),this.source.buffer=this._sound.buffer,this.source.connect(this._inputNode),this.source.onended=this._endedHandler,this.source.loopStart=Fa(this._startTime,this.source.buffer.duration),this._duration&&(this.source.loopEnd=Math.max(this.source.loopStart,Fa(this._startTime+this._duration,this.source.buffer.duration)))),this.source},i._updateCurrentTime=function(){this._currentTime=Fa((this._manager.context.currentTime-this._startedAt)*this._pitch+this._currentOffset,this.duration)},i._onManagerDestroy=function(){this.source&&0===this._state&&(this.source.stop(0),this.source=null)},y(e,[{key:"currentTime",get:function(){return null!==this._startOffset?this._startOffset:1===this._state?this._currentTime:2!==this._state&&this.source?(this._updateCurrentTime(),this._currentTime):0},set:function(t){if(!(t<0))if(0===this._state){var e=this._suspendInstanceEvents;this._suspendInstanceEvents=!0,this.stop(),this._startOffset=t,this.play(),this._suspendInstanceEvents=e}else this._startOffset=t,this._currentTime=t}},{key:"duration",get:function(){return this._sound?this._duration?Fa(this._duration,this._sound.duration):this._sound.duration:0},set:function(t){this._duration=Math.max(0,Number(t)||0);var e=0===this._state;this.stop(),e&&this.play()}},{key:"isPaused",get:function(){return 1===this._state}},{key:"isPlaying",get:function(){return 0===this._state}},{key:"isStopped",get:function(){return 2===this._state}},{key:"isSuspended",get:function(){return this._suspended}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=!!t,this.source&&(this.source.loop=this._loop)}},{key:"pitch",get:function(){return this._pitch},set:function(t){this._currentOffset=this.currentTime,this._startedAt=this._manager.context.currentTime,this._pitch=Math.max(Number(t)||0,.01),this.source&&(this.source.playbackRate.value=this._pitch)}},{key:"sound",get:function(){return this._sound},set:function(t){this._sound=t,2!==this._state?this.stop():this._createSource()}},{key:"startTime",get:function(){return this._startTime},set:function(t){this._startTime=Math.max(0,Number(t)||0);var e=0===this._state;this.stop(),e&&this.play()}},{key:"volume",get:function(){return this._volume},set:function(t){t=_t.clamp(t,0,1),this._volume=t,this.gain&&(this.gain.gain.value=t*this._manager.volume)}}]),e}(P);Ea()||(Object.assign(Ba.prototype,{play:function(){return 2!==this._state&&this.stop(),!(!this.source&&!this._createSource())&&(this.volume=this._volume,this.pitch=this._pitch,this.loop=this._loop,this.source.play(),this._state=0,this._playWhenLoaded=!1,this._manager.on("volumechange",this._onManagerVolumeChange,this),this._manager.on("suspend",this._onManagerSuspend,this),this._manager.on("resume",this._onManagerResume,this),this._manager.on("destroy",this._onManagerDestroy,this),this._manager.suspended&&this._onManagerSuspend(),this._suspendInstanceEvents||this._onPlay(),!0)},pause:function(){return!(!this.source||0!==this._state)&&(this._suspendEndEvent++,this.source.pause(),this._playWhenLoaded=!1,this._state=1,this._startOffset=null,this._suspendInstanceEvents||this._onPause(),!0)},resume:function(){return!(!this.source||1!==this._state)&&(this._state=0,this._playWhenLoaded=!1,this.source.paused&&(this.source.play(),this._suspendInstanceEvents||this._onResume()),!0)},stop:function(){return!(!this.source||2===this._state)&&(this._manager.off("volumechange",this._onManagerVolumeChange,this),this._manager.off("suspend",this._onManagerSuspend,this),this._manager.off("resume",this._onManagerResume,this),this._manager.off("destroy",this._onManagerDestroy,this),this._suspendEndEvent++,this.source.pause(),this._playWhenLoaded=!1,this._state=2,this._startOffset=null,this._suspendInstanceEvents||this._onStop(),!0)},setExternalNodes:function(){},clearExternalNodes:function(){},getExternalNodes:function(){return[null,null]},_onLoadedMetadata:function(){this.source.removeEventListener("loadedmetadata",this._loadedMetadataHandler),this._isReady=!0;var t=Fa(this._startOffset,this.duration);t=Fa(this._startTime+t,this._sound.duration),this._startOffset=null,this.source.currentTime=t},_createSource:function(){return this._sound&&this._sound.audio&&(this._isReady=!1,this.source=this._sound.audio.cloneNode(!0),this.source.addEventListener("loadedmetadata",this._loadedMetadataHandler),this.source.addEventListener("timeupdate",this._timeUpdateHandler),this.source.onended=this._endedHandler),this.source},_onTimeUpdate:function(){this._duration&&this.source.currentTime>Fa(this._startTime+this._duration,this.source.duration)&&(this.loop?this.source.currentTime=Fa(this._startTime,this.source.duration):(this.source.removeEventListener("timeupdate",this._timeUpdateHandler),this.source.pause(),this._onEnded()))},_onManagerDestroy:function(){this.source&&this.source.pause()}}),Object.defineProperty(Ba.prototype,"volume",{get:function(){return this._volume},set:function(t){t=_t.clamp(t,0,1),this._volume=t,this.source&&(this.source.volume=t*this._manager.volume)}}),Object.defineProperty(Ba.prototype,"pitch",{get:function(){return this._pitch},set:function(t){this._pitch=Math.max(Number(t)||0,.01),this.source&&(this.source.playbackRate=this._pitch)}}),Object.defineProperty(Ba.prototype,"sound",{get:function(){return this._sound},set:function(t){this.stop(),this._sound=t}}),Object.defineProperty(Ba.prototype,"currentTime",{get:function(){return null!==this._startOffset?this._startOffset:2!==this._state&&this.source?this.source.currentTime-this._startTime:0},set:function(t){t<0||(this._startOffset=t,this.source&&this._isReady&&(this.source.currentTime=Fa(this._startTime+Fa(t,this.duration),this._sound.duration),this._startOffset=null))}}));var Ua=function(t){function e(e,i,n){var s;return void 0===n&&(n={}),(s=t.call(this,e,i,n)||this)._position=new Et,s._velocity=new Et,n.position&&(s.position=n.position),s.maxDistance=void 0!==n.maxDistance?Number(n.maxDistance):1e4,s.refDistance=void 0!==n.refDistance?Number(n.refDistance):1,s.rollOffFactor=void 0!==n.rollOffFactor?Number(n.rollOffFactor):1,s.distanceModel=void 0!==n.distanceModel?n.distanceModel:re,s}return S(e,t),e.prototype._initializeNodes=function(){this.gain=this._manager.context.createGain(),this.panner=this._manager.context.createPanner(),this.panner.connect(this.gain),this._inputNode=this.panner,this._connectorNode=this.gain,this._connectorNode.connect(this._manager.context.destination)},y(e,[{key:"position",get:function(){return this._position},set:function(t){this._position.copy(t);var e=this.panner;"positionX"in e?(e.positionX.value=t.x,e.positionY.value=t.y,e.positionZ.value=t.z):e.setPosition&&e.setPosition(t.x,t.y,t.z)}},{key:"velocity",get:function(){return this._velocity},set:function(t){this._velocity.copy(t)}},{key:"maxDistance",get:function(){return this.panner.maxDistance},set:function(t){this.panner.maxDistance=t}},{key:"refDistance",get:function(){return this.panner.refDistance},set:function(t){this.panner.refDistance=t}},{key:"rollOffFactor",get:function(){return this.panner.rolloffFactor},set:function(t){this.panner.rolloffFactor=t}},{key:"distanceModel",get:function(){return this.panner.distanceModel},set:function(t){this.panner.distanceModel=t}}]),e}(Ba);if(!Ea()){var Na=new Et;Object.defineProperty(Ua.prototype,"position",{get:function(){return this._position},set:function(t){if(this._position.copy(t),this.source){var e=function(t,e,i,n,s,r){var a=(Na=Na.sub2(t,e)).length();if(an)return 0;var o=0;return r===re?o=1-s*(a-i)/(n-i):r===ae?o=i/(i+s*(a-i)):r===oe&&(o=Math.pow(a/i,-s)),_t.clamp(o,0,1)}(this._manager.listener.getPosition(),this._position,this.refDistance,this.maxDistance,this.rollOffFactor,this.distanceModel),i=this.volume;this.source.volume=i*e*this._manager.volume}}}),Object.defineProperty(Ua.prototype,"maxDistance",{get:function(){return this._maxDistance},set:function(t){this._maxDistance=t}}),Object.defineProperty(Ua.prototype,"refDistance",{get:function(){return this._refDistance},set:function(t){this._refDistance=t}}),Object.defineProperty(Ua.prototype,"rollOffFactor",{get:function(){return this._rollOffFactor},set:function(t){this._rollOffFactor=t}}),Object.defineProperty(Ua.prototype,"distanceModel",{get:function(){return this._distanceModel},set:function(t){this._distanceModel=t}})}var za="none",Va="linear",Ga={0:"PCF3",1:"VSM8",2:"VSM16",3:"VSM32",4:"PCF5",5:"PCF1",6:"PCSS"},Ha="mul",Wa=32,Xa=128,qa=256,ja=512,Ya=1024,Ka=2048,Za=4096,Qa=8192,$a=function(){function t(){this._refCount=0}var e=t.prototype;return e.incRefCount=function(){this._refCount++},e.decRefCount=function(){this._refCount--},y(t,[{key:"refCount",get:function(){return this._refCount}}]),t}(),Ja=function(){function t(){}return t.set=function(e){t._graphicsDevice=e},t.get=function(){return t._graphicsDevice},t}();Ja._graphicsDevice=null;var to=0,eo=function(){function t(){this.initDefaults()}var e=t.prototype;return e.initDefaults=function(){this.recreate=!1,this.verticesUsage=0,this.indicesUsage=0,this.maxVertices=0,this.maxIndices=0,this.vertexCount=0,this.indexCount=0,this.vertexStreamsUpdated=!1,this.indexStreamUpdated=!1,this.vertexStreamDictionary={},this.indices=null},e._changeVertexCount=function(t,e){this.vertexCount||(this.vertexCount=t)},t}();eo.DEFAULT_COMPONENTS_POSITION=3,eo.DEFAULT_COMPONENTS_NORMAL=3,eo.DEFAULT_COMPONENTS_UV=2,eo.DEFAULT_COMPONENTS_COLORS=4;var io=function(t,e,i,n){this.data=t,this.componentCount=e,this.dataType=i,this.dataTypeNormalize=n},no=function(t){function e(e){var i;return(i=t.call(this)||this)._aabbVer=0,i._aabb=new jt,i.id=to++,i.device=e||Ja.get(),i.vertexBuffer=null,i.indexBuffer=[null],i.primitive=[{type:0,base:0,count:0}],i.skin=null,i._morph=null,i._geometryData=null,i.boneAabb=null,i}S(e,t);var i=e.prototype;return i.destroy=function(){var t=this.morph;t&&(this.morph=null,t.refCount<1&&t.destroy()),this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBuffer=null);for(var e=0;e0){var S=g.array[g.index+x];if(u[S]=!0,e=m.array[m.index],i=m.array[m.index+1],n=m.array[m.index+2],s=c[S],(r=l[S]).x>e&&(r.x=e),r.y>i&&(r.y=i),r.z>n&&(r.z=n),s.xb&&(r.x=b),r.y>w&&(r.y=w),r.z>T&&(r.z=T),s.x0&&this.indexBuffer[0]&&(this._geometryData.indexCount=this.indexBuffer[0].numIndices,this._geometryData.maxIndices=this.indexBuffer[0].numIndices))},i.clear=function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=0),this._initGeometryData(),this._geometryData.initDefaults(),this._geometryData.recreate=!0,this._geometryData.maxVertices=i,this._geometryData.maxIndices=n,this._geometryData.verticesUsage=t?0:1,this._geometryData.indicesUsage=e?0:1},i.setVertexStream=function(t,e,i,n,s,r){void 0===s&&(s=6),void 0===r&&(r=!1),this._initGeometryData();var a=n||e.length/i;this._geometryData._changeVertexCount(a,t),this._geometryData.vertexStreamsUpdated=!0,this._geometryData.vertexStreamDictionary[t]=new io(e,i,s,r)},i.getVertexStream=function(t,e){var i=0,n=!1;if(this._geometryData){var s=this._geometryData.vertexStreamDictionary[t];s&&(n=!0,i=this._geometryData.vertexCount,ArrayBuffer.isView(e)?e.set(s.data):(e.length=0,e.push(s.data)))}n||this.vertexBuffer&&(i=new Gr(this.vertexBuffer).readData(t,e));return i},i.setPositions=function(t,e,i){void 0===e&&(e=eo.DEFAULT_COMPONENTS_POSITION),this.setVertexStream(Ee,t,e,i,6,!1)},i.setNormals=function(t,e,i){void 0===e&&(e=eo.DEFAULT_COMPONENTS_NORMAL),this.setVertexStream(Me,t,e,i,6,!1)},i.setUvs=function(t,e,i,n){void 0===i&&(i=eo.DEFAULT_COMPONENTS_UV),this.setVertexStream(De+t,e,i,n,6,!1)},i.setColors=function(t,e,i){void 0===e&&(e=eo.DEFAULT_COMPONENTS_COLORS),this.setVertexStream(Le,t,e,i,6,!1)},i.setColors32=function(t,e){this.setVertexStream(Le,t,eo.DEFAULT_COMPONENTS_COLORS,e,yi,!0)},i.setIndices=function(t,e){this._initGeometryData(),this._geometryData.indexStreamUpdated=!0,this._geometryData.indices=t,this._geometryData.indexCount=e||t.length},i.getPositions=function(t){return this.getVertexStream(Ee,t)},i.getNormals=function(t){return this.getVertexStream(Me,t)},i.getUvs=function(t,e){return this.getVertexStream(De+t,e)},i.getColors=function(t){return this.getVertexStream(Le,t)},i.getIndices=function(t){var e=0;if(this._geometryData&&this._geometryData.indices){var i=this._geometryData.indices;if(e=this._geometryData.indexCount,ArrayBuffer.isView(t))t.set(i);else{t.length=0;for(var n=0,s=i.length;n0&&this.indexBuffer[0])e=this.indexBuffer[0].readData(t)}return e},i.update=function(t,e){if(void 0===t&&(t=4),void 0===e&&(e=!0),this._geometryData){if(e){var i=this._geometryData.vertexStreamDictionary[Ee];i&&3===i.componentCount&&(this._aabb.compute(i.data,this._geometryData.vertexCount),this._aabbVer++)}var n=this._geometryData.recreate;this._geometryData.vertexCount>this._geometryData.maxVertices&&(n=!0,this._geometryData.maxVertices=this._geometryData.vertexCount),n&&this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBuffer=null);var s=this._geometryData.recreate;this._geometryData.indexCount>this._geometryData.maxIndices&&(s=!0,this._geometryData.maxIndices=this._geometryData.indexCount),s&&this.indexBuffer.length>0&&this.indexBuffer[0]&&(this.indexBuffer[0].destroy(),this.indexBuffer[0]=null),this._geometryData.vertexStreamsUpdated&&this._updateVertexBuffer(),this._geometryData.indexStreamUpdated&&this._updateIndexBuffer(),this.primitive[0].type=t,this.indexBuffer.length>0&&this.indexBuffer[0]?this._geometryData.indexStreamUpdated&&(this.primitive[0].count=this._geometryData.indexCount,this.primitive[0].indexed=!0):this._geometryData.vertexStreamsUpdated&&(this.primitive[0].count=this._geometryData.vertexCount,this.primitive[0].indexed=!1),this._geometryData.vertexCount=0,this._geometryData.indexCount=0,this._geometryData.vertexStreamsUpdated=!1,this._geometryData.indexStreamUpdated=!1,this._geometryData.recreate=!1,this.updateRenderStates()}},i._buildVertexFormat=function(t){var e=[];for(var i in this._geometryData.vertexStreamDictionary){var n=this._geometryData.vertexStreamDictionary[i];e.push({semantic:i,components:n.componentCount,type:n.dataType,normalize:n.dataTypeNormalize})}return new sn(this.device,e,t)},i._updateVertexBuffer=function(){if(!this.vertexBuffer){var t=this._geometryData.maxVertices,e=this._buildVertexFormat(t);this.vertexBuffer=new Zi(this.device,e,t,this._geometryData.verticesUsage)}var i=new Gr(this.vertexBuffer),n=this._geometryData.vertexCount;for(var s in this._geometryData.vertexStreamDictionary){var r=this._geometryData.vertexStreamDictionary[s];i.writeData(s,r.data,n),delete this._geometryData.vertexStreamDictionary[s]}i.end()},i._updateIndexBuffer=function(){if(this.indexBuffer.length<=0||!this.indexBuffer[0]){var t=this._geometryData.maxVertices>65535?2:1;this.indexBuffer[0]=new Tr(this.device,t,this._geometryData.maxIndices,this._geometryData.indicesUsage)}var e=this._geometryData.indices;e&&(this.indexBuffer[0].writeData(e,this._geometryData.indexCount),this._geometryData.indices=null)},i.prepareRenderState=function(t){1===t?this.generateWireframe():2===t&&(this.primitive[2]={type:0,base:0,count:this.vertexBuffer?this.vertexBuffer.numVertices:0,indexed:!1})},i.updateRenderStates=function(){this.primitive[2]&&this.prepareRenderState(2),this.primitive[1]&&this.prepareRenderState(1)},i.generateWireframe=function(){this._destroyIndexBuffer(1);var t,e=this.vertexBuffer.numVertices,i=[];if(this.indexBuffer.length>0&&this.indexBuffer[0]){for(var n=[[0,1],[1,2],[2,0]],s=this.primitive[0].base,r=this.primitive[0].count,a=this.indexBuffer[0],o=new Li[a.format](a.storage),h=new Set,l=s;ld?d*e+u:u*e+d;h.has(f)||(h.add(f),i.push(u,d))}t=a.format}else{for(var p=0;p65535?2:1}var m=new Tr(this.vertexBuffer.device,t,i.length);new Li[m.format](m.storage).set(i),m.unlock(),this.primitive[1]={type:1,base:0,count:i.length,indexed:!0},this.indexBuffer[1]=m},y(e,[{key:"morph",get:function(){return this._morph},set:function(t){t!==this._morph&&(this._morph&&this._morph.decRefCount(),this._morph=t,t&&t.incRefCount())}},{key:"aabb",get:function(){return this._aabb},set:function(t){this._aabb=t,this._aabbVer++}}]),e}($a),so=4/64,ro=1-2*so,ao=[];function oo(t,e){for(var i=e.length/3,n=t.length/3,s=new Et,r=new Et,a=new Et,o=new Et,h=new Et,l=new Et,c=[],u=0;u0)for(var v=0;v<=n;v++)for(var y=0;y<=s;y++){var x=y/s*2*Math.PI-Math.PI,S=Math.sin(x),b=Math.cos(x);u.set(S*t,-i/2,b*t),c.set(S*e,i/2,b*e),o.lerp(u,c,v/n),h.sub2(c,u).normalize(),d.set(b,0,-S),l.cross(d,h).normalize(),f.push(o.x,o.y,o.z),p.push(l.x,l.y,l.z);var w=y/s,T=v/n;m.push(w,1-T);var A=T;if(T=w,w=(w=A)*ro+so,T=T*ro+so,w/=3,_.push(w,1-T),v0)for(var ut=0;ut1&&g.push(a,a+ut,a+ut-1)}if(a+=s,e>0)for(var vt=0;vt1&&g.push(a,a+vt-1,a+vt)}}return{positions:f,normals:p,uvs:m,uvs1:_,indices:g}}function fo(t,e){var i,n,s,r,a;void 0===e&&(e={});var o=null!=(i=e.radius)?i:.5,h=null!=(n=e.height)?n:1,l=null!=(s=e.heightSegments)?s:5,c=null!=(r=e.capSegments)?r:20,u=null!=(a=e.calculateTangents)&&a,d=uo(o,o,h,l,c,!1);return u&&(d.tangents=ho(d.positions,d.normals,d.uvs,d.indices)),lo(t,d.positions,d)}function po(t,e){var i,n,s,r,a;void 0===e&&(e={});var o=null!=(i=e.radius)?i:.3,h=null!=(n=e.height)?n:1,l=null!=(s=e.heightSegments)?s:1,c=null!=(r=e.sides)?r:20,u=null!=(a=e.calculateTangents)&&a,d=uo(o,o,h-2*o,l,c,!0);return u&&(d.tangents=ho(d.positions,d.normals,d.uvs,d.indices)),lo(t,d.positions,d)}function mo(t,e){var i,n,s,r,a,o;void 0===e&&(e={});var h=null!=(i=e.baseRadius)?i:.5,l=null!=(n=e.peakRadius)?n:0,c=null!=(s=e.height)?s:1,u=null!=(r=e.heightSegments)?r:5,d=null!=(a=e.capSegments)?a:18,f=null!=(o=e.calculateTangents)&&o,p=uo(h,l,c,u,d,!1);return f&&(p.tangents=ho(p.positions,p.normals,p.uvs,p.indices)),lo(t,p.positions,p)}function _o(t,e){var i,n,s,r;void 0===e&&(e={});for(var a=null!=(i=e.radius)?i:.5,o=null!=(n=e.latitudeBands)?n:16,h=null!=(s=e.longitudeBands)?s:16,l=null!=(r=e.calculateTangents)&&r,c=[],u=[],d=[],f=[],p=0;p<=o;p++)for(var m=p*Math.PI/o,_=Math.sin(m),g=Math.cos(m),v=0;v<=h;v++){var y=2*v*Math.PI/h-Math.PI/2,x=Math.sin(y),S=Math.cos(y)*_,b=g,w=x*_,T=1-v/h,A=1-p/o;c.push(S*a,b*a,w*a),u.push(S,b,w),d.push(T,1-A)}for(var C=0;C shadowZ ? 1.0 : 0.0;\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF3)\n\tfloat getShadowOmniClusteredPCF3(sampler2D shadowMap, vec4 shadowParams, vec3 omniAtlasViewport, float shadowEdgePixels, vec3 lightDir) {\n\t\tfloat shadowTextureResolution = shadowParams.x;\n\t\tvec2 uv = getCubemapAtlasCoordinates(omniAtlasViewport, shadowEdgePixels, shadowTextureResolution, lightDir);\n\t\tfloat shadowZ = length(lightDir) * shadowParams.w + shadowParams.z;\n\t\tvec3 shadowCoord = vec3(uv, shadowZ);\n\t\treturn getShadowPCF3x3(shadowMap, shadowCoord, shadowParams);\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF5)\n\tfloat getShadowOmniClusteredPCF5(sampler2D shadowMap, vec4 shadowParams, vec3 omniAtlasViewport, float shadowEdgePixels, vec3 lightDir) {\n\t\tfloat shadowTextureResolution = shadowParams.x;\n\t\tvec2 uv = getCubemapAtlasCoordinates(omniAtlasViewport, shadowEdgePixels, shadowTextureResolution, lightDir);\n\t\tfloat shadowZ = length(lightDir) * shadowParams.w + shadowParams.z;\n\t\tvec3 shadowCoord = vec3(uv, shadowZ);\n\t\treturn getShadowPCF3x3(shadowMap, shadowCoord, shadowParams);\n\t}\n\t#endif\n#endif\n#ifdef GL2\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF1)\n\tfloat getShadowSpotClusteredPCF1(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\t\treturn textureShadow(shadowMap, shadowCoord);\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF3)\n\tfloat getShadowSpotClusteredPCF3(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\t\treturn getShadowSpotPCF3x3(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams);\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF5)\n\tfloat getShadowSpotClusteredPCF5(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\t\treturn getShadowPCF5x5(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams);\n\t}\n\t#endif\n#else\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF1)\n\tfloat getShadowSpotClusteredPCF1(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\t\tfloat depth = unpackFloat(textureShadow(shadowMap, shadowCoord.xy));\n\t\treturn depth > shadowCoord.z ? 1.0 : 0.0;\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF3)\n\tfloat getShadowSpotClusteredPCF3(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\t\treturn getShadowSpotPCF3x3(shadowMap, shadowCoord, shadowParams);\n\t}\n\t#endif\n\t#if defined(CLUSTER_SHADOW_TYPE_PCF5)\n\tfloat getShadowSpotClusteredPCF5(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\t\treturn getShadowSpotPCF3x3(shadowMap, shadowCoord, shadowParams);\n\t}\n\t#endif\n#endif\n",clusteredLightUtilsPS:"\nvec2 getCubemapFaceCoordinates(const vec3 dir, out float faceIndex, out vec2 tileOffset)\n{\n\tvec3 vAbs = abs(dir);\n\tfloat ma;\n\tvec2 uv;\n\tif (vAbs.z >= vAbs.x && vAbs.z >= vAbs.y) {\n\t\tfaceIndex = dir.z < 0.0 ? 5.0 : 4.0;\n\t\tma = 0.5 / vAbs.z;\n\t\tuv = vec2(dir.z < 0.0 ? -dir.x : dir.x, -dir.y);\n\t\ttileOffset.x = 2.0;\n\t\ttileOffset.y = dir.z < 0.0 ? 1.0 : 0.0;\n\t} else if(vAbs.y >= vAbs.x) {\n\t\tfaceIndex = dir.y < 0.0 ? 3.0 : 2.0;\n\t\tma = 0.5 / vAbs.y;\n\t\tuv = vec2(dir.x, dir.y < 0.0 ? -dir.z : dir.z);\n\t\ttileOffset.x = 1.0;\n\t\ttileOffset.y = dir.y < 0.0 ? 1.0 : 0.0;\n\t} else {\n\t\tfaceIndex = dir.x < 0.0 ? 1.0 : 0.0;\n\t\tma = 0.5 / vAbs.x;\n\t\tuv = vec2(dir.x < 0.0 ? dir.z : -dir.z, -dir.y);\n\t\ttileOffset.x = 0.0;\n\t\ttileOffset.y = dir.x < 0.0 ? 1.0 : 0.0;\n\t}\n\treturn uv * ma + 0.5;\n}\nvec2 getCubemapAtlasCoordinates(const vec3 omniAtlasViewport, float shadowEdgePixels, float shadowTextureResolution, const vec3 dir) {\n\tfloat faceIndex;\n\tvec2 tileOffset;\n\tvec2 uv = getCubemapFaceCoordinates(dir, faceIndex, tileOffset);\n\tfloat atlasFaceSize = omniAtlasViewport.z;\n\tfloat tileSize = shadowTextureResolution * atlasFaceSize;\n\tfloat offset = shadowEdgePixels / tileSize;\n\tuv = uv * vec2(1.0 - offset * 2.0) + vec2(offset * 1.0);\n\tuv *= atlasFaceSize;\n\tuv += tileOffset * atlasFaceSize;\n\tuv += omniAtlasViewport.xy;\n\treturn uv;\n}\n",clusteredLightPS:"\nuniform highp sampler2D clusterWorldTexture;\nuniform highp sampler2D lightsTexture8;\nuniform highp sampler2D lightsTextureFloat;\n#if defined(CLUSTER_COOKIES)\n\t#define CLUSTER_COOKIES_OR_SHADOWS\n#endif\n#if defined(CLUSTER_SHADOWS)\n\t#define CLUSTER_COOKIES_OR_SHADOWS\n#endif\n#ifdef CLUSTER_SHADOWS\n\t#ifdef GL2\n\t\tuniform sampler2DShadow shadowAtlasTexture;\n\t#else\n\t\tuniform sampler2D shadowAtlasTexture;\n\t#endif\n#endif\n#ifdef CLUSTER_COOKIES\n\tuniform sampler2D cookieAtlasTexture;\n#endif\n#ifdef GL2\n\tuniform int clusterMaxCells;\n#else\n\tuniform float clusterMaxCells;\n\tuniform vec4 lightsTextureInvSize;\n#endif\nuniform float clusterSkip;\nuniform vec3 clusterCellsCountByBoundsSize;\nuniform vec3 clusterTextureSize;\nuniform vec3 clusterBoundsMin;\nuniform vec3 clusterBoundsDelta;\nuniform vec3 clusterCellsDot;\nuniform vec3 clusterCellsMax;\nuniform vec2 clusterCompressionLimit0;\nuniform vec2 shadowAtlasParams;\nstruct ClusterLightData {\n\tvec3 halfWidth;\n\tfloat lightType;\n\tvec3 halfHeight;\n\t#ifdef GL2\n\t\tint lightIndex;\n\t#else\n\t\tfloat lightV;\n\t#endif\n\tvec3 position;\n\tfloat shape;\n\tvec3 direction;\n\tfloat falloffMode;\n\tvec3 color;\n\tfloat shadowIntensity;\n\tvec3 omniAtlasViewport;\n\tfloat range;\n\tvec4 cookieChannelMask;\n\tfloat shadowBias;\n\tfloat shadowNormalBias;\n\tfloat innerConeAngleCos;\n\tfloat outerConeAngleCos;\n\tfloat cookie;\n\tfloat cookieRgb;\n\tfloat cookieIntensity;\n\tfloat mask;\n};\nmat4 lightProjectionMatrix;\n#define isClusteredLightCastShadow(light) ( light.shadowIntensity > 0.0 )\n#define isClusteredLightCookie(light) (light.cookie > 0.5 )\n#define isClusteredLightCookieRgb(light) (light.cookieRgb > 0.5 )\n#define isClusteredLightSpot(light) ( light.lightType > 0.5 )\n#define isClusteredLightFalloffLinear(light) ( light.falloffMode < 0.5 )\n#define isClusteredLightArea(light) ( light.shape > 0.1 )\n#define isClusteredLightRect(light) ( light.shape < 0.3 )\n#define isClusteredLightDisk(light) ( light.shape < 0.6 )\n#ifdef CLUSTER_MESH_DYNAMIC_LIGHTS\n\t#define acceptLightMask(light) ( light.mask < 0.75)\n#else\n\t#define acceptLightMask(light) ( light.mask > 0.25)\n#endif\nvec4 decodeClusterLowRange4Vec4(vec4 d0, vec4 d1, vec4 d2, vec4 d3) {\n\treturn vec4(\n\t\tbytes2floatRange4(d0, -2.0, 2.0),\n\t\tbytes2floatRange4(d1, -2.0, 2.0),\n\t\tbytes2floatRange4(d2, -2.0, 2.0),\n\t\tbytes2floatRange4(d3, -2.0, 2.0)\n\t);\n}\n#ifdef GL2\n\tvec4 sampleLightsTexture8(const ClusterLightData clusterLightData, int index) {\n\t\treturn texelFetch(lightsTexture8, ivec2(index, clusterLightData.lightIndex), 0);\n\t}\n\tvec4 sampleLightTextureF(const ClusterLightData clusterLightData, int index) {\n\t\treturn texelFetch(lightsTextureFloat, ivec2(index, clusterLightData.lightIndex), 0);\n\t}\n#else\n\tvec4 sampleLightsTexture8(const ClusterLightData clusterLightData, float index) {\n\t\treturn texture2DLodEXT(lightsTexture8, vec2(index * lightsTextureInvSize.z, clusterLightData.lightV), 0.0);\n\t}\n\tvec4 sampleLightTextureF(const ClusterLightData clusterLightData, float index) {\n\t\treturn texture2DLodEXT(lightsTextureFloat, vec2(index * lightsTextureInvSize.x, clusterLightData.lightV), 0.0);\n\t}\n#endif\nvoid decodeClusterLightCore(inout ClusterLightData clusterLightData, float lightIndex) {\n\t#ifdef GL2\n\t\tclusterLightData.lightIndex = int(lightIndex);\n\t#else\n\t\tclusterLightData.lightV = (lightIndex + 0.5) * lightsTextureInvSize.w;\n\t#endif\n\tvec4 lightInfo = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_FLAGS);\n\tclusterLightData.lightType = lightInfo.x;\n\tclusterLightData.shape = lightInfo.y;\n\tclusterLightData.falloffMode = lightInfo.z;\n\tclusterLightData.shadowIntensity = lightInfo.w;\n\tvec4 colorA = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_COLOR_A);\n\tvec4 colorB = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_COLOR_B);\n\tclusterLightData.color = vec3(bytes2float2(colorA.xy), bytes2float2(colorA.zw), bytes2float2(colorB.xy)) * clusterCompressionLimit0.y;\n\tclusterLightData.cookie = colorB.z;\n\tclusterLightData.mask = colorB.w;\n\t#ifdef CLUSTER_TEXTURE_FLOAT\n\t\tvec4 lightPosRange = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_POSITION_RANGE);\n\t\tclusterLightData.position = lightPosRange.xyz;\n\t\tclusterLightData.range = lightPosRange.w;\n\t\tvec4 lightDir_Unused = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_SPOT_DIRECTION);\n\t\tclusterLightData.direction = lightDir_Unused.xyz;\n\t#else\n\t\tvec4 encPosX = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_POSITION_X);\n\t\tvec4 encPosY = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_POSITION_Y);\n\t\tvec4 encPosZ = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_POSITION_Z);\n\t\tclusterLightData.position = vec3(bytes2float4(encPosX), bytes2float4(encPosY), bytes2float4(encPosZ)) * clusterBoundsDelta + clusterBoundsMin;\n\t\tvec4 encRange = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_RANGE);\n\t\tclusterLightData.range = bytes2float4(encRange) * clusterCompressionLimit0.x;\n\t\tvec4 encDirX = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_SPOT_DIRECTION_X);\n\t\tvec4 encDirY = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_SPOT_DIRECTION_Y);\n\t\tvec4 encDirZ = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_SPOT_DIRECTION_Z);\n\t\tclusterLightData.direction = vec3(bytes2float4(encDirX), bytes2float4(encDirY), bytes2float4(encDirZ)) * 2.0 - 1.0;\n\t#endif\n}\nvoid decodeClusterLightSpot(inout ClusterLightData clusterLightData) {\n\tvec4 coneAngle = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_SPOT_ANGLES);\n\tclusterLightData.innerConeAngleCos = bytes2float2(coneAngle.xy) * 2.0 - 1.0;\n\tclusterLightData.outerConeAngleCos = bytes2float2(coneAngle.zw) * 2.0 - 1.0;\n}\nvoid decodeClusterLightOmniAtlasViewport(inout ClusterLightData clusterLightData) {\n\t#ifdef CLUSTER_TEXTURE_FLOAT\n\t\tclusterLightData.omniAtlasViewport = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_PROJ_MAT_0).xyz;\n\t#else\n\t\tvec4 viewportA = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_ATLAS_VIEWPORT_A);\n\t\tvec4 viewportB = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_ATLAS_VIEWPORT_B);\n\t\tclusterLightData.omniAtlasViewport = vec3(bytes2float2(viewportA.xy), bytes2float2(viewportA.zw), bytes2float2(viewportB.xy));\n\t#endif\n}\nvoid decodeClusterLightAreaData(inout ClusterLightData clusterLightData) {\n\t#ifdef CLUSTER_TEXTURE_FLOAT\n\t\tclusterLightData.halfWidth = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_AREA_DATA_WIDTH).xyz;\n\t\tclusterLightData.halfHeight = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_AREA_DATA_HEIGHT).xyz;\n\t#else\n\t\tvec4 areaWidthX = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_WIDTH_X);\n\t\tvec4 areaWidthY = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_WIDTH_Y);\n\t\tvec4 areaWidthZ = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_WIDTH_Z);\n\t\tclusterLightData.halfWidth = vec3(mantissaExponent2Float(areaWidthX), mantissaExponent2Float(areaWidthY), mantissaExponent2Float(areaWidthZ));\n\t\tvec4 areaHeightX = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_HEIGHT_X);\n\t\tvec4 areaHeightY = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_HEIGHT_Y);\n\t\tvec4 areaHeightZ = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_AREA_DATA_HEIGHT_Z);\n\t\tclusterLightData.halfHeight = vec3(mantissaExponent2Float(areaHeightX), mantissaExponent2Float(areaHeightY), mantissaExponent2Float(areaHeightZ));\n\t#endif\n}\nvoid decodeClusterLightProjectionMatrixData(inout ClusterLightData clusterLightData) {\n\t\n\t#ifdef CLUSTER_TEXTURE_FLOAT\n\t\tvec4 m0 = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_PROJ_MAT_0);\n\t\tvec4 m1 = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_PROJ_MAT_1);\n\t\tvec4 m2 = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_PROJ_MAT_2);\n\t\tvec4 m3 = sampleLightTextureF(clusterLightData, CLUSTER_TEXTURE_F_PROJ_MAT_3);\n\t#else\n\t\tvec4 m00 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_00);\n\t\tvec4 m01 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_01);\n\t\tvec4 m02 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_02);\n\t\tvec4 m03 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_03);\n\t\tvec4 m0 = decodeClusterLowRange4Vec4(m00, m01, m02, m03);\n\t\tvec4 m10 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_10);\n\t\tvec4 m11 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_11);\n\t\tvec4 m12 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_12);\n\t\tvec4 m13 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_13);\n\t\tvec4 m1 = decodeClusterLowRange4Vec4(m10, m11, m12, m13);\n\t\tvec4 m20 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_20);\n\t\tvec4 m21 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_21);\n\t\tvec4 m22 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_22);\n\t\tvec4 m23 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_23);\n\t\tvec4 m2 = decodeClusterLowRange4Vec4(m20, m21, m22, m23);\n\t\tvec4 m30 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_30);\n\t\tvec4 m31 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_31);\n\t\tvec4 m32 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_32);\n\t\tvec4 m33 = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_PROJ_MAT_33);\n\t\tvec4 m3 = vec4(mantissaExponent2Float(m30), mantissaExponent2Float(m31), mantissaExponent2Float(m32), mantissaExponent2Float(m33));\n\t#endif\n\t\n\tlightProjectionMatrix = mat4(m0, m1, m2, m3);\n}\nvoid decodeClusterLightShadowData(inout ClusterLightData clusterLightData) {\n\t\n\tvec4 biases = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_SHADOW_BIAS);\n\tclusterLightData.shadowBias = bytes2floatRange2(biases.xy, -1.0, 20.0),\n\tclusterLightData.shadowNormalBias = bytes2float2(biases.zw);\n}\nvoid decodeClusterLightCookieData(inout ClusterLightData clusterLightData) {\n\tvec4 cookieA = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_COOKIE_A);\n\tclusterLightData.cookieIntensity = cookieA.x;\n\tclusterLightData.cookieRgb = cookieA.y;\n\tclusterLightData.cookieChannelMask = sampleLightsTexture8(clusterLightData, CLUSTER_TEXTURE_8_COOKIE_B);\n}\nvoid evaluateLight(\n\tClusterLightData light, \n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tvec3 reflectionDir,\n#if defined(LIT_CLEARCOAT)\n\tvec3 clearcoatReflectionDir,\n#endif\n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 geometricNormal, \n\tmat3 tbn, \n#if defined(LIT_IRIDESCENCE)\n\tvec3 iridescenceFresnel,\n#endif\n\tvec3 clearcoat_worldNormal,\n\tfloat clearcoat_gloss,\n\tfloat sheen_gloss,\n\tfloat iridescence_intensity\n) {\n\tvec3 cookieAttenuation = vec3(1.0);\n\tfloat diffuseAttenuation = 1.0;\n\tfloat falloffAttenuation = 1.0;\n\tgetLightDirPoint(light.position);\n\t#ifdef CLUSTER_AREALIGHTS\n\tif (isClusteredLightArea(light)) {\n\t\tdecodeClusterLightAreaData(light);\n\t\tif (isClusteredLightRect(light)) {\n\t\t\tcalcRectLightValues(light.position, light.halfWidth, light.halfHeight);\n\t\t} else if (isClusteredLightDisk(light)) {\n\t\t\tcalcDiskLightValues(light.position, light.halfWidth, light.halfHeight);\n\t\t} else {\n\t\t\tcalcSphereLightValues(light.position, light.halfWidth, light.halfHeight);\n\t\t}\n\t\tfalloffAttenuation = getFalloffWindow(light.range, dLightDirW);\n\t} else\n\t#endif\n\t{\n\t\tif (isClusteredLightFalloffLinear(light))\n\t\t\tfalloffAttenuation = getFalloffLinear(light.range, dLightDirW);\n\t\telse\n\t\t\tfalloffAttenuation = getFalloffInvSquared(light.range, dLightDirW);\n\t}\n\tif (falloffAttenuation > 0.00001) {\n\t\t#ifdef CLUSTER_AREALIGHTS\n\t\tif (isClusteredLightArea(light)) {\n\t\t\tif (isClusteredLightRect(light)) {\n\t\t\t\tdiffuseAttenuation = getRectLightDiffuse(worldNormal, viewDir, dLightDirW, dLightDirNormW) * 16.0;\n\t\t\t} else if (isClusteredLightDisk(light)) {\n\t\t\t\tdiffuseAttenuation = getDiskLightDiffuse(worldNormal, viewDir, dLightDirW, dLightDirNormW) * 16.0;\n\t\t\t} else {\n\t\t\t\tdiffuseAttenuation = getSphereLightDiffuse(worldNormal, viewDir, dLightDirW, dLightDirNormW) * 16.0;\n\t\t\t}\n\t\t} else\n\t\t#endif\n\t\t{\n\t\t\tfalloffAttenuation *= getLightDiffuse(worldNormal, viewDir, dLightDirW, dLightDirNormW); \n\t\t}\n\t\tif (isClusteredLightSpot(light)) {\n\t\t\tdecodeClusterLightSpot(light);\n\t\t\tfalloffAttenuation *= getSpotEffect(light.direction, light.innerConeAngleCos, light.outerConeAngleCos, dLightDirNormW);\n\t\t}\n\t\t#if defined(CLUSTER_COOKIES_OR_SHADOWS)\n\t\tif (falloffAttenuation > 0.00001) {\n\t\t\tif (isClusteredLightCastShadow(light) || isClusteredLightCookie(light)) {\n\t\t\t\tif (isClusteredLightSpot(light)) {\n\t\t\t\t\tdecodeClusterLightProjectionMatrixData(light);\n\t\t\t\t} else {\n\t\t\t\t\tdecodeClusterLightOmniAtlasViewport(light);\n\t\t\t\t}\n\t\t\t\tfloat shadowTextureResolution = shadowAtlasParams.x;\n\t\t\t\tfloat shadowEdgePixels = shadowAtlasParams.y;\n\t\t\t\t#ifdef CLUSTER_COOKIES\n\t\t\t\tif (isClusteredLightCookie(light)) {\n\t\t\t\t\tdecodeClusterLightCookieData(light);\n\t\t\t\t\tif (isClusteredLightSpot(light)) {\n\t\t\t\t\t\tcookieAttenuation = getCookie2DClustered(TEXTURE_PASS(cookieAtlasTexture), lightProjectionMatrix, vPositionW, light.cookieIntensity, isClusteredLightCookieRgb(light), light.cookieChannelMask);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcookieAttenuation = getCookieCubeClustered(TEXTURE_PASS(cookieAtlasTexture), dLightDirW, light.cookieIntensity, isClusteredLightCookieRgb(light), light.cookieChannelMask, shadowTextureResolution, shadowEdgePixels, light.omniAtlasViewport);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t#endif\n\t\t\t\t#ifdef CLUSTER_SHADOWS\n\t\t\t\tif (isClusteredLightCastShadow(light)) {\n\t\t\t\t\tdecodeClusterLightShadowData(light);\n\t\t\t\t\tvec4 shadowParams = vec4(shadowTextureResolution, light.shadowNormalBias, light.shadowBias, 1.0 / light.range);\n\t\t\t\t\tif (isClusteredLightSpot(light)) {\n\t\t\t\t\t\tgetShadowCoordPerspZbufferNormalOffset(lightProjectionMatrix, shadowParams, geometricNormal);\n\t\t\t\t\t\t\n\t\t\t\t\t\t#if defined(CLUSTER_SHADOW_TYPE_PCF1)\n\t\t\t\t\t\t\tfloat shadow = getShadowSpotClusteredPCF1(SHADOWMAP_PASS(shadowAtlasTexture), dShadowCoord, shadowParams);\n\t\t\t\t\t\t#elif defined(CLUSTER_SHADOW_TYPE_PCF3)\n\t\t\t\t\t\t\tfloat shadow = getShadowSpotClusteredPCF3(SHADOWMAP_PASS(shadowAtlasTexture), dShadowCoord, shadowParams);\n\t\t\t\t\t\t#elif defined(CLUSTER_SHADOW_TYPE_PCF5)\n\t\t\t\t\t\t\tfloat shadow = getShadowSpotClusteredPCF5(SHADOWMAP_PASS(shadowAtlasTexture), dShadowCoord, shadowParams);\n\t\t\t\t\t\t#elif defined(CLUSTER_SHADOW_TYPE_PCSS)\n\t\t\t\t\t\t\tfloat shadow = getShadowSpotClusteredPCSS(SHADOWMAP_PASS(shadowAtlasTexture), dShadowCoord, shadowParams);\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tfalloffAttenuation *= mix(1.0, shadow, light.shadowIntensity);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvec3 dir = normalOffsetPointShadow(shadowParams, dLightPosW, dLightDirW, dLightDirNormW, geometricNormal);\n\t\t\t\t\t\t#if defined(CLUSTER_SHADOW_TYPE_PCF1)\n\t\t\t\t\t\t\tfloat shadow = getShadowOmniClusteredPCF1(SHADOWMAP_PASS(shadowAtlasTexture), shadowParams, light.omniAtlasViewport, shadowEdgePixels, dir);\n\t\t\t\t\t\t#elif defined(CLUSTER_SHADOW_TYPE_PCF3)\n\t\t\t\t\t\t\tfloat shadow = getShadowOmniClusteredPCF3(SHADOWMAP_PASS(shadowAtlasTexture), shadowParams, light.omniAtlasViewport, shadowEdgePixels, dir);\n\t\t\t\t\t\t#elif defined(CLUSTER_SHADOW_TYPE_PCF5)\n\t\t\t\t\t\t\tfloat shadow = getShadowOmniClusteredPCF5(SHADOWMAP_PASS(shadowAtlasTexture), shadowParams, light.omniAtlasViewport, shadowEdgePixels, dir);\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\tfalloffAttenuation *= mix(1.0, shadow, light.shadowIntensity);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t#endif\n\t\t\t}\n\t\t}\n\t\t#endif\n\t\t#ifdef CLUSTER_AREALIGHTS\n\t\tif (isClusteredLightArea(light)) {\n\t\t\t{\n\t\t\t\tvec3 areaDiffuse = (diffuseAttenuation * falloffAttenuation) * light.color * cookieAttenuation;\n\t\t\t\t#if defined(LIT_SPECULAR)\n\t\t\t\t\t#if defined(LIT_CONSERVE_ENERGY)\n\t\t\t\t\t\tareaDiffuse = mix(areaDiffuse, vec3(0), dLTCSpecFres);\n\t\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t\tdDiffuseLight += areaDiffuse;\n\t\t\t}\n\t\t\t#ifdef LIT_SPECULAR\n\t\t\t\tfloat areaLightSpecular;\n\t\t\t\tif (isClusteredLightRect(light)) {\n\t\t\t\t\tareaLightSpecular = getRectLightSpecular(worldNormal, viewDir);\n\t\t\t\t} else if (isClusteredLightDisk(light)) {\n\t\t\t\t\tareaLightSpecular = getDiskLightSpecular(worldNormal, viewDir);\n\t\t\t\t} else {\n\t\t\t\t\tareaLightSpecular = getSphereLightSpecular(worldNormal, viewDir);\n\t\t\t\t}\n\t\t\t\tdSpecularLight += dLTCSpecFres * areaLightSpecular * falloffAttenuation * light.color * cookieAttenuation;\n\t\t\t\t#ifdef LIT_CLEARCOAT\n\t\t\t\t\tfloat areaLightSpecularCC;\n\t\t\t\t\tif (isClusteredLightRect(light)) {\n\t\t\t\t\t\tareaLightSpecularCC = getRectLightSpecular(clearcoat_worldNormal, viewDir);\n\t\t\t\t\t} else if (isClusteredLightDisk(light)) {\n\t\t\t\t\t\tareaLightSpecularCC = getDiskLightSpecular(clearcoat_worldNormal, viewDir);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tareaLightSpecularCC = getSphereLightSpecular(clearcoat_worldNormal, viewDir);\n\t\t\t\t\t}\n\t\t\t\t\tccSpecularLight += ccLTCSpecFres * areaLightSpecularCC * falloffAttenuation * light.color * cookieAttenuation;\n\t\t\t\t#endif\n\t\t\t#endif\n\t\t} else\n\t\t#endif\n\t\t{\n\t\t\t{\n\t\t\t\tvec3 punctualDiffuse = falloffAttenuation * light.color * cookieAttenuation;\n\t\t\t\t#if defined(CLUSTER_AREALIGHTS)\n\t\t\t\t#if defined(LIT_SPECULAR)\n\t\t\t\t#if defined(LIT_CONSERVE_ENERGY)\n\t\t\t\t\tpunctualDiffuse = mix(punctualDiffuse, vec3(0), specularity);\n\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t\tdDiffuseLight += punctualDiffuse;\n\t\t\t}\n \n\t\t\t#ifdef LIT_SPECULAR\n\t\t\t\tvec3 halfDir = normalize(-dLightDirNormW + viewDir);\n\t\t\t\t\n\t\t\t\t#ifdef LIT_SPECULAR_FRESNEL\n\t\t\t\t\tdSpecularLight += \n\t\t\t\t\t\tgetLightSpecular(halfDir, reflectionDir, worldNormal, viewDir, dLightDirNormW, gloss, tbn) * falloffAttenuation * light.color * cookieAttenuation * \n\t\t\t\t\t\tgetFresnel(\n\t\t\t\t\t\t\tdot(viewDir, halfDir), \n\t\t\t\t\t\t\tgloss, \n\t\t\t\t\t\t\tspecularity\n\t\t\t\t\t\t#if defined(LIT_IRIDESCENCE)\n\t\t\t\t\t\t\t, iridescenceFresnel,\n\t\t\t\t\t\t\tiridescence_intensity\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\t\t);\n\t\t\t\t#else\n\t\t\t\t\tdSpecularLight += getLightSpecular(halfDir, reflectionDir, worldNormal, viewDir, dLightDirNormW, gloss, tbn) * falloffAttenuation * light.color * cookieAttenuation * specularity;\n\t\t\t\t#endif\n\t\t\t\t#ifdef LIT_CLEARCOAT\n\t\t\t\t\t#ifdef LIT_SPECULAR_FRESNEL\n\t\t\t\t\t\tccSpecularLight += getLightSpecular(halfDir, clearcoatReflectionDir, clearcoat_worldNormal, viewDir, dLightDirNormW, clearcoat_gloss, tbn) * falloffAttenuation * light.color * cookieAttenuation * getFresnelCC(dot(viewDir, halfDir));\n\t\t\t\t\t#else\n\t\t\t\t\t\tccSpecularLight += getLightSpecular(halfDir, clearcoatReflectionDir, clearcoat_worldNormal, viewDir, dLightDirNormW, clearcoat_gloss, tbn) * falloffAttenuation * light.color * cookieAttenuation; \n\t\t\t\t\t#endif\n\t\t\t\t#endif\n\t\t\t\t#ifdef LIT_SHEEN\n\t\t\t\t\tsSpecularLight += getLightSpecularSheen(halfDir, worldNormal, viewDir, dLightDirNormW, sheen_gloss) * falloffAttenuation * light.color * cookieAttenuation;\n\t\t\t\t#endif\n\t\t\t#endif\n\t\t}\n\t}\n\tdAtten = falloffAttenuation;\n\tdAttenD = diffuseAttenuation;\n\tdAtten3 = cookieAttenuation;\n}\nvoid evaluateClusterLight(\n\tfloat lightIndex, \n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tvec3 reflectionDir, \n#if defined(LIT_CLEARCOAT)\n\tvec3 clearcoatReflectionDir,\n#endif\n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 geometricNormal, \n\tmat3 tbn, \n#if defined(LIT_IRIDESCENCE)\n\tvec3 iridescenceFresnel,\n#endif\n\tvec3 clearcoat_worldNormal,\n\tfloat clearcoat_gloss,\n\tfloat sheen_gloss,\n\tfloat iridescence_intensity\n) {\n\tClusterLightData clusterLightData;\n\tdecodeClusterLightCore(clusterLightData, lightIndex);\n\tif (acceptLightMask(clusterLightData))\n\t\tevaluateLight(\n\t\t\tclusterLightData, \n\t\t\tworldNormal, \n\t\t\tviewDir, \n\t\t\treflectionDir, \n#if defined(LIT_CLEARCOAT)\n\t\t\tclearcoatReflectionDir, \n#endif\n\t\t\tgloss, \n\t\t\tspecularity, \n\t\t\tgeometricNormal, \n\t\t\ttbn, \n#if defined(LIT_IRIDESCENCE)\n\t\t\tiridescenceFresnel,\n#endif\n\t\t\tclearcoat_worldNormal,\n\t\t\tclearcoat_gloss,\n\t\t\tsheen_gloss,\n\t\t\tiridescence_intensity\n\t\t);\n}\nvoid addClusteredLights(\n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tvec3 reflectionDir, \n#if defined(LIT_CLEARCOAT)\n\tvec3 clearcoatReflectionDir,\n#endif\n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 geometricNormal, \n\tmat3 tbn, \n#if defined(LIT_IRIDESCENCE)\n\tvec3 iridescenceFresnel,\n#endif\n\tvec3 clearcoat_worldNormal,\n\tfloat clearcoat_gloss,\n\tfloat sheen_gloss,\n\tfloat iridescence_intensity\n) {\n\tif (clusterSkip > 0.5)\n\t\treturn;\n\tvec3 cellCoords = floor((vPositionW - clusterBoundsMin) * clusterCellsCountByBoundsSize);\n\tif (!(any(lessThan(cellCoords, vec3(0.0))) || any(greaterThanEqual(cellCoords, clusterCellsMax)))) {\n\t\tfloat cellIndex = dot(clusterCellsDot, cellCoords);\n\t\tfloat clusterV = floor(cellIndex * clusterTextureSize.y);\n\t\tfloat clusterU = cellIndex - (clusterV * clusterTextureSize.x);\n\t\t#ifdef GL2\n\t\t\tfor (int lightCellIndex = 0; lightCellIndex < clusterMaxCells; lightCellIndex++) {\n\t\t\t\tfloat lightIndex = texelFetch(clusterWorldTexture, ivec2(int(clusterU) + lightCellIndex, clusterV), 0).x;\n\t\t\t\tif (lightIndex <= 0.0)\n\t\t\t\t\t\treturn;\n\t\t\t\tevaluateClusterLight(\n\t\t\t\t\tlightIndex * 255.0, \n\t\t\t\t\tworldNormal, \n\t\t\t\t\tviewDir, \n\t\t\t\t\treflectionDir,\n#if defined(LIT_CLEARCOAT)\n\t\t\t\t\tclearcoatReflectionDir,\n#endif\n\t\t\t\t\tgloss, \n\t\t\t\t\tspecularity, \n\t\t\t\t\tgeometricNormal, \n\t\t\t\t\ttbn, \n#if defined(LIT_IRIDESCENCE)\n\t\t\t\t\tiridescenceFresnel,\n#endif\n\t\t\t\t\tclearcoat_worldNormal,\n\t\t\t\t\tclearcoat_gloss,\n\t\t\t\t\tsheen_gloss,\n\t\t\t\t\tiridescence_intensity\n\t\t\t\t); \n\t\t\t}\n\t\t#else\n\t\t\tclusterV = (clusterV + 0.5) * clusterTextureSize.z;\n\t\t\tconst float maxLightCells = 256.0;\n\t\t\tfor (float lightCellIndex = 0.5; lightCellIndex < maxLightCells; lightCellIndex++) {\n\t\t\t\tfloat lightIndex = texture2DLodEXT(clusterWorldTexture, vec2(clusterTextureSize.y * (clusterU + lightCellIndex), clusterV), 0.0).x;\n\t\t\t\tif (lightIndex <= 0.0)\n\t\t\t\t\treturn;\n\t\t\t\t\n\t\t\t\tevaluateClusterLight(\n\t\t\t\t\tlightIndex * 255.0, \n\t\t\t\t\tworldNormal, \n\t\t\t\t\tviewDir, \n\t\t\t\t\treflectionDir,\n#if defined(LIT_CLEARCOAT)\n\t\t\t\t\tclearcoatReflectionDir,\n#endif\n\t\t\t\t\tgloss, \n\t\t\t\t\tspecularity, \n\t\t\t\t\tgeometricNormal, \n\t\t\t\t\ttbn, \n#if defined(LIT_IRIDESCENCE)\n\t\t\t\t\tiridescenceFresnel,\n#endif\n\t\t\t\t\tclearcoat_worldNormal,\n\t\t\t\t\tclearcoat_gloss,\n\t\t\t\t\tsheen_gloss,\n\t\t\t\t\tiridescence_intensity\n\t\t\t\t); \n\t\t\t\tif (lightCellIndex >= clusterMaxCells) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t#endif\n\t}\n}\n",combinePS:"\nvec3 combineColor(vec3 albedo, vec3 sheenSpecularity, float clearcoatSpecularity) {\n\tvec3 ret = vec3(0);\n#ifdef LIT_OLD_AMBIENT\n\tret += (dDiffuseLight - light_globalAmbient) * albedo + material_ambient * light_globalAmbient;\n#else\n\tret += albedo * dDiffuseLight;\n#endif\n#ifdef LIT_SPECULAR\n\tret += dSpecularLight;\n#endif\n#ifdef LIT_REFLECTIONS\n\tret += dReflection.rgb * dReflection.a;\n#endif\n#ifdef LIT_SHEEN\n\tfloat sheenScaling = 1.0 - max(max(sheenSpecularity.r, sheenSpecularity.g), sheenSpecularity.b) * 0.157;\n\tret = ret * sheenScaling + (sSpecularLight + sReflection.rgb) * sheenSpecularity;\n#endif\n#ifdef LIT_CLEARCOAT\n\tfloat clearCoatScaling = 1.0 - ccFresnel * clearcoatSpecularity;\n\tret = ret * clearCoatScaling + (ccSpecularLight + ccReflection.rgb) * clearcoatSpecularity;\n#endif\n\treturn ret;\n}\n",cookiePS:"\nvec4 getCookie2D(sampler2D tex, mat4 transform, float intensity) {\n\tvec4 projPos = transform * vec4(vPositionW, 1.0);\n\tprojPos.xy /= projPos.w;\n\treturn mix(vec4(1.0), texture2D(tex, projPos.xy), intensity);\n}\nvec4 getCookie2DClip(sampler2D tex, mat4 transform, float intensity) {\n\tvec4 projPos = transform * vec4(vPositionW, 1.0);\n\tprojPos.xy /= projPos.w;\n\tif (projPos.x < 0.0 || projPos.x > 1.0 || projPos.y < 0.0 || projPos.y > 1.0 || projPos.z < 0.0) return vec4(0.0);\n\treturn mix(vec4(1.0), texture2D(tex, projPos.xy), intensity);\n}\nvec4 getCookie2DXform(sampler2D tex, mat4 transform, float intensity, vec4 cookieMatrix, vec2 cookieOffset) {\n\tvec4 projPos = transform * vec4(vPositionW, 1.0);\n\tprojPos.xy /= projPos.w;\n\tprojPos.xy += cookieOffset;\n\tvec2 uv = mat2(cookieMatrix) * (projPos.xy-vec2(0.5)) + vec2(0.5);\n\treturn mix(vec4(1.0), texture2D(tex, uv), intensity);\n}\nvec4 getCookie2DClipXform(sampler2D tex, mat4 transform, float intensity, vec4 cookieMatrix, vec2 cookieOffset) {\n\tvec4 projPos = transform * vec4(vPositionW, 1.0);\n\tprojPos.xy /= projPos.w;\n\tprojPos.xy += cookieOffset;\n\tif (projPos.x < 0.0 || projPos.x > 1.0 || projPos.y < 0.0 || projPos.y > 1.0 || projPos.z < 0.0) return vec4(0.0);\n\tvec2 uv = mat2(cookieMatrix) * (projPos.xy-vec2(0.5)) + vec2(0.5);\n\treturn mix(vec4(1.0), texture2D(tex, uv), intensity);\n}\nvec4 getCookieCube(samplerCube tex, mat4 transform, float intensity) {\n\treturn mix(vec4(1.0), textureCube(tex, dLightDirNormW * mat3(transform)), intensity);\n}\n",cubeMapProjectBoxPS:"\nuniform vec3 envBoxMin;\nuniform vec3 envBoxMax;\nvec3 cubeMapProject(vec3 nrdir) {\n\tnrdir = cubeMapRotate(nrdir);\n\tvec3 rbmax = (envBoxMax - vPositionW) / nrdir;\n\tvec3 rbmin = (envBoxMin - vPositionW) / nrdir;\n\tvec3 rbminmax;\n\trbminmax.x = nrdir.x>0.0? rbmax.x : rbmin.x;\n\trbminmax.y = nrdir.y>0.0? rbmax.y : rbmin.y;\n\trbminmax.z = nrdir.z>0.0? rbmax.z : rbmin.z;\n\tfloat fa = min(min(rbminmax.x, rbminmax.y), rbminmax.z);\n\tvec3 posonbox = vPositionW + nrdir * fa;\n\tvec3 envBoxPos = (envBoxMin + envBoxMax) * 0.5;\n\treturn normalize(posonbox - envBoxPos);\n}\n",cubeMapProjectNonePS:"\nvec3 cubeMapProject(vec3 dir) {\n\treturn cubeMapRotate(dir);\n}\n",cubeMapRotatePS:"\n#ifdef CUBEMAP_ROTATION\nuniform mat3 cubeMapRotationMatrix;\n#endif\nvec3 cubeMapRotate(vec3 refDir) {\n#ifdef CUBEMAP_ROTATION\n\treturn refDir * cubeMapRotationMatrix;\n#else\n\treturn refDir;\n#endif\n}\n",debugOutputPS:"\n#ifdef DEBUG_ALBEDO_PASS\ngl_FragColor = vec4(gammaCorrectOutput(litArgs_albedo), 1.0);\n#endif\n#ifdef DEBUG_UV0_PASS\ngl_FragColor = vec4(litArgs_albedo , 1.0);\n#endif\n#ifdef DEBUG_WORLD_NORMAL_PASS\ngl_FragColor = vec4(litArgs_worldNormal * 0.5 + 0.5, 1.0);\n#endif\n#ifdef DEBUG_OPACITY_PASS\ngl_FragColor = vec4(vec3(litArgs_opacity) , 1.0);\n#endif\n#ifdef DEBUG_SPECULARITY_PASS\ngl_FragColor = vec4(litArgs_specularity, 1.0);\n#endif\n#ifdef DEBUG_GLOSS_PASS\ngl_FragColor = vec4(vec3(litArgs_gloss) , 1.0);\n#endif\n#ifdef DEBUG_METALNESS_PASS\ngl_FragColor = vec4(vec3(litArgs_metalness) , 1.0);\n#endif\n#ifdef DEBUG_AO_PASS\ngl_FragColor = vec4(vec3(litArgs_ao) , 1.0);\n#endif\n#ifdef DEBUG_EMISSION_PASS\ngl_FragColor = vec4(gammaCorrectOutput(litArgs_emission), 1.0);\n#endif\n",debugProcessFrontendPS:"\n#ifdef DEBUG_LIGHTING_PASS\nlitArgs_albedo = vec3(0.5);\n#endif\n#ifdef DEBUG_UV0_PASS\n#ifdef VARYING_VUV0\nlitArgs_albedo = vec3(vUv0, 0);\n#else\nlitArgs_albedo = vec3(0);\n#endif\n#endif\n",detailModesPS:"\nvec3 detailMode_mul(vec3 c1, vec3 c2) {\n\treturn c1 * c2;\n}\nvec3 detailMode_add(vec3 c1, vec3 c2) {\n\treturn c1 + c2;\n}\nvec3 detailMode_screen(vec3 c1, vec3 c2) {\n\treturn 1.0 - (1.0 - c1)*(1.0 - c2);\n}\nvec3 detailMode_overlay(vec3 c1, vec3 c2) {\n\treturn mix(1.0 - 2.0*(1.0 - c1)*(1.0 - c2), 2.0*c1*c2, step(c1, vec3(0.5)));\n}\nvec3 detailMode_min(vec3 c1, vec3 c2) {\n\treturn min(c1, c2);\n}\nvec3 detailMode_max(vec3 c1, vec3 c2) {\n\treturn max(c1, c2);\n}\n",diffusePS:"\n#ifdef MAPCOLOR\nuniform vec3 material_diffuse;\n#endif\nvoid getAlbedo() {\n\tdAlbedo = vec3(1.0);\n#ifdef MAPCOLOR\n\tdAlbedo *= material_diffuse.rgb;\n#endif\n#ifdef MAPTEXTURE\n\tvec3 albedoBase = $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\tdAlbedo *= addAlbedoDetail(albedoBase);\n#endif\n#ifdef MAPVERTEX\n\tdAlbedo *= gammaCorrectInput(saturate(vVertexColor.$VC));\n#endif\n}\n",diffuseDetailMapPS:"\nvec3 addAlbedoDetail(vec3 albedo) {\n#ifdef MAPTEXTURE\n\tvec3 albedoDetail = $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\treturn detailMode_$DETAILMODE(albedo, albedoDetail);\n#else\n\treturn albedo;\n#endif\n}\n",decodePS:So,emissivePS:"\n#ifdef MAPCOLOR\nuniform vec3 material_emissive;\n#endif\n#ifdef MAPFLOAT\nuniform float material_emissiveIntensity;\n#endif\nvoid getEmission() {\n\tdEmission = vec3(1.0);\n\t#ifdef MAPFLOAT\n\tdEmission *= material_emissiveIntensity;\n\t#endif\n\t#ifdef MAPCOLOR\n\tdEmission *= material_emissive;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tdEmission *= $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tdEmission *= gammaCorrectInput(saturate(vVertexColor.$VC));\n\t#endif\n}\n",encodePS:bo,endPS:"\n\tgl_FragColor.rgb = combineColor(litArgs_albedo, litArgs_sheen_specularity, litArgs_clearcoat_specularity);\n\tgl_FragColor.rgb += litArgs_emission;\n\tgl_FragColor.rgb = addFog(gl_FragColor.rgb);\n\t#ifndef HDR\n\tgl_FragColor.rgb = toneMap(gl_FragColor.rgb);\n\tgl_FragColor.rgb = gammaCorrectOutput(gl_FragColor.rgb);\n\t#endif\n",endVS:"\n",envAtlasPS:"\nconst float atlasSize = 512.0;\nconst float seamSize = 1.0 / atlasSize;\nvec2 mapUv(vec2 uv, vec4 rect) {\n\treturn vec2(mix(rect.x + seamSize, rect.x + rect.z - seamSize, uv.x),\n\t\t\t\tmix(rect.y + seamSize, rect.y + rect.w - seamSize, uv.y));\n}\nvec2 mapRoughnessUv(vec2 uv, float level) {\n\tfloat t = 1.0 / exp2(level);\n\treturn mapUv(uv, vec4(0, 1.0 - t, t, t * 0.5));\n}\nvec2 mapShinyUv(vec2 uv, float level) {\n\tfloat t = 1.0 / exp2(level);\n\treturn mapUv(uv, vec4(1.0 - t, 1.0 - t, t, t * 0.5));\n}\n",envConstPS:"\nvec3 processEnvironment(vec3 color) {\n\treturn color;\n}\n",envMultiplyPS:"\nuniform float skyboxIntensity;\nvec3 processEnvironment(vec3 color) {\n\treturn color * skyboxIntensity;\n}\n",extensionPS:"\n",extensionVS:"\n",falloffInvSquaredPS:"\nfloat getFalloffWindow(float lightRadius, vec3 lightDir) {\n\tfloat sqrDist = dot(lightDir, lightDir);\n\tfloat invRadius = 1.0 / lightRadius;\n\treturn square( saturate( 1.0 - square( sqrDist * square(invRadius) ) ) );\n}\nfloat getFalloffInvSquared(float lightRadius, vec3 lightDir) {\n\tfloat sqrDist = dot(lightDir, lightDir);\n\tfloat falloff = 1.0 / (sqrDist + 1.0);\n\tfloat invRadius = 1.0 / lightRadius;\n\tfalloff *= 16.0;\n\tfalloff *= square( saturate( 1.0 - square( sqrDist * square(invRadius) ) ) );\n\treturn falloff;\n}\n",falloffLinearPS:"\nfloat getFalloffLinear(float lightRadius, vec3 lightDir) {\n\tfloat d = length(lightDir);\n\treturn max(((lightRadius - d) / lightRadius), 0.0);\n}\n",fixCubemapSeamsNonePS:"\nvec3 fixSeams(vec3 vec, float mipmapIndex) {\n\treturn vec;\n}\nvec3 fixSeams(vec3 vec) {\n\treturn vec;\n}\nvec3 fixSeamsStatic(vec3 vec, float invRecMipSize) {\n\treturn vec;\n}\nvec3 calcSeam(vec3 vec) {\n\treturn vec3(0);\n}\nvec3 applySeam(vec3 vec, vec3 seam, float scale) {\n\treturn vec;\n}\n",fixCubemapSeamsStretchPS:"\nvec3 fixSeams(vec3 vec, float mipmapIndex) {\n\tvec3 avec = abs(vec);\n\tfloat scale = 1.0 - exp2(mipmapIndex) / 128.0;\n\tfloat M = max(max(avec.x, avec.y), avec.z);\n\tif (avec.x != M) vec.x *= scale;\n\tif (avec.y != M) vec.y *= scale;\n\tif (avec.z != M) vec.z *= scale;\n\treturn vec;\n}\nvec3 fixSeams(vec3 vec) {\n\tvec3 avec = abs(vec);\n\tfloat scale = 1.0 - 1.0 / 128.0;\n\tfloat M = max(max(avec.x, avec.y), avec.z);\n\tif (avec.x != M) vec.x *= scale;\n\tif (avec.y != M) vec.y *= scale;\n\tif (avec.z != M) vec.z *= scale;\n\treturn vec;\n}\nvec3 fixSeamsStatic(vec3 vec, float invRecMipSize) {\n\tvec3 avec = abs(vec);\n\tfloat scale = invRecMipSize;\n\tfloat M = max(max(avec.x, avec.y), avec.z);\n\tif (avec.x != M) vec.x *= scale;\n\tif (avec.y != M) vec.y *= scale;\n\tif (avec.z != M) vec.z *= scale;\n\treturn vec;\n}\nvec3 calcSeam(vec3 vec) {\n\tvec3 avec = abs(vec);\n\tfloat M = max(avec.x, max(avec.y, avec.z));\n\treturn vec3(avec.x != M ? 1.0 : 0.0,\n\t\t\t\tavec.y != M ? 1.0 : 0.0,\n\t\t\t\tavec.z != M ? 1.0 : 0.0);\n}\nvec3 applySeam(vec3 vec, vec3 seam, float scale) {\n\treturn vec * (seam * -scale + vec3(1.0));\n}\n",floatUnpackingPS:"\nfloat bytes2float2(vec2 data) {\n\treturn dot(data, vec2(1.0, 1.0 / 255.0));\n}\nfloat bytes2float3(vec3 data) {\n\treturn dot(data, vec3(1.0, 1.0 / 255.0, 1.0 / 65025.0));\n}\nfloat bytes2float4(vec4 data) {\n\treturn dot(data, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n}\nfloat bytes2floatRange2(vec2 data, float min, float max) {\n\treturn mix(min, max, bytes2float2(data));\n}\nfloat bytes2floatRange3(vec3 data, float min, float max) {\n\treturn mix(min, max, bytes2float3(data));\n}\nfloat bytes2floatRange4(vec4 data, float min, float max) {\n\treturn mix(min, max, bytes2float4(data));\n}\nfloat mantissaExponent2Float(vec4 pack)\n{\n\tfloat value = bytes2floatRange3(pack.xyz, -1.0, 1.0);\n\tfloat exponent = floor(pack.w * 255.0 - 127.0);\n\treturn value * exp2(exponent);\n}\n",fogExpPS:"\nuniform vec3 fog_color;\nuniform float fog_density;\nfloat dBlendModeFogFactor = 1.0;\nvec3 addFog(vec3 color) {\n\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\tfloat fogFactor = exp(-depth * fog_density);\n\tfogFactor = clamp(fogFactor, 0.0, 1.0);\n\treturn mix(fog_color * dBlendModeFogFactor, color, fogFactor);\n}\n",fogExp2PS:"\nuniform vec3 fog_color;\nuniform float fog_density;\nfloat dBlendModeFogFactor = 1.0;\nvec3 addFog(vec3 color) {\n\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\tfloat fogFactor = exp(-depth * depth * fog_density * fog_density);\n\tfogFactor = clamp(fogFactor, 0.0, 1.0);\n\treturn mix(fog_color * dBlendModeFogFactor, color, fogFactor);\n}\n",fogLinearPS:"\nuniform vec3 fog_color;\nuniform float fog_start;\nuniform float fog_end;\nfloat dBlendModeFogFactor = 1.0;\nvec3 addFog(vec3 color) {\n\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\tfloat fogFactor = (fog_end - depth) / (fog_end - fog_start);\n\tfogFactor = clamp(fogFactor, 0.0, 1.0);\n\treturn mix(fog_color * dBlendModeFogFactor, color, fogFactor);\n}\n",fogNonePS:"\nfloat dBlendModeFogFactor = 1.0;\nvec3 addFog(vec3 color) {\n\treturn color;\n}\n",fresnelSchlickPS:"\nvec3 getFresnel(\n\t\tfloat cosTheta, \n\t\tfloat gloss, \n\t\tvec3 specularity\n#if defined(LIT_IRIDESCENCE)\n\t\t, vec3 iridescenceFresnel, \n\t\tfloat iridescenceIntensity\n#endif\n\t) {\n\tfloat fresnel = pow(1.0 - max(cosTheta, 0.0), 5.0);\n\tfloat glossSq = gloss * gloss;\n\tvec3 ret = specularity + (max(vec3(glossSq), specularity) - specularity) * fresnel;\n#if defined(LIT_IRIDESCENCE)\n\treturn mix(ret, iridescenceFresnel, iridescenceIntensity);\n#else\n\treturn ret;\n#endif\t\n}\nfloat getFresnelCC(float cosTheta) {\n\tfloat fresnel = pow(1.0 - max(cosTheta, 0.0), 5.0);\n\treturn 0.04 + (1.0 - 0.04) * fresnel;\n}\n",fullscreenQuadPS:"\nvarying vec2 vUv0;\nuniform sampler2D source;\nvoid main(void) {\n\tgl_FragColor = texture2D(source, vUv0);\n}\n",fullscreenQuadVS:"\nattribute vec2 vertex_position;\nvarying vec2 vUv0;\nvoid main(void)\n{\n\tgl_Position = vec4(vertex_position, 0.5, 1.0);\n\tvUv0 = vertex_position.xy*0.5+0.5;\n}\n",gamma1_0PS:"\nfloat gammaCorrectInput(float color) {\n\treturn color;\n}\nvec3 gammaCorrectInput(vec3 color) {\n\treturn color;\n}\nvec4 gammaCorrectInput(vec4 color) {\n\treturn color;\n}\nvec3 gammaCorrectOutput(vec3 color) {\n\treturn color;\n}\n",gamma2_2PS:"\nfloat gammaCorrectInput(float color) {\n\treturn decodeGamma(color);\n}\nvec3 gammaCorrectInput(vec3 color) {\n\treturn decodeGamma(color);\n}\nvec4 gammaCorrectInput(vec4 color) {\n\treturn vec4(decodeGamma(color.xyz), color.w);\n}\nvec3 gammaCorrectOutput(vec3 color) {\n#ifdef HDR\n\treturn color;\n#else\n\treturn pow(color + 0.0000001, vec3(1.0 / 2.2));\n#endif\n}\n",gles2PS:er,gles3PS:ir,gles3VS:nr,glossPS:"\n#ifdef MAPFLOAT\nuniform float material_gloss;\n#endif\nvoid getGlossiness() {\n\tdGlossiness = 1.0;\n\t#ifdef MAPFLOAT\n\tdGlossiness *= material_gloss;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tdGlossiness *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tdGlossiness *= saturate(vVertexColor.$VC);\n\t#endif\n\t#ifdef MAPINVERT\n\tdGlossiness = 1.0 - dGlossiness;\n\t#endif\n\tdGlossiness += 0.0000001;\n}\n",iridescenceDiffractionPS:"\nuniform float material_iridescenceRefractionIndex;\n#ifndef PI\n#define PI 3.14159265\n#endif\nfloat iridescence_iorToFresnel(float transmittedIor, float incidentIor) {\n\treturn pow((transmittedIor - incidentIor) / (transmittedIor + incidentIor), 2.0);\n}\nvec3 iridescence_iorToFresnel(vec3 transmittedIor, float incidentIor) {\n\treturn pow((transmittedIor - vec3(incidentIor)) / (transmittedIor + vec3(incidentIor)), vec3(2.0));\n}\nvec3 iridescence_fresnelToIor(vec3 f0) {\n\tvec3 sqrtF0 = sqrt(f0);\n\treturn (vec3(1.0) + sqrtF0) / (vec3(1.0) - sqrtF0);\n}\nvec3 iridescence_sensitivity(float opd, vec3 shift) {\n\tfloat phase = 2.0 * PI * opd * 1.0e-9;\n\tconst vec3 val = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);\n\tconst vec3 pos = vec3(1.6810e+06, 1.7953e+06, 2.2084e+06);\n\tconst vec3 var = vec3(4.3278e+09, 9.3046e+09, 6.6121e+09);\n\tvec3 xyz = val * sqrt(2.0 * PI * var) * cos(pos * phase + shift) * exp(-pow(phase, 2.0) * var);\n\txyz.x += 9.7470e-14 * sqrt(2.0 * PI * 4.5282e+09) * cos(2.2399e+06 * phase + shift[0]) * exp(-4.5282e+09 * pow(phase, 2.0));\n\txyz /= vec3(1.0685e-07);\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t3.2404542, -0.9692660, 0.0556434,\n\t -1.5371385, 1.8760108, -0.2040259,\n\t -0.4985314, 0.0415560, 1.0572252\n\t);\n\treturn XYZ_TO_REC709 * xyz;\n}\nfloat iridescence_fresnel(float cosTheta, float f0) {\n\tfloat x = clamp(1.0 - cosTheta, 0.0, 1.0);\n\tfloat x2 = x * x;\n\tfloat x5 = x * x2 * x2;\n\treturn f0 + (1.0 - f0) * x5;\n} \nvec3 iridescence_fresnel(float cosTheta, vec3 f0) {\n\tfloat x = clamp(1.0 - cosTheta, 0.0, 1.0);\n\tfloat x2 = x * x;\n\tfloat x5 = x * x2 * x2; \n\treturn f0 + (vec3(1.0) - f0) * x5;\n}\nvec3 calcIridescence(float outsideIor, float cosTheta, vec3 base_f0, float iridescenceThickness) {\n\tfloat iridescenceIor = mix(outsideIor, material_iridescenceRefractionIndex, smoothstep(0.0, 0.03, iridescenceThickness));\n\tfloat sinTheta2Sq = pow(outsideIor / iridescenceIor, 2.0) * (1.0 - pow(cosTheta, 2.0));\n\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\tif (cosTheta2Sq < 0.0) {\n\t\treturn vec3(1.0);\n\t}\n\tfloat cosTheta2 = sqrt(cosTheta2Sq);\n\tfloat r0 = iridescence_iorToFresnel(iridescenceIor, outsideIor);\n\tfloat r12 = iridescence_fresnel(cosTheta, r0);\n\tfloat r21 = r12;\n\tfloat t121 = 1.0 - r12;\n\tfloat phi12 = iridescenceIor < outsideIor ? PI : 0.0;\n\tfloat phi21 = PI - phi12;\n\tvec3 baseIor = iridescence_fresnelToIor(base_f0 + vec3(0.0001));\n\tvec3 r1 = iridescence_iorToFresnel(baseIor, iridescenceIor);\n\tvec3 r23 = iridescence_fresnel(cosTheta2, r1);\n\tvec3 phi23 = vec3(0.0);\n\tif (baseIor[0] < iridescenceIor) phi23[0] = PI;\n\tif (baseIor[1] < iridescenceIor) phi23[1] = PI;\n\tif (baseIor[2] < iridescenceIor) phi23[2] = PI;\n\tfloat opd = 2.0 * iridescenceIor * iridescenceThickness * cosTheta2;\n\tvec3 phi = vec3(phi21) + phi23; \n\tvec3 r123Sq = clamp(r12 * r23, 1e-5, 0.9999);\n\tvec3 r123 = sqrt(r123Sq);\n\tvec3 rs = pow(t121, 2.0) * r23 / (1.0 - r123Sq);\n\tvec3 c0 = r12 + rs;\n\tvec3 i = c0;\n\tvec3 cm = rs - t121;\n\tfor (int m = 1; m <= 2; m++) {\n\t\tcm *= r123;\n\t\tvec3 sm = 2.0 * iridescence_sensitivity(float(m) * opd, float(m) * phi);\n\t\ti += cm * sm;\n\t}\n\treturn max(i, vec3(0.0));\n}\nvec3 getIridescence(float cosTheta, vec3 specularity, float iridescenceThickness) {\n\treturn calcIridescence(1.0, cosTheta, specularity, iridescenceThickness);\n}\n",iridescencePS:"\n#ifdef MAPFLOAT\nuniform float material_iridescence;\n#endif\nvoid getIridescence() {\n\tfloat iridescence = 1.0;\n\t#ifdef MAPFLOAT\n\tiridescence *= material_iridescence;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tiridescence *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\tdIridescence = iridescence; \n}\n",iridescenceThicknessPS:"\nuniform float material_iridescenceThicknessMax;\n#ifdef MAPTEXTURE\nuniform float material_iridescenceThicknessMin;\n#endif\nvoid getIridescenceThickness() {\n\t#ifdef MAPTEXTURE\n\tfloat blend = texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\tfloat iridescenceThickness = mix(material_iridescenceThicknessMin, material_iridescenceThicknessMax, blend);\n\t#else\n\tfloat iridescenceThickness = material_iridescenceThicknessMax;\n\t#endif\n\tdIridescenceThickness = iridescenceThickness; \n}\n",instancingVS:"\nattribute vec4 instance_line1;\nattribute vec4 instance_line2;\nattribute vec4 instance_line3;\nattribute vec4 instance_line4;\n",iorPS:"\n#ifdef MAPFLOAT\nuniform float material_refractionIndex;\n#endif\nvoid getIor() {\n#ifdef MAPFLOAT\n\tdIor = material_refractionIndex;\n#else\n\tdIor = 1.0 / 1.5;\n#endif\n}\n",lightDiffuseLambertPS:"\nfloat getLightDiffuse(vec3 worldNormal, vec3 viewDir, vec3 lightDir, vec3 lightDirNorm) {\n\treturn max(dot(worldNormal, -lightDirNorm), 0.0);\n}\n",lightDirPointPS:"\nvoid getLightDirPoint(vec3 lightPosW) {\n\tdLightDirW = vPositionW - lightPosW;\n\tdLightDirNormW = normalize(dLightDirW);\n\tdLightPosW = lightPosW;\n}\n",lightmapAddPS:"\nvoid addLightMap(\n\tvec3 lightmap, \n\tvec3 dir, \n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tvec3 reflectionDir, \n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 vertexNormal, \n\tmat3 tbn\n#if defined(LIT_IRIDESCENCE)\n\tvec3 iridescenceFresnel, \n\tfloat iridescenceIntensity\n#endif\n) {\n\tdDiffuseLight += lightmap;\n}\n",lightmapDirAddPS:"\nvoid addLightMap(\n\tvec3 lightmap, \n\tvec3 dir, \n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tvec3 reflectionDir, \n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 vertexNormal, \n\tmat3 tbn\n#if defined(LIT_IRIDESCENCE)\n\tvec3 iridescenceFresnel, \n\tfloat iridescenceIntensity\n#endif\n) {\n\tif (dot(dir, dir) < 0.0001) {\n\t\tdDiffuseLight += lightmap;\n\t} else {\n\t\tfloat vlight = saturate(dot(dir, -vertexNormal));\n\t\tfloat flight = saturate(dot(dir, -worldNormal));\n\t\tfloat nlight = (flight / max(vlight, 0.01)) * 0.5;\n\t\tdDiffuseLight += lightmap * nlight * 2.0;\n\t\tvec3 halfDir = normalize(-dir + viewDir);\n\t\tvec3 specularLight = lightmap * getLightSpecular(halfDir, reflectionDir, worldNormal, viewDir, dir, gloss, tbn);\n#ifdef LIT_SPECULAR_FRESNEL\n\t\tspecularLight *= \n\t\t\tgetFresnel(dot(viewDir, halfDir), \n\t\t\tgloss, \n\t\t\tspecularity\n\t\t#if defined(LIT_IRIDESCENCE)\n\t\t\t, iridescenceFresnel,\n\t\t\tiridescenceIntensity\n\t\t#endif\n\t\t\t);\n#endif\n\t\tdSpecularLight += specularLight;\n\t}\n}\n",lightmapDirPS:"\nuniform sampler2D texture_lightMap;\nuniform sampler2D texture_dirLightMap;\nvoid getLightMap() {\n\tdLightmap = $DECODE(texture2DBias(texture_lightMap, $UV, textureBias)).$CH;\n\tvec3 dir = texture2DBias(texture_dirLightMap, $UV, textureBias).xyz * 2.0 - 1.0;\n\tfloat dirDot = dot(dir, dir);\n\tdLightmapDir = (dirDot > 0.001) ? dir / sqrt(dirDot) : vec3(0.0);\n}\n",lightmapSinglePS:"\nvoid getLightMap() {\n\tdLightmap = vec3(1.0);\n\t#ifdef MAPTEXTURE\n\tdLightmap *= $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tdLightmap *= saturate(vVertexColor.$VC);\n\t#endif\n}\n",lightSpecularAnisoGGXPS:"\nfloat calcLightSpecular(float gloss, vec3 worldNormal, vec3 viewDir, vec3 h, vec3 lightDirNorm, mat3 tbn) {\n\tfloat PI = 3.141592653589793;\n\tfloat roughness = max((1.0 - gloss) * (1.0 - gloss), 0.001);\n\tfloat anisotropy = material_anisotropy * roughness;\n \n\tfloat at = max((roughness + anisotropy), roughness / 4.0);\n\tfloat ab = max((roughness - anisotropy), roughness / 4.0);\n\tfloat NoH = dot(worldNormal, h);\n\tfloat ToH = dot(tbn[0], h);\n\tfloat BoH = dot(tbn[1], h);\n\tfloat a2 = at * ab;\n\tvec3 v = vec3(ab * ToH, at * BoH, a2 * NoH);\n\tfloat v2 = dot(v, v);\n\tfloat w2 = a2 / v2;\n\tfloat D = a2 * w2 * w2 * (1.0 / PI);\n\tfloat ToV = dot(tbn[0], viewDir);\n\tfloat BoV = dot(tbn[1], viewDir);\n\tfloat ToL = dot(tbn[0], -lightDirNorm);\n\tfloat BoL = dot(tbn[1], -lightDirNorm);\n\tfloat NoV = dot(worldNormal, viewDir);\n\tfloat NoL = dot(worldNormal, -lightDirNorm);\n\tfloat lambdaV = NoL * length(vec3(at * ToV, ab * BoV, NoV));\n\tfloat lambdaL = NoV * length(vec3(at * ToL, ab * BoL, NoL));\n\tfloat G = 0.5 / (lambdaV + lambdaL);\n\treturn D * G;\n}\nfloat getLightSpecular(vec3 h, vec3 reflDir, vec3 worldNormal, vec3 viewDir, vec3 lightDirNorm, float gloss, mat3 tbn) {\n\treturn calcLightSpecular(gloss, worldNormal, viewDir, h, lightDirNorm, tbn);\n}\n",lightSpecularBlinnPS:"\nfloat calcLightSpecular(float gloss, vec3 worldNormal, vec3 h) {\n\tfloat nh = max( dot( h, worldNormal ), 0.0 );\n\tfloat specPow = exp2(gloss * 11.0);\n\tspecPow = max(specPow, 0.0001);\n\treturn pow(nh, specPow) * (specPow + 2.0) / 8.0;\n}\nfloat getLightSpecular(vec3 h, vec3 reflDir, vec3 worldNormal, vec3 viewDir, vec3 lightDirNorm, float gloss, mat3 tbn) {\n\treturn calcLightSpecular(gloss, worldNormal, h);\n}\n",lightSpecularPhongPS:"\nfloat calcLightSpecular(float gloss, vec3 reflDir, vec3 lightDirNorm) {\n\tfloat specPow = gloss;\n\treturn pow(max(dot(reflDir, -lightDirNorm), 0.0), specPow + 0.0001);\n}\nfloat getLightSpecular(vec3 h, vec3 reflDir, vec3 worldNormal, vec3 viewDir, vec3 lightDirNorm, float gloss, mat3 tbn) {\n\treturn calcLightSpecular(gloss, reflDir, lightDirNorm);\n}\n",lightSheenPS:"\nfloat sheenD(vec3 normal, vec3 h, float roughness) {\n\tfloat invR = 1.0 / (roughness * roughness);\n\tfloat cos2h = max(dot(normal, h), 0.0);\n\tcos2h *= cos2h;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\n\treturn (2.0 + invR) * pow(sin2h, invR * 0.5) / (2.0 * PI);\n}\nfloat sheenV(vec3 normal, vec3 viewDir, vec3 light) {\n\tfloat NoV = max(dot(normal, viewDir), 0.000001);\n\tfloat NoL = max(dot(normal, light), 0.000001);\n\treturn 1.0 / (4.0 * (NoL + NoV - NoL * NoV));\n}\nfloat getLightSpecularSheen(vec3 h, vec3 worldNormal, vec3 viewDir, vec3 lightDirNorm, float sheenGloss) {\n\tfloat D = sheenD(worldNormal, h, sheenGloss);\n\tfloat V = sheenV(worldNormal, viewDir, -lightDirNorm);\n\treturn D * V;\n}\n",linearizeDepthPS:"\n#ifndef LINEARIZE_DEPTH\n#define LINEARIZE_DEPTH\nfloat linearizeDepth(float z, vec4 cameraParams) {\n\tif (cameraParams.w == 0.0)\n\t\treturn (cameraParams.z * cameraParams.y) / (cameraParams.y + z * (cameraParams.z - cameraParams.y));\n\telse\n\t\treturn cameraParams.z + z * (cameraParams.y - cameraParams.z);\n}\n#ifndef CAMERAPLANES\n#define CAMERAPLANES\nuniform vec4 camera_params;\n#endif\n#ifdef GL2\nfloat linearizeDepth(float z) {\n\treturn linearizeDepth(z, camera_params);\n}\n#else\n#ifndef UNPACKFLOAT\n#define UNPACKFLOAT\nfloat unpackFloat(vec4 rgbaDepth) {\n\tconst vec4 bitShift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n\treturn dot(rgbaDepth, bitShift);\n}\n#endif\n#endif\n#endif\n",litShaderArgsPS:"\nvec3 litArgs_albedo;\nfloat litArgs_opacity;\nvec3 litArgs_emission;\nvec3 litArgs_worldNormal;\nfloat litArgs_ao;\nvec3 litArgs_lightmap;\nvec3 litArgs_lightmapDir;\nfloat litArgs_metalness;\nvec3 litArgs_specularity;\nfloat litArgs_specularityFactor;\nfloat litArgs_gloss;\nfloat litArgs_sheen_gloss;\nvec3 litArgs_sheen_specularity;\nfloat litArgs_transmission;\nfloat litArgs_thickness;\nfloat litArgs_ior;\nfloat litArgs_iridescence_intensity;\nfloat litArgs_iridescence_thickness;\nvec3 litArgs_clearcoat_worldNormal;\nfloat litArgs_clearcoat_specularity;\nfloat litArgs_clearcoat_gloss;\n",ltcPS:"\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nstruct Coords {\n\tvec3 coord0;\n\tvec3 coord1;\n\tvec3 coord2;\n\tvec3 coord3;\n};\nfloat LTC_EvaluateRect( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in Coords rectCoords) {\n\tvec3 v1 = rectCoords.coord1 - rectCoords.coord0;\n\tvec3 v2 = rectCoords.coord3 - rectCoords.coord0;\n\t\n\tvec3 lightNormal = cross( v1, v2 );\n\tfloat factor = sign(-dot( lightNormal, P - rectCoords.coord0 ));\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = factor * cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords.coord0 - P );\n\tcoords[ 1 ] = mat * ( rectCoords.coord1 - P );\n\tcoords[ 2 ] = mat * ( rectCoords.coord2 - P );\n\tcoords[ 3 ] = mat * ( rectCoords.coord3 - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn result;\n}\nCoords dLTCCoords;\nCoords getLTCLightCoords(vec3 lightPos, vec3 halfWidth, vec3 halfHeight){\n\tCoords coords;\n\tcoords.coord0 = lightPos + halfWidth - halfHeight;\n\tcoords.coord1 = lightPos - halfWidth - halfHeight;\n\tcoords.coord2 = lightPos - halfWidth + halfHeight;\n\tcoords.coord3 = lightPos + halfWidth + halfHeight;\n\treturn coords;\n}\nfloat dSphereRadius;\nCoords getSphereLightCoords(vec3 lightPos, vec3 halfWidth, vec3 halfHeight){\n\tdSphereRadius = max(length(halfWidth), length(halfHeight));\n\tvec3 f = reflect(normalize(lightPos - view_position), vNormalW);\n\tvec3 w = normalize(cross(f, halfHeight));\n\tvec3 h = normalize(cross(f, w));\n\treturn getLTCLightCoords(lightPos, w * dSphereRadius, h * dSphereRadius);\n}\nvec2 dLTCUV;\n#ifdef LIT_CLEARCOAT\nvec2 ccLTCUV;\n#endif\nvec2 getLTCLightUV(float gloss, vec3 worldNormal, vec3 viewDir)\n{\n\tfloat roughness = max((1.0 - gloss) * (1.0 - gloss), 0.001);\n\treturn LTC_Uv( worldNormal, viewDir, roughness );\n}\nvec3 dLTCSpecFres;\n#ifdef LIT_CLEARCOAT\nvec3 ccLTCSpecFres;\n#endif\nvec3 getLTCLightSpecFres(vec2 uv, vec3 specularity)\n{\n\tvec4 t2 = texture2DLodEXT(areaLightsLutTex2, uv, 0.0);\n\t#ifdef AREA_R8_G8_B8_A8_LUTS\n\tt2 *= vec4(0.693103,1,1,1);\n\tt2 += vec4(0.306897,0,0,0);\n\t#endif\n\treturn specularity * t2.x + ( vec3( 1.0 ) - specularity) * t2.y;\n}\nvoid calcLTCLightValues(float gloss, vec3 worldNormal, vec3 viewDir, vec3 specularity, float clearcoatGloss, vec3 clearcoatWorldNormal, float clearcoatSpecularity)\n{\n\tdLTCUV = getLTCLightUV(gloss, worldNormal, viewDir);\n\tdLTCSpecFres = getLTCLightSpecFres(dLTCUV, specularity); \n#ifdef LIT_CLEARCOAT\n\tccLTCUV = getLTCLightUV(clearcoatGloss, clearcoatWorldNormal, viewDir);\n\tccLTCSpecFres = getLTCLightSpecFres(ccLTCUV, vec3(clearcoatSpecularity));\n#endif\n}\nvoid calcRectLightValues(vec3 lightPos, vec3 halfWidth, vec3 halfHeight)\n{\n\tdLTCCoords = getLTCLightCoords(lightPos, halfWidth, halfHeight);\n}\nvoid calcDiskLightValues(vec3 lightPos, vec3 halfWidth, vec3 halfHeight)\n{\n\tcalcRectLightValues(lightPos, halfWidth, halfHeight);\n}\nvoid calcSphereLightValues(vec3 lightPos, vec3 halfWidth, vec3 halfHeight)\n{\n\tdLTCCoords = getSphereLightCoords(lightPos, halfWidth, halfHeight);\n}\nvec3 SolveCubic(vec4 Coefficient)\n{\n\tfloat pi = 3.14159;\n\tCoefficient.xyz /= Coefficient.w;\n\tCoefficient.yz /= 3.0;\n\tfloat A = Coefficient.w;\n\tfloat B = Coefficient.z;\n\tfloat C = Coefficient.y;\n\tfloat D = Coefficient.x;\n\tvec3 Delta = vec3(\n\t\t-Coefficient.z * Coefficient.z + Coefficient.y,\n\t\t-Coefficient.y * Coefficient.z + Coefficient.x,\n\t\tdot(vec2(Coefficient.z, -Coefficient.y), Coefficient.xy)\n\t);\n\tfloat Discriminant = dot(vec2(4.0 * Delta.x, -Delta.y), Delta.zy);\n\tvec3 RootsA, RootsD;\n\tvec2 xlc, xsc;\n\t{\n\t\tfloat A_a = 1.0;\n\t\tfloat C_a = Delta.x;\n\t\tfloat D_a = -2.0 * B * Delta.x + Delta.y;\n\t\tfloat Theta = atan(sqrt(Discriminant), -D_a) / 3.0;\n\t\tfloat x_1a = 2.0 * sqrt(-C_a) * cos(Theta);\n\t\tfloat x_3a = 2.0 * sqrt(-C_a) * cos(Theta + (2.0 / 3.0) * pi);\n\t\tfloat xl;\n\t\tif ((x_1a + x_3a) > 2.0 * B)\n\t\t\txl = x_1a;\n\t\telse\n\t\t\txl = x_3a;\n\t\txlc = vec2(xl - B, A);\n\t}\n\t{\n\t\tfloat A_d = D;\n\t\tfloat C_d = Delta.z;\n\t\tfloat D_d = -D * Delta.y + 2.0 * C * Delta.z;\n\t\tfloat Theta = atan(D * sqrt(Discriminant), -D_d) / 3.0;\n\t\tfloat x_1d = 2.0 * sqrt(-C_d) * cos(Theta);\n\t\tfloat x_3d = 2.0 * sqrt(-C_d) * cos(Theta + (2.0 / 3.0) * pi);\n\t\tfloat xs;\n\t\tif (x_1d + x_3d < 2.0 * C)\n\t\t\txs = x_1d;\n\t\telse\n\t\t\txs = x_3d;\n\t\txsc = vec2(-D, xs + C);\n\t}\n\tfloat E = xlc.y * xsc.y;\n\tfloat F = -xlc.x * xsc.y - xlc.y * xsc.x;\n\tfloat G = xlc.x * xsc.x;\n\tvec2 xmc = vec2(C * F - B * G, -B * F + C * E);\n\tvec3 Root = vec3(xsc.x / xsc.y, xmc.x / xmc.y, xlc.x / xlc.y);\n\tif (Root.x < Root.y && Root.x < Root.z)\n\t\tRoot.xyz = Root.yxz;\n\telse if (Root.z < Root.x && Root.z < Root.y)\n\t\tRoot.xyz = Root.xzy;\n\treturn Root;\n}\nfloat LTC_EvaluateDisk(vec3 N, vec3 V, vec3 P, mat3 Minv, Coords points)\n{\n\tvec3 T1, T2;\n\tT1 = normalize(V - N * dot(V, N));\n\tT2 = cross(N, T1);\n\tmat3 R = transposeMat3( mat3( T1, T2, N ) );\n\tvec3 L_[ 3 ];\n\tL_[ 0 ] = R * ( points.coord0 - P );\n\tL_[ 1 ] = R * ( points.coord1 - P );\n\tL_[ 2 ] = R * ( points.coord2 - P );\n\tvec3 Lo_i = vec3(0);\n\tvec3 C = 0.5 * (L_[0] + L_[2]);\n\tvec3 V1 = 0.5 * (L_[1] - L_[2]);\n\tvec3 V2 = 0.5 * (L_[1] - L_[0]);\n\tC = Minv * C;\n\tV1 = Minv * V1;\n\tV2 = Minv * V2;\n\tfloat a, b;\n\tfloat d11 = dot(V1, V1);\n\tfloat d22 = dot(V2, V2);\n\tfloat d12 = dot(V1, V2);\n\tif (abs(d12) / sqrt(d11 * d22) > 0.0001)\n\t{\n\t\tfloat tr = d11 + d22;\n\t\tfloat det = -d12 * d12 + d11 * d22;\n\t\tdet = sqrt(det);\n\t\tfloat u = 0.5 * sqrt(tr - 2.0 * det);\n\t\tfloat v = 0.5 * sqrt(tr + 2.0 * det);\n\t\tfloat e_max = (u + v) * (u + v);\n\t\tfloat e_min = (u - v) * (u - v);\n\t\tvec3 V1_, V2_;\n\t\tif (d11 > d22)\n\t\t{\n\t\t\tV1_ = d12 * V1 + (e_max - d11) * V2;\n\t\t\tV2_ = d12 * V1 + (e_min - d11) * V2;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tV1_ = d12*V2 + (e_max - d22)*V1;\n\t\t\tV2_ = d12*V2 + (e_min - d22)*V1;\n\t\t}\n\t\ta = 1.0 / e_max;\n\t\tb = 1.0 / e_min;\n\t\tV1 = normalize(V1_);\n\t\tV2 = normalize(V2_);\n\t}\n\telse\n\t{\n\t\ta = 1.0 / dot(V1, V1);\n\t\tb = 1.0 / dot(V2, V2);\n\t\tV1 *= sqrt(a);\n\t\tV2 *= sqrt(b);\n\t}\n\tvec3 V3 = cross(V1, V2);\n\tif (dot(C, V3) < 0.0)\n\t\tV3 *= -1.0;\n\tfloat L = dot(V3, C);\n\tfloat x0 = dot(V1, C) / L;\n\tfloat y0 = dot(V2, C) / L;\n\tfloat E1 = inversesqrt(a);\n\tfloat E2 = inversesqrt(b);\n\ta *= L * L;\n\tb *= L * L;\n\tfloat c0 = a * b;\n\tfloat c1 = a * b * (1.0 + x0 * x0 + y0 * y0) - a - b;\n\tfloat c2 = 1.0 - a * (1.0 + x0 * x0) - b * (1.0 + y0 * y0);\n\tfloat c3 = 1.0;\n\tvec3 roots = SolveCubic(vec4(c0, c1, c2, c3));\n\tfloat e1 = roots.x;\n\tfloat e2 = roots.y;\n\tfloat e3 = roots.z;\n\tvec3 avgDir = vec3(a * x0 / (a - e2), b * y0 / (b - e2), 1.0);\n\tmat3 rotate = mat3(V1, V2, V3);\n\tavgDir = rotate * avgDir;\n\tavgDir = normalize(avgDir);\n\tfloat L1 = sqrt(-e2 / e3);\n\tfloat L2 = sqrt(-e2 / e1);\n\tfloat formFactor = L1 * L2 * inversesqrt((1.0 + L1 * L1) * (1.0 + L2 * L2));\n\t\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tvec2 uv = vec2(avgDir.z * 0.5 + 0.5, formFactor);\n\tuv = uv*LUT_SCALE + LUT_BIAS;\n\tfloat scale = texture2DLodEXT(areaLightsLutTex2, uv, 0.0).w;\n\treturn formFactor*scale;\n}\nfloat getRectLightDiffuse(vec3 worldNormal, vec3 viewDir, vec3 lightDir, vec3 lightDirNorm) {\n\treturn LTC_EvaluateRect( worldNormal, viewDir, vPositionW, mat3( 1.0 ), dLTCCoords );\n}\nfloat getDiskLightDiffuse(vec3 worldNormal, vec3 viewDir, vec3 lightDir, vec3 lightDirNorm) {\n\treturn LTC_EvaluateDisk( worldNormal, viewDir, vPositionW, mat3( 1.0 ), dLTCCoords );\n}\nfloat getSphereLightDiffuse(vec3 worldNormal, vec3 viewDir, vec3 lightDir, vec3 lightDirNorm) {\n\tfloat falloff = dSphereRadius / (dot(lightDir, lightDir) + dSphereRadius);\n\treturn getLightDiffuse(worldNormal, viewDir, lightDir, lightDirNorm) * falloff;\n}\nmat3 getLTCLightInvMat(vec2 uv)\n{\n\tvec4 t1 = texture2DLodEXT(areaLightsLutTex1, uv, 0.0);\n\t#ifdef AREA_R8_G8_B8_A8_LUTS\n\tt1 *= vec4(1.001, 0.3239, 0.60437568, 1.0);\n\tt1 += vec4(0.0, -0.2976, -0.01381, 0.0);\n\t#endif\n\treturn mat3(\n\t\tvec3( t1.x, 0, t1.y ),\n\t\tvec3(\t0, 1,\t0 ),\n\t\tvec3( t1.z, 0, t1.w )\n\t);\n}\nfloat calcRectLightSpecular(vec3 worldNormal, vec3 viewDir, vec2 uv) {\n\tmat3 mInv = getLTCLightInvMat(uv);\n\treturn LTC_EvaluateRect( worldNormal, viewDir, vPositionW, mInv, dLTCCoords );\n}\nfloat getRectLightSpecular(vec3 worldNormal, vec3 viewDir) {\n\treturn calcRectLightSpecular(worldNormal, viewDir, dLTCUV);\n}\nfloat calcDiskLightSpecular(vec3 worldNormal, vec3 viewDir, vec2 uv) {\n\tmat3 mInv = getLTCLightInvMat(uv);\n\treturn LTC_EvaluateDisk( worldNormal, viewDir, vPositionW, mInv, dLTCCoords );\n}\nfloat getDiskLightSpecular(vec3 worldNormal, vec3 viewDir) {\n\treturn calcDiskLightSpecular(worldNormal, viewDir, dLTCUV);\n}\nfloat getSphereLightSpecular(vec3 worldNormal, vec3 viewDir) {\n\treturn calcDiskLightSpecular(worldNormal, viewDir, dLTCUV);\n}\n",metalnessPS:"\n#ifdef MAPFLOAT\nuniform float material_metalness;\n#endif\nvoid getMetalness() {\n\tfloat metalness = 1.0;\n\t#ifdef MAPFLOAT\n\tmetalness *= material_metalness;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tmetalness *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tmetalness *= saturate(vVertexColor.$VC);\n\t#endif\n\tdMetalness = metalness;\n}\n",metalnessModulatePS:"\nvec3 getSpecularModulate(in vec3 specularity, in vec3 albedo, in float metalness, in float f0) {\n\tvec3 dielectricF0 = f0 * specularity;\n\treturn mix(dielectricF0, albedo, metalness);\n}\nvec3 getAlbedoModulate(in vec3 albedo, in float metalness) {\n\treturn albedo * (1.0 - metalness);\n}\n",msdfPS:"\nuniform sampler2D texture_msdfMap;\n#ifdef GL_OES_standard_derivatives\n#define USE_FWIDTH\n#endif\n#ifdef GL2\n#define USE_FWIDTH\n#endif\nfloat median(float r, float g, float b) {\n\treturn max(min(r, g), min(max(r, g), b));\n}\nfloat map (float min, float max, float v) {\n\treturn (v - min) / (max - min);\n}\nuniform float font_sdfIntensity;\nuniform float font_pxrange;\nuniform float font_textureWidth;\n#ifdef UNIFORM_TEXT_PARAMETERS\nuniform vec4 outline_color;\nuniform float outline_thickness;\nuniform vec4 shadow_color;\nuniform vec2 shadow_offset;\n#else\nvarying vec4 outline_color;\nvarying float outline_thickness;\nvarying vec4 shadow_color;\nvarying vec2 shadow_offset;\n#endif\nvec4 applyMsdf(vec4 color) {\n\tvec3 tsample = texture2D(texture_msdfMap, vUv0).rgb;\n\tvec2 uvShdw = vUv0 - shadow_offset;\n\tvec3 ssample = texture2D(texture_msdfMap, uvShdw).rgb;\n\tfloat sigDist = median(tsample.r, tsample.g, tsample.b);\n\tfloat sigDistShdw = median(ssample.r, ssample.g, ssample.b);\n\tfloat smoothingMax = 0.2;\n\t#ifdef USE_FWIDTH\n\tvec2 w = fwidth(vUv0);\n\tfloat smoothing = clamp(w.x * font_textureWidth / font_pxrange, 0.0, smoothingMax);\n\t#else\n\tfloat font_size = 16.0;\n\tfloat smoothing = clamp(font_pxrange / font_size, 0.0, smoothingMax);\n\t#endif\n\tfloat mapMin = 0.05;\n\tfloat mapMax = clamp(1.0 - font_sdfIntensity, mapMin, 1.0);\n\tfloat sigDistInner = map(mapMin, mapMax, sigDist);\n\tfloat sigDistOutline = map(mapMin, mapMax, sigDist + outline_thickness);\n\tsigDistShdw = map(mapMin, mapMax, sigDistShdw + outline_thickness);\n\tfloat center = 0.5;\n\tfloat inside = smoothstep(center-smoothing, center+smoothing, sigDistInner);\n\tfloat outline = smoothstep(center-smoothing, center+smoothing, sigDistOutline);\n\tfloat shadow = smoothstep(center-smoothing, center+smoothing, sigDistShdw);\n\tvec4 tcolor = (outline > inside) ? outline * vec4(outline_color.a * outline_color.rgb, outline_color.a) : vec4(0.0);\n\ttcolor = mix(tcolor, color, inside);\n\tvec4 scolor = (shadow > outline) ? shadow * vec4(shadow_color.a * shadow_color.rgb, shadow_color.a) : tcolor;\n\ttcolor = mix(scolor, tcolor, outline);\n\t\n\treturn tcolor;\n}\n",msdfVS:"\nattribute vec3 vertex_outlineParameters;\nattribute vec3 vertex_shadowParameters;\nvarying vec4 outline_color;\nvarying float outline_thickness;\nvarying vec4 shadow_color;\nvarying vec2 shadow_offset;\nvoid unpackMsdfParams() {\n\tvec3 little = mod(vertex_outlineParameters, 256.);\n\tvec3 big = (vertex_outlineParameters - little) / 256.;\n\toutline_color.rb = little.xy / 255.;\n\toutline_color.ga = big.xy / 255.;\n\toutline_thickness = little.z / 255. * 0.2;\n\tlittle = mod(vertex_shadowParameters, 256.);\n\tbig = (vertex_shadowParameters - little) / 256.;\n\tshadow_color.rb = little.xy / 255.;\n\tshadow_color.ga = big.xy / 255.;\n\tshadow_offset = (vec2(little.z, big.z) / 127. - 1.) * 0.005;\n}\n",normalVS:"\n#ifdef MORPHING_TEXTURE_BASED_NORMAL\nuniform highp sampler2D morphNormalTex;\n#endif\nvec3 getNormal() {\n\t#ifdef SKIN\n\tdNormalMatrix = mat3(dModelMatrix[0].xyz, dModelMatrix[1].xyz, dModelMatrix[2].xyz);\n\t#elif defined(INSTANCING)\n\tdNormalMatrix = mat3(instance_line1.xyz, instance_line2.xyz, instance_line3.xyz);\n\t#else\n\tdNormalMatrix = matrix_normal;\n\t#endif\n\tvec3 tempNormal = vertex_normal;\n\t#ifdef MORPHING\n\t#ifdef MORPHING_NRM03\n\ttempNormal += morph_weights_a[0] * morph_nrm0;\n\ttempNormal += morph_weights_a[1] * morph_nrm1;\n\ttempNormal += morph_weights_a[2] * morph_nrm2;\n\ttempNormal += morph_weights_a[3] * morph_nrm3;\n\t#endif\n\t#ifdef MORPHING_NRM47\n\ttempNormal += morph_weights_b[0] * morph_nrm4;\n\ttempNormal += morph_weights_b[1] * morph_nrm5;\n\ttempNormal += morph_weights_b[2] * morph_nrm6;\n\ttempNormal += morph_weights_b[3] * morph_nrm7;\n\t#endif\n\t#endif\n\t#ifdef MORPHING_TEXTURE_BASED_NORMAL\n\t\t#ifdef WEBGPU\n\t\t\tivec2 morphUV = getTextureMorphCoords();\n\t\t\tvec3 morphNormal = texelFetch(morphNormalTex, ivec2(morphUV), 0).xyz;\n\t\t#else\n\t\t\tvec2 morphUV = getTextureMorphCoords();\n\t\t\tvec3 morphNormal = texture2D(morphNormalTex, morphUV).xyz;\n\t\t#endif\n\ttempNormal += morphNormal;\n\t#endif\n\treturn normalize(dNormalMatrix * tempNormal);\n}\n",normalDetailMapPS:"\n#ifdef MAPTEXTURE\nuniform float material_normalDetailMapBumpiness;\nvec3 blendNormals(vec3 n1, vec3 n2) {\n\tn1 += vec3(0, 0, 1);\n\tn2 *= vec3(-1, -1, 1);\n\treturn n1 * dot(n1, n2) / n1.z - n2;\n}\n#endif\nvec3 addNormalDetail(vec3 normalMap) {\n#ifdef MAPTEXTURE\n\tvec3 normalDetailMap = unpackNormal(texture2DBias($SAMPLER, $UV, textureBias));\n\tnormalDetailMap = mix(vec3(0.0, 0.0, 1.0), normalDetailMap, material_normalDetailMapBumpiness);\n\treturn blendNormals(normalMap, normalDetailMap);\n#else\n\treturn normalMap;\n#endif\n}\n",normalInstancedVS:"\nvec3 getNormal() {\n\tdNormalMatrix = mat3(instance_line1.xyz, instance_line2.xyz, instance_line3.xyz);\n\treturn normalize(dNormalMatrix * vertex_normal);\n}\n",normalMapPS:"\n#ifdef MAPTEXTURE\nuniform float material_bumpiness;\n#endif\nvoid getNormal() {\n#ifdef MAPTEXTURE\n\tvec3 normalMap = unpackNormal(texture2DBias($SAMPLER, $UV, textureBias));\n\tnormalMap = mix(vec3(0.0, 0.0, 1.0), normalMap, material_bumpiness);\n\tdNormalW = normalize(dTBN * addNormalDetail(normalMap));\n#else\n\tdNormalW = dVertexNormalW;\n#endif\n}\n",normalSkinnedVS:"\nvec3 getNormal() {\n\tdNormalMatrix = mat3(dModelMatrix[0].xyz, dModelMatrix[1].xyz, dModelMatrix[2].xyz);\n\treturn normalize(dNormalMatrix * vertex_normal);\n}\n",normalXYPS:"\nvec3 unpackNormal(vec4 nmap) {\n\tvec3 normal;\n\tnormal.xy = nmap.wy * 2.0 - 1.0;\n\tnormal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));\n\treturn normal;\n}\n",normalXYZPS:"\nvec3 unpackNormal(vec4 nmap) {\n\treturn nmap.xyz * 2.0 - 1.0;\n}\n",opacityPS:"\n#ifdef MAPFLOAT\nuniform float material_opacity;\n#endif\nvoid getOpacity() {\n\tdAlpha = 1.0;\n\t#ifdef MAPFLOAT\n\tdAlpha *= material_opacity;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tdAlpha *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tdAlpha *= clamp(vVertexColor.$VC, 0.0, 1.0);\n\t#endif\n}\n",outputPS:"\n",outputAlphaPS:"\ngl_FragColor.a = litArgs_opacity;\n",outputAlphaOpaquePS:"\n\tgl_FragColor.a = 1.0;\n",outputAlphaPremulPS:"\ngl_FragColor.rgb *= litArgs_opacity;\ngl_FragColor.a = litArgs_opacity;\n",outputTex2DPS:"\nvarying vec2 vUv0;\nuniform sampler2D source;\nvoid main(void) {\n\tgl_FragColor = texture2D(source, vUv0);\n}\n",packDepthPS:"\nvec4 packFloat(float depth) {\n\tconst vec4 bit_shift = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0);\n\tconst vec4 bit_mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);\n\tvec4 res = mod(depth * bit_shift * vec4(255), vec4(256) ) / vec4(255);\n\tres -= res.xxyz * bit_mask;\n\treturn res;\n}\n",sheenPS:"\n#ifdef MAPCOLOR\nuniform vec3 material_sheen;\n#endif\nvoid getSheen() {\n\tvec3 sheenColor = vec3(1, 1, 1);\n\t#ifdef MAPCOLOR\n\tsheenColor *= material_sheen;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tsheenColor *= $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tsheenColor *= saturate(vVertexColor.$VC);\n\t#endif\n\tsSpecularity = sheenColor;\n}\n",sheenGlossPS:"\n#ifdef MAPFLOAT\nuniform float material_sheenGloss;\n#endif\nvoid getSheenGlossiness() {\n\tfloat sheenGlossiness = 1.0;\n\t#ifdef MAPFLOAT\n\tsheenGlossiness *= material_sheenGloss;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tsheenGlossiness *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tsheenGlossiness *= saturate(vVertexColor.$VC);\n\t#endif\n\t#ifdef MAPINVERT\n\tsheenGlossiness = 1.0 - sheenGlossiness;\n\t#endif\n\tsheenGlossiness += 0.0000001;\n\tsGlossiness = sheenGlossiness;\n}\n",parallaxPS:"\nuniform float material_heightMapFactor;\nvoid getParallax() {\n\tfloat parallaxScale = material_heightMapFactor;\n\tfloat height = texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\theight = height * parallaxScale - parallaxScale*0.5;\n\tvec3 viewDirT = dViewDirW * dTBN;\n\tviewDirT.z += 0.42;\n\tdUvOffset = height * (viewDirT.xy / viewDirT.z);\n}\n",particlePS:"\nvarying vec4 texCoordsAlphaLife;\nuniform sampler2D colorMap;\nuniform sampler2D colorParam;\nuniform float graphSampleSize;\nuniform float graphNumSamples;\n#ifndef CAMERAPLANES\n#define CAMERAPLANES\nuniform vec4 camera_params;\n#endif\nuniform float softening;\nuniform float colorMult;\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\n#ifndef UNPACKFLOAT\n#define UNPACKFLOAT\nfloat unpackFloat(vec4 rgbaDepth) {\n\tconst vec4 bitShift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n\tfloat depth = dot(rgbaDepth, bitShift);\n\treturn depth;\n}\n#endif\nvoid main(void) {\n\tvec4 tex = gammaCorrectInput(texture2D(colorMap, vec2(texCoordsAlphaLife.x, 1.0 - texCoordsAlphaLife.y)));\n\tvec4 ramp = gammaCorrectInput(texture2D(colorParam, vec2(texCoordsAlphaLife.w, 0.0)));\n\tramp.rgb *= colorMult;\n\tramp.a += texCoordsAlphaLife.z;\n\tvec3 rgb = tex.rgb * ramp.rgb;\n\tfloat a = tex.a * ramp.a;\n",particleVS:"\nvec3 unpack3NFloats(float src) {\n\tfloat r = fract(src);\n\tfloat g = fract(src * 256.0);\n\tfloat b = fract(src * 65536.0);\n\treturn vec3(r, g, b);\n}\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\nvec4 tex1Dlod_lerp(highp sampler2D tex, vec2 tc) {\n\treturn mix( texture2D(tex,tc), texture2D(tex,tc + graphSampleSize), fract(tc.x*graphNumSamples) );\n}\nvec4 tex1Dlod_lerp(highp sampler2D tex, vec2 tc, out vec3 w) {\n\tvec4 a = texture2D(tex,tc);\n\tvec4 b = texture2D(tex,tc + graphSampleSize);\n\tfloat c = fract(tc.x*graphNumSamples);\n\tvec3 unpackedA = unpack3NFloats(a.w);\n\tvec3 unpackedB = unpack3NFloats(b.w);\n\tw = mix(unpackedA, unpackedB, c);\n\treturn mix(a, b, c);\n}\nvec2 rotate(vec2 quadXY, float pRotation, out mat2 rotMatrix) {\n\tfloat c = cos(pRotation);\n\tfloat s = sin(pRotation);\n\tmat2 m = mat2(c, -s, s, c);\n\trotMatrix = m;\n\treturn m * quadXY;\n}\nvec3 billboard(vec3 InstanceCoords, vec2 quadXY) {\n\t#ifdef SCREEN_SPACE\n\t\tvec3 pos = vec3(-1, 0, 0) * quadXY.x + vec3(0, -1, 0) * quadXY.y;\n\t#else\n\t\tvec3 pos = -matrix_viewInverse[0].xyz * quadXY.x + -matrix_viewInverse[1].xyz * quadXY.y;\n\t#endif\n\treturn pos;\n}\nvec3 customFace(vec3 InstanceCoords, vec2 quadXY) {\n\tvec3 pos = faceTangent * quadXY.x + faceBinorm * quadXY.y;\n\treturn pos;\n}\nvec2 safeNormalize(vec2 v) {\n\tfloat l = length(v);\n\treturn (l > 1e-06) ? v / l : v;\n}\nvoid main(void) {\n\tvec3 meshLocalPos = particle_vertexData.xyz;\n\tfloat id = floor(particle_vertexData.w);\n\tfloat rndFactor = fract(sin(id + 1.0 + seed));\n\tvec3 rndFactor3 = vec3(rndFactor, fract(rndFactor*10.0), fract(rndFactor*100.0));\n\tfloat uv = id / numParticlesPot;\n\treadInput(uv);\n#ifdef LOCAL_SPACE\n\tinVel = mat3(matrix_model) * inVel;\n#endif\n\tvec2 velocityV = safeNormalize((mat3(matrix_view) * inVel).xy);\n\tfloat particleLifetime = lifetime;\n\tif (inLife <= 0.0 || inLife > particleLifetime || !inShow) meshLocalPos = vec3(0.0);\n\tvec2 quadXY = meshLocalPos.xy;\n\tfloat nlife = clamp(inLife / particleLifetime, 0.0, 1.0);\n\tvec3 paramDiv;\n\tvec4 params = tex1Dlod_lerp(internalTex2, vec2(nlife, 0), paramDiv);\n\tfloat scale = params.y;\n\tfloat scaleDiv = paramDiv.x;\n\tfloat alphaDiv = paramDiv.z;\n\tscale += (scaleDiv * 2.0 - 1.0) * scaleDivMult * fract(rndFactor*10000.0);\n#ifndef USE_MESH\n\ttexCoordsAlphaLife = vec4(quadXY * -0.5 + 0.5, (alphaDiv * 2.0 - 1.0) * alphaDivMult * fract(rndFactor*1000.0), nlife);\n#else\n\ttexCoordsAlphaLife = vec4(particle_uv, (alphaDiv * 2.0 - 1.0) * alphaDivMult * fract(rndFactor*1000.0), nlife);\n#endif\n\tvec3 particlePos = inPos;\n\tvec3 particlePosMoved = vec3(0.0);\n\tmat2 rotMatrix;\n",particleAnimFrameClampVS:"\n\tfloat animFrame = min(floor(texCoordsAlphaLife.w * animTexParams.y) + animTexParams.x, animTexParams.z);\n",particleAnimFrameLoopVS:"\n\tfloat animFrame = floor(mod(texCoordsAlphaLife.w * animTexParams.y + animTexParams.x, animTexParams.z + 1.0));\n",particleAnimTexVS:"\n\tfloat animationIndex;\n\tif (animTexIndexParams.y == 1.0) {\n\t\tanimationIndex = floor((animTexParams.w + 1.0) * rndFactor3.z) * (animTexParams.z + 1.0);\n\t} else {\n\t\tanimationIndex = animTexIndexParams.x * (animTexParams.z + 1.0);\n\t}\n\tfloat atlasX = (animationIndex + animFrame) * animTexTilesParams.x;\n\tfloat atlasY = 1.0 - floor(atlasX + 1.0) * animTexTilesParams.y;\n\tatlasX = fract(atlasX);\n\ttexCoordsAlphaLife.xy *= animTexTilesParams.xy;\n\ttexCoordsAlphaLife.xy += vec2(atlasX, atlasY);\n",particleInputFloatPS:"\nvoid readInput(float uv) {\n\tvec4 tex = texture2D(particleTexIN, vec2(uv, 0.25));\n\tvec4 tex2 = texture2D(particleTexIN, vec2(uv, 0.75));\n\tinPos = tex.xyz;\n\tinVel = tex2.xyz;\n\tinAngle = (tex.w < 0.0? -tex.w : tex.w) - 1000.0;\n\tinShow = tex.w >= 0.0;\n\tinLife = tex2.w;\n}\n",particleInputRgba8PS:"\n#define PI2 6.283185307179586\nuniform vec3 inBoundsSize;\nuniform vec3 inBoundsCenter;\nuniform float maxVel;\nfloat decodeFloatRG(vec2 rg) {\n\treturn rg.y*(1.0/255.0) + rg.x;\n}\nfloat decodeFloatRGBA( vec4 rgba ) {\n return dot( rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/160581375.0) );\n}\nvoid readInput(float uv) {\n\tvec4 tex0 = texture2D(particleTexIN, vec2(uv, 0.125));\n\tvec4 tex1 = texture2D(particleTexIN, vec2(uv, 0.375));\n\tvec4 tex2 = texture2D(particleTexIN, vec2(uv, 0.625));\n\tvec4 tex3 = texture2D(particleTexIN, vec2(uv, 0.875));\n\tinPos = vec3(decodeFloatRG(tex0.rg), decodeFloatRG(tex0.ba), decodeFloatRG(tex1.rg));\n\tinPos = (inPos - vec3(0.5)) * inBoundsSize + inBoundsCenter;\n\tinVel = tex2.xyz;\n\tinVel = (inVel - vec3(0.5)) * maxVel;\n\tinAngle = decodeFloatRG(tex1.ba) * PI2;\n\tinShow = tex2.a > 0.5;\n\tinLife = decodeFloatRGBA(tex3);\n\tfloat maxNegLife = max(lifetime, (numParticles - 1.0) * (rate+rateDiv));\n\tfloat maxPosLife = lifetime+1.0;\n\tinLife = inLife * (maxNegLife + maxPosLife) - maxNegLife;\n}\n",particleOutputFloatPS:"\nvoid writeOutput() {\n\tif (gl_FragCoord.y<1.0) {\n\t\tgl_FragColor = vec4(outPos, (outAngle + 1000.0) * visMode);\n\t} else {\n\t\tgl_FragColor = vec4(outVel, outLife);\n\t}\n}\n",particleOutputRgba8PS:"\nuniform vec3 outBoundsMul;\nuniform vec3 outBoundsAdd;\nvec2 encodeFloatRG( float v ) {\n\tvec2 enc = vec2(1.0, 255.0) * v;\n\tenc = fract(enc);\n\tenc -= enc.yy * vec2(1.0/255.0, 1.0/255.0);\n\treturn enc;\n}\nvec4 encodeFloatRGBA( float v ) {\n\tvec4 enc = vec4(1.0, 255.0, 65025.0, 160581375.0) * v;\n\tenc = fract(enc);\n\tenc -= enc.yzww * vec4(1.0/255.0,1.0/255.0,1.0/255.0,0.0);\n\treturn enc;\n}\nvoid writeOutput() {\n\toutPos = outPos * outBoundsMul + outBoundsAdd;\n\toutAngle = fract(outAngle / PI2);\n\toutVel = (outVel / maxVel) + vec3(0.5);\n\tfloat maxNegLife = max(lifetime, (numParticles - 1.0) * (rate+rateDiv));\n\tfloat maxPosLife = lifetime+1.0;\n\toutLife = (outLife + maxNegLife) / (maxNegLife + maxPosLife);\n\tif (gl_FragCoord.y < 1.0) {\n\t\tgl_FragColor = vec4(encodeFloatRG(outPos.x), encodeFloatRG(outPos.y));\n\t} else if (gl_FragCoord.y < 2.0) {\n\t\tgl_FragColor = vec4(encodeFloatRG(outPos.z), encodeFloatRG(outAngle));\n\t} else if (gl_FragCoord.y < 3.0) {\n\t\tgl_FragColor = vec4(outVel, visMode*0.5+0.5);\n\t} else {\n\t\tgl_FragColor = encodeFloatRGBA(outLife);\n\t}\n}\n",particleUpdaterAABBPS:"\nuniform mat3 spawnBounds;\nuniform vec3 spawnPosInnerRatio;\nvec3 calcSpawnPosition(vec3 inBounds, float rndFactor) {\n\tvec3 pos = inBounds - vec3(0.5);\n\tvec3 posAbs = abs(pos);\n\tvec3 maxPos = vec3(max(posAbs.x, max(posAbs.y, posAbs.z)));\n\tvec3 edge = maxPos + (vec3(0.5) - maxPos) * spawnPosInnerRatio;\n\tpos.x = edge.x * (maxPos.x == posAbs.x ? sign(pos.x) : 2.0 * pos.x);\n\tpos.y = edge.y * (maxPos.y == posAbs.y ? sign(pos.y) : 2.0 * pos.y);\n\tpos.z = edge.z * (maxPos.z == posAbs.z ? sign(pos.z) : 2.0 * pos.z);\n#ifndef LOCAL_SPACE\n\treturn emitterPos + spawnBounds * pos;\n#else\n\treturn spawnBounds * pos;\n#endif\n}\nvoid addInitialVelocity(inout vec3 localVelocity, vec3 inBounds) {\n\tlocalVelocity -= vec3(0, 0, initialVelocity);\n}\n",particleUpdaterEndPS:"\n\twriteOutput();\n}\n",particleUpdaterInitPS:"\nvarying vec2 vUv0;\nuniform highp sampler2D particleTexIN;\nuniform highp sampler2D internalTex0;\nuniform highp sampler2D internalTex1;\nuniform highp sampler2D internalTex2;\nuniform highp sampler2D internalTex3;\nuniform mat3 emitterMatrix, emitterMatrixInv;\nuniform vec3 emitterScale;\nuniform vec3 emitterPos, frameRandom, localVelocityDivMult, velocityDivMult;\nuniform float delta, rate, rateDiv, lifetime, numParticles, rotSpeedDivMult, radialSpeedDivMult, seed;\nuniform float startAngle, startAngle2;\nuniform float initialVelocity;\nuniform float graphSampleSize;\nuniform float graphNumSamples;\nvec3 inPos;\nvec3 inVel;\nfloat inAngle;\nbool inShow;\nfloat inLife;\nfloat visMode;\nvec3 outPos;\nvec3 outVel;\nfloat outAngle;\nbool outShow;\nfloat outLife;\n",particleUpdaterNoRespawnPS:"\n\tif (outLife >= lifetime) {\n\t\toutLife -= max(lifetime, (numParticles - 1.0) * particleRate);\n\t\tvisMode = -1.0;\n\t}\n",particleUpdaterOnStopPS:"\n\tvisMode = outLife < 0.0? -1.0: visMode;\n",particleUpdaterRespawnPS:"\n\tif (outLife >= lifetime) {\n\t\toutLife -= max(lifetime, (numParticles - 1.0) * particleRate);\n\t\tvisMode = 1.0;\n\t}\n\tvisMode = outLife < 0.0? 1.0: visMode;\n",particleUpdaterSpherePS:"\nuniform float spawnBoundsSphere;\nuniform float spawnBoundsSphereInnerRatio;\nvec3 calcSpawnPosition(vec3 inBounds, float rndFactor) {\n\tfloat rnd4 = fract(rndFactor * 1000.0);\n\tvec3 norm = normalize(inBounds.xyz - vec3(0.5));\n\tfloat r = rnd4 * (1.0 - spawnBoundsSphereInnerRatio) + spawnBoundsSphereInnerRatio;\n#ifndef LOCAL_SPACE\n\treturn emitterPos + norm * r * spawnBoundsSphere;\n#else\n\treturn norm * r * spawnBoundsSphere;\n#endif\n}\nvoid addInitialVelocity(inout vec3 localVelocity, vec3 inBounds) {\n\tlocalVelocity += normalize(inBounds - vec3(0.5)) * initialVelocity;\n}\n",particleUpdaterStartPS:"\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\nvec3 unpack3NFloats(float src) {\n\tfloat r = fract(src);\n\tfloat g = fract(src * 256.0);\n\tfloat b = fract(src * 65536.0);\n\treturn vec3(r, g, b);\n}\nvec3 tex1Dlod_lerp(highp sampler2D tex, vec2 tc, out vec3 w) {\n\tvec4 a = texture2D(tex, tc);\n\tvec4 b = texture2D(tex, tc + graphSampleSize);\n\tfloat c = fract(tc.x * graphNumSamples);\n\tvec3 unpackedA = unpack3NFloats(a.w);\n\tvec3 unpackedB = unpack3NFloats(b.w);\n\tw = mix(unpackedA, unpackedB, c);\n\treturn mix(a.xyz, b.xyz, c);\n}\n#define HASHSCALE4 vec4(1031, .1030, .0973, .1099)\nvec4 hash41(float p) {\n\tvec4 p4 = fract(vec4(p) * HASHSCALE4);\n\tp4 += dot(p4, p4.wzxy+19.19);\n\treturn fract(vec4((p4.x + p4.y)*p4.z, (p4.x + p4.z)*p4.y, (p4.y + p4.z)*p4.w, (p4.z + p4.w)*p4.x));\n}\nvoid main(void) {\n\tif (gl_FragCoord.x > numParticles) discard;\n\treadInput(vUv0.x);\n\tvisMode = inShow? 1.0 : -1.0;\n\tvec4 rndFactor = hash41(gl_FragCoord.x + seed);\n\tfloat particleRate = rate + rateDiv * rndFactor.x;\n\toutLife = inLife + delta;\n\tfloat nlife = clamp(outLife / lifetime, 0.0, 1.0);\n\tvec3 localVelocityDiv;\n\tvec3 velocityDiv;\n\tvec3 paramDiv;\n\tvec3 localVelocity = tex1Dlod_lerp(internalTex0, vec2(nlife, 0), localVelocityDiv);\n\tvec3 velocity =\t tex1Dlod_lerp(internalTex1, vec2(nlife, 0), velocityDiv);\n\tvec3 params =\t\ttex1Dlod_lerp(internalTex2, vec2(nlife, 0), paramDiv);\n\tfloat rotSpeed = params.x;\n\tfloat rotSpeedDiv = paramDiv.y;\n\tvec3 radialParams = tex1Dlod_lerp(internalTex3, vec2(nlife, 0), paramDiv);\n\tfloat radialSpeed = radialParams.x;\n\tfloat radialSpeedDiv = radialParams.y;\n\tbool respawn = inLife <= 0.0 || outLife >= lifetime;\n\tinPos = respawn ? calcSpawnPosition(rndFactor.xyz, rndFactor.x) : inPos;\n\tinAngle = respawn ? mix(startAngle, startAngle2, rndFactor.x) : inAngle;\n#ifndef LOCAL_SPACE\n\tvec3 radialVel = inPos - emitterPos;\n#else\n\tvec3 radialVel = inPos;\n#endif\n\tradialVel = (dot(radialVel, radialVel) > 1.0E-8) ? radialSpeed * normalize(radialVel) : vec3(0.0);\n\tradialVel += (radialSpeedDiv * vec3(2.0) - vec3(1.0)) * radialSpeedDivMult * rndFactor.xyz;\n\tlocalVelocity +=\t(localVelocityDiv * vec3(2.0) - vec3(1.0)) * localVelocityDivMult * rndFactor.xyz;\n\tvelocity +=\t\t (velocityDiv * vec3(2.0) - vec3(1.0)) * velocityDivMult * rndFactor.xyz;\n\trotSpeed +=\t\t (rotSpeedDiv * 2.0 - 1.0) * rotSpeedDivMult * rndFactor.y;\n\taddInitialVelocity(localVelocity, rndFactor.xyz);\n#ifndef LOCAL_SPACE\n\toutVel = emitterMatrix * localVelocity + (radialVel + velocity) * emitterScale;\n#else\n\toutVel = (localVelocity + radialVel) / emitterScale + emitterMatrixInv * velocity;\n#endif\n\toutPos = inPos + outVel * delta;\n\toutAngle = inAngle + rotSpeed * delta;\n",particle_billboardVS:"\n\tquadXY = rotate(quadXY, inAngle, rotMatrix);\n\tvec3 localPos = billboard(particlePos, quadXY);\n",particle_blendAddPS:"\n\tdBlendModeFogFactor = 0.0;\n\trgb *= saturate(gammaCorrectInput(max(a, 0.0)));\n\tif ((rgb.r + rgb.g + rgb.b) < 0.000001) discard;\n",particle_blendMultiplyPS:"\n\trgb = mix(vec3(1.0), rgb, vec3(a));\n\tif (rgb.r + rgb.g + rgb.b > 2.99) discard;\n",particle_blendNormalPS:"\n\tif (a < 0.01) discard;\n",particle_cpuVS:"\nattribute vec4 particle_vertexData;\nattribute vec4 particle_vertexData2;\nattribute vec4 particle_vertexData3;\nattribute float particle_vertexData4;\n#ifndef USE_MESH\nattribute vec2 particle_vertexData5;\n#else\nattribute vec4 particle_vertexData5;\n#endif\nuniform mat4 matrix_viewProjection;\nuniform mat4 matrix_model;\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform mat3 matrix_normal;\nuniform mat4 matrix_viewInverse;\nuniform float numParticles;\nuniform float lifetime;\nuniform float stretch;\nuniform float seed;\nuniform vec3 wrapBounds;\nuniform vec3 emitterScale;\nuniform vec3 faceTangent;\nuniform vec3 faceBinorm;\nuniform highp sampler2D internalTex0;\nuniform highp sampler2D internalTex1;\nuniform highp sampler2D internalTex2;\nuniform vec3 emitterPos;\nvarying vec4 texCoordsAlphaLife;\nvec2 rotate(vec2 quadXY, float pRotation, out mat2 rotMatrix)\n{\n\tfloat c = cos(pRotation);\n\tfloat s = sin(pRotation);\n\tmat2 m = mat2(c, -s, s, c);\n\trotMatrix = m;\n\treturn m * quadXY;\n}\nvec3 billboard(vec3 InstanceCoords, vec2 quadXY)\n{\n\tvec3 pos = -matrix_viewInverse[0].xyz * quadXY.x + -matrix_viewInverse[1].xyz * quadXY.y;\n\treturn pos;\n}\nvec3 customFace(vec3 InstanceCoords, vec2 quadXY)\n{\n\tvec3 pos = faceTangent * quadXY.x + faceBinorm * quadXY.y;\n\treturn pos;\n}\nvoid main(void)\n{\n\tvec3 particlePos = particle_vertexData.xyz;\n\tvec3 inPos = particlePos;\n\tvec3 vertPos = particle_vertexData3.xyz;\n\tvec3 inVel = vec3(particle_vertexData2.w, particle_vertexData3.w, particle_vertexData5.x);\n\tfloat id = floor(particle_vertexData4);\n\tfloat rndFactor = fract(sin(id + 1.0 + seed));\n\tvec3 rndFactor3 = vec3(rndFactor, fract(rndFactor*10.0), fract(rndFactor*100.0));\n#ifdef LOCAL_SPACE\n\tinVel = mat3(matrix_model) * inVel;\n#endif\n\tvec2 velocityV = normalize((mat3(matrix_view) * inVel).xy);\n\tvec2 quadXY = vertPos.xy;\n#ifdef USE_MESH\n\ttexCoordsAlphaLife = vec4(particle_vertexData5.zw, particle_vertexData2.z, particle_vertexData.w);\n#else\n\ttexCoordsAlphaLife = vec4(quadXY * -0.5 + 0.5, particle_vertexData2.z, particle_vertexData.w);\n#endif\n\tmat2 rotMatrix;\n\tfloat inAngle = particle_vertexData2.x;\n\tvec3 particlePosMoved = vec3(0.0);\n\tvec3 meshLocalPos = particle_vertexData3.xyz;\n",particle_cpu_endVS:"\n\tlocalPos *= particle_vertexData2.y * emitterScale;\n\tlocalPos += particlePos;\n\tgl_Position = matrix_viewProjection * vec4(localPos, 1.0);\n",particle_customFaceVS:"\n\tquadXY = rotate(quadXY, inAngle, rotMatrix);\n\tvec3 localPos = customFace(particlePos, quadXY);\n",particle_endPS:"\n\trgb = addFog(rgb);\n\trgb = toneMap(rgb);\n\trgb = gammaCorrectOutput(rgb);\n\tgl_FragColor = vec4(rgb, a);\n}\n",particle_endVS:"\n\tlocalPos *= scale * emitterScale;\n\tlocalPos += particlePos;\n\t#ifdef SCREEN_SPACE\n\tgl_Position = vec4(localPos.x, localPos.y, 0.0, 1.0);\n\t#else\n\tgl_Position = matrix_viewProjection * vec4(localPos.xyz, 1.0);\n\t#endif\n",particle_halflambertPS:"\n\tvec3 negNormal = normal*0.5+0.5;\n\tvec3 posNormal = -normal*0.5+0.5;\n\tnegNormal *= negNormal;\n\tposNormal *= posNormal;\n",particle_initVS:"\nattribute vec4 particle_vertexData;\n#ifdef USE_MESH\nattribute vec2 particle_uv;\n#endif\nuniform mat4 matrix_viewProjection;\nuniform mat4 matrix_model;\nuniform mat3 matrix_normal;\nuniform mat4 matrix_viewInverse;\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform float numParticles, numParticlesPot;\nuniform float graphSampleSize;\nuniform float graphNumSamples;\nuniform float stretch;\nuniform vec3 wrapBounds;\nuniform vec3 emitterScale, emitterPos, faceTangent, faceBinorm;\nuniform float rate, rateDiv, lifetime, deltaRandomnessStatic, scaleDivMult, alphaDivMult, seed, delta;\nuniform sampler2D particleTexOUT, particleTexIN;\nuniform highp sampler2D internalTex0;\nuniform highp sampler2D internalTex1;\nuniform highp sampler2D internalTex2;\n#ifndef CAMERAPLANES\n#define CAMERAPLANES\nuniform vec4 camera_params;\n#endif\nvarying vec4 texCoordsAlphaLife;\nvec3 inPos;\nvec3 inVel;\nfloat inAngle;\nbool inShow;\nfloat inLife;\n",particle_lambertPS:"\n\tvec3 negNormal = max(normal, vec3(0.0));\n\tvec3 posNormal = max(-normal, vec3(0.0));\n",particle_lightingPS:"\n\tvec3 light = negNormal.x*lightCube[0] + posNormal.x*lightCube[1] +\n\t\t\t\t\t\tnegNormal.y*lightCube[2] + posNormal.y*lightCube[3] +\n\t\t\t\t\t\tnegNormal.z*lightCube[4] + posNormal.z*lightCube[5];\n\trgb *= light;\n",particle_localShiftVS:"\n\tparticlePos = (matrix_model * vec4(particlePos, 1.0)).xyz;\n",particle_meshVS:"\n\tvec3 localPos = meshLocalPos;\n\tlocalPos.xy = rotate(localPos.xy, inAngle, rotMatrix);\n\tlocalPos.yz = rotate(localPos.yz, inAngle, rotMatrix);\n\tbillboard(particlePos, quadXY);\n",particle_normalVS:"\n\tNormal = normalize(localPos + matrix_viewInverse[2].xyz);\n",particle_normalMapPS:"\n\tvec3 normalMap = normalize(texture2D(normalMap, vec2(texCoordsAlphaLife.x, 1.0 - texCoordsAlphaLife.y)).xyz * 2.0 - 1.0);\n\tvec3 normal = ParticleMat * normalMap;\n",particle_pointAlongVS:"\n\tinAngle = atan(velocityV.x, velocityV.y);\n",particle_softPS:"\n\tfloat depth = getLinearScreenDepth();\n\tfloat particleDepth = vDepth;\n\tfloat depthDiff = saturate(abs(particleDepth - depth) * softening);\n\ta *= depthDiff;\n",particle_softVS:"\n\tvDepth = getLinearDepth(localPos);\n",particle_stretchVS:"\n\tvec3 moveDir = inVel * stretch;\n\tvec3 posPrev = particlePos - moveDir;\n\tposPrev += particlePosMoved;\n\tvec2 centerToVertexV = normalize((mat3(matrix_view) * localPos).xy);\n\tfloat interpolation = dot(-velocityV, centerToVertexV) * 0.5 + 0.5;\n\tparticlePos = mix(particlePos, posPrev, interpolation);\n",particle_TBNVS:"\n\tmat3 rot3 = mat3(rotMatrix[0][0], rotMatrix[0][1], 0.0, rotMatrix[1][0], rotMatrix[1][1], 0.0, 0.0, 0.0, 1.0);\n\tParticleMat = mat3(-matrix_viewInverse[0].xyz, -matrix_viewInverse[1].xyz, matrix_viewInverse[2].xyz) * rot3;\n",particle_wrapVS:"\n\tvec3 origParticlePos = particlePos;\n\tparticlePos -= matrix_model[3].xyz;\n\tparticlePos = mod(particlePos, wrapBounds) - wrapBounds * 0.5;\n\tparticlePos += matrix_model[3].xyz;\n\tparticlePosMoved = particlePos - origParticlePos;\n",reflDirPS:"\nvoid getReflDir(vec3 worldNormal, vec3 viewDir, float gloss, mat3 tbn) {\n\tdReflDirW = normalize(-reflect(viewDir, worldNormal));\n}\n",reflDirAnisoPS:"\nvoid getReflDir(vec3 worldNormal, vec3 viewDir, float gloss, mat3 tbn) {\n\tfloat roughness = sqrt(1.0 - min(gloss, 1.0));\n\tfloat anisotropy = material_anisotropy * roughness;\n\tvec3 anisotropicDirection = anisotropy >= 0.0 ? tbn[1] : tbn[0];\n\tvec3 anisotropicTangent = cross(anisotropicDirection, viewDir);\n\tvec3 anisotropicNormal = cross(anisotropicTangent, anisotropicDirection);\n\tvec3 bentNormal = normalize(mix(normalize(worldNormal), normalize(anisotropicNormal), anisotropy));\n\tdReflDirW = reflect(-viewDir, bentNormal);\n}\n",reflectionCCPS:"\n#ifdef LIT_CLEARCOAT\nvoid addReflectionCC(vec3 reflDir, float gloss) {\n\tccReflection += calcReflection(reflDir, gloss);\n}\n#endif\n",reflectionCubePS:"\nuniform samplerCube texture_cubeMap;\nuniform float material_reflectivity;\nvec3 calcReflection(vec3 reflDir, float gloss) {\n\tvec3 lookupVec = fixSeams(cubeMapProject(reflDir));\n\tlookupVec.x *= -1.0;\n\treturn $DECODE(textureCube(texture_cubeMap, lookupVec));\n}\nvoid addReflection(vec3 reflDir, float gloss) { \n\tdReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n",reflectionEnvHQPS:"\n#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform samplerCube texture_cubeMap;\nuniform float material_reflectivity;\nvec3 calcReflection(vec3 reflDir, float gloss) {\n\tvec3 dir = cubeMapProject(reflDir) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(dir);\n\tfloat level = saturate(1.0 - gloss) * 5.0;\n\tfloat ilevel = floor(level);\n\tfloat flevel = level - ilevel;\n\tvec3 sharp = $DECODE_CUBEMAP(textureCube(texture_cubeMap, fixSeams(dir)));\n\tvec3 roughA = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel)));\n\tvec3 roughB = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\treturn processEnvironment(mix(sharp, mix(roughA, roughB, flevel), min(level, 1.0)));\n}\nvoid addReflection(vec3 reflDir, float gloss) { \n\tdReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n",reflectionEnvPS:"\n#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform float material_reflectivity;\nfloat shinyMipLevel(vec2 uv) {\n\tvec2 dx = dFdx(uv);\n\tvec2 dy = dFdy(uv);\n\tvec2 uv2 = vec2(fract(uv.x + 0.5), uv.y);\n\tvec2 dx2 = dFdx(uv2);\n\tvec2 dy2 = dFdy(uv2);\n\tfloat maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2)));\n\treturn clamp(0.5 * log2(maxd) - 1.0 + textureBias, 0.0, 5.0);\n}\nvec3 calcReflection(vec3 reflDir, float gloss) {\n\tvec3 dir = cubeMapProject(reflDir) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(dir);\n\tfloat level = saturate(1.0 - gloss) * 5.0;\n\tfloat ilevel = floor(level);\n\tfloat level2 = shinyMipLevel(uv * atlasSize);\n\tfloat ilevel2 = floor(level2);\n\tvec2 uv0, uv1;\n\tfloat weight;\n\tif (ilevel == 0.0) {\n\t\tuv0 = mapShinyUv(uv, ilevel2);\n\t\tuv1 = mapShinyUv(uv, ilevel2 + 1.0);\n\t\tweight = level2 - ilevel2;\n\t} else {\n\t\tuv0 = uv1 = mapRoughnessUv(uv, ilevel);\n\t\tweight = 0.0;\n\t}\n\tvec3 linearA = $DECODE(texture2D(texture_envAtlas, uv0));\n\tvec3 linearB = $DECODE(texture2D(texture_envAtlas, uv1));\n\tvec3 linear0 = mix(linearA, linearB, weight);\n\tvec3 linear1 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\treturn processEnvironment(mix(linear0, linear1, level - ilevel));\n}\nvoid addReflection(vec3 reflDir, float gloss) { \n\tdReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n",reflectionSpherePS:"\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform sampler2D texture_sphereMap;\nuniform float material_reflectivity;\nvec3 calcReflection(vec3 reflDir, float gloss) {\n\tvec3 reflDirV = (mat3(matrix_view) * reflDir).xyz;\n\tfloat m = 2.0 * sqrt( dot(reflDirV.xy, reflDirV.xy) + (reflDirV.z+1.0)*(reflDirV.z+1.0) );\n\tvec2 sphereMapUv = reflDirV.xy / m + 0.5;\n\treturn $DECODE(texture2D(texture_sphereMap, sphereMapUv));\n}\nvoid addReflection(vec3 reflDir, float gloss) { \n\tdReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n",reflectionSphereLowPS:"\nuniform sampler2D texture_sphereMap;\nuniform float material_reflectivity;\nvec3 calcReflection(vec3 reflDir, float gloss) {\n\tvec3 reflDirV = vNormalV;\n\tvec2 sphereMapUv = reflDirV.xy * 0.5 + 0.5;\n\treturn $DECODE(texture2D(texture_sphereMap, sphereMapUv));\n}\nvoid addReflection(vec3 reflDir, float gloss) { \n\tdReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n",reflectionSheenPS:"\nvoid addReflectionSheen(vec3 worldNormal, vec3 viewDir, float gloss) {\n\tfloat NoV = dot(worldNormal, viewDir);\n\tfloat alphaG = gloss * gloss;\n\tfloat a = gloss < 0.25 ? -339.2 * alphaG + 161.4 * gloss - 25.9 : -8.48 * alphaG + 14.3 * gloss - 9.95;\n\tfloat b = gloss < 0.25 ? 44.0 * alphaG - 23.7 * gloss + 3.26 : 1.97 * alphaG - 3.27 * gloss + 0.72;\n\tfloat DG = exp( a * NoV + b ) + ( gloss < 0.25 ? 0.0 : 0.1 * ( gloss - 0.25 ) );\n\tsReflection += calcReflection(worldNormal, 0.0) * saturate(DG);\n}\n",refractionCubePS:"\nvec3 refract2(vec3 viewVec, vec3 normal, float IOR) {\n\tfloat vn = dot(viewVec, normal);\n\tfloat k = 1.0 - IOR * IOR * (1.0 - vn * vn);\n\tvec3 refrVec = IOR * viewVec - (IOR * vn + sqrt(k)) * normal;\n\treturn refrVec;\n}\nvoid addRefraction(\n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tfloat thickness, \n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 albedo, \n\tfloat transmission,\n\tfloat refractionIndex\n#if defined(LIT_IRIDESCENCE)\n\t, vec3 iridescenceFresnel,\n\tfloat iridescenceIntensity\n#endif \n) {\n\tvec4 tmpRefl = dReflection;\n\tvec3 reflectionDir = refract2(-viewDir, worldNormal, refractionIndex);\n\tdReflection = vec4(0);\n\taddReflection(reflectionDir, gloss);\n\tdDiffuseLight = mix(dDiffuseLight, dReflection.rgb * albedo, transmission);\n\tdReflection = tmpRefl;\n}\n",refractionDynamicPS:"\nuniform float material_invAttenuationDistance;\nuniform vec3 material_attenuation;\nvoid addRefraction(\n\tvec3 worldNormal, \n\tvec3 viewDir, \n\tfloat thickness, \n\tfloat gloss, \n\tvec3 specularity, \n\tvec3 albedo, \n\tfloat transmission,\n\tfloat refractionIndex\n#if defined(LIT_IRIDESCENCE)\n\t, vec3 iridescenceFresnel,\n\tfloat iridescenceIntensity\n#endif\n) {\n\tvec3 modelScale;\n\tmodelScale.x = length(vec3(matrix_model[0].xyz));\n\tmodelScale.y = length(vec3(matrix_model[1].xyz));\n\tmodelScale.z = length(vec3(matrix_model[2].xyz));\n\tvec3 refractionVector = normalize(refract(-viewDir, worldNormal, refractionIndex)) * thickness * modelScale;\n\tvec4 pointOfRefraction = vec4(vPositionW + refractionVector, 1.0);\n\tvec4 projectionPoint = matrix_viewProjection * pointOfRefraction;\n\tvec2 uv = getGrabScreenPos(projectionPoint);\n\t#ifdef SUPPORTS_TEXLOD\n\t\tfloat iorToRoughness = (1.0 - gloss) * clamp((1.0 / refractionIndex) * 2.0 - 2.0, 0.0, 1.0);\n\t\tfloat refractionLod = log2(uScreenSize.x) * iorToRoughness;\n\t\tvec3 refraction = texture2DLodEXT(uSceneColorMap, uv, refractionLod).rgb;\n\t#else\n\t\tvec3 refraction = texture2D(uSceneColorMap, uv).rgb;\n\t#endif\n\tvec3 transmittance;\n\tif (material_invAttenuationDistance != 0.0)\n\t{\n\t\tvec3 attenuation = -log(material_attenuation) * material_invAttenuationDistance;\n\t\ttransmittance = exp(-attenuation * length(refractionVector));\n\t}\n\telse\n\t{\n\t\ttransmittance = refraction;\n\t}\n\tvec3 fresnel = vec3(1.0) - \n\t\tgetFresnel(\n\t\t\tdot(viewDir, worldNormal), \n\t\t\tgloss, \n\t\t\tspecularity\n\t\t#if defined(LIT_IRIDESCENCE)\n\t\t\t, iridescenceFresnel,\n\t\t\tiridescenceIntensity\n\t\t#endif\n\t\t);\n\tdDiffuseLight = mix(dDiffuseLight, refraction * transmittance * fresnel, transmission);\n}\n",reprojectPS:"\nvarying vec2 vUv0;\n#ifdef CUBEMAP_SOURCE\n\tuniform samplerCube sourceCube;\n#else\n\tuniform sampler2D sourceTex;\n#endif\n#ifdef USE_SAMPLES_TEX\n\tuniform sampler2D samplesTex;\n\tuniform vec2 samplesTexInverseSize;\n#endif\nuniform vec4 params;\nuniform vec2 params2;\nfloat targetFace() { return params.x; }\nfloat specularPower() { return params.y; }\nfloat sourceCubeSeamScale() { return params.z; }\nfloat targetCubeSeamScale() { return params.w; }\nfloat targetTotalPixels() { return params2.x; }\nfloat sourceTotalPixels() { return params2.y; }\nfloat PI = 3.141592653589793;\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\n"+So+"\n"+bo+"\nvec3 modifySeams(vec3 dir, float scale) {\n\tvec3 adir = abs(dir);\n\tfloat M = max(max(adir.x, adir.y), adir.z);\n\treturn dir / M * vec3(\n\t\tadir.x == M ? 1.0 : scale,\n\t\tadir.y == M ? 1.0 : scale,\n\t\tadir.z == M ? 1.0 : scale\n\t);\n}\nvec2 toSpherical(vec3 dir) {\n\treturn vec2(dir.xz == vec2(0.0) ? 0.0 : atan(dir.x, dir.z), asin(dir.y));\n}\nvec3 fromSpherical(vec2 uv) {\n\treturn vec3(cos(uv.y) * sin(uv.x),\n\t\t\t\tsin(uv.y),\n\t\t\t\tcos(uv.y) * cos(uv.x));\n}\nvec3 getDirectionEquirect() {\n\treturn fromSpherical((vec2(vUv0.x, 1.0 - vUv0.y) * 2.0 - 1.0) * vec2(PI, PI * 0.5));\n}\nfloat signNotZero(float k){\n\treturn(k >= 0.0) ? 1.0 : -1.0;\n}\nvec2 signNotZero(vec2 v) {\n\treturn vec2(signNotZero(v.x), signNotZero(v.y));\n}\nvec3 octDecode(vec2 o) {\n\tvec3 v = vec3(o.x, 1.0 - abs(o.x) - abs(o.y), o.y);\n\tif (v.y < 0.0) {\n\t\tv.xz = (1.0 - abs(v.zx)) * signNotZero(v.xz);\n\t}\n\treturn normalize(v);\n}\nvec3 getDirectionOctahedral() {\n\treturn octDecode(vec2(vUv0.x, 1.0 - vUv0.y) * 2.0 - 1.0);\n}\nvec2 octEncode(in vec3 v) {\n\tfloat l1norm = abs(v.x) + abs(v.y) + abs(v.z);\n\tvec2 result = v.xz * (1.0 / l1norm);\n\tif (v.y < 0.0) {\n\t\tresult = (1.0 - abs(result.yx)) * signNotZero(result.xy);\n\t}\n\treturn result;\n}\n#ifdef CUBEMAP_SOURCE\n\tvec4 sampleCubemap(vec3 dir) {\n\t\treturn textureCube(sourceCube, modifySeams(dir, 1.0 - sourceCubeSeamScale()));\n\t}\n\tvec4 sampleCubemap(vec2 sph) {\n\treturn sampleCubemap(fromSpherical(sph));\n}\n\tvec4 sampleCubemap(vec3 dir, float mipLevel) {\n\t\treturn textureCubeLodEXT(sourceCube, modifySeams(dir, 1.0 - exp2(mipLevel) * sourceCubeSeamScale()), mipLevel);\n\t}\n\tvec4 sampleCubemap(vec2 sph, float mipLevel) {\n\t\treturn sampleCubemap(fromSpherical(sph), mipLevel);\n\t}\n#else\n\tvec4 sampleEquirect(vec2 sph) {\n\t\tvec2 uv = sph / vec2(PI * 2.0, PI) + 0.5;\n\t\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n\t}\n\tvec4 sampleEquirect(vec3 dir) {\n\t\treturn sampleEquirect(toSpherical(dir));\n\t}\n\tvec4 sampleEquirect(vec2 sph, float mipLevel) {\n\t\tvec2 uv = sph / vec2(PI * 2.0, PI) + 0.5;\n\t\treturn texture2DLodEXT(sourceTex, vec2(uv.x, 1.0 - uv.y), mipLevel);\n\t}\n\tvec4 sampleEquirect(vec3 dir, float mipLevel) {\n\t\treturn sampleEquirect(toSpherical(dir), mipLevel);\n\t}\n\tvec4 sampleOctahedral(vec3 dir) {\n\t\tvec2 uv = octEncode(dir) * 0.5 + 0.5;\n\t\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n\t}\n\tvec4 sampleOctahedral(vec2 sph) {\n\t\treturn sampleOctahedral(fromSpherical(sph));\n\t}\n\tvec4 sampleOctahedral(vec3 dir, float mipLevel) {\n\t\tvec2 uv = octEncode(dir) * 0.5 + 0.5;\n\t\treturn texture2DLodEXT(sourceTex, vec2(uv.x, 1.0 - uv.y), mipLevel);\n\t}\n\tvec4 sampleOctahedral(vec2 sph, float mipLevel) {\n\t\treturn sampleOctahedral(fromSpherical(sph), mipLevel);\n\t}\n#endif\nvec3 getDirectionCubemap() {\n\tvec2 st = vUv0 * 2.0 - 1.0;\n\tfloat face = targetFace();\n\tvec3 vec;\n\tif (face == 0.0) {\n\t\tvec = vec3(1, -st.y, -st.x);\n\t} else if (face == 1.0) {\n\t\tvec = vec3(-1, -st.y, st.x);\n\t} else if (face == 2.0) {\n\t\tvec = vec3(st.x, 1, st.y);\n\t} else if (face == 3.0) {\n\t\tvec = vec3(st.x, -1, -st.y);\n\t} else if (face == 4.0) {\n\t\tvec = vec3(st.x, -st.y, 1);\n\t} else {\n\t\tvec = vec3(-st.x, -st.y, -1);\n\t}\n\treturn normalize(modifySeams(vec, 1.0 / (1.0 - targetCubeSeamScale())));\n}\nmat3 matrixFromVector(vec3 n) {\n\tfloat a = 1.0 / (1.0 + n.z);\n\tfloat b = -n.x * n.y * a;\n\tvec3 b1 = vec3(1.0 - n.x * n.x * a, b, -n.x);\n\tvec3 b2 = vec3(b, 1.0 - n.y * n.y * a, -n.y);\n\treturn mat3(b1, b2, n);\n}\nmat3 matrixFromVectorSlow(vec3 n) {\n\tvec3 up = (1.0 - abs(n.y) <= 0.0000001) ? vec3(0.0, 0.0, n.y > 0.0 ? 1.0 : -1.0) : vec3(0.0, 1.0, 0.0);\n\tvec3 x = normalize(cross(up, n));\n\tvec3 y = cross(n, x);\n\treturn mat3(x, y, n);\n}\nvec4 reproject() {\n\tif (NUM_SAMPLES <= 1) {\n\t\treturn ENCODE_FUNC(DECODE_FUNC(SOURCE_FUNC(TARGET_FUNC())));\n\t} else {\n\t\tvec3 t = TARGET_FUNC();\n\t\tvec3 tu = dFdx(t);\n\t\tvec3 tv = dFdy(t);\n\t\tvec3 result = vec3(0.0);\n\t\tfor (float u = 0.0; u < NUM_SAMPLES_SQRT; ++u) {\n\t\t\tfor (float v = 0.0; v < NUM_SAMPLES_SQRT; ++v) {\n\t\t\t\tresult += DECODE_FUNC(SOURCE_FUNC(normalize(t +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttu * (u / NUM_SAMPLES_SQRT - 0.5) +\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttv * (v / NUM_SAMPLES_SQRT - 0.5))));\n\t\t\t}\n\t\t}\n\t\treturn ENCODE_FUNC(result / (NUM_SAMPLES_SQRT * NUM_SAMPLES_SQRT));\n\t}\n}\nvec4 unpackFloat = vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0);\n#ifdef USE_SAMPLES_TEX\n\tvoid unpackSample(int i, out vec3 L, out float mipLevel) {\n\t\tfloat u = (float(i * 4) + 0.5) * samplesTexInverseSize.x;\n\t\tfloat v = (floor(u) + 0.5) * samplesTexInverseSize.y;\n\t\tvec4 raw;\n\t\traw.x = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\t\traw.y = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\t\traw.z = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\t\traw.w = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat);\n\t\tL.xyz = raw.xyz * 2.0 - 1.0;\n\t\tmipLevel = raw.w * 8.0;\n\t}\n\tvec4 prefilterSamples() {\n\t\tmat3 vecSpace = matrixFromVectorSlow(TARGET_FUNC());\n\t\tvec3 L;\n\t\tfloat mipLevel;\n\t\tvec3 result = vec3(0.0);\n\t\tfloat totalWeight = 0.0;\n\t\tfor (int i = 0; i < NUM_SAMPLES; ++i) {\n\t\t\tunpackSample(i, L, mipLevel);\n\t\t\tresult += DECODE_FUNC(SOURCE_FUNC(vecSpace * L, mipLevel)) * L.z;\n\t\t\ttotalWeight += L.z;\n\t\t}\n\t\treturn ENCODE_FUNC(result / totalWeight);\n\t}\n\tvec4 prefilterSamplesUnweighted() {\n\t\tmat3 vecSpace = matrixFromVectorSlow(TARGET_FUNC());\n\t\tvec3 L;\n\t\tfloat mipLevel;\n\t\tvec3 result = vec3(0.0);\n\t\tfloat totalWeight = 0.0;\n\t\tfor (int i = 0; i < NUM_SAMPLES; ++i) {\n\t\t\tunpackSample(i, L, mipLevel);\n\t\t\tresult += DECODE_FUNC(SOURCE_FUNC(vecSpace * L, mipLevel));\n\t\t}\n\t\treturn ENCODE_FUNC(result / float(NUM_SAMPLES));\n\t}\n#endif\nvoid main(void) {\n\tgl_FragColor = PROCESS_FUNC();\n}\n",screenDepthPS:"\nuniform highp sampler2D uSceneDepthMap;\n#ifndef SCREENSIZE\n#define SCREENSIZE\nuniform vec4 uScreenSize;\n#endif\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\n#ifndef LINEARIZE_DEPTH\n#ifndef CAMERAPLANES\n#define CAMERAPLANES\nuniform vec4 camera_params;\n#endif\n#define LINEARIZE_DEPTH\n#ifdef GL2\nfloat linearizeDepth(float z) {\n\tif (camera_params.w == 0.0)\n\t\treturn (camera_params.z * camera_params.y) / (camera_params.y + z * (camera_params.z - camera_params.y));\n\telse\n\t\treturn camera_params.z + z * (camera_params.y - camera_params.z);\n}\n#else\n#ifndef UNPACKFLOAT\n#define UNPACKFLOAT\nfloat unpackFloat(vec4 rgbaDepth) {\n\tconst vec4 bitShift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n\treturn dot(rgbaDepth, bitShift);\n}\n#endif\n#endif\n#endif\nfloat getLinearScreenDepth(vec2 uv) {\n\t#ifdef GL2\n\t\treturn linearizeDepth(texture2D(uSceneDepthMap, uv).r);\n\t#else\n\t\treturn unpackFloat(texture2D(uSceneDepthMap, uv)) * camera_params.y;\n\t#endif\n}\n#ifndef VERTEXSHADER\nfloat getLinearScreenDepth() {\n\tvec2 uv = gl_FragCoord.xy * uScreenSize.zw;\n\treturn getLinearScreenDepth(uv);\n}\n#endif\nfloat getLinearDepth(vec3 pos) {\n\treturn -(matrix_view * vec4(pos, 1.0)).z;\n}\n",shadowCascadesPS:"\nconst float maxCascades = 4.0;\nmat4 cascadeShadowMat;\nvoid getShadowCascadeMatrix(mat4 shadowMatrixPalette[4], float shadowCascadeDistances[4], float shadowCascadeCount) {\n\tfloat depth = 1.0 / gl_FragCoord.w;\n\tfloat cascadeIndex = 0.0;\n\tfor (float i = 0.0; i < maxCascades; i++) {\n\t\tif (depth < shadowCascadeDistances[int(i)]) {\n\t\t\tcascadeIndex = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tcascadeIndex = min(cascadeIndex, shadowCascadeCount - 1.0);\n\t#ifdef GL2\n\t\tcascadeShadowMat = shadowMatrixPalette[int(cascadeIndex)];\n\t#else\n\t\tif (cascadeIndex == 0.0) {\n\t\t\tcascadeShadowMat = shadowMatrixPalette[0];\n\t\t}\n\t\telse if (cascadeIndex == 1.0) {\n\t\t\tcascadeShadowMat = shadowMatrixPalette[1];\n\t\t}\n\t\telse if (cascadeIndex == 2.0) {\n\t\t\tcascadeShadowMat = shadowMatrixPalette[2];\n\t\t}\n\t\telse {\n\t\t\tcascadeShadowMat = shadowMatrixPalette[3];\n\t\t}\n\t#endif\n}\nvoid fadeShadow(float shadowCascadeDistances[4]) {\t\t\t\t \n\tfloat depth = 1.0 / gl_FragCoord.w;\n\tif (depth > shadowCascadeDistances[int(maxCascades - 1.0)]) {\n\t\tdShadowCoord.z = -9999999.0;\n\t}\n}\n",shadowEVSMPS:"\nfloat VSM$(sampler2D tex, vec2 texCoords, float resolution, float Z, float vsmBias, float exponent) {\n\tvec3 moments = texture2D(tex, texCoords).xyz;\n\treturn calculateEVSM(moments, Z, vsmBias, exponent);\n}\nfloat getShadowVSM$(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM$(shadowMap, shadowCoord.xy, shadowParams.x, shadowCoord.z, shadowParams.y, exponent);\n}\nfloat getShadowSpotVSM$(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM$(shadowMap, shadowCoord.xy, shadowParams.x, length(lightDir) * shadowParams.w + shadowParams.z, shadowParams.y, exponent);\n}\n",shadowEVSMnPS:"\nfloat VSM$(TEXTURE_ACCEPT(tex), vec2 texCoords, float resolution, float Z, float vsmBias, float exponent) {\n\tfloat pixelSize = 1.0 / resolution;\n\ttexCoords -= vec2(pixelSize);\n\tvec3 s00 = texture2D(tex, texCoords).xyz;\n\tvec3 s10 = texture2D(tex, texCoords + vec2(pixelSize, 0)).xyz;\n\tvec3 s01 = texture2D(tex, texCoords + vec2(0, pixelSize)).xyz;\n\tvec3 s11 = texture2D(tex, texCoords + vec2(pixelSize)).xyz;\n\tvec2 fr = fract(texCoords * resolution);\n\tvec3 h0 = mix(s00, s10, fr.x);\n\tvec3 h1 = mix(s01, s11, fr.x);\n\tvec3 moments = mix(h0, h1, fr.y);\n\treturn calculateEVSM(moments, Z, vsmBias, exponent);\n}\nfloat getShadowVSM$(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM$(TEXTURE_PASS(shadowMap), shadowCoord.xy, shadowParams.x, shadowCoord.z, shadowParams.y, exponent);\n}\nfloat getShadowSpotVSM$(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM$(TEXTURE_PASS(shadowMap), shadowCoord.xy, shadowParams.x, length(lightDir) * shadowParams.w + shadowParams.z, shadowParams.y, exponent);\n}\n",shadowPCSSPS:"\n#define PCSS_SAMPLE_COUNT 16\nuniform float pcssDiskSamples[PCSS_SAMPLE_COUNT];\nuniform float pcssSphereSamples[PCSS_SAMPLE_COUNT];\nvec2 vogelDisk(int sampleIndex, float count, float phi, float r) {\n\tconst float GoldenAngle = 2.4;\n\tfloat theta = float(sampleIndex) * GoldenAngle + phi;\n\tfloat sine = sin(theta);\n\tfloat cosine = cos(theta);\n\treturn vec2(r * cosine, r * sine);\n}\nvec3 vogelSphere(int sampleIndex, float count, float phi, float r) {\n\tconst float GoldenAngle = 2.4;\n\tfloat theta = float(sampleIndex) * GoldenAngle + phi;\n\tfloat weight = float(sampleIndex) / count;\n\treturn vec3(cos(theta) * r, weight, sin(theta) * r);\n}\nfloat noise(vec2 screenPos) {\n\tconst float PHI = 1.61803398874989484820459;\n\treturn fract(sin(dot(screenPos * PHI, screenPos)) * screenPos.x);\n}\n#ifndef UNPACKFLOAT\n#define UNPACKFLOAT\nfloat unpackFloat(vec4 rgbaDepth) {\n\tconst vec4 bitShift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n\treturn dot(rgbaDepth, bitShift);\n}\n#endif\nfloat viewSpaceDepth(float depth, mat4 invProjection) {\n\tfloat z = depth * 2.0 - 1.0;\n\tvec4 clipSpace = vec4(0.0, 0.0, z, 1.0);\n\tvec4 viewSpace = invProjection * clipSpace;\n\treturn viewSpace.z;\n}\nfloat PCSSBlockerDistance(TEXTURE_ACCEPT(shadowMap), vec2 sampleCoords[PCSS_SAMPLE_COUNT], vec2 shadowCoords, vec2 searchSize, float z) {\n\tfloat blockers = 0.0;\n\tfloat averageBlocker = 0.0;\n\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i++) {\n\t\tvec2 offset = sampleCoords[i] * searchSize;\n\t\tvec2 sampleUV = shadowCoords + offset;\n\t#ifdef GL2\n\t\tfloat blocker = textureLod(shadowMap, sampleUV, 0.0).r;\n\t#else\n\t\tfloat blocker = unpackFloat(texture2D(shadowMap, sampleUV));\n\t#endif\t\t\n\t\tfloat isBlocking = step(blocker, z);\n\t\tblockers += isBlocking;\n\t\taverageBlocker += blocker * isBlocking;\n\t}\n\tif (blockers > 0.0)\n\t\treturn averageBlocker /= blockers;\n\treturn -1.0;\n}\nfloat PCSS(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoords, vec4 cameraParams, vec2 shadowSearchArea) {\n\tfloat receiverDepth = shadowCoords.z;\n#ifndef GL2\n\treceiverDepth *= 1.0 / (cameraParams.y - cameraParams.z);\n#endif\n\tvec2 samplePoints[PCSS_SAMPLE_COUNT];\n\tfloat noise = noise( gl_FragCoord.xy ) * 2.0 * PI;\n\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i++) {\n\t\tfloat pcssPresample = pcssDiskSamples[i];\n\t\tsamplePoints[i] = vogelDisk(i, float(PCSS_SAMPLE_COUNT), noise, pcssPresample);\n\t}\n\tfloat averageBlocker = PCSSBlockerDistance(TEXTURE_PASS(shadowMap), samplePoints, shadowCoords.xy, shadowSearchArea, receiverDepth);\n\tif (averageBlocker == -1.0) {\n\t\treturn 1.0;\n\t} else {\n\t\tvec2 filterRadius = ((receiverDepth - averageBlocker) / averageBlocker) * shadowSearchArea * cameraParams.x;\n\t\tfloat shadow = 0.0;\n\t\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i ++)\n\t\t{\n\t\t\tvec2 sampleUV = samplePoints[i] * filterRadius;\n\t\t\tsampleUV = shadowCoords.xy + sampleUV;\n\t\t#ifdef GL2\n\t\t\tfloat depth = textureLod(shadowMap, sampleUV, 0.0).r;\n\t\t#else\n\t\t\tfloat depth = unpackFloat(texture2D(shadowMap, sampleUV));\n\t\t#endif\n\t\t\tshadow += step(receiverDepth, depth);\n\t\t}\n\t\treturn shadow / float(PCSS_SAMPLE_COUNT);\n\t} \n}\nfloat PCSSCubeBlockerDistance(samplerCube shadowMap, vec3 lightDirNorm, vec3 samplePoints[PCSS_SAMPLE_COUNT], float z, float shadowSearchArea) {\n\tfloat blockers = 0.0;\n\tfloat averageBlocker = 0.0;\n\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i++) {\n\t\tvec3 sampleDir = lightDirNorm + samplePoints[i] * shadowSearchArea;\n\t\tsampleDir = normalize(sampleDir);\n\t#ifdef GL2\n\t\tfloat blocker = textureCubeLodEXT(shadowMap, sampleDir, 0.0).r;\n\t#else\n\t\tfloat blocker = unpackFloat(textureCube(shadowMap, sampleDir));\n\t#endif\n\t\tfloat isBlocking = step(blocker, z);\n\t\tblockers += isBlocking;\n\t\taverageBlocker += blocker * isBlocking;\n\t}\n\tif (blockers > 0.0)\n\t\treturn averageBlocker /= float(blockers);\n\treturn -1.0;\n}\nfloat PCSSCube(samplerCube shadowMap, vec4 shadowParams, vec3 shadowCoords, vec4 cameraParams, float shadowSearchArea, vec3 lightDir) {\n\t\n\tvec3 samplePoints[PCSS_SAMPLE_COUNT];\n\tfloat noise = noise( gl_FragCoord.xy ) * 2.0 * PI;\n\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i++) {\n\t\tfloat r = pcssSphereSamples[i];\n\t\tsamplePoints[i] = vogelSphere(i, float(PCSS_SAMPLE_COUNT), noise, r);\n\t}\n\tfloat receiverDepth = length(lightDir) * shadowParams.w + shadowParams.z;\n\tvec3 lightDirNorm = normalize(lightDir);\n\t\n\tfloat averageBlocker = PCSSCubeBlockerDistance(shadowMap, lightDirNorm, samplePoints, receiverDepth, shadowSearchArea);\n\tif (averageBlocker == -1.0) {\n\t\treturn 1.0;\n\t} else {\n\t\tfloat filterRadius = ((receiverDepth - averageBlocker) / averageBlocker) * shadowSearchArea;\n\t\tfloat shadow = 0.0;\n\t\tfor (int i = 0; i < PCSS_SAMPLE_COUNT; i++)\n\t\t{\n\t\t\tvec3 offset = samplePoints[i] * filterRadius;\n\t\t\tvec3 sampleDir = lightDirNorm + offset;\n\t\t\tsampleDir = normalize(sampleDir);\n\t\t\t#ifdef GL2\n\t\t\t\tfloat depth = textureCubeLodEXT(shadowMap, sampleDir, 0.0).r;\n\t\t\t#else\n\t\t\t\tfloat depth = unpackFloat(textureCube(shadowMap, sampleDir));\n\t\t\t#endif\n\t\t\tshadow += step(receiverDepth, depth);\n\t\t}\n\t\treturn shadow / float(PCSS_SAMPLE_COUNT);\n\t}\n}\nfloat getShadowPointPCSS(samplerCube shadowMap, vec3 shadowCoord, vec4 shadowParams, vec4 cameraParams, vec2 shadowSearchArea, vec3 lightDir) {\n\treturn PCSSCube(shadowMap, shadowParams, shadowCoord, cameraParams, shadowSearchArea.x, lightDir);\n}\nfloat getShadowSpotPCSS(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, vec4 cameraParams, vec2 shadowSearchArea, vec3 lightDir) {\n\treturn PCSS(TEXTURE_PASS(shadowMap), shadowCoord, cameraParams, shadowSearchArea);\n}\nfloat getShadowPCSS(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, vec4 cameraParams, vec2 shadowSearchArea, vec3 lightDir) {\n\treturn PCSS(TEXTURE_PASS(shadowMap), shadowCoord, cameraParams, shadowSearchArea);\n}\n",shadowSampleCoordPS:"\nvec3 getShadowSampleCoord$LIGHT(mat4 shadowTransform, vec4 shadowParams, vec3 worldPosition, vec3 lightPos, inout vec3 lightDir, vec3 lightDirNorm, vec3 normal) {\n\tvec3 surfacePosition = worldPosition;\n#ifdef SHADOW_SAMPLE_POINT\n\t#ifdef SHADOW_SAMPLE_NORMAL_OFFSET\n\t\tfloat distScale = length(lightDir);\n\t\tsurfacePosition = worldPosition + normal * shadowParams.y * clamp(1.0 - dot(normal, -lightDirNorm), 0.0, 1.0) * distScale;\n\t\tlightDir = surfacePosition - lightPos;\n\t\treturn lightDir;\n\t#endif\n#else\n\t#ifdef SHADOW_SAMPLE_SOURCE_ZBUFFER\n\t\t#ifdef SHADOW_SAMPLE_NORMAL_OFFSET\n\t\t\tsurfacePosition = worldPosition + normal * shadowParams.y;\n\t\t#endif\n\t#else\n\t\t#ifdef SHADOW_SAMPLE_NORMAL_OFFSET\n\t\t\t#ifdef SHADOW_SAMPLE_ORTHO\n\t\t\t\tfloat distScale = 1.0;\n\t\t\t#else\n\t\t\t\tfloat distScale = abs(dot(vPositionW - lightPos, lightDirNorm));\n\t\t\t#endif\n\t\t\tsurfacePosition = worldPosition + normal * shadowParams.y * clamp(1.0 - dot(normal, -lightDirNorm), 0.0, 1.0) * distScale;\n\t\t#endif\n\t#endif\n\tvec4 positionInShadowSpace = shadowTransform * vec4(surfacePosition, 1.0);\n\t#ifdef SHADOW_SAMPLE_ORTHO\n\t\tpositionInShadowSpace.z = saturate(positionInShadowSpace.z) - 0.0001;\n\t#else\n\t\t#ifdef SHADOW_SAMPLE_SOURCE_ZBUFFER\n\t\t\tpositionInShadowSpace.xyz /= positionInShadowSpace.w;\n\t\t#else\n\t\t\tpositionInShadowSpace.xy /= positionInShadowSpace.w;\n\t\t\tpositionInShadowSpace.z = length(lightDir) * shadowParams.w;\n\t\t#endif\n\t#endif\n\t#ifdef SHADOW_SAMPLE_Z_BIAS\n\t\tpositionInShadowSpace.z += getShadowBias(shadowParams.x, shadowParams.z);\n\t#endif\n\tsurfacePosition = positionInShadowSpace.xyz;\n#endif\n\treturn surfacePosition;\n}\n",shadowStandardPS:"\nvec3 lessThan2(vec3 a, vec3 b) {\n\treturn clamp((b - a)*1000.0, 0.0, 1.0);\n}\n#ifndef UNPACKFLOAT\n#define UNPACKFLOAT\n\tfloat unpackFloat(vec4 rgbaDepth) {\n\t\tconst vec4 bitShift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n\t\treturn dot(rgbaDepth, bitShift);\n\t}\n#endif\n#ifdef GL2\nfloat _getShadowPCF3x3(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec3 shadowParams) {\n\tfloat z = shadowCoord.z;\n\tvec2 uv = shadowCoord.xy * shadowParams.x;\n\tfloat shadowMapSizeInv = 1.0 / shadowParams.x;\n\tvec2 base_uv = floor(uv + 0.5);\n\tfloat s = (uv.x + 0.5 - base_uv.x);\n\tfloat t = (uv.y + 0.5 - base_uv.y);\n\tbase_uv -= vec2(0.5);\n\tbase_uv *= shadowMapSizeInv;\n\tfloat sum = 0.0;\n\tfloat uw0 = (3.0 - 2.0 * s);\n\tfloat uw1 = (1.0 + 2.0 * s);\n\tfloat u0 = (2.0 - s) / uw0 - 1.0;\n\tfloat u1 = s / uw1 + 1.0;\n\tfloat vw0 = (3.0 - 2.0 * t);\n\tfloat vw1 = (1.0 + 2.0 * t);\n\tfloat v0 = (2.0 - t) / vw0 - 1.0;\n\tfloat v1 = t / vw1 + 1.0;\n\tu0 = u0 * shadowMapSizeInv + base_uv.x;\n\tv0 = v0 * shadowMapSizeInv + base_uv.y;\n\tu1 = u1 * shadowMapSizeInv + base_uv.x;\n\tv1 = v1 * shadowMapSizeInv + base_uv.y;\n\tsum += uw0 * vw0 * textureShadow(shadowMap, vec3(u0, v0, z));\n\tsum += uw1 * vw0 * textureShadow(shadowMap, vec3(u1, v0, z));\n\tsum += uw0 * vw1 * textureShadow(shadowMap, vec3(u0, v1, z));\n\tsum += uw1 * vw1 * textureShadow(shadowMap, vec3(u1, v1, z));\n\tsum *= 1.0f / 16.0;\n\treturn sum;\n}\nfloat getShadowPCF3x3(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF3x3(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams.xyz);\n}\nfloat getShadowSpotPCF3x3(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF3x3(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams.xyz);\n}\nfloat getShadowPCF1x1(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn textureShadow(shadowMap, shadowCoord);\n}\nfloat getShadowSpotPCF1x1(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn textureShadow(shadowMap, shadowCoord);\n}\n#else\nfloat _xgetShadowPCF3x3(mat3 depthKernel, vec3 shadowCoord, sampler2D shadowMap, vec3 shadowParams) {\n\tmat3 shadowKernel;\n\tvec3 shadowZ = vec3(shadowCoord.z);\n\tshadowKernel[0] = vec3(greaterThan(depthKernel[0], shadowZ));\n\tshadowKernel[1] = vec3(greaterThan(depthKernel[1], shadowZ));\n\tshadowKernel[2] = vec3(greaterThan(depthKernel[2], shadowZ));\n\tvec2 fractionalCoord = fract( shadowCoord.xy * shadowParams.x );\n\tshadowKernel[0] = mix(shadowKernel[0], shadowKernel[1], fractionalCoord.x);\n\tshadowKernel[1] = mix(shadowKernel[1], shadowKernel[2], fractionalCoord.x);\n\tvec4 shadowValues;\n\tshadowValues.x = mix(shadowKernel[0][0], shadowKernel[0][1], fractionalCoord.y);\n\tshadowValues.y = mix(shadowKernel[0][1], shadowKernel[0][2], fractionalCoord.y);\n\tshadowValues.z = mix(shadowKernel[1][0], shadowKernel[1][1], fractionalCoord.y);\n\tshadowValues.w = mix(shadowKernel[1][1], shadowKernel[1][2], fractionalCoord.y);\n\treturn dot( shadowValues, vec4( 1.0 ) ) * 0.25;\n}\nfloat _getShadowPCF3x3(sampler2D shadowMap, vec3 shadowCoord, vec3 shadowParams) {\n\tfloat xoffset = 1.0 / shadowParams.x;\n\tfloat dx0 = -xoffset;\n\tfloat dx1 = xoffset;\n\tmat3 depthKernel;\n\tdepthKernel[0][0] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx0, dx0)));\n\tdepthKernel[0][1] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx0, 0.0)));\n\tdepthKernel[0][2] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx0, dx1)));\n\tdepthKernel[1][0] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(0.0, dx0)));\n\tdepthKernel[1][1] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy));\n\tdepthKernel[1][2] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(0.0, dx1)));\n\tdepthKernel[2][0] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx1, dx0)));\n\tdepthKernel[2][1] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx1, 0.0)));\n\tdepthKernel[2][2] = unpackFloat(textureShadow(shadowMap, shadowCoord.xy + vec2(dx1, dx1)));\n\treturn _xgetShadowPCF3x3(depthKernel, shadowCoord, shadowMap, shadowParams);\n}\nfloat getShadowPCF3x3(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF3x3(shadowMap, shadowCoord, shadowParams.xyz);\n}\nfloat getShadowSpotPCF3x3(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF3x3(shadowMap, shadowCoord, shadowParams.xyz);\n}\nfloat _getShadowPCF1x1(sampler2D shadowMap, vec3 shadowCoord) {\n\tfloat shadowSample = unpackFloat(textureShadow(shadowMap, shadowCoord.xy));\n\treturn shadowSample > shadowCoord.z ? 1.0 : 0.0;\n}\nfloat getShadowPCF1x1(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF1x1(shadowMap, shadowCoord);\n}\nfloat getShadowSpotPCF1x1(sampler2D shadowMap, vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF1x1(shadowMap, shadowCoord);\n}\n#endif\n#ifndef WEBGPU\nfloat _getShadowPoint(samplerCube shadowMap, vec4 shadowParams, vec3 dir) {\n\tvec3 tc = normalize(dir);\n\tvec3 tcAbs = abs(tc);\n\tvec4 dirX = vec4(1,0,0, tc.x);\n\tvec4 dirY = vec4(0,1,0, tc.y);\n\tfloat majorAxisLength = tc.z;\n\tif ((tcAbs.x > tcAbs.y) && (tcAbs.x > tcAbs.z)) {\n\t\tdirX = vec4(0,0,1, tc.z);\n\t\tdirY = vec4(0,1,0, tc.y);\n\t\tmajorAxisLength = tc.x;\n\t} else if ((tcAbs.y > tcAbs.x) && (tcAbs.y > tcAbs.z)) {\n\t\tdirX = vec4(1,0,0, tc.x);\n\t\tdirY = vec4(0,0,1, tc.z);\n\t\tmajorAxisLength = tc.y;\n\t}\n\tfloat shadowParamsInFaceSpace = ((1.0/shadowParams.x) * 2.0) * abs(majorAxisLength);\n\tvec3 xoffset = (dirX.xyz * shadowParamsInFaceSpace);\n\tvec3 yoffset = (dirY.xyz * shadowParamsInFaceSpace);\n\tvec3 dx0 = -xoffset;\n\tvec3 dy0 = -yoffset;\n\tvec3 dx1 = xoffset;\n\tvec3 dy1 = yoffset;\n\tmat3 shadowKernel;\n\tmat3 depthKernel;\n\tdepthKernel[0][0] = unpackFloat(textureCube(shadowMap, tc + dx0 + dy0));\n\tdepthKernel[0][1] = unpackFloat(textureCube(shadowMap, tc + dx0));\n\tdepthKernel[0][2] = unpackFloat(textureCube(shadowMap, tc + dx0 + dy1));\n\tdepthKernel[1][0] = unpackFloat(textureCube(shadowMap, tc + dy0));\n\tdepthKernel[1][1] = unpackFloat(textureCube(shadowMap, tc));\n\tdepthKernel[1][2] = unpackFloat(textureCube(shadowMap, tc + dy1));\n\tdepthKernel[2][0] = unpackFloat(textureCube(shadowMap, tc + dx1 + dy0));\n\tdepthKernel[2][1] = unpackFloat(textureCube(shadowMap, tc + dx1));\n\tdepthKernel[2][2] = unpackFloat(textureCube(shadowMap, tc + dx1 + dy1));\n\tvec3 shadowZ = vec3(length(dir) * shadowParams.w + shadowParams.z);\n\tshadowKernel[0] = vec3(lessThan2(depthKernel[0], shadowZ));\n\tshadowKernel[1] = vec3(lessThan2(depthKernel[1], shadowZ));\n\tshadowKernel[2] = vec3(lessThan2(depthKernel[2], shadowZ));\n\tvec2 uv = (vec2(dirX.w, dirY.w) / abs(majorAxisLength)) * 0.5;\n\tvec2 fractionalCoord = fract( uv * shadowParams.x );\n\tshadowKernel[0] = mix(shadowKernel[0], shadowKernel[1], fractionalCoord.x);\n\tshadowKernel[1] = mix(shadowKernel[1], shadowKernel[2], fractionalCoord.x);\n\tvec4 shadowValues;\n\tshadowValues.x = mix(shadowKernel[0][0], shadowKernel[0][1], fractionalCoord.y);\n\tshadowValues.y = mix(shadowKernel[0][1], shadowKernel[0][2], fractionalCoord.y);\n\tshadowValues.z = mix(shadowKernel[1][0], shadowKernel[1][1], fractionalCoord.y);\n\tshadowValues.w = mix(shadowKernel[1][1], shadowKernel[1][2], fractionalCoord.y);\n\treturn 1.0 - dot( shadowValues, vec4( 1.0 ) ) * 0.25;\n}\nfloat getShadowPointPCF3x3(samplerCube shadowMap, vec3 shadowCoord, vec4 shadowParams, vec3 lightDir) {\n\treturn _getShadowPoint(shadowMap, shadowParams, lightDir);\n}\n#endif\n",shadowStandardGL2PS:"\nfloat _getShadowPCF5x5(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec3 shadowParams) {\n\tfloat z = shadowCoord.z;\n\tvec2 uv = shadowCoord.xy * shadowParams.x;\n\tfloat shadowMapSizeInv = 1.0 / shadowParams.x;\n\tvec2 base_uv = floor(uv + 0.5);\n\tfloat s = (uv.x + 0.5 - base_uv.x);\n\tfloat t = (uv.y + 0.5 - base_uv.y);\n\tbase_uv -= vec2(0.5);\n\tbase_uv *= shadowMapSizeInv;\n\tfloat uw0 = (4.0 - 3.0 * s);\n\tfloat uw1 = 7.0;\n\tfloat uw2 = (1.0 + 3.0 * s);\n\tfloat u0 = (3.0 - 2.0 * s) / uw0 - 2.0;\n\tfloat u1 = (3.0 + s) / uw1;\n\tfloat u2 = s / uw2 + 2.0;\n\tfloat vw0 = (4.0 - 3.0 * t);\n\tfloat vw1 = 7.0;\n\tfloat vw2 = (1.0 + 3.0 * t);\n\tfloat v0 = (3.0 - 2.0 * t) / vw0 - 2.0;\n\tfloat v1 = (3.0 + t) / vw1;\n\tfloat v2 = t / vw2 + 2.0;\n\tfloat sum = 0.0;\n\tu0 = u0 * shadowMapSizeInv + base_uv.x;\n\tv0 = v0 * shadowMapSizeInv + base_uv.y;\n\tu1 = u1 * shadowMapSizeInv + base_uv.x;\n\tv1 = v1 * shadowMapSizeInv + base_uv.y;\n\tu2 = u2 * shadowMapSizeInv + base_uv.x;\n\tv2 = v2 * shadowMapSizeInv + base_uv.y;\n\tsum += uw0 * vw0 * textureShadow(shadowMap, vec3(u0, v0, z));\n\tsum += uw1 * vw0 * textureShadow(shadowMap, vec3(u1, v0, z));\n\tsum += uw2 * vw0 * textureShadow(shadowMap, vec3(u2, v0, z));\n\tsum += uw0 * vw1 * textureShadow(shadowMap, vec3(u0, v1, z));\n\tsum += uw1 * vw1 * textureShadow(shadowMap, vec3(u1, v1, z));\n\tsum += uw2 * vw1 * textureShadow(shadowMap, vec3(u2, v1, z));\n\tsum += uw0 * vw2 * textureShadow(shadowMap, vec3(u0, v2, z));\n\tsum += uw1 * vw2 * textureShadow(shadowMap, vec3(u1, v2, z));\n\tsum += uw2 * vw2 * textureShadow(shadowMap, vec3(u2, v2, z));\n\tsum *= 1.0f / 144.0;\n\tsum = saturate(sum);\n\treturn sum;\n}\nfloat getShadowPCF5x5(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF5x5(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams.xyz);\n}\nfloat getShadowSpotPCF5x5(SHADOWMAP_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams) {\n\treturn _getShadowPCF5x5(SHADOWMAP_PASS(shadowMap), shadowCoord, shadowParams.xyz);\n}\n",shadowVSM8PS:"\nfloat calculateVSM8(vec3 moments, float Z, float vsmBias) {\n\tfloat VSMBias = vsmBias;\n\tfloat depthScale = VSMBias * Z;\n\tfloat minVariance1 = depthScale * depthScale;\n\treturn chebyshevUpperBound(moments.xy, Z, minVariance1, 0.1);\n}\nfloat decodeFloatRG(vec2 rg) {\n\treturn rg.y*(1.0/255.0) + rg.x;\n}\nfloat VSM8(TEXTURE_ACCEPT(tex), vec2 texCoords, float resolution, float Z, float vsmBias, float exponent) {\n\tvec4 c = texture2D(tex, texCoords);\n\tvec3 moments = vec3(decodeFloatRG(c.xy), decodeFloatRG(c.zw), 0.0);\n\treturn calculateVSM8(moments, Z, vsmBias);\n}\nfloat getShadowVSM8(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM8(TEXTURE_PASS(shadowMap), shadowCoord.xy, shadowParams.x, shadowCoord.z, shadowParams.y, 0.0);\n}\nfloat getShadowSpotVSM8(TEXTURE_ACCEPT(shadowMap), vec3 shadowCoord, vec4 shadowParams, float exponent, vec3 lightDir) {\n\treturn VSM8(TEXTURE_PASS(shadowMap), shadowCoord.xy, shadowParams.x, length(lightDir) * shadowParams.w + shadowParams.z, shadowParams.y, 0.0);\n}\n",shadowVSM_commonPS:"\nfloat linstep(float a, float b, float v) {\n\treturn saturate((v - a) / (b - a));\n}\nfloat reduceLightBleeding(float pMax, float amount) {\n return linstep(amount, 1.0, pMax);\n}\nfloat chebyshevUpperBound(vec2 moments, float mean, float minVariance, float lightBleedingReduction) {\n\tfloat variance = moments.y - (moments.x * moments.x);\n\tvariance = max(variance, minVariance);\n\tfloat d = mean - moments.x;\n\tfloat pMax = variance / (variance + (d * d));\n\tpMax = reduceLightBleeding(pMax, lightBleedingReduction);\n\treturn (mean <= moments.x ? 1.0 : pMax);\n}\nfloat calculateEVSM(vec3 moments, float Z, float vsmBias, float exponent) {\n\tZ = 2.0 * Z - 1.0;\n\tfloat warpedDepth = exp(exponent * Z);\n\tmoments.xy += vec2(warpedDepth, warpedDepth*warpedDepth) * (1.0 - moments.z);\n\tfloat VSMBias = vsmBias;\n\tfloat depthScale = VSMBias * exponent * warpedDepth;\n\tfloat minVariance1 = depthScale * depthScale;\n\treturn chebyshevUpperBound(moments.xy, warpedDepth, minVariance1, 0.1);\n}\n",skinBatchConstVS:"\nattribute float vertex_boneIndices;\nuniform vec4 matrix_pose[BONE_LIMIT * 3];\nmat4 getBoneMatrix(const in float i) {\n\tvec4 v1 = matrix_pose[int(3.0 * i)];\n\tvec4 v2 = matrix_pose[int(3.0 * i + 1.0)];\n\tvec4 v3 = matrix_pose[int(3.0 * i + 2.0)];\n\treturn mat4(\n\t\tv1.x, v2.x, v3.x, 0,\n\t\tv1.y, v2.y, v3.y, 0,\n\t\tv1.z, v2.z, v3.z, 0,\n\t\tv1.w, v2.w, v3.w, 1\n\t);\n}\n",skinBatchTexVS:"\nattribute float vertex_boneIndices;\nuniform highp sampler2D texture_poseMap;\nuniform vec4 texture_poseMapSize;\nmat4 getBoneMatrix(const in float i) {\n\tfloat j = i * 3.0;\n\tfloat dx = texture_poseMapSize.z;\n\tfloat dy = texture_poseMapSize.w;\n\tfloat y = floor(j * dx);\n\tfloat x = j - (y * texture_poseMapSize.x);\n\ty = dy * (y + 0.5);\n\tvec4 v1 = texture2D(texture_poseMap, vec2(dx * (x + 0.5), y));\n\tvec4 v2 = texture2D(texture_poseMap, vec2(dx * (x + 1.5), y));\n\tvec4 v3 = texture2D(texture_poseMap, vec2(dx * (x + 2.5), y));\n\treturn mat4(\n\t\tv1.x, v2.x, v3.x, 0,\n\t\tv1.y, v2.y, v3.y, 0,\n\t\tv1.z, v2.z, v3.z, 0,\n\t\tv1.w, v2.w, v3.w, 1\n\t);\n}\n",skinConstVS:"\nattribute vec4 vertex_boneWeights;\nattribute vec4 vertex_boneIndices;\nuniform vec4 matrix_pose[BONE_LIMIT * 3];\nvoid getBoneMatrix(const in float i, out vec4 v1, out vec4 v2, out vec4 v3) {\n\tv1 = matrix_pose[int(3.0 * i)];\n\tv2 = matrix_pose[int(3.0 * i + 1.0)];\n\tv3 = matrix_pose[int(3.0 * i + 2.0)];\n}\nmat4 getSkinMatrix(const in vec4 indices, const in vec4 weights) {\n\tvec4 a1, a2, a3;\n\tgetBoneMatrix(indices.x, a1, a2, a3);\n\tvec4 b1, b2, b3;\n\tgetBoneMatrix(indices.y, b1, b2, b3);\n\tvec4 c1, c2, c3;\n\tgetBoneMatrix(indices.z, c1, c2, c3);\n\tvec4 d1, d2, d3;\n\tgetBoneMatrix(indices.w, d1, d2, d3);\n\tvec4 v1 = a1 * weights.x + b1 * weights.y + c1 * weights.z + d1 * weights.w;\n\tvec4 v2 = a2 * weights.x + b2 * weights.y + c2 * weights.z + d2 * weights.w;\n\tvec4 v3 = a3 * weights.x + b3 * weights.y + c3 * weights.z + d3 * weights.w;\n\tfloat one = dot(weights, vec4(1.0));\n\treturn mat4(\n\t\tv1.x, v2.x, v3.x, 0,\n\t\tv1.y, v2.y, v3.y, 0,\n\t\tv1.z, v2.z, v3.z, 0,\n\t\tv1.w, v2.w, v3.w, one\n\t);\n}\n",skinTexVS:"\nattribute vec4 vertex_boneWeights;\nattribute vec4 vertex_boneIndices;\nuniform highp sampler2D texture_poseMap;\nuniform vec4 texture_poseMapSize;\nvoid getBoneMatrix(const in float index, out vec4 v1, out vec4 v2, out vec4 v3) {\n\tfloat i = float(index);\n\tfloat j = i * 3.0;\n\tfloat dx = texture_poseMapSize.z;\n\tfloat dy = texture_poseMapSize.w;\n\t\n\tfloat y = floor(j * dx);\n\tfloat x = j - (y * texture_poseMapSize.x);\n\ty = dy * (y + 0.5);\n\tv1 = texture2D(texture_poseMap, vec2(dx * (x + 0.5), y));\n\tv2 = texture2D(texture_poseMap, vec2(dx * (x + 1.5), y));\n\tv3 = texture2D(texture_poseMap, vec2(dx * (x + 2.5), y));\n}\nmat4 getSkinMatrix(const in vec4 indices, const in vec4 weights) {\n\tvec4 a1, a2, a3;\n\tgetBoneMatrix(indices.x, a1, a2, a3);\n\tvec4 b1, b2, b3;\n\tgetBoneMatrix(indices.y, b1, b2, b3);\n\tvec4 c1, c2, c3;\n\tgetBoneMatrix(indices.z, c1, c2, c3);\n\tvec4 d1, d2, d3;\n\tgetBoneMatrix(indices.w, d1, d2, d3);\n\tvec4 v1 = a1 * weights.x + b1 * weights.y + c1 * weights.z + d1 * weights.w;\n\tvec4 v2 = a2 * weights.x + b2 * weights.y + c2 * weights.z + d2 * weights.w;\n\tvec4 v3 = a3 * weights.x + b3 * weights.y + c3 * weights.z + d3 * weights.w;\n\tfloat one = dot(weights, vec4(1.0));\n\treturn mat4(\n\t\tv1.x, v2.x, v3.x, 0,\n\t\tv1.y, v2.y, v3.y, 0,\n\t\tv1.z, v2.z, v3.z, 0,\n\t\tv1.w, v2.w, v3.w, one\n\t);\n}\n",skyboxEnvPS:"\nvarying vec3 vViewDir;\nuniform sampler2D texture_envAtlas;\nuniform float mipLevel;\nvoid main(void) {\n\tvec3 dir = vViewDir * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(normalize(dir));\n\tvec3 linear = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, mipLevel)));\n\tgl_FragColor = vec4(gammaCorrectOutput(toneMap(processEnvironment(linear))), 1.0);\n}\n",skyboxHDRPS:"\nvarying vec3 vViewDir;\nuniform samplerCube texture_cubeMap;\nvoid main(void) {\n\tvec3 dir=vViewDir;\n\tdir.x *= -1.0;\n\tvec3 linear = $DECODE(textureCube(texture_cubeMap, fixSeamsStatic(dir, $FIXCONST)));\n\tgl_FragColor = vec4(gammaCorrectOutput(toneMap(processEnvironment(linear))), 1.0);\n}\n",skyboxVS:"\nattribute vec3 aPosition;\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform mat4 matrix_projectionSkybox;\nuniform mat3 cubeMapRotationMatrix;\nvarying vec3 vViewDir;\nvoid main(void) {\n\tmat4 view = matrix_view;\n\tview[3][0] = view[3][1] = view[3][2] = 0.0;\n\tgl_Position = matrix_projectionSkybox * view * vec4(aPosition, 1.0);\n\tgl_Position.z = gl_Position.w - 0.00001;\n\tvViewDir = aPosition * cubeMapRotationMatrix;\n}\n",specularPS:"\n#ifdef MAPCOLOR\nuniform vec3 material_specular;\n#endif\nvoid getSpecularity() {\n\tvec3 specularColor = vec3(1,1,1);\n\t#ifdef MAPCOLOR\n\tspecularColor *= material_specular;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tspecularColor *= $DECODE(texture2DBias($SAMPLER, $UV, textureBias)).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tspecularColor *= saturate(vVertexColor.$VC);\n\t#endif\n\tdSpecularity = specularColor;\n}\n",sphericalPS:"\nconst float PI = 3.141592653589793;\nvec2 toSpherical(vec3 dir) {\n\treturn vec2(dir.xz == vec2(0.0) ? 0.0 : atan(dir.x, dir.z), asin(dir.y));\n}\nvec2 toSphericalUv(vec3 dir) {\n\tvec2 uv = toSpherical(dir) / vec2(PI * 2.0, PI) + 0.5;\n\treturn vec2(uv.x, 1.0 - uv.y);\n}\n",specularityFactorPS:"\n#ifdef MAPFLOAT\nuniform float material_specularityFactor;\n#endif\nvoid getSpecularityFactor() {\n\tfloat specularityFactor = 1.0;\n\t#ifdef MAPFLOAT\n\tspecularityFactor *= material_specularityFactor;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tspecularityFactor *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tspecularityFactor *= saturate(vVertexColor.$VC);\n\t#endif\n\tdSpecularityFactor = specularityFactor;\n}\n",spotPS:"\nfloat getSpotEffect(vec3 lightSpotDir, float lightInnerConeAngle, float lightOuterConeAngle, vec3 lightDirNorm) {\n\tfloat cosAngle = dot(lightDirNorm, lightSpotDir);\n\treturn smoothstep(lightOuterConeAngle, lightInnerConeAngle, cosAngle);\n}\n",startPS:"\nvoid main(void) {\n\tdReflection = vec4(0);\n\t#ifdef LIT_CLEARCOAT\n\tccSpecularLight = vec3(0);\n\tccReflection = vec3(0);\n\t#endif\n",startVS:"\nvoid main(void) {\n\tgl_Position = getPosition();\n",startNineSlicedPS:"\n\tnineSlicedUv = vUv0;\n\tnineSlicedUv.y = 1.0 - nineSlicedUv.y;\n",startNineSlicedTiledPS:"\n\tvec2 tileMask = step(vMask, vec2(0.99999));\n\tvec2 tileSize = 0.5 * (innerOffset.xy + innerOffset.zw);\n\tvec2 tileScale = vec2(1.0) / (vec2(1.0) - tileSize);\n\tvec2 clampedUv = mix(innerOffset.xy * 0.5, vec2(1.0) - innerOffset.zw * 0.5, fract((vTiledUv - tileSize) * tileScale));\n\tclampedUv = clampedUv * atlasRect.zw + atlasRect.xy;\n\tnineSlicedUv = vUv0 * tileMask + clampedUv * (vec2(1.0) - tileMask);\n\tnineSlicedUv.y = 1.0 - nineSlicedUv.y;\n\t\n",storeEVSMPS:"\nfloat exponent = VSM_EXPONENT;\ndepth = 2.0 * depth - 1.0;\ndepth = exp(exponent * depth);\ngl_FragColor = vec4(depth, depth*depth, 1.0, 1.0);\n",tangentBinormalVS:"\nvec3 getTangent() {\n\treturn normalize(dNormalMatrix * vertex_tangent.xyz);\n}\nvec3 getBinormal() {\n\treturn cross(vNormalW, vTangentW) * vertex_tangent.w;\n}\n",TBNPS:"\nvoid getTBN(vec3 tangent, vec3 binormal, vec3 normal) {\n\tdTBN = mat3(normalize(tangent), normalize(binormal), normalize(normal));\n}\n",TBNderivativePS:"\nuniform float tbnBasis;\nvoid getTBN(vec3 tangent, vec3 binormal, vec3 normal) {\n\tvec2 uv = $UV;\n\tvec3 dp1 = dFdx( vPositionW );\n\tvec3 dp2 = dFdy( vPositionW );\n\tvec2 duv1 = dFdx( uv );\n\tvec2 duv2 = dFdy( uv );\n\tvec3 dp2perp = cross( dp2, normal );\n\tvec3 dp1perp = cross( normal, dp1 );\n\tvec3 T = dp2perp * duv1.x + dp1perp * duv2.x;\n\tvec3 B = dp2perp * duv1.y + dp1perp * duv2.y;\n\tfloat denom = max( dot(T,T), dot(B,B) );\n\tfloat invmax = (denom == 0.0) ? 0.0 : tbnBasis / sqrt( denom );\n\tdTBN = mat3(T * invmax, -B * invmax, normal );\n}\n",TBNfastPS:"\nvoid getTBN(vec3 tangent, vec3 binormal, vec3 normal) {\n\tdTBN = mat3(tangent, binormal, normal);\n}\n",TBNObjectSpacePS:"\nvoid getTBN(vec3 tangent, vec3 binormal, vec3 normal) {\n\tvec3 B = cross(normal, vObjectSpaceUpW);\n\tvec3 T = cross(normal, B);\n\tif (dot(B,B)==0.0)\n\t{\n\t\tfloat major=max(max(normal.x, normal.y), normal.z);\n\t\tif (normal.x == major)\n\t\t{\n\t\t\tB=cross(normal, vec3(0,1,0));\n\t\t\tT=cross(normal, B);\n\t\t}\n\t\telse if (normal.y == major)\n\t\t{\n\t\t\tB=cross(normal, vec3(0,0,1));\n\t\t\tT=cross(normal, B);\n\t\t}\n\t\telse if (normal.z == major)\n\t\t{\n\t\t\tB=cross(normal, vec3(1,0,0));\n\t\t\tT=cross(normal, B);\n\t\t}\n\t}\n\tdTBN = mat3(normalize(T), normalize(B), normalize(normal));\n}\n",textureSamplePS:"\nvec4 texture2DSRGB(sampler2D tex, vec2 uv) {\n\treturn gammaCorrectInput(texture2D(tex, uv));\n}\nvec4 texture2DSRGB(sampler2D tex, vec2 uv, float bias) {\n\treturn gammaCorrectInput(texture2D(tex, uv, bias));\n}\nvec3 texture2DRGBM(sampler2D tex, vec2 uv) {\n\treturn decodeRGBM(texture2D(tex, uv));\n}\nvec3 texture2DRGBM(sampler2D tex, vec2 uv, float bias) {\n\treturn decodeRGBM(texture2D(tex, uv, bias));\n}\nvec3 texture2DRGBE(sampler2D tex, vec2 uv) {\n\treturn decodeRGBM(texture2D(tex, uv));\n}\nvec3 texture2DRGBE(sampler2D tex, vec2 uv, float bias) {\n\treturn decodeRGBM(texture2D(tex, uv, bias));\n}\n",thicknessPS:"\n#ifdef MAPFLOAT\nuniform float material_thickness;\n#endif\nvoid getThickness() {\n\tdThickness = 1.0;\n\t#ifdef MAPFLOAT\n\tdThickness *= material_thickness;\n\t#endif\n\t#ifdef MAPTEXTURE\n\tdThickness *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\tdThickness *= saturate(vVertexColor.$VC);\n\t#endif\n}\n",tonemappingAcesPS:"\nuniform float exposure;\nvec3 toneMap(vec3 color) {\n\tfloat tA = 2.51;\n\tfloat tB = 0.03;\n\tfloat tC = 2.43;\n\tfloat tD = 0.59;\n\tfloat tE = 0.14;\n\tvec3 x = color * exposure;\n\treturn (x*(tA*x+tB))/(x*(tC*x+tD)+tE);\n}\n",tonemappingAces2PS:"\nuniform float exposure;\nconst mat3 ACESInputMat = mat3(\n\t0.59719, 0.35458, 0.04823,\n\t0.07600, 0.90834, 0.01566,\n\t0.02840, 0.13383, 0.83777\n);\nconst mat3 ACESOutputMat = mat3(\n\t 1.60475, -0.53108, -0.07367,\n\t-0.10208, 1.10813, -0.00605,\n\t-0.00327, -0.07276, 1.07602\n);\nvec3 RRTAndODTFit(vec3 v) {\n\tvec3 a = v * (v + 0.0245786) - 0.000090537;\n\tvec3 b = v * (0.983729 * v + 0.4329510) + 0.238081;\n\treturn a / b;\n}\nvec3 toneMap(vec3 color) {\n\tcolor *= exposure / 0.6;\n\tcolor = color * ACESInputMat;\n\tcolor = RRTAndODTFit(color);\n\tcolor = color * ACESOutputMat;\n\tcolor = clamp(color, 0.0, 1.0);\n\treturn color;\n}\n",tonemappingFilmicPS:"\nconst float A = 0.15;\nconst float B = 0.50;\nconst float C = 0.10;\nconst float D = 0.20;\nconst float E = 0.02;\nconst float F = 0.30;\nconst float W = 11.2;\nuniform float exposure;\nvec3 uncharted2Tonemap(vec3 x) {\n return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;\n}\nvec3 toneMap(vec3 color) {\n\tcolor = uncharted2Tonemap(color * exposure);\n\tvec3 whiteScale = 1.0 / uncharted2Tonemap(vec3(W,W,W));\n\tcolor = color * whiteScale;\n\treturn color;\n}\n",tonemappingHejlPS:"\nuniform float exposure;\nvec3 toneMap(vec3 color) {\n\tcolor *= exposure;\n\tconst float A = 0.22, B = 0.3, C = .1, D = 0.2, E = .01, F = 0.3;\n\tconst float Scl = 1.25;\n\tvec3 h = max( vec3(0.0), color - vec3(0.004) );\n\treturn (h*((Scl*A)*h+Scl*vec3(C*B,C*B,C*B))+Scl*vec3(D*E,D*E,D*E)) / (h*(A*h+vec3(B,B,B))+vec3(D*F,D*F,D*F)) - Scl*vec3(E/F,E/F,E/F);\n}\n",tonemappingLinearPS:"\nuniform float exposure;\nvec3 toneMap(vec3 color) {\n\treturn color * exposure;\n}\n",tonemappingNonePS:"\nvec3 toneMap(vec3 color) {\n\treturn color;\n}\n",transformVS:"\n#ifdef PIXELSNAP\nuniform vec4 uScreenSize;\n#endif\n#ifdef SCREENSPACE\nuniform float projectionFlipY;\n#endif\n#ifdef MORPHING\nuniform vec4 morph_weights_a;\nuniform vec4 morph_weights_b;\n#endif\n#ifdef MORPHING_TEXTURE_BASED\n\tuniform vec4 morph_tex_params;\n\t#ifdef WEBGPU\n\t\tivec2 getTextureMorphCoords() {\n\t\t\tivec2 textureSize = ivec2(morph_tex_params.xy);\n\t\t\tint morphGridV = int(morph_vertex_id / textureSize.x);\n\t\t\tint morphGridU = int(morph_vertex_id - (morphGridV * textureSize.x));\n\t\t\tmorphGridV = textureSize.y - morphGridV - 1;\n\t\t\treturn ivec2(morphGridU, morphGridV);\n\t\t}\n\t#else\n\t\tvec2 getTextureMorphCoords() {\n\t\t\tvec2 textureSize = morph_tex_params.xy;\n\t\t\tvec2 invTextureSize = morph_tex_params.zw;\n\t\t\tfloat morphGridV = floor(morph_vertex_id * invTextureSize.x);\n\t\t\tfloat morphGridU = morph_vertex_id - (morphGridV * textureSize.x);\n\t\t\treturn vec2(morphGridU, morphGridV) * invTextureSize + (0.5 * invTextureSize);\n\t\t}\n\t#endif\n#endif\n#ifdef MORPHING_TEXTURE_BASED_POSITION\nuniform highp sampler2D morphPositionTex;\n#endif\nmat4 getModelMatrix() {\n\t#ifdef DYNAMICBATCH\n\treturn getBoneMatrix(vertex_boneIndices);\n\t#elif defined(SKIN)\n\treturn matrix_model * getSkinMatrix(vertex_boneIndices, vertex_boneWeights);\n\t#elif defined(INSTANCING)\n\treturn mat4(instance_line1, instance_line2, instance_line3, instance_line4);\n\t#else\n\treturn matrix_model;\n\t#endif\n}\nvec4 getPosition() {\n\tdModelMatrix = getModelMatrix();\n\tvec3 localPos = vertex_position;\n\t#ifdef NINESLICED\n\tlocalPos.xz *= outerScale;\n\tvec2 positiveUnitOffset = clamp(vertex_position.xz, vec2(0.0), vec2(1.0));\n\tvec2 negativeUnitOffset = clamp(-vertex_position.xz, vec2(0.0), vec2(1.0));\n\tlocalPos.xz += (-positiveUnitOffset * innerOffset.xy + negativeUnitOffset * innerOffset.zw) * vertex_texCoord0.xy;\n\tvTiledUv = (localPos.xz - outerScale + innerOffset.xy) * -0.5 + 1.0;\n\tlocalPos.xz *= -0.5;\n\tlocalPos = localPos.xzy;\n\t#endif\n\t#ifdef MORPHING\n\t#ifdef MORPHING_POS03\n\tlocalPos.xyz += morph_weights_a[0] * morph_pos0;\n\tlocalPos.xyz += morph_weights_a[1] * morph_pos1;\n\tlocalPos.xyz += morph_weights_a[2] * morph_pos2;\n\tlocalPos.xyz += morph_weights_a[3] * morph_pos3;\n\t#endif\n\t#ifdef MORPHING_POS47\n\tlocalPos.xyz += morph_weights_b[0] * morph_pos4;\n\tlocalPos.xyz += morph_weights_b[1] * morph_pos5;\n\tlocalPos.xyz += morph_weights_b[2] * morph_pos6;\n\tlocalPos.xyz += morph_weights_b[3] * morph_pos7;\n\t#endif\n\t#endif\n\t#ifdef MORPHING_TEXTURE_BASED_POSITION\n\t\t#ifdef WEBGPU\n\t\t\tivec2 morphUV = getTextureMorphCoords();\n\t\t\tvec3 morphPos = texelFetch(morphPositionTex, ivec2(morphUV), 0).xyz;\n\t\t#else\n\t\t\tvec2 morphUV = getTextureMorphCoords();\n\t\t\tvec3 morphPos = texture2D(morphPositionTex, morphUV).xyz;\n\t\t#endif\n\t\tlocalPos += morphPos;\n\t#endif\n\tvec4 posW = dModelMatrix * vec4(localPos, 1.0);\n\t#ifdef SCREENSPACE\n\tposW.zw = vec2(0.0, 1.0);\n\t#endif\n\tdPositionW = posW.xyz;\n\tvec4 screenPos;\n\t#ifdef UV1LAYOUT\n\tscreenPos = vec4(vertex_texCoord1.xy * 2.0 - 1.0, 0.5, 1);\n\t#else\n\t#ifdef SCREENSPACE\n\tscreenPos = posW;\n\tscreenPos.y *= projectionFlipY;\n\t#else\n\tscreenPos = matrix_viewProjection * posW;\n\t#endif\n\t#ifdef PIXELSNAP\n\tscreenPos.xy = (screenPos.xy * 0.5) + 0.5;\n\tscreenPos.xy *= uScreenSize.xy;\n\tscreenPos.xy = floor(screenPos.xy);\n\tscreenPos.xy *= uScreenSize.zw;\n\tscreenPos.xy = (screenPos.xy * 2.0) - 1.0;\n\t#endif\n\t#endif\n\treturn screenPos;\n}\nvec3 getWorldPosition() {\n\treturn dPositionW;\n}\n",transformDeclVS:"\nattribute vec3 vertex_position;\nuniform mat4 matrix_model;\nuniform mat4 matrix_viewProjection;\nvec3 dPositionW;\nmat4 dModelMatrix;\n",transmissionPS:"\n#ifdef MAPFLOAT\nuniform float material_refraction;\n#endif\nvoid getRefraction() {\n\tfloat refraction = 1.0;\n\t#ifdef MAPFLOAT\n\trefraction = material_refraction;\n\t#endif\n\t#ifdef MAPTEXTURE\n\trefraction *= texture2DBias($SAMPLER, $UV, textureBias).$CH;\n\t#endif\n\t#ifdef MAPVERTEX\n\trefraction *= saturate(vVertexColor.$VC);\n\t#endif\n\tdTransmission = refraction;\n}\n",uv0VS:"\n#ifdef NINESLICED\nvec2 getUv0() {\n\tvec2 uv = vertex_position.xz;\n\tvec2 positiveUnitOffset = clamp(vertex_position.xz, vec2(0.0), vec2(1.0));\n\tvec2 negativeUnitOffset = clamp(-vertex_position.xz, vec2(0.0), vec2(1.0));\n\tuv += (-positiveUnitOffset * innerOffset.xy + negativeUnitOffset * innerOffset.zw) * vertex_texCoord0.xy;\n\tuv = uv * -0.5 + 0.5;\n\tuv = uv * atlasRect.zw + atlasRect.xy;\n\tvMask = vertex_texCoord0.xy;\n\treturn uv;\n}\n#else\nvec2 getUv0() {\n\treturn vertex_texCoord0;\n}\n#endif\n",uv1VS:"\nvec2 getUv1() {\n\treturn vertex_texCoord1;\n}\n",viewDirPS:"\nvoid getViewDir() {\n\tdViewDirW = normalize(view_position - vPositionW);\n}\n",viewNormalVS:"\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nvec3 getViewNormal() {\n\treturn mat3(matrix_view) * vNormalW;\n}\n",webgpuPS:sr,webgpuVS:rr},To=new Hs;function Ao(t){return To.get(t)}function Co(t,e){To.get(t,(function(){return e}))}var Eo=function(){function t(){}return t.begin=function(){return"void main(void)\n{\n"},t.end=function(){return"}\n"},t.skinCode=function(t,e){return e||(e=wo),t.supportsBoneTextures?e.skinTexVS:"#define BONE_LIMIT "+t.getBoneLimit()+"\n"+e.skinConstVS},t.fogCode=function(t,e){return e||(e=wo),"linear"===t?e.fogLinearPS?e.fogLinearPS:wo.fogLinearPS:"exp"===t?e.fogExpPS?e.fogExpPS:wo.fogExpPS:"exp2"===t?e.fogExp2PS?e.fogExp2PS:wo.fogExp2PS:e.fogNonePS?e.fogNonePS:wo.fogNonePS},t.gammaCode=function(t,e){return e||(e=wo),1===t||2===t?e.gamma2_2PS?e.gamma2_2PS:wo.gamma2_2PS:3===t?"#define HDR\n"+(e.gamma2_2PS?e.gamma2_2PS:wo.gamma2_2PS):e.gamma1_0PS?e.gamma1_0PS:wo.gamma1_0PS},t.tonemapCode=function(t,e){return e||(e=wo),1===t?e.tonemappingFilmicPS?e.tonemappingFilmicPS:wo.tonemappingFilmicPS:0===t?e.tonemappingLinearPS?e.tonemappingLinearPS:wo.tonemappingLinearPS:2===t?e.tonemappingHejlPS?e.tonemappingHejlPS:wo.tonemappingHejlPS:3===t?e.tonemappingAcesPS?e.tonemappingAcesPS:wo.tonemappingAcesPS:4===t?e.tonemappingAces2PS?e.tonemappingAces2PS:wo.tonemappingAces2PS:e.tonemapingNonePS?e.tonemapingNonePS:wo.tonemappingNonePS},t}();function Mo(t,e,i,n){return void 0===n&&(n=!1),new vs(t,hr.createDefinition(t,{name:e+"_"+i,vertexCode:wo[e],fragmentCode:wo[i],useTransformFeedback:n}))}function Po(t,e,i,n,s,r){void 0===r&&(r=!1);var a=Ao(t),o=a.getCachedShader(n);return o||(o=new vs(t,hr.createDefinition(t,{name:n,vertexCode:e,fragmentCode:i,attributes:s,useTransformFeedback:r})),a.setCachedShader(n,o)),o}var Ro=function(t){function e(e,i){var n;return(n=t.call(this)||this).key=e,n.shaderDefinition=i,n}S(e,t);var i=e.prototype;return i.generateKey=function(t){return this.key},i.createShaderDefinition=function(t,e){return this.shaderDefinition},e}(Eo);function Io(t,e){var i,n=t.definition,s=(null!=(i=n.name)?i:"shader")+"-id-"+t.id,r=new Ro(s,n),a="shader",o=Ao(t.device);o.register(a,r);var h=o.getProgram(a,{},e);return o.unregister(a),h}wo.createShader=Mo,wo.createShaderFromCode=Po;var Lo={type:Ce,base:0,count:4,indexed:!1},Do=new Dt,Oo=new Dt,ko=function(){function t(t){this.uniformBuffer=void 0,this.bindGroup=void 0;var e=t.device;if(this.shader=t,e.supportsUniformBuffers){var i=new xo;this.shader=Io(t,i);var n=this.shader.meshUniformBufferFormat;n&&(this.uniformBuffer=new As(e,n,!1));var s=this.shader.meshBindGroupFormat;this.bindGroup=new xs(e,s,this.uniformBuffer)}}var e=t.prototype;return e.destroy=function(){var t,e;null==(t=this.uniformBuffer)||t.destroy(),this.uniformBuffer=null,null==(e=this.bindGroup)||e.destroy(),this.bindGroup=null},e.render=function(t,e){var i,n=this.shader.device;t&&(Do.set(n.vx,n.vy,n.vw,n.vh),Oo.set(n.sx,n.sy,n.sw,n.sh),e=null!=(i=e)?i:t,n.setViewport(t.x,t.y,t.z,t.w),n.setScissor(e.x,e.y,e.z,e.w));n.setVertexBuffer(n.quadVertexBuffer,0);var s=this.shader;if(n.setShader(s),n.supportsUniformBuffers){var r,a=this.bindGroup;null==(r=a.defaultUniformBuffer)||r.update(),a.update(),n.setBindGroup(0,a)}n.draw(Lo),t&&(n.setViewport(Do.x,Do.y,Do.z,Do.w),n.setScissor(Oo.x,Oo.y,Oo.z,Oo.w))},t}(),Fo=function(t){function e(e,i,n,s){var r;return(r=t.call(this,e)||this).quad=i,r.rect=n,r.scissorRect=s,r}return S(e,t),e.prototype.execute=function(){var t=this.device;t.setCullMode(he),t.setDepthState(Hi.NODEPTH),t.setStencilState(null,null),this.quad.render(this.rect,this.scissorRect)},e}(Er),Bo=new Dt;function Uo(t,e,i,n,s){var r=new ko(i);n||((n=Bo).x=0,n.y=0,n.z=e?e.width:t.width,n.w=e?e.height:t.height);var a=new Fo(t,r,n,s);a.init(e),a.colorOps.clear=!1,a.depthStencilOps.clearDepth=!1,t.isWebGPU&&null===e&&t.samples>1&&(a.colorOps.store=!0),a.render(),r.destroy()}var No=new Hs,zo=function(){function t(t,e,i){void 0===i&&(i={}),this.index=void 0,this.name=void 0,this.shaderDefine=void 0,this.name=t,this.index=e,Object.assign(this,i),this.initShaderDefines()}return t.prototype.initShaderDefines=function(){var t;this.isShadow?t="SHADOW":this.isForward?t="FORWARD":2===this.index?t="DEPTH":3===this.index&&(t="PICK");var e=t?"#define "+t+"_PASS\n":"",i="#define "+this.name.toUpperCase()+"_PASS\n";this.shaderDefines=e+i},t}(),Vo=function(){function t(){var t=this;this.passesNamed=new Map,this.passesIndexed=[],this.nextIndex=0;var e=function(e,i,n){t.allocate(e,n)};e("forward",0,{isForward:!0}),e("forward_hdr",0,{isForward:!0}),e("depth"),e("pick"),e("shadow")}t.get=function(e){return No.get(e,(function(){return new t}))};var e=t.prototype;return e.allocate=function(t,e){var i=this.passesNamed.get(t);return void 0===i&&(i=new zo(t,this.nextIndex,e),this.passesNamed.set(i.name,i),this.passesIndexed[i.index]=i,this.nextIndex++),i},e.getByIndex=function(t){return this.passesIndexed[t]},e.getByName=function(t){return this.passesNamed.get(t)},t}(),Go=function(t){function e(){return t.apply(this,arguments)||this}S(e,t);var i=e.prototype;return i.generateKey=function(t){var e="basic";return t.fog&&(e+="_fog"),t.alphaTest&&(e+="_atst"),t.vertexColors&&(e+="_vcol"),t.diffuseMap&&(e+="_diff"),t.skin&&(e+="_skin"),t.screenSpace&&(e+="_ss"),t.useInstancing&&(e+="_inst"),t.useMorphPosition&&(e+="_morphp"),t.useMorphNormal&&(e+="_morphn"),t.useMorphTextureBased&&(e+="_morpht"),e+="_"+t.pass},i.createShaderDefinition=function(t,e){var i={vertex_position:Ee};e.skin&&(i.vertex_boneWeights=Re,i.vertex_boneIndices=Ie),e.vertexColors&&(i.vertex_color=Le),e.diffuseMap&&(i.vertex_texCoord0=Oe);var n=Vo.get(t).getByIndex(e.pass).shaderDefines,s=n;s+=wo.transformDeclVS,e.skin?(s+=Eo.skinCode(t),s+=wo.transformSkinnedVS):s+=wo.transformVS,e.vertexColors&&(s+="attribute vec4 vertex_color;\n",s+="varying vec4 vColor;\n"),e.diffuseMap&&(s+="attribute vec2 vertex_texCoord0;\n",s+="varying vec2 vUv0;\n"),2===e.pass&&(s+="varying float vDepth;\n",s+="#ifndef VIEWMATRIX\n",s+="#define VIEWMATRIX\n",s+="uniform mat4 matrix_view;\n",s+="#endif\n",s+="#ifndef CAMERAPLANES\n",s+="#define CAMERAPLANES\n",s+="uniform vec4 camera_params;\n\n",s+="#endif\n"),s+=Eo.begin(),s+=" gl_Position = getPosition();\n",2===e.pass&&(s+=" vDepth = -(matrix_view * vec4(getWorldPosition(),1.0)).z * camera_params.x;\n"),e.vertexColors&&(s+=" vColor = vertex_color;\n"),e.diffuseMap&&(s+=" vUv0 = vertex_texCoord0;\n"),s+=Eo.end();var r=n;return e.vertexColors?r+="varying vec4 vColor;\n":r+="uniform vec4 uColor;\n",e.diffuseMap&&(r+="varying vec2 vUv0;\n",r+="uniform sampler2D texture_diffuseMap;\n"),e.fog&&(r+=Eo.fogCode(e.fog)),e.alphaTest&&(r+=wo.alphaTestPS),2===e.pass&&(r+="varying float vDepth;\n",r+=wo.packDepthPS),r+=Eo.begin(),e.vertexColors?r+=" gl_FragColor = vColor;\n":r+=" gl_FragColor = uColor;\n",e.diffuseMap&&(r+=" gl_FragColor *= texture2D(texture_diffuseMap, vUv0);\n"),e.alphaTest&&(r+=" alphaTest(gl_FragColor.a);\n"),3!==e.pass&&(2===e.pass?r+=" gl_FragColor = packFloat(vDepth);\n":e.fog&&(r+=" glFragColor.rgb = addFog(gl_FragColor.rgb);\n")),r+=Eo.end(),hr.createDefinition(t,{name:"BasicShader",attributes:i,vertexCode:s,fragmentCode:r})},e}(Eo),Ho=new Go,Wo=new Hs;function Xo(t){return Wo.get(t)}var qo=[];qo[0]={src:1,dst:1,op:2},qo[3]={src:1,dst:0,op:0},qo[2]={src:6,dst:8,op:0},qo[4]={src:1,dst:8,op:0},qo[1]={src:1,dst:1,op:0},qo[6]={src:6,dst:1,op:0},qo[7]={src:4,dst:2,op:0},qo[8]={src:5,dst:1,op:0},qo[5]={src:4,dst:0,op:0},qo[9]={src:1,dst:1,op:3},qo[10]={src:1,dst:1,op:4};var jo=0,Yo=function(){function t(){this._shader=null,this.meshInstances=[],this.name="Untitled",this.userId="",this.id=jo++,this.variants=new Map,this.parameters={},this.alphaTest=0,this.alphaToCoverage=!1,this._blendState=new Gi,this._depthState=new Hi,this.cull=1,this.stencilFront=null,this.stencilBack=null,this.depthBias=0,this.slopeDepthBias=0,this._shaderVersion=0,this._scene=null,this.dirty=!0}var e=t.prototype;return e._updateTransparency=function(){for(var t=this.transparent,e=this.meshInstances,i=0;i0,vertexColors:this.vertexColors,diffuseMap:!!this.colorMap,pass:s},c=new xo(a,o,h),u=Ao(t);return u.register("basic",Ho),u.getProgram("basic",l,c,this.userId)},e}(Yo),Zo=function(){function t(t,e,i){this._aabb=new jt,this.origMeshInstances=void 0,this.meshInstance=null,this.dynamic=void 0,this.batchGroupId=void 0,this.origMeshInstances=t,this.dynamic=e,this.batchGroupId=i}var e=t.prototype;return e.destroy=function(t,e){this.meshInstance&&(this.removeFromLayers(t,e),this.meshInstance.destroy(),this.meshInstance=null)},e.addToLayers=function(t,e){for(var i=0;i=0;i--)this.matrices[i].mulAffine2($o,this.bones[i].getWorldTransform()),this.matrices[i].mulAffine2(this.matrices[i],this.skin.inverseBindPose[i])}},e.updateMatrices=function(t,e){this._updateBeforeCull&&this._updateMatrices(t,e)},e.updateMatrixPalette=function(t,e){this._updateMatrices(t,e);for(var i=this.matrixPalette,n=this.bones.length,s=0;s=0?t.insertChild(this,e):t.addChild(this))},i.setLocalEulerAngles=function(t,e,i){this.localRotation.setFromEulerAngles(t,e,i),this._dirtyLocal||this._dirtifyLocal()},i.setLocalPosition=function(t,e,i){t instanceof Et?this.localPosition.copy(t):this.localPosition.set(t,e,i),this._dirtyLocal||this._dirtifyLocal()},i.setLocalRotation=function(t,e,i,n){t instanceof Vt?this.localRotation.copy(t):this.localRotation.set(t,e,i,n),this._dirtyLocal||this._dirtifyLocal()},i.setLocalScale=function(t,e,i){t instanceof Et?this.localScale.copy(t):this.localScale.set(t,e,i),this._dirtyLocal||this._dirtifyLocal()},i._dirtifyLocal=function(){this._dirtyLocal||(this._dirtyLocal=!0,this._dirtyWorld||this._dirtifyWorld())},i._unfreezeParentToRoot=function(){for(var t=this._parent;t;)t._frozen=!1,t=t._parent},i._dirtifyWorld=function(){this._dirtyWorld||this._unfreezeParentToRoot(),this._dirtifyWorldInternal()},i._dirtifyWorldInternal=function(){if(!this._dirtyWorld){this._frozen=!1,this._dirtyWorld=!0;for(var t=0;t>16},set:function(t){var e=65535&this._shaderDefs;this._updateShaderDefs(e|t<<16)}},{key:"instancingCount",get:function(){return this.instancingData?this.instancingData.count:0},set:function(t){this.instancingData&&(this.instancingData.count=t)}}]),t}();function Mh(t,e){if(t&&!e)return!1;if(!t&&e)return!1;if((t=t.data)===(e=e.data))return!0;if(t instanceof Float32Array&&e instanceof Float32Array){if(t.length!==e.length)return!1;for(var i=0;i=0&&(n._obj[t].splice(s,1),this.markGroupDirty(e))}},e._extractRender=function(t,e,i,n){return t.render&&(e=n[t.render.batchGroupId]=e.concat(t.render.meshInstances),t.render.removeFromLayers()),e},e._extractModel=function(t,e,i,n){return t.model&&t.model.model&&(e=n[t.model.batchGroupId]=e.concat(t.model.meshInstances),t.model.removeModelFromLayers()),e},e._extractElement=function(t,e,i){if(t.element){var n=!1;t.element._text&&t.element._text._model.meshInstances.length>0?(e.push(t.element._text._model.meshInstances[0]),t.element.removeModelFromLayers(t.element._text._model),n=!0):t.element._image&&(e.push(t.element._image._renderable.meshInstance),t.element.removeModelFromLayers(t.element._image._renderable.model),t.element._image._renderable.unmaskMeshInstance&&(e.push(t.element._image._renderable.unmaskMeshInstance),t.element._image._renderable.unmaskMeshInstance.stencilFront&&t.element._image._renderable.unmaskMeshInstance.stencilBack||(t.element._dirtifyMask(),t.element._onPrerender())),n=!0),n&&(i._ui=!0)}},e._collectAndRemoveMeshInstances=function(t,e){for(var i=0;i0;){u[d]=[p[0]],f=[];var _=p[0].material,g=p[0].layer,v=p[0]._shaderDefs,y=p[0].parameters,x=p[0].stencilFront,S=p[0].mesh.vertexBuffer.getNumVertices(),b=p[0].drawOrder;h.copy(p[0].aabb);var w=Dh(p[0]),T=p[0].mesh.vertexBuffer.format.batchingHash,A=p[0].mesh.primitive[0].indexed;c=null;for(var C=1;C=a){f=f.concat(p.slice(C));break}_!==E.material||g!==E.layer||T!==E.mesh.vertexBuffer.format.batchingHash||A!==E.mesh.primitive[0].indexed||v!==E._shaderDefs||S+E.mesh.vertexBuffer.getNumVertices()>o?m(E):(l.copy(h),l.add(E.aabb),l.halfExtents.x>r||l.halfExtents.y>r||l.halfExtents.z>r?m(E):(!x||(s=E.stencilFront)&&x.func===s.func&&x.zpass===s.zpass)&&w===Dh(E)&&Ph(y,E.parameters)?n&&c&&c.intersects(E.aabb)&&E.drawOrder!==b?m(E):(h.add(E.aabb),S+=E.mesh.vertexBuffer.getNumVertices(),u[d].push(E)):m(E))}d++,p=f}return u},e.collectBatchedMeshData=function(t,e){for(var i=null,n=0,s=0,r=null,a=0;a=3)if(s===Ee)for(var A=0;A0&&r.setIndices(S),r.update(4,!1),e&&((p=p.clone()).chunks.transformVS=this.transformVS,p.chunks.skinTexVS=this.skinTexVS,p.chunks.skinConstVS=this.skinConstVS,p.update());var I=new Eh(r,p,this.rootNode);I.castShadow=h.origMeshInstances[0].castShadow,I.parameters=h.origMeshInstances[0].parameters,I.layer=h.origMeshInstances[0].layer,I._shaderDefs=h.origMeshInstances[0]._shaderDefs,I.cull=h.origMeshInstances[0].cull;var L=this._batchGroups[i];if(L&&L._ui&&(I.cull=!1),e){for(var D=[],O=0;O0&&this.generate(this._dirtyGroups);for(var t=0;t1&&(h=pe,o=!1));var l=null!=(t=null==(e=r.renderTarget)?void 0:e.depthBuffer)?t:null==(i=r.renderTarget)?void 0:i.colorBuffer;this.shouldReallocate(this.depthRenderTarget,l)&&(this.releaseRenderTarget(this.depthRenderTarget),this.depthRenderTarget=this.allocateRenderTarget(this.depthRenderTarget,r.renderTarget,a,h,o));var c=o?this.depthRenderTarget.depthBuffer:this.depthRenderTarget.colorBuffer;Uh.forEach((function(t){return a.scope.resolve(t).setValue(c)}))},i.execute=function(){var t=this.device;if(t.isWebGL2&&t.renderTarget.samples>1){var e=t.renderTarget.impl._glFrameBuffer,i=this.depthRenderTarget;t.renderTarget=i,t.updateBegin(),this.depthRenderTarget.impl.internalResolve(t,e,i.impl._glFrameBuffer,this.depthRenderTarget,t.gl.DEPTH_BUFFER_BIT)}else t.copyRenderTarget(t.renderTarget,this.depthRenderTarget,!1,!0)},e}(Er),zh=new gt(254/255,254/255,254/255,254/255),Vh=[],Gh=[[],[],[]],Hh=["uSceneDepthMap","uDepthMap"],Wh=function(t){function e(e,i,n){var s;return(s=t.call(this,e)||this).renderer=i,s.camera=n,s}S(e,t);var i=e.prototype;return i.destroy=function(){t.prototype.destroy.call(this),this.releaseRenderTarget(this.renderTarget)},i.update=function(t){this.scene=t},i.shouldReallocate=function(t,e){var i=e.width,n=e.height;return!t||i!==t.width||n!==t.height},i.allocateRenderTarget=function(t,e,i){var n,s,r=new Us(i,{name:Hh[0],format:7,width:null!=(n=null==e?void 0:e.width)?n:this.device.width,height:null!=(s=null==e?void 0:e.height)?s:this.device.height,mipmaps:!1,minFilter:0,magFilter:0,addressU:1,addressV:1});return t?(t.destroyFrameBuffers(),t._colorBuffer=r,t._colorBuffers=[r]):t=new ln({name:Hh[0]+"RT}",colorBuffer:r,depth:!0,stencil:!1}),t},i.releaseRenderTarget=function(t){t&&(t.destroyTextureBuffers(),t.destroy())},i.before=function(){var t,e=this.camera,i=this.device,n=null!=(t=e.renderTarget)?t:i.backBuffer;if(this.shouldReallocate(this.renderTarget,n)){var s;null==(s=this.renderTarget)||s.destroyTextureBuffers();var r=this.allocateRenderTarget(this.renderTarget,e.renderTarget,i);this.renderTarget?this.renderTarget=r:(this.init(r),this.setClearColor(zh),this.setClearDepth(1))}var a=this.renderTarget.colorBuffer;Hh.forEach((function(t){return i.scope.resolve(t).setValue(a)}))},i.execute=function(){for(var t=this.device,e=this.renderer,i=this.camera,n=this.scene,s=this.renderTarget,r=n.layers.layerList,a=n.layers.subLayerEnabled,o=n.layers.subLayerList,h=0;h0,t.blendType=e.blendType,t.screenSpace=n&&0!=(n&qa),t.skin=n&&0!=(2&n),t.useInstancing=n&&0!=(n&Wa),t.useMorphPosition=n&&0!=(n&Ya),t.useMorphNormal=n&&0!=(n&Ka),t.useMorphTextureBased=n&&0!=(n&Za),t.hasTangents=n&&0!=(n&ja),t.nineSlicedMode=e.nineSlicedMode||0,e.useLighting&&i.clusteredLightingEnabled?(t.clusteredLightingEnabled=!0,t.clusteredLightingCookiesEnabled=i.lighting.cookiesEnabled,t.clusteredLightingShadowsEnabled=i.lighting.shadowsEnabled,t.clusteredLightingShadowType=i.lighting.shadowType,t.clusteredLightingAreaLightsEnabled=i.lighting.areaLightsEnabled):(t.clusteredLightingEnabled=!1,t.clusteredLightingCookiesEnabled=!1,t.clusteredLightingShadowsEnabled=!1,t.clusteredLightingAreaLightsEnabled=!1)},t.updateMaterialOptions=function(t,e){t.useAmbientTint=!1,t.separateAmbient=!1,t.customFragmentShader=null,t.pixelSnap=e.pixelSnap,t.shadingModel=e.shadingModel,t.ambientSH=e.ambientSH,t.fastTbn=e.fastTbn,t.twoSidedLighting=e.twoSidedLighting,t.occludeDirect=e.occludeDirect,t.occludeSpecular=e.occludeSpecular,t.occludeSpecularFloat=1!==e.occludeSpecularIntensity,t.useMsdf=!1,t.msdfTextAttribute=!1,t.alphaToCoverage=e.alphaToCoverage,t.opacityFadesSpecular=e.opacityFadesSpecular,t.cubeMapProjection=0,t.conserveEnergy=e.conserveEnergy&&1===e.shadingModel,t.useSpecular=e.hasSpecular,t.useSpecularityFactor=e.hasSpecularityFactor,t.enableGGXSpecular=e.ggxSpecular,t.fresnelModel=e.fresnelModel,t.useRefraction=e.hasRefraction,t.useClearCoat=e.hasClearCoat,t.useSheen=e.hasSheen,t.useIridescence=e.hasIrridescence,t.useMetalness=e.hasMetalness,t.useDynamicRefraction=e.dynamicRefraction,t.vertexColors=!1,t.lightMapEnabled=e.hasLighting,t.dirLightMapEnabled=e.dirLightMap,t.useHeights=e.hasHeights,t.useNormals=e.hasNormals,t.useClearCoatNormals=e.hasClearCoatNormals,t.useAo=e.hasAo,t.diffuseMapEnabled=e.hasDiffuseMap},t.updateEnvOptions=function(t,e,i){t.fog=e.useFog?i.fog:"none",t.gamma=e.useGammaTonemap?i.gammaCorrection:0,t.toneMap=e.useGammaTonemap?i.toneMapping:-1,t.fixSeams=!1,e.useSkybox&&i.envAtlas&&i.skybox?(t.reflectionSource="envAtlasHQ",t.reflectionEncoding=i.envAtlas.encoding,t.reflectionCubemapEncoding=i.skybox.encoding):e.useSkybox&&i.envAtlas?(t.reflectionSource="envAtlas",t.reflectionEncoding=i.envAtlas.encoding):e.useSkybox&&i.skybox?(t.reflectionSource="cubeMap",t.reflectionEncoding=i.skybox.encoding):(t.reflectionSource=null,t.reflectionEncoding=null),e.ambientSH?(t.ambientSource="ambientSH",t.ambientEncoding=null):t.reflectionSource&&i.envAtlas?(t.ambientSource="envAtlas",t.ambientEncoding=i.envAtlas.encoding):(t.ambientSource="constant",t.ambientEncoding=null);var n=!!t.reflectionSource;t.skyboxIntensity=n&&(1!==i.skyboxIntensity||i.physicalUnits),t.useCubeMapRotation=n&&i._skyboxRotationShaderInclude},t.updateLightingOptions=function(e,i,n,s){if(e.lightMapWithoutAmbient=!1,i.useLighting){var r=[],a=n?n>>16:1;e.lightMaskDynamic=!!(1&a),e.lightMapWithoutAmbient=!1,s&&(t.collectLights(0,s[0],r,a),t.collectLights(1,s[1],r,a),t.collectLights(2,s[2],r,a)),e.lights=r}else e.lights=[];0!==e.lights.length&&0==(1&n)||(e.noShadow=!0)},t.collectLights=function(t,e,i,n){for(var s=0;s8?t.FORMAT_FLOAT:t.FORMAT_8BIT,t.useTexelFetch=e.supportsTextureFetch,t.initShaderDefines()},t.createTexture=function(t,e,i,n,s){return new Us(t,{name:s,width:e,height:i,mipmaps:!1,format:n,addressU:1,addressV:1,type:ri,magFilter:0,minFilter:0,anisotropy:1})};var e=t.prototype;return e.destroy=function(){this.lightsTexture8&&(this.lightsTexture8.destroy(),this.lightsTexture8=null),this.lightsTextureFloat&&(this.lightsTextureFloat.destroy(),this.lightsTextureFloat=null)},e.setCompressionRanges=function(t,e){this.invMaxColorValue=1/e,this.invMaxAttenuation=1/t},e.setBounds=function(t,e){this.boundsMin.copy(t),this.boundsDelta.copy(e)},e.uploadTextures=function(){this.lightsTextureFloat&&(this.lightsTextureFloat.lock().set(this.lightsFloat),this.lightsTextureFloat.unlock()),this.lightsTexture8.lock().set(this.lights8),this.lightsTexture8.unlock()},e.updateUniforms=function(){this._lightsTexture8Id.setValue(this.lightsTexture8),t.lightTextureFormat===t.FORMAT_FLOAT&&this._lightsTextureFloatId.setValue(this.lightsTextureFloat),this._lightsTextureInvSizeId.setValue(this._lightsTextureInvSizeData)},e.getSpotDirection=function(t,e){e._node.getWorldTransform().getY(t).mulScalar(-1),t.normalize()},e.getLightAreaSizes=function(t){var e=t._node.getWorldTransform();return e.transformVector(ll,ol),hl[0]=ol.x,hl[1]=ol.y,hl[2]=ol.z,e.transformVector(cl,ol),hl[3]=ol.x,hl[4]=ol.y,hl[5]=ol.z,hl},e.addLightDataFlags=function(t,e,i,n,s,r){t[e+0]=n?255:0,t[e+1]=64*i._shape,t[e+2]=255*i._falloffMode,t[e+3]=s?255*r:0},e.addLightDataColor=function(t,e,i,n,s){var r=this.invMaxColorValue,a=n?i._linearFinalColor:i._finalColor;Ct.float2Bytes(a[0]*r,t,e+0,2),Ct.float2Bytes(a[1]*r,t,e+2,2),Ct.float2Bytes(a[2]*r,t,e+4,2),t[e+6]=s?255:0;var o=!!(1&i.mask),h=!!(2&i.mask);t[e+7]=o&&h?127:h?255:0},e.addLightDataSpotAngles=function(t,e,i){Ct.float2Bytes(.499999*i._innerConeAngleCos+.5,t,e+0,2),Ct.float2Bytes(.499999*i._outerConeAngleCos+.5,t,e+2,2)},e.addLightDataShadowBias=function(t,e,i){var n=i.getRenderData(null,0),s=i._getUniformBiasValues(n);Ct.float2BytesRange(s.bias,t,e,-1,20,2),Ct.float2Bytes(s.normalBias,t,e+2,2)},e.addLightDataPositionRange=function(t,e,i,n){var s=ol.sub2(n,this.boundsMin).div(this.boundsDelta);Ct.float2Bytes(s.x,t,e+0,4),Ct.float2Bytes(s.y,t,e+4,4),Ct.float2Bytes(s.z,t,e+8,4),Ct.float2Bytes(i.attenuationEnd*this.invMaxAttenuation,t,e+12,4)},e.addLightDataSpotDirection=function(t,e,i){this.getSpotDirection(ol,i),Ct.float2Bytes(.499999*ol.x+.5,t,e+0,4),Ct.float2Bytes(.499999*ol.y+.5,t,e+4,4),Ct.float2Bytes(.499999*ol.z+.5,t,e+8,4)},e.addLightDataLightProjMatrix=function(t,e,i){for(var n=i.data,s=0;s<12;s++)Ct.float2BytesRange(n[s],t,e+4*s,-2,2,4);for(var r=12;r<16;r++)Ct.float2MantissaExponent(n[r],t,e+4*r,4)},e.addLightDataCookies=function(t,e,i){var n="rgb"===i._cookieChannel;if(t[e+0]=Math.floor(255*i.cookieIntensity),t[e+1]=n?255:0,!n){var s=i._cookieChannel;t[e+4]="rrr"===s?255:0,t[e+5]="ggg"===s?255:0,t[e+6]="bbb"===s?255:0,t[e+7]="aaa"===s?255:0}},e.addLightAtlasViewport=function(t,e,i){Ct.float2Bytes(i.x,t,e+0,2),Ct.float2Bytes(i.y,t,e+2,2),Ct.float2Bytes(i.z/3,t,e+4,2)},e.addLightAreaSizes=function(t,e,i){for(var n=this.getLightAreaSizes(i),s=0;s<6;s++)Ct.float2MantissaExponent(n[s],t,e+4*s,4)},e.addLightData=function(e,i,n){var s=2===e._type,r=e.atlasViewportAllocated,a=this.cookiesEnabled&&!!e._cookie&&r,o=this.areaLightsEnabled&&0!==e.shape,h=this.shadowsEnabled&&e.castShadows&&r,l=e._node.getPosition(),c=null,u=null;s?h?c=e.getRenderData(null,0).shadowMatrix:a&&(c=al.evalSpotCookieMatrix(e)):(h||a)&&(u=e.atlasViewport);var d=this.lights8,f=i*this.lightsTexture8.width*4;if(this.addLightDataFlags(d,f+4*ul.FLAGS,e,s,h,e.shadowIntensity),this.addLightDataColor(d,f+4*ul.COLOR_A,e,n,a),s&&this.addLightDataSpotAngles(d,f+4*ul.SPOT_ANGLES,e),e.castShadows&&this.addLightDataShadowBias(d,f+4*ul.SHADOW_BIAS,e),a&&this.addLightDataCookies(d,f+4*ul.COOKIE_A,e),t.lightTextureFormat===t.FORMAT_FLOAT){var p=this.lightsFloat,m=i*this.lightsTextureFloat.width*4;if(p[m+4*dl.POSITION_RANGE+0]=l.x,p[m+4*dl.POSITION_RANGE+1]=l.y,p[m+4*dl.POSITION_RANGE+2]=l.z,p[m+4*dl.POSITION_RANGE+3]=e.attenuationEnd,s&&(this.getSpotDirection(ol,e),p[m+4*dl.SPOT_DIRECTION+0]=ol.x,p[m+4*dl.SPOT_DIRECTION+1]=ol.y,p[m+4*dl.SPOT_DIRECTION+2]=ol.z),c)for(var _=c.data,g=0;g<16;g++)p[m+4*dl.PROJ_MAT_0+g]=_[g];if(u&&(p[m+4*dl.ATLAS_VIEWPORT+0]=u.x,p[m+4*dl.ATLAS_VIEWPORT+1]=u.y,p[m+4*dl.ATLAS_VIEWPORT+2]=u.z/3),o){var v=this.getLightAreaSizes(e);p[m+4*dl.AREA_DATA_WIDTH+0]=v[0],p[m+4*dl.AREA_DATA_WIDTH+1]=v[1],p[m+4*dl.AREA_DATA_WIDTH+2]=v[2],p[m+4*dl.AREA_DATA_HEIGHT+0]=v[3],p[m+4*dl.AREA_DATA_HEIGHT+1]=v[4],p[m+4*dl.AREA_DATA_HEIGHT+2]=v[5]}}else this.addLightDataPositionRange(d,f+4*ul.POSITION_X,e,l),s&&this.addLightDataSpotDirection(d,f+4*ul.SPOT_DIRECTION_X,e),c&&this.addLightDataLightProjMatrix(d,f+4*ul.PROJ_MAT_00,c),u&&this.addLightAtlasViewport(d,f+4*ul.ATLAS_VIEWPORT_A,u),o&&this.addLightAreaSizes(d,f+4*ul.AREA_DATA_WIDTH_X,e)},t}();Oh=fl,fl.FORMAT_FLOAT=0,fl.FORMAT_8BIT=1,fl.lightTextureFormat=Oh.FORMAT_8BIT,fl.useTexelFetch=!1,fl.shaderDefines="";var pl={vertex_normal:Me,vertex_tangent:Pe,vertex_texCoord0:Oe,vertex_texCoord1:ke,vertex_color:Le,vertex_boneWeights:Re,vertex_boneIndices:Ie},ml={vVertexColor:"vec4",vPositionW:"vec3",vNormalV:"vec3",vNormalW:"vec3",vTangentW:"vec3",vBinormalW:"vec3",vObjectSpaceUpW:"vec3",vUv0:"vec2",vUv1:"vec2"},_l=function(){function t(t,e){if(this.device=t,this.options=e,this.attributes={vertex_position:Ee},e.userAttributes)for(var i=0,n=Object.entries(e.userAttributes);i=0&&(this.attributes[c]=pl[c]);this.chunks[h]=l}}else this.chunks=wo;this.shaderPassInfo=Vo.get(this.device).getByIndex(e.pass),this.shadowPass=this.shaderPassInfo.isShadow,this.lighting=e.lights.length>0||e.dirLightMapEnabled||e.clusteredLightingEnabled,this.reflections=!!e.reflectionSource,this.needsNormal=this.lighting||this.reflections||e.useSpecular||e.ambientSH||e.useHeights||e.enableGGXSpecular||e.clusteredLightingEnabled&&!this.shadowPass||e.useClearCoatNormals,this.needsNormal=this.needsNormal&&!this.shadowPass,this.needsSceneColor=e.useDynamicRefraction,this.needsScreenSize=e.useDynamicRefraction,this.needsTransforms=e.useDynamicRefraction,this.varyings="",this.varyingDefines="",this.vshader=null,this.frontendDecl=null,this.frontendCode=null,this.frontendFunc=null,this.lightingUv=null,this.defines=[],this.fshader=null}var e=t.prototype;return e._vsAddBaseCode=function(t,e,i){return t+=e.baseVS,1!==i.nineSlicedMode&&2!==i.nineSlicedMode||(t+=e.baseNineSlicedVS),t},e._vsAddTransformCode=function(t,e,i,n){return t+=this.chunks.transformVS},e._setMapTransform=function(t,e,i,n){var s=i+100*n;if(!t[3][s]){var r="texture_"+e+"MapTransform";t[0]+="uniform vec3 "+r+"0;\n",t[0]+="uniform vec3 "+r+"1;\n",t[1]+="varying vec2 vUV"+n+"_"+i+";\n",t[2]+=" vUV"+n+"_"+i+" = vec2(dot(vec3(uv"+n+", 1), "+r+"0), dot(vec3(uv"+n+", 1), "+r+"1));\n",t[3][s]=!0}return t},e._fsGetBaseCode=function(){var t=this.options,e=this.chunks,i=this.chunks.basePS;return 1===t.nineSlicedMode?i+=e.baseNineSlicedPS:2===t.nineSlicedMode&&(i+=e.baseNineSlicedTiledPS),i},e._fsGetStartCode=function(t,e,i,n){var s=i.startPS;return 1===n.nineSlicedMode?s+=i.startNineSlicedPS:2===n.nineSlicedMode&&(s+=i.startNineSlicedTiledPS),s},e._getLightSourceShapeString=function(t){switch(t){case 1:return"Rect";case 2:return"Disk";case 3:return"Sphere";default:return""}},e.generateVertexShader=function(t,e,i){var n=this,s=this.device,r=this.options,a=this.chunks,o="",h="";o=this._vsAddBaseCode(o,a,r),h+=" vPositionW = getWorldPosition();\n",2===this.options.pass&&(o+="varying float vDepth;\n",o+="#ifndef VIEWMATRIX\n",o+="#define VIEWMATRIX\n",o+="uniform mat4 matrix_view;\n",o+="#endif\n",o+="#ifndef CAMERAPLANES\n",o+="#define CAMERAPLANES\n",o+="uniform vec4 camera_params;\n\n",o+="#endif\n",h+=" vDepth = -(matrix_view * vec4(vPositionW,1.0)).z * camera_params.x;\n"),this.options.useInstancing&&(this.attributes.instance_line1=ei,this.attributes.instance_line2=ii,this.attributes.instance_line3=ni,this.attributes.instance_line4=si,o+=a.instancingVS),this.needsNormal&&(this.attributes.vertex_normal=Me,h+=" vNormalW = getNormal();\n","sphereMap"===r.reflectionSource&&s.fragmentUniformsCount<=16&&(o+=a.viewNormalVS,h+=" vNormalV = getViewNormal();\n"),r.hasTangents&&(r.useHeights||r.useNormals||r.enableGGXSpecular)?(this.attributes.vertex_tangent=Pe,o+=a.tangentBinormalVS,h+=" vTangentW = getTangent();\n",h+=" vBinormalW = getBinormal();\n"):!r.enableGGXSpecular&&s.extStandardDerivatives||(h+=" vObjectSpaceUpW = normalize(dNormalMatrix * vec3(0, 1, 0));\n"));for(var l=0;l<2;l++)t[l]&&(this.attributes["vertex_texCoord"+l]="TEXCOORD"+l,o+=a["uv"+l+"VS"],h+=" vec2 uv"+l+" = getUv"+l+"();\n"),e[l]&&(h+=" vUv"+l+" = uv"+l+";\n");var c=[o,this.varyings,h,[]];if(i.forEach((function(t){n._setMapTransform(c,t.name,t.id,t.uv)})),o=c[0],this.varyings=c[1],h=c[2],r.vertexColors&&(this.attributes.vertex_color=Le,h+=" vVertexColor = vertex_color;\n"),r.useMsdf&&r.msdfTextAttribute&&(this.attributes.vertex_outlineParameters=Qe,this.attributes.vertex_shadowParameters=$e,h+=" unpackMsdfParams();\n",o+=a.msdfVS),r.useMorphPosition||r.useMorphNormal)if(r.useMorphTextureBased){o+="#define MORPHING_TEXTURE_BASED\n",r.useMorphPosition&&(o+="#define MORPHING_TEXTURE_BASED_POSITION\n"),r.useMorphNormal&&(o+="#define MORPHING_TEXTURE_BASED_NORMAL\n"),this.attributes.morph_vertex_id=si;var u=s.isWebGPU?"uint":"float";o+="attribute "+u+" morph_vertex_id;\n"}else o+="#define MORPHING\n",r.useMorphPosition?(this.attributes.morph_pos0=Qe,this.attributes.morph_pos1=$e,this.attributes.morph_pos2=Je,this.attributes.morph_pos3=ti,o+="#define MORPHING_POS03\n",o+="attribute vec3 morph_pos0;\n",o+="attribute vec3 morph_pos1;\n",o+="attribute vec3 morph_pos2;\n",o+="attribute vec3 morph_pos3;\n"):r.useMorphNormal&&(this.attributes.morph_nrm0=Qe,this.attributes.morph_nrm1=$e,this.attributes.morph_nrm2=Je,this.attributes.morph_nrm3=ti,o+="#define MORPHING_NRM03\n",o+="attribute vec3 morph_nrm0;\n",o+="attribute vec3 morph_nrm1;\n",o+="attribute vec3 morph_nrm2;\n",o+="attribute vec3 morph_nrm3;\n"),r.useMorphNormal?(this.attributes.morph_nrm4=ei,this.attributes.morph_nrm5=ii,this.attributes.morph_nrm6=ni,this.attributes.morph_nrm7=si,o+="#define MORPHING_NRM47\n",o+="attribute vec3 morph_nrm4;\n",o+="attribute vec3 morph_nrm5;\n",o+="attribute vec3 morph_nrm6;\n",o+="attribute vec3 morph_nrm7;\n"):(this.attributes.morph_pos4=ei,this.attributes.morph_pos5=ii,this.attributes.morph_pos6=ni,this.attributes.morph_pos7=si,o+="#define MORPHING_POS47\n",o+="attribute vec3 morph_pos4;\n",o+="attribute vec3 morph_pos5;\n",o+="attribute vec3 morph_pos6;\n",o+="attribute vec3 morph_pos7;\n");r.skin?(this.attributes.vertex_boneWeights=Re,this.attributes.vertex_boneIndices=Ie,o+=Eo.skinCode(s,a),o+="#define SKIN\n"):r.useInstancing&&(o+="#define INSTANCING\n"),r.screenSpace&&(o+="#define SCREENSPACE\n"),r.pixelSnap&&(o+="#define PIXELSNAP\n"),o=this._vsAddTransformCode(o,s,a,r),this.needsNormal&&(o+=a.normalVS),o+="\n",o+=a.startVS,o+=h,o+=a.endVS,o+="}",Object.keys(ml).forEach((function(t){o.indexOf(t)>=0&&(n.varyings+="varying "+ml[t]+" "+t+";\n",n.varyingDefines+="#define VARYING_"+t.toUpperCase()+"\n")}));var d=this.shaderPassInfo.shaderDefines;this.vshader=d+this.varyings+o},e._fsGetBeginCode=function(){for(var t=this.shaderPassInfo.shaderDefines,e=0;e0&&this.defines.push("LIT_SPECULAR_FRESNEL"),e.conserveEnergy&&this.defines.push("LIT_CONSERVE_ENERGY"),e.useSheen&&this.defines.push("LIT_SHEEN"),e.useIridescence&&this.defines.push("LIT_IRIDESCENCE"));var o=[],h=0,l=!1,c=!1,u=!1,d=e.lights.some((function(t){return t._shape&&0!==t._shape}));e.clusteredLightingEnabled&&e.clusteredLightingAreaLightsEnabled&&(d=!0);var f="highp";7===t.areaLightLutFormat&&(n.append("#define AREA_R8_G8_B8_A8_LUTS"),f="lowp"),(d||e.clusteredLightingEnabled)&&(n.append("#define AREA_LIGHTS"),n.append("uniform "+f+" sampler2D areaLightsLutTex1;"),n.append("uniform "+f+" sampler2D areaLightsLutTex2;"));for(var p=0;p0?i.cubeMapProjectBoxPS:i.cubeMapProjectNonePS),s.append(e.skyboxIntensity?i.envMultiplyPS:i.envConstPS)),(this.lighting&&e.useSpecular||this.reflections)&&(e.useMetalness&&s.append(i.metalnessModulatePS),2===e.fresnelModel&&s.append(i.fresnelSchlickPS),e.useIridescence&&s.append(i.iridescenceDiffractionPS)),e.useAo)switch(s.append(i.aoDiffuseOccPS),e.occludeSpecular){case 1:s.append(e.occludeSpecularFloat?i.aoSpecOccSimplePS:i.aoSpecOccConstSimplePS);break;case 2:s.append(e.occludeSpecularFloat?i.aoSpecOccPS:i.aoSpecOccConstPS)}if("envAtlasHQ"===e.reflectionSource)s.append(e.fixSeams?i.fixCubemapSeamsStretchPS:i.fixCubemapSeamsNonePS),s.append(i.envAtlasPS),s.append(i.reflectionEnvHQPS.replace(/\$DECODE_CUBEMAP/g,il.decodeFunc(e.reflectionCubemapEncoding)).replace(/\$DECODE/g,il.decodeFunc(e.reflectionEncoding)));else if("envAtlas"===e.reflectionSource)s.append(i.envAtlasPS),s.append(i.reflectionEnvPS.replace(/\$DECODE/g,il.decodeFunc(e.reflectionEncoding)));else if("cubeMap"===e.reflectionSource)s.append(e.fixSeams?i.fixCubemapSeamsStretchPS:i.fixCubemapSeamsNonePS),s.append(i.reflectionCubePS.replace(/\$DECODE/g,il.decodeFunc(e.reflectionEncoding)));else if("sphereMap"===e.reflectionSource){var y=t.fragmentUniformsCount>16?i.reflectionSpherePS:i.reflectionSphereLowPS;s.append(y.replace(/\$DECODE/g,il.decodeFunc(e.reflectionEncoding)))}this.reflections&&(e.useClearCoat&&s.append(i.reflectionCCPS),e.useSheen&&s.append(i.reflectionSheenPS)),e.useRefraction&&(e.useDynamicRefraction?s.append(i.refractionDynamicPS):this.reflections&&s.append(i.refractionCubePS)),e.useSheen&&s.append(i.lightSheenPS),e.clusteredLightingEnabled&&(s.append(i.clusteredLightUtilsPS),e.clusteredLightingCookiesEnabled&&s.append(i.clusteredLightCookiesPS),e.clusteredLightingShadowsEnabled&&!e.noShadow&&(o[0]=!0,o[4]=!0,o[6]=!0)),(h>0||e.clusteredLightingEnabled)&&(l&&s.append(i.shadowCascadesPS),(o[5]||o[0])&&s.append(i.shadowStandardPS),o[4]&&!t.isWebGL1&&s.append(i.shadowStandardGL2PS),c&&(s.append(i.shadowVSM_commonPS),o[1]&&s.append(i.shadowVSM8PS),o[2]&&s.append(t.extTextureHalfFloatLinear?i.shadowEVSMPS.replace(/\$/g,"16"):i.shadowEVSMnPS.replace(/\$/g,"16")),o[3]&&s.append(t.extTextureFloatLinear?i.shadowEVSMPS.replace(/\$/g,"32"):i.shadowEVSMnPS.replace(/\$/g,"32"))),u&&(s.append(i.linearizeDepthPS),s.append(i.shadowPCSSPS)),t.isWebGL2||t.isWebGPU||t.extStandardDerivatives||s.append(i.biasConstPS)),e.enableGGXSpecular&&s.append("uniform float material_anisotropy;"),this.lighting&&(s.append(i.lightDiffuseLambertPS),(d||e.clusteredLightingAreaLightsEnabled)&&s.append(i.ltcPS));var x=!1;e.useSpecular&&(this.lighting&&s.append(0===e.shadingModel?i.lightSpecularPhongPS:e.enableGGXSpecular?i.lightSpecularAnisoGGXPS:i.lightSpecularBlinnPS),e.fresnelModel||this.reflections||e.diffuseMapEnabled||(n.append("uniform vec3 material_ambient;"),n.append("#define LIT_OLD_AMBIENT"),x=!0)),s.append(i.combinePS),e.lightMapEnabled&&s.append(e.useSpecular&&e.dirLightMapEnabled?i.lightmapDirAddPS:i.lightmapAddPS);var S=!e.lightMapEnabled||e.lightMapWithoutAmbient;S&&("ambientSH"===e.ambientSource?s.append(i.ambientSHPS):"envAtlas"===e.ambientSource?("envAtlas"!==e.reflectionSource&&"envAtlasHQ"!==e.reflectionSource&&s.append(i.envAtlasPS),s.append(i.ambientEnvPS.replace(/\$DECODE/g,il.decodeFunc(e.ambientEncoding)))):s.append(i.ambientConstantPS)),e.useAmbientTint&&!x&&n.append("uniform vec3 material_ambient;"),e.useMsdf&&(e.msdfTextAttribute||n.append("#define UNIFORM_TEXT_PARAMETERS"),s.append(i.msdfPS)),this.needsNormal&&(s.append(i.viewDirPS),e.useSpecular&&s.append(e.enableGGXSpecular?i.reflDirAnisoPS:i.reflDirPS));var b,w=!1,T=!1,A=!1,C=!1,E=!1;if(e.clusteredLightingEnabled&&this.lighting&&(C=!0,w=!0,T=!0,E=!0,s.append(i.floatUnpackingPS),e.lightMaskDynamic&&n.append("#define CLUSTER_MESH_DYNAMIC_LIGHTS"),e.clusteredLightingCookiesEnabled&&n.append("#define CLUSTER_COOKIES"),e.clusteredLightingShadowsEnabled&&!e.noShadow&&(n.append("#define CLUSTER_SHADOWS"),n.append("#define CLUSTER_SHADOW_TYPE_"+Ga[e.clusteredLightingShadowType])),e.clusteredLightingAreaLightsEnabled&&n.append("#define CLUSTER_AREALIGHTS"),n.append(fl.shaderDefines),e.clusteredLightingShadowsEnabled&&!e.noShadow&&s.append(i.clusteredLightShadowsPS),s.append(i.clusteredLightPS)),e.twoSidedLighting&&n.append("uniform float twoSidedLightingNegScaleFactor;"),a.append(this._fsGetStartCode(a,t,i,e)),this.needsNormal&&(e.twoSidedLighting?a.append(" dVertexNormalW = normalize(gl_FrontFacing ? vNormalW * twoSidedLightingNegScaleFactor : -vNormalW * twoSidedLightingNegScaleFactor);"):a.append(" dVertexNormalW = normalize(vNormalW);"),(e.useHeights||e.useNormals)&&e.hasTangents&&(e.twoSidedLighting?(a.append(" dTangentW = gl_FrontFacing ? vTangentW * twoSidedLightingNegScaleFactor : -vTangentW * twoSidedLightingNegScaleFactor;"),a.append(" dBinormalW = gl_FrontFacing ? vBinormalW * twoSidedLightingNegScaleFactor : -vBinormalW * twoSidedLightingNegScaleFactor;")):(a.append(" dTangentW = vTangentW;"),a.append(" dBinormalW = vBinormalW;"))),a.append(" getViewDir();"),v&&a.append(" getTBN(dTangentW, dBinormalW, dVertexNormalW);")),a.append(this.frontendFunc),this.needsNormal&&(e.useSpecular&&r.append(" getReflDir(litArgs_worldNormal, dViewDirW, litArgs_gloss, dTBN);"),e.useClearCoat&&r.append(" ccReflDirW = normalize(-reflect(dViewDirW, litArgs_clearcoat_worldNormal));")),(this.lighting&&e.useSpecular||this.reflections)&&(e.useMetalness&&(r.append(" float f0 = 1.0 / litArgs_ior; f0 = (f0 - 1.0) / (f0 + 1.0); f0 *= f0;"),r.append(" litArgs_specularity = getSpecularModulate(litArgs_specularity, litArgs_albedo, litArgs_metalness, f0);"),r.append(" litArgs_albedo = getAlbedoModulate(litArgs_albedo, litArgs_metalness);")),e.useIridescence&&r.append(" vec3 iridescenceFresnel = getIridescence(saturate(dot(dViewDirW, litArgs_worldNormal)), litArgs_specularity, litArgs_iridescence_thickness);")),S&&(r.append(" addAmbient(litArgs_worldNormal);"),e.conserveEnergy&&e.useSpecular&&r.append(" dDiffuseLight = dDiffuseLight * (1.0 - litArgs_specularity);"),e.separateAmbient&&r.append("\n vec3 dAmbientLight = dDiffuseLight;\n dDiffuseLight = vec3(0);\n ")),e.useAmbientTint&&!x&&r.append(" dDiffuseLight *= material_ambient;"),e.useAo&&!e.occludeDirect&&r.append(" occludeDiffuse(litArgs_ao);"),e.lightMapEnabled&&r.append(" addLightMap(\n litArgs_lightmap, \n litArgs_lightmapDir, \n litArgs_worldNormal, \n dViewDirW, \n dReflDirW, \n litArgs_gloss, \n litArgs_specularity, \n dVertexNormalW,\n dTBN\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n );"),this.lighting||this.reflections){this.reflections&&(e.useClearCoat&&(r.append(" addReflectionCC(ccReflDirW, litArgs_clearcoat_gloss);"),e.fresnelModel>0?(r.append(" ccFresnel = getFresnelCC(dot(dViewDirW, litArgs_clearcoat_worldNormal));"),r.append(" ccReflection.rgb *= ccFresnel;")):r.append(" ccFresnel = 0.0;")),e.useSpecularityFactor&&r.append(" ccReflection.rgb *= litArgs_specularityFactor;"),e.useSheen&&r.append(" addReflectionSheen(litArgs_worldNormal, dViewDirW, litArgs_sheen_gloss);"),r.append(" addReflection(dReflDirW, litArgs_gloss);"),e.fresnelModel>0?r.append(" dReflection.rgb *= \n getFresnel(\n dot(dViewDirW, litArgs_worldNormal), \n litArgs_gloss, \n litArgs_specularity\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel,\n litArgs_iridescence_intensity\n #endif\n );"):r.append(" dReflection.rgb *= litArgs_specularity;"),e.useSpecularityFactor&&r.append(" dReflection.rgb *= litArgs_specularityFactor;")),d&&(r.append(" dSpecularLight *= litArgs_specularity;"),e.useSpecular&&r.append(" calcLTCLightValues(litArgs_gloss, litArgs_worldNormal, dViewDirW, litArgs_specularity, litArgs_clearcoat_gloss, litArgs_clearcoat_worldNormal, litArgs_clearcoat_specularity);"));for(var M=0;M 0.00001) {"),2===R&&(b&&!P._cookieFalloff||(r.append(" dAtten *= getSpotEffect(light"+M+"_direction, light"+M+"_innerConeAngle, light"+M+"_outerConeAngle, dLightDirNormW);"),C=!0))),0!==I?0===R?r.append(" dAttenD = getLightDiffuse(litArgs_worldNormal, dViewDirW, dLightDirW, dLightDirNormW);"):r.append(" dAttenD = get"+L+"LightDiffuse(litArgs_worldNormal, dViewDirW, dLightDirW, dLightDirNormW) * 16.0;"):r.append(" dAtten *= getLightDiffuse(litArgs_worldNormal, dViewDirW, dLightDirW, dLightDirNormW);"),P.castShadows&&!e.noShadow){var D=6===P._shadowType,O=1===P._shadowType||2===P._shadowType||3===P._shadowType,k=5===P._shadowType||0===P._shadowType||4===P._shadowType,F=null,B=void 0;switch(P._shadowType){case 1:F="VSM8",B="0.0";break;case 2:F="VSM16",B="5.54";break;case 3:F="VSM32",B=t.textureFloatHighPrecision?"15.0":"5.54";break;case 5:F="PCF1x1";break;case 4:F="PCF5x5";break;case 6:F="PCSS";break;default:F="PCF3x3"}if(null!==F){P._normalOffsetBias&&!P._isVsm&&s.append("#define SHADOW_SAMPLE_NORMAL_OFFSET"),0===R&&s.append("#define SHADOW_SAMPLE_ORTHO"),((k||D)&&t.isWebGL2||t.isWebGPU||t.extStandardDerivatives)&&s.append("#define SHADOW_SAMPLE_SOURCE_ZBUFFER"),1===R&&s.append("#define SHADOW_SAMPLE_POINT");var U=i.shadowSampleCoordPS;s.append(U.replace("$LIGHT",M)),s.append("#undef SHADOW_SAMPLE_NORMAL_OFFSET"),s.append("#undef SHADOW_SAMPLE_ORTHO"),s.append("#undef SHADOW_SAMPLE_SOURCE_ZBUFFER"),s.append("#undef SHADOW_SAMPLE_POINT");var N="light"+M+"_shadowMatrix";0===R&&P.numCascades>1&&(r.append(" getShadowCascadeMatrix(light"+M+"_shadowMatrixPalette, light"+M+"_shadowCascadeDistances, light"+M+"_shadowCascadeCount);"),N="cascadeShadowMat"),r.append(" dShadowCoord = getShadowSampleCoord"+M+"("+N+", light"+M+"_shadowParams, vPositionW, dLightPosW, dLightDirW, dLightDirNormW, dVertexNormalW);"),0===R&&r.append(" fadeShadow(light"+M+"_shadowCascadeDistances);");var z="SHADOWMAP_PASS(light"+M+"_shadowMap), dShadowCoord, light"+M+"_shadowParams";if(O)z=z+", "+B+", dLightDirW";else if(D){var V="vec2(light"+M+"_shadowSearchArea)";0!==I&&(V="vec2(length(light"+M+"_halfWidth), length(light"+M+"_halfHeight)) * light"+M+"_shadowSearchArea"),z=z+", light"+M+"_cameraParams, "+V+", dLightDirW"}1===R?(F="Point"+F,D||(z+=", dLightDirW")):2===R&&(F="Spot"+F),r.append(" float shadow"+M+" = getShadow"+F+"("+z+");"),r.append(" dAtten *= mix(1.0, shadow"+M+", light"+M+"_shadowIntensity);")}}if(0!==I?e.conserveEnergy&&e.useSpecular?r.append(" dDiffuseLight += ((dAttenD * dAtten) * light"+M+"_color"+(b?" * dAtten3":"")+") * (1.0 - dLTCSpecFres);"):r.append(" dDiffuseLight += (dAttenD * dAtten) * light"+M+"_color"+(b?" * dAtten3":"")+";"):d&&e.conserveEnergy&&e.useSpecular?r.append(" dDiffuseLight += (dAtten * light"+M+"_color"+(b?" * dAtten3":"")+") * (1.0 - litArgs_specularity);"):r.append(" dDiffuseLight += dAtten * light"+M+"_color"+(b?" * dAtten3":"")+";"),e.useSpecular&&r.append(" dHalfDirW = normalize(-dLightDirNormW + dViewDirW);"),P.affectSpecularity)if(0!==I)e.useClearCoat&&r.append(" ccSpecularLight += ccLTCSpecFres * get"+L+"LightSpecular(litArgs_clearcoat_worldNormal, dViewDirW) * dAtten * light"+M+"_color"+(b?" * dAtten3":"")+";"),e.useSpecular&&r.append(" dSpecularLight += dLTCSpecFres * get"+L+"LightSpecular(litArgs_worldNormal, dViewDirW) * dAtten * light"+M+"_color"+(b?" * dAtten3":"")+";");else{var G=!1;0===R&&e.fresnelModel>0&&(G=!0),e.useClearCoat&&r.append(" ccSpecularLight += getLightSpecular(dHalfDirW, ccReflDirW, litArgs_clearcoat_worldNormal, dViewDirW, dLightDirNormW, litArgs_clearcoat_gloss, dTBN) * dAtten * light"+M+"_color"+(b?" * dAtten3":"")+(G?" * getFresnelCC(dot(dViewDirW, dHalfDirW));":";")),e.useSheen&&r.append(" sSpecularLight += getLightSpecularSheen(dHalfDirW, litArgs_worldNormal, dViewDirW, dLightDirNormW, litArgs_sheen_gloss) * dAtten * light"+M+"_color"+(b?" * dAtten3;":";")),e.useSpecular&&r.append(" dSpecularLight += getLightSpecular(dHalfDirW, dReflDirW, litArgs_worldNormal, dViewDirW, dLightDirNormW, litArgs_gloss, dTBN) * dAtten * light"+M+"_color"+(b?" * dAtten3":"")+(G?" \n * getFresnel(\n dot(dViewDirW, dHalfDirW), \n litArgs_gloss, \n litArgs_specularity\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel, \n litArgs_iridescence_intensity\n #endif\n );":"* litArgs_specularity;"))}0!==R&&r.append(" }")}}e.clusteredLightingEnabled&&this.lighting&&(T=!0,A=!0,w=!0,r.append(" addClusteredLights(\n litArgs_worldNormal, \n dViewDirW, \n dReflDirW,\n #if defined(LIT_CLEARCOAT)\n ccReflDirW,\n #endif\n litArgs_gloss, \n litArgs_specularity, \n dVertexNormalW, \n dTBN, \n #if defined(LIT_IRIDESCENCE)\n iridescenceFresnel,\n #endif\n litArgs_clearcoat_worldNormal, \n litArgs_clearcoat_gloss,\n litArgs_sheen_gloss,\n litArgs_iridescence_intensity\n );")),d&&(e.useClearCoat&&r.append(" litArgs_clearcoat_specularity = 1.0;"),e.useSpecular&&r.append(" litArgs_specularity = vec3(1);")),e.useRefraction&&r.append(" addRefraction(\n litArgs_worldNormal, \n dViewDirW, \n litArgs_thickness, \n litArgs_gloss, \n litArgs_specularity, \n litArgs_albedo, \n litArgs_transmission,\n litArgs_ior\n #if defined(LIT_IRIDESCENCE)\n , iridescenceFresnel, \n litArgs_iridescence_intensity\n #endif\n );")}e.useAo&&(e.occludeDirect&&r.append(" occludeDiffuse(litArgs_ao);"),1!==e.occludeSpecular&&2!==e.occludeSpecular||r.append(" occludeSpecular(litArgs_gloss, litArgs_ao, litArgs_worldNormal, dViewDirW);")),e.useSpecularityFactor&&r.append(" dSpecularLight *= litArgs_specularityFactor;"),!1===e.opacityFadesSpecular&&(2!==e.blendType&&4!==e.blendType||(r.append("float specLum = dot((dSpecularLight + dReflection.rgb * dReflection.a), vec3( 0.2126, 0.7152, 0.0722 ));"),r.append("#ifdef LIT_CLEARCOAT\n specLum += dot(ccSpecularLight * litArgs_clearcoat_specularity + ccReflection.rgb * litArgs_clearcoat_specularity, vec3( 0.2126, 0.7152, 0.0722 ));\n#endif"),r.append("litArgs_opacity = clamp(litArgs_opacity + gammaCorrectInput(specLum), 0.0, 1.0);")),r.append("litArgs_opacity *= material_alphaFade;")),r.append(i.endPS),2===e.blendType||6===e.blendType||e.alphaToCoverage?r.append(i.outputAlphaPS):4===e.blendType?r.append(i.outputAlphaPremulPS):r.append(i.outputAlphaOpaquePS),e.useMsdf&&r.append(" gl_FragColor = applyMsdf(gl_FragColor);"),r.append(i.outputPS),r.append(i.debugOutputPS),w&&s.prepend(i.lightDirPointPS),T&&s.prepend(i.falloffLinearPS),A&&s.prepend(i.falloffInvSquaredPS),C&&s.prepend(i.spotPS),E&&!e.clusteredLightingEnabled&&s.prepend(i.cookiePS);var H="",W="void evaluateBackend() {\n"+r.code+"\n}";s.append(W),a.append(i.debugProcessFrontendPS),a.append(" evaluateBackend();"),a.append(Eo.end());var X=n.code+s.code+a.code;return X.includes("dTBN")&&(H+="mat3 dTBN;\n"),X.includes("dVertexNormalW")&&(H+="vec3 dVertexNormalW;\n"),X.includes("dTangentW")&&(H+="vec3 dTangentW;\n"),X.includes("dBinormalW")&&(H+="vec3 dBinormalW;\n"),X.includes("dViewDirW")&&(H+="vec3 dViewDirW;\n"),X.includes("dReflDirW")&&(H+="vec3 dReflDirW;\n"),X.includes("dHalfDirW")&&(H+="vec3 dHalfDirW;\n"),X.includes("ccReflDirW")&&(H+="vec3 ccReflDirW;\n"),X.includes("dLightDirNormW")&&(H+="vec3 dLightDirNormW;\n"),X.includes("dLightDirW")&&(H+="vec3 dLightDirW;\n"),X.includes("dLightPosW")&&(H+="vec3 dLightPosW;\n"),X.includes("dShadowCoord")&&(H+="vec3 dShadowCoord;\n"),X.includes("dReflection")&&(H+="vec4 dReflection;\n"),X.includes("dDiffuseLight")&&(H+="vec3 dDiffuseLight;\n"),X.includes("dSpecularLight")&&(H+="vec3 dSpecularLight;\n"),X.includes("dAtten")&&(H+="float dAtten;\n"),X.includes("dAttenD")&&(H+="float dAttenD;\n"),X.includes("dAtten3")&&(H+="vec3 dAtten3;\n"),X.includes("dMsdf")&&(H+="vec4 dMsdf;\n"),X.includes("ccFresnel")&&(H+="float ccFresnel;\n"),X.includes("ccReflection")&&(H+="vec3 ccReflection;\n"),X.includes("ccSpecularLight")&&(H+="vec3 ccSpecularLight;\n"),X.includes("ccSpecularityNoFres")&&(H+="float ccSpecularityNoFres;\n"),X.includes("sSpecularLight")&&(H+="vec3 sSpecularLight;\n"),X.includes("sReflection")&&(H+="vec3 sReflection;\n"),this._fsGetBeginCode()+this.varyings+this.varyingDefines+this._fsGetBaseCode()+H+this.frontendDecl+X},e.generateFragmentShader=function(t,e,i,n){var s,r=this.options;this.frontendDecl=t,this.frontendCode=e,this.frontendFunc=i,this.lightingUv=n,3===r.pass?this.fshader=this._fsGetPickPassCode():2===r.pass?this.fshader=this._fsGetDepthPassCode():this.shadowPass?this.fshader=this._fsGetShadowPassCode():r.customFragmentShader?this.fshader=this._fsGetBeginCode()+r.customFragmentShader:this.fshader=this._fsGetLitPassCode(),null==(s=this.handleCompatibility)||s.call(this)},e.getDefinition=function(){var t=hr.createDefinition(this.device,{name:"LitShader",attributes:this.attributes,vertexCode:this.vshader,fragmentCode:this.fshader});return this.shaderPassInfo.isForward&&(t.tag=1),t},t}(),gl={generateKey:function(t){return"lit"+Object.keys(t).sort().map((function(e){return"chunks"===e?gl.generateChunksKey(t):"lights"===e?gl.generateLightsKey(t):e+t[e]})).join("\n")},generateLightsKey:function(t){return"lights:"+t.lights.map((function(e){return t.clusteredLightingEnabled&&0!==e._type?"":e.key+","})).join("")},generateChunksKey:function(t){var e;return"chunks:\n"+Object.keys(null!=(e=t.chunks)?e:{}).sort().map((function(e){return e+t.chunks[e]})).join("")}},vl=[0,1,2,3,4,5,6,7],yl=function(t){function e(){return t.apply(this,arguments)||this}S(e,t);var i=e.prototype;return i.generateKey=function(t){return"lit"+vl.map((function(e,i){return t.usedUvs[i]?"1":"0"})).join("")+t.shaderChunk+gl.generateKey(t.litOptions)},i.createShaderDefinition=function(t,e){var i=new _l(t,e.litOptions),n=new Jh,s=new Jh,r=new Jh;n.append("uniform float textureBias;"),n.append(i.chunks.litShaderArgsPS),s.append(e.shaderChunk),r.code="evaluateFrontend();",r.code="\n"+r.code.split("\n").map((function(t){return" "+t})).join("\n")+"\n\n";var a=e.usedUvs||[!0];return i.generateVertexShader(a,a,[]),i.generateFragmentShader(n.code,s.code,r.code,"vUv0"),i.getDefinition()},e}(Eo),xl=new yl,Sl=new function(){this.usedUvs=void 0,this.shaderChunk=void 0,this.litOptions=new Qh},bl=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),s=0;s1?0:1),this.lightsBuffer.updateUniforms(),this._clusterWorldTextureId.setValue(this.clusterTexture),this._clusterMaxCellsId.setValue(this.maxCellLightCount);var t=this.boundsDelta;this._clusterCellsCountByBoundsSizeData[0]=this._cells.x/t.x,this._clusterCellsCountByBoundsSizeData[1]=this._cells.y/t.y,this._clusterCellsCountByBoundsSizeData[2]=this._cells.z/t.z,this._clusterCellsCountByBoundsSizeId.setValue(this._clusterCellsCountByBoundsSizeData),this._clusterBoundsMinData[0]=this.boundsMin.x,this._clusterBoundsMinData[1]=this.boundsMin.y,this._clusterBoundsMinData[2]=this.boundsMin.z,this._clusterBoundsDeltaData[0]=t.x,this._clusterBoundsDeltaData[1]=t.y,this._clusterBoundsDeltaData[2]=t.z,this._clusterCompressionLimit0Data[0]=this._maxAttenuation,this._clusterCompressionLimit0Data[1]=this._maxColorValue,this._clusterTextureSizeId.setValue(this._clusterTextureSizeData),this._clusterBoundsMinId.setValue(this._clusterBoundsMinData),this._clusterBoundsDeltaId.setValue(this._clusterBoundsDeltaData),this._clusterCellsDotId.setValue(this._clusterCellsDotData),this._clusterCellsMaxId.setValue(this._clusterCellsMaxData),this._clusterCompressionLimit0Id.setValue(this._clusterCompressionLimit0Data)},e.evalLightCellMinMax=function(t,e,i){e.copy(t.min),e.sub(this.boundsMin),e.div(this.boundsDelta),e.mul2(e,this.cells),e.floor(),i.copy(t.max),i.sub(this.boundsMin),i.div(this.boundsDelta),i.mul2(i,this.cells),i.ceil(),e.max(Et.ZERO),i.min(this._cellsLimit)},e.collectLights=function(t){var e=this.lightsBuffer.maxLights,i=this._usedLights,n=1;t.forEach((function(t){var s,r=!!(3&t.mask),a=2===t.type&&0===t._outerConeAngle;t.enabled&&0!==t.type&&t.visibleThisFrame&&t.intensity>0&&r&&!a&&(n1){e.copy(t[1].min),i.copy(t[1].max);for(var n=2;n1)for(var h=1/o,l=0;l1)for(var f=0;f0){for(var n=this.slots,s=0;ss&&(s=a)}return jl.min=n,jl.max=s,jl}var Kl=function(){function t(t,e){this.renderer=void 0,this.shadowRenderer=void 0,this.device=void 0,this.renderer=t,this.shadowRenderer=e,this.device=t.device}var e=t.prototype;return e.cull=function(t,e,i,n){void 0===n&&(n=null),t.visibleThisFrame=!0,t._shadowMap||(t._shadowMap=Rl.create(this.device,t));var s=i._nearClip;this.generateSplitDistances(t,s,Math.min(i._farClip,t.shadowDistance));for(var r=t.shadowUpdateOverrides,a=0;a_&&(_=v)}var y=l.right,x=l.up,S=l.forward,b=.25*t._shadowResolution/_,w=Math.ceil(Wl.dot(x)*b)/b,T=Math.ceil(Wl.dot(y)*b)/b,A=x.mulScalar(w),C=y.mulScalar(T),E=Wl.dot(S),M=S.mulScalar(E);Wl.add2(A,C).add(M),l.setPosition(Wl),l.translateLocal(0,0,1e6),h.nearClip=.01,h.farClip=2e6,h.orthoHeight=_,this.renderer.updateCameraFrustum(h),this.shadowRenderer.cullShadowCasters(e,t,o.visibleCasters,h,n);for(var P=!0,R=o.visibleCasters,I=0;I=1&&e<=3?new gt(0,0,0,0):new gt(1,1,1,1),s.clearDepthBuffer=!0,s.clearStencilBuffer=!1,s},t.setShadowCameraSettings=function(t,e,i,n,s){var r=4===i||(5===i||0===i)&&e.supportsDepthShadow;1!==n||s||(r=!1),t.clearColorBuffer=!r};var e=t.prototype;return e._cullShadowCastersInternal=function(t,e,i){for(var n=t.length,s=0;s1&&(this.renderer.scene.clusteredLightingEnabled&&0!==t._type||this.applyVsmBlur(t,e))},e.getVsmBlurShader=function(t,e,i){var n=(t?this.blurPackedVsmShader:this.blurVsmShader)[e][i];if(!n){this.blurVsmWeights[i]=function(t){for(var e=(t-1)/6,i=.5*(t-1),n=new Array(t),s=0,r=0;r0},i.filter=function(t,e){for(var i=0;i1?this.quadRendererCube:this.quadRenderer2D;a>1&&this.initInvViewProjMatrices(),this.blitTextureId.setValue(r.cookie);for(var h=0;h1){var l=oc.z/3,c=i[h];oc.x+=l*c.x,oc.y+=l*c.y,oc.z=l,oc.w=l,this.invViewProjId.setValue(hc[h].data)}oc.mulScalar(e),o.render(oc)}}n.length=0},y(e,[{key:"quadRenderer2D",get:function(){if(!this._quadRenderer2D){var t=Po(this.device,ac,"\n\tvarying vec2 uv0;\n\tuniform sampler2D blitTexture;\n\tvoid main(void) {\n\t\tgl_FragColor = texture2D(blitTexture, uv0);\n\t}","cookieRenderer2d");this._quadRenderer2D=new ko(t)}return this._quadRenderer2D}},{key:"quadRendererCube",get:function(){if(!this._quadRendererCube){var t=Po(this.device,ac,"\n\tvarying vec2 uv0;\n\tuniform samplerCube blitTexture;\n\tuniform mat4 invViewProj;\n\tvoid main(void) {\n\t\tvec4 projPos = vec4(uv0 * 2.0 - 1.0, 0.5, 1.0);\n\t\tvec4 worldPos = invViewProj * projPos;\n\t\tgl_FragColor = textureCube(blitTexture, worldPos.xyz);\n\t}","cookieRendererCube");this._quadRendererCube=new ko(t)}return this._quadRendererCube}}]),e}(Er),cc=function(t){function e(e,i,n){var s;return(s=t.call(this,e)||this).requiresCubemaps=!1,s.shadowRenderer=i,s.shadowRendererLocal=n,s}S(e,t);var i=e.prototype;return i.update=function(t){var e=this.shadowRendererLocal.shadowLights,i=this.shadowRendererLocal.prepareLights(e,t),n=e.length;this.enabled=n>0,n&&this.shadowRenderer.setupRenderPass(this,i,!1)},i.execute=function(){for(var t=this.shadowRendererLocal.shadowLights,e=t.length,i=0;i0)&&this.alphaTestId.setValue(e.alphaTest)},e.updateCpuSkinMatrices=function(t){dc++;var e=t.length;if(0!==e)for(var i=0;i0&&(this._instancedDrawCalls++,t.setVertexBuffer(a.vertexBuffer),t.draw(i.primitive[n],a.count)):t.draw(i.primitive[n])},e.drawInstance2=function(t,e,i,n){var s=e.instancingData;s?s.count>0&&(this._instancedDrawCalls++,t.draw(i.primitive[n],s.count,!0)):t.draw(i.primitive[n],void 0,!0)},e.cull=function(t,e,i){var n=i.opaque;n.length=0;var s=i.transparent;s.length=0;for(var r=t.frustumCulling,a=e.length,o=0;o0}}]),t}(),Lc=2.399963229728653,Dc=function(t,e,i){var n=e*Lc,s=Math.sqrt(e)/Math.sqrt(i);t.x=s*Math.cos(n),t.y=s*Math.sin(n)},Oc=function(t,e,i,n,s){void 0===n&&(n=0),void 0===s&&(s=1),n=1-2*n,s=1-2*s;var r=_t.lerp(n,s,e/i),a=Math.sqrt(1-r*r),o=Lc*e;t.x=Math.cos(o)*a,t.y=r,t.z=Math.sin(o)*a},kc=function(t){var e=(t<<16|t>>>16)>>>0;return 2.3283064365386963e-10*(e=((16711935&(e=((252645135&(e=((858993459&(e=((1431655765&e)<<1|(2863311530&e)>>>1)>>>0))<<2|(3435973836&e)>>>2)>>>0))<<4|(4042322160&e)>>>4)>>>0))<<8|(4278255360&e)>>>8)>>>0)},Fc=function(t){switch(t){case mi:return"Cubemap";case gi:return"Octahedral";default:return"Equirect"}},Bc=function(t,e,i){if(t<=0)e[i+0]=0,e[i+1]=0,e[i+2]=0,e[i+3]=0;else if(t>=1)e[i+0]=255,e[i+1]=0,e[i+2]=0,e[i+3]=0;else{var n=1*t%1,s=255*t%1,r=65025*t%1,a=16581375*t%1;n-=s/255,s-=r/255,r-=a/255,e[i+0]=Math.min(255,Math.floor(256*n)),e[i+1]=Math.min(255,Math.floor(256*s)),e[i+2]=Math.min(255,Math.floor(256*r)),e[i+3]=Math.min(255,Math.floor(256*a))}},Uc=function(t,e,i,n){var s=2*i*Math.PI,r=Math.pow(1-e,1/(n+1)),a=Math.sqrt(1-r*r);t.set(Math.cos(s)*a,Math.sin(s)*a,r).normalize()},Nc=function(t,e,i){var n=2*i*Math.PI,s=Math.sqrt(1-e),r=Math.sqrt(e);t.set(Math.cos(n)*r,Math.sin(n)*r,s).normalize()},zc=function(t,e,i,n){var s=2*i*Math.PI,r=Math.sqrt((1-e)/(1+(n*n-1)*e)),a=Math.sqrt(1-r*r);t.set(Math.cos(s)*a,Math.sin(s)*a,r).normalize()},Vc=function(t,e){var i=t*e,n=e/(1-t*t+i*i);return n*n*(1/Math.PI)},Gc={16:{2:26,8:20,32:17,128:16,512:16},32:{2:53,8:40,32:34,128:32,512:32},128:{2:214,8:163,32:139,128:130,512:128},1024:{2:1722,8:1310,32:1114,128:1041,512:1025}},Hc=function(t,e,i){for(var n=i/t,s=1-Math.log2(e)/11,r=s*s,a=new Et,o=new Et,h=new Et(0,0,1),l=[],c=function(t,e){var i=Gc[t];return i&&i[e]||t}(t,e),u=0;u0){var f=Vc(Math.min(1,d),r)/4+.001,p=.5*Math.log2(n/f);l.push(o.x,o.y,o.z,p)}}for(;l.length<4*t;)l.push(0,0,0,0);return l},Wc=function(t,e,i){var n=function(t){for(var e=t.length,i=Math.min(e,512),n=Math.ceil(e/i),s=new Uint8Array(i*n*4),r=0,a=0;a>2*h),rect:r,seamPixels:s}),r.y+=r.w,r.z=Math.max(1,Math.floor(.5*r.z)),r.w=Math.max(1,Math.floor(.5*r.w));return r.set(128*s,384*s,64*s,32*s),Qc(t,n,{numSamples:(null==e?void 0:e.numAmbientSamples)||2048,distribution:"lambert",rect:r,seamPixels:s}),n},t.generatePrefilteredAtlas=function(t,e){for(var i=t[0].device,n=t[0].format,s=t[0].type,r=(null==e?void 0:e.target)||new Us(i,{name:"envPrefilteredAtlas",width:(null==e?void 0:e.size)||512,height:(null==e?void 0:e.size)||512,format:n,type:s,projection:_i,addressU:1,addressV:1,mipmaps:!1}),a=r.width/512,o=new Dt(0,0,512*a,256*a),h=$c(512),l=0;l0){if(i[t]e.length){for(var n=e,s=n.charAt(n.length-1),r=i[t]-n.length,a=0;a0,t.litOptions.blendType=i.blendType,t.litOptions.screenSpace=n&&0!=(n&qa),t.litOptions.skin=n&&0!=(2&n),t.litOptions.useInstancing=n&&0!=(n&Wa),t.litOptions.useMorphPosition=n&&0!=(n&Ya),t.litOptions.useMorphNormal=n&&0!=(n&Ka),t.litOptions.useMorphTextureBased=n&&0!=(n&Za),t.litOptions.nineSlicedMode=i.nineSlicedMode||0,e.clusteredLightingEnabled&&i.useLighting?(t.litOptions.clusteredLightingEnabled=!0,t.litOptions.clusteredLightingCookiesEnabled=e.lighting.cookiesEnabled,t.litOptions.clusteredLightingShadowsEnabled=e.lighting.shadowsEnabled,t.litOptions.clusteredLightingShadowType=e.lighting.shadowType,t.litOptions.clusteredLightingAreaLightsEnabled=e.lighting.areaLightsEnabled):(t.litOptions.clusteredLightingEnabled=!1,t.litOptions.clusteredLightingCookiesEnabled=!1,t.litOptions.clusteredLightingShadowsEnabled=!1,t.litOptions.clusteredLightingAreaLightsEnabled=!1)},e._updateUVOptions=function(t,e,i,n){var s=!1,r=!1,a=!1;i&&(s=0!=(4&i),r=0!=(8&i),a=0!=(16&i)),t.litOptions.vertexColors=!1,this._mapXForms=[];var o={};for(var h in eu)this._updateTexOptions(t,e,h,s,r,a,n,o);this._mapXForms=null,t.litOptions.lightMapEnabled=t.lightMap,t.litOptions.dirLightMapEnabled=t.dirLightMap,t.litOptions.useHeights=t.heightMap,t.litOptions.useNormals=t.normalMap,t.litOptions.useClearCoatNormals=t.clearCoatNormalMap,t.litOptions.useAo=t.aoMap||t.aoVertexColor,t.litOptions.diffuseMapEnabled=t.diffuseMap},e._updateTexOptions=function(t,e,i,n,s,r,a,o){var h="opacity"===i;if(!a||h){var l=i+"Map",c=i+"VertexColor",u=i+"VertexColorChannel",d=l+"Channel",f=l+"Transform",p=l+"Uv",m=l+"Identifier";if("light"!==i&&(t[l]=!1,t[m]=void 0,t[d]="",t[f]=0,t[p]=0),t[c]=!1,t[u]="",h&&3===e.blendType&&0===e.alphaTest&&!e.alphaToCoverage)return;if("height"!==i&&e[c]&&r&&(t[c]=e[c],t[u]=e[u],t.litOptions.vertexColors=!0),e[l]){var _=!0;if(0!==e[p]||n||(_=!1),1!==e[p]||s||(_=!1),_){var g=e[l].id,v=o[g];void 0===v&&(o[g]=i,v=i),t[l]=!!e[l],t[m]=v,t[f]=this._getMapTransformID(e.getUniform(f),e[p]),t[d]=e[d],t[p]=e[p]}}}},e._updateMinOptions=function(t,e){t.opacityTint=1!==e.opacity&&3!==e.blendType,t.litOptions.lights=[]},e._updateMaterialOptions=function(t,e){var i,n,s,r,a,o=(e.diffuseTint||!e.diffuseMap&&!e.diffuseVertexColor)&&au(e.diffuse),h=!!(e.useMetalness||e.specularMap||e.sphereMap||e.cubeMap||(a=e.specular,0!==a.r||0!==a.g||0!==a.b)||e.specularityFactor>0&&e.useMetalness||e.enableGGXSpecular||e.clearCoat>0),l=!e.useMetalness||e.useMetalnessSpecularColor,c=h&&(e.specularTint||!e.specularMap&&!e.specularVertexColor)&&au(e.specular),u=h&&e.useMetalnessSpecularColor&&(e.specularityFactorTint||e.specularityFactor<1&&!e.specularityFactorMap),d=!e.emissiveMap||au(e.emissive)&&e.emissiveTint,f=1!==e.emissiveIntensity,p=!!e.normalMap&&(e.normalMap.format===le||e.normalMap.type===li);t.opacityTint=1!==e.opacity&&3!==e.blendType?1:0,t.ambientTint=e.ambientTint,t.diffuseTint=o?2:0,t.specularTint=c?2:0,t.specularityFactorTint=u?1:0,t.metalnessTint=e.useMetalness&&e.metalness<1?1:0,t.glossTint=1,t.emissiveTint=(d?2:0)+(f?1:0),t.diffuseEncoding=null==(i=e.diffuseMap)?void 0:i.encoding,t.diffuseDetailEncoding=null==(n=e.diffuseDetailMap)?void 0:n.encoding,t.emissiveEncoding=null==(s=e.emissiveMap)?void 0:s.encoding,t.lightMapEncoding=null==(r=e.lightMap)?void 0:r.encoding,t.packedNormal=p,t.refractionTint=1!==e.refraction?1:0,t.refractionIndexTint=e.refractionIndex!==1/1.5?1:0,t.thicknessTint=e.useDynamicRefraction&&1!==e.thickness?1:0,t.specularEncoding=e.specularEncoding||"linear",t.sheenEncoding=e.sheenEncoding||"linear",t.aoMapUv=e.aoUvSet,t.aoDetail=!!e.aoMap,t.diffuseDetail=!!e.diffuseMap,t.normalDetail=!!e.normalMap,t.diffuseDetailMode=e.diffuseDetailMode,t.aoDetailMode=e.aoDetailMode,t.clearCoatTint=1!==e.clearCoat?1:0,t.clearCoatGloss=!!e.clearCoatGloss,t.clearCoatGlossTint=1!==e.clearCoatGloss?1:0,t.iorTint=e.refractionIndex!==1/1.5?1:0,t.iridescenceTint=1!==e.iridescence?1:0,t.sheenTint=e.useSheen&&au(e.sheen)?2:0,t.sheenGlossTint=1,t.glossInvert=e.glossInvert,t.sheenGlossInvert=e.sheenGlossInvert,t.clearCoatGlossInvert=e.clearCoatGlossInvert,t.useSpecularColor=l,t.litOptions.separateAmbient=!1,t.litOptions.useAmbientTint=e.ambientTint,t.litOptions.customFragmentShader=e.customFragmentShader,t.litOptions.pixelSnap=e.pixelSnap,t.litOptions.shadingModel=e.shadingModel,t.litOptions.ambientSH=!!e.ambientSH,t.litOptions.fastTbn=e.fastTbn,t.litOptions.twoSidedLighting=e.twoSidedLighting,t.litOptions.occludeSpecular=e.occludeSpecular,t.litOptions.occludeSpecularFloat=1!==e.occludeSpecularIntensity,t.litOptions.useMsdf=!!e.msdfMap,t.litOptions.msdfTextAttribute=!!e.msdfTextAttribute,t.litOptions.alphaToCoverage=e.alphaToCoverage,t.litOptions.opacityFadesSpecular=e.opacityFadesSpecular,t.litOptions.cubeMapProjection=e.cubeMapProjection,t.litOptions.occludeDirect=e.occludeDirect,t.litOptions.conserveEnergy=e.conserveEnergy&&0!==e.shadingModel,t.litOptions.useSpecular=h,t.litOptions.useSpecularityFactor=(u||!!e.specularityFactorMap)&&e.useMetalnessSpecularColor,t.litOptions.enableGGXSpecular=e.enableGGXSpecular,t.litOptions.fresnelModel=e.fresnelModel,t.litOptions.useRefraction=(e.refraction||!!e.refractionMap)&&(e.useDynamicRefraction||!!t.litOptions.reflectionSource),t.litOptions.useClearCoat=!!e.clearCoat,t.litOptions.useSheen=e.useSheen,t.litOptions.useIridescence=e.useIridescence&&0!==e.iridescence,t.litOptions.useMetalness=e.useMetalness,t.litOptions.useDynamicRefraction=e.useDynamicRefraction},e._updateEnvOptions=function(t,e,i){t.litOptions.fog=e.useFog?i.fog:"none",t.litOptions.gamma=e.useGammaTonemap?i.gammaCorrection:0,t.litOptions.toneMap=e.useGammaTonemap?i.toneMapping:-1,t.litOptions.fixSeams=!!e.cubeMap&&e.cubeMap.fixCubemapSeams;var n=0===e.shadingModel,s=!1;if(e.envAtlas&&e.cubeMap&&!n?(t.litOptions.reflectionSource="envAtlasHQ",t.litOptions.reflectionEncoding=e.envAtlas.encoding,t.litOptions.reflectionCubemapEncoding=e.cubeMap.encoding):e.envAtlas&&!n?(t.litOptions.reflectionSource="envAtlas",t.litOptions.reflectionEncoding=e.envAtlas.encoding):e.cubeMap?(t.litOptions.reflectionSource="cubeMap",t.litOptions.reflectionEncoding=e.cubeMap.encoding):e.sphereMap?(t.litOptions.reflectionSource="sphereMap",t.litOptions.reflectionEncoding=e.sphereMap.encoding):e.useSkybox&&i.envAtlas&&i.skybox&&!n?(t.litOptions.reflectionSource="envAtlasHQ",t.litOptions.reflectionEncoding=i.envAtlas.encoding,t.litOptions.reflectionCubemapEncoding=i.skybox.encoding,s=!0):e.useSkybox&&i.envAtlas&&!n?(t.litOptions.reflectionSource="envAtlas",t.litOptions.reflectionEncoding=i.envAtlas.encoding,s=!0):e.useSkybox&&i.skybox?(t.litOptions.reflectionSource="cubeMap",t.litOptions.reflectionEncoding=i.skybox.encoding,s=!0):(t.litOptions.reflectionSource=null,t.litOptions.reflectionEncoding=null),e.ambientSH&&!n)t.litOptions.ambientSource="ambientSH",t.litOptions.ambientEncoding=null;else{var r=e.envAtlas||(e.useSkybox&&i.envAtlas?i.envAtlas:null);r&&!n?(t.litOptions.ambientSource="envAtlas",t.litOptions.ambientEncoding=r.encoding):(t.litOptions.ambientSource="constant",t.litOptions.ambientEncoding=null)}t.litOptions.skyboxIntensity=s&&(1!==i.skyboxIntensity||i.physicalUnits),t.litOptions.useCubeMapRotation=s&&i._skyboxRotationShaderInclude},e._updateLightOptions=function(t,e,i,n,s){if(t.lightMap=!1,t.lightMapChannel="",t.lightMapUv=0,t.lightMapTransform=0,t.litOptions.lightMapWithoutAmbient=!1,t.dirLightMap=!1,n&&(t.litOptions.noShadow=0!=(1&n),0!=(64&n)&&(t.lightMapEncoding=7===e.lightmapPixelFormat?"rgbm":"linear",t.lightMap=!0,t.lightMapChannel="rgb",t.lightMapUv=1,t.lightMapTransform=0,t.litOptions.lightMapWithoutAmbient=!i.lightMap,0!=(n&Xa)&&(t.dirLightMap=!0),0!=(n&Qa)&&(t.litOptions.lightMapWithoutAmbient=!1))),i.useLighting){var r=[],a=n?n>>16:1;t.litOptions.lightMaskDynamic=!!(1&a),s&&($h.collectLights(0,s[0],r,a),$h.collectLights(1,s[1],r,a),$h.collectLights(2,s[2],r,a)),t.litOptions.lights=r}else t.litOptions.lights=[];0===t.litOptions.lights.length&&(t.litOptions.noShadow=!0)},e._getMapTransformID=function(t,e){if(!t)return 0;var i=this._mapXForms[e];i||(i=[],this._mapXForms[e]=i);for(var n=0;n0&&(this._setParameter("material_clearCoat",this.clearCoat),this._setParameter("material_clearCoatGloss",this.clearCoatGloss),this._setParameter("material_clearCoatBumpiness",this.clearCoatBumpiness)),this._setParameter("material_gloss",n("gloss")),this.emissiveMap&&!this.emissiveTint||this._setParameter("material_emissive",n("emissive")),1!==this.emissiveIntensity&&this._setParameter("material_emissiveIntensity",this.emissiveIntensity),this.refraction>0&&this._setParameter("material_refraction",this.refraction),this.useDynamicRefraction&&(this._setParameter("material_thickness",this.thickness),this._setParameter("material_attenuation",n("attenuation")),this._setParameter("material_invAttenuationDistance",0===this.attenuationDistance?0:1/this.attenuationDistance)),this.useIridescence&&(this._setParameter("material_iridescence",this.iridescence),this._setParameter("material_iridescenceRefractionIndex",this.iridescenceRefractionIndex),this._setParameter("material_iridescenceThicknessMin",this.iridescenceThicknessMin),this._setParameter("material_iridescenceThicknessMax",this.iridescenceThicknessMax)),this._setParameter("material_opacity",this.opacity),!1===this.opacityFadesSpecular&&this._setParameter("material_alphaFade",this.alphaFade),this.occludeSpecular&&this._setParameter("material_occludeSpecularIntensity",this.occludeSpecularIntensity),1===this.cubeMapProjection&&this._setParameter(n("cubeMapProjectionBox")),eu)this._updateMap(s);this.ambientSH&&this._setParameter("ambientSH[0]",this.ambientSH),this.normalMap&&this._setParameter("material_bumpiness",this.bumpiness),this.normalMap&&this.normalDetailMap&&this._setParameter("material_normalDetailMapBumpiness",this.normalDetailMapBumpiness),this.heightMap&&this._setParameter("material_heightMapFactor",n("heightMapFactor"));var r=0===this.shadingModel;this.envAtlas&&this.cubeMap&&!r?(this._setParameter("texture_envAtlas",this.envAtlas),this._setParameter("texture_cubeMap",this.cubeMap)):this.envAtlas&&!r?this._setParameter("texture_envAtlas",this.envAtlas):this.cubeMap?this._setParameter("texture_cubeMap",this.cubeMap):this.sphereMap&&this._setParameter("texture_sphereMap",this.sphereMap),this._setParameter("material_reflectivity",this.reflectivity),this._processParameters("_activeParams"),this._dirtyShader&&this.clearVariants()},i.updateEnvUniforms=function(t,e){var i=0===this.shadingModel;!(this.envAtlas&&!i||this.cubeMap||this.sphereMap)&&this.useSkybox&&(e.envAtlas&&e.skybox&&!i?(this._setParameter("texture_envAtlas",e.envAtlas),this._setParameter("texture_cubeMap",e.skybox)):e.envAtlas&&!i?this._setParameter("texture_envAtlas",e.envAtlas):e.skybox&&this._setParameter("texture_cubeMap",e.skybox)),this._processParameters("_activeLightingParams")},i.getShaderVariant=function(t,e,i,n,s,r,a,o,h){this.updateEnvUniforms(t,e);var l=Vo.get(t).getByIndex(s),c=2===s||3===s||l.isShadow,u=c?su.optionsContextMin:su.optionsContext;c?this.shaderOptBuilder.updateMinRef(u,e,this,i,s,r):this.shaderOptBuilder.updateRef(u,e,this,i,s,r),this.onUpdateShader&&(u=this.onUpdateShader(u));var d=new xo(a,o,h),f=Ao(t);f.register("standard",su);var p=f.getProgram("standard",u,d,this.userId);return this._dirtyShader=!1,p},i.destroy=function(){for(var e in this._assetReferences)this._assetReferences[e]._unbind();this._assetReferences=null,t.prototype.destroy.call(this)},y(e,[{key:"shader",get:function(){return null},set:function(t){}},{key:"chunks",get:function(){return this._dirtyShader=!0,this._chunks},set:function(t){this._dirtyShader=!0,this._chunks=t}}]),e}(Yo);vu.TEXTURE_PARAMETERS=cu,vu.CUBEMAP_PARAMETERS=du;var yu=function(t,e){_u[t]=e},xu=function(t,e,i,n){Object.defineProperty(vu.prototype,t,{get:n||function(){return this["_"+t]},set:i}),mu[t]={value:e}},Su=function(t){return t.defaultValue&&t.defaultValue.clone?function(t){var e="_"+t.name,i=t.dirtyShaderFunc||function(){return!0};xu(t.name,(function(){return t.defaultValue.clone()}),(function(t){var n=this[e];n.equals(t)||(this._dirtyShader=this._dirtyShader||i(n,t),this[e]=n.copy(t))}),t.getterFunc)}(t):function(t){var e="_"+t.name,i=t.dirtyShaderFunc||function(){return!0};xu(t.name,(function(){return t.defaultValue}),(function(t){var n=this[e];n!==t&&(this._dirtyShader=this._dirtyShader||i(n,t),this[e]=t)}),t.getterFunc)}(t)};function bu(t,e,i,n){void 0===e&&(e="rgb"),void 0===i&&(i=!0),void 0===n&&(n=0),eu[t]=e.length||-1,Su({name:t+"Map",defaultValue:null,dirtyShaderFunc:function(t,e){return!!t!=!!e||t&&(t.type!==e.type||t.fixCubemapSeams!==e.fixCubemapSeams||t.format!==e.format)}}),Su({name:t+"MapTiling",defaultValue:new It(1,1)}),Su({name:t+"MapOffset",defaultValue:new It(0,0)}),Su({name:t+"MapRotation",defaultValue:0}),Su({name:t+"MapUv",defaultValue:n}),e&&(Su({name:t+"MapChannel",defaultValue:e}),i&&(Su({name:t+"VertexColor",defaultValue:!1}),Su({name:t+"VertexColorChannel",defaultValue:e})));var s=t+"MapTiling",r=t+"MapOffset",a=t+"MapRotation",o=t+"MapTransform";yu(o,(function(t,e,i){var n=t[s],h=t[r],l=t[a];if(1===n.x&&1===n.y&&0===h.x&&0===h.y&&0===l)return null;var c=t._allocUniform(o,(function(){return[{name:"texture_"+o+"0",value:new Float32Array(3)},{name:"texture_"+o+"1",value:new Float32Array(3)}]})),u=Math.cos(l*_t.DEG_TO_RAD),d=Math.sin(l*_t.DEG_TO_RAD),f=c[0].value;f[0]=u*n.x,f[1]=-d*n.y,f[2]=h.x;var p=c[1].value;return p[0]=d*n.x,p[1]=u*n.y,p[2]=1-n.y-h.y,c}))}function wu(t,e){Su({name:t,defaultValue:e,getterFunc:function(){return this._dirtyShader=!0,this["_"+t]}}),yu(t,(function(e,i,n){var s=e._allocUniform(t,(function(){return new Float32Array(3)})),r=e[t];return e.useGammaTonemap&&n.gammaCorrection?(s[0]=Math.pow(r.r,2.2),s[1]=Math.pow(r.g,2.2),s[2]=Math.pow(r.b,2.2)):(s[0]=r.r,s[1]=r.g,s[2]=r.b),s}))}function Tu(t,e,i){Su({name:t,defaultValue:e,dirtyShaderFunc:function(t,e){return(0===t||1===t)!=(0===e||1===e)}}),yu(t,i)}function Au(t,e){Su({name:t,defaultValue:null,dirtyShaderFunc:function(t,e){return!!t==!!e}}),yu(t,e)}function Cu(t,e){Su({name:t,defaultValue:e})}!function(){wu("ambient",new gt(.7,.7,.7)),wu("diffuse",new gt(1,1,1)),wu("specular",new gt(0,0,0)),wu("emissive",new gt(0,0,0)),wu("sheen",new gt(1,1,1)),wu("attenuation",new gt(1,1,1)),Tu("emissiveIntensity",1),Tu("specularityFactor",1),Tu("sheenGloss",0),Tu("gloss",.25,(function(t,e,i){return 0===t.shadingModel?Math.pow(2,11*t.gloss):t.gloss})),Tu("heightMapFactor",1,(function(t,e,i){return.025*t.heightMapFactor})),Tu("opacity",1),Tu("alphaFade",1),Tu("alphaTest",0),Tu("bumpiness",1),Tu("normalDetailMapBumpiness",1),Tu("reflectivity",1),Tu("occludeSpecularIntensity",1),Tu("refraction",0),Tu("refractionIndex",1/1.5),Tu("thickness",0),Tu("attenuationDistance",0),Tu("metalness",1),Tu("anisotropy",0),Tu("clearCoat",0),Tu("clearCoatGloss",1),Tu("clearCoatBumpiness",1),Tu("aoUvSet",0,null),Tu("iridescence",0),Tu("iridescenceRefractionIndex",1/1.5),Tu("iridescenceThicknessMin",0),Tu("iridescenceThicknessMax",0),Au("ambientSH"),Au("cubeMapProjectionBox",(function(t,e,i){var n=t._allocUniform("cubeMapProjectionBox",(function(){return[{name:"envBoxMin",value:new Float32Array(3)},{name:"envBoxMax",value:new Float32Array(3)}]})),s=t.cubeMapProjectionBox.getMin(),r=n[0].value;r[0]=s.x,r[1]=s.y,r[2]=s.z;var a=t.cubeMapProjectionBox.getMax(),o=n[1].value;return o[0]=a.x,o[1]=a.y,o[2]=a.z,n})),Cu("ambientTint",!1),Cu("diffuseTint",!1),Cu("specularTint",!1),Cu("specularityFactorTint",!1),Cu("emissiveTint",!1),Cu("fastTbn",!1),Cu("useMetalness",!1),Cu("useMetalnessSpecularColor",!1),Cu("useSheen",!1),Cu("enableGGXSpecular",!1),Cu("occludeDirect",!1),Cu("normalizeNormalMap",!0),Cu("conserveEnergy",!0),Cu("opacityFadesSpecular",!0),Cu("occludeSpecular",1),Cu("shadingModel",1),Cu("fresnelModel",2),Cu("useDynamicRefraction",!1),Cu("cubeMapProjection",0),Cu("customFragmentShader",null),Cu("useFog",!0),Cu("useLighting",!0),Cu("useGammaTonemap",!0),Cu("useSkybox",!0),Cu("forceUv1",!1),Cu("pixelSnap",!1),Cu("twoSidedLighting",!1),Cu("nineSlicedMode",void 0),Cu("msdfTextAttribute",!1),Cu("useIridescence",!1),Cu("glossInvert",!1),Cu("sheenGlossInvert",!1),Cu("clearCoatGlossInvert",!1),bu("diffuse"),bu("specular"),bu("emissive"),bu("thickness","g"),bu("specularityFactor","g"),bu("normal",""),bu("metalness","g"),bu("gloss","g"),bu("opacity","a"),bu("refraction","g"),bu("height","g",!1),bu("ao","g"),bu("light","rgb",!0,1),bu("msdf",""),bu("diffuseDetail","rgb",!1),bu("normalDetail",""),bu("aoDetail","g",!1),bu("clearCoat","g"),bu("clearCoatGloss","g"),bu("clearCoatNormal",""),bu("sheen","rgb"),bu("sheenGloss","g"),bu("iridescence","g"),bu("iridescenceThickness","g"),Cu("diffuseDetailMode",Ha),Cu("aoDetailMode",Ha),Au("cubeMap"),Au("sphereMap"),Au("envAtlas");var t=[null,null,null,null,null,null];xu("prefilteredCubemaps",(function(){return t.slice()}),(function(t){var e=this._prefilteredCubemaps;t=t||[];for(var i=!1,n=!0,s=0;s<6;++s){var r=t[s]||null;e[s]!==r&&(e[s]=r,i=!0),n=n&&!!e[s]}i&&(n?this.envAtlas=Jc.generatePrefilteredAtlas(e,{target:this.envAtlas}):this.envAtlas&&(this.envAtlas.destroy(),this.envAtlas=null),this._dirtyShader=!0)}),(function(){return this._prefilteredCubemaps}))}(),new Et(1,1,1),new Et(40,0,0);var Eu=function(t){function e(e,i,n,s){var r;return(r=t.call(this,e)||this).layerComposition=void 0,r.scene=void 0,r.renderer=void 0,r.renderActions=[],r.layerComposition=i,r.scene=n,r.renderer=s,r}S(e,t);var i=e.prototype;return i.addRenderAction=function(t){if(this.renderActions.push(t),1===this.renderActions.length){var e=t.camera;this.fullSizeClearRect=e.camera.fullSizeClearRect,this.fullSizeClearRect&&(t.clearColor&&this.setClearColor(e.camera.clearColor),t.clearDepth&&this.setClearDepth(e.camera.clearDepth),t.clearStencil&&this.setClearStencil(e.camera.clearStencil))}},i.addLayer=function(t,e,i,n){void 0===n&&(n=!0);var s=new Ic;if(s.renderTarget=this.renderTarget,s.camera=t,s.layer=e,s.transparent=i,n){var r=0===this.renderActions.length;s.setupClears(r?t:void 0,e)}this.addRenderAction(s)},i.before=function(){var t=this.renderActions;if(t.length){var e=t[0];e.camera.onPreRender&&e.firstCameraUse&&e.camera.onPreRender()}},i.execute=function(){for(var t=this.layerComposition,e=this.renderActions,i=0;i0){var a=this._shaderVersion;ku.forEach((function(t){a>=0&&t._shaderVersion!==a&&(t.getShaderVariant!==Yo.prototype.getShaderVariant&&t.clearVariants(),t._shaderVersion=a)})),ku.clear()}},e.removeMeshInstances=function(t,e){for(var i=this.meshInstances,n=this.meshInstancesSet,s=0;s=0&&i.splice(a,1)}}e||this.removeShadowCasters(t)},e.addShadowCasters=function(t){for(var e=this.shadowCasters,i=this.shadowCastersSet,n=0;n=0&&e.splice(r,1)}}},e.clearMeshInstances=function(t){void 0===t&&(t=!1),this.meshInstances.length=0,this.meshInstancesSet.clear(),t||(this.shadowCasters.length=0,this.shadowCastersSet.clear())},e.markLightsDirty=function(){this._lightHashDirty=!0,this._lightIdHashDirty=!0,this._splitLightsDirty=!0},e.addLight=function(t){var e=t.light;this._lightsSet.has(e)||(this._lightsSet.add(e),this._lights.push(e),this.markLightsDirty()),0!==e.type&&this._clusteredLightsSet.add(e)},e.removeLight=function(t){var e=t.light;this._lightsSet.has(e)&&(this._lightsSet.delete(e),this._lights.splice(this._lights.indexOf(e),1),this.markLightsDirty()),0!==e.type&&this._clusteredLightsSet.delete(e)},e.clearLights=function(){var t=this;this._lightsSet.forEach((function(e){return e.removeLayer(t)})),this._lightsSet.clear(),this._clusteredLightsSet.clear(),this._lights.length=0,this.markLightsDirty()},e.evaluateLightHash=function(t,e,i){for(var n=0,s=this._lights,r=0;r0&&(Ou.sort(),n=$i(Ou),Ou.length=0),n},e.getLightHash=function(t){return this._lightHashDirty&&(this._lightHashDirty=!1,this._lightHash=this.evaluateLightHash(!t,!0,!1)),this._lightHash},e.getLightIdHash=function(){return this._lightIdHashDirty&&(this._lightIdHashDirty=!1,this._lightIdHash=this.evaluateLightHash(!0,!1,!0)),this._lightIdHash},e.addCamera=function(t){this.camerasSet.has(t.camera)||(this.camerasSet.add(t.camera),this.cameras.push(t),this._dirtyComposition=!0)},e.removeCamera=function(t){if(this.camerasSet.has(t.camera)){this.camerasSet.delete(t.camera);var e=this.cameras.indexOf(t);this.cameras.splice(e,1),this._dirtyComposition=!0}},e.clearCameras=function(){this.cameras.length=0,this.camerasSet.clear(),this._dirtyComposition=!0},e._calculateSortDistances=function(t,e,i,n){for(var s=0;s0}},{key:"clusteredLightsSet",get:function(){return this._clusteredLightsSet}},{key:"splitLights",get:function(){if(this._splitLightsDirty){this._splitLightsDirty=!1;for(var t=this._splitLights,e=0;e1&&Nu(this.cameras),this.camerasMap.clear();for(var a=0;a0)this.addDummyRenderAction(h,c);else{for(var u=!0,d=h,f=null,p=!1,m=0;m0&&c.layers.indexOf(_.id)>=0){o.push(_),p||_.id!==c.disablePostEffectsLayer||(p=!0,f&&(f.triggerPostprocess=!0));var g=this.subLayerList[m];f=this.addRenderAction(h,_,g,c,u,p),h++,u=!1}}d=0;l--)if(h[l].camera===n&&h[l].renderTarget===a){o=!0;break}r&&n.postEffectsEnabled&&(a=null);var c=this.getNextRenderAction(t);c.triggerPostprocess=!1,c.layer=e,c.transparent=i,c.camera=n,c.renderTarget=a,c.firstCameraUse=s,c.lastCameraUse=!1;var u=s||!o,d=e.clearColorBuffer||e.clearDepthBuffer||e.clearStencilBuffer;return(u||d)&&c.setupClears(u?n:void 0,e),c},i.propagateRenderTarget=function(t,e){for(var i=t;i>=0;i--){var n=this._renderActions[i],s=n.layer;if(n.renderTarget&&1!==s.id)break;if(1!==s.id){if(n.useCameraPasses)break;var r=null==n?void 0:n.camera.camera;if(r&&(!e.camera.rect.equals(r.rect)||!e.camera.scissorRect.equals(r.scissorRect)))break;n.renderTarget=e.renderTarget}}},i._logRenderActions=function(){},i._isLayerAdded=function(t){return this.layerIdMap.get(t.id)===t},i._isSublayerAdded=function(t,e){return void 0!==(e?this.layerTransparentIndexMap:this.layerOpaqueIndexMap).get(t)},i.push=function(t){this._isLayerAdded(t)||(this.layerList.push(t),this.layerList.push(t),this._opaqueOrder[t.id]=this.subLayerList.push(!1)-1,this._transparentOrder[t.id]=this.subLayerList.push(!0)-1,this.subLayerEnabled.push(!0),this.subLayerEnabled.push(!0),this._updateLayerMaps(),this._dirty=!0,this.fire("add",t))},i.insert=function(t,e){if(!this._isLayerAdded(t)){this.layerList.splice(e,0,t,t),this.subLayerList.splice(e,0,!1,!0);var i=this.layerList.length;this._updateOpaqueOrder(e,i-1),this._updateTransparentOrder(e,i-1),this.subLayerEnabled.splice(e,0,!0,!0),this._updateLayerMaps(),this._dirty=!0,this.fire("add",t)}},i.remove=function(t){var e=this.layerList.indexOf(t);for(delete this._opaqueOrder[e],delete this._transparentOrder[e];e>=0;)this.layerList.splice(e,1),this.subLayerList.splice(e,1),this.subLayerEnabled.splice(e,1),e=this.layerList.indexOf(t),this._dirty=!0,this.fire("remove",t);var i=this.layerList.length;this._updateOpaqueOrder(0,i-1),this._updateTransparentOrder(0,i-1),this._updateLayerMaps()},i.pushOpaque=function(t){this._isSublayerAdded(t,!1)||(this.layerList.push(t),this._opaqueOrder[t.id]=this.subLayerList.push(!1)-1,this.subLayerEnabled.push(!0),this._updateLayerMaps(),this._dirty=!0,this.fire("add",t))},i.insertOpaque=function(t,e){if(!this._isSublayerAdded(t,!1)){this.layerList.splice(e,0,t),this.subLayerList.splice(e,0,!1);var i=this.subLayerList.length;this._updateOpaqueOrder(e,i-1),this.subLayerEnabled.splice(e,0,!0),this._updateLayerMaps(),this._dirty=!0,this.fire("add",t)}},i.removeOpaque=function(t){for(var e=0,i=this.layerList.length;e45?(t.radius=e*this._outerConeAngleSin,Vu.mulScalar(-e*n)):(t.radius=e/(2*n),Vu.mulScalar(-t.radius)),t.center.add2(s.getPosition(),Vu)}else 1===this._type&&(t.center=this._node.getPosition(),t.radius=this.attenuationEnd)},e.getBoundingBox=function(t){if(2===this._type){var e=this.attenuationEnd,i=this._outerConeAngle,n=this._node,s=Math.abs(Math.sin(i*_t.DEG_TO_RAD)*e);t.center.set(0,.5*-e,0),t.halfExtents.set(s,.5*e,s),t.setFromTransformedAabb(t,n.getWorldTransform(),!0)}else 1===this._type&&(t.center.copy(this._node.getPosition()),t.halfExtents.set(this.attenuationEnd,this.attenuationEnd,this.attenuationEnd))},e._updateFinalColor=function(){var e=this._color,i=e.r,n=e.g,s=e.b,r=this._intensity;this._usePhysicalUnits&&(r=this._luminance/t.getLightUnitConversion(this._type,this._outerConeAngle*_t.DEG_TO_RAD,this._innerConeAngle*_t.DEG_TO_RAD));var a=this._finalColor,o=this._linearFinalColor;a[0]=i*r,a[1]=n*r,a[2]=s*r,r>=1?(o[0]=Math.pow(i,2.2)*r,o[1]=Math.pow(n,2.2)*r,o[2]=Math.pow(s,2.2)*r):(o[0]=Math.pow(a[0],2.2),o[1]=Math.pow(a[1],2.2),o[2]=Math.pow(a[2],2.2))},e.setColor=function(){1===arguments.length?this._color.set(arguments[0].r,arguments[0].g,arguments[0].b):3===arguments.length&&this._color.set(arguments[0],arguments[1],arguments[2]),this._updateFinalColor()},e.layersDirty=function(){this.layers.forEach((function(t){t.markLightsDirty()}))},e.updateKey=function(){var t=this._type<<29|(this._castShadows?1:0)<<28|this._shadowType<<25|this._falloffMode<<23|(0!==this._normalOffsetBias?1:0)<<22|(this._cookie?1:0)<<21|(this._cookieFalloff?1:0)<<20|Hu[this._cookieChannel.charAt(0)]<<18|(this._cookieTransform?1:0)<<12|this._shape<<10|this.numCascades-1<<8|(this.affectSpecularity?1:0)<<7|this.mask<<6;3===this._cookieChannel.length&&(t|=Hu[this._cookieChannel.charAt(1)]<<16,t|=Hu[this._cookieChannel.charAt(2)]<<14),t!==this.key&&this.layersDirty(),this.key=t},y(t,[{key:"numCascades",get:function(){return this.cascades.length},set:function(t){this.cascades&&this.numCascades===t||(this.cascades=Xu[t-1],this._shadowMatrixPalette=new Float32Array(64),this._shadowCascadeDistances=new Float32Array(4),this._destroyShadowMap(),this.updateKey())}},{key:"shadowMap",get:function(){return this._shadowMap},set:function(t){this._shadowMap!==t&&(this._destroyShadowMap(),this._shadowMap=t)}},{key:"mask",get:function(){return this._mask},set:function(t){this._mask!==t&&(this._mask=t,this.updateKey())}},{key:"numShadowFaces",get:function(){var t=this._type;return 0===t?this.numCascades:1===t?6:1}},{key:"type",get:function(){return this._type},set:function(t){if(this._type!==t){this._type=t,this._destroyShadowMap(),this.updateKey();var e=this._shadowType;this._shadowType=null,this.shadowUpdateOverrides=null,this.shadowType=e}}},{key:"shape",get:function(){return this._shape},set:function(t){if(this._shape!==t){this._shape=t,this._destroyShadowMap(),this.updateKey();var e=this._shadowType;this._shadowType=null,this.shadowType=e}}},{key:"usePhysicalUnits",get:function(){return this._usePhysicalUnits},set:function(t){this._usePhysicalUnits!==t&&(this._usePhysicalUnits=t,this._updateFinalColor())}},{key:"shadowType",get:function(){return this._shadowType},set:function(t){if(this._shadowType!==t){var e=this.device;1===this._type&&0!==t&&6!==t&&(t=0);var i=e.supportsDepthShadow;4!==t||i||(t=0),3!==t||e.textureFloatRenderable&&e.textureFloatFilterable||(t=2),2!==t||e.textureHalfFloatRenderable||(t=1),this._isVsm=t>=1&&t<=3,this._isPcf=5===t||0===t||4===t,this._shadowType=t,this._destroyShadowMap(),this.updateKey()}}},{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(this._enabled=t,this.layersDirty())}},{key:"castShadows",get:function(){return this._castShadows&&4!==this._mask&&0!==this._mask},set:function(t){this._castShadows!==t&&(this._castShadows=t,this._destroyShadowMap(),this.layersDirty(),this.updateKey())}},{key:"shadowResolution",get:function(){return this._shadowResolution},set:function(t){this._shadowResolution!==t&&(t=1===this._type?Math.min(t,this.device.maxCubeMapSize):Math.min(t,this.device.maxTextureSize),this._shadowResolution=t,this._destroyShadowMap())}},{key:"vsmBlurSize",get:function(){return this._vsmBlurSize},set:function(t){this._vsmBlurSize!==t&&(t%2==0&&t++,this._vsmBlurSize=t)}},{key:"normalOffsetBias",get:function(){return this._normalOffsetBias},set:function(t){this._normalOffsetBias!==t&&((!this._normalOffsetBias&&t||this._normalOffsetBias&&!t)&&this.updateKey(),this._normalOffsetBias=t)}},{key:"falloffMode",get:function(){return this._falloffMode},set:function(t){this._falloffMode!==t&&(this._falloffMode=t,this.updateKey())}},{key:"innerConeAngle",get:function(){return this._innerConeAngle},set:function(t){this._innerConeAngle!==t&&(this._innerConeAngle=t,this._innerConeAngleCos=Math.cos(t*Math.PI/180),this._usePhysicalUnits&&this._updateFinalColor())}},{key:"outerConeAngle",get:function(){return this._outerConeAngle},set:function(t){this._outerConeAngle!==t&&(this._outerConeAngle=t,this._updateOuterAngle(t),this._usePhysicalUnits&&this._updateFinalColor())}},{key:"penumbraSize",get:function(){return this._penumbraSize},set:function(t){this._penumbraSize=t}},{key:"intensity",get:function(){return this._intensity},set:function(t){this._intensity!==t&&(this._intensity=t,this._updateFinalColor())}},{key:"affectSpecularity",get:function(){return this._affectSpecularity},set:function(t){0===this._type&&(this._affectSpecularity=t,this.updateKey())}},{key:"luminance",get:function(){return this._luminance},set:function(t){this._luminance!==t&&(this._luminance=t,this._updateFinalColor())}},{key:"cookieMatrix",get:function(){return this._cookieMatrix||(this._cookieMatrix=new zt),this._cookieMatrix}},{key:"atlasViewport",get:function(){return this._atlasViewport||(this._atlasViewport=new Dt(0,0,1,1)),this._atlasViewport}},{key:"cookie",get:function(){return this._cookie},set:function(t){this._cookie!==t&&(this._cookie=t,this.updateKey())}},{key:"cookieFalloff",get:function(){return this._cookieFalloff},set:function(t){this._cookieFalloff!==t&&(this._cookieFalloff=t,this.updateKey())}},{key:"cookieChannel",get:function(){return this._cookieChannel},set:function(t){if(this._cookieChannel!==t){if(t.length<3)for(var e=t.charAt(t.length-1),i=3-t.length,n=0;n0&&(e+="varying vec2 uv0;\nuniform highp float morphFactor["+t+"];\n");for(var i=0;i=this.maxSubmitCount&&(s(r,a),r=0,a=!0))}(r>0||0===o&&!this.zeroTextures)&&s(r,a)},e._updateTextureMorph=function(){this.device,(this._activeTargets.length>0||!this.zeroTextures)&&(this.rtPositions&&this._updateTextureRenderTarget(this.rtPositions,"texturePositions"),this.rtNormals&&this._updateTextureRenderTarget(this.rtNormals,"textureNormals"),this.zeroTextures=0===this._activeTargets.length)},e._updateVertexMorph=function(){for(var t=this.maxSubmitCount,e=0;e1e-5){this._activeTargets.length<=e&&(this._activeTargets[e]={});var s=this._activeTargets[e++];s.absWeight=n,s.weight=this.getWeight(i),s.target=t[i]}}this._activeTargets.length=e;var r=this.morph.maxActiveTargets;this._activeTargets.length>r&&(this._activeTargets.sort((function(t,e){return t.absWeightl)return!1;this.morphTextureWidth=c,this.morphTextureHeight=u;var d=!1,f=3,p=Ct.float2Half;this._textureFormat===ue&&(d=!0,f=4);for(var m=[],_=0;_0&&(s+=wo.screenDepthPS),s+=wo.particle_cpuVS,e.localSpace&&(s+=wo.particle_localShiftVS),e.animTex&&(s+=this._animTex(e)),e.alignToMotion&&(s+=wo.particle_pointAlongVS),s+=e.mesh?wo.particle_meshVS:r,1===e.normal&&(s+=wo.particle_normalVS),2===e.normal&&(s+=wo.particle_TBNVS),e.stretch>0&&(s+=wo.particle_stretchVS),s+=wo.particle_cpu_endVS,e.soft>0&&(s+=wo.particle_softVS)):(s+=wo.particle_initVS,s+=e.pack8?wo.particleInputRgba8PS:wo.particleInputFloatPS,e.soft>0&&(s+=wo.screenDepthPS),s+=wo.particleVS,e.localSpace&&(s+=wo.particle_localShiftVS),e.animTex&&(s+=this._animTex(e)),e.wrap&&(s+=wo.particle_wrapVS),e.alignToMotion&&(s+=wo.particle_pointAlongVS),s+=e.mesh?wo.particle_meshVS:r,1===e.normal&&(s+=wo.particle_normalVS),2===e.normal&&(s+=wo.particle_TBNVS),e.stretch>0&&(s+=wo.particle_stretchVS),s+=wo.particle_endVS,e.soft>0&&(s+=wo.particle_softVS)),s+="}\n",e.normal>0&&(1===e.normal?n+="\nvarying vec3 Normal;\n":2===e.normal&&(n+="\nvarying mat3 ParticleMat;\n"),n+="\nuniform vec3 lightCube[6];\n"),e.soft&&(n+="\nvarying float vDepth;\n"),0===e.normal&&"none"===e.fog&&(e.srgb=!1),n+=wo.decodePS,n+=Eo.gammaCode(e.gamma),n+=Eo.tonemapCode(e.toneMap),"linear"===e.fog?n+=wo.fogLinearPS:"exp"===e.fog?n+=wo.fogExpPS:"exp2"===e.fog?n+=wo.fogExp2PS:n+=wo.fogNonePS,2===e.normal&&(n+="\nuniform sampler2D normalMap;\n"),e.soft>0&&(n+=wo.screenDepthPS),n+=wo.particlePS,e.soft>0&&(n+=wo.particle_softPS),1===e.normal&&(n+="\nvec3 normal = Normal;\n"),2===e.normal&&(n+=wo.particle_normalMapPS),e.normal>0&&(n+=e.halflambert?wo.particle_halflambertPS:wo.particle_lambertPS),e.normal>0&&(n+=wo.particle_lightingPS),2===e.blend?n+=wo.particle_blendNormalPS:1===e.blend?n+=wo.particle_blendAddPS:5===e.blend&&(n+=wo.particle_blendMultiplyPS),n+=wo.particle_endPS,hr.createDefinition(t,{name:"ParticleShader",vertexCode:s,fragmentCode:n})},e}(Eo),id=new ed,nd=1,sd=new zt,rd=new zt,ad=new Et,od=new Et,hd=new Et,ld=new Et,cd=new Et,ud=new Et,dd=new Et,fd=new Et,pd=new Et,md=new Et,_d=new Et,gd=new Et,vd=new Et;function yd(t){return t-Math.floor(t)}function xd(t){return Math.max(Math.min(t,1),0)}function Sd(t,e){return t-e*Math.floor(t/e)}function bd(t){var e=yd(t),i=yd(255*t);return[e-=i/255,i-=i/255]}var wd=function(){function t(t){this._emitter=t}var e=t.prototype;return e.calcSpawnPosition=function(t,e,i,n,s){var r=this._emitter,a=Math.random(),o=Math.random(),h=Math.random(),l=Math.random();if(r.useCpu&&(t[4*s+0+2*r.numParticlesPot*4]=a,t[4*s+1+2*r.numParticlesPot*4]=o,t[4*s+2+2*r.numParticlesPot*4]=h),od.x=a-.5,od.y=o-.5,od.z=h-.5,0===r.emitterShape){var c=Math.max(Math.abs(od.x),Math.max(Math.abs(od.y),Math.abs(od.z))),u=c+(.5-c)*i[0],d=c+(.5-c)*i[1],f=c+(.5-c)*i[2];od.x=u*(c===Math.abs(od.x)?Math.sign(od.x):2*od.x),od.y=d*(c===Math.abs(od.y)?Math.sign(od.y):2*od.y),od.z=f*(c===Math.abs(od.z)?Math.sign(od.z):2*od.z),r.localSpace?ad.copy(e.transformPoint(od)):ad.copy(n).add(e.transformPoint(od))}else{od.normalize();var p=0===r.emitterRadius?0:r.emitterRadiusInner/r.emitterRadius,m=l*(1-p)+p;r.localSpace?ad.copy(od.mulScalar(m*r.emitterRadius)):ad.copy(n).add(od.mulScalar(m*r.emitterRadius))}var _,g,v,y,x,S=-_t.lerp(r.rate,r.rate2,a)*s;if(r.pack8){var b=(ad.x-r.worldBounds.center.x)/r.worldBoundsSize.x+.5,w=(ad.y-r.worldBounds.center.y)/r.worldBoundsSize.y+.5,T=(ad.z-r.worldBounds.center.z)/r.worldBoundsSize.z+.5,A=_t.lerp(r.startAngle*_t.DEG_TO_RAD,r.startAngle2*_t.DEG_TO_RAD,a);A=A%(2*Math.PI)/(2*Math.PI);var C=bd(b);t[4*s]=C[0],t[4*s+1]=C[1];var E=bd(w);t[4*s+2]=E[0],t[4*s+3]=E[1];var M=bd(T);t[4*s+0+4*r.numParticlesPot]=M[0],t[4*s+1+4*r.numParticlesPot]=M[1];var P=bd(A);t[4*s+2+4*r.numParticlesPot]=P[0],t[4*s+3+4*r.numParticlesPot]=P[1];t[4*s+3+4*r.numParticlesPot*2]=1;var R=Math.max(r.lifetime,(r.numParticles-1)*Math.max(r.rate,r.rate2)),I=r.lifetime+1,L=(g=yd(_=S=(S+R)/(R+I)),v=yd(255*_),y=yd(65025*_),x=yd(160581375*_),[g-=v/255,v-=y/255,y-=x/255,x-=x/255]);t[4*s+0+4*r.numParticlesPot*3]=L[0],t[4*s+1+4*r.numParticlesPot*3]=L[1],t[4*s+2+4*r.numParticlesPot*3]=L[2],t[4*s+3+4*r.numParticlesPot*3]=L[3]}else t[4*s]=ad.x,t[4*s+1]=ad.y,t[4*s+2]=ad.z,t[4*s+3]=_t.lerp(r.startAngle*_t.DEG_TO_RAD,r.startAngle2*_t.DEG_TO_RAD,a),t[4*s+3+4*r.numParticlesPot]=S},e.update=function(t,e,i,n,s,r,a,o){var h,l,c,u=this._emitter;if(u.meshInstance.node){for(var d=u.meshInstance.node.worldTransform,f=0;f<12;f++)sd.data[f]=d.data[f];rd.copy(sd),rd.invert(),Iu=u.meshInstance.node.localScale,nd=Math.max(Math.max(Iu.x,Iu.y),Iu.z)}r=null===u.meshInstance.node||u.localSpace?Et.ZERO:u.meshInstance.node.getPosition();for(var p,m,_,g,v,y,x,S,b=u.camera?u.camera._node.getPosition():Et.ZERO,w=u.useMesh?17:15,T=u.precision-1,A=0;A=P)&&this.calcSpawnPosition(i,n,s,r,C);var O=R>0&&R0&&(1===u.emitterShape?(od.copy(hd).mulScalar(2).sub(Et.ONE).normalize(),ud.add(od.mulScalar(u.initialVelocity))):ud.add(Et.FORWARD.mulScalar(u.initialVelocity))),cd.x+=(dd.x-cd.x)*hd.x,cd.y+=(dd.y-cd.y)*hd.y,cd.z+=(dd.z-cd.z)*hd.z,_+=(g-_)*hd.y,L=(L+1e4*E%1*(v-L))*nd,D=1e3*E%1*(x-y),u.meshInstance.node&&(u.localSpace?(ud.x/=Iu.x,ud.y/=Iu.y,ud.z/=Iu.z):sd.transformPoint(ud,ud)),u.localSpace?(rd.transformPoint(cd,cd),ud.add(cd).add(pd)):(ud.add(cd.mul(Iu)),ud.add(pd.mul(Iu))),gd.copy(ud),md.copy(ld).add(ud.mulScalar(a)),_d.copy(md),i[4*C]=_d.x,i[4*C+1]=_d.y,i[4*C+2]=_d.z,i[4*C+3]+=_*a,u.wrap&&u.wrapBounds&&(u.localSpace||_d.sub(r),_d.x=Sd(_d.x,u.wrapBounds.x)-.5*u.wrapBounds.x,_d.y=Sd(_d.y,u.wrapBounds.y)-.5*u.wrapBounds.y,_d.z=Sd(_d.z,u.wrapBounds.z)-.5*u.wrapBounds.z,u.localSpace||_d.add(r)),u.sort>0&&(1===u.sort?(vd.copy(_d).sub(b),u.particleDistance[C]=-(vd.x*vd.x+vd.y*vd.y+vd.z*vd.z)):2===u.sort?u.particleDistance[C]=R:3===u.sort&&(u.particleDistance[C]=-R))),o?R<0&&(i[4*C+3+2*u.numParticlesPot*4]=-1):(R>=P&&(R-=Math.max(P,(u.numParticles-1)*M),i[4*C+3+2*u.numParticlesPot*4]=u.loop?1:-1),R<0&&u.loop&&(i[4*C+3+2*u.numParticlesPot*4]=1)),i[4*C+3+2*u.numParticlesPot*4]<0&&(O=!1),i[4*C+3+4*u.numParticlesPot]=R;for(var k=0;k0&&u.camera){for(var V=u.useMesh?6:4,G=u.particleDistance,H=0;Ht.maxTextureSize&&(this.numParticles=t.maxTextureSize),Hd("rate",1),Hd("rate2",this.rate),Hd("lifetime",50),Hd("emitterExtents",new Et(0,0,0)),Hd("emitterExtentsInner",new Et(0,0,0)),Hd("emitterRadius",0),Hd("emitterRadiusInner",0),Hd("emitterShape",0),Hd("initialVelocity",1),Hd("wrap",!1),Hd("localSpace",!1),Hd("screenSpace",!1),Hd("wrapBounds",null),Hd("colorMap",this.defaultParamTexture),Hd("normalMap",null),Hd("loop",!0),Hd("preWarm",!1),Hd("sort",0),Hd("mode",0),Hd("scene",null),Hd("lighting",!1),Hd("halfLambert",!1),Hd("intensity",1),Hd("stretch",0),Hd("alignToMotion",!1),Hd("depthSoftening",0),Hd("mesh",null),Hd("particleNormal",new Et(0,1,0)),Hd("orientation",0),Hd("depthWrite",!1),Hd("noFog",!1),Hd("blendType",2),Hd("node",null),Hd("startAngle",0),Hd("startAngle2",this.startAngle),Hd("animTilesX",1),Hd("animTilesY",1),Hd("animStartFrame",0),Hd("animNumFrames",1),Hd("animNumAnimations",1),Hd("animIndex",0),Hd("randomizeAnimIndex",!1),Hd("animSpeed",1),Hd("animLoop",!0),this._gpuUpdater=new Ed(this,i),this._cpuUpdater=new wd(this),this.emitterPosUniform=new Float32Array(3),this.wrapBoundsUniform=new Float32Array(3),this.emitterScaleUniform=new Float32Array([1,1,1]),Hd("colorGraph",Fd),Hd("colorGraph2",this.colorGraph),Hd("scaleGraph",Od),Hd("scaleGraph2",this.scaleGraph),Hd("alphaGraph",Od),Hd("alphaGraph2",this.alphaGraph),Hd("localVelocityGraph",kd),Hd("localVelocityGraph2",this.localVelocityGraph),Hd("velocityGraph",kd),Hd("velocityGraph2",this.velocityGraph),Hd("rotationSpeedGraph",Dd),Hd("rotationSpeedGraph2",this.rotationSpeedGraph),Hd("radialSpeedGraph",Dd),Hd("radialSpeedGraph2",this.radialSpeedGraph),this.animTilesParams=new Float32Array(2),this.animParams=new Float32Array(4),this.animIndexParams=new Float32Array(2),this.internalTex0=null,this.internalTex1=null,this.internalTex2=null,this.colorParam=null,this.vbToSort=null,this.vbOld=null,this.particleDistance=null,this.camera=null,this.swapTex=!1,this.useMesh=!0,this.useCpu=!t.supportsGpuParticles,this.pack8=!0,this.localBounds=new jt,this.worldBoundsNoTrail=new jt,this.worldBoundsTrail=[new jt,new jt],this.worldBounds=new jt,this.worldBoundsSize=new Et,this.prevWorldBoundsSize=new Et,this.prevWorldBoundsCenter=new Et,this.prevEmitterExtents=this.emitterExtents,this.prevEmitterRadius=this.emitterRadius,this.worldBoundsMul=new Et,this.worldBoundsAdd=new Et,this.timeToSwitchBounds=0,this.shaderParticleUpdateRespawn=null,this.shaderParticleUpdateNoRespawn=null,this.shaderParticleUpdateOnStop=null,this.numParticleVerts=0,this.numParticleIndices=0,this.material=null,this.meshInstance=null,this.drawOrder=0,this.seed=Math.random(),this.fixedTimeStep=1/60,this.maxSubSteps=10,this.simTime=0,this.simTimeTotal=0,this.beenReset=!1,this._layer=null,this.rebuild()}var e=t.prototype;return e.onChangeCamera=function(){this.regenShader(),this.resetMaterial()},e.calculateBoundsMad=function(){this.worldBoundsMul.x=1/this.worldBoundsSize.x,this.worldBoundsMul.y=1/this.worldBoundsSize.y,this.worldBoundsMul.z=1/this.worldBoundsSize.z,this.worldBoundsAdd.copy(this.worldBounds.center).mul(this.worldBoundsMul).mulScalar(-1),this.worldBoundsAdd.x+=.5,this.worldBoundsAdd.y+=.5,this.worldBoundsAdd.z+=.5},e.calculateWorldBounds=function(){if(this.node){if(this.prevWorldBoundsSize.copy(this.worldBoundsSize),this.prevWorldBoundsCenter.copy(this.worldBounds.center),!this.useCpu){(0===this.emitterShape?!this.emitterExtents.equals(this.prevEmitterExtents):!(this.emitterRadius===this.prevEmitterRadius))&&this.calculateLocalBounds()}var t=this.node.getWorldTransform();this.localSpace?this.worldBoundsNoTrail.copy(this.localBounds):this.worldBoundsNoTrail.setFromTransformedAabb(this.localBounds,t),this.worldBoundsTrail[0].add(this.worldBoundsNoTrail),this.worldBoundsTrail[1].add(this.worldBoundsNoTrail);var e=this.simTimeTotal;e>=this.timeToSwitchBounds&&(this.worldBoundsTrail[0].copy(this.worldBoundsTrail[1]),this.worldBoundsTrail[1].copy(this.worldBoundsNoTrail),this.timeToSwitchBounds=e+this.lifetime),this.worldBounds.copy(this.worldBoundsTrail[0]),this.worldBoundsSize.copy(this.worldBounds.halfExtents).mulScalar(2),this.localSpace?(this.meshInstance.aabb.setFromTransformedAabb(this.worldBounds,t),this.meshInstance.mesh.aabb.setFromTransformedAabb(this.worldBounds,t)):(this.meshInstance.aabb.copy(this.worldBounds),this.meshInstance.mesh.aabb.copy(this.worldBounds)),this.meshInstance._aabbVer=1-this.meshInstance._aabbVer,this.pack8&&this.calculateBoundsMad()}},e.resetWorldBounds=function(){this.node&&(this.worldBoundsNoTrail.setFromTransformedAabb(this.localBounds,this.localSpace?zt.IDENTITY:this.node.getWorldTransform()),this.worldBoundsTrail[0].copy(this.worldBoundsNoTrail),this.worldBoundsTrail[1].copy(this.worldBoundsNoTrail),this.worldBounds.copy(this.worldBoundsTrail[0]),this.worldBoundsSize.copy(this.worldBounds.halfExtents).mulScalar(2),this.prevWorldBoundsSize.copy(this.worldBoundsSize),this.prevWorldBoundsCenter.copy(this.worldBounds.center),this.simTimeTotal=0,this.timeToSwitchBounds=0)},e.calculateLocalBounds=function(){for(var t,e,i,n=Number.MAX_VALUE,s=Number.MAX_VALUE,r=Number.MAX_VALUE,a=-Number.MAX_VALUE,o=-Number.MAX_VALUE,h=-Number.MAX_VALUE,l=0,c=0,u=this.lifetime/this.precision,d=[this.qVelocity,this.qVelocity2],f=[this.qLocalVelocity,this.qLocalVelocity2],p=[0,0],m=[0,0],_=[0,0],g=[0,0],v=[0,0],y=0;y0||t.maxVertexTextures<=1||t.fragmentUniformsCount<64||t.forceCpuParticles||!t.extTextureFloat,this._destroyResources(),this.pack8=(this.pack8||!t.textureFloatRenderable)&&!this.useCpu,Bd=this.useCpu||this.pack8?4:2,this.useMesh=!1,this.mesh)&&(this.numParticles*this.mesh.vertexBuffer.numVertices>65535||(this.useMesh=!0));this.numParticlesPot=_t.nextPowerOfTwo(this.numParticles),this.rebuildGraphs(),this.calculateLocalBounds(),this.resetWorldBounds(),this.node&&(this.worldBounds.setFromTransformedAabb(this.localBounds,this.localSpace?zt.IDENTITY:this.node.getWorldTransform()),this.worldBoundsTrail[0].copy(this.worldBounds),this.worldBoundsTrail[1].copy(this.worldBounds),this.worldBoundsSize.copy(this.worldBounds.halfExtents).mulScalar(2),this.prevWorldBoundsSize.copy(this.worldBoundsSize),this.prevWorldBoundsCenter.copy(this.worldBounds.center),this.pack8&&this.calculateBoundsMad()),this.vbToSort=new Array(this.numParticles);for(var e=0;e=1&&(this.animTilesX>1||this.animTilesY>1)&&(this.colorMap&&this.colorMap!==this.defaultParamTexture||this.normalMap)},e.rebuildGraphs=function(){var t=this.precision,e=this.graphicsDevice;this.qLocalVelocity=this.localVelocityGraph.quantize(t),this.qVelocity=this.velocityGraph.quantize(t),this.qColor=this.colorGraph.quantizeClamped(t,0,1),this.qRotSpeed=this.rotationSpeedGraph.quantize(t),this.qScale=this.scaleGraph.quantize(t),this.qAlpha=this.alphaGraph.quantize(t),this.qRadialSpeed=this.radialSpeedGraph.quantize(t),this.qLocalVelocity2=this.localVelocityGraph2.quantize(t),this.qVelocity2=this.velocityGraph2.quantize(t),this.qColor2=this.colorGraph2.quantizeClamped(t,0,1),this.qRotSpeed2=this.rotationSpeedGraph2.quantize(t),this.qScale2=this.scaleGraph2.quantize(t),this.qAlpha2=this.alphaGraph2.quantize(t),this.qRadialSpeed2=this.radialSpeedGraph2.quantize(t);for(var i=0;i0&&t.setParameter("softening",1/(this.depthSoftening*this.depthSoftening*100)),this.stretch>0&&(t.cull=he),this._compParticleFaceParams()},e._compParticleFaceParams=function(){var t,e;if(0===this.orientation)t=new Float32Array([1,0,0]),e=new Float32Array([0,0,1]);else{var i;if(1===this.orientation)i=this.particleNormal.normalize();else i=(null===this.node?zt.IDENTITY:this.node.getWorldTransform()).transformVector(this.particleNormal).normalize();var n=new Et(1,0,0);1===Math.abs(n.dot(i))&&n.set(0,0,1);var s=(new Et).cross(i,n).normalize();n.cross(s,i).normalize(),t=new Float32Array([n.x,n.y,n.z]),e=new Float32Array([s.x,s.y,s.z])}this.material.setParameter("faceTangent",t),this.material.setParameter("faceBinorm",e)},e._allocate=function(t){var e=t*this.numParticleVerts,i=t*this.numParticleIndices;if(void 0===this.vertexBuffer||this.vertexBuffer.getNumVertices()!==e){if(this.useCpu){var n=[{semantic:He,components:4,type:6},{semantic:We,components:4,type:6},{semantic:Xe,components:4,type:6},{semantic:qe,components:1,type:6},{semantic:je,components:this.useMesh?4:2,type:6}],s=new sn(this.graphicsDevice,n);this.vertexBuffer=new Zi(this.graphicsDevice,s,e,1),this.indexBuffer=new Tr(this.graphicsDevice,1,i)}else{var r=[{semantic:He,components:4,type:6}];this.useMesh&&r.push({semantic:We,components:2,type:6});var a=new sn(this.graphicsDevice,r);this.vertexBuffer=new Zi(this.graphicsDevice,a,e,1),this.indexBuffer=new Tr(this.graphicsDevice,1,i)}var o,h,l,c=new Float32Array(this.vertexBuffer.lock());if(this.useMesh){h=(o=new Float32Array(this.mesh.vertexBuffer.lock())).length/this.mesh.vertexBuffer.numVertices;for(var u=0;uthis.endTime&&(this.onFinished&&this.onFinished(),this.meshInstance.visible=!1),this.meshInstance&&(this.meshInstance.drawOrder=this.drawOrder)},e._destroyResources=function(){this.particleTexIN&&(this.particleTexIN.destroy(),this.particleTexIN=null),this.particleTexOUT&&(this.particleTexOUT.destroy(),this.particleTexOUT=null),this.particleTexStart&&this.particleTexStart.destroy&&(this.particleTexStart.destroy(),this.particleTexStart=null),this.rtParticleTexIN&&(this.rtParticleTexIN.destroy(),this.rtParticleTexIN=null),this.rtParticleTexOUT&&(this.rtParticleTexOUT.destroy(),this.rtParticleTexOUT=null),this.internalTex0&&(this.internalTex0.destroy(),this.internalTex0=null),this.internalTex1&&(this.internalTex1.destroy(),this.internalTex1=null),this.internalTex2&&(this.internalTex2.destroy(),this.internalTex2=null),this.internalTex3&&(this.internalTex3.destroy(),this.internalTex3=null),this.colorParam&&(this.colorParam.destroy(),this.colorParam=null),this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBuffer=void 0),this.indexBuffer&&(this.indexBuffer.destroy(),this.indexBuffer=void 0),this.material&&(this.material.destroy(),this.material=null)},e.destroy=function(){this.camera=null,this._destroyResources()},y(t,[{key:"defaultParamTexture",get:function(){var t=this;return Yd.get(this.graphicsDevice,(function(){for(var e=16,i=new Float32Array(1024),n=0;n0&&this.material.transparent===e&&(this.mesh.setPositions(this.positions),this.mesh.setColors(this.colors),this.mesh.update(1,!1),this.meshInstance||(this.meshInstance=new Eh(this.mesh,this.material,Jd)),this.positions.length=0,this.colors.length=0,t.push(this.meshInstance))},t}(),ef=function(){function t(t){this.device=t,this.map=new Map}var e=t.prototype;return e.getBatch=function(t,e){var i=this.map.get(t);return i||(i=new tf(this.device,t,e),this.map.set(t,i)),i},e.onPreRender=function(t,e){this.map.forEach((function(i){i.onPreRender(t,e)}))},t}(),nf=[],sf=function(){function t(t){this.device=t,this.quadMesh=null,this.textureShader=null,this.depthTextureShader=null,this.cubeLocalPos=null,this.cubeWorldPos=null,this.batchesMap=new Map,this.allBatches=new Set,this.updatedLayers=new Set,this._materialDepth=null,this._materialNoDepth=null,this.layerMeshInstances=new Map}var e=t.prototype;return e.createMaterial=function(t){var e=new Ko;return e.vertexColors=!0,e.blendType=2,e.depthTest=t,e.update(),e},e.getBatch=function(t,e){var i=this.batchesMap.get(t);i||(i=new ef(this.device),this.batchesMap.set(t,i)),this.allBatches.add(i);var n=e?this.materialDepth:this.materialNoDepth;return i.getBatch(n,t)},e.getShader=function(t,e){if(!this[t]){this[t]=Po(this.device,"\n\t\t\t\tattribute vec2 vertex_position;\n\t\t\t\tuniform mat4 matrix_model;\n\t\t\t\tvarying vec2 uv0;\n\t\t\t\tvoid main(void) {\n\t\t\t\t\tgl_Position = matrix_model * vec4(vertex_position, 0, 1);\n\t\t\t\t\tuv0 = vertex_position.xy + 0.5;\n\t\t\t\t}\n\t\t\t",e,"DebugShader:"+t)}return this[t]},e.getTextureShader=function(){return this.getShader("textureShader","\n\t\t\tvarying vec2 uv0;\n\t\t\tuniform sampler2D colorMap;\n\t\t\tvoid main (void) {\n\t\t\t\tgl_FragColor = vec4(texture2D(colorMap, uv0).xyz, 1);\n\t\t\t}\n\t\t")},e.getUnfilterableTextureShader=function(){return this.getShader("textureShaderUnfilterable","\n\t\t\tvarying vec2 uv0;\n\t\t\tuniform highp sampler2D colorMap;\n\t\t\tvoid main (void) {\n\t\t\t\tivec2 uv = ivec2(uv0 * textureSize(colorMap, 0));\n\t\t\t\tgl_FragColor = vec4(texelFetch(colorMap, uv, 0).xyz, 1);\n\t\t\t}\n\t\t")},e.getDepthTextureShader=function(){return this.getShader("depthTextureShader","\n\t\t\t"+wo.screenDepthPS+"\n\t\t\tvarying vec2 uv0;\n\t\t\tvoid main() {\n\t\t\t\tfloat depth = getLinearScreenDepth(uv0) * camera_params.x;\n\t\t\t\tgl_FragColor = vec4(vec3(depth), 1.0);\n\t\t\t}\n\t\t")},e.getQuadMesh=function(){return this.quadMesh||(this.quadMesh=new no(this.device),this.quadMesh.setPositions([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),this.quadMesh.update(Ce)),this.quadMesh},e.drawMesh=function(t,e,i,n,s){if(!n){var r=this.getGraphNode(e);n=new Eh(i,t,r)}var a=this.layerMeshInstances.get(s);a||(a=[],this.layerMeshInstances.set(s,a)),a.push(n)},e.drawWireAlignedBox=function(t,e,i,n,s){nf.push(t.x,t.y,t.z,t.x,e.y,t.z,t.x,e.y,t.z,e.x,e.y,t.z,e.x,e.y,t.z,e.x,t.y,t.z,e.x,t.y,t.z,t.x,t.y,t.z,t.x,t.y,e.z,t.x,e.y,e.z,t.x,e.y,e.z,e.x,e.y,e.z,e.x,e.y,e.z,e.x,t.y,e.z,e.x,t.y,e.z,t.x,t.y,e.z,t.x,t.y,t.z,t.x,t.y,e.z,t.x,e.y,t.z,t.x,e.y,e.z,e.x,e.y,t.z,e.x,e.y,e.z,e.x,t.y,t.z,e.x,t.y,e.z),this.getBatch(s,n).addLinesArrays(nf,i),nf.length=0},e.drawWireSphere=function(t,e,i,n,s,r){for(var a=2*Math.PI/n,o=0,h=0;hi){this._time=this.looping?0:i;for(var n=0;n=0?1:-1,l=0;l=0;m+=h){var _=d[m],g=d[m+1];if(_.time<=this._time&&g.time>=this._time){var v=(this._time-_.time)/(g.time-_.time);f._pos.lerp(_.position,g.position,v),f._quat.slerp(_.rotation,g.rotation,v),f._scale.lerp(_.scale,g.scale,v),f._written=!0,this._currKeyIndices[u]=m,p=!0;break}}(1===d.length||!p&&0===this._time&&this.looping)&&(f._pos.copy(d[0].position),f._quat.copy(d[0].rotation),f._scale.copy(d[0].scale),f._written=!0)}}}},e.blend=function(t,e,i){for(var n=this._interpolatedKeys.length,s=0;s 0.5) {\n\t\tif (dAtten > 0.00001) {\n\t\t\tdirLm.xyz = dirLm.xyz * 2.0 - vec3(1.0);\n\t\t\tdAtten = saturate(dAtten);\n\t\t\tgl_FragColor.rgb = normalize(dLightDirNormW.xyz*dAtten + dirLm.xyz*dirLm.w) * 0.5 + vec3(0.5);\n\t\t\tgl_FragColor.a = dirLm.w + dAtten;\n\t\t\tgl_FragColor.a = max(gl_FragColor.a, 1.0 / 255.0);\n\t\t} else {\n\t\t\tgl_FragColor = dirLm;\n\t\t}\n\t} else {\n\t\tgl_FragColor.rgb = dirLm.xyz;\n\t\tgl_FragColor.a = max(dirLm.w, dAtten > 0.00001? (1.0/255.0) : 0.0);\n\t}\n",bakeLmEndPS:"\n#ifdef LIGHTMAP_RGBM\n\tgl_FragColor.rgb = dDiffuseLight;\n\tgl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.5));\n\tgl_FragColor.rgb /= 8.0;\n\tgl_FragColor.a = clamp( max( max( gl_FragColor.r, gl_FragColor.g ), max( gl_FragColor.b, 1.0 / 255.0 ) ), 0.0,1.0 );\n\tgl_FragColor.a = ceil(gl_FragColor.a * 255.0) / 255.0;\n\tgl_FragColor.rgb /= gl_FragColor.a;\n#else\n\tgl_FragColor = vec4(dDiffuseLight, 1.0);\n#endif\n",dilatePS:"\nvarying vec2 vUv0;\nuniform sampler2D source;\nuniform vec2 pixelOffset;\nvoid main(void) {\n\tvec4 c = texture2D(source, vUv0);\n\tc = c.a>0.0? c : texture2D(source, vUv0 - pixelOffset);\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(0, -pixelOffset.y));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(pixelOffset.x, -pixelOffset.y));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(-pixelOffset.x, 0));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(pixelOffset.x, 0));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(-pixelOffset.x, pixelOffset.y));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(0, pixelOffset.y));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + pixelOffset);\n\tgl_FragColor = c;\n}\n",bilateralDeNoisePS:"\nfloat normpdf3(in vec3 v, in float sigma) {\n\treturn 0.39894 * exp(-0.5 * dot(v, v) / (sigma * sigma)) / sigma;\n}\nvec3 decodeRGBM(vec4 rgbm) {\n\tvec3 color = (8.0 * rgbm.a) * rgbm.rgb;\n\treturn color * color;\n}\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\nvec4 encodeRGBM(vec3 color) {\n\tvec4 encoded;\n\tencoded.rgb = pow(color.rgb, vec3(0.5));\n\tencoded.rgb *= 1.0 / 8.0;\n\tencoded.a = saturate( max( max( encoded.r, encoded.g ), max( encoded.b, 1.0 / 255.0 ) ) );\n\tencoded.a = ceil(encoded.a * 255.0) / 255.0;\n\tencoded.rgb /= encoded.a;\n\treturn encoded;\n}\n#define MSIZE 15\nvarying vec2 vUv0;\nuniform sampler2D source;\nuniform vec2 pixelOffset;\nuniform vec2 sigmas;\nuniform float bZnorm;\nuniform float kernel[MSIZE];\nvoid main(void) {\n\t\n\tvec4 pixelRgbm = texture2D(source, vUv0);\n\tif (pixelRgbm.a <= 0.0) {\n\t\tgl_FragColor = pixelRgbm;\n\t\treturn ;\n\t}\n\tfloat sigma = sigmas.x;\n\tfloat bSigma = sigmas.y;\n\tvec3 pixelHdr = decodeRGBM(pixelRgbm);\n\tvec3 accumulatedHdr = vec3(0.0);\n\tfloat accumulatedFactor = 0.0;\n\tconst int kSize = (MSIZE-1)/2;\n\tfor (int i = -kSize; i <= kSize; ++i) {\n\t\tfor (int j = -kSize; j <= kSize; ++j) {\n\t\t\t\n\t\t\tvec2 coord = vUv0 + vec2(float(i), float(j)) * pixelOffset;\n\t\t\tvec4 rgbm = texture2D(source, coord);\n\t\t\tif (rgbm.a > 0.0) {\n\t\t\t\tvec3 hdr = decodeRGBM(rgbm);\n\t\t\t\tfloat factor = kernel[kSize + j] * kernel[kSize + i];\n\t\t\t\tfactor *= normpdf3(hdr - pixelHdr, bSigma) * bZnorm;\n\t\t\t\taccumulatedHdr += factor * hdr;\n\t\t\t\taccumulatedFactor += factor;\n\t\t\t}\n\t\t}\n\t}\n\tgl_FragColor = encodeRGBM(accumulatedHdr / accumulatedFactor);\n}\n"},Tf="FILL_WINDOW",Af="KEEP_ASPECT",Cf="AUTO",Ef="FIXED";function Mf(){return Sf}function Pf(t){Sf=t,Ja.set(null==t?void 0:t.graphicsDevice)}var Rf=function(){function t(){}return t.push=function(e,i){i&&t._types.length>0?console.assert("Script Ordering Error. Contact support@playcanvas.com"):t._types.push(e)},t}();Rf._types=[];var If=!1,Lf=!1,Df={app:null,create:function(t,e){if(If){var i=e(Df.app);i._pcScriptName=t,Rf.push(i,If),this.fire("created",t,e)}},attribute:function(t,e,i,n){},createLoadingScreen:function(t){Lf||(Lf=!0,t(Mf()))}};Object.defineProperty(Df,"legacy",{get:function(){return If},set:function(t){If=t}}),R.attach(Df);var Of=function(){function t(){this.renderPasses=[],this.renderTargetMap=new Map}var e=t.prototype;return e.addRenderPass=function(t){t.frameUpdate();for(var e=this.renderPasses,i=t.beforePasses,n=0;n=0&&t<=1?0:1})),Vf(["fr","pt"],(function(t){return t>=0&&t<2?0:1})),Vf(["da"],(function(t){return 1===t||!Number.isInteger(t)&&t>=0&&t<=1?0:1})),Vf(["de","en","it","el","es","tr","fi","sv","nb","no","ur"],(function(t){return 1===t?0:1})),Vf(["ru","uk"],(function(t){if(Number.isInteger(t)){var e=t%10,i=t%100;if(1===e&&11!==i)return 0;if(e>=2&&e<=4&&(i<12||i>14))return 1;if(0===e||e>=5&&e<=9||i>=11&&i<=14)return 2}return 3})),Vf(["pl"],(function(t){if(Number.isInteger(t)){if(1===t)return 0;var e=t%10,i=t%100;if(e>=2&&e<=4&&(i<12||i>14))return 1;if(e>=0&&e<=1||e>=5&&e<=9||i>=12&&i<=14)return 2}return 3})),Vf(["ar"],(function(t){if(0===t)return 0;if(1===t)return 1;if(2===t)return 2;if(Number.isInteger(t)){var e=t%100;if(e>=3&&e<=10)return 3;if(e>=11&&e<=99)return 4}return 5}));var Wf=zf[Gf(Uf)];function Xf(t){return zf[t]||Wf}var qf,jf=new RegExp("^\\s*(?:(?:[a-z]+[a-z0-9\\-\\+\\.]*:)?//|data:|blob:)","i"),Yf=function(){function t(t,e,i,n,s,r){void 0===t&&(t=""),void 0===e&&(e=""),void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=null),void 0===r&&(r=null),this.url=t,this.filename=e,this.hash=i,this.size=n,this.opt=s,this.contents=r}return t.prototype.equals=function(t){return this.url===t.url&&this.filename===t.filename&&this.hash===t.hash&&this.size===t.size&&this.opt===t.opt&&this.contents===t.contents},t}(),Kf=-1,Zf={pvr:"extCompressedTexturePVRTC",dxt:"extCompressedTextureS3TC",etc2:"extCompressedTextureETC",etc1:"extCompressedTextureETC1",basis:"canvas"},Qf=["pvr","dxt","etc2","etc1","basis"],$f=function(t){function e(e,i,n,s,r){var a;return(a=t.call(this)||this)._id=Kf--,a._name=e||"",a.type=i,a.tags=new ut(w(a)),a._preload=!1,a._file=null,a._data=s||{},a.options=r||{},a._resources=[],a._i18n={},a.loaded=!1,a.loading=!1,a.registry=null,n&&(a.file=n),a}S(e,t);var i=e.prototype;return i.getFileUrl=function(){var t=this.file;if(!t||!t.url)return null;var e=t.url;if(this.registry&&this.registry.prefix&&!jf.test(e)&&(e=this.registry.prefix+e),"script"!==this.type&&t.hash){var i=-1!==e.indexOf("?")?"&":"?";e+=i+"t="+t.hash}return e},i.getAbsoluteUrl=function(t){if(t.startsWith("blob:")||t.startsWith("data:"))return t;var e=L.getDirectory(this.file.url);return L.join(e,t)},i.getLocalizedAssetId=function(t){return t=Hf(t,this._i18n),this._i18n[t]||null},i.addLocalizedAssetId=function(t,e){this._i18n[t]=e,this.fire("add:localized",t,e)},i.removeLocalizedAssetId=function(t){var e=this._i18n[t];e&&(delete this._i18n[t],this.fire("remove:localized",t,e))},i.ready=function(t,e){e=e||this,this.loaded?t.call(e,this):this.once("load",(function(i){t.call(e,i)}))},i.reload=function(){this.loaded&&(this.loaded=!1,this.registry.load(this))},i.unload=function(){if(this.loaded||0!==this._resources.length){this.fire("unload",this),this.registry.fire("unload:"+this.id,this);var t=this._resources;this.resources=[],this.loaded=!1,this.file&&this.registry._loader.clearCache(this.getFileUrl(),this.type);for(var e=0;e0,maxRetries:n},e)},y(e,[{key:"id",get:function(){return this._id},set:function(t){this._id=t}},{key:"name",get:function(){return this._name},set:function(t){if(this._name!==t){var e=this._name;this._name=t,this.fire("name",this,this._name,e)}}},{key:"file",get:function(){return this._file},set:function(t){var e=this;if(t&&t.variants&&-1!==["texture","textureatlas","bundle"].indexOf(this.type)){var i,n=(null==(i=this.registry)||null==(i=i._loader)?void 0:i._app)||Mf(),s=null==n?void 0:n.graphicsDevice;if(s)for(var r=function(){var i=Qf[a];if(t.variants[i]&&s[Zf[i]])return t=t.variants[i],0;if(n.enableBundles){var r=n.bundles.listBundlesForAsset(e);if(r&&r.find((function(t){var e;return null==t||null==(e=t.file)?void 0:e.variants[i]})))return 0}},a=0,o=Qf.length;a=s)throw new Error("Invalid PAX header data format.");var l=parseInt(e.decode(new Uint8Array(t,i+a,h-a)),10),c=e.decode(new Uint8Array(t,i+h+1,l-(h-a)-2)).split("=");if(2!==c.length)throw new Error("Invalid PAX header data format.");0===c[1].length&&(c[1]=null),o.push({name:c[0],value:c[1]}),a+=l}return new n(o)},n.prototype.applyHeader=function(t){for(var e=0;e0&&(r=p.trim()+r.trim())}var m={name:r,start:l,size:o,url:c};return this._globalPaxHeader&&this._globalPaxHeader.applyHeader(m),this._paxHeader&&(this._paxHeader.applyHeader(m),this._paxHeader=null),m},s.prototype.untar=function(t){if(!e)return console.error("Cannot untar because TextDecoder interface is not available for this platform."),[];for(var i=[];this._hasNext();){var n=this._readNextFile();n&&(t&&n.name&&(n.name=t+n.name),i.push(n))}return i},t&&(self.onmessage=function(t){var e=t.data.id;try{var i=new s(t.data.arrayBuffer).untar(t.data.prefix);postMessage({id:e,files:i,arrayBuffer:t.data.arrayBuffer},[t.data.arrayBuffer])}catch(t){postMessage({id:e,error:t.toString()})}})}var rp=null;var ap=function(){function t(t){this._requestId=0,this._pendingRequests={},this._filenamePrefix=t,this._worker=new Worker(function(){if(!rp){var t="("+sp.toString()+")(true)\n\n",e=new Blob([t],{type:"application/javascript"});rp=URL.createObjectURL(e)}return rp}()),this._worker.addEventListener("message",this._onMessage.bind(this))}var e=t.prototype;return e._onMessage=function(t){var e=t.data.id;if(this._pendingRequests[e]){var i=this._pendingRequests[e];if(delete this._pendingRequests[e],t.data.error)i(t.data.error);else{for(var n=t.data.arrayBuffer,s=0,r=t.data.files.length;s0},e.destroy=function(){this._worker&&(this._worker.terminate(),this._worker=null,this._pendingRequests=null)},t}();sp();var op=function(){function t(t){this.handlerType="bundle",this._assets=t.assets,this._worker=null,this.maxRetries=0}var e=t.prototype;return e.load=function(t,e){"string"==typeof t&&(t={load:t,original:t});var i=this;Ca.get(t.load,{responseType:Aa.ResponseType.ARRAY_BUFFER,retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(n,s){if(n)e("Error loading bundle resource "+t.original+": "+n);else try{i._untar(s,e)}catch(i){e("Error loading bundle resource "+t.original+": "+i)}}))},e._untar=function(t,e){var i=this;if(G.workers)i._worker||(i._worker=new ap(i._assets.prefix)),i._worker.untar(t,(function(t,n){e(t,n),i._worker.hasPendingRequests()||(i._worker.destroy(),i._worker=null)}));else{var n=new qf(t).untar(i._assets.prefix);e(null,n)}},e.open=function(t,e){return new np(e)},e.patch=function(t,e){},t}(),hp=function(){function t(t){this._handlers={},this._requests={},this._cache={},this._app=t}var e=t.prototype;return e.addHandler=function(t,e){this._handlers[t]=e,e._loader=this},e.removeHandler=function(t){delete this._handlers[t]},e.getHandler=function(t){return this._handlers[t]},t.makeKey=function(t,e){return t+"-"+e},e.load=function(e,i,n,s){var r=this._handlers[i];if(r)if(e){var a=t.makeKey(e,i);if(void 0!==this._cache[a])n(null,this._cache[a]);else if(this._requests[a])this._requests[a].push(n);else{this._requests[a]=[n];var o=this,h=function(t,e){t?o._onFailure(a,t):r.load(e,(function(t,i,n){if(o._requests[a])if(t)o._onFailure(a,t);else try{o._onSuccess(a,r.open(e.original,i,s),n)}catch(t){o._onFailure(a,t)}}),s)},l=e.split("?")[0];if(this._app.enableBundles&&this._app.bundles.hasUrl(l)){if(!this._app.bundles.canLoadUrl(l))return void h("Bundle for "+e+" not loaded yet");this._app.bundles.loadUrl(l,(function(t,e){h(t,{load:e,original:l})}))}else h(null,{load:e,original:s&&s.file.filename||e})}}else this._loadNull(r,n,s);else n("No resource handler for asset type: '"+i+"' when loading ["+e+"]")},e._loadNull=function(t,e,i){t.load(null,(function(n,s,r){if(n)e(n);else try{e(null,t.open(null,s,i),r)}catch(t){e(t)}}),i)},e._onSuccess=function(t,e,i){null!==e?this._cache[t]=e:delete this._cache[t];for(var n=0;n0&&this.loader.enableRetry(t.maxAssetRetries),t.useDevicePixelRatio||(t.useDevicePixelRatio=t.use_device_pixel_ratio),t.resolutionMode||(t.resolutionMode=t.resolution_mode),t.fillMode||(t.fillMode=t.fill_mode),this._width=t.width,this._height=t.height,t.useDevicePixelRatio&&(this.graphicsDevice.maxPixelRatio=window.devicePixelRatio),this.setCanvasResolution(t.resolutionMode,this._width,this._height),this.setCanvasFillMode(t.fillMode,this._width,this._height),t.layers&&t.layerOrder){var i=new zu("application"),n={};for(var s in t.layers){var r=t.layers[s];r.id=parseInt(s,10),r.enabled=1!==r.id,n[s]=new Bu(r)}for(var a=0,o=t.layerOrder.length;a0,d.tags.add(u.tags),u.i18n)for(var f in u.i18n)d.addLocalizedAssetId(f,u.i18n[f]);this.assets.add(d)}},n._getScriptReferences=function(t){var e=[];t.settings.priority_scripts&&(e=t.settings.priority_scripts);for(var i=[],n={},s=0;sn._timeToCountFrames?(n.fps=n._fpsAccum,n._fpsAccum=0,n._timeToCountFrames=t+1e3):n._fpsAccum++,this.stats.drawCalls.total=this.graphicsDevice._drawCallsPerFrame,this.graphicsDevice._drawCallsPerFrame=0},n._fillFrameStats=function(){var t=this.stats.frame;t.cameras=this.renderer._camerasRendered,t.materials=this.renderer._materialSwitches,t.shaders=this.graphicsDevice._shaderSwitchesPerFrame,t.shadowMapUpdates=this.renderer._shadowMapUpdates,t.shadowMapTime=this.renderer._shadowMapTime,t.depthMapTime=this.renderer._depthMapTime,t.forwardTime=this.renderer._forwardTime;var e=this.graphicsDevice._primsPerFrame;t.triangles=e[4]/3+Math.max(e[Ce]-2,0)+Math.max(e[6]-2,0),t.cullTime=this.renderer._cullTime,t.sortTime=this.renderer._sortTime,t.skinTime=this.renderer._skinTime,t.morphTime=this.renderer._morphTime,t.lightClusters=this.renderer._lightClusters,t.lightClustersTime=this.renderer._lightClustersTime,t.otherPrimitives=0;for(var i=0;ii/n?e=(t=i)/s:t=(e=n)*s}else this._fillMode===Tf&&(t=i,e=n);return this.graphicsDevice.canvas.style.width=t+"px",this.graphicsDevice.canvas.style.height=e+"px",this.updateCanvasSize(),{width:t,height:e}}},n.updateCanvasSize=function(){var t;if(this._allowResize&&(null==(t=this.xr)||!t.active)&&this._resolutionMode===Cf){var e=this.graphicsDevice.canvas;this.graphicsDevice.resizeCanvas(e.clientWidth,e.clientHeight)}},n.onLibrariesLoaded=function(){this._librariesLoaded=!0,this.systems.rigidbody&&this.systems.rigidbody.onLibraryLoaded()},n.applySceneSettings=function(t){var e;if(this.systems.rigidbody&&"undefined"!=typeof Ammo){var i=t.physics.gravity;this.systems.rigidbody.gravity.set(i[0],i[1],i[2])}this.scene.applySettings(t),t.render.hasOwnProperty("skybox")&&(t.render.skybox?(e=this.assets.get(t.render.skybox))?this.setSkybox(e):this.assets.once("add:"+t.render.skybox,this.setSkybox,this):this.setSkybox(null))},n.setAreaLightLuts=function(t,e){t&&e&&Bf.set(this.graphicsDevice,t,e)},n.setSkybox=function(t){var e=this;if(t!==this._skyboxAsset){var i=function(){e.setSkybox(null)},n=function(){e.scene.setSkybox(e._skyboxAsset?e._skyboxAsset.resources:null)};this._skyboxAsset&&(this.assets.off("load:"+this._skyboxAsset.id,n,this),this.assets.off("remove:"+this._skyboxAsset.id,i,this),this._skyboxAsset.off("change",n,this)),this._skyboxAsset=t,this._skyboxAsset&&(this.assets.on("load:"+this._skyboxAsset.id,n,this),this.assets.once("remove:"+this._skyboxAsset.id,i,this),this._skyboxAsset.on("change",n,this),0!==this.scene.skyboxMip||this._skyboxAsset.loadFaces||(this._skyboxAsset.loadFaces=!0),this.assets.load(this._skyboxAsset)),n()}},n._firstBake=function(){var t;null==(t=this.lightmapper)||t.bake(null,this.scene.lightmapMode)},n._firstBatch=function(){var t;null==(t=this.batcher)||t.generate()},n._processTimestamp=function(t){return t},n.drawLine=function(t,e,i,n,s){this.scene.drawLine(t,e,i,n,s)},n.drawLines=function(t,e,i,n){void 0===i&&(i=!0),void 0===n&&(n=this.scene.defaultDrawLayer),this.scene.drawLines(t,e,i,n)},n.drawLineArrays=function(t,e,i,n){void 0===i&&(i=!0),void 0===n&&(n=this.scene.defaultDrawLayer),this.scene.drawLineArrays(t,e,i,n)},n.drawWireSphere=function(t,e,i,n,s,r){void 0===i&&(i=gt.WHITE),void 0===n&&(n=20),void 0===s&&(s=!0),void 0===r&&(r=this.scene.defaultDrawLayer),this.scene.immediate.drawWireSphere(t,e,i,n,s,r)},n.drawWireAlignedBox=function(t,e,i,n,s){void 0===i&&(i=gt.WHITE),void 0===n&&(n=!0),void 0===s&&(s=this.scene.defaultDrawLayer),this.scene.immediate.drawWireAlignedBox(t,e,i,n,s)},n.drawMeshInstance=function(t,e){void 0===e&&(e=this.scene.defaultDrawLayer),this.scene.immediate.drawMesh(null,null,null,t,e)},n.drawMesh=function(t,e,i,n){void 0===n&&(n=this.scene.defaultDrawLayer),this.scene.immediate.drawMesh(e,i,t,null,n)},n.drawQuad=function(t,e,i){void 0===i&&(i=this.scene.defaultDrawLayer),this.scene.immediate.drawMesh(e,t,this.scene.immediate.getQuadMesh(),null,i)},n.drawTexture=function(t,e,i,n,s,r,a,o){if(void 0===a&&(a=this.scene.defaultDrawLayer),void 0===o&&(o=!0),!1!==o||this.graphicsDevice.isWebGPU){var h=new zt;h.setTRS(new Et(t,e,0),Vt.IDENTITY,new Et(i,-n,0)),r||((r=new Yo).cull=he,r.setParameter("colorMap",s),r.shader=o?this.scene.immediate.getTextureShader():this.scene.immediate.getUnfilterableTextureShader(),r.update()),this.drawQuad(h,r,a)}},n.drawDepthTexture=function(t,e,i,n,s){void 0===s&&(s=this.scene.defaultDrawLayer);var r=new Yo;r.cull=he,r.shader=this.scene.immediate.getDepthTextureShader(),r.update(),this.drawTexture(t,e,i,n,null,r,s)},n.destroy=function(){var t,e,n,s;if(this._inFrameUpdate)this._destroyRequested=!0;else{var r=this.graphicsDevice.canvas.id;this.fire("destroy",this),this.off("librariesloaded"),"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this._visibilityChangeHandler,!1),document.removeEventListener("mozvisibilitychange",this._visibilityChangeHandler,!1),document.removeEventListener("msvisibilitychange",this._visibilityChangeHandler,!1),document.removeEventListener("webkitvisibilitychange",this._visibilityChangeHandler,!1)),this._visibilityChangeHandler=null,this.root.destroy(),this.root=null,this.mouse&&(this.mouse.off(),this.mouse.detach(),this.mouse=null),this.keyboard&&(this.keyboard.off(),this.keyboard.detach(),this.keyboard=null),this.touch&&(this.touch.off(),this.touch.detach(),this.touch=null),this.elementInput&&(this.elementInput.detach(),this.elementInput=null),this.gamepads&&(this.gamepads.destroy(),this.gamepads=null),this.controller&&(this.controller=null),this.systems.destroy(),this.scene.layers&&this.scene.layers.destroy();for(var a=this.assets.list(),o=0;o0){var n=i.bakeArea;Dc(Ap,t,e),Ap.mulScalar(.5*n),i._node.rotateLocal(Ap.x,0,Ap.y)}i._node.getWorldTransform();var s=this.scene.gammaCorrection?2.2:1,r=Math.pow(this.intensity,s);i.intensity=Math.pow(r/e,1/s)},y(e,[{key:"numVirtualLights",get:function(){return 0===this.light.type?this.light.bakeNumSamples:1}}]),e}(Tp),Ep=new Et,Mp=function(t){function e(e){var i=new fp("AmbientLight");return i.addComponent("light",{type:"directional",affectDynamic:!0,affectLightmapped:!1,bake:!0,bakeNumSamples:e.ambientBakeNumSamples,castShadows:!0,normalOffsetBias:.05,shadowBias:.2,shadowDistance:1,shadowResolution:2048,shadowType:0,color:gt.WHITE,intensity:1,bakeDir:!1}),t.call(this,e,i.light.light)||this}return S(e,t),e.prototype.prepareVirtualLight=function(t,e){Oc(Ep,t,e,0,this.scene.ambientBakeSpherePart),this.light._node.lookAt(Ep.mulScalar(-1)),this.light._node.rotateLocal(90,0,0);var i=this.scene.gammaCorrection?2.2:1,n=2*Math.PI*this.scene.ambientBakeSpherePart,s=Math.pow(n,i);this.light.intensity=Math.pow(s/e,1/i)},y(e,[{key:"numVirtualLights",get:function(){return this.light.bakeNumSamples}}]),e}(Tp),Pp=function(){function t(t,e){void 0===e&&(e=null),this.node=t,this.component=t.render||t.model,e=e||this.component.meshInstances,this.store(),this.meshInstances=e,this.bounds=null,this.renderTargets=[]}var e=t.prototype;return e.store=function(){this.castShadows=this.component.castShadows},e.restore=function(){this.component.castShadows=this.castShadows},t}(),Rp=function(){function t(t){this.device=t,this.shaderDilate=Po(t,wo.fullscreenQuadVS,wf.dilatePS,"lmDilate"),this.constantTexSource=t.scope.resolve("source"),this.constantPixelOffset=t.scope.resolve("pixelOffset"),this.pixelOffset=new Float32Array(2),this.shaderDenoise=null,this.sigmas=null,this.constantSigmas=null,this.kernel=null}var e=t.prototype;return e.setSourceTexture=function(t){this.constantTexSource.setValue(t)},e.prepare=function(t,e){this.pixelOffset[0]=1/t,this.pixelOffset[1]=1/e,this.constantPixelOffset.setValue(this.pixelOffset)},e.prepareDenoise=function(t,e){this.shaderDenoise||(this.shaderDenoise=Po(this.device,wo.fullscreenQuadVS,wf.bilateralDeNoisePS,"lmBilateralDeNoise"),this.sigmas=new Float32Array(2),this.constantSigmas=this.device.scope.resolve("sigmas"),this.constantKernel=this.device.scope.resolve("kernel[0]"),this.bZnorm=this.device.scope.resolve("bZnorm")),this.sigmas[0]=t,this.sigmas[1]=e,this.constantSigmas.setValue(this.sigmas),this.evaluateDenoiseUniforms(t,e)},e.evaluateDenoiseUniforms=function(t,e){function i(t,e){return.39894*Math.exp(-.5*t*t/(e*e))/e}this.kernel=this.kernel||new Float32Array(15);for(var n=this.kernel,s=Math.floor(7),r=0;r<=s;++r){var a=i(r,t);n[s+r]=a,n[s-r]=a}this.constantKernel.setValue(this.kernel);var o=1/i(0,e);this.bZnorm.setValue(o)},t}(),Ip=new Et,Lp=function(){function t(t,e,i,n,s){this.device=t,this.root=e,this.scene=i,this.renderer=n,this.assets=s,this.shadowMapCache=n.shadowMapCache,this._tempSet=new Set,this._initCalled=!1,this.passMaterials=[],this.ambientAOMaterial=null,this.fog="",this.ambientLight=new gt,this.renderTargets=new Map,this.stats={renderPasses:0,lightmapCount:0,totalRenderTime:0,forwardTime:0,fboTime:0,shadowMapTime:0,compileTime:0,shadersLinked:0}}var e=t.prototype;return e.destroy=function(){var t;vh.decRef(this.blackTex),this.blackTex=null,vh.destroy(),this.device=null,this.root=null,this.scene=null,this.renderer=null,this.assets=null,null==(t=this.camera)||t.destroy(),this.camera=null},e.initBake=function(t){if(!this._initCalled){this._initCalled=!0,this.lightmapFilters=new Rp(t),this.constantBakeDir=t.scope.resolve("bakeDir"),this.materials=[],this.blackTex=new Us(this.device,{width:4,height:4,format:7,type:ai,name:"lightmapBlack"}),vh.incRef(this.blackTex);var e=new Zh;e.clearColor.set(0,0,0,0),e.clearColorBuffer=!0,e.clearDepthBuffer=!1,e.clearStencilBuffer=!1,e.frustumCulling=!1,e.projection=1,e.aspectRatio=1,e.node=new _h,this.camera=e}if(this.scene.clusteredLightingEnabled){var i=new Ku(t.supportsAreaLights,t.maxTextureSize,(function(){}));this.lightingParams=i;var n=this.scene.lighting;i.shadowsEnabled=n.shadowsEnabled,i.shadowAtlasResolution=n.shadowAtlasResolution,i.cookiesEnabled=n.cookiesEnabled,i.cookieAtlasResolution=n.cookieAtlasResolution,i.areaLightsEnabled=n.areaLightsEnabled,i.cells=new Et(3,3,3),i.maxLightsPerCell=4,this.worldClusters=new Pl(t),this.worldClusters.name="ClusterLightmapper"}},e.finishBake=function(t){function e(t){vh.decRef(t.colorBuffer),t.destroy()}this.materials=[],this.renderTargets.forEach((function(t){e(t)})),this.renderTargets.clear(),t.forEach((function(t){t.renderTargets.forEach((function(t){e(t)})),t.renderTargets.length=0})),this.ambientAOMaterial=null,this.worldClusters&&(this.worldClusters.destroy(),this.worldClusters=null)},e.createMaterialForPass=function(t,e,i,n){var s=new vu;if(s.name="lmMaterial-pass:"+i+"-ambient:"+n,s.chunks.APIVersion=Bi,s.chunks.transformVS="#define UV1LAYOUT\n"+wo.transformVS,0===i){var r=wf.bakeLmEndPS;n?r="\n dDiffuseLight = ((dDiffuseLight - 0.5) * max("+e.ambientBakeOcclusionContrast.toFixed(1)+" + 1.0, 0.0)) + 0.5;\n dDiffuseLight += vec3("+e.ambientBakeOcclusionBrightness.toFixed(1)+");\n dDiffuseLight = saturate(dDiffuseLight);\n dDiffuseLight *= dAmbientLight;\n "+r:(s.ambient=new gt(0,0,0),s.ambientTint=!0),s.chunks.basePS=wo.basePS+(7===e.lightmapPixelFormat?"\n#define LIGHTMAP_RGBM\n":""),s.chunks.endPS=r,s.lightMap=this.blackTex}else s.chunks.basePS=wo.basePS+"\nuniform sampler2D texture_dirLightMap;\nuniform float bakeDir;\n",s.chunks.endPS=wf.bakeDirLmEndPS;return s.chunks.outputAlphaPS="\n",s.chunks.outputAlphaOpaquePS="\n",s.chunks.outputAlphaPremulPS="\n",s.cull=he,s.forceUv1=!0,s.update(),s},e.createMaterials=function(t,e,i){for(var n=0;n0&&e.push(new Pp(t,l))}}for(var d=0;d0){this.renderer.shadowRenderer.frameUpdate();var c=1===e?2:1;this.setLightmapping(o,!1,c),this.initBake(i),this.bakeInternal(c,o,h);var u=64;1===e&&(u|=Xa),this.scene.ambientBake&&(u|=Qa),this.setLightmapping(o,!0,c,u),this.finishBake(o)}var d=dt();this.stats.totalRenderTime=d-n,this.stats.shadersLinked=i._shaderStats.linked-s,this.stats.compileTime=i._shaderStats.compileTime-a,this.stats.fboTime=i._renderTargetCreationTime-r,this.stats.lightmapCount=o.length}},e.allocateTextures=function(t,e){for(var i=0;i0){e.copy(t[0].aabb);for(var i=1;i1&&b>1&&y.light.bakeDir&&(b=1);for(var w=0;w1&&y.prepareVirtualLight(w,b),y.startBake();var T=!1,A=this.lightCameraPrepare(r,y);for(_=0;_0&&w>0)&&!(x&&m>0);m++){var M=C.renderTargets[m],P=C.renderTargets[m].colorBuffer.width,R=this.renderTargets.get(P),I=R.colorBuffer;0===m?v=n.updateShaders:v&&(n.updateShaders=!0);var L=this.passMaterials[m];for(x&&w+1===b&&0===m&&(L=this.ambientAOMaterial),u=0;u=this._right){var i=e.length;if(i)if(t=e[i-1])this._left=e[i-1],this._right=1/0,this._len=0,this._recip=0,this._p0=this._p1=i-1;else{var n=this._findKey(t,e);this._left=e[n],this._right=e[n+1],this._len=this._right-this._left;var s=1/this._len;this._recip=isFinite(s)?s:0,this._p0=n,this._p1=n+1}else this._left=-1/0,this._right=1/0,this._len=0,this._recip=0,this._p0=this._p1=0}this._t=0===this._recip?0:(t-this._left)*this._recip,this._hermite.valid=!1},e._findKey=function(t,e){for(var i=0;t>=e[i+1];)i++;return i},e.eval=function(t,e,i){var n=i._data,s=i._components,r=this._p0*s;if(0===e)for(var a=0;a=t)},e.nextEventBehindTime=function(t){return!!this.nextEvent&&(t===this.track.duration?this.isReverse?this.nextEvent.time>=t:this.nextEvent.time<=t:this.isReverse?this.nextEvent.time>t:this.nextEvent.time=this.track.events.length?this._eventCursor=0:this._eventCursor<0&&(this._eventCursor=this.track.events.length-1)},e.clipFrameTime=function(e){var i=t.eventFrame;i.start=0,i.end=e,i.residual=0,this.isReverse?e<0&&(i.start=this.track.duration,i.end=0,i.residual=e+this.track.duration):e>this.track.duration&&(i.start=0,i.end=this.track.duration,i.residual=e-this.track.duration)},e.alignCursorToCurrentTime=function(){for(this.resetEventCursor();this.nextEventBehindTime(this._time)&&this._eventCursor!==this.eventCursorEnd;)this.moveEventCursor()},e.fireNextEvent=function(){this._eventHandler.fire(this.nextEvent.name,x({track:this.track},this.nextEvent)),this.moveEventCursor()},e.fireNextEventInFrame=function(t,e){return!(!this.nextEventAheadOfTime(t)||!this.nextEventBehindTime(e))&&(this.fireNextEvent(),!0)},e.activeEventsForFrame=function(e,i){var n=t.eventFrame;this.clipFrameTime(i);for(var s=this.eventCursor;this.fireNextEventInFrame(e,n.end)&&s!==this.eventCursor;);this.loop&&Math.abs(n.residual)>0&&this.activeEventsForFrame(n.start,n.residual)},e.progressForTime=function(t){return t*this._speed/this._track.duration},e._update=function(t){if(this._playing){var e=this._time,i=this._track.duration,n=this._speed,s=this._loop;this._track.events.length>0&&i>0&&this.activeEventsForFrame(e,e+n*t),e+=n*t,n>=0?e>i&&(s?e=e%i||0:(e=this._track.duration,this.pause())):e<0&&(s?e=i+(e%i||0):(e=0,this.pause())),this._time=e}this._time!==this._snapshot._time&&this._track.eval(this._time,this._snapshot)},e.play=function(){this._playing=!0,this._time=0},e.stop=function(){this._playing=!1,this._time=0},e.pause=function(){this._playing=!1},e.resume=function(){this._playing=!0},e.reset=function(){this._time=0},y(t,[{key:"name",get:function(){return this._name},set:function(t){this._name=t}},{key:"track",get:function(){return this._track},set:function(t){this._track=t,this._snapshot=new Bp(t)}},{key:"snapshot",get:function(){return this._snapshot}},{key:"time",get:function(){return this._time},set:function(t){this._time=t,this.alignCursorToCurrentTime()}},{key:"speed",get:function(){return this._speed},set:function(t){var e=Math.sign(t)!==Math.sign(this._speed);this._speed=t,e&&this.alignCursorToCurrentTime()}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t}},{key:"blendWeight",get:function(){return this._blendWeight},set:function(t){this._blendWeight=t}},{key:"blendOrder",get:function(){return this._blendOrder},set:function(t){this._blendOrder=t}},{key:"eventCursor",get:function(){return this._eventCursor},set:function(t){this._eventCursor=t}},{key:"eventCursorEnd",get:function(){return this.isReverse?0:this._track.events.length-1}},{key:"nextEvent",get:function(){return this._track.events[this._eventCursor]}},{key:"isReverse",get:function(){return this._speed<0}}]),t}();Up.eventFrame={start:0,end:0,residual:0};var Np="NONE",zp="PREV_STATE",Vp="NEXT_STATE",Gp="PREV_STATE_NEXT_STATE",Hp="NEXT_STATE_PREV_STATE",Wp="GREATER_THAN",Xp="LESS_THAN",qp="GREATER_THAN_EQUAL_TO",jp="LESS_THAN_EQUAL_TO",Yp="EQUAL_TO",Kp="NOT_EQUAL_TO",Zp="INTEGER",Qp="FLOAT",$p="BOOLEAN",Jp="TRIGGER",tm="2D_DIRECTIONAL",em="2D_CARTESIAN",im="DIRECT",nm="START",sm="END",rm="ANY",am=[nm,sm,rm],om="OVERWRITE",hm="ADDITIVE",lm=function(){function t(){}return t.dot=function(t,e){for(var i=t.length,n=0,s=0;s0){i=1/Math.sqrt(i);for(var n=e.length,s=0;s0&&(r=1/Math.sqrt(r));for(var a=0;a0;)this.removeClip(0)},e.updateClipTrack=function(t,e){this._clips.forEach((function(i){i.name.includes(t)&&(i.track=e)})),this.rebind()},e.findClip=function(t){for(var e=this._clips,i=0;i0&&a._update(t),!e)break;var c=void 0,u=void 0,d=void 0;if(l>=1)for(var f=0;f0)for(var p=0;p0&&i.push(n),i},t.encode=function(t,e,i){return(Array.isArray(t)?t.join("/"):t)+"/"+e+"/"+(Array.isArray(i)?i.join("/"):i)};var e=t.prototype;return e.resolve=function(t){return null},e.unresolve=function(t){},e.update=function(t){},t}(),_m=function(){function t(t,e,i,n){t.set?(this._set=t.set,this._get=t.get):this._set=t,this._type=e,this._components=i,this._targetPath=n,this._isTransform="localRotation"===this._targetPath.substring(this._targetPath.length-13)||"localPosition"===this._targetPath.substring(this._targetPath.length-13)||"localScale"===this._targetPath.substring(this._targetPath.length-10)}return y(t,[{key:"set",get:function(){return this._set}},{key:"get",get:function(){return this._get}},{key:"type",get:function(){return this._type}},{key:"components",get:function(){return this._components}},{key:"targetPath",get:function(){return this._targetPath}},{key:"isTransform",get:function(){return this._isTransform}}]),t}(),gm=function(){function t(e){var i=this;if(this._isPathInMask=function(t,e){var n=i._mask[t];return!!n&&!!(n.children||e&&!1!==n.value)},this.graph=e,e){this._mask=null;var n={};!function t(e){n[e.name]=e;for(var i=0;i0&&!!this.prevAnim,this.blending&&(this.blend=0,this.blendSpeed=1/e),this.skeleton&&(this.blending?(this.fromSkel.animation=i,this.fromSkel.addTime(this.skeleton._time),this.toSkel.animation=n):this.skeleton.animation=n),this.animEvaluator){var s=this.animEvaluator;if(this.blending)for(;s.clips.length>1;)s.removeClip(0);else this.animEvaluator.removeClips();var r=new Up(this.animations[this.currAnim],0,1,!0,this.loop);r.name=this.currAnim,r.blendWeight=this.blending?0:1,r.reset(),this.animEvaluator.addClip(r)}}this.playing=!0}},i.getAnimation=function(t){return this.animations[t]},i.setModel=function(t){t!==this.model&&(this._resetAnimationController(),this.model=t,this.animations&&this.currAnim&&this.animations[this.currAnim]&&this.play(this.currAnim))},i.onSetAnimations=function(){var t=this.entity.model;if(t){var e=t.model;e&&e!==this.model&&this.setModel(e)}if(!this.currAnim&&this.activate&&this.enabled&&this.entity.enabled){var i=Object.keys(this._animations);i.length>0&&this.play(i[0])}},i._resetAnimationController=function(){this.skeleton=null,this.fromSkel=null,this.toSkel=null,this.animEvaluator=null},i._createAnimationController=function(){var t=this.model,e=this.animations,i=!1,n=!1;for(var s in e){if(e.hasOwnProperty(s))e[s].constructor===pm?n=!0:i=!0}var r=t.getGraph();i?(this.fromSkel=new mf(r),this.toSkel=new mf(r),this.skeleton=new mf(r),this.skeleton.looping=this.loop,this.skeleton.setGraph(r)):n&&(this.animEvaluator=new dm(new gm(this.entity)))},i.loadAnimationAssets=function(t){var e=this;if(t&&t.length)for(var i=this.system.app.assets,n=function(t){if(t.resources.length>1)for(var i=0;i1){if(n&&n.length>1)for(var r=0;r1)for(var o=0;o1)for(var h=0;h1)for(var e=0;e0&&this.play(a[0])}},i.onBeforeRemove=function(){for(var t=0;t=1&&(this.blend=1)),this.playing){var e=this.skeleton;if(null!==e&&null!==this.model){if(this.blending)e.blend(this.fromSkel,this.toSkel,this.blend);else{var i=t*this.speed;e.addTime(i),(this.speed>0&&e._time===e.animation.duration&&!this.loop||this.speed<0&&0===e._time&&!this.loop)&&(this.playing=!1)}this.blending&&1===this.blend&&(e.animation=this.toSkel.animation),e.updateGraph()}}var n=this.animEvaluator;if(n){for(var s=0;s1&&(n.clips[1].blendWeight=this.blend),n.update(t)}this.blending&&1===this.blend&&(this.blending=!1)},y(e,[{key:"animations",get:function(){return this._animations},set:function(t){this._animations=t,this.onSetAnimations()}},{key:"assets",get:function(){return this._assets},set:function(t){var e=this._assets;if(e&&e.length)for(var i=0;i0)return t[t.length-1].time}return 0},set:function(t){if(this.skeleton&&(this.skeleton.currentTime=t,this.skeleton.addTime(0),this.skeleton.updateGraph()),this.animEvaluator)for(var e=this.animEvaluator.clips,i=0;i=0)this._animationList[n].animTrack=e;else{var s=this._getNodeFromPath(t);s.animTrack=e,this._animationList.push(s)}this._updateHasAnimations()},e._updateHasAnimations=function(){this._hasAnimations=this._animationList.length>0&&this._animationList.every((function(t){return t.animTrack&&t.animTrack!==pm.EMPTY}))},y(t,[{key:"name",get:function(){return this._name}},{key:"animations",get:function(){return this._animationList},set:function(t){this._animationList=t,this._updateHasAnimations()}},{key:"hasAnimations",get:function(){return this._hasAnimations}},{key:"speed",get:function(){return this._speed},set:function(t){this._speed=t}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t}},{key:"nodeCount",get:function(){return this._blendTree&&this._blendTree.constructor!==bm?this._blendTree.getNodeCount():1}},{key:"playable",get:function(){return-1!==am.indexOf(this.name)||this.animations.length===this.nodeCount}},{key:"looping",get:function(){if(this.animations.length>0){var t=this.name+"."+this.animations[0].animTrack.name,e=this._controller.animEvaluator.findClip(t);if(e)return e.loop}return!1}},{key:"totalWeight",get:function(){for(var t=0,e=0;et&&(t=i.animTrack.duration)}return t}}]),t}(),Pm=function(){function t(t){var e=t.from,i=t.to,n=t.time,s=void 0===n?0:n,r=t.priority,a=void 0===r?0:r,o=t.conditions,h=void 0===o?[]:o,l=t.exitTime,c=void 0===l?null:l,u=t.transitionOffset,d=void 0===u?null:u,f=t.interruptionSource,p=void 0===f?Np:f;this._from=e,this._to=i,this._time=s,this._priority=a,this._conditions=h,this._exitTime=c,this._transitionOffset=d,this._interruptionSource=p}return y(t,[{key:"from",get:function(){return this._from}},{key:"to",get:function(){return this._to},set:function(t){this._to=t}},{key:"time",get:function(){return this._time}},{key:"priority",get:function(){return this._priority}},{key:"conditions",get:function(){return this._conditions}},{key:"exitTime",get:function(){return this._exitTime}},{key:"transitionOffset",get:function(){return this._transitionOffset}},{key:"interruptionSource",get:function(){return this._interruptionSource}},{key:"hasExitTime",get:function(){return!!this.exitTime}}]),t}(),Rm=function(){function t(t,e,i,n,s,r,a){var o=this;this.findParameter=function(t){return o._findParameter(t)},this._animEvaluator=t,this._states={},this._stateNames=[],this._eventHandler=s,this._findParameter=r,this._consumeTrigger=a;for(var h=0;h"+e];return i||(i=this._transitions.filter((function(i){return i.from===t&&i.to===e})),Nu(i),this._findTransitionsBetweenStatesCache[t+"->"+e]=i),i},e._transitionHasConditionsMet=function(t){for(var e=t.conditions,i=0;in.value))return!1;break;case Xp:if(!(s.value=n.value))return!1;break;case jp:if(!(s.value<=n.value))return!1;break;case Yp:if(s.value!==n.value)return!1;break;case Kp:if(s.value===n.value)return!1}}return!0},e._findTransition=function(t,e){var i=this,n=[];if(t&&e)n=n.concat(this._findTransitionsBetweenStates(t,e));else if(this._isTransitioning)switch(this._transitionInterruptionSource){case zp:n=(n=n.concat(this._findTransitionsFromState(this._previousStateName))).concat(this._findTransitionsFromState(rm));break;case Vp:n=(n=n.concat(this._findTransitionsFromState(this._activeStateName))).concat(this._findTransitionsFromState(rm));break;case Gp:n=(n=(n=n.concat(this._findTransitionsFromState(this._previousStateName))).concat(this._findTransitionsFromState(this._activeStateName))).concat(this._findTransitionsFromState(rm));break;case Hp:n=(n=(n=n.concat(this._findTransitionsFromState(this._activeStateName))).concat(this._findTransitionsFromState(this._previousStateName))).concat(this._findTransitionsFromState(rm))}else n=(n=n.concat(this._findTransitionsFromState(this._activeStateName))).concat(this._findTransitionsFromState(rm));if(n=n.filter((function(t){if(t.to===i.activeStateName)return!1;if(t.hasExitTime){var e=i._getActiveStateProgressForTime(i._timeInStateBefore),n=i._getActiveStateProgressForTime(i._timeInState);if(t.exitTime<1&&i.activeState.loop&&(e-=Math.floor(e),n-=Math.floor(n)),n===e){if(n!==t.exitTime)return null}else if(!(t.exitTime>e&&t.exitTime<=n))return null}return i._transitionHasConditionsMet(t)})),n.length>0){var s=n[0];if(s.to===sm){var r=this._findTransitionsFromState(nm)[0];s.to=r.to}return s}return null},e.updateStateFromTransition=function(t){var e,i,n;this.previousState=t.from?this.activeStateName:null,this.activeState=t.to,this._activeStateDurationDirty=!0;for(var s=0;s0&&t.transitionOffset<1,u=0,d=0;if(c){var f=l.timelineDuration*t.transitionOffset;u=f,d=f}this._timeInState=u,this._timeInStateBefore=d;for(var p=0;p0?n.blendWeight=0:n.blendWeight=l.animations[p].normalizedWeight,n.play(),c)n.time=l.timelineDuration*t.transitionOffset;else{var _=l.speed>=0?0:this.activeStateDuration;n.time=_}}},e._transitionToState=function(t){if(this._findState(t)){var e=this._findTransition(this._activeStateName,t);e||(this._animEvaluator.removeClips(),e=new Pm({from:null,to:t})),this.updateStateFromTransition(e)}},e.assignAnimation=function(t,e,i,n){var s=t.split("."),r=this._findState(s[0]);r||(r=new Mm(this,s[0],i),this._states[s[0]]=r,this._stateNames.push(s[0])),r.addAnimation(s,e),this._animEvaluator.updateClipTrack(r.name,e),void 0!==i&&(r.speed=i),void 0!==n&&(r.loop=n),!this._playing&&this._activate&&this.playable&&this.play(),this._activeStateDurationDirty=!0},e.removeNodeAnimations=function(t){if(-1!==am.indexOf(t))return!1;var e=this._findState(t);return!!e&&(e.animations=[],!0)},e.play=function(t){t&&this._transitionToState(t),this._playing=!0},e.pause=function(){this._playing=!1},e.reset=function(){this._previousStateName=null,this._activeStateName=nm,this._playing=!1,this._currTransitionTime=1,this._totalTransitionTime=1,this._isTransitioning=!1,this._timeInState=0,this._timeInStateBefore=0,this._animEvaluator.removeClips()},e.rebind=function(){this._animEvaluator.rebind()},e.update=function(t){if(this._playing){var e,i,n;(this.activeState.loop||this._timeInStatethis.activeStateDuration&&(this._timeInState=this.activeStateDuration,t=this.activeStateDuration-this._timeInStateBefore));var s=this._findTransition(this._activeStateName);if(s&&this.updateStateFromTransition(s),this._isTransitioning)if(this._currTransitionTime+=t,this._currTransitionTime<=this._totalTransitionTime){for(var r=0!==this._totalTransitionTime?this._currTransitionTime/this._totalTransitionTime:1,a=0;a1){var l=e.length>2?this._resolvePath(t,e.slice(0,-1)):t,c=e[e.length-2];return function(t){n[s]=i(t),l[c]=n}}return function(t){n[s]=i(t)}},i._createAnimTargetForProperty=function(t,i,n){if(this.handlers&&i[0].startsWith("weight."))return this.handlers.weight(t,i[0].replace("weight.",""));if(this.handlers&&"material"===i[0]&&2===i.length){var s=i[1];if(s.endsWith("Map"))return this.handlers.materialTexture(t,s)}var r,a,o,h=this._resolvePath(t,i,!0);if(void 0===h)return null;if("number"==typeof h)r=this._setter(t,i,e._packFloat),a="vector",o=1;else if("boolean"==typeof h)r=this._setter(t,i,e._packBoolean),a="vector",o=1;else if("object"==typeof h)switch(h.constructor){case It:r=this._setter(t,i,e._packVec2),a="vector",o=2;break;case Et:r=this._setter(t,i,e._packVec3),a="vector",o=3;break;case Dt:r=this._setter(t,i,e._packVec4),a="vector",o=4;break;case gt:r=this._setter(t,i,e._packColor),a="vector",o=4;break;case Vt:r=this._setter(t,i,e._packQuat),a="quaternion",o=4;break;default:return null}return-1!==i.indexOf("material")?new _m((function(e){r(e),t.material.update()}),a,o,n):new _m(r,a,o,n)},i.rebind=function(){this.targetCache={},this.animComponent.rootBone?this.graph=this.animComponent.rootBone:this.graph=this.animComponent.entity;var t={};!function e(i){t[i.name]=i;for(var n=0;n0?this._layers[0]:null}}]),e}(Dp),zm=function(){this.enabled=!0},Vm=["enabled"],Gm=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="anim",i.ComponentType=Nm,i.DataType=zm,i.schema=Vm,i.on("beforeremove",i.onBeforeRemove,w(i)),i.app.systems.on("animationUpdate",i.onAnimationUpdate,w(i)),i}S(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){var s=this;t.prototype.initializeComponentData.call(this,e,i,Vm);var r=["animationAssets","stateGraph","layers","masks"];Object.keys(i).forEach((function(t){r.includes(t)||(e[t]=i[t])})),i.stateGraph&&(e.stateGraph=i.stateGraph,e.loadStateGraph(e.stateGraph)),i.layers?i.layers.forEach((function(t,i){t._controller.states.forEach((function(n){t._controller._states[n]._animationList.forEach((function(n){if(n.animTrack&&n.animTrack!==pm.EMPTY)e.layers[i].assignAnimation(n.name,n.animTrack);else{var r=s.app.assets.get(t._component._animationAssets[t.name+":"+n.name].asset);r&&!r.loaded&&r.once("load",(function(){e.layers[i].assignAnimation(n.name,r.resource)}))}}))}))})):i.animationAssets&&(e.animationAssets=Object.assign(e.animationAssets,i.animationAssets)),i.masks&&Object.keys(i.masks).forEach((function(t){if(e.layers[t]){var n=i.masks[t].mask,s={};Object.keys(n).forEach((function(t){s[decodeURI(t)]=n[t]})),e.layers[t].mask=s}}))},i.onAnimationUpdate=function(t){var e=this.store;for(var i in e)if(e.hasOwnProperty(i)){var n=e[i].entity.anim;n.data.enabled&&n.entity.enabled&&n.playing&&n.update(t)}},i.cloneComponent=function(t,e){var i;t.anim.rootBone&&t.anim.rootBone!==t||(i={},t.anim.layers.forEach((function(t,n){if(t.mask){var s={};Object.keys(t.mask).forEach((function(i){var n=i.split("/");n.shift();var r=[e.name].concat(n).join("/");s[r]=t.mask[i]})),i[n]={mask:s}}})));var n={stateGraphAsset:t.anim.stateGraphAsset,animationAssets:t.anim.animationAssets,speed:t.anim.speed,activate:t.anim.activate,playing:t.anim.playing,rootBone:t.anim.rootBone,stateGraph:t.anim.stateGraph,layers:t.anim.layers,layerIndices:t.anim.layerIndices,parameters:t.anim.parameters,normalizeWeights:t.anim.normalizeWeights,masks:i};return this.addComponent(e,n)},i.onBeforeRemove=function(t,e){e.onBeforeRemove()},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("animationUpdate",this.onAnimationUpdate,this)},e}(Op);Dp._buildAccessors(Nm.prototype,Vm);var Hm=function(t){function e(e,i){return t.call(this,e,i)||this}S(e,t);var i=e.prototype;return i.setCurrentListener=function(){if(this.enabled&&this.entity.audiolistener&&this.entity.enabled){this.system.current=this.entity;var t=this.system.current.getPosition();this.system.manager.listener.setPosition(t)}},i.onEnable=function(){this.setCurrentListener()},i.onDisable=function(){this.system.current===this.entity&&(this.system.current=null)},e}(Dp),Wm=function(){this.enabled=!0},Xm=["enabled"],qm=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="audiolistener",i.ComponentType=Hm,i.DataType=Wm,i.schema=Xm,i.manager=e.soundManager,i.current=null,i.app.systems.on("update",i.onUpdate,w(i)),i}S(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){n=["enabled"],t.prototype.initializeComponentData.call(this,e,i,n)},i.onUpdate=function(t){if(this.current){var e=this.current.getPosition();this.manager.listener.setPosition(e);var i=this.current.getWorldTransform();this.manager.listener.setOrientation(i)}},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("update",this.onUpdate,this)},e}(Op);Dp._buildAccessors(Hm.prototype,Xm);var jm=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this).on("set_assets",n.onSetAssets,w(n)),n.on("set_loop",n.onSetLoop,w(n)),n.on("set_volume",n.onSetVolume,w(n)),n.on("set_pitch",n.onSetPitch,w(n)),n.on("set_minDistance",n.onSetMinDistance,w(n)),n.on("set_maxDistance",n.onSetMaxDistance,w(n)),n.on("set_rollOffFactor",n.onSetRollOffFactor,w(n)),n.on("set_distanceModel",n.onSetDistanceModel,w(n)),n.on("set_3d",n.onSet3d,w(n)),n}S(e,t);var i=e.prototype;return i.play=function(t){if(this.enabled&&this.entity.enabled){var e;this.channel&&this.stop();var i=this.data;if(i.sources[t])if(i["3d"]){var n=this.entity.getPosition();e=this.system.manager.playSound3d(i.sources[t],n,i),i.currentSource=t,i.channel=e}else e=this.system.manager.playSound(i.sources[t],i),i.currentSource=t,i.channel=e}},i.pause=function(){this.channel&&this.channel.pause()},i.unpause=function(){this.channel&&this.channel.paused&&this.channel.unpause()},i.stop=function(){this.channel&&(this.channel.stop(),this.channel=null)},i.onSetAssets=function(t,e,i){var n=[],s=i.length;if(e&&e.length)for(var r=0;r1e-5){var i=this._tweenInfo.lerpColor;i.lerp(this._tweenInfo.from,this._tweenInfo.to,e),this._applyTintImmediately(new gt(i.r,i.g,i.b,i.a))}else this._applyTintImmediately(this._tweenInfo.to),this._cancelTween()},i._cancelTween=function(){delete this._tweenInfo},i.onUpdate=function(){this._tweenInfo&&this._updateTintTween()},i.onEnable=function(){this._isHovering=!1,this._hoveringCounter=0,this._isPressed=!1,this._imageReference.onParentComponentEnable(),this._toggleHitElementListeners("on"),this._forceReapplyVisualState()},i.onDisable=function(){this._toggleHitElementListeners("off"),this._resetToDefaultVisualState(this.transitionMode)},i.onRemove=function(){this._toggleLifecycleListeners("off",this.system),this.onDisable()},e}(Dp);function d_(t){return new gt(t.r,t.g,t.b)}var f_=function(){this.enabled=!0,this.active=!0,this.imageEntity=null,this.hitPadding=new Dt,this.transitionMode=0,this.hoverTint=new gt(.75,.75,.75),this.pressedTint=new gt(.5,.5,.5),this.inactiveTint=new gt(.25,.25,.25),this.fadeDuration=0,this.hoverSpriteAsset=null,this.hoverSpriteFrame=0,this.pressedSpriteAsset=null,this.pressedSpriteFrame=0,this.inactiveSpriteAsset=null,this.inactiveSpriteFrame=0},p_=["enabled","active",{name:"imageEntity",type:"entity"},{name:"hitPadding",type:"vec4"},"transitionMode",{name:"hoverTint",type:"rgba"},{name:"pressedTint",type:"rgba"},{name:"inactiveTint",type:"rgba"},"fadeDuration","hoverSpriteAsset","hoverSpriteFrame","pressedSpriteAsset","pressedSpriteFrame","inactiveSpriteAsset","inactiveSpriteFrame"],m_=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="button",i.ComponentType=u_,i.DataType=f_,i.schema=p_,i.on("beforeremove",i._onRemoveComponent,w(i)),i.app.systems.on("update",i.onUpdate,w(i)),i}S(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){t.prototype.initializeComponentData.call(this,e,i,p_)},i.onUpdate=function(t){var e=this.store;for(var i in e){var n=e[i].entity,s=n.button;s.enabled&&n.enabled&&s.onUpdate()}},i._onRemoveComponent=function(t,e){e.onRemove()},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("update",this.onUpdate,this)},e}(Op);Dp._buildAccessors(u_.prototype,p_);var __,g_,v_,y_=new Et,x_=new Vt,S_=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._compoundParent=null,n._hasOffset=!1,n.entity.on("insert",n._onInsert,w(n)),n.on("set_type",n.onSetType,w(n)),n.on("set_halfExtents",n.onSetHalfExtents,w(n)),n.on("set_linearOffset",n.onSetOffset,w(n)),n.on("set_angularOffset",n.onSetOffset,w(n)),n.on("set_radius",n.onSetRadius,w(n)),n.on("set_height",n.onSetHeight,w(n)),n.on("set_axis",n.onSetAxis,w(n)),n.on("set_asset",n.onSetAsset,w(n)),n.on("set_renderAsset",n.onSetRenderAsset,w(n)),n.on("set_model",n.onSetModel,w(n)),n.on("set_render",n.onSetRender,w(n)),n}S(e,t);var i=e.prototype;return i.onSetType=function(t,e,i){e!==i&&this.system.changeType(this,e,i)},i.onSetHalfExtents=function(t,e,i){var n=this.data.type;this.data.initialized&&"box"===n&&this.system.recreatePhysicalShapes(this)},i.onSetOffset=function(t,e,i){this._hasOffset=!this.data.linearOffset.equals(Et.ZERO)||!this.data.angularOffset.equals(Vt.IDENTITY),this.data.initialized&&this.system.recreatePhysicalShapes(this)},i.onSetRadius=function(t,e,i){var n=this.data.type;!this.data.initialized||"sphere"!==n&&"capsule"!==n&&"cylinder"!==n&&"cone"!==n||this.system.recreatePhysicalShapes(this)},i.onSetHeight=function(t,e,i){var n=this.data.type;!this.data.initialized||"capsule"!==n&&"cylinder"!==n&&"cone"!==n||this.system.recreatePhysicalShapes(this)},i.onSetAxis=function(t,e,i){var n=this.data.type;!this.data.initialized||"capsule"!==n&&"cylinder"!==n&&"cone"!==n||this.system.recreatePhysicalShapes(this)},i.onSetAsset=function(t,e,i){var n=this.system.app.assets;if(e){var s=n.get(e);s&&s.off("remove",this.onAssetRemoved,this)}if(i){i instanceof $f&&(this.data.asset=i.id);var r=n.get(this.data.asset);r&&(r.off("remove",this.onAssetRemoved,this),r.on("remove",this.onAssetRemoved,this))}this.data.initialized&&"mesh"===this.data.type&&(i||(this.data.model=null),this.system.recreatePhysicalShapes(this))},i.onSetRenderAsset=function(t,e,i){var n=this.system.app.assets;if(e){var s=n.get(e);s&&s.off("remove",this.onRenderAssetRemoved,this)}if(i){i instanceof $f&&(this.data.renderAsset=i.id);var r=n.get(this.data.renderAsset);r&&(r.off("remove",this.onRenderAssetRemoved,this),r.on("remove",this.onRenderAssetRemoved,this))}this.data.initialized&&"mesh"===this.data.type&&(i||(this.data.render=null),this.system.recreatePhysicalShapes(this))},i.onSetModel=function(t,e,i){this.data.initialized&&"mesh"===this.data.type&&this.system.implementations.mesh.doRecreatePhysicalShape(this)},i.onSetRender=function(t,e,i){this.onSetModel(t,e,i)},i.onAssetRemoved=function(t){t.off("remove",this.onAssetRemoved,this),this.data.asset===t.id&&(this.asset=null)},i.onRenderAssetRemoved=function(t){t.off("remove",this.onRenderAssetRemoved,this),this.data.renderAsset===t.id&&(this.renderAsset=null)},i._getCompoundChildShapeIndex=function(t){for(var e=this.data.shape,i=e.getNumChildShapes(),n=0;n-1&&e.rigidbody._triggers.splice(i,1),e.rigidbody.removeBody(t),t.forceActivationState(5)}},t}(),P_=new zt,R_=new Et,I_=new Et,L_=new Vt,D_=new _h,O_=["enabled","type","halfExtents","linearOffset","angularOffset","radius","axis","height","asset","renderAsset","shape","model","render"],k_=function(){function t(t){this.system=t}var e=t.prototype;return e.beforeInitialize=function(t,e){e.shape=null,e.model=new $u,e.model.graph=new _h},e.afterInitialize=function(t,e){this.recreatePhysicalShapes(t),t.data.initialized=!0},e.reset=function(t,e){this.beforeInitialize(t,e),this.afterInitialize(t,e)},e.recreatePhysicalShapes=function(t){var e=t.entity,i=t.data;if("undefined"!=typeof Ammo){e.trigger&&(e.trigger.destroy(),delete e.trigger),i.shape&&(t._compoundParent&&(this.system._removeCompoundChild(t._compoundParent,i.shape),t._compoundParent.entity.rigidbody&&t._compoundParent.entity.rigidbody.activate()),this.destroyShape(i)),i.shape=this.createPhysicalShape(t.entity,i);var n=!t._compoundParent;if("compound"!==i.type||t._compoundParent&&t!==t._compoundParent){if("compound"!==i.type&&(t._compoundParent&&t===t._compoundParent&&e.forEach(this.system.implementations.compound._updateEachDescendant,t),!t.rigidbody)){t._compoundParent=null;for(var s=e.parent;s;){if(s.collision&&"compound"===s.collision.type){t._compoundParent=s.collision;break}s=s.parent}}}else t._compoundParent=t,e.forEach(this._addEachDescendant,t);t._compoundParent&&t!==t._compoundParent&&(n&&0===t._compoundParent.shape.getNumChildShapes()?this.system.recreatePhysicalShapes(t._compoundParent):(this.system.updateCompoundChildTransform(e),t._compoundParent.entity.rigidbody&&t._compoundParent.entity.rigidbody.activate())),e.rigidbody?(e.rigidbody.disableSimulation(),e.rigidbody.createBody(),e.enabled&&e.rigidbody.enabled&&e.rigidbody.enableSimulation()):t._compoundParent||(e.trigger?e.trigger.initialize(i):e.trigger=new M_(this.system.app,t,i))}},e.createPhysicalShape=function(t,e){},e.updateTransform=function(t,e,i,n){t.entity.trigger&&t.entity.trigger.updateTransform()},e.destroyShape=function(t){t.shape&&(Ammo.destroy(t.shape),t.shape=null)},e.beforeRemove=function(t,e){e.data.shape&&(e._compoundParent&&!e._compoundParent.entity._destroying&&(this.system._removeCompoundChild(e._compoundParent,e.data.shape),e._compoundParent.entity.rigidbody&&e._compoundParent.entity.rigidbody.activate()),e._compoundParent=null,this.destroyShape(e.data))},e.remove=function(t,e){t.rigidbody&&t.rigidbody.body&&t.rigidbody.disableSimulation(),t.trigger&&(t.trigger.destroy(),delete t.trigger)},e.clone=function(t,e){var i=this.system.store[t.getGuid()],n={enabled:i.data.enabled,type:i.data.type,halfExtents:[i.data.halfExtents.x,i.data.halfExtents.y,i.data.halfExtents.z],linearOffset:[i.data.linearOffset.x,i.data.linearOffset.y,i.data.linearOffset.z],angularOffset:[i.data.angularOffset.x,i.data.angularOffset.y,i.data.angularOffset.z,i.data.angularOffset.w],radius:i.data.radius,axis:i.data.axis,height:i.data.height,asset:i.data.asset,renderAsset:i.data.renderAsset,model:i.data.model,render:i.data.render};return this.system.addComponent(e,n)},t}(),F_=function(t){function e(){return t.apply(this,arguments)||this}return S(e,t),e.prototype.createPhysicalShape=function(t,e){if("undefined"!=typeof Ammo){var i=e.halfExtents,n=new Ammo.btVector3(i?i.x:.5,i?i.y:.5,i?i.z:.5),s=new Ammo.btBoxShape(n);return Ammo.destroy(n),s}},e}(k_),B_=function(t){function e(){return t.apply(this,arguments)||this}return S(e,t),e.prototype.createPhysicalShape=function(t,e){if("undefined"!=typeof Ammo)return new Ammo.btSphereShape(e.radius)},e}(k_),U_=function(t){function e(){return t.apply(this,arguments)||this}return S(e,t),e.prototype.createPhysicalShape=function(t,e){var i,n,s,r=null!=(i=e.axis)?i:1,a=null!=(n=e.radius)?n:.5,o=Math.max((null!=(s=e.height)?s:2)-2*a,0),h=null;if("undefined"!=typeof Ammo)switch(r){case 0:h=new Ammo.btCapsuleShapeX(a,o);break;case 1:h=new Ammo.btCapsuleShape(a,o);break;case 2:h=new Ammo.btCapsuleShapeZ(a,o)}return h},e}(k_),N_=function(t){function e(){return t.apply(this,arguments)||this}return S(e,t),e.prototype.createPhysicalShape=function(t,e){var i,n,s,r=null!=(i=e.axis)?i:1,a=null!=(n=e.radius)?n:.5,o=null!=(s=e.height)?s:1,h=null,l=null;if("undefined"!=typeof Ammo)switch(r){case 0:h=new Ammo.btVector3(.5*o,a,a),l=new Ammo.btCylinderShapeX(h);break;case 1:h=new Ammo.btVector3(a,.5*o,a),l=new Ammo.btCylinderShape(h);break;case 2:h=new Ammo.btVector3(a,a,.5*o),l=new Ammo.btCylinderShapeZ(h)}return h&&Ammo.destroy(h),l},e}(k_),z_=function(t){function e(){return t.apply(this,arguments)||this}return S(e,t),e.prototype.createPhysicalShape=function(t,e){var i,n,s,r=null!=(i=e.axis)?i:1,a=null!=(n=e.radius)?n:.5,o=null!=(s=e.height)?s:1,h=null;if("undefined"!=typeof Ammo)switch(r){case 0:h=new Ammo.btConeShapeX(a,o);break;case 1:h=new Ammo.btConeShape(a,o);break;case 2:h=new Ammo.btConeShapeZ(a,o)}return h},e}(k_),V_=function(t){function e(){return t.apply(this,arguments)||this}S(e,t);var i=e.prototype;return i.beforeInitialize=function(t,e){},i.createAmmoMesh=function(t,e,i){var n;if(this.system._triMeshCache[t.id])n=this.system._triMeshCache[t.id];else{for(var s,r,a=t.vertexBuffer,o=a.getFormat(),h=0;h=0&&this.model.meshInstances.splice(i,1),this.unmaskMeshInstance=null}this._entity.enabled&&this._element.enabled&&(this._element.removeModelFromLayers(this.model),this._element.addModelToLayers(this.model))}},e.setMaterial=function(t){this.meshInstance&&(this.meshInstance.material=t,this.unmaskMeshInstance&&(this.unmaskMeshInstance.material=t))},e.setParameter=function(t,e){this.meshInstance&&(this.meshInstance.setParameter(t,e),this.unmaskMeshInstance&&this.unmaskMeshInstance.setParameter(t,e))},e.deleteParameter=function(t){this.meshInstance&&(this.meshInstance.deleteParameter(t),this.unmaskMeshInstance&&this.unmaskMeshInstance.deleteParameter(t))},e.setUnmaskDrawOrder=function(){if(this.meshInstance){if(this.unmaskMeshInstance){var t=function t(e){var i,n=e.children,s=n.length;if(s){for(var r=0;r0){var s=e.calculatedWidth/e.calculatedHeight;e.fitMode===i_&&s>this._targetAspectRatio||e.fitMode===n_&&s0&&(this._targetAspectRatio=i.rect.z/i.rect.w)}this.mesh=t?e:this._defaultMesh,this.refreshMesh()},e.refreshMesh=function(){this.mesh&&(this._element._beingInitialized?this._meshDirty=!0:this._updateMesh(this.mesh))},e._updateAabb=function(t){return t.center.set(0,0,0),t.halfExtents.set(.5*this._outerScale.x,.5*this._outerScale.y,.001),t.setFromTransformedAabb(t,this._renderable.node.getWorldTransform()),t},e._toggleMask=function(){this._element._dirtifyMask();var t=this._element._isScreenSpace();this._updateMaterial(t),this._renderable.setMask(!!this._mask)},e._onMaterialLoad=function(t){this.material=t.resource},e._onMaterialAdded=function(t){this._system.app.assets.off("add:"+t.id,this._onMaterialAdded,this),this._materialAsset===t.id&&this._bindMaterialAsset(t)},e._bindMaterialAsset=function(t){this._entity.enabled&&(t.on("load",this._onMaterialLoad,this),t.on("change",this._onMaterialChange,this),t.on("remove",this._onMaterialRemove,this),t.resource?this._onMaterialLoad(t):this._system.app.assets.load(t))},e._unbindMaterialAsset=function(t){t.off("load",this._onMaterialLoad,this),t.off("change",this._onMaterialChange,this),t.off("remove",this._onMaterialRemove,this)},e._onMaterialChange=function(){},e._onMaterialRemove=function(){},e._onTextureAdded=function(t){this._system.app.assets.off("add:"+t.id,this._onTextureAdded,this),this._textureAsset===t.id&&this._bindTextureAsset(t)},e._bindTextureAsset=function(t){this._entity.enabled&&(t.on("load",this._onTextureLoad,this),t.on("change",this._onTextureChange,this),t.on("remove",this._onTextureRemove,this),t.resource?this._onTextureLoad(t):this._system.app.assets.load(t))},e._unbindTextureAsset=function(t){t.off("load",this._onTextureLoad,this),t.off("change",this._onTextureChange,this),t.off("remove",this._onTextureRemove,this)},e._onTextureLoad=function(t){this.texture=t.resource},e._onTextureChange=function(t){},e._onTextureRemove=function(t){},e._onSpriteAssetAdded=function(t){this._system.app.assets.off("add:"+t.id,this._onSpriteAssetAdded,this),this._spriteAsset===t.id&&this._bindSpriteAsset(t)},e._bindSpriteAsset=function(t){this._entity.enabled&&(t.on("load",this._onSpriteAssetLoad,this),t.on("change",this._onSpriteAssetChange,this),t.on("remove",this._onSpriteAssetRemove,this),t.resource?this._onSpriteAssetLoad(t):this._system.app.assets.load(t))},e._unbindSpriteAsset=function(t){t.off("load",this._onSpriteAssetLoad,this),t.off("change",this._onSpriteAssetChange,this),t.off("remove",this._onSpriteAssetRemove,this),t.data.textureAtlasAsset&&this._system.app.assets.off("load:"+t.data.textureAtlasAsset,this._onTextureAtlasLoad,this)},e._onSpriteAssetLoad=function(t){if(t&&t.resource)if(t.resource.atlas)this.sprite=t.resource;else{var e=t.data.textureAtlasAsset;if(e){var i=this._system.app.assets;i.off("load:"+e,this._onTextureAtlasLoad,this),i.once("load:"+e,this._onTextureAtlasLoad,this)}}else this.sprite=null},e._onSpriteAssetChange=function(t){this._onSpriteAssetLoad(t)},e._onSpriteAssetRemove=function(t){},e._bindSprite=function(t){t.on("set:meshes",this._onSpriteMeshesChange,this),t.on("set:pixelsPerUnit",this._onSpritePpuChange,this),t.on("set:atlas",this._onAtlasTextureChange,this),t.atlas&&t.atlas.on("set:texture",this._onAtlasTextureChange,this)},e._unbindSprite=function(t){t.off("set:meshes",this._onSpriteMeshesChange,this),t.off("set:pixelsPerUnit",this._onSpritePpuChange,this),t.off("set:atlas",this._onAtlasTextureChange,this),t.atlas&&t.atlas.off("set:texture",this._onAtlasTextureChange,this)},e._onSpriteMeshesChange=function(){this._sprite&&(this._spriteFrame=_t.clamp(this._spriteFrame,0,this._sprite.frameKeys.length-1)),this._updateSprite()},e._onSpritePpuChange=function(){0!==this.sprite.renderMode&&null===this._pixelsPerUnit&&this._updateSprite()},e._onAtlasTextureChange=function(){this.sprite&&this.sprite.atlas&&this.sprite.atlas.texture?(this._renderable.setParameter("texture_emissiveMap",this._sprite.atlas.texture),this._renderable.setParameter("texture_opacityMap",this._sprite.atlas.texture)):(this._renderable.deleteParameter("texture_emissiveMap"),this._renderable.deleteParameter("texture_opacityMap"))},e._onTextureAtlasLoad=function(t){var e=this._spriteAsset;e instanceof $f?this._onSpriteAssetLoad(e):this._onSpriteAssetLoad(this._system.app.assets.get(e))},e.onEnable=function(){if(this._materialAsset){var t=this._system.app.assets.get(this._materialAsset);t&&t.resource!==this._material&&this._bindMaterialAsset(t)}if(this._textureAsset){var e=this._system.app.assets.get(this._textureAsset);e&&e.resource!==this._texture&&this._bindTextureAsset(e)}if(this._spriteAsset){var i=this._system.app.assets.get(this._spriteAsset);i&&i.resource!==this._sprite&&this._bindSpriteAsset(i)}this._element.addModelToLayers(this._renderable.model)},e.onDisable=function(){this._element.removeModelFromLayers(this._renderable.model)},e._setStencil=function(t){this._renderable.meshInstance.stencilFront=t,this._renderable.meshInstance.stencilBack=t;var e=0;if(this._element.maskedBy&&(e=this._element.maskedBy.element._image._maskRef),this._renderable.unmaskMeshInstance){var i=new an({ref:e+1,func:2,zpass:5});this._renderable.unmaskMeshInstance.stencilFront=i,this._renderable.unmaskMeshInstance.stencilBack=i}},e._removeMaterialAssetEvents=function(){if(this._materialAsset){var t=this._system.app.assets;t.off("add:"+this._materialAsset,this._onMaterialAdded,this);var e=t.get(this._materialAsset);e&&(e.off("load",this._onMaterialLoad,this),e.off("change",this._onMaterialChange,this),e.off("remove",this._onMaterialRemove,this))}},y(t,[{key:"color",get:function(){return this._color},set:function(t){var e=t.r,i=t.g,n=t.b;this._color.r===e&&this._color.g===i&&this._color.b===n||(this._color.r=e,this._color.g=i,this._color.b=n,this._colorUniform[0]=e,this._colorUniform[1]=i,this._colorUniform[2]=n,this._renderable.setParameter("material_emissive",this._colorUniform)),this._element&&this._element.fire("set:color",this._color)}},{key:"opacity",get:function(){return this._color.a},set:function(t){t!==this._color.a&&(this._color.a=t,this._renderable.setParameter("material_opacity",t)),this._element&&this._element.fire("set:opacity",t)}},{key:"rect",get:function(){return this._rect},set:function(t){var e,i,n,s;t instanceof Dt?(e=t.x,i=t.y,n=t.z,s=t.w):(e=t[0],i=t[1],n=t[2],s=t[3]),e===this._rect.x&&i===this._rect.y&&n===this._rect.z&&s===this._rect.w||(this._rect.set(e,i,n,s),this._renderable.mesh&&(this._element._beingInitialized?this._meshDirty=!0:this._updateMesh(this._renderable.mesh)))}},{key:"material",get:function(){return this._material},set:function(t){if(this._material!==t){if(!t){var e=this._element._isScreenSpace();t=this.mask?e?this._system.defaultScreenSpaceImageMaskMaterial:this._system.defaultImageMaskMaterial:e?this._system.defaultScreenSpaceImageMaterial:this._system.defaultImageMaterial}if(this._material=t,this._materialAsset){var i=this._system.app.assets.get(this._materialAsset);i&&i.resource===t||(this._removeMaterialAssetEvents(),this._materialAsset=null)}t&&(this._renderable.setMaterial(t),this._hasUserMaterial()?(this._renderable.deleteParameter("material_opacity"),this._renderable.deleteParameter("material_emissive")):(this._colorUniform[0]=this._color.r,this._colorUniform[1]=this._color.g,this._colorUniform[2]=this._color.b,this._renderable.setParameter("material_emissive",this._colorUniform),this._renderable.setParameter("material_opacity",this._color.a)))}}},{key:"materialAsset",get:function(){return this._materialAsset},set:function(t){var e=this._system.app.assets,i=t;if(t instanceof $f&&(i=t.id),this._materialAsset!==i)if(this._removeMaterialAssetEvents(),this._materialAsset=i,this._materialAsset){var n=e.get(this._materialAsset);n?this._bindMaterialAsset(n):(this._materialAsset=null,this.material=null,this._materialAsset=i,e.on("add:"+this._materialAsset,this._onMaterialAdded,this))}else this._materialAsset=null,this.material=null,this._materialAsset=i}},{key:"texture",get:function(){return this._texture},set:function(t){if(this._texture!==t){if(this._textureAsset){var e=this._system.app.assets.get(this._textureAsset);e&&e.resource!==t&&(this.textureAsset=null)}if(this._texture=t,t){this._spriteAsset&&(this.spriteAsset=null),this._renderable.setParameter("texture_emissiveMap",this._texture),this._renderable.setParameter("texture_opacityMap",this._texture),this._colorUniform[0]=this._color.r,this._colorUniform[1]=this._color.g,this._colorUniform[2]=this._color.b,this._renderable.setParameter("material_emissive",this._colorUniform),this._renderable.setParameter("material_opacity",this._color.a);var i=this._texture.width/this._texture.height;i!==this._targetAspectRatio&&(this._targetAspectRatio=i,this._element.fitMode!==e_&&this.refreshMesh())}else this._renderable.deleteParameter("texture_emissiveMap"),this._renderable.deleteParameter("texture_opacityMap"),this._targetAspectRatio=-1,this._element.fitMode!==e_&&this.refreshMesh()}}},{key:"textureAsset",get:function(){return this._textureAsset},set:function(t){var e=this._system.app.assets,i=t;if(t instanceof $f&&(i=t.id),this._textureAsset!==i){if(this._textureAsset){e.off("add:"+this._textureAsset,this._onTextureAdded,this);var n=e.get(this._textureAsset);n&&(n.off("load",this._onTextureLoad,this),n.off("change",this._onTextureChange,this),n.off("remove",this._onTextureRemove,this))}if(this._textureAsset=i,this._textureAsset){var s=e.get(this._textureAsset);s?this._bindTextureAsset(s):(this.texture=null,e.on("add:"+this._textureAsset,this._onTextureAdded,this))}else this.texture=null}}},{key:"spriteAsset",get:function(){return this._spriteAsset},set:function(t){var e=this._system.app.assets,i=t;if(t instanceof $f&&(i=t.id),this._spriteAsset!==i){if(this._spriteAsset){e.off("add:"+this._spriteAsset,this._onSpriteAssetAdded,this);var n=e.get(this._spriteAsset);n&&this._unbindSpriteAsset(n)}if(this._spriteAsset=i,this._spriteAsset){var s=e.get(this._spriteAsset);s?this._bindSpriteAsset(s):(this.sprite=null,e.on("add:"+this._spriteAsset,this._onSpriteAssetAdded,this))}else this.sprite=null}this._element&&this._element.fire("set:spriteAsset",i)}},{key:"sprite",get:function(){return this._sprite},set:function(t){if(this._sprite!==t){if(this._sprite&&this._unbindSprite(this._sprite),this._spriteAsset){var e=this._system.app.assets.get(this._spriteAsset);e&&e.resource!==t&&(this.spriteAsset=null)}this._sprite=t,this._sprite&&(this._bindSprite(this._sprite),this._textureAsset&&(this.textureAsset=null)),this._sprite&&this._sprite.atlas&&this._sprite.atlas.texture?(this._renderable.setParameter("texture_emissiveMap",this._sprite.atlas.texture),this._renderable.setParameter("texture_opacityMap",this._sprite.atlas.texture)):(this._renderable.deleteParameter("texture_emissiveMap"),this._renderable.deleteParameter("texture_opacityMap")),this._sprite&&(this._spriteFrame=_t.clamp(this._spriteFrame,0,this._sprite.frameKeys.length-1)),this._updateSprite()}}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){var e=this._spriteFrame;this._sprite?this._spriteFrame=_t.clamp(t,0,this._sprite.frameKeys.length-1):this._spriteFrame=t,this._spriteFrame!==e&&this._updateSprite(),this._element&&this._element.fire("set:spriteFrame",t)}},{key:"mesh",get:function(){return this._renderable.mesh},set:function(t){this._renderable.setMesh(t),this._defaultMesh===t?this._renderable.setAabbFunc(null):this._renderable.setAabbFunc(this._updateAabbFunc)}},{key:"mask",get:function(){return this._mask},set:function(t){this._mask!==t&&(this._mask=t,this._toggleMask())}},{key:"pixelsPerUnit",get:function(){return this._pixelsPerUnit},set:function(t){this._pixelsPerUnit!==t&&(this._pixelsPerUnit=t,!this._sprite||1!==this._sprite.renderMode&&2!==this._sprite.renderMode||this._updateSprite())}},{key:"aabb",get:function(){return this._renderable.meshInstance?this._renderable.meshInstance.aabb:null}}]),t}(),j_=function(t){function e(e){var i;return(i=t.call(this)||this)._app=e,e.i18n.on("set:locale",i._onSetLocale,w(i)),i._autoLoad=!1,i._disableLocalization=!1,i._defaultAsset=null,i._localizedAsset=null,i}S(e,t);var i=e.prototype;return i._bindDefaultAsset=function(){var t=this._app.assets.get(this._defaultAsset);t?this._onDefaultAssetAdd(t):this._app.assets.once("add:"+this._defaultAsset,this._onDefaultAssetAdd,this)},i._unbindDefaultAsset=function(){if(this._defaultAsset){this._app.assets.off("add:"+this._defaultAsset,this._onDefaultAssetAdd,this);var t=this._app.assets.get(this._defaultAsset);t&&(t.off("add:localized",this._onLocaleAdd,this),t.off("remove:localized",this._onLocaleRemove,this),t.off("remove",this._onDefaultAssetRemove,this))}},i._onDefaultAssetAdd=function(t){this._defaultAsset===t.id&&(t.on("add:localized",this._onLocaleAdd,this),t.on("remove:localized",this._onLocaleRemove,this),t.once("remove",this._onDefaultAssetRemove,this))},i._onDefaultAssetRemove=function(t){this._defaultAsset===t.id&&(t.off("add:localized",this._onLocaleAdd,this),t.off("remove:localized",this._onLocaleAdd,this),this._app.assets.once("add:"+this._defaultAsset,this._onDefaultAssetAdd,this))},i._bindLocalizedAsset=function(){if(this._autoLoad){var t=this._app.assets.get(this._localizedAsset);t&&(t.on("load",this._onLocalizedAssetLoad,this),t.on("change",this._onLocalizedAssetChange,this),t.on("remove",this._onLocalizedAssetRemove,this),t.resource?this._onLocalizedAssetLoad(t):this._app.assets.load(t))}},i._unbindLocalizedAsset=function(){var t=this._app.assets.get(this._localizedAsset);t&&(t.off("load",this._onLocalizedAssetLoad,this),t.off("change",this._onLocalizedAssetChange,this),t.off("remove",this._onLocalizedAssetRemove,this))},i._onLocalizedAssetAdd=function(t){this._localizedAsset===t.id&&this._bindLocalizedAsset()},i._onLocalizedAssetLoad=function(t){this.fire("load",t)},i._onLocalizedAssetChange=function(t,e,i,n){this.fire("change",t,e,i,n)},i._onLocalizedAssetRemove=function(t){this._localizedAsset===t.id&&(this.localizedAsset=this._defaultAsset),this.fire("remove",t)},i._onLocaleAdd=function(t,e){this._app.i18n.locale===t&&this._onSetLocale(t)},i._onLocaleRemove=function(t,e){this._app.i18n.locale===t&&this._onSetLocale(t)},i._onSetLocale=function(t){if(this._defaultAsset){var e=this._app.assets.get(this._defaultAsset);if(e&&!this._disableLocalization){var i=e.getLocalizedAssetId(t);this.localizedAsset=i||this._defaultAsset}else this.localizedAsset=this._defaultAsset}else this.localizedAsset=null},i.destroy=function(){this.defaultAsset=null,this._app.i18n.off("set:locale",this._onSetLocale,this),this.off()},y(e,[{key:"defaultAsset",get:function(){return this._defaultAsset},set:function(t){var e=t instanceof $f?t.id:t;this._defaultAsset!==e&&(this._defaultAsset&&this._unbindDefaultAsset(),this._defaultAsset=e,this._defaultAsset&&this._bindDefaultAsset(),this._onSetLocale(this._app.i18n.locale))}},{key:"localizedAsset",get:function(){return this._localizedAsset},set:function(t){var e=t instanceof $f?t.id:t;this._localizedAsset!==e&&(this._localizedAsset&&(this._app.assets.off("add:"+this._localizedAsset,this._onLocalizedAssetAdd,this),this._unbindLocalizedAsset(),this._localizedAsset=null),this._localizedAsset=e,this._localizedAsset&&(this._app.assets.get(this._localizedAsset)?this._bindLocalizedAsset():this._app.assets.once("add:"+this._localizedAsset,this._onLocalizedAssetAdd,this)))}},{key:"autoLoad",get:function(){return this._autoLoad},set:function(t){this._autoLoad!==t&&(this._autoLoad=t,this._autoLoad&&this._localizedAsset&&(this._unbindLocalizedAsset(),this._bindLocalizedAsset()))}},{key:"disableLocalization",get:function(){return this._disableLocalization},set:function(t){this._disableLocalization!==t&&(this._disableLocalization=t,this._onSetLocale(this._app.i18n.locale))}}]),e}(P),Y_="msdf",K_="bitmap",Z_=/[A-Z|a-z|0-9|_|-|/]/,Q_=function(){function t(t){this._symbols=t,this._index=0,this._last=0,this._cur=this._symbols.length>0?this._symbols[0]:null,this._buf=[],this._mode="text",this._error=null}var e=t.prototype;return e.read=function(){for(var t=this._read();8===t;)t=this._read();return 0!==t&&1!==t&&(this._last=this._index),t},e.buf=function(){return this._buf},e.last=function(){return this._last},e.error=function(){return this._error},e.debugPrint=function(){for(var t=["EOF","ERROR","TEXT","OPEN_BRACKET","CLOSE_BRACKET","EQUALS","STRING","IDENTIFIER","WHITESPACE"],e=this.read(),i="";i+=(i.length>0?"\n":"")+t[e]+" '"+this.buf().join("")+"'",0!==e&&1!==e;)e=this.read();return i},e._read=function(){return this._buf=[],this._eof()?0:"text"===this._mode?this._text():this._tag()},e._text=function(){for(;;)switch(this._cur){case null:return this._buf.length>0?2:0;case"[":return this._mode="tag",this._buf.length>0?2:this._tag();case"\\":if(this._next(),"["===this._cur)this._store();else this._output("\\");break;default:this._store()}},e._tag=function(){switch(this._cur){case null:return this._error="unexpected end of input reading tag",1;case"[":return this._store(),3;case"]":return this._store(),this._mode="text",4;case"=":return this._store(),5;case" ":case"\t":case"\n":case"\r":case"\v":case"\f":return this._whitespace();case'"':return this._string();default:return this._isIdentifierSymbol(this._cur)?this._identifier():(this._error="unrecognized character",1)}},e._whitespace=function(){for(this._store();-1!==" \t\n\r\v\f".indexOf(this._cur);)this._store();return 8},e._string=function(){for(this._next();;)switch(this._cur){case null:return this._error="unexpected end of input reading string",1;case'"':return this._next(),6;default:this._store()}},e._identifier=function(){for(this._store();null!==this._cur&&this._isIdentifierSymbol(this._cur);)this._store();return 7},e._isIdentifierSymbol=function(t){return 1===t.length&&null!==t.match(Z_)},e._eof=function(){return null===this._cur},e._next=function(){return this._eof()||(this._index++,this._cur=this._index=0;--s)if(n==="/"+e[s].name&&null===e[s].end)return e[s].end=t.length,4===(i=this._scanner.read())||(this._error="expected close bracket",!1);return this._error="failed to find matching tag",!1}var r={name:n,value:null,attributes:{},start:t.length,end:null};if(5===(i=this._scanner.read())){if(6!==(i=this._scanner.read()))return this._error="expected string",!1;r.value=this._scanner.buf().join(""),i=this._scanner.read()}for(;;){switch(i){case 4:return e.push(r),!0;case 7:var a=this._scanner.buf().join("");if(5!==(i=this._scanner.read()))return this._error="expected equals",!1;if(6!==(i=this._scanner.read()))return this._error="expected string",!1;var o=this._scanner.buf().join("");r.attributes[a]=o;break;default:return this._error="expected close bracket or identifier",!1}i=this._scanner.read()}},t}();function J_(t,e){for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];n instanceof Object?(t.hasOwnProperty(i)||(t[i]={}),J_(t[i],e[i])):t[i]=n}}function tg(t){if(0===t.length)return null;for(var e={},i=0;i=1e-4,v=this._element.calculatedWidth;(this.autoWidth&&!g||!this._wrapLines)&&(v=Number.POSITIVE_INFINITY);var y,x,S,b,w=0,T=0;function A(t,i,n){e._lineWidths.push(Math.abs(n));var s=f>i?i+1:f,r=f>i?f+1:i,h=t.slice(s,r);if(_)for(var l=h.length;l--&&_>0;)rg.test(h[l])&&(h.splice(l,1),_--);e._lineContents.push(h.join("")),a=0,o-=e._scaledLineHeight,c++,p=0,m=0,_=0,u=0,f=i}for(var C=!0;C;){C=!1,this._scaledLineHeight=s?this._lineHeight*this._fontSize/(this._maxFontSize||1e-4):this._lineHeight,this.width=0,this.height=0,this._lineWidths=[],this._lineContents=[],a=0,o=0,h=0,l=0,c=1,u=0,d=0,f=0,p=0,m=0,_=0;var E=this._fontSize/32;w=this._fontMinY*E,T=this._fontMaxY*E;for(var M=0;M=r?null:this._symbols[U+1],rg.test(y))_++,(!this._wrapLines||this._maxLines<0||c0){var q=this._font.data.kerning;if(q){var j=q[rt.getCodePoint(this._symbols[U-1])||0];j&&(X=j[rt.getCodePoint(this._symbols[U])||0]||0)}}H=x.scale||1,G=E*((x.width+x.height)/2)/H,V=(x.xadvance+X)*E,N=(x.xoffset-X)*E,z=x.yoffset*E}else console.error("Couldn't substitute missing character: '"+y+"'");var Y=ag.test(y),K=x&&x.map||0,Z=-this._font.data.info.maps[K].width/this._font.data.info.maps[K].height,Q=this._meshInfo[K],$=a+this._spacing*V;if($>v&&m>0&&!Y&&(this._maxLines<0||cthis._element.calculatedWidth&&(ut=Math.floor(this._element.fontSize*this._element.calculatedWidth/(this.width||1e-4)),(ut=_t.clamp(ut,i,n))!==this._element.fontSize)){this._fontSize=ut,C=!0;break}if(this.height=Math.max(this.height,T-(o+w)),this._shouldAutoFitHeight()&&this.height>this._element.calculatedHeight&&(ut=_t.clamp(this._fontSize-1,i,n))!==this._element.fontSize){this._fontSize=ut,C=!0;break}a+=this._spacing*V,Y||(l=a),(this._isWordBoundary(y)||this._isValidNextChar(b)&&(this._isNextCJKBoundary(y,b)||this._isNextCJKWholeWord(b)))&&(p++,u=l,d=U+1),m++;var dt=this._getUv(y);if(Q.uvs[4*S*2+0]=dt[0],Q.uvs[4*S*2+1]=1-dt[1],Q.uvs[4*S*2+2]=dt[2],Q.uvs[4*S*2+3]=1-dt[1],Q.uvs[4*S*2+4]=dt[2],Q.uvs[4*S*2+5]=1-dt[3],Q.uvs[4*S*2+6]=dt[0],Q.uvs[4*S*2+7]=1-dt[3],this._symbolColors){var ft=3*this._symbolColors[U];P=this._colorPalette[ft],R=this._colorPalette[ft+1],I=this._colorPalette[ft+2]}if(Q.colors[4*S*4+0]=P,Q.colors[4*S*4+1]=R,Q.colors[4*S*4+2]=I,Q.colors[4*S*4+3]=255,Q.colors[4*S*4+4]=P,Q.colors[4*S*4+5]=R,Q.colors[4*S*4+6]=I,Q.colors[4*S*4+7]=255,Q.colors[4*S*4+8]=P,Q.colors[4*S*4+9]=R,Q.colors[4*S*4+10]=I,Q.colors[4*S*4+11]=255,Q.colors[4*S*4+12]=P,Q.colors[4*S*4+13]=R,Q.colors[4*S*4+14]=I,Q.colors[4*S*4+15]=255,this._symbolOutlineParams){var pt=5*this._symbolOutlineParams[U];L=this._outlinePalette[pt]+256*this._outlinePalette[pt+1],D=this._outlinePalette[pt+2]+256*this._outlinePalette[pt+3],O=this._outlinePalette[pt+4]}if(Q.outlines[4*S*3+0]=L,Q.outlines[4*S*3+1]=D,Q.outlines[4*S*3+2]=O,Q.outlines[4*S*3+3]=L,Q.outlines[4*S*3+4]=D,Q.outlines[4*S*3+5]=O,Q.outlines[4*S*3+6]=L,Q.outlines[4*S*3+7]=D,Q.outlines[4*S*3+8]=O,Q.outlines[4*S*3+9]=L,Q.outlines[4*S*3+10]=D,Q.outlines[4*S*3+11]=O,this._symbolShadowParams){var mt=6*this._symbolShadowParams[U];k=this._shadowPalette[mt]+256*this._shadowPalette[mt+1],F=this._shadowPalette[mt+2]+256*this._shadowPalette[mt+3],B=this._shadowPalette[mt+4]+127+256*Math.round(Z*this._shadowPalette[mt+5]+127)}Q.shadows[4*S*3+0]=k,Q.shadows[4*S*3+1]=F,Q.shadows[4*S*3+2]=B,Q.shadows[4*S*3+3]=k,Q.shadows[4*S*3+4]=F,Q.shadows[4*S*3+5]=B,Q.shadows[4*S*3+6]=k,Q.shadows[4*S*3+7]=F,Q.shadows[4*S*3+8]=B,Q.shadows[4*S*3+9]=k,Q.shadows[4*S*3+10]=F,Q.shadows[4*S*3+11]=B,Q.quad++}}C||f=kt?(Ft.element[Ee].set(0,0,0),Ft.element[Oe].set(0,0),Ft.element[Le].set(0,0,0,0),Ft.element[Qe].set(0,0,0,0),Ft.element[$e].set(0,0,0,0)):(Ft.element[Ee].set(this._meshInfo[St].positions[3*Bt+0],this._meshInfo[St].positions[3*Bt+1],this._meshInfo[St].positions[3*Bt+2]),Ft.element[Oe].set(this._meshInfo[St].uvs[2*Bt+0],this._meshInfo[St].uvs[2*Bt+1]),Ft.element[Le].set(this._meshInfo[St].colors[4*Bt+0],this._meshInfo[St].colors[4*Bt+1],this._meshInfo[St].colors[4*Bt+2],this._meshInfo[St].colors[4*Bt+3]),Ft.element[Qe].set(this._meshInfo[St].outlines[3*Bt+0],this._meshInfo[St].outlines[3*Bt+1],this._meshInfo[St].outlines[3*Bt+2]),Ft.element[$e].set(this._meshInfo[St].shadows[3*Bt+0],this._meshInfo[St].shadows[3*Bt+1],this._meshInfo[St].shadows[3*Bt+2])),Ft.next();Ft.end(),this._meshInfo[St].meshInstance.mesh.aabb.compute(this._meshInfo[St].positions),this._meshInfo[St].meshInstance._aabbVer=-1}this._aabbDirty=!0},e._onFontRender=function(){this.font=this._font},e._onFontLoad=function(t){this.font!==t.resource&&(this.font=t.resource)},e._onFontChange=function(t,e,i,n){if("data"===e){this._font.data=i;for(var s=this._font.data.info.maps.length,r=0;rthis._font.textures.length&&(this._meshInfo.length=this._font.textures.length),this._updateText()}}},{key:"alignment",get:function(){return this._alignment},set:function(t){t instanceof It?this._alignment.set(t.x,t.y):this._alignment.set(t[0],t[1]),this._font&&this._updateText()}},{key:"autoWidth",get:function(){return this._autoWidth},set:function(t){var e=this._autoWidth;if(this._autoWidth=t,t&&Math.abs(this._element.anchor.x-this._element.anchor.z)<1e-4&&(this._element.width=this.width),e!==t){var i=this._shouldAutoFit()?this._maxFontSize:this._originalFontSize;i!==this._fontSize&&(this._fontSize=i,this._font&&this._updateText())}}},{key:"autoHeight",get:function(){return this._autoHeight},set:function(t){var e=this._autoHeight;if(this._autoHeight=t,t&&Math.abs(this._element.anchor.y-this._element.anchor.w)<1e-4&&(this._element.height=this.height),e!==t){var i=this._shouldAutoFit()?this._maxFontSize:this._originalFontSize;i!==this._fontSize&&(this._fontSize=i,this._font&&this._updateText())}}},{key:"rtlReorder",get:function(){return this._rtlReorder},set:function(t){this._rtlReorder!==t&&(this._rtlReorder=t,this._font&&this._updateText())}},{key:"unicodeConverter",get:function(){return this._unicodeConverter},set:function(t){this._unicodeConverter!==t&&(this._unicodeConverter=t,this._setText(this._text))}},{key:"aabb",get:function(){if(this._aabbDirty){for(var t=!1,e=0;e=0&&this.system._prerender.splice(i,1),this.system._prerender.indexOf(t)<0&&this.system._prerender.push(t)}t=e}},i._onPrerender=function(){for(var t=0;t=0)&&(null==(t=this.system.app.batcher)||t.insert(Qo.ELEMENT,this.batchGroupId,this.entity));this.fire("enableelement")},i.onDisable=function(){var t;(this.system.app.scene.off("set:layers",this.onLayersChanged,this),this.system.app.scene.layers&&(this.system.app.scene.layers.off("add",this.onLayerAdded,this),this.system.app.scene.layers.off("remove",this.onLayerRemoved,this)),this._image&&this._image.onDisable(),this._text&&this._text.onDisable(),this._group&&this._group.onDisable(),this.system.app.elementInput&&this.useInput&&this.system.app.elementInput.removeElement(this),this._batchGroupId>=0)&&(null==(t=this.system.app.batcher)||t.remove(Qo.ELEMENT,this.batchGroupId,this.entity));this.fire("disableelement")},i.onRemove=function(){this.entity.off("insert",this._onInsert,this),this._unpatch(),this._image&&this._image.destroy(),this._text&&this._text.destroy(),this.system.app.elementInput&&this.useInput&&this.system.app.elementInput.removeElement(this),this.screen&&this.screen.screen&&(this._unbindScreen(this.screen.screen),this.screen.screen.syncDrawOrder()),this.off()},i._calculateSize=function(t,e){if(this.entity._parent||this.screen){this._calculateLocalAnchors();var i=this._absRight-this._absLeft,n=this._absTop-this._absBottom;t?this._setWidth(i):this._setCalculatedWidth(i,!1),e?this._setHeight(n):this._setCalculatedHeight(n,!1);var s=this.entity.getLocalPosition();s.x=this._margin.x+this._calculatedWidth*this._pivot.x,s.y=this._margin.y+this._calculatedHeight*this._pivot.y,this.entity.setLocalPosition(s),this._sizeDirty=!1}},i._setWidth=function(t){this._width=t,this._setCalculatedWidth(t,!1),this.fire("set:width",this._width)},i._setHeight=function(t){this._height=t,this._setCalculatedHeight(t,!1),this.fire("set:height",this._height)},i._setCalculatedWidth=function(t,e){if(!(Math.abs(t-this._calculatedWidth)<=1e-4)){if(this._calculatedWidth=t,this.entity._dirtifyLocal(),e){var i=this.entity.getLocalPosition(),n=this._pivot;this._margin.x=i.x-this._calculatedWidth*n.x,this._margin.z=this._localAnchor.z-this._localAnchor.x-this._calculatedWidth-this._margin.x}this._flagChildrenAsDirty(),this.fire("set:calculatedWidth",this._calculatedWidth),this.fire("resize",this._calculatedWidth,this._calculatedHeight)}},i._setCalculatedHeight=function(t,e){if(!(Math.abs(t-this._calculatedHeight)<=1e-4)){if(this._calculatedHeight=t,this.entity._dirtifyLocal(),e){var i=this.entity.getLocalPosition(),n=this._pivot;this._margin.y=i.y-this._calculatedHeight*n.y,this._margin.w=this._localAnchor.w-this._localAnchor.y-this._calculatedHeight-this._margin.y}this._flagChildrenAsDirty(),this.fire("set:calculatedHeight",this._calculatedHeight),this.fire("resize",this._calculatedWidth,this._calculatedHeight)}},i._flagChildrenAsDirty=function(){for(var t=this.entity._children,e=0,i=t.length;e=0&&this._addedModels.splice(e,1);for(var i=0;ii||f>n||p.001}},{key:"_hasSplitAnchorsY",get:function(){return Math.abs(this._anchor.y-this._anchor.w)>.001}},{key:"aabb",get:function(){return this._image?this._image.aabb:this._text?this._text.aabb:null}},{key:"anchor",get:function(){return this._anchor},set:function(t){var e;t instanceof Dt?this._anchor.copy(t):(e=this._anchor).set.apply(e,t);this.entity._parent||this.screen?this._calculateSize(this._hasSplitAnchorsX,this._hasSplitAnchorsY):this._calculateLocalAnchors(),this._anchorDirty=!0,this.entity._dirtyLocal||this.entity._dirtifyLocal(),this.fire("set:anchor",this._anchor)}},{key:"batchGroupId",get:function(){return this._batchGroupId},set:function(t){if(this._batchGroupId!==t){var e,i;if(this.entity.enabled&&this._batchGroupId>=0)null==(e=this.system.app.batcher)||e.remove(Qo.ELEMENT,this.batchGroupId,this.entity);if(this.entity.enabled&&t>=0)null==(i=this.system.app.batcher)||i.insert(Qo.ELEMENT,t,this.entity);t<0&&this._batchGroupId>=0&&this.enabled&&this.entity.enabled&&(this._image&&this._image._renderable.model?this.addModelToLayers(this._image._renderable.model):this._text&&this._text._model&&this.addModelToLayers(this._text._model)),this._batchGroupId=t}}},{key:"bottom",get:function(){return this._margin.y},set:function(t){this._margin.y=t;var e=this.entity.getLocalPosition(),i=this._absTop,n=this._localAnchor.y+t;this._setHeight(i-n),e.y=t+this._calculatedHeight*this._pivot.y,this.entity.setLocalPosition(e)}},{key:"calculatedWidth",get:function(){return this._calculatedWidth},set:function(t){this._setCalculatedWidth(t,!0)}},{key:"calculatedHeight",get:function(){return this._calculatedHeight},set:function(t){this._setCalculatedHeight(t,!0)}},{key:"canvasCorners",get:function(){if(!this._canvasCornersDirty||!this.screen||!this.screen.screen.screenSpace)return this._canvasCorners;for(var t=this.system.app.graphicsDevice,e=this.screenCorners,i=t.canvas.clientWidth/t.width,n=t.canvas.clientHeight/t.height,s=0;s<4;s++)this._canvasCorners[s].set(e[s].x*i,(t.height-e[s].y)*n);return this._canvasCornersDirty=!1,this._canvasCorners}},{key:"drawOrder",get:function(){return this._drawOrder},set:function(t){var e=0;this.screen&&(e=this.screen.screen.priority),t>16777215&&(t=16777215),this._drawOrder=(e<<24)+t,this.fire("set:draworder",this._drawOrder)}},{key:"height",get:function(){return this._height},set:function(t){this._height=t,this._hasSplitAnchorsY||this._setCalculatedHeight(t,!0),this.fire("set:height",this._height)}},{key:"layers",get:function(){return this._layers},set:function(t){if(this._addedModels.length)for(var e=0;e.001,a=Math.abs(e.anchor.y-e.anchor.w)>.001,o=!1;void 0!==i.margin&&(i.margin instanceof Dt?e.margin.copy(i.margin):e._margin.set(i.margin[0],i.margin[1],i.margin[2],i.margin[3]),o=!0),void 0!==i.left&&(e._margin.x=i.left,o=!0),void 0!==i.bottom&&(e._margin.y=i.bottom,o=!0),void 0!==i.right&&(e._margin.z=i.right,o=!0),void 0!==i.top&&(e._margin.w=i.top,o=!0),o&&(e.margin=e._margin);var h=!1;void 0===i.width||r?r&&(h=!0):e.width=i.width,void 0===i.height||a?a&&(h=!0):e.height=i.height,h&&(e.anchor=e.anchor),void 0!==i.enabled&&(e.enabled=i.enabled),void 0!==i.useInput&&(e.useInput=i.useInput),void 0!==i.fitMode&&(e.fitMode=i.fitMode),e.batchGroupId=void 0===i.batchGroupId||null===i.batchGroupId?-1:i.batchGroupId,i.layers&&Array.isArray(i.layers)&&(e.layers=i.layers.slice(0)),void 0!==i.type&&(e.type=i.type),e.type===Jm?(void 0!==i.rect&&(e.rect=i.rect),void 0!==i.color&&((s=i.color)instanceof gt||(s=new gt(i.color[0],i.color[1],i.color[2])),e.color=s),void 0!==i.opacity&&(e.opacity=i.opacity),void 0!==i.textureAsset&&(e.textureAsset=i.textureAsset),i.texture&&(e.texture=i.texture),void 0!==i.spriteAsset&&(e.spriteAsset=i.spriteAsset),i.sprite&&(e.sprite=i.sprite),void 0!==i.spriteFrame&&(e.spriteFrame=i.spriteFrame),void 0!==i.pixelsPerUnit&&null!==i.pixelsPerUnit&&(e.pixelsPerUnit=i.pixelsPerUnit),void 0!==i.materialAsset&&(e.materialAsset=i.materialAsset),i.material&&(e.material=i.material),void 0!==i.mask&&(e.mask=i.mask)):e.type===t_&&(void 0!==i.autoWidth&&(e.autoWidth=i.autoWidth),void 0!==i.autoHeight&&(e.autoHeight=i.autoHeight),void 0!==i.rtlReorder&&(e.rtlReorder=i.rtlReorder),void 0!==i.unicodeConverter&&(e.unicodeConverter=i.unicodeConverter),null!==i.text&&void 0!==i.text?e.text=i.text:null!==i.key&&void 0!==i.key&&(e.key=i.key),void 0!==i.color&&((s=i.color)instanceof gt||(s=new gt(s[0],s[1],s[2])),e.color=s),void 0!==i.opacity&&(e.opacity=i.opacity),void 0!==i.spacing&&(e.spacing=i.spacing),void 0!==i.fontSize&&(e.fontSize=i.fontSize,i.lineHeight||(e.lineHeight=i.fontSize)),void 0!==i.lineHeight&&(e.lineHeight=i.lineHeight),void 0!==i.maxLines&&(e.maxLines=i.maxLines),void 0!==i.wrapLines&&(e.wrapLines=i.wrapLines),void 0!==i.minFontSize&&(e.minFontSize=i.minFontSize),void 0!==i.maxFontSize&&(e.maxFontSize=i.maxFontSize),i.autoFitWidth&&(e.autoFitWidth=i.autoFitWidth),i.autoFitHeight&&(e.autoFitHeight=i.autoFitHeight),void 0!==i.fontAsset&&(e.fontAsset=i.fontAsset),void 0!==i.font&&(e.font=i.font),void 0!==i.alignment&&(e.alignment=i.alignment),void 0!==i.outlineColor&&(e.outlineColor=i.outlineColor),void 0!==i.outlineThickness&&(e.outlineThickness=i.outlineThickness),void 0!==i.shadowColor&&(e.shadowColor=i.shadowColor),void 0!==i.shadowOffset&&(e.shadowOffset=i.shadowOffset),void 0!==i.enableMarkup&&(e.enableMarkup=i.enableMarkup));var l=e._parseUpToScreen();l.screen&&e._updateScreen(l.screen),t.prototype.initializeComponentData.call(this,e,i,n),e._beingInitialized=!1,e.type===Jm&&e._image._meshDirty&&e._image._updateMesh(e._image.mesh)},i.onRemoveComponent=function(t,e){e.onRemove()},i.cloneComponent=function(t,e){var i=t.element,n={enabled:i.enabled,width:i.width,height:i.height,anchor:i.anchor.clone(),pivot:i.pivot.clone(),margin:i.margin.clone(),alignment:i.alignment&&i.alignment.clone()||i.alignment,autoWidth:i.autoWidth,autoHeight:i.autoHeight,type:i.type,rect:i.rect&&i.rect.clone()||i.rect,rtlReorder:i.rtlReorder,unicodeConverter:i.unicodeConverter,materialAsset:i.materialAsset,material:i.material,color:i.color&&i.color.clone()||i.color,opacity:i.opacity,textureAsset:i.textureAsset,texture:i.texture,spriteAsset:i.spriteAsset,sprite:i.sprite,spriteFrame:i.spriteFrame,pixelsPerUnit:i.pixelsPerUnit,spacing:i.spacing,lineHeight:i.lineHeight,wrapLines:i.wrapLines,layers:i.layers,fontSize:i.fontSize,minFontSize:i.minFontSize,maxFontSize:i.maxFontSize,autoFitWidth:i.autoFitWidth,autoFitHeight:i.autoFitHeight,maxLines:i.maxLines,fontAsset:i.fontAsset,font:i.font,useInput:i.useInput,fitMode:i.fitMode,batchGroupId:i.batchGroupId,mask:i.mask,outlineColor:i.outlineColor&&i.outlineColor.clone()||i.outlineColor,outlineThickness:i.outlineThickness,shadowColor:i.shadowColor&&i.shadowColor.clone()||i.shadowColor,shadowOffset:i.shadowOffset&&i.shadowOffset.clone()||i.shadowOffset,enableMarkup:i.enableMarkup};return void 0!==i.key&&null!==i.key?n.key=i.key:n.text=i.text,this.addComponent(e,n)},i.getTextElementMaterial=function(t,e,i){var n=(t&&1)|(e&&2)|(i&&4),s=this._defaultTextMaterials[n];if(s)return s;var r="TextMaterial";return s=new vu,e?(s.msdfMap=this._defaultTexture,s.msdfTextAttribute=i,s.emissive.set(1,1,1)):(r="Bitmap"+r,s.emissive.set(.5,.5,.5),s.emissiveMap=this._defaultTexture,s.emissiveTint=!0,s.opacityMap=this._defaultTexture,s.opacityMapChannel="a"),t&&(r="ScreenSpace"+r,s.depthTest=!1),s.name="default"+r,s.useLighting=!1,s.useGammaTonemap=!1,s.useFog=!1,s.useSkybox=!1,s.diffuse.set(0,0,0),s.opacity=.5,s.blendType=4,s.depthWrite=!1,s.emissiveVertexColor=!0,s.update(),this._defaultTextMaterials[n]=s,s},i._createBaseImageMaterial=function(){var t=new vu;return t.diffuse.set(0,0,0),t.emissive.set(.5,.5,.5),t.emissiveMap=this._defaultTexture,t.emissiveTint=!0,t.opacityMap=this._defaultTexture,t.opacityMapChannel="a",t.opacityTint=!0,t.opacity=0,t.useLighting=!1,t.useGammaTonemap=!1,t.useFog=!1,t.useSkybox=!1,t.blendType=4,t.depthWrite=!1,t},i.getImageElementMaterial=function(t,e,i,n){return t?e?i?(this.defaultScreenSpaceImageMask9SlicedMaterial||(this.defaultScreenSpaceImageMask9SlicedMaterial=this._createBaseImageMaterial(),this.defaultScreenSpaceImageMask9SlicedMaterial.name="defaultScreenSpaceImageMask9SlicedMaterial",this.defaultScreenSpaceImageMask9SlicedMaterial.nineSlicedMode=1,this.defaultScreenSpaceImageMask9SlicedMaterial.depthTest=!1,this.defaultScreenSpaceImageMask9SlicedMaterial.alphaTest=1,this.defaultScreenSpaceImageMask9SlicedMaterial.redWrite=!1,this.defaultScreenSpaceImageMask9SlicedMaterial.greenWrite=!1,this.defaultScreenSpaceImageMask9SlicedMaterial.blueWrite=!1,this.defaultScreenSpaceImageMask9SlicedMaterial.alphaWrite=!1,this.defaultScreenSpaceImageMask9SlicedMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImageMask9SlicedMaterial)),this.defaultScreenSpaceImageMask9SlicedMaterial):n?(this.defaultScreenSpaceImageMask9TiledMaterial||(this.defaultScreenSpaceImageMask9TiledMaterial=this.defaultScreenSpaceImage9TiledMaterial.clone(),this.defaultScreenSpaceImageMask9TiledMaterial.name="defaultScreenSpaceImageMask9TiledMaterial",this.defaultScreenSpaceImageMask9TiledMaterial.nineSlicedMode=2,this.defaultScreenSpaceImageMask9TiledMaterial.depthTest=!1,this.defaultScreenSpaceImageMask9TiledMaterial.alphaTest=1,this.defaultScreenSpaceImageMask9TiledMaterial.redWrite=!1,this.defaultScreenSpaceImageMask9TiledMaterial.greenWrite=!1,this.defaultScreenSpaceImageMask9TiledMaterial.blueWrite=!1,this.defaultScreenSpaceImageMask9TiledMaterial.alphaWrite=!1,this.defaultScreenSpaceImageMask9TiledMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImageMask9TiledMaterial)),this.defaultScreenSpaceImageMask9TiledMaterial):(this.defaultScreenSpaceImageMaskMaterial||(this.defaultScreenSpaceImageMaskMaterial=this._createBaseImageMaterial(),this.defaultScreenSpaceImageMaskMaterial.name="defaultScreenSpaceImageMaskMaterial",this.defaultScreenSpaceImageMaskMaterial.depthTest=!1,this.defaultScreenSpaceImageMaskMaterial.alphaTest=1,this.defaultScreenSpaceImageMaskMaterial.redWrite=!1,this.defaultScreenSpaceImageMaskMaterial.greenWrite=!1,this.defaultScreenSpaceImageMaskMaterial.blueWrite=!1,this.defaultScreenSpaceImageMaskMaterial.alphaWrite=!1,this.defaultScreenSpaceImageMaskMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImageMaskMaterial)),this.defaultScreenSpaceImageMaskMaterial):i?(this.defaultScreenSpaceImage9SlicedMaterial||(this.defaultScreenSpaceImage9SlicedMaterial=this._createBaseImageMaterial(),this.defaultScreenSpaceImage9SlicedMaterial.name="defaultScreenSpaceImage9SlicedMaterial",this.defaultScreenSpaceImage9SlicedMaterial.nineSlicedMode=1,this.defaultScreenSpaceImage9SlicedMaterial.depthTest=!1,this.defaultScreenSpaceImage9SlicedMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImage9SlicedMaterial)),this.defaultScreenSpaceImage9SlicedMaterial):n?(this.defaultScreenSpaceImage9TiledMaterial||(this.defaultScreenSpaceImage9TiledMaterial=this._createBaseImageMaterial(),this.defaultScreenSpaceImage9TiledMaterial.name="defaultScreenSpaceImage9TiledMaterial",this.defaultScreenSpaceImage9TiledMaterial.nineSlicedMode=2,this.defaultScreenSpaceImage9TiledMaterial.depthTest=!1,this.defaultScreenSpaceImage9TiledMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImage9TiledMaterial)),this.defaultScreenSpaceImage9TiledMaterial):(this.defaultScreenSpaceImageMaterial||(this.defaultScreenSpaceImageMaterial=this._createBaseImageMaterial(),this.defaultScreenSpaceImageMaterial.name="defaultScreenSpaceImageMaterial",this.defaultScreenSpaceImageMaterial.depthTest=!1,this.defaultScreenSpaceImageMaterial.update(),this.defaultImageMaterials.push(this.defaultScreenSpaceImageMaterial)),this.defaultScreenSpaceImageMaterial):e?i?(this.defaultImage9SlicedMaskMaterial||(this.defaultImage9SlicedMaskMaterial=this._createBaseImageMaterial(),this.defaultImage9SlicedMaskMaterial.name="defaultImage9SlicedMaskMaterial",this.defaultImage9SlicedMaskMaterial.nineSlicedMode=1,this.defaultImage9SlicedMaskMaterial.alphaTest=1,this.defaultImage9SlicedMaskMaterial.redWrite=!1,this.defaultImage9SlicedMaskMaterial.greenWrite=!1,this.defaultImage9SlicedMaskMaterial.blueWrite=!1,this.defaultImage9SlicedMaskMaterial.alphaWrite=!1,this.defaultImage9SlicedMaskMaterial.update(),this.defaultImageMaterials.push(this.defaultImage9SlicedMaskMaterial)),this.defaultImage9SlicedMaskMaterial):n?(this.defaultImage9TiledMaskMaterial||(this.defaultImage9TiledMaskMaterial=this._createBaseImageMaterial(),this.defaultImage9TiledMaskMaterial.name="defaultImage9TiledMaskMaterial",this.defaultImage9TiledMaskMaterial.nineSlicedMode=2,this.defaultImage9TiledMaskMaterial.alphaTest=1,this.defaultImage9TiledMaskMaterial.redWrite=!1,this.defaultImage9TiledMaskMaterial.greenWrite=!1,this.defaultImage9TiledMaskMaterial.blueWrite=!1,this.defaultImage9TiledMaskMaterial.alphaWrite=!1,this.defaultImage9TiledMaskMaterial.update(),this.defaultImageMaterials.push(this.defaultImage9TiledMaskMaterial)),this.defaultImage9TiledMaskMaterial):(this.defaultImageMaskMaterial||(this.defaultImageMaskMaterial=this._createBaseImageMaterial(),this.defaultImageMaskMaterial.name="defaultImageMaskMaterial",this.defaultImageMaskMaterial.alphaTest=1,this.defaultImageMaskMaterial.redWrite=!1,this.defaultImageMaskMaterial.greenWrite=!1,this.defaultImageMaskMaterial.blueWrite=!1,this.defaultImageMaskMaterial.alphaWrite=!1,this.defaultImageMaskMaterial.update(),this.defaultImageMaterials.push(this.defaultImageMaskMaterial)),this.defaultImageMaskMaterial):i?(this.defaultImage9SlicedMaterial||(this.defaultImage9SlicedMaterial=this._createBaseImageMaterial(),this.defaultImage9SlicedMaterial.name="defaultImage9SlicedMaterial",this.defaultImage9SlicedMaterial.nineSlicedMode=1,this.defaultImage9SlicedMaterial.update(),this.defaultImageMaterials.push(this.defaultImage9SlicedMaterial)),this.defaultImage9SlicedMaterial):n?(this.defaultImage9TiledMaterial||(this.defaultImage9TiledMaterial=this._createBaseImageMaterial(),this.defaultImage9TiledMaterial.name="defaultImage9TiledMaterial",this.defaultImage9TiledMaterial.nineSlicedMode=2,this.defaultImage9TiledMaterial.update(),this.defaultImageMaterials.push(this.defaultImage9TiledMaterial)),this.defaultImage9TiledMaterial):(this.defaultImageMaterial||(this.defaultImageMaterial=this._createBaseImageMaterial(),this.defaultImageMaterial.name="defaultImageMaterial",this.defaultImageMaterial.update(),this.defaultImageMaterials.push(this.defaultImageMaterial)),this.defaultImageMaterial)},i.registerUnicodeConverter=function(t){this._unicodeConverter=t},i.registerRtlReorder=function(t){this._rtlReorder=t},i.getUnicodeConverter=function(){return this._unicodeConverter},i.getRtlReorder=function(){return this._rtlReorder},e}(Op);Dp._buildAccessors(Tg.prototype,Eg);var Pg="free",Rg="limited",Ig="locked",Lg=["angularDampingX","angularDampingY","angularDampingZ","angularEquilibriumX","angularEquilibriumY","angularEquilibriumZ","angularLimitsX","angularLimitsY","angularLimitsZ","angularMotionX","angularMotionY","angularMotionZ","angularSpringX","angularSpringY","angularSpringZ","angularStiffnessX","angularStiffnessY","angularStiffnessZ","breakForce","enableCollision","enabled","entityA","entityB","linearDampingX","linearDampingY","linearDampingZ","linearEquilibriumX","linearEquilibriumY","linearEquilibriumZ","linearLimitsX","linearLimitsY","linearLimitsZ","linearMotionX","linearMotionY","linearMotionZ","linearSpringX","linearSpringY","linearSpringZ","linearStiffnessX","linearStiffnessY","linearStiffnessZ"],Dg=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._constraint=null,n._entityA=null,n._entityB=null,n._breakForce=34e37,n._enableCollision=!0,n._linearMotionX=Ig,n._linearLimitsX=new It(0,0),n._linearSpringX=!1,n._linearStiffnessX=0,n._linearDampingX=1,n._linearEquilibriumX=0,n._linearMotionY=Ig,n._linearLimitsY=new It(0,0),n._linearSpringY=!1,n._linearStiffnessY=0,n._linearDampingY=1,n._linearEquilibriumY=0,n._linearMotionZ=Ig,n._linearLimitsZ=new It(0,0),n._linearSpringZ=!1,n._linearStiffnessZ=0,n._linearDampingZ=1,n._linearEquilibriumZ=0,n._angularMotionX=Ig,n._angularLimitsX=new It(0,0),n._angularSpringX=!1,n._angularStiffnessX=0,n._angularDampingX=1,n._angularEquilibriumX=0,n._angularMotionY=Ig,n._angularLimitsY=new It(0,0),n._angularSpringY=!1,n._angularStiffnessY=0,n._angularDampingY=1,n._angularEquilibriumY=0,n._angularMotionZ=Ig,n._angularLimitsZ=new It(0,0),n._angularSpringZ=!1,n._angularEquilibriumZ=0,n._angularDampingZ=1,n._angularStiffnessZ=0,n.on("set_enabled",n._onSetEnabled,w(n)),n}S(e,t);var i=e.prototype;return i._convertTransform=function(t,e){var i=t.getTranslation(),n=new Vt;n.setFromMat4(t);var s=new Ammo.btVector3(i.x,i.y,i.z),r=new Ammo.btQuaternion(n.x,n.y,n.z,n.w);e.setOrigin(s),e.setRotation(r),Ammo.destroy(s),Ammo.destroy(r)},i._updateAngularLimits=function(){var t=this._constraint;if(t){var e,i,n,s,r,a;this._angularMotionX===Rg?(e=this._angularLimitsX.x*_t.DEG_TO_RAD,s=this._angularLimitsX.y*_t.DEG_TO_RAD):this._angularMotionX===Pg?(e=1,s=0):e=s=0,this._angularMotionY===Rg?(i=this._angularLimitsY.x*_t.DEG_TO_RAD,r=this._angularLimitsY.y*_t.DEG_TO_RAD):this._angularMotionY===Pg?(i=1,r=0):i=r=0,this._angularMotionZ===Rg?(n=this._angularLimitsZ.x*_t.DEG_TO_RAD,a=this._angularLimitsZ.y*_t.DEG_TO_RAD):this._angularMotionZ===Pg?(n=1,a=0):n=a=0;var o=new Ammo.btVector3(e,i,n);t.setAngularLowerLimit(o),o.setValue(s,r,a),t.setAngularUpperLimit(o),Ammo.destroy(o)}},i._updateLinearLimits=function(){var t=this._constraint;if(t){var e,i,n,s,r,a;this._linearMotionX===Rg?(e=this._linearLimitsX.x,s=this._linearLimitsX.y):this._linearMotionX===Pg?(e=1,s=0):e=s=0,this._linearMotionY===Rg?(i=this._linearLimitsY.x,r=this._linearLimitsY.y):this._linearMotionY===Pg?(i=1,r=0):i=r=0,this._linearMotionZ===Rg?(n=this._linearLimitsZ.x,a=this._linearLimitsZ.y):this._linearMotionZ===Pg?(n=1,a=0):n=a=0;var o=new Ammo.btVector3(e,i,n);t.setLinearLowerLimit(o),o.setValue(s,r,a),t.setLinearUpperLimit(o),Ammo.destroy(o)}},i._createConstraint=function(){if(this._entityA&&this._entityA.rigidbody){this._destroyConstraint();var t=new zt,e=this._entityA.rigidbody.body;e.activate();var i=this.entity.getWorldTransform(),n=this._entityA.getWorldTransform().clone().invert();t.mul2(n,i);var s=new Ammo.btTransform;if(this._convertTransform(t,s),this._entityB&&this._entityB.rigidbody){var r=this._entityB.rigidbody.body;r.activate();var a=this._entityB.getWorldTransform().clone().invert();t.mul2(a,i);var o=new Ammo.btTransform;this._convertTransform(t,o),this._constraint=new Ammo.btGeneric6DofSpringConstraint(e,r,s,o,!this._enableCollision),Ammo.destroy(o)}else this._constraint=new Ammo.btGeneric6DofSpringConstraint(e,s,!this._enableCollision);Ammo.destroy(s);for(var h=["X","Y","Z","X","Y","Z"],l=0;l<6;l++){var c=l<3?"_linear":"_angular";this._constraint.enableSpring(l,this[c+"Spring"+h[l]]),this._constraint.setDamping(l,this[c+"Damping"+h[l]]),this._constraint.setEquilibriumPoint(l,this[c+"Equilibrium"+h[l]]),this._constraint.setStiffness(l,this[c+"Stiffness"+h[l]])}this._constraint.setBreakingImpulseThreshold(this._breakForce),this._updateLinearLimits(),this._updateAngularLimits(),this.system.app.systems.rigidbody.dynamicsWorld.addConstraint(this._constraint,!this._enableCollision)}},i._destroyConstraint=function(){this._constraint&&(this.system.app.systems.rigidbody.dynamicsWorld.removeConstraint(this._constraint),Ammo.destroy(this._constraint),this._constraint=null)},i.initFromData=function(t){for(var e=0,i=Lg;e=i?jg:Xg;case 3:return e=0;--n)i[e[n]]=i[e[n+1]]+t[e[n]];return i}return function(t,d){t=t.filter(o),e=d,Yg.x=e.containerSize.x-e.padding.x-e.padding.z,Yg.y=e.containerSize.y-e.padding.y-e.padding.w,function(t){for(var e=0;e0&&(r+=e.spacing[i.axis]);var h=s[o][i.size];r+=h,!a&&r>Yg[i.axis]&&0!==n[n.length-1].length&&(r=h,n.push([])),n[n.length-1].push(t[o]),a&&r>Yg[i.axis]&&o!==t.length-1&&(r=0,n.push([]))}return n}(t)),m=function(t,i){for(var s=[],r=[],a=0;ao.largestSize[n.size]&&(o.largestElement=o[d],o.largestSize=f)}s.push(o.largestElement),r.push(o.largestSize)}var p=l(r,n),m=h(e[n.fitting],p,Yg[n.axis]);m===qg?c(r,p,n):m===jg&&u(r,p,n);for(var _=0;_0;){var e=this._reflowQueue.slice();this._reflowQueue.length=0,e.sort((function(t,e){return t.entity.graphDepth-e.entity.graphDepth}));for(var i=0;i=100){console.warn("Max reflow iterations limit reached, bailing.");break}}},i._onRemoveComponent=function(t,e){e.onRemove()},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("postUpdate",this._onPostUpdate,this)},e}(Op);Dp._buildAccessors(tv.prototype,iv);var sv=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._type="asset",n._asset=null,n._model=null,n._mapping={},n._castShadows=!0,n._receiveShadows=!0,n._materialAsset=null,n._material=void 0,n._castShadowsLightmap=!0,n._lightmapped=!1,n._lightmapSizeMultiplier=1,n.isStatic=!1,n._layers=[0],n._batchGroupId=-1,n._customAabb=null,n._area=null,n._materialEvents=null,n._clonedModel=!1,n._material=e.defaultMaterial,i.on("remove",n.onRemoveChild,w(n)),i.on("removehierarchy",n.onRemoveChild,w(n)),i.on("insert",n.onInsertChild,w(n)),i.on("inserthierarchy",n.onInsertChild,w(n)),n}S(e,t);var i=e.prototype;return i.addModelToLayers=function(){for(var t=this.system.app.scene.layers,e=0;e=0&&(null==(n=t.batcher)||n.insert(Qo.MODEL,this.batchGroupId,this.entity))},i.onDisable=function(){var t,e=this.system.app,i=e.scene;(i.off("set:layers",this.onLayersChanged,this),i.layers&&(i.layers.off("add",this.onLayerAdded,this),i.layers.off("remove",this.onLayerRemoved,this)),this._batchGroupId>=0)&&(null==(t=e.batcher)||t.remove(Qo.MODEL,this.batchGroupId,this.entity));this._model&&this.removeModelFromLayers()},i.hide=function(){if(this._model)for(var t=this._model.meshInstances,e=0,i=t.length;e=0)null==(e=this.system.app.batcher)||e.remove(Qo.MODEL,this.batchGroupId,this.entity);if(this.entity.enabled&&t>=0)null==(i=this.system.app.batcher)||i.insert(Qo.MODEL,t,this.entity);t<0&&this._batchGroupId>=0&&this.enabled&&this.entity.enabled&&this.addModelToLayers(),this._batchGroupId=t}}},{key:"materialAsset",get:function(){return this._materialAsset},set:function(t){var e=t;t instanceof $f&&(e=t.id);var i=this.system.app.assets;if(e!==this._materialAsset){if(this._materialAsset){i.off("add:"+this._materialAsset,this._onMaterialAssetAdd,this);var n=i.get(this._materialAsset);n&&this._unbindMaterialAsset(n)}if(this._materialAsset=e,this._materialAsset){var s=i.get(this._materialAsset);s?this._bindMaterialAsset(s):(this._setMaterial(this.system.defaultMaterial),i.on("add:"+this._materialAsset,this._onMaterialAssetAdd,this))}else this._setMaterial(this.system.defaultMaterial)}}},{key:"material",get:function(){return this._material},set:function(t){this._material!==t&&(this.materialAsset=null,this._setMaterial(t))}},{key:"mapping",get:function(){return this._mapping},set:function(t){if("asset"===this._type&&(this._unsetMaterialEvents(),t||(t={}),this._mapping=t,this._model))for(var e=this._model.meshInstances,i=this.asset?this.system.app.assets.get(this.asset):null,n=i?i.data.mapping:null,s=null,r=0,a=e.length;r=0))continue;n=this.system.app.assets.get(n)}n&&!n.resource&&this.system.app.assets.load(n)}}if(!this.system.app.graphicsDevice.disableParticleSystem){if(!this.emitter){var s=t.mesh;s instanceof no||(s=null),this.emitter=new Kd(this.system.app.graphicsDevice,{numParticles:t.numParticles,emitterExtents:t.emitterExtents,emitterExtentsInner:t.emitterExtentsInner,emitterRadius:t.emitterRadius,emitterRadiusInner:t.emitterRadiusInner,emitterShape:t.emitterShape,initialVelocity:t.initialVelocity,wrap:t.wrap,localSpace:t.localSpace,screenSpace:t.screenSpace,wrapBounds:t.wrapBounds,lifetime:t.lifetime,rate:t.rate,rate2:t.rate2,orientation:t.orientation,particleNormal:t.particleNormal,animTilesX:t.animTilesX,animTilesY:t.animTilesY,animStartFrame:t.animStartFrame,animNumFrames:t.animNumFrames,animNumAnimations:t.animNumAnimations,animIndex:t.animIndex,randomizeAnimIndex:t.randomizeAnimIndex,animSpeed:t.animSpeed,animLoop:t.animLoop,startAngle:t.startAngle,startAngle2:t.startAngle2,scaleGraph:t.scaleGraph,scaleGraph2:t.scaleGraph2,colorGraph:t.colorGraph,colorGraph2:t.colorGraph2,alphaGraph:t.alphaGraph,alphaGraph2:t.alphaGraph2,localVelocityGraph:t.localVelocityGraph,localVelocityGraph2:t.localVelocityGraph2,velocityGraph:t.velocityGraph,velocityGraph2:t.velocityGraph2,rotationSpeedGraph:t.rotationSpeedGraph,rotationSpeedGraph2:t.rotationSpeedGraph2,radialSpeedGraph:t.radialSpeedGraph,radialSpeedGraph2:t.radialSpeedGraph2,colorMap:t.colorMap,normalMap:t.normalMap,loop:t.loop,preWarm:t.preWarm,sort:t.sort,stretch:t.stretch,alignToMotion:t.alignToMotion,lighting:t.lighting,halfLambert:t.halfLambert,intensity:t.intensity,depthSoftening:t.depthSoftening,scene:this.system.app.scene,mesh:s,depthWrite:t.depthWrite,noFog:t.noFog,node:this.entity,blendType:t.blendType}),this.emitter.meshInstance.node=this.entity,this.emitter.drawOrder=this.drawOrder,t.autoPlay||(this.pause(),this.emitter.meshInstance.visible=!1)}this.emitter.colorMap&&this.addMeshInstanceToLayers(),this.system.app.scene.on("set:layers",this.onLayersChanged,this),this.system.app.scene.layers&&(this.system.app.scene.layers.on("add",this.onLayerAdded,this),this.system.app.scene.layers.on("remove",this.onLayerRemoved,this)),this.enabled&&this.entity.enabled&&t.depthSoftening&&this._requestDepth()}},i.onDisable=function(){this.system.app.scene.off("set:layers",this.onLayersChanged,this),this.system.app.scene.layers&&(this.system.app.scene.layers.off("add",this.onLayerAdded,this),this.system.app.scene.layers.off("remove",this.onLayerRemoved,this)),this.emitter&&(this.removeMeshInstanceFromLayers(),this.data.depthSoftening&&this._releaseDepth(),this.emitter.camera=null)},i.onBeforeRemove=function(){this.enabled&&(this.enabled=!1),this.emitter&&(this.emitter.destroy(),this.emitter=null);for(var t=0;tc.fixedTimeStep&&(e=Math.floor(c.simTime/c.fixedTimeStep),c.simTime-=e*c.fixedTimeStep),e){e=Math.min(e,c.maxSubSteps);for(var p=0;p=0){var r=n[s];r.decRefCount(),0===r.refCount&&(n.splice(s,1),n.length||t._skinInstanceCache.delete(i),e&&(e.destroy(),r.skinInstance=null))}}}}},t}();vv._skinInstanceCache=new Map;var yv=function(){function t(t,e,i,n,s){this.propertyName=t,this.parent=e,this._scope=s,this._registry=i,this.id=null,this.url=null,this.asset=null,this._onAssetLoad=n.load,this._onAssetAdd=n.add,this._onAssetRemove=n.remove,this._onAssetUnload=n.unload}var e=t.prototype;return e._bind=function(){this.id&&(this._onAssetLoad&&this._registry.on("load:"+this.id,this._onLoad,this),this._onAssetAdd&&this._registry.once("add:"+this.id,this._onAdd,this),this._onAssetRemove&&this._registry.on("remove:"+this.id,this._onRemove,this),this._onAssetUnload&&this._registry.on("unload:"+this.id,this._onUnload,this)),this.url&&(this._onAssetLoad&&this._registry.on("load:url:"+this.url,this._onLoad,this),this._onAssetAdd&&this._registry.once("add:url:"+this.url,this._onAdd,this),this._onAssetRemove&&this._registry.on("remove:url:"+this.url,this._onRemove,this))},e._unbind=function(){this.id&&(this._onAssetLoad&&this._registry.off("load:"+this.id,this._onLoad,this),this._onAssetAdd&&this._registry.off("add:"+this.id,this._onAdd,this),this._onAssetRemove&&this._registry.off("remove:"+this.id,this._onRemove,this),this._onAssetUnload&&this._registry.off("unload:"+this.id,this._onUnload,this)),this.url&&(this._onAssetLoad&&this._registry.off("load:"+this.url,this._onLoad,this),this._onAssetAdd&&this._registry.off("add:"+this.url,this._onAdd,this),this._onAssetRemove&&this._registry.off("remove:"+this.url,this._onRemove,this))},e._onLoad=function(t){this._onAssetLoad.call(this._scope,this.propertyName,this.parent,t)},e._onAdd=function(t){this.asset=t,this._onAssetAdd.call(this._scope,this.propertyName,this.parent,t)},e._onRemove=function(t){this._onAssetRemove.call(this._scope,this.propertyName,this.parent,t),this.asset=null},e._onUnload=function(t){this._onAssetUnload.call(this._scope,this.propertyName,this.parent,t)},y(t,[{key:"id",get:function(){return this._id},set:function(t){if(this.url)throw Error("Can't set id and url");this._unbind(),this._id=t,this.asset=this._registry.get(this._id),this._bind()}},{key:"url",get:function(){return this._url},set:function(t){if(this.id)throw Error("Can't set id and url");this._unbind(),this._url=t,this.asset=this._registry.getByUrl(this._url),this._bind()}}]),t}(),xv=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._type="asset",n._castShadows=!0,n._receiveShadows=!0,n._castShadowsLightmap=!0,n._lightmapped=!1,n._lightmapSizeMultiplier=1,n.isStatic=!1,n._batchGroupId=-1,n._layers=[0],n._renderStyle=0,n._meshInstances=[],n._customAabb=null,n._area=null,n._assetReference=[],n._materialReferences=[],n._material=void 0,n._rootBone=void 0,n._rootBone=new Qm(w(n),"rootBone"),n._rootBone.on("set:entity",n._onSetRootBone,w(n)),n._assetReference=new yv("asset",w(n),e.app.assets,{add:n._onRenderAssetAdded,load:n._onRenderAssetLoad,remove:n._onRenderAssetRemove,unload:n._onRenderAssetUnload},w(n)),n._material=e.defaultMaterial,i.on("remove",n.onRemoveChild,w(n)),i.on("removehierarchy",n.onRemoveChild,w(n)),i.on("insert",n.onInsertChild,w(n)),i.on("inserthierarchy",n.onInsertChild,w(n)),n}S(e,t);var i=e.prototype;return i.assignAsset=function(t){var e=t instanceof $f?t.id:t;this._assetReference.id=e},i._onSetRootBone=function(t){t&&this._onRootBoneChanged()},i._onRootBoneChanged=function(){this._clearSkinInstances(),this.enabled&&this.entity.enabled&&this._cloneSkinInstances()},i.destroyMeshInstances=function(){var t=this._meshInstances;if(t){this.removeFromLayers(),this._clearSkinInstances();for(var e=0;e=0&&(null==(i=t.batcher)||i.insert(Qo.RENDER,this.batchGroupId,this.entity))},i.onDisable=function(){var t,e=this.system.app,i=e.scene;(i.off("set:layers",this.onLayersChanged,this),i.layers&&(i.layers.off("add",this.onLayerAdded,this),i.layers.off("remove",this.onLayerRemoved,this)),this._batchGroupId>=0)&&(null==(t=e.batcher)||t.remove(Qo.RENDER,this.batchGroupId,this.entity));this.removeFromLayers()},i.hide=function(){if(this._meshInstances)for(var t=0;t=0)null==(e=this.system.app.batcher)||e.remove(Qo.RENDER,this.batchGroupId,this.entity);if(this.entity.enabled&&t>=0)null==(i=this.system.app.batcher)||i.insert(Qo.RENDER,t,this.entity);t<0&&this._batchGroupId>=0&&this.enabled&&this.entity.enabled&&this.addToLayers(),this._batchGroupId=t}}},{key:"material",get:function(){return this._material},set:function(t){if(this._material!==t&&(this._material=t,this._meshInstances&&"asset"!==this._type))for(var e=0;et.length){for(var e=t.length;ethis._pool.length)for(var e=this._pool.length;e=this._pool.length&&this._resize(2*this._pool.length),this._pool[this._count++]},e.freeAll=function(){this._count=0},t}(),Lv=new Vt,Dv=new Vt,Ov=new Et,kv=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._angularDamping=0,n._angularFactor=new Et(1,1,1),n._angularVelocity=new Et,n._body=null,n._friction=.5,n._group=2,n._linearDamping=0,n._linearFactor=new Et(1,1,1),n._linearVelocity=new Et,n._mask=E_,n._mass=1,n._restitution=0,n._rollingFriction=0,n._simulationEnabled=!1,n._type=w_,n}S(e,t),e.onLibraryLoaded=function(){"undefined"!=typeof Ammo&&(Av=new Ammo.btTransform,Cv=new Ammo.btVector3,Ev=new Ammo.btVector3,Mv=new Ammo.btQuaternion)};var i=e.prototype;return i.createBody=function(){var t,e=this.entity;if(e.collision&&(t=e.collision.shape,e.trigger&&(e.trigger.destroy(),delete e.trigger)),t){this._body&&(this.system.removeBody(this._body),this.system.destroyBody(this._body),this._body=null);var i=this._type===T_?this._mass:0;this._getEntityTransform(Av);var n=this.system.createBody(i,t,Av);if(n.setRestitution(this._restitution),n.setFriction(this._friction),n.setRollingFriction(this._rollingFriction),n.setDamping(this._linearDamping,this._angularDamping),this._type===T_){var s=this._linearFactor;Cv.setValue(s.x,s.y,s.z),n.setLinearFactor(Cv);var r=this._angularFactor;Cv.setValue(r.x,r.y,r.z),n.setAngularFactor(Cv)}else this._type===A_&&(n.setCollisionFlags(2|n.getCollisionFlags()),n.setActivationState(4));n.entity=e,this.body=n,this.enabled&&e.enabled&&this.enableSimulation()}},i.isActive=function(){return!!this._body&&this._body.isActive()},i.activate=function(){this._body&&this._body.activate()},i.enableSimulation=function(){var t=this.entity;if(t.collision&&t.collision.enabled&&!this._simulationEnabled){var e=this._body;if(e){switch(this.system.addBody(e,this._group,this._mask),this._type){case T_:this.system._dynamic.push(this),e.forceActivationState(1),this.syncEntityToBody();break;case A_:this.system._kinematic.push(this),e.forceActivationState(4);break;case w_:e.forceActivationState(1),this.syncEntityToBody()}"compound"===t.collision.type&&this.system._compounds.push(t.collision),e.activate(),this._simulationEnabled=!0}}},i.disableSimulation=function(){var t=this._body;if(t&&this._simulationEnabled){var e=this.system,i=e._compounds.indexOf(this.entity.collision);i>-1&&e._compounds.splice(i,1),(i=e._dynamic.indexOf(this))>-1&&e._dynamic.splice(i,1),(i=e._kinematic.indexOf(this))>-1&&e._kinematic.splice(i,1),e.removeBody(t),t.forceActivationState(5),this._simulationEnabled=!1}},i.applyForce=function(t,e,i,n,s,r){var a=this._body;a&&(a.activate(),t instanceof Et?Cv.setValue(t.x,t.y,t.z):Cv.setValue(t,e,i),e instanceof Et?Ev.setValue(e.x,e.y,e.z):void 0!==n?Ev.setValue(n,s,r):Ev.setValue(0,0,0),a.applyForce(Cv,Ev))},i.applyTorque=function(t,e,i){var n=this._body;n&&(n.activate(),t instanceof Et?Cv.setValue(t.x,t.y,t.z):Cv.setValue(t,e,i),n.applyTorque(Cv))},i.applyImpulse=function(t,e,i,n,s,r){var a=this._body;a&&(a.activate(),t instanceof Et?Cv.setValue(t.x,t.y,t.z):Cv.setValue(t,e,i),e instanceof Et?Ev.setValue(e.x,e.y,e.z):void 0!==n?Ev.setValue(n,s,r):Ev.setValue(0,0,0),a.applyImpulse(Cv,Ev))},i.applyTorqueImpulse=function(t,e,i){var n=this._body;n&&(n.activate(),t instanceof Et?Cv.setValue(t.x,t.y,t.z):Cv.setValue(t,e,i),n.applyTorqueImpulse(Cv))},i.isStatic=function(){return this._type===w_},i.isStaticOrKinematic=function(){return this._type===w_||this._type===A_},i.isKinematic=function(){return this._type===A_},i._getEntityTransform=function(t){var e=this.entity,i=e.collision;if(i){var n=i.getShapePosition(),s=i.getShapeRotation();Cv.setValue(n.x,n.y,n.z),Mv.setValue(s.x,s.y,s.z,s.w)}else{var r=e.getPosition(),a=e.getRotation();Cv.setValue(r.x,r.y,r.z),Mv.setValue(a.x,a.y,a.z,a.w)}t.setOrigin(Cv),t.setRotation(Mv)},i.syncEntityToBody=function(){var t=this._body;if(t){if(this._getEntityTransform(Av),t.setWorldTransform(Av),this._type===A_){var e=t.getMotionState();e&&e.setWorldTransform(Av)}t.activate()}},i._updateDynamic=function(){var t=this._body;if(t.isActive()){var e=t.getMotionState();if(e){var i=this.entity;e.getWorldTransform(Av);var n=Av.getOrigin(),s=Av.getRotation(),r=i.collision;if(r&&r._hasOffset){var a=r.data.linearOffset,o=r.data.angularOffset,h=Dv.copy(o).invert(),l=Lv.set(s.x(),s.y(),s.z(),s.w()).mul(h);l.transformVector(a,Ov),i.setPosition(n.x()-Ov.x,n.y()-Ov.y,n.z()-Ov.z),i.setRotation(l)}else i.setPosition(n.x(),n.y(),n.z()),i.setRotation(s.x(),s.y(),s.z(),s.w())}}},i._updateKinematic=function(){var t=this._body.getMotionState();t&&(this._getEntityTransform(Av),t.setWorldTransform(Av))},i.teleport=function(t,e,i,n,s,r){t instanceof Et?this.entity.setPosition(t):this.entity.setPosition(t,e,i),e instanceof Vt?this.entity.setRotation(e):e instanceof Et?this.entity.setEulerAngles(e):void 0!==n&&this.entity.setEulerAngles(n,s,r),this.syncEntityToBody()},i.onEnable=function(){this._body||this.createBody(),this.enableSimulation()},i.onDisable=function(){this.disableSimulation()},y(e,[{key:"angularDamping",get:function(){return this._angularDamping},set:function(t){this._angularDamping!==t&&(this._angularDamping=t,this._body&&this._body.setDamping(this._linearDamping,t))}},{key:"angularFactor",get:function(){return this._angularFactor},set:function(t){this._angularFactor.equals(t)||(this._angularFactor.copy(t),this._body&&this._type===T_&&(Cv.setValue(t.x,t.y,t.z),this._body.setAngularFactor(Cv)))}},{key:"angularVelocity",get:function(){if(this._body&&this._type===T_){var t=this._body.getAngularVelocity();this._angularVelocity.set(t.x(),t.y(),t.z())}return this._angularVelocity},set:function(t){this._body&&this._type===T_&&(this._body.activate(),Cv.setValue(t.x,t.y,t.z),this._body.setAngularVelocity(Cv),this._angularVelocity.copy(t))}},{key:"body",get:function(){return this._body},set:function(t){this._body!==t&&(this._body=t,t&&this._simulationEnabled&&t.activate())}},{key:"friction",get:function(){return this._friction},set:function(t){this._friction!==t&&(this._friction=t,this._body&&this._body.setFriction(t))}},{key:"group",get:function(){return this._group},set:function(t){this._group!==t&&(this._group=t,this.enabled&&this.entity.enabled&&(this.disableSimulation(),this.enableSimulation()))}},{key:"linearDamping",get:function(){return this._linearDamping},set:function(t){this._linearDamping!==t&&(this._linearDamping=t,this._body&&this._body.setDamping(t,this._angularDamping))}},{key:"linearFactor",get:function(){return this._linearFactor},set:function(t){this._linearFactor.equals(t)||(this._linearFactor.copy(t),this._body&&this._type===T_&&(Cv.setValue(t.x,t.y,t.z),this._body.setLinearFactor(Cv)))}},{key:"linearVelocity",get:function(){if(this._body&&this._type===T_){var t=this._body.getLinearVelocity();this._linearVelocity.set(t.x(),t.y(),t.z())}return this._linearVelocity},set:function(t){this._body&&this._type===T_&&(this._body.activate(),Cv.setValue(t.x,t.y,t.z),this._body.setLinearVelocity(Cv),this._linearVelocity.copy(t))}},{key:"mask",get:function(){return this._mask},set:function(t){this._mask!==t&&(this._mask=t,this.enabled&&this.entity.enabled&&(this.disableSimulation(),this.enableSimulation()))}},{key:"mass",get:function(){return this._mass},set:function(t){if(this._mass!==t&&(this._mass=t,this._body&&this._type===T_)){var e=this.enabled&&this.entity.enabled;e&&this.disableSimulation(),this._body.getCollisionShape().calculateLocalInertia(t,Cv),this._body.setMassProps(t,Cv),this._body.updateInertiaTensor(),e&&this.enableSimulation()}}},{key:"restitution",get:function(){return this._restitution},set:function(t){this._restitution!==t&&(this._restitution=t,this._body&&this._body.setRestitution(t))}},{key:"rollingFriction",get:function(){return this._rollingFriction},set:function(t){this._rollingFriction!==t&&(this._rollingFriction=t,this._body&&this._body.setRollingFriction(t))}},{key:"type",get:function(){return this._type},set:function(t){if(this._type!==t){switch(this._type=t,this.disableSimulation(),t){case T_:this._group=1,this._mask=C_;break;case A_:this._group=4,this._mask=C_;break;default:this._group=2,this._mask=E_}this.createBody()}}}]),e}(Dp),Fv=function(){this.enabled=!0},Bv=function(t,e,i,n){this.entity=t,this.point=e,this.normal=i,this.hitFraction=n},Uv=function(t,e,i){0===arguments.length?(this.a=null,this.b=null,this.impulse=0,this.localPointA=new Et,this.localPointB=new Et,this.pointA=new Et,this.pointB=new Et,this.normal=new Et):(this.a=t,this.b=e,this.impulse=i.impulse,this.localPointA=i.localPoint,this.localPointB=i.localPointOther,this.pointA=i.point,this.pointB=i.pointOther,this.normal=i.normal)},Nv=function(t,e,i,n,s,r){void 0===t&&(t=new Et),void 0===e&&(e=new Et),void 0===i&&(i=new Et),void 0===n&&(n=new Et),void 0===s&&(s=new Et),void 0===r&&(r=0),this.localPoint=t,this.localPointOther=e,this.point=i,this.pointOther=n,this.normal=s,this.impulse=r},zv=function(t,e){this.other=t,this.contacts=e},Vv=["enabled"],Gv=function(t){function e(e){var i;return(i=t.call(this,e)||this).maxSubSteps=10,i.fixedTimeStep=1/60,i.gravity=new Et(0,-9.81,0),i._gravityFloat32=new Float32Array(3),i._dynamic=[],i._kinematic=[],i._triggers=[],i._compounds=[],i.id="rigidbody",i._stats=e.stats.frame,i.ComponentType=kv,i.DataType=Fv,i.contactPointPool=null,i.contactResultPool=null,i.singleContactResultPool=null,i.schema=Vv,i.collisions={},i.frameCollisions={},i.on("beforeremove",i.onBeforeRemove,w(i)),i}S(e,t);var i=e.prototype;return i.onLibraryLoaded=function(){if("undefined"!=typeof Ammo){if(this.collisionConfiguration=new Ammo.btDefaultCollisionConfiguration,this.dispatcher=new Ammo.btCollisionDispatcher(this.collisionConfiguration),this.overlappingPairCache=new Ammo.btDbvtBroadphase,this.solver=new Ammo.btSequentialImpulseConstraintSolver,this.dynamicsWorld=new Ammo.btDiscreteDynamicsWorld(this.dispatcher,this.overlappingPairCache,this.solver,this.collisionConfiguration),this.dynamicsWorld.setInternalTickCallback){var t=Ammo.addFunction(this._checkForCollisions.bind(this),"vif");this.dynamicsWorld.setInternalTickCallback(t)}Pv=new Ammo.btVector3,Rv=new Ammo.btVector3,kv.onLibraryLoaded(),this.contactPointPool=new Iv(Nv,1),this.contactResultPool=new Iv(zv,1),this.singleContactResultPool=new Iv(Uv,1),this.app.systems.on("update",this.onUpdate,this)}else this.app.systems.off("update",this.onUpdate,this)},i.initializeComponentData=function(e,i,n){for(var s=0,r=["mass","linearDamping","angularDamping","linearFactor","angularFactor","friction","rollingFriction","restitution","type","group","mask"];s0)if(4&d||4&f){var v=c.collision&&(c.collision.hasEvent("triggerenter")||c.collision.hasEvent("triggerleave")),y=u.collision&&(u.collision.hasEvent("triggerenter")||u.collision.hasEvent("triggerleave")),x=c.rigidbody&&(c.rigidbody.hasEvent("triggerenter")||c.rigidbody.hasEvent("triggerleave")),S=u.rigidbody&&(u.rigidbody.hasEvent("triggerenter")||u.rigidbody.hasEvent("triggerleave"));v&&(!(g=this._storeCollision(c,u))||4&f||c.collision.fire("triggerenter",u)),y&&(!(g=this._storeCollision(u,c))||4&d||u.collision.fire("triggerenter",c)),x&&(g||(g=this._storeCollision(u,c)),g&&c.rigidbody.fire("triggerenter",u)),S&&(g||(g=this._storeCollision(c,u)),g&&u.rigidbody.fire("triggerenter",c))}else{var b=this._hasContactEvent(c),w=this._hasContactEvent(u),T=this.hasEvent("contact");if(T||b||w){for(var A=0;A=0&&n!==t.element.drawOrder)null==(i=this.system.app.batcher)||i.markGroupDirty(t.element._batchGroupId)}t.particlesystem&&(t.particlesystem.drawOrder=e++);for(var s=t.children,r=0;r255&&(t=255),this._priority!==t&&(this._priority=t,this.syncDrawOrder())}}]),e}(Dp),jv=function(){this.enabled=!0},Yv=["enabled"],Kv=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="screen",i.ComponentType=qv,i.DataType=jv,i.schema=Yv,i.windowResolution=new It,i._drawOrderSyncQueue=new at,i.app.graphicsDevice.on("resizecanvas",i._onResize,w(i)),i.app.systems.on("update",i._onUpdate,w(i)),i.on("beforeremove",i.onRemoveComponent,w(i)),i}S(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){void 0!==i.priority&&(e.priority=i.priority),void 0!==i.screenSpace&&(e.screenSpace=i.screenSpace),e.cull=e.screenSpace,void 0!==i.scaleMode&&(e.scaleMode=i.scaleMode),void 0!==i.scaleBlend&&(e.scaleBlend=i.scaleBlend),void 0!==i.resolution&&(i.resolution instanceof It?e._resolution.copy(i.resolution):e._resolution.set(i.resolution[0],i.resolution[1]),e.resolution=e._resolution),void 0!==i.referenceResolution&&(i.referenceResolution instanceof It?e._referenceResolution.copy(i.referenceResolution):e._referenceResolution.set(i.referenceResolution[0],i.referenceResolution[1]),e.referenceResolution=e._referenceResolution),e.syncDrawOrder(),t.prototype.initializeComponentData.call(this,e,i,n)},i.destroy=function(){t.prototype.destroy.call(this),this.app.graphicsDevice.off("resizecanvas",this._onResize,this),this.app.systems.off("update",this._onUpdate,this)},i._onUpdate=function(t){var e=this.store;for(var i in e)e[i].entity.screen.update&&e[i].entity.screen.update(t)},i._onResize=function(t,e){this.windowResolution.x=t,this.windowResolution.y=e},i.cloneComponent=function(t,e){var i=t.screen;return this.addComponent(e,{enabled:i.enabled,screenSpace:i.screenSpace,scaleMode:i.scaleMode,resolution:i.resolution.clone(),referenceResolution:i.referenceResolution.clone()})},i.onRemoveComponent=function(t,e){e.onRemove()},i.processDrawOrderSyncQueue=function(){for(var t=this._drawOrderSyncQueue.list(),e=0;e=0&&this.instancesWithUpdate.splice(s,1)}if(n.fixedUpdate){var r=this.instancesWithFixedUpdate.indexOf(n);r>=0&&this.instancesWithFixedUpdate.splice(r,1)}if(n.postUpdate){var a=this.instancesWithPostUpdate.indexOf(n);a>=0&&this.instancesWithPostUpdate.splice(a,1)}if(n.toolsUpdate){var o=this.instancesWithToolsUpdate.indexOf(n);o>=0&&this.instancesWithToolsUpdate.splice(o,1)}t.instances[i].instance===t[i]&&delete t[i],delete t.instances[i]}},i._postInitializeScriptComponent=function(t){this._callInstancesMethod(t,ty),t.data.postInitialized=!0},i._updateInstances=function(t,e,i){for(var n=0,s=e.length;nthis.dragThreshold||Math.abs(i)>this.dragThreshold)&&this._disableContentInput()}},i._onSetContentOrViewportSize=function(){this._syncAll()},i._onSetHorizontalScrollbarValue=function(t){!this._scrollbarUpdateFlags[0]&&this.enabled&&this.entity.enabled&&this._onSetScroll(t,null)},i._onSetVerticalScrollbarValue=function(t){!this._scrollbarUpdateFlags[1]&&this.enabled&&this.entity.enabled&&this._onSetScroll(null,t)},i._onSetHorizontalScrollingEnabled=function(){this._syncScrollbarEnabledState(0)},i._onSetVerticalScrollingEnabled=function(){this._syncScrollbarEnabledState(1)},i._onHorizontalScrollbarGain=function(){this._syncScrollbarEnabledState(0),this._syncScrollbarPosition(0)},i._onVerticalScrollbarGain=function(){this._syncScrollbarEnabledState(1),this._syncScrollbarPosition(1)},i._onSetScroll=function(t,e,i){!1!==i&&this._velocity.set(0,0,0);var n=this._updateAxis(t,"x",0),s=this._updateAxis(e,"y",1);(n||s)&&this.fire("set:scroll",this._scroll)},i._updateAxis=function(t,e,i){var n=null!==t&&Math.abs(t-this._scroll[e])>1e-5;return(n||this._isDragging()||0===t)&&(this._scroll[e]=this._determineNewScrollValue(t,e,i),this._syncContentPosition(i),this._syncScrollbarPosition(i)),n},i._determineNewScrollValue=function(t,e,i){if(!this._getScrollingEnabled(i))return this._scroll[e];switch(this.scrollMode){case 0:return _t.clamp(t,0,this._getMaxScrollValue(i));case 1:return this._setVelocityFromOvershoot(t,e,i),t;case 2:return t;default:return console.warn("Unhandled scroll mode:"+this.scrollMode),t}},i._syncAll=function(){this._syncContentPosition(0),this._syncContentPosition(1),this._syncScrollbarPosition(0),this._syncScrollbarPosition(1),this._syncScrollbarEnabledState(0),this._syncScrollbarEnabledState(1)},i._syncContentPosition=function(t){var e=this._getAxis(t),i=this._getSign(t),n=this._contentReference.entity;if(n){var s=this._prevContentSizes[t],r=this._getContentSize(t);if(null!==s&&Math.abs(s-r)>1e-4){var a=this._getMaxOffset(t,s),o=this._getMaxOffset(t,r);this._scroll[e]=0===o?1:_t.clamp(this._scroll[e]*a/o,0,1)}var h=this._scroll[e]*this._getMaxOffset(t),l=n.getLocalPosition();l[e]=h*i,n.setLocalPosition(l),this._prevContentSizes[t]=r}},i._syncScrollbarPosition=function(t){var e=this._getAxis(t),i=this._scrollbarReferences[t].entity;i&&i.scrollbar&&(this._scrollbarUpdateFlags[t]=!0,i.scrollbar.value=this._scroll[e],i.scrollbar.handleSize=this._getScrollbarHandleSize(e,t),this._scrollbarUpdateFlags[t]=!1)},i._syncScrollbarEnabledState=function(t){var e=this._scrollbarReferences[t].entity;if(e){var i=this._getScrollingEnabled(t),n=this._getScrollbarVisibility(t);switch(n){case 0:return void(e.enabled=i);case 1:return void(e.enabled=i&&this._contentIsLargerThanViewport(t));default:console.warn("Unhandled scrollbar visibility:"+n),e.enabled=i}}},i._contentIsLargerThanViewport=function(t){return this._getContentSize(t)>this._getViewportSize(t)},i._contentPositionToScrollValue=function(t){var e=this._getMaxOffset(0),i=this._getMaxOffset(1);return my.x=0===e?0:t.x/e,my.y=0===i?0:t.y/-i,my},i._getMaxOffset=function(t,e){e=void 0===e?this._getContentSize(t):e;var i=this._getViewportSize(t);return e1e-4||Math.abs(this._velocity.y)>1e-4){var t=this._contentReference.entity.getLocalPosition();t.x+=this._velocity.x,t.y+=this._velocity.y,this._contentReference.entity.setLocalPosition(t),this._setScrollFromContentPosition(t)}this._velocity.x*=1-this.friction,this._velocity.y*=1-this.friction}},i._hasOvershoot=function(t,e){return Math.abs(this._toOvershoot(this.scroll[t],e))>.001},i._toOvershoot=function(t,e){var i=this._getMaxScrollValue(e);return t<0?t:t>i?t-i:0},i._setVelocityFromOvershoot=function(t,e,i){var n=this._toOvershoot(t,i)*this._getMaxOffset(i)*this._getSign(i);Math.abs(n)>0&&(this._velocity[e]=-n/(50*this.bounceAmount+1))},i._setVelocityFromContentPositionDelta=function(t){this._prevContentDragPosition?(this._velocity.sub2(t,this._prevContentDragPosition),this._prevContentDragPosition.copy(t)):(this._velocity.set(0,0,0),this._prevContentDragPosition=t.clone())},i._setScrollFromContentPosition=function(t){var e=this._contentPositionToScrollValue(t);this._isDragging()&&(e=this._applyScrollValueTension(e)),this._onSetScroll(e.x,e.y,!1)},i._applyScrollValueTension=function(t){var e=this._getMaxScrollValue(0),i=this._toOvershoot(t.x,0);return i>0?t.x=e+1*Math.log10(1+i):i<0&&(t.x=-1*Math.log10(1-i)),e=this._getMaxScrollValue(1),(i=this._toOvershoot(t.y,1))>0?t.y=e+1*Math.log10(1+i):i<0&&(t.y=-1*Math.log10(1-i)),t},i._isDragging=function(){return this._contentDragHelper&&this._contentDragHelper.isDragging},i._setScrollbarComponentsEnabled=function(t){this._scrollbarReferences[0].hasComponent("scrollbar")&&(this._scrollbarReferences[0].entity.scrollbar.enabled=t),this._scrollbarReferences[1].hasComponent("scrollbar")&&(this._scrollbarReferences[1].entity.scrollbar.enabled=t)},i._setContentDraggingEnabled=function(t){this._contentDragHelper&&(this._contentDragHelper.enabled=t)},i._onMouseWheel=function(t){if(this.useMouseWheel){var e=t.event,i=e.deltaX/this._contentReference.entity.element.calculatedWidth*this.mouseWheelSensitivity.x,n=e.deltaY/this._contentReference.entity.element.calculatedHeight*this.mouseWheelSensitivity.y,s=_t.clamp(this._scroll.x+i,0,this._getMaxScrollValue(0)),r=_t.clamp(this._scroll.y+n,0,this._getMaxScrollValue(1));this.scroll=new It(s,r)}},i._enableContentInput=function(){for(;this._disabledContentInputEntities.length;){var t=this._disabledContentInputEntities.pop();t.element&&(t.element.useInput=!0)}this._disabledContentInput=!1},i._disableContentInput=function(){var t=this,e=function e(i){i.element&&i.element.useInput&&(t._disabledContentInputEntities.push(i),i.element.useInput=!1);for(var n=i.children,s=0,r=n.length;s1e-5&&(this.data.value=_t.clamp(i,0,1),this._updateHandlePositionAndSize(),this.fire("set:value",this.data.value))},i._onSetHandleSize=function(t,e,i){Math.abs(i-e)>1e-5&&(this.data.handleSize=_t.clamp(i,0,1),this._updateHandlePositionAndSize())},i._onSetHandleAlignment=function(){this._updateHandlePositionAndSize()},i._onSetOrientation=function(t,e,i){i!==e&&this._handleReference.hasComponent("element")&&(this._handleReference.entity.element[this._getOppositeDimension()]=0)},i._updateHandlePositionAndSize=function(){var t=this._handleReference.entity,e=t&&t.element;if(t){var i=t.getLocalPosition();i[this._getAxis()]=this._getHandlePosition(),this._handleReference.entity.setLocalPosition(i)}e&&(e[this._getDimension()]=this._getHandleLength())},i._handlePositionToScrollValue=function(t){return t*this._getSign()/this._getUsableTrackLength()},i._scrollValueToHandlePosition=function(t){return t*this._getSign()*this._getUsableTrackLength()},i._getUsableTrackLength=function(){return Math.max(this._getTrackLength()-this._getHandleLength(),.001)},i._getTrackLength=function(){return this.entity.element?0===this.orientation?this.entity.element.calculatedWidth:this.entity.element.calculatedHeight:0},i._getHandleLength=function(){return this._getTrackLength()*this.handleSize},i._getHandlePosition=function(){return this._scrollValueToHandlePosition(this.value)},i._getSign=function(){return 0===this.orientation?1:-1},i._getAxis=function(){return 0===this.orientation?"x":"y"},i._getDimension=function(){return 0===this.orientation?"width":"height"},i._getOppositeDimension=function(){return 0===this.orientation?"height":"width"},i._destroyDragHelper=function(){this._handleDragHelper&&this._handleDragHelper.destroy()},i._setHandleDraggingEnabled=function(t){this._handleDragHelper&&(this._handleDragHelper.enabled=t)},i.onEnable=function(){this._handleReference.onParentComponentEnable(),this._setHandleDraggingEnabled(!0)},i.onDisable=function(){this._setHandleDraggingEnabled(!1)},i.onRemove=function(){this._destroyDragHelper(),this._toggleLifecycleListeners("off")},e}(Dp),Sy=function(){this.enabled=!0},by=[{name:"enabled",type:"boolean"},{name:"orientation",type:"number"},{name:"value",type:"number"},{name:"handleSize",type:"number"},{name:"handleEntity",type:"entity"}],wy=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="scrollbar",i.ComponentType=xy,i.DataType=Sy,i.schema=by,i.on("beforeremove",i._onRemoveComponent,w(i)),i}S(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){t.prototype.initializeComponentData.call(this,e,i,by)},i._onRemoveComponent=function(t,e){e.onRemove()},e}(Op);Dp._buildAccessors(xy.prototype,by);var Ty={volume:0,pitch:0,loop:!1,startTime:0,duration:0,position:new Et,maxDistance:0,refDistance:0,rollOffFactor:0,distanceModel:0,onPlay:null,onPause:null,onResume:null,onStop:null,onEnd:null},Ay=function(t){function e(e,i,n){var s;return void 0===i&&(i="Untitled"),void 0===n&&(n={}),(s=t.call(this)||this).name=void 0,s.instances=[],s._component=e,s._assets=e.system.app.assets,s._manager=e.system.manager,s.name=i,s._volume=void 0!==n.volume?_t.clamp(Number(n.volume)||0,0,1):1,s._pitch=void 0!==n.pitch?Math.max(.01,Number(n.pitch)||0):1,s._loop=!(void 0===n.loop||!n.loop),s._duration=n.duration>0?n.duration:null,s._startTime=Math.max(0,Number(n.startTime)||0),s._overlap=!!n.overlap,s._autoPlay=!!n.autoPlay,s._firstNode=null,s._lastNode=null,s._asset=n.asset,s._asset instanceof $f&&(s._asset=s._asset.id),s._onInstancePlayHandler=s._onInstancePlay.bind(w(s)),s._onInstancePauseHandler=s._onInstancePause.bind(w(s)),s._onInstanceResumeHandler=s._onInstanceResume.bind(w(s)),s._onInstanceStopHandler=s._onInstanceStop.bind(w(s)),s._onInstanceEndHandler=s._onInstanceEnd.bind(w(s)),s}S(e,t);var i=e.prototype;return i.play=function(){if(this.overlap||this.stop(),this.isLoaded||this._hasAsset()){var t=this._createInstance();if(this.instances.push(t),this.isLoaded)t.play();else{var e=function(e){var i=t._playWhenLoaded;t.sound=e,i&&t.play()};this.off("load",e),this.once("load",e),this.load()}return t}},i.pause=function(){for(var t=!1,e=this.instances,i=0,n=e.length;i=0;r--){var a=s[r].isPlaying||s[r].isSuspended,o=s[r].currentTime;a&&s[r].stop();var h=n._createInstance();a&&(h.play(),h.currentTime=o),s.push(h)}}}},{key:"slots",get:function(){return this._slots},set:function(t){var e=this._slots;if(e)for(var i in e)e[i].stop();var n={};for(var s in t)t[s]instanceof Ay?n[t[s].name]=t[s]:t[s].name&&(n[t[s].name]=new Ay(this,t[s].name,t[s]));this._slots=n,this.enabled&&this.entity.enabled&&this.onEnable()}}]),e}(Dp),Ey=function(){this.enabled=!0},My=["enabled"],Py=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="sound",i.ComponentType=Cy,i.DataType=Ey,i.schema=My,i.manager=e.soundManager,i.app.systems.on("update",i.onUpdate,w(i)),i.on("beforeremove",i.onBeforeRemove,w(i)),i}S(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){n=["volume","pitch","positional","refDistance","maxDistance","rollOffFactor","distanceModel","slots"];for(var s=0;sn||i<0;this._setTime(i);var r=this.frame;(r=this._sprite?Math.floor(this._sprite.frameKeys.length*this._time/n):0)!==this._frame&&this._setFrame(r),s&&(this.loop?(this.fire("loop"),this._component.fire("loop",this)):(this._playing=!1,this._paused=!1,this.fire("end"),this._component.fire("end",this)))}},i._setTime=function(t){this._time=t;var e=this.duration;this._time<0?this.loop?this._time=this._time%e+e:this._time=0:this._time>e&&(this.loop?this._time%=e:this._time=e)},i._setFrame=function(t){this._sprite?this._frame=_t.clamp(t,0,this._sprite.frameKeys.length-1):this._frame=t,this._component.currentClip===this&&this._component._showFrame(this._frame)},i._destroy=function(){if(this._spriteAsset){var t=this._component.system.app.assets;this._unbindSpriteAsset(t.get(this._spriteAsset))}this._sprite&&(this.sprite=null),this._spriteAsset&&(this.spriteAsset=null)},i.play=function(){this._playing||(this._playing=!0,this._paused=!1,this.frame=0,this.fire("play"),this._component.fire("play",this))},i.pause=function(){this._playing&&!this._paused&&(this._paused=!0,this.fire("pause"),this._component.fire("pause",this))},i.resume=function(){this._paused&&(this._paused=!1,this.fire("resume"),this._component.fire("resume",this))},i.stop=function(){this._playing&&(this._playing=!1,this._paused=!1,this._time=0,this.frame=0,this.fire("stop"),this._component.fire("stop",this))},y(e,[{key:"duration",get:function(){if(this._sprite){var t=this.fps||Number.MIN_VALUE;return this._sprite.frameKeys.length/Math.abs(t)}return 0}},{key:"frame",get:function(){return this._frame},set:function(t){this._setFrame(t);var e=this.fps||Number.MIN_VALUE;this._setTime(this._frame/e)}},{key:"isPaused",get:function(){return this._paused}},{key:"isPlaying",get:function(){return this._playing}},{key:"sprite",get:function(){return this._sprite},set:function(t){var e;(this._sprite&&(this._sprite.off("set:meshes",this._onSpriteMeshesChange,this),this._sprite.off("set:pixelsPerUnit",this._onSpritePpuChanged,this),this._sprite.off("set:atlas",this._onSpriteMeshesChange,this),this._sprite.atlas&&this._sprite.atlas.off("set:texture",this._onSpriteMeshesChange,this)),this._sprite=t,this._sprite&&(this._sprite.on("set:meshes",this._onSpriteMeshesChange,this),this._sprite.on("set:pixelsPerUnit",this._onSpritePpuChanged,this),this._sprite.on("set:atlas",this._onSpriteMeshesChange,this),this._sprite.atlas&&this._sprite.atlas.on("set:texture",this._onSpriteMeshesChange,this)),this._component.currentClip===this)&&(t&&t.atlas?(t.atlas.texture&&((e=this._component._meshInstance)&&(e.setParameter("texture_emissiveMap",t.atlas.texture),e.setParameter("texture_opacityMap",t.atlas.texture)),this._component.enabled&&this._component.entity.enabled&&this._component._showModel()),this.time&&this.fps?this.time=this.time:this.frame=this.frame):((e=this._component._meshInstance)&&(e.deleteParameter("texture_emissiveMap"),e.deleteParameter("texture_opacityMap")),this._component._hideModel()))}},{key:"spriteAsset",get:function(){return this._spriteAsset},set:function(t){var e=this._component.system.app.assets,i=t;if(t instanceof $f&&(i=t.id),this._spriteAsset!==i){if(this._spriteAsset){var n=e.get(this._spriteAsset);n&&this._unbindSpriteAsset(n)}if(this._spriteAsset=i,this._spriteAsset){var s=e.get(this._spriteAsset);s?this._bindSpriteAsset(s):(this.sprite=null,e.on("add:"+this._spriteAsset,this._onSpriteAssetAdded,this))}else this.sprite=null}}},{key:"time",get:function(){return this._time},set:function(t){this._setTime(t),this._sprite?this.frame=Math.min(this._sprite.frameKeys.length-1,Math.floor(this._time*Math.abs(this.fps))):this.frame=0}}]),e}(P),Dy="texture_emissiveMap",Oy="texture_opacityMap",ky="material_emissive",Fy="material_opacity",By=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._type=Ry,n._material=e.defaultMaterial,n._color=new gt(1,1,1,1),n._colorUniform=new Float32Array(3),n._speed=1,n._flipX=!1,n._flipY=!1,n._width=1,n._height=1,n._drawOrder=0,n._layers=[0],n._outerScale=new It(1,1),n._outerScaleUniform=new Float32Array(2),n._innerOffset=new Dt,n._innerOffsetUniform=new Float32Array(4),n._atlasRect=new Dt,n._atlasRectUniform=new Float32Array(4),n._batchGroupId=-1,n._batchGroup=null,n._node=new _h,n._model=new $u,n._model.graph=n._node,n._meshInstance=null,i.addChild(n._model.graph),n._model._entity=i,n._updateAabbFunc=n._updateAabb.bind(w(n)),n._addedModel=!1,n._autoPlayClip=null,n._clips={},n._defaultClip=new Ly(w(n),{name:n.entity.name,fps:0,loop:!1,spriteAsset:null}),n._currentClip=n._defaultClip,n}S(e,t);var i=e.prototype;return i.onEnable=function(){var t,e=this.system.app,i=e.scene;(i.on("set:layers",this._onLayersChanged,this),i.layers&&(i.layers.on("add",this._onLayerAdded,this),i.layers.on("remove",this._onLayerRemoved,this)),this._showModel(),this._autoPlayClip&&this._tryAutoPlay(),this._batchGroupId>=0)&&(null==(t=e.batcher)||t.insert(Qo.SPRITE,this._batchGroupId,this.entity))},i.onDisable=function(){var t,e=this.system.app,i=e.scene;(i.off("set:layers",this._onLayersChanged,this),i.layers&&(i.layers.off("add",this._onLayerAdded,this),i.layers.off("remove",this._onLayerRemoved,this)),this.stop(),this._hideModel(),this._batchGroupId>=0)&&(null==(t=e.batcher)||t.remove(Qo.SPRITE,this._batchGroupId,this.entity))},i.onDestroy=function(){var t;for(var e in this._currentClip=null,this._defaultClip&&(this._defaultClip._destroy(),this._defaultClip=null),this._clips)this._clips[e]._destroy();this._clips=null,this._hideModel(),this._model=null,null==(t=this._node)||t.remove(),this._node=null,this._meshInstance&&(this._meshInstance.material=null,this._meshInstance.mesh=null,this._meshInstance=null)},i._showModel=function(){if(!this._addedModel&&this._meshInstance){for(var t=[this._meshInstance],e=0,i=this._layers.length;e=0)null==(e=this.system.app.batcher)||e.remove(Qo.SPRITE,n,this.entity);if(this.entity.enabled&&t>=0)null==(i=this.system.app.batcher)||i.insert(Qo.SPRITE,t,this.entity);else n>=0&&this._currentClip&&this._currentClip.sprite&&this.enabled&&this.entity.enabled&&this._showModel()}}},{key:"autoPlayClip",get:function(){return this._autoPlayClip},set:function(t){this._autoPlayClip=t instanceof Ly?t.name:t,this._tryAutoPlay()}},{key:"drawOrder",get:function(){return this._drawOrder},set:function(t){this._drawOrder=t,this._meshInstance&&(this._meshInstance.drawOrder=t)}},{key:"layers",get:function(){return this._layers},set:function(t){this._addedModel&&this._hideModel(),this._layers=t,this._meshInstance&&this.enabled&&this.entity.enabled&&this._showModel()}},{key:"aabb",get:function(){return this._meshInstance?this._meshInstance.aabb:null}}]),e}(Dp),Uy=function(){this.enabled=!0},Ny=["enabled"],zy=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="sprite",i.ComponentType=By,i.DataType=Uy,i.schema=Ny,i._defaultTexture=null,i._defaultMaterial=null,i._default9SlicedMaterialSlicedMode=null,i._default9SlicedMaterialTiledMode=null,i.app.systems.on("update",i.onUpdate,w(i)),i.on("beforeremove",i.onBeforeRemove,w(i)),i}S(e,t);var i=e.prototype;return i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("update",this.onUpdate,this),this._defaultTexture&&(this._defaultTexture.destroy(),this._defaultTexture=null)},i.initializeComponentData=function(e,i,n){if(void 0!==i.enabled&&(e.enabled=i.enabled),e.type=i.type,i.layers&&Array.isArray(i.layers)&&(e.layers=i.layers.slice(0)),void 0!==i.drawOrder&&(e.drawOrder=i.drawOrder),void 0!==i.color){var s,r;if(i.color instanceof gt)e.color.set(i.color.r,i.color.g,i.color.b,null!=(s=i.opacity)?s:1);else e.color.set(i.color[0],i.color[1],i.color[2],null!=(r=i.opacity)?r:1);e.color=e.color}if(void 0!==i.opacity&&(e.opacity=i.opacity),void 0!==i.flipX&&(e.flipX=i.flipX),void 0!==i.flipY&&(e.flipY=i.flipY),void 0!==i.width&&(e.width=i.width),void 0!==i.height&&(e.height=i.height),void 0!==i.spriteAsset&&(e.spriteAsset=i.spriteAsset),i.sprite&&(e.sprite=i.sprite),void 0!==i.frame&&(e.frame=i.frame),i.clips)for(var a in i.clips)e.addClip(i.clips[a]);void 0!==i.speed&&(e.speed=i.speed),i.autoPlayClip&&(e.autoPlayClip=i.autoPlayClip),e.batchGroupId=void 0===i.batchGroupId||null===i.batchGroupId?-1:i.batchGroupId,t.prototype.initializeComponentData.call(this,e,i,n)},i.cloneComponent=function(t,e){var i=t.sprite;return this.addComponent(e,{enabled:i.enabled,type:i.type,spriteAsset:i.spriteAsset,sprite:i.sprite,width:i.width,height:i.height,frame:i.frame,color:i.color.clone(),opacity:i.opacity,flipX:i.flipX,flipY:i.flipY,speed:i.speed,clips:i.clips,autoPlayClip:i.autoPlayClip,batchGroupId:i.batchGroupId,drawOrder:i.drawOrder,layers:i.layers.slice(0)})},i.onUpdate=function(t){var e=this.store;for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];if(n.data.enabled&&n.entity.enabled){var s=n.entity.sprite;s._currentClip&&s._currentClip._update(t)}}},i.onBeforeRemove=function(t,e){e.onDestroy()},y(e,[{key:"defaultMaterial",get:function(){if(!this._defaultMaterial){var t=new Us(this.app.graphicsDevice,{width:1,height:1,format:7,name:"sprite"}),e=new Uint8Array(t.lock());e[0]=e[1]=e[2]=e[3]=255,t.unlock();var i=new vu;i.diffuse.set(0,0,0),i.emissive.set(.5,.5,.5),i.emissiveMap=t,i.emissiveTint=!0,i.opacityMap=t,i.opacityMapChannel="a",i.opacityTint=!0,i.opacity=0,i.useLighting=!1,i.useGammaTonemap=!1,i.useFog=!1,i.useSkybox=!1,i.blendType=4,i.depthWrite=!1,i.pixelSnap=!1,i.cull=he,i.update(),this._defaultTexture=t,this._defaultMaterial=i}return this._defaultMaterial},set:function(t){this._defaultMaterial=t}},{key:"default9SlicedMaterialSlicedMode",get:function(){if(!this._default9SlicedMaterialSlicedMode){var t=this.defaultMaterial.clone();t.nineSlicedMode=1,t.update(),this._default9SlicedMaterialSlicedMode=t}return this._default9SlicedMaterialSlicedMode},set:function(t){this._default9SlicedMaterialSlicedMode=t}},{key:"default9SlicedMaterialTiledMode",get:function(){if(!this._default9SlicedMaterialTiledMode){var t=this.defaultMaterial.clone();t.nineSlicedMode=2,t.update(),this._default9SlicedMaterialTiledMode=t}return this._default9SlicedMaterialTiledMode},set:function(t){this._default9SlicedMaterialTiledMode=t}}]),e}(Op);Dp._buildAccessors(By.prototype,Ny);var Vy=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._oldState=!0,n._size=new Et,n.on("set_enabled",n._onSetEnabled,w(n)),n}S(e,t);var i=e.prototype;return i.onEnable=function(){this._checkState()},i.onDisable=function(){this._checkState()},i._onSetEnabled=function(t,e,i){this._checkState()},i._checkState=function(){var t=this.enabled&&this.entity.enabled;t!==this._oldState&&(this._oldState=t,this.fire("enable"),this.fire("state",this.enabled))},i._onBeforeRemove=function(){this.fire("remove")},y(e,[{key:"size",get:function(){return this._size},set:function(t){t instanceof Et?this._size.copy(t):t instanceof Array&&t.length>=3&&this.size.set(t[0],t[1],t[2])}}]),e}(Dp),Gy=function(){this.enabled=!0},Hy=["enabled"],Wy=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="zone",i.ComponentType=Vy,i.DataType=Gy,i.schema=Hy,i.on("beforeremove",i._onBeforeRemove,w(i)),i}S(e,t);var i=e.prototype;return i.initializeComponentData=function(t,e,i){t.enabled=!e.hasOwnProperty("enabled")||!!e.enabled,e.size&&(e.size instanceof Et?t.size.copy(e.size):e.size instanceof Array&&e.size.length>=3&&t.size.set(e.size[0],e.size[1],e.size[2]))},i.cloneComponent=function(t,e){var i={size:t.zone.size};return this.addComponent(e,i)},i._onBeforeRemove=function(t,e){e._onBeforeRemove()},e}(Op);Dp._buildAccessors(Vy.prototype,Hy);var Xy=function(t,e){this.effect=t,this.inputTarget=e,this.outputTarget=null,this.name=t.constructor.name},qy=function(){function t(t,e){this.app=t,this.camera=e,this.destinationRenderTarget=null,this.effects=[],this.enabled=!1,this.depthTarget=null,e.on("set:rect",this.onCameraRectChanged,this)}var e=t.prototype;return e._allocateColorBuffer=function(t,e){var i,n,s=this.camera.rect,r=this.destinationRenderTarget,a=this.app.graphicsDevice,o=Math.floor(s.z*(null!=(i=null==r?void 0:r.width)?i:a.width)),h=Math.floor(s.w*(null!=(n=null==r?void 0:r.height)?n:a.height));return new Us(a,{name:e,format:t,width:o,height:h,mipmaps:!1,minFilter:0,magFilter:0,addressU:1,addressV:1})},e._createOffscreenTarget=function(t,e){var i=this.app.graphicsDevice,n=e&&i.getRenderableHdrFormat([ue,fe],!0)||7,s=this.camera.entity.name+"-posteffect-"+this.effects.length,r=this._allocateColorBuffer(n,s);return new ln({colorBuffer:r,depth:t,stencil:t&&this.app.graphicsDevice.supportsStencil,samples:t?i.samples:1})},e._resizeOffscreenTarget=function(t){var e=t.colorBuffer.format,i=t.colorBuffer.name;t.destroyFrameBuffers(),t.destroyTextureBuffers(),t._colorBuffer=this._allocateColorBuffer(e,i),t._colorBuffers=[t._colorBuffer]},e._destroyOffscreenTarget=function(t){t.destroyTextureBuffers(),t.destroy()},e.addEffect=function(t){var e=this.effects,i=0===e.length,n=this._createOffscreenTarget(i,t.hdr),s=new Xy(t,n);e.push(s),this._sourceTarget=s.inputTarget,e.length>1&&(e[e.length-2].outputTarget=s.inputTarget),this._newPostEffect=t,t.needsDepthBuffer&&this._requestDepthMap(),this.enable(),this._newPostEffect=void 0},e.removeEffect=function(t){for(var e=-1,i=0,n=this.effects.length;i=0&&(e>0?this.effects[e-1].outputTarget=e+11&&(this.effects[1].inputTarget._depth||(this._destroyOffscreenTarget(this.effects[1].inputTarget),this.effects[1].inputTarget=this._createOffscreenTarget(!0,this.effects[1].hdr),this._sourceTarget=this.effects[1].inputTarget),this.camera.renderTarget=this.effects[1].inputTarget),this._destroyOffscreenTarget(this.effects[e].inputTarget),this.effects.splice(e,1)),this.enabled&&t.needsDepthBuffer&&this._releaseDepthMap(),0===this.effects.length&&this.disable()},e._requestDepthMaps=function(){for(var t=0,e=this.effects.length;t0},set:function(t){t&&!this._sceneColorMapRequested?(this.requestSceneColorMap(!0),this._sceneColorMapRequested=!0):this._sceneColorMapRequested&&(this.requestSceneColorMap(!1),this._sceneColorMapRequested=!1)}},{key:"renderSceneDepthMap",get:function(){return this._renderSceneDepthMap>0},set:function(t){t&&!this._sceneDepthMapRequested?(this.requestSceneDepthMap(!0),this._sceneDepthMapRequested=!0):this._sceneDepthMapRequested&&(this.requestSceneDepthMap(!1),this._sceneDepthMapRequested=!1)}},{key:"renderTarget",get:function(){return this._camera.renderTarget},set:function(t){this._camera.renderTarget=t,this.dirtyLayerCompositionCameras()}},{key:"scissorRect",get:function(){return this._camera.scissorRect},set:function(t){this._camera.scissorRect=t}},{key:"sensitivity",get:function(){return this._camera.sensitivity},set:function(t){this._camera.sensitivity=t}},{key:"shutter",get:function(){return this._camera.shutter},set:function(t){this._camera.shutter=t}},{key:"viewMatrix",get:function(){return this._camera.viewMatrix}}]),e}(Dp),Yy=function(){this.enabled=!0},Ky=["enabled"],Zy=function(t){function e(e){var i;return(i=t.call(this,e)||this).cameras=[],i.id="camera",i.ComponentType=jy,i.DataType=Yy,i.schema=Ky,i.on("beforeremove",i.onBeforeRemove,w(i)),i.app.on("prerender",i.onAppPrerender,w(i)),i.app.systems.on("update",i.onUpdate,w(i)),i}S(e,t);var i=e.prototype;return i.initializeComponentData=function(e,i,n){n=["aspectRatio","aspectRatioMode","calculateProjection","calculateTransform","clearColor","clearColorBuffer","clearDepthBuffer","clearStencilBuffer","renderSceneColorMap","renderSceneDepthMap","cullFaces","farClip","flipFaces","fov","frustumCulling","horizontalFov","layers","renderTarget","nearClip","orthoHeight","projection","priority","rect","scissorRect","aperture","shutter","sensitivity"];for(var s=0;s=0&&(this.cameras.splice(e,1),Nu(this.cameras))},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("update",this.onUpdate,this)},e}(Op);Dp._buildAccessors(jy.prototype,Ky);var Qy=[],$y=[],Jy=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this)._cookieAsset=null,n._cookieAssetId=null,n._cookieAssetAdd=!1,n._cookieMatrix=null,n}S(e,t);var i=e.prototype;return i.addLightToLayers=function(){for(var t=0;t=0&&this.enabled&&this.entity.enabled&&(t.addLight(this),this.light.addLayer(t))},i.onLayerRemoved=function(t){this.layers.indexOf(t.id)>=0&&(t.removeLight(this),this.light.removeLayer(t))},i.refreshProperties=function(){for(var t=0;t=3&&i.length<=4){for(var u=0;ue.ind&&(o=e.ind),this._insertScriptInstance(r,o,a),this._scriptsIndex[s]={instance:r,onSwap:function(){i.swap(s)}},this[s]=r,e.preloading||r.__initializeAttributes(),this.fire("create",s,r),this.fire("create:"+s,r),this.system.app.scripts.on("swap:"+s,this._scriptsIndex[s].onSwap),e.preloading||(r.enabled&&!r._initialized&&(r._initialized=!0,r.initialize&&this._scriptMethod(r,ox)),r.enabled&&!r._postInitialized&&(r._postInitialized=!0,r.postInitialize&&this._scriptMethod(r,hx))),r}}else this._scriptsIndex[s]={awaiting:!0,ind:this._scripts.length};return null},i.destroy=function(t){var e=t,i=t;"string"==typeof i?i=this.system.app.scripts.get(i):i&&(e=i.__name);var n=this._scriptsIndex[e];if(delete this._scriptsIndex[e],!n)return!1;var s=n.instance;if(s&&!s._destroyed)if(s.enabled=!1,s._destroyed=!0,this._isLoopingThroughScripts)this._destroyedScripts.push(s);else{var r=this._removeScriptInstance(s);r>=0&&this._resetExecutionOrder(r,this._scripts.length)}return this.system.app.scripts.off("swap:"+e,n.onSwap),delete this[e],this.fire("destroy",e,s||null),this.fire("destroy:"+e,s||null),s&&s.fire("destroy"),!0},i.swap=function(t){var e=t,i=t;"string"==typeof i?i=this.system.app.scripts.get(i):i&&(e=i.__name);var n=this._scriptsIndex[e];if(!n||!n.instance)return!1;var s=n.instance,r=this._scripts.indexOf(s),a=new i({app:this.system.app,entity:this.entity,enabled:s.enabled,attributes:s.__attributes});return!!a.swap&&(a.__initializeAttributes(),this._scripts[r]=a,this._scriptsIndex[e].instance=a,this[e]=a,a.__executionOrder=r,s.update&&this._updateList.remove(s),s.postUpdate&&this._postUpdateList.remove(s),a.update&&this._updateList.insert(a),a.postUpdate&&this._postUpdateList.insert(a),this._scriptMethod(a,"swap",s),this.fire("swap",e,a),this.fire("swap:"+e,a),!0)},i.resolveDuplicatedEntityReferenceProperties=function(t,e){var i=this.entity.script;for(var n in t._scriptsIndex){var s=this.system.app.scripts.get(n);if(s){var r=t._scriptsIndex[n];if(r&&r.instance){var a=i[n].__attributesRaw,o=i[n].__attributes;if(a||o){var h=!!a,l=r.instance.__attributes;for(var c in l)if(l[c]){var u=s.attributes.get(c);if(u)if("entity"===u.type)this._resolveEntityScriptAttribute(u,c,l[c],h,a||o,e);else if("json"===u.type&&Array.isArray(u.schema))for(var d=l[c],f=a?a[c]:o[c],p=0;p=i||e<0)return!1;var n=t,s=t;"string"!=typeof s?s=t.__name:n=null;var r=this._scriptsIndex[s];if(!r||!r.instance)return!1;var a=r.instance;if(n&&!(a instanceof n))return!1;var o=this._scripts.indexOf(a);return-1!==o&&o!==e&&(this._scripts.splice(e,0,this._scripts.splice(o,1)[0]),this._resetExecutionOrder(0,i),this._updateList.sort(),this._postUpdateList.sort(),this.fire("move",s,a,e,o),this.fire("move:"+s,a,e,o),!0)},y(e,[{key:"scripts",get:function(){return this._scripts},set:function(t){for(var e in this._scriptsData=t,t)if(t.hasOwnProperty(e)){var i=this._scriptsIndex[e];if(i){if("boolean"==typeof t[e].enabled&&(i.enabled=!!t[e].enabled),"object"==typeof t[e].attributes)for(var n in t[e].attributes)if(!ax.reservedNames.has(n)){if(!i.__attributes.hasOwnProperty(n)){var s=this.system.app.scripts.get(e);s&&s.attributes.add(n,{})}i[n]=t[e].attributes[n]}}else console.log(this.order)}}},{key:"enabled",get:function(){return this._enabled},set:function(t){var e=this._enabled;this._enabled=t,this.fire("set","enabled",e,t)}}]),e}(Dp),cx=function(){this.enabled=!0},ux=0,dx=function(t){function e(e){var i;return(i=t.call(this,e)||this).id="script",i.ComponentType=lx,i.DataType=cx,i._components=new ct({sortBy:"_executionOrder"}),i._enabledComponents=new ct({sortBy:"_executionOrder"}),i.preloading=!0,i.on("beforeremove",i._onBeforeRemove,w(i)),i.app.systems.on("initialize",i._onInitialize,w(i)),i.app.systems.on("postInitialize",i._onPostInitialize,w(i)),i.app.systems.on("update",i._onUpdate,w(i)),i.app.systems.on("postUpdate",i._onPostUpdate,w(i)),i}S(e,t);var i=e.prototype;return i.initializeComponentData=function(t,e){if(t._executionOrder=ux++,this._components.append(t),ux>Number.MAX_SAFE_INTEGER&&this._resetExecutionOrder(),t.enabled=!e.hasOwnProperty("enabled")||!!e.enabled,t.enabled&&t.entity.enabled&&this._enabledComponents.append(t),e.hasOwnProperty("order")&&e.hasOwnProperty("scripts")){t._scriptsData=e.scripts;for(var i=0;i=0&&e._onBeforeRemove(),this._removeComponentFromEnabled(e),this._components.remove(e)},i.destroy=function(){t.prototype.destroy.call(this),this.app.systems.off("initialize",this._onInitialize,this),this.app.systems.off("postInitialize",this._onPostInitialize,this),this.app.systems.off("update",this._onUpdate,this),this.app.systems.off("postUpdate",this._onPostUpdate,this)},e}(Op),fx=function(t){function e(){var e;return(e=t.call(this)||this)._meshes=null,e}S(e,t);var i=e.prototype;return i.destroy=function(){this.meshes=null},i.decRefMeshes=function(){if(this._meshes)for(var t=this._meshes.length,e=0;e0){var r=e.jobQueue.shift();e.run(t,r)}else{var a=e.workers[2].indexOf(t);if(-1!==a)e.workers[2].splice(a,1),e.workers[1].push(t);else{var o=e.workers[1].indexOf(t);-1!==o&&(e.workers[1].splice(o,1),e.workers[0].push(t))}}}))})),this.workers[0]=t;this.jobQueue.length&&(this.workers[0].length||this.workers[1].length);){var i=this.jobQueue.shift();if(this.workers[0].length>0){var n=this.workers[0].shift();this.workers[1].push(n),this.run(n,i)}else{var s=this.workers[1].shift();this.workers[2].push(s),this.run(s,i)}}},e.enqueueJob=function(t,e){var i={jobId:this.jobId++,buffer:t};if(this.jobCallbacks.set(i.jobId,e),this.workers[0].length>0){var n=this.workers[0].shift();this.workers[1].push(n),this.run(n,i)}else if(this.workers[1].length>0){var s=this.workers[1].shift();this.workers[2].push(s),this.run(s,i)}else this.jobQueue.push(i)},t}(),Cx=function(t){var e=function(){return fetch(t).then((function(t){return t.arrayBuffer()})).then((function(t){return WebAssembly.compile(t)}))};return WebAssembly.compileStreaming?WebAssembly.compileStreaming(fetch(t)).catch((function(t){return e()})):e()},Ex=function(t){if(Sx)return!0;if(!t)if(bx)t=bx;else{var e=ht.getConfig("DracoDecoderModule");t=e?{jsUrl:e.glueUrl,wasmUrl:e.wasmUrl,numWorkers:e.numWorkers}:{jsUrl:"draco.wasm.js",wasmUrl:"draco.wasm.wasm",numWorkers:1}}return!(!t.jsUrl||!t.wasmUrl)&&(Sx=new Ax,Promise.all([(i=t.jsUrl,new Promise((function(t,e){var n={cache:!0,responseType:"text",retry:!0,maxRetries:3};Ca.get(i,n,(function(i,n){i?e(i):t(n)}))}))),Cx(t.wasmUrl)]).then((function(e){for(var i=e[0],n=e[1],s=["/* draco */",i,"/* worker */","(\n"+xx.toString()+"\n)()\n\n"].join("\n"),r=new Blob([s],{type:"application/javascript"}),a=URL.createObjectURL(r),o=Math.max(1,Math.min(16,t.numWorkers||1)),h=[],l=0;l0&&o(n,Float32Array,1),s.length>0&&o(s,Uint16Array,65535),r.length>0&&o(r,Uint8Array,255)}(y),y.unlock(),y},Hx=function(t,e,i,n,s,r,a){var o,h=new no(t);h.aabb=Ux(i[e.attributes.POSITION]);for(var l=[],c=0,u=Object.entries(e.attributes);c0?i.name=t.name:i.name="node_"+e,t.hasOwnProperty("matrix")&&(nS.data.set(t.matrix),nS.getTranslation(sS),i.setLocalPosition(sS),nS.getEulerAngles(sS),i.setLocalEulerAngles(sS),nS.getScale(sS),i.setLocalScale(sS)),t.hasOwnProperty("rotation")){var n=t.rotation;i.setLocalRotation(n[0],n[1],n[2],n[3])}if(t.hasOwnProperty("translation")){var s=t.translation;i.setLocalPosition(s[0],s[1],s[2])}if(t.hasOwnProperty("scale")){var r=t.scale;i.setLocalScale(r[0],r[1],r[2])}return i},aS=function(t,e){var i="orthographic"===t.type?1:0,n=1===i?t.orthographic:t.perspective,s={enabled:!1,projection:i,nearClip:n.znear,aspectRatioMode:0};n.zfar&&(s.farClip=n.zfar),1===i?(s.orthoHeight=.5*n.ymag,n.ymag&&(s.aspectRatioMode=1,s.aspectRatio=n.xmag/n.ymag)):(s.fov=n.yfov*_t.RAD_TO_DEG,n.aspectRatio&&(s.aspectRatioMode=1,s.aspectRatio=n.aspectRatio));var r=new fp(t.name);return r.addComponent("camera",s),r},oS=function(t,e){var i={enabled:!1,type:"point"===t.type?"omni":t.type,color:t.hasOwnProperty("color")?new gt(t.color):gt.WHITE,range:t.hasOwnProperty("range")?t.range:9999,falloffMode:1,intensity:t.hasOwnProperty("intensity")?_t.clamp(t.intensity,0,2):1};t.hasOwnProperty("spot")&&(i.innerConeAngle=t.spot.hasOwnProperty("innerConeAngle")?t.spot.innerConeAngle*_t.RAD_TO_DEG:0,i.outerConeAngle=t.spot.hasOwnProperty("outerConeAngle")?t.spot.outerConeAngle*_t.RAD_TO_DEG:Math.PI/4),t.hasOwnProperty("intensity")&&(i.luminance=t.intensity*Yu.getLightUnitConversion(Wu[i.type],i.outerConeAngle,i.innerConeAngle));var n=new fp(e.name);return n.rotateLocal(90,0,0),n.addComponent("light",i),n},hS=function(t,e,i,n){if(!e.hasOwnProperty("skins")||0===e.skins.length)return[];var s=new Map;return e.skins.map((function(r){return function(t,e,i,n,s,r){var a,o,h,l=e.joints,c=l.length,u=[];if(e.hasOwnProperty("inverseBindMatrices")){var d=e.inverseBindMatrices,f=Fx(i[d],n,!0),p=[];for(a=0;a0&&"localRotation"===D.paths[0].propertyPath[0]&&2!==D.interpolation&&g.push(P[P.length-1].output))}g.sort();var O,k=null;for(o=0;o0){var s,r,a,o,h=null==i||null==(s=i.camera)?void 0:s.preprocess,l=null!=(r=null==i||null==(a=i.camera)?void 0:a.process)?r:aS,c=null==i||null==(o=i.camera)?void 0:o.postprocess;t.nodes.forEach((function(i,s){if(i.hasOwnProperty("camera")){var r=t.cameras[i.camera];if(r){h&&h(r);var a=l(r,e[s]);c&&c(r,a),a&&(n||(n=new Map),n.set(i,a))}}}))}return n},_S=function(t,e,i){var n=null;if(t.hasOwnProperty("nodes")&&t.hasOwnProperty("extensions")&&t.extensions.hasOwnProperty("KHR_lights_punctual")&&t.extensions.KHR_lights_punctual.hasOwnProperty("lights")){var s=t.extensions.KHR_lights_punctual.lights;if(s.length){var r,a,o,h,l=null==i||null==(r=i.light)?void 0:r.preprocess,c=null!=(a=null==i||null==(o=i.light)?void 0:o.process)?a:oS,u=null==i||null==(h=i.light)?void 0:h.postprocess;t.nodes.forEach((function(t,i){if(t.hasOwnProperty("extensions")&&t.extensions.hasOwnProperty("KHR_lights_punctual")&&t.extensions.KHR_lights_punctual.hasOwnProperty("light")){var r=t.extensions.KHR_lights_punctual.light,a=s[r];if(a){l&&l(a);var o=c(a,e[i]);u&&u(a,o),o&&(n||(n=new Map),n.set(t,o))}}}))}}return n},gS=function(t,e,i){t.nodes.forEach((function(t){t.hasOwnProperty("mesh")&&t.hasOwnProperty("skin")&&e[t.mesh].meshes.forEach((function(e){e.skin=i[t.skin]}))}))},vS=(Tx=g(m().mark((function t(e,i,n,s,r){var a,o,h,l,c,u,d,f,p,_,g,v,y,x,S,b,w,T,A,C,E,M,P,R;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return h=null==r||null==(a=r.global)?void 0:a.preprocess,l=null==r||null==(o=r.global)?void 0:o.postprocess,h&&h(i),c=i.asset&&"PlayCanvas"===i.asset.generator,u=fS(i,r),d=pS(i,u),f=_S(i,u,r),p=mS(i,u,r),_=uS(i),t.next=12,Promise.all(n);case 12:return g=t.sent,v=lS(e,i,g,c,r),y=v.meshes,x=v.meshVariants,S=v.meshDefaultMaterials,b=v.promises,w=dS(i,u,g,r),t.next=17,Promise.all(s);case 17:for(T=t.sent,A=T.map((function(t){return t.resource})),C=cS(i,A,r,c),E=hS(e,i,u,g),M=[],P=0;Pi.byteLength)e("Invalid length found in glb header. Found "+r);else{for(var a=[],o=12;oi.byteLength&&e("Invalid chunk length found in glb. Found "+h);var l=i.getUint32(o+4,!0),c=new Uint8Array(i.buffer,i.byteOffset+o+8,h);a.push({length:h,type:l,data:c}),o+=h+8}1===a.length||2===a.length?1313821514===a[0].type?a.length>1&&5130562!==a[1].type?e("Invalid chunk type found in glb file. Expected 0x004E4942, found 0x"+a[1].type.toString(16)):e(null,{gltfChunk:a[0].data,binaryChunk:2===a.length?a[1].data:null}):e("Invalid chunk type found in glb file. Expected 0x4E4F534A, found 0x"+a[0].type.toString(16)):e("Invalid number of chunks found in glb file.")}else e("Invalid version number found in glb header. Expected 2, found "+s);else e("Invalid magic number found in glb header. Expected 0x46546C67, found 0x"+n.toString(16))}(e,i):i(null,{gltfChunk:e,binaryChunk:null})},SS=function(){function t(){}return t.parse=function(t,e,i,n,s,r,a){xS(t,i,(function(t,i){t?a(t):function(t,e){var i=JSON.parse(function(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);for(var e="",i=0;i0,maxRetries:this.maxRetries};(t.load.startsWith("blob:")||t.load.startsWith("data:"))&&(".glb"===L.getExtension(t.original).toLowerCase()?s.responseType=Aa.ResponseType.ARRAY_BUFFER:s.responseType=Aa.ResponseType.JSON),Ca.get(t.load,s,(function(s,r){var a;s?e("Error loading animation resource: "+t.original+" ["+s+"]"):".glb"===L.getExtension(t.original).toLowerCase()?SS.parse("filename.glb","",r,n.device,n.assets,null!=(a=null==i?void 0:i.options)?a:{},(function(t,n){if(t)e(t);else{var s,r=n.animations;if(null!=i&&null!=(s=i.data)&&s.events)for(var a=0;a0,maxRetries:this.maxRetries};t.load.startsWith("blob:")&&(i.responseType=Aa.ResponseType.JSON),Ca.get(t.load,i,(function(i,n){i?e("Error loading animation clip resource: "+t.original+" ["+i+"]"):e(null,n)}))},e.open=function(t,e){var i=e.name,n=e.duration,s=e.inputs.map((function(t){return new yx(1,t)})),r=e.outputs.map((function(t){return new yx(t.components,t.data)})),a=e.curves.map((function(t){return new vx([t.path],t.inputIndex,t.outputIndex,t.interpolation)}));return new pm(i,n,s,r,a)},e.patch=function(t,e){},t}(),TS=function(){function t(t){this.handlerType="animstategraph",this.maxRetries=0}var e=t.prototype;return e.load=function(t,e){"string"==typeof t&&(t={load:t,original:t});var i={retry:this.maxRetries>0,maxRetries:this.maxRetries};t.load.startsWith("blob:")&&(i.responseType=Aa.ResponseType.JSON),Ca.get(t.load,i,(function(i,n){i?e("Error loading animation state graph resource: "+t.original+" ["+i+"]"):e(null,n)}))},e.open=function(t,e){return new Um(e)},e.patch=function(t,e){},t}(),AS=function(){if("undefined"==typeof window)return!1;var t=window.navigator.userAgent,e=t.indexOf("MSIE ");if(e>0)return parseInt(t.substring(e+5,t.indexOf(".",e)),10);if(t.indexOf("Trident/")>0){var i=t.indexOf("rv:");return parseInt(t.substring(i+3,t.indexOf(".",i)),10)}return!1}(),CS=[".ogg",".mp3",".wav",".mp4a",".m4a",".mp4",".aac",".opus"],ES=function(){function t(t){this.handlerType="audio",this.manager=t.soundManager,this.maxRetries=0}var e=t.prototype;return e._isSupported=function(t){var e=L.getExtension(t);return CS.indexOf(e)>-1},e.load=function(t,e){"string"==typeof t&&(t={load:t,original:t});var i=function(i){var n="Error loading audio url: "+t.original;i&&(n+=": "+(i.message||i)),console.warn(n),e(n)};if(this._createSound){if(!this._isSupported(t.original))return void i("Audio format for "+t.original+" not supported");this._createSound(t.load,(function(t){e(null,new ka(t))}),i)}else i(null)},e.open=function(t,e){return e},e.patch=function(t,e){},e._createSound=function(t,e,i){if(Ea()){var n=this.manager;if(!n.context)return void i("Audio manager has no audio context");var s={retry:this.maxRetries>0,maxRetries:this.maxRetries};(t.startsWith("blob:")||t.startsWith("data:"))&&(s.responseType=Aa.ResponseType.ARRAY_BUFFER),Ca.get(t,s,(function(t,s){t?i(t):n.context.decodeAudioData(s,e,i)}))}else{var r=null;try{r=new Audio}catch(t){return void i("No support for Audio element")}AS&&document.body.appendChild(r);r.onerror=function(){r.onerror=null,AS&&document.body.removeChild(r),i()},r.addEventListener("canplaythrough",(function t(){r.removeEventListener("canplaythrough",t),AS&&document.body.removeChild(r),e(r)})),r.src=t}},t}(),MS=function(){function t(t){this.handlerType="binary",this.maxRetries=0}var e=t.prototype;return e.load=function(t,e){"string"==typeof t&&(t={load:t,original:t}),Ca.get(t.load,{responseType:Aa.ResponseType.ARRAY_BUFFER,retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(i,n){i?e("Error loading binary resource: "+t.original+" ["+i+"]"):e(null,n)}))},e.open=function(t,e){return e},e.patch=function(t,e){},t}(),PS=function(){function t(e,i,n,s){for(var r=function(e,s,r){var a=t.createAsset(i.name,e,s,r);return n.add(a),a},a=[],o=0;o=0?t.split("?")[0]:t},e.load=function(t,e,i){var n=this;$f.fetchArrayBuffer(t.load,(function(s,r){s?e(s):SS.parse(n._getUrlWithoutParams(t.original),L.extractPath(t.load),r,n._device,i.registry,i.options,(function(t,s){t?e(t):e(null,new PS(s,i,n._assets,n._defaultMaterial))}))}),i,this.maxRetries)},e.open=function(t,e,i){return e},e.patch=function(t,e){},t}(),IS=function(){function t(){}var e=t.prototype;return e.instantiateModelEntity=function(t){return null},e.instantiateRenderEntity=function(t){return null},e.getMaterialVariants=function(){return null},e.applyMaterialVariant=function(t,e){},e.applyMaterialVariantInstances=function(t,e){},t}(),LS=function(){function t(t){this.handlerType="container",this.glbContainerParser=new RS(t.graphicsDevice,t.assets,0),this.parsers={}}var e=t.prototype;return e._getUrlWithoutParams=function(t){return t.indexOf("?")>=0?t.split("?")[0]:t},e._getParser=function(t){var e=t?L.getExtension(this._getUrlWithoutParams(t)).toLowerCase().replace(".",""):null;return this.parsers[e]||this.glbContainerParser},e.load=function(t,e,i){"string"==typeof t&&(t={load:t,original:t}),this._getParser(t.original).load(t,e,i)},e.open=function(t,e,i){return this._getParser(t).open(t,e,i)},e.patch=function(t,e){},y(t,[{key:"maxRetries",get:function(){return this.glbContainerParser.maxRetries},set:function(t){for(var e in this.glbContainerParser.maxRetries=t,this.parsers)this.parsers.hasOwnProperty(e)&&(this.parsers[e].maxRetries=t)}}]),t}(),DS=function(){function t(t){this.handlerType="css",this.maxRetries=0}var e=t.prototype;return e.load=function(t,e){"string"==typeof t&&(t={load:t,original:t}),Ca.get(t.load,{retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(i,n){i?e("Error loading css resource: "+t.original+" ["+i+"]"):e(null,n)}))},e.open=function(t,e){return e},e.patch=function(t,e){},t}(),OS=function(){function t(t){this.handlerType="cubemap",this._device=t.graphicsDevice,this._registry=t.assets,this._loader=t.loader}var e=t.prototype;return e.load=function(t,e,i){this.loadAssets(i,e)},e.open=function(t,e,i){return i?i.resource:null},e.patch=function(t,e){this.loadAssets(t,(function(i,n){i&&(e.fire("error",t),e.fire("error:"+t.id,i,t),t.fire("error",t))}))},e.getAssetIds=function(t){var e=[];if(e[0]=t.file,(t.loadFaces||!t.file)&&t.data&&t.data.textures)for(var i=0;i<6;++i)e[i+1]=t.data.textures[i];else e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=null;return e},e.compareAssetIds=function(t,e){return t&&e?parseInt(t,10)===t||"string"==typeof t?t===e:t.url===e.url:null!==t==(null!==e)},e.update=function(t,e,i){var n,s,r,a=t.data||{},o=t._handlerState.assets,h=t._resources,l=[null,null,null,null,null,null,null],c=function(){return a.hasOwnProperty("type")?a.type:a.hasOwnProperty("rgbm")?a.rgbm?ai:ri:null};if(t.loaded&&i[0]===o[0])l[1]=h[1]||null,l[2]=h[2]||null,l[3]=h[3]||null,l[4]=h[4]||null,l[5]=h[5]||null,l[6]=h[6]||null;else if(i[0])if((n=i[0].resource).cubemap)for(r=0;r<6;++r)l[r+1]=new Us(this._device,{name:t.name+"_prelitCubemap"+(n.width>>r),cubemap:!0,type:c()||n.type,width:n.width>>r,height:n.height>>r,format:n.format,levels:[n._levels[r]],fixCubemapSeams:!0,addressU:1,addressV:1,mipmaps:0===r});else n.type=hi,n.addressU=1,n.addressV=1,n.mipmaps=!1,l[1]=n;var u=i.slice(1);if(t.loaded&&this.cmpArrays(u,o.slice(1)))l[0]=h[0]||null;else if(-1===u.indexOf(null)){var d,f=u.map((function(t){return t.resource})),p=[];for(s=0;s0,maxRetries:this.maxRetries},(function(i,s){if(i)e("Error loading font resource: "+t.original+" ["+i+"]");else{var r=BS(s);n._loadTextures(t.load.replace(".json",".png"),r,(function(t,i){t?e(t):e(null,{data:r,textures:i})}))}})):(i&&i.data&&(i.data=BS(i.data)),this._loadTextures(t.load,i&&i.data,e))},e._loadTextures=function(t,e,i){for(var n=e.info.maps.length,s=0,r=null,a=new Array(n),o=this._loader,h=function(e){var h=function(t,o){if(!r){if(t)return r=t,void i(t);o.upload(),a[e]=o,++s===n&&i(null,a)}};0===e?o.load(t,"texture",h):o.load(t.replace(".png",e+".png"),"texture",h)},l=0;l0,maxRetries:e},(function(e,n){if(e){var s="Error while loading scene JSON "+t.original;e.message?(s+=": "+e.message,e.stack&&(s+="\n"+e.stack)):s+=": "+e,i(s)}else i(e,n)}))},t}(),HS=function(){function t(t){this.handlerType="hierarchy",this._app=t,this.maxRetries=0}var e=t.prototype;return e.load=function(t,e){GS.load(t,this.maxRetries,e)},e.open=function(t,e){this._app.systems.script.preloading=!0;var i=new VS(this._app,!1).parse(e);return this._app.systems.script.preloading=!1,i},t}(),WS=function(){function t(t){this.handlerType="html",this.maxRetries=0}var e=t.prototype;return e.load=function(t,e){"string"==typeof t&&(t={load:t,original:t}),Ca.get(t.load,{retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(i,n){i?e("Error loading html resource: "+t.original+" ["+i+"]"):e(null,n)}))},e.open=function(t,e){return e},e.patch=function(t,e){},t}(),XS=function(){function t(t){this.handlerType="json",this.maxRetries=0}var e=t.prototype;return e.load=function(t,e){"string"==typeof t&&(t={load:t,original:t});var i={retry:this.maxRetries>0,maxRetries:this.maxRetries};t.load.startsWith("blob:")&&(i.responseType=Aa.ResponseType.JSON),Ca.get(t.load,i,(function(i,n){i?e("Error loading JSON resource: "+t.original+" ["+i+"]"):e(null,n)}))},e.open=function(t,e){return e},e.patch=function(t,e){},t}(),qS=function(){function t(){this.removeInvalid=!0,this.valid=!0,this.enumValidators={occludeSpecular:this._createEnumValidator([0,1,2]),cull:this._createEnumValidator([he,1,2,3]),blendType:this._createEnumValidator([0,1,2,3,4,5,6,7,8,9,10]),depthFunc:this._createEnumValidator([0,1,2,3,4,5,6,7]),shadingModel:this._createEnumValidator([0,1])}}var e=t.prototype;return e.setInvalid=function(t,e){this.valid=!1,this.removeInvalid&&delete e[t]},e.validate=function(t){var e=lu,i=pu,n="path"===t.mappingFormat;for(var s in t){var r=e[s];if(r)if(r.startsWith("enum")){var a=r.split(":")[1];this.enumValidators[a]&&(this.enumValidators[a](t[s])||this.setInvalid(s,t))}else if("number"===r)"number"!=typeof t[s]&&this.setInvalid(s,t);else if("boolean"===r)"boolean"!=typeof t[s]&&this.setInvalid(s,t);else if("string"===r)"string"!=typeof t[s]&&this.setInvalid(s,t);else if("vec2"===r)t[s]instanceof Array&&2===t[s].length||this.setInvalid(s,t);else if("rgb"===r)t[s]instanceof Array&&3===t[s].length||this.setInvalid(s,t);else if("texture"===r)n?"string"!=typeof t[s]&&null!==t[s]&&(t[s]instanceof Us||this.setInvalid(s,t)):"number"!=typeof t[s]&&null!==t[s]&&(t[s]instanceof Us||this.setInvalid(s,t));else if("boundingbox"===r)t[s].center&&t[s].center instanceof Array&&3===t[s].center.length||this.setInvalid(s,t),t[s].halfExtents&&t[s].halfExtents instanceof Array&&3===t[s].halfExtents.length||this.setInvalid(s,t);else if("cubemap"===r)"number"!=typeof t[s]&&null!==t[s]&&void 0!==t[s]&&(t[s]instanceof Us&&t[s].cubemap||this.setInvalid(s,t));else if("chunks"===r)for(var o=Object.keys(t[s]),h=0;h=0}},t}(),jS=function(){function t(){this._validator=null}var e=t.prototype;return e.parse=function(t){var e=this.migrate(t),i=this._validate(e),n=new vu;return this.initialize(n,i),n},e.initialize=function(t,e){for(var i in e.validated||(e=this._validate(e)),e.chunks&&(t.chunks=x({},e.chunks)),e){var n=lu[i],s=e[i];if("vec2"===n)t[i]=new It(s[0],s[1]);else if("rgb"===n)t[i]=new gt(s[0],s[1],s[2]);else if("texture"===n)s instanceof Us?t[i]=s:t[i]instanceof Us&&"number"==typeof s&&s>0||(t[i]=null);else if("cubemap"===n)s instanceof Us?t[i]=s:t[i]instanceof Us&&"number"==typeof s&&s>0||(t[i]=null),"cubeMap"!==i||s||(t.prefilteredCubemaps=null);else if("boundingbox"===n){var r=new Et(s.center[0],s.center[1],s.center[2]),a=new Et(s.halfExtents[0],s.halfExtents[1],s.halfExtents[2]);t[i]=new jt(r,a)}else t[i]=e[i]}t.update()},e.migrate=function(t){var e;void 0===t.shadingModel&&("blinn"===t.shader?t.shadingModel=1:t.shadingModel=0),t.shader&&delete t.shader,t.mapping_format&&(t.mappingFormat=t.mapping_format,delete t.mapping_format);var i=[["bumpMapFactor","bumpiness"],["aoUvSet","aoMapUv"],["aoMapVertexColor","aoVertexColor"],["diffuseMapVertexColor","diffuseVertexColor"],["emissiveMapVertexColor","emissiveVertexColor"],["specularMapVertexColor","specularVertexColor"],["metalnessMapVertexColor","metalnessVertexColor"],["opacityMapVertexColor","opacityVertexColor"],["glossMapVertexColor","glossVertexColor"],["lightMapVertexColor","lightVertexColor"],["diffuseMapTint","diffuseTint"],["specularMapTint","specularTint"],["emissiveMapTint","emissiveTint"],["metalnessMapTint","metalnessTint"],["clearCoatGlossiness","clearCoatGloss"]];for(e=0;e0,maxRetries:this.maxRetries},(function(i,n){i?e&&e("Error loading material: "+t.original+" ["+i+"]"):e&&(n._engine=!0,e(null,n))}))},e.open=function(t,e){var i=this._parser.parse(e);return e._engine&&(i._data=e,delete e._engine),i},e._createPlaceholders=function(){this._placeholderTextures={};var t={white:[255,255,255,255],gray:[128,128,128,255],black:[0,0,0,255],normal:[128,128,255,255]};for(var e in t)if(t.hasOwnProperty(e)){this._placeholderTextures[e]=new Us(this._device,{width:2,height:2,format:7,name:"material_placeholder"});for(var i=this._placeholderTextures[e].lock(),n=0;n<4;n++)for(var s=0;s<4;s++)i[4*n+s]=t[e][s];this._placeholderTextures[e].unlock()}},e.patch=function(t,e){t.resource._data&&(t._data=t.resource._data,delete t.resource._data),t.data.name=t.name,t.resource.name=t.name,this._bindAndAssignAssets(t,e),t.off("unload",this._onAssetUnload,this),t.on("unload",this._onAssetUnload,this)},e._onAssetUnload=function(t){delete t.data.parameters,delete t.data.chunks,delete t.data.name},e._assignTexture=function(t,e,i){e.resource[t]=i},e._getPlaceholderTexture=function(t){this._placeholderTextures||this._createPlaceholders();var e=YS[t];return this._placeholderTextures[e]},e._assignPlaceholderTexture=function(t,e){e.resource[t]=this._getPlaceholderTexture(t)},e._onTextureLoad=function(t,e,i){this._assignTexture(t,e,i.resource),e.resource.update()},e._onTextureAdd=function(t,e,i){this._assets.load(i)},e._onTextureRemoveOrUnload=function(t,e,i){var n=e.resource;n&&e.resource[t]===i.resource&&(this._assignPlaceholderTexture(t,e),n.update())},e._assignCubemap=function(t,e,i){if(e.resource[t]=i[0],"cubeMap"===t){var n=i.slice(1);n.every((function(t){return t}))?e.resource.prefilteredCubemaps=n:n[0]&&(e.resource.envAtlas=n[0])}},e._onCubemapLoad=function(t,e,i){this._assignCubemap(t,e,i.resources),this._parser.initialize(e.resource,e.data)},e._onCubemapAdd=function(t,e,i){0===e.data.shadingModel&&(e.loadFaces=!0),this._assets.load(i)},e._onCubemapRemoveOrUnload=function(t,e,i){var n=e.resource;e.data.prefilteredCubeMap128===i.resources[1]&&(this._assignCubemap(t,e,[null,null,null,null,null,null,null]),n.update())},e._bindAndAssignAssets=function(t,e){var i,n,s,r=this._parser.migrate(t.data),a=t.resource,o="path"===r.mappingFormat,h=cu;for(i=0;i0){for(var c=i.blendIndices.data[4*h+l],u=!0,d=0;dn)return!1;for(var f=0;f=0;n--)if(l[n].boneNames.length>i){var f=l.splice(n,1)[0],p=[];for(s=0;s=0;r--)u[r].mesh===_.originalMesh&&(u.push({mesh:o,node:u[r].node}),e&&e.push({material:e[r].material,path:e[r].path}));for(s=0;s=0;r--)u[r].mesh===_.originalMesh&&(u.splice(r,1),e&&e.splice(r,1))}!function(t){for(var e=t.vertices,i=t.skins,n=t.meshes,s=t.meshInstances,r=0;r0&&JS(s,null,this._device.getBoneLimit());for(i=0;i0&&(h>65535&&this._device.extUintElement?(s=new Tr(this._device,2,a),r=new Uint32Array(s.lock())):(s=new Tr(this._device,1,a),r=new Uint16Array(s.lock()))),{buffer:s,data:r}},e._parseMeshes=function(t,e,i,n,s,r){for(var a=t.model,o=[],h=0,l=0;l0,maxRetries:this.maxRetries};(t.load.startsWith("blob:")||t.load.startsWith("data:"))&&(".glb"===L.getExtension(t.original).toLowerCase()?s.responseType=Aa.ResponseType.ARRAY_BUFFER:s.responseType=Aa.ResponseType.JSON),Ca.get(t.load,s,(function(s,r){if(e)if(s)e("Error loading model: "+t.original+" ["+s+"]");else{for(var a=0;a0,maxRetries:this.maxRetries},(function(i,n){i?e("Error loading shader resource: "+t.original+" ["+i+"]"):e(null,n)}))},e.open=function(t,e){return e},e.patch=function(t,e){},t}();function ob(t){this.resource&&(this.resource.atlas=t.resource)}function hb(t){this.registry.load(t)}var lb=function(){function t(t){this.handlerType="sprite",this._assets=t.assets,this._device=t.graphicsDevice,this.maxRetries=0}var e=t.prototype;return e.load=function(t,e){"string"==typeof t&&(t={load:t,original:t}),".json"===L.getExtension(t.original)&&Ca.get(t.load,{retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(t,i){t?e(t):e(null,i)}))},e.open=function(t,e){var i=new lf(this._device);return t&&(i.__data=e),i},e.patch=function(t,e){var i=t.resource;if(i.__data&&(t.data.pixelsPerUnit=i.__data.pixelsPerUnit,t.data.renderMode=i.__data.renderMode,t.data.frameKeys=i.__data.frameKeys,i.__data.textureAtlasAsset)){var n=e.getByUrl(i.__data.textureAtlasAsset);n?t.data.textureAtlasAsset=n.id:console.warn("Could not find textureatlas with url: "+i.__data.textureAtlasAsset)}i.startUpdate(),i.renderMode=t.data.renderMode,i.pixelsPerUnit=t.data.pixelsPerUnit,i.frameKeys=t.data.frameKeys,this._updateAtlas(t),i.endUpdate(),t.off("change",this._onAssetChange,this),t.on("change",this._onAssetChange,this)},e._updateAtlas=function(t){var e=t.resource;if(t.data.textureAtlasAsset){this._assets.off("load:"+t.data.textureAtlasAsset,ob,t),this._assets.on("load:"+t.data.textureAtlasAsset,ob,t);var i=this._assets.get(t.data.textureAtlasAsset);i&&i.resource?e.atlas=i.resource:i?this._assets.load(i):(this._assets.off("add:"+t.data.textureAtlasAsset,hb,t),this._assets.on("add:"+t.data.textureAtlasAsset,hb,t))}else e.atlas=null},e._onAssetChange=function(t,e,i,n){"data"===e&&i&&i.textureAtlasAsset&&n&&i.textureAtlasAsset!==n.textureAtlasAsset&&(this._assets.off("load:"+n.textureAtlasAsset,ob,t),this._assets.off("add:"+n.textureAtlasAsset,hb,t))},t}(),cb=function(){function t(t,e){this._app=void 0,this._data=void 0,this._templateRoot=null,this._app=t,this._data=e}var e=t.prototype;return e.instantiate=function(){return this._templateRoot||this._parseTemplate(),this._templateRoot.clone()},e._parseTemplate=function(){var t=new VS(this._app,!0);this._templateRoot=t.parse(this._data)},t}(),ub=function(){function t(t){this.handlerType="template",this._app=t,this.maxRetries=0}var e=t.prototype;return e.load=function(t,e){"string"==typeof t&&(t={load:t,original:t});var i={retry:this.maxRetries>0,maxRetries:this.maxRetries};Ca.get(t.load,i,(function(i,n){i?e("Error requesting template: "+t.original):e(i,n)}))},e.open=function(t,e){return new cb(this._app,e)},t}(),db=function(){function t(t){this.handlerType="text",this.maxRetries=0}var e=t.prototype;return e.load=function(t,e){"string"==typeof t&&(t={load:t,original:t}),Ca.get(t.load,{retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(i,n){i?e("Error loading text resource: "+t.original+" ["+i+"]"):e(null,n)}))},e.open=function(t,e){return e},e.patch=function(t,e){},t}(),fb={repeat:0,clamp:1,mirror:2},pb={nearest:0,linear:1,nearest_mip_nearest:2,linear_mip_nearest:4,nearest_mip_linear:3,linear_mip_linear:5},mb=/^data\.frames\.(\d+)$/,_b=function(){function t(t){this.handlerType="textureatlas",this._loader=t.loader,this.maxRetries=0}var e=t.prototype;return e.load=function(t,e){"string"==typeof t&&(t={load:t,original:t});var i=this,n=this._loader.getHandler("texture");".json"===L.getExtension(t.original)?Ca.get(t.load,{retry:this.maxRetries>0,maxRetries:this.maxRetries},(function(n,s){if(n)e(n);else{var r=t.original.replace(".json",".png");i._loader.load(r,"texture",(function(t,i){t?e(t):e(null,{data:s,texture:i})}))}})):n.load(t,e)},e.open=function(t,e){var i=new cf;if(e.texture&&e.data)i.texture=e.texture,i.__data=e.data;else{var n=this._loader.getHandler("texture").open(t,e);if(!n)return null;i.texture=n}return i},e.patch=function(t,e){if(t.resource){t.resource.__data&&(void 0!==t.resource.__data.minfilter&&(t.data.minfilter=t.resource.__data.minfilter),void 0!==t.resource.__data.magfilter&&(t.data.magfilter=t.resource.__data.magfilter),void 0!==t.resource.__data.addressu&&(t.data.addressu=t.resource.__data.addressu),void 0!==t.resource.__data.addressv&&(t.data.addressv=t.resource.__data.addressv),void 0!==t.resource.__data.mipmaps&&(t.data.mipmaps=t.resource.__data.mipmaps),void 0!==t.resource.__data.anisotropy&&(t.data.anisotropy=t.resource.__data.anisotropy),void 0!==t.resource.__data.rgbm&&(t.data.rgbm=!!t.resource.__data.rgbm),t.data.frames=t.resource.__data.frames,delete t.resource.__data);var i=t.resource.texture;if(i&&(i.name=t.name,t.data.hasOwnProperty("minfilter")&&i.minFilter!==pb[t.data.minfilter]&&(i.minFilter=pb[t.data.minfilter]),t.data.hasOwnProperty("magfilter")&&i.magFilter!==pb[t.data.magfilter]&&(i.magFilter=pb[t.data.magfilter]),t.data.hasOwnProperty("addressu")&&i.addressU!==fb[t.data.addressu]&&(i.addressU=fb[t.data.addressu]),t.data.hasOwnProperty("addressv")&&i.addressV!==fb[t.data.addressv]&&(i.addressV=fb[t.data.addressv]),t.data.hasOwnProperty("mipmaps")&&i.mipmaps!==t.data.mipmaps&&(i.mipmaps=t.data.mipmaps),t.data.hasOwnProperty("anisotropy")&&i.anisotropy!==t.data.anisotropy&&(i.anisotropy=t.data.anisotropy),t.data.hasOwnProperty("rgbm"))){var n=t.data.rgbm?ai:ri;i.type!==n&&(i.type=n)}t.resource.texture=i;var s={};for(var r in t.data.frames){var a=t.data.frames[r];s[r]={rect:new Dt(a.rect),pivot:new It(a.pivot),border:new Dt(a.border)}}t.resource.frames=s,t.off("change",this._onAssetChange,this),t.on("change",this._onAssetChange,this)}},e._onAssetChange=function(t,e,i){var n;if("data"===e||"data.frames"===e){var s={};for(var r in i.frames)n=i.frames[r],s[r]={rect:new Dt(n.rect),pivot:new It(n.pivot),border:new Dt(n.border)};t.resource.frames=s}else{var a=e.match(mb);if(a){var o=a[1];i?(t.resource.frames[o]?((n=t.resource.frames[o]).rect.set(i.rect[0],i.rect[1],i.rect[2],i.rect[3]),n.pivot.set(i.pivot[0],i.pivot[1]),n.border.set(i.border[0],i.border[1],i.border[2],i.border[3])):t.resource.frames[o]={rect:new Dt(i.rect),pivot:new It(i.pivot),border:new Dt(i.border)},t.resource.fire("set:frame",o,t.resource.frames[o])):t.resource.frames[o]&&(delete t.resource.frames[o],t.resource.fire("remove:frame",o))}}},t}();function gb(){var t,e,i,n=0,s=1,r=2,a=3,o=8,h=9,l=10,c=11,u=12,d=13,f=14,p=16,m={astc:l,dxt:r,etc1:n,etc2:n,pvr:o,atc:c,none:f},_={astc:l,dxt:a,etc1:p,etc2:s,pvr:h,atc:u,none:p},g=21,v=22,y=23,x=8,S=10,b=26,w=27,T=28,A=29,C=30,E=7,M=3,P=5,R=function(t,e){switch(t){case n:return e.formats.etc1?g:v;case s:return y;case r:return x;case a:return S;case o:return b;case h:return w;case l:return T;case c:return A;case u:return C;case d:return E;case f:return M;case p:return P}},I=function(t){for(var e=function(t,e){var i=t*(2/255)-1,n=e*(2/255)-1,s=Math.sqrt(1-Math.min(1,i*i+n*n));return Math.max(0,Math.min(255,Math.floor(.5*(s+1)*255)))},i=0;i>3}return e},D=function(){return"undefined"!=typeof performance?performance.now():0},O=function(t,n,s){if(s){if(t.formats.astc)return"astc"}else if(n){if(t.formats.etc2)return"etc2"}else if(t.formats.etc1||t.formats.etc2)return"etc1";return function(e){for(var i=0;i0,maxRetries:t.maxRetries};if(t.glueUrl&&t.wasmUrl&&function(){try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){var t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1}()){var r=null,a=null;Ca.get(t.glueUrl,s,(function(t,i){t?e(t):a?n(i,a):r=i}));var o=fetch(t.wasmUrl),h=function(){o.then((function(t){return t.arrayBuffer()})).then((function(t){return WebAssembly.compile(t)})).then((function(t){r?n(r,t):a=t})).catch((function(t){e(t,null)}))};WebAssembly.compileStreaming?WebAssembly.compileStreaming(o).then((function(t){r?n(r,t):a=t})).catch((function(t){h()})):h()}else Ca.get(t.fallbackUrl,s,(function(t,i){t?e(t,null):n(i,null)}))},xb=function(){function t(){this.callbacks={},this.queue=[],this.clients=[]}var e=t.prototype;return e.enqueueJob=function(t,e,i,n){if(this.callbacks.hasOwnProperty(t))this.callbacks[t].push(i);else{this.callbacks[t]=[i];var s={url:t,data:e,options:n};this.clients.length>0?this.clients.shift().run(s):this.queue.push(s)}},e.enqueueClient=function(t){this.queue.length>0?t.run(this.queue.shift()):this.clients.push(t)},e.handleResponse=function(t,e,i){var n=this.callbacks[t];if(e)for(var s=0;s0&&++a<=o){var i=100*Math.pow(2,a);console.log("Error loading Texture from: '"+e+"' - Retrying in "+i+"ms...");var h=t.indexOf("?")>=0?"&":"?";r=setTimeout((function(){s.src=t+h+"retry="+Date.now(),r=null}),i)}else n("Error loading Texture from: '"+e+"'")},s.src=t},e._loadImageBitmap=function(t,e,i,n){var s=this,r={cache:!0,responseType:"blob",retry:this.maxRetries>0,maxRetries:this.maxRetries};Ca.get(t,r,(function(t,e){t?n(t):s._loadImageBitmapFromBlob(e,n)}))},e._loadImageBitmapFromBlob=function(t,e){createImageBitmap(t,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then((function(t){return e(null,t)})).catch((function(t){return e(t)}))},t}(),Ob=[1481919403,3140563232,169478669],kb={33776:8,33778:9,33779:le,36196:ve,37492:22,37496:23,35840:Se,35841:ye,35842:be,35843:xe,32849:6,32856:7,35905:19,35907:20,35898:ge,34843:ce,34842:ue};for(var Fb=function(){function t(t){this.maxRetries=0}var e=t.prototype;return e.load=function(t,e,i){$f.fetchArrayBuffer(t.load,e,i,this.maxRetries)},e.open=function(t,e,i,n){void 0===n&&(n={});var s=this.parse(e);if(!s)return null;var r=new Us(i,x({name:t,addressU:s.cubemap?1:0,addressV:s.cubemap?1:0,width:s.width,height:s.height,format:s.format,cubemap:s.cubemap,levels:s.levels},n));return r.upload(),r},e.parse=function(t){var e=new Uint32Array(t);if(Ob[0]!==e[0]||Ob[1]!==e[1]||Ob[2]!==e[2])return null;var i={endianness:e[3],glType:e[4],glTypeSize:e[5],glFormat:e[6],glInternalFormat:e[7],glBaseInternalFormat:e[8],pixelWidth:e[9],pixelHeight:e[10],pixelDepth:e[11],numberOfArrayElements:e[12],numberOfFaces:e[13],numberOfMipmapLevels:e[14],bytesOfKeyValueData:e[15]};if(i.pixelDepth>1)return null;if(0!==i.numberOfArrayElements)return null;var n=kb[i.glInternalFormat];if(void 0===n)return null;for(var s,r,a,o=16+i.bytesOfKeyValueData/4,h=i.numberOfFaces>1,l=[],c=0;c<(i.numberOfMipmapLevels||1);c++){var u=e[o++];h&&l.push([]);for(var d=h?l[c]:l,f=0;f<(h?6:1);++f)d.push((s=t,r=4*o,a=u,n===ge?new Uint32Array(s,r,a/4):new Uint8Array(s,r,a))),o+=u+3>>2}return{format:n,width:i.pixelWidth,height:i.pixelHeight,levels:l,cubemap:h}},t}(),Bb=166,Ub=function(){function t(t,e){this.maxRetries=0,this.device=e}var e=t.prototype;return e.load=function(t,e,i){var n=this;$f.fetchArrayBuffer(t.load,(function(s,r){s?e(s,r):n.parse(r,t,e,i)}),i,this.maxRetries)},e.open=function(t,e,i,n){void 0===n&&(n={});var s=new Us(i,x({name:t,addressU:e.cubemap?1:0,addressV:e.cubemap?1:0,width:e.width,height:e.height,format:e.format,cubemap:e.cubemap,levels:e.levels},n));return s.upload(),s},e.parse=function(t,e,i,n){var s=new lt(t),r=[s.readU32be(),s.readU32be(),s.readU32be()];if(2873840728!==r[0]||540160187!==r[1]||218765834!==r[2])return null;for(var a={vkFormat:s.readU32(),typeSize:s.readU32(),pixelWidth:s.readU32(),pixelHeight:s.readU32(),pixelDepth:s.readU32(),layerCount:s.readU32(),faceCount:s.readU32(),levelCount:s.readU32(),supercompressionScheme:s.readU32()},o={dfdByteOffset:s.readU32(),dfdByteLength:s.readU32(),kvdByteOffset:s.readU32(),kvdByteLength:s.readU32(),sgdByteOffset:s.readU64(),sgdByteLength:s.readU64()},h=[],l=0;l1},n));for(var w,T=128,A=d?6:1,C=c===f?8:16,E=0;E32767)return this._readPixelsFlat(t,e,i);var s=[0,0,0,0];if(t.readArray(s),2!==s[0]||2!==s[1]||0!=(128&s[2]))return t.skip(-4),this._readPixelsFlat(t,e,i);var r,a,o,h,l,c,u=new ArrayBuffer(e*i*4),d=new Uint8Array(u),f=n?0:4*e*(i-1);for(a=0;a128){if(r+(l-=128)>e)return null;for(c=t.readU8(),o=0;oe)return null;for(o=0;o=0?t.split("?")[0]:t},e._getParser=function(t){var e=L.getExtension(this._getUrlWithoutParams(t)).toLowerCase().replace(".","");return this.parsers[e]||this.imgParser},e._getTextureOptions=function(t){var e={};if(t){var i;(null==(i=t.name)?void 0:i.length)>0&&(e.name=t.name);var n=t.data;n.hasOwnProperty("minfilter")&&(e.minFilter=Gb[n.minfilter]),n.hasOwnProperty("magfilter")&&(e.magFilter=Gb[n.magfilter]),n.hasOwnProperty("addressu")&&(e.addressU=Vb[n.addressu]),n.hasOwnProperty("addressv")&&(e.addressV=Vb[n.addressv]),n.hasOwnProperty("mipmaps")&&(e.mipmaps=n.mipmaps),n.hasOwnProperty("anisotropy")&&(e.anisotropy=n.anisotropy),n.hasOwnProperty("flipY")&&(e.flipY=!!n.flipY),n.hasOwnProperty("type")?e.type=Hb[n.type]:n.hasOwnProperty("rgbm")&&n.rgbm?e.type=ai:t.file&&0!=(8&t.file.opt)&&(e.type=li)}return e},e.load=function(t,e,i){"string"==typeof t&&(t={load:t,original:t}),this._getParser(t.original).load(t,e,i)},e.open=function(t,e,i){if(t){var n=this._getTextureOptions(i),s=this._getParser(t).open(t,e,this._device,n);return null===s?s=new Us(this._device,{width:4,height:4,format:6}):(!function(t){var e=es.calcMipLevelsCount(t._width,t._height);if(!(7!==t._format&&t._format!==fe||t._volume||t._compressed||1===t._levels.length||t._levels.length===e||(i=t._cubemap?t._levels[0][0]:t._levels[0],i instanceof HTMLCanvasElement||i instanceof HTMLImageElement||i instanceof HTMLVideoElement))){for(var i,n=function(t,e,i){for(var n=Math.max(1,t>>1),s=Math.max(1,e>>1),r=new i.constructor(n*s*4),a=Math.floor(t/n),o=Math.floor(e/s),h=a*o,l=0;l>s-1),a=Math.max(1,t._height>>s-1);if(t._cubemap){for(var o=[],h=0;h<6;++h)o.push(n(r,a,t._levels[s-1][h]));t._levels.push(o)}else t._levels.push(n(r,a,t._levels[s-1]))}t._levelsUpdated=t._cubemap?[[!0,!0,!0,!0,!0,!0]]:[!0]}}(s),e.unswizzledGGGR&&(i.file.variants.basis.opt&=-9)),s}},e.patch=function(t,e){var i=t.resource;if(i)for(var n=this._getTextureOptions(t),s=0,r=Object.keys(n);s=a||(a=d,o=t[c],h.copy(u.transform.position),l.copy(u.transform.orientation))}this.fire("result",h,l,e,o),this.manager.hitTest.fire("result",this,h,l,e,o),iw.push(r),iw.push(h),nw.push(l)}},e}(P),rw=function(t){function e(e){var i;return(i=t.call(this)||this).manager=void 0,i._supported=G.browser&&!(!window.XRSession||!window.XRSession.prototype.requestHitTestSource),i._session=null,i.sources=[],i.manager=e,i._supported&&(i.manager.on("start",i._onSessionStart,w(i)),i.manager.on("end",i._onSessionEnd,w(i))),i}S(e,t);var i=e.prototype;return i._onSessionStart=function(){this.manager.type===Yb&&(this._session=this.manager.session)},i._onSessionEnd=function(){if(this._session){this._session=null;for(var t=0;tthis.views.length;){var a=this.viewsPool.pop();a||(a={viewport:new Dt,projMat:new zt,viewMat:new zt,viewOffMat:new zt,viewInvMat:new zt,viewInvOffMat:new zt,projViewOffMat:new zt,viewMat3:new Pt,position:new Float32Array(3),rotation:new Vt}),this.views.push(a)}for(;r0){var p=new zt,m=this.views[0];p.copy(m.projMat);var _=p.data,g=2*Math.atan(1/_[5])*180/Math.PI,v=_[5]/_[0],y=_[14]/(_[10]+1),x=_[14]/(_[10]-1);this._camera.camera.setXrProperties({aspectRatio:v,farClip:y,fov:g,horizontalFov:!1,nearClip:x})}return this._camera.camera._node.setLocalPosition(this._localPosition),this._camera.camera._node.setLocalRotation(this._localRotation),this.input.update(t),this._type===Yb&&(this.hitTest.supported&&this.hitTest.update(t),this.lightEstimation.supported&&this.lightEstimation.update(t),this.depthSensing.supported&&this.depthSensing.update(t,n&&n.views[0]),this.imageTracking.supported&&this.imageTracking.update(t),this.anchors.supported&&this.anchors.update(t),this.planeDetection.supported&&this.planeDetection.update(t)),this.fire("update",t),!0},y(e,[{key:"supported",get:function(){return this._supported}},{key:"active",get:function(){return!!this._session}},{key:"type",get:function(){return this._type}},{key:"spaceType",get:function(){return this._spaceType}},{key:"session",get:function(){return this._session}},{key:"camera",get:function(){return this._camera?this._camera.entity:null}},{key:"visibilityState",get:function(){return this._session?this._session.visibilityState:null}}]),e}(P),kw=function(t){function e(e,i){var n;void 0===i&&(i={}),n=t.call(this,e)||this;var s=new bp;return s.graphicsDevice=n.createDevice(e,i),n.addComponentSystems(s),n.addResourceHandles(s),s.elementInput=i.elementInput,s.keyboard=i.keyboard,s.mouse=i.mouse,s.touch=i.touch,s.gamepads=i.gamepads,s.scriptPrefix=i.scriptPrefix,s.assetPrefix=i.assetPrefix,s.scriptsOrder=i.scriptsOrder,s.soundManager=new Oa,s.lightmapper=Lp,s.batchManager=kh,s.xr=Ow,n.init(s),n}S(e,t);var i=e.prototype;return i.createDevice=function(t,e){return e.graphicsDeviceOptions||(e.graphicsDeviceOptions={}),G.browser&&navigator.xr&&(e.graphicsDeviceOptions.xrCompatible=!0),e.graphicsDeviceOptions.alpha=e.graphicsDeviceOptions.alpha||!1,new mr(t,e.graphicsDeviceOptions)},i.addComponentSystems=function(t){t.componentSystems=[Gv,H_,Bg,Sm,Gm,ov,Tv,Zy,ix,Df.legacy?ry:dx,Zm,Py,qm,_v,Kv,Mg,m_,yy,wy,zy,nv,Vg,Wy]},i.addResourceHandles=function(t){t.resourceHandlers=[gx,bS,wS,TS,nb,KS,Xb,db,XS,ES,rb,sb,OS,WS,DS,ab,HS,kS,US,MS,_b,lb,ub,LS]},e}(yp),Fw=function(t){function e(e,i){var n;return(n=t.call(this)||this)._assets=new Set,n._loadingAssets=new Set,n._waitingAssets=new Set,n._registry=i,n._loading=!1,n._loaded=!1,n._failed=[],e.forEach((function(t){if(t instanceof $f)t.registry||(t.registry=i),n._assets.add(t);else{var e=i.get(t);e?n._assets.add(e):n._waitForAsset(t)}})),n}S(e,t);var i=e.prototype;return i.destroy=function(){var t=this;this._registry.off("load",this._onLoad),this._registry.off("error",this._onError),this._waitingAssets.forEach((function(e){t._registry.off("add:"+e,this._onAddAsset)})),this.off("progress"),this.off("load")},i._assetHasDependencies=function(t){var e;return"model"===t.type&&(null==(e=t.file)?void 0:e.url)&&t.file.url&&t.file.url.match(/.json$/g)},i.load=function(t,e){var i=this;if(!this._loading){this._loading=!0,this._callback=t,this._scope=e,this._registry.on("load",this._onLoad,this),this._registry.on("error",this._onError,this);var n=!1;this._assets.forEach((function(t){t.loaded||(n=!0,i._assetHasDependencies(t)&&i._registry.loadFromUrl(t.file.url,t.type,(function(e,n){e?i._onError(e,t):i._onLoad(t)})),i._loadingAssets.add(t),i._registry.add(t))})),this._loadingAssets.forEach((function(t){i._assetHasDependencies(t)||i._registry.load(t)})),n||0!==this._waitingAssets.size||this._loadingComplete()}},i.ready=function(t,e){void 0===e&&(e=this),this._loaded?t.call(e,Array.from(this._assets)):this.once("load",(function(i){t.call(e,i)}))},i._loadingComplete=function(){this._loaded||(this._loaded=!0,this._registry.off("load",this._onLoad,this),this._registry.off("error",this._onError,this),this._failed.length?(this._callback&&this._callback.call(this._scope,"Failed to load some assets",this._failed),this.fire("error",this._failed)):(this._callback&&this._callback.call(this._scope),this.fire("load",Array.from(this._assets))))},i._onLoad=function(t){var e=this;this._loadingAssets.has(t)&&(this.fire("progress",t),this._loadingAssets.delete(t)),0===this._loadingAssets.size&&setTimeout((function(){e._loadingComplete(e._failed)}),0)},i._onError=function(t,e){var i=this;this._loadingAssets.has(e)&&(this._failed.push(e),this._loadingAssets.delete(e)),0===this._loadingAssets.size&&setTimeout((function(){i._loadingComplete(i._failed)}),0)},i._onAddAsset=function(t){this._waitingAssets.delete(t),this._assets.add(t),t.loaded||(this._loadingAssets.add(t),this._registry.load(t))},i._waitForAsset=function(t){this._waitingAssets.add(t),this._registry.once("add:"+t,this._onAddAsset,this)},e}(P),Bw=function(){function t(t,e,i,n){this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=i,this.texture=new Us(t,{name:n,format:7,width:e,height:i,mipmaps:!0,minFilter:5,magFilter:1,addressU:1,addressV:1,levels:[this.canvas]}),this.ctx=this.canvas.getContext("2d",{alpha:!0})}var e=t.prototype;return e.destroy=function(){this.texture.destroy()},e.clear=function(t){var e=this.canvas,i=e.width,n=e.height;this.ctx.clearRect(0,0,i,n),this.ctx.fillStyle=t,this.ctx.fillRect(0,0,i,n)},t}(),Uw=function(t){function e(e,i){var n;return void 0===i&&(i={}),(n=t.call(this)||this).type="bitmap",n.app=e,n.intensity=0,n.fontWeight=i.fontWeight||"normal",n.fontSize=parseInt(i.fontSize,10),n.glyphSize=n.fontSize,n.fontName=i.fontName||"Arial",n.color=i.color||new gt(1,1,1),n.padding=i.padding||0,n.width=Math.min(4096,i.width||512),n.height=Math.min(4096,i.height||512),n.atlases=[],n.chars="",n.data={},n}S(e,t);var i=e.prototype;return i.createTextures=function(t){var e=this._normalizeCharsSet(t);if(e.length===this.chars.length){for(var i=0;i0&&this._renderAtlas(this.chars.concat(i))},i.destroy=function(){this.atlases.forEach((function(t){return t.destroy()})),this.chars=null,this.color=null,this.data=null,this.fontName=null,this.fontSize=null,this.glyphSize=null,this.intensity=null,this.atlases=null,this.type=null,this.fontWeight=null},i._colorToRgbString=function(t,e){var i=Math.round(255*t.r),n=Math.round(255*t.g),s=Math.round(255*t.b);return e?"rgba("+i+", "+n+", "+s+", "+t.a+")":"rgb("+i+", "+n+", "+s+")"},i.renderCharacter=function(t,e,i,n,s){t.fillStyle=s,t.fillText(e,i,n)},i._getAtlas=function(t){return t>=this.atlases.length&&(this.atlases[t]=new Bw(this.app.graphicsDevice,this.width,this.height,"font-atlas-"+this.fontName+"-"+t)),this.atlases[t]},i._renderAtlas=function(t){this.chars=t;var e=this.width,i=this.height,n=this._colorToRgbString(this.color,!1),s=this.color.a;this.color.a=1/255;var r=this._colorToRgbString(this.color,!0);this.color.a=s;var a=0,o=this._getAtlas(a++);o.clear(r),this.data=this._createJson(this.chars,this.fontName,e,i);for(var h=rt.getSymbols(this.chars.join("")),l=0,c=0,u={},d=0;dw&&(w=this.fontSize*this.fontSize/T,o.ctx.font=this.fontWeight+" "+w.toString()+"px "+this.fontName,T=this.fontSize),this.renderCharacter(o.ctx,S,v+_,y+g,n);var A=this.padding+(this.glyphSize-T)/2,C=-this.padding+u[S].descent-c,E=T;this._addChar(this.data,S,b,v,y,p,m,A,C,E,a-1,e,i),(v+=p)+p>e&&(v=0,(y+=m)+m>i&&((o=this._getAtlas(a++)).clear(r),y=0))}this.atlases.splice(a).forEach((function(t){return t.destroy()})),this.atlases.forEach((function(t){return t.texture.upload()})),this.fire("render")},i._createJson=function(t,e,i,n){return{version:3,intensity:this.intensity,info:{face:e,width:i,height:n,maps:[{width:i,height:n}]},chars:{}}},i._addChar=function(t,e,i,n,s,r,a,o,h,l,c,u,d){t.info.maps.length0&&(e.setCameraUniforms(i.camera,a),e.renderForward(i.camera,Nw,zw,3,(function(e){var i=e.id;u[0]=(i>>16&255)/255,u[1]=(i>>8&255)/255,u[2]=(255&i)/255,u[3]=(i>>24&255)/255,c.setValue(u),t.setBlendState(Gi.NOBLEND)})),Nw.length=0)}}},e}(Er),Gw=new Set,Hw=function(){function t(t,e,i){this.renderTarget=null,this.mapping=new Map,t instanceof on&&(t=Mf()),this.renderer=t.renderer,this.device=t.graphicsDevice,this.renderPass=new Vw(this.device,t.renderer),this.width=0,this.height=0,this.resize(e,i)}var e=t.prototype;return e.getSelection=function(t,e,i,n){var s=this.device;if("object"==typeof t){var r=t;t=r.x,e=r.y,i=r.width,n=r.height}else e=this.renderTarget.height-(e+(n||1));t=Math.floor(t),e=Math.floor(e),i=Math.floor(Math.max(i||1,1)),n=Math.floor(Math.max(n||1,1)),s.setRenderTarget(this.renderTarget),s.updateBegin();var a=new Uint8Array(4*i*n);s.readPixels(t,e,i,n,a),s.updateEnd();for(var o=this.mapping,h=0;h0?h.wheelDelta=1:e.deltaY<0&&(h.wheelDelta=-1)),h}return S(e,t),e}(yT),ST=function(t){function e(e,i,n,s,r,a){var o;return(o=t.call(this,e,i,n)||this).touches=e.touches,o.changedTouches=e.changedTouches,o.x=s,o.y=r,o.touch=a,o}return S(e,t),e}(yT),bT=function(t){function e(e,i,n,s){var r;return(r=t.call(this,e,i,n)||this).inputSource=s,r}return S(e,t),e}(yT),wT=function(){function t(t,e){this._app=null,this._attached=!1,this._target=null,this._enabled=!0,this._lastX=0,this._lastY=0,this._upHandler=this._handleUp.bind(this),this._downHandler=this._handleDown.bind(this),this._moveHandler=this._handleMove.bind(this),this._wheelHandler=this._handleWheel.bind(this),this._touchstartHandler=this._handleTouchStart.bind(this),this._touchendHandler=this._handleTouchEnd.bind(this),this._touchcancelHandler=this._touchendHandler,this._touchmoveHandler=this._handleTouchMove.bind(this),this._sortHandler=this._sortElements.bind(this),this._elements=[],this._hoveredElement=null,this._pressedElement=null,this._touchedElements={},this._touchesForWhichTouchLeaveHasFired={},this._selectedElements={},this._selectedPressedElements={},this._useMouse=!e||!1!==e.useMouse,this._useTouch=!e||!1!==e.useTouch,this._useXr=!e||!1!==e.useXr,this._selectEventsAttached=!1,G.touch&&(this._clickedEntities={}),this.attach(t)}var e=t.prototype;return e.attach=function(t){this._attached&&(this._attached=!1,this.detach()),this._target=t,this._attached=!0;var e=!!G.passiveEvents&&{passive:!0};this._useMouse&&(window.addEventListener("mouseup",this._upHandler,e),window.addEventListener("mousedown",this._downHandler,e),window.addEventListener("mousemove",this._moveHandler,e),window.addEventListener("wheel",this._wheelHandler,e)),this._useTouch&&G.touch&&(this._target.addEventListener("touchstart",this._touchstartHandler,e),this._target.addEventListener("touchend",this._touchendHandler,!1),this._target.addEventListener("touchmove",this._touchmoveHandler,!1),this._target.addEventListener("touchcancel",this._touchcancelHandler,!1)),this.attachSelectEvents()},e.attachSelectEvents=function(){!this._selectEventsAttached&&this._useXr&&this.app&&this.app.xr&&this.app.xr.supported&&(this._clickedEntities||(this._clickedEntities={}),this._selectEventsAttached=!0,this.app.xr.on("start",this._onXrStart,this))},e.detach=function(){if(this._attached){this._attached=!1;var t=!!G.passiveEvents&&{passive:!0};this._useMouse&&(window.removeEventListener("mouseup",this._upHandler,t),window.removeEventListener("mousedown",this._downHandler,t),window.removeEventListener("mousemove",this._moveHandler,t),window.removeEventListener("wheel",this._wheelHandler,t)),this._useTouch&&(this._target.removeEventListener("touchstart",this._touchstartHandler,t),this._target.removeEventListener("touchend",this._touchendHandler,!1),this._target.removeEventListener("touchmove",this._touchmoveHandler,!1),this._target.removeEventListener("touchcancel",this._touchcancelHandler,!1)),this._selectEventsAttached&&(this._selectEventsAttached=!1,this.app.xr.off("start",this._onXrStart,this),this.app.xr.off("end",this._onXrEnd,this),this.app.xr.off("update",this._onXrUpdate,this),this.app.xr.input.off("selectstart",this._onSelectStart,this),this.app.xr.input.off("selectend",this._onSelectEnd,this),this.app.xr.input.off("remove",this._onXrInputRemove,this)),this._target=null}},e.addElement=function(t){-1===this._elements.indexOf(t)&&this._elements.push(t)},e.removeElement=function(t){var e=this._elements.indexOf(t);-1!==e&&this._elements.splice(e,1)},e._handleUp=function(t){this._enabled&&(aa.isPointerLocked()||(this._calcMouseCoords(t),this._onElementMouseEvent("mouseup",t)))},e._handleDown=function(t){this._enabled&&(aa.isPointerLocked()||(this._calcMouseCoords(t),this._onElementMouseEvent("mousedown",t)))},e._handleMove=function(t){this._enabled&&(this._calcMouseCoords(t),this._onElementMouseEvent("mousemove",t),this._lastX=gw,this._lastY=vw)},e._handleWheel=function(t){this._enabled&&(this._calcMouseCoords(t),this._onElementMouseEvent("mousewheel",t))},e._determineTouchedElements=function(t){for(var e={},i=this.app.systems.camera.cameras,n=i.length-1;n>=0;n--){for(var s=i[n],r=0,a=t.changedTouches.length,o=0;o=0;d--){this._getTargetElementByCoords(e[d],u.x,u.y)===o&&(this._clickedEntities[o.entity.getGuid()]||(this._fireEvent("click",new ST(t,o,h,l,c,r)),this._clickedEntities[o.entity.getGuid()]=Date.now()))}this._fireEvent(t.type,new ST(t,o,h,l,c,r))}}}},e._handleTouchMove=function(t){if(t.preventDefault(),this._enabled)for(var e=this._determineTouchedElements(t),i=0,n=t.changedTouches.length;i=0&&(s=r[a],!(i=this._getTargetElementByCoords(s,gw,vw)));a--);if(this._hoveredElement=i,"mousemove"!==t&&"mouseup"!==t||!this._pressedElement?i&&(this._fireEvent(t,new xT(e,i,s,gw,vw,this._lastX,this._lastY)),"mousedown"===t&&(this._pressedElement=i)):this._fireEvent(t,new xT(e,this._pressedElement,s,gw,vw,this._lastX,this._lastY)),n!==this._hoveredElement&&(n&&this._fireEvent("mouseleave",new xT(e,n,s,gw,vw,this._lastX,this._lastY)),this._hoveredElement&&this._fireEvent("mouseenter",new xT(e,this._hoveredElement,s,gw,vw,this._lastX,this._lastY))),"mouseup"===t&&this._pressedElement){if(this._pressedElement===this._hoveredElement){var o=this._hoveredElement.entity.getGuid(),h=!this._clickedEntities;if(this._clickedEntities){var l=this._clickedEntities[o]||0;h=Date.now()-l>300,delete this._clickedEntities[o]}h&&this._fireEvent("click",new xT(e,this._hoveredElement,s,gw,vw,this._lastX,this._lastY))}this._pressedElement=null}},e._onXrStart=function(){this.app.xr.on("end",this._onXrEnd,this),this.app.xr.on("update",this._onXrUpdate,this),this.app.xr.input.on("selectstart",this._onSelectStart,this),this.app.xr.input.on("selectend",this._onSelectEnd,this),this.app.xr.input.on("remove",this._onXrInputRemove,this)},e._onXrEnd=function(){this.app.xr.off("update",this._onXrUpdate,this),this.app.xr.input.off("selectstart",this._onSelectStart,this),this.app.xr.input.off("selectend",this._onSelectEnd,this),this.app.xr.input.off("remove",this._onXrInputRemove,this)},e._onXrUpdate=function(){if(this._enabled)for(var t=this.app.xr.input.inputSources,e=0;e=0&&(r=o[h],!(n=this._getTargetElementByRay(Zw,r)));h--);}e._elementEntity=n||null,n?(this._selectedElements[e.id]=n,s=n):delete this._selectedElements[e.id],a!==s&&(a&&this._fireEvent("selectleave",new bT(i,a,r,e)),s&&this._fireEvent("selectenter",new bT(i,s,r,e)));var l=this._selectedPressedElements[e.id];"selectmove"===t&&l&&this._fireEvent("selectmove",new bT(i,l,r,e)),"selectstart"===t&&(this._selectedPressedElements[e.id]=s,s&&this._fireEvent("selectstart",new bT(i,s,r,e))),!e.elementInput&&l&&(delete this._selectedPressedElements[e.id],a&&this._fireEvent("selectend",new bT(i,l,r,e))),"selectend"===t&&e.elementInput&&(delete this._selectedPressedElements[e.id],l&&this._fireEvent("selectend",new bT(i,l,r,e)),l&&l===a&&this._fireEvent("click",new bT(i,l,r,e)))},e._fireEvent=function(t,e){for(var i=e.element;i.fire(t,e),!e._stopPropagation&&i.entity.parent&&(i=i.entity.parent.element););},e._calcMouseCoords=function(t){var e=this._target.getBoundingClientRect(),i=Math.floor(e.left),n=Math.floor(e.top);gw=t.clientX-i,vw=t.clientY-n},e._calcTouchCoords=function(t){for(var e=0,i=0,n=t.target;!(n instanceof HTMLElement);)n=n.parentNode;var s=n;do{e+=s.offsetLeft-s.scrollLeft,i+=s.offsetTop-s.scrollTop,s=s.offsetParent}while(s);return{x:t.pageX-e,y:t.pageY-i}},e._sortElements=function(t,e){var i=this.app.scene.layers.sortTransparentLayers(t.layers,e.layers);return 0!==i?i:t.screen&&!e.screen?-1:!t.screen&&e.screen?1:t.screen||e.screen?t.screen.screen.screenSpace&&!e.screen.screen.screenSpace?-1:e.screen.screen.screenSpace&&!t.screen.screen.screenSpace?1:e.drawOrder-t.drawOrder:0},e._getTargetElementByCoords=function(t,e,i){var n=this._calculateRayScreen(e,i,t,Yw)?Yw:null,s=this._calculateRay3d(e,i,t,Kw)?Kw:null;return this._getTargetElement(t,n,s)},e._getTargetElementByRay=function(t,e){Yw.origin.copy(t.origin),Yw.direction.copy(t.direction),Yw.end.copy(Yw.direction).mulScalar(2*e.farClip).add(Yw.origin);var i=Yw,n=e.worldToScreen(i.origin,qw),s=this._calculateRayScreen(n.x,n.y,e,Kw)?Kw:null;return this._getTargetElement(e,s,i)},e._getTargetElement=function(t,e,i){var n=null,s=1/0;this._elements.sort(this._sortHandler);for(var r=0,a=this._elements.length;r=0){n=o;break}}else{if(!i)continue;var h=this._checkElement(i,o,!1);if(h>=0&&(h=h&&d<=l&&f<=c&&f>=u&&(d=s*(d-h)/a,f=r-(f=r*(f-u)/o),n.origin.set(d,f,1),n.direction.set(0,0,-1),n.end.copy(n.direction).mulScalar(2).add(n.origin),!0)},e._calculateRay3d=function(t,e,i,n){var s=this._target.clientWidth,r=this._target.clientHeight,a=i.rect.z*s,o=i.rect.w*r,h=i.rect.x*s,l=h+a,c=(1-i.rect.y)*r,u=c-o,d=t,f=e;return t>=h&&t<=l&&e<=c&&f>=u&&(d=s*(d-h)/a,f=r*(f-u)/o,i.screenToWorld(d,f,i.nearClip,qw),i.screenToWorld(d,f,i.farClip,jw),n.origin.copy(qw),n.direction.set(0,0,-1),n.end.copy(jw),!0)},e._checkElement=function(e,i,n){if(i.maskedBy&&this._checkElement(e,i.maskedBy.element,n)<0)return-1;var s;s=n?t.calculateScaleToScreen(i):t.calculateScaleToWorld(i);var r=t.buildHitCorners(i,n?i.screenCorners:i.worldCorners,s);return function(t,e,i){Qw.sub2(e,t),$w.sub2(i[0],t),Jw.sub2(i[1],t),tT.sub2(i[2],t),iT.cross(tT,Qw);var n,s,r=$w.dot(iT);if(r>=0){if((n=-Jw.dot(iT))<0)return-1;if((s=vT(Qw,Jw,$w))<0)return-1;var a=1/(n+r+s);nT.copy(i[0]).mulScalar(n*a),sT.copy(i[1]).mulScalar(r*a),rT.copy(i[2]).mulScalar(s*a),aT.copy(nT).add(sT).add(rT)}else{if(eT.sub2(i[3],t),(n=eT.dot(iT))<0)return-1;if((s=vT(Qw,$w,eT))<0)return-1;var o=1/(n+(r=-r)+s);nT.copy(i[0]).mulScalar(n*o),sT.copy(i[3]).mulScalar(r*o),rT.copy(i[2]).mulScalar(s*o),aT.copy(nT).add(sT).add(rT)}return Qw.sub2(i[0],i[2]).lengthSq()<1e-8||Qw.sub2(i[1],i[3]).lengthSq()<1e-8?-1:aT.sub(t).lengthSq()}(e.origin,e.end,r)},t.buildHitCorners=function(t,e,i){var n=e;if(t.entity&&t.entity.button){var s=t.entity.button.hitPadding||gT;lT.copy(t.entity.up),cT.copy(lT).mulScalar(-1),dT.copy(t.entity.right),uT.copy(dT).mulScalar(-1),lT.mulScalar(s.w*i.y),cT.mulScalar(s.y*i.y),dT.mulScalar(s.z*i.x),uT.mulScalar(s.x*i.x),fT.copy(n[0]).add(cT).add(uT),pT.copy(n[1]).add(cT).add(dT),mT.copy(n[2]).add(lT).add(dT),_T.copy(n[3]).add(lT).add(uT),n=[fT,pT,mT,_T]}if(i.x<0){var r=n[2].x,a=n[0].x;n[0].x=r,n[1].x=a,n[2].x=a,n[3].x=r}if(i.y<0){var o=n[2].y,h=n[0].y;n[0].y=o,n[1].y=o,n[2].y=h,n[3].y=h}if(i.z<0){var l=n[2].x,c=n[2].y,u=n[2].z;n[2].x=n[0].x,n[2].y=n[0].y,n[2].z=n[0].z,n[0].x=l,n[0].y=c,n[0].z=u}return n},t.calculateScaleToScreen=function(t){var e=t.entity,i=t.screen.screen.scale;for(hT.set(i,i,i);e&&!e.screen;)hT.mul(e.getLocalScale()),e=e.parent;return hT},t.calculateScaleToWorld=function(t){var e=t.entity;for(hT.set(1,1,1);e;)hT.mul(e.getLocalScale()),e=e.parent;return hT},y(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"app",get:function(){return this._app||Mf()},set:function(t){this._app=t}}]),t}(),TT=new RegExp("^\\s*function(?:\\s|\\s*\\/\\*.*\\*\\/\\s*)+([^\\(\\s\\/]*)\\s*"),AT=function(t){function e(e){var i;return(i=t.call(this)||this).app=void 0,i.entity=void 0,i._enabled=void 0,i._enabledOld=void 0,i._initialized=void 0,i._postInitialized=void 0,i.__destroyed=void 0,i.__attributes=void 0,i.__attributesRaw=void 0,i.__scriptType=void 0,i.__executionOrder=void 0,i.initScriptType(e),i}S(e,t);var i=e.prototype;return i.initScriptType=function(t){var e=this.constructor;this.app=t.app,this.entity=t.entity,this._enabled="boolean"!=typeof t.enabled||t.enabled,this._enabledOld=this.enabled,this.__destroyed=!1,this.__attributes={},this.__attributesRaw=t.attributes||{},this.__scriptType=e,this.__executionOrder=-1},e.__getScriptName=function(t){if("function"==typeof t){if("name"in Function.prototype)return t.name;if(t===Function||t===Function.prototype.constructor)return"Function";var e=(""+t).match(TT);return e?e[1]:void 0}},i.__initializeAttributes=function(t){if(t||this.__attributesRaw){for(var e in this.__scriptType.attributes.index)this.__attributesRaw&&this.__attributesRaw.hasOwnProperty(e)?this[e]=this.__attributesRaw[e]:this.__attributes.hasOwnProperty(e)||(this.__scriptType.attributes.index[e].hasOwnProperty("default")?this[e]=this.__scriptType.attributes.index[e].default:this[e]=null);this.__attributesRaw=null}},e.extend=function(t){for(var e in t)t.hasOwnProperty(e)&&(this.prototype[e]=t[e])},y(e,[{key:"enabled",get:function(){return this._enabled&&!this._destroyed&&this.entity.script.enabled&&this.entity.enabled},set:function(t){this._enabled=!!t,this.enabled!==this._enabledOld&&(this._enabledOld=this.enabled,this.fire(this.enabled?"enable":"disable"),this.fire("state",this.enabled),!this._initialized&&this.enabled&&(this._initialized=!0,this.__initializeAttributes(!0),this.initialize&&this.entity.script._scriptMethod(this,ox)),this._initialized&&!this._postInitialized&&this.enabled&&!this.entity.script._beingEnabled&&(this._postInitialized=!0,this.postInitialize&&this.entity.script._scriptMethod(this,hx)))}}],[{key:"scriptName",get:function(){return this.__name}},{key:"attributes",get:function(){return this.hasOwnProperty("__attributes")||(this.__attributes=new ax(this)),this.__attributes}}]),e}(P);AT.__name=null;var CT=new Set(["system","entity","create","destroy","swap","move","data","scripts","_scripts","_scriptsIndex","_scriptsData","enabled","_oldState","onEnable","onDisable","onPostStateChange","_onSetEnabled","_checkState","_onBeforeRemove","_onInitializeAttributes","_onInitialize","_onPostInitialize","_onUpdate","_onPostUpdate","_callbacks","_callbackActive","has","get","on","off","fire","once","hasEvent"]);function ET(t,e){if(Df.legacy)return null;if(CT.has(t))throw new Error("Script name '"+t+"' is reserved, please rename the script");var i=function(t){P.prototype.initEventHandler.call(this),AT.prototype.initScriptType.call(this,t)};return(i.prototype=Object.create(AT.prototype)).constructor=i,i.extend=AT.extend,i.attributes=new ax(i),PT(i,t,e),i}var MT={};function PT(t,e,i){if(!t.legacy){if("function"!=typeof t)throw new Error("script class: '"+t+"' must be a constructor function (i.e. class).");if(!(t.prototype instanceof AT))throw new Error("script class: '"+AT.__getScriptName(t)+"' does not extend pc.ScriptType.");if(e=e||t.__name||AT.__getScriptName(t),CT.has(e))throw new Error("script name: '"+e+"' is reserved, please change script name");t.__name=e,(i?i.scripts:yp.getApplication().scripts).add(t),Rf.push(t,t.legacy)}}ax.reservedNames.forEach((function(t,e,i){MT[t]=1})),ET.reservedAttributes=MT;var RT={write:function(t){console.log(t)},open:function(){RT.write("Powered by PlayCanvas "+c+" "+u)},info:function(t){console.info("INFO: "+t)},debug:function(t){console.debug("DEBUG: "+t)},error:function(t){console.error("ERROR: "+t)},warning:function(t){console.warn("WARNING: "+t)},alert:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t){RT.write("ALERT: "+t),alert(t)})),assert:function(t,e){!1===t&&RT.write("ASSERT: "+e)}};rt.endsWith=function(t,e){return t.endsWith(e)},rt.startsWith=function(t,e){return t.startsWith(e)};var IT=function(){function t(){this._isRunning=!1,this._a=0,this._b=0}var e=t.prototype;return e.start=function(){this._isRunning=!0,this._a=dt()},e.stop=function(){this._isRunning=!1,this._b=dt()},e.getMilliseconds=function(){return this._b-this._a},t}(),LT={now:dt,Timer:IT};Object.defineProperty(gt.prototype,"data",{get:function(){return this._data||(this._data=new Float32Array(4)),this._data[0]=this.r,this._data[1]=this.g,this._data[2]=this.b,this._data[3]=this.a,this._data}}),Object.defineProperty(gt.prototype,"data3",{get:function(){return this._data3||(this._data3=new Float32Array(3)),this._data3[0]=this.r,this._data3[1]=this.g,this._data3[2]=this.b,this._data3}}),_t.INV_LOG2=Math.LOG2E,_t.intToBytes=_t.intToBytes32,_t.bytesToInt=_t.bytesToInt32,Object.defineProperty(It.prototype,"data",{get:function(){return this._data||(this._data=new Float32Array(2)),this._data[0]=this.x,this._data[1]=this.y,this._data}}),It.prototype.scale=It.prototype.mulScalar,Object.defineProperty(Et.prototype,"data",{get:function(){return this._data||(this._data=new Float32Array(3)),this._data[0]=this.x,this._data[1]=this.y,this._data[2]=this.z,this._data}}),Et.prototype.scale=Et.prototype.mulScalar,Object.defineProperty(Dt.prototype,"data",{get:function(){return this._data||(this._data=new Float32Array(4)),this._data[0]=this.x,this._data[1]=this.y,this._data[2]=this.z,this._data[3]=this.w,this._data}}),Dt.prototype.scale=Dt.prototype.mulScalar;var DT={Aabb:jt,Sphere:Zt,Plane:se};Zt.prototype.intersectRay=Zt.prototype.intersectsRay,Qt.prototype.update=function(t,e){var i=new zt;i.mul2(t,e),this.setFromMat4(i)};var OT=yi;function kT(t){this.name="UnsupportedBrowserError",this.message=t||""}function FT(t){this.name="ContextCreationError",this.message=t||""}kT.prototype=Error.prototype,FT.prototype=Error.prototype;var BT={begin:Eo.begin,dummyFragmentCode:hr.dummyFragmentCode,end:Eo.end,fogCode:Eo.fogCode,gammaCode:Eo.gammaCode,precisionCode:hr.precisionCode,skinCode:Eo.skinCode,tonemapCode:Eo.tonemapCode,versionCode:hr.versionCode},UT={ADDRESS_CLAMP_TO_EDGE:1,ADDRESS_MIRRORED_REPEAT:2,ADDRESS_REPEAT:0,BLENDMODE_ZERO:0,BLENDMODE_ONE:1,BLENDMODE_SRC_COLOR:2,BLENDMODE_ONE_MINUS_SRC_COLOR:3,BLENDMODE_DST_COLOR:4,BLENDMODE_ONE_MINUS_DST_COLOR:5,BLENDMODE_SRC_ALPHA:6,BLENDMODE_SRC_ALPHA_SATURATE:7,BLENDMODE_ONE_MINUS_SRC_ALPHA:8,BLENDMODE_DST_ALPHA:9,BLENDMODE_ONE_MINUS_DST_ALPHA:10,BUFFER_STATIC:0,BUFFER_DYNAMIC:1,BUFFER_STREAM:2,CULLFACE_NONE:he,CULLFACE_BACK:1,CULLFACE_FRONT:2,CULLFACE_FRONTANDBACK:3,ELEMENTTYPE_INT8:0,ELEMENTTYPE_UINT8:yi,ELEMENTTYPE_INT16:2,ELEMENTTYPE_UINT16:3,ELEMENTTYPE_INT32:4,ELEMENTTYPE_UINT32:5,ELEMENTTYPE_FLOAT32:6,FILTER_NEAREST:0,FILTER_LINEAR:1,FILTER_NEAREST_MIPMAP_NEAREST:2,FILTER_NEAREST_MIPMAP_LINEAR:3,FILTER_LINEAR_MIPMAP_NEAREST:4,FILTER_LINEAR_MIPMAP_LINEAR:5,INDEXFORMAT_UINT8:0,INDEXFORMAT_UINT16:1,INDEXFORMAT_UINT32:2,PIXELFORMAT_RGB565:3,PIXELFORMAT_RGB8:6,PIXELFORMAT_RGBA8:7,PRIMITIVE_POINTS:0,PRIMITIVE_LINES:1,PRIMITIVE_LINELOOP:2,PRIMITIVE_LINESTRIP:3,PRIMITIVE_TRIANGLES:4,PRIMITIVE_TRISTRIP:Ce,PRIMITIVE_TRIFAN:6,SEMANTIC_POSITION:Ee,SEMANTIC_NORMAL:Me,SEMANTIC_COLOR:Le,SEMANTIC_TEXCOORD:De,SEMANTIC_TEXCOORD0:Oe,SEMANTIC_TEXCOORD1:ke,SEMANTIC_ATTR0:He,SEMANTIC_ATTR1:We,SEMANTIC_ATTR2:Xe,SEMANTIC_ATTR3:qe,TEXTURELOCK_READ:1,TEXTURELOCK_WRITE:2,drawQuadWithShader:Uo,programlib:BT,shaderChunks:wo,ContextCreationError:FT,Device:on,IndexBuffer:Tr,ProgramLibrary:bf,RenderTarget:ln,ScopeId:ji,Shader:vs,ShaderInput:Gs,Texture:Us,UnsupportedBrowserError:kT,VertexBuffer:Zi,VertexFormat:sn,VertexIterator:Gr},NT=new Dt;function zT(t,e,i,n,s){var r;if(s){var a=e?e.width:t.width,o=e?e.height:t.height;r=NT.set(s.x*a,s.y*o,s.z*a,s.w*o)}Uo(t,e,n,r)}var VT={createFullscreenQuad:function(t){return t.quadVertexBuffer},drawFullscreenQuad:zT,PostEffect:gf,PostEffectQueue:qy};Object.defineProperty(wo,"transformSkinnedVS",{get:function(){return"#define SKIN\n"+wo.transformVS}});Object.keys({"ambientPrefilteredCube.frag":"ambientEnv.frag","ambientPrefilteredCubeLod.frag":"ambientEnv.frag","dpAtlasQuad.frag":null,"genParaboloid.frag":null,"prefilterCubemap.frag":null,"reflectionDpAtlas.frag":"reflectionEnv.frag","reflectionPrefilteredCube.frag":"reflectionEnv.frag","reflectionPrefilteredCubeLod.frag":"reflectionEnv.frag"}).forEach((function(t){Object.defineProperty(wo,t,{get:function(){return null},set:function(){}})})),Object.defineProperties(ln.prototype,{_glFrameBuffer:{get:function(){return this.impl._glFrameBuffer},set:function(t){}}}),Object.defineProperty(sn,"defaultInstancingFormat",{get:function(){return sn.getDefaultInstancingFormat(Ja.get())}}),Object.defineProperties(Us.prototype,{rgbm:{get:function(){return this.type===ai},set:function(t){this.type=t?ai:ri}},swizzleGGGR:{get:function(){return this.type===li},set:function(t){this.type=t?li:ri}},_glTexture:{get:function(){return this.impl._glTexture}},autoMipmap:{get:function(){return this._mipmaps},set:function(t){this._mipmaps=t}}}),Object.defineProperty(on.prototype,"webgl2",{get:function(){return this.isWebGL2}}),on.prototype.getProgramLibrary=function(){return Ao(this)},on.prototype.setProgramLibrary=function(t){Co(this,t)},on.prototype.removeShaderFromCache=function(t){Ao(this).removeFromCache(t)},Gi.DEFAULT=Object.freeze(new Gi);var GT=new Gi,HT=new Hi;on.prototype.setBlendFunction=function(t,e){var i=this.blendState;GT.copy(i),GT.setColorBlend(i.colorOp,t,e),GT.setAlphaBlend(i.alphaOp,t,e),this.setBlendState(GT)},on.prototype.setBlendFunctionSeparate=function(t,e,i,n){var s=this.blendState;GT.copy(s),GT.setColorBlend(s.colorOp,t,e),GT.setAlphaBlend(s.alphaOp,i,n),this.setBlendState(GT)},on.prototype.setBlendEquation=function(t){var e=this.blendState;GT.copy(e),GT.setColorBlend(t,e.colorSrcFactor,e.colorDstFactor),GT.setAlphaBlend(t,e.alphaSrcFactor,e.alphaDstFactor),this.setBlendState(GT)},on.prototype.setBlendEquationSeparate=function(t,e){var i=this.blendState;GT.copy(i),GT.setColorBlend(t,i.colorSrcFactor,i.colorDstFactor),GT.setAlphaBlend(e,i.alphaSrcFactor,i.alphaDstFactor),this.setBlendState(GT)},on.prototype.setColorWrite=function(t,e,i,n){var s=this.blendState;GT.copy(s),GT.setColorWrite(t,e,i,n),this.setBlendState(GT)},on.prototype.getBlending=function(){return this.blendState.blend},on.prototype.setBlending=function(t){GT.copy(this.blendState),GT.blend=t,this.setBlendState(GT)},on.prototype.setDepthWrite=function(t){HT.copy(this.depthState),HT.write=t,this.setDepthState(HT)},on.prototype.setDepthFunc=function(t){HT.copy(this.depthState),HT.func=t,this.setDepthState(HT)},on.prototype.setDepthTest=function(t){HT.copy(this.depthState),HT.test=t,this.setDepthState(HT)},on.prototype.getCullMode=function(){return this.cullMode};var WT=vu,XT=Qh,qT={partitionSkin:JS,procedural:{calculateTangents:ho,createMesh:lo,createTorus:co,createCylinder:fo,createCapsule:po,createCone:mo,createSphere:_o,createPlane:go,createBox:vo},BasicMaterial:Ko,ForwardRenderer:Ru,GraphNode:_h,Material:Yo,Mesh:no,MeshInstance:Eh,Model:$u,ParticleEmitter:Kd,PhongMaterial:vu,Picker:Hw,Projection:{ORTHOGRAPHIC:1,PERSPECTIVE:0},Scene:rf,Skin:af,SkinInstance:Jo};function jT(t,e){Object.defineProperty(vu.prototype,e,{get:function(){return this[t]},set:function(e){this[t]=e}})}function YT(t,e){"pass"!==t&&Object.defineProperty(tu.prototype,t,{get:function(){return this.litOptions[e||t]},set:function(i){this.litOptions[e||t]=i}})}Object.defineProperty(rf.prototype,"defaultMaterial",{get:function(){return Xo(Mf().graphicsDevice)}}),Object.defineProperty(zu.prototype,"_meshInstances",{get:function(){return null}}),Object.defineProperty(rf.prototype,"drawCalls",{get:function(){return null}}),["128","64","32","16","8","4"].forEach((function(t,e){Object.defineProperty(rf.prototype,"skyboxPrefiltered"+t,{get:function(){return this._prefilteredCubemaps[e]},set:function(t){this._prefilteredCubemaps[e]=t,this.updateShaders=!0}})})),Object.defineProperty(rf.prototype,"models",{get:function(){return this._models||(this._models=[]),this._models}}),Object.defineProperty(Bu.prototype,"renderTarget",{set:function(t){this._renderTarget=t,this._dirtyComposition=!0},get:function(){return this._renderTarget}}),rf.prototype._updateSkybox=function(t){this._updateSky(t)},rf.prototype.addModel=function(t){if(!this.containsModel(t)){var e=this.layers.getLayerById(0);e&&(e.addMeshInstances(t.meshInstances),this.models.push(t))}},rf.prototype.addShadowCaster=function(t){var e=this.layers.getLayerById(0);e&&e.addShadowCasters(t.meshInstances)},rf.prototype.removeModel=function(t){var e=this.models.indexOf(t);if(-1!==e){var i=this.layers.getLayerById(0);if(!i)return;i.removeMeshInstances(t.meshInstances),this.models.splice(e,1)}},rf.prototype.removeShadowCasters=function(t){var e=this.layers.getLayerById(0);e&&e.removeShadowCasters(t.meshInstances)},rf.prototype.containsModel=function(t){return this.models.indexOf(t)>=0},rf.prototype.getModels=function(t){return this.models},Object.defineProperty(Zo.prototype,"model",{get:function(){return null}}),Ru.prototype.renderComposition=function(t){Mf().renderComposition(t)},Eh.prototype.syncAabb=function(){},Ju.prototype.getTarget=function(t){return this.targets[t]},_h.prototype._dirtify=function(t){t?this._dirtifyLocal():this._dirtifyWorld()},_h.prototype.addLabel=function(t){this._labels[t]=!0},_h.prototype.getLabels=function(){return Object.keys(this._labels)},_h.prototype.hasLabel=function(t){return!!this._labels[t]},_h.prototype.removeLabel=function(t){delete this._labels[t]},_h.prototype.findByLabel=function(t,e){void 0===e&&(e=[]),this.hasLabel(t)&&e.push(this);for(var i=0;i=r.length?e(new Error("Failed to create a graphics device")):Promise.resolve(r[i++]()).then((function(e){e?t(e):n()})).catch((function(t){console.log(t),n()}))}()}))},t.createMesh=lo,t.createPlane=go,t.createScript=ET,t.createShader=Mo,t.createShaderFromCode=Po,t.createSphere=_o,t.createStyle=function(t){var e=document.createElement("style");return e.type="text/css",e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t)),e},t.createTorus=co,t.createURI=function(t){var e="";if((t.authority||t.scheme)&&(t.host||t.hostpath))throw new Error("Can't have 'scheme' or 'authority' and 'host' or 'hostpath' option");if(t.host&&t.hostpath)throw new Error("Can't have 'host' and 'hostpath' option");if(t.path&&t.hostpath)throw new Error("Can't have 'path' and 'hostpath' option");return t.scheme&&(e+=t.scheme+":"),t.authority&&(e+="//"+t.authority),t.host&&(e+=t.host),t.path&&(e+=t.path),t.hostpath&&(e+=t.hostpath),t.query&&(e+="?"+t.query),t.fragment&&(e+="#"+t.fragment),e},t.data={},t.dracoInitialize=function(t){null!=t&&t.lazyInit?bx=t:Ex(t)},t.drawFullscreenQuad=zT,t.drawQuadWithShader=Uo,t.drawTexture=function(t,e,i,n,s,r){n=n||t.getCopyShader(),t.constantTexSource.setValue(e),Uo(t,i,n,s,r)},t.events=R,t.extend=p,t.getPixelFormatArrayType=Ae,t.getReservedScriptNames=function(){return CT},t.getTouchTargetCoords=Sa,t.gfx=UT,t.guid=I,t.http=Ca,t.inherits=function(t,e){var i=function(){},n=function(i,n,s,r,a,o,h,l){e.call(this,i,n,s,r,a,o,h,l),t.call(this,i,n,s,r,a,o,h,l)};return n._super=e.prototype,i.prototype=e.prototype,n.prototype=new i,n},t.input=tA,t.isCompressedPixelFormat=Te,t.log=RT,t.makeArray=function(t){return Array.prototype.slice.call(t)},t.math=_t,t.now=dt,t.path=L,t.pixelFormatInfo=we,t.platform=G,t.posteffect=VT,t.prefilterCubemap=function(t){},t.programlib=BT,t.registerScript=PT,t.reprojectTexture=Qc,t.revision=u,t.scene=qT,t.script=Df,t.semanticToLocation=Oi,t.shFromCubemap=function(t,e,i){if(7!==e.format)return null;if(!e._levels[0]||!e._levels[0][0])return null;var n=e.width;if(!e._levels[0][0].length){if(!(e._levels[0][0]instanceof HTMLImageElement))return null;for(var s=Po(t,wo.fullscreenQuadVS,wo.fullscreenQuadPS,"fsQuadSimple"),r=t.scope.resolve("source"),a=0;a<6;a++){var o=e._levels[0][a],h=new Us(t,{name:"prefiltered-cube",cubemap:!1,type:ri,format:e.format,width:n,height:n,mipmaps:!1});h._levels[0]=o,h.upload();var l=new Us(t,{name:"prefiltered-cube",cubemap:!1,type:ri,format:e.format,width:n,height:n,mipmaps:!1}),c=new ln({colorBuffer:l,depth:!1});r.setValue(h),t.setBlendState(Gi.NOBLEND),Uo(t,c,s);var u=t.gl;u.bindFramebuffer(u.FRAMEBUFFER,c.impl._glFrameBuffer);var d=new Uint8Array(n*n*4);u.readPixels(0,0,h.width,h.height,u.RGBA,u.UNSIGNED_BYTE,d),e._levels[0][a]=d}}for(var f=[],p=0;p-1||this._tweens.push(this._add[t]);this._add.length=0}}};var Tween=function(t,i,e){pc.events.attach(this),this.manager=i,e&&(this.entity=null),this.time=0,this.complete=!1,this.playing=!1,this.stopped=!0,this.pending=!1,this.target=t,this.duration=0,this._currentDelay=0,this.timeScale=1,this._reverse=!1,this._delay=0,this._yoyo=!1,this._count=0,this._numRepeats=0,this._repeatDelay=0,this._from=!1,this._slerp=!1,this._fromQuat=new pc.Quat,this._toQuat=new pc.Quat,this._quat=new pc.Quat,this.easing=pc.Linear,this._sv={},this._ev={}},_parseProperties=function(t){var i;return t instanceof pc.Vec2?i={x:t.x,y:t.y}:t instanceof pc.Vec3?i={x:t.x,y:t.y,z:t.z}:t instanceof pc.Vec4||t instanceof pc.Quat?i={x:t.x,y:t.y,z:t.z,w:t.w}:t instanceof pc.Color?(i={r:t.r,g:t.g,b:t.b},void 0!==t.a&&(i.a=t.a)):i=t,i};Tween.prototype={to:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this},from:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this._from=!0,this},rotate:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this._slerp=!0,this},start:function(){var t,i,e,s;if(this.playing=!0,this.complete=!1,this.stopped=!1,this._count=0,this.pending=this._delay>0,this._reverse&&!this.pending?this.time=this.duration:this.time=0,this._from){for(t in this._properties)this._properties.hasOwnProperty(t)&&(this._sv[t]=this._properties[t],this._ev[t]=this.target[t]);this._slerp&&(this._toQuat.setFromEulerAngles(this.target.x,this.target.y,this.target.z),i=void 0!==this._properties.x?this._properties.x:this.target.x,e=void 0!==this._properties.y?this._properties.y:this.target.y,s=void 0!==this._properties.z?this._properties.z:this.target.z,this._fromQuat.setFromEulerAngles(i,e,s))}else{for(t in this._properties)this._properties.hasOwnProperty(t)&&(this._sv[t]=this.target[t],this._ev[t]=this._properties[t]);this._slerp&&(i=void 0!==this._properties.x?this._properties.x:this.target.x,e=void 0!==this._properties.y?this._properties.y:this.target.y,s=void 0!==this._properties.z?this._properties.z:this.target.z,void 0!==this._properties.w?(this._fromQuat.copy(this.target),this._toQuat.set(i,e,s,this._properties.w)):(this._fromQuat.setFromEulerAngles(this.target.x,this.target.y,this.target.z),this._toQuat.setFromEulerAngles(i,e,s)))}return this._currentDelay=this._delay,this.manager.add(this),this},pause:function(){this.playing=!1},resume:function(){this.playing=!0},stop:function(){this.playing=!1,this.stopped=!0},delay:function(t){return this._delay=t,this.pending=!0,this},repeat:function(t,i){return this._count=0,this._numRepeats=t,this._repeatDelay=i||0,this},loop:function(t){return t?(this._count=0,this._numRepeats=1/0):this._numRepeats=0,this},yoyo:function(t){return this._yoyo=t,this},reverse:function(){return this._reverse=!this._reverse,this},chain:function(){for(var t=arguments.length;t--;)t>0?arguments[t-1]._chained=arguments[t]:this._chained=arguments[t];return this},update:function(t){if(this.stopped)return!1;if(!this.playing)return!0;if(!this._reverse||this.pending?this.time+=t*this.timeScale:this.time-=t*this.timeScale,this.pending){if(!(this.time>this._currentDelay))return!0;this._reverse?this.time=this.duration-(this.time-this._currentDelay):this.time-=this._currentDelay,this.pending=!1}var i=0;(!this._reverse&&this.time>this.duration||this._reverse&&this.time<0)&&(this._count++,this.complete=!0,this.playing=!1,this._reverse?(i=this.duration-this.time,this.time=0):(i=this.time-this.duration,this.time=this.duration));var e,s,n=0===this.duration?1:this.time/this.duration,r=this.easing(n);for(var h in this._properties)this._properties.hasOwnProperty(h)&&(e=this._sv[h],s=this._ev[h],this.target[h]=e+(s-e)*r);if(this._slerp&&this._quat.slerp(this._fromQuat,this._toQuat,r),this.entity&&(this.entity._dirtifyLocal(),this.element&&this.entity.element&&(this.entity.element[this.element]=this.target),this._slerp&&this.entity.setLocalRotation(this._quat)),this.fire("update",t),this.complete){var a=this._repeat(i);return a?this.fire("loop"):(this.fire("complete",i),this.entity&&this.entity.off("destroy",this.stop,this),this._chained&&this._chained.start()),a}return!0},_repeat:function(t){if(this._count{this.setOpacityCascade(s.v)})).start()},pc.Entity.prototype.opacityTo=function(t,i,e){if(!this.element.material)return;let s={v:t};return this.setOpacity(t),this.tween(s).to({v:i},e,pc.SineOut).on("update",(()=>{this.setOpacity(s.v)})).start()},pc.Entity.prototype.setTextureFromURL=function(t){let i="t_"+t,e=pc.app.assets.find(i,"texture");if(null===e){pc.app.loader.getHandler("texture").crossOrigin="anonymous";var s=new pc.Asset(i,"texture",{url:t});pc.app.assets.add(s),s.on("load",(t=>{this.element.texture=t.resource})),pc.app.assets.load(s)}else this.element.texture=e.resource},pc.Entity.prototype.blink=function(t,i,e,s){for(let n=0;n{this.setOpacity(t)}),e*n*2),setTimeout((()=>{this.setOpacity(i)}),e*(2*n+1))};var t=pc.AppBase.getApplication();t&&t.addTweenManager()}();var Background=pc.createScript("background");Background.attributes.add("startPosX",{type:"number",default:1}),Background.attributes.add("endPosX",{type:"number",default:1}),Background.attributes.add("durationTime",{type:"number",default:1}),Background.prototype.initialize=function(){this.entity.setLocalPosition(this.startPosX,0,0),this.tween=this.entity.tween(this.entity.getLocalPosition()).to(new pc.Vec3(this.endPosX,0,0),this.durationTime,pc.Linear).loop(!0).yoyo(!0),this.tween.start()};var UserBalance=pc.createScript("userBalance");UserBalance.attributes.add("userBalanceText",{type:"entity"}),UserBalance.attributes.add("userName",{type:"entity"}),UserBalance.prototype.initialize=function(){UserBalance.instance=this,this.userBalance=0},UserBalance.prototype.setUserName=function(e){this.userName.element.text=e},UserBalance.prototype.getUserBalance=function(){return this.userBalance},UserBalance.prototype.setBalance=function(e){this.userBalance=e;let t={value:Number(this.userBalanceText.element.text)},a=this.userBalanceText.element,n=this.entity.tween(t).to({value:e},.3,pc.Linear);n.on("update",(function(e){let n=parseFloat(t.value.toFixed(0));a.text=`${n}`})),n.start()},UserBalance.prototype.update=function(e){};var DummyServer=pc.createScript("dummyServer");DummyServer.prototype.initialize=function(){DummyServer.instance=this,this.betAmount=-1,this.userBalance=0},DummyServer.prototype.login=async function(){return this.userBalance=getRandomInt(1e3,5e3),{id:"userName",balance:this.userBalance}},DummyServer.prototype.startGame=function(e,t,n){console.log(e+" / "+t+" / "+n);let r=getRandomInt(1,4);this.userBalance=this.userBalance-e,this.betAmount=e;let a=t===r,i=n===r,s=0;return!0===a&&(s=0===n?3*e:2*e),i&&(s=e),this.userBalance=this.userBalance+s,{balance:this.userBalance,betAmount:this.betAmount,profit:s,winner:r,isWin:a,isTie:i}};var GlobalFunction=pc.createScript("globalFunction");function getRandomInt(o,r){return o=Math.ceil(o),r=Math.floor(r),Math.floor(Math.random()*(r-o))+o}var CardType={Clubs:0,Spades:1,Diamonds:2,Hearts:3},CardNumber={Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9,Ten:10,Jack:11,Queen:12,King:13};function shuffle(o){var r,e,n;for(n=o.length-1;n>0;n--)r=Math.floor(Math.random()*(n+1)),e=o[n],o[n]=o[r],o[r]=e;return o}function getDeck(){let o=[],r=Object.values(JSON.parse(JSON.stringify(CardType))),e=Object.values(JSON.parse(JSON.stringify(CardNumber)));for(const n of r)for(const r of e){let e={type:n,number:r};o.push(e)}return o}function getOColor(){return new pc.Color(1,136/255,116/255,1)}function getEColor(){return rgbToColor(86,98,181,255)}function getQColor(){return new pc.Color(168/255,216/255,131/255,1)}function getPlayerColor(){return new pc.Color(0,1,159/255,1)}function getRedColor(){return rgbToColor(221,42,63,255)}function getGreenColor(){return rgbToColor(0,148,68,255)}function getBlueColor(){return rgbToColor(0,169,215,255)}function getBlackColor(){return rgbToColor(0,0,0,255)}function getWhiteColor(){return rgbToColor(255,255,255,255)}function setButton(o,r,e){o.button.on("touchend",r,e),o.button.on("mouseup",r,e)}function rgbToColor(o,r,e,n){return new pc.Color(o/255,r/255,e/255,n/255)}function getCommaText(o){return o.toLocaleString("en-US")}function changeTexture(o,r){o.element.texture=r.resource}async function loadJsonFromUrl(n){return new Promise((e=>{this.loadJsonFromRemote(n,(function(n){let o=JSON.stringify(n),t=JSON.parse(o);e(t)}))}))}async function delay(n){return new Promise((e=>setTimeout((()=>{e(n)}),n)))}async function loadJsonFromRemote(n,e){var o=new XMLHttpRequest;o.addEventListener("load",(function(){e(JSON.parse(this.response))})),o.open("GET",n),o.send()}var Middle=pc.createScript("middle");Middle.prototype.initialize=function(){Middle.instance=this,this.idleTimer=null},Middle.prototype.postInitialize=function(){this.setIdle()},Middle.prototype.update=function(t){},Middle.prototype.startRace=async function(t,e){},Middle.prototype.setIdle=function(){NumberController.instance.setIdle()},Middle.prototype.setResult=async function(t){await NumberController.instance.stopRand(t)},Middle.prototype.setReady=function(){NumberController.instance.startRand()};var GameController=pc.createScript("gameController");GameController.prototype.initialize=function(){GameController.instance=this},GameController.prototype.postInitialize=function(){this.init(),this.setIdle()},GameController.prototype.init=async function(){let e=await DummyServer.instance.login();UserBalance.instance.setBalance(e.balance),UserBalance.instance.setUserName(e.id)},GameController.prototype.update=function(e){},GameController.prototype.betStart=function(){BetController.instance.reset(),Middle.instance.setReady(),Bottom.instance.setBet()},GameController.prototype.startGame=async function(e){},GameController.prototype.betGame=async function(e,t,n){let a=DummyServer.instance.startGame(e,t,n);await Middle.instance.setResult(a.winner),await delay(500),await Bottom.instance.setResultGame(a.isWin,a.isTie,a.profit),await delay(1e3),UserBalance.instance.setBalance(a.balance),await delay(3e3),this.setIdle()},GameController.prototype.setIdle=function(){Middle.instance.setIdle(),Bottom.instance.setIdle()};var Bottom=pc.createScript("bottom");Bottom.attributes.add("startButton",{type:"entity"}),Bottom.attributes.add("start_active",{type:"asset",assetType:"texture"}),Bottom.attributes.add("start_deactive",{type:"asset",assetType:"texture"}),Bottom.attributes.add("betUi",{type:"entity"}),Bottom.prototype.initialize=function(){Bottom.instance=this,this.setButton(this.startButton,this.onClickStart),this.winEffectTimer=null,this.bellToggle=!1},Bottom.prototype.postInitialize=function(){this.disableAll(),BetButtonController.instance.setBetButton()},Bottom.prototype.initBetButton=function(){},Bottom.prototype.setButton=function(t,e){t.button.on("touchend",e,this),t.button.on("mouseup",e,this)},Bottom.prototype.onClickStart=function(){AudioController.instance.playSound("Click"),this.changeButtonState(this.startButton,!1),this.changeTexture(this.startButton,this.start_active),this.setBet()},Bottom.prototype.onClickPlayer=function(t,e,o){AudioController.instance.playSound("Click"),BetButtonController.instance.setHide(t),GameController.instance.betGame(BetController.instance.betAmount,e,o)},Bottom.prototype.changeTexture=function(t,e){t.element.texture=e.resource},Bottom.prototype.changeButtonState=function(t,e){t.button.active=e},Bottom.prototype.disableAll=function(){clearTimeout(this.winEffectTimer),this.changeButtonState(this.startButton,!1),this.changeTexture(this.startButton,this.start_deactive),Result.instance.hideResult(),this.startButton.enabled=!1,this.betUi.enabled=!1},Bottom.prototype.setBet=function(){Middle.instance.setReady(),this.disableAll(),this.changeTexture(this.startButton,this.start_active),this.betUi.enabled=!0,this.changeButtonState(this.startButton,!1)},Bottom.prototype.setIdle=function(){this.disableAll(),BetButtonController.instance.showBetButton(!1),setTimeout((()=>{this.startButton.enabled=!0,this.changeButtonState(this.startButton,!0)}),1e3)},Bottom.prototype.setStartGame=async function(){this.disableAll(),this.changeTexture(this.startButton,this.start_active),this.betUi.enabled=!1,BetButtonController.instance.showBetButton(!0)},Bottom.prototype.setResultGame=function(t,e,o){setTimeout((()=>{this.disableAll(),Result.instance.setResult(t,e,o)}),1e3)};var AudioController=pc.createScript("audioController");AudioController.attributes.add("soundSource",{type:"entity"}),AudioController.prototype.initialize=function(){AudioController.instance=this,this.isMute=!0,this.soundSource.sound.volume=0},AudioController.prototype.setMute=function(o){this.isMute=o,this.isMute?this.soundSource.sound.volume=0:this.soundSource.sound.volume=.55},AudioController.prototype.playSound=function(o){!0!==this.isMute&&this.soundSource.sound.play(o)};var BetController=pc.createScript("betController");BetController.attributes.add("betButton",{type:"entity",array:!0}),BetController.attributes.add("okButton",{type:"entity"}),BetController.attributes.add("cancelButton",{type:"entity"}),BetController.attributes.add("clearButton",{type:"entity"}),BetController.attributes.add("betAmountText",{type:"entity"}),BetController.attributes.add("errorText",{type:"entity"}),BetController.prototype.initialize=function(){BetController.instance=this,this.timer=null,this.betAmount=0,this.errorText.enabled=!1,setButton(this.cancelButton,this.onBetCancel,this),setButton(this.okButton,this.onBetOk,this),setButton(this.clearButton,this.onBetClear,this)},BetController.prototype.reset=function(){this.betAmount=0,this.updateText(),this.resetAllButton()},BetController.prototype.resetAllButton=function(){this.betButton.forEach((t=>t.element.color=new pc.Color(.5,.5,.5,1)))},BetController.prototype.betChange=function(t){let e=this.betAmount+t;return e>UserBalance.instance.getUserBalance()?(this.showErrorMsg(),!1):(this.errorText.enabled=!1,this.betAmount=e,this.updateText(),!0)},BetController.prototype.updateText=function(){let t=getCommaText(this.betAmount);this.betAmountText.element.text=`${t}`},BetController.prototype.onBetClear=function(){AudioController.instance.playSound("Click"),console.log("BetController.prototype.onBetClear"),this.betAmount=0,this.updateText()},BetController.prototype.onBetOk=function(){AudioController.instance.playSound("Click"),console.log("BetController.prototype.betOk"),0!==this.betAmount&&Bottom.instance.setStartGame()},BetController.prototype.onBetCancel=function(){AudioController.instance.playSound("Click"),GameController.instance.setIdle()},BetController.prototype.showErrorMsg=function(){this.errorText.enabled=!0,clearTimeout(this.timer),this.timer=setTimeout((()=>{this.errorText.enabled=!1}),1e3)};var NumButton=pc.createScript("numButton");NumButton.attributes.add("betAmount",{type:"number"}),NumButton.prototype.initialize=function(){let t=this.entity.children[0],n=this.betAmount,e=getCommaText(n);t.element.text=`+${e}`,setButton(this.entity,this.onClick,this)},NumButton.prototype.onClick=function(){AudioController.instance.playSound("Click");BetController.instance.betChange(this.betAmount)};var SoundButton=pc.createScript("soundButton");SoundButton.attributes.add("onImg",{type:"entity"}),SoundButton.attributes.add("offImg",{type:"entity"}),SoundButton.prototype.initialize=function(){SoundButton.instance=this,this.isMute=!0,this.setButton(this.entity,this.onClick)},SoundButton.prototype.onClick=function(){this.isMute=!this.isMute,this.onImg.enabled=!1,this.offImg.enabled=!1,this.isMute?this.offImg.enabled=!0:this.onImg.enabled=!0,AudioController.instance.setMute(this.isMute)},SoundButton.prototype.setButton=function(t,n){t.element.on("touchend",n,this),t.element.on("mouseup",n,this)};var BetButton=pc.createScript("betButton");BetButton.attributes.add("buttonIdx",{type:"number"}),BetButton.attributes.add("winNumber",{type:"number"}),BetButton.attributes.add("tieNumber",{type:"number"}),BetButton.attributes.add("winImage",{type:"entity"}),BetButton.attributes.add("tieImage",{type:"entity"}),BetButton.attributes.add("buttonText",{type:"entity"}),BetButton.prototype.initialize=function(){setButton(this.entity,this.onClick,this)},BetButton.prototype.numberToColor=function(t){return 1===t?getRedColor():2===t?getGreenColor():getBlueColor()},BetButton.prototype.setButton=function(t,e,o){this.buttonIdx=t,this.winNumber=e,this.tieNumber=o,this.winImage.element.color=this.numberToColor(e),this.tieImage.element.color=this.numberToColor(0===o?e:o);let n="";n=`${e} WIN`,0!==o&&(n+=`\n${o} TIE`),this.buttonText.element.text=n},BetButton.prototype.onClick=function(){this.activeButton(!1),Bottom.instance.onClickPlayer(this.buttonIdx,this.winNumber,this.tieNumber)},BetButton.prototype.activeButton=function(t){this.entity.button.active=t},BetButton.prototype.changeButtonImage=function(t){this.entity.element.color=getEColor()};var Result=pc.createScript("result");Result.attributes.add("win",{type:"entity"}),Result.attributes.add("draw",{type:"entity"}),Result.attributes.add("lose",{type:"entity"}),Result.prototype.initialize=function(){Result.instance=this},Result.prototype.setResult=function(t,e,i){!0===t?(AudioController.instance.playSound("Win"),this.win.enabled=!0,this.win.children[1].element.text=`+${i}`):(AudioController.instance.playSound("Lose"),!0===e?this.draw.enabled=!0:this.lose.enabled=!0)},Result.prototype.hideResult=function(){this.win.enabled=!1,this.lose.enabled=!1,this.draw.enabled=!1};var BetButtonController=pc.createScript("betButtonController");BetButtonController.prototype.initialize=function(){BetButtonController.instance=this},BetButtonController.prototype.setBetButton=function(){let t=[{idx:0,win:1,tie:0},{idx:1,win:2,tie:0},{idx:2,win:3,tie:0},{idx:3,win:1,tie:2},{idx:4,win:1,tie:3},{idx:5,win:2,tie:1},{idx:6,win:2,tie:3},{idx:7,win:3,tie:1},{idx:8,win:3,tie:2}],e=0;console.log(this.entity.children),this.entity.children.forEach((i=>{i.children.forEach((i=>{let n=t[e];i.script.betButton.setButton(n.idx,n.win,n.tie),e++}))}))},BetButtonController.prototype.setHide=function(t){this.entity.children.forEach((e=>{e.children.forEach((e=>{e.script.betButton.buttonIdx!=t?e.enabled=!1:e.button.active=!1}))}))},BetButtonController.prototype.showBetButton=function(t){this.entity.children.forEach((e=>{e.enabled=t,e.children.forEach((e=>{e.button.active=t,e.enabled=t}))}))};var NumberController=pc.createScript("numberController");NumberController.prototype.initialize=function(){NumberController.instance=this,this.start=!1,this.interval=0,this.accTime=0,this.prevNumber=0},NumberController.prototype.postInitialize=function(){this.setIdle()},NumberController.prototype.update=function(t){!0===this.start&&(this.accTime+=t,this.accTime>=this.interval&&(this.prevNumber=this.generateRandomNumber(this.prevNumber),this.setNumber(this.prevNumber),this.accTime=0))},NumberController.prototype.generateRandomNumber=function(t){for(;;){var e=getRandomInt(1,4);if(e!==t)return e}},NumberController.prototype.setIdle=function(){this.start=!1,this.prevNumber=0,this.entity.element.text="?",this.entity.element.color=getWhiteColor()},NumberController.prototype.setNumber=function(t){let e=null;e=1===t?getRedColor():2===t?getGreenColor():getBlueColor(),this.entity.element.color=e,this.entity.element.text=`${t}`},NumberController.prototype.startRand=function(){this.start=!0,this.interval=.1,this.prevNumber=0},NumberController.prototype.stopRandLoop=async function(){for(let t=0;t<9;++t){this.interval+=.06;let t=1e3*this.interval;await delay(t)}},NumberController.prototype.stopRand=async function(t){await this.stopRandLoop(),this.start=!1;let e=this.interval-this.accTime;console.log(e),await delay(1e3*e),this.setNumber(t)}; \ No newline at end of file diff --git a/OneTwoThree/OneTwoThree/__loading__.js b/OneTwoThree/OneTwoThree/__loading__.js new file mode 100644 index 0000000..627a013 --- /dev/null +++ b/OneTwoThree/OneTwoThree/__loading__.js @@ -0,0 +1,112 @@ +pc.script.createLoadingScreen(function (app) { + var showSplash = function () { + // splash wrapper + var wrapper = document.createElement('div'); + wrapper.id = 'application-splash-wrapper'; + document.body.appendChild(wrapper); + + // splash + var splash = document.createElement('div'); + splash.id = 'application-splash'; + wrapper.appendChild(splash); + splash.style.display = 'none'; + + var logo = document.createElement('img'); + logo.src = ASSET_PREFIX + 'logo.png'; + splash.appendChild(logo); + logo.onload = function () { + splash.style.display = 'block'; + }; + + var container = document.createElement('div'); + container.id = 'progress-bar-container'; + splash.appendChild(container); + + var bar = document.createElement('div'); + bar.id = 'progress-bar'; + container.appendChild(bar); + + }; + + var hideSplash = function () { + var splash = document.getElementById('application-splash-wrapper'); + splash.parentElement.removeChild(splash); + }; + + var setProgress = function (value) { + var bar = document.getElementById('progress-bar'); + if (bar) { + value = Math.min(1, Math.max(0, value)); + bar.style.width = value * 100 + '%'; + } + }; + + var createCss = function () { + var css = [ + 'body {', + ' background-color: #283538;', + '}', + + '#application-splash-wrapper {', + ' position: absolute;', + ' top: 0;', + ' left: 0;', + ' height: 100%;', + ' width: 100%;', + ' background-color: #283538;', + '}', + + '#application-splash {', + ' position: absolute;', + ' top: calc(50% - 28px);', + ' width: 264px;', + ' left: calc(50% - 132px);', + '}', + + '#application-splash img {', + ' width: 100%;', + '}', + + '#progress-bar-container {', + ' margin: 20px auto 0 auto;', + ' height: 2px;', + ' width: 100%;', + ' background-color: #1d292c;', + '}', + + '#progress-bar {', + ' width: 0%;', + ' height: 100%;', + ' background-color: #f60;', + '}', + '@media (max-width: 480px) {', + ' #application-splash {', + ' width: 170px;', + ' left: calc(50% - 85px);', + ' }', + '}' + + ].join('\n'); + + var style = document.createElement('style'); + style.type = 'text/css'; + if (style.styleSheet) { + style.styleSheet.cssText = css; + } else { + style.appendChild(document.createTextNode(css)); + } + + document.head.appendChild(style); + }; + + + createCss(); + + showSplash(); + + app.on('preload:end', function () { + app.off('preload:progress'); + }); + app.on('preload:progress', setProgress); + app.on('start', hideSplash); +}); diff --git a/OneTwoThree/OneTwoThree/__modules__.js b/OneTwoThree/OneTwoThree/__modules__.js new file mode 100644 index 0000000..35109fe --- /dev/null +++ b/OneTwoThree/OneTwoThree/__modules__.js @@ -0,0 +1,45 @@ +var loadModules = function (modules, urlPrefix, doneCallback) { // eslint-disable-line no-unused-vars + + if (typeof modules === "undefined" || modules.length === 0) { + // caller may depend on callback behaviour being async + setTimeout(doneCallback); + } else { + let remaining = modules.length; + const moduleLoaded = () => { + if (--remaining === 0) { + doneCallback(); + } + }; + + modules.forEach(function (m) { + pc.WasmModule.setConfig(m.moduleName, { + glueUrl: urlPrefix + m.glueUrl, + wasmUrl: urlPrefix + m.wasmUrl, + fallbackUrl: urlPrefix + m.fallbackUrl + }); + + if (!m.hasOwnProperty('preload') || m.preload) { + if (m.moduleName === 'BASIS') { + // preload basis transcoder + pc.basisInitialize(); + moduleLoaded(); + } else if (m.moduleName === 'DracoDecoderModule') { + // preload draco decoder + if (pc.dracoInitialize) { + // 1.63 onwards + pc.dracoInitialize(); + moduleLoaded(); + } else { + // 1.62 and earlier + pc.WasmModule.getInstance(m.moduleName, () => { moduleLoaded(); }); + } + } else { + // load remaining modules in global scope + pc.WasmModule.getInstance(m.moduleName, () => { moduleLoaded(); }); + } + } else { + moduleLoaded(); + } + }); + } +}; diff --git a/OneTwoThree/__settings__.js b/OneTwoThree/OneTwoThree/__settings__.js similarity index 70% rename from OneTwoThree/__settings__.js rename to OneTwoThree/OneTwoThree/__settings__.js index f9a4800..26d43c0 100644 --- a/OneTwoThree/__settings__.js +++ b/OneTwoThree/OneTwoThree/__settings__.js @@ -8,7 +8,7 @@ window.CONTEXT_OPTIONS = { 'preferWebGl2': true, 'powerPreference': "high-performance" }; -window.SCRIPTS = [ 154122863, 154122878, 154122826, 154122844, 154122831, 154122839, 154122820, 154122835, 154122880, 154122884, 154122840, 154122861, 154122885, 154122823, 154122825, 154122848, 154122828, 154122842, 154122829, 154122849, 154122846, 154122843, 154142061, 154653300 ]; +window.SCRIPTS = [ 154122863, 154122878, 154122826, 154122844, 154122831, 154122820, 154122835, 154122884, 154122840, 154122861, 154122885, 154122823, 154122825, 154122828, 154122843, 154142061, 154653300 ]; window.CONFIG_FILENAME = "config.json"; window.INPUT_SETTINGS = { useKeyboard: true, diff --git a/OneTwoThree/OneTwoThree/__start__.js b/OneTwoThree/OneTwoThree/__start__.js new file mode 100644 index 0000000..d519ed7 --- /dev/null +++ b/OneTwoThree/OneTwoThree/__start__.js @@ -0,0 +1,228 @@ +(function () { + // Shared Lib + var CANVAS_ID = 'application-canvas'; + + // Needed as we will have edge cases for particular versions of iOS + // returns null if not iOS + var getIosVersion = function () { + if (/iP(hone|od|ad)/.test(navigator.platform)) { + var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/); + var version = [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)]; + return version; + } + + return null; + }; + + var lastWindowHeight = window.innerHeight; + var lastWindowWidth = window.innerWidth; + var windowSizeChangeIntervalHandler = null; + + var pcBootstrap = { + reflowHandler: null, + iosVersion: getIosVersion(), + + createCanvas: function () { + var canvas = document.createElement('canvas'); + canvas.setAttribute('id', CANVAS_ID); + canvas.setAttribute('tabindex', 0); + + // Disable I-bar cursor on click+drag + canvas.onselectstart = function () { return false; }; + + // Disable long-touch select on iOS devices + canvas.style['-webkit-user-select'] = 'none'; + + document.body.appendChild(canvas); + + return canvas; + }, + + + resizeCanvas: function (app, canvas) { + canvas.style.width = ''; + canvas.style.height = ''; + app.resizeCanvas(canvas.width, canvas.height); + + var fillMode = app._fillMode; + + if (fillMode === pc.FILLMODE_NONE || fillMode === pc.FILLMODE_KEEP_ASPECT) { + if ((fillMode === pc.FILLMODE_NONE && canvas.clientHeight < window.innerHeight) || (canvas.clientWidth / canvas.clientHeight >= window.innerWidth / window.innerHeight)) { + canvas.style.marginTop = Math.floor((window.innerHeight - canvas.clientHeight) / 2) + 'px'; + } else { + canvas.style.marginTop = ''; + } + } + + lastWindowHeight = window.innerHeight; + lastWindowWidth = window.innerWidth; + + // Work around when in landscape to work on iOS 12 otherwise + // the content is under the URL bar at the top + if (this.iosVersion && this.iosVersion[0] <= 12) { + window.scrollTo(0, 0); + } + }, + + reflow: function (app, canvas) { + this.resizeCanvas(app, canvas); + + // Poll for size changes as the window inner height can change after the resize event for iOS + // Have one tab only, and rotate from portrait -> landscape -> portrait + if (windowSizeChangeIntervalHandler === null) { + windowSizeChangeIntervalHandler = setInterval(function () { + if (lastWindowHeight !== window.innerHeight || lastWindowWidth !== window.innerWidth) { + this.resizeCanvas(app, canvas); + } + }.bind(this), 100); + + // Don't want to do this all the time so stop polling after some short time + setTimeout(function () { + if (!!windowSizeChangeIntervalHandler) { + clearInterval(windowSizeChangeIntervalHandler); + windowSizeChangeIntervalHandler = null; + } + }, 2000); + } + } + }; + + // Expose the reflow to users so that they can override the existing + // reflow logic if need be + window.pcBootstrap = pcBootstrap; +})(); + + +(function () { + var canvas, devices, app; + + var createInputDevices = function (canvas) { + var devices = { + elementInput: new pc.ElementInput(canvas, { + useMouse: INPUT_SETTINGS.useMouse, + useTouch: INPUT_SETTINGS.useTouch + }), + keyboard: INPUT_SETTINGS.useKeyboard ? new pc.Keyboard(window) : null, + mouse: INPUT_SETTINGS.useMouse ? new pc.Mouse(canvas) : null, + gamepads: INPUT_SETTINGS.useGamepads ? new pc.GamePads() : null, + touch: INPUT_SETTINGS.useTouch && pc.platform.touch ? new pc.TouchDevice(canvas) : null + }; + + return devices; + }; + + var configureCss = function (fillMode, width, height) { + // Configure resolution and resize event + if (canvas.classList) { + canvas.classList.add('fill-mode-' + fillMode); + } + + // css media query for aspect ratio changes + var css = "@media screen and (min-aspect-ratio: " + width + "/" + height + ") {"; + css += " #application-canvas.fill-mode-KEEP_ASPECT {"; + css += " width: auto;"; + css += " height: 100%;"; + css += " margin: 0 auto;"; + css += " }"; + css += "}"; + + // append css to style + if (document.head.querySelector) { + document.head.querySelector('style').innerHTML += css; + } + }; + + var displayError = function (html) { + var div = document.createElement('div'); + + div.innerHTML = [ + '', + ' ', + ' ', + ' ', + '
', + '
', + '
' + html + '
', + '
', + '
' + ].join('\n'); + + document.body.appendChild(div); + }; + + canvas = pcBootstrap.createCanvas(); + devices = createInputDevices(canvas); + + try { + app = new pc.Application(canvas, { + elementInput: devices.elementInput, + keyboard: devices.keyboard, + mouse: devices.mouse, + gamepads: devices.gamepads, + touch: devices.touch, + graphicsDeviceOptions: window.CONTEXT_OPTIONS, + assetPrefix: window.ASSET_PREFIX || "", + scriptPrefix: window.SCRIPT_PREFIX || "", + scriptsOrder: window.SCRIPTS || [] + }); + } catch (e) { + if (e instanceof pc.UnsupportedBrowserError) { + displayError('This page requires a browser that supports WebGL.
' + + '
Click here to find out more.'); + } else if (e instanceof pc.ContextCreationError) { + displayError("It doesn't appear your computer can support WebGL.
" + + 'Click here for more information.'); + } else { + displayError('Could not initialize application. Error: ' + e); + } + + return; + } + + var configure = function () { + app.configure(CONFIG_FILENAME, function (err) { + if (err) { + console.error(err); + } + + configureCss(app._fillMode, app._width, app._height); + + const ltcMat1 = []; + const ltcMat2 = []; + + if (ltcMat1.length && ltcMat2.length && app.setAreaLightLuts.length === 2) { + app.setAreaLightLuts(ltcMat1, ltcMat2); + } + + // do the first reflow after a timeout because of + // iOS showing a squished iframe sometimes + setTimeout(function () { + pcBootstrap.reflow(app, canvas); + pcBootstrap.reflowHandler = function () { pcBootstrap.reflow(app, canvas); }; + + window.addEventListener('resize', pcBootstrap.reflowHandler, false); + window.addEventListener('orientationchange', pcBootstrap.reflowHandler, false); + + app.preload(function (err) { + if (err) { + console.error(err); + } + + app.scenes.loadScene(SCENE_PATH, function (err, scene) { + if (err) { + console.error(err); + } + + app.start(); + }); + }); + }); + }); + }; + + if (PRELOAD_MODULES.length > 0) { + loadModules(PRELOAD_MODULES, ASSET_PREFIX, configure); + } else { + configure(); + } +})(); diff --git a/OneTwoThree/files/assets/154122815/1/win_m.mp3 b/OneTwoThree/OneTwoThree/files/assets/154122815/1/win_m.mp3 similarity index 100% rename from OneTwoThree/files/assets/154122815/1/win_m.mp3 rename to OneTwoThree/OneTwoThree/files/assets/154122815/1/win_m.mp3 diff --git a/OneTwoThree/OneTwoThree/files/assets/154122816/1/click3.mp3 b/OneTwoThree/OneTwoThree/files/assets/154122816/1/click3.mp3 new file mode 100644 index 0000000..d82a03c Binary files /dev/null and b/OneTwoThree/OneTwoThree/files/assets/154122816/1/click3.mp3 differ diff --git a/OneTwoThree/OneTwoThree/files/assets/154122818/1/lose.mp3 b/OneTwoThree/OneTwoThree/files/assets/154122818/1/lose.mp3 new file mode 100644 index 0000000..bf0b562 Binary files /dev/null and b/OneTwoThree/OneTwoThree/files/assets/154122818/1/lose.mp3 differ diff --git a/OneTwoThree/files/assets/154122827/1/vitro_core.png b/OneTwoThree/OneTwoThree/files/assets/154122827/1/vitro_core.png similarity index 100% rename from OneTwoThree/files/assets/154122827/1/vitro_core.png rename to OneTwoThree/OneTwoThree/files/assets/154122827/1/vitro_core.png diff --git a/OneTwoThree/OneTwoThree/files/assets/154122830/1/win.mp3 b/OneTwoThree/OneTwoThree/files/assets/154122830/1/win.mp3 new file mode 100644 index 0000000..f180be6 Binary files /dev/null and b/OneTwoThree/OneTwoThree/files/assets/154122830/1/win.mp3 differ diff --git a/OneTwoThree/files/assets/154122838/1/superstar_memesbruh03.png b/OneTwoThree/OneTwoThree/files/assets/154122838/1/superstar_memesbruh03.png similarity index 100% rename from OneTwoThree/files/assets/154122838/1/superstar_memesbruh03.png rename to OneTwoThree/OneTwoThree/files/assets/154122838/1/superstar_memesbruh03.png diff --git a/OneTwoThree/files/assets/154122841/1/Ok.png b/OneTwoThree/OneTwoThree/files/assets/154122841/1/Ok.png similarity index 100% rename from OneTwoThree/files/assets/154122841/1/Ok.png rename to OneTwoThree/OneTwoThree/files/assets/154122841/1/Ok.png diff --git a/OneTwoThree/OneTwoThree/files/assets/154122845/1/up_Money.png b/OneTwoThree/OneTwoThree/files/assets/154122845/1/up_Money.png new file mode 100644 index 0000000..a00694c Binary files /dev/null and b/OneTwoThree/OneTwoThree/files/assets/154122845/1/up_Money.png differ diff --git a/OneTwoThree/OneTwoThree/files/assets/154122847/1/Clear_copy.png b/OneTwoThree/OneTwoThree/files/assets/154122847/1/Clear_copy.png new file mode 100644 index 0000000..67b313d Binary files /dev/null and b/OneTwoThree/OneTwoThree/files/assets/154122847/1/Clear_copy.png differ diff --git a/OneTwoThree/OneTwoThree/files/assets/154122852/1/open.mp3 b/OneTwoThree/OneTwoThree/files/assets/154122852/1/open.mp3 new file mode 100644 index 0000000..bc765b0 Binary files /dev/null and b/OneTwoThree/OneTwoThree/files/assets/154122852/1/open.mp3 differ diff --git a/OneTwoThree/files/assets/154122862/1/cardMove_m.mp3 b/OneTwoThree/OneTwoThree/files/assets/154122862/1/cardMove_m.mp3 similarity index 100% rename from OneTwoThree/files/assets/154122862/1/cardMove_m.mp3 rename to OneTwoThree/OneTwoThree/files/assets/154122862/1/cardMove_m.mp3 diff --git a/OneTwoThree/files/assets/154122882/1/cardFlip_m.mp3 b/OneTwoThree/OneTwoThree/files/assets/154122882/1/cardFlip_m.mp3 similarity index 100% rename from OneTwoThree/files/assets/154122882/1/cardFlip_m.mp3 rename to OneTwoThree/OneTwoThree/files/assets/154122882/1/cardFlip_m.mp3 diff --git a/OneTwoThree/files/assets/154122886/1/draw_m.mp3 b/OneTwoThree/OneTwoThree/files/assets/154122886/1/draw_m.mp3 similarity index 100% rename from OneTwoThree/files/assets/154122886/1/draw_m.mp3 rename to OneTwoThree/OneTwoThree/files/assets/154122886/1/draw_m.mp3 diff --git a/OneTwoThree/files/assets/154122887/1/Cancel.png b/OneTwoThree/OneTwoThree/files/assets/154122887/1/Cancel.png similarity index 100% rename from OneTwoThree/files/assets/154122887/1/Cancel.png rename to OneTwoThree/OneTwoThree/files/assets/154122887/1/Cancel.png diff --git a/OneTwoThree/OneTwoThree/files/assets/154122889/1/Layer_5_copy_5.png b/OneTwoThree/OneTwoThree/files/assets/154122889/1/Layer_5_copy_5.png new file mode 100644 index 0000000..b7ba6c3 Binary files /dev/null and b/OneTwoThree/OneTwoThree/files/assets/154122889/1/Layer_5_copy_5.png differ diff --git a/OneTwoThree/files/assets/154122890/1/lose_m.mp3 b/OneTwoThree/OneTwoThree/files/assets/154122890/1/lose_m.mp3 similarity index 100% rename from OneTwoThree/files/assets/154122890/1/lose_m.mp3 rename to OneTwoThree/OneTwoThree/files/assets/154122890/1/lose_m.mp3 diff --git a/OneTwoThree/OneTwoThree/files/assets/155554346/1/s_on.png b/OneTwoThree/OneTwoThree/files/assets/155554346/1/s_on.png new file mode 100644 index 0000000..dc0b7ed Binary files /dev/null and b/OneTwoThree/OneTwoThree/files/assets/155554346/1/s_on.png differ diff --git a/OneTwoThree/OneTwoThree/files/assets/155554347/1/s_off.png b/OneTwoThree/OneTwoThree/files/assets/155554347/1/s_off.png new file mode 100644 index 0000000..0a2086f Binary files /dev/null and b/OneTwoThree/OneTwoThree/files/assets/155554347/1/s_off.png differ diff --git a/OneTwoThree/index.html b/OneTwoThree/OneTwoThree/index.html similarity index 100% rename from OneTwoThree/index.html rename to OneTwoThree/OneTwoThree/index.html diff --git a/OneTwoThree/OneTwoThree/logo.png b/OneTwoThree/OneTwoThree/logo.png new file mode 100644 index 0000000..bb25c22 Binary files /dev/null and b/OneTwoThree/OneTwoThree/logo.png differ diff --git a/OneTwoThree/manifest.json b/OneTwoThree/OneTwoThree/manifest.json similarity index 100% rename from OneTwoThree/manifest.json rename to OneTwoThree/OneTwoThree/manifest.json diff --git a/OneTwoThree/playcanvas-stable.min.js b/OneTwoThree/OneTwoThree/playcanvas-stable.min.js similarity index 100% rename from OneTwoThree/playcanvas-stable.min.js rename to OneTwoThree/OneTwoThree/playcanvas-stable.min.js diff --git a/OneTwoThree/OneTwoThree/styles.css b/OneTwoThree/OneTwoThree/styles.css new file mode 100644 index 0000000..5fcf103 --- /dev/null +++ b/OneTwoThree/OneTwoThree/styles.css @@ -0,0 +1,43 @@ +html { + height: 100%; + width: 100%; + background-color: #1d292c; +} +body { + margin: 0; + max-height: 100%; + height: 100%; + overflow: hidden; + background-color: #1d292c; + font-family: Helvetica, arial, sans-serif; + position: relative; + width: 100%; + + -webkit-tap-highlight-color: transparent; +} + +#application-canvas { + display: block; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; +} +#application-canvas.fill-mode-NONE { + margin: auto; +} +#application-canvas.fill-mode-KEEP_ASPECT { + width: 100%; + height: auto; + margin: 0; +} +#application-canvas.fill-mode-FILL_WINDOW { + width: 100%; + height: 100%; + margin: 0; +} + +canvas:focus { + outline: none; +} diff --git a/OneTwoThree/README_KR.md b/OneTwoThree/README_KR.md new file mode 100644 index 0000000..8a59fa1 --- /dev/null +++ b/OneTwoThree/README_KR.md @@ -0,0 +1,67 @@ +![hackathon](https://user-images.githubusercontent.com/109493423/196602490-c73a44f0-16f8-4321-9538-244b3e6fc09d.png) + +# OneTwoThree +- 1, 2, 3중에 하나의 숫자를 예측하는 게임입니다. + +# 게임 설명 +- 플레이어는 1, 2, 3 중에서 하나의 숫자를 선택하여 예측합니다. +- 만약 플레이어가 숫자를 정확히 예측하면 3배의 보상을 받습니다. +- 또한, 승리와 무승부를 동시에 선택할 수 있습니다. +- 이 선택은 숫자를 정확하게 예측하지 못해도 무승부 숫자를 맞히면 포인트를 잃지 않습니다. +- 이 선택에서 예측성공시 2배의 보상을 받습니다. + +# 화면 구성 +![image](https://github.com/mossland/Hackathon/assets/38033515/d97f6629-ff54-489a-b5e4-c51089a6efa4) + +1. 사운드 On/Off버튼 +2. 보유 포인트 +3. 게임 숫자 결과 +4. 시작 버튼 +5. 게임 포인트 선택버튼 +6. 승리 선택버튼 +7. 승리/무승부 선택버튼 + + +# 플레이 방법 +1. 시작 버튼을 누르고, 포인트를 선택합니다. + +![image](https://github.com/mossland/Hackathon/assets/38033515/3e235cdf-9e65-47ce-8784-5e2756d0a19e) + +2. 예측 결과 숫자를 선택합니다. +3. 단일 승리 숫자 선택하면, 예측성 공시 3배의 보상을 받습니다. + +![image](https://github.com/mossland/Hackathon/assets/38033515/352814dc-e23a-46bf-9832-c5a9e87a38b3) + +4. 승리 무승부 숫자 선택하면, 예측성 공시 2배의 보상을 받고, 무승부 예측 성공 시 포인트를 잃지 않습니다. + +![image](https://github.com/mossland/Hackathon/assets/38033515/06698b7a-9464-488b-b1f6-a15a2e41516c) + +5. 숫자 선택 후 결과를 확인할 수 있습니다. + +![image](https://github.com/mossland/Hackathon/assets/38033515/9fc63781-000e-40c8-bc73-25ea00269b97) + +6. 승무패 결과를 다시 확인할 수 있습니다. 승리 시 보상 포인트도 확인할 수 있습니다. + +![image](https://github.com/mossland/Hackathon/assets/38033515/e366f405-7888-480b-a387-04686d8da42e) + + +# 플레이 영상 + +![win](https://github.com/mossland/Hackathon/assets/38033515/772abb2c-ebb4-4bb4-a814-96dc027cad06) +![draw](https://github.com/mossland/Hackathon/assets/38033515/3a313560-1f5d-470b-8d4d-65545dfce8f8) +![lost](https://github.com/mossland/Hackathon/assets/38033515/c930bf04-7ba3-4a8b-9a19-5451dff11530) + +# 데모 페이지 +[데모 페이지](https://asset.moss.land/OneTwoThree/index.html) + +# 실행 +[npm](https://www.npmjs.com) 및 [http-server](https://www.npmjs.com/package/http-server)를 전역으로 설치합니다. +``` +npm install --global http-server +``` + +프로젝트를 다운로드한 폴더에서 http-server를 실행한 후, +로컬호스트로 접속하여 간단한 테스트를 진행할 수 있습니다. + +# Credits +PlayCanvas WebGL: https://playcanvas.com/ diff --git a/OneTwoThree/__game-scripts.js b/OneTwoThree/__game-scripts.js deleted file mode 100644 index 7c710a3..0000000 --- a/OneTwoThree/__game-scripts.js +++ /dev/null @@ -1 +0,0 @@ -pc.extend(pc,function(){var TweenManager=function(t){this._app=t,this._tweens=[],this._add=[]};TweenManager.prototype={add:function(t){return this._add.push(t),t},update:function(t){for(var i=0,e=this._tweens.length;i-1||this._tweens.push(this._add[t]);this._add.length=0}}};var Tween=function(t,i,e){pc.events.attach(this),this.manager=i,e&&(this.entity=null),this.time=0,this.complete=!1,this.playing=!1,this.stopped=!0,this.pending=!1,this.target=t,this.duration=0,this._currentDelay=0,this.timeScale=1,this._reverse=!1,this._delay=0,this._yoyo=!1,this._count=0,this._numRepeats=0,this._repeatDelay=0,this._from=!1,this._slerp=!1,this._fromQuat=new pc.Quat,this._toQuat=new pc.Quat,this._quat=new pc.Quat,this.easing=pc.Linear,this._sv={},this._ev={}},_parseProperties=function(t){var i;return t instanceof pc.Vec2?i={x:t.x,y:t.y}:t instanceof pc.Vec3?i={x:t.x,y:t.y,z:t.z}:t instanceof pc.Vec4||t instanceof pc.Quat?i={x:t.x,y:t.y,z:t.z,w:t.w}:t instanceof pc.Color?(i={r:t.r,g:t.g,b:t.b},void 0!==t.a&&(i.a=t.a)):i=t,i};Tween.prototype={to:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this},from:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this._from=!0,this},rotate:function(t,i,e,s,n,r){return this._properties=_parseProperties(t),this.duration=i,e&&(this.easing=e),s&&this.delay(s),n&&this.repeat(n),r&&this.yoyo(r),this._slerp=!0,this},start:function(){var t,i,e,s;if(this.playing=!0,this.complete=!1,this.stopped=!1,this._count=0,this.pending=this._delay>0,this._reverse&&!this.pending?this.time=this.duration:this.time=0,this._from){for(t in this._properties)this._properties.hasOwnProperty(t)&&(this._sv[t]=this._properties[t],this._ev[t]=this.target[t]);this._slerp&&(this._toQuat.setFromEulerAngles(this.target.x,this.target.y,this.target.z),i=void 0!==this._properties.x?this._properties.x:this.target.x,e=void 0!==this._properties.y?this._properties.y:this.target.y,s=void 0!==this._properties.z?this._properties.z:this.target.z,this._fromQuat.setFromEulerAngles(i,e,s))}else{for(t in this._properties)this._properties.hasOwnProperty(t)&&(this._sv[t]=this.target[t],this._ev[t]=this._properties[t]);this._slerp&&(i=void 0!==this._properties.x?this._properties.x:this.target.x,e=void 0!==this._properties.y?this._properties.y:this.target.y,s=void 0!==this._properties.z?this._properties.z:this.target.z,void 0!==this._properties.w?(this._fromQuat.copy(this.target),this._toQuat.set(i,e,s,this._properties.w)):(this._fromQuat.setFromEulerAngles(this.target.x,this.target.y,this.target.z),this._toQuat.setFromEulerAngles(i,e,s)))}return this._currentDelay=this._delay,this.manager.add(this),this},pause:function(){this.playing=!1},resume:function(){this.playing=!0},stop:function(){this.playing=!1,this.stopped=!0},delay:function(t){return this._delay=t,this.pending=!0,this},repeat:function(t,i){return this._count=0,this._numRepeats=t,this._repeatDelay=i||0,this},loop:function(t){return t?(this._count=0,this._numRepeats=1/0):this._numRepeats=0,this},yoyo:function(t){return this._yoyo=t,this},reverse:function(){return this._reverse=!this._reverse,this},chain:function(){for(var t=arguments.length;t--;)t>0?arguments[t-1]._chained=arguments[t]:this._chained=arguments[t];return this},update:function(t){if(this.stopped)return!1;if(!this.playing)return!0;if(!this._reverse||this.pending?this.time+=t*this.timeScale:this.time-=t*this.timeScale,this.pending){if(!(this.time>this._currentDelay))return!0;this._reverse?this.time=this.duration-(this.time-this._currentDelay):this.time-=this._currentDelay,this.pending=!1}var i=0;(!this._reverse&&this.time>this.duration||this._reverse&&this.time<0)&&(this._count++,this.complete=!0,this.playing=!1,this._reverse?(i=this.duration-this.time,this.time=0):(i=this.time-this.duration,this.time=this.duration));var e,s,n=0===this.duration?1:this.time/this.duration,r=this.easing(n);for(var h in this._properties)this._properties.hasOwnProperty(h)&&(e=this._sv[h],s=this._ev[h],this.target[h]=e+(s-e)*r);if(this._slerp&&this._quat.slerp(this._fromQuat,this._toQuat,r),this.entity&&(this.entity._dirtifyLocal(),this.element&&this.entity.element&&(this.entity.element[this.element]=this.target),this._slerp&&this.entity.setLocalRotation(this._quat)),this.fire("update",t),this.complete){var a=this._repeat(i);return a?this.fire("loop"):(this.fire("complete",i),this.entity&&this.entity.off("destroy",this.stop,this),this._chained&&this._chained.start()),a}return!0},_repeat:function(t){if(this._count{this.setOpacityCascade(s.v)})).start()},pc.Entity.prototype.opacityTo=function(t,i,e){if(!this.element.material)return;let s={v:t};return this.setOpacity(t),this.tween(s).to({v:i},e,pc.SineOut).on("update",(()=>{this.setOpacity(s.v)})).start()},pc.Entity.prototype.setTextureFromURL=function(t){let i="t_"+t,e=pc.app.assets.find(i,"texture");if(null===e){pc.app.loader.getHandler("texture").crossOrigin="anonymous";var s=new pc.Asset(i,"texture",{url:t});pc.app.assets.add(s),s.on("load",(t=>{this.element.texture=t.resource})),pc.app.assets.load(s)}else this.element.texture=e.resource},pc.Entity.prototype.blink=function(t,i,e,s){for(let n=0;n{this.setOpacity(t)}),e*n*2),setTimeout((()=>{this.setOpacity(i)}),e*(2*n+1))};var t=pc.AppBase.getApplication();t&&t.addTweenManager()}();var Background=pc.createScript("background");Background.attributes.add("startPosX",{type:"number",default:1}),Background.attributes.add("endPosX",{type:"number",default:1}),Background.attributes.add("durationTime",{type:"number",default:1}),Background.prototype.initialize=function(){this.entity.setLocalPosition(this.startPosX,0,0),this.tween=this.entity.tween(this.entity.getLocalPosition()).to(new pc.Vec3(this.endPosX,0,0),this.durationTime,pc.Linear).loop(!0).yoyo(!0),this.tween.start()};var UserBalance=pc.createScript("userBalance");UserBalance.attributes.add("userBalanceText",{type:"entity"}),UserBalance.attributes.add("userName",{type:"entity"}),UserBalance.prototype.initialize=function(){UserBalance.instance=this,this.userBalance=0},UserBalance.prototype.setUserName=function(e){this.userName.element.text=e},UserBalance.prototype.getUserBalance=function(){return this.userBalance},UserBalance.prototype.setBalance=function(e){this.userBalance=e;let t={value:Number(this.userBalanceText.element.text)},a=this.userBalanceText.element,n=this.entity.tween(t).to({value:e},.3,pc.Linear);n.on("update",(function(e){let n=parseFloat(t.value.toFixed(0));a.text=`${n}`})),n.start()},UserBalance.prototype.update=function(e){};var DummyServer=pc.createScript("dummyServer");DummyServer.prototype.initialize=function(){DummyServer.instance=this,this.betAmount=-1,this.userBalance=0,this.gameDeck=null,this.gameOdds=null},DummyServer.prototype.login=async function(){return this.userBalance=getRandomInt(1e3,5e3),{id:"userName",balance:this.userBalance}},DummyServer.prototype.isValidGame=function(e){let t=[0,0,0,0];e.reduce(((e,t)=>(console.log(e),e[t.type]++,e)),t);let r=!0;return t.forEach((e=>{e>4&&(r=!1)})),this.gameOdds=[0,0,0,0],!0===r&&(this.gameOdds=t.map((e=>0===e?1:1===e?2:2===e?3:3===e?5:10))),r},DummyServer.prototype.initGame=function(){let e;do{this.gameDeck=getDeck(),this.gameDeck=shuffle(this.gameDeck),e=this.gameDeck.slice(0,7),console.log(e)}while(!1===this.isValidGame(e));return{cards:e,odds:this.gameOdds}},DummyServer.prototype.getWinner=function(e){let t=-1;return e.forEach(((e,r)=>{e>=8&&(t=r)})),t},DummyServer.prototype.startGame=function(e,t){let r=[0,0,0,0],i=this.gameDeck.slice(7,this.gameDeck.length),s=-1;for(let e=0;e=0)break}this.userBalance=this.userBalance-e,this.betAmount=e;let a=t===s,n=0;return!0===a&&(n=e*this.gameOdds[s]),this.userBalance=this.userBalance+n,{balance:this.userBalance,betAmount:this.betAmount,profit:n,raceCards:i,playerHorse:t,winner:s,isWin:a}};var GlobalFunction=pc.createScript("globalFunction");function getRandomInt(o,r){return o=Math.ceil(o),r=Math.floor(r),Math.floor(Math.random()*(r-o))+o}var CardType={Clubs:0,Spades:1,Diamonds:2,Hearts:3},CardNumber={Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9,Ten:10,Jack:11,Queen:12,King:13};function shuffle(o){var r,e,n;for(n=o.length-1;n>0;n--)r=Math.floor(Math.random()*(n+1)),e=o[n],o[n]=o[r],o[r]=e;return o}function getDeck(){let o=[],r=Object.values(JSON.parse(JSON.stringify(CardType))),e=Object.values(JSON.parse(JSON.stringify(CardNumber)));for(const n of r)for(const r of e){let e={type:n,number:r};o.push(e)}return o}function getOColor(){return new pc.Color(1,136/255,116/255,1)}function getEColor(){return rgbToColor(86,98,181,255)}function getQColor(){return new pc.Color(168/255,216/255,131/255,1)}function getPlayerColor(){return new pc.Color(0,1,159/255,1)}function getRedColor(){return rgbToColor(221,42,63,255)}function getGreenColor(){return rgbToColor(0,148,68,255)}function getBlueColor(){return rgbToColor(0,169,215,255)}function getBlackColor(){return rgbToColor(0,0,0,255)}function getWhiteColor(){return rgbToColor(255,255,255,255)}function setButton(o,r,e){o.button.on("touchend",r,e),o.button.on("mouseup",r,e)}function rgbToColor(o,r,e,n){return new pc.Color(o/255,r/255,e/255,n/255)}function getCommaText(o){return o.toLocaleString("en-US")}function changeTexture(o,r){o.element.texture=r.resource}var CardFront=pc.createScript("cardFront");CardFront.attributes.add("numberText",{type:"entity"}),CardFront.attributes.add("typeImage",{type:"entity"}),CardFront.attributes.add("fruitImage",{type:"asset",assetType:"texture",array:!0}),CardFront.prototype.initialize=function(){},CardFront.prototype.setCardType=function(t){let e=this.fruitImage[t].resource;this.typeImage.element.texture=e,this.numberText.element.color=t<2?getBlackColor():getRedColor()},CardFront.prototype.setPlayerColor=function(){this.entity.element.color=getPlayerColor()},CardFront.prototype.resetColor=function(){this.entity.element.color=getWhiteColor()},CardFront.prototype.setCardNumber=function(t){let e=t;1===t?e="A":11===t?e="J":12===t?e="Q":13===t&&(e="K"),this.numberText.element.text=`${e}`},CardFront.prototype.setCard=function(t,e){this.setCardType(t),this.setCardNumber(e)};async function loadJsonFromUrl(n){return new Promise((e=>{this.loadJsonFromRemote(n,(function(n){console.log(n);let o=JSON.stringify(n),s=JSON.parse(o);e(s)}))}))}async function delay(n){return new Promise((e=>setTimeout((()=>{e(n)}),n)))}async function loadJsonFromRemote(n,e){var o=new XMLHttpRequest;o.addEventListener("load",(function(){e(JSON.parse(this.response))})),o.open("GET",n),o.send()}var Middle=pc.createScript("middle");Middle.prototype.initialize=function(){Middle.instance=this,this.idleTimer=null},Middle.prototype.postInitialize=function(){this.setReady()},Middle.prototype.update=function(e){},Middle.prototype.startRace=async function(e,t){HorseController.instance.reset(),HorseController.instance.setPlayerCard(t);for(let t=0;t=8)break}},Middle.prototype.setIdle=function(){},Middle.prototype.dispenseCard=async function(e){},Middle.prototype.setCard=function(e,t){},Middle.prototype.setResult=async function(e,t){},Middle.prototype.setReady=function(){};var Card=pc.createScript("card");Card.attributes.add("cardRoot",{type:"entity"}),Card.attributes.add("cardFront",{type:"entity"}),Card.prototype.initialize=function(){},Card.prototype.setCard=function(t,r){this.cardRoot.enabled=!0,this.cardRoot.setLocalEulerAngles(0,0,0),this.cardFront.script.cardFront.setCard(t,r)},Card.prototype.setPlayerCard=function(t){!0===t?this.cardFront.script.cardFront.setPlayerColor():this.cardFront.script.cardFront.resetColor()},Card.prototype.setReady=function(){this.cardRoot.enabled=!0,this.cardFront.script.cardFront.resetColor(),this.cardRoot.setLocalEulerAngles(0,180,0)},Card.prototype.setHide=function(t){this.cardRoot.enabled=!t};var GameController=pc.createScript("gameController");GameController.prototype.initialize=function(){GameController.instance=this},GameController.prototype.postInitialize=function(){this.init(),this.setIdle()},GameController.prototype.init=async function(){let e=await DummyServer.instance.login();console.log(e),UserBalance.instance.setBalance(e.balance),UserBalance.instance.setUserName(e.id)},GameController.prototype.update=function(e){},GameController.prototype.betStart=function(){BetController.instance.reset(),Middle.instance.setReady(),Bottom.instance.setBet()},GameController.prototype.startGame=async function(e){Bottom.instance.betUi.enabled=!1;let t=DummyServer.instance.initGame();await Middle.instance.dispenseCard(t.cards),Bottom.instance.setOdds(t.odds),await delay(1e3),Bottom.instance.setBet()},GameController.prototype.betGame=async function(e,t){let n=DummyServer.instance.startGame(e,t);console.log(n),await Middle.instance.startRace(n.raceCards,n.playerHorse),await Bottom.instance.setResultGame(n.isWin,n.winner,n.profit),await delay(500),UserBalance.instance.setBalance(n.balance),await delay(3e3),this.setIdle()},GameController.prototype.setIdle=function(){Middle.instance.setIdle(),Bottom.instance.setIdle()};var Bottom=pc.createScript("bottom");Bottom.attributes.add("startButton",{type:"entity"}),Bottom.attributes.add("start_active",{type:"asset",assetType:"texture"}),Bottom.attributes.add("start_deactive",{type:"asset",assetType:"texture"}),Bottom.attributes.add("betUi",{type:"entity"}),Bottom.prototype.initialize=function(){Bottom.instance=this,this.setButton(this.startButton,this.onClickStart),this.winEffectTimer=null,this.bellToggle=!1},Bottom.prototype.postInitialize=function(){this.disableAll(),BetButtonController.instance.setBetButton()},Bottom.prototype.initBetButton=function(){},Bottom.prototype.setOdds=function(t){},Bottom.prototype.resetOdds=function(){},Bottom.prototype.setButton=function(t,e){t.button.on("touchend",e,this),t.button.on("mouseup",e,this)},Bottom.prototype.onClickStart=function(){AudioController.instance.playSound("Click"),GameController.instance.startGame(),this.changeButtonState(this.startButton,!1),this.changeTexture(this.startButton,this.start_active)},Bottom.prototype.onClickPlayer=function(t){this.activePlayerBtn(!1),AudioController.instance.playSound("Click"),GameController.instance.betGame(BetController.instance.betAmount,t)},Bottom.prototype.changeTexture=function(t,e){t.element.texture=e.resource},Bottom.prototype.changeButtonState=function(t,e){t.button.active=e},Bottom.prototype.disableAll=function(){clearTimeout(this.winEffectTimer),this.changeButtonState(this.startButton,!1),this.changeTexture(this.startButton,this.start_deactive),Result.instance.hideResult(),this.betUi.enabled=!1},Bottom.prototype.setBet=function(){this.disableAll(),this.changeTexture(this.startButton,this.start_active),this.betUi.enabled=!0,this.changeButtonState(this.startButton,!1),this.activePlayerBtn(!1)},Bottom.prototype.setIdle=function(){this.disableAll(),this.resetOdds(),setTimeout((()=>{this.changeButtonState(this.startButton,!0)}),1e3)},Bottom.prototype.setStartGame=async function(){this.disableAll(),this.changeTexture(this.startButton,this.start_active),console.log(this.betUi),this.betUi.enabled=!1,this.activePlayerBtn(!0)},Bottom.prototype.activePlayerBtn=function(t){},Bottom.prototype.setResultGame=function(t,e,o){console.log("setResultGame",t,o),setTimeout((()=>{this.disableAll(),Result.instance.setResult(t,e,o)}),1e3)};var AudioController=pc.createScript("audioController");AudioController.attributes.add("soundSource",{type:"entity"}),AudioController.prototype.initialize=function(){AudioController.instance=this,this.isMute=!0,this.soundSource.sound.volume=0},AudioController.prototype.setMute=function(o){this.isMute=o,this.isMute?this.soundSource.sound.volume=0:this.soundSource.sound.volume=.55},AudioController.prototype.playSound=function(o){!0!==this.isMute&&this.soundSource.sound.play(o)};var BetController=pc.createScript("betController");BetController.attributes.add("betButton",{type:"entity",array:!0}),BetController.attributes.add("okButton",{type:"entity"}),BetController.attributes.add("cancelButton",{type:"entity"}),BetController.attributes.add("clearButton",{type:"entity"}),BetController.attributes.add("betAmountText",{type:"entity"}),BetController.attributes.add("errorText",{type:"entity"}),BetController.prototype.initialize=function(){BetController.instance=this,this.timer=null,this.betAmount=0,this.errorText.enabled=!1,setButton(this.cancelButton,this.onBetCancel,this),setButton(this.okButton,this.onBetOk,this),setButton(this.clearButton,this.onBetClear,this)},BetController.prototype.reset=function(){this.betAmount=0,this.updateText(),this.resetAllButton()},BetController.prototype.resetAllButton=function(){this.betButton.forEach((t=>t.element.color=new pc.Color(.5,.5,.5,1)))},BetController.prototype.betChange=function(t){let e=this.betAmount+t;return e>UserBalance.instance.getUserBalance()?(this.showErrorMsg(),!1):(this.errorText.enabled=!1,this.betAmount=e,this.updateText(),!0)},BetController.prototype.updateText=function(){let t=getCommaText(this.betAmount);this.betAmountText.element.text=`${t}`},BetController.prototype.onBetClear=function(){AudioController.instance.playSound("Click"),console.log("BetController.prototype.onBetClear"),this.betAmount=0,this.updateText()},BetController.prototype.onBetOk=function(){AudioController.instance.playSound("Click"),console.log("BetController.prototype.betOk"),0!==this.betAmount&&Bottom.instance.setStartGame()},BetController.prototype.onBetCancel=function(){AudioController.instance.playSound("Click"),GameController.instance.setIdle()},BetController.prototype.showErrorMsg=function(){this.errorText.enabled=!0,clearTimeout(this.timer),this.timer=setTimeout((()=>{this.errorText.enabled=!1}),1e3)};var NumButton=pc.createScript("numButton");NumButton.attributes.add("betAmount",{type:"number"}),NumButton.prototype.initialize=function(){let t=this.entity.children[0],n=this.betAmount,e=getCommaText(n);t.element.text=`+${e}`,setButton(this.entity,this.onClick,this)},NumButton.prototype.onClick=function(){AudioController.instance.playSound("Click");BetController.instance.betChange(this.betAmount)};var SoundButton=pc.createScript("soundButton");SoundButton.attributes.add("onImg",{type:"entity"}),SoundButton.attributes.add("offImg",{type:"entity"}),SoundButton.prototype.initialize=function(){SoundButton.instance=this,this.isMute=!0,this.setButton(this.entity,this.onClick)},SoundButton.prototype.onClick=function(){this.isMute=!this.isMute,this.onImg.enabled=!1,this.offImg.enabled=!1,this.isMute?this.offImg.enabled=!0:this.onImg.enabled=!0,AudioController.instance.setMute(this.isMute)},SoundButton.prototype.setButton=function(t,n){t.element.on("touchend",n,this),t.element.on("mouseup",n,this)};var Player=pc.createScript("player");Player.attributes.add("winLose",{type:"entity"}),Player.attributes.add("pair",{type:"entity"}),Player.attributes.add("cards",{type:"entity",array:"true"}),Player.attributes.add("nonSelImg",{type:"asset",assetType:"texture"}),Player.attributes.add("selImg",{type:"asset",assetType:"texture"}),Player.attributes.add("winImg",{type:"asset",assetType:"texture"}),Player.attributes.add("loseImg",{type:"asset",assetType:"texture"}),Player.attributes.add("draw",{type:"asset",assetType:"texture"}),Player.prototype.initialize=function(){},Player.prototype.reset=function(){this.winLose.enabled=!1,this.pair.element.text="?",changeTexture(this.entity,this.nonSelImg),this.cards.forEach((e=>{e.script.card.setHide(!0)}))},Player.prototype.selectPlayer=function(){changeTexture(this.entity,this.selImg)},Player.prototype.showCard=function(e){AudioController.instance.playSound("moveCard"),this.cards[e].script.card.setReady()},Player.prototype.setCard=function(e){let t=0;AudioController.instance.playSound("flipCard");for(let a=0;a{let o=t.getLocalPosition();t.setLocalPosition(this.startPositionX,o.y,0),t.script.card.setPlayerCard(!1)})),this.step=[0,0,0,0]};var TopCardController=pc.createScript("topCardController");TopCardController.attributes.add("topCards",{type:"entity",array:"true"}),TopCardController.prototype.initialize=function(){TopCardController.instance=this},TopCardController.prototype.postInitialize=function(){this.setReady()},TopCardController.prototype.setReady=function(){for(let t=0;tt.enabled=!1)),this.cardNumber=0},RaceHistory.prototype.addType=function(t){this.historyElement[this.cardNumber].enabled=!0,changeTexture(this.historyElement[this.cardNumber],this.typeImage[t]),this.cardNumber++},RaceHistory.prototype.update=function(t){};var Result=pc.createScript("result");Result.attributes.add("win",{type:"entity"}),Result.attributes.add("lose",{type:"entity"}),Result.prototype.initialize=function(){Result.instance=this},Result.prototype.typeToString=function(e){let t="";switch(e){case 0:t="Clubs";break;case 1:t="Spades";break;case 2:t="Diamonds";break;default:t="Hearts"}return t},Result.prototype.setResult=function(e,t,i){let n=e?this.win:this.lose,s=`The winner is ace of ${this.typeToString(t)}`;n.children[0].element.text=s,!0===e?(AudioController.instance.playSound("Win"),this.win.enabled=!0,n.children[2].element.text=`+${i}`):(AudioController.instance.playSound("Lose"),this.lose.enabled=!0)},Result.prototype.hideResult=function(){this.win.enabled=!1,this.lose.enabled=!1};var BetButtonController=pc.createScript("betButtonController");BetButtonController.prototype.initialize=function(){BetButtonController.instance=this},BetButtonController.prototype.setBetButton=function(){let t=[{idx:0,win:1,tie:0},{idx:1,win:2,tie:0},{idx:2,win:3,tie:0},{idx:3,win:1,tie:2},{idx:4,win:1,tie:3},{idx:5,win:2,tie:1},{idx:6,win:2,tie:3},{idx:7,win:3,tie:1},{idx:8,win:3,tie:2}],i=0;console.log(this.entity.children),this.entity.children.forEach((e=>{e.children.forEach((e=>{let n=t[i];e.script.betButton.setButton(n.idx,n.win,n.tie),i++}))}))};var NumberController=pc.createScript("numberController");NumberController.prototype.initialize=function(){NumberController.instance=this,this.start=!1,this.interval=0,this.accTime=0,this.prevNumber=0},NumberController.prototype.update=function(t){!0===this.start&&(this.accTime+=t,this.accTime>=this.interval&&(this.prevNumber=this.generateRandomNumber(this.prevNumber),this.setNumber(this.prevNumber),this.accTime=0))},NumberController.prototype.generateRandomNumber=function(t){for(;;){var e=getRandomInt(1,4);if(e!==t)return e}},NumberController.prototype.setNumber=function(t){this.entity.element.text=`${t}`},NumberController.prototype.startRand=function(){this.start=!0,this.interval=.1,this.prevNumber=0},NumberController.prototype.stopRandLoop=async function(){for(let t=0;t<9;++t){this.interval+=.06;let t=1e3*this.interval;await delay(t)}},NumberController.prototype.stopRand=async function(t){await this.stopRandLoop(),this.start=!1;let e=this.interval-this.accTime;console.log(e),await delay(1e3*e),this.setNumber(t)}; \ No newline at end of file diff --git a/OneTwoThree/files/assets/154122817/1/1.png b/OneTwoThree/files/assets/154122817/1/1.png deleted file mode 100644 index e4b5912..0000000 Binary files a/OneTwoThree/files/assets/154122817/1/1.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122821/1/B_gray_off.png b/OneTwoThree/files/assets/154122821/1/B_gray_off.png deleted file mode 100644 index 682ee8f..0000000 Binary files a/OneTwoThree/files/assets/154122821/1/B_gray_off.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122854/1/B_green_off.png b/OneTwoThree/files/assets/154122854/1/B_green_off.png deleted file mode 100644 index 2189369..0000000 Binary files a/OneTwoThree/files/assets/154122854/1/B_green_off.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122855/1/2.png b/OneTwoThree/files/assets/154122855/1/2.png deleted file mode 100644 index b542e4b..0000000 Binary files a/OneTwoThree/files/assets/154122855/1/2.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122856/1/B_blue_on.png b/OneTwoThree/files/assets/154122856/1/B_blue_on.png deleted file mode 100644 index 7760c80..0000000 Binary files a/OneTwoThree/files/assets/154122856/1/B_blue_on.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122857/1/B_red_off.png b/OneTwoThree/files/assets/154122857/1/B_red_off.png deleted file mode 100644 index 804f7c2..0000000 Binary files a/OneTwoThree/files/assets/154122857/1/B_red_off.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122858/1/redBG.png b/OneTwoThree/files/assets/154122858/1/redBG.png deleted file mode 100644 index c43959a..0000000 Binary files a/OneTwoThree/files/assets/154122858/1/redBG.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122859/1/B_blue_off.png b/OneTwoThree/files/assets/154122859/1/B_blue_off.png deleted file mode 100644 index ecbf462..0000000 Binary files a/OneTwoThree/files/assets/154122859/1/B_blue_off.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122860/1/border_m.png b/OneTwoThree/files/assets/154122860/1/border_m.png deleted file mode 100644 index 2b469f7..0000000 Binary files a/OneTwoThree/files/assets/154122860/1/border_m.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122868/1/B_gray_on.png b/OneTwoThree/files/assets/154122868/1/B_gray_on.png deleted file mode 100644 index 05ed183..0000000 Binary files a/OneTwoThree/files/assets/154122868/1/B_gray_on.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122869/1/loseImg.png b/OneTwoThree/files/assets/154122869/1/loseImg.png deleted file mode 100644 index f957a29..0000000 Binary files a/OneTwoThree/files/assets/154122869/1/loseImg.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122870/1/winImg.png b/OneTwoThree/files/assets/154122870/1/winImg.png deleted file mode 100644 index e760553..0000000 Binary files a/OneTwoThree/files/assets/154122870/1/winImg.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122871/1/4.png b/OneTwoThree/files/assets/154122871/1/4.png deleted file mode 100644 index bd2de10..0000000 Binary files a/OneTwoThree/files/assets/154122871/1/4.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122873/1/B_red_on.png b/OneTwoThree/files/assets/154122873/1/B_red_on.png deleted file mode 100644 index 0816653..0000000 Binary files a/OneTwoThree/files/assets/154122873/1/B_red_on.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122874/1/B_green_on.png b/OneTwoThree/files/assets/154122874/1/B_green_on.png deleted file mode 100644 index 8648dee..0000000 Binary files a/OneTwoThree/files/assets/154122874/1/B_green_on.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122875/1/drawImg.png b/OneTwoThree/files/assets/154122875/1/drawImg.png deleted file mode 100644 index f51bf2a..0000000 Binary files a/OneTwoThree/files/assets/154122875/1/drawImg.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122877/1/3.png b/OneTwoThree/files/assets/154122877/1/3.png deleted file mode 100644 index 1b03de3..0000000 Binary files a/OneTwoThree/files/assets/154122877/1/3.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122881/1/blueBG.png b/OneTwoThree/files/assets/154122881/1/blueBG.png deleted file mode 100644 index 59a388a..0000000 Binary files a/OneTwoThree/files/assets/154122881/1/blueBG.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122888/1/cardBack_2.png b/OneTwoThree/files/assets/154122888/1/cardBack_2.png deleted file mode 100644 index 2771352..0000000 Binary files a/OneTwoThree/files/assets/154122888/1/cardBack_2.png and /dev/null differ diff --git a/OneTwoThree/files/assets/154122891/1/border.png b/OneTwoThree/files/assets/154122891/1/border.png deleted file mode 100644 index b3a01b8..0000000 Binary files a/OneTwoThree/files/assets/154122891/1/border.png and /dev/null differ