chunk-66BJ5UTJ.js 549 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129
  1. import {
  2. __commonJS,
  3. __export,
  4. __toESM
  5. } from "./chunk-DC5AMYBS.js";
  6. // node_modules/eventemitter3/index.js
  7. var require_eventemitter3 = __commonJS({
  8. "node_modules/eventemitter3/index.js"(exports, module) {
  9. "use strict";
  10. var has = Object.prototype.hasOwnProperty;
  11. var prefix = "~";
  12. function Events() {
  13. }
  14. if (Object.create) {
  15. Events.prototype = /* @__PURE__ */ Object.create(null);
  16. if (!new Events().__proto__) prefix = false;
  17. }
  18. function EE(fn, context2, once) {
  19. this.fn = fn;
  20. this.context = context2;
  21. this.once = once || false;
  22. }
  23. function addListener(emitter, event, fn, context2, once) {
  24. if (typeof fn !== "function") {
  25. throw new TypeError("The listener must be a function");
  26. }
  27. var listener = new EE(fn, context2 || emitter, once), evt = prefix ? prefix + event : event;
  28. if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
  29. else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
  30. else emitter._events[evt] = [emitter._events[evt], listener];
  31. return emitter;
  32. }
  33. function clearEvent(emitter, evt) {
  34. if (--emitter._eventsCount === 0) emitter._events = new Events();
  35. else delete emitter._events[evt];
  36. }
  37. function EventEmitter() {
  38. this._events = new Events();
  39. this._eventsCount = 0;
  40. }
  41. EventEmitter.prototype.eventNames = function eventNames() {
  42. var names = [], events, name;
  43. if (this._eventsCount === 0) return names;
  44. for (name in events = this._events) {
  45. if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
  46. }
  47. if (Object.getOwnPropertySymbols) {
  48. return names.concat(Object.getOwnPropertySymbols(events));
  49. }
  50. return names;
  51. };
  52. EventEmitter.prototype.listeners = function listeners(event) {
  53. var evt = prefix ? prefix + event : event, handlers = this._events[evt];
  54. if (!handlers) return [];
  55. if (handlers.fn) return [handlers.fn];
  56. for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
  57. ee[i] = handlers[i].fn;
  58. }
  59. return ee;
  60. };
  61. EventEmitter.prototype.listenerCount = function listenerCount(event) {
  62. var evt = prefix ? prefix + event : event, listeners = this._events[evt];
  63. if (!listeners) return 0;
  64. if (listeners.fn) return 1;
  65. return listeners.length;
  66. };
  67. EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
  68. var evt = prefix ? prefix + event : event;
  69. if (!this._events[evt]) return false;
  70. var listeners = this._events[evt], len = arguments.length, args, i;
  71. if (listeners.fn) {
  72. if (listeners.once) this.removeListener(event, listeners.fn, void 0, true);
  73. switch (len) {
  74. case 1:
  75. return listeners.fn.call(listeners.context), true;
  76. case 2:
  77. return listeners.fn.call(listeners.context, a1), true;
  78. case 3:
  79. return listeners.fn.call(listeners.context, a1, a2), true;
  80. case 4:
  81. return listeners.fn.call(listeners.context, a1, a2, a3), true;
  82. case 5:
  83. return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
  84. case 6:
  85. return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
  86. }
  87. for (i = 1, args = new Array(len - 1); i < len; i++) {
  88. args[i - 1] = arguments[i];
  89. }
  90. listeners.fn.apply(listeners.context, args);
  91. } else {
  92. var length = listeners.length, j;
  93. for (i = 0; i < length; i++) {
  94. if (listeners[i].once) this.removeListener(event, listeners[i].fn, void 0, true);
  95. switch (len) {
  96. case 1:
  97. listeners[i].fn.call(listeners[i].context);
  98. break;
  99. case 2:
  100. listeners[i].fn.call(listeners[i].context, a1);
  101. break;
  102. case 3:
  103. listeners[i].fn.call(listeners[i].context, a1, a2);
  104. break;
  105. case 4:
  106. listeners[i].fn.call(listeners[i].context, a1, a2, a3);
  107. break;
  108. default:
  109. if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) {
  110. args[j - 1] = arguments[j];
  111. }
  112. listeners[i].fn.apply(listeners[i].context, args);
  113. }
  114. }
  115. }
  116. return true;
  117. };
  118. EventEmitter.prototype.on = function on(event, fn, context2) {
  119. return addListener(this, event, fn, context2, false);
  120. };
  121. EventEmitter.prototype.once = function once(event, fn, context2) {
  122. return addListener(this, event, fn, context2, true);
  123. };
  124. EventEmitter.prototype.removeListener = function removeListener(event, fn, context2, once) {
  125. var evt = prefix ? prefix + event : event;
  126. if (!this._events[evt]) return this;
  127. if (!fn) {
  128. clearEvent(this, evt);
  129. return this;
  130. }
  131. var listeners = this._events[evt];
  132. if (listeners.fn) {
  133. if (listeners.fn === fn && (!once || listeners.once) && (!context2 || listeners.context === context2)) {
  134. clearEvent(this, evt);
  135. }
  136. } else {
  137. for (var i = 0, events = [], length = listeners.length; i < length; i++) {
  138. if (listeners[i].fn !== fn || once && !listeners[i].once || context2 && listeners[i].context !== context2) {
  139. events.push(listeners[i]);
  140. }
  141. }
  142. if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
  143. else clearEvent(this, evt);
  144. }
  145. return this;
  146. };
  147. EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
  148. var evt;
  149. if (event) {
  150. evt = prefix ? prefix + event : event;
  151. if (this._events[evt]) clearEvent(this, evt);
  152. } else {
  153. this._events = new Events();
  154. this._eventsCount = 0;
  155. }
  156. return this;
  157. };
  158. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  159. EventEmitter.prototype.addListener = EventEmitter.prototype.on;
  160. EventEmitter.prefixed = prefix;
  161. EventEmitter.EventEmitter = EventEmitter;
  162. if ("undefined" !== typeof module) {
  163. module.exports = EventEmitter;
  164. }
  165. }
  166. });
  167. // node_modules/earcut/src/earcut.js
  168. var require_earcut = __commonJS({
  169. "node_modules/earcut/src/earcut.js"(exports, module) {
  170. "use strict";
  171. module.exports = earcut;
  172. module.exports.default = earcut;
  173. function earcut(data, holeIndices, dim) {
  174. dim = dim || 2;
  175. var hasHoles = holeIndices && holeIndices.length, outerLen = hasHoles ? holeIndices[0] * dim : data.length, outerNode = linkedList(data, 0, outerLen, dim, true), triangles = [];
  176. if (!outerNode || outerNode.next === outerNode.prev) return triangles;
  177. var minX, minY, maxX, maxY, x, y, invSize;
  178. if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
  179. if (data.length > 80 * dim) {
  180. minX = maxX = data[0];
  181. minY = maxY = data[1];
  182. for (var i = dim; i < outerLen; i += dim) {
  183. x = data[i];
  184. y = data[i + 1];
  185. if (x < minX) minX = x;
  186. if (y < minY) minY = y;
  187. if (x > maxX) maxX = x;
  188. if (y > maxY) maxY = y;
  189. }
  190. invSize = Math.max(maxX - minX, maxY - minY);
  191. invSize = invSize !== 0 ? 32767 / invSize : 0;
  192. }
  193. earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
  194. return triangles;
  195. }
  196. function linkedList(data, start, end, dim, clockwise) {
  197. var i, last;
  198. if (clockwise === signedArea(data, start, end, dim) > 0) {
  199. for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
  200. } else {
  201. for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
  202. }
  203. if (last && equals(last, last.next)) {
  204. removeNode(last);
  205. last = last.next;
  206. }
  207. return last;
  208. }
  209. function filterPoints(start, end) {
  210. if (!start) return start;
  211. if (!end) end = start;
  212. var p = start, again;
  213. do {
  214. again = false;
  215. if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
  216. removeNode(p);
  217. p = end = p.prev;
  218. if (p === p.next) break;
  219. again = true;
  220. } else {
  221. p = p.next;
  222. }
  223. } while (again || p !== end);
  224. return end;
  225. }
  226. function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
  227. if (!ear) return;
  228. if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
  229. var stop = ear, prev, next;
  230. while (ear.prev !== ear.next) {
  231. prev = ear.prev;
  232. next = ear.next;
  233. if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
  234. triangles.push(prev.i / dim | 0);
  235. triangles.push(ear.i / dim | 0);
  236. triangles.push(next.i / dim | 0);
  237. removeNode(ear);
  238. ear = next.next;
  239. stop = next.next;
  240. continue;
  241. }
  242. ear = next;
  243. if (ear === stop) {
  244. if (!pass) {
  245. earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
  246. } else if (pass === 1) {
  247. ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
  248. earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
  249. } else if (pass === 2) {
  250. splitEarcut(ear, triangles, dim, minX, minY, invSize);
  251. }
  252. break;
  253. }
  254. }
  255. }
  256. function isEar(ear) {
  257. var a = ear.prev, b = ear, c = ear.next;
  258. if (area(a, b, c) >= 0) return false;
  259. var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
  260. var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx, y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy, x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx, y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
  261. var p = c.next;
  262. while (p !== a) {
  263. if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
  264. p = p.next;
  265. }
  266. return true;
  267. }
  268. function isEarHashed(ear, minX, minY, invSize) {
  269. var a = ear.prev, b = ear, c = ear.next;
  270. if (area(a, b, c) >= 0) return false;
  271. var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
  272. var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx, y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy, x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx, y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
  273. var minZ = zOrder(x0, y0, minX, minY, invSize), maxZ = zOrder(x1, y1, minX, minY, invSize);
  274. var p = ear.prevZ, n = ear.nextZ;
  275. while (p && p.z >= minZ && n && n.z <= maxZ) {
  276. if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
  277. p = p.prevZ;
  278. if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
  279. n = n.nextZ;
  280. }
  281. while (p && p.z >= minZ) {
  282. if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
  283. p = p.prevZ;
  284. }
  285. while (n && n.z <= maxZ) {
  286. if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
  287. n = n.nextZ;
  288. }
  289. return true;
  290. }
  291. function cureLocalIntersections(start, triangles, dim) {
  292. var p = start;
  293. do {
  294. var a = p.prev, b = p.next.next;
  295. if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
  296. triangles.push(a.i / dim | 0);
  297. triangles.push(p.i / dim | 0);
  298. triangles.push(b.i / dim | 0);
  299. removeNode(p);
  300. removeNode(p.next);
  301. p = start = b;
  302. }
  303. p = p.next;
  304. } while (p !== start);
  305. return filterPoints(p);
  306. }
  307. function splitEarcut(start, triangles, dim, minX, minY, invSize) {
  308. var a = start;
  309. do {
  310. var b = a.next.next;
  311. while (b !== a.prev) {
  312. if (a.i !== b.i && isValidDiagonal(a, b)) {
  313. var c = splitPolygon(a, b);
  314. a = filterPoints(a, a.next);
  315. c = filterPoints(c, c.next);
  316. earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
  317. earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
  318. return;
  319. }
  320. b = b.next;
  321. }
  322. a = a.next;
  323. } while (a !== start);
  324. }
  325. function eliminateHoles(data, holeIndices, outerNode, dim) {
  326. var queue = [], i, len, start, end, list;
  327. for (i = 0, len = holeIndices.length; i < len; i++) {
  328. start = holeIndices[i] * dim;
  329. end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
  330. list = linkedList(data, start, end, dim, false);
  331. if (list === list.next) list.steiner = true;
  332. queue.push(getLeftmost(list));
  333. }
  334. queue.sort(compareX);
  335. for (i = 0; i < queue.length; i++) {
  336. outerNode = eliminateHole(queue[i], outerNode);
  337. }
  338. return outerNode;
  339. }
  340. function compareX(a, b) {
  341. return a.x - b.x;
  342. }
  343. function eliminateHole(hole, outerNode) {
  344. var bridge = findHoleBridge(hole, outerNode);
  345. if (!bridge) {
  346. return outerNode;
  347. }
  348. var bridgeReverse = splitPolygon(bridge, hole);
  349. filterPoints(bridgeReverse, bridgeReverse.next);
  350. return filterPoints(bridge, bridge.next);
  351. }
  352. function findHoleBridge(hole, outerNode) {
  353. var p = outerNode, hx = hole.x, hy = hole.y, qx = -Infinity, m;
  354. do {
  355. if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
  356. var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
  357. if (x <= hx && x > qx) {
  358. qx = x;
  359. m = p.x < p.next.x ? p : p.next;
  360. if (x === hx) return m;
  361. }
  362. }
  363. p = p.next;
  364. } while (p !== outerNode);
  365. if (!m) return null;
  366. var stop = m, mx = m.x, my = m.y, tanMin = Infinity, tan2;
  367. p = m;
  368. do {
  369. if (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
  370. tan2 = Math.abs(hy - p.y) / (hx - p.x);
  371. if (locallyInside(p, hole) && (tan2 < tanMin || tan2 === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
  372. m = p;
  373. tanMin = tan2;
  374. }
  375. }
  376. p = p.next;
  377. } while (p !== stop);
  378. return m;
  379. }
  380. function sectorContainsSector(m, p) {
  381. return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
  382. }
  383. function indexCurve(start, minX, minY, invSize) {
  384. var p = start;
  385. do {
  386. if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);
  387. p.prevZ = p.prev;
  388. p.nextZ = p.next;
  389. p = p.next;
  390. } while (p !== start);
  391. p.prevZ.nextZ = null;
  392. p.prevZ = null;
  393. sortLinked(p);
  394. }
  395. function sortLinked(list) {
  396. var i, p, q, e, tail, numMerges, pSize, qSize, inSize = 1;
  397. do {
  398. p = list;
  399. list = null;
  400. tail = null;
  401. numMerges = 0;
  402. while (p) {
  403. numMerges++;
  404. q = p;
  405. pSize = 0;
  406. for (i = 0; i < inSize; i++) {
  407. pSize++;
  408. q = q.nextZ;
  409. if (!q) break;
  410. }
  411. qSize = inSize;
  412. while (pSize > 0 || qSize > 0 && q) {
  413. if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
  414. e = p;
  415. p = p.nextZ;
  416. pSize--;
  417. } else {
  418. e = q;
  419. q = q.nextZ;
  420. qSize--;
  421. }
  422. if (tail) tail.nextZ = e;
  423. else list = e;
  424. e.prevZ = tail;
  425. tail = e;
  426. }
  427. p = q;
  428. }
  429. tail.nextZ = null;
  430. inSize *= 2;
  431. } while (numMerges > 1);
  432. return list;
  433. }
  434. function zOrder(x, y, minX, minY, invSize) {
  435. x = (x - minX) * invSize | 0;
  436. y = (y - minY) * invSize | 0;
  437. x = (x | x << 8) & 16711935;
  438. x = (x | x << 4) & 252645135;
  439. x = (x | x << 2) & 858993459;
  440. x = (x | x << 1) & 1431655765;
  441. y = (y | y << 8) & 16711935;
  442. y = (y | y << 4) & 252645135;
  443. y = (y | y << 2) & 858993459;
  444. y = (y | y << 1) & 1431655765;
  445. return x | y << 1;
  446. }
  447. function getLeftmost(start) {
  448. var p = start, leftmost = start;
  449. do {
  450. if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y) leftmost = p;
  451. p = p.next;
  452. } while (p !== start);
  453. return leftmost;
  454. }
  455. function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
  456. return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
  457. }
  458. function isValidDiagonal(a, b) {
  459. return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
  460. (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
  461. (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
  462. equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
  463. }
  464. function area(p, q, r) {
  465. return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
  466. }
  467. function equals(p1, p2) {
  468. return p1.x === p2.x && p1.y === p2.y;
  469. }
  470. function intersects(p1, q1, p2, q2) {
  471. var o1 = sign2(area(p1, q1, p2));
  472. var o2 = sign2(area(p1, q1, q2));
  473. var o3 = sign2(area(p2, q2, p1));
  474. var o4 = sign2(area(p2, q2, q1));
  475. if (o1 !== o2 && o3 !== o4) return true;
  476. if (o1 === 0 && onSegment(p1, p2, q1)) return true;
  477. if (o2 === 0 && onSegment(p1, q2, q1)) return true;
  478. if (o3 === 0 && onSegment(p2, p1, q2)) return true;
  479. if (o4 === 0 && onSegment(p2, q1, q2)) return true;
  480. return false;
  481. }
  482. function onSegment(p, q, r) {
  483. return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
  484. }
  485. function sign2(num) {
  486. return num > 0 ? 1 : num < 0 ? -1 : 0;
  487. }
  488. function intersectsPolygon(a, b) {
  489. var p = a;
  490. do {
  491. if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b)) return true;
  492. p = p.next;
  493. } while (p !== a);
  494. return false;
  495. }
  496. function locallyInside(a, b) {
  497. return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
  498. }
  499. function middleInside(a, b) {
  500. var p = a, inside = false, px = (a.x + b.x) / 2, py = (a.y + b.y) / 2;
  501. do {
  502. if (p.y > py !== p.next.y > py && p.next.y !== p.y && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)
  503. inside = !inside;
  504. p = p.next;
  505. } while (p !== a);
  506. return inside;
  507. }
  508. function splitPolygon(a, b) {
  509. var a2 = new Node(a.i, a.x, a.y), b2 = new Node(b.i, b.x, b.y), an = a.next, bp = b.prev;
  510. a.next = b;
  511. b.prev = a;
  512. a2.next = an;
  513. an.prev = a2;
  514. b2.next = a2;
  515. a2.prev = b2;
  516. bp.next = b2;
  517. b2.prev = bp;
  518. return b2;
  519. }
  520. function insertNode(i, x, y, last) {
  521. var p = new Node(i, x, y);
  522. if (!last) {
  523. p.prev = p;
  524. p.next = p;
  525. } else {
  526. p.next = last.next;
  527. p.prev = last;
  528. last.next.prev = p;
  529. last.next = p;
  530. }
  531. return p;
  532. }
  533. function removeNode(p) {
  534. p.next.prev = p.prev;
  535. p.prev.next = p.next;
  536. if (p.prevZ) p.prevZ.nextZ = p.nextZ;
  537. if (p.nextZ) p.nextZ.prevZ = p.prevZ;
  538. }
  539. function Node(i, x, y) {
  540. this.i = i;
  541. this.x = x;
  542. this.y = y;
  543. this.prev = null;
  544. this.next = null;
  545. this.z = 0;
  546. this.prevZ = null;
  547. this.nextZ = null;
  548. this.steiner = false;
  549. }
  550. earcut.deviation = function(data, holeIndices, dim, triangles) {
  551. var hasHoles = holeIndices && holeIndices.length;
  552. var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
  553. var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
  554. if (hasHoles) {
  555. for (var i = 0, len = holeIndices.length; i < len; i++) {
  556. var start = holeIndices[i] * dim;
  557. var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
  558. polygonArea -= Math.abs(signedArea(data, start, end, dim));
  559. }
  560. }
  561. var trianglesArea = 0;
  562. for (i = 0; i < triangles.length; i += 3) {
  563. var a = triangles[i] * dim;
  564. var b = triangles[i + 1] * dim;
  565. var c = triangles[i + 2] * dim;
  566. trianglesArea += Math.abs(
  567. (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - (data[a] - data[b]) * (data[c + 1] - data[a + 1])
  568. );
  569. }
  570. return polygonArea === 0 && trianglesArea === 0 ? 0 : Math.abs((trianglesArea - polygonArea) / polygonArea);
  571. };
  572. function signedArea(data, start, end, dim) {
  573. var sum = 0;
  574. for (var i = start, j = end - dim; i < end; i += dim) {
  575. sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
  576. j = i;
  577. }
  578. return sum;
  579. }
  580. earcut.flatten = function(data) {
  581. var dim = data[0][0].length, result = { vertices: [], holes: [], dimensions: dim }, holeIndex = 0;
  582. for (var i = 0; i < data.length; i++) {
  583. for (var j = 0; j < data[i].length; j++) {
  584. for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
  585. }
  586. if (i > 0) {
  587. holeIndex += data[i - 1].length;
  588. result.holes.push(holeIndex);
  589. }
  590. }
  591. return result;
  592. };
  593. }
  594. });
  595. // node_modules/punycode/punycode.js
  596. var require_punycode = __commonJS({
  597. "node_modules/punycode/punycode.js"(exports, module) {
  598. (function(root) {
  599. var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
  600. var freeModule = typeof module == "object" && module && !module.nodeType && module;
  601. var freeGlobal = typeof global == "object" && global;
  602. if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {
  603. root = freeGlobal;
  604. }
  605. var punycode, maxInt = 2147483647, base = 36, tMin = 1, tMax = 26, skew = 38, damp = 700, initialBias = 72, initialN = 128, delimiter = "-", regexPunycode = /^xn--/, regexNonASCII = /[^\x20-\x7E]/, regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, errors = {
  606. "overflow": "Overflow: input needs wider integers to process",
  607. "not-basic": "Illegal input >= 0x80 (not a basic code point)",
  608. "invalid-input": "Invalid input"
  609. }, baseMinusTMin = base - tMin, floor = Math.floor, stringFromCharCode = String.fromCharCode, key;
  610. function error(type) {
  611. throw new RangeError(errors[type]);
  612. }
  613. function map3(array, fn) {
  614. var length = array.length;
  615. var result = [];
  616. while (length--) {
  617. result[length] = fn(array[length]);
  618. }
  619. return result;
  620. }
  621. function mapDomain(string, fn) {
  622. var parts = string.split("@");
  623. var result = "";
  624. if (parts.length > 1) {
  625. result = parts[0] + "@";
  626. string = parts[1];
  627. }
  628. string = string.replace(regexSeparators, ".");
  629. var labels = string.split(".");
  630. var encoded = map3(labels, fn).join(".");
  631. return result + encoded;
  632. }
  633. function ucs2decode(string) {
  634. var output = [], counter = 0, length = string.length, value, extra;
  635. while (counter < length) {
  636. value = string.charCodeAt(counter++);
  637. if (value >= 55296 && value <= 56319 && counter < length) {
  638. extra = string.charCodeAt(counter++);
  639. if ((extra & 64512) == 56320) {
  640. output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
  641. } else {
  642. output.push(value);
  643. counter--;
  644. }
  645. } else {
  646. output.push(value);
  647. }
  648. }
  649. return output;
  650. }
  651. function ucs2encode(array) {
  652. return map3(array, function(value) {
  653. var output = "";
  654. if (value > 65535) {
  655. value -= 65536;
  656. output += stringFromCharCode(value >>> 10 & 1023 | 55296);
  657. value = 56320 | value & 1023;
  658. }
  659. output += stringFromCharCode(value);
  660. return output;
  661. }).join("");
  662. }
  663. function basicToDigit(codePoint) {
  664. if (codePoint - 48 < 10) {
  665. return codePoint - 22;
  666. }
  667. if (codePoint - 65 < 26) {
  668. return codePoint - 65;
  669. }
  670. if (codePoint - 97 < 26) {
  671. return codePoint - 97;
  672. }
  673. return base;
  674. }
  675. function digitToBasic(digit, flag) {
  676. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  677. }
  678. function adapt(delta, numPoints, firstTime) {
  679. var k = 0;
  680. delta = firstTime ? floor(delta / damp) : delta >> 1;
  681. delta += floor(delta / numPoints);
  682. for (; delta > baseMinusTMin * tMax >> 1; k += base) {
  683. delta = floor(delta / baseMinusTMin);
  684. }
  685. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  686. }
  687. function decode(input) {
  688. var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t, baseMinusT;
  689. basic = input.lastIndexOf(delimiter);
  690. if (basic < 0) {
  691. basic = 0;
  692. }
  693. for (j = 0; j < basic; ++j) {
  694. if (input.charCodeAt(j) >= 128) {
  695. error("not-basic");
  696. }
  697. output.push(input.charCodeAt(j));
  698. }
  699. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
  700. for (oldi = i, w = 1, k = base; ; k += base) {
  701. if (index >= inputLength) {
  702. error("invalid-input");
  703. }
  704. digit = basicToDigit(input.charCodeAt(index++));
  705. if (digit >= base || digit > floor((maxInt - i) / w)) {
  706. error("overflow");
  707. }
  708. i += digit * w;
  709. t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  710. if (digit < t) {
  711. break;
  712. }
  713. baseMinusT = base - t;
  714. if (w > floor(maxInt / baseMinusT)) {
  715. error("overflow");
  716. }
  717. w *= baseMinusT;
  718. }
  719. out = output.length + 1;
  720. bias = adapt(i - oldi, out, oldi == 0);
  721. if (floor(i / out) > maxInt - n) {
  722. error("overflow");
  723. }
  724. n += floor(i / out);
  725. i %= out;
  726. output.splice(i++, 0, n);
  727. }
  728. return ucs2encode(output);
  729. }
  730. function encode(input) {
  731. var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [], inputLength, handledCPCountPlusOne, baseMinusT, qMinusT;
  732. input = ucs2decode(input);
  733. inputLength = input.length;
  734. n = initialN;
  735. delta = 0;
  736. bias = initialBias;
  737. for (j = 0; j < inputLength; ++j) {
  738. currentValue = input[j];
  739. if (currentValue < 128) {
  740. output.push(stringFromCharCode(currentValue));
  741. }
  742. }
  743. handledCPCount = basicLength = output.length;
  744. if (basicLength) {
  745. output.push(delimiter);
  746. }
  747. while (handledCPCount < inputLength) {
  748. for (m = maxInt, j = 0; j < inputLength; ++j) {
  749. currentValue = input[j];
  750. if (currentValue >= n && currentValue < m) {
  751. m = currentValue;
  752. }
  753. }
  754. handledCPCountPlusOne = handledCPCount + 1;
  755. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  756. error("overflow");
  757. }
  758. delta += (m - n) * handledCPCountPlusOne;
  759. n = m;
  760. for (j = 0; j < inputLength; ++j) {
  761. currentValue = input[j];
  762. if (currentValue < n && ++delta > maxInt) {
  763. error("overflow");
  764. }
  765. if (currentValue == n) {
  766. for (q = delta, k = base; ; k += base) {
  767. t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
  768. if (q < t) {
  769. break;
  770. }
  771. qMinusT = q - t;
  772. baseMinusT = base - t;
  773. output.push(
  774. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  775. );
  776. q = floor(qMinusT / baseMinusT);
  777. }
  778. output.push(stringFromCharCode(digitToBasic(q, 0)));
  779. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  780. delta = 0;
  781. ++handledCPCount;
  782. }
  783. }
  784. ++delta;
  785. ++n;
  786. }
  787. return output.join("");
  788. }
  789. function toUnicode(input) {
  790. return mapDomain(input, function(string) {
  791. return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
  792. });
  793. }
  794. function toASCII(input) {
  795. return mapDomain(input, function(string) {
  796. return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
  797. });
  798. }
  799. punycode = {
  800. /**
  801. * A string representing the current Punycode.js version number.
  802. * @memberOf punycode
  803. * @type String
  804. */
  805. "version": "1.4.1",
  806. /**
  807. * An object of methods to convert from JavaScript's internal character
  808. * representation (UCS-2) to Unicode code points, and back.
  809. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  810. * @memberOf punycode
  811. * @type Object
  812. */
  813. "ucs2": {
  814. "decode": ucs2decode,
  815. "encode": ucs2encode
  816. },
  817. "decode": decode,
  818. "encode": encode,
  819. "toASCII": toASCII,
  820. "toUnicode": toUnicode
  821. };
  822. if (typeof define == "function" && typeof define.amd == "object" && define.amd) {
  823. define("punycode", function() {
  824. return punycode;
  825. });
  826. } else if (freeExports && freeModule) {
  827. if (module.exports == freeExports) {
  828. freeModule.exports = punycode;
  829. } else {
  830. for (key in punycode) {
  831. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  832. }
  833. }
  834. } else {
  835. root.punycode = punycode;
  836. }
  837. })(exports);
  838. }
  839. });
  840. // node_modules/es-errors/type.js
  841. var require_type = __commonJS({
  842. "node_modules/es-errors/type.js"(exports, module) {
  843. "use strict";
  844. module.exports = TypeError;
  845. }
  846. });
  847. // (disabled):node_modules/object-inspect/util.inspect
  848. var require_util = __commonJS({
  849. "(disabled):node_modules/object-inspect/util.inspect"() {
  850. }
  851. });
  852. // node_modules/object-inspect/index.js
  853. var require_object_inspect = __commonJS({
  854. "node_modules/object-inspect/index.js"(exports, module) {
  855. var hasMap = typeof Map === "function" && Map.prototype;
  856. var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, "size") : null;
  857. var mapSize2 = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === "function" ? mapSizeDescriptor.get : null;
  858. var mapForEach = hasMap && Map.prototype.forEach;
  859. var hasSet = typeof Set === "function" && Set.prototype;
  860. var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, "size") : null;
  861. var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === "function" ? setSizeDescriptor.get : null;
  862. var setForEach = hasSet && Set.prototype.forEach;
  863. var hasWeakMap = typeof WeakMap === "function" && WeakMap.prototype;
  864. var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
  865. var hasWeakSet = typeof WeakSet === "function" && WeakSet.prototype;
  866. var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
  867. var hasWeakRef = typeof WeakRef === "function" && WeakRef.prototype;
  868. var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
  869. var booleanValueOf = Boolean.prototype.valueOf;
  870. var objectToString = Object.prototype.toString;
  871. var functionToString = Function.prototype.toString;
  872. var $match = String.prototype.match;
  873. var $slice = String.prototype.slice;
  874. var $replace = String.prototype.replace;
  875. var $toUpperCase = String.prototype.toUpperCase;
  876. var $toLowerCase = String.prototype.toLowerCase;
  877. var $test = RegExp.prototype.test;
  878. var $concat = Array.prototype.concat;
  879. var $join = Array.prototype.join;
  880. var $arrSlice = Array.prototype.slice;
  881. var $floor = Math.floor;
  882. var bigIntValueOf = typeof BigInt === "function" ? BigInt.prototype.valueOf : null;
  883. var gOPS = Object.getOwnPropertySymbols;
  884. var symToString = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? Symbol.prototype.toString : null;
  885. var hasShammedSymbols = typeof Symbol === "function" && typeof Symbol.iterator === "object";
  886. var toStringTag = typeof Symbol === "function" && Symbol.toStringTag && (typeof Symbol.toStringTag === hasShammedSymbols ? "object" : "symbol") ? Symbol.toStringTag : null;
  887. var isEnumerable = Object.prototype.propertyIsEnumerable;
  888. var gPO = (typeof Reflect === "function" ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function(O) {
  889. return O.__proto__;
  890. } : null);
  891. function addNumericSeparator(num, str) {
  892. if (num === Infinity || num === -Infinity || num !== num || num && num > -1e3 && num < 1e3 || $test.call(/e/, str)) {
  893. return str;
  894. }
  895. var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
  896. if (typeof num === "number") {
  897. var int = num < 0 ? -$floor(-num) : $floor(num);
  898. if (int !== num) {
  899. var intStr = String(int);
  900. var dec = $slice.call(str, intStr.length + 1);
  901. return $replace.call(intStr, sepRegex, "$&_") + "." + $replace.call($replace.call(dec, /([0-9]{3})/g, "$&_"), /_$/, "");
  902. }
  903. }
  904. return $replace.call(str, sepRegex, "$&_");
  905. }
  906. var utilInspect = require_util();
  907. var inspectCustom = utilInspect.custom;
  908. var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
  909. var quotes = {
  910. __proto__: null,
  911. "double": '"',
  912. single: "'"
  913. };
  914. var quoteREs = {
  915. __proto__: null,
  916. "double": /(["\\])/g,
  917. single: /(['\\])/g
  918. };
  919. module.exports = function inspect_(obj, options, depth, seen) {
  920. var opts = options || {};
  921. if (has(opts, "quoteStyle") && !has(quotes, opts.quoteStyle)) {
  922. throw new TypeError('option "quoteStyle" must be "single" or "double"');
  923. }
  924. if (has(opts, "maxStringLength") && (typeof opts.maxStringLength === "number" ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity : opts.maxStringLength !== null)) {
  925. throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
  926. }
  927. var customInspect = has(opts, "customInspect") ? opts.customInspect : true;
  928. if (typeof customInspect !== "boolean" && customInspect !== "symbol") {
  929. throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");
  930. }
  931. if (has(opts, "indent") && opts.indent !== null && opts.indent !== " " && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)) {
  932. throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
  933. }
  934. if (has(opts, "numericSeparator") && typeof opts.numericSeparator !== "boolean") {
  935. throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
  936. }
  937. var numericSeparator = opts.numericSeparator;
  938. if (typeof obj === "undefined") {
  939. return "undefined";
  940. }
  941. if (obj === null) {
  942. return "null";
  943. }
  944. if (typeof obj === "boolean") {
  945. return obj ? "true" : "false";
  946. }
  947. if (typeof obj === "string") {
  948. return inspectString(obj, opts);
  949. }
  950. if (typeof obj === "number") {
  951. if (obj === 0) {
  952. return Infinity / obj > 0 ? "0" : "-0";
  953. }
  954. var str = String(obj);
  955. return numericSeparator ? addNumericSeparator(obj, str) : str;
  956. }
  957. if (typeof obj === "bigint") {
  958. var bigIntStr = String(obj) + "n";
  959. return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
  960. }
  961. var maxDepth = typeof opts.depth === "undefined" ? 5 : opts.depth;
  962. if (typeof depth === "undefined") {
  963. depth = 0;
  964. }
  965. if (depth >= maxDepth && maxDepth > 0 && typeof obj === "object") {
  966. return isArray(obj) ? "[Array]" : "[Object]";
  967. }
  968. var indent = getIndent(opts, depth);
  969. if (typeof seen === "undefined") {
  970. seen = [];
  971. } else if (indexOf(seen, obj) >= 0) {
  972. return "[Circular]";
  973. }
  974. function inspect(value, from, noIndent) {
  975. if (from) {
  976. seen = $arrSlice.call(seen);
  977. seen.push(from);
  978. }
  979. if (noIndent) {
  980. var newOpts = {
  981. depth: opts.depth
  982. };
  983. if (has(opts, "quoteStyle")) {
  984. newOpts.quoteStyle = opts.quoteStyle;
  985. }
  986. return inspect_(value, newOpts, depth + 1, seen);
  987. }
  988. return inspect_(value, opts, depth + 1, seen);
  989. }
  990. if (typeof obj === "function" && !isRegExp(obj)) {
  991. var name = nameOf(obj);
  992. var keys = arrObjKeys(obj, inspect);
  993. return "[Function" + (name ? ": " + name : " (anonymous)") + "]" + (keys.length > 0 ? " { " + $join.call(keys, ", ") + " }" : "");
  994. }
  995. if (isSymbol(obj)) {
  996. var symString = hasShammedSymbols ? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, "$1") : symToString.call(obj);
  997. return typeof obj === "object" && !hasShammedSymbols ? markBoxed(symString) : symString;
  998. }
  999. if (isElement(obj)) {
  1000. var s = "<" + $toLowerCase.call(String(obj.nodeName));
  1001. var attrs = obj.attributes || [];
  1002. for (var i = 0; i < attrs.length; i++) {
  1003. s += " " + attrs[i].name + "=" + wrapQuotes(quote(attrs[i].value), "double", opts);
  1004. }
  1005. s += ">";
  1006. if (obj.childNodes && obj.childNodes.length) {
  1007. s += "...";
  1008. }
  1009. s += "</" + $toLowerCase.call(String(obj.nodeName)) + ">";
  1010. return s;
  1011. }
  1012. if (isArray(obj)) {
  1013. if (obj.length === 0) {
  1014. return "[]";
  1015. }
  1016. var xs = arrObjKeys(obj, inspect);
  1017. if (indent && !singleLineValues(xs)) {
  1018. return "[" + indentedJoin(xs, indent) + "]";
  1019. }
  1020. return "[ " + $join.call(xs, ", ") + " ]";
  1021. }
  1022. if (isError(obj)) {
  1023. var parts = arrObjKeys(obj, inspect);
  1024. if (!("cause" in Error.prototype) && "cause" in obj && !isEnumerable.call(obj, "cause")) {
  1025. return "{ [" + String(obj) + "] " + $join.call($concat.call("[cause]: " + inspect(obj.cause), parts), ", ") + " }";
  1026. }
  1027. if (parts.length === 0) {
  1028. return "[" + String(obj) + "]";
  1029. }
  1030. return "{ [" + String(obj) + "] " + $join.call(parts, ", ") + " }";
  1031. }
  1032. if (typeof obj === "object" && customInspect) {
  1033. if (inspectSymbol && typeof obj[inspectSymbol] === "function" && utilInspect) {
  1034. return utilInspect(obj, { depth: maxDepth - depth });
  1035. } else if (customInspect !== "symbol" && typeof obj.inspect === "function") {
  1036. return obj.inspect();
  1037. }
  1038. }
  1039. if (isMap(obj)) {
  1040. var mapParts = [];
  1041. if (mapForEach) {
  1042. mapForEach.call(obj, function(value, key) {
  1043. mapParts.push(inspect(key, obj, true) + " => " + inspect(value, obj));
  1044. });
  1045. }
  1046. return collectionOf("Map", mapSize2.call(obj), mapParts, indent);
  1047. }
  1048. if (isSet(obj)) {
  1049. var setParts = [];
  1050. if (setForEach) {
  1051. setForEach.call(obj, function(value) {
  1052. setParts.push(inspect(value, obj));
  1053. });
  1054. }
  1055. return collectionOf("Set", setSize.call(obj), setParts, indent);
  1056. }
  1057. if (isWeakMap(obj)) {
  1058. return weakCollectionOf("WeakMap");
  1059. }
  1060. if (isWeakSet(obj)) {
  1061. return weakCollectionOf("WeakSet");
  1062. }
  1063. if (isWeakRef(obj)) {
  1064. return weakCollectionOf("WeakRef");
  1065. }
  1066. if (isNumber(obj)) {
  1067. return markBoxed(inspect(Number(obj)));
  1068. }
  1069. if (isBigInt(obj)) {
  1070. return markBoxed(inspect(bigIntValueOf.call(obj)));
  1071. }
  1072. if (isBoolean(obj)) {
  1073. return markBoxed(booleanValueOf.call(obj));
  1074. }
  1075. if (isString(obj)) {
  1076. return markBoxed(inspect(String(obj)));
  1077. }
  1078. if (typeof window !== "undefined" && obj === window) {
  1079. return "{ [object Window] }";
  1080. }
  1081. if (typeof globalThis !== "undefined" && obj === globalThis || typeof global !== "undefined" && obj === global) {
  1082. return "{ [object globalThis] }";
  1083. }
  1084. if (!isDate(obj) && !isRegExp(obj)) {
  1085. var ys = arrObjKeys(obj, inspect);
  1086. var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
  1087. var protoTag = obj instanceof Object ? "" : "null prototype";
  1088. var stringTag = !isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
  1089. var constructorTag = isPlainObject || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
  1090. var tag = constructorTag + (stringTag || protoTag ? "[" + $join.call($concat.call([], stringTag || [], protoTag || []), ": ") + "] " : "");
  1091. if (ys.length === 0) {
  1092. return tag + "{}";
  1093. }
  1094. if (indent) {
  1095. return tag + "{" + indentedJoin(ys, indent) + "}";
  1096. }
  1097. return tag + "{ " + $join.call(ys, ", ") + " }";
  1098. }
  1099. return String(obj);
  1100. };
  1101. function wrapQuotes(s, defaultStyle, opts) {
  1102. var style = opts.quoteStyle || defaultStyle;
  1103. var quoteChar = quotes[style];
  1104. return quoteChar + s + quoteChar;
  1105. }
  1106. function quote(s) {
  1107. return $replace.call(String(s), /"/g, "&quot;");
  1108. }
  1109. function canTrustToString(obj) {
  1110. return !toStringTag || !(typeof obj === "object" && (toStringTag in obj || typeof obj[toStringTag] !== "undefined"));
  1111. }
  1112. function isArray(obj) {
  1113. return toStr(obj) === "[object Array]" && canTrustToString(obj);
  1114. }
  1115. function isDate(obj) {
  1116. return toStr(obj) === "[object Date]" && canTrustToString(obj);
  1117. }
  1118. function isRegExp(obj) {
  1119. return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
  1120. }
  1121. function isError(obj) {
  1122. return toStr(obj) === "[object Error]" && canTrustToString(obj);
  1123. }
  1124. function isString(obj) {
  1125. return toStr(obj) === "[object String]" && canTrustToString(obj);
  1126. }
  1127. function isNumber(obj) {
  1128. return toStr(obj) === "[object Number]" && canTrustToString(obj);
  1129. }
  1130. function isBoolean(obj) {
  1131. return toStr(obj) === "[object Boolean]" && canTrustToString(obj);
  1132. }
  1133. function isSymbol(obj) {
  1134. if (hasShammedSymbols) {
  1135. return obj && typeof obj === "object" && obj instanceof Symbol;
  1136. }
  1137. if (typeof obj === "symbol") {
  1138. return true;
  1139. }
  1140. if (!obj || typeof obj !== "object" || !symToString) {
  1141. return false;
  1142. }
  1143. try {
  1144. symToString.call(obj);
  1145. return true;
  1146. } catch (e) {
  1147. }
  1148. return false;
  1149. }
  1150. function isBigInt(obj) {
  1151. if (!obj || typeof obj !== "object" || !bigIntValueOf) {
  1152. return false;
  1153. }
  1154. try {
  1155. bigIntValueOf.call(obj);
  1156. return true;
  1157. } catch (e) {
  1158. }
  1159. return false;
  1160. }
  1161. var hasOwn = Object.prototype.hasOwnProperty || function(key) {
  1162. return key in this;
  1163. };
  1164. function has(obj, key) {
  1165. return hasOwn.call(obj, key);
  1166. }
  1167. function toStr(obj) {
  1168. return objectToString.call(obj);
  1169. }
  1170. function nameOf(f) {
  1171. if (f.name) {
  1172. return f.name;
  1173. }
  1174. var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
  1175. if (m) {
  1176. return m[1];
  1177. }
  1178. return null;
  1179. }
  1180. function indexOf(xs, x) {
  1181. if (xs.indexOf) {
  1182. return xs.indexOf(x);
  1183. }
  1184. for (var i = 0, l = xs.length; i < l; i++) {
  1185. if (xs[i] === x) {
  1186. return i;
  1187. }
  1188. }
  1189. return -1;
  1190. }
  1191. function isMap(x) {
  1192. if (!mapSize2 || !x || typeof x !== "object") {
  1193. return false;
  1194. }
  1195. try {
  1196. mapSize2.call(x);
  1197. try {
  1198. setSize.call(x);
  1199. } catch (s) {
  1200. return true;
  1201. }
  1202. return x instanceof Map;
  1203. } catch (e) {
  1204. }
  1205. return false;
  1206. }
  1207. function isWeakMap(x) {
  1208. if (!weakMapHas || !x || typeof x !== "object") {
  1209. return false;
  1210. }
  1211. try {
  1212. weakMapHas.call(x, weakMapHas);
  1213. try {
  1214. weakSetHas.call(x, weakSetHas);
  1215. } catch (s) {
  1216. return true;
  1217. }
  1218. return x instanceof WeakMap;
  1219. } catch (e) {
  1220. }
  1221. return false;
  1222. }
  1223. function isWeakRef(x) {
  1224. if (!weakRefDeref || !x || typeof x !== "object") {
  1225. return false;
  1226. }
  1227. try {
  1228. weakRefDeref.call(x);
  1229. return true;
  1230. } catch (e) {
  1231. }
  1232. return false;
  1233. }
  1234. function isSet(x) {
  1235. if (!setSize || !x || typeof x !== "object") {
  1236. return false;
  1237. }
  1238. try {
  1239. setSize.call(x);
  1240. try {
  1241. mapSize2.call(x);
  1242. } catch (m) {
  1243. return true;
  1244. }
  1245. return x instanceof Set;
  1246. } catch (e) {
  1247. }
  1248. return false;
  1249. }
  1250. function isWeakSet(x) {
  1251. if (!weakSetHas || !x || typeof x !== "object") {
  1252. return false;
  1253. }
  1254. try {
  1255. weakSetHas.call(x, weakSetHas);
  1256. try {
  1257. weakMapHas.call(x, weakMapHas);
  1258. } catch (s) {
  1259. return true;
  1260. }
  1261. return x instanceof WeakSet;
  1262. } catch (e) {
  1263. }
  1264. return false;
  1265. }
  1266. function isElement(x) {
  1267. if (!x || typeof x !== "object") {
  1268. return false;
  1269. }
  1270. if (typeof HTMLElement !== "undefined" && x instanceof HTMLElement) {
  1271. return true;
  1272. }
  1273. return typeof x.nodeName === "string" && typeof x.getAttribute === "function";
  1274. }
  1275. function inspectString(str, opts) {
  1276. if (str.length > opts.maxStringLength) {
  1277. var remaining = str.length - opts.maxStringLength;
  1278. var trailer = "... " + remaining + " more character" + (remaining > 1 ? "s" : "");
  1279. return inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer;
  1280. }
  1281. var quoteRE = quoteREs[opts.quoteStyle || "single"];
  1282. quoteRE.lastIndex = 0;
  1283. var s = $replace.call($replace.call(str, quoteRE, "\\$1"), /[\x00-\x1f]/g, lowbyte);
  1284. return wrapQuotes(s, "single", opts);
  1285. }
  1286. function lowbyte(c) {
  1287. var n = c.charCodeAt(0);
  1288. var x = {
  1289. 8: "b",
  1290. 9: "t",
  1291. 10: "n",
  1292. 12: "f",
  1293. 13: "r"
  1294. }[n];
  1295. if (x) {
  1296. return "\\" + x;
  1297. }
  1298. return "\\x" + (n < 16 ? "0" : "") + $toUpperCase.call(n.toString(16));
  1299. }
  1300. function markBoxed(str) {
  1301. return "Object(" + str + ")";
  1302. }
  1303. function weakCollectionOf(type) {
  1304. return type + " { ? }";
  1305. }
  1306. function collectionOf(type, size, entries, indent) {
  1307. var joinedEntries = indent ? indentedJoin(entries, indent) : $join.call(entries, ", ");
  1308. return type + " (" + size + ") {" + joinedEntries + "}";
  1309. }
  1310. function singleLineValues(xs) {
  1311. for (var i = 0; i < xs.length; i++) {
  1312. if (indexOf(xs[i], "\n") >= 0) {
  1313. return false;
  1314. }
  1315. }
  1316. return true;
  1317. }
  1318. function getIndent(opts, depth) {
  1319. var baseIndent;
  1320. if (opts.indent === " ") {
  1321. baseIndent = " ";
  1322. } else if (typeof opts.indent === "number" && opts.indent > 0) {
  1323. baseIndent = $join.call(Array(opts.indent + 1), " ");
  1324. } else {
  1325. return null;
  1326. }
  1327. return {
  1328. base: baseIndent,
  1329. prev: $join.call(Array(depth + 1), baseIndent)
  1330. };
  1331. }
  1332. function indentedJoin(xs, indent) {
  1333. if (xs.length === 0) {
  1334. return "";
  1335. }
  1336. var lineJoiner = "\n" + indent.prev + indent.base;
  1337. return lineJoiner + $join.call(xs, "," + lineJoiner) + "\n" + indent.prev;
  1338. }
  1339. function arrObjKeys(obj, inspect) {
  1340. var isArr = isArray(obj);
  1341. var xs = [];
  1342. if (isArr) {
  1343. xs.length = obj.length;
  1344. for (var i = 0; i < obj.length; i++) {
  1345. xs[i] = has(obj, i) ? inspect(obj[i], obj) : "";
  1346. }
  1347. }
  1348. var syms = typeof gOPS === "function" ? gOPS(obj) : [];
  1349. var symMap;
  1350. if (hasShammedSymbols) {
  1351. symMap = {};
  1352. for (var k = 0; k < syms.length; k++) {
  1353. symMap["$" + syms[k]] = syms[k];
  1354. }
  1355. }
  1356. for (var key in obj) {
  1357. if (!has(obj, key)) {
  1358. continue;
  1359. }
  1360. if (isArr && String(Number(key)) === key && key < obj.length) {
  1361. continue;
  1362. }
  1363. if (hasShammedSymbols && symMap["$" + key] instanceof Symbol) {
  1364. continue;
  1365. } else if ($test.call(/[^\w$]/, key)) {
  1366. xs.push(inspect(key, obj) + ": " + inspect(obj[key], obj));
  1367. } else {
  1368. xs.push(key + ": " + inspect(obj[key], obj));
  1369. }
  1370. }
  1371. if (typeof gOPS === "function") {
  1372. for (var j = 0; j < syms.length; j++) {
  1373. if (isEnumerable.call(obj, syms[j])) {
  1374. xs.push("[" + inspect(syms[j]) + "]: " + inspect(obj[syms[j]], obj));
  1375. }
  1376. }
  1377. }
  1378. return xs;
  1379. }
  1380. }
  1381. });
  1382. // node_modules/side-channel-list/index.js
  1383. var require_side_channel_list = __commonJS({
  1384. "node_modules/side-channel-list/index.js"(exports, module) {
  1385. "use strict";
  1386. var inspect = require_object_inspect();
  1387. var $TypeError = require_type();
  1388. var listGetNode = function(list, key, isDelete) {
  1389. var prev = list;
  1390. var curr;
  1391. for (; (curr = prev.next) != null; prev = curr) {
  1392. if (curr.key === key) {
  1393. prev.next = curr.next;
  1394. if (!isDelete) {
  1395. curr.next = /** @type {NonNullable<typeof list.next>} */
  1396. list.next;
  1397. list.next = curr;
  1398. }
  1399. return curr;
  1400. }
  1401. }
  1402. };
  1403. var listGet = function(objects, key) {
  1404. if (!objects) {
  1405. return void 0;
  1406. }
  1407. var node = listGetNode(objects, key);
  1408. return node && node.value;
  1409. };
  1410. var listSet = function(objects, key, value) {
  1411. var node = listGetNode(objects, key);
  1412. if (node) {
  1413. node.value = value;
  1414. } else {
  1415. objects.next = /** @type {import('./list.d.ts').ListNode<typeof value, typeof key>} */
  1416. {
  1417. // eslint-disable-line no-param-reassign, no-extra-parens
  1418. key,
  1419. next: objects.next,
  1420. value
  1421. };
  1422. }
  1423. };
  1424. var listHas = function(objects, key) {
  1425. if (!objects) {
  1426. return false;
  1427. }
  1428. return !!listGetNode(objects, key);
  1429. };
  1430. var listDelete = function(objects, key) {
  1431. if (objects) {
  1432. return listGetNode(objects, key, true);
  1433. }
  1434. };
  1435. module.exports = function getSideChannelList() {
  1436. var $o;
  1437. var channel = {
  1438. assert: function(key) {
  1439. if (!channel.has(key)) {
  1440. throw new $TypeError("Side channel does not contain " + inspect(key));
  1441. }
  1442. },
  1443. "delete": function(key) {
  1444. var root = $o && $o.next;
  1445. var deletedNode = listDelete($o, key);
  1446. if (deletedNode && root && root === deletedNode) {
  1447. $o = void 0;
  1448. }
  1449. return !!deletedNode;
  1450. },
  1451. get: function(key) {
  1452. return listGet($o, key);
  1453. },
  1454. has: function(key) {
  1455. return listHas($o, key);
  1456. },
  1457. set: function(key, value) {
  1458. if (!$o) {
  1459. $o = {
  1460. next: void 0
  1461. };
  1462. }
  1463. listSet(
  1464. /** @type {NonNullable<typeof $o>} */
  1465. $o,
  1466. key,
  1467. value
  1468. );
  1469. }
  1470. };
  1471. return channel;
  1472. };
  1473. }
  1474. });
  1475. // node_modules/es-object-atoms/index.js
  1476. var require_es_object_atoms = __commonJS({
  1477. "node_modules/es-object-atoms/index.js"(exports, module) {
  1478. "use strict";
  1479. module.exports = Object;
  1480. }
  1481. });
  1482. // node_modules/es-errors/index.js
  1483. var require_es_errors = __commonJS({
  1484. "node_modules/es-errors/index.js"(exports, module) {
  1485. "use strict";
  1486. module.exports = Error;
  1487. }
  1488. });
  1489. // node_modules/es-errors/eval.js
  1490. var require_eval = __commonJS({
  1491. "node_modules/es-errors/eval.js"(exports, module) {
  1492. "use strict";
  1493. module.exports = EvalError;
  1494. }
  1495. });
  1496. // node_modules/es-errors/range.js
  1497. var require_range = __commonJS({
  1498. "node_modules/es-errors/range.js"(exports, module) {
  1499. "use strict";
  1500. module.exports = RangeError;
  1501. }
  1502. });
  1503. // node_modules/es-errors/ref.js
  1504. var require_ref = __commonJS({
  1505. "node_modules/es-errors/ref.js"(exports, module) {
  1506. "use strict";
  1507. module.exports = ReferenceError;
  1508. }
  1509. });
  1510. // node_modules/es-errors/syntax.js
  1511. var require_syntax = __commonJS({
  1512. "node_modules/es-errors/syntax.js"(exports, module) {
  1513. "use strict";
  1514. module.exports = SyntaxError;
  1515. }
  1516. });
  1517. // node_modules/es-errors/uri.js
  1518. var require_uri = __commonJS({
  1519. "node_modules/es-errors/uri.js"(exports, module) {
  1520. "use strict";
  1521. module.exports = URIError;
  1522. }
  1523. });
  1524. // node_modules/math-intrinsics/abs.js
  1525. var require_abs = __commonJS({
  1526. "node_modules/math-intrinsics/abs.js"(exports, module) {
  1527. "use strict";
  1528. module.exports = Math.abs;
  1529. }
  1530. });
  1531. // node_modules/math-intrinsics/floor.js
  1532. var require_floor = __commonJS({
  1533. "node_modules/math-intrinsics/floor.js"(exports, module) {
  1534. "use strict";
  1535. module.exports = Math.floor;
  1536. }
  1537. });
  1538. // node_modules/math-intrinsics/max.js
  1539. var require_max = __commonJS({
  1540. "node_modules/math-intrinsics/max.js"(exports, module) {
  1541. "use strict";
  1542. module.exports = Math.max;
  1543. }
  1544. });
  1545. // node_modules/math-intrinsics/min.js
  1546. var require_min = __commonJS({
  1547. "node_modules/math-intrinsics/min.js"(exports, module) {
  1548. "use strict";
  1549. module.exports = Math.min;
  1550. }
  1551. });
  1552. // node_modules/math-intrinsics/pow.js
  1553. var require_pow = __commonJS({
  1554. "node_modules/math-intrinsics/pow.js"(exports, module) {
  1555. "use strict";
  1556. module.exports = Math.pow;
  1557. }
  1558. });
  1559. // node_modules/math-intrinsics/round.js
  1560. var require_round = __commonJS({
  1561. "node_modules/math-intrinsics/round.js"(exports, module) {
  1562. "use strict";
  1563. module.exports = Math.round;
  1564. }
  1565. });
  1566. // node_modules/math-intrinsics/isNaN.js
  1567. var require_isNaN = __commonJS({
  1568. "node_modules/math-intrinsics/isNaN.js"(exports, module) {
  1569. "use strict";
  1570. module.exports = Number.isNaN || function isNaN2(a) {
  1571. return a !== a;
  1572. };
  1573. }
  1574. });
  1575. // node_modules/math-intrinsics/sign.js
  1576. var require_sign = __commonJS({
  1577. "node_modules/math-intrinsics/sign.js"(exports, module) {
  1578. "use strict";
  1579. var $isNaN = require_isNaN();
  1580. module.exports = function sign2(number) {
  1581. if ($isNaN(number) || number === 0) {
  1582. return number;
  1583. }
  1584. return number < 0 ? -1 : 1;
  1585. };
  1586. }
  1587. });
  1588. // node_modules/gopd/gOPD.js
  1589. var require_gOPD = __commonJS({
  1590. "node_modules/gopd/gOPD.js"(exports, module) {
  1591. "use strict";
  1592. module.exports = Object.getOwnPropertyDescriptor;
  1593. }
  1594. });
  1595. // node_modules/gopd/index.js
  1596. var require_gopd = __commonJS({
  1597. "node_modules/gopd/index.js"(exports, module) {
  1598. "use strict";
  1599. var $gOPD = require_gOPD();
  1600. if ($gOPD) {
  1601. try {
  1602. $gOPD([], "length");
  1603. } catch (e) {
  1604. $gOPD = null;
  1605. }
  1606. }
  1607. module.exports = $gOPD;
  1608. }
  1609. });
  1610. // node_modules/es-define-property/index.js
  1611. var require_es_define_property = __commonJS({
  1612. "node_modules/es-define-property/index.js"(exports, module) {
  1613. "use strict";
  1614. var $defineProperty = Object.defineProperty || false;
  1615. if ($defineProperty) {
  1616. try {
  1617. $defineProperty({}, "a", { value: 1 });
  1618. } catch (e) {
  1619. $defineProperty = false;
  1620. }
  1621. }
  1622. module.exports = $defineProperty;
  1623. }
  1624. });
  1625. // node_modules/has-symbols/shams.js
  1626. var require_shams = __commonJS({
  1627. "node_modules/has-symbols/shams.js"(exports, module) {
  1628. "use strict";
  1629. module.exports = function hasSymbols() {
  1630. if (typeof Symbol !== "function" || typeof Object.getOwnPropertySymbols !== "function") {
  1631. return false;
  1632. }
  1633. if (typeof Symbol.iterator === "symbol") {
  1634. return true;
  1635. }
  1636. var obj = {};
  1637. var sym = Symbol("test");
  1638. var symObj = Object(sym);
  1639. if (typeof sym === "string") {
  1640. return false;
  1641. }
  1642. if (Object.prototype.toString.call(sym) !== "[object Symbol]") {
  1643. return false;
  1644. }
  1645. if (Object.prototype.toString.call(symObj) !== "[object Symbol]") {
  1646. return false;
  1647. }
  1648. var symVal = 42;
  1649. obj[sym] = symVal;
  1650. for (var _ in obj) {
  1651. return false;
  1652. }
  1653. if (typeof Object.keys === "function" && Object.keys(obj).length !== 0) {
  1654. return false;
  1655. }
  1656. if (typeof Object.getOwnPropertyNames === "function" && Object.getOwnPropertyNames(obj).length !== 0) {
  1657. return false;
  1658. }
  1659. var syms = Object.getOwnPropertySymbols(obj);
  1660. if (syms.length !== 1 || syms[0] !== sym) {
  1661. return false;
  1662. }
  1663. if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) {
  1664. return false;
  1665. }
  1666. if (typeof Object.getOwnPropertyDescriptor === "function") {
  1667. var descriptor = (
  1668. /** @type {PropertyDescriptor} */
  1669. Object.getOwnPropertyDescriptor(obj, sym)
  1670. );
  1671. if (descriptor.value !== symVal || descriptor.enumerable !== true) {
  1672. return false;
  1673. }
  1674. }
  1675. return true;
  1676. };
  1677. }
  1678. });
  1679. // node_modules/has-symbols/index.js
  1680. var require_has_symbols = __commonJS({
  1681. "node_modules/has-symbols/index.js"(exports, module) {
  1682. "use strict";
  1683. var origSymbol = typeof Symbol !== "undefined" && Symbol;
  1684. var hasSymbolSham = require_shams();
  1685. module.exports = function hasNativeSymbols() {
  1686. if (typeof origSymbol !== "function") {
  1687. return false;
  1688. }
  1689. if (typeof Symbol !== "function") {
  1690. return false;
  1691. }
  1692. if (typeof origSymbol("foo") !== "symbol") {
  1693. return false;
  1694. }
  1695. if (typeof Symbol("bar") !== "symbol") {
  1696. return false;
  1697. }
  1698. return hasSymbolSham();
  1699. };
  1700. }
  1701. });
  1702. // node_modules/get-proto/Reflect.getPrototypeOf.js
  1703. var require_Reflect_getPrototypeOf = __commonJS({
  1704. "node_modules/get-proto/Reflect.getPrototypeOf.js"(exports, module) {
  1705. "use strict";
  1706. module.exports = typeof Reflect !== "undefined" && Reflect.getPrototypeOf || null;
  1707. }
  1708. });
  1709. // node_modules/get-proto/Object.getPrototypeOf.js
  1710. var require_Object_getPrototypeOf = __commonJS({
  1711. "node_modules/get-proto/Object.getPrototypeOf.js"(exports, module) {
  1712. "use strict";
  1713. var $Object = require_es_object_atoms();
  1714. module.exports = $Object.getPrototypeOf || null;
  1715. }
  1716. });
  1717. // node_modules/function-bind/implementation.js
  1718. var require_implementation = __commonJS({
  1719. "node_modules/function-bind/implementation.js"(exports, module) {
  1720. "use strict";
  1721. var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
  1722. var toStr = Object.prototype.toString;
  1723. var max = Math.max;
  1724. var funcType = "[object Function]";
  1725. var concatty = function concatty2(a, b) {
  1726. var arr = [];
  1727. for (var i = 0; i < a.length; i += 1) {
  1728. arr[i] = a[i];
  1729. }
  1730. for (var j = 0; j < b.length; j += 1) {
  1731. arr[j + a.length] = b[j];
  1732. }
  1733. return arr;
  1734. };
  1735. var slicy = function slicy2(arrLike, offset) {
  1736. var arr = [];
  1737. for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {
  1738. arr[j] = arrLike[i];
  1739. }
  1740. return arr;
  1741. };
  1742. var joiny = function(arr, joiner) {
  1743. var str = "";
  1744. for (var i = 0; i < arr.length; i += 1) {
  1745. str += arr[i];
  1746. if (i + 1 < arr.length) {
  1747. str += joiner;
  1748. }
  1749. }
  1750. return str;
  1751. };
  1752. module.exports = function bind(that) {
  1753. var target = this;
  1754. if (typeof target !== "function" || toStr.apply(target) !== funcType) {
  1755. throw new TypeError(ERROR_MESSAGE + target);
  1756. }
  1757. var args = slicy(arguments, 1);
  1758. var bound;
  1759. var binder = function() {
  1760. if (this instanceof bound) {
  1761. var result = target.apply(
  1762. this,
  1763. concatty(args, arguments)
  1764. );
  1765. if (Object(result) === result) {
  1766. return result;
  1767. }
  1768. return this;
  1769. }
  1770. return target.apply(
  1771. that,
  1772. concatty(args, arguments)
  1773. );
  1774. };
  1775. var boundLength = max(0, target.length - args.length);
  1776. var boundArgs = [];
  1777. for (var i = 0; i < boundLength; i++) {
  1778. boundArgs[i] = "$" + i;
  1779. }
  1780. bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
  1781. if (target.prototype) {
  1782. var Empty = function Empty2() {
  1783. };
  1784. Empty.prototype = target.prototype;
  1785. bound.prototype = new Empty();
  1786. Empty.prototype = null;
  1787. }
  1788. return bound;
  1789. };
  1790. }
  1791. });
  1792. // node_modules/function-bind/index.js
  1793. var require_function_bind = __commonJS({
  1794. "node_modules/function-bind/index.js"(exports, module) {
  1795. "use strict";
  1796. var implementation = require_implementation();
  1797. module.exports = Function.prototype.bind || implementation;
  1798. }
  1799. });
  1800. // node_modules/call-bind-apply-helpers/functionCall.js
  1801. var require_functionCall = __commonJS({
  1802. "node_modules/call-bind-apply-helpers/functionCall.js"(exports, module) {
  1803. "use strict";
  1804. module.exports = Function.prototype.call;
  1805. }
  1806. });
  1807. // node_modules/call-bind-apply-helpers/functionApply.js
  1808. var require_functionApply = __commonJS({
  1809. "node_modules/call-bind-apply-helpers/functionApply.js"(exports, module) {
  1810. "use strict";
  1811. module.exports = Function.prototype.apply;
  1812. }
  1813. });
  1814. // node_modules/call-bind-apply-helpers/reflectApply.js
  1815. var require_reflectApply = __commonJS({
  1816. "node_modules/call-bind-apply-helpers/reflectApply.js"(exports, module) {
  1817. "use strict";
  1818. module.exports = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
  1819. }
  1820. });
  1821. // node_modules/call-bind-apply-helpers/actualApply.js
  1822. var require_actualApply = __commonJS({
  1823. "node_modules/call-bind-apply-helpers/actualApply.js"(exports, module) {
  1824. "use strict";
  1825. var bind = require_function_bind();
  1826. var $apply = require_functionApply();
  1827. var $call = require_functionCall();
  1828. var $reflectApply = require_reflectApply();
  1829. module.exports = $reflectApply || bind.call($call, $apply);
  1830. }
  1831. });
  1832. // node_modules/call-bind-apply-helpers/index.js
  1833. var require_call_bind_apply_helpers = __commonJS({
  1834. "node_modules/call-bind-apply-helpers/index.js"(exports, module) {
  1835. "use strict";
  1836. var bind = require_function_bind();
  1837. var $TypeError = require_type();
  1838. var $call = require_functionCall();
  1839. var $actualApply = require_actualApply();
  1840. module.exports = function callBindBasic(args) {
  1841. if (args.length < 1 || typeof args[0] !== "function") {
  1842. throw new $TypeError("a function is required");
  1843. }
  1844. return $actualApply(bind, $call, args);
  1845. };
  1846. }
  1847. });
  1848. // node_modules/dunder-proto/get.js
  1849. var require_get = __commonJS({
  1850. "node_modules/dunder-proto/get.js"(exports, module) {
  1851. "use strict";
  1852. var callBind = require_call_bind_apply_helpers();
  1853. var gOPD = require_gopd();
  1854. var hasProtoAccessor;
  1855. try {
  1856. hasProtoAccessor = /** @type {{ __proto__?: typeof Array.prototype }} */
  1857. [].__proto__ === Array.prototype;
  1858. } catch (e) {
  1859. if (!e || typeof e !== "object" || !("code" in e) || e.code !== "ERR_PROTO_ACCESS") {
  1860. throw e;
  1861. }
  1862. }
  1863. var desc = !!hasProtoAccessor && gOPD && gOPD(
  1864. Object.prototype,
  1865. /** @type {keyof typeof Object.prototype} */
  1866. "__proto__"
  1867. );
  1868. var $Object = Object;
  1869. var $getPrototypeOf = $Object.getPrototypeOf;
  1870. module.exports = desc && typeof desc.get === "function" ? callBind([desc.get]) : typeof $getPrototypeOf === "function" ? (
  1871. /** @type {import('./get')} */
  1872. function getDunder(value) {
  1873. return $getPrototypeOf(value == null ? value : $Object(value));
  1874. }
  1875. ) : false;
  1876. }
  1877. });
  1878. // node_modules/get-proto/index.js
  1879. var require_get_proto = __commonJS({
  1880. "node_modules/get-proto/index.js"(exports, module) {
  1881. "use strict";
  1882. var reflectGetProto = require_Reflect_getPrototypeOf();
  1883. var originalGetProto = require_Object_getPrototypeOf();
  1884. var getDunderProto = require_get();
  1885. module.exports = reflectGetProto ? function getProto(O) {
  1886. return reflectGetProto(O);
  1887. } : originalGetProto ? function getProto(O) {
  1888. if (!O || typeof O !== "object" && typeof O !== "function") {
  1889. throw new TypeError("getProto: not an object");
  1890. }
  1891. return originalGetProto(O);
  1892. } : getDunderProto ? function getProto(O) {
  1893. return getDunderProto(O);
  1894. } : null;
  1895. }
  1896. });
  1897. // node_modules/hasown/index.js
  1898. var require_hasown = __commonJS({
  1899. "node_modules/hasown/index.js"(exports, module) {
  1900. "use strict";
  1901. var call = Function.prototype.call;
  1902. var $hasOwn = Object.prototype.hasOwnProperty;
  1903. var bind = require_function_bind();
  1904. module.exports = bind.call(call, $hasOwn);
  1905. }
  1906. });
  1907. // node_modules/get-intrinsic/index.js
  1908. var require_get_intrinsic = __commonJS({
  1909. "node_modules/get-intrinsic/index.js"(exports, module) {
  1910. "use strict";
  1911. var undefined2;
  1912. var $Object = require_es_object_atoms();
  1913. var $Error = require_es_errors();
  1914. var $EvalError = require_eval();
  1915. var $RangeError = require_range();
  1916. var $ReferenceError = require_ref();
  1917. var $SyntaxError = require_syntax();
  1918. var $TypeError = require_type();
  1919. var $URIError = require_uri();
  1920. var abs = require_abs();
  1921. var floor = require_floor();
  1922. var max = require_max();
  1923. var min = require_min();
  1924. var pow = require_pow();
  1925. var round = require_round();
  1926. var sign2 = require_sign();
  1927. var $Function = Function;
  1928. var getEvalledConstructor = function(expressionSyntax) {
  1929. try {
  1930. return $Function('"use strict"; return (' + expressionSyntax + ").constructor;")();
  1931. } catch (e) {
  1932. }
  1933. };
  1934. var $gOPD = require_gopd();
  1935. var $defineProperty = require_es_define_property();
  1936. var throwTypeError = function() {
  1937. throw new $TypeError();
  1938. };
  1939. var ThrowTypeError = $gOPD ? (function() {
  1940. try {
  1941. arguments.callee;
  1942. return throwTypeError;
  1943. } catch (calleeThrows) {
  1944. try {
  1945. return $gOPD(arguments, "callee").get;
  1946. } catch (gOPDthrows) {
  1947. return throwTypeError;
  1948. }
  1949. }
  1950. })() : throwTypeError;
  1951. var hasSymbols = require_has_symbols()();
  1952. var getProto = require_get_proto();
  1953. var $ObjectGPO = require_Object_getPrototypeOf();
  1954. var $ReflectGPO = require_Reflect_getPrototypeOf();
  1955. var $apply = require_functionApply();
  1956. var $call = require_functionCall();
  1957. var needsEval = {};
  1958. var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined2 : getProto(Uint8Array);
  1959. var INTRINSICS = {
  1960. __proto__: null,
  1961. "%AggregateError%": typeof AggregateError === "undefined" ? undefined2 : AggregateError,
  1962. "%Array%": Array,
  1963. "%ArrayBuffer%": typeof ArrayBuffer === "undefined" ? undefined2 : ArrayBuffer,
  1964. "%ArrayIteratorPrototype%": hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined2,
  1965. "%AsyncFromSyncIteratorPrototype%": undefined2,
  1966. "%AsyncFunction%": needsEval,
  1967. "%AsyncGenerator%": needsEval,
  1968. "%AsyncGeneratorFunction%": needsEval,
  1969. "%AsyncIteratorPrototype%": needsEval,
  1970. "%Atomics%": typeof Atomics === "undefined" ? undefined2 : Atomics,
  1971. "%BigInt%": typeof BigInt === "undefined" ? undefined2 : BigInt,
  1972. "%BigInt64Array%": typeof BigInt64Array === "undefined" ? undefined2 : BigInt64Array,
  1973. "%BigUint64Array%": typeof BigUint64Array === "undefined" ? undefined2 : BigUint64Array,
  1974. "%Boolean%": Boolean,
  1975. "%DataView%": typeof DataView === "undefined" ? undefined2 : DataView,
  1976. "%Date%": Date,
  1977. "%decodeURI%": decodeURI,
  1978. "%decodeURIComponent%": decodeURIComponent,
  1979. "%encodeURI%": encodeURI,
  1980. "%encodeURIComponent%": encodeURIComponent,
  1981. "%Error%": $Error,
  1982. "%eval%": eval,
  1983. // eslint-disable-line no-eval
  1984. "%EvalError%": $EvalError,
  1985. "%Float16Array%": typeof Float16Array === "undefined" ? undefined2 : Float16Array,
  1986. "%Float32Array%": typeof Float32Array === "undefined" ? undefined2 : Float32Array,
  1987. "%Float64Array%": typeof Float64Array === "undefined" ? undefined2 : Float64Array,
  1988. "%FinalizationRegistry%": typeof FinalizationRegistry === "undefined" ? undefined2 : FinalizationRegistry,
  1989. "%Function%": $Function,
  1990. "%GeneratorFunction%": needsEval,
  1991. "%Int8Array%": typeof Int8Array === "undefined" ? undefined2 : Int8Array,
  1992. "%Int16Array%": typeof Int16Array === "undefined" ? undefined2 : Int16Array,
  1993. "%Int32Array%": typeof Int32Array === "undefined" ? undefined2 : Int32Array,
  1994. "%isFinite%": isFinite,
  1995. "%isNaN%": isNaN,
  1996. "%IteratorPrototype%": hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined2,
  1997. "%JSON%": typeof JSON === "object" ? JSON : undefined2,
  1998. "%Map%": typeof Map === "undefined" ? undefined2 : Map,
  1999. "%MapIteratorPrototype%": typeof Map === "undefined" || !hasSymbols || !getProto ? undefined2 : getProto((/* @__PURE__ */ new Map())[Symbol.iterator]()),
  2000. "%Math%": Math,
  2001. "%Number%": Number,
  2002. "%Object%": $Object,
  2003. "%Object.getOwnPropertyDescriptor%": $gOPD,
  2004. "%parseFloat%": parseFloat,
  2005. "%parseInt%": parseInt,
  2006. "%Promise%": typeof Promise === "undefined" ? undefined2 : Promise,
  2007. "%Proxy%": typeof Proxy === "undefined" ? undefined2 : Proxy,
  2008. "%RangeError%": $RangeError,
  2009. "%ReferenceError%": $ReferenceError,
  2010. "%Reflect%": typeof Reflect === "undefined" ? undefined2 : Reflect,
  2011. "%RegExp%": RegExp,
  2012. "%Set%": typeof Set === "undefined" ? undefined2 : Set,
  2013. "%SetIteratorPrototype%": typeof Set === "undefined" || !hasSymbols || !getProto ? undefined2 : getProto((/* @__PURE__ */ new Set())[Symbol.iterator]()),
  2014. "%SharedArrayBuffer%": typeof SharedArrayBuffer === "undefined" ? undefined2 : SharedArrayBuffer,
  2015. "%String%": String,
  2016. "%StringIteratorPrototype%": hasSymbols && getProto ? getProto(""[Symbol.iterator]()) : undefined2,
  2017. "%Symbol%": hasSymbols ? Symbol : undefined2,
  2018. "%SyntaxError%": $SyntaxError,
  2019. "%ThrowTypeError%": ThrowTypeError,
  2020. "%TypedArray%": TypedArray,
  2021. "%TypeError%": $TypeError,
  2022. "%Uint8Array%": typeof Uint8Array === "undefined" ? undefined2 : Uint8Array,
  2023. "%Uint8ClampedArray%": typeof Uint8ClampedArray === "undefined" ? undefined2 : Uint8ClampedArray,
  2024. "%Uint16Array%": typeof Uint16Array === "undefined" ? undefined2 : Uint16Array,
  2025. "%Uint32Array%": typeof Uint32Array === "undefined" ? undefined2 : Uint32Array,
  2026. "%URIError%": $URIError,
  2027. "%WeakMap%": typeof WeakMap === "undefined" ? undefined2 : WeakMap,
  2028. "%WeakRef%": typeof WeakRef === "undefined" ? undefined2 : WeakRef,
  2029. "%WeakSet%": typeof WeakSet === "undefined" ? undefined2 : WeakSet,
  2030. "%Function.prototype.call%": $call,
  2031. "%Function.prototype.apply%": $apply,
  2032. "%Object.defineProperty%": $defineProperty,
  2033. "%Object.getPrototypeOf%": $ObjectGPO,
  2034. "%Math.abs%": abs,
  2035. "%Math.floor%": floor,
  2036. "%Math.max%": max,
  2037. "%Math.min%": min,
  2038. "%Math.pow%": pow,
  2039. "%Math.round%": round,
  2040. "%Math.sign%": sign2,
  2041. "%Reflect.getPrototypeOf%": $ReflectGPO
  2042. };
  2043. if (getProto) {
  2044. try {
  2045. null.error;
  2046. } catch (e) {
  2047. errorProto = getProto(getProto(e));
  2048. INTRINSICS["%Error.prototype%"] = errorProto;
  2049. }
  2050. }
  2051. var errorProto;
  2052. var doEval = function doEval2(name) {
  2053. var value;
  2054. if (name === "%AsyncFunction%") {
  2055. value = getEvalledConstructor("async function () {}");
  2056. } else if (name === "%GeneratorFunction%") {
  2057. value = getEvalledConstructor("function* () {}");
  2058. } else if (name === "%AsyncGeneratorFunction%") {
  2059. value = getEvalledConstructor("async function* () {}");
  2060. } else if (name === "%AsyncGenerator%") {
  2061. var fn = doEval2("%AsyncGeneratorFunction%");
  2062. if (fn) {
  2063. value = fn.prototype;
  2064. }
  2065. } else if (name === "%AsyncIteratorPrototype%") {
  2066. var gen = doEval2("%AsyncGenerator%");
  2067. if (gen && getProto) {
  2068. value = getProto(gen.prototype);
  2069. }
  2070. }
  2071. INTRINSICS[name] = value;
  2072. return value;
  2073. };
  2074. var LEGACY_ALIASES = {
  2075. __proto__: null,
  2076. "%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"],
  2077. "%ArrayPrototype%": ["Array", "prototype"],
  2078. "%ArrayProto_entries%": ["Array", "prototype", "entries"],
  2079. "%ArrayProto_forEach%": ["Array", "prototype", "forEach"],
  2080. "%ArrayProto_keys%": ["Array", "prototype", "keys"],
  2081. "%ArrayProto_values%": ["Array", "prototype", "values"],
  2082. "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"],
  2083. "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"],
  2084. "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"],
  2085. "%BooleanPrototype%": ["Boolean", "prototype"],
  2086. "%DataViewPrototype%": ["DataView", "prototype"],
  2087. "%DatePrototype%": ["Date", "prototype"],
  2088. "%ErrorPrototype%": ["Error", "prototype"],
  2089. "%EvalErrorPrototype%": ["EvalError", "prototype"],
  2090. "%Float32ArrayPrototype%": ["Float32Array", "prototype"],
  2091. "%Float64ArrayPrototype%": ["Float64Array", "prototype"],
  2092. "%FunctionPrototype%": ["Function", "prototype"],
  2093. "%Generator%": ["GeneratorFunction", "prototype"],
  2094. "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"],
  2095. "%Int8ArrayPrototype%": ["Int8Array", "prototype"],
  2096. "%Int16ArrayPrototype%": ["Int16Array", "prototype"],
  2097. "%Int32ArrayPrototype%": ["Int32Array", "prototype"],
  2098. "%JSONParse%": ["JSON", "parse"],
  2099. "%JSONStringify%": ["JSON", "stringify"],
  2100. "%MapPrototype%": ["Map", "prototype"],
  2101. "%NumberPrototype%": ["Number", "prototype"],
  2102. "%ObjectPrototype%": ["Object", "prototype"],
  2103. "%ObjProto_toString%": ["Object", "prototype", "toString"],
  2104. "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"],
  2105. "%PromisePrototype%": ["Promise", "prototype"],
  2106. "%PromiseProto_then%": ["Promise", "prototype", "then"],
  2107. "%Promise_all%": ["Promise", "all"],
  2108. "%Promise_reject%": ["Promise", "reject"],
  2109. "%Promise_resolve%": ["Promise", "resolve"],
  2110. "%RangeErrorPrototype%": ["RangeError", "prototype"],
  2111. "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"],
  2112. "%RegExpPrototype%": ["RegExp", "prototype"],
  2113. "%SetPrototype%": ["Set", "prototype"],
  2114. "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"],
  2115. "%StringPrototype%": ["String", "prototype"],
  2116. "%SymbolPrototype%": ["Symbol", "prototype"],
  2117. "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"],
  2118. "%TypedArrayPrototype%": ["TypedArray", "prototype"],
  2119. "%TypeErrorPrototype%": ["TypeError", "prototype"],
  2120. "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"],
  2121. "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"],
  2122. "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"],
  2123. "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"],
  2124. "%URIErrorPrototype%": ["URIError", "prototype"],
  2125. "%WeakMapPrototype%": ["WeakMap", "prototype"],
  2126. "%WeakSetPrototype%": ["WeakSet", "prototype"]
  2127. };
  2128. var bind = require_function_bind();
  2129. var hasOwn = require_hasown();
  2130. var $concat = bind.call($call, Array.prototype.concat);
  2131. var $spliceApply = bind.call($apply, Array.prototype.splice);
  2132. var $replace = bind.call($call, String.prototype.replace);
  2133. var $strSlice = bind.call($call, String.prototype.slice);
  2134. var $exec = bind.call($call, RegExp.prototype.exec);
  2135. var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
  2136. var reEscapeChar = /\\(\\)?/g;
  2137. var stringToPath = function stringToPath2(string) {
  2138. var first = $strSlice(string, 0, 1);
  2139. var last = $strSlice(string, -1);
  2140. if (first === "%" && last !== "%") {
  2141. throw new $SyntaxError("invalid intrinsic syntax, expected closing `%`");
  2142. } else if (last === "%" && first !== "%") {
  2143. throw new $SyntaxError("invalid intrinsic syntax, expected opening `%`");
  2144. }
  2145. var result = [];
  2146. $replace(string, rePropName, function(match, number, quote, subString) {
  2147. result[result.length] = quote ? $replace(subString, reEscapeChar, "$1") : number || match;
  2148. });
  2149. return result;
  2150. };
  2151. var getBaseIntrinsic = function getBaseIntrinsic2(name, allowMissing) {
  2152. var intrinsicName = name;
  2153. var alias;
  2154. if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
  2155. alias = LEGACY_ALIASES[intrinsicName];
  2156. intrinsicName = "%" + alias[0] + "%";
  2157. }
  2158. if (hasOwn(INTRINSICS, intrinsicName)) {
  2159. var value = INTRINSICS[intrinsicName];
  2160. if (value === needsEval) {
  2161. value = doEval(intrinsicName);
  2162. }
  2163. if (typeof value === "undefined" && !allowMissing) {
  2164. throw new $TypeError("intrinsic " + name + " exists, but is not available. Please file an issue!");
  2165. }
  2166. return {
  2167. alias,
  2168. name: intrinsicName,
  2169. value
  2170. };
  2171. }
  2172. throw new $SyntaxError("intrinsic " + name + " does not exist!");
  2173. };
  2174. module.exports = function GetIntrinsic(name, allowMissing) {
  2175. if (typeof name !== "string" || name.length === 0) {
  2176. throw new $TypeError("intrinsic name must be a non-empty string");
  2177. }
  2178. if (arguments.length > 1 && typeof allowMissing !== "boolean") {
  2179. throw new $TypeError('"allowMissing" argument must be a boolean');
  2180. }
  2181. if ($exec(/^%?[^%]*%?$/, name) === null) {
  2182. throw new $SyntaxError("`%` may not be present anywhere but at the beginning and end of the intrinsic name");
  2183. }
  2184. var parts = stringToPath(name);
  2185. var intrinsicBaseName = parts.length > 0 ? parts[0] : "";
  2186. var intrinsic = getBaseIntrinsic("%" + intrinsicBaseName + "%", allowMissing);
  2187. var intrinsicRealName = intrinsic.name;
  2188. var value = intrinsic.value;
  2189. var skipFurtherCaching = false;
  2190. var alias = intrinsic.alias;
  2191. if (alias) {
  2192. intrinsicBaseName = alias[0];
  2193. $spliceApply(parts, $concat([0, 1], alias));
  2194. }
  2195. for (var i = 1, isOwn = true; i < parts.length; i += 1) {
  2196. var part = parts[i];
  2197. var first = $strSlice(part, 0, 1);
  2198. var last = $strSlice(part, -1);
  2199. if ((first === '"' || first === "'" || first === "`" || (last === '"' || last === "'" || last === "`")) && first !== last) {
  2200. throw new $SyntaxError("property names with quotes must have matching quotes");
  2201. }
  2202. if (part === "constructor" || !isOwn) {
  2203. skipFurtherCaching = true;
  2204. }
  2205. intrinsicBaseName += "." + part;
  2206. intrinsicRealName = "%" + intrinsicBaseName + "%";
  2207. if (hasOwn(INTRINSICS, intrinsicRealName)) {
  2208. value = INTRINSICS[intrinsicRealName];
  2209. } else if (value != null) {
  2210. if (!(part in value)) {
  2211. if (!allowMissing) {
  2212. throw new $TypeError("base intrinsic for " + name + " exists, but the property is not available.");
  2213. }
  2214. return void undefined2;
  2215. }
  2216. if ($gOPD && i + 1 >= parts.length) {
  2217. var desc = $gOPD(value, part);
  2218. isOwn = !!desc;
  2219. if (isOwn && "get" in desc && !("originalValue" in desc.get)) {
  2220. value = desc.get;
  2221. } else {
  2222. value = value[part];
  2223. }
  2224. } else {
  2225. isOwn = hasOwn(value, part);
  2226. value = value[part];
  2227. }
  2228. if (isOwn && !skipFurtherCaching) {
  2229. INTRINSICS[intrinsicRealName] = value;
  2230. }
  2231. }
  2232. }
  2233. return value;
  2234. };
  2235. }
  2236. });
  2237. // node_modules/call-bound/index.js
  2238. var require_call_bound = __commonJS({
  2239. "node_modules/call-bound/index.js"(exports, module) {
  2240. "use strict";
  2241. var GetIntrinsic = require_get_intrinsic();
  2242. var callBindBasic = require_call_bind_apply_helpers();
  2243. var $indexOf = callBindBasic([GetIntrinsic("%String.prototype.indexOf%")]);
  2244. module.exports = function callBoundIntrinsic(name, allowMissing) {
  2245. var intrinsic = (
  2246. /** @type {(this: unknown, ...args: unknown[]) => unknown} */
  2247. GetIntrinsic(name, !!allowMissing)
  2248. );
  2249. if (typeof intrinsic === "function" && $indexOf(name, ".prototype.") > -1) {
  2250. return callBindBasic(
  2251. /** @type {const} */
  2252. [intrinsic]
  2253. );
  2254. }
  2255. return intrinsic;
  2256. };
  2257. }
  2258. });
  2259. // node_modules/side-channel-map/index.js
  2260. var require_side_channel_map = __commonJS({
  2261. "node_modules/side-channel-map/index.js"(exports, module) {
  2262. "use strict";
  2263. var GetIntrinsic = require_get_intrinsic();
  2264. var callBound = require_call_bound();
  2265. var inspect = require_object_inspect();
  2266. var $TypeError = require_type();
  2267. var $Map = GetIntrinsic("%Map%", true);
  2268. var $mapGet = callBound("Map.prototype.get", true);
  2269. var $mapSet = callBound("Map.prototype.set", true);
  2270. var $mapHas = callBound("Map.prototype.has", true);
  2271. var $mapDelete = callBound("Map.prototype.delete", true);
  2272. var $mapSize = callBound("Map.prototype.size", true);
  2273. module.exports = !!$Map && /** @type {Exclude<import('.'), false>} */
  2274. function getSideChannelMap() {
  2275. var $m;
  2276. var channel = {
  2277. assert: function(key) {
  2278. if (!channel.has(key)) {
  2279. throw new $TypeError("Side channel does not contain " + inspect(key));
  2280. }
  2281. },
  2282. "delete": function(key) {
  2283. if ($m) {
  2284. var result = $mapDelete($m, key);
  2285. if ($mapSize($m) === 0) {
  2286. $m = void 0;
  2287. }
  2288. return result;
  2289. }
  2290. return false;
  2291. },
  2292. get: function(key) {
  2293. if ($m) {
  2294. return $mapGet($m, key);
  2295. }
  2296. },
  2297. has: function(key) {
  2298. if ($m) {
  2299. return $mapHas($m, key);
  2300. }
  2301. return false;
  2302. },
  2303. set: function(key, value) {
  2304. if (!$m) {
  2305. $m = new $Map();
  2306. }
  2307. $mapSet($m, key, value);
  2308. }
  2309. };
  2310. return channel;
  2311. };
  2312. }
  2313. });
  2314. // node_modules/side-channel-weakmap/index.js
  2315. var require_side_channel_weakmap = __commonJS({
  2316. "node_modules/side-channel-weakmap/index.js"(exports, module) {
  2317. "use strict";
  2318. var GetIntrinsic = require_get_intrinsic();
  2319. var callBound = require_call_bound();
  2320. var inspect = require_object_inspect();
  2321. var getSideChannelMap = require_side_channel_map();
  2322. var $TypeError = require_type();
  2323. var $WeakMap = GetIntrinsic("%WeakMap%", true);
  2324. var $weakMapGet = callBound("WeakMap.prototype.get", true);
  2325. var $weakMapSet = callBound("WeakMap.prototype.set", true);
  2326. var $weakMapHas = callBound("WeakMap.prototype.has", true);
  2327. var $weakMapDelete = callBound("WeakMap.prototype.delete", true);
  2328. module.exports = $WeakMap ? (
  2329. /** @type {Exclude<import('.'), false>} */
  2330. function getSideChannelWeakMap() {
  2331. var $wm;
  2332. var $m;
  2333. var channel = {
  2334. assert: function(key) {
  2335. if (!channel.has(key)) {
  2336. throw new $TypeError("Side channel does not contain " + inspect(key));
  2337. }
  2338. },
  2339. "delete": function(key) {
  2340. if ($WeakMap && key && (typeof key === "object" || typeof key === "function")) {
  2341. if ($wm) {
  2342. return $weakMapDelete($wm, key);
  2343. }
  2344. } else if (getSideChannelMap) {
  2345. if ($m) {
  2346. return $m["delete"](key);
  2347. }
  2348. }
  2349. return false;
  2350. },
  2351. get: function(key) {
  2352. if ($WeakMap && key && (typeof key === "object" || typeof key === "function")) {
  2353. if ($wm) {
  2354. return $weakMapGet($wm, key);
  2355. }
  2356. }
  2357. return $m && $m.get(key);
  2358. },
  2359. has: function(key) {
  2360. if ($WeakMap && key && (typeof key === "object" || typeof key === "function")) {
  2361. if ($wm) {
  2362. return $weakMapHas($wm, key);
  2363. }
  2364. }
  2365. return !!$m && $m.has(key);
  2366. },
  2367. set: function(key, value) {
  2368. if ($WeakMap && key && (typeof key === "object" || typeof key === "function")) {
  2369. if (!$wm) {
  2370. $wm = new $WeakMap();
  2371. }
  2372. $weakMapSet($wm, key, value);
  2373. } else if (getSideChannelMap) {
  2374. if (!$m) {
  2375. $m = getSideChannelMap();
  2376. }
  2377. $m.set(key, value);
  2378. }
  2379. }
  2380. };
  2381. return channel;
  2382. }
  2383. ) : getSideChannelMap;
  2384. }
  2385. });
  2386. // node_modules/side-channel/index.js
  2387. var require_side_channel = __commonJS({
  2388. "node_modules/side-channel/index.js"(exports, module) {
  2389. "use strict";
  2390. var $TypeError = require_type();
  2391. var inspect = require_object_inspect();
  2392. var getSideChannelList = require_side_channel_list();
  2393. var getSideChannelMap = require_side_channel_map();
  2394. var getSideChannelWeakMap = require_side_channel_weakmap();
  2395. var makeChannel = getSideChannelWeakMap || getSideChannelMap || getSideChannelList;
  2396. module.exports = function getSideChannel() {
  2397. var $channelData;
  2398. var channel = {
  2399. assert: function(key) {
  2400. if (!channel.has(key)) {
  2401. throw new $TypeError("Side channel does not contain " + inspect(key));
  2402. }
  2403. },
  2404. "delete": function(key) {
  2405. return !!$channelData && $channelData["delete"](key);
  2406. },
  2407. get: function(key) {
  2408. return $channelData && $channelData.get(key);
  2409. },
  2410. has: function(key) {
  2411. return !!$channelData && $channelData.has(key);
  2412. },
  2413. set: function(key, value) {
  2414. if (!$channelData) {
  2415. $channelData = makeChannel();
  2416. }
  2417. $channelData.set(key, value);
  2418. }
  2419. };
  2420. return channel;
  2421. };
  2422. }
  2423. });
  2424. // node_modules/qs/lib/formats.js
  2425. var require_formats = __commonJS({
  2426. "node_modules/qs/lib/formats.js"(exports, module) {
  2427. "use strict";
  2428. var replace = String.prototype.replace;
  2429. var percentTwenties = /%20/g;
  2430. var Format = {
  2431. RFC1738: "RFC1738",
  2432. RFC3986: "RFC3986"
  2433. };
  2434. module.exports = {
  2435. "default": Format.RFC3986,
  2436. formatters: {
  2437. RFC1738: function(value) {
  2438. return replace.call(value, percentTwenties, "+");
  2439. },
  2440. RFC3986: function(value) {
  2441. return String(value);
  2442. }
  2443. },
  2444. RFC1738: Format.RFC1738,
  2445. RFC3986: Format.RFC3986
  2446. };
  2447. }
  2448. });
  2449. // node_modules/qs/lib/utils.js
  2450. var require_utils = __commonJS({
  2451. "node_modules/qs/lib/utils.js"(exports, module) {
  2452. "use strict";
  2453. var formats = require_formats();
  2454. var getSideChannel = require_side_channel();
  2455. var has = Object.prototype.hasOwnProperty;
  2456. var isArray = Array.isArray;
  2457. var overflowChannel = getSideChannel();
  2458. var markOverflow = function markOverflow2(obj, maxIndex) {
  2459. overflowChannel.set(obj, maxIndex);
  2460. return obj;
  2461. };
  2462. var isOverflow = function isOverflow2(obj) {
  2463. return overflowChannel.has(obj);
  2464. };
  2465. var getMaxIndex = function getMaxIndex2(obj) {
  2466. return overflowChannel.get(obj);
  2467. };
  2468. var setMaxIndex = function setMaxIndex2(obj, maxIndex) {
  2469. overflowChannel.set(obj, maxIndex);
  2470. };
  2471. var hexTable = (function() {
  2472. var array = [];
  2473. for (var i = 0; i < 256; ++i) {
  2474. array[array.length] = "%" + ((i < 16 ? "0" : "") + i.toString(16)).toUpperCase();
  2475. }
  2476. return array;
  2477. })();
  2478. var compactQueue = function compactQueue2(queue) {
  2479. while (queue.length > 1) {
  2480. var item = queue.pop();
  2481. var obj = item.obj[item.prop];
  2482. if (isArray(obj)) {
  2483. var compacted = [];
  2484. for (var j = 0; j < obj.length; ++j) {
  2485. if (typeof obj[j] !== "undefined") {
  2486. compacted[compacted.length] = obj[j];
  2487. }
  2488. }
  2489. item.obj[item.prop] = compacted;
  2490. }
  2491. }
  2492. };
  2493. var arrayToObject = function arrayToObject2(source, options) {
  2494. var obj = options && options.plainObjects ? { __proto__: null } : {};
  2495. for (var i = 0; i < source.length; ++i) {
  2496. if (typeof source[i] !== "undefined") {
  2497. obj[i] = source[i];
  2498. }
  2499. }
  2500. return obj;
  2501. };
  2502. var merge = function merge2(target, source, options) {
  2503. if (!source) {
  2504. return target;
  2505. }
  2506. if (typeof source !== "object" && typeof source !== "function") {
  2507. if (isArray(target)) {
  2508. var nextIndex = target.length;
  2509. if (options && typeof options.arrayLimit === "number" && nextIndex > options.arrayLimit) {
  2510. return markOverflow(arrayToObject(target.concat(source), options), nextIndex);
  2511. }
  2512. target[nextIndex] = source;
  2513. } else if (target && typeof target === "object") {
  2514. if (isOverflow(target)) {
  2515. var newIndex = getMaxIndex(target) + 1;
  2516. target[newIndex] = source;
  2517. setMaxIndex(target, newIndex);
  2518. } else if (options && options.strictMerge) {
  2519. return [target, source];
  2520. } else if (options && (options.plainObjects || options.allowPrototypes) || !has.call(Object.prototype, source)) {
  2521. target[source] = true;
  2522. }
  2523. } else {
  2524. return [target, source];
  2525. }
  2526. return target;
  2527. }
  2528. if (!target || typeof target !== "object") {
  2529. if (isOverflow(source)) {
  2530. var sourceKeys = Object.keys(source);
  2531. var result = options && options.plainObjects ? { __proto__: null, 0: target } : { 0: target };
  2532. for (var m = 0; m < sourceKeys.length; m++) {
  2533. var oldKey = parseInt(sourceKeys[m], 10);
  2534. result[oldKey + 1] = source[sourceKeys[m]];
  2535. }
  2536. return markOverflow(result, getMaxIndex(source) + 1);
  2537. }
  2538. var combined = [target].concat(source);
  2539. if (options && typeof options.arrayLimit === "number" && combined.length > options.arrayLimit) {
  2540. return markOverflow(arrayToObject(combined, options), combined.length - 1);
  2541. }
  2542. return combined;
  2543. }
  2544. var mergeTarget = target;
  2545. if (isArray(target) && !isArray(source)) {
  2546. mergeTarget = arrayToObject(target, options);
  2547. }
  2548. if (isArray(target) && isArray(source)) {
  2549. source.forEach(function(item, i) {
  2550. if (has.call(target, i)) {
  2551. var targetItem = target[i];
  2552. if (targetItem && typeof targetItem === "object" && item && typeof item === "object") {
  2553. target[i] = merge2(targetItem, item, options);
  2554. } else {
  2555. target[target.length] = item;
  2556. }
  2557. } else {
  2558. target[i] = item;
  2559. }
  2560. });
  2561. return target;
  2562. }
  2563. return Object.keys(source).reduce(function(acc, key) {
  2564. var value = source[key];
  2565. if (has.call(acc, key)) {
  2566. acc[key] = merge2(acc[key], value, options);
  2567. } else {
  2568. acc[key] = value;
  2569. }
  2570. if (isOverflow(source) && !isOverflow(acc)) {
  2571. markOverflow(acc, getMaxIndex(source));
  2572. }
  2573. if (isOverflow(acc)) {
  2574. var keyNum = parseInt(key, 10);
  2575. if (String(keyNum) === key && keyNum >= 0 && keyNum > getMaxIndex(acc)) {
  2576. setMaxIndex(acc, keyNum);
  2577. }
  2578. }
  2579. return acc;
  2580. }, mergeTarget);
  2581. };
  2582. var assign = function assignSingleSource(target, source) {
  2583. return Object.keys(source).reduce(function(acc, key) {
  2584. acc[key] = source[key];
  2585. return acc;
  2586. }, target);
  2587. };
  2588. var decode = function(str, defaultDecoder, charset) {
  2589. var strWithoutPlus = str.replace(/\+/g, " ");
  2590. if (charset === "iso-8859-1") {
  2591. return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
  2592. }
  2593. try {
  2594. return decodeURIComponent(strWithoutPlus);
  2595. } catch (e) {
  2596. return strWithoutPlus;
  2597. }
  2598. };
  2599. var limit = 1024;
  2600. var encode = function encode2(str, defaultEncoder, charset, kind, format2) {
  2601. if (str.length === 0) {
  2602. return str;
  2603. }
  2604. var string = str;
  2605. if (typeof str === "symbol") {
  2606. string = Symbol.prototype.toString.call(str);
  2607. } else if (typeof str !== "string") {
  2608. string = String(str);
  2609. }
  2610. if (charset === "iso-8859-1") {
  2611. return escape(string).replace(/%u[0-9a-f]{4}/gi, function($0) {
  2612. return "%26%23" + parseInt($0.slice(2), 16) + "%3B";
  2613. });
  2614. }
  2615. var out = "";
  2616. for (var j = 0; j < string.length; j += limit) {
  2617. var segment = string.length >= limit ? string.slice(j, j + limit) : string;
  2618. var arr = [];
  2619. for (var i = 0; i < segment.length; ++i) {
  2620. var c = segment.charCodeAt(i);
  2621. if (c === 45 || c === 46 || c === 95 || c === 126 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || format2 === formats.RFC1738 && (c === 40 || c === 41)) {
  2622. arr[arr.length] = segment.charAt(i);
  2623. continue;
  2624. }
  2625. if (c < 128) {
  2626. arr[arr.length] = hexTable[c];
  2627. continue;
  2628. }
  2629. if (c < 2048) {
  2630. arr[arr.length] = hexTable[192 | c >> 6] + hexTable[128 | c & 63];
  2631. continue;
  2632. }
  2633. if (c < 55296 || c >= 57344) {
  2634. arr[arr.length] = hexTable[224 | c >> 12] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63];
  2635. continue;
  2636. }
  2637. i += 1;
  2638. c = 65536 + ((c & 1023) << 10 | segment.charCodeAt(i) & 1023);
  2639. arr[arr.length] = hexTable[240 | c >> 18] + hexTable[128 | c >> 12 & 63] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63];
  2640. }
  2641. out += arr.join("");
  2642. }
  2643. return out;
  2644. };
  2645. var compact = function compact2(value) {
  2646. var queue = [{ obj: { o: value }, prop: "o" }];
  2647. var refs = [];
  2648. for (var i = 0; i < queue.length; ++i) {
  2649. var item = queue[i];
  2650. var obj = item.obj[item.prop];
  2651. var keys = Object.keys(obj);
  2652. for (var j = 0; j < keys.length; ++j) {
  2653. var key = keys[j];
  2654. var val = obj[key];
  2655. if (typeof val === "object" && val !== null && refs.indexOf(val) === -1) {
  2656. queue[queue.length] = { obj, prop: key };
  2657. refs[refs.length] = val;
  2658. }
  2659. }
  2660. }
  2661. compactQueue(queue);
  2662. return value;
  2663. };
  2664. var isRegExp = function isRegExp2(obj) {
  2665. return Object.prototype.toString.call(obj) === "[object RegExp]";
  2666. };
  2667. var isBuffer = function isBuffer2(obj) {
  2668. if (!obj || typeof obj !== "object") {
  2669. return false;
  2670. }
  2671. return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
  2672. };
  2673. var combine = function combine2(a, b, arrayLimit, plainObjects) {
  2674. if (isOverflow(a)) {
  2675. var newIndex = getMaxIndex(a) + 1;
  2676. a[newIndex] = b;
  2677. setMaxIndex(a, newIndex);
  2678. return a;
  2679. }
  2680. var result = [].concat(a, b);
  2681. if (result.length > arrayLimit) {
  2682. return markOverflow(arrayToObject(result, { plainObjects }), result.length - 1);
  2683. }
  2684. return result;
  2685. };
  2686. var maybeMap = function maybeMap2(val, fn) {
  2687. if (isArray(val)) {
  2688. var mapped = [];
  2689. for (var i = 0; i < val.length; i += 1) {
  2690. mapped[mapped.length] = fn(val[i]);
  2691. }
  2692. return mapped;
  2693. }
  2694. return fn(val);
  2695. };
  2696. module.exports = {
  2697. arrayToObject,
  2698. assign,
  2699. combine,
  2700. compact,
  2701. decode,
  2702. encode,
  2703. isBuffer,
  2704. isOverflow,
  2705. isRegExp,
  2706. markOverflow,
  2707. maybeMap,
  2708. merge
  2709. };
  2710. }
  2711. });
  2712. // node_modules/qs/lib/stringify.js
  2713. var require_stringify = __commonJS({
  2714. "node_modules/qs/lib/stringify.js"(exports, module) {
  2715. "use strict";
  2716. var getSideChannel = require_side_channel();
  2717. var utils = require_utils();
  2718. var formats = require_formats();
  2719. var has = Object.prototype.hasOwnProperty;
  2720. var arrayPrefixGenerators = {
  2721. brackets: function brackets(prefix) {
  2722. return prefix + "[]";
  2723. },
  2724. comma: "comma",
  2725. indices: function indices(prefix, key) {
  2726. return prefix + "[" + key + "]";
  2727. },
  2728. repeat: function repeat(prefix) {
  2729. return prefix;
  2730. }
  2731. };
  2732. var isArray = Array.isArray;
  2733. var push = Array.prototype.push;
  2734. var pushToArray = function(arr, valueOrArray) {
  2735. push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
  2736. };
  2737. var toISO = Date.prototype.toISOString;
  2738. var defaultFormat = formats["default"];
  2739. var defaults = {
  2740. addQueryPrefix: false,
  2741. allowDots: false,
  2742. allowEmptyArrays: false,
  2743. arrayFormat: "indices",
  2744. charset: "utf-8",
  2745. charsetSentinel: false,
  2746. commaRoundTrip: false,
  2747. delimiter: "&",
  2748. encode: true,
  2749. encodeDotInKeys: false,
  2750. encoder: utils.encode,
  2751. encodeValuesOnly: false,
  2752. filter: void 0,
  2753. format: defaultFormat,
  2754. formatter: formats.formatters[defaultFormat],
  2755. // deprecated
  2756. indices: false,
  2757. serializeDate: function serializeDate(date) {
  2758. return toISO.call(date);
  2759. },
  2760. skipNulls: false,
  2761. strictNullHandling: false
  2762. };
  2763. var isNonNullishPrimitive = function isNonNullishPrimitive2(v) {
  2764. return typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "bigint";
  2765. };
  2766. var sentinel = {};
  2767. var stringify = function stringify2(object, prefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, encoder, filter, sort, allowDots, serializeDate, format2, formatter, encodeValuesOnly, charset, sideChannel) {
  2768. var obj = object;
  2769. var tmpSc = sideChannel;
  2770. var step = 0;
  2771. var findFlag = false;
  2772. while ((tmpSc = tmpSc.get(sentinel)) !== void 0 && !findFlag) {
  2773. var pos = tmpSc.get(object);
  2774. step += 1;
  2775. if (typeof pos !== "undefined") {
  2776. if (pos === step) {
  2777. throw new RangeError("Cyclic object value");
  2778. } else {
  2779. findFlag = true;
  2780. }
  2781. }
  2782. if (typeof tmpSc.get(sentinel) === "undefined") {
  2783. step = 0;
  2784. }
  2785. }
  2786. if (typeof filter === "function") {
  2787. obj = filter(prefix, obj);
  2788. } else if (obj instanceof Date) {
  2789. obj = serializeDate(obj);
  2790. } else if (generateArrayPrefix === "comma" && isArray(obj)) {
  2791. obj = utils.maybeMap(obj, function(value2) {
  2792. if (value2 instanceof Date) {
  2793. return serializeDate(value2);
  2794. }
  2795. return value2;
  2796. });
  2797. }
  2798. if (obj === null) {
  2799. if (strictNullHandling) {
  2800. return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, "key", format2) : prefix;
  2801. }
  2802. obj = "";
  2803. }
  2804. if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
  2805. if (encoder) {
  2806. var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, "key", format2);
  2807. return [formatter(keyValue) + "=" + formatter(encoder(obj, defaults.encoder, charset, "value", format2))];
  2808. }
  2809. return [formatter(prefix) + "=" + formatter(String(obj))];
  2810. }
  2811. var values = [];
  2812. if (typeof obj === "undefined") {
  2813. return values;
  2814. }
  2815. var objKeys;
  2816. if (generateArrayPrefix === "comma" && isArray(obj)) {
  2817. if (encodeValuesOnly && encoder) {
  2818. obj = utils.maybeMap(obj, encoder);
  2819. }
  2820. objKeys = [{ value: obj.length > 0 ? obj.join(",") || null : void 0 }];
  2821. } else if (isArray(filter)) {
  2822. objKeys = filter;
  2823. } else {
  2824. var keys = Object.keys(obj);
  2825. objKeys = sort ? keys.sort(sort) : keys;
  2826. }
  2827. var encodedPrefix = encodeDotInKeys ? String(prefix).replace(/\./g, "%2E") : String(prefix);
  2828. var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? encodedPrefix + "[]" : encodedPrefix;
  2829. if (allowEmptyArrays && isArray(obj) && obj.length === 0) {
  2830. return adjustedPrefix + "[]";
  2831. }
  2832. for (var j = 0; j < objKeys.length; ++j) {
  2833. var key = objKeys[j];
  2834. var value = typeof key === "object" && key && typeof key.value !== "undefined" ? key.value : obj[key];
  2835. if (skipNulls && value === null) {
  2836. continue;
  2837. }
  2838. var encodedKey = allowDots && encodeDotInKeys ? String(key).replace(/\./g, "%2E") : String(key);
  2839. var keyPrefix = isArray(obj) ? typeof generateArrayPrefix === "function" ? generateArrayPrefix(adjustedPrefix, encodedKey) : adjustedPrefix : adjustedPrefix + (allowDots ? "." + encodedKey : "[" + encodedKey + "]");
  2840. sideChannel.set(object, step);
  2841. var valueSideChannel = getSideChannel();
  2842. valueSideChannel.set(sentinel, sideChannel);
  2843. pushToArray(values, stringify2(
  2844. value,
  2845. keyPrefix,
  2846. generateArrayPrefix,
  2847. commaRoundTrip,
  2848. allowEmptyArrays,
  2849. strictNullHandling,
  2850. skipNulls,
  2851. encodeDotInKeys,
  2852. generateArrayPrefix === "comma" && encodeValuesOnly && isArray(obj) ? null : encoder,
  2853. filter,
  2854. sort,
  2855. allowDots,
  2856. serializeDate,
  2857. format2,
  2858. formatter,
  2859. encodeValuesOnly,
  2860. charset,
  2861. valueSideChannel
  2862. ));
  2863. }
  2864. return values;
  2865. };
  2866. var normalizeStringifyOptions = function normalizeStringifyOptions2(opts) {
  2867. if (!opts) {
  2868. return defaults;
  2869. }
  2870. if (typeof opts.allowEmptyArrays !== "undefined" && typeof opts.allowEmptyArrays !== "boolean") {
  2871. throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
  2872. }
  2873. if (typeof opts.encodeDotInKeys !== "undefined" && typeof opts.encodeDotInKeys !== "boolean") {
  2874. throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");
  2875. }
  2876. if (opts.encoder !== null && typeof opts.encoder !== "undefined" && typeof opts.encoder !== "function") {
  2877. throw new TypeError("Encoder has to be a function.");
  2878. }
  2879. var charset = opts.charset || defaults.charset;
  2880. if (typeof opts.charset !== "undefined" && opts.charset !== "utf-8" && opts.charset !== "iso-8859-1") {
  2881. throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
  2882. }
  2883. var format2 = formats["default"];
  2884. if (typeof opts.format !== "undefined") {
  2885. if (!has.call(formats.formatters, opts.format)) {
  2886. throw new TypeError("Unknown format option provided.");
  2887. }
  2888. format2 = opts.format;
  2889. }
  2890. var formatter = formats.formatters[format2];
  2891. var filter = defaults.filter;
  2892. if (typeof opts.filter === "function" || isArray(opts.filter)) {
  2893. filter = opts.filter;
  2894. }
  2895. var arrayFormat;
  2896. if (opts.arrayFormat in arrayPrefixGenerators) {
  2897. arrayFormat = opts.arrayFormat;
  2898. } else if ("indices" in opts) {
  2899. arrayFormat = opts.indices ? "indices" : "repeat";
  2900. } else {
  2901. arrayFormat = defaults.arrayFormat;
  2902. }
  2903. if ("commaRoundTrip" in opts && typeof opts.commaRoundTrip !== "boolean") {
  2904. throw new TypeError("`commaRoundTrip` must be a boolean, or absent");
  2905. }
  2906. var allowDots = typeof opts.allowDots === "undefined" ? opts.encodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots;
  2907. return {
  2908. addQueryPrefix: typeof opts.addQueryPrefix === "boolean" ? opts.addQueryPrefix : defaults.addQueryPrefix,
  2909. allowDots,
  2910. allowEmptyArrays: typeof opts.allowEmptyArrays === "boolean" ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
  2911. arrayFormat,
  2912. charset,
  2913. charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults.charsetSentinel,
  2914. commaRoundTrip: !!opts.commaRoundTrip,
  2915. delimiter: typeof opts.delimiter === "undefined" ? defaults.delimiter : opts.delimiter,
  2916. encode: typeof opts.encode === "boolean" ? opts.encode : defaults.encode,
  2917. encodeDotInKeys: typeof opts.encodeDotInKeys === "boolean" ? opts.encodeDotInKeys : defaults.encodeDotInKeys,
  2918. encoder: typeof opts.encoder === "function" ? opts.encoder : defaults.encoder,
  2919. encodeValuesOnly: typeof opts.encodeValuesOnly === "boolean" ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
  2920. filter,
  2921. format: format2,
  2922. formatter,
  2923. serializeDate: typeof opts.serializeDate === "function" ? opts.serializeDate : defaults.serializeDate,
  2924. skipNulls: typeof opts.skipNulls === "boolean" ? opts.skipNulls : defaults.skipNulls,
  2925. sort: typeof opts.sort === "function" ? opts.sort : null,
  2926. strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults.strictNullHandling
  2927. };
  2928. };
  2929. module.exports = function(object, opts) {
  2930. var obj = object;
  2931. var options = normalizeStringifyOptions(opts);
  2932. var objKeys;
  2933. var filter;
  2934. if (typeof options.filter === "function") {
  2935. filter = options.filter;
  2936. obj = filter("", obj);
  2937. } else if (isArray(options.filter)) {
  2938. filter = options.filter;
  2939. objKeys = filter;
  2940. }
  2941. var keys = [];
  2942. if (typeof obj !== "object" || obj === null) {
  2943. return "";
  2944. }
  2945. var generateArrayPrefix = arrayPrefixGenerators[options.arrayFormat];
  2946. var commaRoundTrip = generateArrayPrefix === "comma" && options.commaRoundTrip;
  2947. if (!objKeys) {
  2948. objKeys = Object.keys(obj);
  2949. }
  2950. if (options.sort) {
  2951. objKeys.sort(options.sort);
  2952. }
  2953. var sideChannel = getSideChannel();
  2954. for (var i = 0; i < objKeys.length; ++i) {
  2955. var key = objKeys[i];
  2956. var value = obj[key];
  2957. if (options.skipNulls && value === null) {
  2958. continue;
  2959. }
  2960. pushToArray(keys, stringify(
  2961. value,
  2962. key,
  2963. generateArrayPrefix,
  2964. commaRoundTrip,
  2965. options.allowEmptyArrays,
  2966. options.strictNullHandling,
  2967. options.skipNulls,
  2968. options.encodeDotInKeys,
  2969. options.encode ? options.encoder : null,
  2970. options.filter,
  2971. options.sort,
  2972. options.allowDots,
  2973. options.serializeDate,
  2974. options.format,
  2975. options.formatter,
  2976. options.encodeValuesOnly,
  2977. options.charset,
  2978. sideChannel
  2979. ));
  2980. }
  2981. var joined = keys.join(options.delimiter);
  2982. var prefix = options.addQueryPrefix === true ? "?" : "";
  2983. if (options.charsetSentinel) {
  2984. if (options.charset === "iso-8859-1") {
  2985. prefix += "utf8=%26%2310003%3B&";
  2986. } else {
  2987. prefix += "utf8=%E2%9C%93&";
  2988. }
  2989. }
  2990. return joined.length > 0 ? prefix + joined : "";
  2991. };
  2992. }
  2993. });
  2994. // node_modules/qs/lib/parse.js
  2995. var require_parse = __commonJS({
  2996. "node_modules/qs/lib/parse.js"(exports, module) {
  2997. "use strict";
  2998. var utils = require_utils();
  2999. var has = Object.prototype.hasOwnProperty;
  3000. var isArray = Array.isArray;
  3001. var defaults = {
  3002. allowDots: false,
  3003. allowEmptyArrays: false,
  3004. allowPrototypes: false,
  3005. allowSparse: false,
  3006. arrayLimit: 20,
  3007. charset: "utf-8",
  3008. charsetSentinel: false,
  3009. comma: false,
  3010. decodeDotInKeys: false,
  3011. decoder: utils.decode,
  3012. delimiter: "&",
  3013. depth: 5,
  3014. duplicates: "combine",
  3015. ignoreQueryPrefix: false,
  3016. interpretNumericEntities: false,
  3017. parameterLimit: 1e3,
  3018. parseArrays: true,
  3019. plainObjects: false,
  3020. strictDepth: false,
  3021. strictMerge: true,
  3022. strictNullHandling: false,
  3023. throwOnLimitExceeded: false
  3024. };
  3025. var interpretNumericEntities = function(str) {
  3026. return str.replace(/&#(\d+);/g, function($0, numberStr) {
  3027. return String.fromCharCode(parseInt(numberStr, 10));
  3028. });
  3029. };
  3030. var parseArrayValue = function(val, options, currentArrayLength) {
  3031. if (val && typeof val === "string" && options.comma && val.indexOf(",") > -1) {
  3032. return val.split(",");
  3033. }
  3034. if (options.throwOnLimitExceeded && currentArrayLength >= options.arrayLimit) {
  3035. throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
  3036. }
  3037. return val;
  3038. };
  3039. var isoSentinel = "utf8=%26%2310003%3B";
  3040. var charsetSentinel = "utf8=%E2%9C%93";
  3041. var parseValues = function parseQueryStringValues(str, options) {
  3042. var obj = { __proto__: null };
  3043. var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, "") : str;
  3044. cleanStr = cleanStr.replace(/%5B/gi, "[").replace(/%5D/gi, "]");
  3045. var limit = options.parameterLimit === Infinity ? void 0 : options.parameterLimit;
  3046. var parts = cleanStr.split(
  3047. options.delimiter,
  3048. options.throwOnLimitExceeded ? limit + 1 : limit
  3049. );
  3050. if (options.throwOnLimitExceeded && parts.length > limit) {
  3051. throw new RangeError("Parameter limit exceeded. Only " + limit + " parameter" + (limit === 1 ? "" : "s") + " allowed.");
  3052. }
  3053. var skipIndex = -1;
  3054. var i;
  3055. var charset = options.charset;
  3056. if (options.charsetSentinel) {
  3057. for (i = 0; i < parts.length; ++i) {
  3058. if (parts[i].indexOf("utf8=") === 0) {
  3059. if (parts[i] === charsetSentinel) {
  3060. charset = "utf-8";
  3061. } else if (parts[i] === isoSentinel) {
  3062. charset = "iso-8859-1";
  3063. }
  3064. skipIndex = i;
  3065. i = parts.length;
  3066. }
  3067. }
  3068. }
  3069. for (i = 0; i < parts.length; ++i) {
  3070. if (i === skipIndex) {
  3071. continue;
  3072. }
  3073. var part = parts[i];
  3074. var bracketEqualsPos = part.indexOf("]=");
  3075. var pos = bracketEqualsPos === -1 ? part.indexOf("=") : bracketEqualsPos + 1;
  3076. var key;
  3077. var val;
  3078. if (pos === -1) {
  3079. key = options.decoder(part, defaults.decoder, charset, "key");
  3080. val = options.strictNullHandling ? null : "";
  3081. } else {
  3082. key = options.decoder(part.slice(0, pos), defaults.decoder, charset, "key");
  3083. if (key !== null) {
  3084. val = utils.maybeMap(
  3085. parseArrayValue(
  3086. part.slice(pos + 1),
  3087. options,
  3088. isArray(obj[key]) ? obj[key].length : 0
  3089. ),
  3090. function(encodedVal) {
  3091. return options.decoder(encodedVal, defaults.decoder, charset, "value");
  3092. }
  3093. );
  3094. }
  3095. }
  3096. if (val && options.interpretNumericEntities && charset === "iso-8859-1") {
  3097. val = interpretNumericEntities(String(val));
  3098. }
  3099. if (part.indexOf("[]=") > -1) {
  3100. val = isArray(val) ? [val] : val;
  3101. }
  3102. if (options.comma && isArray(val) && val.length > options.arrayLimit) {
  3103. if (options.throwOnLimitExceeded) {
  3104. throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
  3105. }
  3106. val = utils.combine([], val, options.arrayLimit, options.plainObjects);
  3107. }
  3108. if (key !== null) {
  3109. var existing = has.call(obj, key);
  3110. if (existing && (options.duplicates === "combine" || part.indexOf("[]=") > -1)) {
  3111. obj[key] = utils.combine(
  3112. obj[key],
  3113. val,
  3114. options.arrayLimit,
  3115. options.plainObjects
  3116. );
  3117. } else if (!existing || options.duplicates === "last") {
  3118. obj[key] = val;
  3119. }
  3120. }
  3121. }
  3122. return obj;
  3123. };
  3124. var parseObject = function(chain, val, options, valuesParsed) {
  3125. var currentArrayLength = 0;
  3126. if (chain.length > 0 && chain[chain.length - 1] === "[]") {
  3127. var parentKey = chain.slice(0, -1).join("");
  3128. currentArrayLength = Array.isArray(val) && val[parentKey] ? val[parentKey].length : 0;
  3129. }
  3130. var leaf = valuesParsed ? val : parseArrayValue(val, options, currentArrayLength);
  3131. for (var i = chain.length - 1; i >= 0; --i) {
  3132. var obj;
  3133. var root = chain[i];
  3134. if (root === "[]" && options.parseArrays) {
  3135. if (utils.isOverflow(leaf)) {
  3136. obj = leaf;
  3137. } else {
  3138. obj = options.allowEmptyArrays && (leaf === "" || options.strictNullHandling && leaf === null) ? [] : utils.combine(
  3139. [],
  3140. leaf,
  3141. options.arrayLimit,
  3142. options.plainObjects
  3143. );
  3144. }
  3145. } else {
  3146. obj = options.plainObjects ? { __proto__: null } : {};
  3147. var cleanRoot = root.charAt(0) === "[" && root.charAt(root.length - 1) === "]" ? root.slice(1, -1) : root;
  3148. var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/g, ".") : cleanRoot;
  3149. var index = parseInt(decodedRoot, 10);
  3150. var isValidArrayIndex = !isNaN(index) && root !== decodedRoot && String(index) === decodedRoot && index >= 0 && options.parseArrays;
  3151. if (!options.parseArrays && decodedRoot === "") {
  3152. obj = { 0: leaf };
  3153. } else if (isValidArrayIndex && index < options.arrayLimit) {
  3154. obj = [];
  3155. obj[index] = leaf;
  3156. } else if (isValidArrayIndex && options.throwOnLimitExceeded) {
  3157. throw new RangeError("Array limit exceeded. Only " + options.arrayLimit + " element" + (options.arrayLimit === 1 ? "" : "s") + " allowed in an array.");
  3158. } else if (isValidArrayIndex) {
  3159. obj[index] = leaf;
  3160. utils.markOverflow(obj, index);
  3161. } else if (decodedRoot !== "__proto__") {
  3162. obj[decodedRoot] = leaf;
  3163. }
  3164. }
  3165. leaf = obj;
  3166. }
  3167. return leaf;
  3168. };
  3169. var splitKeyIntoSegments = function splitKeyIntoSegments2(givenKey, options) {
  3170. var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, "[$1]") : givenKey;
  3171. if (options.depth <= 0) {
  3172. if (!options.plainObjects && has.call(Object.prototype, key)) {
  3173. if (!options.allowPrototypes) {
  3174. return;
  3175. }
  3176. }
  3177. return [key];
  3178. }
  3179. var brackets = /(\[[^[\]]*])/;
  3180. var child = /(\[[^[\]]*])/g;
  3181. var segment = brackets.exec(key);
  3182. var parent = segment ? key.slice(0, segment.index) : key;
  3183. var keys = [];
  3184. if (parent) {
  3185. if (!options.plainObjects && has.call(Object.prototype, parent)) {
  3186. if (!options.allowPrototypes) {
  3187. return;
  3188. }
  3189. }
  3190. keys[keys.length] = parent;
  3191. }
  3192. var i = 0;
  3193. while ((segment = child.exec(key)) !== null && i < options.depth) {
  3194. i += 1;
  3195. var segmentContent = segment[1].slice(1, -1);
  3196. if (!options.plainObjects && has.call(Object.prototype, segmentContent)) {
  3197. if (!options.allowPrototypes) {
  3198. return;
  3199. }
  3200. }
  3201. keys[keys.length] = segment[1];
  3202. }
  3203. if (segment) {
  3204. if (options.strictDepth === true) {
  3205. throw new RangeError("Input depth exceeded depth option of " + options.depth + " and strictDepth is true");
  3206. }
  3207. keys[keys.length] = "[" + key.slice(segment.index) + "]";
  3208. }
  3209. return keys;
  3210. };
  3211. var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
  3212. if (!givenKey) {
  3213. return;
  3214. }
  3215. var keys = splitKeyIntoSegments(givenKey, options);
  3216. if (!keys) {
  3217. return;
  3218. }
  3219. return parseObject(keys, val, options, valuesParsed);
  3220. };
  3221. var normalizeParseOptions = function normalizeParseOptions2(opts) {
  3222. if (!opts) {
  3223. return defaults;
  3224. }
  3225. if (typeof opts.allowEmptyArrays !== "undefined" && typeof opts.allowEmptyArrays !== "boolean") {
  3226. throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
  3227. }
  3228. if (typeof opts.decodeDotInKeys !== "undefined" && typeof opts.decodeDotInKeys !== "boolean") {
  3229. throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");
  3230. }
  3231. if (opts.decoder !== null && typeof opts.decoder !== "undefined" && typeof opts.decoder !== "function") {
  3232. throw new TypeError("Decoder has to be a function.");
  3233. }
  3234. if (typeof opts.charset !== "undefined" && opts.charset !== "utf-8" && opts.charset !== "iso-8859-1") {
  3235. throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
  3236. }
  3237. if (typeof opts.throwOnLimitExceeded !== "undefined" && typeof opts.throwOnLimitExceeded !== "boolean") {
  3238. throw new TypeError("`throwOnLimitExceeded` option must be a boolean");
  3239. }
  3240. var charset = typeof opts.charset === "undefined" ? defaults.charset : opts.charset;
  3241. var duplicates = typeof opts.duplicates === "undefined" ? defaults.duplicates : opts.duplicates;
  3242. if (duplicates !== "combine" && duplicates !== "first" && duplicates !== "last") {
  3243. throw new TypeError("The duplicates option must be either combine, first, or last");
  3244. }
  3245. var allowDots = typeof opts.allowDots === "undefined" ? opts.decodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots;
  3246. return {
  3247. allowDots,
  3248. allowEmptyArrays: typeof opts.allowEmptyArrays === "boolean" ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
  3249. allowPrototypes: typeof opts.allowPrototypes === "boolean" ? opts.allowPrototypes : defaults.allowPrototypes,
  3250. allowSparse: typeof opts.allowSparse === "boolean" ? opts.allowSparse : defaults.allowSparse,
  3251. arrayLimit: typeof opts.arrayLimit === "number" ? opts.arrayLimit : defaults.arrayLimit,
  3252. charset,
  3253. charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults.charsetSentinel,
  3254. comma: typeof opts.comma === "boolean" ? opts.comma : defaults.comma,
  3255. decodeDotInKeys: typeof opts.decodeDotInKeys === "boolean" ? opts.decodeDotInKeys : defaults.decodeDotInKeys,
  3256. decoder: typeof opts.decoder === "function" ? opts.decoder : defaults.decoder,
  3257. delimiter: typeof opts.delimiter === "string" || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
  3258. // eslint-disable-next-line no-implicit-coercion, no-extra-parens
  3259. depth: typeof opts.depth === "number" || opts.depth === false ? +opts.depth : defaults.depth,
  3260. duplicates,
  3261. ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
  3262. interpretNumericEntities: typeof opts.interpretNumericEntities === "boolean" ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
  3263. parameterLimit: typeof opts.parameterLimit === "number" ? opts.parameterLimit : defaults.parameterLimit,
  3264. parseArrays: opts.parseArrays !== false,
  3265. plainObjects: typeof opts.plainObjects === "boolean" ? opts.plainObjects : defaults.plainObjects,
  3266. strictDepth: typeof opts.strictDepth === "boolean" ? !!opts.strictDepth : defaults.strictDepth,
  3267. strictMerge: typeof opts.strictMerge === "boolean" ? !!opts.strictMerge : defaults.strictMerge,
  3268. strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults.strictNullHandling,
  3269. throwOnLimitExceeded: typeof opts.throwOnLimitExceeded === "boolean" ? opts.throwOnLimitExceeded : false
  3270. };
  3271. };
  3272. module.exports = function(str, opts) {
  3273. var options = normalizeParseOptions(opts);
  3274. if (str === "" || str === null || typeof str === "undefined") {
  3275. return options.plainObjects ? { __proto__: null } : {};
  3276. }
  3277. var tempObj = typeof str === "string" ? parseValues(str, options) : str;
  3278. var obj = options.plainObjects ? { __proto__: null } : {};
  3279. var keys = Object.keys(tempObj);
  3280. for (var i = 0; i < keys.length; ++i) {
  3281. var key = keys[i];
  3282. var newObj = parseKeys(key, tempObj[key], options, typeof str === "string");
  3283. obj = utils.merge(obj, newObj, options);
  3284. }
  3285. if (options.allowSparse === true) {
  3286. return obj;
  3287. }
  3288. return utils.compact(obj);
  3289. };
  3290. }
  3291. });
  3292. // node_modules/qs/lib/index.js
  3293. var require_lib = __commonJS({
  3294. "node_modules/qs/lib/index.js"(exports, module) {
  3295. "use strict";
  3296. var stringify = require_stringify();
  3297. var parse2 = require_parse();
  3298. var formats = require_formats();
  3299. module.exports = {
  3300. formats,
  3301. parse: parse2,
  3302. stringify
  3303. };
  3304. }
  3305. });
  3306. // node_modules/url/url.js
  3307. var require_url = __commonJS({
  3308. "node_modules/url/url.js"(exports) {
  3309. "use strict";
  3310. var punycode = require_punycode();
  3311. function Url() {
  3312. this.protocol = null;
  3313. this.slashes = null;
  3314. this.auth = null;
  3315. this.host = null;
  3316. this.port = null;
  3317. this.hostname = null;
  3318. this.hash = null;
  3319. this.search = null;
  3320. this.query = null;
  3321. this.pathname = null;
  3322. this.path = null;
  3323. this.href = null;
  3324. }
  3325. var protocolPattern = /^([a-z0-9.+-]+:)/i;
  3326. var portPattern = /:[0-9]*$/;
  3327. var simplePathPattern = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/;
  3328. var delims = [
  3329. "<",
  3330. ">",
  3331. '"',
  3332. "`",
  3333. " ",
  3334. "\r",
  3335. "\n",
  3336. " "
  3337. ];
  3338. var unwise = [
  3339. "{",
  3340. "}",
  3341. "|",
  3342. "\\",
  3343. "^",
  3344. "`"
  3345. ].concat(delims);
  3346. var autoEscape = ["'"].concat(unwise);
  3347. var nonHostChars = [
  3348. "%",
  3349. "/",
  3350. "?",
  3351. ";",
  3352. "#"
  3353. ].concat(autoEscape);
  3354. var hostEndingChars = [
  3355. "/",
  3356. "?",
  3357. "#"
  3358. ];
  3359. var hostnameMaxLen = 255;
  3360. var hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/;
  3361. var hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/;
  3362. var unsafeProtocol = {
  3363. javascript: true,
  3364. "javascript:": true
  3365. };
  3366. var hostlessProtocol = {
  3367. javascript: true,
  3368. "javascript:": true
  3369. };
  3370. var slashedProtocol = {
  3371. http: true,
  3372. https: true,
  3373. ftp: true,
  3374. gopher: true,
  3375. file: true,
  3376. "http:": true,
  3377. "https:": true,
  3378. "ftp:": true,
  3379. "gopher:": true,
  3380. "file:": true
  3381. };
  3382. var querystring = require_lib();
  3383. function urlParse(url2, parseQueryString, slashesDenoteHost) {
  3384. if (url2 && typeof url2 === "object" && url2 instanceof Url) {
  3385. return url2;
  3386. }
  3387. var u = new Url();
  3388. u.parse(url2, parseQueryString, slashesDenoteHost);
  3389. return u;
  3390. }
  3391. Url.prototype.parse = function(url2, parseQueryString, slashesDenoteHost) {
  3392. if (typeof url2 !== "string") {
  3393. throw new TypeError("Parameter 'url' must be a string, not " + typeof url2);
  3394. }
  3395. var queryIndex = url2.indexOf("?"), splitter = queryIndex !== -1 && queryIndex < url2.indexOf("#") ? "?" : "#", uSplit = url2.split(splitter), slashRegex = /\\/g;
  3396. uSplit[0] = uSplit[0].replace(slashRegex, "/");
  3397. url2 = uSplit.join(splitter);
  3398. var rest = url2;
  3399. rest = rest.trim();
  3400. if (!slashesDenoteHost && url2.split("#").length === 1) {
  3401. var simplePath = simplePathPattern.exec(rest);
  3402. if (simplePath) {
  3403. this.path = rest;
  3404. this.href = rest;
  3405. this.pathname = simplePath[1];
  3406. if (simplePath[2]) {
  3407. this.search = simplePath[2];
  3408. if (parseQueryString) {
  3409. this.query = querystring.parse(this.search.substr(1));
  3410. } else {
  3411. this.query = this.search.substr(1);
  3412. }
  3413. } else if (parseQueryString) {
  3414. this.search = "";
  3415. this.query = {};
  3416. }
  3417. return this;
  3418. }
  3419. }
  3420. var proto = protocolPattern.exec(rest);
  3421. if (proto) {
  3422. proto = proto[0];
  3423. var lowerProto = proto.toLowerCase();
  3424. this.protocol = lowerProto;
  3425. rest = rest.substr(proto.length);
  3426. }
  3427. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@/]+@[^@/]+/)) {
  3428. var slashes = rest.substr(0, 2) === "//";
  3429. if (slashes && !(proto && hostlessProtocol[proto])) {
  3430. rest = rest.substr(2);
  3431. this.slashes = true;
  3432. }
  3433. }
  3434. if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) {
  3435. var hostEnd = -1;
  3436. for (var i = 0; i < hostEndingChars.length; i++) {
  3437. var hec = rest.indexOf(hostEndingChars[i]);
  3438. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
  3439. hostEnd = hec;
  3440. }
  3441. }
  3442. var auth, atSign;
  3443. if (hostEnd === -1) {
  3444. atSign = rest.lastIndexOf("@");
  3445. } else {
  3446. atSign = rest.lastIndexOf("@", hostEnd);
  3447. }
  3448. if (atSign !== -1) {
  3449. auth = rest.slice(0, atSign);
  3450. rest = rest.slice(atSign + 1);
  3451. this.auth = decodeURIComponent(auth);
  3452. }
  3453. hostEnd = -1;
  3454. for (var i = 0; i < nonHostChars.length; i++) {
  3455. var hec = rest.indexOf(nonHostChars[i]);
  3456. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
  3457. hostEnd = hec;
  3458. }
  3459. }
  3460. if (hostEnd === -1) {
  3461. hostEnd = rest.length;
  3462. }
  3463. this.host = rest.slice(0, hostEnd);
  3464. rest = rest.slice(hostEnd);
  3465. this.parseHost();
  3466. this.hostname = this.hostname || "";
  3467. var ipv6Hostname = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]";
  3468. if (!ipv6Hostname) {
  3469. var hostparts = this.hostname.split(/\./);
  3470. for (var i = 0, l = hostparts.length; i < l; i++) {
  3471. var part = hostparts[i];
  3472. if (!part) {
  3473. continue;
  3474. }
  3475. if (!part.match(hostnamePartPattern)) {
  3476. var newpart = "";
  3477. for (var j = 0, k = part.length; j < k; j++) {
  3478. if (part.charCodeAt(j) > 127) {
  3479. newpart += "x";
  3480. } else {
  3481. newpart += part[j];
  3482. }
  3483. }
  3484. if (!newpart.match(hostnamePartPattern)) {
  3485. var validParts = hostparts.slice(0, i);
  3486. var notHost = hostparts.slice(i + 1);
  3487. var bit = part.match(hostnamePartStart);
  3488. if (bit) {
  3489. validParts.push(bit[1]);
  3490. notHost.unshift(bit[2]);
  3491. }
  3492. if (notHost.length) {
  3493. rest = "/" + notHost.join(".") + rest;
  3494. }
  3495. this.hostname = validParts.join(".");
  3496. break;
  3497. }
  3498. }
  3499. }
  3500. }
  3501. if (this.hostname.length > hostnameMaxLen) {
  3502. this.hostname = "";
  3503. } else {
  3504. this.hostname = this.hostname.toLowerCase();
  3505. }
  3506. if (!ipv6Hostname) {
  3507. this.hostname = punycode.toASCII(this.hostname);
  3508. }
  3509. var p = this.port ? ":" + this.port : "";
  3510. var h = this.hostname || "";
  3511. this.host = h + p;
  3512. this.href += this.host;
  3513. if (ipv6Hostname) {
  3514. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  3515. if (rest[0] !== "/") {
  3516. rest = "/" + rest;
  3517. }
  3518. }
  3519. }
  3520. if (!unsafeProtocol[lowerProto]) {
  3521. for (var i = 0, l = autoEscape.length; i < l; i++) {
  3522. var ae = autoEscape[i];
  3523. if (rest.indexOf(ae) === -1) {
  3524. continue;
  3525. }
  3526. var esc = encodeURIComponent(ae);
  3527. if (esc === ae) {
  3528. esc = escape(ae);
  3529. }
  3530. rest = rest.split(ae).join(esc);
  3531. }
  3532. }
  3533. var hash = rest.indexOf("#");
  3534. if (hash !== -1) {
  3535. this.hash = rest.substr(hash);
  3536. rest = rest.slice(0, hash);
  3537. }
  3538. var qm = rest.indexOf("?");
  3539. if (qm !== -1) {
  3540. this.search = rest.substr(qm);
  3541. this.query = rest.substr(qm + 1);
  3542. if (parseQueryString) {
  3543. this.query = querystring.parse(this.query);
  3544. }
  3545. rest = rest.slice(0, qm);
  3546. } else if (parseQueryString) {
  3547. this.search = "";
  3548. this.query = {};
  3549. }
  3550. if (rest) {
  3551. this.pathname = rest;
  3552. }
  3553. if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) {
  3554. this.pathname = "/";
  3555. }
  3556. if (this.pathname || this.search) {
  3557. var p = this.pathname || "";
  3558. var s = this.search || "";
  3559. this.path = p + s;
  3560. }
  3561. this.href = this.format();
  3562. return this;
  3563. };
  3564. function urlFormat(obj) {
  3565. if (typeof obj === "string") {
  3566. obj = urlParse(obj);
  3567. }
  3568. if (!(obj instanceof Url)) {
  3569. return Url.prototype.format.call(obj);
  3570. }
  3571. return obj.format();
  3572. }
  3573. Url.prototype.format = function() {
  3574. var auth = this.auth || "";
  3575. if (auth) {
  3576. auth = encodeURIComponent(auth);
  3577. auth = auth.replace(/%3A/i, ":");
  3578. auth += "@";
  3579. }
  3580. var protocol = this.protocol || "", pathname = this.pathname || "", hash = this.hash || "", host = false, query = "";
  3581. if (this.host) {
  3582. host = auth + this.host;
  3583. } else if (this.hostname) {
  3584. host = auth + (this.hostname.indexOf(":") === -1 ? this.hostname : "[" + this.hostname + "]");
  3585. if (this.port) {
  3586. host += ":" + this.port;
  3587. }
  3588. }
  3589. if (this.query && typeof this.query === "object" && Object.keys(this.query).length) {
  3590. query = querystring.stringify(this.query, {
  3591. arrayFormat: "repeat",
  3592. addQueryPrefix: false
  3593. });
  3594. }
  3595. var search = this.search || query && "?" + query || "";
  3596. if (protocol && protocol.substr(-1) !== ":") {
  3597. protocol += ":";
  3598. }
  3599. if (this.slashes || (!protocol || slashedProtocol[protocol]) && host !== false) {
  3600. host = "//" + (host || "");
  3601. if (pathname && pathname.charAt(0) !== "/") {
  3602. pathname = "/" + pathname;
  3603. }
  3604. } else if (!host) {
  3605. host = "";
  3606. }
  3607. if (hash && hash.charAt(0) !== "#") {
  3608. hash = "#" + hash;
  3609. }
  3610. if (search && search.charAt(0) !== "?") {
  3611. search = "?" + search;
  3612. }
  3613. pathname = pathname.replace(/[?#]/g, function(match) {
  3614. return encodeURIComponent(match);
  3615. });
  3616. search = search.replace("#", "%23");
  3617. return protocol + host + pathname + search + hash;
  3618. };
  3619. function urlResolve(source, relative) {
  3620. return urlParse(source, false, true).resolve(relative);
  3621. }
  3622. Url.prototype.resolve = function(relative) {
  3623. return this.resolveObject(urlParse(relative, false, true)).format();
  3624. };
  3625. function urlResolveObject(source, relative) {
  3626. if (!source) {
  3627. return relative;
  3628. }
  3629. return urlParse(source, false, true).resolveObject(relative);
  3630. }
  3631. Url.prototype.resolveObject = function(relative) {
  3632. if (typeof relative === "string") {
  3633. var rel = new Url();
  3634. rel.parse(relative, false, true);
  3635. relative = rel;
  3636. }
  3637. var result = new Url();
  3638. var tkeys = Object.keys(this);
  3639. for (var tk = 0; tk < tkeys.length; tk++) {
  3640. var tkey = tkeys[tk];
  3641. result[tkey] = this[tkey];
  3642. }
  3643. result.hash = relative.hash;
  3644. if (relative.href === "") {
  3645. result.href = result.format();
  3646. return result;
  3647. }
  3648. if (relative.slashes && !relative.protocol) {
  3649. var rkeys = Object.keys(relative);
  3650. for (var rk = 0; rk < rkeys.length; rk++) {
  3651. var rkey = rkeys[rk];
  3652. if (rkey !== "protocol") {
  3653. result[rkey] = relative[rkey];
  3654. }
  3655. }
  3656. if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) {
  3657. result.pathname = "/";
  3658. result.path = result.pathname;
  3659. }
  3660. result.href = result.format();
  3661. return result;
  3662. }
  3663. if (relative.protocol && relative.protocol !== result.protocol) {
  3664. if (!slashedProtocol[relative.protocol]) {
  3665. var keys = Object.keys(relative);
  3666. for (var v = 0; v < keys.length; v++) {
  3667. var k = keys[v];
  3668. result[k] = relative[k];
  3669. }
  3670. result.href = result.format();
  3671. return result;
  3672. }
  3673. result.protocol = relative.protocol;
  3674. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  3675. var relPath = (relative.pathname || "").split("/");
  3676. while (relPath.length && !(relative.host = relPath.shift())) {
  3677. }
  3678. if (!relative.host) {
  3679. relative.host = "";
  3680. }
  3681. if (!relative.hostname) {
  3682. relative.hostname = "";
  3683. }
  3684. if (relPath[0] !== "") {
  3685. relPath.unshift("");
  3686. }
  3687. if (relPath.length < 2) {
  3688. relPath.unshift("");
  3689. }
  3690. result.pathname = relPath.join("/");
  3691. } else {
  3692. result.pathname = relative.pathname;
  3693. }
  3694. result.search = relative.search;
  3695. result.query = relative.query;
  3696. result.host = relative.host || "";
  3697. result.auth = relative.auth;
  3698. result.hostname = relative.hostname || relative.host;
  3699. result.port = relative.port;
  3700. if (result.pathname || result.search) {
  3701. var p = result.pathname || "";
  3702. var s = result.search || "";
  3703. result.path = p + s;
  3704. }
  3705. result.slashes = result.slashes || relative.slashes;
  3706. result.href = result.format();
  3707. return result;
  3708. }
  3709. var isSourceAbs = result.pathname && result.pathname.charAt(0) === "/", isRelAbs = relative.host || relative.pathname && relative.pathname.charAt(0) === "/", mustEndAbs = isRelAbs || isSourceAbs || result.host && relative.pathname, removeAllDots = mustEndAbs, srcPath = result.pathname && result.pathname.split("/") || [], relPath = relative.pathname && relative.pathname.split("/") || [], psychotic = result.protocol && !slashedProtocol[result.protocol];
  3710. if (psychotic) {
  3711. result.hostname = "";
  3712. result.port = null;
  3713. if (result.host) {
  3714. if (srcPath[0] === "") {
  3715. srcPath[0] = result.host;
  3716. } else {
  3717. srcPath.unshift(result.host);
  3718. }
  3719. }
  3720. result.host = "";
  3721. if (relative.protocol) {
  3722. relative.hostname = null;
  3723. relative.port = null;
  3724. if (relative.host) {
  3725. if (relPath[0] === "") {
  3726. relPath[0] = relative.host;
  3727. } else {
  3728. relPath.unshift(relative.host);
  3729. }
  3730. }
  3731. relative.host = null;
  3732. }
  3733. mustEndAbs = mustEndAbs && (relPath[0] === "" || srcPath[0] === "");
  3734. }
  3735. if (isRelAbs) {
  3736. result.host = relative.host || relative.host === "" ? relative.host : result.host;
  3737. result.hostname = relative.hostname || relative.hostname === "" ? relative.hostname : result.hostname;
  3738. result.search = relative.search;
  3739. result.query = relative.query;
  3740. srcPath = relPath;
  3741. } else if (relPath.length) {
  3742. if (!srcPath) {
  3743. srcPath = [];
  3744. }
  3745. srcPath.pop();
  3746. srcPath = srcPath.concat(relPath);
  3747. result.search = relative.search;
  3748. result.query = relative.query;
  3749. } else if (relative.search != null) {
  3750. if (psychotic) {
  3751. result.host = srcPath.shift();
  3752. result.hostname = result.host;
  3753. var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : false;
  3754. if (authInHost) {
  3755. result.auth = authInHost.shift();
  3756. result.hostname = authInHost.shift();
  3757. result.host = result.hostname;
  3758. }
  3759. }
  3760. result.search = relative.search;
  3761. result.query = relative.query;
  3762. if (result.pathname !== null || result.search !== null) {
  3763. result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
  3764. }
  3765. result.href = result.format();
  3766. return result;
  3767. }
  3768. if (!srcPath.length) {
  3769. result.pathname = null;
  3770. if (result.search) {
  3771. result.path = "/" + result.search;
  3772. } else {
  3773. result.path = null;
  3774. }
  3775. result.href = result.format();
  3776. return result;
  3777. }
  3778. var last = srcPath.slice(-1)[0];
  3779. var hasTrailingSlash = (result.host || relative.host || srcPath.length > 1) && (last === "." || last === "..") || last === "";
  3780. var up = 0;
  3781. for (var i = srcPath.length; i >= 0; i--) {
  3782. last = srcPath[i];
  3783. if (last === ".") {
  3784. srcPath.splice(i, 1);
  3785. } else if (last === "..") {
  3786. srcPath.splice(i, 1);
  3787. up++;
  3788. } else if (up) {
  3789. srcPath.splice(i, 1);
  3790. up--;
  3791. }
  3792. }
  3793. if (!mustEndAbs && !removeAllDots) {
  3794. for (; up--; up) {
  3795. srcPath.unshift("..");
  3796. }
  3797. }
  3798. if (mustEndAbs && srcPath[0] !== "" && (!srcPath[0] || srcPath[0].charAt(0) !== "/")) {
  3799. srcPath.unshift("");
  3800. }
  3801. if (hasTrailingSlash && srcPath.join("/").substr(-1) !== "/") {
  3802. srcPath.push("");
  3803. }
  3804. var isAbsolute = srcPath[0] === "" || srcPath[0] && srcPath[0].charAt(0) === "/";
  3805. if (psychotic) {
  3806. result.hostname = isAbsolute ? "" : srcPath.length ? srcPath.shift() : "";
  3807. result.host = result.hostname;
  3808. var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : false;
  3809. if (authInHost) {
  3810. result.auth = authInHost.shift();
  3811. result.hostname = authInHost.shift();
  3812. result.host = result.hostname;
  3813. }
  3814. }
  3815. mustEndAbs = mustEndAbs || result.host && srcPath.length;
  3816. if (mustEndAbs && !isAbsolute) {
  3817. srcPath.unshift("");
  3818. }
  3819. if (srcPath.length > 0) {
  3820. result.pathname = srcPath.join("/");
  3821. } else {
  3822. result.pathname = null;
  3823. result.path = null;
  3824. }
  3825. if (result.pathname !== null || result.search !== null) {
  3826. result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
  3827. }
  3828. result.auth = relative.auth || result.auth;
  3829. result.slashes = result.slashes || relative.slashes;
  3830. result.href = result.format();
  3831. return result;
  3832. };
  3833. Url.prototype.parseHost = function() {
  3834. var host = this.host;
  3835. var port = portPattern.exec(host);
  3836. if (port) {
  3837. port = port[0];
  3838. if (port !== ":") {
  3839. this.port = port.substr(1);
  3840. }
  3841. host = host.substr(0, host.length - port.length);
  3842. }
  3843. if (host) {
  3844. this.hostname = host;
  3845. }
  3846. };
  3847. exports.parse = urlParse;
  3848. exports.resolve = urlResolve;
  3849. exports.resolveObject = urlResolveObject;
  3850. exports.format = urlFormat;
  3851. exports.Url = Url;
  3852. }
  3853. });
  3854. // node_modules/@pixi/constants/dist/esm/constants.mjs
  3855. var ENV;
  3856. (function(ENV2) {
  3857. ENV2[ENV2["WEBGL_LEGACY"] = 0] = "WEBGL_LEGACY";
  3858. ENV2[ENV2["WEBGL"] = 1] = "WEBGL";
  3859. ENV2[ENV2["WEBGL2"] = 2] = "WEBGL2";
  3860. })(ENV || (ENV = {}));
  3861. var RENDERER_TYPE;
  3862. (function(RENDERER_TYPE2) {
  3863. RENDERER_TYPE2[RENDERER_TYPE2["UNKNOWN"] = 0] = "UNKNOWN";
  3864. RENDERER_TYPE2[RENDERER_TYPE2["WEBGL"] = 1] = "WEBGL";
  3865. RENDERER_TYPE2[RENDERER_TYPE2["CANVAS"] = 2] = "CANVAS";
  3866. })(RENDERER_TYPE || (RENDERER_TYPE = {}));
  3867. var BUFFER_BITS;
  3868. (function(BUFFER_BITS2) {
  3869. BUFFER_BITS2[BUFFER_BITS2["COLOR"] = 16384] = "COLOR";
  3870. BUFFER_BITS2[BUFFER_BITS2["DEPTH"] = 256] = "DEPTH";
  3871. BUFFER_BITS2[BUFFER_BITS2["STENCIL"] = 1024] = "STENCIL";
  3872. })(BUFFER_BITS || (BUFFER_BITS = {}));
  3873. var BLEND_MODES;
  3874. (function(BLEND_MODES2) {
  3875. BLEND_MODES2[BLEND_MODES2["NORMAL"] = 0] = "NORMAL";
  3876. BLEND_MODES2[BLEND_MODES2["ADD"] = 1] = "ADD";
  3877. BLEND_MODES2[BLEND_MODES2["MULTIPLY"] = 2] = "MULTIPLY";
  3878. BLEND_MODES2[BLEND_MODES2["SCREEN"] = 3] = "SCREEN";
  3879. BLEND_MODES2[BLEND_MODES2["OVERLAY"] = 4] = "OVERLAY";
  3880. BLEND_MODES2[BLEND_MODES2["DARKEN"] = 5] = "DARKEN";
  3881. BLEND_MODES2[BLEND_MODES2["LIGHTEN"] = 6] = "LIGHTEN";
  3882. BLEND_MODES2[BLEND_MODES2["COLOR_DODGE"] = 7] = "COLOR_DODGE";
  3883. BLEND_MODES2[BLEND_MODES2["COLOR_BURN"] = 8] = "COLOR_BURN";
  3884. BLEND_MODES2[BLEND_MODES2["HARD_LIGHT"] = 9] = "HARD_LIGHT";
  3885. BLEND_MODES2[BLEND_MODES2["SOFT_LIGHT"] = 10] = "SOFT_LIGHT";
  3886. BLEND_MODES2[BLEND_MODES2["DIFFERENCE"] = 11] = "DIFFERENCE";
  3887. BLEND_MODES2[BLEND_MODES2["EXCLUSION"] = 12] = "EXCLUSION";
  3888. BLEND_MODES2[BLEND_MODES2["HUE"] = 13] = "HUE";
  3889. BLEND_MODES2[BLEND_MODES2["SATURATION"] = 14] = "SATURATION";
  3890. BLEND_MODES2[BLEND_MODES2["COLOR"] = 15] = "COLOR";
  3891. BLEND_MODES2[BLEND_MODES2["LUMINOSITY"] = 16] = "LUMINOSITY";
  3892. BLEND_MODES2[BLEND_MODES2["NORMAL_NPM"] = 17] = "NORMAL_NPM";
  3893. BLEND_MODES2[BLEND_MODES2["ADD_NPM"] = 18] = "ADD_NPM";
  3894. BLEND_MODES2[BLEND_MODES2["SCREEN_NPM"] = 19] = "SCREEN_NPM";
  3895. BLEND_MODES2[BLEND_MODES2["NONE"] = 20] = "NONE";
  3896. BLEND_MODES2[BLEND_MODES2["SRC_OVER"] = 0] = "SRC_OVER";
  3897. BLEND_MODES2[BLEND_MODES2["SRC_IN"] = 21] = "SRC_IN";
  3898. BLEND_MODES2[BLEND_MODES2["SRC_OUT"] = 22] = "SRC_OUT";
  3899. BLEND_MODES2[BLEND_MODES2["SRC_ATOP"] = 23] = "SRC_ATOP";
  3900. BLEND_MODES2[BLEND_MODES2["DST_OVER"] = 24] = "DST_OVER";
  3901. BLEND_MODES2[BLEND_MODES2["DST_IN"] = 25] = "DST_IN";
  3902. BLEND_MODES2[BLEND_MODES2["DST_OUT"] = 26] = "DST_OUT";
  3903. BLEND_MODES2[BLEND_MODES2["DST_ATOP"] = 27] = "DST_ATOP";
  3904. BLEND_MODES2[BLEND_MODES2["ERASE"] = 26] = "ERASE";
  3905. BLEND_MODES2[BLEND_MODES2["SUBTRACT"] = 28] = "SUBTRACT";
  3906. BLEND_MODES2[BLEND_MODES2["XOR"] = 29] = "XOR";
  3907. })(BLEND_MODES || (BLEND_MODES = {}));
  3908. var DRAW_MODES;
  3909. (function(DRAW_MODES2) {
  3910. DRAW_MODES2[DRAW_MODES2["POINTS"] = 0] = "POINTS";
  3911. DRAW_MODES2[DRAW_MODES2["LINES"] = 1] = "LINES";
  3912. DRAW_MODES2[DRAW_MODES2["LINE_LOOP"] = 2] = "LINE_LOOP";
  3913. DRAW_MODES2[DRAW_MODES2["LINE_STRIP"] = 3] = "LINE_STRIP";
  3914. DRAW_MODES2[DRAW_MODES2["TRIANGLES"] = 4] = "TRIANGLES";
  3915. DRAW_MODES2[DRAW_MODES2["TRIANGLE_STRIP"] = 5] = "TRIANGLE_STRIP";
  3916. DRAW_MODES2[DRAW_MODES2["TRIANGLE_FAN"] = 6] = "TRIANGLE_FAN";
  3917. })(DRAW_MODES || (DRAW_MODES = {}));
  3918. var FORMATS;
  3919. (function(FORMATS2) {
  3920. FORMATS2[FORMATS2["RGBA"] = 6408] = "RGBA";
  3921. FORMATS2[FORMATS2["RGB"] = 6407] = "RGB";
  3922. FORMATS2[FORMATS2["RG"] = 33319] = "RG";
  3923. FORMATS2[FORMATS2["RED"] = 6403] = "RED";
  3924. FORMATS2[FORMATS2["RGBA_INTEGER"] = 36249] = "RGBA_INTEGER";
  3925. FORMATS2[FORMATS2["RGB_INTEGER"] = 36248] = "RGB_INTEGER";
  3926. FORMATS2[FORMATS2["RG_INTEGER"] = 33320] = "RG_INTEGER";
  3927. FORMATS2[FORMATS2["RED_INTEGER"] = 36244] = "RED_INTEGER";
  3928. FORMATS2[FORMATS2["ALPHA"] = 6406] = "ALPHA";
  3929. FORMATS2[FORMATS2["LUMINANCE"] = 6409] = "LUMINANCE";
  3930. FORMATS2[FORMATS2["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA";
  3931. FORMATS2[FORMATS2["DEPTH_COMPONENT"] = 6402] = "DEPTH_COMPONENT";
  3932. FORMATS2[FORMATS2["DEPTH_STENCIL"] = 34041] = "DEPTH_STENCIL";
  3933. })(FORMATS || (FORMATS = {}));
  3934. var TARGETS;
  3935. (function(TARGETS2) {
  3936. TARGETS2[TARGETS2["TEXTURE_2D"] = 3553] = "TEXTURE_2D";
  3937. TARGETS2[TARGETS2["TEXTURE_CUBE_MAP"] = 34067] = "TEXTURE_CUBE_MAP";
  3938. TARGETS2[TARGETS2["TEXTURE_2D_ARRAY"] = 35866] = "TEXTURE_2D_ARRAY";
  3939. TARGETS2[TARGETS2["TEXTURE_CUBE_MAP_POSITIVE_X"] = 34069] = "TEXTURE_CUBE_MAP_POSITIVE_X";
  3940. TARGETS2[TARGETS2["TEXTURE_CUBE_MAP_NEGATIVE_X"] = 34070] = "TEXTURE_CUBE_MAP_NEGATIVE_X";
  3941. TARGETS2[TARGETS2["TEXTURE_CUBE_MAP_POSITIVE_Y"] = 34071] = "TEXTURE_CUBE_MAP_POSITIVE_Y";
  3942. TARGETS2[TARGETS2["TEXTURE_CUBE_MAP_NEGATIVE_Y"] = 34072] = "TEXTURE_CUBE_MAP_NEGATIVE_Y";
  3943. TARGETS2[TARGETS2["TEXTURE_CUBE_MAP_POSITIVE_Z"] = 34073] = "TEXTURE_CUBE_MAP_POSITIVE_Z";
  3944. TARGETS2[TARGETS2["TEXTURE_CUBE_MAP_NEGATIVE_Z"] = 34074] = "TEXTURE_CUBE_MAP_NEGATIVE_Z";
  3945. })(TARGETS || (TARGETS = {}));
  3946. var TYPES;
  3947. (function(TYPES2) {
  3948. TYPES2[TYPES2["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
  3949. TYPES2[TYPES2["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
  3950. TYPES2[TYPES2["UNSIGNED_SHORT_5_6_5"] = 33635] = "UNSIGNED_SHORT_5_6_5";
  3951. TYPES2[TYPES2["UNSIGNED_SHORT_4_4_4_4"] = 32819] = "UNSIGNED_SHORT_4_4_4_4";
  3952. TYPES2[TYPES2["UNSIGNED_SHORT_5_5_5_1"] = 32820] = "UNSIGNED_SHORT_5_5_5_1";
  3953. TYPES2[TYPES2["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT";
  3954. TYPES2[TYPES2["UNSIGNED_INT_10F_11F_11F_REV"] = 35899] = "UNSIGNED_INT_10F_11F_11F_REV";
  3955. TYPES2[TYPES2["UNSIGNED_INT_2_10_10_10_REV"] = 33640] = "UNSIGNED_INT_2_10_10_10_REV";
  3956. TYPES2[TYPES2["UNSIGNED_INT_24_8"] = 34042] = "UNSIGNED_INT_24_8";
  3957. TYPES2[TYPES2["UNSIGNED_INT_5_9_9_9_REV"] = 35902] = "UNSIGNED_INT_5_9_9_9_REV";
  3958. TYPES2[TYPES2["BYTE"] = 5120] = "BYTE";
  3959. TYPES2[TYPES2["SHORT"] = 5122] = "SHORT";
  3960. TYPES2[TYPES2["INT"] = 5124] = "INT";
  3961. TYPES2[TYPES2["FLOAT"] = 5126] = "FLOAT";
  3962. TYPES2[TYPES2["FLOAT_32_UNSIGNED_INT_24_8_REV"] = 36269] = "FLOAT_32_UNSIGNED_INT_24_8_REV";
  3963. TYPES2[TYPES2["HALF_FLOAT"] = 36193] = "HALF_FLOAT";
  3964. })(TYPES || (TYPES = {}));
  3965. var SAMPLER_TYPES;
  3966. (function(SAMPLER_TYPES2) {
  3967. SAMPLER_TYPES2[SAMPLER_TYPES2["FLOAT"] = 0] = "FLOAT";
  3968. SAMPLER_TYPES2[SAMPLER_TYPES2["INT"] = 1] = "INT";
  3969. SAMPLER_TYPES2[SAMPLER_TYPES2["UINT"] = 2] = "UINT";
  3970. })(SAMPLER_TYPES || (SAMPLER_TYPES = {}));
  3971. var SCALE_MODES;
  3972. (function(SCALE_MODES2) {
  3973. SCALE_MODES2[SCALE_MODES2["NEAREST"] = 0] = "NEAREST";
  3974. SCALE_MODES2[SCALE_MODES2["LINEAR"] = 1] = "LINEAR";
  3975. })(SCALE_MODES || (SCALE_MODES = {}));
  3976. var WRAP_MODES;
  3977. (function(WRAP_MODES2) {
  3978. WRAP_MODES2[WRAP_MODES2["CLAMP"] = 33071] = "CLAMP";
  3979. WRAP_MODES2[WRAP_MODES2["REPEAT"] = 10497] = "REPEAT";
  3980. WRAP_MODES2[WRAP_MODES2["MIRRORED_REPEAT"] = 33648] = "MIRRORED_REPEAT";
  3981. })(WRAP_MODES || (WRAP_MODES = {}));
  3982. var MIPMAP_MODES;
  3983. (function(MIPMAP_MODES2) {
  3984. MIPMAP_MODES2[MIPMAP_MODES2["OFF"] = 0] = "OFF";
  3985. MIPMAP_MODES2[MIPMAP_MODES2["POW2"] = 1] = "POW2";
  3986. MIPMAP_MODES2[MIPMAP_MODES2["ON"] = 2] = "ON";
  3987. MIPMAP_MODES2[MIPMAP_MODES2["ON_MANUAL"] = 3] = "ON_MANUAL";
  3988. })(MIPMAP_MODES || (MIPMAP_MODES = {}));
  3989. var ALPHA_MODES;
  3990. (function(ALPHA_MODES2) {
  3991. ALPHA_MODES2[ALPHA_MODES2["NPM"] = 0] = "NPM";
  3992. ALPHA_MODES2[ALPHA_MODES2["UNPACK"] = 1] = "UNPACK";
  3993. ALPHA_MODES2[ALPHA_MODES2["PMA"] = 2] = "PMA";
  3994. ALPHA_MODES2[ALPHA_MODES2["NO_PREMULTIPLIED_ALPHA"] = 0] = "NO_PREMULTIPLIED_ALPHA";
  3995. ALPHA_MODES2[ALPHA_MODES2["PREMULTIPLY_ON_UPLOAD"] = 1] = "PREMULTIPLY_ON_UPLOAD";
  3996. ALPHA_MODES2[ALPHA_MODES2["PREMULTIPLY_ALPHA"] = 2] = "PREMULTIPLY_ALPHA";
  3997. ALPHA_MODES2[ALPHA_MODES2["PREMULTIPLIED_ALPHA"] = 2] = "PREMULTIPLIED_ALPHA";
  3998. })(ALPHA_MODES || (ALPHA_MODES = {}));
  3999. var CLEAR_MODES;
  4000. (function(CLEAR_MODES2) {
  4001. CLEAR_MODES2[CLEAR_MODES2["NO"] = 0] = "NO";
  4002. CLEAR_MODES2[CLEAR_MODES2["YES"] = 1] = "YES";
  4003. CLEAR_MODES2[CLEAR_MODES2["AUTO"] = 2] = "AUTO";
  4004. CLEAR_MODES2[CLEAR_MODES2["BLEND"] = 0] = "BLEND";
  4005. CLEAR_MODES2[CLEAR_MODES2["CLEAR"] = 1] = "CLEAR";
  4006. CLEAR_MODES2[CLEAR_MODES2["BLIT"] = 2] = "BLIT";
  4007. })(CLEAR_MODES || (CLEAR_MODES = {}));
  4008. var GC_MODES;
  4009. (function(GC_MODES2) {
  4010. GC_MODES2[GC_MODES2["AUTO"] = 0] = "AUTO";
  4011. GC_MODES2[GC_MODES2["MANUAL"] = 1] = "MANUAL";
  4012. })(GC_MODES || (GC_MODES = {}));
  4013. var PRECISION;
  4014. (function(PRECISION2) {
  4015. PRECISION2["LOW"] = "lowp";
  4016. PRECISION2["MEDIUM"] = "mediump";
  4017. PRECISION2["HIGH"] = "highp";
  4018. })(PRECISION || (PRECISION = {}));
  4019. var MASK_TYPES;
  4020. (function(MASK_TYPES2) {
  4021. MASK_TYPES2[MASK_TYPES2["NONE"] = 0] = "NONE";
  4022. MASK_TYPES2[MASK_TYPES2["SCISSOR"] = 1] = "SCISSOR";
  4023. MASK_TYPES2[MASK_TYPES2["STENCIL"] = 2] = "STENCIL";
  4024. MASK_TYPES2[MASK_TYPES2["SPRITE"] = 3] = "SPRITE";
  4025. MASK_TYPES2[MASK_TYPES2["COLOR"] = 4] = "COLOR";
  4026. })(MASK_TYPES || (MASK_TYPES = {}));
  4027. var COLOR_MASK_BITS;
  4028. (function(COLOR_MASK_BITS2) {
  4029. COLOR_MASK_BITS2[COLOR_MASK_BITS2["RED"] = 1] = "RED";
  4030. COLOR_MASK_BITS2[COLOR_MASK_BITS2["GREEN"] = 2] = "GREEN";
  4031. COLOR_MASK_BITS2[COLOR_MASK_BITS2["BLUE"] = 4] = "BLUE";
  4032. COLOR_MASK_BITS2[COLOR_MASK_BITS2["ALPHA"] = 8] = "ALPHA";
  4033. })(COLOR_MASK_BITS || (COLOR_MASK_BITS = {}));
  4034. var MSAA_QUALITY;
  4035. (function(MSAA_QUALITY2) {
  4036. MSAA_QUALITY2[MSAA_QUALITY2["NONE"] = 0] = "NONE";
  4037. MSAA_QUALITY2[MSAA_QUALITY2["LOW"] = 2] = "LOW";
  4038. MSAA_QUALITY2[MSAA_QUALITY2["MEDIUM"] = 4] = "MEDIUM";
  4039. MSAA_QUALITY2[MSAA_QUALITY2["HIGH"] = 8] = "HIGH";
  4040. })(MSAA_QUALITY || (MSAA_QUALITY = {}));
  4041. var BUFFER_TYPE;
  4042. (function(BUFFER_TYPE2) {
  4043. BUFFER_TYPE2[BUFFER_TYPE2["ELEMENT_ARRAY_BUFFER"] = 34963] = "ELEMENT_ARRAY_BUFFER";
  4044. BUFFER_TYPE2[BUFFER_TYPE2["ARRAY_BUFFER"] = 34962] = "ARRAY_BUFFER";
  4045. BUFFER_TYPE2[BUFFER_TYPE2["UNIFORM_BUFFER"] = 35345] = "UNIFORM_BUFFER";
  4046. })(BUFFER_TYPE || (BUFFER_TYPE = {}));
  4047. // node_modules/@pixi/settings/dist/esm/settings.mjs
  4048. var BrowserAdapter = {
  4049. /**
  4050. * Creates a canvas element of the given size.
  4051. * This canvas is created using the browser's native canvas element.
  4052. * @param width - width of the canvas
  4053. * @param height - height of the canvas
  4054. */
  4055. createCanvas: function(width, height) {
  4056. var canvas = document.createElement("canvas");
  4057. canvas.width = width;
  4058. canvas.height = height;
  4059. return canvas;
  4060. },
  4061. getWebGLRenderingContext: function() {
  4062. return WebGLRenderingContext;
  4063. },
  4064. getNavigator: function() {
  4065. return navigator;
  4066. },
  4067. getBaseUrl: function() {
  4068. var _a;
  4069. return (_a = document.baseURI) !== null && _a !== void 0 ? _a : window.location.href;
  4070. },
  4071. fetch: function(url2, options) {
  4072. return fetch(url2, options);
  4073. }
  4074. };
  4075. var appleIphone = /iPhone/i;
  4076. var appleIpod = /iPod/i;
  4077. var appleTablet = /iPad/i;
  4078. var appleUniversal = /\biOS-universal(?:.+)Mac\b/i;
  4079. var androidPhone = /\bAndroid(?:.+)Mobile\b/i;
  4080. var androidTablet = /Android/i;
  4081. var amazonPhone = /(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i;
  4082. var amazonTablet = /Silk/i;
  4083. var windowsPhone = /Windows Phone/i;
  4084. var windowsTablet = /\bWindows(?:.+)ARM\b/i;
  4085. var otherBlackBerry = /BlackBerry/i;
  4086. var otherBlackBerry10 = /BB10/i;
  4087. var otherOpera = /Opera Mini/i;
  4088. var otherChrome = /\b(CriOS|Chrome)(?:.+)Mobile/i;
  4089. var otherFirefox = /Mobile(?:.+)Firefox\b/i;
  4090. var isAppleTabletOnIos13 = function(navigator2) {
  4091. return typeof navigator2 !== "undefined" && navigator2.platform === "MacIntel" && typeof navigator2.maxTouchPoints === "number" && navigator2.maxTouchPoints > 1 && typeof MSStream === "undefined";
  4092. };
  4093. function createMatch(userAgent) {
  4094. return function(regex) {
  4095. return regex.test(userAgent);
  4096. };
  4097. }
  4098. function isMobile$1(param) {
  4099. var nav = {
  4100. userAgent: "",
  4101. platform: "",
  4102. maxTouchPoints: 0
  4103. };
  4104. if (!param && typeof navigator !== "undefined") {
  4105. nav = {
  4106. userAgent: navigator.userAgent,
  4107. platform: navigator.platform,
  4108. maxTouchPoints: navigator.maxTouchPoints || 0
  4109. };
  4110. } else if (typeof param === "string") {
  4111. nav.userAgent = param;
  4112. } else if (param && param.userAgent) {
  4113. nav = {
  4114. userAgent: param.userAgent,
  4115. platform: param.platform,
  4116. maxTouchPoints: param.maxTouchPoints || 0
  4117. };
  4118. }
  4119. var userAgent = nav.userAgent;
  4120. var tmp = userAgent.split("[FBAN");
  4121. if (typeof tmp[1] !== "undefined") {
  4122. userAgent = tmp[0];
  4123. }
  4124. tmp = userAgent.split("Twitter");
  4125. if (typeof tmp[1] !== "undefined") {
  4126. userAgent = tmp[0];
  4127. }
  4128. var match = createMatch(userAgent);
  4129. var result = {
  4130. apple: {
  4131. phone: match(appleIphone) && !match(windowsPhone),
  4132. ipod: match(appleIpod),
  4133. tablet: !match(appleIphone) && (match(appleTablet) || isAppleTabletOnIos13(nav)) && !match(windowsPhone),
  4134. universal: match(appleUniversal),
  4135. device: (match(appleIphone) || match(appleIpod) || match(appleTablet) || match(appleUniversal) || isAppleTabletOnIos13(nav)) && !match(windowsPhone)
  4136. },
  4137. amazon: {
  4138. phone: match(amazonPhone),
  4139. tablet: !match(amazonPhone) && match(amazonTablet),
  4140. device: match(amazonPhone) || match(amazonTablet)
  4141. },
  4142. android: {
  4143. phone: !match(windowsPhone) && match(amazonPhone) || !match(windowsPhone) && match(androidPhone),
  4144. tablet: !match(windowsPhone) && !match(amazonPhone) && !match(androidPhone) && (match(amazonTablet) || match(androidTablet)),
  4145. device: !match(windowsPhone) && (match(amazonPhone) || match(amazonTablet) || match(androidPhone) || match(androidTablet)) || match(/\bokhttp\b/i)
  4146. },
  4147. windows: {
  4148. phone: match(windowsPhone),
  4149. tablet: match(windowsTablet),
  4150. device: match(windowsPhone) || match(windowsTablet)
  4151. },
  4152. other: {
  4153. blackberry: match(otherBlackBerry),
  4154. blackberry10: match(otherBlackBerry10),
  4155. opera: match(otherOpera),
  4156. firefox: match(otherFirefox),
  4157. chrome: match(otherChrome),
  4158. device: match(otherBlackBerry) || match(otherBlackBerry10) || match(otherOpera) || match(otherFirefox) || match(otherChrome)
  4159. },
  4160. any: false,
  4161. phone: false,
  4162. tablet: false
  4163. };
  4164. result.any = result.apple.device || result.android.device || result.windows.device || result.other.device;
  4165. result.phone = result.apple.phone || result.android.phone || result.windows.phone;
  4166. result.tablet = result.apple.tablet || result.android.tablet || result.windows.tablet;
  4167. return result;
  4168. }
  4169. var isMobile = isMobile$1(globalThis.navigator);
  4170. function canUploadSameBuffer() {
  4171. return !isMobile.apple.device;
  4172. }
  4173. function maxRecommendedTextures(max) {
  4174. var allowMax = true;
  4175. if (isMobile.tablet || isMobile.phone) {
  4176. if (isMobile.apple.device) {
  4177. var match = navigator.userAgent.match(/OS (\d+)_(\d+)?/);
  4178. if (match) {
  4179. var majorVersion = parseInt(match[1], 10);
  4180. if (majorVersion < 11) {
  4181. allowMax = false;
  4182. }
  4183. }
  4184. }
  4185. if (isMobile.android.device) {
  4186. var match = navigator.userAgent.match(/Android\s([0-9.]*)/);
  4187. if (match) {
  4188. var majorVersion = parseInt(match[1], 10);
  4189. if (majorVersion < 7) {
  4190. allowMax = false;
  4191. }
  4192. }
  4193. }
  4194. }
  4195. return allowMax ? max : 4;
  4196. }
  4197. var settings = {
  4198. /**
  4199. * This adapter is used to call methods that are platform dependent.
  4200. * For example `document.createElement` only runs on the web but fails in node environments.
  4201. * This allows us to support more platforms by abstracting away specific implementations per platform.
  4202. *
  4203. * By default the adapter is set to work in the browser. However you can create your own
  4204. * by implementing the `IAdapter` interface. See `IAdapter` for more information.
  4205. * @name ADAPTER
  4206. * @memberof PIXI.settings
  4207. * @type {PIXI.IAdapter}
  4208. * @default PIXI.BrowserAdapter
  4209. */
  4210. ADAPTER: BrowserAdapter,
  4211. /**
  4212. * If set to true WebGL will attempt make textures mimpaped by default.
  4213. * Mipmapping will only succeed if the base texture uploaded has power of two dimensions.
  4214. * @static
  4215. * @name MIPMAP_TEXTURES
  4216. * @memberof PIXI.settings
  4217. * @type {PIXI.MIPMAP_MODES}
  4218. * @default PIXI.MIPMAP_MODES.POW2
  4219. */
  4220. MIPMAP_TEXTURES: MIPMAP_MODES.POW2,
  4221. /**
  4222. * Default anisotropic filtering level of textures.
  4223. * Usually from 0 to 16
  4224. * @static
  4225. * @name ANISOTROPIC_LEVEL
  4226. * @memberof PIXI.settings
  4227. * @type {number}
  4228. * @default 0
  4229. */
  4230. ANISOTROPIC_LEVEL: 0,
  4231. /**
  4232. * Default resolution / device pixel ratio of the renderer.
  4233. * @static
  4234. * @name RESOLUTION
  4235. * @memberof PIXI.settings
  4236. * @type {number}
  4237. * @default 1
  4238. */
  4239. RESOLUTION: 1,
  4240. /**
  4241. * Default filter resolution.
  4242. * @static
  4243. * @name FILTER_RESOLUTION
  4244. * @memberof PIXI.settings
  4245. * @type {number}
  4246. * @default 1
  4247. */
  4248. FILTER_RESOLUTION: 1,
  4249. /**
  4250. * Default filter samples.
  4251. * @static
  4252. * @name FILTER_MULTISAMPLE
  4253. * @memberof PIXI.settings
  4254. * @type {PIXI.MSAA_QUALITY}
  4255. * @default PIXI.MSAA_QUALITY.NONE
  4256. */
  4257. FILTER_MULTISAMPLE: MSAA_QUALITY.NONE,
  4258. /**
  4259. * The maximum textures that this device supports.
  4260. * @static
  4261. * @name SPRITE_MAX_TEXTURES
  4262. * @memberof PIXI.settings
  4263. * @type {number}
  4264. * @default 32
  4265. */
  4266. SPRITE_MAX_TEXTURES: maxRecommendedTextures(32),
  4267. // TODO: maybe change to SPRITE.BATCH_SIZE: 2000
  4268. // TODO: maybe add PARTICLE.BATCH_SIZE: 15000
  4269. /**
  4270. * The default sprite batch size.
  4271. *
  4272. * The default aims to balance desktop and mobile devices.
  4273. * @static
  4274. * @name SPRITE_BATCH_SIZE
  4275. * @memberof PIXI.settings
  4276. * @type {number}
  4277. * @default 4096
  4278. */
  4279. SPRITE_BATCH_SIZE: 4096,
  4280. /**
  4281. * The default render options if none are supplied to {@link PIXI.Renderer}
  4282. * or {@link PIXI.CanvasRenderer}.
  4283. * @static
  4284. * @name RENDER_OPTIONS
  4285. * @memberof PIXI.settings
  4286. * @type {object}
  4287. * @property {boolean} [antialias=false] - {@link PIXI.IRendererOptions.antialias}
  4288. * @property {boolean} [autoDensity=false] - {@link PIXI.IRendererOptions.autoDensity}
  4289. * @property {number} [backgroundAlpha=1] - {@link PIXI.IRendererOptions.backgroundAlpha}
  4290. * @property {number} [backgroundColor=0x000000] - {@link PIXI.IRendererOptions.backgroundColor}
  4291. * @property {boolean} [clearBeforeRender=true] - {@link PIXI.IRendererOptions.clearBeforeRender}
  4292. * @property {number} [height=600] - {@link PIXI.IRendererOptions.height}
  4293. * @property {boolean} [preserveDrawingBuffer=false] - {@link PIXI.IRendererOptions.preserveDrawingBuffer}
  4294. * @property {boolean|'notMultiplied'} [useContextAlpha=true] - {@link PIXI.IRendererOptions.useContextAlpha}
  4295. * @property {HTMLCanvasElement} [view=null] - {@link PIXI.IRendererOptions.view}
  4296. * @property {number} [width=800] - {@link PIXI.IRendererOptions.width}
  4297. */
  4298. RENDER_OPTIONS: {
  4299. view: null,
  4300. width: 800,
  4301. height: 600,
  4302. autoDensity: false,
  4303. backgroundColor: 0,
  4304. backgroundAlpha: 1,
  4305. useContextAlpha: true,
  4306. clearBeforeRender: true,
  4307. antialias: false,
  4308. preserveDrawingBuffer: false
  4309. },
  4310. /**
  4311. * Default Garbage Collection mode.
  4312. * @static
  4313. * @name GC_MODE
  4314. * @memberof PIXI.settings
  4315. * @type {PIXI.GC_MODES}
  4316. * @default PIXI.GC_MODES.AUTO
  4317. */
  4318. GC_MODE: GC_MODES.AUTO,
  4319. /**
  4320. * Default Garbage Collection max idle.
  4321. * @static
  4322. * @name GC_MAX_IDLE
  4323. * @memberof PIXI.settings
  4324. * @type {number}
  4325. * @default 3600
  4326. */
  4327. GC_MAX_IDLE: 60 * 60,
  4328. /**
  4329. * Default Garbage Collection maximum check count.
  4330. * @static
  4331. * @name GC_MAX_CHECK_COUNT
  4332. * @memberof PIXI.settings
  4333. * @type {number}
  4334. * @default 600
  4335. */
  4336. GC_MAX_CHECK_COUNT: 60 * 10,
  4337. /**
  4338. * Default wrap modes that are supported by pixi.
  4339. * @static
  4340. * @name WRAP_MODE
  4341. * @memberof PIXI.settings
  4342. * @type {PIXI.WRAP_MODES}
  4343. * @default PIXI.WRAP_MODES.CLAMP
  4344. */
  4345. WRAP_MODE: WRAP_MODES.CLAMP,
  4346. /**
  4347. * Default scale mode for textures.
  4348. * @static
  4349. * @name SCALE_MODE
  4350. * @memberof PIXI.settings
  4351. * @type {PIXI.SCALE_MODES}
  4352. * @default PIXI.SCALE_MODES.LINEAR
  4353. */
  4354. SCALE_MODE: SCALE_MODES.LINEAR,
  4355. /**
  4356. * Default specify float precision in vertex shader.
  4357. * @static
  4358. * @name PRECISION_VERTEX
  4359. * @memberof PIXI.settings
  4360. * @type {PIXI.PRECISION}
  4361. * @default PIXI.PRECISION.HIGH
  4362. */
  4363. PRECISION_VERTEX: PRECISION.HIGH,
  4364. /**
  4365. * Default specify float precision in fragment shader.
  4366. * iOS is best set at highp due to https://github.com/pixijs/pixi.js/issues/3742
  4367. * @static
  4368. * @name PRECISION_FRAGMENT
  4369. * @memberof PIXI.settings
  4370. * @type {PIXI.PRECISION}
  4371. * @default PIXI.PRECISION.MEDIUM
  4372. */
  4373. PRECISION_FRAGMENT: isMobile.apple.device ? PRECISION.HIGH : PRECISION.MEDIUM,
  4374. /**
  4375. * Can we upload the same buffer in a single frame?
  4376. * @static
  4377. * @name CAN_UPLOAD_SAME_BUFFER
  4378. * @memberof PIXI.settings
  4379. * @type {boolean}
  4380. */
  4381. CAN_UPLOAD_SAME_BUFFER: canUploadSameBuffer(),
  4382. /**
  4383. * Enables bitmap creation before image load. This feature is experimental.
  4384. * @static
  4385. * @name CREATE_IMAGE_BITMAP
  4386. * @memberof PIXI.settings
  4387. * @type {boolean}
  4388. * @default false
  4389. */
  4390. CREATE_IMAGE_BITMAP: false,
  4391. /**
  4392. * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.
  4393. * Advantages can include sharper image quality (like text) and faster rendering on canvas.
  4394. * The main disadvantage is movement of objects may appear less smooth.
  4395. * @static
  4396. * @constant
  4397. * @memberof PIXI.settings
  4398. * @type {boolean}
  4399. * @default false
  4400. */
  4401. ROUND_PIXELS: false
  4402. };
  4403. // node_modules/@pixi/utils/dist/esm/utils.mjs
  4404. var utils_exports = {};
  4405. __export(utils_exports, {
  4406. BaseTextureCache: () => BaseTextureCache,
  4407. CanvasRenderTarget: () => CanvasRenderTarget,
  4408. DATA_URI: () => DATA_URI,
  4409. EventEmitter: () => import_eventemitter3.default,
  4410. ProgramCache: () => ProgramCache,
  4411. TextureCache: () => TextureCache,
  4412. clearTextureCache: () => clearTextureCache,
  4413. correctBlendMode: () => correctBlendMode,
  4414. createIndicesForQuads: () => createIndicesForQuads,
  4415. decomposeDataUri: () => decomposeDataUri,
  4416. deprecation: () => deprecation,
  4417. destroyTextureCache: () => destroyTextureCache,
  4418. determineCrossOrigin: () => determineCrossOrigin,
  4419. earcut: () => import_earcut.default,
  4420. getBufferType: () => getBufferType,
  4421. getResolutionOfUrl: () => getResolutionOfUrl,
  4422. hex2rgb: () => hex2rgb,
  4423. hex2string: () => hex2string,
  4424. interleaveTypedArrays: () => interleaveTypedArrays,
  4425. isMobile: () => isMobile,
  4426. isPow2: () => isPow2,
  4427. isWebGLSupported: () => isWebGLSupported,
  4428. log2: () => log2,
  4429. nextPow2: () => nextPow2,
  4430. path: () => path,
  4431. premultiplyBlendMode: () => premultiplyBlendMode,
  4432. premultiplyRgba: () => premultiplyRgba,
  4433. premultiplyTint: () => premultiplyTint,
  4434. premultiplyTintToRgba: () => premultiplyTintToRgba,
  4435. removeItems: () => removeItems,
  4436. rgb2hex: () => rgb2hex,
  4437. sayHello: () => sayHello,
  4438. sign: () => sign,
  4439. skipHello: () => skipHello,
  4440. string2hex: () => string2hex,
  4441. trimCanvas: () => trimCanvas,
  4442. uid: () => uid,
  4443. url: () => url
  4444. });
  4445. var import_eventemitter3 = __toESM(require_eventemitter3(), 1);
  4446. var import_earcut = __toESM(require_earcut(), 1);
  4447. var import_url = __toESM(require_url(), 1);
  4448. var url = {
  4449. parse: import_url.parse,
  4450. format: import_url.format,
  4451. resolve: import_url.resolve
  4452. };
  4453. function assertPath(path2) {
  4454. if (typeof path2 !== "string") {
  4455. throw new TypeError("Path must be a string. Received " + JSON.stringify(path2));
  4456. }
  4457. }
  4458. function removeUrlParams(url2) {
  4459. var re = url2.split("?")[0];
  4460. return re.split("#")[0];
  4461. }
  4462. function escapeRegExp(string) {
  4463. return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
  4464. }
  4465. function replaceAll(str, find, replace) {
  4466. return str.replace(new RegExp(escapeRegExp(find), "g"), replace);
  4467. }
  4468. function normalizeStringPosix(path2, allowAboveRoot) {
  4469. var res = "";
  4470. var lastSegmentLength = 0;
  4471. var lastSlash = -1;
  4472. var dots = 0;
  4473. var code;
  4474. for (var i = 0; i <= path2.length; ++i) {
  4475. if (i < path2.length) {
  4476. code = path2.charCodeAt(i);
  4477. } else if (code === 47) {
  4478. break;
  4479. } else {
  4480. code = 47;
  4481. }
  4482. if (code === 47) {
  4483. if (lastSlash === i - 1 || dots === 1) ;
  4484. else if (lastSlash !== i - 1 && dots === 2) {
  4485. if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
  4486. if (res.length > 2) {
  4487. var lastSlashIndex = res.lastIndexOf("/");
  4488. if (lastSlashIndex !== res.length - 1) {
  4489. if (lastSlashIndex === -1) {
  4490. res = "";
  4491. lastSegmentLength = 0;
  4492. } else {
  4493. res = res.slice(0, lastSlashIndex);
  4494. lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
  4495. }
  4496. lastSlash = i;
  4497. dots = 0;
  4498. continue;
  4499. }
  4500. } else if (res.length === 2 || res.length === 1) {
  4501. res = "";
  4502. lastSegmentLength = 0;
  4503. lastSlash = i;
  4504. dots = 0;
  4505. continue;
  4506. }
  4507. }
  4508. if (allowAboveRoot) {
  4509. if (res.length > 0) {
  4510. res += "/..";
  4511. } else {
  4512. res = "..";
  4513. }
  4514. lastSegmentLength = 2;
  4515. }
  4516. } else {
  4517. if (res.length > 0) {
  4518. res += "/" + path2.slice(lastSlash + 1, i);
  4519. } else {
  4520. res = path2.slice(lastSlash + 1, i);
  4521. }
  4522. lastSegmentLength = i - lastSlash - 1;
  4523. }
  4524. lastSlash = i;
  4525. dots = 0;
  4526. } else if (code === 46 && dots !== -1) {
  4527. ++dots;
  4528. } else {
  4529. dots = -1;
  4530. }
  4531. }
  4532. return res;
  4533. }
  4534. var path = {
  4535. /**
  4536. * Converts a path to posix format.
  4537. * @param path - The path to convert to posix
  4538. */
  4539. toPosix: function(path2) {
  4540. return replaceAll(path2, "\\", "/");
  4541. },
  4542. /**
  4543. * Checks if the path is a URL
  4544. * @param path - The path to check
  4545. */
  4546. isUrl: function(path2) {
  4547. return /^https?:/.test(this.toPosix(path2));
  4548. },
  4549. /**
  4550. * Checks if the path is a data URL
  4551. * @param path - The path to check
  4552. */
  4553. isDataUrl: function(path2) {
  4554. return /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(path2);
  4555. },
  4556. /**
  4557. * Checks if the path has a protocol e.g. http://
  4558. * This will return true for windows file paths
  4559. * @param path - The path to check
  4560. */
  4561. hasProtocol: function(path2) {
  4562. return /^[^/:]+:\//.test(this.toPosix(path2));
  4563. },
  4564. /**
  4565. * Returns the protocol of the path e.g. http://, C:/, file:///
  4566. * @param path - The path to get the protocol from
  4567. */
  4568. getProtocol: function(path2) {
  4569. assertPath(path2);
  4570. path2 = this.toPosix(path2);
  4571. var protocol = "";
  4572. var isFile = /^file:\/\/\//.exec(path2);
  4573. var isHttp = /^[^/:]+:\/\//.exec(path2);
  4574. var isWindows = /^[^/:]+:\//.exec(path2);
  4575. if (isFile || isHttp || isWindows) {
  4576. var arr = (isFile === null || isFile === void 0 ? void 0 : isFile[0]) || (isHttp === null || isHttp === void 0 ? void 0 : isHttp[0]) || (isWindows === null || isWindows === void 0 ? void 0 : isWindows[0]);
  4577. protocol = arr;
  4578. path2 = path2.slice(arr.length);
  4579. }
  4580. return protocol;
  4581. },
  4582. /**
  4583. * Converts URL to an absolute path.
  4584. * When loading from a Web Worker, we must use absolute paths.
  4585. * If the URL is already absolute we return it as is
  4586. * If it's not, we convert it
  4587. * @param url - The URL to test
  4588. * @param customBaseUrl - The base URL to use
  4589. * @param customRootUrl - The root URL to use
  4590. */
  4591. toAbsolute: function(url2, customBaseUrl, customRootUrl) {
  4592. if (this.isDataUrl(url2)) {
  4593. return url2;
  4594. }
  4595. var baseUrl = removeUrlParams(this.toPosix(customBaseUrl !== null && customBaseUrl !== void 0 ? customBaseUrl : settings.ADAPTER.getBaseUrl()));
  4596. var rootUrl = removeUrlParams(this.toPosix(customRootUrl !== null && customRootUrl !== void 0 ? customRootUrl : this.rootname(baseUrl)));
  4597. assertPath(url2);
  4598. url2 = this.toPosix(url2);
  4599. if (url2.startsWith("/")) {
  4600. return path.join(rootUrl, url2.slice(1));
  4601. }
  4602. var absolutePath = this.isAbsolute(url2) ? url2 : this.join(baseUrl, url2);
  4603. return absolutePath;
  4604. },
  4605. /**
  4606. * Normalizes the given path, resolving '..' and '.' segments
  4607. * @param path - The path to normalize
  4608. */
  4609. normalize: function(path2) {
  4610. path2 = this.toPosix(path2);
  4611. assertPath(path2);
  4612. if (path2.length === 0) {
  4613. return ".";
  4614. }
  4615. var protocol = "";
  4616. var isAbsolute = path2.startsWith("/");
  4617. if (this.hasProtocol(path2)) {
  4618. protocol = this.rootname(path2);
  4619. path2 = path2.slice(protocol.length);
  4620. }
  4621. var trailingSeparator = path2.endsWith("/");
  4622. path2 = normalizeStringPosix(path2, false);
  4623. if (path2.length > 0 && trailingSeparator) {
  4624. path2 += "/";
  4625. }
  4626. if (isAbsolute) {
  4627. return "/" + path2;
  4628. }
  4629. return protocol + path2;
  4630. },
  4631. /**
  4632. * Determines if path is an absolute path.
  4633. * Absolute paths can be urls, data urls, or paths on disk
  4634. * @param path - The path to test
  4635. */
  4636. isAbsolute: function(path2) {
  4637. assertPath(path2);
  4638. path2 = this.toPosix(path2);
  4639. if (this.hasProtocol(path2)) {
  4640. return true;
  4641. }
  4642. return path2.startsWith("/");
  4643. },
  4644. /**
  4645. * Joins all given path segments together using the platform-specific separator as a delimiter,
  4646. * then normalizes the resulting path
  4647. * @param segments - The segments of the path to join
  4648. */
  4649. join: function() {
  4650. var arguments$1 = arguments;
  4651. var _a;
  4652. var segments = [];
  4653. for (var _i = 0; _i < arguments.length; _i++) {
  4654. segments[_i] = arguments$1[_i];
  4655. }
  4656. if (segments.length === 0) {
  4657. return ".";
  4658. }
  4659. var joined;
  4660. for (var i = 0; i < segments.length; ++i) {
  4661. var arg = segments[i];
  4662. assertPath(arg);
  4663. if (arg.length > 0) {
  4664. if (joined === void 0) {
  4665. joined = arg;
  4666. } else {
  4667. var prevArg = (_a = segments[i - 1]) !== null && _a !== void 0 ? _a : "";
  4668. if (this.extname(prevArg)) {
  4669. joined += "/../" + arg;
  4670. } else {
  4671. joined += "/" + arg;
  4672. }
  4673. }
  4674. }
  4675. }
  4676. if (joined === void 0) {
  4677. return ".";
  4678. }
  4679. return this.normalize(joined);
  4680. },
  4681. /**
  4682. * Returns the directory name of a path
  4683. * @param path - The path to parse
  4684. */
  4685. dirname: function(path2) {
  4686. assertPath(path2);
  4687. if (path2.length === 0) {
  4688. return ".";
  4689. }
  4690. path2 = this.toPosix(path2);
  4691. var code = path2.charCodeAt(0);
  4692. var hasRoot = code === 47;
  4693. var end = -1;
  4694. var matchedSlash = true;
  4695. var proto = this.getProtocol(path2);
  4696. var origpath = path2;
  4697. path2 = path2.slice(proto.length);
  4698. for (var i = path2.length - 1; i >= 1; --i) {
  4699. code = path2.charCodeAt(i);
  4700. if (code === 47) {
  4701. if (!matchedSlash) {
  4702. end = i;
  4703. break;
  4704. }
  4705. } else {
  4706. matchedSlash = false;
  4707. }
  4708. }
  4709. if (end === -1) {
  4710. return hasRoot ? "/" : this.isUrl(origpath) ? proto + path2 : proto;
  4711. }
  4712. if (hasRoot && end === 1) {
  4713. return "//";
  4714. }
  4715. return proto + path2.slice(0, end);
  4716. },
  4717. /**
  4718. * Returns the root of the path e.g. /, C:/, file:///, http://domain.com/
  4719. * @param path - The path to parse
  4720. */
  4721. rootname: function(path2) {
  4722. assertPath(path2);
  4723. path2 = this.toPosix(path2);
  4724. var root = "";
  4725. if (path2.startsWith("/")) {
  4726. root = "/";
  4727. } else {
  4728. root = this.getProtocol(path2);
  4729. }
  4730. if (this.isUrl(path2)) {
  4731. var index = path2.indexOf("/", root.length);
  4732. if (index !== -1) {
  4733. root = path2.slice(0, index);
  4734. } else {
  4735. root = path2;
  4736. }
  4737. if (!root.endsWith("/")) {
  4738. root += "/";
  4739. }
  4740. }
  4741. return root;
  4742. },
  4743. /**
  4744. * Returns the last portion of a path
  4745. * @param path - The path to test
  4746. * @param ext - Optional extension to remove
  4747. */
  4748. basename: function(path2, ext) {
  4749. assertPath(path2);
  4750. if (ext) {
  4751. assertPath(ext);
  4752. }
  4753. path2 = this.toPosix(path2);
  4754. var start = 0;
  4755. var end = -1;
  4756. var matchedSlash = true;
  4757. var i;
  4758. if (ext !== void 0 && ext.length > 0 && ext.length <= path2.length) {
  4759. if (ext.length === path2.length && ext === path2) {
  4760. return "";
  4761. }
  4762. var extIdx = ext.length - 1;
  4763. var firstNonSlashEnd = -1;
  4764. for (i = path2.length - 1; i >= 0; --i) {
  4765. var code = path2.charCodeAt(i);
  4766. if (code === 47) {
  4767. if (!matchedSlash) {
  4768. start = i + 1;
  4769. break;
  4770. }
  4771. } else {
  4772. if (firstNonSlashEnd === -1) {
  4773. matchedSlash = false;
  4774. firstNonSlashEnd = i + 1;
  4775. }
  4776. if (extIdx >= 0) {
  4777. if (code === ext.charCodeAt(extIdx)) {
  4778. if (--extIdx === -1) {
  4779. end = i;
  4780. }
  4781. } else {
  4782. extIdx = -1;
  4783. end = firstNonSlashEnd;
  4784. }
  4785. }
  4786. }
  4787. }
  4788. if (start === end) {
  4789. end = firstNonSlashEnd;
  4790. } else if (end === -1) {
  4791. end = path2.length;
  4792. }
  4793. return path2.slice(start, end);
  4794. }
  4795. for (i = path2.length - 1; i >= 0; --i) {
  4796. if (path2.charCodeAt(i) === 47) {
  4797. if (!matchedSlash) {
  4798. start = i + 1;
  4799. break;
  4800. }
  4801. } else if (end === -1) {
  4802. matchedSlash = false;
  4803. end = i + 1;
  4804. }
  4805. }
  4806. if (end === -1) {
  4807. return "";
  4808. }
  4809. return path2.slice(start, end);
  4810. },
  4811. /**
  4812. * Returns the extension of the path, from the last occurrence of the . (period) character to end of string in the last
  4813. * portion of the path. If there is no . in the last portion of the path, or if there are no . characters other than
  4814. * the first character of the basename of path, an empty string is returned.
  4815. * @param path - The path to parse
  4816. */
  4817. extname: function(path2) {
  4818. assertPath(path2);
  4819. path2 = this.toPosix(path2);
  4820. var startDot = -1;
  4821. var startPart = 0;
  4822. var end = -1;
  4823. var matchedSlash = true;
  4824. var preDotState = 0;
  4825. for (var i = path2.length - 1; i >= 0; --i) {
  4826. var code = path2.charCodeAt(i);
  4827. if (code === 47) {
  4828. if (!matchedSlash) {
  4829. startPart = i + 1;
  4830. break;
  4831. }
  4832. continue;
  4833. }
  4834. if (end === -1) {
  4835. matchedSlash = false;
  4836. end = i + 1;
  4837. }
  4838. if (code === 46) {
  4839. if (startDot === -1) {
  4840. startDot = i;
  4841. } else if (preDotState !== 1) {
  4842. preDotState = 1;
  4843. }
  4844. } else if (startDot !== -1) {
  4845. preDotState = -1;
  4846. }
  4847. }
  4848. if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
  4849. return "";
  4850. }
  4851. return path2.slice(startDot, end);
  4852. },
  4853. /**
  4854. * Parses a path into an object containing the 'root', `dir`, `base`, `ext`, and `name` properties.
  4855. * @param path - The path to parse
  4856. */
  4857. parse: function(path2) {
  4858. assertPath(path2);
  4859. var ret = { root: "", dir: "", base: "", ext: "", name: "" };
  4860. if (path2.length === 0) {
  4861. return ret;
  4862. }
  4863. path2 = this.toPosix(path2);
  4864. var code = path2.charCodeAt(0);
  4865. var isAbsolute = this.isAbsolute(path2);
  4866. var start;
  4867. ret.root = this.rootname(path2);
  4868. if (isAbsolute || this.hasProtocol(path2)) {
  4869. start = 1;
  4870. } else {
  4871. start = 0;
  4872. }
  4873. var startDot = -1;
  4874. var startPart = 0;
  4875. var end = -1;
  4876. var matchedSlash = true;
  4877. var i = path2.length - 1;
  4878. var preDotState = 0;
  4879. for (; i >= start; --i) {
  4880. code = path2.charCodeAt(i);
  4881. if (code === 47) {
  4882. if (!matchedSlash) {
  4883. startPart = i + 1;
  4884. break;
  4885. }
  4886. continue;
  4887. }
  4888. if (end === -1) {
  4889. matchedSlash = false;
  4890. end = i + 1;
  4891. }
  4892. if (code === 46) {
  4893. if (startDot === -1) {
  4894. startDot = i;
  4895. } else if (preDotState !== 1) {
  4896. preDotState = 1;
  4897. }
  4898. } else if (startDot !== -1) {
  4899. preDotState = -1;
  4900. }
  4901. }
  4902. if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
  4903. if (end !== -1) {
  4904. if (startPart === 0 && isAbsolute) {
  4905. ret.base = ret.name = path2.slice(1, end);
  4906. } else {
  4907. ret.base = ret.name = path2.slice(startPart, end);
  4908. }
  4909. }
  4910. } else {
  4911. if (startPart === 0 && isAbsolute) {
  4912. ret.name = path2.slice(1, startDot);
  4913. ret.base = path2.slice(1, end);
  4914. } else {
  4915. ret.name = path2.slice(startPart, startDot);
  4916. ret.base = path2.slice(startPart, end);
  4917. }
  4918. ret.ext = path2.slice(startDot, end);
  4919. }
  4920. ret.dir = this.dirname(path2);
  4921. return ret;
  4922. },
  4923. sep: "/",
  4924. delimiter: ":"
  4925. };
  4926. settings.RETINA_PREFIX = /@([0-9\.]+)x/;
  4927. settings.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT = false;
  4928. var saidHello = false;
  4929. var VERSION = "6.5.10";
  4930. function skipHello() {
  4931. saidHello = true;
  4932. }
  4933. function sayHello(type) {
  4934. var _a;
  4935. if (saidHello) {
  4936. return;
  4937. }
  4938. if (settings.ADAPTER.getNavigator().userAgent.toLowerCase().indexOf("chrome") > -1) {
  4939. var args = [
  4940. "\n %c %c %c PixiJS " + VERSION + " - ✰ " + type + " ✰ %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥ \n\n",
  4941. "background: #ff66a5; padding:5px 0;",
  4942. "background: #ff66a5; padding:5px 0;",
  4943. "color: #ff66a5; background: #030307; padding:5px 0;",
  4944. "background: #ff66a5; padding:5px 0;",
  4945. "background: #ffc3dc; padding:5px 0;",
  4946. "background: #ff66a5; padding:5px 0;",
  4947. "color: #ff2424; background: #fff; padding:5px 0;",
  4948. "color: #ff2424; background: #fff; padding:5px 0;",
  4949. "color: #ff2424; background: #fff; padding:5px 0;"
  4950. ];
  4951. (_a = globalThis.console).log.apply(_a, args);
  4952. } else if (globalThis.console) {
  4953. globalThis.console.log("PixiJS " + VERSION + " - " + type + " - http://www.pixijs.com/");
  4954. }
  4955. saidHello = true;
  4956. }
  4957. var supported;
  4958. function isWebGLSupported() {
  4959. if (typeof supported === "undefined") {
  4960. supported = (function supported2() {
  4961. var contextOptions = {
  4962. stencil: true,
  4963. failIfMajorPerformanceCaveat: settings.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT
  4964. };
  4965. try {
  4966. if (!settings.ADAPTER.getWebGLRenderingContext()) {
  4967. return false;
  4968. }
  4969. var canvas = settings.ADAPTER.createCanvas();
  4970. var gl = canvas.getContext("webgl", contextOptions) || canvas.getContext("experimental-webgl", contextOptions);
  4971. var success = !!(gl && gl.getContextAttributes().stencil);
  4972. if (gl) {
  4973. var loseContext = gl.getExtension("WEBGL_lose_context");
  4974. if (loseContext) {
  4975. loseContext.loseContext();
  4976. }
  4977. }
  4978. gl = null;
  4979. return success;
  4980. } catch (e) {
  4981. return false;
  4982. }
  4983. })();
  4984. }
  4985. return supported;
  4986. }
  4987. var aliceblue = "#f0f8ff";
  4988. var antiquewhite = "#faebd7";
  4989. var aqua = "#00ffff";
  4990. var aquamarine = "#7fffd4";
  4991. var azure = "#f0ffff";
  4992. var beige = "#f5f5dc";
  4993. var bisque = "#ffe4c4";
  4994. var black = "#000000";
  4995. var blanchedalmond = "#ffebcd";
  4996. var blue = "#0000ff";
  4997. var blueviolet = "#8a2be2";
  4998. var brown = "#a52a2a";
  4999. var burlywood = "#deb887";
  5000. var cadetblue = "#5f9ea0";
  5001. var chartreuse = "#7fff00";
  5002. var chocolate = "#d2691e";
  5003. var coral = "#ff7f50";
  5004. var cornflowerblue = "#6495ed";
  5005. var cornsilk = "#fff8dc";
  5006. var crimson = "#dc143c";
  5007. var cyan = "#00ffff";
  5008. var darkblue = "#00008b";
  5009. var darkcyan = "#008b8b";
  5010. var darkgoldenrod = "#b8860b";
  5011. var darkgray = "#a9a9a9";
  5012. var darkgreen = "#006400";
  5013. var darkgrey = "#a9a9a9";
  5014. var darkkhaki = "#bdb76b";
  5015. var darkmagenta = "#8b008b";
  5016. var darkolivegreen = "#556b2f";
  5017. var darkorange = "#ff8c00";
  5018. var darkorchid = "#9932cc";
  5019. var darkred = "#8b0000";
  5020. var darksalmon = "#e9967a";
  5021. var darkseagreen = "#8fbc8f";
  5022. var darkslateblue = "#483d8b";
  5023. var darkslategray = "#2f4f4f";
  5024. var darkslategrey = "#2f4f4f";
  5025. var darkturquoise = "#00ced1";
  5026. var darkviolet = "#9400d3";
  5027. var deeppink = "#ff1493";
  5028. var deepskyblue = "#00bfff";
  5029. var dimgray = "#696969";
  5030. var dimgrey = "#696969";
  5031. var dodgerblue = "#1e90ff";
  5032. var firebrick = "#b22222";
  5033. var floralwhite = "#fffaf0";
  5034. var forestgreen = "#228b22";
  5035. var fuchsia = "#ff00ff";
  5036. var gainsboro = "#dcdcdc";
  5037. var ghostwhite = "#f8f8ff";
  5038. var goldenrod = "#daa520";
  5039. var gold = "#ffd700";
  5040. var gray = "#808080";
  5041. var green = "#008000";
  5042. var greenyellow = "#adff2f";
  5043. var grey = "#808080";
  5044. var honeydew = "#f0fff0";
  5045. var hotpink = "#ff69b4";
  5046. var indianred = "#cd5c5c";
  5047. var indigo = "#4b0082";
  5048. var ivory = "#fffff0";
  5049. var khaki = "#f0e68c";
  5050. var lavenderblush = "#fff0f5";
  5051. var lavender = "#e6e6fa";
  5052. var lawngreen = "#7cfc00";
  5053. var lemonchiffon = "#fffacd";
  5054. var lightblue = "#add8e6";
  5055. var lightcoral = "#f08080";
  5056. var lightcyan = "#e0ffff";
  5057. var lightgoldenrodyellow = "#fafad2";
  5058. var lightgray = "#d3d3d3";
  5059. var lightgreen = "#90ee90";
  5060. var lightgrey = "#d3d3d3";
  5061. var lightpink = "#ffb6c1";
  5062. var lightsalmon = "#ffa07a";
  5063. var lightseagreen = "#20b2aa";
  5064. var lightskyblue = "#87cefa";
  5065. var lightslategray = "#778899";
  5066. var lightslategrey = "#778899";
  5067. var lightsteelblue = "#b0c4de";
  5068. var lightyellow = "#ffffe0";
  5069. var lime = "#00ff00";
  5070. var limegreen = "#32cd32";
  5071. var linen = "#faf0e6";
  5072. var magenta = "#ff00ff";
  5073. var maroon = "#800000";
  5074. var mediumaquamarine = "#66cdaa";
  5075. var mediumblue = "#0000cd";
  5076. var mediumorchid = "#ba55d3";
  5077. var mediumpurple = "#9370db";
  5078. var mediumseagreen = "#3cb371";
  5079. var mediumslateblue = "#7b68ee";
  5080. var mediumspringgreen = "#00fa9a";
  5081. var mediumturquoise = "#48d1cc";
  5082. var mediumvioletred = "#c71585";
  5083. var midnightblue = "#191970";
  5084. var mintcream = "#f5fffa";
  5085. var mistyrose = "#ffe4e1";
  5086. var moccasin = "#ffe4b5";
  5087. var navajowhite = "#ffdead";
  5088. var navy = "#000080";
  5089. var oldlace = "#fdf5e6";
  5090. var olive = "#808000";
  5091. var olivedrab = "#6b8e23";
  5092. var orange = "#ffa500";
  5093. var orangered = "#ff4500";
  5094. var orchid = "#da70d6";
  5095. var palegoldenrod = "#eee8aa";
  5096. var palegreen = "#98fb98";
  5097. var paleturquoise = "#afeeee";
  5098. var palevioletred = "#db7093";
  5099. var papayawhip = "#ffefd5";
  5100. var peachpuff = "#ffdab9";
  5101. var peru = "#cd853f";
  5102. var pink = "#ffc0cb";
  5103. var plum = "#dda0dd";
  5104. var powderblue = "#b0e0e6";
  5105. var purple = "#800080";
  5106. var rebeccapurple = "#663399";
  5107. var red = "#ff0000";
  5108. var rosybrown = "#bc8f8f";
  5109. var royalblue = "#4169e1";
  5110. var saddlebrown = "#8b4513";
  5111. var salmon = "#fa8072";
  5112. var sandybrown = "#f4a460";
  5113. var seagreen = "#2e8b57";
  5114. var seashell = "#fff5ee";
  5115. var sienna = "#a0522d";
  5116. var silver = "#c0c0c0";
  5117. var skyblue = "#87ceeb";
  5118. var slateblue = "#6a5acd";
  5119. var slategray = "#708090";
  5120. var slategrey = "#708090";
  5121. var snow = "#fffafa";
  5122. var springgreen = "#00ff7f";
  5123. var steelblue = "#4682b4";
  5124. var tan = "#d2b48c";
  5125. var teal = "#008080";
  5126. var thistle = "#d8bfd8";
  5127. var tomato = "#ff6347";
  5128. var turquoise = "#40e0d0";
  5129. var violet = "#ee82ee";
  5130. var wheat = "#f5deb3";
  5131. var white = "#ffffff";
  5132. var whitesmoke = "#f5f5f5";
  5133. var yellow = "#ffff00";
  5134. var yellowgreen = "#9acd32";
  5135. var cssColorNames = {
  5136. aliceblue,
  5137. antiquewhite,
  5138. aqua,
  5139. aquamarine,
  5140. azure,
  5141. beige,
  5142. bisque,
  5143. black,
  5144. blanchedalmond,
  5145. blue,
  5146. blueviolet,
  5147. brown,
  5148. burlywood,
  5149. cadetblue,
  5150. chartreuse,
  5151. chocolate,
  5152. coral,
  5153. cornflowerblue,
  5154. cornsilk,
  5155. crimson,
  5156. cyan,
  5157. darkblue,
  5158. darkcyan,
  5159. darkgoldenrod,
  5160. darkgray,
  5161. darkgreen,
  5162. darkgrey,
  5163. darkkhaki,
  5164. darkmagenta,
  5165. darkolivegreen,
  5166. darkorange,
  5167. darkorchid,
  5168. darkred,
  5169. darksalmon,
  5170. darkseagreen,
  5171. darkslateblue,
  5172. darkslategray,
  5173. darkslategrey,
  5174. darkturquoise,
  5175. darkviolet,
  5176. deeppink,
  5177. deepskyblue,
  5178. dimgray,
  5179. dimgrey,
  5180. dodgerblue,
  5181. firebrick,
  5182. floralwhite,
  5183. forestgreen,
  5184. fuchsia,
  5185. gainsboro,
  5186. ghostwhite,
  5187. goldenrod,
  5188. gold,
  5189. gray,
  5190. green,
  5191. greenyellow,
  5192. grey,
  5193. honeydew,
  5194. hotpink,
  5195. indianred,
  5196. indigo,
  5197. ivory,
  5198. khaki,
  5199. lavenderblush,
  5200. lavender,
  5201. lawngreen,
  5202. lemonchiffon,
  5203. lightblue,
  5204. lightcoral,
  5205. lightcyan,
  5206. lightgoldenrodyellow,
  5207. lightgray,
  5208. lightgreen,
  5209. lightgrey,
  5210. lightpink,
  5211. lightsalmon,
  5212. lightseagreen,
  5213. lightskyblue,
  5214. lightslategray,
  5215. lightslategrey,
  5216. lightsteelblue,
  5217. lightyellow,
  5218. lime,
  5219. limegreen,
  5220. linen,
  5221. magenta,
  5222. maroon,
  5223. mediumaquamarine,
  5224. mediumblue,
  5225. mediumorchid,
  5226. mediumpurple,
  5227. mediumseagreen,
  5228. mediumslateblue,
  5229. mediumspringgreen,
  5230. mediumturquoise,
  5231. mediumvioletred,
  5232. midnightblue,
  5233. mintcream,
  5234. mistyrose,
  5235. moccasin,
  5236. navajowhite,
  5237. navy,
  5238. oldlace,
  5239. olive,
  5240. olivedrab,
  5241. orange,
  5242. orangered,
  5243. orchid,
  5244. palegoldenrod,
  5245. palegreen,
  5246. paleturquoise,
  5247. palevioletred,
  5248. papayawhip,
  5249. peachpuff,
  5250. peru,
  5251. pink,
  5252. plum,
  5253. powderblue,
  5254. purple,
  5255. rebeccapurple,
  5256. red,
  5257. rosybrown,
  5258. royalblue,
  5259. saddlebrown,
  5260. salmon,
  5261. sandybrown,
  5262. seagreen,
  5263. seashell,
  5264. sienna,
  5265. silver,
  5266. skyblue,
  5267. slateblue,
  5268. slategray,
  5269. slategrey,
  5270. snow,
  5271. springgreen,
  5272. steelblue,
  5273. tan,
  5274. teal,
  5275. thistle,
  5276. tomato,
  5277. turquoise,
  5278. violet,
  5279. wheat,
  5280. white,
  5281. whitesmoke,
  5282. yellow,
  5283. yellowgreen
  5284. };
  5285. function hex2rgb(hex, out) {
  5286. if (out === void 0) {
  5287. out = [];
  5288. }
  5289. out[0] = (hex >> 16 & 255) / 255;
  5290. out[1] = (hex >> 8 & 255) / 255;
  5291. out[2] = (hex & 255) / 255;
  5292. return out;
  5293. }
  5294. function hex2string(hex) {
  5295. var hexString = hex.toString(16);
  5296. hexString = "000000".substring(0, 6 - hexString.length) + hexString;
  5297. return "#" + hexString;
  5298. }
  5299. function string2hex(string) {
  5300. if (typeof string === "string") {
  5301. string = cssColorNames[string.toLowerCase()] || string;
  5302. if (string[0] === "#") {
  5303. string = string.slice(1);
  5304. }
  5305. }
  5306. return parseInt(string, 16);
  5307. }
  5308. function rgb2hex(rgb) {
  5309. return (rgb[0] * 255 << 16) + (rgb[1] * 255 << 8) + (rgb[2] * 255 | 0);
  5310. }
  5311. function mapPremultipliedBlendModes() {
  5312. var pm = [];
  5313. var npm = [];
  5314. for (var i = 0; i < 32; i++) {
  5315. pm[i] = i;
  5316. npm[i] = i;
  5317. }
  5318. pm[BLEND_MODES.NORMAL_NPM] = BLEND_MODES.NORMAL;
  5319. pm[BLEND_MODES.ADD_NPM] = BLEND_MODES.ADD;
  5320. pm[BLEND_MODES.SCREEN_NPM] = BLEND_MODES.SCREEN;
  5321. npm[BLEND_MODES.NORMAL] = BLEND_MODES.NORMAL_NPM;
  5322. npm[BLEND_MODES.ADD] = BLEND_MODES.ADD_NPM;
  5323. npm[BLEND_MODES.SCREEN] = BLEND_MODES.SCREEN_NPM;
  5324. var array = [];
  5325. array.push(npm);
  5326. array.push(pm);
  5327. return array;
  5328. }
  5329. var premultiplyBlendMode = mapPremultipliedBlendModes();
  5330. function correctBlendMode(blendMode, premultiplied) {
  5331. return premultiplyBlendMode[premultiplied ? 1 : 0][blendMode];
  5332. }
  5333. function premultiplyRgba(rgb, alpha, out, premultiply) {
  5334. out = out || new Float32Array(4);
  5335. if (premultiply || premultiply === void 0) {
  5336. out[0] = rgb[0] * alpha;
  5337. out[1] = rgb[1] * alpha;
  5338. out[2] = rgb[2] * alpha;
  5339. } else {
  5340. out[0] = rgb[0];
  5341. out[1] = rgb[1];
  5342. out[2] = rgb[2];
  5343. }
  5344. out[3] = alpha;
  5345. return out;
  5346. }
  5347. function premultiplyTint(tint, alpha) {
  5348. if (alpha === 1) {
  5349. return (alpha * 255 << 24) + tint;
  5350. }
  5351. if (alpha === 0) {
  5352. return 0;
  5353. }
  5354. var R = tint >> 16 & 255;
  5355. var G = tint >> 8 & 255;
  5356. var B = tint & 255;
  5357. R = R * alpha + 0.5 | 0;
  5358. G = G * alpha + 0.5 | 0;
  5359. B = B * alpha + 0.5 | 0;
  5360. return (alpha * 255 << 24) + (R << 16) + (G << 8) + B;
  5361. }
  5362. function premultiplyTintToRgba(tint, alpha, out, premultiply) {
  5363. out = out || new Float32Array(4);
  5364. out[0] = (tint >> 16 & 255) / 255;
  5365. out[1] = (tint >> 8 & 255) / 255;
  5366. out[2] = (tint & 255) / 255;
  5367. if (premultiply || premultiply === void 0) {
  5368. out[0] *= alpha;
  5369. out[1] *= alpha;
  5370. out[2] *= alpha;
  5371. }
  5372. out[3] = alpha;
  5373. return out;
  5374. }
  5375. function createIndicesForQuads(size, outBuffer) {
  5376. if (outBuffer === void 0) {
  5377. outBuffer = null;
  5378. }
  5379. var totalIndices = size * 6;
  5380. outBuffer = outBuffer || new Uint16Array(totalIndices);
  5381. if (outBuffer.length !== totalIndices) {
  5382. throw new Error("Out buffer length is incorrect, got " + outBuffer.length + " and expected " + totalIndices);
  5383. }
  5384. for (var i = 0, j = 0; i < totalIndices; i += 6, j += 4) {
  5385. outBuffer[i + 0] = j + 0;
  5386. outBuffer[i + 1] = j + 1;
  5387. outBuffer[i + 2] = j + 2;
  5388. outBuffer[i + 3] = j + 0;
  5389. outBuffer[i + 4] = j + 2;
  5390. outBuffer[i + 5] = j + 3;
  5391. }
  5392. return outBuffer;
  5393. }
  5394. function getBufferType(array) {
  5395. if (array.BYTES_PER_ELEMENT === 4) {
  5396. if (array instanceof Float32Array) {
  5397. return "Float32Array";
  5398. } else if (array instanceof Uint32Array) {
  5399. return "Uint32Array";
  5400. }
  5401. return "Int32Array";
  5402. } else if (array.BYTES_PER_ELEMENT === 2) {
  5403. if (array instanceof Uint16Array) {
  5404. return "Uint16Array";
  5405. }
  5406. } else if (array.BYTES_PER_ELEMENT === 1) {
  5407. if (array instanceof Uint8Array) {
  5408. return "Uint8Array";
  5409. }
  5410. }
  5411. return null;
  5412. }
  5413. var map = { Float32Array, Uint32Array, Int32Array, Uint8Array };
  5414. function interleaveTypedArrays(arrays, sizes) {
  5415. var outSize = 0;
  5416. var stride = 0;
  5417. var views = {};
  5418. for (var i = 0; i < arrays.length; i++) {
  5419. stride += sizes[i];
  5420. outSize += arrays[i].length;
  5421. }
  5422. var buffer = new ArrayBuffer(outSize * 4);
  5423. var out = null;
  5424. var littleOffset = 0;
  5425. for (var i = 0; i < arrays.length; i++) {
  5426. var size = sizes[i];
  5427. var array = arrays[i];
  5428. var type = getBufferType(array);
  5429. if (!views[type]) {
  5430. views[type] = new map[type](buffer);
  5431. }
  5432. out = views[type];
  5433. for (var j = 0; j < array.length; j++) {
  5434. var indexStart = (j / size | 0) * stride + littleOffset;
  5435. var index = j % size;
  5436. out[indexStart + index] = array[j];
  5437. }
  5438. littleOffset += size;
  5439. }
  5440. return new Float32Array(buffer);
  5441. }
  5442. function nextPow2(v) {
  5443. v += v === 0 ? 1 : 0;
  5444. --v;
  5445. v |= v >>> 1;
  5446. v |= v >>> 2;
  5447. v |= v >>> 4;
  5448. v |= v >>> 8;
  5449. v |= v >>> 16;
  5450. return v + 1;
  5451. }
  5452. function isPow2(v) {
  5453. return !(v & v - 1) && !!v;
  5454. }
  5455. function log2(v) {
  5456. var r = (v > 65535 ? 1 : 0) << 4;
  5457. v >>>= r;
  5458. var shift = (v > 255 ? 1 : 0) << 3;
  5459. v >>>= shift;
  5460. r |= shift;
  5461. shift = (v > 15 ? 1 : 0) << 2;
  5462. v >>>= shift;
  5463. r |= shift;
  5464. shift = (v > 3 ? 1 : 0) << 1;
  5465. v >>>= shift;
  5466. r |= shift;
  5467. return r | v >> 1;
  5468. }
  5469. function removeItems(arr, startIdx, removeCount) {
  5470. var length = arr.length;
  5471. var i;
  5472. if (startIdx >= length || removeCount === 0) {
  5473. return;
  5474. }
  5475. removeCount = startIdx + removeCount > length ? length - startIdx : removeCount;
  5476. var len = length - removeCount;
  5477. for (i = startIdx; i < len; ++i) {
  5478. arr[i] = arr[i + removeCount];
  5479. }
  5480. arr.length = len;
  5481. }
  5482. function sign(n) {
  5483. if (n === 0) {
  5484. return 0;
  5485. }
  5486. return n < 0 ? -1 : 1;
  5487. }
  5488. var nextUid = 0;
  5489. function uid() {
  5490. return ++nextUid;
  5491. }
  5492. var warnings = {};
  5493. function deprecation(version, message, ignoreDepth) {
  5494. if (ignoreDepth === void 0) {
  5495. ignoreDepth = 3;
  5496. }
  5497. if (warnings[message]) {
  5498. return;
  5499. }
  5500. var stack = new Error().stack;
  5501. if (typeof stack === "undefined") {
  5502. console.warn("PixiJS Deprecation Warning: ", message + "\nDeprecated since v" + version);
  5503. } else {
  5504. stack = stack.split("\n").splice(ignoreDepth).join("\n");
  5505. if (console.groupCollapsed) {
  5506. console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s", "color:#614108;background:#fffbe6", "font-weight:normal;color:#614108;background:#fffbe6", message + "\nDeprecated since v" + version);
  5507. console.warn(stack);
  5508. console.groupEnd();
  5509. } else {
  5510. console.warn("PixiJS Deprecation Warning: ", message + "\nDeprecated since v" + version);
  5511. console.warn(stack);
  5512. }
  5513. }
  5514. warnings[message] = true;
  5515. }
  5516. var ProgramCache = {};
  5517. var TextureCache = /* @__PURE__ */ Object.create(null);
  5518. var BaseTextureCache = /* @__PURE__ */ Object.create(null);
  5519. function destroyTextureCache() {
  5520. var key;
  5521. for (key in TextureCache) {
  5522. TextureCache[key].destroy();
  5523. }
  5524. for (key in BaseTextureCache) {
  5525. BaseTextureCache[key].destroy();
  5526. }
  5527. }
  5528. function clearTextureCache() {
  5529. var key;
  5530. for (key in TextureCache) {
  5531. delete TextureCache[key];
  5532. }
  5533. for (key in BaseTextureCache) {
  5534. delete BaseTextureCache[key];
  5535. }
  5536. }
  5537. var CanvasRenderTarget = (
  5538. /** @class */
  5539. (function() {
  5540. function CanvasRenderTarget2(width, height, resolution) {
  5541. this.canvas = settings.ADAPTER.createCanvas();
  5542. this.context = this.canvas.getContext("2d");
  5543. this.resolution = resolution || settings.RESOLUTION;
  5544. this.resize(width, height);
  5545. }
  5546. CanvasRenderTarget2.prototype.clear = function() {
  5547. this.context.setTransform(1, 0, 0, 1, 0, 0);
  5548. this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
  5549. };
  5550. CanvasRenderTarget2.prototype.resize = function(desiredWidth, desiredHeight) {
  5551. this.canvas.width = Math.round(desiredWidth * this.resolution);
  5552. this.canvas.height = Math.round(desiredHeight * this.resolution);
  5553. };
  5554. CanvasRenderTarget2.prototype.destroy = function() {
  5555. this.context = null;
  5556. this.canvas = null;
  5557. };
  5558. Object.defineProperty(CanvasRenderTarget2.prototype, "width", {
  5559. /**
  5560. * The width of the canvas buffer in pixels.
  5561. * @member {number}
  5562. */
  5563. get: function() {
  5564. return this.canvas.width;
  5565. },
  5566. set: function(val) {
  5567. this.canvas.width = Math.round(val);
  5568. },
  5569. enumerable: false,
  5570. configurable: true
  5571. });
  5572. Object.defineProperty(CanvasRenderTarget2.prototype, "height", {
  5573. /**
  5574. * The height of the canvas buffer in pixels.
  5575. * @member {number}
  5576. */
  5577. get: function() {
  5578. return this.canvas.height;
  5579. },
  5580. set: function(val) {
  5581. this.canvas.height = Math.round(val);
  5582. },
  5583. enumerable: false,
  5584. configurable: true
  5585. });
  5586. return CanvasRenderTarget2;
  5587. })()
  5588. );
  5589. function trimCanvas(canvas) {
  5590. var width = canvas.width;
  5591. var height = canvas.height;
  5592. var context2 = canvas.getContext("2d", {
  5593. willReadFrequently: true
  5594. });
  5595. var imageData = context2.getImageData(0, 0, width, height);
  5596. var pixels = imageData.data;
  5597. var len = pixels.length;
  5598. var bound = {
  5599. top: null,
  5600. left: null,
  5601. right: null,
  5602. bottom: null
  5603. };
  5604. var data = null;
  5605. var i;
  5606. var x;
  5607. var y;
  5608. for (i = 0; i < len; i += 4) {
  5609. if (pixels[i + 3] !== 0) {
  5610. x = i / 4 % width;
  5611. y = ~~(i / 4 / width);
  5612. if (bound.top === null) {
  5613. bound.top = y;
  5614. }
  5615. if (bound.left === null) {
  5616. bound.left = x;
  5617. } else if (x < bound.left) {
  5618. bound.left = x;
  5619. }
  5620. if (bound.right === null) {
  5621. bound.right = x + 1;
  5622. } else if (bound.right < x) {
  5623. bound.right = x + 1;
  5624. }
  5625. if (bound.bottom === null) {
  5626. bound.bottom = y;
  5627. } else if (bound.bottom < y) {
  5628. bound.bottom = y;
  5629. }
  5630. }
  5631. }
  5632. if (bound.top !== null) {
  5633. width = bound.right - bound.left;
  5634. height = bound.bottom - bound.top + 1;
  5635. data = context2.getImageData(bound.left, bound.top, width, height);
  5636. }
  5637. return {
  5638. height,
  5639. width,
  5640. data
  5641. };
  5642. }
  5643. var DATA_URI = /^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;
  5644. function decomposeDataUri(dataUri) {
  5645. var dataUriMatch = DATA_URI.exec(dataUri);
  5646. if (dataUriMatch) {
  5647. return {
  5648. mediaType: dataUriMatch[1] ? dataUriMatch[1].toLowerCase() : void 0,
  5649. subType: dataUriMatch[2] ? dataUriMatch[2].toLowerCase() : void 0,
  5650. charset: dataUriMatch[3] ? dataUriMatch[3].toLowerCase() : void 0,
  5651. encoding: dataUriMatch[4] ? dataUriMatch[4].toLowerCase() : void 0,
  5652. data: dataUriMatch[5]
  5653. };
  5654. }
  5655. return void 0;
  5656. }
  5657. var tempAnchor;
  5658. function determineCrossOrigin(url$1, loc) {
  5659. if (loc === void 0) {
  5660. loc = globalThis.location;
  5661. }
  5662. if (url$1.indexOf("data:") === 0) {
  5663. return "";
  5664. }
  5665. loc = loc || globalThis.location;
  5666. if (!tempAnchor) {
  5667. tempAnchor = document.createElement("a");
  5668. }
  5669. tempAnchor.href = url$1;
  5670. var parsedUrl = url.parse(tempAnchor.href);
  5671. var samePort = !parsedUrl.port && loc.port === "" || parsedUrl.port === loc.port;
  5672. if (parsedUrl.hostname !== loc.hostname || !samePort || parsedUrl.protocol !== loc.protocol) {
  5673. return "anonymous";
  5674. }
  5675. return "";
  5676. }
  5677. function getResolutionOfUrl(url2, defaultValue2) {
  5678. var resolution = settings.RETINA_PREFIX.exec(url2);
  5679. if (resolution) {
  5680. return parseFloat(resolution[1]);
  5681. }
  5682. return defaultValue2 !== void 0 ? defaultValue2 : 1;
  5683. }
  5684. // node_modules/@pixi/math/dist/esm/math.mjs
  5685. var PI_2 = Math.PI * 2;
  5686. var RAD_TO_DEG = 180 / Math.PI;
  5687. var DEG_TO_RAD = Math.PI / 180;
  5688. var SHAPES;
  5689. (function(SHAPES2) {
  5690. SHAPES2[SHAPES2["POLY"] = 0] = "POLY";
  5691. SHAPES2[SHAPES2["RECT"] = 1] = "RECT";
  5692. SHAPES2[SHAPES2["CIRC"] = 2] = "CIRC";
  5693. SHAPES2[SHAPES2["ELIP"] = 3] = "ELIP";
  5694. SHAPES2[SHAPES2["RREC"] = 4] = "RREC";
  5695. })(SHAPES || (SHAPES = {}));
  5696. var Point = (
  5697. /** @class */
  5698. (function() {
  5699. function Point2(x, y) {
  5700. if (x === void 0) {
  5701. x = 0;
  5702. }
  5703. if (y === void 0) {
  5704. y = 0;
  5705. }
  5706. this.x = 0;
  5707. this.y = 0;
  5708. this.x = x;
  5709. this.y = y;
  5710. }
  5711. Point2.prototype.clone = function() {
  5712. return new Point2(this.x, this.y);
  5713. };
  5714. Point2.prototype.copyFrom = function(p) {
  5715. this.set(p.x, p.y);
  5716. return this;
  5717. };
  5718. Point2.prototype.copyTo = function(p) {
  5719. p.set(this.x, this.y);
  5720. return p;
  5721. };
  5722. Point2.prototype.equals = function(p) {
  5723. return p.x === this.x && p.y === this.y;
  5724. };
  5725. Point2.prototype.set = function(x, y) {
  5726. if (x === void 0) {
  5727. x = 0;
  5728. }
  5729. if (y === void 0) {
  5730. y = x;
  5731. }
  5732. this.x = x;
  5733. this.y = y;
  5734. return this;
  5735. };
  5736. Point2.prototype.toString = function() {
  5737. return "[@pixi/math:Point x=" + this.x + " y=" + this.y + "]";
  5738. };
  5739. return Point2;
  5740. })()
  5741. );
  5742. var tempPoints = [new Point(), new Point(), new Point(), new Point()];
  5743. var Rectangle = (
  5744. /** @class */
  5745. (function() {
  5746. function Rectangle2(x, y, width, height) {
  5747. if (x === void 0) {
  5748. x = 0;
  5749. }
  5750. if (y === void 0) {
  5751. y = 0;
  5752. }
  5753. if (width === void 0) {
  5754. width = 0;
  5755. }
  5756. if (height === void 0) {
  5757. height = 0;
  5758. }
  5759. this.x = Number(x);
  5760. this.y = Number(y);
  5761. this.width = Number(width);
  5762. this.height = Number(height);
  5763. this.type = SHAPES.RECT;
  5764. }
  5765. Object.defineProperty(Rectangle2.prototype, "left", {
  5766. /** Returns the left edge of the rectangle. */
  5767. get: function() {
  5768. return this.x;
  5769. },
  5770. enumerable: false,
  5771. configurable: true
  5772. });
  5773. Object.defineProperty(Rectangle2.prototype, "right", {
  5774. /** Returns the right edge of the rectangle. */
  5775. get: function() {
  5776. return this.x + this.width;
  5777. },
  5778. enumerable: false,
  5779. configurable: true
  5780. });
  5781. Object.defineProperty(Rectangle2.prototype, "top", {
  5782. /** Returns the top edge of the rectangle. */
  5783. get: function() {
  5784. return this.y;
  5785. },
  5786. enumerable: false,
  5787. configurable: true
  5788. });
  5789. Object.defineProperty(Rectangle2.prototype, "bottom", {
  5790. /** Returns the bottom edge of the rectangle. */
  5791. get: function() {
  5792. return this.y + this.height;
  5793. },
  5794. enumerable: false,
  5795. configurable: true
  5796. });
  5797. Object.defineProperty(Rectangle2, "EMPTY", {
  5798. /** A constant empty rectangle. */
  5799. get: function() {
  5800. return new Rectangle2(0, 0, 0, 0);
  5801. },
  5802. enumerable: false,
  5803. configurable: true
  5804. });
  5805. Rectangle2.prototype.clone = function() {
  5806. return new Rectangle2(this.x, this.y, this.width, this.height);
  5807. };
  5808. Rectangle2.prototype.copyFrom = function(rectangle) {
  5809. this.x = rectangle.x;
  5810. this.y = rectangle.y;
  5811. this.width = rectangle.width;
  5812. this.height = rectangle.height;
  5813. return this;
  5814. };
  5815. Rectangle2.prototype.copyTo = function(rectangle) {
  5816. rectangle.x = this.x;
  5817. rectangle.y = this.y;
  5818. rectangle.width = this.width;
  5819. rectangle.height = this.height;
  5820. return rectangle;
  5821. };
  5822. Rectangle2.prototype.contains = function(x, y) {
  5823. if (this.width <= 0 || this.height <= 0) {
  5824. return false;
  5825. }
  5826. if (x >= this.x && x < this.x + this.width) {
  5827. if (y >= this.y && y < this.y + this.height) {
  5828. return true;
  5829. }
  5830. }
  5831. return false;
  5832. };
  5833. Rectangle2.prototype.intersects = function(other, transform) {
  5834. if (!transform) {
  5835. var x0_1 = this.x < other.x ? other.x : this.x;
  5836. var x1_1 = this.right > other.right ? other.right : this.right;
  5837. if (x1_1 <= x0_1) {
  5838. return false;
  5839. }
  5840. var y0_1 = this.y < other.y ? other.y : this.y;
  5841. var y1_1 = this.bottom > other.bottom ? other.bottom : this.bottom;
  5842. return y1_1 > y0_1;
  5843. }
  5844. var x0 = this.left;
  5845. var x1 = this.right;
  5846. var y0 = this.top;
  5847. var y1 = this.bottom;
  5848. if (x1 <= x0 || y1 <= y0) {
  5849. return false;
  5850. }
  5851. var lt = tempPoints[0].set(other.left, other.top);
  5852. var lb = tempPoints[1].set(other.left, other.bottom);
  5853. var rt = tempPoints[2].set(other.right, other.top);
  5854. var rb = tempPoints[3].set(other.right, other.bottom);
  5855. if (rt.x <= lt.x || lb.y <= lt.y) {
  5856. return false;
  5857. }
  5858. var s = Math.sign(transform.a * transform.d - transform.b * transform.c);
  5859. if (s === 0) {
  5860. return false;
  5861. }
  5862. transform.apply(lt, lt);
  5863. transform.apply(lb, lb);
  5864. transform.apply(rt, rt);
  5865. transform.apply(rb, rb);
  5866. if (Math.max(lt.x, lb.x, rt.x, rb.x) <= x0 || Math.min(lt.x, lb.x, rt.x, rb.x) >= x1 || Math.max(lt.y, lb.y, rt.y, rb.y) <= y0 || Math.min(lt.y, lb.y, rt.y, rb.y) >= y1) {
  5867. return false;
  5868. }
  5869. var nx = s * (lb.y - lt.y);
  5870. var ny = s * (lt.x - lb.x);
  5871. var n00 = nx * x0 + ny * y0;
  5872. var n10 = nx * x1 + ny * y0;
  5873. var n01 = nx * x0 + ny * y1;
  5874. var n11 = nx * x1 + ny * y1;
  5875. if (Math.max(n00, n10, n01, n11) <= nx * lt.x + ny * lt.y || Math.min(n00, n10, n01, n11) >= nx * rb.x + ny * rb.y) {
  5876. return false;
  5877. }
  5878. var mx = s * (lt.y - rt.y);
  5879. var my = s * (rt.x - lt.x);
  5880. var m00 = mx * x0 + my * y0;
  5881. var m10 = mx * x1 + my * y0;
  5882. var m01 = mx * x0 + my * y1;
  5883. var m11 = mx * x1 + my * y1;
  5884. if (Math.max(m00, m10, m01, m11) <= mx * lt.x + my * lt.y || Math.min(m00, m10, m01, m11) >= mx * rb.x + my * rb.y) {
  5885. return false;
  5886. }
  5887. return true;
  5888. };
  5889. Rectangle2.prototype.pad = function(paddingX, paddingY) {
  5890. if (paddingX === void 0) {
  5891. paddingX = 0;
  5892. }
  5893. if (paddingY === void 0) {
  5894. paddingY = paddingX;
  5895. }
  5896. this.x -= paddingX;
  5897. this.y -= paddingY;
  5898. this.width += paddingX * 2;
  5899. this.height += paddingY * 2;
  5900. return this;
  5901. };
  5902. Rectangle2.prototype.fit = function(rectangle) {
  5903. var x1 = Math.max(this.x, rectangle.x);
  5904. var x2 = Math.min(this.x + this.width, rectangle.x + rectangle.width);
  5905. var y1 = Math.max(this.y, rectangle.y);
  5906. var y2 = Math.min(this.y + this.height, rectangle.y + rectangle.height);
  5907. this.x = x1;
  5908. this.width = Math.max(x2 - x1, 0);
  5909. this.y = y1;
  5910. this.height = Math.max(y2 - y1, 0);
  5911. return this;
  5912. };
  5913. Rectangle2.prototype.ceil = function(resolution, eps) {
  5914. if (resolution === void 0) {
  5915. resolution = 1;
  5916. }
  5917. if (eps === void 0) {
  5918. eps = 1e-3;
  5919. }
  5920. var x2 = Math.ceil((this.x + this.width - eps) * resolution) / resolution;
  5921. var y2 = Math.ceil((this.y + this.height - eps) * resolution) / resolution;
  5922. this.x = Math.floor((this.x + eps) * resolution) / resolution;
  5923. this.y = Math.floor((this.y + eps) * resolution) / resolution;
  5924. this.width = x2 - this.x;
  5925. this.height = y2 - this.y;
  5926. return this;
  5927. };
  5928. Rectangle2.prototype.enlarge = function(rectangle) {
  5929. var x1 = Math.min(this.x, rectangle.x);
  5930. var x2 = Math.max(this.x + this.width, rectangle.x + rectangle.width);
  5931. var y1 = Math.min(this.y, rectangle.y);
  5932. var y2 = Math.max(this.y + this.height, rectangle.y + rectangle.height);
  5933. this.x = x1;
  5934. this.width = x2 - x1;
  5935. this.y = y1;
  5936. this.height = y2 - y1;
  5937. return this;
  5938. };
  5939. Rectangle2.prototype.toString = function() {
  5940. return "[@pixi/math:Rectangle x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + "]";
  5941. };
  5942. return Rectangle2;
  5943. })()
  5944. );
  5945. var Circle = (
  5946. /** @class */
  5947. (function() {
  5948. function Circle2(x, y, radius) {
  5949. if (x === void 0) {
  5950. x = 0;
  5951. }
  5952. if (y === void 0) {
  5953. y = 0;
  5954. }
  5955. if (radius === void 0) {
  5956. radius = 0;
  5957. }
  5958. this.x = x;
  5959. this.y = y;
  5960. this.radius = radius;
  5961. this.type = SHAPES.CIRC;
  5962. }
  5963. Circle2.prototype.clone = function() {
  5964. return new Circle2(this.x, this.y, this.radius);
  5965. };
  5966. Circle2.prototype.contains = function(x, y) {
  5967. if (this.radius <= 0) {
  5968. return false;
  5969. }
  5970. var r2 = this.radius * this.radius;
  5971. var dx = this.x - x;
  5972. var dy = this.y - y;
  5973. dx *= dx;
  5974. dy *= dy;
  5975. return dx + dy <= r2;
  5976. };
  5977. Circle2.prototype.getBounds = function() {
  5978. return new Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2);
  5979. };
  5980. Circle2.prototype.toString = function() {
  5981. return "[@pixi/math:Circle x=" + this.x + " y=" + this.y + " radius=" + this.radius + "]";
  5982. };
  5983. return Circle2;
  5984. })()
  5985. );
  5986. var Ellipse = (
  5987. /** @class */
  5988. (function() {
  5989. function Ellipse2(x, y, halfWidth, halfHeight) {
  5990. if (x === void 0) {
  5991. x = 0;
  5992. }
  5993. if (y === void 0) {
  5994. y = 0;
  5995. }
  5996. if (halfWidth === void 0) {
  5997. halfWidth = 0;
  5998. }
  5999. if (halfHeight === void 0) {
  6000. halfHeight = 0;
  6001. }
  6002. this.x = x;
  6003. this.y = y;
  6004. this.width = halfWidth;
  6005. this.height = halfHeight;
  6006. this.type = SHAPES.ELIP;
  6007. }
  6008. Ellipse2.prototype.clone = function() {
  6009. return new Ellipse2(this.x, this.y, this.width, this.height);
  6010. };
  6011. Ellipse2.prototype.contains = function(x, y) {
  6012. if (this.width <= 0 || this.height <= 0) {
  6013. return false;
  6014. }
  6015. var normx = (x - this.x) / this.width;
  6016. var normy = (y - this.y) / this.height;
  6017. normx *= normx;
  6018. normy *= normy;
  6019. return normx + normy <= 1;
  6020. };
  6021. Ellipse2.prototype.getBounds = function() {
  6022. return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);
  6023. };
  6024. Ellipse2.prototype.toString = function() {
  6025. return "[@pixi/math:Ellipse x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + "]";
  6026. };
  6027. return Ellipse2;
  6028. })()
  6029. );
  6030. var Polygon = (
  6031. /** @class */
  6032. (function() {
  6033. function Polygon2() {
  6034. var arguments$1 = arguments;
  6035. var points = [];
  6036. for (var _i = 0; _i < arguments.length; _i++) {
  6037. points[_i] = arguments$1[_i];
  6038. }
  6039. var flat = Array.isArray(points[0]) ? points[0] : points;
  6040. if (typeof flat[0] !== "number") {
  6041. var p = [];
  6042. for (var i = 0, il = flat.length; i < il; i++) {
  6043. p.push(flat[i].x, flat[i].y);
  6044. }
  6045. flat = p;
  6046. }
  6047. this.points = flat;
  6048. this.type = SHAPES.POLY;
  6049. this.closeStroke = true;
  6050. }
  6051. Polygon2.prototype.clone = function() {
  6052. var points = this.points.slice();
  6053. var polygon = new Polygon2(points);
  6054. polygon.closeStroke = this.closeStroke;
  6055. return polygon;
  6056. };
  6057. Polygon2.prototype.contains = function(x, y) {
  6058. var inside = false;
  6059. var length = this.points.length / 2;
  6060. for (var i = 0, j = length - 1; i < length; j = i++) {
  6061. var xi = this.points[i * 2];
  6062. var yi = this.points[i * 2 + 1];
  6063. var xj = this.points[j * 2];
  6064. var yj = this.points[j * 2 + 1];
  6065. var intersect = yi > y !== yj > y && x < (xj - xi) * ((y - yi) / (yj - yi)) + xi;
  6066. if (intersect) {
  6067. inside = !inside;
  6068. }
  6069. }
  6070. return inside;
  6071. };
  6072. Polygon2.prototype.toString = function() {
  6073. return "[@pixi/math:Polygon" + ("closeStroke=" + this.closeStroke) + ("points=" + this.points.reduce(function(pointsDesc, currentPoint) {
  6074. return pointsDesc + ", " + currentPoint;
  6075. }, "") + "]");
  6076. };
  6077. return Polygon2;
  6078. })()
  6079. );
  6080. var RoundedRectangle = (
  6081. /** @class */
  6082. (function() {
  6083. function RoundedRectangle2(x, y, width, height, radius) {
  6084. if (x === void 0) {
  6085. x = 0;
  6086. }
  6087. if (y === void 0) {
  6088. y = 0;
  6089. }
  6090. if (width === void 0) {
  6091. width = 0;
  6092. }
  6093. if (height === void 0) {
  6094. height = 0;
  6095. }
  6096. if (radius === void 0) {
  6097. radius = 20;
  6098. }
  6099. this.x = x;
  6100. this.y = y;
  6101. this.width = width;
  6102. this.height = height;
  6103. this.radius = radius;
  6104. this.type = SHAPES.RREC;
  6105. }
  6106. RoundedRectangle2.prototype.clone = function() {
  6107. return new RoundedRectangle2(this.x, this.y, this.width, this.height, this.radius);
  6108. };
  6109. RoundedRectangle2.prototype.contains = function(x, y) {
  6110. if (this.width <= 0 || this.height <= 0) {
  6111. return false;
  6112. }
  6113. if (x >= this.x && x <= this.x + this.width) {
  6114. if (y >= this.y && y <= this.y + this.height) {
  6115. var radius = Math.max(0, Math.min(this.radius, Math.min(this.width, this.height) / 2));
  6116. if (y >= this.y + radius && y <= this.y + this.height - radius || x >= this.x + radius && x <= this.x + this.width - radius) {
  6117. return true;
  6118. }
  6119. var dx = x - (this.x + radius);
  6120. var dy = y - (this.y + radius);
  6121. var radius2 = radius * radius;
  6122. if (dx * dx + dy * dy <= radius2) {
  6123. return true;
  6124. }
  6125. dx = x - (this.x + this.width - radius);
  6126. if (dx * dx + dy * dy <= radius2) {
  6127. return true;
  6128. }
  6129. dy = y - (this.y + this.height - radius);
  6130. if (dx * dx + dy * dy <= radius2) {
  6131. return true;
  6132. }
  6133. dx = x - (this.x + radius);
  6134. if (dx * dx + dy * dy <= radius2) {
  6135. return true;
  6136. }
  6137. }
  6138. }
  6139. return false;
  6140. };
  6141. RoundedRectangle2.prototype.toString = function() {
  6142. return "[@pixi/math:RoundedRectangle x=" + this.x + " y=" + this.y + ("width=" + this.width + " height=" + this.height + " radius=" + this.radius + "]");
  6143. };
  6144. return RoundedRectangle2;
  6145. })()
  6146. );
  6147. var ObservablePoint = (
  6148. /** @class */
  6149. (function() {
  6150. function ObservablePoint2(cb, scope, x, y) {
  6151. if (x === void 0) {
  6152. x = 0;
  6153. }
  6154. if (y === void 0) {
  6155. y = 0;
  6156. }
  6157. this._x = x;
  6158. this._y = y;
  6159. this.cb = cb;
  6160. this.scope = scope;
  6161. }
  6162. ObservablePoint2.prototype.clone = function(cb, scope) {
  6163. if (cb === void 0) {
  6164. cb = this.cb;
  6165. }
  6166. if (scope === void 0) {
  6167. scope = this.scope;
  6168. }
  6169. return new ObservablePoint2(cb, scope, this._x, this._y);
  6170. };
  6171. ObservablePoint2.prototype.set = function(x, y) {
  6172. if (x === void 0) {
  6173. x = 0;
  6174. }
  6175. if (y === void 0) {
  6176. y = x;
  6177. }
  6178. if (this._x !== x || this._y !== y) {
  6179. this._x = x;
  6180. this._y = y;
  6181. this.cb.call(this.scope);
  6182. }
  6183. return this;
  6184. };
  6185. ObservablePoint2.prototype.copyFrom = function(p) {
  6186. if (this._x !== p.x || this._y !== p.y) {
  6187. this._x = p.x;
  6188. this._y = p.y;
  6189. this.cb.call(this.scope);
  6190. }
  6191. return this;
  6192. };
  6193. ObservablePoint2.prototype.copyTo = function(p) {
  6194. p.set(this._x, this._y);
  6195. return p;
  6196. };
  6197. ObservablePoint2.prototype.equals = function(p) {
  6198. return p.x === this._x && p.y === this._y;
  6199. };
  6200. ObservablePoint2.prototype.toString = function() {
  6201. return "[@pixi/math:ObservablePoint x=0 y=0 scope=" + this.scope + "]";
  6202. };
  6203. Object.defineProperty(ObservablePoint2.prototype, "x", {
  6204. /** Position of the observable point on the x axis. */
  6205. get: function() {
  6206. return this._x;
  6207. },
  6208. set: function(value) {
  6209. if (this._x !== value) {
  6210. this._x = value;
  6211. this.cb.call(this.scope);
  6212. }
  6213. },
  6214. enumerable: false,
  6215. configurable: true
  6216. });
  6217. Object.defineProperty(ObservablePoint2.prototype, "y", {
  6218. /** Position of the observable point on the y axis. */
  6219. get: function() {
  6220. return this._y;
  6221. },
  6222. set: function(value) {
  6223. if (this._y !== value) {
  6224. this._y = value;
  6225. this.cb.call(this.scope);
  6226. }
  6227. },
  6228. enumerable: false,
  6229. configurable: true
  6230. });
  6231. return ObservablePoint2;
  6232. })()
  6233. );
  6234. var Matrix = (
  6235. /** @class */
  6236. (function() {
  6237. function Matrix2(a, b, c, d, tx, ty) {
  6238. if (a === void 0) {
  6239. a = 1;
  6240. }
  6241. if (b === void 0) {
  6242. b = 0;
  6243. }
  6244. if (c === void 0) {
  6245. c = 0;
  6246. }
  6247. if (d === void 0) {
  6248. d = 1;
  6249. }
  6250. if (tx === void 0) {
  6251. tx = 0;
  6252. }
  6253. if (ty === void 0) {
  6254. ty = 0;
  6255. }
  6256. this.array = null;
  6257. this.a = a;
  6258. this.b = b;
  6259. this.c = c;
  6260. this.d = d;
  6261. this.tx = tx;
  6262. this.ty = ty;
  6263. }
  6264. Matrix2.prototype.fromArray = function(array) {
  6265. this.a = array[0];
  6266. this.b = array[1];
  6267. this.c = array[3];
  6268. this.d = array[4];
  6269. this.tx = array[2];
  6270. this.ty = array[5];
  6271. };
  6272. Matrix2.prototype.set = function(a, b, c, d, tx, ty) {
  6273. this.a = a;
  6274. this.b = b;
  6275. this.c = c;
  6276. this.d = d;
  6277. this.tx = tx;
  6278. this.ty = ty;
  6279. return this;
  6280. };
  6281. Matrix2.prototype.toArray = function(transpose, out) {
  6282. if (!this.array) {
  6283. this.array = new Float32Array(9);
  6284. }
  6285. var array = out || this.array;
  6286. if (transpose) {
  6287. array[0] = this.a;
  6288. array[1] = this.b;
  6289. array[2] = 0;
  6290. array[3] = this.c;
  6291. array[4] = this.d;
  6292. array[5] = 0;
  6293. array[6] = this.tx;
  6294. array[7] = this.ty;
  6295. array[8] = 1;
  6296. } else {
  6297. array[0] = this.a;
  6298. array[1] = this.c;
  6299. array[2] = this.tx;
  6300. array[3] = this.b;
  6301. array[4] = this.d;
  6302. array[5] = this.ty;
  6303. array[6] = 0;
  6304. array[7] = 0;
  6305. array[8] = 1;
  6306. }
  6307. return array;
  6308. };
  6309. Matrix2.prototype.apply = function(pos, newPos) {
  6310. newPos = newPos || new Point();
  6311. var x = pos.x;
  6312. var y = pos.y;
  6313. newPos.x = this.a * x + this.c * y + this.tx;
  6314. newPos.y = this.b * x + this.d * y + this.ty;
  6315. return newPos;
  6316. };
  6317. Matrix2.prototype.applyInverse = function(pos, newPos) {
  6318. newPos = newPos || new Point();
  6319. var id = 1 / (this.a * this.d + this.c * -this.b);
  6320. var x = pos.x;
  6321. var y = pos.y;
  6322. newPos.x = this.d * id * x + -this.c * id * y + (this.ty * this.c - this.tx * this.d) * id;
  6323. newPos.y = this.a * id * y + -this.b * id * x + (-this.ty * this.a + this.tx * this.b) * id;
  6324. return newPos;
  6325. };
  6326. Matrix2.prototype.translate = function(x, y) {
  6327. this.tx += x;
  6328. this.ty += y;
  6329. return this;
  6330. };
  6331. Matrix2.prototype.scale = function(x, y) {
  6332. this.a *= x;
  6333. this.d *= y;
  6334. this.c *= x;
  6335. this.b *= y;
  6336. this.tx *= x;
  6337. this.ty *= y;
  6338. return this;
  6339. };
  6340. Matrix2.prototype.rotate = function(angle) {
  6341. var cos = Math.cos(angle);
  6342. var sin = Math.sin(angle);
  6343. var a1 = this.a;
  6344. var c1 = this.c;
  6345. var tx1 = this.tx;
  6346. this.a = a1 * cos - this.b * sin;
  6347. this.b = a1 * sin + this.b * cos;
  6348. this.c = c1 * cos - this.d * sin;
  6349. this.d = c1 * sin + this.d * cos;
  6350. this.tx = tx1 * cos - this.ty * sin;
  6351. this.ty = tx1 * sin + this.ty * cos;
  6352. return this;
  6353. };
  6354. Matrix2.prototype.append = function(matrix) {
  6355. var a1 = this.a;
  6356. var b1 = this.b;
  6357. var c1 = this.c;
  6358. var d1 = this.d;
  6359. this.a = matrix.a * a1 + matrix.b * c1;
  6360. this.b = matrix.a * b1 + matrix.b * d1;
  6361. this.c = matrix.c * a1 + matrix.d * c1;
  6362. this.d = matrix.c * b1 + matrix.d * d1;
  6363. this.tx = matrix.tx * a1 + matrix.ty * c1 + this.tx;
  6364. this.ty = matrix.tx * b1 + matrix.ty * d1 + this.ty;
  6365. return this;
  6366. };
  6367. Matrix2.prototype.setTransform = function(x, y, pivotX, pivotY, scaleX, scaleY, rotation, skewX, skewY) {
  6368. this.a = Math.cos(rotation + skewY) * scaleX;
  6369. this.b = Math.sin(rotation + skewY) * scaleX;
  6370. this.c = -Math.sin(rotation - skewX) * scaleY;
  6371. this.d = Math.cos(rotation - skewX) * scaleY;
  6372. this.tx = x - (pivotX * this.a + pivotY * this.c);
  6373. this.ty = y - (pivotX * this.b + pivotY * this.d);
  6374. return this;
  6375. };
  6376. Matrix2.prototype.prepend = function(matrix) {
  6377. var tx1 = this.tx;
  6378. if (matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1) {
  6379. var a1 = this.a;
  6380. var c1 = this.c;
  6381. this.a = a1 * matrix.a + this.b * matrix.c;
  6382. this.b = a1 * matrix.b + this.b * matrix.d;
  6383. this.c = c1 * matrix.a + this.d * matrix.c;
  6384. this.d = c1 * matrix.b + this.d * matrix.d;
  6385. }
  6386. this.tx = tx1 * matrix.a + this.ty * matrix.c + matrix.tx;
  6387. this.ty = tx1 * matrix.b + this.ty * matrix.d + matrix.ty;
  6388. return this;
  6389. };
  6390. Matrix2.prototype.decompose = function(transform) {
  6391. var a = this.a;
  6392. var b = this.b;
  6393. var c = this.c;
  6394. var d = this.d;
  6395. var pivot = transform.pivot;
  6396. var skewX = -Math.atan2(-c, d);
  6397. var skewY = Math.atan2(b, a);
  6398. var delta = Math.abs(skewX + skewY);
  6399. if (delta < 1e-5 || Math.abs(PI_2 - delta) < 1e-5) {
  6400. transform.rotation = skewY;
  6401. transform.skew.x = transform.skew.y = 0;
  6402. } else {
  6403. transform.rotation = 0;
  6404. transform.skew.x = skewX;
  6405. transform.skew.y = skewY;
  6406. }
  6407. transform.scale.x = Math.sqrt(a * a + b * b);
  6408. transform.scale.y = Math.sqrt(c * c + d * d);
  6409. transform.position.x = this.tx + (pivot.x * a + pivot.y * c);
  6410. transform.position.y = this.ty + (pivot.x * b + pivot.y * d);
  6411. return transform;
  6412. };
  6413. Matrix2.prototype.invert = function() {
  6414. var a1 = this.a;
  6415. var b1 = this.b;
  6416. var c1 = this.c;
  6417. var d1 = this.d;
  6418. var tx1 = this.tx;
  6419. var n = a1 * d1 - b1 * c1;
  6420. this.a = d1 / n;
  6421. this.b = -b1 / n;
  6422. this.c = -c1 / n;
  6423. this.d = a1 / n;
  6424. this.tx = (c1 * this.ty - d1 * tx1) / n;
  6425. this.ty = -(a1 * this.ty - b1 * tx1) / n;
  6426. return this;
  6427. };
  6428. Matrix2.prototype.identity = function() {
  6429. this.a = 1;
  6430. this.b = 0;
  6431. this.c = 0;
  6432. this.d = 1;
  6433. this.tx = 0;
  6434. this.ty = 0;
  6435. return this;
  6436. };
  6437. Matrix2.prototype.clone = function() {
  6438. var matrix = new Matrix2();
  6439. matrix.a = this.a;
  6440. matrix.b = this.b;
  6441. matrix.c = this.c;
  6442. matrix.d = this.d;
  6443. matrix.tx = this.tx;
  6444. matrix.ty = this.ty;
  6445. return matrix;
  6446. };
  6447. Matrix2.prototype.copyTo = function(matrix) {
  6448. matrix.a = this.a;
  6449. matrix.b = this.b;
  6450. matrix.c = this.c;
  6451. matrix.d = this.d;
  6452. matrix.tx = this.tx;
  6453. matrix.ty = this.ty;
  6454. return matrix;
  6455. };
  6456. Matrix2.prototype.copyFrom = function(matrix) {
  6457. this.a = matrix.a;
  6458. this.b = matrix.b;
  6459. this.c = matrix.c;
  6460. this.d = matrix.d;
  6461. this.tx = matrix.tx;
  6462. this.ty = matrix.ty;
  6463. return this;
  6464. };
  6465. Matrix2.prototype.toString = function() {
  6466. return "[@pixi/math:Matrix a=" + this.a + " b=" + this.b + " c=" + this.c + " d=" + this.d + " tx=" + this.tx + " ty=" + this.ty + "]";
  6467. };
  6468. Object.defineProperty(Matrix2, "IDENTITY", {
  6469. /**
  6470. * A default (identity) matrix
  6471. * @readonly
  6472. */
  6473. get: function() {
  6474. return new Matrix2();
  6475. },
  6476. enumerable: false,
  6477. configurable: true
  6478. });
  6479. Object.defineProperty(Matrix2, "TEMP_MATRIX", {
  6480. /**
  6481. * A temp matrix
  6482. * @readonly
  6483. */
  6484. get: function() {
  6485. return new Matrix2();
  6486. },
  6487. enumerable: false,
  6488. configurable: true
  6489. });
  6490. return Matrix2;
  6491. })()
  6492. );
  6493. var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1];
  6494. var uy = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1];
  6495. var vx = [0, -1, -1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, -1, -1, -1];
  6496. var vy = [1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, -1];
  6497. var rotationCayley = [];
  6498. var rotationMatrices = [];
  6499. var signum = Math.sign;
  6500. function init() {
  6501. for (var i = 0; i < 16; i++) {
  6502. var row = [];
  6503. rotationCayley.push(row);
  6504. for (var j = 0; j < 16; j++) {
  6505. var _ux = signum(ux[i] * ux[j] + vx[i] * uy[j]);
  6506. var _uy = signum(uy[i] * ux[j] + vy[i] * uy[j]);
  6507. var _vx = signum(ux[i] * vx[j] + vx[i] * vy[j]);
  6508. var _vy = signum(uy[i] * vx[j] + vy[i] * vy[j]);
  6509. for (var k = 0; k < 16; k++) {
  6510. if (ux[k] === _ux && uy[k] === _uy && vx[k] === _vx && vy[k] === _vy) {
  6511. row.push(k);
  6512. break;
  6513. }
  6514. }
  6515. }
  6516. }
  6517. for (var i = 0; i < 16; i++) {
  6518. var mat = new Matrix();
  6519. mat.set(ux[i], uy[i], vx[i], vy[i], 0, 0);
  6520. rotationMatrices.push(mat);
  6521. }
  6522. }
  6523. init();
  6524. var groupD8 = {
  6525. /**
  6526. * | Rotation | Direction |
  6527. * |----------|-----------|
  6528. * | 0° | East |
  6529. * @memberof PIXI.groupD8
  6530. * @constant {PIXI.GD8Symmetry}
  6531. */
  6532. E: 0,
  6533. /**
  6534. * | Rotation | Direction |
  6535. * |----------|-----------|
  6536. * | 45°↻ | Southeast |
  6537. * @memberof PIXI.groupD8
  6538. * @constant {PIXI.GD8Symmetry}
  6539. */
  6540. SE: 1,
  6541. /**
  6542. * | Rotation | Direction |
  6543. * |----------|-----------|
  6544. * | 90°↻ | South |
  6545. * @memberof PIXI.groupD8
  6546. * @constant {PIXI.GD8Symmetry}
  6547. */
  6548. S: 2,
  6549. /**
  6550. * | Rotation | Direction |
  6551. * |----------|-----------|
  6552. * | 135°↻ | Southwest |
  6553. * @memberof PIXI.groupD8
  6554. * @constant {PIXI.GD8Symmetry}
  6555. */
  6556. SW: 3,
  6557. /**
  6558. * | Rotation | Direction |
  6559. * |----------|-----------|
  6560. * | 180° | West |
  6561. * @memberof PIXI.groupD8
  6562. * @constant {PIXI.GD8Symmetry}
  6563. */
  6564. W: 4,
  6565. /**
  6566. * | Rotation | Direction |
  6567. * |-------------|--------------|
  6568. * | -135°/225°↻ | Northwest |
  6569. * @memberof PIXI.groupD8
  6570. * @constant {PIXI.GD8Symmetry}
  6571. */
  6572. NW: 5,
  6573. /**
  6574. * | Rotation | Direction |
  6575. * |-------------|--------------|
  6576. * | -90°/270°↻ | North |
  6577. * @memberof PIXI.groupD8
  6578. * @constant {PIXI.GD8Symmetry}
  6579. */
  6580. N: 6,
  6581. /**
  6582. * | Rotation | Direction |
  6583. * |-------------|--------------|
  6584. * | -45°/315°↻ | Northeast |
  6585. * @memberof PIXI.groupD8
  6586. * @constant {PIXI.GD8Symmetry}
  6587. */
  6588. NE: 7,
  6589. /**
  6590. * Reflection about Y-axis.
  6591. * @memberof PIXI.groupD8
  6592. * @constant {PIXI.GD8Symmetry}
  6593. */
  6594. MIRROR_VERTICAL: 8,
  6595. /**
  6596. * Reflection about the main diagonal.
  6597. * @memberof PIXI.groupD8
  6598. * @constant {PIXI.GD8Symmetry}
  6599. */
  6600. MAIN_DIAGONAL: 10,
  6601. /**
  6602. * Reflection about X-axis.
  6603. * @memberof PIXI.groupD8
  6604. * @constant {PIXI.GD8Symmetry}
  6605. */
  6606. MIRROR_HORIZONTAL: 12,
  6607. /**
  6608. * Reflection about reverse diagonal.
  6609. * @memberof PIXI.groupD8
  6610. * @constant {PIXI.GD8Symmetry}
  6611. */
  6612. REVERSE_DIAGONAL: 14,
  6613. /**
  6614. * @memberof PIXI.groupD8
  6615. * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
  6616. * @returns {PIXI.GD8Symmetry} The X-component of the U-axis
  6617. * after rotating the axes.
  6618. */
  6619. uX: function(ind) {
  6620. return ux[ind];
  6621. },
  6622. /**
  6623. * @memberof PIXI.groupD8
  6624. * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
  6625. * @returns {PIXI.GD8Symmetry} The Y-component of the U-axis
  6626. * after rotating the axes.
  6627. */
  6628. uY: function(ind) {
  6629. return uy[ind];
  6630. },
  6631. /**
  6632. * @memberof PIXI.groupD8
  6633. * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
  6634. * @returns {PIXI.GD8Symmetry} The X-component of the V-axis
  6635. * after rotating the axes.
  6636. */
  6637. vX: function(ind) {
  6638. return vx[ind];
  6639. },
  6640. /**
  6641. * @memberof PIXI.groupD8
  6642. * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
  6643. * @returns {PIXI.GD8Symmetry} The Y-component of the V-axis
  6644. * after rotating the axes.
  6645. */
  6646. vY: function(ind) {
  6647. return vy[ind];
  6648. },
  6649. /**
  6650. * @memberof PIXI.groupD8
  6651. * @param {PIXI.GD8Symmetry} rotation - symmetry whose opposite
  6652. * is needed. Only rotations have opposite symmetries while
  6653. * reflections don't.
  6654. * @returns {PIXI.GD8Symmetry} The opposite symmetry of `rotation`
  6655. */
  6656. inv: function(rotation) {
  6657. if (rotation & 8) {
  6658. return rotation & 15;
  6659. }
  6660. return -rotation & 7;
  6661. },
  6662. /**
  6663. * Composes the two D8 operations.
  6664. *
  6665. * Taking `^` as reflection:
  6666. *
  6667. * | | E=0 | S=2 | W=4 | N=6 | E^=8 | S^=10 | W^=12 | N^=14 |
  6668. * |-------|-----|-----|-----|-----|------|-------|-------|-------|
  6669. * | E=0 | E | S | W | N | E^ | S^ | W^ | N^ |
  6670. * | S=2 | S | W | N | E | S^ | W^ | N^ | E^ |
  6671. * | W=4 | W | N | E | S | W^ | N^ | E^ | S^ |
  6672. * | N=6 | N | E | S | W | N^ | E^ | S^ | W^ |
  6673. * | E^=8 | E^ | N^ | W^ | S^ | E | N | W | S |
  6674. * | S^=10 | S^ | E^ | N^ | W^ | S | E | N | W |
  6675. * | W^=12 | W^ | S^ | E^ | N^ | W | S | E | N |
  6676. * | N^=14 | N^ | W^ | S^ | E^ | N | W | S | E |
  6677. *
  6678. * [This is a Cayley table]{@link https://en.wikipedia.org/wiki/Cayley_table}
  6679. * @memberof PIXI.groupD8
  6680. * @param {PIXI.GD8Symmetry} rotationSecond - Second operation, which
  6681. * is the row in the above cayley table.
  6682. * @param {PIXI.GD8Symmetry} rotationFirst - First operation, which
  6683. * is the column in the above cayley table.
  6684. * @returns {PIXI.GD8Symmetry} Composed operation
  6685. */
  6686. add: function(rotationSecond, rotationFirst) {
  6687. return rotationCayley[rotationSecond][rotationFirst];
  6688. },
  6689. /**
  6690. * Reverse of `add`.
  6691. * @memberof PIXI.groupD8
  6692. * @param {PIXI.GD8Symmetry} rotationSecond - Second operation
  6693. * @param {PIXI.GD8Symmetry} rotationFirst - First operation
  6694. * @returns {PIXI.GD8Symmetry} Result
  6695. */
  6696. sub: function(rotationSecond, rotationFirst) {
  6697. return rotationCayley[rotationSecond][groupD8.inv(rotationFirst)];
  6698. },
  6699. /**
  6700. * Adds 180 degrees to rotation, which is a commutative
  6701. * operation.
  6702. * @memberof PIXI.groupD8
  6703. * @param {number} rotation - The number to rotate.
  6704. * @returns {number} Rotated number
  6705. */
  6706. rotate180: function(rotation) {
  6707. return rotation ^ 4;
  6708. },
  6709. /**
  6710. * Checks if the rotation angle is vertical, i.e. south
  6711. * or north. It doesn't work for reflections.
  6712. * @memberof PIXI.groupD8
  6713. * @param {PIXI.GD8Symmetry} rotation - The number to check.
  6714. * @returns {boolean} Whether or not the direction is vertical
  6715. */
  6716. isVertical: function(rotation) {
  6717. return (rotation & 3) === 2;
  6718. },
  6719. /**
  6720. * Approximates the vector `V(dx,dy)` into one of the
  6721. * eight directions provided by `groupD8`.
  6722. * @memberof PIXI.groupD8
  6723. * @param {number} dx - X-component of the vector
  6724. * @param {number} dy - Y-component of the vector
  6725. * @returns {PIXI.GD8Symmetry} Approximation of the vector into
  6726. * one of the eight symmetries.
  6727. */
  6728. byDirection: function(dx, dy) {
  6729. if (Math.abs(dx) * 2 <= Math.abs(dy)) {
  6730. if (dy >= 0) {
  6731. return groupD8.S;
  6732. }
  6733. return groupD8.N;
  6734. } else if (Math.abs(dy) * 2 <= Math.abs(dx)) {
  6735. if (dx > 0) {
  6736. return groupD8.E;
  6737. }
  6738. return groupD8.W;
  6739. } else if (dy > 0) {
  6740. if (dx > 0) {
  6741. return groupD8.SE;
  6742. }
  6743. return groupD8.SW;
  6744. } else if (dx > 0) {
  6745. return groupD8.NE;
  6746. }
  6747. return groupD8.NW;
  6748. },
  6749. /**
  6750. * Helps sprite to compensate texture packer rotation.
  6751. * @memberof PIXI.groupD8
  6752. * @param {PIXI.Matrix} matrix - sprite world matrix
  6753. * @param {PIXI.GD8Symmetry} rotation - The rotation factor to use.
  6754. * @param {number} tx - sprite anchoring
  6755. * @param {number} ty - sprite anchoring
  6756. */
  6757. matrixAppendRotationInv: function(matrix, rotation, tx, ty) {
  6758. if (tx === void 0) {
  6759. tx = 0;
  6760. }
  6761. if (ty === void 0) {
  6762. ty = 0;
  6763. }
  6764. var mat = rotationMatrices[groupD8.inv(rotation)];
  6765. mat.tx = tx;
  6766. mat.ty = ty;
  6767. matrix.append(mat);
  6768. }
  6769. };
  6770. var Transform = (
  6771. /** @class */
  6772. (function() {
  6773. function Transform2() {
  6774. this.worldTransform = new Matrix();
  6775. this.localTransform = new Matrix();
  6776. this.position = new ObservablePoint(this.onChange, this, 0, 0);
  6777. this.scale = new ObservablePoint(this.onChange, this, 1, 1);
  6778. this.pivot = new ObservablePoint(this.onChange, this, 0, 0);
  6779. this.skew = new ObservablePoint(this.updateSkew, this, 0, 0);
  6780. this._rotation = 0;
  6781. this._cx = 1;
  6782. this._sx = 0;
  6783. this._cy = 0;
  6784. this._sy = 1;
  6785. this._localID = 0;
  6786. this._currentLocalID = 0;
  6787. this._worldID = 0;
  6788. this._parentID = 0;
  6789. }
  6790. Transform2.prototype.onChange = function() {
  6791. this._localID++;
  6792. };
  6793. Transform2.prototype.updateSkew = function() {
  6794. this._cx = Math.cos(this._rotation + this.skew.y);
  6795. this._sx = Math.sin(this._rotation + this.skew.y);
  6796. this._cy = -Math.sin(this._rotation - this.skew.x);
  6797. this._sy = Math.cos(this._rotation - this.skew.x);
  6798. this._localID++;
  6799. };
  6800. Transform2.prototype.toString = function() {
  6801. return "[@pixi/math:Transform " + ("position=(" + this.position.x + ", " + this.position.y + ") ") + ("rotation=" + this.rotation + " ") + ("scale=(" + this.scale.x + ", " + this.scale.y + ") ") + ("skew=(" + this.skew.x + ", " + this.skew.y + ") ") + "]";
  6802. };
  6803. Transform2.prototype.updateLocalTransform = function() {
  6804. var lt = this.localTransform;
  6805. if (this._localID !== this._currentLocalID) {
  6806. lt.a = this._cx * this.scale.x;
  6807. lt.b = this._sx * this.scale.x;
  6808. lt.c = this._cy * this.scale.y;
  6809. lt.d = this._sy * this.scale.y;
  6810. lt.tx = this.position.x - (this.pivot.x * lt.a + this.pivot.y * lt.c);
  6811. lt.ty = this.position.y - (this.pivot.x * lt.b + this.pivot.y * lt.d);
  6812. this._currentLocalID = this._localID;
  6813. this._parentID = -1;
  6814. }
  6815. };
  6816. Transform2.prototype.updateTransform = function(parentTransform) {
  6817. var lt = this.localTransform;
  6818. if (this._localID !== this._currentLocalID) {
  6819. lt.a = this._cx * this.scale.x;
  6820. lt.b = this._sx * this.scale.x;
  6821. lt.c = this._cy * this.scale.y;
  6822. lt.d = this._sy * this.scale.y;
  6823. lt.tx = this.position.x - (this.pivot.x * lt.a + this.pivot.y * lt.c);
  6824. lt.ty = this.position.y - (this.pivot.x * lt.b + this.pivot.y * lt.d);
  6825. this._currentLocalID = this._localID;
  6826. this._parentID = -1;
  6827. }
  6828. if (this._parentID !== parentTransform._worldID) {
  6829. var pt = parentTransform.worldTransform;
  6830. var wt = this.worldTransform;
  6831. wt.a = lt.a * pt.a + lt.b * pt.c;
  6832. wt.b = lt.a * pt.b + lt.b * pt.d;
  6833. wt.c = lt.c * pt.a + lt.d * pt.c;
  6834. wt.d = lt.c * pt.b + lt.d * pt.d;
  6835. wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx;
  6836. wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty;
  6837. this._parentID = parentTransform._worldID;
  6838. this._worldID++;
  6839. }
  6840. };
  6841. Transform2.prototype.setFromMatrix = function(matrix) {
  6842. matrix.decompose(this);
  6843. this._localID++;
  6844. };
  6845. Object.defineProperty(Transform2.prototype, "rotation", {
  6846. /** The rotation of the object in radians. */
  6847. get: function() {
  6848. return this._rotation;
  6849. },
  6850. set: function(value) {
  6851. if (this._rotation !== value) {
  6852. this._rotation = value;
  6853. this.updateSkew();
  6854. }
  6855. },
  6856. enumerable: false,
  6857. configurable: true
  6858. });
  6859. Transform2.IDENTITY = new Transform2();
  6860. return Transform2;
  6861. })()
  6862. );
  6863. // node_modules/@pixi/display/dist/esm/display.mjs
  6864. settings.SORTABLE_CHILDREN = false;
  6865. var Bounds = (
  6866. /** @class */
  6867. (function() {
  6868. function Bounds2() {
  6869. this.minX = Infinity;
  6870. this.minY = Infinity;
  6871. this.maxX = -Infinity;
  6872. this.maxY = -Infinity;
  6873. this.rect = null;
  6874. this.updateID = -1;
  6875. }
  6876. Bounds2.prototype.isEmpty = function() {
  6877. return this.minX > this.maxX || this.minY > this.maxY;
  6878. };
  6879. Bounds2.prototype.clear = function() {
  6880. this.minX = Infinity;
  6881. this.minY = Infinity;
  6882. this.maxX = -Infinity;
  6883. this.maxY = -Infinity;
  6884. };
  6885. Bounds2.prototype.getRectangle = function(rect) {
  6886. if (this.minX > this.maxX || this.minY > this.maxY) {
  6887. return Rectangle.EMPTY;
  6888. }
  6889. rect = rect || new Rectangle(0, 0, 1, 1);
  6890. rect.x = this.minX;
  6891. rect.y = this.minY;
  6892. rect.width = this.maxX - this.minX;
  6893. rect.height = this.maxY - this.minY;
  6894. return rect;
  6895. };
  6896. Bounds2.prototype.addPoint = function(point) {
  6897. this.minX = Math.min(this.minX, point.x);
  6898. this.maxX = Math.max(this.maxX, point.x);
  6899. this.minY = Math.min(this.minY, point.y);
  6900. this.maxY = Math.max(this.maxY, point.y);
  6901. };
  6902. Bounds2.prototype.addPointMatrix = function(matrix, point) {
  6903. var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, tx = matrix.tx, ty = matrix.ty;
  6904. var x = a * point.x + c * point.y + tx;
  6905. var y = b * point.x + d * point.y + ty;
  6906. this.minX = Math.min(this.minX, x);
  6907. this.maxX = Math.max(this.maxX, x);
  6908. this.minY = Math.min(this.minY, y);
  6909. this.maxY = Math.max(this.maxY, y);
  6910. };
  6911. Bounds2.prototype.addQuad = function(vertices) {
  6912. var minX = this.minX;
  6913. var minY = this.minY;
  6914. var maxX = this.maxX;
  6915. var maxY = this.maxY;
  6916. var x = vertices[0];
  6917. var y = vertices[1];
  6918. minX = x < minX ? x : minX;
  6919. minY = y < minY ? y : minY;
  6920. maxX = x > maxX ? x : maxX;
  6921. maxY = y > maxY ? y : maxY;
  6922. x = vertices[2];
  6923. y = vertices[3];
  6924. minX = x < minX ? x : minX;
  6925. minY = y < minY ? y : minY;
  6926. maxX = x > maxX ? x : maxX;
  6927. maxY = y > maxY ? y : maxY;
  6928. x = vertices[4];
  6929. y = vertices[5];
  6930. minX = x < minX ? x : minX;
  6931. minY = y < minY ? y : minY;
  6932. maxX = x > maxX ? x : maxX;
  6933. maxY = y > maxY ? y : maxY;
  6934. x = vertices[6];
  6935. y = vertices[7];
  6936. minX = x < minX ? x : minX;
  6937. minY = y < minY ? y : minY;
  6938. maxX = x > maxX ? x : maxX;
  6939. maxY = y > maxY ? y : maxY;
  6940. this.minX = minX;
  6941. this.minY = minY;
  6942. this.maxX = maxX;
  6943. this.maxY = maxY;
  6944. };
  6945. Bounds2.prototype.addFrame = function(transform, x0, y0, x1, y1) {
  6946. this.addFrameMatrix(transform.worldTransform, x0, y0, x1, y1);
  6947. };
  6948. Bounds2.prototype.addFrameMatrix = function(matrix, x0, y0, x1, y1) {
  6949. var a = matrix.a;
  6950. var b = matrix.b;
  6951. var c = matrix.c;
  6952. var d = matrix.d;
  6953. var tx = matrix.tx;
  6954. var ty = matrix.ty;
  6955. var minX = this.minX;
  6956. var minY = this.minY;
  6957. var maxX = this.maxX;
  6958. var maxY = this.maxY;
  6959. var x = a * x0 + c * y0 + tx;
  6960. var y = b * x0 + d * y0 + ty;
  6961. minX = x < minX ? x : minX;
  6962. minY = y < minY ? y : minY;
  6963. maxX = x > maxX ? x : maxX;
  6964. maxY = y > maxY ? y : maxY;
  6965. x = a * x1 + c * y0 + tx;
  6966. y = b * x1 + d * y0 + ty;
  6967. minX = x < minX ? x : minX;
  6968. minY = y < minY ? y : minY;
  6969. maxX = x > maxX ? x : maxX;
  6970. maxY = y > maxY ? y : maxY;
  6971. x = a * x0 + c * y1 + tx;
  6972. y = b * x0 + d * y1 + ty;
  6973. minX = x < minX ? x : minX;
  6974. minY = y < minY ? y : minY;
  6975. maxX = x > maxX ? x : maxX;
  6976. maxY = y > maxY ? y : maxY;
  6977. x = a * x1 + c * y1 + tx;
  6978. y = b * x1 + d * y1 + ty;
  6979. minX = x < minX ? x : minX;
  6980. minY = y < minY ? y : minY;
  6981. maxX = x > maxX ? x : maxX;
  6982. maxY = y > maxY ? y : maxY;
  6983. this.minX = minX;
  6984. this.minY = minY;
  6985. this.maxX = maxX;
  6986. this.maxY = maxY;
  6987. };
  6988. Bounds2.prototype.addVertexData = function(vertexData, beginOffset, endOffset) {
  6989. var minX = this.minX;
  6990. var minY = this.minY;
  6991. var maxX = this.maxX;
  6992. var maxY = this.maxY;
  6993. for (var i = beginOffset; i < endOffset; i += 2) {
  6994. var x = vertexData[i];
  6995. var y = vertexData[i + 1];
  6996. minX = x < minX ? x : minX;
  6997. minY = y < minY ? y : minY;
  6998. maxX = x > maxX ? x : maxX;
  6999. maxY = y > maxY ? y : maxY;
  7000. }
  7001. this.minX = minX;
  7002. this.minY = minY;
  7003. this.maxX = maxX;
  7004. this.maxY = maxY;
  7005. };
  7006. Bounds2.prototype.addVertices = function(transform, vertices, beginOffset, endOffset) {
  7007. this.addVerticesMatrix(transform.worldTransform, vertices, beginOffset, endOffset);
  7008. };
  7009. Bounds2.prototype.addVerticesMatrix = function(matrix, vertices, beginOffset, endOffset, padX, padY) {
  7010. if (padX === void 0) {
  7011. padX = 0;
  7012. }
  7013. if (padY === void 0) {
  7014. padY = padX;
  7015. }
  7016. var a = matrix.a;
  7017. var b = matrix.b;
  7018. var c = matrix.c;
  7019. var d = matrix.d;
  7020. var tx = matrix.tx;
  7021. var ty = matrix.ty;
  7022. var minX = this.minX;
  7023. var minY = this.minY;
  7024. var maxX = this.maxX;
  7025. var maxY = this.maxY;
  7026. for (var i = beginOffset; i < endOffset; i += 2) {
  7027. var rawX = vertices[i];
  7028. var rawY = vertices[i + 1];
  7029. var x = a * rawX + c * rawY + tx;
  7030. var y = d * rawY + b * rawX + ty;
  7031. minX = Math.min(minX, x - padX);
  7032. maxX = Math.max(maxX, x + padX);
  7033. minY = Math.min(minY, y - padY);
  7034. maxY = Math.max(maxY, y + padY);
  7035. }
  7036. this.minX = minX;
  7037. this.minY = minY;
  7038. this.maxX = maxX;
  7039. this.maxY = maxY;
  7040. };
  7041. Bounds2.prototype.addBounds = function(bounds) {
  7042. var minX = this.minX;
  7043. var minY = this.minY;
  7044. var maxX = this.maxX;
  7045. var maxY = this.maxY;
  7046. this.minX = bounds.minX < minX ? bounds.minX : minX;
  7047. this.minY = bounds.minY < minY ? bounds.minY : minY;
  7048. this.maxX = bounds.maxX > maxX ? bounds.maxX : maxX;
  7049. this.maxY = bounds.maxY > maxY ? bounds.maxY : maxY;
  7050. };
  7051. Bounds2.prototype.addBoundsMask = function(bounds, mask) {
  7052. var _minX = bounds.minX > mask.minX ? bounds.minX : mask.minX;
  7053. var _minY = bounds.minY > mask.minY ? bounds.minY : mask.minY;
  7054. var _maxX = bounds.maxX < mask.maxX ? bounds.maxX : mask.maxX;
  7055. var _maxY = bounds.maxY < mask.maxY ? bounds.maxY : mask.maxY;
  7056. if (_minX <= _maxX && _minY <= _maxY) {
  7057. var minX = this.minX;
  7058. var minY = this.minY;
  7059. var maxX = this.maxX;
  7060. var maxY = this.maxY;
  7061. this.minX = _minX < minX ? _minX : minX;
  7062. this.minY = _minY < minY ? _minY : minY;
  7063. this.maxX = _maxX > maxX ? _maxX : maxX;
  7064. this.maxY = _maxY > maxY ? _maxY : maxY;
  7065. }
  7066. };
  7067. Bounds2.prototype.addBoundsMatrix = function(bounds, matrix) {
  7068. this.addFrameMatrix(matrix, bounds.minX, bounds.minY, bounds.maxX, bounds.maxY);
  7069. };
  7070. Bounds2.prototype.addBoundsArea = function(bounds, area) {
  7071. var _minX = bounds.minX > area.x ? bounds.minX : area.x;
  7072. var _minY = bounds.minY > area.y ? bounds.minY : area.y;
  7073. var _maxX = bounds.maxX < area.x + area.width ? bounds.maxX : area.x + area.width;
  7074. var _maxY = bounds.maxY < area.y + area.height ? bounds.maxY : area.y + area.height;
  7075. if (_minX <= _maxX && _minY <= _maxY) {
  7076. var minX = this.minX;
  7077. var minY = this.minY;
  7078. var maxX = this.maxX;
  7079. var maxY = this.maxY;
  7080. this.minX = _minX < minX ? _minX : minX;
  7081. this.minY = _minY < minY ? _minY : minY;
  7082. this.maxX = _maxX > maxX ? _maxX : maxX;
  7083. this.maxY = _maxY > maxY ? _maxY : maxY;
  7084. }
  7085. };
  7086. Bounds2.prototype.pad = function(paddingX, paddingY) {
  7087. if (paddingX === void 0) {
  7088. paddingX = 0;
  7089. }
  7090. if (paddingY === void 0) {
  7091. paddingY = paddingX;
  7092. }
  7093. if (!this.isEmpty()) {
  7094. this.minX -= paddingX;
  7095. this.maxX += paddingX;
  7096. this.minY -= paddingY;
  7097. this.maxY += paddingY;
  7098. }
  7099. };
  7100. Bounds2.prototype.addFramePad = function(x0, y0, x1, y1, padX, padY) {
  7101. x0 -= padX;
  7102. y0 -= padY;
  7103. x1 += padX;
  7104. y1 += padY;
  7105. this.minX = this.minX < x0 ? this.minX : x0;
  7106. this.maxX = this.maxX > x1 ? this.maxX : x1;
  7107. this.minY = this.minY < y0 ? this.minY : y0;
  7108. this.maxY = this.maxY > y1 ? this.maxY : y1;
  7109. };
  7110. return Bounds2;
  7111. })()
  7112. );
  7113. var extendStatics = function(d, b) {
  7114. extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
  7115. d2.__proto__ = b2;
  7116. } || function(d2, b2) {
  7117. for (var p in b2) {
  7118. if (b2.hasOwnProperty(p)) {
  7119. d2[p] = b2[p];
  7120. }
  7121. }
  7122. };
  7123. return extendStatics(d, b);
  7124. };
  7125. function __extends(d, b) {
  7126. extendStatics(d, b);
  7127. function __() {
  7128. this.constructor = d;
  7129. }
  7130. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7131. }
  7132. var DisplayObject = (
  7133. /** @class */
  7134. (function(_super) {
  7135. __extends(DisplayObject2, _super);
  7136. function DisplayObject2() {
  7137. var _this = _super.call(this) || this;
  7138. _this.tempDisplayObjectParent = null;
  7139. _this.transform = new Transform();
  7140. _this.alpha = 1;
  7141. _this.visible = true;
  7142. _this.renderable = true;
  7143. _this.cullable = false;
  7144. _this.cullArea = null;
  7145. _this.parent = null;
  7146. _this.worldAlpha = 1;
  7147. _this._lastSortedIndex = 0;
  7148. _this._zIndex = 0;
  7149. _this.filterArea = null;
  7150. _this.filters = null;
  7151. _this._enabledFilters = null;
  7152. _this._bounds = new Bounds();
  7153. _this._localBounds = null;
  7154. _this._boundsID = 0;
  7155. _this._boundsRect = null;
  7156. _this._localBoundsRect = null;
  7157. _this._mask = null;
  7158. _this._maskRefCount = 0;
  7159. _this._destroyed = false;
  7160. _this.isSprite = false;
  7161. _this.isMask = false;
  7162. return _this;
  7163. }
  7164. DisplayObject2.mixin = function(source) {
  7165. var keys = Object.keys(source);
  7166. for (var i = 0; i < keys.length; ++i) {
  7167. var propertyName = keys[i];
  7168. Object.defineProperty(DisplayObject2.prototype, propertyName, Object.getOwnPropertyDescriptor(source, propertyName));
  7169. }
  7170. };
  7171. Object.defineProperty(DisplayObject2.prototype, "destroyed", {
  7172. /**
  7173. * Fired when this DisplayObject is added to a Container.
  7174. * @instance
  7175. * @event added
  7176. * @param {PIXI.Container} container - The container added to.
  7177. */
  7178. /**
  7179. * Fired when this DisplayObject is removed from a Container.
  7180. * @instance
  7181. * @event removed
  7182. * @param {PIXI.Container} container - The container removed from.
  7183. */
  7184. /**
  7185. * Fired when this DisplayObject is destroyed. This event is emitted once
  7186. * destroy is finished.
  7187. * @instance
  7188. * @event destroyed
  7189. */
  7190. /** Readonly flag for destroyed display objects. */
  7191. get: function() {
  7192. return this._destroyed;
  7193. },
  7194. enumerable: false,
  7195. configurable: true
  7196. });
  7197. DisplayObject2.prototype._recursivePostUpdateTransform = function() {
  7198. if (this.parent) {
  7199. this.parent._recursivePostUpdateTransform();
  7200. this.transform.updateTransform(this.parent.transform);
  7201. } else {
  7202. this.transform.updateTransform(this._tempDisplayObjectParent.transform);
  7203. }
  7204. };
  7205. DisplayObject2.prototype.updateTransform = function() {
  7206. this._boundsID++;
  7207. this.transform.updateTransform(this.parent.transform);
  7208. this.worldAlpha = this.alpha * this.parent.worldAlpha;
  7209. };
  7210. DisplayObject2.prototype.getBounds = function(skipUpdate, rect) {
  7211. if (!skipUpdate) {
  7212. if (!this.parent) {
  7213. this.parent = this._tempDisplayObjectParent;
  7214. this.updateTransform();
  7215. this.parent = null;
  7216. } else {
  7217. this._recursivePostUpdateTransform();
  7218. this.updateTransform();
  7219. }
  7220. }
  7221. if (this._bounds.updateID !== this._boundsID) {
  7222. this.calculateBounds();
  7223. this._bounds.updateID = this._boundsID;
  7224. }
  7225. if (!rect) {
  7226. if (!this._boundsRect) {
  7227. this._boundsRect = new Rectangle();
  7228. }
  7229. rect = this._boundsRect;
  7230. }
  7231. return this._bounds.getRectangle(rect);
  7232. };
  7233. DisplayObject2.prototype.getLocalBounds = function(rect) {
  7234. if (!rect) {
  7235. if (!this._localBoundsRect) {
  7236. this._localBoundsRect = new Rectangle();
  7237. }
  7238. rect = this._localBoundsRect;
  7239. }
  7240. if (!this._localBounds) {
  7241. this._localBounds = new Bounds();
  7242. }
  7243. var transformRef = this.transform;
  7244. var parentRef = this.parent;
  7245. this.parent = null;
  7246. this.transform = this._tempDisplayObjectParent.transform;
  7247. var worldBounds = this._bounds;
  7248. var worldBoundsID = this._boundsID;
  7249. this._bounds = this._localBounds;
  7250. var bounds = this.getBounds(false, rect);
  7251. this.parent = parentRef;
  7252. this.transform = transformRef;
  7253. this._bounds = worldBounds;
  7254. this._bounds.updateID += this._boundsID - worldBoundsID;
  7255. return bounds;
  7256. };
  7257. DisplayObject2.prototype.toGlobal = function(position, point, skipUpdate) {
  7258. if (skipUpdate === void 0) {
  7259. skipUpdate = false;
  7260. }
  7261. if (!skipUpdate) {
  7262. this._recursivePostUpdateTransform();
  7263. if (!this.parent) {
  7264. this.parent = this._tempDisplayObjectParent;
  7265. this.displayObjectUpdateTransform();
  7266. this.parent = null;
  7267. } else {
  7268. this.displayObjectUpdateTransform();
  7269. }
  7270. }
  7271. return this.worldTransform.apply(position, point);
  7272. };
  7273. DisplayObject2.prototype.toLocal = function(position, from, point, skipUpdate) {
  7274. if (from) {
  7275. position = from.toGlobal(position, point, skipUpdate);
  7276. }
  7277. if (!skipUpdate) {
  7278. this._recursivePostUpdateTransform();
  7279. if (!this.parent) {
  7280. this.parent = this._tempDisplayObjectParent;
  7281. this.displayObjectUpdateTransform();
  7282. this.parent = null;
  7283. } else {
  7284. this.displayObjectUpdateTransform();
  7285. }
  7286. }
  7287. return this.worldTransform.applyInverse(position, point);
  7288. };
  7289. DisplayObject2.prototype.setParent = function(container) {
  7290. if (!container || !container.addChild) {
  7291. throw new Error("setParent: Argument must be a Container");
  7292. }
  7293. container.addChild(this);
  7294. return container;
  7295. };
  7296. DisplayObject2.prototype.setTransform = function(x, y, scaleX, scaleY, rotation, skewX, skewY, pivotX, pivotY) {
  7297. if (x === void 0) {
  7298. x = 0;
  7299. }
  7300. if (y === void 0) {
  7301. y = 0;
  7302. }
  7303. if (scaleX === void 0) {
  7304. scaleX = 1;
  7305. }
  7306. if (scaleY === void 0) {
  7307. scaleY = 1;
  7308. }
  7309. if (rotation === void 0) {
  7310. rotation = 0;
  7311. }
  7312. if (skewX === void 0) {
  7313. skewX = 0;
  7314. }
  7315. if (skewY === void 0) {
  7316. skewY = 0;
  7317. }
  7318. if (pivotX === void 0) {
  7319. pivotX = 0;
  7320. }
  7321. if (pivotY === void 0) {
  7322. pivotY = 0;
  7323. }
  7324. this.position.x = x;
  7325. this.position.y = y;
  7326. this.scale.x = !scaleX ? 1 : scaleX;
  7327. this.scale.y = !scaleY ? 1 : scaleY;
  7328. this.rotation = rotation;
  7329. this.skew.x = skewX;
  7330. this.skew.y = skewY;
  7331. this.pivot.x = pivotX;
  7332. this.pivot.y = pivotY;
  7333. return this;
  7334. };
  7335. DisplayObject2.prototype.destroy = function(_options) {
  7336. if (this.parent) {
  7337. this.parent.removeChild(this);
  7338. }
  7339. this._destroyed = true;
  7340. this.transform = null;
  7341. this.parent = null;
  7342. this._bounds = null;
  7343. this.mask = null;
  7344. this.cullArea = null;
  7345. this.filters = null;
  7346. this.filterArea = null;
  7347. this.hitArea = null;
  7348. this.interactive = false;
  7349. this.interactiveChildren = false;
  7350. this.emit("destroyed");
  7351. this.removeAllListeners();
  7352. };
  7353. Object.defineProperty(DisplayObject2.prototype, "_tempDisplayObjectParent", {
  7354. /**
  7355. * @protected
  7356. * @member {PIXI.Container}
  7357. */
  7358. get: function() {
  7359. if (this.tempDisplayObjectParent === null) {
  7360. this.tempDisplayObjectParent = new TemporaryDisplayObject();
  7361. }
  7362. return this.tempDisplayObjectParent;
  7363. },
  7364. enumerable: false,
  7365. configurable: true
  7366. });
  7367. DisplayObject2.prototype.enableTempParent = function() {
  7368. var myParent = this.parent;
  7369. this.parent = this._tempDisplayObjectParent;
  7370. return myParent;
  7371. };
  7372. DisplayObject2.prototype.disableTempParent = function(cacheParent) {
  7373. this.parent = cacheParent;
  7374. };
  7375. Object.defineProperty(DisplayObject2.prototype, "x", {
  7376. /**
  7377. * The position of the displayObject on the x axis relative to the local coordinates of the parent.
  7378. * An alias to position.x
  7379. */
  7380. get: function() {
  7381. return this.position.x;
  7382. },
  7383. set: function(value) {
  7384. this.transform.position.x = value;
  7385. },
  7386. enumerable: false,
  7387. configurable: true
  7388. });
  7389. Object.defineProperty(DisplayObject2.prototype, "y", {
  7390. /**
  7391. * The position of the displayObject on the y axis relative to the local coordinates of the parent.
  7392. * An alias to position.y
  7393. */
  7394. get: function() {
  7395. return this.position.y;
  7396. },
  7397. set: function(value) {
  7398. this.transform.position.y = value;
  7399. },
  7400. enumerable: false,
  7401. configurable: true
  7402. });
  7403. Object.defineProperty(DisplayObject2.prototype, "worldTransform", {
  7404. /**
  7405. * Current transform of the object based on world (parent) factors.
  7406. * @readonly
  7407. */
  7408. get: function() {
  7409. return this.transform.worldTransform;
  7410. },
  7411. enumerable: false,
  7412. configurable: true
  7413. });
  7414. Object.defineProperty(DisplayObject2.prototype, "localTransform", {
  7415. /**
  7416. * Current transform of the object based on local factors: position, scale, other stuff.
  7417. * @readonly
  7418. */
  7419. get: function() {
  7420. return this.transform.localTransform;
  7421. },
  7422. enumerable: false,
  7423. configurable: true
  7424. });
  7425. Object.defineProperty(DisplayObject2.prototype, "position", {
  7426. /**
  7427. * The coordinate of the object relative to the local coordinates of the parent.
  7428. * @since 4.0.0
  7429. */
  7430. get: function() {
  7431. return this.transform.position;
  7432. },
  7433. set: function(value) {
  7434. this.transform.position.copyFrom(value);
  7435. },
  7436. enumerable: false,
  7437. configurable: true
  7438. });
  7439. Object.defineProperty(DisplayObject2.prototype, "scale", {
  7440. /**
  7441. * The scale factors of this object along the local coordinate axes.
  7442. *
  7443. * The default scale is (1, 1).
  7444. * @since 4.0.0
  7445. */
  7446. get: function() {
  7447. return this.transform.scale;
  7448. },
  7449. set: function(value) {
  7450. this.transform.scale.copyFrom(value);
  7451. },
  7452. enumerable: false,
  7453. configurable: true
  7454. });
  7455. Object.defineProperty(DisplayObject2.prototype, "pivot", {
  7456. /**
  7457. * The center of rotation, scaling, and skewing for this display object in its local space. The `position`
  7458. * is the projection of `pivot` in the parent's local space.
  7459. *
  7460. * By default, the pivot is the origin (0, 0).
  7461. * @since 4.0.0
  7462. */
  7463. get: function() {
  7464. return this.transform.pivot;
  7465. },
  7466. set: function(value) {
  7467. this.transform.pivot.copyFrom(value);
  7468. },
  7469. enumerable: false,
  7470. configurable: true
  7471. });
  7472. Object.defineProperty(DisplayObject2.prototype, "skew", {
  7473. /**
  7474. * The skew factor for the object in radians.
  7475. * @since 4.0.0
  7476. */
  7477. get: function() {
  7478. return this.transform.skew;
  7479. },
  7480. set: function(value) {
  7481. this.transform.skew.copyFrom(value);
  7482. },
  7483. enumerable: false,
  7484. configurable: true
  7485. });
  7486. Object.defineProperty(DisplayObject2.prototype, "rotation", {
  7487. /**
  7488. * The rotation of the object in radians.
  7489. * 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees.
  7490. */
  7491. get: function() {
  7492. return this.transform.rotation;
  7493. },
  7494. set: function(value) {
  7495. this.transform.rotation = value;
  7496. },
  7497. enumerable: false,
  7498. configurable: true
  7499. });
  7500. Object.defineProperty(DisplayObject2.prototype, "angle", {
  7501. /**
  7502. * The angle of the object in degrees.
  7503. * 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees.
  7504. */
  7505. get: function() {
  7506. return this.transform.rotation * RAD_TO_DEG;
  7507. },
  7508. set: function(value) {
  7509. this.transform.rotation = value * DEG_TO_RAD;
  7510. },
  7511. enumerable: false,
  7512. configurable: true
  7513. });
  7514. Object.defineProperty(DisplayObject2.prototype, "zIndex", {
  7515. /**
  7516. * The zIndex of the displayObject.
  7517. *
  7518. * If a container has the sortableChildren property set to true, children will be automatically
  7519. * sorted by zIndex value; a higher value will mean it will be moved towards the end of the array,
  7520. * and thus rendered on top of other display objects within the same container.
  7521. * @see PIXI.Container#sortableChildren
  7522. */
  7523. get: function() {
  7524. return this._zIndex;
  7525. },
  7526. set: function(value) {
  7527. this._zIndex = value;
  7528. if (this.parent) {
  7529. this.parent.sortDirty = true;
  7530. }
  7531. },
  7532. enumerable: false,
  7533. configurable: true
  7534. });
  7535. Object.defineProperty(DisplayObject2.prototype, "worldVisible", {
  7536. /**
  7537. * Indicates if the object is globally visible.
  7538. * @readonly
  7539. */
  7540. get: function() {
  7541. var item = this;
  7542. do {
  7543. if (!item.visible) {
  7544. return false;
  7545. }
  7546. item = item.parent;
  7547. } while (item);
  7548. return true;
  7549. },
  7550. enumerable: false,
  7551. configurable: true
  7552. });
  7553. Object.defineProperty(DisplayObject2.prototype, "mask", {
  7554. /**
  7555. * Sets a mask for the displayObject. A mask is an object that limits the visibility of an
  7556. * object to the shape of the mask applied to it. In PixiJS a regular mask must be a
  7557. * {@link PIXI.Graphics} or a {@link PIXI.Sprite} object. This allows for much faster masking in canvas as it
  7558. * utilities shape clipping. Furthermore, a mask of an object must be in the subtree of its parent.
  7559. * Otherwise, `getLocalBounds` may calculate incorrect bounds, which makes the container's width and height wrong.
  7560. * To remove a mask, set this property to `null`.
  7561. *
  7562. * For sprite mask both alpha and red channel are used. Black mask is the same as transparent mask.
  7563. * @example
  7564. * const graphics = new PIXI.Graphics();
  7565. * graphics.beginFill(0xFF3300);
  7566. * graphics.drawRect(50, 250, 100, 100);
  7567. * graphics.endFill();
  7568. *
  7569. * const sprite = new PIXI.Sprite(texture);
  7570. * sprite.mask = graphics;
  7571. * @todo At the moment, PIXI.CanvasRenderer doesn't support PIXI.Sprite as mask.
  7572. */
  7573. get: function() {
  7574. return this._mask;
  7575. },
  7576. set: function(value) {
  7577. if (this._mask === value) {
  7578. return;
  7579. }
  7580. if (this._mask) {
  7581. var maskObject = this._mask.isMaskData ? this._mask.maskObject : this._mask;
  7582. if (maskObject) {
  7583. maskObject._maskRefCount--;
  7584. if (maskObject._maskRefCount === 0) {
  7585. maskObject.renderable = true;
  7586. maskObject.isMask = false;
  7587. }
  7588. }
  7589. }
  7590. this._mask = value;
  7591. if (this._mask) {
  7592. var maskObject = this._mask.isMaskData ? this._mask.maskObject : this._mask;
  7593. if (maskObject) {
  7594. if (maskObject._maskRefCount === 0) {
  7595. maskObject.renderable = false;
  7596. maskObject.isMask = true;
  7597. }
  7598. maskObject._maskRefCount++;
  7599. }
  7600. }
  7601. },
  7602. enumerable: false,
  7603. configurable: true
  7604. });
  7605. return DisplayObject2;
  7606. })(import_eventemitter3.default)
  7607. );
  7608. var TemporaryDisplayObject = (
  7609. /** @class */
  7610. (function(_super) {
  7611. __extends(TemporaryDisplayObject2, _super);
  7612. function TemporaryDisplayObject2() {
  7613. var _this = _super !== null && _super.apply(this, arguments) || this;
  7614. _this.sortDirty = null;
  7615. return _this;
  7616. }
  7617. return TemporaryDisplayObject2;
  7618. })(DisplayObject)
  7619. );
  7620. DisplayObject.prototype.displayObjectUpdateTransform = DisplayObject.prototype.updateTransform;
  7621. function sortChildren(a, b) {
  7622. if (a.zIndex === b.zIndex) {
  7623. return a._lastSortedIndex - b._lastSortedIndex;
  7624. }
  7625. return a.zIndex - b.zIndex;
  7626. }
  7627. var Container = (
  7628. /** @class */
  7629. (function(_super) {
  7630. __extends(Container2, _super);
  7631. function Container2() {
  7632. var _this = _super.call(this) || this;
  7633. _this.children = [];
  7634. _this.sortableChildren = settings.SORTABLE_CHILDREN;
  7635. _this.sortDirty = false;
  7636. return _this;
  7637. }
  7638. Container2.prototype.onChildrenChange = function(_length) {
  7639. };
  7640. Container2.prototype.addChild = function() {
  7641. var arguments$1 = arguments;
  7642. var children = [];
  7643. for (var _i = 0; _i < arguments.length; _i++) {
  7644. children[_i] = arguments$1[_i];
  7645. }
  7646. if (children.length > 1) {
  7647. for (var i = 0; i < children.length; i++) {
  7648. this.addChild(children[i]);
  7649. }
  7650. } else {
  7651. var child = children[0];
  7652. if (child.parent) {
  7653. child.parent.removeChild(child);
  7654. }
  7655. child.parent = this;
  7656. this.sortDirty = true;
  7657. child.transform._parentID = -1;
  7658. this.children.push(child);
  7659. this._boundsID++;
  7660. this.onChildrenChange(this.children.length - 1);
  7661. this.emit("childAdded", child, this, this.children.length - 1);
  7662. child.emit("added", this);
  7663. }
  7664. return children[0];
  7665. };
  7666. Container2.prototype.addChildAt = function(child, index) {
  7667. if (index < 0 || index > this.children.length) {
  7668. throw new Error(child + "addChildAt: The index " + index + " supplied is out of bounds " + this.children.length);
  7669. }
  7670. if (child.parent) {
  7671. child.parent.removeChild(child);
  7672. }
  7673. child.parent = this;
  7674. this.sortDirty = true;
  7675. child.transform._parentID = -1;
  7676. this.children.splice(index, 0, child);
  7677. this._boundsID++;
  7678. this.onChildrenChange(index);
  7679. child.emit("added", this);
  7680. this.emit("childAdded", child, this, index);
  7681. return child;
  7682. };
  7683. Container2.prototype.swapChildren = function(child, child2) {
  7684. if (child === child2) {
  7685. return;
  7686. }
  7687. var index1 = this.getChildIndex(child);
  7688. var index2 = this.getChildIndex(child2);
  7689. this.children[index1] = child2;
  7690. this.children[index2] = child;
  7691. this.onChildrenChange(index1 < index2 ? index1 : index2);
  7692. };
  7693. Container2.prototype.getChildIndex = function(child) {
  7694. var index = this.children.indexOf(child);
  7695. if (index === -1) {
  7696. throw new Error("The supplied DisplayObject must be a child of the caller");
  7697. }
  7698. return index;
  7699. };
  7700. Container2.prototype.setChildIndex = function(child, index) {
  7701. if (index < 0 || index >= this.children.length) {
  7702. throw new Error("The index " + index + " supplied is out of bounds " + this.children.length);
  7703. }
  7704. var currentIndex = this.getChildIndex(child);
  7705. removeItems(this.children, currentIndex, 1);
  7706. this.children.splice(index, 0, child);
  7707. this.onChildrenChange(index);
  7708. };
  7709. Container2.prototype.getChildAt = function(index) {
  7710. if (index < 0 || index >= this.children.length) {
  7711. throw new Error("getChildAt: Index (" + index + ") does not exist.");
  7712. }
  7713. return this.children[index];
  7714. };
  7715. Container2.prototype.removeChild = function() {
  7716. var arguments$1 = arguments;
  7717. var children = [];
  7718. for (var _i = 0; _i < arguments.length; _i++) {
  7719. children[_i] = arguments$1[_i];
  7720. }
  7721. if (children.length > 1) {
  7722. for (var i = 0; i < children.length; i++) {
  7723. this.removeChild(children[i]);
  7724. }
  7725. } else {
  7726. var child = children[0];
  7727. var index = this.children.indexOf(child);
  7728. if (index === -1) {
  7729. return null;
  7730. }
  7731. child.parent = null;
  7732. child.transform._parentID = -1;
  7733. removeItems(this.children, index, 1);
  7734. this._boundsID++;
  7735. this.onChildrenChange(index);
  7736. child.emit("removed", this);
  7737. this.emit("childRemoved", child, this, index);
  7738. }
  7739. return children[0];
  7740. };
  7741. Container2.prototype.removeChildAt = function(index) {
  7742. var child = this.getChildAt(index);
  7743. child.parent = null;
  7744. child.transform._parentID = -1;
  7745. removeItems(this.children, index, 1);
  7746. this._boundsID++;
  7747. this.onChildrenChange(index);
  7748. child.emit("removed", this);
  7749. this.emit("childRemoved", child, this, index);
  7750. return child;
  7751. };
  7752. Container2.prototype.removeChildren = function(beginIndex, endIndex) {
  7753. if (beginIndex === void 0) {
  7754. beginIndex = 0;
  7755. }
  7756. if (endIndex === void 0) {
  7757. endIndex = this.children.length;
  7758. }
  7759. var begin = beginIndex;
  7760. var end = endIndex;
  7761. var range = end - begin;
  7762. var removed;
  7763. if (range > 0 && range <= end) {
  7764. removed = this.children.splice(begin, range);
  7765. for (var i = 0; i < removed.length; ++i) {
  7766. removed[i].parent = null;
  7767. if (removed[i].transform) {
  7768. removed[i].transform._parentID = -1;
  7769. }
  7770. }
  7771. this._boundsID++;
  7772. this.onChildrenChange(beginIndex);
  7773. for (var i = 0; i < removed.length; ++i) {
  7774. removed[i].emit("removed", this);
  7775. this.emit("childRemoved", removed[i], this, i);
  7776. }
  7777. return removed;
  7778. } else if (range === 0 && this.children.length === 0) {
  7779. return [];
  7780. }
  7781. throw new RangeError("removeChildren: numeric values are outside the acceptable range.");
  7782. };
  7783. Container2.prototype.sortChildren = function() {
  7784. var sortRequired = false;
  7785. for (var i = 0, j = this.children.length; i < j; ++i) {
  7786. var child = this.children[i];
  7787. child._lastSortedIndex = i;
  7788. if (!sortRequired && child.zIndex !== 0) {
  7789. sortRequired = true;
  7790. }
  7791. }
  7792. if (sortRequired && this.children.length > 1) {
  7793. this.children.sort(sortChildren);
  7794. }
  7795. this.sortDirty = false;
  7796. };
  7797. Container2.prototype.updateTransform = function() {
  7798. if (this.sortableChildren && this.sortDirty) {
  7799. this.sortChildren();
  7800. }
  7801. this._boundsID++;
  7802. this.transform.updateTransform(this.parent.transform);
  7803. this.worldAlpha = this.alpha * this.parent.worldAlpha;
  7804. for (var i = 0, j = this.children.length; i < j; ++i) {
  7805. var child = this.children[i];
  7806. if (child.visible) {
  7807. child.updateTransform();
  7808. }
  7809. }
  7810. };
  7811. Container2.prototype.calculateBounds = function() {
  7812. this._bounds.clear();
  7813. this._calculateBounds();
  7814. for (var i = 0; i < this.children.length; i++) {
  7815. var child = this.children[i];
  7816. if (!child.visible || !child.renderable) {
  7817. continue;
  7818. }
  7819. child.calculateBounds();
  7820. if (child._mask) {
  7821. var maskObject = child._mask.isMaskData ? child._mask.maskObject : child._mask;
  7822. if (maskObject) {
  7823. maskObject.calculateBounds();
  7824. this._bounds.addBoundsMask(child._bounds, maskObject._bounds);
  7825. } else {
  7826. this._bounds.addBounds(child._bounds);
  7827. }
  7828. } else if (child.filterArea) {
  7829. this._bounds.addBoundsArea(child._bounds, child.filterArea);
  7830. } else {
  7831. this._bounds.addBounds(child._bounds);
  7832. }
  7833. }
  7834. this._bounds.updateID = this._boundsID;
  7835. };
  7836. Container2.prototype.getLocalBounds = function(rect, skipChildrenUpdate) {
  7837. if (skipChildrenUpdate === void 0) {
  7838. skipChildrenUpdate = false;
  7839. }
  7840. var result = _super.prototype.getLocalBounds.call(this, rect);
  7841. if (!skipChildrenUpdate) {
  7842. for (var i = 0, j = this.children.length; i < j; ++i) {
  7843. var child = this.children[i];
  7844. if (child.visible) {
  7845. child.updateTransform();
  7846. }
  7847. }
  7848. }
  7849. return result;
  7850. };
  7851. Container2.prototype._calculateBounds = function() {
  7852. };
  7853. Container2.prototype._renderWithCulling = function(renderer) {
  7854. var sourceFrame = renderer.renderTexture.sourceFrame;
  7855. if (!(sourceFrame.width > 0 && sourceFrame.height > 0)) {
  7856. return;
  7857. }
  7858. var bounds;
  7859. var transform;
  7860. if (this.cullArea) {
  7861. bounds = this.cullArea;
  7862. transform = this.worldTransform;
  7863. } else if (this._render !== Container2.prototype._render) {
  7864. bounds = this.getBounds(true);
  7865. }
  7866. if (bounds && sourceFrame.intersects(bounds, transform)) {
  7867. this._render(renderer);
  7868. } else if (this.cullArea) {
  7869. return;
  7870. }
  7871. for (var i = 0, j = this.children.length; i < j; ++i) {
  7872. var child = this.children[i];
  7873. var childCullable = child.cullable;
  7874. child.cullable = childCullable || !this.cullArea;
  7875. child.render(renderer);
  7876. child.cullable = childCullable;
  7877. }
  7878. };
  7879. Container2.prototype.render = function(renderer) {
  7880. if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {
  7881. return;
  7882. }
  7883. if (this._mask || this.filters && this.filters.length) {
  7884. this.renderAdvanced(renderer);
  7885. } else if (this.cullable) {
  7886. this._renderWithCulling(renderer);
  7887. } else {
  7888. this._render(renderer);
  7889. for (var i = 0, j = this.children.length; i < j; ++i) {
  7890. this.children[i].render(renderer);
  7891. }
  7892. }
  7893. };
  7894. Container2.prototype.renderAdvanced = function(renderer) {
  7895. var filters = this.filters;
  7896. var mask = this._mask;
  7897. if (filters) {
  7898. if (!this._enabledFilters) {
  7899. this._enabledFilters = [];
  7900. }
  7901. this._enabledFilters.length = 0;
  7902. for (var i = 0; i < filters.length; i++) {
  7903. if (filters[i].enabled) {
  7904. this._enabledFilters.push(filters[i]);
  7905. }
  7906. }
  7907. }
  7908. var flush = filters && this._enabledFilters && this._enabledFilters.length || mask && (!mask.isMaskData || mask.enabled && (mask.autoDetect || mask.type !== MASK_TYPES.NONE));
  7909. if (flush) {
  7910. renderer.batch.flush();
  7911. }
  7912. if (filters && this._enabledFilters && this._enabledFilters.length) {
  7913. renderer.filter.push(this, this._enabledFilters);
  7914. }
  7915. if (mask) {
  7916. renderer.mask.push(this, this._mask);
  7917. }
  7918. if (this.cullable) {
  7919. this._renderWithCulling(renderer);
  7920. } else {
  7921. this._render(renderer);
  7922. for (var i = 0, j = this.children.length; i < j; ++i) {
  7923. this.children[i].render(renderer);
  7924. }
  7925. }
  7926. if (flush) {
  7927. renderer.batch.flush();
  7928. }
  7929. if (mask) {
  7930. renderer.mask.pop(this);
  7931. }
  7932. if (filters && this._enabledFilters && this._enabledFilters.length) {
  7933. renderer.filter.pop();
  7934. }
  7935. };
  7936. Container2.prototype._render = function(_renderer) {
  7937. };
  7938. Container2.prototype.destroy = function(options) {
  7939. _super.prototype.destroy.call(this);
  7940. this.sortDirty = false;
  7941. var destroyChildren = typeof options === "boolean" ? options : options && options.children;
  7942. var oldChildren = this.removeChildren(0, this.children.length);
  7943. if (destroyChildren) {
  7944. for (var i = 0; i < oldChildren.length; ++i) {
  7945. oldChildren[i].destroy(options);
  7946. }
  7947. }
  7948. };
  7949. Object.defineProperty(Container2.prototype, "width", {
  7950. /** The width of the Container, setting this will actually modify the scale to achieve the value set. */
  7951. get: function() {
  7952. return this.scale.x * this.getLocalBounds().width;
  7953. },
  7954. set: function(value) {
  7955. var width = this.getLocalBounds().width;
  7956. if (width !== 0) {
  7957. this.scale.x = value / width;
  7958. } else {
  7959. this.scale.x = 1;
  7960. }
  7961. this._width = value;
  7962. },
  7963. enumerable: false,
  7964. configurable: true
  7965. });
  7966. Object.defineProperty(Container2.prototype, "height", {
  7967. /** The height of the Container, setting this will actually modify the scale to achieve the value set. */
  7968. get: function() {
  7969. return this.scale.y * this.getLocalBounds().height;
  7970. },
  7971. set: function(value) {
  7972. var height = this.getLocalBounds().height;
  7973. if (height !== 0) {
  7974. this.scale.y = value / height;
  7975. } else {
  7976. this.scale.y = 1;
  7977. }
  7978. this._height = value;
  7979. },
  7980. enumerable: false,
  7981. configurable: true
  7982. });
  7983. return Container2;
  7984. })(DisplayObject)
  7985. );
  7986. Container.prototype.containerUpdateTransform = Container.prototype.updateTransform;
  7987. // node_modules/@pixi/extensions/dist/esm/extensions.mjs
  7988. var __assign = function() {
  7989. __assign = Object.assign || function __assign3(t) {
  7990. var arguments$1 = arguments;
  7991. for (var s, i = 1, n = arguments.length; i < n; i++) {
  7992. s = arguments$1[i];
  7993. for (var p in s) {
  7994. if (Object.prototype.hasOwnProperty.call(s, p)) {
  7995. t[p] = s[p];
  7996. }
  7997. }
  7998. }
  7999. return t;
  8000. };
  8001. return __assign.apply(this, arguments);
  8002. };
  8003. var ExtensionType;
  8004. (function(ExtensionType2) {
  8005. ExtensionType2["Application"] = "application";
  8006. ExtensionType2["RendererPlugin"] = "renderer-webgl-plugin";
  8007. ExtensionType2["CanvasRendererPlugin"] = "renderer-canvas-plugin";
  8008. ExtensionType2["Loader"] = "loader";
  8009. ExtensionType2["LoadParser"] = "load-parser";
  8010. ExtensionType2["ResolveParser"] = "resolve-parser";
  8011. ExtensionType2["CacheParser"] = "cache-parser";
  8012. ExtensionType2["DetectionParser"] = "detection-parser";
  8013. })(ExtensionType || (ExtensionType = {}));
  8014. var normalizeExtension = function(ext) {
  8015. if (typeof ext === "function" || typeof ext === "object" && ext.extension) {
  8016. if (!ext.extension) {
  8017. throw new Error("Extension class must have an extension object");
  8018. }
  8019. var metadata = typeof ext.extension !== "object" ? { type: ext.extension } : ext.extension;
  8020. ext = __assign(__assign({}, metadata), { ref: ext });
  8021. }
  8022. if (typeof ext === "object") {
  8023. ext = __assign({}, ext);
  8024. } else {
  8025. throw new Error("Invalid extension type");
  8026. }
  8027. if (typeof ext.type === "string") {
  8028. ext.type = [ext.type];
  8029. }
  8030. return ext;
  8031. };
  8032. var extensions = {
  8033. /** @ignore */
  8034. _addHandlers: null,
  8035. /** @ignore */
  8036. _removeHandlers: null,
  8037. /** @ignore */
  8038. _queue: {},
  8039. /**
  8040. * Remove extensions from PixiJS.
  8041. * @param extensions - Extensions to be removed.
  8042. * @returns {PIXI.extensions} For chaining.
  8043. */
  8044. remove: function() {
  8045. var arguments$1 = arguments;
  8046. var _this = this;
  8047. var extensions2 = [];
  8048. for (var _i = 0; _i < arguments.length; _i++) {
  8049. extensions2[_i] = arguments$1[_i];
  8050. }
  8051. extensions2.map(normalizeExtension).forEach(function(ext) {
  8052. ext.type.forEach(function(type) {
  8053. var _a, _b;
  8054. return (_b = (_a = _this._removeHandlers)[type]) === null || _b === void 0 ? void 0 : _b.call(_a, ext);
  8055. });
  8056. });
  8057. return this;
  8058. },
  8059. /**
  8060. * Register new extensions with PixiJS.
  8061. * @param extensions - The spread of extensions to add to PixiJS.
  8062. * @returns {PIXI.extensions} For chaining.
  8063. */
  8064. add: function() {
  8065. var arguments$1 = arguments;
  8066. var _this = this;
  8067. var extensions2 = [];
  8068. for (var _i = 0; _i < arguments.length; _i++) {
  8069. extensions2[_i] = arguments$1[_i];
  8070. }
  8071. extensions2.map(normalizeExtension).forEach(function(ext) {
  8072. ext.type.forEach(function(type) {
  8073. var handlers = _this._addHandlers;
  8074. var queue = _this._queue;
  8075. if (!handlers[type]) {
  8076. queue[type] = queue[type] || [];
  8077. queue[type].push(ext);
  8078. } else {
  8079. handlers[type](ext);
  8080. }
  8081. });
  8082. });
  8083. return this;
  8084. },
  8085. /**
  8086. * Internal method to handle extensions by name.
  8087. * @param type - The extension type.
  8088. * @param onAdd - Function for handling when extensions are added/registered passes {@link PIXI.ExtensionFormat}.
  8089. * @param onRemove - Function for handling when extensions are removed/unregistered passes {@link PIXI.ExtensionFormat}.
  8090. * @returns {PIXI.extensions} For chaining.
  8091. */
  8092. handle: function(type, onAdd, onRemove) {
  8093. var addHandlers = this._addHandlers = this._addHandlers || {};
  8094. var removeHandlers = this._removeHandlers = this._removeHandlers || {};
  8095. if (addHandlers[type] || removeHandlers[type]) {
  8096. throw new Error("Extension type " + type + " already has a handler");
  8097. }
  8098. addHandlers[type] = onAdd;
  8099. removeHandlers[type] = onRemove;
  8100. var queue = this._queue;
  8101. if (queue[type]) {
  8102. queue[type].forEach(function(ext) {
  8103. return onAdd(ext);
  8104. });
  8105. delete queue[type];
  8106. }
  8107. return this;
  8108. },
  8109. /**
  8110. * Handle a type, but using a map by `name` property.
  8111. * @param type - Type of extension to handle.
  8112. * @param map - The object map of named extensions.
  8113. * @returns {PIXI.extensions} For chaining.
  8114. */
  8115. handleByMap: function(type, map3) {
  8116. return this.handle(type, function(extension) {
  8117. map3[extension.name] = extension.ref;
  8118. }, function(extension) {
  8119. delete map3[extension.name];
  8120. });
  8121. },
  8122. /**
  8123. * Handle a type, but using a list of extensions.
  8124. * @param type - Type of extension to handle.
  8125. * @param list - The list of extensions.
  8126. * @returns {PIXI.extensions} For chaining.
  8127. */
  8128. handleByList: function(type, list) {
  8129. return this.handle(type, function(extension) {
  8130. var _a, _b;
  8131. if (list.includes(extension.ref)) {
  8132. return;
  8133. }
  8134. list.push(extension.ref);
  8135. if (type === ExtensionType.Loader) {
  8136. (_b = (_a = extension.ref).add) === null || _b === void 0 ? void 0 : _b.call(_a);
  8137. }
  8138. }, function(extension) {
  8139. var index = list.indexOf(extension.ref);
  8140. if (index !== -1) {
  8141. list.splice(index, 1);
  8142. }
  8143. });
  8144. }
  8145. };
  8146. // node_modules/@pixi/runner/dist/esm/runner.mjs
  8147. var Runner = (
  8148. /** @class */
  8149. (function() {
  8150. function Runner2(name) {
  8151. this.items = [];
  8152. this._name = name;
  8153. this._aliasCount = 0;
  8154. }
  8155. Runner2.prototype.emit = function(a0, a1, a2, a3, a4, a5, a6, a7) {
  8156. if (arguments.length > 8) {
  8157. throw new Error("max arguments reached");
  8158. }
  8159. var _a = this, name = _a.name, items = _a.items;
  8160. this._aliasCount++;
  8161. for (var i = 0, len = items.length; i < len; i++) {
  8162. items[i][name](a0, a1, a2, a3, a4, a5, a6, a7);
  8163. }
  8164. if (items === this.items) {
  8165. this._aliasCount--;
  8166. }
  8167. return this;
  8168. };
  8169. Runner2.prototype.ensureNonAliasedItems = function() {
  8170. if (this._aliasCount > 0 && this.items.length > 1) {
  8171. this._aliasCount = 0;
  8172. this.items = this.items.slice(0);
  8173. }
  8174. };
  8175. Runner2.prototype.add = function(item) {
  8176. if (item[this._name]) {
  8177. this.ensureNonAliasedItems();
  8178. this.remove(item);
  8179. this.items.push(item);
  8180. }
  8181. return this;
  8182. };
  8183. Runner2.prototype.remove = function(item) {
  8184. var index = this.items.indexOf(item);
  8185. if (index !== -1) {
  8186. this.ensureNonAliasedItems();
  8187. this.items.splice(index, 1);
  8188. }
  8189. return this;
  8190. };
  8191. Runner2.prototype.contains = function(item) {
  8192. return this.items.indexOf(item) !== -1;
  8193. };
  8194. Runner2.prototype.removeAll = function() {
  8195. this.ensureNonAliasedItems();
  8196. this.items.length = 0;
  8197. return this;
  8198. };
  8199. Runner2.prototype.destroy = function() {
  8200. this.removeAll();
  8201. this.items = null;
  8202. this._name = null;
  8203. };
  8204. Object.defineProperty(Runner2.prototype, "empty", {
  8205. /**
  8206. * `true` if there are no this Runner contains no listeners
  8207. * @readonly
  8208. */
  8209. get: function() {
  8210. return this.items.length === 0;
  8211. },
  8212. enumerable: false,
  8213. configurable: true
  8214. });
  8215. Object.defineProperty(Runner2.prototype, "name", {
  8216. /**
  8217. * The name of the runner.
  8218. * @readonly
  8219. */
  8220. get: function() {
  8221. return this._name;
  8222. },
  8223. enumerable: false,
  8224. configurable: true
  8225. });
  8226. return Runner2;
  8227. })()
  8228. );
  8229. Object.defineProperties(Runner.prototype, {
  8230. /**
  8231. * Alias for `emit`
  8232. * @memberof PIXI.Runner#
  8233. * @method dispatch
  8234. * @see PIXI.Runner#emit
  8235. */
  8236. dispatch: { value: Runner.prototype.emit },
  8237. /**
  8238. * Alias for `emit`
  8239. * @memberof PIXI.Runner#
  8240. * @method run
  8241. * @see PIXI.Runner#emit
  8242. */
  8243. run: { value: Runner.prototype.emit }
  8244. });
  8245. // node_modules/@pixi/ticker/dist/esm/ticker.mjs
  8246. settings.TARGET_FPMS = 0.06;
  8247. var UPDATE_PRIORITY;
  8248. (function(UPDATE_PRIORITY2) {
  8249. UPDATE_PRIORITY2[UPDATE_PRIORITY2["INTERACTION"] = 50] = "INTERACTION";
  8250. UPDATE_PRIORITY2[UPDATE_PRIORITY2["HIGH"] = 25] = "HIGH";
  8251. UPDATE_PRIORITY2[UPDATE_PRIORITY2["NORMAL"] = 0] = "NORMAL";
  8252. UPDATE_PRIORITY2[UPDATE_PRIORITY2["LOW"] = -25] = "LOW";
  8253. UPDATE_PRIORITY2[UPDATE_PRIORITY2["UTILITY"] = -50] = "UTILITY";
  8254. })(UPDATE_PRIORITY || (UPDATE_PRIORITY = {}));
  8255. var TickerListener = (
  8256. /** @class */
  8257. (function() {
  8258. function TickerListener2(fn, context2, priority, once) {
  8259. if (context2 === void 0) {
  8260. context2 = null;
  8261. }
  8262. if (priority === void 0) {
  8263. priority = 0;
  8264. }
  8265. if (once === void 0) {
  8266. once = false;
  8267. }
  8268. this.next = null;
  8269. this.previous = null;
  8270. this._destroyed = false;
  8271. this.fn = fn;
  8272. this.context = context2;
  8273. this.priority = priority;
  8274. this.once = once;
  8275. }
  8276. TickerListener2.prototype.match = function(fn, context2) {
  8277. if (context2 === void 0) {
  8278. context2 = null;
  8279. }
  8280. return this.fn === fn && this.context === context2;
  8281. };
  8282. TickerListener2.prototype.emit = function(deltaTime) {
  8283. if (this.fn) {
  8284. if (this.context) {
  8285. this.fn.call(this.context, deltaTime);
  8286. } else {
  8287. this.fn(deltaTime);
  8288. }
  8289. }
  8290. var redirect = this.next;
  8291. if (this.once) {
  8292. this.destroy(true);
  8293. }
  8294. if (this._destroyed) {
  8295. this.next = null;
  8296. }
  8297. return redirect;
  8298. };
  8299. TickerListener2.prototype.connect = function(previous) {
  8300. this.previous = previous;
  8301. if (previous.next) {
  8302. previous.next.previous = this;
  8303. }
  8304. this.next = previous.next;
  8305. previous.next = this;
  8306. };
  8307. TickerListener2.prototype.destroy = function(hard) {
  8308. if (hard === void 0) {
  8309. hard = false;
  8310. }
  8311. this._destroyed = true;
  8312. this.fn = null;
  8313. this.context = null;
  8314. if (this.previous) {
  8315. this.previous.next = this.next;
  8316. }
  8317. if (this.next) {
  8318. this.next.previous = this.previous;
  8319. }
  8320. var redirect = this.next;
  8321. this.next = hard ? null : redirect;
  8322. this.previous = null;
  8323. return redirect;
  8324. };
  8325. return TickerListener2;
  8326. })()
  8327. );
  8328. var Ticker = (
  8329. /** @class */
  8330. (function() {
  8331. function Ticker2() {
  8332. var _this = this;
  8333. this.autoStart = false;
  8334. this.deltaTime = 1;
  8335. this.lastTime = -1;
  8336. this.speed = 1;
  8337. this.started = false;
  8338. this._requestId = null;
  8339. this._maxElapsedMS = 100;
  8340. this._minElapsedMS = 0;
  8341. this._protected = false;
  8342. this._lastFrame = -1;
  8343. this._head = new TickerListener(null, null, Infinity);
  8344. this.deltaMS = 1 / settings.TARGET_FPMS;
  8345. this.elapsedMS = 1 / settings.TARGET_FPMS;
  8346. this._tick = function(time) {
  8347. _this._requestId = null;
  8348. if (_this.started) {
  8349. _this.update(time);
  8350. if (_this.started && _this._requestId === null && _this._head.next) {
  8351. _this._requestId = requestAnimationFrame(_this._tick);
  8352. }
  8353. }
  8354. };
  8355. }
  8356. Ticker2.prototype._requestIfNeeded = function() {
  8357. if (this._requestId === null && this._head.next) {
  8358. this.lastTime = performance.now();
  8359. this._lastFrame = this.lastTime;
  8360. this._requestId = requestAnimationFrame(this._tick);
  8361. }
  8362. };
  8363. Ticker2.prototype._cancelIfNeeded = function() {
  8364. if (this._requestId !== null) {
  8365. cancelAnimationFrame(this._requestId);
  8366. this._requestId = null;
  8367. }
  8368. };
  8369. Ticker2.prototype._startIfPossible = function() {
  8370. if (this.started) {
  8371. this._requestIfNeeded();
  8372. } else if (this.autoStart) {
  8373. this.start();
  8374. }
  8375. };
  8376. Ticker2.prototype.add = function(fn, context2, priority) {
  8377. if (priority === void 0) {
  8378. priority = UPDATE_PRIORITY.NORMAL;
  8379. }
  8380. return this._addListener(new TickerListener(fn, context2, priority));
  8381. };
  8382. Ticker2.prototype.addOnce = function(fn, context2, priority) {
  8383. if (priority === void 0) {
  8384. priority = UPDATE_PRIORITY.NORMAL;
  8385. }
  8386. return this._addListener(new TickerListener(fn, context2, priority, true));
  8387. };
  8388. Ticker2.prototype._addListener = function(listener) {
  8389. var current = this._head.next;
  8390. var previous = this._head;
  8391. if (!current) {
  8392. listener.connect(previous);
  8393. } else {
  8394. while (current) {
  8395. if (listener.priority > current.priority) {
  8396. listener.connect(previous);
  8397. break;
  8398. }
  8399. previous = current;
  8400. current = current.next;
  8401. }
  8402. if (!listener.previous) {
  8403. listener.connect(previous);
  8404. }
  8405. }
  8406. this._startIfPossible();
  8407. return this;
  8408. };
  8409. Ticker2.prototype.remove = function(fn, context2) {
  8410. var listener = this._head.next;
  8411. while (listener) {
  8412. if (listener.match(fn, context2)) {
  8413. listener = listener.destroy();
  8414. } else {
  8415. listener = listener.next;
  8416. }
  8417. }
  8418. if (!this._head.next) {
  8419. this._cancelIfNeeded();
  8420. }
  8421. return this;
  8422. };
  8423. Object.defineProperty(Ticker2.prototype, "count", {
  8424. /**
  8425. * The number of listeners on this ticker, calculated by walking through linked list
  8426. * @readonly
  8427. * @member {number}
  8428. */
  8429. get: function() {
  8430. if (!this._head) {
  8431. return 0;
  8432. }
  8433. var count = 0;
  8434. var current = this._head;
  8435. while (current = current.next) {
  8436. count++;
  8437. }
  8438. return count;
  8439. },
  8440. enumerable: false,
  8441. configurable: true
  8442. });
  8443. Ticker2.prototype.start = function() {
  8444. if (!this.started) {
  8445. this.started = true;
  8446. this._requestIfNeeded();
  8447. }
  8448. };
  8449. Ticker2.prototype.stop = function() {
  8450. if (this.started) {
  8451. this.started = false;
  8452. this._cancelIfNeeded();
  8453. }
  8454. };
  8455. Ticker2.prototype.destroy = function() {
  8456. if (!this._protected) {
  8457. this.stop();
  8458. var listener = this._head.next;
  8459. while (listener) {
  8460. listener = listener.destroy(true);
  8461. }
  8462. this._head.destroy();
  8463. this._head = null;
  8464. }
  8465. };
  8466. Ticker2.prototype.update = function(currentTime) {
  8467. if (currentTime === void 0) {
  8468. currentTime = performance.now();
  8469. }
  8470. var elapsedMS;
  8471. if (currentTime > this.lastTime) {
  8472. elapsedMS = this.elapsedMS = currentTime - this.lastTime;
  8473. if (elapsedMS > this._maxElapsedMS) {
  8474. elapsedMS = this._maxElapsedMS;
  8475. }
  8476. elapsedMS *= this.speed;
  8477. if (this._minElapsedMS) {
  8478. var delta = currentTime - this._lastFrame | 0;
  8479. if (delta < this._minElapsedMS) {
  8480. return;
  8481. }
  8482. this._lastFrame = currentTime - delta % this._minElapsedMS;
  8483. }
  8484. this.deltaMS = elapsedMS;
  8485. this.deltaTime = this.deltaMS * settings.TARGET_FPMS;
  8486. var head = this._head;
  8487. var listener = head.next;
  8488. while (listener) {
  8489. listener = listener.emit(this.deltaTime);
  8490. }
  8491. if (!head.next) {
  8492. this._cancelIfNeeded();
  8493. }
  8494. } else {
  8495. this.deltaTime = this.deltaMS = this.elapsedMS = 0;
  8496. }
  8497. this.lastTime = currentTime;
  8498. };
  8499. Object.defineProperty(Ticker2.prototype, "FPS", {
  8500. /**
  8501. * The frames per second at which this ticker is running.
  8502. * The default is approximately 60 in most modern browsers.
  8503. * **Note:** This does not factor in the value of
  8504. * {@link PIXI.Ticker#speed}, which is specific
  8505. * to scaling {@link PIXI.Ticker#deltaTime}.
  8506. * @member {number}
  8507. * @readonly
  8508. */
  8509. get: function() {
  8510. return 1e3 / this.elapsedMS;
  8511. },
  8512. enumerable: false,
  8513. configurable: true
  8514. });
  8515. Object.defineProperty(Ticker2.prototype, "minFPS", {
  8516. /**
  8517. * Manages the maximum amount of milliseconds allowed to
  8518. * elapse between invoking {@link PIXI.Ticker#update}.
  8519. * This value is used to cap {@link PIXI.Ticker#deltaTime},
  8520. * but does not effect the measured value of {@link PIXI.Ticker#FPS}.
  8521. * When setting this property it is clamped to a value between
  8522. * `0` and `PIXI.settings.TARGET_FPMS * 1000`.
  8523. * @member {number}
  8524. * @default 10
  8525. */
  8526. get: function() {
  8527. return 1e3 / this._maxElapsedMS;
  8528. },
  8529. set: function(fps) {
  8530. var minFPS = Math.min(this.maxFPS, fps);
  8531. var minFPMS = Math.min(Math.max(0, minFPS) / 1e3, settings.TARGET_FPMS);
  8532. this._maxElapsedMS = 1 / minFPMS;
  8533. },
  8534. enumerable: false,
  8535. configurable: true
  8536. });
  8537. Object.defineProperty(Ticker2.prototype, "maxFPS", {
  8538. /**
  8539. * Manages the minimum amount of milliseconds required to
  8540. * elapse between invoking {@link PIXI.Ticker#update}.
  8541. * This will effect the measured value of {@link PIXI.Ticker#FPS}.
  8542. * If it is set to `0`, then there is no limit; PixiJS will render as many frames as it can.
  8543. * Otherwise it will be at least `minFPS`
  8544. * @member {number}
  8545. * @default 0
  8546. */
  8547. get: function() {
  8548. if (this._minElapsedMS) {
  8549. return Math.round(1e3 / this._minElapsedMS);
  8550. }
  8551. return 0;
  8552. },
  8553. set: function(fps) {
  8554. if (fps === 0) {
  8555. this._minElapsedMS = 0;
  8556. } else {
  8557. var maxFPS = Math.max(this.minFPS, fps);
  8558. this._minElapsedMS = 1 / (maxFPS / 1e3);
  8559. }
  8560. },
  8561. enumerable: false,
  8562. configurable: true
  8563. });
  8564. Object.defineProperty(Ticker2, "shared", {
  8565. /**
  8566. * The shared ticker instance used by {@link PIXI.AnimatedSprite} and by
  8567. * {@link PIXI.VideoResource} to update animation frames / video textures.
  8568. *
  8569. * It may also be used by {@link PIXI.Application} if created with the `sharedTicker` option property set to true.
  8570. *
  8571. * The property {@link PIXI.Ticker#autoStart} is set to `true` for this instance.
  8572. * Please follow the examples for usage, including how to opt-out of auto-starting the shared ticker.
  8573. * @example
  8574. * let ticker = PIXI.Ticker.shared;
  8575. * // Set this to prevent starting this ticker when listeners are added.
  8576. * // By default this is true only for the PIXI.Ticker.shared instance.
  8577. * ticker.autoStart = false;
  8578. * // FYI, call this to ensure the ticker is stopped. It should be stopped
  8579. * // if you have not attempted to render anything yet.
  8580. * ticker.stop();
  8581. * // Call this when you are ready for a running shared ticker.
  8582. * ticker.start();
  8583. * @example
  8584. * // You may use the shared ticker to render...
  8585. * let renderer = PIXI.autoDetectRenderer();
  8586. * let stage = new PIXI.Container();
  8587. * document.body.appendChild(renderer.view);
  8588. * ticker.add(function (time) {
  8589. * renderer.render(stage);
  8590. * });
  8591. * @example
  8592. * // Or you can just update it manually.
  8593. * ticker.autoStart = false;
  8594. * ticker.stop();
  8595. * function animate(time) {
  8596. * ticker.update(time);
  8597. * renderer.render(stage);
  8598. * requestAnimationFrame(animate);
  8599. * }
  8600. * animate(performance.now());
  8601. * @member {PIXI.Ticker}
  8602. * @static
  8603. */
  8604. get: function() {
  8605. if (!Ticker2._shared) {
  8606. var shared = Ticker2._shared = new Ticker2();
  8607. shared.autoStart = true;
  8608. shared._protected = true;
  8609. }
  8610. return Ticker2._shared;
  8611. },
  8612. enumerable: false,
  8613. configurable: true
  8614. });
  8615. Object.defineProperty(Ticker2, "system", {
  8616. /**
  8617. * The system ticker instance used by {@link PIXI.InteractionManager} and by
  8618. * {@link PIXI.BasePrepare} for core timing functionality that shouldn't usually need to be paused,
  8619. * unlike the `shared` ticker which drives visual animations and rendering which may want to be paused.
  8620. *
  8621. * The property {@link PIXI.Ticker#autoStart} is set to `true` for this instance.
  8622. * @member {PIXI.Ticker}
  8623. * @static
  8624. */
  8625. get: function() {
  8626. if (!Ticker2._system) {
  8627. var system = Ticker2._system = new Ticker2();
  8628. system.autoStart = true;
  8629. system._protected = true;
  8630. }
  8631. return Ticker2._system;
  8632. },
  8633. enumerable: false,
  8634. configurable: true
  8635. });
  8636. return Ticker2;
  8637. })()
  8638. );
  8639. var TickerPlugin = (
  8640. /** @class */
  8641. (function() {
  8642. function TickerPlugin2() {
  8643. }
  8644. TickerPlugin2.init = function(options) {
  8645. var _this = this;
  8646. options = Object.assign({
  8647. autoStart: true,
  8648. sharedTicker: false
  8649. }, options);
  8650. Object.defineProperty(this, "ticker", {
  8651. set: function(ticker) {
  8652. if (this._ticker) {
  8653. this._ticker.remove(this.render, this);
  8654. }
  8655. this._ticker = ticker;
  8656. if (ticker) {
  8657. ticker.add(this.render, this, UPDATE_PRIORITY.LOW);
  8658. }
  8659. },
  8660. get: function() {
  8661. return this._ticker;
  8662. }
  8663. });
  8664. this.stop = function() {
  8665. _this._ticker.stop();
  8666. };
  8667. this.start = function() {
  8668. _this._ticker.start();
  8669. };
  8670. this._ticker = null;
  8671. this.ticker = options.sharedTicker ? Ticker.shared : new Ticker();
  8672. if (options.autoStart) {
  8673. this.start();
  8674. }
  8675. };
  8676. TickerPlugin2.destroy = function() {
  8677. if (this._ticker) {
  8678. var oldTicker = this._ticker;
  8679. this.ticker = null;
  8680. oldTicker.destroy();
  8681. }
  8682. };
  8683. TickerPlugin2.extension = ExtensionType.Application;
  8684. return TickerPlugin2;
  8685. })()
  8686. );
  8687. // node_modules/@pixi/core/dist/esm/core.mjs
  8688. settings.PREFER_ENV = isMobile.any ? ENV.WEBGL : ENV.WEBGL2;
  8689. settings.STRICT_TEXTURE_CACHE = false;
  8690. var INSTALLED = [];
  8691. function autoDetectResource(source, options) {
  8692. if (!source) {
  8693. return null;
  8694. }
  8695. var extension = "";
  8696. if (typeof source === "string") {
  8697. var result = /\.(\w{3,4})(?:$|\?|#)/i.exec(source);
  8698. if (result) {
  8699. extension = result[1].toLowerCase();
  8700. }
  8701. }
  8702. for (var i = INSTALLED.length - 1; i >= 0; --i) {
  8703. var ResourcePlugin = INSTALLED[i];
  8704. if (ResourcePlugin.test && ResourcePlugin.test(source, extension)) {
  8705. return new ResourcePlugin(source, options);
  8706. }
  8707. }
  8708. throw new Error("Unrecognized source type to auto-detect Resource");
  8709. }
  8710. var extendStatics2 = function(d, b) {
  8711. extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
  8712. d2.__proto__ = b2;
  8713. } || function(d2, b2) {
  8714. for (var p in b2) {
  8715. if (b2.hasOwnProperty(p)) {
  8716. d2[p] = b2[p];
  8717. }
  8718. }
  8719. };
  8720. return extendStatics2(d, b);
  8721. };
  8722. function __extends2(d, b) {
  8723. extendStatics2(d, b);
  8724. function __() {
  8725. this.constructor = d;
  8726. }
  8727. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8728. }
  8729. var __assign2 = function() {
  8730. __assign2 = Object.assign || function __assign3(t) {
  8731. var arguments$1 = arguments;
  8732. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8733. s = arguments$1[i];
  8734. for (var p in s) {
  8735. if (Object.prototype.hasOwnProperty.call(s, p)) {
  8736. t[p] = s[p];
  8737. }
  8738. }
  8739. }
  8740. return t;
  8741. };
  8742. return __assign2.apply(this, arguments);
  8743. };
  8744. function __rest(s, e) {
  8745. var t = {};
  8746. for (var p in s) {
  8747. if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) {
  8748. t[p] = s[p];
  8749. }
  8750. }
  8751. if (s != null && typeof Object.getOwnPropertySymbols === "function") {
  8752. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  8753. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) {
  8754. t[p[i]] = s[p[i]];
  8755. }
  8756. }
  8757. }
  8758. return t;
  8759. }
  8760. var Resource = (
  8761. /** @class */
  8762. (function() {
  8763. function Resource2(width, height) {
  8764. if (width === void 0) {
  8765. width = 0;
  8766. }
  8767. if (height === void 0) {
  8768. height = 0;
  8769. }
  8770. this._width = width;
  8771. this._height = height;
  8772. this.destroyed = false;
  8773. this.internal = false;
  8774. this.onResize = new Runner("setRealSize");
  8775. this.onUpdate = new Runner("update");
  8776. this.onError = new Runner("onError");
  8777. }
  8778. Resource2.prototype.bind = function(baseTexture) {
  8779. this.onResize.add(baseTexture);
  8780. this.onUpdate.add(baseTexture);
  8781. this.onError.add(baseTexture);
  8782. if (this._width || this._height) {
  8783. this.onResize.emit(this._width, this._height);
  8784. }
  8785. };
  8786. Resource2.prototype.unbind = function(baseTexture) {
  8787. this.onResize.remove(baseTexture);
  8788. this.onUpdate.remove(baseTexture);
  8789. this.onError.remove(baseTexture);
  8790. };
  8791. Resource2.prototype.resize = function(width, height) {
  8792. if (width !== this._width || height !== this._height) {
  8793. this._width = width;
  8794. this._height = height;
  8795. this.onResize.emit(width, height);
  8796. }
  8797. };
  8798. Object.defineProperty(Resource2.prototype, "valid", {
  8799. /**
  8800. * Has been validated
  8801. * @readonly
  8802. */
  8803. get: function() {
  8804. return !!this._width && !!this._height;
  8805. },
  8806. enumerable: false,
  8807. configurable: true
  8808. });
  8809. Resource2.prototype.update = function() {
  8810. if (!this.destroyed) {
  8811. this.onUpdate.emit();
  8812. }
  8813. };
  8814. Resource2.prototype.load = function() {
  8815. return Promise.resolve(this);
  8816. };
  8817. Object.defineProperty(Resource2.prototype, "width", {
  8818. /**
  8819. * The width of the resource.
  8820. * @readonly
  8821. */
  8822. get: function() {
  8823. return this._width;
  8824. },
  8825. enumerable: false,
  8826. configurable: true
  8827. });
  8828. Object.defineProperty(Resource2.prototype, "height", {
  8829. /**
  8830. * The height of the resource.
  8831. * @readonly
  8832. */
  8833. get: function() {
  8834. return this._height;
  8835. },
  8836. enumerable: false,
  8837. configurable: true
  8838. });
  8839. Resource2.prototype.style = function(_renderer, _baseTexture, _glTexture) {
  8840. return false;
  8841. };
  8842. Resource2.prototype.dispose = function() {
  8843. };
  8844. Resource2.prototype.destroy = function() {
  8845. if (!this.destroyed) {
  8846. this.destroyed = true;
  8847. this.dispose();
  8848. this.onError.removeAll();
  8849. this.onError = null;
  8850. this.onResize.removeAll();
  8851. this.onResize = null;
  8852. this.onUpdate.removeAll();
  8853. this.onUpdate = null;
  8854. }
  8855. };
  8856. Resource2.test = function(_source, _extension) {
  8857. return false;
  8858. };
  8859. return Resource2;
  8860. })()
  8861. );
  8862. var BufferResource = (
  8863. /** @class */
  8864. (function(_super) {
  8865. __extends2(BufferResource2, _super);
  8866. function BufferResource2(source, options) {
  8867. var _this = this;
  8868. var _a = options || {}, width = _a.width, height = _a.height;
  8869. if (!width || !height) {
  8870. throw new Error("BufferResource width or height invalid");
  8871. }
  8872. _this = _super.call(this, width, height) || this;
  8873. _this.data = source;
  8874. return _this;
  8875. }
  8876. BufferResource2.prototype.upload = function(renderer, baseTexture, glTexture) {
  8877. var gl = renderer.gl;
  8878. gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.alphaMode === ALPHA_MODES.UNPACK);
  8879. var width = baseTexture.realWidth;
  8880. var height = baseTexture.realHeight;
  8881. if (glTexture.width === width && glTexture.height === height) {
  8882. gl.texSubImage2D(baseTexture.target, 0, 0, 0, width, height, baseTexture.format, glTexture.type, this.data);
  8883. } else {
  8884. glTexture.width = width;
  8885. glTexture.height = height;
  8886. gl.texImage2D(baseTexture.target, 0, glTexture.internalFormat, width, height, 0, baseTexture.format, glTexture.type, this.data);
  8887. }
  8888. return true;
  8889. };
  8890. BufferResource2.prototype.dispose = function() {
  8891. this.data = null;
  8892. };
  8893. BufferResource2.test = function(source) {
  8894. return source instanceof Float32Array || source instanceof Uint8Array || source instanceof Uint32Array;
  8895. };
  8896. return BufferResource2;
  8897. })(Resource)
  8898. );
  8899. var defaultBufferOptions = {
  8900. scaleMode: SCALE_MODES.NEAREST,
  8901. format: FORMATS.RGBA,
  8902. alphaMode: ALPHA_MODES.NPM
  8903. };
  8904. var BaseTexture = (
  8905. /** @class */
  8906. (function(_super) {
  8907. __extends2(BaseTexture2, _super);
  8908. function BaseTexture2(resource, options) {
  8909. if (resource === void 0) {
  8910. resource = null;
  8911. }
  8912. if (options === void 0) {
  8913. options = null;
  8914. }
  8915. var _this = _super.call(this) || this;
  8916. options = options || {};
  8917. var alphaMode = options.alphaMode, mipmap = options.mipmap, anisotropicLevel = options.anisotropicLevel, scaleMode = options.scaleMode, width = options.width, height = options.height, wrapMode = options.wrapMode, format2 = options.format, type = options.type, target = options.target, resolution = options.resolution, resourceOptions = options.resourceOptions;
  8918. if (resource && !(resource instanceof Resource)) {
  8919. resource = autoDetectResource(resource, resourceOptions);
  8920. resource.internal = true;
  8921. }
  8922. _this.resolution = resolution || settings.RESOLUTION;
  8923. _this.width = Math.round((width || 0) * _this.resolution) / _this.resolution;
  8924. _this.height = Math.round((height || 0) * _this.resolution) / _this.resolution;
  8925. _this._mipmap = mipmap !== void 0 ? mipmap : settings.MIPMAP_TEXTURES;
  8926. _this.anisotropicLevel = anisotropicLevel !== void 0 ? anisotropicLevel : settings.ANISOTROPIC_LEVEL;
  8927. _this._wrapMode = wrapMode || settings.WRAP_MODE;
  8928. _this._scaleMode = scaleMode !== void 0 ? scaleMode : settings.SCALE_MODE;
  8929. _this.format = format2 || FORMATS.RGBA;
  8930. _this.type = type || TYPES.UNSIGNED_BYTE;
  8931. _this.target = target || TARGETS.TEXTURE_2D;
  8932. _this.alphaMode = alphaMode !== void 0 ? alphaMode : ALPHA_MODES.UNPACK;
  8933. _this.uid = uid();
  8934. _this.touched = 0;
  8935. _this.isPowerOfTwo = false;
  8936. _this._refreshPOT();
  8937. _this._glTextures = {};
  8938. _this.dirtyId = 0;
  8939. _this.dirtyStyleId = 0;
  8940. _this.cacheId = null;
  8941. _this.valid = width > 0 && height > 0;
  8942. _this.textureCacheIds = [];
  8943. _this.destroyed = false;
  8944. _this.resource = null;
  8945. _this._batchEnabled = 0;
  8946. _this._batchLocation = 0;
  8947. _this.parentTextureArray = null;
  8948. _this.setResource(resource);
  8949. return _this;
  8950. }
  8951. Object.defineProperty(BaseTexture2.prototype, "realWidth", {
  8952. /**
  8953. * Pixel width of the source of this texture
  8954. * @readonly
  8955. */
  8956. get: function() {
  8957. return Math.round(this.width * this.resolution);
  8958. },
  8959. enumerable: false,
  8960. configurable: true
  8961. });
  8962. Object.defineProperty(BaseTexture2.prototype, "realHeight", {
  8963. /**
  8964. * Pixel height of the source of this texture
  8965. * @readonly
  8966. */
  8967. get: function() {
  8968. return Math.round(this.height * this.resolution);
  8969. },
  8970. enumerable: false,
  8971. configurable: true
  8972. });
  8973. Object.defineProperty(BaseTexture2.prototype, "mipmap", {
  8974. /**
  8975. * Mipmap mode of the texture, affects downscaled images
  8976. * @default PIXI.settings.MIPMAP_TEXTURES
  8977. */
  8978. get: function() {
  8979. return this._mipmap;
  8980. },
  8981. set: function(value) {
  8982. if (this._mipmap !== value) {
  8983. this._mipmap = value;
  8984. this.dirtyStyleId++;
  8985. }
  8986. },
  8987. enumerable: false,
  8988. configurable: true
  8989. });
  8990. Object.defineProperty(BaseTexture2.prototype, "scaleMode", {
  8991. /**
  8992. * The scale mode to apply when scaling this texture
  8993. * @default PIXI.settings.SCALE_MODE
  8994. */
  8995. get: function() {
  8996. return this._scaleMode;
  8997. },
  8998. set: function(value) {
  8999. if (this._scaleMode !== value) {
  9000. this._scaleMode = value;
  9001. this.dirtyStyleId++;
  9002. }
  9003. },
  9004. enumerable: false,
  9005. configurable: true
  9006. });
  9007. Object.defineProperty(BaseTexture2.prototype, "wrapMode", {
  9008. /**
  9009. * How the texture wraps
  9010. * @default PIXI.settings.WRAP_MODE
  9011. */
  9012. get: function() {
  9013. return this._wrapMode;
  9014. },
  9015. set: function(value) {
  9016. if (this._wrapMode !== value) {
  9017. this._wrapMode = value;
  9018. this.dirtyStyleId++;
  9019. }
  9020. },
  9021. enumerable: false,
  9022. configurable: true
  9023. });
  9024. BaseTexture2.prototype.setStyle = function(scaleMode, mipmap) {
  9025. var dirty;
  9026. if (scaleMode !== void 0 && scaleMode !== this.scaleMode) {
  9027. this.scaleMode = scaleMode;
  9028. dirty = true;
  9029. }
  9030. if (mipmap !== void 0 && mipmap !== this.mipmap) {
  9031. this.mipmap = mipmap;
  9032. dirty = true;
  9033. }
  9034. if (dirty) {
  9035. this.dirtyStyleId++;
  9036. }
  9037. return this;
  9038. };
  9039. BaseTexture2.prototype.setSize = function(desiredWidth, desiredHeight, resolution) {
  9040. resolution = resolution || this.resolution;
  9041. return this.setRealSize(desiredWidth * resolution, desiredHeight * resolution, resolution);
  9042. };
  9043. BaseTexture2.prototype.setRealSize = function(realWidth, realHeight, resolution) {
  9044. this.resolution = resolution || this.resolution;
  9045. this.width = Math.round(realWidth) / this.resolution;
  9046. this.height = Math.round(realHeight) / this.resolution;
  9047. this._refreshPOT();
  9048. this.update();
  9049. return this;
  9050. };
  9051. BaseTexture2.prototype._refreshPOT = function() {
  9052. this.isPowerOfTwo = isPow2(this.realWidth) && isPow2(this.realHeight);
  9053. };
  9054. BaseTexture2.prototype.setResolution = function(resolution) {
  9055. var oldResolution = this.resolution;
  9056. if (oldResolution === resolution) {
  9057. return this;
  9058. }
  9059. this.resolution = resolution;
  9060. if (this.valid) {
  9061. this.width = Math.round(this.width * oldResolution) / resolution;
  9062. this.height = Math.round(this.height * oldResolution) / resolution;
  9063. this.emit("update", this);
  9064. }
  9065. this._refreshPOT();
  9066. return this;
  9067. };
  9068. BaseTexture2.prototype.setResource = function(resource) {
  9069. if (this.resource === resource) {
  9070. return this;
  9071. }
  9072. if (this.resource) {
  9073. throw new Error("Resource can be set only once");
  9074. }
  9075. resource.bind(this);
  9076. this.resource = resource;
  9077. return this;
  9078. };
  9079. BaseTexture2.prototype.update = function() {
  9080. if (!this.valid) {
  9081. if (this.width > 0 && this.height > 0) {
  9082. this.valid = true;
  9083. this.emit("loaded", this);
  9084. this.emit("update", this);
  9085. }
  9086. } else {
  9087. this.dirtyId++;
  9088. this.dirtyStyleId++;
  9089. this.emit("update", this);
  9090. }
  9091. };
  9092. BaseTexture2.prototype.onError = function(event) {
  9093. this.emit("error", this, event);
  9094. };
  9095. BaseTexture2.prototype.destroy = function() {
  9096. if (this.resource) {
  9097. this.resource.unbind(this);
  9098. if (this.resource.internal) {
  9099. this.resource.destroy();
  9100. }
  9101. this.resource = null;
  9102. }
  9103. if (this.cacheId) {
  9104. delete BaseTextureCache[this.cacheId];
  9105. delete TextureCache[this.cacheId];
  9106. this.cacheId = null;
  9107. }
  9108. this.dispose();
  9109. BaseTexture2.removeFromCache(this);
  9110. this.textureCacheIds = null;
  9111. this.destroyed = true;
  9112. };
  9113. BaseTexture2.prototype.dispose = function() {
  9114. this.emit("dispose", this);
  9115. };
  9116. BaseTexture2.prototype.castToBaseTexture = function() {
  9117. return this;
  9118. };
  9119. BaseTexture2.from = function(source, options, strict) {
  9120. if (strict === void 0) {
  9121. strict = settings.STRICT_TEXTURE_CACHE;
  9122. }
  9123. var isFrame = typeof source === "string";
  9124. var cacheId = null;
  9125. if (isFrame) {
  9126. cacheId = source;
  9127. } else {
  9128. if (!source._pixiId) {
  9129. var prefix = options && options.pixiIdPrefix || "pixiid";
  9130. source._pixiId = prefix + "_" + uid();
  9131. }
  9132. cacheId = source._pixiId;
  9133. }
  9134. var baseTexture = BaseTextureCache[cacheId];
  9135. if (isFrame && strict && !baseTexture) {
  9136. throw new Error('The cacheId "' + cacheId + '" does not exist in BaseTextureCache.');
  9137. }
  9138. if (!baseTexture) {
  9139. baseTexture = new BaseTexture2(source, options);
  9140. baseTexture.cacheId = cacheId;
  9141. BaseTexture2.addToCache(baseTexture, cacheId);
  9142. }
  9143. return baseTexture;
  9144. };
  9145. BaseTexture2.fromBuffer = function(buffer, width, height, options) {
  9146. buffer = buffer || new Float32Array(width * height * 4);
  9147. var resource = new BufferResource(buffer, { width, height });
  9148. var type = buffer instanceof Float32Array ? TYPES.FLOAT : TYPES.UNSIGNED_BYTE;
  9149. return new BaseTexture2(resource, Object.assign({}, defaultBufferOptions, options || { width, height, type }));
  9150. };
  9151. BaseTexture2.addToCache = function(baseTexture, id) {
  9152. if (id) {
  9153. if (baseTexture.textureCacheIds.indexOf(id) === -1) {
  9154. baseTexture.textureCacheIds.push(id);
  9155. }
  9156. if (BaseTextureCache[id]) {
  9157. console.warn("BaseTexture added to the cache with an id [" + id + "] that already had an entry");
  9158. }
  9159. BaseTextureCache[id] = baseTexture;
  9160. }
  9161. };
  9162. BaseTexture2.removeFromCache = function(baseTexture) {
  9163. if (typeof baseTexture === "string") {
  9164. var baseTextureFromCache = BaseTextureCache[baseTexture];
  9165. if (baseTextureFromCache) {
  9166. var index = baseTextureFromCache.textureCacheIds.indexOf(baseTexture);
  9167. if (index > -1) {
  9168. baseTextureFromCache.textureCacheIds.splice(index, 1);
  9169. }
  9170. delete BaseTextureCache[baseTexture];
  9171. return baseTextureFromCache;
  9172. }
  9173. } else if (baseTexture && baseTexture.textureCacheIds) {
  9174. for (var i = 0; i < baseTexture.textureCacheIds.length; ++i) {
  9175. delete BaseTextureCache[baseTexture.textureCacheIds[i]];
  9176. }
  9177. baseTexture.textureCacheIds.length = 0;
  9178. return baseTexture;
  9179. }
  9180. return null;
  9181. };
  9182. BaseTexture2._globalBatch = 0;
  9183. return BaseTexture2;
  9184. })(import_eventemitter3.default)
  9185. );
  9186. var AbstractMultiResource = (
  9187. /** @class */
  9188. (function(_super) {
  9189. __extends2(AbstractMultiResource2, _super);
  9190. function AbstractMultiResource2(length, options) {
  9191. var _this = this;
  9192. var _a = options || {}, width = _a.width, height = _a.height;
  9193. _this = _super.call(this, width, height) || this;
  9194. _this.items = [];
  9195. _this.itemDirtyIds = [];
  9196. for (var i = 0; i < length; i++) {
  9197. var partTexture = new BaseTexture();
  9198. _this.items.push(partTexture);
  9199. _this.itemDirtyIds.push(-2);
  9200. }
  9201. _this.length = length;
  9202. _this._load = null;
  9203. _this.baseTexture = null;
  9204. return _this;
  9205. }
  9206. AbstractMultiResource2.prototype.initFromArray = function(resources2, options) {
  9207. for (var i = 0; i < this.length; i++) {
  9208. if (!resources2[i]) {
  9209. continue;
  9210. }
  9211. if (resources2[i].castToBaseTexture) {
  9212. this.addBaseTextureAt(resources2[i].castToBaseTexture(), i);
  9213. } else if (resources2[i] instanceof Resource) {
  9214. this.addResourceAt(resources2[i], i);
  9215. } else {
  9216. this.addResourceAt(autoDetectResource(resources2[i], options), i);
  9217. }
  9218. }
  9219. };
  9220. AbstractMultiResource2.prototype.dispose = function() {
  9221. for (var i = 0, len = this.length; i < len; i++) {
  9222. this.items[i].destroy();
  9223. }
  9224. this.items = null;
  9225. this.itemDirtyIds = null;
  9226. this._load = null;
  9227. };
  9228. AbstractMultiResource2.prototype.addResourceAt = function(resource, index) {
  9229. if (!this.items[index]) {
  9230. throw new Error("Index " + index + " is out of bounds");
  9231. }
  9232. if (resource.valid && !this.valid) {
  9233. this.resize(resource.width, resource.height);
  9234. }
  9235. this.items[index].setResource(resource);
  9236. return this;
  9237. };
  9238. AbstractMultiResource2.prototype.bind = function(baseTexture) {
  9239. if (this.baseTexture !== null) {
  9240. throw new Error("Only one base texture per TextureArray is allowed");
  9241. }
  9242. _super.prototype.bind.call(this, baseTexture);
  9243. for (var i = 0; i < this.length; i++) {
  9244. this.items[i].parentTextureArray = baseTexture;
  9245. this.items[i].on("update", baseTexture.update, baseTexture);
  9246. }
  9247. };
  9248. AbstractMultiResource2.prototype.unbind = function(baseTexture) {
  9249. _super.prototype.unbind.call(this, baseTexture);
  9250. for (var i = 0; i < this.length; i++) {
  9251. this.items[i].parentTextureArray = null;
  9252. this.items[i].off("update", baseTexture.update, baseTexture);
  9253. }
  9254. };
  9255. AbstractMultiResource2.prototype.load = function() {
  9256. var _this = this;
  9257. if (this._load) {
  9258. return this._load;
  9259. }
  9260. var resources2 = this.items.map(function(item) {
  9261. return item.resource;
  9262. }).filter(function(item) {
  9263. return item;
  9264. });
  9265. var promises = resources2.map(function(item) {
  9266. return item.load();
  9267. });
  9268. this._load = Promise.all(promises).then(function() {
  9269. var _a = _this.items[0], realWidth = _a.realWidth, realHeight = _a.realHeight;
  9270. _this.resize(realWidth, realHeight);
  9271. return Promise.resolve(_this);
  9272. });
  9273. return this._load;
  9274. };
  9275. return AbstractMultiResource2;
  9276. })(Resource)
  9277. );
  9278. var ArrayResource = (
  9279. /** @class */
  9280. (function(_super) {
  9281. __extends2(ArrayResource2, _super);
  9282. function ArrayResource2(source, options) {
  9283. var _this = this;
  9284. var _a = options || {}, width = _a.width, height = _a.height;
  9285. var urls;
  9286. var length;
  9287. if (Array.isArray(source)) {
  9288. urls = source;
  9289. length = source.length;
  9290. } else {
  9291. length = source;
  9292. }
  9293. _this = _super.call(this, length, { width, height }) || this;
  9294. if (urls) {
  9295. _this.initFromArray(urls, options);
  9296. }
  9297. return _this;
  9298. }
  9299. ArrayResource2.prototype.addBaseTextureAt = function(baseTexture, index) {
  9300. if (baseTexture.resource) {
  9301. this.addResourceAt(baseTexture.resource, index);
  9302. } else {
  9303. throw new Error("ArrayResource does not support RenderTexture");
  9304. }
  9305. return this;
  9306. };
  9307. ArrayResource2.prototype.bind = function(baseTexture) {
  9308. _super.prototype.bind.call(this, baseTexture);
  9309. baseTexture.target = TARGETS.TEXTURE_2D_ARRAY;
  9310. };
  9311. ArrayResource2.prototype.upload = function(renderer, texture, glTexture) {
  9312. var _a = this, length = _a.length, itemDirtyIds = _a.itemDirtyIds, items = _a.items;
  9313. var gl = renderer.gl;
  9314. if (glTexture.dirtyId < 0) {
  9315. gl.texImage3D(gl.TEXTURE_2D_ARRAY, 0, glTexture.internalFormat, this._width, this._height, length, 0, texture.format, glTexture.type, null);
  9316. }
  9317. for (var i = 0; i < length; i++) {
  9318. var item = items[i];
  9319. if (itemDirtyIds[i] < item.dirtyId) {
  9320. itemDirtyIds[i] = item.dirtyId;
  9321. if (item.valid) {
  9322. gl.texSubImage3D(
  9323. gl.TEXTURE_2D_ARRAY,
  9324. 0,
  9325. 0,
  9326. // xoffset
  9327. 0,
  9328. // yoffset
  9329. i,
  9330. // zoffset
  9331. item.resource.width,
  9332. item.resource.height,
  9333. 1,
  9334. texture.format,
  9335. glTexture.type,
  9336. item.resource.source
  9337. );
  9338. }
  9339. }
  9340. }
  9341. return true;
  9342. };
  9343. return ArrayResource2;
  9344. })(AbstractMultiResource)
  9345. );
  9346. var BaseImageResource = (
  9347. /** @class */
  9348. (function(_super) {
  9349. __extends2(BaseImageResource2, _super);
  9350. function BaseImageResource2(source) {
  9351. var _this = this;
  9352. var sourceAny = source;
  9353. var width = sourceAny.naturalWidth || sourceAny.videoWidth || sourceAny.width;
  9354. var height = sourceAny.naturalHeight || sourceAny.videoHeight || sourceAny.height;
  9355. _this = _super.call(this, width, height) || this;
  9356. _this.source = source;
  9357. _this.noSubImage = false;
  9358. return _this;
  9359. }
  9360. BaseImageResource2.crossOrigin = function(element, url2, crossorigin) {
  9361. if (crossorigin === void 0 && url2.indexOf("data:") !== 0) {
  9362. element.crossOrigin = determineCrossOrigin(url2);
  9363. } else if (crossorigin !== false) {
  9364. element.crossOrigin = typeof crossorigin === "string" ? crossorigin : "anonymous";
  9365. }
  9366. };
  9367. BaseImageResource2.prototype.upload = function(renderer, baseTexture, glTexture, source) {
  9368. var gl = renderer.gl;
  9369. var width = baseTexture.realWidth;
  9370. var height = baseTexture.realHeight;
  9371. source = source || this.source;
  9372. if (source instanceof HTMLImageElement) {
  9373. if (!source.complete || source.naturalWidth === 0) {
  9374. return false;
  9375. }
  9376. } else if (source instanceof HTMLVideoElement) {
  9377. if (source.readyState <= 1) {
  9378. return false;
  9379. }
  9380. }
  9381. gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.alphaMode === ALPHA_MODES.UNPACK);
  9382. if (!this.noSubImage && baseTexture.target === gl.TEXTURE_2D && glTexture.width === width && glTexture.height === height) {
  9383. gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, baseTexture.format, glTexture.type, source);
  9384. } else {
  9385. glTexture.width = width;
  9386. glTexture.height = height;
  9387. gl.texImage2D(baseTexture.target, 0, glTexture.internalFormat, baseTexture.format, glTexture.type, source);
  9388. }
  9389. return true;
  9390. };
  9391. BaseImageResource2.prototype.update = function() {
  9392. if (this.destroyed) {
  9393. return;
  9394. }
  9395. var source = this.source;
  9396. var width = source.naturalWidth || source.videoWidth || source.width;
  9397. var height = source.naturalHeight || source.videoHeight || source.height;
  9398. this.resize(width, height);
  9399. _super.prototype.update.call(this);
  9400. };
  9401. BaseImageResource2.prototype.dispose = function() {
  9402. this.source = null;
  9403. };
  9404. return BaseImageResource2;
  9405. })(Resource)
  9406. );
  9407. var CanvasResource = (
  9408. /** @class */
  9409. (function(_super) {
  9410. __extends2(CanvasResource2, _super);
  9411. function CanvasResource2(source) {
  9412. return _super.call(this, source) || this;
  9413. }
  9414. CanvasResource2.test = function(source) {
  9415. var OffscreenCanvas = globalThis.OffscreenCanvas;
  9416. if (OffscreenCanvas && source instanceof OffscreenCanvas) {
  9417. return true;
  9418. }
  9419. return globalThis.HTMLCanvasElement && source instanceof HTMLCanvasElement;
  9420. };
  9421. return CanvasResource2;
  9422. })(BaseImageResource)
  9423. );
  9424. var CubeResource = (
  9425. /** @class */
  9426. (function(_super) {
  9427. __extends2(CubeResource2, _super);
  9428. function CubeResource2(source, options) {
  9429. var _this = this;
  9430. var _a = options || {}, width = _a.width, height = _a.height, autoLoad = _a.autoLoad, linkBaseTexture = _a.linkBaseTexture;
  9431. if (source && source.length !== CubeResource2.SIDES) {
  9432. throw new Error("Invalid length. Got " + source.length + ", expected 6");
  9433. }
  9434. _this = _super.call(this, 6, { width, height }) || this;
  9435. for (var i = 0; i < CubeResource2.SIDES; i++) {
  9436. _this.items[i].target = TARGETS.TEXTURE_CUBE_MAP_POSITIVE_X + i;
  9437. }
  9438. _this.linkBaseTexture = linkBaseTexture !== false;
  9439. if (source) {
  9440. _this.initFromArray(source, options);
  9441. }
  9442. if (autoLoad !== false) {
  9443. _this.load();
  9444. }
  9445. return _this;
  9446. }
  9447. CubeResource2.prototype.bind = function(baseTexture) {
  9448. _super.prototype.bind.call(this, baseTexture);
  9449. baseTexture.target = TARGETS.TEXTURE_CUBE_MAP;
  9450. };
  9451. CubeResource2.prototype.addBaseTextureAt = function(baseTexture, index, linkBaseTexture) {
  9452. if (!this.items[index]) {
  9453. throw new Error("Index " + index + " is out of bounds");
  9454. }
  9455. if (!this.linkBaseTexture || baseTexture.parentTextureArray || Object.keys(baseTexture._glTextures).length > 0) {
  9456. if (baseTexture.resource) {
  9457. this.addResourceAt(baseTexture.resource, index);
  9458. } else {
  9459. throw new Error("CubeResource does not support copying of renderTexture.");
  9460. }
  9461. } else {
  9462. baseTexture.target = TARGETS.TEXTURE_CUBE_MAP_POSITIVE_X + index;
  9463. baseTexture.parentTextureArray = this.baseTexture;
  9464. this.items[index] = baseTexture;
  9465. }
  9466. if (baseTexture.valid && !this.valid) {
  9467. this.resize(baseTexture.realWidth, baseTexture.realHeight);
  9468. }
  9469. this.items[index] = baseTexture;
  9470. return this;
  9471. };
  9472. CubeResource2.prototype.upload = function(renderer, _baseTexture, glTexture) {
  9473. var dirty = this.itemDirtyIds;
  9474. for (var i = 0; i < CubeResource2.SIDES; i++) {
  9475. var side = this.items[i];
  9476. if (dirty[i] < side.dirtyId || glTexture.dirtyId < _baseTexture.dirtyId) {
  9477. if (side.valid && side.resource) {
  9478. side.resource.upload(renderer, side, glTexture);
  9479. dirty[i] = side.dirtyId;
  9480. } else if (dirty[i] < -1) {
  9481. renderer.gl.texImage2D(side.target, 0, glTexture.internalFormat, _baseTexture.realWidth, _baseTexture.realHeight, 0, _baseTexture.format, glTexture.type, null);
  9482. dirty[i] = -1;
  9483. }
  9484. }
  9485. }
  9486. return true;
  9487. };
  9488. CubeResource2.test = function(source) {
  9489. return Array.isArray(source) && source.length === CubeResource2.SIDES;
  9490. };
  9491. CubeResource2.SIDES = 6;
  9492. return CubeResource2;
  9493. })(AbstractMultiResource)
  9494. );
  9495. var ImageResource = (
  9496. /** @class */
  9497. (function(_super) {
  9498. __extends2(ImageResource2, _super);
  9499. function ImageResource2(source, options) {
  9500. var _this = this;
  9501. options = options || {};
  9502. if (!(source instanceof HTMLImageElement)) {
  9503. var imageElement = new Image();
  9504. BaseImageResource.crossOrigin(imageElement, source, options.crossorigin);
  9505. imageElement.src = source;
  9506. source = imageElement;
  9507. }
  9508. _this = _super.call(this, source) || this;
  9509. if (!source.complete && !!_this._width && !!_this._height) {
  9510. _this._width = 0;
  9511. _this._height = 0;
  9512. }
  9513. _this.url = source.src;
  9514. _this._process = null;
  9515. _this.preserveBitmap = false;
  9516. _this.createBitmap = (options.createBitmap !== void 0 ? options.createBitmap : settings.CREATE_IMAGE_BITMAP) && !!globalThis.createImageBitmap;
  9517. _this.alphaMode = typeof options.alphaMode === "number" ? options.alphaMode : null;
  9518. _this.bitmap = null;
  9519. _this._load = null;
  9520. if (options.autoLoad !== false) {
  9521. _this.load();
  9522. }
  9523. return _this;
  9524. }
  9525. ImageResource2.prototype.load = function(createBitmap) {
  9526. var _this = this;
  9527. if (this._load) {
  9528. return this._load;
  9529. }
  9530. if (createBitmap !== void 0) {
  9531. this.createBitmap = createBitmap;
  9532. }
  9533. this._load = new Promise(function(resolve2, reject) {
  9534. var source = _this.source;
  9535. _this.url = source.src;
  9536. var completed = function() {
  9537. if (_this.destroyed) {
  9538. return;
  9539. }
  9540. source.onload = null;
  9541. source.onerror = null;
  9542. _this.resize(source.width, source.height);
  9543. _this._load = null;
  9544. if (_this.createBitmap) {
  9545. resolve2(_this.process());
  9546. } else {
  9547. resolve2(_this);
  9548. }
  9549. };
  9550. if (source.complete && source.src) {
  9551. completed();
  9552. } else {
  9553. source.onload = completed;
  9554. source.onerror = function(event) {
  9555. reject(event);
  9556. _this.onError.emit(event);
  9557. };
  9558. }
  9559. });
  9560. return this._load;
  9561. };
  9562. ImageResource2.prototype.process = function() {
  9563. var _this = this;
  9564. var source = this.source;
  9565. if (this._process !== null) {
  9566. return this._process;
  9567. }
  9568. if (this.bitmap !== null || !globalThis.createImageBitmap) {
  9569. return Promise.resolve(this);
  9570. }
  9571. var createImageBitmap = globalThis.createImageBitmap;
  9572. var cors = !source.crossOrigin || source.crossOrigin === "anonymous";
  9573. this._process = fetch(source.src, {
  9574. mode: cors ? "cors" : "no-cors"
  9575. }).then(function(r) {
  9576. return r.blob();
  9577. }).then(function(blob) {
  9578. return createImageBitmap(blob, 0, 0, source.width, source.height, {
  9579. premultiplyAlpha: _this.alphaMode === null || _this.alphaMode === ALPHA_MODES.UNPACK ? "premultiply" : "none"
  9580. });
  9581. }).then(function(bitmap) {
  9582. if (_this.destroyed) {
  9583. return Promise.reject();
  9584. }
  9585. _this.bitmap = bitmap;
  9586. _this.update();
  9587. _this._process = null;
  9588. return Promise.resolve(_this);
  9589. });
  9590. return this._process;
  9591. };
  9592. ImageResource2.prototype.upload = function(renderer, baseTexture, glTexture) {
  9593. if (typeof this.alphaMode === "number") {
  9594. baseTexture.alphaMode = this.alphaMode;
  9595. }
  9596. if (!this.createBitmap) {
  9597. return _super.prototype.upload.call(this, renderer, baseTexture, glTexture);
  9598. }
  9599. if (!this.bitmap) {
  9600. this.process();
  9601. if (!this.bitmap) {
  9602. return false;
  9603. }
  9604. }
  9605. _super.prototype.upload.call(this, renderer, baseTexture, glTexture, this.bitmap);
  9606. if (!this.preserveBitmap) {
  9607. var flag = true;
  9608. var glTextures = baseTexture._glTextures;
  9609. for (var key in glTextures) {
  9610. var otherTex = glTextures[key];
  9611. if (otherTex !== glTexture && otherTex.dirtyId !== baseTexture.dirtyId) {
  9612. flag = false;
  9613. break;
  9614. }
  9615. }
  9616. if (flag) {
  9617. if (this.bitmap.close) {
  9618. this.bitmap.close();
  9619. }
  9620. this.bitmap = null;
  9621. }
  9622. }
  9623. return true;
  9624. };
  9625. ImageResource2.prototype.dispose = function() {
  9626. this.source.onload = null;
  9627. this.source.onerror = null;
  9628. _super.prototype.dispose.call(this);
  9629. if (this.bitmap) {
  9630. this.bitmap.close();
  9631. this.bitmap = null;
  9632. }
  9633. this._process = null;
  9634. this._load = null;
  9635. };
  9636. ImageResource2.test = function(source) {
  9637. return typeof source === "string" || source instanceof HTMLImageElement;
  9638. };
  9639. return ImageResource2;
  9640. })(BaseImageResource)
  9641. );
  9642. var SVGResource = (
  9643. /** @class */
  9644. (function(_super) {
  9645. __extends2(SVGResource2, _super);
  9646. function SVGResource2(sourceBase64, options) {
  9647. var _this = this;
  9648. options = options || {};
  9649. _this = _super.call(this, settings.ADAPTER.createCanvas()) || this;
  9650. _this._width = 0;
  9651. _this._height = 0;
  9652. _this.svg = sourceBase64;
  9653. _this.scale = options.scale || 1;
  9654. _this._overrideWidth = options.width;
  9655. _this._overrideHeight = options.height;
  9656. _this._resolve = null;
  9657. _this._crossorigin = options.crossorigin;
  9658. _this._load = null;
  9659. if (options.autoLoad !== false) {
  9660. _this.load();
  9661. }
  9662. return _this;
  9663. }
  9664. SVGResource2.prototype.load = function() {
  9665. var _this = this;
  9666. if (this._load) {
  9667. return this._load;
  9668. }
  9669. this._load = new Promise(function(resolve2) {
  9670. _this._resolve = function() {
  9671. _this.resize(_this.source.width, _this.source.height);
  9672. resolve2(_this);
  9673. };
  9674. if (SVGResource2.SVG_XML.test(_this.svg.trim())) {
  9675. if (!btoa) {
  9676. throw new Error("Your browser doesn't support base64 conversions.");
  9677. }
  9678. _this.svg = "data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(_this.svg)));
  9679. }
  9680. _this._loadSvg();
  9681. });
  9682. return this._load;
  9683. };
  9684. SVGResource2.prototype._loadSvg = function() {
  9685. var _this = this;
  9686. var tempImage = new Image();
  9687. BaseImageResource.crossOrigin(tempImage, this.svg, this._crossorigin);
  9688. tempImage.src = this.svg;
  9689. tempImage.onerror = function(event) {
  9690. if (!_this._resolve) {
  9691. return;
  9692. }
  9693. tempImage.onerror = null;
  9694. _this.onError.emit(event);
  9695. };
  9696. tempImage.onload = function() {
  9697. if (!_this._resolve) {
  9698. return;
  9699. }
  9700. var svgWidth = tempImage.width;
  9701. var svgHeight = tempImage.height;
  9702. if (!svgWidth || !svgHeight) {
  9703. throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");
  9704. }
  9705. var width = svgWidth * _this.scale;
  9706. var height = svgHeight * _this.scale;
  9707. if (_this._overrideWidth || _this._overrideHeight) {
  9708. width = _this._overrideWidth || _this._overrideHeight / svgHeight * svgWidth;
  9709. height = _this._overrideHeight || _this._overrideWidth / svgWidth * svgHeight;
  9710. }
  9711. width = Math.round(width);
  9712. height = Math.round(height);
  9713. var canvas = _this.source;
  9714. canvas.width = width;
  9715. canvas.height = height;
  9716. canvas._pixiId = "canvas_" + uid();
  9717. canvas.getContext("2d").drawImage(tempImage, 0, 0, svgWidth, svgHeight, 0, 0, width, height);
  9718. _this._resolve();
  9719. _this._resolve = null;
  9720. };
  9721. };
  9722. SVGResource2.getSize = function(svgString) {
  9723. var sizeMatch = SVGResource2.SVG_SIZE.exec(svgString);
  9724. var size = {};
  9725. if (sizeMatch) {
  9726. size[sizeMatch[1]] = Math.round(parseFloat(sizeMatch[3]));
  9727. size[sizeMatch[5]] = Math.round(parseFloat(sizeMatch[7]));
  9728. }
  9729. return size;
  9730. };
  9731. SVGResource2.prototype.dispose = function() {
  9732. _super.prototype.dispose.call(this);
  9733. this._resolve = null;
  9734. this._crossorigin = null;
  9735. };
  9736. SVGResource2.test = function(source, extension) {
  9737. return extension === "svg" || typeof source === "string" && source.startsWith("data:image/svg+xml") || typeof source === "string" && SVGResource2.SVG_XML.test(source);
  9738. };
  9739. SVGResource2.SVG_XML = /^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m;
  9740. SVGResource2.SVG_SIZE = /<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;
  9741. return SVGResource2;
  9742. })(BaseImageResource)
  9743. );
  9744. var VideoResource = (
  9745. /** @class */
  9746. (function(_super) {
  9747. __extends2(VideoResource2, _super);
  9748. function VideoResource2(source, options) {
  9749. var _this = this;
  9750. options = options || {};
  9751. if (!(source instanceof HTMLVideoElement)) {
  9752. var videoElement = document.createElement("video");
  9753. videoElement.setAttribute("preload", "auto");
  9754. videoElement.setAttribute("webkit-playsinline", "");
  9755. videoElement.setAttribute("playsinline", "");
  9756. if (typeof source === "string") {
  9757. source = [source];
  9758. }
  9759. var firstSrc = source[0].src || source[0];
  9760. BaseImageResource.crossOrigin(videoElement, firstSrc, options.crossorigin);
  9761. for (var i = 0; i < source.length; ++i) {
  9762. var sourceElement = document.createElement("source");
  9763. var _a = source[i], src = _a.src, mime = _a.mime;
  9764. src = src || source[i];
  9765. var baseSrc = src.split("?").shift().toLowerCase();
  9766. var ext = baseSrc.slice(baseSrc.lastIndexOf(".") + 1);
  9767. mime = mime || VideoResource2.MIME_TYPES[ext] || "video/" + ext;
  9768. sourceElement.src = src;
  9769. sourceElement.type = mime;
  9770. videoElement.appendChild(sourceElement);
  9771. }
  9772. source = videoElement;
  9773. }
  9774. _this = _super.call(this, source) || this;
  9775. _this.noSubImage = true;
  9776. _this._autoUpdate = true;
  9777. _this._isConnectedToTicker = false;
  9778. _this._updateFPS = options.updateFPS || 0;
  9779. _this._msToNextUpdate = 0;
  9780. _this.autoPlay = options.autoPlay !== false;
  9781. _this._load = null;
  9782. _this._resolve = null;
  9783. _this._onCanPlay = _this._onCanPlay.bind(_this);
  9784. _this._onError = _this._onError.bind(_this);
  9785. if (options.autoLoad !== false) {
  9786. _this.load();
  9787. }
  9788. return _this;
  9789. }
  9790. VideoResource2.prototype.update = function(_deltaTime) {
  9791. if (!this.destroyed) {
  9792. var elapsedMS = Ticker.shared.elapsedMS * this.source.playbackRate;
  9793. this._msToNextUpdate = Math.floor(this._msToNextUpdate - elapsedMS);
  9794. if (!this._updateFPS || this._msToNextUpdate <= 0) {
  9795. _super.prototype.update.call(this);
  9796. this._msToNextUpdate = this._updateFPS ? Math.floor(1e3 / this._updateFPS) : 0;
  9797. }
  9798. }
  9799. };
  9800. VideoResource2.prototype.load = function() {
  9801. var _this = this;
  9802. if (this._load) {
  9803. return this._load;
  9804. }
  9805. var source = this.source;
  9806. if ((source.readyState === source.HAVE_ENOUGH_DATA || source.readyState === source.HAVE_FUTURE_DATA) && source.width && source.height) {
  9807. source.complete = true;
  9808. }
  9809. source.addEventListener("play", this._onPlayStart.bind(this));
  9810. source.addEventListener("pause", this._onPlayStop.bind(this));
  9811. if (!this._isSourceReady()) {
  9812. source.addEventListener("canplay", this._onCanPlay);
  9813. source.addEventListener("canplaythrough", this._onCanPlay);
  9814. source.addEventListener("error", this._onError, true);
  9815. } else {
  9816. this._onCanPlay();
  9817. }
  9818. this._load = new Promise(function(resolve2) {
  9819. if (_this.valid) {
  9820. resolve2(_this);
  9821. } else {
  9822. _this._resolve = resolve2;
  9823. source.load();
  9824. }
  9825. });
  9826. return this._load;
  9827. };
  9828. VideoResource2.prototype._onError = function(event) {
  9829. this.source.removeEventListener("error", this._onError, true);
  9830. this.onError.emit(event);
  9831. };
  9832. VideoResource2.prototype._isSourcePlaying = function() {
  9833. var source = this.source;
  9834. return !source.paused && !source.ended && this._isSourceReady();
  9835. };
  9836. VideoResource2.prototype._isSourceReady = function() {
  9837. var source = this.source;
  9838. return source.readyState > 2;
  9839. };
  9840. VideoResource2.prototype._onPlayStart = function() {
  9841. if (!this.valid) {
  9842. this._onCanPlay();
  9843. }
  9844. if (this.autoUpdate && !this._isConnectedToTicker) {
  9845. Ticker.shared.add(this.update, this);
  9846. this._isConnectedToTicker = true;
  9847. }
  9848. };
  9849. VideoResource2.prototype._onPlayStop = function() {
  9850. if (this._isConnectedToTicker) {
  9851. Ticker.shared.remove(this.update, this);
  9852. this._isConnectedToTicker = false;
  9853. }
  9854. };
  9855. VideoResource2.prototype._onCanPlay = function() {
  9856. var source = this.source;
  9857. source.removeEventListener("canplay", this._onCanPlay);
  9858. source.removeEventListener("canplaythrough", this._onCanPlay);
  9859. var valid = this.valid;
  9860. this.resize(source.videoWidth, source.videoHeight);
  9861. if (!valid && this._resolve) {
  9862. this._resolve(this);
  9863. this._resolve = null;
  9864. }
  9865. if (this._isSourcePlaying()) {
  9866. this._onPlayStart();
  9867. } else if (this.autoPlay) {
  9868. source.play();
  9869. }
  9870. };
  9871. VideoResource2.prototype.dispose = function() {
  9872. if (this._isConnectedToTicker) {
  9873. Ticker.shared.remove(this.update, this);
  9874. this._isConnectedToTicker = false;
  9875. }
  9876. var source = this.source;
  9877. if (source) {
  9878. source.removeEventListener("error", this._onError, true);
  9879. source.pause();
  9880. source.src = "";
  9881. source.load();
  9882. }
  9883. _super.prototype.dispose.call(this);
  9884. };
  9885. Object.defineProperty(VideoResource2.prototype, "autoUpdate", {
  9886. /** Should the base texture automatically update itself, set to true by default. */
  9887. get: function() {
  9888. return this._autoUpdate;
  9889. },
  9890. set: function(value) {
  9891. if (value !== this._autoUpdate) {
  9892. this._autoUpdate = value;
  9893. if (!this._autoUpdate && this._isConnectedToTicker) {
  9894. Ticker.shared.remove(this.update, this);
  9895. this._isConnectedToTicker = false;
  9896. } else if (this._autoUpdate && !this._isConnectedToTicker && this._isSourcePlaying()) {
  9897. Ticker.shared.add(this.update, this);
  9898. this._isConnectedToTicker = true;
  9899. }
  9900. }
  9901. },
  9902. enumerable: false,
  9903. configurable: true
  9904. });
  9905. Object.defineProperty(VideoResource2.prototype, "updateFPS", {
  9906. /**
  9907. * How many times a second to update the texture from the video. Leave at 0 to update at every render.
  9908. * A lower fps can help performance, as updating the texture at 60fps on a 30ps video may not be efficient.
  9909. */
  9910. get: function() {
  9911. return this._updateFPS;
  9912. },
  9913. set: function(value) {
  9914. if (value !== this._updateFPS) {
  9915. this._updateFPS = value;
  9916. }
  9917. },
  9918. enumerable: false,
  9919. configurable: true
  9920. });
  9921. VideoResource2.test = function(source, extension) {
  9922. return globalThis.HTMLVideoElement && source instanceof HTMLVideoElement || VideoResource2.TYPES.indexOf(extension) > -1;
  9923. };
  9924. VideoResource2.TYPES = ["mp4", "m4v", "webm", "ogg", "ogv", "h264", "avi", "mov"];
  9925. VideoResource2.MIME_TYPES = {
  9926. ogv: "video/ogg",
  9927. mov: "video/quicktime",
  9928. m4v: "video/mp4"
  9929. };
  9930. return VideoResource2;
  9931. })(BaseImageResource)
  9932. );
  9933. var ImageBitmapResource = (
  9934. /** @class */
  9935. (function(_super) {
  9936. __extends2(ImageBitmapResource2, _super);
  9937. function ImageBitmapResource2(source) {
  9938. return _super.call(this, source) || this;
  9939. }
  9940. ImageBitmapResource2.test = function(source) {
  9941. return !!globalThis.createImageBitmap && typeof ImageBitmap !== "undefined" && source instanceof ImageBitmap;
  9942. };
  9943. return ImageBitmapResource2;
  9944. })(BaseImageResource)
  9945. );
  9946. INSTALLED.push(ImageResource, ImageBitmapResource, CanvasResource, VideoResource, SVGResource, BufferResource, CubeResource, ArrayResource);
  9947. var _resources = {
  9948. __proto__: null,
  9949. Resource,
  9950. BaseImageResource,
  9951. INSTALLED,
  9952. autoDetectResource,
  9953. AbstractMultiResource,
  9954. ArrayResource,
  9955. BufferResource,
  9956. CanvasResource,
  9957. CubeResource,
  9958. ImageResource,
  9959. SVGResource,
  9960. VideoResource,
  9961. ImageBitmapResource
  9962. };
  9963. var DepthResource = (
  9964. /** @class */
  9965. (function(_super) {
  9966. __extends2(DepthResource2, _super);
  9967. function DepthResource2() {
  9968. return _super !== null && _super.apply(this, arguments) || this;
  9969. }
  9970. DepthResource2.prototype.upload = function(renderer, baseTexture, glTexture) {
  9971. var gl = renderer.gl;
  9972. gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.alphaMode === ALPHA_MODES.UNPACK);
  9973. var width = baseTexture.realWidth;
  9974. var height = baseTexture.realHeight;
  9975. if (glTexture.width === width && glTexture.height === height) {
  9976. gl.texSubImage2D(baseTexture.target, 0, 0, 0, width, height, baseTexture.format, glTexture.type, this.data);
  9977. } else {
  9978. glTexture.width = width;
  9979. glTexture.height = height;
  9980. gl.texImage2D(baseTexture.target, 0, glTexture.internalFormat, width, height, 0, baseTexture.format, glTexture.type, this.data);
  9981. }
  9982. return true;
  9983. };
  9984. return DepthResource2;
  9985. })(BufferResource)
  9986. );
  9987. var Framebuffer = (
  9988. /** @class */
  9989. (function() {
  9990. function Framebuffer2(width, height) {
  9991. this.width = Math.round(width || 100);
  9992. this.height = Math.round(height || 100);
  9993. this.stencil = false;
  9994. this.depth = false;
  9995. this.dirtyId = 0;
  9996. this.dirtyFormat = 0;
  9997. this.dirtySize = 0;
  9998. this.depthTexture = null;
  9999. this.colorTextures = [];
  10000. this.glFramebuffers = {};
  10001. this.disposeRunner = new Runner("disposeFramebuffer");
  10002. this.multisample = MSAA_QUALITY.NONE;
  10003. }
  10004. Object.defineProperty(Framebuffer2.prototype, "colorTexture", {
  10005. /**
  10006. * Reference to the colorTexture.
  10007. * @readonly
  10008. */
  10009. get: function() {
  10010. return this.colorTextures[0];
  10011. },
  10012. enumerable: false,
  10013. configurable: true
  10014. });
  10015. Framebuffer2.prototype.addColorTexture = function(index, texture) {
  10016. if (index === void 0) {
  10017. index = 0;
  10018. }
  10019. this.colorTextures[index] = texture || new BaseTexture(null, {
  10020. scaleMode: SCALE_MODES.NEAREST,
  10021. resolution: 1,
  10022. mipmap: MIPMAP_MODES.OFF,
  10023. width: this.width,
  10024. height: this.height
  10025. });
  10026. this.dirtyId++;
  10027. this.dirtyFormat++;
  10028. return this;
  10029. };
  10030. Framebuffer2.prototype.addDepthTexture = function(texture) {
  10031. this.depthTexture = texture || new BaseTexture(new DepthResource(null, { width: this.width, height: this.height }), {
  10032. scaleMode: SCALE_MODES.NEAREST,
  10033. resolution: 1,
  10034. width: this.width,
  10035. height: this.height,
  10036. mipmap: MIPMAP_MODES.OFF,
  10037. format: FORMATS.DEPTH_COMPONENT,
  10038. type: TYPES.UNSIGNED_SHORT
  10039. });
  10040. this.dirtyId++;
  10041. this.dirtyFormat++;
  10042. return this;
  10043. };
  10044. Framebuffer2.prototype.enableDepth = function() {
  10045. this.depth = true;
  10046. this.dirtyId++;
  10047. this.dirtyFormat++;
  10048. return this;
  10049. };
  10050. Framebuffer2.prototype.enableStencil = function() {
  10051. this.stencil = true;
  10052. this.dirtyId++;
  10053. this.dirtyFormat++;
  10054. return this;
  10055. };
  10056. Framebuffer2.prototype.resize = function(width, height) {
  10057. width = Math.round(width);
  10058. height = Math.round(height);
  10059. if (width === this.width && height === this.height) {
  10060. return;
  10061. }
  10062. this.width = width;
  10063. this.height = height;
  10064. this.dirtyId++;
  10065. this.dirtySize++;
  10066. for (var i = 0; i < this.colorTextures.length; i++) {
  10067. var texture = this.colorTextures[i];
  10068. var resolution = texture.resolution;
  10069. texture.setSize(width / resolution, height / resolution);
  10070. }
  10071. if (this.depthTexture) {
  10072. var resolution = this.depthTexture.resolution;
  10073. this.depthTexture.setSize(width / resolution, height / resolution);
  10074. }
  10075. };
  10076. Framebuffer2.prototype.dispose = function() {
  10077. this.disposeRunner.emit(this, false);
  10078. };
  10079. Framebuffer2.prototype.destroyDepthTexture = function() {
  10080. if (this.depthTexture) {
  10081. this.depthTexture.destroy();
  10082. this.depthTexture = null;
  10083. ++this.dirtyId;
  10084. ++this.dirtyFormat;
  10085. }
  10086. };
  10087. return Framebuffer2;
  10088. })()
  10089. );
  10090. var BaseRenderTexture = (
  10091. /** @class */
  10092. (function(_super) {
  10093. __extends2(BaseRenderTexture2, _super);
  10094. function BaseRenderTexture2(options) {
  10095. if (options === void 0) {
  10096. options = {};
  10097. }
  10098. var _this = this;
  10099. if (typeof options === "number") {
  10100. var width = arguments[0];
  10101. var height = arguments[1];
  10102. var scaleMode = arguments[2];
  10103. var resolution = arguments[3];
  10104. options = { width, height, scaleMode, resolution };
  10105. }
  10106. options.width = options.width || 100;
  10107. options.height = options.height || 100;
  10108. options.multisample = options.multisample !== void 0 ? options.multisample : MSAA_QUALITY.NONE;
  10109. _this = _super.call(this, null, options) || this;
  10110. _this.mipmap = MIPMAP_MODES.OFF;
  10111. _this.valid = true;
  10112. _this.clearColor = [0, 0, 0, 0];
  10113. _this.framebuffer = new Framebuffer(_this.realWidth, _this.realHeight).addColorTexture(0, _this);
  10114. _this.framebuffer.multisample = options.multisample;
  10115. _this.maskStack = [];
  10116. _this.filterStack = [{}];
  10117. return _this;
  10118. }
  10119. BaseRenderTexture2.prototype.resize = function(desiredWidth, desiredHeight) {
  10120. this.framebuffer.resize(desiredWidth * this.resolution, desiredHeight * this.resolution);
  10121. this.setRealSize(this.framebuffer.width, this.framebuffer.height);
  10122. };
  10123. BaseRenderTexture2.prototype.dispose = function() {
  10124. this.framebuffer.dispose();
  10125. _super.prototype.dispose.call(this);
  10126. };
  10127. BaseRenderTexture2.prototype.destroy = function() {
  10128. _super.prototype.destroy.call(this);
  10129. this.framebuffer.destroyDepthTexture();
  10130. this.framebuffer = null;
  10131. };
  10132. return BaseRenderTexture2;
  10133. })(BaseTexture)
  10134. );
  10135. var TextureUvs = (
  10136. /** @class */
  10137. (function() {
  10138. function TextureUvs2() {
  10139. this.x0 = 0;
  10140. this.y0 = 0;
  10141. this.x1 = 1;
  10142. this.y1 = 0;
  10143. this.x2 = 1;
  10144. this.y2 = 1;
  10145. this.x3 = 0;
  10146. this.y3 = 1;
  10147. this.uvsFloat32 = new Float32Array(8);
  10148. }
  10149. TextureUvs2.prototype.set = function(frame, baseFrame, rotate) {
  10150. var tw = baseFrame.width;
  10151. var th = baseFrame.height;
  10152. if (rotate) {
  10153. var w2 = frame.width / 2 / tw;
  10154. var h2 = frame.height / 2 / th;
  10155. var cX = frame.x / tw + w2;
  10156. var cY = frame.y / th + h2;
  10157. rotate = groupD8.add(rotate, groupD8.NW);
  10158. this.x0 = cX + w2 * groupD8.uX(rotate);
  10159. this.y0 = cY + h2 * groupD8.uY(rotate);
  10160. rotate = groupD8.add(rotate, 2);
  10161. this.x1 = cX + w2 * groupD8.uX(rotate);
  10162. this.y1 = cY + h2 * groupD8.uY(rotate);
  10163. rotate = groupD8.add(rotate, 2);
  10164. this.x2 = cX + w2 * groupD8.uX(rotate);
  10165. this.y2 = cY + h2 * groupD8.uY(rotate);
  10166. rotate = groupD8.add(rotate, 2);
  10167. this.x3 = cX + w2 * groupD8.uX(rotate);
  10168. this.y3 = cY + h2 * groupD8.uY(rotate);
  10169. } else {
  10170. this.x0 = frame.x / tw;
  10171. this.y0 = frame.y / th;
  10172. this.x1 = (frame.x + frame.width) / tw;
  10173. this.y1 = frame.y / th;
  10174. this.x2 = (frame.x + frame.width) / tw;
  10175. this.y2 = (frame.y + frame.height) / th;
  10176. this.x3 = frame.x / tw;
  10177. this.y3 = (frame.y + frame.height) / th;
  10178. }
  10179. this.uvsFloat32[0] = this.x0;
  10180. this.uvsFloat32[1] = this.y0;
  10181. this.uvsFloat32[2] = this.x1;
  10182. this.uvsFloat32[3] = this.y1;
  10183. this.uvsFloat32[4] = this.x2;
  10184. this.uvsFloat32[5] = this.y2;
  10185. this.uvsFloat32[6] = this.x3;
  10186. this.uvsFloat32[7] = this.y3;
  10187. };
  10188. TextureUvs2.prototype.toString = function() {
  10189. return "[@pixi/core:TextureUvs " + ("x0=" + this.x0 + " y0=" + this.y0 + " ") + ("x1=" + this.x1 + " y1=" + this.y1 + " x2=" + this.x2 + " ") + ("y2=" + this.y2 + " x3=" + this.x3 + " y3=" + this.y3) + "]";
  10190. };
  10191. return TextureUvs2;
  10192. })()
  10193. );
  10194. var DEFAULT_UVS = new TextureUvs();
  10195. function removeAllHandlers(tex) {
  10196. tex.destroy = function _emptyDestroy() {
  10197. };
  10198. tex.on = function _emptyOn() {
  10199. };
  10200. tex.once = function _emptyOnce() {
  10201. };
  10202. tex.emit = function _emptyEmit() {
  10203. };
  10204. }
  10205. var Texture = (
  10206. /** @class */
  10207. (function(_super) {
  10208. __extends2(Texture2, _super);
  10209. function Texture2(baseTexture, frame, orig, trim, rotate, anchor) {
  10210. var _this = _super.call(this) || this;
  10211. _this.noFrame = false;
  10212. if (!frame) {
  10213. _this.noFrame = true;
  10214. frame = new Rectangle(0, 0, 1, 1);
  10215. }
  10216. if (baseTexture instanceof Texture2) {
  10217. baseTexture = baseTexture.baseTexture;
  10218. }
  10219. _this.baseTexture = baseTexture;
  10220. _this._frame = frame;
  10221. _this.trim = trim;
  10222. _this.valid = false;
  10223. _this._uvs = DEFAULT_UVS;
  10224. _this.uvMatrix = null;
  10225. _this.orig = orig || frame;
  10226. _this._rotate = Number(rotate || 0);
  10227. if (rotate === true) {
  10228. _this._rotate = 2;
  10229. } else if (_this._rotate % 2 !== 0) {
  10230. throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");
  10231. }
  10232. _this.defaultAnchor = anchor ? new Point(anchor.x, anchor.y) : new Point(0, 0);
  10233. _this._updateID = 0;
  10234. _this.textureCacheIds = [];
  10235. if (!baseTexture.valid) {
  10236. baseTexture.once("loaded", _this.onBaseTextureUpdated, _this);
  10237. } else if (_this.noFrame) {
  10238. if (baseTexture.valid) {
  10239. _this.onBaseTextureUpdated(baseTexture);
  10240. }
  10241. } else {
  10242. _this.frame = frame;
  10243. }
  10244. if (_this.noFrame) {
  10245. baseTexture.on("update", _this.onBaseTextureUpdated, _this);
  10246. }
  10247. return _this;
  10248. }
  10249. Texture2.prototype.update = function() {
  10250. if (this.baseTexture.resource) {
  10251. this.baseTexture.resource.update();
  10252. }
  10253. };
  10254. Texture2.prototype.onBaseTextureUpdated = function(baseTexture) {
  10255. if (this.noFrame) {
  10256. if (!this.baseTexture.valid) {
  10257. return;
  10258. }
  10259. this._frame.width = baseTexture.width;
  10260. this._frame.height = baseTexture.height;
  10261. this.valid = true;
  10262. this.updateUvs();
  10263. } else {
  10264. this.frame = this._frame;
  10265. }
  10266. this.emit("update", this);
  10267. };
  10268. Texture2.prototype.destroy = function(destroyBase) {
  10269. if (this.baseTexture) {
  10270. if (destroyBase) {
  10271. var resource = this.baseTexture.resource;
  10272. if (resource && resource.url && TextureCache[resource.url]) {
  10273. Texture2.removeFromCache(resource.url);
  10274. }
  10275. this.baseTexture.destroy();
  10276. }
  10277. this.baseTexture.off("loaded", this.onBaseTextureUpdated, this);
  10278. this.baseTexture.off("update", this.onBaseTextureUpdated, this);
  10279. this.baseTexture = null;
  10280. }
  10281. this._frame = null;
  10282. this._uvs = null;
  10283. this.trim = null;
  10284. this.orig = null;
  10285. this.valid = false;
  10286. Texture2.removeFromCache(this);
  10287. this.textureCacheIds = null;
  10288. };
  10289. Texture2.prototype.clone = function() {
  10290. var clonedFrame = this._frame.clone();
  10291. var clonedOrig = this._frame === this.orig ? clonedFrame : this.orig.clone();
  10292. var clonedTexture = new Texture2(this.baseTexture, !this.noFrame && clonedFrame, clonedOrig, this.trim && this.trim.clone(), this.rotate, this.defaultAnchor);
  10293. if (this.noFrame) {
  10294. clonedTexture._frame = clonedFrame;
  10295. }
  10296. return clonedTexture;
  10297. };
  10298. Texture2.prototype.updateUvs = function() {
  10299. if (this._uvs === DEFAULT_UVS) {
  10300. this._uvs = new TextureUvs();
  10301. }
  10302. this._uvs.set(this._frame, this.baseTexture, this.rotate);
  10303. this._updateID++;
  10304. };
  10305. Texture2.from = function(source, options, strict) {
  10306. if (options === void 0) {
  10307. options = {};
  10308. }
  10309. if (strict === void 0) {
  10310. strict = settings.STRICT_TEXTURE_CACHE;
  10311. }
  10312. var isFrame = typeof source === "string";
  10313. var cacheId = null;
  10314. if (isFrame) {
  10315. cacheId = source;
  10316. } else if (source instanceof BaseTexture) {
  10317. if (!source.cacheId) {
  10318. var prefix = options && options.pixiIdPrefix || "pixiid";
  10319. source.cacheId = prefix + "-" + uid();
  10320. BaseTexture.addToCache(source, source.cacheId);
  10321. }
  10322. cacheId = source.cacheId;
  10323. } else {
  10324. if (!source._pixiId) {
  10325. var prefix = options && options.pixiIdPrefix || "pixiid";
  10326. source._pixiId = prefix + "_" + uid();
  10327. }
  10328. cacheId = source._pixiId;
  10329. }
  10330. var texture = TextureCache[cacheId];
  10331. if (isFrame && strict && !texture) {
  10332. throw new Error('The cacheId "' + cacheId + '" does not exist in TextureCache.');
  10333. }
  10334. if (!texture && !(source instanceof BaseTexture)) {
  10335. if (!options.resolution) {
  10336. options.resolution = getResolutionOfUrl(source);
  10337. }
  10338. texture = new Texture2(new BaseTexture(source, options));
  10339. texture.baseTexture.cacheId = cacheId;
  10340. BaseTexture.addToCache(texture.baseTexture, cacheId);
  10341. Texture2.addToCache(texture, cacheId);
  10342. } else if (!texture && source instanceof BaseTexture) {
  10343. texture = new Texture2(source);
  10344. Texture2.addToCache(texture, cacheId);
  10345. }
  10346. return texture;
  10347. };
  10348. Texture2.fromURL = function(url2, options) {
  10349. var resourceOptions = Object.assign({ autoLoad: false }, options === null || options === void 0 ? void 0 : options.resourceOptions);
  10350. var texture = Texture2.from(url2, Object.assign({ resourceOptions }, options), false);
  10351. var resource = texture.baseTexture.resource;
  10352. if (texture.baseTexture.valid) {
  10353. return Promise.resolve(texture);
  10354. }
  10355. return resource.load().then(function() {
  10356. return Promise.resolve(texture);
  10357. });
  10358. };
  10359. Texture2.fromBuffer = function(buffer, width, height, options) {
  10360. return new Texture2(BaseTexture.fromBuffer(buffer, width, height, options));
  10361. };
  10362. Texture2.fromLoader = function(source, imageUrl, name, options) {
  10363. var baseTexture = new BaseTexture(source, Object.assign({
  10364. scaleMode: settings.SCALE_MODE,
  10365. resolution: getResolutionOfUrl(imageUrl)
  10366. }, options));
  10367. var resource = baseTexture.resource;
  10368. if (resource instanceof ImageResource) {
  10369. resource.url = imageUrl;
  10370. }
  10371. var texture = new Texture2(baseTexture);
  10372. if (!name) {
  10373. name = imageUrl;
  10374. }
  10375. BaseTexture.addToCache(texture.baseTexture, name);
  10376. Texture2.addToCache(texture, name);
  10377. if (name !== imageUrl) {
  10378. BaseTexture.addToCache(texture.baseTexture, imageUrl);
  10379. Texture2.addToCache(texture, imageUrl);
  10380. }
  10381. if (texture.baseTexture.valid) {
  10382. return Promise.resolve(texture);
  10383. }
  10384. return new Promise(function(resolve2) {
  10385. texture.baseTexture.once("loaded", function() {
  10386. return resolve2(texture);
  10387. });
  10388. });
  10389. };
  10390. Texture2.addToCache = function(texture, id) {
  10391. if (id) {
  10392. if (texture.textureCacheIds.indexOf(id) === -1) {
  10393. texture.textureCacheIds.push(id);
  10394. }
  10395. if (TextureCache[id]) {
  10396. console.warn("Texture added to the cache with an id [" + id + "] that already had an entry");
  10397. }
  10398. TextureCache[id] = texture;
  10399. }
  10400. };
  10401. Texture2.removeFromCache = function(texture) {
  10402. if (typeof texture === "string") {
  10403. var textureFromCache = TextureCache[texture];
  10404. if (textureFromCache) {
  10405. var index = textureFromCache.textureCacheIds.indexOf(texture);
  10406. if (index > -1) {
  10407. textureFromCache.textureCacheIds.splice(index, 1);
  10408. }
  10409. delete TextureCache[texture];
  10410. return textureFromCache;
  10411. }
  10412. } else if (texture && texture.textureCacheIds) {
  10413. for (var i = 0; i < texture.textureCacheIds.length; ++i) {
  10414. if (TextureCache[texture.textureCacheIds[i]] === texture) {
  10415. delete TextureCache[texture.textureCacheIds[i]];
  10416. }
  10417. }
  10418. texture.textureCacheIds.length = 0;
  10419. return texture;
  10420. }
  10421. return null;
  10422. };
  10423. Object.defineProperty(Texture2.prototype, "resolution", {
  10424. /**
  10425. * Returns resolution of baseTexture
  10426. * @readonly
  10427. */
  10428. get: function() {
  10429. return this.baseTexture.resolution;
  10430. },
  10431. enumerable: false,
  10432. configurable: true
  10433. });
  10434. Object.defineProperty(Texture2.prototype, "frame", {
  10435. /**
  10436. * The frame specifies the region of the base texture that this texture uses.
  10437. * Please call `updateUvs()` after you change coordinates of `frame` manually.
  10438. */
  10439. get: function() {
  10440. return this._frame;
  10441. },
  10442. set: function(frame) {
  10443. this._frame = frame;
  10444. this.noFrame = false;
  10445. var x = frame.x, y = frame.y, width = frame.width, height = frame.height;
  10446. var xNotFit = x + width > this.baseTexture.width;
  10447. var yNotFit = y + height > this.baseTexture.height;
  10448. if (xNotFit || yNotFit) {
  10449. var relationship = xNotFit && yNotFit ? "and" : "or";
  10450. var errorX = "X: " + x + " + " + width + " = " + (x + width) + " > " + this.baseTexture.width;
  10451. var errorY = "Y: " + y + " + " + height + " = " + (y + height) + " > " + this.baseTexture.height;
  10452. throw new Error("Texture Error: frame does not fit inside the base Texture dimensions: " + (errorX + " " + relationship + " " + errorY));
  10453. }
  10454. this.valid = width && height && this.baseTexture.valid;
  10455. if (!this.trim && !this.rotate) {
  10456. this.orig = frame;
  10457. }
  10458. if (this.valid) {
  10459. this.updateUvs();
  10460. }
  10461. },
  10462. enumerable: false,
  10463. configurable: true
  10464. });
  10465. Object.defineProperty(Texture2.prototype, "rotate", {
  10466. /**
  10467. * Indicates whether the texture is rotated inside the atlas
  10468. * set to 2 to compensate for texture packer rotation
  10469. * set to 6 to compensate for spine packer rotation
  10470. * can be used to rotate or mirror sprites
  10471. * See {@link PIXI.groupD8} for explanation
  10472. */
  10473. get: function() {
  10474. return this._rotate;
  10475. },
  10476. set: function(rotate) {
  10477. this._rotate = rotate;
  10478. if (this.valid) {
  10479. this.updateUvs();
  10480. }
  10481. },
  10482. enumerable: false,
  10483. configurable: true
  10484. });
  10485. Object.defineProperty(Texture2.prototype, "width", {
  10486. /** The width of the Texture in pixels. */
  10487. get: function() {
  10488. return this.orig.width;
  10489. },
  10490. enumerable: false,
  10491. configurable: true
  10492. });
  10493. Object.defineProperty(Texture2.prototype, "height", {
  10494. /** The height of the Texture in pixels. */
  10495. get: function() {
  10496. return this.orig.height;
  10497. },
  10498. enumerable: false,
  10499. configurable: true
  10500. });
  10501. Texture2.prototype.castToBaseTexture = function() {
  10502. return this.baseTexture;
  10503. };
  10504. Object.defineProperty(Texture2, "EMPTY", {
  10505. /** An empty texture, used often to not have to create multiple empty textures. Can not be destroyed. */
  10506. get: function() {
  10507. if (!Texture2._EMPTY) {
  10508. Texture2._EMPTY = new Texture2(new BaseTexture());
  10509. removeAllHandlers(Texture2._EMPTY);
  10510. removeAllHandlers(Texture2._EMPTY.baseTexture);
  10511. }
  10512. return Texture2._EMPTY;
  10513. },
  10514. enumerable: false,
  10515. configurable: true
  10516. });
  10517. Object.defineProperty(Texture2, "WHITE", {
  10518. /** A white texture of 16x16 size, used for graphics and other things Can not be destroyed. */
  10519. get: function() {
  10520. if (!Texture2._WHITE) {
  10521. var canvas = settings.ADAPTER.createCanvas(16, 16);
  10522. var context2 = canvas.getContext("2d");
  10523. canvas.width = 16;
  10524. canvas.height = 16;
  10525. context2.fillStyle = "white";
  10526. context2.fillRect(0, 0, 16, 16);
  10527. Texture2._WHITE = new Texture2(BaseTexture.from(canvas));
  10528. removeAllHandlers(Texture2._WHITE);
  10529. removeAllHandlers(Texture2._WHITE.baseTexture);
  10530. }
  10531. return Texture2._WHITE;
  10532. },
  10533. enumerable: false,
  10534. configurable: true
  10535. });
  10536. return Texture2;
  10537. })(import_eventemitter3.default)
  10538. );
  10539. var RenderTexture = (
  10540. /** @class */
  10541. (function(_super) {
  10542. __extends2(RenderTexture2, _super);
  10543. function RenderTexture2(baseRenderTexture, frame) {
  10544. var _this = _super.call(this, baseRenderTexture, frame) || this;
  10545. _this.valid = true;
  10546. _this.filterFrame = null;
  10547. _this.filterPoolKey = null;
  10548. _this.updateUvs();
  10549. return _this;
  10550. }
  10551. Object.defineProperty(RenderTexture2.prototype, "framebuffer", {
  10552. /**
  10553. * Shortcut to `this.baseTexture.framebuffer`, saves baseTexture cast.
  10554. * @readonly
  10555. */
  10556. get: function() {
  10557. return this.baseTexture.framebuffer;
  10558. },
  10559. enumerable: false,
  10560. configurable: true
  10561. });
  10562. Object.defineProperty(RenderTexture2.prototype, "multisample", {
  10563. /**
  10564. * Shortcut to `this.framebuffer.multisample`.
  10565. * @default PIXI.MSAA_QUALITY.NONE
  10566. */
  10567. get: function() {
  10568. return this.framebuffer.multisample;
  10569. },
  10570. set: function(value) {
  10571. this.framebuffer.multisample = value;
  10572. },
  10573. enumerable: false,
  10574. configurable: true
  10575. });
  10576. RenderTexture2.prototype.resize = function(desiredWidth, desiredHeight, resizeBaseTexture) {
  10577. if (resizeBaseTexture === void 0) {
  10578. resizeBaseTexture = true;
  10579. }
  10580. var resolution = this.baseTexture.resolution;
  10581. var width = Math.round(desiredWidth * resolution) / resolution;
  10582. var height = Math.round(desiredHeight * resolution) / resolution;
  10583. this.valid = width > 0 && height > 0;
  10584. this._frame.width = this.orig.width = width;
  10585. this._frame.height = this.orig.height = height;
  10586. if (resizeBaseTexture) {
  10587. this.baseTexture.resize(width, height);
  10588. }
  10589. this.updateUvs();
  10590. };
  10591. RenderTexture2.prototype.setResolution = function(resolution) {
  10592. var baseTexture = this.baseTexture;
  10593. if (baseTexture.resolution === resolution) {
  10594. return;
  10595. }
  10596. baseTexture.setResolution(resolution);
  10597. this.resize(baseTexture.width, baseTexture.height, false);
  10598. };
  10599. RenderTexture2.create = function(options) {
  10600. var arguments$1 = arguments;
  10601. var rest = [];
  10602. for (var _i = 1; _i < arguments.length; _i++) {
  10603. rest[_i - 1] = arguments$1[_i];
  10604. }
  10605. if (typeof options === "number") {
  10606. deprecation("6.0.0", "Arguments (width, height, scaleMode, resolution) have been deprecated.");
  10607. options = {
  10608. width: options,
  10609. height: rest[0],
  10610. scaleMode: rest[1],
  10611. resolution: rest[2]
  10612. };
  10613. }
  10614. return new RenderTexture2(new BaseRenderTexture(options));
  10615. };
  10616. return RenderTexture2;
  10617. })(Texture)
  10618. );
  10619. var RenderTexturePool = (
  10620. /** @class */
  10621. (function() {
  10622. function RenderTexturePool2(textureOptions) {
  10623. this.texturePool = {};
  10624. this.textureOptions = textureOptions || {};
  10625. this.enableFullScreen = false;
  10626. this._pixelsWidth = 0;
  10627. this._pixelsHeight = 0;
  10628. }
  10629. RenderTexturePool2.prototype.createTexture = function(realWidth, realHeight, multisample) {
  10630. if (multisample === void 0) {
  10631. multisample = MSAA_QUALITY.NONE;
  10632. }
  10633. var baseRenderTexture = new BaseRenderTexture(Object.assign({
  10634. width: realWidth,
  10635. height: realHeight,
  10636. resolution: 1,
  10637. multisample
  10638. }, this.textureOptions));
  10639. return new RenderTexture(baseRenderTexture);
  10640. };
  10641. RenderTexturePool2.prototype.getOptimalTexture = function(minWidth, minHeight, resolution, multisample) {
  10642. if (resolution === void 0) {
  10643. resolution = 1;
  10644. }
  10645. if (multisample === void 0) {
  10646. multisample = MSAA_QUALITY.NONE;
  10647. }
  10648. var key;
  10649. minWidth = Math.ceil(minWidth * resolution - 1e-6);
  10650. minHeight = Math.ceil(minHeight * resolution - 1e-6);
  10651. if (!this.enableFullScreen || minWidth !== this._pixelsWidth || minHeight !== this._pixelsHeight) {
  10652. minWidth = nextPow2(minWidth);
  10653. minHeight = nextPow2(minHeight);
  10654. key = ((minWidth & 65535) << 16 | minHeight & 65535) >>> 0;
  10655. if (multisample > 1) {
  10656. key += multisample * 4294967296;
  10657. }
  10658. } else {
  10659. key = multisample > 1 ? -multisample : -1;
  10660. }
  10661. if (!this.texturePool[key]) {
  10662. this.texturePool[key] = [];
  10663. }
  10664. var renderTexture = this.texturePool[key].pop();
  10665. if (!renderTexture) {
  10666. renderTexture = this.createTexture(minWidth, minHeight, multisample);
  10667. }
  10668. renderTexture.filterPoolKey = key;
  10669. renderTexture.setResolution(resolution);
  10670. return renderTexture;
  10671. };
  10672. RenderTexturePool2.prototype.getFilterTexture = function(input, resolution, multisample) {
  10673. var filterTexture = this.getOptimalTexture(input.width, input.height, resolution || input.resolution, multisample || MSAA_QUALITY.NONE);
  10674. filterTexture.filterFrame = input.filterFrame;
  10675. return filterTexture;
  10676. };
  10677. RenderTexturePool2.prototype.returnTexture = function(renderTexture) {
  10678. var key = renderTexture.filterPoolKey;
  10679. renderTexture.filterFrame = null;
  10680. this.texturePool[key].push(renderTexture);
  10681. };
  10682. RenderTexturePool2.prototype.returnFilterTexture = function(renderTexture) {
  10683. this.returnTexture(renderTexture);
  10684. };
  10685. RenderTexturePool2.prototype.clear = function(destroyTextures) {
  10686. destroyTextures = destroyTextures !== false;
  10687. if (destroyTextures) {
  10688. for (var i in this.texturePool) {
  10689. var textures = this.texturePool[i];
  10690. if (textures) {
  10691. for (var j = 0; j < textures.length; j++) {
  10692. textures[j].destroy(true);
  10693. }
  10694. }
  10695. }
  10696. }
  10697. this.texturePool = {};
  10698. };
  10699. RenderTexturePool2.prototype.setScreenSize = function(size) {
  10700. if (size.width === this._pixelsWidth && size.height === this._pixelsHeight) {
  10701. return;
  10702. }
  10703. this.enableFullScreen = size.width > 0 && size.height > 0;
  10704. for (var i in this.texturePool) {
  10705. if (!(Number(i) < 0)) {
  10706. continue;
  10707. }
  10708. var textures = this.texturePool[i];
  10709. if (textures) {
  10710. for (var j = 0; j < textures.length; j++) {
  10711. textures[j].destroy(true);
  10712. }
  10713. }
  10714. this.texturePool[i] = [];
  10715. }
  10716. this._pixelsWidth = size.width;
  10717. this._pixelsHeight = size.height;
  10718. };
  10719. RenderTexturePool2.SCREEN_KEY = -1;
  10720. return RenderTexturePool2;
  10721. })()
  10722. );
  10723. var Attribute = (
  10724. /** @class */
  10725. (function() {
  10726. function Attribute2(buffer, size, normalized, type, stride, start, instance) {
  10727. if (size === void 0) {
  10728. size = 0;
  10729. }
  10730. if (normalized === void 0) {
  10731. normalized = false;
  10732. }
  10733. if (type === void 0) {
  10734. type = TYPES.FLOAT;
  10735. }
  10736. this.buffer = buffer;
  10737. this.size = size;
  10738. this.normalized = normalized;
  10739. this.type = type;
  10740. this.stride = stride;
  10741. this.start = start;
  10742. this.instance = instance;
  10743. }
  10744. Attribute2.prototype.destroy = function() {
  10745. this.buffer = null;
  10746. };
  10747. Attribute2.from = function(buffer, size, normalized, type, stride) {
  10748. return new Attribute2(buffer, size, normalized, type, stride);
  10749. };
  10750. return Attribute2;
  10751. })()
  10752. );
  10753. var UID$4 = 0;
  10754. var Buffer = (
  10755. /** @class */
  10756. (function() {
  10757. function Buffer2(data, _static, index) {
  10758. if (_static === void 0) {
  10759. _static = true;
  10760. }
  10761. if (index === void 0) {
  10762. index = false;
  10763. }
  10764. this.data = data || new Float32Array(1);
  10765. this._glBuffers = {};
  10766. this._updateID = 0;
  10767. this.index = index;
  10768. this.static = _static;
  10769. this.id = UID$4++;
  10770. this.disposeRunner = new Runner("disposeBuffer");
  10771. }
  10772. Buffer2.prototype.update = function(data) {
  10773. if (data instanceof Array) {
  10774. data = new Float32Array(data);
  10775. }
  10776. this.data = data || this.data;
  10777. this._updateID++;
  10778. };
  10779. Buffer2.prototype.dispose = function() {
  10780. this.disposeRunner.emit(this, false);
  10781. };
  10782. Buffer2.prototype.destroy = function() {
  10783. this.dispose();
  10784. this.data = null;
  10785. };
  10786. Object.defineProperty(Buffer2.prototype, "index", {
  10787. get: function() {
  10788. return this.type === BUFFER_TYPE.ELEMENT_ARRAY_BUFFER;
  10789. },
  10790. /**
  10791. * Flags whether this is an index buffer.
  10792. *
  10793. * Index buffers are of type `ELEMENT_ARRAY_BUFFER`. Note that setting this property to false will make
  10794. * the buffer of type `ARRAY_BUFFER`.
  10795. *
  10796. * For backwards compatibility.
  10797. */
  10798. set: function(value) {
  10799. this.type = value ? BUFFER_TYPE.ELEMENT_ARRAY_BUFFER : BUFFER_TYPE.ARRAY_BUFFER;
  10800. },
  10801. enumerable: false,
  10802. configurable: true
  10803. });
  10804. Buffer2.from = function(data) {
  10805. if (data instanceof Array) {
  10806. data = new Float32Array(data);
  10807. }
  10808. return new Buffer2(data);
  10809. };
  10810. return Buffer2;
  10811. })()
  10812. );
  10813. var map$1 = {
  10814. Float32Array,
  10815. Uint32Array,
  10816. Int32Array,
  10817. Uint8Array
  10818. };
  10819. function interleaveTypedArrays2(arrays, sizes) {
  10820. var outSize = 0;
  10821. var stride = 0;
  10822. var views = {};
  10823. for (var i = 0; i < arrays.length; i++) {
  10824. stride += sizes[i];
  10825. outSize += arrays[i].length;
  10826. }
  10827. var buffer = new ArrayBuffer(outSize * 4);
  10828. var out = null;
  10829. var littleOffset = 0;
  10830. for (var i = 0; i < arrays.length; i++) {
  10831. var size = sizes[i];
  10832. var array = arrays[i];
  10833. var type = getBufferType(array);
  10834. if (!views[type]) {
  10835. views[type] = new map$1[type](buffer);
  10836. }
  10837. out = views[type];
  10838. for (var j = 0; j < array.length; j++) {
  10839. var indexStart = (j / size | 0) * stride + littleOffset;
  10840. var index = j % size;
  10841. out[indexStart + index] = array[j];
  10842. }
  10843. littleOffset += size;
  10844. }
  10845. return new Float32Array(buffer);
  10846. }
  10847. var byteSizeMap$1 = { 5126: 4, 5123: 2, 5121: 1 };
  10848. var UID$3 = 0;
  10849. var map2 = {
  10850. Float32Array,
  10851. Uint32Array,
  10852. Int32Array,
  10853. Uint8Array,
  10854. Uint16Array
  10855. };
  10856. var Geometry = (
  10857. /** @class */
  10858. (function() {
  10859. function Geometry2(buffers, attributes) {
  10860. if (buffers === void 0) {
  10861. buffers = [];
  10862. }
  10863. if (attributes === void 0) {
  10864. attributes = {};
  10865. }
  10866. this.buffers = buffers;
  10867. this.indexBuffer = null;
  10868. this.attributes = attributes;
  10869. this.glVertexArrayObjects = {};
  10870. this.id = UID$3++;
  10871. this.instanced = false;
  10872. this.instanceCount = 1;
  10873. this.disposeRunner = new Runner("disposeGeometry");
  10874. this.refCount = 0;
  10875. }
  10876. Geometry2.prototype.addAttribute = function(id, buffer, size, normalized, type, stride, start, instance) {
  10877. if (size === void 0) {
  10878. size = 0;
  10879. }
  10880. if (normalized === void 0) {
  10881. normalized = false;
  10882. }
  10883. if (instance === void 0) {
  10884. instance = false;
  10885. }
  10886. if (!buffer) {
  10887. throw new Error("You must pass a buffer when creating an attribute");
  10888. }
  10889. if (!(buffer instanceof Buffer)) {
  10890. if (buffer instanceof Array) {
  10891. buffer = new Float32Array(buffer);
  10892. }
  10893. buffer = new Buffer(buffer);
  10894. }
  10895. var ids = id.split("|");
  10896. if (ids.length > 1) {
  10897. for (var i = 0; i < ids.length; i++) {
  10898. this.addAttribute(ids[i], buffer, size, normalized, type);
  10899. }
  10900. return this;
  10901. }
  10902. var bufferIndex = this.buffers.indexOf(buffer);
  10903. if (bufferIndex === -1) {
  10904. this.buffers.push(buffer);
  10905. bufferIndex = this.buffers.length - 1;
  10906. }
  10907. this.attributes[id] = new Attribute(bufferIndex, size, normalized, type, stride, start, instance);
  10908. this.instanced = this.instanced || instance;
  10909. return this;
  10910. };
  10911. Geometry2.prototype.getAttribute = function(id) {
  10912. return this.attributes[id];
  10913. };
  10914. Geometry2.prototype.getBuffer = function(id) {
  10915. return this.buffers[this.getAttribute(id).buffer];
  10916. };
  10917. Geometry2.prototype.addIndex = function(buffer) {
  10918. if (!(buffer instanceof Buffer)) {
  10919. if (buffer instanceof Array) {
  10920. buffer = new Uint16Array(buffer);
  10921. }
  10922. buffer = new Buffer(buffer);
  10923. }
  10924. buffer.type = BUFFER_TYPE.ELEMENT_ARRAY_BUFFER;
  10925. this.indexBuffer = buffer;
  10926. if (this.buffers.indexOf(buffer) === -1) {
  10927. this.buffers.push(buffer);
  10928. }
  10929. return this;
  10930. };
  10931. Geometry2.prototype.getIndex = function() {
  10932. return this.indexBuffer;
  10933. };
  10934. Geometry2.prototype.interleave = function() {
  10935. if (this.buffers.length === 1 || this.buffers.length === 2 && this.indexBuffer) {
  10936. return this;
  10937. }
  10938. var arrays = [];
  10939. var sizes = [];
  10940. var interleavedBuffer = new Buffer();
  10941. var i;
  10942. for (i in this.attributes) {
  10943. var attribute = this.attributes[i];
  10944. var buffer = this.buffers[attribute.buffer];
  10945. arrays.push(buffer.data);
  10946. sizes.push(attribute.size * byteSizeMap$1[attribute.type] / 4);
  10947. attribute.buffer = 0;
  10948. }
  10949. interleavedBuffer.data = interleaveTypedArrays2(arrays, sizes);
  10950. for (i = 0; i < this.buffers.length; i++) {
  10951. if (this.buffers[i] !== this.indexBuffer) {
  10952. this.buffers[i].destroy();
  10953. }
  10954. }
  10955. this.buffers = [interleavedBuffer];
  10956. if (this.indexBuffer) {
  10957. this.buffers.push(this.indexBuffer);
  10958. }
  10959. return this;
  10960. };
  10961. Geometry2.prototype.getSize = function() {
  10962. for (var i in this.attributes) {
  10963. var attribute = this.attributes[i];
  10964. var buffer = this.buffers[attribute.buffer];
  10965. return buffer.data.length / (attribute.stride / 4 || attribute.size);
  10966. }
  10967. return 0;
  10968. };
  10969. Geometry2.prototype.dispose = function() {
  10970. this.disposeRunner.emit(this, false);
  10971. };
  10972. Geometry2.prototype.destroy = function() {
  10973. this.dispose();
  10974. this.buffers = null;
  10975. this.indexBuffer = null;
  10976. this.attributes = null;
  10977. };
  10978. Geometry2.prototype.clone = function() {
  10979. var geometry = new Geometry2();
  10980. for (var i = 0; i < this.buffers.length; i++) {
  10981. geometry.buffers[i] = new Buffer(this.buffers[i].data.slice(0));
  10982. }
  10983. for (var i in this.attributes) {
  10984. var attrib = this.attributes[i];
  10985. geometry.attributes[i] = new Attribute(attrib.buffer, attrib.size, attrib.normalized, attrib.type, attrib.stride, attrib.start, attrib.instance);
  10986. }
  10987. if (this.indexBuffer) {
  10988. geometry.indexBuffer = geometry.buffers[this.buffers.indexOf(this.indexBuffer)];
  10989. geometry.indexBuffer.type = BUFFER_TYPE.ELEMENT_ARRAY_BUFFER;
  10990. }
  10991. return geometry;
  10992. };
  10993. Geometry2.merge = function(geometries) {
  10994. var geometryOut = new Geometry2();
  10995. var arrays = [];
  10996. var sizes = [];
  10997. var offsets = [];
  10998. var geometry;
  10999. for (var i = 0; i < geometries.length; i++) {
  11000. geometry = geometries[i];
  11001. for (var j = 0; j < geometry.buffers.length; j++) {
  11002. sizes[j] = sizes[j] || 0;
  11003. sizes[j] += geometry.buffers[j].data.length;
  11004. offsets[j] = 0;
  11005. }
  11006. }
  11007. for (var i = 0; i < geometry.buffers.length; i++) {
  11008. arrays[i] = new map2[getBufferType(geometry.buffers[i].data)](sizes[i]);
  11009. geometryOut.buffers[i] = new Buffer(arrays[i]);
  11010. }
  11011. for (var i = 0; i < geometries.length; i++) {
  11012. geometry = geometries[i];
  11013. for (var j = 0; j < geometry.buffers.length; j++) {
  11014. arrays[j].set(geometry.buffers[j].data, offsets[j]);
  11015. offsets[j] += geometry.buffers[j].data.length;
  11016. }
  11017. }
  11018. geometryOut.attributes = geometry.attributes;
  11019. if (geometry.indexBuffer) {
  11020. geometryOut.indexBuffer = geometryOut.buffers[geometry.buffers.indexOf(geometry.indexBuffer)];
  11021. geometryOut.indexBuffer.type = BUFFER_TYPE.ELEMENT_ARRAY_BUFFER;
  11022. var offset = 0;
  11023. var stride = 0;
  11024. var offset2 = 0;
  11025. var bufferIndexToCount = 0;
  11026. for (var i = 0; i < geometry.buffers.length; i++) {
  11027. if (geometry.buffers[i] !== geometry.indexBuffer) {
  11028. bufferIndexToCount = i;
  11029. break;
  11030. }
  11031. }
  11032. for (var i in geometry.attributes) {
  11033. var attribute = geometry.attributes[i];
  11034. if ((attribute.buffer | 0) === bufferIndexToCount) {
  11035. stride += attribute.size * byteSizeMap$1[attribute.type] / 4;
  11036. }
  11037. }
  11038. for (var i = 0; i < geometries.length; i++) {
  11039. var indexBufferData = geometries[i].indexBuffer.data;
  11040. for (var j = 0; j < indexBufferData.length; j++) {
  11041. geometryOut.indexBuffer.data[j + offset2] += offset;
  11042. }
  11043. offset += geometries[i].buffers[bufferIndexToCount].data.length / stride;
  11044. offset2 += indexBufferData.length;
  11045. }
  11046. }
  11047. return geometryOut;
  11048. };
  11049. return Geometry2;
  11050. })()
  11051. );
  11052. var Quad = (
  11053. /** @class */
  11054. (function(_super) {
  11055. __extends2(Quad2, _super);
  11056. function Quad2() {
  11057. var _this = _super.call(this) || this;
  11058. _this.addAttribute("aVertexPosition", new Float32Array([
  11059. 0,
  11060. 0,
  11061. 1,
  11062. 0,
  11063. 1,
  11064. 1,
  11065. 0,
  11066. 1
  11067. ])).addIndex([0, 1, 3, 2]);
  11068. return _this;
  11069. }
  11070. return Quad2;
  11071. })(Geometry)
  11072. );
  11073. var QuadUv = (
  11074. /** @class */
  11075. (function(_super) {
  11076. __extends2(QuadUv2, _super);
  11077. function QuadUv2() {
  11078. var _this = _super.call(this) || this;
  11079. _this.vertices = new Float32Array([
  11080. -1,
  11081. -1,
  11082. 1,
  11083. -1,
  11084. 1,
  11085. 1,
  11086. -1,
  11087. 1
  11088. ]);
  11089. _this.uvs = new Float32Array([
  11090. 0,
  11091. 0,
  11092. 1,
  11093. 0,
  11094. 1,
  11095. 1,
  11096. 0,
  11097. 1
  11098. ]);
  11099. _this.vertexBuffer = new Buffer(_this.vertices);
  11100. _this.uvBuffer = new Buffer(_this.uvs);
  11101. _this.addAttribute("aVertexPosition", _this.vertexBuffer).addAttribute("aTextureCoord", _this.uvBuffer).addIndex([0, 1, 2, 0, 2, 3]);
  11102. return _this;
  11103. }
  11104. QuadUv2.prototype.map = function(targetTextureFrame, destinationFrame) {
  11105. var x = 0;
  11106. var y = 0;
  11107. this.uvs[0] = x;
  11108. this.uvs[1] = y;
  11109. this.uvs[2] = x + destinationFrame.width / targetTextureFrame.width;
  11110. this.uvs[3] = y;
  11111. this.uvs[4] = x + destinationFrame.width / targetTextureFrame.width;
  11112. this.uvs[5] = y + destinationFrame.height / targetTextureFrame.height;
  11113. this.uvs[6] = x;
  11114. this.uvs[7] = y + destinationFrame.height / targetTextureFrame.height;
  11115. x = destinationFrame.x;
  11116. y = destinationFrame.y;
  11117. this.vertices[0] = x;
  11118. this.vertices[1] = y;
  11119. this.vertices[2] = x + destinationFrame.width;
  11120. this.vertices[3] = y;
  11121. this.vertices[4] = x + destinationFrame.width;
  11122. this.vertices[5] = y + destinationFrame.height;
  11123. this.vertices[6] = x;
  11124. this.vertices[7] = y + destinationFrame.height;
  11125. this.invalidate();
  11126. return this;
  11127. };
  11128. QuadUv2.prototype.invalidate = function() {
  11129. this.vertexBuffer._updateID++;
  11130. this.uvBuffer._updateID++;
  11131. return this;
  11132. };
  11133. return QuadUv2;
  11134. })(Geometry)
  11135. );
  11136. var UID$2 = 0;
  11137. var UniformGroup = (
  11138. /** @class */
  11139. (function() {
  11140. function UniformGroup2(uniforms, isStatic, isUbo) {
  11141. this.group = true;
  11142. this.syncUniforms = {};
  11143. this.dirtyId = 0;
  11144. this.id = UID$2++;
  11145. this.static = !!isStatic;
  11146. this.ubo = !!isUbo;
  11147. if (uniforms instanceof Buffer) {
  11148. this.buffer = uniforms;
  11149. this.buffer.type = BUFFER_TYPE.UNIFORM_BUFFER;
  11150. this.autoManage = false;
  11151. this.ubo = true;
  11152. } else {
  11153. this.uniforms = uniforms;
  11154. if (this.ubo) {
  11155. this.buffer = new Buffer(new Float32Array(1));
  11156. this.buffer.type = BUFFER_TYPE.UNIFORM_BUFFER;
  11157. this.autoManage = true;
  11158. }
  11159. }
  11160. }
  11161. UniformGroup2.prototype.update = function() {
  11162. this.dirtyId++;
  11163. if (!this.autoManage && this.buffer) {
  11164. this.buffer.update();
  11165. }
  11166. };
  11167. UniformGroup2.prototype.add = function(name, uniforms, _static) {
  11168. if (!this.ubo) {
  11169. this.uniforms[name] = new UniformGroup2(uniforms, _static);
  11170. } else {
  11171. throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them");
  11172. }
  11173. };
  11174. UniformGroup2.from = function(uniforms, _static, _ubo) {
  11175. return new UniformGroup2(uniforms, _static, _ubo);
  11176. };
  11177. UniformGroup2.uboFrom = function(uniforms, _static) {
  11178. return new UniformGroup2(uniforms, _static !== null && _static !== void 0 ? _static : true, true);
  11179. };
  11180. return UniformGroup2;
  11181. })()
  11182. );
  11183. var FilterState = (
  11184. /** @class */
  11185. (function() {
  11186. function FilterState2() {
  11187. this.renderTexture = null;
  11188. this.target = null;
  11189. this.legacy = false;
  11190. this.resolution = 1;
  11191. this.multisample = MSAA_QUALITY.NONE;
  11192. this.sourceFrame = new Rectangle();
  11193. this.destinationFrame = new Rectangle();
  11194. this.bindingSourceFrame = new Rectangle();
  11195. this.bindingDestinationFrame = new Rectangle();
  11196. this.filters = [];
  11197. this.transform = null;
  11198. }
  11199. FilterState2.prototype.clear = function() {
  11200. this.target = null;
  11201. this.filters = null;
  11202. this.renderTexture = null;
  11203. };
  11204. return FilterState2;
  11205. })()
  11206. );
  11207. var tempPoints2 = [new Point(), new Point(), new Point(), new Point()];
  11208. var tempMatrix$2 = new Matrix();
  11209. var FilterSystem = (
  11210. /** @class */
  11211. (function() {
  11212. function FilterSystem2(renderer) {
  11213. this.renderer = renderer;
  11214. this.defaultFilterStack = [{}];
  11215. this.texturePool = new RenderTexturePool();
  11216. this.texturePool.setScreenSize(renderer.view);
  11217. this.statePool = [];
  11218. this.quad = new Quad();
  11219. this.quadUv = new QuadUv();
  11220. this.tempRect = new Rectangle();
  11221. this.activeState = {};
  11222. this.globalUniforms = new UniformGroup({
  11223. outputFrame: new Rectangle(),
  11224. inputSize: new Float32Array(4),
  11225. inputPixel: new Float32Array(4),
  11226. inputClamp: new Float32Array(4),
  11227. resolution: 1,
  11228. // legacy variables
  11229. filterArea: new Float32Array(4),
  11230. filterClamp: new Float32Array(4)
  11231. }, true);
  11232. this.forceClear = false;
  11233. this.useMaxPadding = false;
  11234. }
  11235. FilterSystem2.prototype.push = function(target, filters) {
  11236. var _a, _b;
  11237. var renderer = this.renderer;
  11238. var filterStack = this.defaultFilterStack;
  11239. var state = this.statePool.pop() || new FilterState();
  11240. var renderTextureSystem = this.renderer.renderTexture;
  11241. var resolution = filters[0].resolution;
  11242. var multisample = filters[0].multisample;
  11243. var padding = filters[0].padding;
  11244. var autoFit = filters[0].autoFit;
  11245. var legacy = (_a = filters[0].legacy) !== null && _a !== void 0 ? _a : true;
  11246. for (var i = 1; i < filters.length; i++) {
  11247. var filter = filters[i];
  11248. resolution = Math.min(resolution, filter.resolution);
  11249. multisample = Math.min(multisample, filter.multisample);
  11250. padding = this.useMaxPadding ? Math.max(padding, filter.padding) : padding + filter.padding;
  11251. autoFit = autoFit && filter.autoFit;
  11252. legacy = legacy || ((_b = filter.legacy) !== null && _b !== void 0 ? _b : true);
  11253. }
  11254. if (filterStack.length === 1) {
  11255. this.defaultFilterStack[0].renderTexture = renderTextureSystem.current;
  11256. }
  11257. filterStack.push(state);
  11258. state.resolution = resolution;
  11259. state.multisample = multisample;
  11260. state.legacy = legacy;
  11261. state.target = target;
  11262. state.sourceFrame.copyFrom(target.filterArea || target.getBounds(true));
  11263. state.sourceFrame.pad(padding);
  11264. var sourceFrameProjected = this.tempRect.copyFrom(renderTextureSystem.sourceFrame);
  11265. if (renderer.projection.transform) {
  11266. this.transformAABB(tempMatrix$2.copyFrom(renderer.projection.transform).invert(), sourceFrameProjected);
  11267. }
  11268. if (autoFit) {
  11269. state.sourceFrame.fit(sourceFrameProjected);
  11270. if (state.sourceFrame.width <= 0 || state.sourceFrame.height <= 0) {
  11271. state.sourceFrame.width = 0;
  11272. state.sourceFrame.height = 0;
  11273. }
  11274. } else if (!state.sourceFrame.intersects(sourceFrameProjected)) {
  11275. state.sourceFrame.width = 0;
  11276. state.sourceFrame.height = 0;
  11277. }
  11278. this.roundFrame(state.sourceFrame, renderTextureSystem.current ? renderTextureSystem.current.resolution : renderer.resolution, renderTextureSystem.sourceFrame, renderTextureSystem.destinationFrame, renderer.projection.transform);
  11279. state.renderTexture = this.getOptimalFilterTexture(state.sourceFrame.width, state.sourceFrame.height, resolution, multisample);
  11280. state.filters = filters;
  11281. state.destinationFrame.width = state.renderTexture.width;
  11282. state.destinationFrame.height = state.renderTexture.height;
  11283. var destinationFrame = this.tempRect;
  11284. destinationFrame.x = 0;
  11285. destinationFrame.y = 0;
  11286. destinationFrame.width = state.sourceFrame.width;
  11287. destinationFrame.height = state.sourceFrame.height;
  11288. state.renderTexture.filterFrame = state.sourceFrame;
  11289. state.bindingSourceFrame.copyFrom(renderTextureSystem.sourceFrame);
  11290. state.bindingDestinationFrame.copyFrom(renderTextureSystem.destinationFrame);
  11291. state.transform = renderer.projection.transform;
  11292. renderer.projection.transform = null;
  11293. renderTextureSystem.bind(state.renderTexture, state.sourceFrame, destinationFrame);
  11294. renderer.framebuffer.clear(0, 0, 0, 0);
  11295. };
  11296. FilterSystem2.prototype.pop = function() {
  11297. var filterStack = this.defaultFilterStack;
  11298. var state = filterStack.pop();
  11299. var filters = state.filters;
  11300. this.activeState = state;
  11301. var globalUniforms = this.globalUniforms.uniforms;
  11302. globalUniforms.outputFrame = state.sourceFrame;
  11303. globalUniforms.resolution = state.resolution;
  11304. var inputSize = globalUniforms.inputSize;
  11305. var inputPixel = globalUniforms.inputPixel;
  11306. var inputClamp = globalUniforms.inputClamp;
  11307. inputSize[0] = state.destinationFrame.width;
  11308. inputSize[1] = state.destinationFrame.height;
  11309. inputSize[2] = 1 / inputSize[0];
  11310. inputSize[3] = 1 / inputSize[1];
  11311. inputPixel[0] = Math.round(inputSize[0] * state.resolution);
  11312. inputPixel[1] = Math.round(inputSize[1] * state.resolution);
  11313. inputPixel[2] = 1 / inputPixel[0];
  11314. inputPixel[3] = 1 / inputPixel[1];
  11315. inputClamp[0] = 0.5 * inputPixel[2];
  11316. inputClamp[1] = 0.5 * inputPixel[3];
  11317. inputClamp[2] = state.sourceFrame.width * inputSize[2] - 0.5 * inputPixel[2];
  11318. inputClamp[3] = state.sourceFrame.height * inputSize[3] - 0.5 * inputPixel[3];
  11319. if (state.legacy) {
  11320. var filterArea = globalUniforms.filterArea;
  11321. filterArea[0] = state.destinationFrame.width;
  11322. filterArea[1] = state.destinationFrame.height;
  11323. filterArea[2] = state.sourceFrame.x;
  11324. filterArea[3] = state.sourceFrame.y;
  11325. globalUniforms.filterClamp = globalUniforms.inputClamp;
  11326. }
  11327. this.globalUniforms.update();
  11328. var lastState = filterStack[filterStack.length - 1];
  11329. this.renderer.framebuffer.blit();
  11330. if (filters.length === 1) {
  11331. filters[0].apply(this, state.renderTexture, lastState.renderTexture, CLEAR_MODES.BLEND, state);
  11332. this.returnFilterTexture(state.renderTexture);
  11333. } else {
  11334. var flip = state.renderTexture;
  11335. var flop = this.getOptimalFilterTexture(flip.width, flip.height, state.resolution);
  11336. flop.filterFrame = flip.filterFrame;
  11337. var i = 0;
  11338. for (i = 0; i < filters.length - 1; ++i) {
  11339. if (i === 1 && state.multisample > 1) {
  11340. flop = this.getOptimalFilterTexture(flip.width, flip.height, state.resolution);
  11341. flop.filterFrame = flip.filterFrame;
  11342. }
  11343. filters[i].apply(this, flip, flop, CLEAR_MODES.CLEAR, state);
  11344. var t = flip;
  11345. flip = flop;
  11346. flop = t;
  11347. }
  11348. filters[i].apply(this, flip, lastState.renderTexture, CLEAR_MODES.BLEND, state);
  11349. if (i > 1 && state.multisample > 1) {
  11350. this.returnFilterTexture(state.renderTexture);
  11351. }
  11352. this.returnFilterTexture(flip);
  11353. this.returnFilterTexture(flop);
  11354. }
  11355. state.clear();
  11356. this.statePool.push(state);
  11357. };
  11358. FilterSystem2.prototype.bindAndClear = function(filterTexture, clearMode) {
  11359. if (clearMode === void 0) {
  11360. clearMode = CLEAR_MODES.CLEAR;
  11361. }
  11362. var _a = this.renderer, renderTextureSystem = _a.renderTexture, stateSystem = _a.state;
  11363. if (filterTexture === this.defaultFilterStack[this.defaultFilterStack.length - 1].renderTexture) {
  11364. this.renderer.projection.transform = this.activeState.transform;
  11365. } else {
  11366. this.renderer.projection.transform = null;
  11367. }
  11368. if (filterTexture && filterTexture.filterFrame) {
  11369. var destinationFrame = this.tempRect;
  11370. destinationFrame.x = 0;
  11371. destinationFrame.y = 0;
  11372. destinationFrame.width = filterTexture.filterFrame.width;
  11373. destinationFrame.height = filterTexture.filterFrame.height;
  11374. renderTextureSystem.bind(filterTexture, filterTexture.filterFrame, destinationFrame);
  11375. } else if (filterTexture !== this.defaultFilterStack[this.defaultFilterStack.length - 1].renderTexture) {
  11376. renderTextureSystem.bind(filterTexture);
  11377. } else {
  11378. this.renderer.renderTexture.bind(filterTexture, this.activeState.bindingSourceFrame, this.activeState.bindingDestinationFrame);
  11379. }
  11380. var autoClear = stateSystem.stateId & 1 || this.forceClear;
  11381. if (clearMode === CLEAR_MODES.CLEAR || clearMode === CLEAR_MODES.BLIT && autoClear) {
  11382. this.renderer.framebuffer.clear(0, 0, 0, 0);
  11383. }
  11384. };
  11385. FilterSystem2.prototype.applyFilter = function(filter, input, output, clearMode) {
  11386. var renderer = this.renderer;
  11387. renderer.state.set(filter.state);
  11388. this.bindAndClear(output, clearMode);
  11389. filter.uniforms.uSampler = input;
  11390. filter.uniforms.filterGlobals = this.globalUniforms;
  11391. renderer.shader.bind(filter);
  11392. filter.legacy = !!filter.program.attributeData.aTextureCoord;
  11393. if (filter.legacy) {
  11394. this.quadUv.map(input._frame, input.filterFrame);
  11395. renderer.geometry.bind(this.quadUv);
  11396. renderer.geometry.draw(DRAW_MODES.TRIANGLES);
  11397. } else {
  11398. renderer.geometry.bind(this.quad);
  11399. renderer.geometry.draw(DRAW_MODES.TRIANGLE_STRIP);
  11400. }
  11401. };
  11402. FilterSystem2.prototype.calculateSpriteMatrix = function(outputMatrix, sprite) {
  11403. var _a = this.activeState, sourceFrame = _a.sourceFrame, destinationFrame = _a.destinationFrame;
  11404. var orig = sprite._texture.orig;
  11405. var mappedMatrix = outputMatrix.set(destinationFrame.width, 0, 0, destinationFrame.height, sourceFrame.x, sourceFrame.y);
  11406. var worldTransform = sprite.worldTransform.copyTo(Matrix.TEMP_MATRIX);
  11407. worldTransform.invert();
  11408. mappedMatrix.prepend(worldTransform);
  11409. mappedMatrix.scale(1 / orig.width, 1 / orig.height);
  11410. mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y);
  11411. return mappedMatrix;
  11412. };
  11413. FilterSystem2.prototype.destroy = function() {
  11414. this.renderer = null;
  11415. this.texturePool.clear(false);
  11416. };
  11417. FilterSystem2.prototype.getOptimalFilterTexture = function(minWidth, minHeight, resolution, multisample) {
  11418. if (resolution === void 0) {
  11419. resolution = 1;
  11420. }
  11421. if (multisample === void 0) {
  11422. multisample = MSAA_QUALITY.NONE;
  11423. }
  11424. return this.texturePool.getOptimalTexture(minWidth, minHeight, resolution, multisample);
  11425. };
  11426. FilterSystem2.prototype.getFilterTexture = function(input, resolution, multisample) {
  11427. if (typeof input === "number") {
  11428. var swap = input;
  11429. input = resolution;
  11430. resolution = swap;
  11431. }
  11432. input = input || this.activeState.renderTexture;
  11433. var filterTexture = this.texturePool.getOptimalTexture(input.width, input.height, resolution || input.resolution, multisample || MSAA_QUALITY.NONE);
  11434. filterTexture.filterFrame = input.filterFrame;
  11435. return filterTexture;
  11436. };
  11437. FilterSystem2.prototype.returnFilterTexture = function(renderTexture) {
  11438. this.texturePool.returnTexture(renderTexture);
  11439. };
  11440. FilterSystem2.prototype.emptyPool = function() {
  11441. this.texturePool.clear(true);
  11442. };
  11443. FilterSystem2.prototype.resize = function() {
  11444. this.texturePool.setScreenSize(this.renderer.view);
  11445. };
  11446. FilterSystem2.prototype.transformAABB = function(matrix, rect) {
  11447. var lt = tempPoints2[0];
  11448. var lb = tempPoints2[1];
  11449. var rt = tempPoints2[2];
  11450. var rb = tempPoints2[3];
  11451. lt.set(rect.left, rect.top);
  11452. lb.set(rect.left, rect.bottom);
  11453. rt.set(rect.right, rect.top);
  11454. rb.set(rect.right, rect.bottom);
  11455. matrix.apply(lt, lt);
  11456. matrix.apply(lb, lb);
  11457. matrix.apply(rt, rt);
  11458. matrix.apply(rb, rb);
  11459. var x0 = Math.min(lt.x, lb.x, rt.x, rb.x);
  11460. var y0 = Math.min(lt.y, lb.y, rt.y, rb.y);
  11461. var x1 = Math.max(lt.x, lb.x, rt.x, rb.x);
  11462. var y1 = Math.max(lt.y, lb.y, rt.y, rb.y);
  11463. rect.x = x0;
  11464. rect.y = y0;
  11465. rect.width = x1 - x0;
  11466. rect.height = y1 - y0;
  11467. };
  11468. FilterSystem2.prototype.roundFrame = function(frame, resolution, bindingSourceFrame, bindingDestinationFrame, transform) {
  11469. if (frame.width <= 0 || frame.height <= 0 || bindingSourceFrame.width <= 0 || bindingSourceFrame.height <= 0) {
  11470. return;
  11471. }
  11472. if (transform) {
  11473. var a = transform.a, b = transform.b, c = transform.c, d = transform.d;
  11474. if ((Math.abs(b) > 1e-4 || Math.abs(c) > 1e-4) && (Math.abs(a) > 1e-4 || Math.abs(d) > 1e-4)) {
  11475. return;
  11476. }
  11477. }
  11478. transform = transform ? tempMatrix$2.copyFrom(transform) : tempMatrix$2.identity();
  11479. transform.translate(-bindingSourceFrame.x, -bindingSourceFrame.y).scale(bindingDestinationFrame.width / bindingSourceFrame.width, bindingDestinationFrame.height / bindingSourceFrame.height).translate(bindingDestinationFrame.x, bindingDestinationFrame.y);
  11480. this.transformAABB(transform, frame);
  11481. frame.ceil(resolution);
  11482. this.transformAABB(transform.invert(), frame);
  11483. };
  11484. return FilterSystem2;
  11485. })()
  11486. );
  11487. var ObjectRenderer = (
  11488. /** @class */
  11489. (function() {
  11490. function ObjectRenderer2(renderer) {
  11491. this.renderer = renderer;
  11492. }
  11493. ObjectRenderer2.prototype.flush = function() {
  11494. };
  11495. ObjectRenderer2.prototype.destroy = function() {
  11496. this.renderer = null;
  11497. };
  11498. ObjectRenderer2.prototype.start = function() {
  11499. };
  11500. ObjectRenderer2.prototype.stop = function() {
  11501. this.flush();
  11502. };
  11503. ObjectRenderer2.prototype.render = function(_object) {
  11504. };
  11505. return ObjectRenderer2;
  11506. })()
  11507. );
  11508. var BatchSystem = (
  11509. /** @class */
  11510. (function() {
  11511. function BatchSystem2(renderer) {
  11512. this.renderer = renderer;
  11513. this.emptyRenderer = new ObjectRenderer(renderer);
  11514. this.currentRenderer = this.emptyRenderer;
  11515. }
  11516. BatchSystem2.prototype.setObjectRenderer = function(objectRenderer) {
  11517. if (this.currentRenderer === objectRenderer) {
  11518. return;
  11519. }
  11520. this.currentRenderer.stop();
  11521. this.currentRenderer = objectRenderer;
  11522. this.currentRenderer.start();
  11523. };
  11524. BatchSystem2.prototype.flush = function() {
  11525. this.setObjectRenderer(this.emptyRenderer);
  11526. };
  11527. BatchSystem2.prototype.reset = function() {
  11528. this.setObjectRenderer(this.emptyRenderer);
  11529. };
  11530. BatchSystem2.prototype.copyBoundTextures = function(arr, maxTextures) {
  11531. var boundTextures = this.renderer.texture.boundTextures;
  11532. for (var i = maxTextures - 1; i >= 0; --i) {
  11533. arr[i] = boundTextures[i] || null;
  11534. if (arr[i]) {
  11535. arr[i]._batchLocation = i;
  11536. }
  11537. }
  11538. };
  11539. BatchSystem2.prototype.boundArray = function(texArray, boundTextures, batchId, maxTextures) {
  11540. var elements = texArray.elements, ids = texArray.ids, count = texArray.count;
  11541. var j = 0;
  11542. for (var i = 0; i < count; i++) {
  11543. var tex = elements[i];
  11544. var loc = tex._batchLocation;
  11545. if (loc >= 0 && loc < maxTextures && boundTextures[loc] === tex) {
  11546. ids[i] = loc;
  11547. continue;
  11548. }
  11549. while (j < maxTextures) {
  11550. var bound = boundTextures[j];
  11551. if (bound && bound._batchEnabled === batchId && bound._batchLocation === j) {
  11552. j++;
  11553. continue;
  11554. }
  11555. ids[i] = j;
  11556. tex._batchLocation = j;
  11557. boundTextures[j] = tex;
  11558. break;
  11559. }
  11560. }
  11561. };
  11562. BatchSystem2.prototype.destroy = function() {
  11563. this.renderer = null;
  11564. };
  11565. return BatchSystem2;
  11566. })()
  11567. );
  11568. var CONTEXT_UID_COUNTER = 0;
  11569. var ContextSystem = (
  11570. /** @class */
  11571. (function() {
  11572. function ContextSystem2(renderer) {
  11573. this.renderer = renderer;
  11574. this.webGLVersion = 1;
  11575. this.extensions = {};
  11576. this.supports = {
  11577. uint32Indices: false
  11578. };
  11579. this.handleContextLost = this.handleContextLost.bind(this);
  11580. this.handleContextRestored = this.handleContextRestored.bind(this);
  11581. renderer.view.addEventListener("webglcontextlost", this.handleContextLost, false);
  11582. renderer.view.addEventListener("webglcontextrestored", this.handleContextRestored, false);
  11583. }
  11584. Object.defineProperty(ContextSystem2.prototype, "isLost", {
  11585. /**
  11586. * `true` if the context is lost
  11587. * @readonly
  11588. */
  11589. get: function() {
  11590. return !this.gl || this.gl.isContextLost();
  11591. },
  11592. enumerable: false,
  11593. configurable: true
  11594. });
  11595. ContextSystem2.prototype.contextChange = function(gl) {
  11596. this.gl = gl;
  11597. this.renderer.gl = gl;
  11598. this.renderer.CONTEXT_UID = CONTEXT_UID_COUNTER++;
  11599. };
  11600. ContextSystem2.prototype.initFromContext = function(gl) {
  11601. this.gl = gl;
  11602. this.validateContext(gl);
  11603. this.renderer.gl = gl;
  11604. this.renderer.CONTEXT_UID = CONTEXT_UID_COUNTER++;
  11605. this.renderer.runners.contextChange.emit(gl);
  11606. };
  11607. ContextSystem2.prototype.initFromOptions = function(options) {
  11608. var gl = this.createContext(this.renderer.view, options);
  11609. this.initFromContext(gl);
  11610. };
  11611. ContextSystem2.prototype.createContext = function(canvas, options) {
  11612. var gl;
  11613. if (settings.PREFER_ENV >= ENV.WEBGL2) {
  11614. gl = canvas.getContext("webgl2", options);
  11615. }
  11616. if (gl) {
  11617. this.webGLVersion = 2;
  11618. } else {
  11619. this.webGLVersion = 1;
  11620. gl = canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options);
  11621. if (!gl) {
  11622. throw new Error("This browser does not support WebGL. Try using the canvas renderer");
  11623. }
  11624. }
  11625. this.gl = gl;
  11626. this.getExtensions();
  11627. return this.gl;
  11628. };
  11629. ContextSystem2.prototype.getExtensions = function() {
  11630. var gl = this.gl;
  11631. var common = {
  11632. loseContext: gl.getExtension("WEBGL_lose_context"),
  11633. anisotropicFiltering: gl.getExtension("EXT_texture_filter_anisotropic"),
  11634. floatTextureLinear: gl.getExtension("OES_texture_float_linear"),
  11635. s3tc: gl.getExtension("WEBGL_compressed_texture_s3tc"),
  11636. s3tc_sRGB: gl.getExtension("WEBGL_compressed_texture_s3tc_srgb"),
  11637. etc: gl.getExtension("WEBGL_compressed_texture_etc"),
  11638. etc1: gl.getExtension("WEBGL_compressed_texture_etc1"),
  11639. pvrtc: gl.getExtension("WEBGL_compressed_texture_pvrtc") || gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
  11640. atc: gl.getExtension("WEBGL_compressed_texture_atc"),
  11641. astc: gl.getExtension("WEBGL_compressed_texture_astc")
  11642. };
  11643. if (this.webGLVersion === 1) {
  11644. Object.assign(this.extensions, common, {
  11645. drawBuffers: gl.getExtension("WEBGL_draw_buffers"),
  11646. depthTexture: gl.getExtension("WEBGL_depth_texture"),
  11647. vertexArrayObject: gl.getExtension("OES_vertex_array_object") || gl.getExtension("MOZ_OES_vertex_array_object") || gl.getExtension("WEBKIT_OES_vertex_array_object"),
  11648. uint32ElementIndex: gl.getExtension("OES_element_index_uint"),
  11649. // Floats and half-floats
  11650. floatTexture: gl.getExtension("OES_texture_float"),
  11651. floatTextureLinear: gl.getExtension("OES_texture_float_linear"),
  11652. textureHalfFloat: gl.getExtension("OES_texture_half_float"),
  11653. textureHalfFloatLinear: gl.getExtension("OES_texture_half_float_linear")
  11654. });
  11655. } else if (this.webGLVersion === 2) {
  11656. Object.assign(this.extensions, common, {
  11657. // Floats and half-floats
  11658. colorBufferFloat: gl.getExtension("EXT_color_buffer_float")
  11659. });
  11660. }
  11661. };
  11662. ContextSystem2.prototype.handleContextLost = function(event) {
  11663. var _this = this;
  11664. event.preventDefault();
  11665. setTimeout(function() {
  11666. if (_this.gl.isContextLost() && _this.extensions.loseContext) {
  11667. _this.extensions.loseContext.restoreContext();
  11668. }
  11669. }, 0);
  11670. };
  11671. ContextSystem2.prototype.handleContextRestored = function() {
  11672. this.renderer.runners.contextChange.emit(this.gl);
  11673. };
  11674. ContextSystem2.prototype.destroy = function() {
  11675. var view = this.renderer.view;
  11676. this.renderer = null;
  11677. view.removeEventListener("webglcontextlost", this.handleContextLost);
  11678. view.removeEventListener("webglcontextrestored", this.handleContextRestored);
  11679. this.gl.useProgram(null);
  11680. if (this.extensions.loseContext) {
  11681. this.extensions.loseContext.loseContext();
  11682. }
  11683. };
  11684. ContextSystem2.prototype.postrender = function() {
  11685. if (this.renderer.renderingToScreen) {
  11686. this.gl.flush();
  11687. }
  11688. };
  11689. ContextSystem2.prototype.validateContext = function(gl) {
  11690. var attributes = gl.getContextAttributes();
  11691. var isWebGl2 = "WebGL2RenderingContext" in globalThis && gl instanceof globalThis.WebGL2RenderingContext;
  11692. if (isWebGl2) {
  11693. this.webGLVersion = 2;
  11694. }
  11695. if (attributes && !attributes.stencil) {
  11696. console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");
  11697. }
  11698. var hasuint32 = isWebGl2 || !!gl.getExtension("OES_element_index_uint");
  11699. this.supports.uint32Indices = hasuint32;
  11700. if (!hasuint32) {
  11701. console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly");
  11702. }
  11703. };
  11704. return ContextSystem2;
  11705. })()
  11706. );
  11707. var GLFramebuffer = (
  11708. /** @class */
  11709. /* @__PURE__ */ (function() {
  11710. function GLFramebuffer2(framebuffer) {
  11711. this.framebuffer = framebuffer;
  11712. this.stencil = null;
  11713. this.dirtyId = -1;
  11714. this.dirtyFormat = -1;
  11715. this.dirtySize = -1;
  11716. this.multisample = MSAA_QUALITY.NONE;
  11717. this.msaaBuffer = null;
  11718. this.blitFramebuffer = null;
  11719. this.mipLevel = 0;
  11720. }
  11721. return GLFramebuffer2;
  11722. })()
  11723. );
  11724. var tempRectangle = new Rectangle();
  11725. var FramebufferSystem = (
  11726. /** @class */
  11727. (function() {
  11728. function FramebufferSystem2(renderer) {
  11729. this.renderer = renderer;
  11730. this.managedFramebuffers = [];
  11731. this.unknownFramebuffer = new Framebuffer(10, 10);
  11732. this.msaaSamples = null;
  11733. }
  11734. FramebufferSystem2.prototype.contextChange = function() {
  11735. this.disposeAll(true);
  11736. var gl = this.gl = this.renderer.gl;
  11737. this.CONTEXT_UID = this.renderer.CONTEXT_UID;
  11738. this.current = this.unknownFramebuffer;
  11739. this.viewport = new Rectangle();
  11740. this.hasMRT = true;
  11741. this.writeDepthTexture = true;
  11742. if (this.renderer.context.webGLVersion === 1) {
  11743. var nativeDrawBuffersExtension_1 = this.renderer.context.extensions.drawBuffers;
  11744. var nativeDepthTextureExtension = this.renderer.context.extensions.depthTexture;
  11745. if (settings.PREFER_ENV === ENV.WEBGL_LEGACY) {
  11746. nativeDrawBuffersExtension_1 = null;
  11747. nativeDepthTextureExtension = null;
  11748. }
  11749. if (nativeDrawBuffersExtension_1) {
  11750. gl.drawBuffers = function(activeTextures) {
  11751. return nativeDrawBuffersExtension_1.drawBuffersWEBGL(activeTextures);
  11752. };
  11753. } else {
  11754. this.hasMRT = false;
  11755. gl.drawBuffers = function() {
  11756. };
  11757. }
  11758. if (!nativeDepthTextureExtension) {
  11759. this.writeDepthTexture = false;
  11760. }
  11761. } else {
  11762. this.msaaSamples = gl.getInternalformatParameter(gl.RENDERBUFFER, gl.RGBA8, gl.SAMPLES);
  11763. }
  11764. };
  11765. FramebufferSystem2.prototype.bind = function(framebuffer, frame, mipLevel) {
  11766. if (mipLevel === void 0) {
  11767. mipLevel = 0;
  11768. }
  11769. var gl = this.gl;
  11770. if (framebuffer) {
  11771. var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID] || this.initFramebuffer(framebuffer);
  11772. if (this.current !== framebuffer) {
  11773. this.current = framebuffer;
  11774. gl.bindFramebuffer(gl.FRAMEBUFFER, fbo.framebuffer);
  11775. }
  11776. if (fbo.mipLevel !== mipLevel) {
  11777. framebuffer.dirtyId++;
  11778. framebuffer.dirtyFormat++;
  11779. fbo.mipLevel = mipLevel;
  11780. }
  11781. if (fbo.dirtyId !== framebuffer.dirtyId) {
  11782. fbo.dirtyId = framebuffer.dirtyId;
  11783. if (fbo.dirtyFormat !== framebuffer.dirtyFormat) {
  11784. fbo.dirtyFormat = framebuffer.dirtyFormat;
  11785. fbo.dirtySize = framebuffer.dirtySize;
  11786. this.updateFramebuffer(framebuffer, mipLevel);
  11787. } else if (fbo.dirtySize !== framebuffer.dirtySize) {
  11788. fbo.dirtySize = framebuffer.dirtySize;
  11789. this.resizeFramebuffer(framebuffer);
  11790. }
  11791. }
  11792. for (var i = 0; i < framebuffer.colorTextures.length; i++) {
  11793. var tex = framebuffer.colorTextures[i];
  11794. this.renderer.texture.unbind(tex.parentTextureArray || tex);
  11795. }
  11796. if (framebuffer.depthTexture) {
  11797. this.renderer.texture.unbind(framebuffer.depthTexture);
  11798. }
  11799. if (frame) {
  11800. var mipWidth = frame.width >> mipLevel;
  11801. var mipHeight = frame.height >> mipLevel;
  11802. var scale = mipWidth / frame.width;
  11803. this.setViewport(frame.x * scale, frame.y * scale, mipWidth, mipHeight);
  11804. } else {
  11805. var mipWidth = framebuffer.width >> mipLevel;
  11806. var mipHeight = framebuffer.height >> mipLevel;
  11807. this.setViewport(0, 0, mipWidth, mipHeight);
  11808. }
  11809. } else {
  11810. if (this.current) {
  11811. this.current = null;
  11812. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  11813. }
  11814. if (frame) {
  11815. this.setViewport(frame.x, frame.y, frame.width, frame.height);
  11816. } else {
  11817. this.setViewport(0, 0, this.renderer.width, this.renderer.height);
  11818. }
  11819. }
  11820. };
  11821. FramebufferSystem2.prototype.setViewport = function(x, y, width, height) {
  11822. var v = this.viewport;
  11823. x = Math.round(x);
  11824. y = Math.round(y);
  11825. width = Math.round(width);
  11826. height = Math.round(height);
  11827. if (v.width !== width || v.height !== height || v.x !== x || v.y !== y) {
  11828. v.x = x;
  11829. v.y = y;
  11830. v.width = width;
  11831. v.height = height;
  11832. this.gl.viewport(x, y, width, height);
  11833. }
  11834. };
  11835. Object.defineProperty(FramebufferSystem2.prototype, "size", {
  11836. /**
  11837. * Get the size of the current width and height. Returns object with `width` and `height` values.
  11838. * @readonly
  11839. */
  11840. get: function() {
  11841. if (this.current) {
  11842. return { x: 0, y: 0, width: this.current.width, height: this.current.height };
  11843. }
  11844. return { x: 0, y: 0, width: this.renderer.width, height: this.renderer.height };
  11845. },
  11846. enumerable: false,
  11847. configurable: true
  11848. });
  11849. FramebufferSystem2.prototype.clear = function(r, g, b, a, mask) {
  11850. if (mask === void 0) {
  11851. mask = BUFFER_BITS.COLOR | BUFFER_BITS.DEPTH;
  11852. }
  11853. var gl = this.gl;
  11854. gl.clearColor(r, g, b, a);
  11855. gl.clear(mask);
  11856. };
  11857. FramebufferSystem2.prototype.initFramebuffer = function(framebuffer) {
  11858. var gl = this.gl;
  11859. var fbo = new GLFramebuffer(gl.createFramebuffer());
  11860. fbo.multisample = this.detectSamples(framebuffer.multisample);
  11861. framebuffer.glFramebuffers[this.CONTEXT_UID] = fbo;
  11862. this.managedFramebuffers.push(framebuffer);
  11863. framebuffer.disposeRunner.add(this);
  11864. return fbo;
  11865. };
  11866. FramebufferSystem2.prototype.resizeFramebuffer = function(framebuffer) {
  11867. var gl = this.gl;
  11868. var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID];
  11869. if (fbo.msaaBuffer) {
  11870. gl.bindRenderbuffer(gl.RENDERBUFFER, fbo.msaaBuffer);
  11871. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, fbo.multisample, gl.RGBA8, framebuffer.width, framebuffer.height);
  11872. }
  11873. if (fbo.stencil) {
  11874. gl.bindRenderbuffer(gl.RENDERBUFFER, fbo.stencil);
  11875. if (fbo.msaaBuffer) {
  11876. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, fbo.multisample, gl.DEPTH24_STENCIL8, framebuffer.width, framebuffer.height);
  11877. } else {
  11878. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, framebuffer.width, framebuffer.height);
  11879. }
  11880. }
  11881. var colorTextures = framebuffer.colorTextures;
  11882. var count = colorTextures.length;
  11883. if (!gl.drawBuffers) {
  11884. count = Math.min(count, 1);
  11885. }
  11886. for (var i = 0; i < count; i++) {
  11887. var texture = colorTextures[i];
  11888. var parentTexture = texture.parentTextureArray || texture;
  11889. this.renderer.texture.bind(parentTexture, 0);
  11890. }
  11891. if (framebuffer.depthTexture && this.writeDepthTexture) {
  11892. this.renderer.texture.bind(framebuffer.depthTexture, 0);
  11893. }
  11894. };
  11895. FramebufferSystem2.prototype.updateFramebuffer = function(framebuffer, mipLevel) {
  11896. var gl = this.gl;
  11897. var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID];
  11898. var colorTextures = framebuffer.colorTextures;
  11899. var count = colorTextures.length;
  11900. if (!gl.drawBuffers) {
  11901. count = Math.min(count, 1);
  11902. }
  11903. if (fbo.multisample > 1 && this.canMultisampleFramebuffer(framebuffer)) {
  11904. fbo.msaaBuffer = fbo.msaaBuffer || gl.createRenderbuffer();
  11905. gl.bindRenderbuffer(gl.RENDERBUFFER, fbo.msaaBuffer);
  11906. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, fbo.multisample, gl.RGBA8, framebuffer.width, framebuffer.height);
  11907. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, fbo.msaaBuffer);
  11908. } else if (fbo.msaaBuffer) {
  11909. gl.deleteRenderbuffer(fbo.msaaBuffer);
  11910. fbo.msaaBuffer = null;
  11911. if (fbo.blitFramebuffer) {
  11912. fbo.blitFramebuffer.dispose();
  11913. fbo.blitFramebuffer = null;
  11914. }
  11915. }
  11916. var activeTextures = [];
  11917. for (var i = 0; i < count; i++) {
  11918. var texture = colorTextures[i];
  11919. var parentTexture = texture.parentTextureArray || texture;
  11920. this.renderer.texture.bind(parentTexture, 0);
  11921. if (i === 0 && fbo.msaaBuffer) {
  11922. continue;
  11923. }
  11924. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, texture.target, parentTexture._glTextures[this.CONTEXT_UID].texture, mipLevel);
  11925. activeTextures.push(gl.COLOR_ATTACHMENT0 + i);
  11926. }
  11927. if (activeTextures.length > 1) {
  11928. gl.drawBuffers(activeTextures);
  11929. }
  11930. if (framebuffer.depthTexture) {
  11931. var writeDepthTexture = this.writeDepthTexture;
  11932. if (writeDepthTexture) {
  11933. var depthTexture = framebuffer.depthTexture;
  11934. this.renderer.texture.bind(depthTexture, 0);
  11935. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._glTextures[this.CONTEXT_UID].texture, mipLevel);
  11936. }
  11937. }
  11938. if ((framebuffer.stencil || framebuffer.depth) && !(framebuffer.depthTexture && this.writeDepthTexture)) {
  11939. fbo.stencil = fbo.stencil || gl.createRenderbuffer();
  11940. gl.bindRenderbuffer(gl.RENDERBUFFER, fbo.stencil);
  11941. if (fbo.msaaBuffer) {
  11942. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, fbo.multisample, gl.DEPTH24_STENCIL8, framebuffer.width, framebuffer.height);
  11943. } else {
  11944. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, framebuffer.width, framebuffer.height);
  11945. }
  11946. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, fbo.stencil);
  11947. } else if (fbo.stencil) {
  11948. gl.deleteRenderbuffer(fbo.stencil);
  11949. fbo.stencil = null;
  11950. }
  11951. };
  11952. FramebufferSystem2.prototype.canMultisampleFramebuffer = function(framebuffer) {
  11953. return this.renderer.context.webGLVersion !== 1 && framebuffer.colorTextures.length <= 1 && !framebuffer.depthTexture;
  11954. };
  11955. FramebufferSystem2.prototype.detectSamples = function(samples) {
  11956. var msaaSamples = this.msaaSamples;
  11957. var res = MSAA_QUALITY.NONE;
  11958. if (samples <= 1 || msaaSamples === null) {
  11959. return res;
  11960. }
  11961. for (var i = 0; i < msaaSamples.length; i++) {
  11962. if (msaaSamples[i] <= samples) {
  11963. res = msaaSamples[i];
  11964. break;
  11965. }
  11966. }
  11967. if (res === 1) {
  11968. res = MSAA_QUALITY.NONE;
  11969. }
  11970. return res;
  11971. };
  11972. FramebufferSystem2.prototype.blit = function(framebuffer, sourcePixels, destPixels) {
  11973. var _a = this, current = _a.current, renderer = _a.renderer, gl = _a.gl, CONTEXT_UID = _a.CONTEXT_UID;
  11974. if (renderer.context.webGLVersion !== 2) {
  11975. return;
  11976. }
  11977. if (!current) {
  11978. return;
  11979. }
  11980. var fbo = current.glFramebuffers[CONTEXT_UID];
  11981. if (!fbo) {
  11982. return;
  11983. }
  11984. if (!framebuffer) {
  11985. if (!fbo.msaaBuffer) {
  11986. return;
  11987. }
  11988. var colorTexture = current.colorTextures[0];
  11989. if (!colorTexture) {
  11990. return;
  11991. }
  11992. if (!fbo.blitFramebuffer) {
  11993. fbo.blitFramebuffer = new Framebuffer(current.width, current.height);
  11994. fbo.blitFramebuffer.addColorTexture(0, colorTexture);
  11995. }
  11996. framebuffer = fbo.blitFramebuffer;
  11997. if (framebuffer.colorTextures[0] !== colorTexture) {
  11998. framebuffer.colorTextures[0] = colorTexture;
  11999. framebuffer.dirtyId++;
  12000. framebuffer.dirtyFormat++;
  12001. }
  12002. if (framebuffer.width !== current.width || framebuffer.height !== current.height) {
  12003. framebuffer.width = current.width;
  12004. framebuffer.height = current.height;
  12005. framebuffer.dirtyId++;
  12006. framebuffer.dirtySize++;
  12007. }
  12008. }
  12009. if (!sourcePixels) {
  12010. sourcePixels = tempRectangle;
  12011. sourcePixels.width = current.width;
  12012. sourcePixels.height = current.height;
  12013. }
  12014. if (!destPixels) {
  12015. destPixels = sourcePixels;
  12016. }
  12017. var sameSize = sourcePixels.width === destPixels.width && sourcePixels.height === destPixels.height;
  12018. this.bind(framebuffer);
  12019. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, fbo.framebuffer);
  12020. gl.blitFramebuffer(sourcePixels.left, sourcePixels.top, sourcePixels.right, sourcePixels.bottom, destPixels.left, destPixels.top, destPixels.right, destPixels.bottom, gl.COLOR_BUFFER_BIT, sameSize ? gl.NEAREST : gl.LINEAR);
  12021. };
  12022. FramebufferSystem2.prototype.disposeFramebuffer = function(framebuffer, contextLost) {
  12023. var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID];
  12024. var gl = this.gl;
  12025. if (!fbo) {
  12026. return;
  12027. }
  12028. delete framebuffer.glFramebuffers[this.CONTEXT_UID];
  12029. var index = this.managedFramebuffers.indexOf(framebuffer);
  12030. if (index >= 0) {
  12031. this.managedFramebuffers.splice(index, 1);
  12032. }
  12033. framebuffer.disposeRunner.remove(this);
  12034. if (!contextLost) {
  12035. gl.deleteFramebuffer(fbo.framebuffer);
  12036. if (fbo.msaaBuffer) {
  12037. gl.deleteRenderbuffer(fbo.msaaBuffer);
  12038. }
  12039. if (fbo.stencil) {
  12040. gl.deleteRenderbuffer(fbo.stencil);
  12041. }
  12042. }
  12043. if (fbo.blitFramebuffer) {
  12044. fbo.blitFramebuffer.dispose();
  12045. }
  12046. };
  12047. FramebufferSystem2.prototype.disposeAll = function(contextLost) {
  12048. var list = this.managedFramebuffers;
  12049. this.managedFramebuffers = [];
  12050. for (var i = 0; i < list.length; i++) {
  12051. this.disposeFramebuffer(list[i], contextLost);
  12052. }
  12053. };
  12054. FramebufferSystem2.prototype.forceStencil = function() {
  12055. var framebuffer = this.current;
  12056. if (!framebuffer) {
  12057. return;
  12058. }
  12059. var fbo = framebuffer.glFramebuffers[this.CONTEXT_UID];
  12060. if (!fbo || fbo.stencil) {
  12061. return;
  12062. }
  12063. framebuffer.stencil = true;
  12064. var w = framebuffer.width;
  12065. var h = framebuffer.height;
  12066. var gl = this.gl;
  12067. var stencil = gl.createRenderbuffer();
  12068. gl.bindRenderbuffer(gl.RENDERBUFFER, stencil);
  12069. if (fbo.msaaBuffer) {
  12070. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, fbo.multisample, gl.DEPTH24_STENCIL8, w, h);
  12071. } else {
  12072. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, w, h);
  12073. }
  12074. fbo.stencil = stencil;
  12075. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, stencil);
  12076. };
  12077. FramebufferSystem2.prototype.reset = function() {
  12078. this.current = this.unknownFramebuffer;
  12079. this.viewport = new Rectangle();
  12080. };
  12081. FramebufferSystem2.prototype.destroy = function() {
  12082. this.renderer = null;
  12083. };
  12084. return FramebufferSystem2;
  12085. })()
  12086. );
  12087. var byteSizeMap = { 5126: 4, 5123: 2, 5121: 1 };
  12088. var GeometrySystem = (
  12089. /** @class */
  12090. (function() {
  12091. function GeometrySystem2(renderer) {
  12092. this.renderer = renderer;
  12093. this._activeGeometry = null;
  12094. this._activeVao = null;
  12095. this.hasVao = true;
  12096. this.hasInstance = true;
  12097. this.canUseUInt32ElementIndex = false;
  12098. this.managedGeometries = {};
  12099. }
  12100. GeometrySystem2.prototype.contextChange = function() {
  12101. this.disposeAll(true);
  12102. var gl = this.gl = this.renderer.gl;
  12103. var context2 = this.renderer.context;
  12104. this.CONTEXT_UID = this.renderer.CONTEXT_UID;
  12105. if (context2.webGLVersion !== 2) {
  12106. var nativeVaoExtension_1 = this.renderer.context.extensions.vertexArrayObject;
  12107. if (settings.PREFER_ENV === ENV.WEBGL_LEGACY) {
  12108. nativeVaoExtension_1 = null;
  12109. }
  12110. if (nativeVaoExtension_1) {
  12111. gl.createVertexArray = function() {
  12112. return nativeVaoExtension_1.createVertexArrayOES();
  12113. };
  12114. gl.bindVertexArray = function(vao) {
  12115. return nativeVaoExtension_1.bindVertexArrayOES(vao);
  12116. };
  12117. gl.deleteVertexArray = function(vao) {
  12118. return nativeVaoExtension_1.deleteVertexArrayOES(vao);
  12119. };
  12120. } else {
  12121. this.hasVao = false;
  12122. gl.createVertexArray = function() {
  12123. return null;
  12124. };
  12125. gl.bindVertexArray = function() {
  12126. return null;
  12127. };
  12128. gl.deleteVertexArray = function() {
  12129. return null;
  12130. };
  12131. }
  12132. }
  12133. if (context2.webGLVersion !== 2) {
  12134. var instanceExt_1 = gl.getExtension("ANGLE_instanced_arrays");
  12135. if (instanceExt_1) {
  12136. gl.vertexAttribDivisor = function(a, b) {
  12137. return instanceExt_1.vertexAttribDivisorANGLE(a, b);
  12138. };
  12139. gl.drawElementsInstanced = function(a, b, c, d, e) {
  12140. return instanceExt_1.drawElementsInstancedANGLE(a, b, c, d, e);
  12141. };
  12142. gl.drawArraysInstanced = function(a, b, c, d) {
  12143. return instanceExt_1.drawArraysInstancedANGLE(a, b, c, d);
  12144. };
  12145. } else {
  12146. this.hasInstance = false;
  12147. }
  12148. }
  12149. this.canUseUInt32ElementIndex = context2.webGLVersion === 2 || !!context2.extensions.uint32ElementIndex;
  12150. };
  12151. GeometrySystem2.prototype.bind = function(geometry, shader) {
  12152. shader = shader || this.renderer.shader.shader;
  12153. var gl = this.gl;
  12154. var vaos = geometry.glVertexArrayObjects[this.CONTEXT_UID];
  12155. var incRefCount = false;
  12156. if (!vaos) {
  12157. this.managedGeometries[geometry.id] = geometry;
  12158. geometry.disposeRunner.add(this);
  12159. geometry.glVertexArrayObjects[this.CONTEXT_UID] = vaos = {};
  12160. incRefCount = true;
  12161. }
  12162. var vao = vaos[shader.program.id] || this.initGeometryVao(geometry, shader, incRefCount);
  12163. this._activeGeometry = geometry;
  12164. if (this._activeVao !== vao) {
  12165. this._activeVao = vao;
  12166. if (this.hasVao) {
  12167. gl.bindVertexArray(vao);
  12168. } else {
  12169. this.activateVao(geometry, shader.program);
  12170. }
  12171. }
  12172. this.updateBuffers();
  12173. };
  12174. GeometrySystem2.prototype.reset = function() {
  12175. this.unbind();
  12176. };
  12177. GeometrySystem2.prototype.updateBuffers = function() {
  12178. var geometry = this._activeGeometry;
  12179. var bufferSystem = this.renderer.buffer;
  12180. for (var i = 0; i < geometry.buffers.length; i++) {
  12181. var buffer = geometry.buffers[i];
  12182. bufferSystem.update(buffer);
  12183. }
  12184. };
  12185. GeometrySystem2.prototype.checkCompatibility = function(geometry, program) {
  12186. var geometryAttributes = geometry.attributes;
  12187. var shaderAttributes = program.attributeData;
  12188. for (var j in shaderAttributes) {
  12189. if (!geometryAttributes[j]) {
  12190. throw new Error('shader and geometry incompatible, geometry missing the "' + j + '" attribute');
  12191. }
  12192. }
  12193. };
  12194. GeometrySystem2.prototype.getSignature = function(geometry, program) {
  12195. var attribs = geometry.attributes;
  12196. var shaderAttributes = program.attributeData;
  12197. var strings = ["g", geometry.id];
  12198. for (var i in attribs) {
  12199. if (shaderAttributes[i]) {
  12200. strings.push(i, shaderAttributes[i].location);
  12201. }
  12202. }
  12203. return strings.join("-");
  12204. };
  12205. GeometrySystem2.prototype.initGeometryVao = function(geometry, shader, incRefCount) {
  12206. if (incRefCount === void 0) {
  12207. incRefCount = true;
  12208. }
  12209. var gl = this.gl;
  12210. var CONTEXT_UID = this.CONTEXT_UID;
  12211. var bufferSystem = this.renderer.buffer;
  12212. var program = shader.program;
  12213. if (!program.glPrograms[CONTEXT_UID]) {
  12214. this.renderer.shader.generateProgram(shader);
  12215. }
  12216. this.checkCompatibility(geometry, program);
  12217. var signature = this.getSignature(geometry, program);
  12218. var vaoObjectHash = geometry.glVertexArrayObjects[this.CONTEXT_UID];
  12219. var vao = vaoObjectHash[signature];
  12220. if (vao) {
  12221. vaoObjectHash[program.id] = vao;
  12222. return vao;
  12223. }
  12224. var buffers = geometry.buffers;
  12225. var attributes = geometry.attributes;
  12226. var tempStride = {};
  12227. var tempStart = {};
  12228. for (var j in buffers) {
  12229. tempStride[j] = 0;
  12230. tempStart[j] = 0;
  12231. }
  12232. for (var j in attributes) {
  12233. if (!attributes[j].size && program.attributeData[j]) {
  12234. attributes[j].size = program.attributeData[j].size;
  12235. } else if (!attributes[j].size) {
  12236. console.warn("PIXI Geometry attribute '" + j + "' size cannot be determined (likely the bound shader does not have the attribute)");
  12237. }
  12238. tempStride[attributes[j].buffer] += attributes[j].size * byteSizeMap[attributes[j].type];
  12239. }
  12240. for (var j in attributes) {
  12241. var attribute = attributes[j];
  12242. var attribSize = attribute.size;
  12243. if (attribute.stride === void 0) {
  12244. if (tempStride[attribute.buffer] === attribSize * byteSizeMap[attribute.type]) {
  12245. attribute.stride = 0;
  12246. } else {
  12247. attribute.stride = tempStride[attribute.buffer];
  12248. }
  12249. }
  12250. if (attribute.start === void 0) {
  12251. attribute.start = tempStart[attribute.buffer];
  12252. tempStart[attribute.buffer] += attribSize * byteSizeMap[attribute.type];
  12253. }
  12254. }
  12255. vao = gl.createVertexArray();
  12256. gl.bindVertexArray(vao);
  12257. for (var i = 0; i < buffers.length; i++) {
  12258. var buffer = buffers[i];
  12259. bufferSystem.bind(buffer);
  12260. if (incRefCount) {
  12261. buffer._glBuffers[CONTEXT_UID].refCount++;
  12262. }
  12263. }
  12264. this.activateVao(geometry, program);
  12265. this._activeVao = vao;
  12266. vaoObjectHash[program.id] = vao;
  12267. vaoObjectHash[signature] = vao;
  12268. return vao;
  12269. };
  12270. GeometrySystem2.prototype.disposeGeometry = function(geometry, contextLost) {
  12271. var _a;
  12272. if (!this.managedGeometries[geometry.id]) {
  12273. return;
  12274. }
  12275. delete this.managedGeometries[geometry.id];
  12276. var vaos = geometry.glVertexArrayObjects[this.CONTEXT_UID];
  12277. var gl = this.gl;
  12278. var buffers = geometry.buffers;
  12279. var bufferSystem = (_a = this.renderer) === null || _a === void 0 ? void 0 : _a.buffer;
  12280. geometry.disposeRunner.remove(this);
  12281. if (!vaos) {
  12282. return;
  12283. }
  12284. if (bufferSystem) {
  12285. for (var i = 0; i < buffers.length; i++) {
  12286. var buf = buffers[i]._glBuffers[this.CONTEXT_UID];
  12287. if (buf) {
  12288. buf.refCount--;
  12289. if (buf.refCount === 0 && !contextLost) {
  12290. bufferSystem.dispose(buffers[i], contextLost);
  12291. }
  12292. }
  12293. }
  12294. }
  12295. if (!contextLost) {
  12296. for (var vaoId in vaos) {
  12297. if (vaoId[0] === "g") {
  12298. var vao = vaos[vaoId];
  12299. if (this._activeVao === vao) {
  12300. this.unbind();
  12301. }
  12302. gl.deleteVertexArray(vao);
  12303. }
  12304. }
  12305. }
  12306. delete geometry.glVertexArrayObjects[this.CONTEXT_UID];
  12307. };
  12308. GeometrySystem2.prototype.disposeAll = function(contextLost) {
  12309. var all = Object.keys(this.managedGeometries);
  12310. for (var i = 0; i < all.length; i++) {
  12311. this.disposeGeometry(this.managedGeometries[all[i]], contextLost);
  12312. }
  12313. };
  12314. GeometrySystem2.prototype.activateVao = function(geometry, program) {
  12315. var gl = this.gl;
  12316. var CONTEXT_UID = this.CONTEXT_UID;
  12317. var bufferSystem = this.renderer.buffer;
  12318. var buffers = geometry.buffers;
  12319. var attributes = geometry.attributes;
  12320. if (geometry.indexBuffer) {
  12321. bufferSystem.bind(geometry.indexBuffer);
  12322. }
  12323. var lastBuffer = null;
  12324. for (var j in attributes) {
  12325. var attribute = attributes[j];
  12326. var buffer = buffers[attribute.buffer];
  12327. var glBuffer = buffer._glBuffers[CONTEXT_UID];
  12328. if (program.attributeData[j]) {
  12329. if (lastBuffer !== glBuffer) {
  12330. bufferSystem.bind(buffer);
  12331. lastBuffer = glBuffer;
  12332. }
  12333. var location = program.attributeData[j].location;
  12334. gl.enableVertexAttribArray(location);
  12335. gl.vertexAttribPointer(location, attribute.size, attribute.type || gl.FLOAT, attribute.normalized, attribute.stride, attribute.start);
  12336. if (attribute.instance) {
  12337. if (this.hasInstance) {
  12338. gl.vertexAttribDivisor(location, 1);
  12339. } else {
  12340. throw new Error("geometry error, GPU Instancing is not supported on this device");
  12341. }
  12342. }
  12343. }
  12344. }
  12345. };
  12346. GeometrySystem2.prototype.draw = function(type, size, start, instanceCount) {
  12347. var gl = this.gl;
  12348. var geometry = this._activeGeometry;
  12349. if (geometry.indexBuffer) {
  12350. var byteSize = geometry.indexBuffer.data.BYTES_PER_ELEMENT;
  12351. var glType = byteSize === 2 ? gl.UNSIGNED_SHORT : gl.UNSIGNED_INT;
  12352. if (byteSize === 2 || byteSize === 4 && this.canUseUInt32ElementIndex) {
  12353. if (geometry.instanced) {
  12354. gl.drawElementsInstanced(type, size || geometry.indexBuffer.data.length, glType, (start || 0) * byteSize, instanceCount || 1);
  12355. } else {
  12356. gl.drawElements(type, size || geometry.indexBuffer.data.length, glType, (start || 0) * byteSize);
  12357. }
  12358. } else {
  12359. console.warn("unsupported index buffer type: uint32");
  12360. }
  12361. } else if (geometry.instanced) {
  12362. gl.drawArraysInstanced(type, start, size || geometry.getSize(), instanceCount || 1);
  12363. } else {
  12364. gl.drawArrays(type, start, size || geometry.getSize());
  12365. }
  12366. return this;
  12367. };
  12368. GeometrySystem2.prototype.unbind = function() {
  12369. this.gl.bindVertexArray(null);
  12370. this._activeVao = null;
  12371. this._activeGeometry = null;
  12372. };
  12373. GeometrySystem2.prototype.destroy = function() {
  12374. this.renderer = null;
  12375. };
  12376. return GeometrySystem2;
  12377. })()
  12378. );
  12379. var MaskData = (
  12380. /** @class */
  12381. (function() {
  12382. function MaskData2(maskObject) {
  12383. if (maskObject === void 0) {
  12384. maskObject = null;
  12385. }
  12386. this.type = MASK_TYPES.NONE;
  12387. this.autoDetect = true;
  12388. this.maskObject = maskObject || null;
  12389. this.pooled = false;
  12390. this.isMaskData = true;
  12391. this.resolution = null;
  12392. this.multisample = settings.FILTER_MULTISAMPLE;
  12393. this.enabled = true;
  12394. this.colorMask = 15;
  12395. this._filters = null;
  12396. this._stencilCounter = 0;
  12397. this._scissorCounter = 0;
  12398. this._scissorRect = null;
  12399. this._scissorRectLocal = null;
  12400. this._colorMask = 15;
  12401. this._target = null;
  12402. }
  12403. Object.defineProperty(MaskData2.prototype, "filter", {
  12404. /**
  12405. * The sprite mask filter.
  12406. * If set to `null`, the default sprite mask filter is used.
  12407. * @default null
  12408. */
  12409. get: function() {
  12410. return this._filters ? this._filters[0] : null;
  12411. },
  12412. set: function(value) {
  12413. if (value) {
  12414. if (this._filters) {
  12415. this._filters[0] = value;
  12416. } else {
  12417. this._filters = [value];
  12418. }
  12419. } else {
  12420. this._filters = null;
  12421. }
  12422. },
  12423. enumerable: false,
  12424. configurable: true
  12425. });
  12426. MaskData2.prototype.reset = function() {
  12427. if (this.pooled) {
  12428. this.maskObject = null;
  12429. this.type = MASK_TYPES.NONE;
  12430. this.autoDetect = true;
  12431. }
  12432. this._target = null;
  12433. this._scissorRectLocal = null;
  12434. };
  12435. MaskData2.prototype.copyCountersOrReset = function(maskAbove) {
  12436. if (maskAbove) {
  12437. this._stencilCounter = maskAbove._stencilCounter;
  12438. this._scissorCounter = maskAbove._scissorCounter;
  12439. this._scissorRect = maskAbove._scissorRect;
  12440. } else {
  12441. this._stencilCounter = 0;
  12442. this._scissorCounter = 0;
  12443. this._scissorRect = null;
  12444. }
  12445. };
  12446. return MaskData2;
  12447. })()
  12448. );
  12449. function compileShader(gl, type, src) {
  12450. var shader = gl.createShader(type);
  12451. gl.shaderSource(shader, src);
  12452. gl.compileShader(shader);
  12453. return shader;
  12454. }
  12455. function logPrettyShaderError(gl, shader) {
  12456. var shaderSrc = gl.getShaderSource(shader).split("\n").map(function(line, index) {
  12457. return index + ": " + line;
  12458. });
  12459. var shaderLog = gl.getShaderInfoLog(shader);
  12460. var splitShader = shaderLog.split("\n");
  12461. var dedupe = {};
  12462. var lineNumbers = splitShader.map(function(line) {
  12463. return parseFloat(line.replace(/^ERROR\: 0\:([\d]+)\:.*$/, "$1"));
  12464. }).filter(function(n) {
  12465. if (n && !dedupe[n]) {
  12466. dedupe[n] = true;
  12467. return true;
  12468. }
  12469. return false;
  12470. });
  12471. var logArgs = [""];
  12472. lineNumbers.forEach(function(number) {
  12473. shaderSrc[number - 1] = "%c" + shaderSrc[number - 1] + "%c";
  12474. logArgs.push("background: #FF0000; color:#FFFFFF; font-size: 10px", "font-size: 10px");
  12475. });
  12476. var fragmentSourceToLog = shaderSrc.join("\n");
  12477. logArgs[0] = fragmentSourceToLog;
  12478. console.error(shaderLog);
  12479. console.groupCollapsed("click to view full shader code");
  12480. console.warn.apply(console, logArgs);
  12481. console.groupEnd();
  12482. }
  12483. function logProgramError(gl, program, vertexShader, fragmentShader) {
  12484. if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
  12485. if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
  12486. logPrettyShaderError(gl, vertexShader);
  12487. }
  12488. if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
  12489. logPrettyShaderError(gl, fragmentShader);
  12490. }
  12491. console.error("PixiJS Error: Could not initialize shader.");
  12492. if (gl.getProgramInfoLog(program) !== "") {
  12493. console.warn("PixiJS Warning: gl.getProgramInfoLog()", gl.getProgramInfoLog(program));
  12494. }
  12495. }
  12496. }
  12497. function booleanArray(size) {
  12498. var array = new Array(size);
  12499. for (var i = 0; i < array.length; i++) {
  12500. array[i] = false;
  12501. }
  12502. return array;
  12503. }
  12504. function defaultValue(type, size) {
  12505. switch (type) {
  12506. case "float":
  12507. return 0;
  12508. case "vec2":
  12509. return new Float32Array(2 * size);
  12510. case "vec3":
  12511. return new Float32Array(3 * size);
  12512. case "vec4":
  12513. return new Float32Array(4 * size);
  12514. case "int":
  12515. case "uint":
  12516. case "sampler2D":
  12517. case "sampler2DArray":
  12518. return 0;
  12519. case "ivec2":
  12520. return new Int32Array(2 * size);
  12521. case "ivec3":
  12522. return new Int32Array(3 * size);
  12523. case "ivec4":
  12524. return new Int32Array(4 * size);
  12525. case "uvec2":
  12526. return new Uint32Array(2 * size);
  12527. case "uvec3":
  12528. return new Uint32Array(3 * size);
  12529. case "uvec4":
  12530. return new Uint32Array(4 * size);
  12531. case "bool":
  12532. return false;
  12533. case "bvec2":
  12534. return booleanArray(2 * size);
  12535. case "bvec3":
  12536. return booleanArray(3 * size);
  12537. case "bvec4":
  12538. return booleanArray(4 * size);
  12539. case "mat2":
  12540. return new Float32Array([
  12541. 1,
  12542. 0,
  12543. 0,
  12544. 1
  12545. ]);
  12546. case "mat3":
  12547. return new Float32Array([
  12548. 1,
  12549. 0,
  12550. 0,
  12551. 0,
  12552. 1,
  12553. 0,
  12554. 0,
  12555. 0,
  12556. 1
  12557. ]);
  12558. case "mat4":
  12559. return new Float32Array([
  12560. 1,
  12561. 0,
  12562. 0,
  12563. 0,
  12564. 0,
  12565. 1,
  12566. 0,
  12567. 0,
  12568. 0,
  12569. 0,
  12570. 1,
  12571. 0,
  12572. 0,
  12573. 0,
  12574. 0,
  12575. 1
  12576. ]);
  12577. }
  12578. return null;
  12579. }
  12580. var unknownContext = {};
  12581. var context = unknownContext;
  12582. function getTestContext() {
  12583. if (context === unknownContext || context && context.isContextLost()) {
  12584. var canvas = settings.ADAPTER.createCanvas();
  12585. var gl = void 0;
  12586. if (settings.PREFER_ENV >= ENV.WEBGL2) {
  12587. gl = canvas.getContext("webgl2", {});
  12588. }
  12589. if (!gl) {
  12590. gl = canvas.getContext("webgl", {}) || canvas.getContext("experimental-webgl", {});
  12591. if (!gl) {
  12592. gl = null;
  12593. } else {
  12594. gl.getExtension("WEBGL_draw_buffers");
  12595. }
  12596. }
  12597. context = gl;
  12598. }
  12599. return context;
  12600. }
  12601. var maxFragmentPrecision;
  12602. function getMaxFragmentPrecision() {
  12603. if (!maxFragmentPrecision) {
  12604. maxFragmentPrecision = PRECISION.MEDIUM;
  12605. var gl = getTestContext();
  12606. if (gl) {
  12607. if (gl.getShaderPrecisionFormat) {
  12608. var shaderFragment = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
  12609. maxFragmentPrecision = shaderFragment.precision ? PRECISION.HIGH : PRECISION.MEDIUM;
  12610. }
  12611. }
  12612. }
  12613. return maxFragmentPrecision;
  12614. }
  12615. function setPrecision(src, requestedPrecision, maxSupportedPrecision) {
  12616. if (src.substring(0, 9) !== "precision") {
  12617. var precision = requestedPrecision;
  12618. if (requestedPrecision === PRECISION.HIGH && maxSupportedPrecision !== PRECISION.HIGH) {
  12619. precision = PRECISION.MEDIUM;
  12620. }
  12621. return "precision " + precision + " float;\n" + src;
  12622. } else if (maxSupportedPrecision !== PRECISION.HIGH && src.substring(0, 15) === "precision highp") {
  12623. return src.replace("precision highp", "precision mediump");
  12624. }
  12625. return src;
  12626. }
  12627. var GLSL_TO_SIZE = {
  12628. float: 1,
  12629. vec2: 2,
  12630. vec3: 3,
  12631. vec4: 4,
  12632. int: 1,
  12633. ivec2: 2,
  12634. ivec3: 3,
  12635. ivec4: 4,
  12636. uint: 1,
  12637. uvec2: 2,
  12638. uvec3: 3,
  12639. uvec4: 4,
  12640. bool: 1,
  12641. bvec2: 2,
  12642. bvec3: 3,
  12643. bvec4: 4,
  12644. mat2: 4,
  12645. mat3: 9,
  12646. mat4: 16,
  12647. sampler2D: 1
  12648. };
  12649. function mapSize(type) {
  12650. return GLSL_TO_SIZE[type];
  12651. }
  12652. var GL_TABLE = null;
  12653. var GL_TO_GLSL_TYPES = {
  12654. FLOAT: "float",
  12655. FLOAT_VEC2: "vec2",
  12656. FLOAT_VEC3: "vec3",
  12657. FLOAT_VEC4: "vec4",
  12658. INT: "int",
  12659. INT_VEC2: "ivec2",
  12660. INT_VEC3: "ivec3",
  12661. INT_VEC4: "ivec4",
  12662. UNSIGNED_INT: "uint",
  12663. UNSIGNED_INT_VEC2: "uvec2",
  12664. UNSIGNED_INT_VEC3: "uvec3",
  12665. UNSIGNED_INT_VEC4: "uvec4",
  12666. BOOL: "bool",
  12667. BOOL_VEC2: "bvec2",
  12668. BOOL_VEC3: "bvec3",
  12669. BOOL_VEC4: "bvec4",
  12670. FLOAT_MAT2: "mat2",
  12671. FLOAT_MAT3: "mat3",
  12672. FLOAT_MAT4: "mat4",
  12673. SAMPLER_2D: "sampler2D",
  12674. INT_SAMPLER_2D: "sampler2D",
  12675. UNSIGNED_INT_SAMPLER_2D: "sampler2D",
  12676. SAMPLER_CUBE: "samplerCube",
  12677. INT_SAMPLER_CUBE: "samplerCube",
  12678. UNSIGNED_INT_SAMPLER_CUBE: "samplerCube",
  12679. SAMPLER_2D_ARRAY: "sampler2DArray",
  12680. INT_SAMPLER_2D_ARRAY: "sampler2DArray",
  12681. UNSIGNED_INT_SAMPLER_2D_ARRAY: "sampler2DArray"
  12682. };
  12683. function mapType(gl, type) {
  12684. if (!GL_TABLE) {
  12685. var typeNames = Object.keys(GL_TO_GLSL_TYPES);
  12686. GL_TABLE = {};
  12687. for (var i = 0; i < typeNames.length; ++i) {
  12688. var tn = typeNames[i];
  12689. GL_TABLE[gl[tn]] = GL_TO_GLSL_TYPES[tn];
  12690. }
  12691. }
  12692. return GL_TABLE[type];
  12693. }
  12694. var uniformParsers = [
  12695. // a float cache layer
  12696. {
  12697. test: function(data) {
  12698. return data.type === "float" && data.size === 1 && !data.isArray;
  12699. },
  12700. code: function(name) {
  12701. return '\n if(uv["' + name + '"] !== ud["' + name + '"].value)\n {\n ud["' + name + '"].value = uv["' + name + '"]\n gl.uniform1f(ud["' + name + '"].location, uv["' + name + '"])\n }\n ';
  12702. }
  12703. },
  12704. // handling samplers
  12705. {
  12706. test: function(data, uniform) {
  12707. return (data.type === "sampler2D" || data.type === "samplerCube" || data.type === "sampler2DArray") && data.size === 1 && !data.isArray && (uniform == null || uniform.castToBaseTexture !== void 0);
  12708. },
  12709. code: function(name) {
  12710. return 't = syncData.textureCount++;\n\n renderer.texture.bind(uv["' + name + '"], t);\n\n if(ud["' + name + '"].value !== t)\n {\n ud["' + name + '"].value = t;\n gl.uniform1i(ud["' + name + '"].location, t);\n; // eslint-disable-line max-len\n }';
  12711. }
  12712. },
  12713. // uploading pixi matrix object to mat3
  12714. {
  12715. test: function(data, uniform) {
  12716. return data.type === "mat3" && data.size === 1 && !data.isArray && uniform.a !== void 0;
  12717. },
  12718. code: function(name) {
  12719. return '\n gl.uniformMatrix3fv(ud["' + name + '"].location, false, uv["' + name + '"].toArray(true));\n ';
  12720. },
  12721. codeUbo: function(name) {
  12722. return "\n var " + name + "_matrix = uv." + name + ".toArray(true);\n\n data[offset] = " + name + "_matrix[0];\n data[offset+1] = " + name + "_matrix[1];\n data[offset+2] = " + name + "_matrix[2];\n \n data[offset + 4] = " + name + "_matrix[3];\n data[offset + 5] = " + name + "_matrix[4];\n data[offset + 6] = " + name + "_matrix[5];\n \n data[offset + 8] = " + name + "_matrix[6];\n data[offset + 9] = " + name + "_matrix[7];\n data[offset + 10] = " + name + "_matrix[8];\n ";
  12723. }
  12724. },
  12725. // uploading a pixi point as a vec2 with caching layer
  12726. {
  12727. test: function(data, uniform) {
  12728. return data.type === "vec2" && data.size === 1 && !data.isArray && uniform.x !== void 0;
  12729. },
  12730. code: function(name) {
  12731. return '\n cv = ud["' + name + '"].value;\n v = uv["' + name + '"];\n\n if(cv[0] !== v.x || cv[1] !== v.y)\n {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud["' + name + '"].location, v.x, v.y);\n }';
  12732. },
  12733. codeUbo: function(name) {
  12734. return "\n v = uv." + name + ";\n\n data[offset] = v.x;\n data[offset+1] = v.y;\n ";
  12735. }
  12736. },
  12737. // caching layer for a vec2
  12738. {
  12739. test: function(data) {
  12740. return data.type === "vec2" && data.size === 1 && !data.isArray;
  12741. },
  12742. code: function(name) {
  12743. return '\n cv = ud["' + name + '"].value;\n v = uv["' + name + '"];\n\n if(cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(ud["' + name + '"].location, v[0], v[1]);\n }\n ';
  12744. }
  12745. },
  12746. // upload a pixi rectangle as a vec4 with caching layer
  12747. {
  12748. test: function(data, uniform) {
  12749. return data.type === "vec4" && data.size === 1 && !data.isArray && uniform.width !== void 0;
  12750. },
  12751. code: function(name) {
  12752. return '\n cv = ud["' + name + '"].value;\n v = uv["' + name + '"];\n\n if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height)\n {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud["' + name + '"].location, v.x, v.y, v.width, v.height)\n }';
  12753. },
  12754. codeUbo: function(name) {
  12755. return "\n v = uv." + name + ";\n\n data[offset] = v.x;\n data[offset+1] = v.y;\n data[offset+2] = v.width;\n data[offset+3] = v.height;\n ";
  12756. }
  12757. },
  12758. // a caching layer for vec4 uploading
  12759. {
  12760. test: function(data) {
  12761. return data.type === "vec4" && data.size === 1 && !data.isArray;
  12762. },
  12763. code: function(name) {
  12764. return '\n cv = ud["' + name + '"].value;\n v = uv["' + name + '"];\n\n if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4f(ud["' + name + '"].location, v[0], v[1], v[2], v[3])\n }';
  12765. }
  12766. }
  12767. ];
  12768. var GLSL_TO_SINGLE_SETTERS_CACHED = {
  12769. float: "\n if (cv !== v)\n {\n cu.value = v;\n gl.uniform1f(location, v);\n }",
  12770. vec2: "\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2f(location, v[0], v[1])\n }",
  12771. vec3: "\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3f(location, v[0], v[1], v[2])\n }",
  12772. vec4: "\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4f(location, v[0], v[1], v[2], v[3]);\n }",
  12773. int: "\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",
  12774. ivec2: "\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2i(location, v[0], v[1]);\n }",
  12775. ivec3: "\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3i(location, v[0], v[1], v[2]);\n }",
  12776. ivec4: "\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",
  12777. uint: "\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1ui(location, v);\n }",
  12778. uvec2: "\n if (cv[0] !== v[0] || cv[1] !== v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2ui(location, v[0], v[1]);\n }",
  12779. uvec3: "\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3ui(location, v[0], v[1], v[2]);\n }",
  12780. uvec4: "\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4ui(location, v[0], v[1], v[2], v[3]);\n }",
  12781. bool: "\n if (cv !== v)\n {\n cu.value = v;\n gl.uniform1i(location, v);\n }",
  12782. bvec2: "\n if (cv[0] != v[0] || cv[1] != v[1])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n\n gl.uniform2i(location, v[0], v[1]);\n }",
  12783. bvec3: "\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n\n gl.uniform3i(location, v[0], v[1], v[2]);\n }",
  12784. bvec4: "\n if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])\n {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",
  12785. mat2: "gl.uniformMatrix2fv(location, false, v)",
  12786. mat3: "gl.uniformMatrix3fv(location, false, v)",
  12787. mat4: "gl.uniformMatrix4fv(location, false, v)",
  12788. sampler2D: "\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",
  12789. samplerCube: "\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }",
  12790. sampler2DArray: "\n if (cv !== v)\n {\n cu.value = v;\n\n gl.uniform1i(location, v);\n }"
  12791. };
  12792. var GLSL_TO_ARRAY_SETTERS = {
  12793. float: "gl.uniform1fv(location, v)",
  12794. vec2: "gl.uniform2fv(location, v)",
  12795. vec3: "gl.uniform3fv(location, v)",
  12796. vec4: "gl.uniform4fv(location, v)",
  12797. mat4: "gl.uniformMatrix4fv(location, false, v)",
  12798. mat3: "gl.uniformMatrix3fv(location, false, v)",
  12799. mat2: "gl.uniformMatrix2fv(location, false, v)",
  12800. int: "gl.uniform1iv(location, v)",
  12801. ivec2: "gl.uniform2iv(location, v)",
  12802. ivec3: "gl.uniform3iv(location, v)",
  12803. ivec4: "gl.uniform4iv(location, v)",
  12804. uint: "gl.uniform1uiv(location, v)",
  12805. uvec2: "gl.uniform2uiv(location, v)",
  12806. uvec3: "gl.uniform3uiv(location, v)",
  12807. uvec4: "gl.uniform4uiv(location, v)",
  12808. bool: "gl.uniform1iv(location, v)",
  12809. bvec2: "gl.uniform2iv(location, v)",
  12810. bvec3: "gl.uniform3iv(location, v)",
  12811. bvec4: "gl.uniform4iv(location, v)",
  12812. sampler2D: "gl.uniform1iv(location, v)",
  12813. samplerCube: "gl.uniform1iv(location, v)",
  12814. sampler2DArray: "gl.uniform1iv(location, v)"
  12815. };
  12816. function generateUniformsSync(group, uniformData) {
  12817. var _a;
  12818. var funcFragments = ["\n var v = null;\n var cv = null;\n var cu = null;\n var t = 0;\n var gl = renderer.gl;\n "];
  12819. for (var i in group.uniforms) {
  12820. var data = uniformData[i];
  12821. if (!data) {
  12822. if ((_a = group.uniforms[i]) === null || _a === void 0 ? void 0 : _a.group) {
  12823. if (group.uniforms[i].ubo) {
  12824. funcFragments.push("\n renderer.shader.syncUniformBufferGroup(uv." + i + ", '" + i + "');\n ");
  12825. } else {
  12826. funcFragments.push("\n renderer.shader.syncUniformGroup(uv." + i + ", syncData);\n ");
  12827. }
  12828. }
  12829. continue;
  12830. }
  12831. var uniform = group.uniforms[i];
  12832. var parsed = false;
  12833. for (var j = 0; j < uniformParsers.length; j++) {
  12834. if (uniformParsers[j].test(data, uniform)) {
  12835. funcFragments.push(uniformParsers[j].code(i, uniform));
  12836. parsed = true;
  12837. break;
  12838. }
  12839. }
  12840. if (!parsed) {
  12841. var templateType = data.size === 1 && !data.isArray ? GLSL_TO_SINGLE_SETTERS_CACHED : GLSL_TO_ARRAY_SETTERS;
  12842. var template = templateType[data.type].replace("location", 'ud["' + i + '"].location');
  12843. funcFragments.push('\n cu = ud["' + i + '"];\n cv = cu.value;\n v = uv["' + i + '"];\n ' + template + ";");
  12844. }
  12845. }
  12846. return new Function("ud", "uv", "renderer", "syncData", funcFragments.join("\n"));
  12847. }
  12848. var fragTemplate = [
  12849. "precision mediump float;",
  12850. "void main(void){",
  12851. "float test = 0.1;",
  12852. "%forloop%",
  12853. "gl_FragColor = vec4(0.0);",
  12854. "}"
  12855. ].join("\n");
  12856. function generateIfTestSrc(maxIfs) {
  12857. var src = "";
  12858. for (var i = 0; i < maxIfs; ++i) {
  12859. if (i > 0) {
  12860. src += "\nelse ";
  12861. }
  12862. if (i < maxIfs - 1) {
  12863. src += "if(test == " + i + ".0){}";
  12864. }
  12865. }
  12866. return src;
  12867. }
  12868. function checkMaxIfStatementsInShader(maxIfs, gl) {
  12869. if (maxIfs === 0) {
  12870. throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");
  12871. }
  12872. var shader = gl.createShader(gl.FRAGMENT_SHADER);
  12873. while (true) {
  12874. var fragmentSrc = fragTemplate.replace(/%forloop%/gi, generateIfTestSrc(maxIfs));
  12875. gl.shaderSource(shader, fragmentSrc);
  12876. gl.compileShader(shader);
  12877. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  12878. maxIfs = maxIfs / 2 | 0;
  12879. } else {
  12880. break;
  12881. }
  12882. }
  12883. return maxIfs;
  12884. }
  12885. var unsafeEval;
  12886. function unsafeEvalSupported() {
  12887. if (typeof unsafeEval === "boolean") {
  12888. return unsafeEval;
  12889. }
  12890. try {
  12891. var func = new Function("param1", "param2", "param3", "return param1[param2] === param3;");
  12892. unsafeEval = func({ a: "b" }, "a", "b") === true;
  12893. } catch (e) {
  12894. unsafeEval = false;
  12895. }
  12896. return unsafeEval;
  12897. }
  12898. var defaultFragment$2 = "varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n gl_FragColor *= texture2D(uSampler, vTextureCoord);\n}";
  12899. var defaultVertex$3 = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n";
  12900. var UID$1 = 0;
  12901. var nameCache = {};
  12902. var Program = (
  12903. /** @class */
  12904. (function() {
  12905. function Program2(vertexSrc, fragmentSrc, name) {
  12906. if (name === void 0) {
  12907. name = "pixi-shader";
  12908. }
  12909. this.id = UID$1++;
  12910. this.vertexSrc = vertexSrc || Program2.defaultVertexSrc;
  12911. this.fragmentSrc = fragmentSrc || Program2.defaultFragmentSrc;
  12912. this.vertexSrc = this.vertexSrc.trim();
  12913. this.fragmentSrc = this.fragmentSrc.trim();
  12914. if (this.vertexSrc.substring(0, 8) !== "#version") {
  12915. name = name.replace(/\s+/g, "-");
  12916. if (nameCache[name]) {
  12917. nameCache[name]++;
  12918. name += "-" + nameCache[name];
  12919. } else {
  12920. nameCache[name] = 1;
  12921. }
  12922. this.vertexSrc = "#define SHADER_NAME " + name + "\n" + this.vertexSrc;
  12923. this.fragmentSrc = "#define SHADER_NAME " + name + "\n" + this.fragmentSrc;
  12924. this.vertexSrc = setPrecision(this.vertexSrc, settings.PRECISION_VERTEX, PRECISION.HIGH);
  12925. this.fragmentSrc = setPrecision(this.fragmentSrc, settings.PRECISION_FRAGMENT, getMaxFragmentPrecision());
  12926. }
  12927. this.glPrograms = {};
  12928. this.syncUniforms = null;
  12929. }
  12930. Object.defineProperty(Program2, "defaultVertexSrc", {
  12931. /**
  12932. * The default vertex shader source.
  12933. * @constant
  12934. */
  12935. get: function() {
  12936. return defaultVertex$3;
  12937. },
  12938. enumerable: false,
  12939. configurable: true
  12940. });
  12941. Object.defineProperty(Program2, "defaultFragmentSrc", {
  12942. /**
  12943. * The default fragment shader source.
  12944. * @constant
  12945. */
  12946. get: function() {
  12947. return defaultFragment$2;
  12948. },
  12949. enumerable: false,
  12950. configurable: true
  12951. });
  12952. Program2.from = function(vertexSrc, fragmentSrc, name) {
  12953. var key = vertexSrc + fragmentSrc;
  12954. var program = ProgramCache[key];
  12955. if (!program) {
  12956. ProgramCache[key] = program = new Program2(vertexSrc, fragmentSrc, name);
  12957. }
  12958. return program;
  12959. };
  12960. return Program2;
  12961. })()
  12962. );
  12963. var Shader = (
  12964. /** @class */
  12965. (function() {
  12966. function Shader2(program, uniforms) {
  12967. this.uniformBindCount = 0;
  12968. this.program = program;
  12969. if (uniforms) {
  12970. if (uniforms instanceof UniformGroup) {
  12971. this.uniformGroup = uniforms;
  12972. } else {
  12973. this.uniformGroup = new UniformGroup(uniforms);
  12974. }
  12975. } else {
  12976. this.uniformGroup = new UniformGroup({});
  12977. }
  12978. this.disposeRunner = new Runner("disposeShader");
  12979. }
  12980. Shader2.prototype.checkUniformExists = function(name, group) {
  12981. if (group.uniforms[name]) {
  12982. return true;
  12983. }
  12984. for (var i in group.uniforms) {
  12985. var uniform = group.uniforms[i];
  12986. if (uniform.group) {
  12987. if (this.checkUniformExists(name, uniform)) {
  12988. return true;
  12989. }
  12990. }
  12991. }
  12992. return false;
  12993. };
  12994. Shader2.prototype.destroy = function() {
  12995. this.uniformGroup = null;
  12996. this.disposeRunner.emit(this);
  12997. this.disposeRunner.destroy();
  12998. };
  12999. Object.defineProperty(Shader2.prototype, "uniforms", {
  13000. /**
  13001. * Shader uniform values, shortcut for `uniformGroup.uniforms`.
  13002. * @readonly
  13003. */
  13004. get: function() {
  13005. return this.uniformGroup.uniforms;
  13006. },
  13007. enumerable: false,
  13008. configurable: true
  13009. });
  13010. Shader2.from = function(vertexSrc, fragmentSrc, uniforms) {
  13011. var program = Program.from(vertexSrc, fragmentSrc);
  13012. return new Shader2(program, uniforms);
  13013. };
  13014. return Shader2;
  13015. })()
  13016. );
  13017. var BLEND$1 = 0;
  13018. var OFFSET$1 = 1;
  13019. var CULLING$1 = 2;
  13020. var DEPTH_TEST$1 = 3;
  13021. var WINDING$1 = 4;
  13022. var DEPTH_MASK$1 = 5;
  13023. var State = (
  13024. /** @class */
  13025. (function() {
  13026. function State2() {
  13027. this.data = 0;
  13028. this.blendMode = BLEND_MODES.NORMAL;
  13029. this.polygonOffset = 0;
  13030. this.blend = true;
  13031. this.depthMask = true;
  13032. }
  13033. Object.defineProperty(State2.prototype, "blend", {
  13034. /**
  13035. * Activates blending of the computed fragment color values.
  13036. * @default true
  13037. */
  13038. get: function() {
  13039. return !!(this.data & 1 << BLEND$1);
  13040. },
  13041. set: function(value) {
  13042. if (!!(this.data & 1 << BLEND$1) !== value) {
  13043. this.data ^= 1 << BLEND$1;
  13044. }
  13045. },
  13046. enumerable: false,
  13047. configurable: true
  13048. });
  13049. Object.defineProperty(State2.prototype, "offsets", {
  13050. /**
  13051. * Activates adding an offset to depth values of polygon's fragments
  13052. * @default false
  13053. */
  13054. get: function() {
  13055. return !!(this.data & 1 << OFFSET$1);
  13056. },
  13057. set: function(value) {
  13058. if (!!(this.data & 1 << OFFSET$1) !== value) {
  13059. this.data ^= 1 << OFFSET$1;
  13060. }
  13061. },
  13062. enumerable: false,
  13063. configurable: true
  13064. });
  13065. Object.defineProperty(State2.prototype, "culling", {
  13066. /**
  13067. * Activates culling of polygons.
  13068. * @default false
  13069. */
  13070. get: function() {
  13071. return !!(this.data & 1 << CULLING$1);
  13072. },
  13073. set: function(value) {
  13074. if (!!(this.data & 1 << CULLING$1) !== value) {
  13075. this.data ^= 1 << CULLING$1;
  13076. }
  13077. },
  13078. enumerable: false,
  13079. configurable: true
  13080. });
  13081. Object.defineProperty(State2.prototype, "depthTest", {
  13082. /**
  13083. * Activates depth comparisons and updates to the depth buffer.
  13084. * @default false
  13085. */
  13086. get: function() {
  13087. return !!(this.data & 1 << DEPTH_TEST$1);
  13088. },
  13089. set: function(value) {
  13090. if (!!(this.data & 1 << DEPTH_TEST$1) !== value) {
  13091. this.data ^= 1 << DEPTH_TEST$1;
  13092. }
  13093. },
  13094. enumerable: false,
  13095. configurable: true
  13096. });
  13097. Object.defineProperty(State2.prototype, "depthMask", {
  13098. /**
  13099. * Enables or disables writing to the depth buffer.
  13100. * @default true
  13101. */
  13102. get: function() {
  13103. return !!(this.data & 1 << DEPTH_MASK$1);
  13104. },
  13105. set: function(value) {
  13106. if (!!(this.data & 1 << DEPTH_MASK$1) !== value) {
  13107. this.data ^= 1 << DEPTH_MASK$1;
  13108. }
  13109. },
  13110. enumerable: false,
  13111. configurable: true
  13112. });
  13113. Object.defineProperty(State2.prototype, "clockwiseFrontFace", {
  13114. /**
  13115. * Specifies whether or not front or back-facing polygons can be culled.
  13116. * @default false
  13117. */
  13118. get: function() {
  13119. return !!(this.data & 1 << WINDING$1);
  13120. },
  13121. set: function(value) {
  13122. if (!!(this.data & 1 << WINDING$1) !== value) {
  13123. this.data ^= 1 << WINDING$1;
  13124. }
  13125. },
  13126. enumerable: false,
  13127. configurable: true
  13128. });
  13129. Object.defineProperty(State2.prototype, "blendMode", {
  13130. /**
  13131. * The blend mode to be applied when this state is set. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode.
  13132. * Setting this mode to anything other than NO_BLEND will automatically switch blending on.
  13133. * @default PIXI.BLEND_MODES.NORMAL
  13134. */
  13135. get: function() {
  13136. return this._blendMode;
  13137. },
  13138. set: function(value) {
  13139. this.blend = value !== BLEND_MODES.NONE;
  13140. this._blendMode = value;
  13141. },
  13142. enumerable: false,
  13143. configurable: true
  13144. });
  13145. Object.defineProperty(State2.prototype, "polygonOffset", {
  13146. /**
  13147. * The polygon offset. Setting this property to anything other than 0 will automatically enable polygon offset fill.
  13148. * @default 0
  13149. */
  13150. get: function() {
  13151. return this._polygonOffset;
  13152. },
  13153. set: function(value) {
  13154. this.offsets = !!value;
  13155. this._polygonOffset = value;
  13156. },
  13157. enumerable: false,
  13158. configurable: true
  13159. });
  13160. State2.prototype.toString = function() {
  13161. return "[@pixi/core:State " + ("blendMode=" + this.blendMode + " ") + ("clockwiseFrontFace=" + this.clockwiseFrontFace + " ") + ("culling=" + this.culling + " ") + ("depthMask=" + this.depthMask + " ") + ("polygonOffset=" + this.polygonOffset) + "]";
  13162. };
  13163. State2.for2d = function() {
  13164. var state = new State2();
  13165. state.depthTest = false;
  13166. state.blend = true;
  13167. return state;
  13168. };
  13169. return State2;
  13170. })()
  13171. );
  13172. var defaultFragment$1 = "varying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void){\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n}\n";
  13173. var defaultVertex$2 = "attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n";
  13174. var Filter = (
  13175. /** @class */
  13176. (function(_super) {
  13177. __extends2(Filter2, _super);
  13178. function Filter2(vertexSrc, fragmentSrc, uniforms) {
  13179. var _this = this;
  13180. var program = Program.from(vertexSrc || Filter2.defaultVertexSrc, fragmentSrc || Filter2.defaultFragmentSrc);
  13181. _this = _super.call(this, program, uniforms) || this;
  13182. _this.padding = 0;
  13183. _this.resolution = settings.FILTER_RESOLUTION;
  13184. _this.multisample = settings.FILTER_MULTISAMPLE;
  13185. _this.enabled = true;
  13186. _this.autoFit = true;
  13187. _this.state = new State();
  13188. return _this;
  13189. }
  13190. Filter2.prototype.apply = function(filterManager, input, output, clearMode, _currentState) {
  13191. filterManager.applyFilter(this, input, output, clearMode);
  13192. };
  13193. Object.defineProperty(Filter2.prototype, "blendMode", {
  13194. /**
  13195. * Sets the blend mode of the filter.
  13196. * @default PIXI.BLEND_MODES.NORMAL
  13197. */
  13198. get: function() {
  13199. return this.state.blendMode;
  13200. },
  13201. set: function(value) {
  13202. this.state.blendMode = value;
  13203. },
  13204. enumerable: false,
  13205. configurable: true
  13206. });
  13207. Object.defineProperty(Filter2.prototype, "resolution", {
  13208. /**
  13209. * The resolution of the filter. Setting this to be lower will lower the quality but
  13210. * increase the performance of the filter.
  13211. */
  13212. get: function() {
  13213. return this._resolution;
  13214. },
  13215. set: function(value) {
  13216. this._resolution = value;
  13217. },
  13218. enumerable: false,
  13219. configurable: true
  13220. });
  13221. Object.defineProperty(Filter2, "defaultVertexSrc", {
  13222. /**
  13223. * The default vertex shader source
  13224. * @constant
  13225. */
  13226. get: function() {
  13227. return defaultVertex$2;
  13228. },
  13229. enumerable: false,
  13230. configurable: true
  13231. });
  13232. Object.defineProperty(Filter2, "defaultFragmentSrc", {
  13233. /**
  13234. * The default fragment shader source
  13235. * @constant
  13236. */
  13237. get: function() {
  13238. return defaultFragment$1;
  13239. },
  13240. enumerable: false,
  13241. configurable: true
  13242. });
  13243. return Filter2;
  13244. })(Shader)
  13245. );
  13246. var vertex = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n}\n";
  13247. var fragment = "varying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D mask;\nuniform float alpha;\nuniform float npmAlpha;\nuniform vec4 maskClamp;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(maskClamp.x, vMaskCoord.x) +\n step(maskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, maskClamp.z) +\n step(vMaskCoord.y, maskClamp.w));\n\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);\n\n original *= (alphaMul * masky.r * alpha * clip);\n\n gl_FragColor = original;\n}\n";
  13248. var tempMat = new Matrix();
  13249. var TextureMatrix = (
  13250. /** @class */
  13251. (function() {
  13252. function TextureMatrix2(texture, clampMargin) {
  13253. this._texture = texture;
  13254. this.mapCoord = new Matrix();
  13255. this.uClampFrame = new Float32Array(4);
  13256. this.uClampOffset = new Float32Array(2);
  13257. this._textureID = -1;
  13258. this._updateID = 0;
  13259. this.clampOffset = 0;
  13260. this.clampMargin = typeof clampMargin === "undefined" ? 0.5 : clampMargin;
  13261. this.isSimple = false;
  13262. }
  13263. Object.defineProperty(TextureMatrix2.prototype, "texture", {
  13264. /** Texture property. */
  13265. get: function() {
  13266. return this._texture;
  13267. },
  13268. set: function(value) {
  13269. this._texture = value;
  13270. this._textureID = -1;
  13271. },
  13272. enumerable: false,
  13273. configurable: true
  13274. });
  13275. TextureMatrix2.prototype.multiplyUvs = function(uvs, out) {
  13276. if (out === void 0) {
  13277. out = uvs;
  13278. }
  13279. var mat = this.mapCoord;
  13280. for (var i = 0; i < uvs.length; i += 2) {
  13281. var x = uvs[i];
  13282. var y = uvs[i + 1];
  13283. out[i] = x * mat.a + y * mat.c + mat.tx;
  13284. out[i + 1] = x * mat.b + y * mat.d + mat.ty;
  13285. }
  13286. return out;
  13287. };
  13288. TextureMatrix2.prototype.update = function(forceUpdate) {
  13289. var tex = this._texture;
  13290. if (!tex || !tex.valid) {
  13291. return false;
  13292. }
  13293. if (!forceUpdate && this._textureID === tex._updateID) {
  13294. return false;
  13295. }
  13296. this._textureID = tex._updateID;
  13297. this._updateID++;
  13298. var uvs = tex._uvs;
  13299. this.mapCoord.set(uvs.x1 - uvs.x0, uvs.y1 - uvs.y0, uvs.x3 - uvs.x0, uvs.y3 - uvs.y0, uvs.x0, uvs.y0);
  13300. var orig = tex.orig;
  13301. var trim = tex.trim;
  13302. if (trim) {
  13303. tempMat.set(orig.width / trim.width, 0, 0, orig.height / trim.height, -trim.x / trim.width, -trim.y / trim.height);
  13304. this.mapCoord.append(tempMat);
  13305. }
  13306. var texBase = tex.baseTexture;
  13307. var frame = this.uClampFrame;
  13308. var margin = this.clampMargin / texBase.resolution;
  13309. var offset = this.clampOffset;
  13310. frame[0] = (tex._frame.x + margin + offset) / texBase.width;
  13311. frame[1] = (tex._frame.y + margin + offset) / texBase.height;
  13312. frame[2] = (tex._frame.x + tex._frame.width - margin + offset) / texBase.width;
  13313. frame[3] = (tex._frame.y + tex._frame.height - margin + offset) / texBase.height;
  13314. this.uClampOffset[0] = offset / texBase.realWidth;
  13315. this.uClampOffset[1] = offset / texBase.realHeight;
  13316. this.isSimple = tex._frame.width === texBase.width && tex._frame.height === texBase.height && tex.rotate === 0;
  13317. return true;
  13318. };
  13319. return TextureMatrix2;
  13320. })()
  13321. );
  13322. var SpriteMaskFilter = (
  13323. /** @class */
  13324. (function(_super) {
  13325. __extends2(SpriteMaskFilter2, _super);
  13326. function SpriteMaskFilter2(vertexSrc, fragmentSrc, uniforms) {
  13327. var _this = this;
  13328. var sprite = null;
  13329. if (typeof vertexSrc !== "string" && fragmentSrc === void 0 && uniforms === void 0) {
  13330. sprite = vertexSrc;
  13331. vertexSrc = void 0;
  13332. fragmentSrc = void 0;
  13333. uniforms = void 0;
  13334. }
  13335. _this = _super.call(this, vertexSrc || vertex, fragmentSrc || fragment, uniforms) || this;
  13336. _this.maskSprite = sprite;
  13337. _this.maskMatrix = new Matrix();
  13338. return _this;
  13339. }
  13340. Object.defineProperty(SpriteMaskFilter2.prototype, "maskSprite", {
  13341. /**
  13342. * Sprite mask
  13343. * @type {PIXI.DisplayObject}
  13344. */
  13345. get: function() {
  13346. return this._maskSprite;
  13347. },
  13348. set: function(value) {
  13349. this._maskSprite = value;
  13350. if (this._maskSprite) {
  13351. this._maskSprite.renderable = false;
  13352. }
  13353. },
  13354. enumerable: false,
  13355. configurable: true
  13356. });
  13357. SpriteMaskFilter2.prototype.apply = function(filterManager, input, output, clearMode) {
  13358. var maskSprite = this._maskSprite;
  13359. var tex = maskSprite._texture;
  13360. if (!tex.valid) {
  13361. return;
  13362. }
  13363. if (!tex.uvMatrix) {
  13364. tex.uvMatrix = new TextureMatrix(tex, 0);
  13365. }
  13366. tex.uvMatrix.update();
  13367. this.uniforms.npmAlpha = tex.baseTexture.alphaMode ? 0 : 1;
  13368. this.uniforms.mask = tex;
  13369. this.uniforms.otherMatrix = filterManager.calculateSpriteMatrix(this.maskMatrix, maskSprite).prepend(tex.uvMatrix.mapCoord);
  13370. this.uniforms.alpha = maskSprite.worldAlpha;
  13371. this.uniforms.maskClamp = tex.uvMatrix.uClampFrame;
  13372. filterManager.applyFilter(this, input, output, clearMode);
  13373. };
  13374. return SpriteMaskFilter2;
  13375. })(Filter)
  13376. );
  13377. var MaskSystem = (
  13378. /** @class */
  13379. (function() {
  13380. function MaskSystem2(renderer) {
  13381. this.renderer = renderer;
  13382. this.enableScissor = true;
  13383. this.alphaMaskPool = [];
  13384. this.maskDataPool = [];
  13385. this.maskStack = [];
  13386. this.alphaMaskIndex = 0;
  13387. }
  13388. MaskSystem2.prototype.setMaskStack = function(maskStack) {
  13389. this.maskStack = maskStack;
  13390. this.renderer.scissor.setMaskStack(maskStack);
  13391. this.renderer.stencil.setMaskStack(maskStack);
  13392. };
  13393. MaskSystem2.prototype.push = function(target, maskDataOrTarget) {
  13394. var maskData = maskDataOrTarget;
  13395. if (!maskData.isMaskData) {
  13396. var d = this.maskDataPool.pop() || new MaskData();
  13397. d.pooled = true;
  13398. d.maskObject = maskDataOrTarget;
  13399. maskData = d;
  13400. }
  13401. var maskAbove = this.maskStack.length !== 0 ? this.maskStack[this.maskStack.length - 1] : null;
  13402. maskData.copyCountersOrReset(maskAbove);
  13403. maskData._colorMask = maskAbove ? maskAbove._colorMask : 15;
  13404. if (maskData.autoDetect) {
  13405. this.detect(maskData);
  13406. }
  13407. maskData._target = target;
  13408. if (maskData.type !== MASK_TYPES.SPRITE) {
  13409. this.maskStack.push(maskData);
  13410. }
  13411. if (maskData.enabled) {
  13412. switch (maskData.type) {
  13413. case MASK_TYPES.SCISSOR:
  13414. this.renderer.scissor.push(maskData);
  13415. break;
  13416. case MASK_TYPES.STENCIL:
  13417. this.renderer.stencil.push(maskData);
  13418. break;
  13419. case MASK_TYPES.SPRITE:
  13420. maskData.copyCountersOrReset(null);
  13421. this.pushSpriteMask(maskData);
  13422. break;
  13423. case MASK_TYPES.COLOR:
  13424. this.pushColorMask(maskData);
  13425. break;
  13426. }
  13427. }
  13428. if (maskData.type === MASK_TYPES.SPRITE) {
  13429. this.maskStack.push(maskData);
  13430. }
  13431. };
  13432. MaskSystem2.prototype.pop = function(target) {
  13433. var maskData = this.maskStack.pop();
  13434. if (!maskData || maskData._target !== target) {
  13435. return;
  13436. }
  13437. if (maskData.enabled) {
  13438. switch (maskData.type) {
  13439. case MASK_TYPES.SCISSOR:
  13440. this.renderer.scissor.pop(maskData);
  13441. break;
  13442. case MASK_TYPES.STENCIL:
  13443. this.renderer.stencil.pop(maskData.maskObject);
  13444. break;
  13445. case MASK_TYPES.SPRITE:
  13446. this.popSpriteMask(maskData);
  13447. break;
  13448. case MASK_TYPES.COLOR:
  13449. this.popColorMask(maskData);
  13450. break;
  13451. }
  13452. }
  13453. maskData.reset();
  13454. if (maskData.pooled) {
  13455. this.maskDataPool.push(maskData);
  13456. }
  13457. if (this.maskStack.length !== 0) {
  13458. var maskCurrent = this.maskStack[this.maskStack.length - 1];
  13459. if (maskCurrent.type === MASK_TYPES.SPRITE && maskCurrent._filters) {
  13460. maskCurrent._filters[0].maskSprite = maskCurrent.maskObject;
  13461. }
  13462. }
  13463. };
  13464. MaskSystem2.prototype.detect = function(maskData) {
  13465. var maskObject = maskData.maskObject;
  13466. if (!maskObject) {
  13467. maskData.type = MASK_TYPES.COLOR;
  13468. } else if (maskObject.isSprite) {
  13469. maskData.type = MASK_TYPES.SPRITE;
  13470. } else if (this.enableScissor && this.renderer.scissor.testScissor(maskData)) {
  13471. maskData.type = MASK_TYPES.SCISSOR;
  13472. } else {
  13473. maskData.type = MASK_TYPES.STENCIL;
  13474. }
  13475. };
  13476. MaskSystem2.prototype.pushSpriteMask = function(maskData) {
  13477. var _a, _b;
  13478. var maskObject = maskData.maskObject;
  13479. var target = maskData._target;
  13480. var alphaMaskFilter = maskData._filters;
  13481. if (!alphaMaskFilter) {
  13482. alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex];
  13483. if (!alphaMaskFilter) {
  13484. alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex] = [new SpriteMaskFilter()];
  13485. }
  13486. }
  13487. var renderer = this.renderer;
  13488. var renderTextureSystem = renderer.renderTexture;
  13489. var resolution;
  13490. var multisample;
  13491. if (renderTextureSystem.current) {
  13492. var renderTexture = renderTextureSystem.current;
  13493. resolution = maskData.resolution || renderTexture.resolution;
  13494. multisample = (_a = maskData.multisample) !== null && _a !== void 0 ? _a : renderTexture.multisample;
  13495. } else {
  13496. resolution = maskData.resolution || renderer.resolution;
  13497. multisample = (_b = maskData.multisample) !== null && _b !== void 0 ? _b : renderer.multisample;
  13498. }
  13499. alphaMaskFilter[0].resolution = resolution;
  13500. alphaMaskFilter[0].multisample = multisample;
  13501. alphaMaskFilter[0].maskSprite = maskObject;
  13502. var stashFilterArea = target.filterArea;
  13503. target.filterArea = maskObject.getBounds(true);
  13504. renderer.filter.push(target, alphaMaskFilter);
  13505. target.filterArea = stashFilterArea;
  13506. if (!maskData._filters) {
  13507. this.alphaMaskIndex++;
  13508. }
  13509. };
  13510. MaskSystem2.prototype.popSpriteMask = function(maskData) {
  13511. this.renderer.filter.pop();
  13512. if (maskData._filters) {
  13513. maskData._filters[0].maskSprite = null;
  13514. } else {
  13515. this.alphaMaskIndex--;
  13516. this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite = null;
  13517. }
  13518. };
  13519. MaskSystem2.prototype.pushColorMask = function(maskData) {
  13520. var currColorMask = maskData._colorMask;
  13521. var nextColorMask = maskData._colorMask = currColorMask & maskData.colorMask;
  13522. if (nextColorMask !== currColorMask) {
  13523. this.renderer.gl.colorMask((nextColorMask & 1) !== 0, (nextColorMask & 2) !== 0, (nextColorMask & 4) !== 0, (nextColorMask & 8) !== 0);
  13524. }
  13525. };
  13526. MaskSystem2.prototype.popColorMask = function(maskData) {
  13527. var currColorMask = maskData._colorMask;
  13528. var nextColorMask = this.maskStack.length > 0 ? this.maskStack[this.maskStack.length - 1]._colorMask : 15;
  13529. if (nextColorMask !== currColorMask) {
  13530. this.renderer.gl.colorMask((nextColorMask & 1) !== 0, (nextColorMask & 2) !== 0, (nextColorMask & 4) !== 0, (nextColorMask & 8) !== 0);
  13531. }
  13532. };
  13533. MaskSystem2.prototype.destroy = function() {
  13534. this.renderer = null;
  13535. };
  13536. return MaskSystem2;
  13537. })()
  13538. );
  13539. var AbstractMaskSystem = (
  13540. /** @class */
  13541. (function() {
  13542. function AbstractMaskSystem2(renderer) {
  13543. this.renderer = renderer;
  13544. this.maskStack = [];
  13545. this.glConst = 0;
  13546. }
  13547. AbstractMaskSystem2.prototype.getStackLength = function() {
  13548. return this.maskStack.length;
  13549. };
  13550. AbstractMaskSystem2.prototype.setMaskStack = function(maskStack) {
  13551. var gl = this.renderer.gl;
  13552. var curStackLen = this.getStackLength();
  13553. this.maskStack = maskStack;
  13554. var newStackLen = this.getStackLength();
  13555. if (newStackLen !== curStackLen) {
  13556. if (newStackLen === 0) {
  13557. gl.disable(this.glConst);
  13558. } else {
  13559. gl.enable(this.glConst);
  13560. this._useCurrent();
  13561. }
  13562. }
  13563. };
  13564. AbstractMaskSystem2.prototype._useCurrent = function() {
  13565. };
  13566. AbstractMaskSystem2.prototype.destroy = function() {
  13567. this.renderer = null;
  13568. this.maskStack = null;
  13569. };
  13570. return AbstractMaskSystem2;
  13571. })()
  13572. );
  13573. var tempMatrix$1 = new Matrix();
  13574. var rectPool = [];
  13575. var ScissorSystem = (
  13576. /** @class */
  13577. (function(_super) {
  13578. __extends2(ScissorSystem2, _super);
  13579. function ScissorSystem2(renderer) {
  13580. var _this = _super.call(this, renderer) || this;
  13581. _this.glConst = settings.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST;
  13582. return _this;
  13583. }
  13584. ScissorSystem2.prototype.getStackLength = function() {
  13585. var maskData = this.maskStack[this.maskStack.length - 1];
  13586. if (maskData) {
  13587. return maskData._scissorCounter;
  13588. }
  13589. return 0;
  13590. };
  13591. ScissorSystem2.prototype.calcScissorRect = function(maskData) {
  13592. var _a;
  13593. if (maskData._scissorRectLocal) {
  13594. return;
  13595. }
  13596. var prevData = maskData._scissorRect;
  13597. var maskObject = maskData.maskObject;
  13598. var renderer = this.renderer;
  13599. var renderTextureSystem = renderer.renderTexture;
  13600. var rect = maskObject.getBounds(true, (_a = rectPool.pop()) !== null && _a !== void 0 ? _a : new Rectangle());
  13601. this.roundFrameToPixels(rect, renderTextureSystem.current ? renderTextureSystem.current.resolution : renderer.resolution, renderTextureSystem.sourceFrame, renderTextureSystem.destinationFrame, renderer.projection.transform);
  13602. if (prevData) {
  13603. rect.fit(prevData);
  13604. }
  13605. maskData._scissorRectLocal = rect;
  13606. };
  13607. ScissorSystem2.isMatrixRotated = function(matrix) {
  13608. if (!matrix) {
  13609. return false;
  13610. }
  13611. var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d;
  13612. return (Math.abs(b) > 1e-4 || Math.abs(c) > 1e-4) && (Math.abs(a) > 1e-4 || Math.abs(d) > 1e-4);
  13613. };
  13614. ScissorSystem2.prototype.testScissor = function(maskData) {
  13615. var maskObject = maskData.maskObject;
  13616. if (!maskObject.isFastRect || !maskObject.isFastRect()) {
  13617. return false;
  13618. }
  13619. if (ScissorSystem2.isMatrixRotated(maskObject.worldTransform)) {
  13620. return false;
  13621. }
  13622. if (ScissorSystem2.isMatrixRotated(this.renderer.projection.transform)) {
  13623. return false;
  13624. }
  13625. this.calcScissorRect(maskData);
  13626. var rect = maskData._scissorRectLocal;
  13627. return rect.width > 0 && rect.height > 0;
  13628. };
  13629. ScissorSystem2.prototype.roundFrameToPixels = function(frame, resolution, bindingSourceFrame, bindingDestinationFrame, transform) {
  13630. if (ScissorSystem2.isMatrixRotated(transform)) {
  13631. return;
  13632. }
  13633. transform = transform ? tempMatrix$1.copyFrom(transform) : tempMatrix$1.identity();
  13634. transform.translate(-bindingSourceFrame.x, -bindingSourceFrame.y).scale(bindingDestinationFrame.width / bindingSourceFrame.width, bindingDestinationFrame.height / bindingSourceFrame.height).translate(bindingDestinationFrame.x, bindingDestinationFrame.y);
  13635. this.renderer.filter.transformAABB(transform, frame);
  13636. frame.fit(bindingDestinationFrame);
  13637. frame.x = Math.round(frame.x * resolution);
  13638. frame.y = Math.round(frame.y * resolution);
  13639. frame.width = Math.round(frame.width * resolution);
  13640. frame.height = Math.round(frame.height * resolution);
  13641. };
  13642. ScissorSystem2.prototype.push = function(maskData) {
  13643. if (!maskData._scissorRectLocal) {
  13644. this.calcScissorRect(maskData);
  13645. }
  13646. var gl = this.renderer.gl;
  13647. if (!maskData._scissorRect) {
  13648. gl.enable(gl.SCISSOR_TEST);
  13649. }
  13650. maskData._scissorCounter++;
  13651. maskData._scissorRect = maskData._scissorRectLocal;
  13652. this._useCurrent();
  13653. };
  13654. ScissorSystem2.prototype.pop = function(maskData) {
  13655. var gl = this.renderer.gl;
  13656. if (maskData) {
  13657. rectPool.push(maskData._scissorRectLocal);
  13658. }
  13659. if (this.getStackLength() > 0) {
  13660. this._useCurrent();
  13661. } else {
  13662. gl.disable(gl.SCISSOR_TEST);
  13663. }
  13664. };
  13665. ScissorSystem2.prototype._useCurrent = function() {
  13666. var rect = this.maskStack[this.maskStack.length - 1]._scissorRect;
  13667. var y;
  13668. if (this.renderer.renderTexture.current) {
  13669. y = rect.y;
  13670. } else {
  13671. y = this.renderer.height - rect.height - rect.y;
  13672. }
  13673. this.renderer.gl.scissor(rect.x, y, rect.width, rect.height);
  13674. };
  13675. return ScissorSystem2;
  13676. })(AbstractMaskSystem)
  13677. );
  13678. var StencilSystem = (
  13679. /** @class */
  13680. (function(_super) {
  13681. __extends2(StencilSystem2, _super);
  13682. function StencilSystem2(renderer) {
  13683. var _this = _super.call(this, renderer) || this;
  13684. _this.glConst = settings.ADAPTER.getWebGLRenderingContext().STENCIL_TEST;
  13685. return _this;
  13686. }
  13687. StencilSystem2.prototype.getStackLength = function() {
  13688. var maskData = this.maskStack[this.maskStack.length - 1];
  13689. if (maskData) {
  13690. return maskData._stencilCounter;
  13691. }
  13692. return 0;
  13693. };
  13694. StencilSystem2.prototype.push = function(maskData) {
  13695. var maskObject = maskData.maskObject;
  13696. var gl = this.renderer.gl;
  13697. var prevMaskCount = maskData._stencilCounter;
  13698. if (prevMaskCount === 0) {
  13699. this.renderer.framebuffer.forceStencil();
  13700. gl.clearStencil(0);
  13701. gl.clear(gl.STENCIL_BUFFER_BIT);
  13702. gl.enable(gl.STENCIL_TEST);
  13703. }
  13704. maskData._stencilCounter++;
  13705. var colorMask = maskData._colorMask;
  13706. if (colorMask !== 0) {
  13707. maskData._colorMask = 0;
  13708. gl.colorMask(false, false, false, false);
  13709. }
  13710. gl.stencilFunc(gl.EQUAL, prevMaskCount, 4294967295);
  13711. gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR);
  13712. maskObject.renderable = true;
  13713. maskObject.render(this.renderer);
  13714. this.renderer.batch.flush();
  13715. maskObject.renderable = false;
  13716. if (colorMask !== 0) {
  13717. maskData._colorMask = colorMask;
  13718. gl.colorMask((colorMask & 1) !== 0, (colorMask & 2) !== 0, (colorMask & 4) !== 0, (colorMask & 8) !== 0);
  13719. }
  13720. this._useCurrent();
  13721. };
  13722. StencilSystem2.prototype.pop = function(maskObject) {
  13723. var gl = this.renderer.gl;
  13724. if (this.getStackLength() === 0) {
  13725. gl.disable(gl.STENCIL_TEST);
  13726. } else {
  13727. var maskData = this.maskStack.length !== 0 ? this.maskStack[this.maskStack.length - 1] : null;
  13728. var colorMask = maskData ? maskData._colorMask : 15;
  13729. if (colorMask !== 0) {
  13730. maskData._colorMask = 0;
  13731. gl.colorMask(false, false, false, false);
  13732. }
  13733. gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR);
  13734. maskObject.renderable = true;
  13735. maskObject.render(this.renderer);
  13736. this.renderer.batch.flush();
  13737. maskObject.renderable = false;
  13738. if (colorMask !== 0) {
  13739. maskData._colorMask = colorMask;
  13740. gl.colorMask((colorMask & 1) !== 0, (colorMask & 2) !== 0, (colorMask & 4) !== 0, (colorMask & 8) !== 0);
  13741. }
  13742. this._useCurrent();
  13743. }
  13744. };
  13745. StencilSystem2.prototype._useCurrent = function() {
  13746. var gl = this.renderer.gl;
  13747. gl.stencilFunc(gl.EQUAL, this.getStackLength(), 4294967295);
  13748. gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
  13749. };
  13750. return StencilSystem2;
  13751. })(AbstractMaskSystem)
  13752. );
  13753. var ProjectionSystem = (
  13754. /** @class */
  13755. (function() {
  13756. function ProjectionSystem2(renderer) {
  13757. this.renderer = renderer;
  13758. this.destinationFrame = null;
  13759. this.sourceFrame = null;
  13760. this.defaultFrame = null;
  13761. this.projectionMatrix = new Matrix();
  13762. this.transform = null;
  13763. }
  13764. ProjectionSystem2.prototype.update = function(destinationFrame, sourceFrame, resolution, root) {
  13765. this.destinationFrame = destinationFrame || this.destinationFrame || this.defaultFrame;
  13766. this.sourceFrame = sourceFrame || this.sourceFrame || destinationFrame;
  13767. this.calculateProjection(this.destinationFrame, this.sourceFrame, resolution, root);
  13768. if (this.transform) {
  13769. this.projectionMatrix.append(this.transform);
  13770. }
  13771. var renderer = this.renderer;
  13772. renderer.globalUniforms.uniforms.projectionMatrix = this.projectionMatrix;
  13773. renderer.globalUniforms.update();
  13774. if (renderer.shader.shader) {
  13775. renderer.shader.syncUniformGroup(renderer.shader.shader.uniforms.globals);
  13776. }
  13777. };
  13778. ProjectionSystem2.prototype.calculateProjection = function(_destinationFrame, sourceFrame, _resolution, root) {
  13779. var pm = this.projectionMatrix;
  13780. var sign2 = !root ? 1 : -1;
  13781. pm.identity();
  13782. pm.a = 1 / sourceFrame.width * 2;
  13783. pm.d = sign2 * (1 / sourceFrame.height * 2);
  13784. pm.tx = -1 - sourceFrame.x * pm.a;
  13785. pm.ty = -sign2 - sourceFrame.y * pm.d;
  13786. };
  13787. ProjectionSystem2.prototype.setTransform = function(_matrix) {
  13788. };
  13789. ProjectionSystem2.prototype.destroy = function() {
  13790. this.renderer = null;
  13791. };
  13792. return ProjectionSystem2;
  13793. })()
  13794. );
  13795. var tempRect = new Rectangle();
  13796. var tempRect2 = new Rectangle();
  13797. var RenderTextureSystem = (
  13798. /** @class */
  13799. (function() {
  13800. function RenderTextureSystem2(renderer) {
  13801. this.renderer = renderer;
  13802. this.clearColor = renderer._backgroundColorRgba;
  13803. this.defaultMaskStack = [];
  13804. this.current = null;
  13805. this.sourceFrame = new Rectangle();
  13806. this.destinationFrame = new Rectangle();
  13807. this.viewportFrame = new Rectangle();
  13808. }
  13809. RenderTextureSystem2.prototype.bind = function(renderTexture, sourceFrame, destinationFrame) {
  13810. if (renderTexture === void 0) {
  13811. renderTexture = null;
  13812. }
  13813. var renderer = this.renderer;
  13814. this.current = renderTexture;
  13815. var baseTexture;
  13816. var framebuffer;
  13817. var resolution;
  13818. if (renderTexture) {
  13819. baseTexture = renderTexture.baseTexture;
  13820. resolution = baseTexture.resolution;
  13821. if (!sourceFrame) {
  13822. tempRect.width = renderTexture.frame.width;
  13823. tempRect.height = renderTexture.frame.height;
  13824. sourceFrame = tempRect;
  13825. }
  13826. if (!destinationFrame) {
  13827. tempRect2.x = renderTexture.frame.x;
  13828. tempRect2.y = renderTexture.frame.y;
  13829. tempRect2.width = sourceFrame.width;
  13830. tempRect2.height = sourceFrame.height;
  13831. destinationFrame = tempRect2;
  13832. }
  13833. framebuffer = baseTexture.framebuffer;
  13834. } else {
  13835. resolution = renderer.resolution;
  13836. if (!sourceFrame) {
  13837. tempRect.width = renderer.screen.width;
  13838. tempRect.height = renderer.screen.height;
  13839. sourceFrame = tempRect;
  13840. }
  13841. if (!destinationFrame) {
  13842. destinationFrame = tempRect;
  13843. destinationFrame.width = sourceFrame.width;
  13844. destinationFrame.height = sourceFrame.height;
  13845. }
  13846. }
  13847. var viewportFrame = this.viewportFrame;
  13848. viewportFrame.x = destinationFrame.x * resolution;
  13849. viewportFrame.y = destinationFrame.y * resolution;
  13850. viewportFrame.width = destinationFrame.width * resolution;
  13851. viewportFrame.height = destinationFrame.height * resolution;
  13852. if (!renderTexture) {
  13853. viewportFrame.y = renderer.view.height - (viewportFrame.y + viewportFrame.height);
  13854. }
  13855. viewportFrame.ceil();
  13856. this.renderer.framebuffer.bind(framebuffer, viewportFrame);
  13857. this.renderer.projection.update(destinationFrame, sourceFrame, resolution, !framebuffer);
  13858. if (renderTexture) {
  13859. this.renderer.mask.setMaskStack(baseTexture.maskStack);
  13860. } else {
  13861. this.renderer.mask.setMaskStack(this.defaultMaskStack);
  13862. }
  13863. this.sourceFrame.copyFrom(sourceFrame);
  13864. this.destinationFrame.copyFrom(destinationFrame);
  13865. };
  13866. RenderTextureSystem2.prototype.clear = function(clearColor, mask) {
  13867. if (this.current) {
  13868. clearColor = clearColor || this.current.baseTexture.clearColor;
  13869. } else {
  13870. clearColor = clearColor || this.clearColor;
  13871. }
  13872. var destinationFrame = this.destinationFrame;
  13873. var baseFrame = this.current ? this.current.baseTexture : this.renderer.screen;
  13874. var clearMask = destinationFrame.width !== baseFrame.width || destinationFrame.height !== baseFrame.height;
  13875. if (clearMask) {
  13876. var _a = this.viewportFrame, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
  13877. x = Math.round(x);
  13878. y = Math.round(y);
  13879. width = Math.round(width);
  13880. height = Math.round(height);
  13881. this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST);
  13882. this.renderer.gl.scissor(x, y, width, height);
  13883. }
  13884. this.renderer.framebuffer.clear(clearColor[0], clearColor[1], clearColor[2], clearColor[3], mask);
  13885. if (clearMask) {
  13886. this.renderer.scissor.pop();
  13887. }
  13888. };
  13889. RenderTextureSystem2.prototype.resize = function() {
  13890. this.bind(null);
  13891. };
  13892. RenderTextureSystem2.prototype.reset = function() {
  13893. this.bind(null);
  13894. };
  13895. RenderTextureSystem2.prototype.destroy = function() {
  13896. this.renderer = null;
  13897. };
  13898. return RenderTextureSystem2;
  13899. })()
  13900. );
  13901. function uboUpdate(_ud, _uv, _renderer, _syncData, buffer) {
  13902. _renderer.buffer.update(buffer);
  13903. }
  13904. var UBO_TO_SINGLE_SETTERS = {
  13905. float: "\n data[offset] = v;\n ",
  13906. vec2: "\n data[offset] = v[0];\n data[offset+1] = v[1];\n ",
  13907. vec3: "\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n\n ",
  13908. vec4: "\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n data[offset+3] = v[3];\n ",
  13909. mat2: "\n data[offset] = v[0];\n data[offset+1] = v[1];\n\n data[offset+4] = v[2];\n data[offset+5] = v[3];\n ",
  13910. mat3: "\n data[offset] = v[0];\n data[offset+1] = v[1];\n data[offset+2] = v[2];\n\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];\n ",
  13911. mat4: "\n for(var i = 0; i < 16; i++)\n {\n data[offset + i] = v[i];\n }\n "
  13912. };
  13913. var GLSL_TO_STD40_SIZE = {
  13914. float: 4,
  13915. vec2: 8,
  13916. vec3: 12,
  13917. vec4: 16,
  13918. int: 4,
  13919. ivec2: 8,
  13920. ivec3: 12,
  13921. ivec4: 16,
  13922. uint: 4,
  13923. uvec2: 8,
  13924. uvec3: 12,
  13925. uvec4: 16,
  13926. bool: 4,
  13927. bvec2: 8,
  13928. bvec3: 12,
  13929. bvec4: 16,
  13930. mat2: 16 * 2,
  13931. mat3: 16 * 3,
  13932. mat4: 16 * 4
  13933. };
  13934. function createUBOElements(uniformData) {
  13935. var uboElements = uniformData.map(function(data) {
  13936. return {
  13937. data,
  13938. offset: 0,
  13939. dataLen: 0,
  13940. dirty: 0
  13941. };
  13942. });
  13943. var size = 0;
  13944. var chunkSize = 0;
  13945. var offset = 0;
  13946. for (var i = 0; i < uboElements.length; i++) {
  13947. var uboElement = uboElements[i];
  13948. size = GLSL_TO_STD40_SIZE[uboElement.data.type];
  13949. if (uboElement.data.size > 1) {
  13950. size = Math.max(size, 16) * uboElement.data.size;
  13951. }
  13952. uboElement.dataLen = size;
  13953. if (chunkSize % size !== 0 && chunkSize < 16) {
  13954. var lineUpValue = chunkSize % size % 16;
  13955. chunkSize += lineUpValue;
  13956. offset += lineUpValue;
  13957. }
  13958. if (chunkSize + size > 16) {
  13959. offset = Math.ceil(offset / 16) * 16;
  13960. uboElement.offset = offset;
  13961. offset += size;
  13962. chunkSize = size;
  13963. } else {
  13964. uboElement.offset = offset;
  13965. chunkSize += size;
  13966. offset += size;
  13967. }
  13968. }
  13969. offset = Math.ceil(offset / 16) * 16;
  13970. return { uboElements, size: offset };
  13971. }
  13972. function getUBOData(uniforms, uniformData) {
  13973. var usedUniformDatas = [];
  13974. for (var i in uniforms) {
  13975. if (uniformData[i]) {
  13976. usedUniformDatas.push(uniformData[i]);
  13977. }
  13978. }
  13979. usedUniformDatas.sort(function(a, b) {
  13980. return a.index - b.index;
  13981. });
  13982. return usedUniformDatas;
  13983. }
  13984. function generateUniformBufferSync(group, uniformData) {
  13985. if (!group.autoManage) {
  13986. return { size: 0, syncFunc: uboUpdate };
  13987. }
  13988. var usedUniformDatas = getUBOData(group.uniforms, uniformData);
  13989. var _a = createUBOElements(usedUniformDatas), uboElements = _a.uboElements, size = _a.size;
  13990. var funcFragments = ["\n var v = null;\n var v2 = null;\n var cv = null;\n var t = 0;\n var gl = renderer.gl\n var index = 0;\n var data = buffer.data;\n "];
  13991. for (var i = 0; i < uboElements.length; i++) {
  13992. var uboElement = uboElements[i];
  13993. var uniform = group.uniforms[uboElement.data.name];
  13994. var name = uboElement.data.name;
  13995. var parsed = false;
  13996. for (var j = 0; j < uniformParsers.length; j++) {
  13997. var uniformParser = uniformParsers[j];
  13998. if (uniformParser.codeUbo && uniformParser.test(uboElement.data, uniform)) {
  13999. funcFragments.push("offset = " + uboElement.offset / 4 + ";", uniformParsers[j].codeUbo(uboElement.data.name, uniform));
  14000. parsed = true;
  14001. break;
  14002. }
  14003. }
  14004. if (!parsed) {
  14005. if (uboElement.data.size > 1) {
  14006. var size_1 = mapSize(uboElement.data.type);
  14007. var rowSize = Math.max(GLSL_TO_STD40_SIZE[uboElement.data.type] / 16, 1);
  14008. var elementSize = size_1 / rowSize;
  14009. var remainder = (4 - elementSize % 4) % 4;
  14010. funcFragments.push("\n cv = ud." + name + ".value;\n v = uv." + name + ";\n offset = " + uboElement.offset / 4 + ";\n\n t = 0;\n\n for(var i=0; i < " + uboElement.data.size * rowSize + "; i++)\n {\n for(var j = 0; j < " + elementSize + "; j++)\n {\n data[offset++] = v[t++];\n }\n offset += " + remainder + ";\n }\n\n ");
  14011. } else {
  14012. var template = UBO_TO_SINGLE_SETTERS[uboElement.data.type];
  14013. funcFragments.push("\n cv = ud." + name + ".value;\n v = uv." + name + ";\n offset = " + uboElement.offset / 4 + ";\n " + template + ";\n ");
  14014. }
  14015. }
  14016. }
  14017. funcFragments.push("\n renderer.buffer.update(buffer);\n ");
  14018. return {
  14019. size,
  14020. // eslint-disable-next-line no-new-func
  14021. syncFunc: new Function("ud", "uv", "renderer", "syncData", "buffer", funcFragments.join("\n"))
  14022. };
  14023. }
  14024. var IGLUniformData = (
  14025. /** @class */
  14026. /* @__PURE__ */ (function() {
  14027. function IGLUniformData2() {
  14028. }
  14029. return IGLUniformData2;
  14030. })()
  14031. );
  14032. var GLProgram = (
  14033. /** @class */
  14034. (function() {
  14035. function GLProgram2(program, uniformData) {
  14036. this.program = program;
  14037. this.uniformData = uniformData;
  14038. this.uniformGroups = {};
  14039. this.uniformDirtyGroups = {};
  14040. this.uniformBufferBindings = {};
  14041. }
  14042. GLProgram2.prototype.destroy = function() {
  14043. this.uniformData = null;
  14044. this.uniformGroups = null;
  14045. this.uniformDirtyGroups = null;
  14046. this.uniformBufferBindings = null;
  14047. this.program = null;
  14048. };
  14049. return GLProgram2;
  14050. })()
  14051. );
  14052. function getAttributeData(program, gl) {
  14053. var attributes = {};
  14054. var totalAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
  14055. for (var i = 0; i < totalAttributes; i++) {
  14056. var attribData = gl.getActiveAttrib(program, i);
  14057. if (attribData.name.indexOf("gl_") === 0) {
  14058. continue;
  14059. }
  14060. var type = mapType(gl, attribData.type);
  14061. var data = {
  14062. type,
  14063. name: attribData.name,
  14064. size: mapSize(type),
  14065. location: gl.getAttribLocation(program, attribData.name)
  14066. };
  14067. attributes[attribData.name] = data;
  14068. }
  14069. return attributes;
  14070. }
  14071. function getUniformData(program, gl) {
  14072. var uniforms = {};
  14073. var totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
  14074. for (var i = 0; i < totalUniforms; i++) {
  14075. var uniformData = gl.getActiveUniform(program, i);
  14076. var name = uniformData.name.replace(/\[.*?\]$/, "");
  14077. var isArray = !!uniformData.name.match(/\[.*?\]$/);
  14078. var type = mapType(gl, uniformData.type);
  14079. uniforms[name] = {
  14080. name,
  14081. index: i,
  14082. type,
  14083. size: uniformData.size,
  14084. isArray,
  14085. value: defaultValue(type, uniformData.size)
  14086. };
  14087. }
  14088. return uniforms;
  14089. }
  14090. function generateProgram(gl, program) {
  14091. var glVertShader = compileShader(gl, gl.VERTEX_SHADER, program.vertexSrc);
  14092. var glFragShader = compileShader(gl, gl.FRAGMENT_SHADER, program.fragmentSrc);
  14093. var webGLProgram = gl.createProgram();
  14094. gl.attachShader(webGLProgram, glVertShader);
  14095. gl.attachShader(webGLProgram, glFragShader);
  14096. gl.linkProgram(webGLProgram);
  14097. if (!gl.getProgramParameter(webGLProgram, gl.LINK_STATUS)) {
  14098. logProgramError(gl, webGLProgram, glVertShader, glFragShader);
  14099. }
  14100. program.attributeData = getAttributeData(webGLProgram, gl);
  14101. program.uniformData = getUniformData(webGLProgram, gl);
  14102. if (!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(program.vertexSrc)) {
  14103. var keys = Object.keys(program.attributeData);
  14104. keys.sort(function(a, b) {
  14105. return a > b ? 1 : -1;
  14106. });
  14107. for (var i = 0; i < keys.length; i++) {
  14108. program.attributeData[keys[i]].location = i;
  14109. gl.bindAttribLocation(webGLProgram, i, keys[i]);
  14110. }
  14111. gl.linkProgram(webGLProgram);
  14112. }
  14113. gl.deleteShader(glVertShader);
  14114. gl.deleteShader(glFragShader);
  14115. var uniformData = {};
  14116. for (var i in program.uniformData) {
  14117. var data = program.uniformData[i];
  14118. uniformData[i] = {
  14119. location: gl.getUniformLocation(webGLProgram, i),
  14120. value: defaultValue(data.type, data.size)
  14121. };
  14122. }
  14123. var glProgram = new GLProgram(webGLProgram, uniformData);
  14124. return glProgram;
  14125. }
  14126. var UID = 0;
  14127. var defaultSyncData = { textureCount: 0, uboCount: 0 };
  14128. var ShaderSystem = (
  14129. /** @class */
  14130. (function() {
  14131. function ShaderSystem2(renderer) {
  14132. this.destroyed = false;
  14133. this.renderer = renderer;
  14134. this.systemCheck();
  14135. this.gl = null;
  14136. this.shader = null;
  14137. this.program = null;
  14138. this.cache = {};
  14139. this._uboCache = {};
  14140. this.id = UID++;
  14141. }
  14142. ShaderSystem2.prototype.systemCheck = function() {
  14143. if (!unsafeEvalSupported()) {
  14144. throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.");
  14145. }
  14146. };
  14147. ShaderSystem2.prototype.contextChange = function(gl) {
  14148. this.gl = gl;
  14149. this.reset();
  14150. };
  14151. ShaderSystem2.prototype.bind = function(shader, dontSync) {
  14152. shader.disposeRunner.add(this);
  14153. shader.uniforms.globals = this.renderer.globalUniforms;
  14154. var program = shader.program;
  14155. var glProgram = program.glPrograms[this.renderer.CONTEXT_UID] || this.generateProgram(shader);
  14156. this.shader = shader;
  14157. if (this.program !== program) {
  14158. this.program = program;
  14159. this.gl.useProgram(glProgram.program);
  14160. }
  14161. if (!dontSync) {
  14162. defaultSyncData.textureCount = 0;
  14163. defaultSyncData.uboCount = 0;
  14164. this.syncUniformGroup(shader.uniformGroup, defaultSyncData);
  14165. }
  14166. return glProgram;
  14167. };
  14168. ShaderSystem2.prototype.setUniforms = function(uniforms) {
  14169. var shader = this.shader.program;
  14170. var glProgram = shader.glPrograms[this.renderer.CONTEXT_UID];
  14171. shader.syncUniforms(glProgram.uniformData, uniforms, this.renderer);
  14172. };
  14173. ShaderSystem2.prototype.syncUniformGroup = function(group, syncData) {
  14174. var glProgram = this.getGlProgram();
  14175. if (!group.static || group.dirtyId !== glProgram.uniformDirtyGroups[group.id]) {
  14176. glProgram.uniformDirtyGroups[group.id] = group.dirtyId;
  14177. this.syncUniforms(group, glProgram, syncData);
  14178. }
  14179. };
  14180. ShaderSystem2.prototype.syncUniforms = function(group, glProgram, syncData) {
  14181. var syncFunc = group.syncUniforms[this.shader.program.id] || this.createSyncGroups(group);
  14182. syncFunc(glProgram.uniformData, group.uniforms, this.renderer, syncData);
  14183. };
  14184. ShaderSystem2.prototype.createSyncGroups = function(group) {
  14185. var id = this.getSignature(group, this.shader.program.uniformData, "u");
  14186. if (!this.cache[id]) {
  14187. this.cache[id] = generateUniformsSync(group, this.shader.program.uniformData);
  14188. }
  14189. group.syncUniforms[this.shader.program.id] = this.cache[id];
  14190. return group.syncUniforms[this.shader.program.id];
  14191. };
  14192. ShaderSystem2.prototype.syncUniformBufferGroup = function(group, name) {
  14193. var glProgram = this.getGlProgram();
  14194. if (!group.static || group.dirtyId !== 0 || !glProgram.uniformGroups[group.id]) {
  14195. group.dirtyId = 0;
  14196. var syncFunc = glProgram.uniformGroups[group.id] || this.createSyncBufferGroup(group, glProgram, name);
  14197. group.buffer.update();
  14198. syncFunc(glProgram.uniformData, group.uniforms, this.renderer, defaultSyncData, group.buffer);
  14199. }
  14200. this.renderer.buffer.bindBufferBase(group.buffer, glProgram.uniformBufferBindings[name]);
  14201. };
  14202. ShaderSystem2.prototype.createSyncBufferGroup = function(group, glProgram, name) {
  14203. var gl = this.renderer.gl;
  14204. this.renderer.buffer.bind(group.buffer);
  14205. var uniformBlockIndex = this.gl.getUniformBlockIndex(glProgram.program, name);
  14206. glProgram.uniformBufferBindings[name] = this.shader.uniformBindCount;
  14207. gl.uniformBlockBinding(glProgram.program, uniformBlockIndex, this.shader.uniformBindCount);
  14208. this.shader.uniformBindCount++;
  14209. var id = this.getSignature(group, this.shader.program.uniformData, "ubo");
  14210. var uboData = this._uboCache[id];
  14211. if (!uboData) {
  14212. uboData = this._uboCache[id] = generateUniformBufferSync(group, this.shader.program.uniformData);
  14213. }
  14214. if (group.autoManage) {
  14215. var data = new Float32Array(uboData.size / 4);
  14216. group.buffer.update(data);
  14217. }
  14218. glProgram.uniformGroups[group.id] = uboData.syncFunc;
  14219. return glProgram.uniformGroups[group.id];
  14220. };
  14221. ShaderSystem2.prototype.getSignature = function(group, uniformData, preFix) {
  14222. var uniforms = group.uniforms;
  14223. var strings = [preFix + "-"];
  14224. for (var i in uniforms) {
  14225. strings.push(i);
  14226. if (uniformData[i]) {
  14227. strings.push(uniformData[i].type);
  14228. }
  14229. }
  14230. return strings.join("-");
  14231. };
  14232. ShaderSystem2.prototype.getGlProgram = function() {
  14233. if (this.shader) {
  14234. return this.shader.program.glPrograms[this.renderer.CONTEXT_UID];
  14235. }
  14236. return null;
  14237. };
  14238. ShaderSystem2.prototype.generateProgram = function(shader) {
  14239. var gl = this.gl;
  14240. var program = shader.program;
  14241. var glProgram = generateProgram(gl, program);
  14242. program.glPrograms[this.renderer.CONTEXT_UID] = glProgram;
  14243. return glProgram;
  14244. };
  14245. ShaderSystem2.prototype.reset = function() {
  14246. this.program = null;
  14247. this.shader = null;
  14248. };
  14249. ShaderSystem2.prototype.disposeShader = function(shader) {
  14250. if (this.shader === shader) {
  14251. this.shader = null;
  14252. }
  14253. };
  14254. ShaderSystem2.prototype.destroy = function() {
  14255. this.renderer = null;
  14256. this.destroyed = true;
  14257. };
  14258. return ShaderSystem2;
  14259. })()
  14260. );
  14261. function mapWebGLBlendModesToPixi(gl, array) {
  14262. if (array === void 0) {
  14263. array = [];
  14264. }
  14265. array[BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14266. array[BLEND_MODES.ADD] = [gl.ONE, gl.ONE];
  14267. array[BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14268. array[BLEND_MODES.SCREEN] = [gl.ONE, gl.ONE_MINUS_SRC_COLOR, gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14269. array[BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14270. array[BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14271. array[BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14272. array[BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14273. array[BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14274. array[BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14275. array[BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14276. array[BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14277. array[BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14278. array[BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14279. array[BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14280. array[BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14281. array[BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14282. array[BLEND_MODES.NONE] = [0, 0];
  14283. array[BLEND_MODES.NORMAL_NPM] = [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14284. array[BLEND_MODES.ADD_NPM] = [gl.SRC_ALPHA, gl.ONE, gl.ONE, gl.ONE];
  14285. array[BLEND_MODES.SCREEN_NPM] = [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_COLOR, gl.ONE, gl.ONE_MINUS_SRC_ALPHA];
  14286. array[BLEND_MODES.SRC_IN] = [gl.DST_ALPHA, gl.ZERO];
  14287. array[BLEND_MODES.SRC_OUT] = [gl.ONE_MINUS_DST_ALPHA, gl.ZERO];
  14288. array[BLEND_MODES.SRC_ATOP] = [gl.DST_ALPHA, gl.ONE_MINUS_SRC_ALPHA];
  14289. array[BLEND_MODES.DST_OVER] = [gl.ONE_MINUS_DST_ALPHA, gl.ONE];
  14290. array[BLEND_MODES.DST_IN] = [gl.ZERO, gl.SRC_ALPHA];
  14291. array[BLEND_MODES.DST_OUT] = [gl.ZERO, gl.ONE_MINUS_SRC_ALPHA];
  14292. array[BLEND_MODES.DST_ATOP] = [gl.ONE_MINUS_DST_ALPHA, gl.SRC_ALPHA];
  14293. array[BLEND_MODES.XOR] = [gl.ONE_MINUS_DST_ALPHA, gl.ONE_MINUS_SRC_ALPHA];
  14294. array[BLEND_MODES.SUBTRACT] = [gl.ONE, gl.ONE, gl.ONE, gl.ONE, gl.FUNC_REVERSE_SUBTRACT, gl.FUNC_ADD];
  14295. return array;
  14296. }
  14297. var BLEND = 0;
  14298. var OFFSET = 1;
  14299. var CULLING = 2;
  14300. var DEPTH_TEST = 3;
  14301. var WINDING = 4;
  14302. var DEPTH_MASK = 5;
  14303. var StateSystem = (
  14304. /** @class */
  14305. (function() {
  14306. function StateSystem2() {
  14307. this.gl = null;
  14308. this.stateId = 0;
  14309. this.polygonOffset = 0;
  14310. this.blendMode = BLEND_MODES.NONE;
  14311. this._blendEq = false;
  14312. this.map = [];
  14313. this.map[BLEND] = this.setBlend;
  14314. this.map[OFFSET] = this.setOffset;
  14315. this.map[CULLING] = this.setCullFace;
  14316. this.map[DEPTH_TEST] = this.setDepthTest;
  14317. this.map[WINDING] = this.setFrontFace;
  14318. this.map[DEPTH_MASK] = this.setDepthMask;
  14319. this.checks = [];
  14320. this.defaultState = new State();
  14321. this.defaultState.blend = true;
  14322. }
  14323. StateSystem2.prototype.contextChange = function(gl) {
  14324. this.gl = gl;
  14325. this.blendModes = mapWebGLBlendModesToPixi(gl);
  14326. this.set(this.defaultState);
  14327. this.reset();
  14328. };
  14329. StateSystem2.prototype.set = function(state) {
  14330. state = state || this.defaultState;
  14331. if (this.stateId !== state.data) {
  14332. var diff = this.stateId ^ state.data;
  14333. var i = 0;
  14334. while (diff) {
  14335. if (diff & 1) {
  14336. this.map[i].call(this, !!(state.data & 1 << i));
  14337. }
  14338. diff = diff >> 1;
  14339. i++;
  14340. }
  14341. this.stateId = state.data;
  14342. }
  14343. for (var i = 0; i < this.checks.length; i++) {
  14344. this.checks[i](this, state);
  14345. }
  14346. };
  14347. StateSystem2.prototype.forceState = function(state) {
  14348. state = state || this.defaultState;
  14349. for (var i = 0; i < this.map.length; i++) {
  14350. this.map[i].call(this, !!(state.data & 1 << i));
  14351. }
  14352. for (var i = 0; i < this.checks.length; i++) {
  14353. this.checks[i](this, state);
  14354. }
  14355. this.stateId = state.data;
  14356. };
  14357. StateSystem2.prototype.setBlend = function(value) {
  14358. this.updateCheck(StateSystem2.checkBlendMode, value);
  14359. this.gl[value ? "enable" : "disable"](this.gl.BLEND);
  14360. };
  14361. StateSystem2.prototype.setOffset = function(value) {
  14362. this.updateCheck(StateSystem2.checkPolygonOffset, value);
  14363. this.gl[value ? "enable" : "disable"](this.gl.POLYGON_OFFSET_FILL);
  14364. };
  14365. StateSystem2.prototype.setDepthTest = function(value) {
  14366. this.gl[value ? "enable" : "disable"](this.gl.DEPTH_TEST);
  14367. };
  14368. StateSystem2.prototype.setDepthMask = function(value) {
  14369. this.gl.depthMask(value);
  14370. };
  14371. StateSystem2.prototype.setCullFace = function(value) {
  14372. this.gl[value ? "enable" : "disable"](this.gl.CULL_FACE);
  14373. };
  14374. StateSystem2.prototype.setFrontFace = function(value) {
  14375. this.gl.frontFace(this.gl[value ? "CW" : "CCW"]);
  14376. };
  14377. StateSystem2.prototype.setBlendMode = function(value) {
  14378. if (value === this.blendMode) {
  14379. return;
  14380. }
  14381. this.blendMode = value;
  14382. var mode = this.blendModes[value];
  14383. var gl = this.gl;
  14384. if (mode.length === 2) {
  14385. gl.blendFunc(mode[0], mode[1]);
  14386. } else {
  14387. gl.blendFuncSeparate(mode[0], mode[1], mode[2], mode[3]);
  14388. }
  14389. if (mode.length === 6) {
  14390. this._blendEq = true;
  14391. gl.blendEquationSeparate(mode[4], mode[5]);
  14392. } else if (this._blendEq) {
  14393. this._blendEq = false;
  14394. gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD);
  14395. }
  14396. };
  14397. StateSystem2.prototype.setPolygonOffset = function(value, scale) {
  14398. this.gl.polygonOffset(value, scale);
  14399. };
  14400. StateSystem2.prototype.reset = function() {
  14401. this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, false);
  14402. this.forceState(this.defaultState);
  14403. this._blendEq = true;
  14404. this.blendMode = -1;
  14405. this.setBlendMode(0);
  14406. };
  14407. StateSystem2.prototype.updateCheck = function(func, value) {
  14408. var index = this.checks.indexOf(func);
  14409. if (value && index === -1) {
  14410. this.checks.push(func);
  14411. } else if (!value && index !== -1) {
  14412. this.checks.splice(index, 1);
  14413. }
  14414. };
  14415. StateSystem2.checkBlendMode = function(system, state) {
  14416. system.setBlendMode(state.blendMode);
  14417. };
  14418. StateSystem2.checkPolygonOffset = function(system, state) {
  14419. system.setPolygonOffset(1, state.polygonOffset);
  14420. };
  14421. StateSystem2.prototype.destroy = function() {
  14422. this.gl = null;
  14423. };
  14424. return StateSystem2;
  14425. })()
  14426. );
  14427. var TextureGCSystem = (
  14428. /** @class */
  14429. (function() {
  14430. function TextureGCSystem2(renderer) {
  14431. this.renderer = renderer;
  14432. this.count = 0;
  14433. this.checkCount = 0;
  14434. this.maxIdle = settings.GC_MAX_IDLE;
  14435. this.checkCountMax = settings.GC_MAX_CHECK_COUNT;
  14436. this.mode = settings.GC_MODE;
  14437. }
  14438. TextureGCSystem2.prototype.postrender = function() {
  14439. if (!this.renderer.renderingToScreen) {
  14440. return;
  14441. }
  14442. this.count++;
  14443. if (this.mode === GC_MODES.MANUAL) {
  14444. return;
  14445. }
  14446. this.checkCount++;
  14447. if (this.checkCount > this.checkCountMax) {
  14448. this.checkCount = 0;
  14449. this.run();
  14450. }
  14451. };
  14452. TextureGCSystem2.prototype.run = function() {
  14453. var tm = this.renderer.texture;
  14454. var managedTextures = tm.managedTextures;
  14455. var wasRemoved = false;
  14456. for (var i = 0; i < managedTextures.length; i++) {
  14457. var texture = managedTextures[i];
  14458. if (!texture.framebuffer && this.count - texture.touched > this.maxIdle) {
  14459. tm.destroyTexture(texture, true);
  14460. managedTextures[i] = null;
  14461. wasRemoved = true;
  14462. }
  14463. }
  14464. if (wasRemoved) {
  14465. var j = 0;
  14466. for (var i = 0; i < managedTextures.length; i++) {
  14467. if (managedTextures[i] !== null) {
  14468. managedTextures[j++] = managedTextures[i];
  14469. }
  14470. }
  14471. managedTextures.length = j;
  14472. }
  14473. };
  14474. TextureGCSystem2.prototype.unload = function(displayObject) {
  14475. var tm = this.renderer.texture;
  14476. var texture = displayObject._texture;
  14477. if (texture && !texture.framebuffer) {
  14478. tm.destroyTexture(texture);
  14479. }
  14480. for (var i = displayObject.children.length - 1; i >= 0; i--) {
  14481. this.unload(displayObject.children[i]);
  14482. }
  14483. };
  14484. TextureGCSystem2.prototype.destroy = function() {
  14485. this.renderer = null;
  14486. };
  14487. return TextureGCSystem2;
  14488. })()
  14489. );
  14490. function mapTypeAndFormatToInternalFormat(gl) {
  14491. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
  14492. var table;
  14493. if ("WebGL2RenderingContext" in globalThis && gl instanceof globalThis.WebGL2RenderingContext) {
  14494. table = (_a = {}, _a[TYPES.UNSIGNED_BYTE] = (_b = {}, _b[FORMATS.RGBA] = gl.RGBA8, _b[FORMATS.RGB] = gl.RGB8, _b[FORMATS.RG] = gl.RG8, _b[FORMATS.RED] = gl.R8, _b[FORMATS.RGBA_INTEGER] = gl.RGBA8UI, _b[FORMATS.RGB_INTEGER] = gl.RGB8UI, _b[FORMATS.RG_INTEGER] = gl.RG8UI, _b[FORMATS.RED_INTEGER] = gl.R8UI, _b[FORMATS.ALPHA] = gl.ALPHA, _b[FORMATS.LUMINANCE] = gl.LUMINANCE, _b[FORMATS.LUMINANCE_ALPHA] = gl.LUMINANCE_ALPHA, _b), _a[TYPES.BYTE] = (_c = {}, _c[FORMATS.RGBA] = gl.RGBA8_SNORM, _c[FORMATS.RGB] = gl.RGB8_SNORM, _c[FORMATS.RG] = gl.RG8_SNORM, _c[FORMATS.RED] = gl.R8_SNORM, _c[FORMATS.RGBA_INTEGER] = gl.RGBA8I, _c[FORMATS.RGB_INTEGER] = gl.RGB8I, _c[FORMATS.RG_INTEGER] = gl.RG8I, _c[FORMATS.RED_INTEGER] = gl.R8I, _c), _a[TYPES.UNSIGNED_SHORT] = (_d = {}, _d[FORMATS.RGBA_INTEGER] = gl.RGBA16UI, _d[FORMATS.RGB_INTEGER] = gl.RGB16UI, _d[FORMATS.RG_INTEGER] = gl.RG16UI, _d[FORMATS.RED_INTEGER] = gl.R16UI, _d[FORMATS.DEPTH_COMPONENT] = gl.DEPTH_COMPONENT16, _d), _a[TYPES.SHORT] = (_e = {}, _e[FORMATS.RGBA_INTEGER] = gl.RGBA16I, _e[FORMATS.RGB_INTEGER] = gl.RGB16I, _e[FORMATS.RG_INTEGER] = gl.RG16I, _e[FORMATS.RED_INTEGER] = gl.R16I, _e), _a[TYPES.UNSIGNED_INT] = (_f = {}, _f[FORMATS.RGBA_INTEGER] = gl.RGBA32UI, _f[FORMATS.RGB_INTEGER] = gl.RGB32UI, _f[FORMATS.RG_INTEGER] = gl.RG32UI, _f[FORMATS.RED_INTEGER] = gl.R32UI, _f[FORMATS.DEPTH_COMPONENT] = gl.DEPTH_COMPONENT24, _f), _a[TYPES.INT] = (_g = {}, _g[FORMATS.RGBA_INTEGER] = gl.RGBA32I, _g[FORMATS.RGB_INTEGER] = gl.RGB32I, _g[FORMATS.RG_INTEGER] = gl.RG32I, _g[FORMATS.RED_INTEGER] = gl.R32I, _g), _a[TYPES.FLOAT] = (_h = {}, _h[FORMATS.RGBA] = gl.RGBA32F, _h[FORMATS.RGB] = gl.RGB32F, _h[FORMATS.RG] = gl.RG32F, _h[FORMATS.RED] = gl.R32F, _h[FORMATS.DEPTH_COMPONENT] = gl.DEPTH_COMPONENT32F, _h), _a[TYPES.HALF_FLOAT] = (_j = {}, _j[FORMATS.RGBA] = gl.RGBA16F, _j[FORMATS.RGB] = gl.RGB16F, _j[FORMATS.RG] = gl.RG16F, _j[FORMATS.RED] = gl.R16F, _j), _a[TYPES.UNSIGNED_SHORT_5_6_5] = (_k = {}, _k[FORMATS.RGB] = gl.RGB565, _k), _a[TYPES.UNSIGNED_SHORT_4_4_4_4] = (_l = {}, _l[FORMATS.RGBA] = gl.RGBA4, _l), _a[TYPES.UNSIGNED_SHORT_5_5_5_1] = (_m = {}, _m[FORMATS.RGBA] = gl.RGB5_A1, _m), _a[TYPES.UNSIGNED_INT_2_10_10_10_REV] = (_o = {}, _o[FORMATS.RGBA] = gl.RGB10_A2, _o[FORMATS.RGBA_INTEGER] = gl.RGB10_A2UI, _o), _a[TYPES.UNSIGNED_INT_10F_11F_11F_REV] = (_p = {}, _p[FORMATS.RGB] = gl.R11F_G11F_B10F, _p), _a[TYPES.UNSIGNED_INT_5_9_9_9_REV] = (_q = {}, _q[FORMATS.RGB] = gl.RGB9_E5, _q), _a[TYPES.UNSIGNED_INT_24_8] = (_r = {}, _r[FORMATS.DEPTH_STENCIL] = gl.DEPTH24_STENCIL8, _r), _a[TYPES.FLOAT_32_UNSIGNED_INT_24_8_REV] = (_s = {}, _s[FORMATS.DEPTH_STENCIL] = gl.DEPTH32F_STENCIL8, _s), _a);
  14495. } else {
  14496. table = (_t = {}, _t[TYPES.UNSIGNED_BYTE] = (_u = {}, _u[FORMATS.RGBA] = gl.RGBA, _u[FORMATS.RGB] = gl.RGB, _u[FORMATS.ALPHA] = gl.ALPHA, _u[FORMATS.LUMINANCE] = gl.LUMINANCE, _u[FORMATS.LUMINANCE_ALPHA] = gl.LUMINANCE_ALPHA, _u), _t[TYPES.UNSIGNED_SHORT_5_6_5] = (_v = {}, _v[FORMATS.RGB] = gl.RGB, _v), _t[TYPES.UNSIGNED_SHORT_4_4_4_4] = (_w = {}, _w[FORMATS.RGBA] = gl.RGBA, _w), _t[TYPES.UNSIGNED_SHORT_5_5_5_1] = (_x = {}, _x[FORMATS.RGBA] = gl.RGBA, _x), _t);
  14497. }
  14498. return table;
  14499. }
  14500. var GLTexture = (
  14501. /** @class */
  14502. /* @__PURE__ */ (function() {
  14503. function GLTexture2(texture) {
  14504. this.texture = texture;
  14505. this.width = -1;
  14506. this.height = -1;
  14507. this.dirtyId = -1;
  14508. this.dirtyStyleId = -1;
  14509. this.mipmap = false;
  14510. this.wrapMode = 33071;
  14511. this.type = TYPES.UNSIGNED_BYTE;
  14512. this.internalFormat = FORMATS.RGBA;
  14513. this.samplerType = 0;
  14514. }
  14515. return GLTexture2;
  14516. })()
  14517. );
  14518. var TextureSystem = (
  14519. /** @class */
  14520. (function() {
  14521. function TextureSystem2(renderer) {
  14522. this.renderer = renderer;
  14523. this.boundTextures = [];
  14524. this.currentLocation = -1;
  14525. this.managedTextures = [];
  14526. this._unknownBoundTextures = false;
  14527. this.unknownTexture = new BaseTexture();
  14528. this.hasIntegerTextures = false;
  14529. }
  14530. TextureSystem2.prototype.contextChange = function() {
  14531. var gl = this.gl = this.renderer.gl;
  14532. this.CONTEXT_UID = this.renderer.CONTEXT_UID;
  14533. this.webGLVersion = this.renderer.context.webGLVersion;
  14534. this.internalFormats = mapTypeAndFormatToInternalFormat(gl);
  14535. var maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
  14536. this.boundTextures.length = maxTextures;
  14537. for (var i = 0; i < maxTextures; i++) {
  14538. this.boundTextures[i] = null;
  14539. }
  14540. this.emptyTextures = {};
  14541. var emptyTexture2D = new GLTexture(gl.createTexture());
  14542. gl.bindTexture(gl.TEXTURE_2D, emptyTexture2D.texture);
  14543. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array(4));
  14544. this.emptyTextures[gl.TEXTURE_2D] = emptyTexture2D;
  14545. this.emptyTextures[gl.TEXTURE_CUBE_MAP] = new GLTexture(gl.createTexture());
  14546. gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.emptyTextures[gl.TEXTURE_CUBE_MAP].texture);
  14547. for (var i = 0; i < 6; i++) {
  14548. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
  14549. }
  14550. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  14551. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  14552. for (var i = 0; i < this.boundTextures.length; i++) {
  14553. this.bind(null, i);
  14554. }
  14555. };
  14556. TextureSystem2.prototype.bind = function(texture, location) {
  14557. if (location === void 0) {
  14558. location = 0;
  14559. }
  14560. var gl = this.gl;
  14561. texture = texture === null || texture === void 0 ? void 0 : texture.castToBaseTexture();
  14562. if (texture && texture.valid && !texture.parentTextureArray) {
  14563. texture.touched = this.renderer.textureGC.count;
  14564. var glTexture = texture._glTextures[this.CONTEXT_UID] || this.initTexture(texture);
  14565. if (this.boundTextures[location] !== texture) {
  14566. if (this.currentLocation !== location) {
  14567. this.currentLocation = location;
  14568. gl.activeTexture(gl.TEXTURE0 + location);
  14569. }
  14570. gl.bindTexture(texture.target, glTexture.texture);
  14571. }
  14572. if (glTexture.dirtyId !== texture.dirtyId) {
  14573. if (this.currentLocation !== location) {
  14574. this.currentLocation = location;
  14575. gl.activeTexture(gl.TEXTURE0 + location);
  14576. }
  14577. this.updateTexture(texture);
  14578. } else if (glTexture.dirtyStyleId !== texture.dirtyStyleId) {
  14579. this.updateTextureStyle(texture);
  14580. }
  14581. this.boundTextures[location] = texture;
  14582. } else {
  14583. if (this.currentLocation !== location) {
  14584. this.currentLocation = location;
  14585. gl.activeTexture(gl.TEXTURE0 + location);
  14586. }
  14587. gl.bindTexture(gl.TEXTURE_2D, this.emptyTextures[gl.TEXTURE_2D].texture);
  14588. this.boundTextures[location] = null;
  14589. }
  14590. };
  14591. TextureSystem2.prototype.reset = function() {
  14592. this._unknownBoundTextures = true;
  14593. this.hasIntegerTextures = false;
  14594. this.currentLocation = -1;
  14595. for (var i = 0; i < this.boundTextures.length; i++) {
  14596. this.boundTextures[i] = this.unknownTexture;
  14597. }
  14598. };
  14599. TextureSystem2.prototype.unbind = function(texture) {
  14600. var _a = this, gl = _a.gl, boundTextures = _a.boundTextures;
  14601. if (this._unknownBoundTextures) {
  14602. this._unknownBoundTextures = false;
  14603. for (var i = 0; i < boundTextures.length; i++) {
  14604. if (boundTextures[i] === this.unknownTexture) {
  14605. this.bind(null, i);
  14606. }
  14607. }
  14608. }
  14609. for (var i = 0; i < boundTextures.length; i++) {
  14610. if (boundTextures[i] === texture) {
  14611. if (this.currentLocation !== i) {
  14612. gl.activeTexture(gl.TEXTURE0 + i);
  14613. this.currentLocation = i;
  14614. }
  14615. gl.bindTexture(texture.target, this.emptyTextures[texture.target].texture);
  14616. boundTextures[i] = null;
  14617. }
  14618. }
  14619. };
  14620. TextureSystem2.prototype.ensureSamplerType = function(maxTextures) {
  14621. var _a = this, boundTextures = _a.boundTextures, hasIntegerTextures = _a.hasIntegerTextures, CONTEXT_UID = _a.CONTEXT_UID;
  14622. if (!hasIntegerTextures) {
  14623. return;
  14624. }
  14625. for (var i = maxTextures - 1; i >= 0; --i) {
  14626. var tex = boundTextures[i];
  14627. if (tex) {
  14628. var glTexture = tex._glTextures[CONTEXT_UID];
  14629. if (glTexture.samplerType !== SAMPLER_TYPES.FLOAT) {
  14630. this.renderer.texture.unbind(tex);
  14631. }
  14632. }
  14633. }
  14634. };
  14635. TextureSystem2.prototype.initTexture = function(texture) {
  14636. var glTexture = new GLTexture(this.gl.createTexture());
  14637. glTexture.dirtyId = -1;
  14638. texture._glTextures[this.CONTEXT_UID] = glTexture;
  14639. this.managedTextures.push(texture);
  14640. texture.on("dispose", this.destroyTexture, this);
  14641. return glTexture;
  14642. };
  14643. TextureSystem2.prototype.initTextureType = function(texture, glTexture) {
  14644. var _a, _b;
  14645. glTexture.internalFormat = (_b = (_a = this.internalFormats[texture.type]) === null || _a === void 0 ? void 0 : _a[texture.format]) !== null && _b !== void 0 ? _b : texture.format;
  14646. if (this.webGLVersion === 2 && texture.type === TYPES.HALF_FLOAT) {
  14647. glTexture.type = this.gl.HALF_FLOAT;
  14648. } else {
  14649. glTexture.type = texture.type;
  14650. }
  14651. };
  14652. TextureSystem2.prototype.updateTexture = function(texture) {
  14653. var glTexture = texture._glTextures[this.CONTEXT_UID];
  14654. if (!glTexture) {
  14655. return;
  14656. }
  14657. var renderer = this.renderer;
  14658. this.initTextureType(texture, glTexture);
  14659. if (texture.resource && texture.resource.upload(renderer, texture, glTexture)) {
  14660. if (glTexture.samplerType !== SAMPLER_TYPES.FLOAT) {
  14661. this.hasIntegerTextures = true;
  14662. }
  14663. } else {
  14664. var width = texture.realWidth;
  14665. var height = texture.realHeight;
  14666. var gl = renderer.gl;
  14667. if (glTexture.width !== width || glTexture.height !== height || glTexture.dirtyId < 0) {
  14668. glTexture.width = width;
  14669. glTexture.height = height;
  14670. gl.texImage2D(texture.target, 0, glTexture.internalFormat, width, height, 0, texture.format, glTexture.type, null);
  14671. }
  14672. }
  14673. if (texture.dirtyStyleId !== glTexture.dirtyStyleId) {
  14674. this.updateTextureStyle(texture);
  14675. }
  14676. glTexture.dirtyId = texture.dirtyId;
  14677. };
  14678. TextureSystem2.prototype.destroyTexture = function(texture, skipRemove) {
  14679. var gl = this.gl;
  14680. texture = texture.castToBaseTexture();
  14681. if (texture._glTextures[this.CONTEXT_UID]) {
  14682. this.unbind(texture);
  14683. gl.deleteTexture(texture._glTextures[this.CONTEXT_UID].texture);
  14684. texture.off("dispose", this.destroyTexture, this);
  14685. delete texture._glTextures[this.CONTEXT_UID];
  14686. if (!skipRemove) {
  14687. var i = this.managedTextures.indexOf(texture);
  14688. if (i !== -1) {
  14689. removeItems(this.managedTextures, i, 1);
  14690. }
  14691. }
  14692. }
  14693. };
  14694. TextureSystem2.prototype.updateTextureStyle = function(texture) {
  14695. var glTexture = texture._glTextures[this.CONTEXT_UID];
  14696. if (!glTexture) {
  14697. return;
  14698. }
  14699. if ((texture.mipmap === MIPMAP_MODES.POW2 || this.webGLVersion !== 2) && !texture.isPowerOfTwo) {
  14700. glTexture.mipmap = false;
  14701. } else {
  14702. glTexture.mipmap = texture.mipmap >= 1;
  14703. }
  14704. if (this.webGLVersion !== 2 && !texture.isPowerOfTwo) {
  14705. glTexture.wrapMode = WRAP_MODES.CLAMP;
  14706. } else {
  14707. glTexture.wrapMode = texture.wrapMode;
  14708. }
  14709. if (texture.resource && texture.resource.style(this.renderer, texture, glTexture)) ;
  14710. else {
  14711. this.setStyle(texture, glTexture);
  14712. }
  14713. glTexture.dirtyStyleId = texture.dirtyStyleId;
  14714. };
  14715. TextureSystem2.prototype.setStyle = function(texture, glTexture) {
  14716. var gl = this.gl;
  14717. if (glTexture.mipmap && texture.mipmap !== MIPMAP_MODES.ON_MANUAL) {
  14718. gl.generateMipmap(texture.target);
  14719. }
  14720. gl.texParameteri(texture.target, gl.TEXTURE_WRAP_S, glTexture.wrapMode);
  14721. gl.texParameteri(texture.target, gl.TEXTURE_WRAP_T, glTexture.wrapMode);
  14722. if (glTexture.mipmap) {
  14723. gl.texParameteri(texture.target, gl.TEXTURE_MIN_FILTER, texture.scaleMode === SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST);
  14724. var anisotropicExt = this.renderer.context.extensions.anisotropicFiltering;
  14725. if (anisotropicExt && texture.anisotropicLevel > 0 && texture.scaleMode === SCALE_MODES.LINEAR) {
  14726. var level = Math.min(texture.anisotropicLevel, gl.getParameter(anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT));
  14727. gl.texParameterf(texture.target, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, level);
  14728. }
  14729. } else {
  14730. gl.texParameteri(texture.target, gl.TEXTURE_MIN_FILTER, texture.scaleMode === SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST);
  14731. }
  14732. gl.texParameteri(texture.target, gl.TEXTURE_MAG_FILTER, texture.scaleMode === SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST);
  14733. };
  14734. TextureSystem2.prototype.destroy = function() {
  14735. this.renderer = null;
  14736. };
  14737. return TextureSystem2;
  14738. })()
  14739. );
  14740. var _systems = {
  14741. __proto__: null,
  14742. FilterSystem,
  14743. BatchSystem,
  14744. ContextSystem,
  14745. FramebufferSystem,
  14746. GeometrySystem,
  14747. MaskSystem,
  14748. ScissorSystem,
  14749. StencilSystem,
  14750. ProjectionSystem,
  14751. RenderTextureSystem,
  14752. ShaderSystem,
  14753. StateSystem,
  14754. TextureGCSystem,
  14755. TextureSystem
  14756. };
  14757. var tempMatrix = new Matrix();
  14758. var AbstractRenderer = (
  14759. /** @class */
  14760. (function(_super) {
  14761. __extends2(AbstractRenderer2, _super);
  14762. function AbstractRenderer2(type, options) {
  14763. if (type === void 0) {
  14764. type = RENDERER_TYPE.UNKNOWN;
  14765. }
  14766. var _this = _super.call(this) || this;
  14767. options = Object.assign({}, settings.RENDER_OPTIONS, options);
  14768. _this.options = options;
  14769. _this.type = type;
  14770. _this.screen = new Rectangle(0, 0, options.width, options.height);
  14771. _this.view = options.view || settings.ADAPTER.createCanvas();
  14772. _this.resolution = options.resolution || settings.RESOLUTION;
  14773. _this.useContextAlpha = options.useContextAlpha;
  14774. _this.autoDensity = !!options.autoDensity;
  14775. _this.preserveDrawingBuffer = options.preserveDrawingBuffer;
  14776. _this.clearBeforeRender = options.clearBeforeRender;
  14777. _this._backgroundColor = 0;
  14778. _this._backgroundColorRgba = [0, 0, 0, 1];
  14779. _this._backgroundColorString = "#000000";
  14780. _this.backgroundColor = options.backgroundColor || _this._backgroundColor;
  14781. _this.backgroundAlpha = options.backgroundAlpha;
  14782. if (options.transparent !== void 0) {
  14783. deprecation("6.0.0", "Option transparent is deprecated, please use backgroundAlpha instead.");
  14784. _this.useContextAlpha = options.transparent;
  14785. _this.backgroundAlpha = options.transparent ? 0 : 1;
  14786. }
  14787. _this._lastObjectRendered = null;
  14788. _this.plugins = {};
  14789. return _this;
  14790. }
  14791. AbstractRenderer2.prototype.initPlugins = function(staticMap) {
  14792. for (var o in staticMap) {
  14793. this.plugins[o] = new staticMap[o](this);
  14794. }
  14795. };
  14796. Object.defineProperty(AbstractRenderer2.prototype, "width", {
  14797. /**
  14798. * Same as view.width, actual number of pixels in the canvas by horizontal.
  14799. * @member {number}
  14800. * @readonly
  14801. * @default 800
  14802. */
  14803. get: function() {
  14804. return this.view.width;
  14805. },
  14806. enumerable: false,
  14807. configurable: true
  14808. });
  14809. Object.defineProperty(AbstractRenderer2.prototype, "height", {
  14810. /**
  14811. * Same as view.height, actual number of pixels in the canvas by vertical.
  14812. * @member {number}
  14813. * @readonly
  14814. * @default 600
  14815. */
  14816. get: function() {
  14817. return this.view.height;
  14818. },
  14819. enumerable: false,
  14820. configurable: true
  14821. });
  14822. AbstractRenderer2.prototype.resize = function(desiredScreenWidth, desiredScreenHeight) {
  14823. this.view.width = Math.round(desiredScreenWidth * this.resolution);
  14824. this.view.height = Math.round(desiredScreenHeight * this.resolution);
  14825. var screenWidth = this.view.width / this.resolution;
  14826. var screenHeight = this.view.height / this.resolution;
  14827. this.screen.width = screenWidth;
  14828. this.screen.height = screenHeight;
  14829. if (this.autoDensity) {
  14830. this.view.style.width = screenWidth + "px";
  14831. this.view.style.height = screenHeight + "px";
  14832. }
  14833. this.emit("resize", screenWidth, screenHeight);
  14834. };
  14835. AbstractRenderer2.prototype.generateTexture = function(displayObject, options, resolution, region) {
  14836. if (options === void 0) {
  14837. options = {};
  14838. }
  14839. if (typeof options === "number") {
  14840. deprecation("6.1.0", "generateTexture options (scaleMode, resolution, region) are now object options.");
  14841. options = { scaleMode: options, resolution, region };
  14842. }
  14843. var manualRegion = options.region, textureOptions = __rest(options, ["region"]);
  14844. region = manualRegion || displayObject.getLocalBounds(null, true);
  14845. if (region.width === 0) {
  14846. region.width = 1;
  14847. }
  14848. if (region.height === 0) {
  14849. region.height = 1;
  14850. }
  14851. var renderTexture = RenderTexture.create(__assign2({ width: region.width, height: region.height }, textureOptions));
  14852. tempMatrix.tx = -region.x;
  14853. tempMatrix.ty = -region.y;
  14854. this.render(displayObject, {
  14855. renderTexture,
  14856. clear: false,
  14857. transform: tempMatrix,
  14858. skipUpdateTransform: !!displayObject.parent
  14859. });
  14860. return renderTexture;
  14861. };
  14862. AbstractRenderer2.prototype.destroy = function(removeView) {
  14863. for (var o in this.plugins) {
  14864. this.plugins[o].destroy();
  14865. this.plugins[o] = null;
  14866. }
  14867. if (removeView && this.view.parentNode) {
  14868. this.view.parentNode.removeChild(this.view);
  14869. }
  14870. var thisAny = this;
  14871. thisAny.plugins = null;
  14872. thisAny.type = RENDERER_TYPE.UNKNOWN;
  14873. thisAny.view = null;
  14874. thisAny.screen = null;
  14875. thisAny._tempDisplayObjectParent = null;
  14876. thisAny.options = null;
  14877. this._backgroundColorRgba = null;
  14878. this._backgroundColorString = null;
  14879. this._lastObjectRendered = null;
  14880. };
  14881. Object.defineProperty(AbstractRenderer2.prototype, "backgroundColor", {
  14882. /**
  14883. * The background color to fill if not transparent
  14884. * @member {number}
  14885. */
  14886. get: function() {
  14887. return this._backgroundColor;
  14888. },
  14889. set: function(value) {
  14890. this._backgroundColor = value;
  14891. this._backgroundColorString = hex2string(value);
  14892. hex2rgb(value, this._backgroundColorRgba);
  14893. },
  14894. enumerable: false,
  14895. configurable: true
  14896. });
  14897. Object.defineProperty(AbstractRenderer2.prototype, "backgroundAlpha", {
  14898. /**
  14899. * The background color alpha. Setting this to 0 will make the canvas transparent.
  14900. * @member {number}
  14901. */
  14902. get: function() {
  14903. return this._backgroundColorRgba[3];
  14904. },
  14905. set: function(value) {
  14906. this._backgroundColorRgba[3] = value;
  14907. },
  14908. enumerable: false,
  14909. configurable: true
  14910. });
  14911. return AbstractRenderer2;
  14912. })(import_eventemitter3.default)
  14913. );
  14914. var GLBuffer = (
  14915. /** @class */
  14916. /* @__PURE__ */ (function() {
  14917. function GLBuffer2(buffer) {
  14918. this.buffer = buffer || null;
  14919. this.updateID = -1;
  14920. this.byteLength = -1;
  14921. this.refCount = 0;
  14922. }
  14923. return GLBuffer2;
  14924. })()
  14925. );
  14926. var BufferSystem = (
  14927. /** @class */
  14928. (function() {
  14929. function BufferSystem2(renderer) {
  14930. this.renderer = renderer;
  14931. this.managedBuffers = {};
  14932. this.boundBufferBases = {};
  14933. }
  14934. BufferSystem2.prototype.destroy = function() {
  14935. this.renderer = null;
  14936. };
  14937. BufferSystem2.prototype.contextChange = function() {
  14938. this.disposeAll(true);
  14939. this.gl = this.renderer.gl;
  14940. this.CONTEXT_UID = this.renderer.CONTEXT_UID;
  14941. };
  14942. BufferSystem2.prototype.bind = function(buffer) {
  14943. var _a = this, gl = _a.gl, CONTEXT_UID = _a.CONTEXT_UID;
  14944. var glBuffer = buffer._glBuffers[CONTEXT_UID] || this.createGLBuffer(buffer);
  14945. gl.bindBuffer(buffer.type, glBuffer.buffer);
  14946. };
  14947. BufferSystem2.prototype.bindBufferBase = function(buffer, index) {
  14948. var _a = this, gl = _a.gl, CONTEXT_UID = _a.CONTEXT_UID;
  14949. if (this.boundBufferBases[index] !== buffer) {
  14950. var glBuffer = buffer._glBuffers[CONTEXT_UID] || this.createGLBuffer(buffer);
  14951. this.boundBufferBases[index] = buffer;
  14952. gl.bindBufferBase(gl.UNIFORM_BUFFER, index, glBuffer.buffer);
  14953. }
  14954. };
  14955. BufferSystem2.prototype.bindBufferRange = function(buffer, index, offset) {
  14956. var _a = this, gl = _a.gl, CONTEXT_UID = _a.CONTEXT_UID;
  14957. offset = offset || 0;
  14958. var glBuffer = buffer._glBuffers[CONTEXT_UID] || this.createGLBuffer(buffer);
  14959. gl.bindBufferRange(gl.UNIFORM_BUFFER, index || 0, glBuffer.buffer, offset * 256, 256);
  14960. };
  14961. BufferSystem2.prototype.update = function(buffer) {
  14962. var _a = this, gl = _a.gl, CONTEXT_UID = _a.CONTEXT_UID;
  14963. var glBuffer = buffer._glBuffers[CONTEXT_UID];
  14964. if (buffer._updateID === glBuffer.updateID) {
  14965. return;
  14966. }
  14967. glBuffer.updateID = buffer._updateID;
  14968. gl.bindBuffer(buffer.type, glBuffer.buffer);
  14969. if (glBuffer.byteLength >= buffer.data.byteLength) {
  14970. gl.bufferSubData(buffer.type, 0, buffer.data);
  14971. } else {
  14972. var drawType = buffer.static ? gl.STATIC_DRAW : gl.DYNAMIC_DRAW;
  14973. glBuffer.byteLength = buffer.data.byteLength;
  14974. gl.bufferData(buffer.type, buffer.data, drawType);
  14975. }
  14976. };
  14977. BufferSystem2.prototype.dispose = function(buffer, contextLost) {
  14978. if (!this.managedBuffers[buffer.id]) {
  14979. return;
  14980. }
  14981. delete this.managedBuffers[buffer.id];
  14982. var glBuffer = buffer._glBuffers[this.CONTEXT_UID];
  14983. var gl = this.gl;
  14984. buffer.disposeRunner.remove(this);
  14985. if (!glBuffer) {
  14986. return;
  14987. }
  14988. if (!contextLost) {
  14989. gl.deleteBuffer(glBuffer.buffer);
  14990. }
  14991. delete buffer._glBuffers[this.CONTEXT_UID];
  14992. };
  14993. BufferSystem2.prototype.disposeAll = function(contextLost) {
  14994. var all = Object.keys(this.managedBuffers);
  14995. for (var i = 0; i < all.length; i++) {
  14996. this.dispose(this.managedBuffers[all[i]], contextLost);
  14997. }
  14998. };
  14999. BufferSystem2.prototype.createGLBuffer = function(buffer) {
  15000. var _a = this, CONTEXT_UID = _a.CONTEXT_UID, gl = _a.gl;
  15001. buffer._glBuffers[CONTEXT_UID] = new GLBuffer(gl.createBuffer());
  15002. this.managedBuffers[buffer.id] = buffer;
  15003. buffer.disposeRunner.add(this);
  15004. return buffer._glBuffers[CONTEXT_UID];
  15005. };
  15006. return BufferSystem2;
  15007. })()
  15008. );
  15009. var Renderer = (
  15010. /** @class */
  15011. (function(_super) {
  15012. __extends2(Renderer2, _super);
  15013. function Renderer2(options) {
  15014. var _this = _super.call(this, RENDERER_TYPE.WEBGL, options) || this;
  15015. options = _this.options;
  15016. _this.gl = null;
  15017. _this.CONTEXT_UID = 0;
  15018. _this.runners = {
  15019. destroy: new Runner("destroy"),
  15020. contextChange: new Runner("contextChange"),
  15021. reset: new Runner("reset"),
  15022. update: new Runner("update"),
  15023. postrender: new Runner("postrender"),
  15024. prerender: new Runner("prerender"),
  15025. resize: new Runner("resize")
  15026. };
  15027. _this.runners.contextChange.add(_this);
  15028. _this.globalUniforms = new UniformGroup({
  15029. projectionMatrix: new Matrix()
  15030. }, true);
  15031. _this.addSystem(MaskSystem, "mask").addSystem(ContextSystem, "context").addSystem(StateSystem, "state").addSystem(ShaderSystem, "shader").addSystem(TextureSystem, "texture").addSystem(BufferSystem, "buffer").addSystem(GeometrySystem, "geometry").addSystem(FramebufferSystem, "framebuffer").addSystem(ScissorSystem, "scissor").addSystem(StencilSystem, "stencil").addSystem(ProjectionSystem, "projection").addSystem(TextureGCSystem, "textureGC").addSystem(FilterSystem, "filter").addSystem(RenderTextureSystem, "renderTexture").addSystem(BatchSystem, "batch");
  15032. _this.initPlugins(Renderer2.__plugins);
  15033. _this.multisample = void 0;
  15034. if (options.context) {
  15035. _this.context.initFromContext(options.context);
  15036. } else {
  15037. _this.context.initFromOptions({
  15038. alpha: !!_this.useContextAlpha,
  15039. antialias: options.antialias,
  15040. premultipliedAlpha: _this.useContextAlpha && _this.useContextAlpha !== "notMultiplied",
  15041. stencil: true,
  15042. preserveDrawingBuffer: options.preserveDrawingBuffer,
  15043. powerPreference: _this.options.powerPreference
  15044. });
  15045. }
  15046. _this.renderingToScreen = true;
  15047. sayHello(_this.context.webGLVersion === 2 ? "WebGL 2" : "WebGL 1");
  15048. _this.resize(_this.options.width, _this.options.height);
  15049. return _this;
  15050. }
  15051. Renderer2.create = function(options) {
  15052. if (isWebGLSupported()) {
  15053. return new Renderer2(options);
  15054. }
  15055. throw new Error('WebGL unsupported in this browser, use "pixi.js-legacy" for fallback canvas2d support.');
  15056. };
  15057. Renderer2.prototype.contextChange = function() {
  15058. var gl = this.gl;
  15059. var samples;
  15060. if (this.context.webGLVersion === 1) {
  15061. var framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
  15062. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  15063. samples = gl.getParameter(gl.SAMPLES);
  15064. gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
  15065. } else {
  15066. var framebuffer = gl.getParameter(gl.DRAW_FRAMEBUFFER_BINDING);
  15067. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);
  15068. samples = gl.getParameter(gl.SAMPLES);
  15069. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, framebuffer);
  15070. }
  15071. if (samples >= MSAA_QUALITY.HIGH) {
  15072. this.multisample = MSAA_QUALITY.HIGH;
  15073. } else if (samples >= MSAA_QUALITY.MEDIUM) {
  15074. this.multisample = MSAA_QUALITY.MEDIUM;
  15075. } else if (samples >= MSAA_QUALITY.LOW) {
  15076. this.multisample = MSAA_QUALITY.LOW;
  15077. } else {
  15078. this.multisample = MSAA_QUALITY.NONE;
  15079. }
  15080. };
  15081. Renderer2.prototype.addSystem = function(ClassRef, name) {
  15082. var system = new ClassRef(this);
  15083. if (this[name]) {
  15084. throw new Error('Whoops! The name "' + name + '" is already in use');
  15085. }
  15086. this[name] = system;
  15087. for (var i in this.runners) {
  15088. this.runners[i].add(system);
  15089. }
  15090. return this;
  15091. };
  15092. Renderer2.prototype.render = function(displayObject, options) {
  15093. var renderTexture;
  15094. var clear;
  15095. var transform;
  15096. var skipUpdateTransform;
  15097. if (options) {
  15098. if (options instanceof RenderTexture) {
  15099. deprecation("6.0.0", "Renderer#render arguments changed, use options instead.");
  15100. renderTexture = options;
  15101. clear = arguments[2];
  15102. transform = arguments[3];
  15103. skipUpdateTransform = arguments[4];
  15104. } else {
  15105. renderTexture = options.renderTexture;
  15106. clear = options.clear;
  15107. transform = options.transform;
  15108. skipUpdateTransform = options.skipUpdateTransform;
  15109. }
  15110. }
  15111. this.renderingToScreen = !renderTexture;
  15112. this.runners.prerender.emit();
  15113. this.emit("prerender");
  15114. this.projection.transform = transform;
  15115. if (this.context.isLost) {
  15116. return;
  15117. }
  15118. if (!renderTexture) {
  15119. this._lastObjectRendered = displayObject;
  15120. }
  15121. if (!skipUpdateTransform) {
  15122. var cacheParent = displayObject.enableTempParent();
  15123. displayObject.updateTransform();
  15124. displayObject.disableTempParent(cacheParent);
  15125. }
  15126. this.renderTexture.bind(renderTexture);
  15127. this.batch.currentRenderer.start();
  15128. if (clear !== void 0 ? clear : this.clearBeforeRender) {
  15129. this.renderTexture.clear();
  15130. }
  15131. displayObject.render(this);
  15132. this.batch.currentRenderer.flush();
  15133. if (renderTexture) {
  15134. renderTexture.baseTexture.update();
  15135. }
  15136. this.runners.postrender.emit();
  15137. this.projection.transform = null;
  15138. this.emit("postrender");
  15139. };
  15140. Renderer2.prototype.generateTexture = function(displayObject, options, resolution, region) {
  15141. if (options === void 0) {
  15142. options = {};
  15143. }
  15144. var renderTexture = _super.prototype.generateTexture.call(this, displayObject, options, resolution, region);
  15145. this.framebuffer.blit();
  15146. return renderTexture;
  15147. };
  15148. Renderer2.prototype.resize = function(desiredScreenWidth, desiredScreenHeight) {
  15149. _super.prototype.resize.call(this, desiredScreenWidth, desiredScreenHeight);
  15150. this.runners.resize.emit(this.screen.height, this.screen.width);
  15151. };
  15152. Renderer2.prototype.reset = function() {
  15153. this.runners.reset.emit();
  15154. return this;
  15155. };
  15156. Renderer2.prototype.clear = function() {
  15157. this.renderTexture.bind();
  15158. this.renderTexture.clear();
  15159. };
  15160. Renderer2.prototype.destroy = function(removeView) {
  15161. this.runners.destroy.emit();
  15162. for (var r in this.runners) {
  15163. this.runners[r].destroy();
  15164. }
  15165. _super.prototype.destroy.call(this, removeView);
  15166. this.gl = null;
  15167. };
  15168. Object.defineProperty(Renderer2.prototype, "extract", {
  15169. /**
  15170. * Please use `plugins.extract` instead.
  15171. * @member {PIXI.Extract} extract
  15172. * @deprecated since 6.0.0
  15173. * @readonly
  15174. */
  15175. get: function() {
  15176. deprecation("6.0.0", "Renderer#extract has been deprecated, please use Renderer#plugins.extract instead.");
  15177. return this.plugins.extract;
  15178. },
  15179. enumerable: false,
  15180. configurable: true
  15181. });
  15182. Renderer2.registerPlugin = function(pluginName, ctor) {
  15183. deprecation("6.5.0", "Renderer.registerPlugin() has been deprecated, please use extensions.add() instead.");
  15184. extensions.add({
  15185. name: pluginName,
  15186. type: ExtensionType.RendererPlugin,
  15187. ref: ctor
  15188. });
  15189. };
  15190. Renderer2.__plugins = {};
  15191. return Renderer2;
  15192. })(AbstractRenderer)
  15193. );
  15194. extensions.handleByMap(ExtensionType.RendererPlugin, Renderer.__plugins);
  15195. function autoDetectRenderer(options) {
  15196. return Renderer.create(options);
  15197. }
  15198. var $defaultVertex = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}";
  15199. var $defaultFilterVertex = "attribute vec2 aVertexPosition;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nuniform vec4 inputSize;\nuniform vec4 outputFrame;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;\n\n return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aVertexPosition * (outputFrame.zw * inputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n";
  15200. var defaultVertex$1 = $defaultVertex;
  15201. var defaultFilterVertex = $defaultFilterVertex;
  15202. var System = (
  15203. /** @class */
  15204. (function() {
  15205. function System2(renderer) {
  15206. deprecation("6.1.0", "System class is deprecated, implemement ISystem interface instead.");
  15207. this.renderer = renderer;
  15208. }
  15209. System2.prototype.destroy = function() {
  15210. this.renderer = null;
  15211. };
  15212. return System2;
  15213. })()
  15214. );
  15215. var BatchDrawCall = (
  15216. /** @class */
  15217. /* @__PURE__ */ (function() {
  15218. function BatchDrawCall2() {
  15219. this.texArray = null;
  15220. this.blend = 0;
  15221. this.type = DRAW_MODES.TRIANGLES;
  15222. this.start = 0;
  15223. this.size = 0;
  15224. this.data = null;
  15225. }
  15226. return BatchDrawCall2;
  15227. })()
  15228. );
  15229. var BatchTextureArray = (
  15230. /** @class */
  15231. (function() {
  15232. function BatchTextureArray2() {
  15233. this.elements = [];
  15234. this.ids = [];
  15235. this.count = 0;
  15236. }
  15237. BatchTextureArray2.prototype.clear = function() {
  15238. for (var i = 0; i < this.count; i++) {
  15239. this.elements[i] = null;
  15240. }
  15241. this.count = 0;
  15242. };
  15243. return BatchTextureArray2;
  15244. })()
  15245. );
  15246. var ViewableBuffer = (
  15247. /** @class */
  15248. (function() {
  15249. function ViewableBuffer2(sizeOrBuffer) {
  15250. if (typeof sizeOrBuffer === "number") {
  15251. this.rawBinaryData = new ArrayBuffer(sizeOrBuffer);
  15252. } else if (sizeOrBuffer instanceof Uint8Array) {
  15253. this.rawBinaryData = sizeOrBuffer.buffer;
  15254. } else {
  15255. this.rawBinaryData = sizeOrBuffer;
  15256. }
  15257. this.uint32View = new Uint32Array(this.rawBinaryData);
  15258. this.float32View = new Float32Array(this.rawBinaryData);
  15259. }
  15260. Object.defineProperty(ViewableBuffer2.prototype, "int8View", {
  15261. /** View on the raw binary data as a `Int8Array`. */
  15262. get: function() {
  15263. if (!this._int8View) {
  15264. this._int8View = new Int8Array(this.rawBinaryData);
  15265. }
  15266. return this._int8View;
  15267. },
  15268. enumerable: false,
  15269. configurable: true
  15270. });
  15271. Object.defineProperty(ViewableBuffer2.prototype, "uint8View", {
  15272. /** View on the raw binary data as a `Uint8Array`. */
  15273. get: function() {
  15274. if (!this._uint8View) {
  15275. this._uint8View = new Uint8Array(this.rawBinaryData);
  15276. }
  15277. return this._uint8View;
  15278. },
  15279. enumerable: false,
  15280. configurable: true
  15281. });
  15282. Object.defineProperty(ViewableBuffer2.prototype, "int16View", {
  15283. /** View on the raw binary data as a `Int16Array`. */
  15284. get: function() {
  15285. if (!this._int16View) {
  15286. this._int16View = new Int16Array(this.rawBinaryData);
  15287. }
  15288. return this._int16View;
  15289. },
  15290. enumerable: false,
  15291. configurable: true
  15292. });
  15293. Object.defineProperty(ViewableBuffer2.prototype, "uint16View", {
  15294. /** View on the raw binary data as a `Uint16Array`. */
  15295. get: function() {
  15296. if (!this._uint16View) {
  15297. this._uint16View = new Uint16Array(this.rawBinaryData);
  15298. }
  15299. return this._uint16View;
  15300. },
  15301. enumerable: false,
  15302. configurable: true
  15303. });
  15304. Object.defineProperty(ViewableBuffer2.prototype, "int32View", {
  15305. /** View on the raw binary data as a `Int32Array`. */
  15306. get: function() {
  15307. if (!this._int32View) {
  15308. this._int32View = new Int32Array(this.rawBinaryData);
  15309. }
  15310. return this._int32View;
  15311. },
  15312. enumerable: false,
  15313. configurable: true
  15314. });
  15315. ViewableBuffer2.prototype.view = function(type) {
  15316. return this[type + "View"];
  15317. };
  15318. ViewableBuffer2.prototype.destroy = function() {
  15319. this.rawBinaryData = null;
  15320. this._int8View = null;
  15321. this._uint8View = null;
  15322. this._int16View = null;
  15323. this._uint16View = null;
  15324. this._int32View = null;
  15325. this.uint32View = null;
  15326. this.float32View = null;
  15327. };
  15328. ViewableBuffer2.sizeOf = function(type) {
  15329. switch (type) {
  15330. case "int8":
  15331. case "uint8":
  15332. return 1;
  15333. case "int16":
  15334. case "uint16":
  15335. return 2;
  15336. case "int32":
  15337. case "uint32":
  15338. case "float32":
  15339. return 4;
  15340. default:
  15341. throw new Error(type + " isn't a valid view type");
  15342. }
  15343. };
  15344. return ViewableBuffer2;
  15345. })()
  15346. );
  15347. var AbstractBatchRenderer = (
  15348. /** @class */
  15349. (function(_super) {
  15350. __extends2(AbstractBatchRenderer2, _super);
  15351. function AbstractBatchRenderer2(renderer) {
  15352. var _this = _super.call(this, renderer) || this;
  15353. _this.shaderGenerator = null;
  15354. _this.geometryClass = null;
  15355. _this.vertexSize = null;
  15356. _this.state = State.for2d();
  15357. _this.size = settings.SPRITE_BATCH_SIZE * 4;
  15358. _this._vertexCount = 0;
  15359. _this._indexCount = 0;
  15360. _this._bufferedElements = [];
  15361. _this._bufferedTextures = [];
  15362. _this._bufferSize = 0;
  15363. _this._shader = null;
  15364. _this._packedGeometries = [];
  15365. _this._packedGeometryPoolSize = 2;
  15366. _this._flushId = 0;
  15367. _this._aBuffers = {};
  15368. _this._iBuffers = {};
  15369. _this.MAX_TEXTURES = 1;
  15370. _this.renderer.on("prerender", _this.onPrerender, _this);
  15371. renderer.runners.contextChange.add(_this);
  15372. _this._dcIndex = 0;
  15373. _this._aIndex = 0;
  15374. _this._iIndex = 0;
  15375. _this._attributeBuffer = null;
  15376. _this._indexBuffer = null;
  15377. _this._tempBoundTextures = [];
  15378. return _this;
  15379. }
  15380. AbstractBatchRenderer2.prototype.contextChange = function() {
  15381. var gl = this.renderer.gl;
  15382. if (settings.PREFER_ENV === ENV.WEBGL_LEGACY) {
  15383. this.MAX_TEXTURES = 1;
  15384. } else {
  15385. this.MAX_TEXTURES = Math.min(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS), settings.SPRITE_MAX_TEXTURES);
  15386. this.MAX_TEXTURES = checkMaxIfStatementsInShader(this.MAX_TEXTURES, gl);
  15387. }
  15388. this._shader = this.shaderGenerator.generateShader(this.MAX_TEXTURES);
  15389. for (var i = 0; i < this._packedGeometryPoolSize; i++) {
  15390. this._packedGeometries[i] = new this.geometryClass();
  15391. }
  15392. this.initFlushBuffers();
  15393. };
  15394. AbstractBatchRenderer2.prototype.initFlushBuffers = function() {
  15395. var _drawCallPool = AbstractBatchRenderer2._drawCallPool, _textureArrayPool = AbstractBatchRenderer2._textureArrayPool;
  15396. var MAX_SPRITES = this.size / 4;
  15397. var MAX_TA = Math.floor(MAX_SPRITES / this.MAX_TEXTURES) + 1;
  15398. while (_drawCallPool.length < MAX_SPRITES) {
  15399. _drawCallPool.push(new BatchDrawCall());
  15400. }
  15401. while (_textureArrayPool.length < MAX_TA) {
  15402. _textureArrayPool.push(new BatchTextureArray());
  15403. }
  15404. for (var i = 0; i < this.MAX_TEXTURES; i++) {
  15405. this._tempBoundTextures[i] = null;
  15406. }
  15407. };
  15408. AbstractBatchRenderer2.prototype.onPrerender = function() {
  15409. this._flushId = 0;
  15410. };
  15411. AbstractBatchRenderer2.prototype.render = function(element) {
  15412. if (!element._texture.valid) {
  15413. return;
  15414. }
  15415. if (this._vertexCount + element.vertexData.length / 2 > this.size) {
  15416. this.flush();
  15417. }
  15418. this._vertexCount += element.vertexData.length / 2;
  15419. this._indexCount += element.indices.length;
  15420. this._bufferedTextures[this._bufferSize] = element._texture.baseTexture;
  15421. this._bufferedElements[this._bufferSize++] = element;
  15422. };
  15423. AbstractBatchRenderer2.prototype.buildTexturesAndDrawCalls = function() {
  15424. var _a = this, textures = _a._bufferedTextures, MAX_TEXTURES = _a.MAX_TEXTURES;
  15425. var textureArrays = AbstractBatchRenderer2._textureArrayPool;
  15426. var batch = this.renderer.batch;
  15427. var boundTextures = this._tempBoundTextures;
  15428. var touch = this.renderer.textureGC.count;
  15429. var TICK = ++BaseTexture._globalBatch;
  15430. var countTexArrays = 0;
  15431. var texArray = textureArrays[0];
  15432. var start = 0;
  15433. batch.copyBoundTextures(boundTextures, MAX_TEXTURES);
  15434. for (var i = 0; i < this._bufferSize; ++i) {
  15435. var tex = textures[i];
  15436. textures[i] = null;
  15437. if (tex._batchEnabled === TICK) {
  15438. continue;
  15439. }
  15440. if (texArray.count >= MAX_TEXTURES) {
  15441. batch.boundArray(texArray, boundTextures, TICK, MAX_TEXTURES);
  15442. this.buildDrawCalls(texArray, start, i);
  15443. start = i;
  15444. texArray = textureArrays[++countTexArrays];
  15445. ++TICK;
  15446. }
  15447. tex._batchEnabled = TICK;
  15448. tex.touched = touch;
  15449. texArray.elements[texArray.count++] = tex;
  15450. }
  15451. if (texArray.count > 0) {
  15452. batch.boundArray(texArray, boundTextures, TICK, MAX_TEXTURES);
  15453. this.buildDrawCalls(texArray, start, this._bufferSize);
  15454. ++countTexArrays;
  15455. ++TICK;
  15456. }
  15457. for (var i = 0; i < boundTextures.length; i++) {
  15458. boundTextures[i] = null;
  15459. }
  15460. BaseTexture._globalBatch = TICK;
  15461. };
  15462. AbstractBatchRenderer2.prototype.buildDrawCalls = function(texArray, start, finish) {
  15463. var _a = this, elements = _a._bufferedElements, _attributeBuffer = _a._attributeBuffer, _indexBuffer = _a._indexBuffer, vertexSize = _a.vertexSize;
  15464. var drawCalls = AbstractBatchRenderer2._drawCallPool;
  15465. var dcIndex = this._dcIndex;
  15466. var aIndex = this._aIndex;
  15467. var iIndex = this._iIndex;
  15468. var drawCall = drawCalls[dcIndex];
  15469. drawCall.start = this._iIndex;
  15470. drawCall.texArray = texArray;
  15471. for (var i = start; i < finish; ++i) {
  15472. var sprite = elements[i];
  15473. var tex = sprite._texture.baseTexture;
  15474. var spriteBlendMode = premultiplyBlendMode[tex.alphaMode ? 1 : 0][sprite.blendMode];
  15475. elements[i] = null;
  15476. if (start < i && drawCall.blend !== spriteBlendMode) {
  15477. drawCall.size = iIndex - drawCall.start;
  15478. start = i;
  15479. drawCall = drawCalls[++dcIndex];
  15480. drawCall.texArray = texArray;
  15481. drawCall.start = iIndex;
  15482. }
  15483. this.packInterleavedGeometry(sprite, _attributeBuffer, _indexBuffer, aIndex, iIndex);
  15484. aIndex += sprite.vertexData.length / 2 * vertexSize;
  15485. iIndex += sprite.indices.length;
  15486. drawCall.blend = spriteBlendMode;
  15487. }
  15488. if (start < finish) {
  15489. drawCall.size = iIndex - drawCall.start;
  15490. ++dcIndex;
  15491. }
  15492. this._dcIndex = dcIndex;
  15493. this._aIndex = aIndex;
  15494. this._iIndex = iIndex;
  15495. };
  15496. AbstractBatchRenderer2.prototype.bindAndClearTexArray = function(texArray) {
  15497. var textureSystem = this.renderer.texture;
  15498. for (var j = 0; j < texArray.count; j++) {
  15499. textureSystem.bind(texArray.elements[j], texArray.ids[j]);
  15500. texArray.elements[j] = null;
  15501. }
  15502. texArray.count = 0;
  15503. };
  15504. AbstractBatchRenderer2.prototype.updateGeometry = function() {
  15505. var _a = this, packedGeometries = _a._packedGeometries, attributeBuffer = _a._attributeBuffer, indexBuffer = _a._indexBuffer;
  15506. if (!settings.CAN_UPLOAD_SAME_BUFFER) {
  15507. if (this._packedGeometryPoolSize <= this._flushId) {
  15508. this._packedGeometryPoolSize++;
  15509. packedGeometries[this._flushId] = new this.geometryClass();
  15510. }
  15511. packedGeometries[this._flushId]._buffer.update(attributeBuffer.rawBinaryData);
  15512. packedGeometries[this._flushId]._indexBuffer.update(indexBuffer);
  15513. this.renderer.geometry.bind(packedGeometries[this._flushId]);
  15514. this.renderer.geometry.updateBuffers();
  15515. this._flushId++;
  15516. } else {
  15517. packedGeometries[this._flushId]._buffer.update(attributeBuffer.rawBinaryData);
  15518. packedGeometries[this._flushId]._indexBuffer.update(indexBuffer);
  15519. this.renderer.geometry.updateBuffers();
  15520. }
  15521. };
  15522. AbstractBatchRenderer2.prototype.drawBatches = function() {
  15523. var dcCount = this._dcIndex;
  15524. var _a = this.renderer, gl = _a.gl, stateSystem = _a.state;
  15525. var drawCalls = AbstractBatchRenderer2._drawCallPool;
  15526. var curTexArray = null;
  15527. for (var i = 0; i < dcCount; i++) {
  15528. var _b = drawCalls[i], texArray = _b.texArray, type = _b.type, size = _b.size, start = _b.start, blend = _b.blend;
  15529. if (curTexArray !== texArray) {
  15530. curTexArray = texArray;
  15531. this.bindAndClearTexArray(texArray);
  15532. }
  15533. this.state.blendMode = blend;
  15534. stateSystem.set(this.state);
  15535. gl.drawElements(type, size, gl.UNSIGNED_SHORT, start * 2);
  15536. }
  15537. };
  15538. AbstractBatchRenderer2.prototype.flush = function() {
  15539. if (this._vertexCount === 0) {
  15540. return;
  15541. }
  15542. this._attributeBuffer = this.getAttributeBuffer(this._vertexCount);
  15543. this._indexBuffer = this.getIndexBuffer(this._indexCount);
  15544. this._aIndex = 0;
  15545. this._iIndex = 0;
  15546. this._dcIndex = 0;
  15547. this.buildTexturesAndDrawCalls();
  15548. this.updateGeometry();
  15549. this.drawBatches();
  15550. this._bufferSize = 0;
  15551. this._vertexCount = 0;
  15552. this._indexCount = 0;
  15553. };
  15554. AbstractBatchRenderer2.prototype.start = function() {
  15555. this.renderer.state.set(this.state);
  15556. this.renderer.texture.ensureSamplerType(this.MAX_TEXTURES);
  15557. this.renderer.shader.bind(this._shader);
  15558. if (settings.CAN_UPLOAD_SAME_BUFFER) {
  15559. this.renderer.geometry.bind(this._packedGeometries[this._flushId]);
  15560. }
  15561. };
  15562. AbstractBatchRenderer2.prototype.stop = function() {
  15563. this.flush();
  15564. };
  15565. AbstractBatchRenderer2.prototype.destroy = function() {
  15566. for (var i = 0; i < this._packedGeometryPoolSize; i++) {
  15567. if (this._packedGeometries[i]) {
  15568. this._packedGeometries[i].destroy();
  15569. }
  15570. }
  15571. this.renderer.off("prerender", this.onPrerender, this);
  15572. this._aBuffers = null;
  15573. this._iBuffers = null;
  15574. this._packedGeometries = null;
  15575. this._attributeBuffer = null;
  15576. this._indexBuffer = null;
  15577. if (this._shader) {
  15578. this._shader.destroy();
  15579. this._shader = null;
  15580. }
  15581. _super.prototype.destroy.call(this);
  15582. };
  15583. AbstractBatchRenderer2.prototype.getAttributeBuffer = function(size) {
  15584. var roundedP2 = nextPow2(Math.ceil(size / 8));
  15585. var roundedSizeIndex = log2(roundedP2);
  15586. var roundedSize = roundedP2 * 8;
  15587. if (this._aBuffers.length <= roundedSizeIndex) {
  15588. this._iBuffers.length = roundedSizeIndex + 1;
  15589. }
  15590. var buffer = this._aBuffers[roundedSize];
  15591. if (!buffer) {
  15592. this._aBuffers[roundedSize] = buffer = new ViewableBuffer(roundedSize * this.vertexSize * 4);
  15593. }
  15594. return buffer;
  15595. };
  15596. AbstractBatchRenderer2.prototype.getIndexBuffer = function(size) {
  15597. var roundedP2 = nextPow2(Math.ceil(size / 12));
  15598. var roundedSizeIndex = log2(roundedP2);
  15599. var roundedSize = roundedP2 * 12;
  15600. if (this._iBuffers.length <= roundedSizeIndex) {
  15601. this._iBuffers.length = roundedSizeIndex + 1;
  15602. }
  15603. var buffer = this._iBuffers[roundedSizeIndex];
  15604. if (!buffer) {
  15605. this._iBuffers[roundedSizeIndex] = buffer = new Uint16Array(roundedSize);
  15606. }
  15607. return buffer;
  15608. };
  15609. AbstractBatchRenderer2.prototype.packInterleavedGeometry = function(element, attributeBuffer, indexBuffer, aIndex, iIndex) {
  15610. var uint32View = attributeBuffer.uint32View, float32View = attributeBuffer.float32View;
  15611. var packedVertices = aIndex / this.vertexSize;
  15612. var uvs = element.uvs;
  15613. var indicies = element.indices;
  15614. var vertexData = element.vertexData;
  15615. var textureId = element._texture.baseTexture._batchLocation;
  15616. var alpha = Math.min(element.worldAlpha, 1);
  15617. var argb = alpha < 1 && element._texture.baseTexture.alphaMode ? premultiplyTint(element._tintRGB, alpha) : element._tintRGB + (alpha * 255 << 24);
  15618. for (var i = 0; i < vertexData.length; i += 2) {
  15619. float32View[aIndex++] = vertexData[i];
  15620. float32View[aIndex++] = vertexData[i + 1];
  15621. float32View[aIndex++] = uvs[i];
  15622. float32View[aIndex++] = uvs[i + 1];
  15623. uint32View[aIndex++] = argb;
  15624. float32View[aIndex++] = textureId;
  15625. }
  15626. for (var i = 0; i < indicies.length; i++) {
  15627. indexBuffer[iIndex++] = packedVertices + indicies[i];
  15628. }
  15629. };
  15630. AbstractBatchRenderer2._drawCallPool = [];
  15631. AbstractBatchRenderer2._textureArrayPool = [];
  15632. return AbstractBatchRenderer2;
  15633. })(ObjectRenderer)
  15634. );
  15635. var BatchShaderGenerator = (
  15636. /** @class */
  15637. (function() {
  15638. function BatchShaderGenerator2(vertexSrc, fragTemplate2) {
  15639. this.vertexSrc = vertexSrc;
  15640. this.fragTemplate = fragTemplate2;
  15641. this.programCache = {};
  15642. this.defaultGroupCache = {};
  15643. if (fragTemplate2.indexOf("%count%") < 0) {
  15644. throw new Error('Fragment template must contain "%count%".');
  15645. }
  15646. if (fragTemplate2.indexOf("%forloop%") < 0) {
  15647. throw new Error('Fragment template must contain "%forloop%".');
  15648. }
  15649. }
  15650. BatchShaderGenerator2.prototype.generateShader = function(maxTextures) {
  15651. if (!this.programCache[maxTextures]) {
  15652. var sampleValues = new Int32Array(maxTextures);
  15653. for (var i = 0; i < maxTextures; i++) {
  15654. sampleValues[i] = i;
  15655. }
  15656. this.defaultGroupCache[maxTextures] = UniformGroup.from({ uSamplers: sampleValues }, true);
  15657. var fragmentSrc = this.fragTemplate;
  15658. fragmentSrc = fragmentSrc.replace(/%count%/gi, "" + maxTextures);
  15659. fragmentSrc = fragmentSrc.replace(/%forloop%/gi, this.generateSampleSrc(maxTextures));
  15660. this.programCache[maxTextures] = new Program(this.vertexSrc, fragmentSrc);
  15661. }
  15662. var uniforms = {
  15663. tint: new Float32Array([1, 1, 1, 1]),
  15664. translationMatrix: new Matrix(),
  15665. default: this.defaultGroupCache[maxTextures]
  15666. };
  15667. return new Shader(this.programCache[maxTextures], uniforms);
  15668. };
  15669. BatchShaderGenerator2.prototype.generateSampleSrc = function(maxTextures) {
  15670. var src = "";
  15671. src += "\n";
  15672. src += "\n";
  15673. for (var i = 0; i < maxTextures; i++) {
  15674. if (i > 0) {
  15675. src += "\nelse ";
  15676. }
  15677. if (i < maxTextures - 1) {
  15678. src += "if(vTextureId < " + i + ".5)";
  15679. }
  15680. src += "\n{";
  15681. src += "\n color = texture2D(uSamplers[" + i + "], vTextureCoord);";
  15682. src += "\n}";
  15683. }
  15684. src += "\n";
  15685. src += "\n";
  15686. return src;
  15687. };
  15688. return BatchShaderGenerator2;
  15689. })()
  15690. );
  15691. var BatchGeometry = (
  15692. /** @class */
  15693. (function(_super) {
  15694. __extends2(BatchGeometry2, _super);
  15695. function BatchGeometry2(_static) {
  15696. if (_static === void 0) {
  15697. _static = false;
  15698. }
  15699. var _this = _super.call(this) || this;
  15700. _this._buffer = new Buffer(null, _static, false);
  15701. _this._indexBuffer = new Buffer(null, _static, true);
  15702. _this.addAttribute("aVertexPosition", _this._buffer, 2, false, TYPES.FLOAT).addAttribute("aTextureCoord", _this._buffer, 2, false, TYPES.FLOAT).addAttribute("aColor", _this._buffer, 4, true, TYPES.UNSIGNED_BYTE).addAttribute("aTextureId", _this._buffer, 1, true, TYPES.FLOAT).addIndex(_this._indexBuffer);
  15703. return _this;
  15704. }
  15705. return BatchGeometry2;
  15706. })(Geometry)
  15707. );
  15708. var defaultVertex = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform vec4 tint;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor * tint;\n}\n";
  15709. var defaultFragment = "varying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\nuniform sampler2D uSamplers[%count%];\n\nvoid main(void){\n vec4 color;\n %forloop%\n gl_FragColor = color * vColor;\n}\n";
  15710. var BatchPluginFactory = (
  15711. /** @class */
  15712. (function() {
  15713. function BatchPluginFactory2() {
  15714. }
  15715. BatchPluginFactory2.create = function(options) {
  15716. var _a = Object.assign({
  15717. vertex: defaultVertex,
  15718. fragment: defaultFragment,
  15719. geometryClass: BatchGeometry,
  15720. vertexSize: 6
  15721. }, options), vertex2 = _a.vertex, fragment2 = _a.fragment, vertexSize = _a.vertexSize, geometryClass = _a.geometryClass;
  15722. return (
  15723. /** @class */
  15724. (function(_super) {
  15725. __extends2(BatchPlugin, _super);
  15726. function BatchPlugin(renderer) {
  15727. var _this = _super.call(this, renderer) || this;
  15728. _this.shaderGenerator = new BatchShaderGenerator(vertex2, fragment2);
  15729. _this.geometryClass = geometryClass;
  15730. _this.vertexSize = vertexSize;
  15731. return _this;
  15732. }
  15733. return BatchPlugin;
  15734. })(AbstractBatchRenderer)
  15735. );
  15736. };
  15737. Object.defineProperty(BatchPluginFactory2, "defaultVertexSrc", {
  15738. /**
  15739. * The default vertex shader source
  15740. * @readonly
  15741. */
  15742. get: function() {
  15743. return defaultVertex;
  15744. },
  15745. enumerable: false,
  15746. configurable: true
  15747. });
  15748. Object.defineProperty(BatchPluginFactory2, "defaultFragmentTemplate", {
  15749. /**
  15750. * The default fragment shader source
  15751. * @readonly
  15752. */
  15753. get: function() {
  15754. return defaultFragment;
  15755. },
  15756. enumerable: false,
  15757. configurable: true
  15758. });
  15759. return BatchPluginFactory2;
  15760. })()
  15761. );
  15762. var BatchRenderer = BatchPluginFactory.create();
  15763. Object.assign(BatchRenderer, {
  15764. extension: {
  15765. name: "batch",
  15766. type: ExtensionType.RendererPlugin
  15767. }
  15768. });
  15769. var resources = {};
  15770. var _loop_1 = function(name) {
  15771. Object.defineProperty(resources, name, {
  15772. get: function() {
  15773. deprecation("6.0.0", "PIXI.systems." + name + " has moved to PIXI." + name);
  15774. return _resources[name];
  15775. }
  15776. });
  15777. };
  15778. for (name in _resources) {
  15779. _loop_1(name);
  15780. }
  15781. var name;
  15782. var systems = {};
  15783. var _loop_2 = function(name) {
  15784. Object.defineProperty(systems, name, {
  15785. get: function() {
  15786. deprecation("6.0.0", "PIXI.resources." + name + " has moved to PIXI." + name);
  15787. return _systems[name];
  15788. }
  15789. });
  15790. };
  15791. for (name in _systems) {
  15792. _loop_2(name);
  15793. }
  15794. var name;
  15795. var VERSION2 = "6.5.10";
  15796. export {
  15797. ENV,
  15798. RENDERER_TYPE,
  15799. BUFFER_BITS,
  15800. BLEND_MODES,
  15801. DRAW_MODES,
  15802. FORMATS,
  15803. TARGETS,
  15804. TYPES,
  15805. SAMPLER_TYPES,
  15806. SCALE_MODES,
  15807. WRAP_MODES,
  15808. MIPMAP_MODES,
  15809. ALPHA_MODES,
  15810. CLEAR_MODES,
  15811. GC_MODES,
  15812. PRECISION,
  15813. MASK_TYPES,
  15814. COLOR_MASK_BITS,
  15815. MSAA_QUALITY,
  15816. BUFFER_TYPE,
  15817. BrowserAdapter,
  15818. isMobile,
  15819. settings,
  15820. url,
  15821. hex2rgb,
  15822. hex2string,
  15823. string2hex,
  15824. correctBlendMode,
  15825. premultiplyRgba,
  15826. premultiplyTint,
  15827. premultiplyTintToRgba,
  15828. createIndicesForQuads,
  15829. removeItems,
  15830. sign,
  15831. uid,
  15832. deprecation,
  15833. CanvasRenderTarget,
  15834. trimCanvas,
  15835. getResolutionOfUrl,
  15836. utils_exports,
  15837. import_eventemitter3,
  15838. import_earcut,
  15839. PI_2,
  15840. RAD_TO_DEG,
  15841. DEG_TO_RAD,
  15842. SHAPES,
  15843. Point,
  15844. Rectangle,
  15845. Circle,
  15846. Ellipse,
  15847. Polygon,
  15848. RoundedRectangle,
  15849. ObservablePoint,
  15850. Matrix,
  15851. groupD8,
  15852. Transform,
  15853. Bounds,
  15854. DisplayObject,
  15855. TemporaryDisplayObject,
  15856. Container,
  15857. ExtensionType,
  15858. extensions,
  15859. Runner,
  15860. UPDATE_PRIORITY,
  15861. Ticker,
  15862. TickerPlugin,
  15863. INSTALLED,
  15864. autoDetectResource,
  15865. Resource,
  15866. BufferResource,
  15867. BaseTexture,
  15868. AbstractMultiResource,
  15869. ArrayResource,
  15870. BaseImageResource,
  15871. CanvasResource,
  15872. CubeResource,
  15873. ImageResource,
  15874. SVGResource,
  15875. VideoResource,
  15876. ImageBitmapResource,
  15877. Framebuffer,
  15878. BaseRenderTexture,
  15879. TextureUvs,
  15880. Texture,
  15881. RenderTexture,
  15882. RenderTexturePool,
  15883. Attribute,
  15884. Buffer,
  15885. Geometry,
  15886. Quad,
  15887. QuadUv,
  15888. UniformGroup,
  15889. FilterState,
  15890. FilterSystem,
  15891. ObjectRenderer,
  15892. BatchSystem,
  15893. ContextSystem,
  15894. GLFramebuffer,
  15895. FramebufferSystem,
  15896. GeometrySystem,
  15897. MaskData,
  15898. getTestContext,
  15899. uniformParsers,
  15900. checkMaxIfStatementsInShader,
  15901. Program,
  15902. Shader,
  15903. State,
  15904. Filter,
  15905. TextureMatrix,
  15906. SpriteMaskFilter,
  15907. MaskSystem,
  15908. ScissorSystem,
  15909. StencilSystem,
  15910. ProjectionSystem,
  15911. RenderTextureSystem,
  15912. createUBOElements,
  15913. getUBOData,
  15914. generateUniformBufferSync,
  15915. IGLUniformData,
  15916. GLProgram,
  15917. generateProgram,
  15918. ShaderSystem,
  15919. StateSystem,
  15920. TextureGCSystem,
  15921. GLTexture,
  15922. TextureSystem,
  15923. AbstractRenderer,
  15924. Renderer,
  15925. autoDetectRenderer,
  15926. defaultVertex$1,
  15927. defaultFilterVertex,
  15928. System,
  15929. BatchDrawCall,
  15930. BatchTextureArray,
  15931. ViewableBuffer,
  15932. AbstractBatchRenderer,
  15933. BatchShaderGenerator,
  15934. BatchGeometry,
  15935. BatchPluginFactory,
  15936. BatchRenderer,
  15937. resources,
  15938. systems,
  15939. VERSION2 as VERSION
  15940. };
  15941. /*! Bundled license information:
  15942. punycode/punycode.js:
  15943. (*! https://mths.be/punycode v1.4.1 by @mathias *)
  15944. @pixi/constants/dist/esm/constants.mjs:
  15945. (*!
  15946. * @pixi/constants - v6.5.10
  15947. * Compiled Thu, 06 Jul 2023 15:25:11 UTC
  15948. *
  15949. * @pixi/constants is licensed under the MIT License.
  15950. * http://www.opensource.org/licenses/mit-license
  15951. *)
  15952. @pixi/settings/dist/esm/settings.mjs:
  15953. (*!
  15954. * @pixi/settings - v6.5.10
  15955. * Compiled Thu, 06 Jul 2023 15:25:11 UTC
  15956. *
  15957. * @pixi/settings is licensed under the MIT License.
  15958. * http://www.opensource.org/licenses/mit-license
  15959. *)
  15960. @pixi/utils/dist/esm/utils.mjs:
  15961. (*!
  15962. * @pixi/utils - v6.5.10
  15963. * Compiled Thu, 06 Jul 2023 15:25:11 UTC
  15964. *
  15965. * @pixi/utils is licensed under the MIT License.
  15966. * http://www.opensource.org/licenses/mit-license
  15967. *)
  15968. @pixi/math/dist/esm/math.mjs:
  15969. (*!
  15970. * @pixi/math - v6.5.10
  15971. * Compiled Thu, 06 Jul 2023 15:25:11 UTC
  15972. *
  15973. * @pixi/math is licensed under the MIT License.
  15974. * http://www.opensource.org/licenses/mit-license
  15975. *)
  15976. @pixi/display/dist/esm/display.mjs:
  15977. (*!
  15978. * @pixi/display - v6.5.10
  15979. * Compiled Thu, 06 Jul 2023 15:25:11 UTC
  15980. *
  15981. * @pixi/display is licensed under the MIT License.
  15982. * http://www.opensource.org/licenses/mit-license
  15983. *)
  15984. (*! *****************************************************************************
  15985. Copyright (c) Microsoft Corporation.
  15986. Permission to use, copy, modify, and/or distribute this software for any
  15987. purpose with or without fee is hereby granted.
  15988. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  15989. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  15990. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  15991. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  15992. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  15993. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15994. PERFORMANCE OF THIS SOFTWARE.
  15995. ***************************************************************************** *)
  15996. @pixi/extensions/dist/esm/extensions.mjs:
  15997. (*!
  15998. * @pixi/extensions - v6.5.10
  15999. * Compiled Thu, 06 Jul 2023 15:25:11 UTC
  16000. *
  16001. * @pixi/extensions is licensed under the MIT License.
  16002. * http://www.opensource.org/licenses/mit-license
  16003. *)
  16004. (*! *****************************************************************************
  16005. Copyright (c) Microsoft Corporation.
  16006. Permission to use, copy, modify, and/or distribute this software for any
  16007. purpose with or without fee is hereby granted.
  16008. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  16009. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  16010. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  16011. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  16012. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  16013. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16014. PERFORMANCE OF THIS SOFTWARE.
  16015. ***************************************************************************** *)
  16016. @pixi/runner/dist/esm/runner.mjs:
  16017. (*!
  16018. * @pixi/runner - v6.5.10
  16019. * Compiled Thu, 06 Jul 2023 15:25:11 UTC
  16020. *
  16021. * @pixi/runner is licensed under the MIT License.
  16022. * http://www.opensource.org/licenses/mit-license
  16023. *)
  16024. @pixi/ticker/dist/esm/ticker.mjs:
  16025. (*!
  16026. * @pixi/ticker - v6.5.10
  16027. * Compiled Thu, 06 Jul 2023 15:25:11 UTC
  16028. *
  16029. * @pixi/ticker is licensed under the MIT License.
  16030. * http://www.opensource.org/licenses/mit-license
  16031. *)
  16032. @pixi/core/dist/esm/core.mjs:
  16033. (*!
  16034. * @pixi/core - v6.5.10
  16035. * Compiled Thu, 06 Jul 2023 15:25:11 UTC
  16036. *
  16037. * @pixi/core is licensed under the MIT License.
  16038. * http://www.opensource.org/licenses/mit-license
  16039. *)
  16040. (*! *****************************************************************************
  16041. Copyright (c) Microsoft Corporation.
  16042. Permission to use, copy, modify, and/or distribute this software for any
  16043. purpose with or without fee is hereby granted.
  16044. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  16045. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  16046. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  16047. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  16048. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  16049. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16050. PERFORMANCE OF THIS SOFTWARE.
  16051. ***************************************************************************** *)
  16052. */
  16053. //# sourceMappingURL=chunk-66BJ5UTJ.js.map