@tresjs_cientos.js 566 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565
  1. import {
  2. createEventHook,
  3. toValue,
  4. unrefElement,
  5. useDevicePixelRatio,
  6. useElementSize,
  7. useEventListener,
  8. useRafFn,
  9. useWindowSize
  10. } from "./chunk-YZCJI2S3.js";
  11. import {
  12. Fragment,
  13. computed,
  14. createBaseVNode,
  15. createBlock,
  16. createCommentVNode,
  17. createElementBlock,
  18. createRenderer,
  19. customRef,
  20. defineComponent,
  21. getCurrentInstance,
  22. getCurrentScope,
  23. guardReactiveProps,
  24. h,
  25. inject,
  26. mergeProps,
  27. nextTick,
  28. normalizeProps,
  29. onMounted,
  30. onScopeDispose,
  31. onUnmounted,
  32. openBlock,
  33. provide,
  34. readonly,
  35. ref,
  36. renderList,
  37. renderSlot,
  38. resolveComponent,
  39. shallowReactive,
  40. shallowRef,
  41. toRef,
  42. toRefs,
  43. unref,
  44. useSlots,
  45. watch,
  46. watchEffect,
  47. withAsyncContext
  48. } from "./chunk-LZPJ5JBW.js";
  49. import {
  50. ACESFilmicToneMapping,
  51. AmbientLight,
  52. AnimationClip,
  53. AnimationMixer,
  54. Bone,
  55. Box3,
  56. BoxGeometry,
  57. BufferAttribute,
  58. BufferGeometry,
  59. ClampToEdgeWrapping,
  60. Clock,
  61. Color,
  62. CubeReflectionMapping,
  63. CubeTextureLoader,
  64. Curve,
  65. CylinderGeometry,
  66. DataTextureLoader,
  67. DataUtils,
  68. DirectionalLight,
  69. DoubleSide,
  70. EquirectangularReflectionMapping,
  71. Euler,
  72. EventDispatcher,
  73. ExtrudeGeometry,
  74. FileLoader,
  75. Float32BufferAttribute,
  76. FloatType,
  77. FrontSide,
  78. Group,
  79. HalfFloatType,
  80. ImageBitmapLoader,
  81. InstancedMesh,
  82. InterleavedBuffer,
  83. InterleavedBufferAttribute,
  84. Interpolant,
  85. InterpolateDiscrete,
  86. InterpolateLinear,
  87. Line,
  88. LineBasicMaterial,
  89. LineLoop,
  90. LineSegments,
  91. LinearEncoding,
  92. LinearFilter,
  93. LinearMipmapLinearFilter,
  94. LinearMipmapNearestFilter,
  95. LinearSRGBColorSpace,
  96. Loader,
  97. LoaderUtils,
  98. LoadingManager,
  99. MOUSE,
  100. Material,
  101. MathUtils,
  102. Matrix3,
  103. Matrix4,
  104. Mesh,
  105. MeshBasicMaterial,
  106. MeshLambertMaterial,
  107. MeshPhongMaterial,
  108. MeshPhysicalMaterial,
  109. MeshStandardMaterial,
  110. MirroredRepeatWrapping,
  111. NearestFilter,
  112. NearestMipmapLinearFilter,
  113. NearestMipmapNearestFilter,
  114. NoToneMapping,
  115. NumberKeyframeTrack,
  116. Object3D,
  117. OctahedronGeometry,
  118. OrthographicCamera,
  119. PCFShadowMap,
  120. PCFSoftShadowMap,
  121. PerspectiveCamera,
  122. PlaneGeometry,
  123. PointLight,
  124. Points,
  125. PointsMaterial,
  126. PropertyBinding,
  127. QuadraticBezierCurve3,
  128. Quaternion,
  129. QuaternionKeyframeTrack,
  130. Raycaster,
  131. RepeatWrapping,
  132. SRGBColorSpace,
  133. Scene,
  134. ShapePath,
  135. Skeleton,
  136. SkinnedMesh,
  137. Sphere,
  138. SphereGeometry,
  139. Spherical,
  140. SpotLight,
  141. TOUCH,
  142. Texture,
  143. TextureLoader,
  144. TorusGeometry,
  145. TriangleFanDrawMode,
  146. TriangleStripDrawMode,
  147. TrianglesDrawMode,
  148. Uint16BufferAttribute,
  149. Vector2,
  150. Vector3,
  151. Vector4,
  152. VectorKeyframeTrack,
  153. WebGLRenderer,
  154. sRGBEncoding,
  155. three_module_exports
  156. } from "./chunk-PDZK3SQX.js";
  157. import "./chunk-JC4IRQUL.js";
  158. // dist/tres.js
  159. var Ce = ref({ uuid: MathUtils.generateUUID() });
  160. var Me = (e) => void Object.assign(Ce.value, e);
  161. var Ze = ((e) => (e.Perspective = "Perspective", e.Orthographic = "Orthographic", e))(Ze || {});
  162. var et = 45;
  163. var A;
  164. function xe() {
  165. const { state: e, setState: t, aspectRatio: o } = _();
  166. function a(s = "Perspective", f) {
  167. var u, m, g;
  168. if (s === "Perspective") {
  169. const { near: w, far: C, fov: h2 } = f || {
  170. near: 0.1,
  171. far: 1e3,
  172. fov: et
  173. };
  174. A = new PerspectiveCamera(h2, ((u = e.aspectRatio) == null ? void 0 : u.value) || window.innerWidth / window.innerHeight, w, C), (m = e.cameras) == null || m.push(A);
  175. } else {
  176. const { left: w, right: C, top: h2, bottom: P2, near: M, far: O } = f || {
  177. left: -100,
  178. right: 100,
  179. top: 100,
  180. bottom: -100,
  181. near: 0.1,
  182. far: 1e3
  183. };
  184. A = new OrthographicCamera(w, C, h2, P2, M, O), (g = e.cameras) == null || g.push(A);
  185. }
  186. return e.camera = A, t("camera", e.camera), A;
  187. }
  188. function n() {
  189. var s;
  190. e.camera instanceof PerspectiveCamera && e.aspectRatio && (e.camera.aspect = e.aspectRatio.value), (s = e.camera) == null || s.updateProjectionMatrix();
  191. }
  192. function r(s) {
  193. var f;
  194. (f = e.cameras) == null || f.push(s), s instanceof PerspectiveCamera && e.aspectRatio && (s.aspect = e.aspectRatio.value), s.updateProjectionMatrix(), t("camera", s);
  195. }
  196. function c(s) {
  197. var f;
  198. ((f = e.cameras) == null ? void 0 : f.length) === 0 && r(s);
  199. }
  200. function i() {
  201. e.cameras = [];
  202. }
  203. return watchEffect(() => {
  204. o != null && o.value && n();
  205. }), {
  206. activeCamera: toRef(e, "camera"),
  207. createCamera: a,
  208. updateCamera: n,
  209. pushCamera: r,
  210. clearCameras: i,
  211. setFirstCamera: c
  212. };
  213. }
  214. var Re = createEventHook();
  215. var Ee = createEventHook();
  216. var X = createEventHook();
  217. var D = new Clock();
  218. var H = 0;
  219. var U = 0;
  220. var { pause: tt, resume: at, isActive: nt } = useRafFn(
  221. () => {
  222. Re.trigger({ delta: H, elapsed: U, clock: D }), Ee.trigger({ delta: H, elapsed: U, clock: D }), X.trigger({ delta: H, elapsed: U, clock: D });
  223. },
  224. { immediate: false }
  225. );
  226. X.on(() => {
  227. H = D.getDelta(), U = D.getElapsedTime();
  228. });
  229. function Pe() {
  230. return {
  231. onBeforeLoop: Re.on,
  232. onLoop: Ee.on,
  233. onAfterLoop: X.on,
  234. pause: tt,
  235. resume: at,
  236. isActive: nt
  237. };
  238. }
  239. function rt(e) {
  240. return e instanceof Color ? e : Array.isArray(e) ? new Color(...e) : new Color(e);
  241. }
  242. var K = {
  243. realistic: {
  244. outputColorSpace: SRGBColorSpace,
  245. toneMapping: ACESFilmicToneMapping,
  246. toneMappingExposure: 3,
  247. shadowMap: {
  248. enabled: true,
  249. type: PCFSoftShadowMap
  250. }
  251. }
  252. };
  253. var Se = (e, t) => {
  254. for (const o of Object.keys(t))
  255. t[o] instanceof Object && Object.assign(t[o], Se(e[o], t[o]));
  256. return Object.assign(e || {}, t), e;
  257. };
  258. var ot = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
  259. var it = st(ot);
  260. function V(e) {
  261. return e.replace(/-([a-z])/g, (t, o) => o.toUpperCase());
  262. }
  263. function st(e, t) {
  264. const o = /* @__PURE__ */ Object.create(null), a = e.split(",");
  265. for (let n = 0; n < a.length; n++)
  266. o[a[n]] = true;
  267. return t ? (n) => !!o[n.toLowerCase()] : (n) => !!o[n];
  268. }
  269. function ct(e) {
  270. var te, ae;
  271. const t = shallowRef(), o = ref(false), {
  272. alpha: a = true,
  273. antialias: n = true,
  274. depth: r,
  275. logarithmicDepthBuffer: c,
  276. failIfMajorPerformanceCaveat: i,
  277. precision: s,
  278. premultipliedAlpha: f,
  279. stencil: u,
  280. shadows: m = false,
  281. shadowMapType: g = PCFShadowMap,
  282. useLegacyLights: w = false,
  283. outputColorSpace: C = LinearSRGBColorSpace,
  284. toneMapping: h2 = NoToneMapping,
  285. toneMappingExposure: P2 = 1,
  286. context: M = void 0,
  287. powerPreference: O = "default",
  288. preserveDrawingBuffer: S = false,
  289. clearColor: d,
  290. windowSize: b = false,
  291. preset: y = void 0
  292. } = toRefs(e), { state: v, setState: T } = _(), { width: k, height: x } = toValue(b) == true || toValue(b) === "" || toValue(b) === "true" ? useWindowSize() : useElementSize(v.container), { logError: B, logWarning: F } = I(), { pixelRatio: R } = useDevicePixelRatio(), { pause: z, resume: G } = Pe(), Y = computed(() => k.value / x.value);
  293. !toValue(b) && ((ae = (te = v.container) == null ? void 0 : te.value) == null ? void 0 : ae.offsetHeight) === 0 && F(`Oops... Seems like your canvas height is currently 0px, by default it takes the height of it's parent, so make sure it has some height with CSS.
  294. You could set windowSize=true to force the canvas to be the size of the window.`);
  295. const Z = () => {
  296. t.value && (t.value.setSize(k.value, x.value), t.value.setPixelRatio(Math.min(R.value, 2)));
  297. }, ee = () => {
  298. if (!t.value)
  299. return;
  300. const L = toValue(y);
  301. if (L) {
  302. L in K || B("Renderer Preset must be one of these: " + Object.keys(K).join(", ")), Se(t.value, K[L]);
  303. return;
  304. }
  305. t.value.shadowMap.enabled = toValue(m), t.value.shadowMap.type = toValue(g), t.value.toneMapping = toValue(h2) || NoToneMapping, t.value.toneMappingExposure = toValue(P2), t.value.outputColorSpace = toValue(C) || LinearSRGBColorSpace, d != null && d.value && t.value.setClearColor(rt(toValue(d))), t.value.useLegacyLights = toValue(w);
  306. }, Le = () => {
  307. const L = unrefElement(v.canvas);
  308. L && (t.value = new WebGLRenderer({
  309. canvas: L,
  310. alpha: toValue(a),
  311. antialias: toValue(n),
  312. context: toValue(M),
  313. depth: toValue(r),
  314. failIfMajorPerformanceCaveat: toValue(i),
  315. logarithmicDepthBuffer: toValue(c),
  316. powerPreference: toValue(O),
  317. precision: toValue(s),
  318. stencil: toValue(u),
  319. preserveDrawingBuffer: toValue(S),
  320. premultipliedAlpha: toValue(f)
  321. }), T("renderer", t.value), T("clock", new Clock()), T("aspectRatio", Y), ee(), Z(), G(), o.value = true);
  322. }, Ae = () => {
  323. t.value && (t.value.dispose(), t.value = void 0, o.value = false, z());
  324. };
  325. return watch([Y, R], Z), watch(
  326. [m, g, C, w, h2, P2, d],
  327. ee
  328. ), watch(
  329. () => [v.canvas, v.container],
  330. () => {
  331. unrefElement(v.canvas) && unrefElement(v.container) && Le();
  332. },
  333. { immediate: true, deep: true }
  334. ), {
  335. renderer: t,
  336. isReady: o,
  337. dispose: Ae,
  338. aspectRatio: Y
  339. };
  340. }
  341. var oe = (e) => typeof e == "function";
  342. var ft = (e) => typeof e == "string";
  343. var Te = (e) => !!e && e.constructor === Array;
  344. function ut(e) {
  345. const t = { nodes: {}, materials: {} };
  346. return e && e.traverse((o) => {
  347. o.name && (t.nodes[o.name] = o), o.material && !t.materials[o.material.name] && (t.materials[o.material.name] = o.material);
  348. }), t;
  349. }
  350. async function Rt(e, t, o, a, n) {
  351. const { logError: r } = I(), c = new e();
  352. n && n(c), o && o(c);
  353. const s = (Array.isArray(t) ? t : [t]).map(
  354. (f) => new Promise((u, m) => {
  355. c.load(
  356. f,
  357. (g) => {
  358. g.scene && Object.assign(g, ut(g.scene)), u(g);
  359. },
  360. a,
  361. (g) => m(r("[useLoader] - Failed to load resource", g))
  362. );
  363. })
  364. );
  365. return Te(t) ? await Promise.all(s) : await s[0];
  366. }
  367. async function Et(e) {
  368. const t = new LoadingManager(), o = new TextureLoader(t), a = (n) => new Promise((r, c) => {
  369. o.load(
  370. n,
  371. (i) => r(i),
  372. () => null,
  373. () => {
  374. c(new Error("[useTextures] - Failed to load texture"));
  375. }
  376. );
  377. });
  378. if (Te(e)) {
  379. const n = await Promise.all(e.map((r) => a(r)));
  380. return e.length > 1 ? n : n[0];
  381. } else {
  382. const {
  383. map: n,
  384. displacementMap: r,
  385. normalMap: c,
  386. roughnessMap: i,
  387. metalnessMap: s,
  388. aoMap: f,
  389. alphaMap: u,
  390. matcap: m
  391. } = e;
  392. return {
  393. map: n ? await a(n) : null,
  394. displacementMap: r ? await a(r) : null,
  395. normalMap: c ? await a(c) : null,
  396. roughnessMap: i ? await a(i) : null,
  397. metalnessMap: s ? await a(s) : null,
  398. aoMap: f ? await a(f) : null,
  399. alphaMap: u ? await a(u) : null,
  400. matcap: m ? await a(m) : null
  401. };
  402. }
  403. }
  404. var p = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
  405. function lt() {
  406. const e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, o = Math.random() * 4294967295 | 0, a = Math.random() * 4294967295 | 0;
  407. return (p[e & 255] + p[e >> 8 & 255] + p[e >> 16 & 255] + p[e >> 24 & 255] + "-" + p[t & 255] + p[t >> 8 & 255] + "-" + p[t >> 16 & 15 | 64] + p[t >> 24 & 255] + "-" + p[o & 63 | 128] + p[o >> 8 & 255] + "-" + p[o >> 16 & 255] + p[o >> 24 & 255] + p[a & 255] + p[a >> 8 & 255] + p[a >> 16 & 255] + p[a >> 24 & 255]).toLowerCase();
  408. }
  409. var Q = Symbol();
  410. function dt() {
  411. const e = shallowReactive({
  412. uuid: lt(),
  413. camera: void 0,
  414. cameras: [],
  415. scene: void 0,
  416. renderer: void 0,
  417. aspectRatio: computed(() => window.innerWidth / window.innerHeight)
  418. });
  419. function t(n) {
  420. return e[n];
  421. }
  422. function o(n, r) {
  423. e[n] = r;
  424. }
  425. const a = {
  426. state: e,
  427. ...toRefs(e),
  428. getState: t,
  429. setState: o
  430. };
  431. return provide(Q, a), a;
  432. }
  433. var _ = () => inject(Q, {
  434. state: shallowReactive({
  435. camera: void 0,
  436. cameras: [],
  437. scene: void 0,
  438. renderer: void 0
  439. })
  440. });
  441. function mt() {
  442. var c;
  443. const e = shallowRef(new Raycaster()), t = ref(new Vector2()), o = ref(null), { setState: a, state: n } = _();
  444. a("raycaster", e.value), a("pointer", t), a("currentInstance", o);
  445. function r(i) {
  446. t.value.x = i.clientX / window.innerWidth * 2 - 1, t.value.y = -(i.clientY / window.innerHeight) * 2 + 1;
  447. }
  448. return (c = n == null ? void 0 : n.renderer) == null || c.domElement.addEventListener("pointermove", r), onUnmounted(() => {
  449. var i;
  450. (i = n == null ? void 0 : n.renderer) == null || i.domElement.removeEventListener("pointermove", r);
  451. }), {
  452. raycaster: e,
  453. pointer: t
  454. };
  455. }
  456. var ie = "[TresJS ▲ ■ ●] ";
  457. function I() {
  458. function e(a, n) {
  459. console.error(`${ie} ${a}`, n || "");
  460. }
  461. function t(a) {
  462. console.warn(`${ie} ${a}`);
  463. }
  464. function o(a, n) {
  465. }
  466. return {
  467. logError: e,
  468. logWarning: t,
  469. logMessage: o
  470. };
  471. }
  472. var pt = /^on[^a-z]/;
  473. var vt = (e) => pt.test(e);
  474. var se = null;
  475. var ce = {
  476. GEOMETRY_VIA_PROP: "tres__geometryViaProp",
  477. MATERIAL_VIA_PROP: "tres__materialViaProp"
  478. };
  479. var { logError: fe } = I();
  480. var ue = true;
  481. var gt = {
  482. createElement(e, t, o, a) {
  483. var s, f;
  484. if (a || (a = {}), a.args || (a.args = []), e === "template" || it(e))
  485. return null;
  486. let n = e.replace("Tres", ""), r;
  487. if (e === "primitive") {
  488. (a == null ? void 0 : a.object) === void 0 && fe("Tres primitives need a prop 'object'");
  489. const u = a.object;
  490. n = u.type, r = Object.assign(u, { type: n, attach: a.attach, primitive: true });
  491. } else {
  492. const u = Ce.value[n];
  493. u || fe(`${n} is not defined on the THREE namespace. Use extend to add it to the catalog.`), r = new u(...a.args);
  494. }
  495. if (r.isCamera && ue) {
  496. a != null && a.position || r.position.set(3, 3, 3), a != null && a.lookAt || r.lookAt(0, 0, 0);
  497. const { setFirstCamera: u } = xe();
  498. u(r), ue = false;
  499. }
  500. (a == null ? void 0 : a.attach) === void 0 && (r.isMaterial ? r.attach = "material" : r.isBufferGeometry && (r.attach = "geometry"));
  501. const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = ce;
  502. return r.isObject3D && ((s = a == null ? void 0 : a.material) != null && s.isMaterial && (r.userData[i] = true), (f = a == null ? void 0 : a.geometry) != null && f.isBufferGeometry && (r.userData[c] = true)), r.events = {}, r;
  503. },
  504. insert(e, t) {
  505. var o, a, n, r;
  506. if ((((o = e == null ? void 0 : e.__vnode) == null ? void 0 : o.type) === "TresGroup" || ((a = e == null ? void 0 : e.__vnode) == null ? void 0 : a.type) === "TresObject3D") && t === null && !((r = (n = e == null ? void 0 : e.__vnode) == null ? void 0 : n.ctx) != null && r.asyncResolved)) {
  507. se = e;
  508. return;
  509. }
  510. t || (t = se), e != null && e.isObject3D && (t != null && t.isObject3D) ? (t.add(e), e.dispatchEvent({ type: "added" })) : e != null && e.isFog ? t.fog = e : typeof (e == null ? void 0 : e.attach) == "string" && (e.__previousAttach = e[t == null ? void 0 : t.attach], t && (t[e.attach] = e));
  511. },
  512. remove(e) {
  513. var t, o;
  514. if (e) {
  515. if (e.isObject3D) {
  516. const a = e, n = (r) => {
  517. var s, f;
  518. const { GEOMETRY_VIA_PROP: c, MATERIAL_VIA_PROP: i } = ce;
  519. r.userData[i] || (s = r.material) == null || s.dispose(), r.userData[c] || (f = r.geometry) == null || f.dispose();
  520. };
  521. a.traverse((r) => n(r)), n(a);
  522. }
  523. (t = e.removeFromParent) == null || t.call(e), (o = e.dispose) == null || o.call(e);
  524. }
  525. },
  526. patchProp(e, t, o, a) {
  527. if (e) {
  528. let n = e, r = t, c = V(r), i = n == null ? void 0 : n[c];
  529. if (n.type === "BufferGeometry") {
  530. if (r === "args")
  531. return;
  532. n.setAttribute(
  533. V(r),
  534. new BufferAttribute(...a)
  535. );
  536. return;
  537. }
  538. if (r.includes("-") && i === void 0) {
  539. const f = r.split("-");
  540. i = f.reduce((u, m) => u[V(m)], n), r = f.pop(), c = r.toLowerCase(), i != null && i.set || (n = f.reduce((u, m) => u[V(m)], n));
  541. }
  542. vt(r) && (e.events[r] = a);
  543. let s = a;
  544. if (s === "" && (s = true), oe(i)) {
  545. Array.isArray(s) ? e[c](...s) : e[c](s);
  546. return;
  547. }
  548. !(i != null && i.set) && !oe(i) ? n[c] = s : i.constructor === s.constructor && (i != null && i.copy) ? i == null || i.copy(s) : Array.isArray(s) ? i.set(...s) : !i.isColor && i.setScalar ? i.setScalar(s) : i.set(s);
  549. }
  550. },
  551. parentNode(e) {
  552. return (e == null ? void 0 : e.parent) || null;
  553. },
  554. createText: () => void 0,
  555. createComment: () => void 0,
  556. setText: () => void 0,
  557. setElementText: () => void 0,
  558. nextSibling: () => void 0,
  559. querySelector: () => void 0,
  560. setScopeId: () => void 0,
  561. cloneNode: () => void 0,
  562. insertStaticContent: () => void 0
  563. };
  564. var { createApp: ht } = createRenderer(gt);
  565. var wt = (e) => {
  566. const t = ht(o);
  567. function o() {
  568. return e && e.default ? e.default() : [];
  569. }
  570. return t;
  571. };
  572. Me(three_module_exports);
  573. var { logWarning: le } = I();
  574. var bt = defineComponent({
  575. name: "TresScene",
  576. props: [
  577. "shadows",
  578. "shadowMapType",
  579. "physicallyCorrectLights",
  580. "useLegacyLights",
  581. "outputColorSpace",
  582. "toneMapping",
  583. "toneMappingExposure",
  584. "context",
  585. "powerPreference",
  586. "preserveDrawingBuffer",
  587. "clearColor",
  588. "windowSize",
  589. "preset",
  590. "disableRender",
  591. "camera"
  592. ],
  593. setup(e, { slots: t, expose: o }) {
  594. e.physicallyCorrectLights === true && le("physicallyCorrectLights is deprecated, useLegacyLights is now false by default");
  595. const a = ref(), n = ref(), r = new Scene(), { setState: c } = _();
  596. c("scene", r), c("canvas", n), c("container", a);
  597. const i = ref(), s = t && t.default && t.default();
  598. s && (s == null ? void 0 : s.length) > 0 && (i.value = s.some((h2) => ft(h2.type) && h2.type.includes("Camera")) || e.camera, i.value || le("No camera found in the scene, please add one!")), onMounted(() => {
  599. g();
  600. }), onUnmounted(() => {
  601. c("renderer", null);
  602. });
  603. const { activeCamera: f, pushCamera: u, clearCameras: m } = xe();
  604. function g() {
  605. const { renderer: h2 } = ct(e);
  606. e.camera && u(e.camera);
  607. const { onLoop: P2 } = Pe(), { raycaster: M, pointer: O } = mt();
  608. let S = null, d = null;
  609. watchEffect(() => {
  610. f.value && M.value.setFromCamera(O.value, f.value);
  611. }), P2(() => {
  612. var b, y, v, T, k, x, B, F, R, z;
  613. if (f.value && e.disableRender !== true && ((b = h2.value) == null || b.render(r, f.value)), M.value) {
  614. const G = M.value.intersectObjects(r.children);
  615. G.length > 0 ? (d = G[0], S === null && ((T = (v = (y = d.object) == null ? void 0 : y.events) == null ? void 0 : v.onPointerEnter) == null || T.call(v, d)), (B = (x = (k = d.object) == null ? void 0 : k.events) == null ? void 0 : x.onPointerMove) == null || B.call(x, d)) : S !== null && ((z = (R = (F = d == null ? void 0 : d.object) == null ? void 0 : F.events) == null ? void 0 : R.onPointerLeave) == null || z.call(R, S), d = null), S = d;
  616. }
  617. }), useEventListener(n.value, "click", () => {
  618. var b, y, v;
  619. d !== null && ((v = (y = (b = d.object) == null ? void 0 : b.events) == null ? void 0 : y.onClick) == null || v.call(y, d));
  620. });
  621. }
  622. let w;
  623. function C() {
  624. w = wt(t), w.provide("useTres", _()), w.provide(Q, _()), w.provide("extend", Me), w.mount(r);
  625. }
  626. return C(), o({
  627. scene: r
  628. }), watch(
  629. () => e.camera,
  630. (h2) => {
  631. h2 && (m(), u(h2));
  632. }
  633. ), () => h(
  634. h(
  635. "div",
  636. {
  637. ref: a,
  638. "data-scene": r.uuid,
  639. key: r.uuid,
  640. style: {
  641. position: "relative",
  642. width: "100%",
  643. height: "100%",
  644. pointerEvents: "auto",
  645. touchAction: "none"
  646. }
  647. },
  648. [
  649. h(
  650. "div",
  651. {
  652. style: {
  653. width: "100%",
  654. height: "100%"
  655. }
  656. },
  657. [
  658. h("canvas", {
  659. ref: n,
  660. "data-scene": r.uuid,
  661. style: {
  662. display: "block",
  663. width: "100%",
  664. height: "100%",
  665. position: e.windowSize ? "fixed" : "absolute",
  666. top: 0,
  667. left: 0
  668. }
  669. })
  670. ]
  671. )
  672. ]
  673. )
  674. );
  675. }
  676. });
  677. var yt = defineComponent({
  678. name: "TresCanvas",
  679. props: [
  680. "shadows",
  681. "shadowMapType",
  682. "physicallyCorrectLights",
  683. "useLegacyLights",
  684. "outputColorSpace",
  685. "toneMapping",
  686. "toneMappingExposure",
  687. "context",
  688. "powerPreference",
  689. "preserveDrawingBuffer",
  690. "clearColor",
  691. "windowSize",
  692. "preset",
  693. "disableRender",
  694. "camera"
  695. ],
  696. setup(e, { slots: t, expose: o }) {
  697. const a = dt();
  698. return o(a), () => h(bt, e, t);
  699. }
  700. });
  701. // node_modules/.pnpm/@tresjs+cientos@2.0.0_@tresjs+core@_three@0.152.2_vue@3.2.47/node_modules/@tresjs/cientos/dist/trescientos.js
  702. var Jc = Object.defineProperty;
  703. var eu = (f, i, s) => i in f ? Jc(f, i, { enumerable: true, configurable: true, writable: true, value: s }) : f[i] = s;
  704. var Zr = (f, i, s) => (eu(f, typeof i != "symbol" ? i + "" : i, s), s);
  705. function Zu(f, i) {
  706. for (var s = 0; s < i.length; s++) {
  707. const r = i[s];
  708. if (typeof r != "string" && !Array.isArray(r)) {
  709. for (const o in r)
  710. if (o !== "default" && !(o in f)) {
  711. const c = Object.getOwnPropertyDescriptor(r, o);
  712. c && Object.defineProperty(f, o, c.get ? c : {
  713. enumerable: true,
  714. get: () => r[o]
  715. });
  716. }
  717. }
  718. }
  719. return Object.freeze(Object.defineProperty(f, Symbol.toStringTag, { value: "Module" }));
  720. }
  721. function is(f) {
  722. return is = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(i) {
  723. return typeof i;
  724. } : function(i) {
  725. return i && typeof Symbol == "function" && i.constructor === Symbol && i !== Symbol.prototype ? "symbol" : typeof i;
  726. }, is(f);
  727. }
  728. function Wu(f, i) {
  729. if (is(f) !== "object" || f === null)
  730. return f;
  731. var s = f[Symbol.toPrimitive];
  732. if (s !== void 0) {
  733. var r = s.call(f, i || "default");
  734. if (is(r) !== "object")
  735. return r;
  736. throw new TypeError("@@toPrimitive must return a primitive value.");
  737. }
  738. return (i === "string" ? String : Number)(f);
  739. }
  740. function Ju(f) {
  741. var i = Wu(f, "string");
  742. return is(i) === "symbol" ? i : String(i);
  743. }
  744. function P(f, i, s) {
  745. return i = Ju(i), i in f ? Object.defineProperty(f, i, {
  746. value: s,
  747. enumerable: true,
  748. configurable: true,
  749. writable: true
  750. }) : f[i] = s, f;
  751. }
  752. function da(f, i) {
  753. if (i === TrianglesDrawMode)
  754. return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), f;
  755. if (i === TriangleFanDrawMode || i === TriangleStripDrawMode) {
  756. let s = f.getIndex();
  757. if (s === null) {
  758. const p2 = [], h2 = f.getAttribute("position");
  759. if (h2 !== void 0) {
  760. for (let m = 0; m < h2.count; m++)
  761. p2.push(m);
  762. f.setIndex(p2), s = f.getIndex();
  763. } else
  764. return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), f;
  765. }
  766. const r = s.count - 2, o = [];
  767. if (s)
  768. if (i === TriangleFanDrawMode)
  769. for (let p2 = 1; p2 <= r; p2++)
  770. o.push(s.getX(0)), o.push(s.getX(p2)), o.push(s.getX(p2 + 1));
  771. else
  772. for (let p2 = 0; p2 < r; p2++)
  773. p2 % 2 === 0 ? (o.push(s.getX(p2)), o.push(s.getX(p2 + 1)), o.push(s.getX(p2 + 2))) : (o.push(s.getX(p2 + 2)), o.push(s.getX(p2 + 1)), o.push(s.getX(p2)));
  774. o.length / 3 !== r && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
  775. const c = f.clone();
  776. return c.setIndex(o), c.clearGroups(), c;
  777. } else
  778. return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", i), f;
  779. }
  780. var ft2 = Uint8Array;
  781. var cn = Uint16Array;
  782. var vo = Uint32Array;
  783. var Ga = new ft2([
  784. 0,
  785. 0,
  786. 0,
  787. 0,
  788. 0,
  789. 0,
  790. 0,
  791. 0,
  792. 1,
  793. 1,
  794. 1,
  795. 1,
  796. 2,
  797. 2,
  798. 2,
  799. 2,
  800. 3,
  801. 3,
  802. 3,
  803. 3,
  804. 4,
  805. 4,
  806. 4,
  807. 4,
  808. 5,
  809. 5,
  810. 5,
  811. 5,
  812. 0,
  813. /* unused */
  814. 0,
  815. 0,
  816. /* impossible */
  817. 0
  818. ]);
  819. var Ha = new ft2([
  820. 0,
  821. 0,
  822. 0,
  823. 0,
  824. 1,
  825. 1,
  826. 2,
  827. 2,
  828. 3,
  829. 3,
  830. 4,
  831. 4,
  832. 5,
  833. 5,
  834. 6,
  835. 6,
  836. 7,
  837. 7,
  838. 8,
  839. 8,
  840. 9,
  841. 9,
  842. 10,
  843. 10,
  844. 11,
  845. 11,
  846. 12,
  847. 12,
  848. 13,
  849. 13,
  850. /* unused */
  851. 0,
  852. 0
  853. ]);
  854. var ep = new ft2([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
  855. var Ka = function(f, i) {
  856. for (var s = new cn(31), r = 0; r < 31; ++r)
  857. s[r] = i += 1 << f[r - 1];
  858. for (var o = new vo(s[30]), r = 1; r < 30; ++r)
  859. for (var c = s[r]; c < s[r + 1]; ++c)
  860. o[c] = c - s[r] << 5 | r;
  861. return [s, o];
  862. };
  863. var $a = Ka(Ga, 2);
  864. var Xa = $a[0];
  865. var tp = $a[1];
  866. Xa[28] = 258, tp[258] = 28;
  867. var np = Ka(Ha, 0);
  868. var ip = np[0];
  869. var bo = new cn(32768);
  870. for (Te2 = 0; Te2 < 32768; ++Te2) {
  871. nn = (Te2 & 43690) >>> 1 | (Te2 & 21845) << 1;
  872. nn = (nn & 52428) >>> 2 | (nn & 13107) << 2, nn = (nn & 61680) >>> 4 | (nn & 3855) << 4, bo[Te2] = ((nn & 65280) >>> 8 | (nn & 255) << 8) >>> 1;
  873. }
  874. var nn;
  875. var Te2;
  876. var Ji = function(f, i, s) {
  877. for (var r = f.length, o = 0, c = new cn(i); o < r; ++o)
  878. ++c[f[o] - 1];
  879. var p2 = new cn(i);
  880. for (o = 0; o < i; ++o)
  881. p2[o] = p2[o - 1] + c[o - 1] << 1;
  882. var h2;
  883. if (s) {
  884. h2 = new cn(1 << i);
  885. var m = 15 - i;
  886. for (o = 0; o < r; ++o)
  887. if (f[o])
  888. for (var g = o << 4 | f[o], w = i - f[o], _2 = p2[f[o] - 1]++ << w, y = _2 | (1 << w) - 1; _2 <= y; ++_2)
  889. h2[bo[_2] >>> m] = g;
  890. } else
  891. for (h2 = new cn(r), o = 0; o < r; ++o)
  892. f[o] && (h2[o] = bo[p2[f[o] - 1]++] >>> 15 - f[o]);
  893. return h2;
  894. };
  895. var os = new ft2(288);
  896. for (Te2 = 0; Te2 < 144; ++Te2)
  897. os[Te2] = 8;
  898. var Te2;
  899. for (Te2 = 144; Te2 < 256; ++Te2)
  900. os[Te2] = 9;
  901. var Te2;
  902. for (Te2 = 256; Te2 < 280; ++Te2)
  903. os[Te2] = 7;
  904. var Te2;
  905. for (Te2 = 280; Te2 < 288; ++Te2)
  906. os[Te2] = 8;
  907. var Te2;
  908. var Ya = new ft2(32);
  909. for (Te2 = 0; Te2 < 32; ++Te2)
  910. Ya[Te2] = 5;
  911. var Te2;
  912. var sp = Ji(os, 9, 1);
  913. var rp = Ji(Ya, 5, 1);
  914. var to = function(f) {
  915. for (var i = f[0], s = 1; s < f.length; ++s)
  916. f[s] > i && (i = f[s]);
  917. return i;
  918. };
  919. var xt = function(f, i, s) {
  920. var r = i / 8 | 0;
  921. return (f[r] | f[r + 1] << 8) >> (i & 7) & s;
  922. };
  923. var no = function(f, i) {
  924. var s = i / 8 | 0;
  925. return (f[s] | f[s + 1] << 8 | f[s + 2] << 16) >> (i & 7);
  926. };
  927. var op = function(f) {
  928. return (f / 8 | 0) + (f & 7 && 1);
  929. };
  930. var ap = function(f, i, s) {
  931. (i == null || i < 0) && (i = 0), (s == null || s > f.length) && (s = f.length);
  932. var r = new (f instanceof cn ? cn : f instanceof vo ? vo : ft2)(s - i);
  933. return r.set(f.subarray(i, s)), r;
  934. };
  935. var lp = function(f, i, s) {
  936. var r = f.length;
  937. if (!r || s && !s.l && r < 5)
  938. return i || new ft2(0);
  939. var o = !i || s, c = !s || s.i;
  940. s || (s = {}), i || (i = new ft2(r * 3));
  941. var p2 = function(Ne) {
  942. var Ue = i.length;
  943. if (Ne > Ue) {
  944. var xe2 = new ft2(Math.max(Ue * 2, Ne));
  945. xe2.set(i), i = xe2;
  946. }
  947. }, h2 = s.f || 0, m = s.p || 0, g = s.b || 0, w = s.l, _2 = s.d, y = s.m, C = s.n, L = r * 8;
  948. do {
  949. if (!w) {
  950. s.f = h2 = xt(f, m, 1);
  951. var S = xt(f, m + 1, 3);
  952. if (m += 3, S)
  953. if (S == 1)
  954. w = sp, _2 = rp, y = 9, C = 5;
  955. else if (S == 2) {
  956. var I2 = xt(f, m, 31) + 257, D2 = xt(f, m + 10, 15) + 4, Y = I2 + xt(f, m + 5, 31) + 1;
  957. m += 14;
  958. for (var G = new ft2(Y), F = new ft2(19), B = 0; B < D2; ++B)
  959. F[ep[B]] = xt(f, m + B * 3, 7);
  960. m += D2 * 3;
  961. for (var H2 = to(F), K2 = (1 << H2) - 1, q = Ji(F, H2, 1), B = 0; B < Y; ) {
  962. var pe = q[xt(f, m, K2)];
  963. m += pe & 15;
  964. var R = pe >>> 4;
  965. if (R < 16)
  966. G[B++] = R;
  967. else {
  968. var _e = 0, ce2 = 0;
  969. for (R == 16 ? (ce2 = 3 + xt(f, m, 3), m += 2, _e = G[B - 1]) : R == 17 ? (ce2 = 3 + xt(f, m, 7), m += 3) : R == 18 && (ce2 = 11 + xt(f, m, 127), m += 7); ce2--; )
  970. G[B++] = _e;
  971. }
  972. }
  973. var me = G.subarray(0, I2), he = G.subarray(I2);
  974. y = to(me), C = to(he), w = Ji(me, y, 1), _2 = Ji(he, C, 1);
  975. } else
  976. throw "invalid block type";
  977. else {
  978. var R = op(m) + 4, O = f[R - 4] | f[R - 3] << 8, N = R + O;
  979. if (N > r) {
  980. if (c)
  981. throw "unexpected EOF";
  982. break;
  983. }
  984. o && p2(g + O), i.set(f.subarray(R, N), g), s.b = g += O, s.p = m = N * 8;
  985. continue;
  986. }
  987. if (m > L) {
  988. if (c)
  989. throw "unexpected EOF";
  990. break;
  991. }
  992. }
  993. o && p2(g + 131072);
  994. for (var ee = (1 << y) - 1, X2 = (1 << C) - 1, Se2 = m; ; Se2 = m) {
  995. var _e = w[no(f, m) & ee], fe2 = _e >>> 4;
  996. if (m += _e & 15, m > L) {
  997. if (c)
  998. throw "unexpected EOF";
  999. break;
  1000. }
  1001. if (!_e)
  1002. throw "invalid length/literal";
  1003. if (fe2 < 256)
  1004. i[g++] = fe2;
  1005. else if (fe2 == 256) {
  1006. Se2 = m, w = null;
  1007. break;
  1008. } else {
  1009. var oe2 = fe2 - 254;
  1010. if (fe2 > 264) {
  1011. var B = fe2 - 257, ne = Ga[B];
  1012. oe2 = xt(f, m, (1 << ne) - 1) + Xa[B], m += ne;
  1013. }
  1014. var ge = _2[no(f, m) & X2], A2 = ge >>> 4;
  1015. if (!ge)
  1016. throw "invalid distance";
  1017. m += ge & 15;
  1018. var he = ip[A2];
  1019. if (A2 > 3) {
  1020. var ne = Ha[A2];
  1021. he += no(f, m) & (1 << ne) - 1, m += ne;
  1022. }
  1023. if (m > L) {
  1024. if (c)
  1025. throw "unexpected EOF";
  1026. break;
  1027. }
  1028. o && p2(g + 131072);
  1029. for (var ae = g + oe2; g < ae; g += 4)
  1030. i[g] = i[g - he], i[g + 1] = i[g + 1 - he], i[g + 2] = i[g + 2 - he], i[g + 3] = i[g + 3 - he];
  1031. g = ae;
  1032. }
  1033. }
  1034. s.l = w, s.p = Se2, s.b = g, w && (h2 = 1, s.m = y, s.d = _2, s.n = C);
  1035. } while (!h2);
  1036. return g == i.length ? i : ap(i, 0, g);
  1037. };
  1038. var cp = new ft2(0);
  1039. var up = function(f) {
  1040. if ((f[0] & 15) != 8 || f[0] >>> 4 > 7 || (f[0] << 8 | f[1]) % 31)
  1041. throw "invalid zlib data";
  1042. if (f[1] & 32)
  1043. throw "invalid zlib data: preset dictionaries not supported";
  1044. };
  1045. function pp(f, i) {
  1046. return lp((up(f), f.subarray(2, -4)), i);
  1047. }
  1048. var hp = typeof TextDecoder < "u" && new TextDecoder();
  1049. var dp = 0;
  1050. try {
  1051. hp.decode(cp, { stream: true }), dp = 1;
  1052. } catch {
  1053. }
  1054. var mp = class extends Object3D {
  1055. // events
  1056. constructor(i, s) {
  1057. super(), P(this, "isTransformControls", true), P(this, "visible", false), P(this, "domElement", void 0), P(this, "raycaster", new Raycaster()), P(this, "gizmo", void 0), P(this, "plane", void 0), P(this, "tempVector", new Vector3()), P(this, "tempVector2", new Vector3()), P(this, "tempQuaternion", new Quaternion()), P(this, "unit", {
  1058. X: new Vector3(1, 0, 0),
  1059. Y: new Vector3(0, 1, 0),
  1060. Z: new Vector3(0, 0, 1)
  1061. }), P(this, "pointStart", new Vector3()), P(this, "pointEnd", new Vector3()), P(this, "offset", new Vector3()), P(this, "rotationAxis", new Vector3()), P(this, "startNorm", new Vector3()), P(this, "endNorm", new Vector3()), P(this, "rotationAngle", 0), P(this, "cameraPosition", new Vector3()), P(this, "cameraQuaternion", new Quaternion()), P(this, "cameraScale", new Vector3()), P(this, "parentPosition", new Vector3()), P(this, "parentQuaternion", new Quaternion()), P(this, "parentQuaternionInv", new Quaternion()), P(this, "parentScale", new Vector3()), P(this, "worldPositionStart", new Vector3()), P(this, "worldQuaternionStart", new Quaternion()), P(this, "worldScaleStart", new Vector3()), P(this, "worldPosition", new Vector3()), P(this, "worldQuaternion", new Quaternion()), P(this, "worldQuaternionInv", new Quaternion()), P(this, "worldScale", new Vector3()), P(this, "eye", new Vector3()), P(this, "positionStart", new Vector3()), P(this, "quaternionStart", new Quaternion()), P(this, "scaleStart", new Vector3()), P(this, "camera", void 0), P(this, "object", void 0), P(this, "enabled", true), P(this, "axis", null), P(this, "mode", "translate"), P(this, "translationSnap", null), P(this, "rotationSnap", null), P(this, "scaleSnap", null), P(this, "space", "world"), P(this, "size", 1), P(this, "dragging", false), P(this, "showX", true), P(this, "showY", true), P(this, "showZ", true), P(this, "changeEvent", {
  1062. type: "change"
  1063. }), P(this, "mouseDownEvent", {
  1064. type: "mouseDown",
  1065. mode: this.mode
  1066. }), P(this, "mouseUpEvent", {
  1067. type: "mouseUp",
  1068. mode: this.mode
  1069. }), P(this, "objectChangeEvent", {
  1070. type: "objectChange"
  1071. }), P(this, "intersectObjectWithRay", (o, c, p2) => {
  1072. const h2 = c.intersectObject(o, true);
  1073. for (let m = 0; m < h2.length; m++)
  1074. if (h2[m].object.visible || p2)
  1075. return h2[m];
  1076. return false;
  1077. }), P(this, "attach", (o) => (this.object = o, this.visible = true, this)), P(this, "detach", () => (this.object = void 0, this.visible = false, this.axis = null, this)), P(this, "reset", () => this.enabled ? (this.dragging && this.object !== void 0 && (this.object.position.copy(this.positionStart), this.object.quaternion.copy(this.quaternionStart), this.object.scale.copy(this.scaleStart), this.dispatchEvent(this.changeEvent), this.dispatchEvent(this.objectChangeEvent), this.pointStart.copy(this.pointEnd)), this) : this), P(this, "updateMatrixWorld", () => {
  1078. this.object !== void 0 && (this.object.updateMatrixWorld(), this.object.parent === null ? console.error("TransformControls: The attached 3D object must be a part of the scene graph.") : this.object.parent.matrixWorld.decompose(this.parentPosition, this.parentQuaternion, this.parentScale), this.object.matrixWorld.decompose(this.worldPosition, this.worldQuaternion, this.worldScale), this.parentQuaternionInv.copy(this.parentQuaternion).invert(), this.worldQuaternionInv.copy(this.worldQuaternion).invert()), this.camera.updateMatrixWorld(), this.camera.matrixWorld.decompose(this.cameraPosition, this.cameraQuaternion, this.cameraScale), this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(), super.updateMatrixWorld();
  1079. }), P(this, "pointerHover", (o) => {
  1080. if (this.object === void 0 || this.dragging === true)
  1081. return;
  1082. this.raycaster.setFromCamera(o, this.camera);
  1083. const c = this.intersectObjectWithRay(this.gizmo.picker[this.mode], this.raycaster);
  1084. c ? this.axis = c.object.name : this.axis = null;
  1085. }), P(this, "pointerDown", (o) => {
  1086. if (!(this.object === void 0 || this.dragging === true || o.button !== 0) && this.axis !== null) {
  1087. this.raycaster.setFromCamera(o, this.camera);
  1088. const c = this.intersectObjectWithRay(this.plane, this.raycaster, true);
  1089. if (c) {
  1090. let p2 = this.space;
  1091. if (this.mode === "scale" ? p2 = "local" : (this.axis === "E" || this.axis === "XYZE" || this.axis === "XYZ") && (p2 = "world"), p2 === "local" && this.mode === "rotate") {
  1092. const h2 = this.rotationSnap;
  1093. this.axis === "X" && h2 && (this.object.rotation.x = Math.round(this.object.rotation.x / h2) * h2), this.axis === "Y" && h2 && (this.object.rotation.y = Math.round(this.object.rotation.y / h2) * h2), this.axis === "Z" && h2 && (this.object.rotation.z = Math.round(this.object.rotation.z / h2) * h2);
  1094. }
  1095. this.object.updateMatrixWorld(), this.object.parent && this.object.parent.updateMatrixWorld(), this.positionStart.copy(this.object.position), this.quaternionStart.copy(this.object.quaternion), this.scaleStart.copy(this.object.scale), this.object.matrixWorld.decompose(this.worldPositionStart, this.worldQuaternionStart, this.worldScaleStart), this.pointStart.copy(c.point).sub(this.worldPositionStart);
  1096. }
  1097. this.dragging = true, this.mouseDownEvent.mode = this.mode, this.dispatchEvent(this.mouseDownEvent);
  1098. }
  1099. }), P(this, "pointerMove", (o) => {
  1100. const c = this.axis, p2 = this.mode, h2 = this.object;
  1101. let m = this.space;
  1102. if (p2 === "scale" ? m = "local" : (c === "E" || c === "XYZE" || c === "XYZ") && (m = "world"), h2 === void 0 || c === null || this.dragging === false || o.button !== -1)
  1103. return;
  1104. this.raycaster.setFromCamera(o, this.camera);
  1105. const g = this.intersectObjectWithRay(this.plane, this.raycaster, true);
  1106. if (g) {
  1107. if (this.pointEnd.copy(g.point).sub(this.worldPositionStart), p2 === "translate")
  1108. this.offset.copy(this.pointEnd).sub(this.pointStart), m === "local" && c !== "XYZ" && this.offset.applyQuaternion(this.worldQuaternionInv), c.indexOf("X") === -1 && (this.offset.x = 0), c.indexOf("Y") === -1 && (this.offset.y = 0), c.indexOf("Z") === -1 && (this.offset.z = 0), m === "local" && c !== "XYZ" ? this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale) : this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale), h2.position.copy(this.offset).add(this.positionStart), this.translationSnap && (m === "local" && (h2.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()), c.search("X") !== -1 && (h2.position.x = Math.round(h2.position.x / this.translationSnap) * this.translationSnap), c.search("Y") !== -1 && (h2.position.y = Math.round(h2.position.y / this.translationSnap) * this.translationSnap), c.search("Z") !== -1 && (h2.position.z = Math.round(h2.position.z / this.translationSnap) * this.translationSnap), h2.position.applyQuaternion(this.quaternionStart)), m === "world" && (h2.parent && h2.position.add(this.tempVector.setFromMatrixPosition(h2.parent.matrixWorld)), c.search("X") !== -1 && (h2.position.x = Math.round(h2.position.x / this.translationSnap) * this.translationSnap), c.search("Y") !== -1 && (h2.position.y = Math.round(h2.position.y / this.translationSnap) * this.translationSnap), c.search("Z") !== -1 && (h2.position.z = Math.round(h2.position.z / this.translationSnap) * this.translationSnap), h2.parent && h2.position.sub(this.tempVector.setFromMatrixPosition(h2.parent.matrixWorld))));
  1109. else if (p2 === "scale") {
  1110. if (c.search("XYZ") !== -1) {
  1111. let w = this.pointEnd.length() / this.pointStart.length();
  1112. this.pointEnd.dot(this.pointStart) < 0 && (w *= -1), this.tempVector2.set(w, w, w);
  1113. } else
  1114. this.tempVector.copy(this.pointStart), this.tempVector2.copy(this.pointEnd), this.tempVector.applyQuaternion(this.worldQuaternionInv), this.tempVector2.applyQuaternion(this.worldQuaternionInv), this.tempVector2.divide(this.tempVector), c.search("X") === -1 && (this.tempVector2.x = 1), c.search("Y") === -1 && (this.tempVector2.y = 1), c.search("Z") === -1 && (this.tempVector2.z = 1);
  1115. h2.scale.copy(this.scaleStart).multiply(this.tempVector2), this.scaleSnap && this.object && (c.search("X") !== -1 && (this.object.scale.x = Math.round(h2.scale.x / this.scaleSnap) * this.scaleSnap || this.scaleSnap), c.search("Y") !== -1 && (h2.scale.y = Math.round(h2.scale.y / this.scaleSnap) * this.scaleSnap || this.scaleSnap), c.search("Z") !== -1 && (h2.scale.z = Math.round(h2.scale.z / this.scaleSnap) * this.scaleSnap || this.scaleSnap));
  1116. } else if (p2 === "rotate") {
  1117. this.offset.copy(this.pointEnd).sub(this.pointStart);
  1118. const w = 20 / this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));
  1119. c === "E" ? (this.rotationAxis.copy(this.eye), this.rotationAngle = this.pointEnd.angleTo(this.pointStart), this.startNorm.copy(this.pointStart).normalize(), this.endNorm.copy(this.pointEnd).normalize(), this.rotationAngle *= this.endNorm.cross(this.startNorm).dot(this.eye) < 0 ? 1 : -1) : c === "XYZE" ? (this.rotationAxis.copy(this.offset).cross(this.eye).normalize(), this.rotationAngle = this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye)) * w) : (c === "X" || c === "Y" || c === "Z") && (this.rotationAxis.copy(this.unit[c]), this.tempVector.copy(this.unit[c]), m === "local" && this.tempVector.applyQuaternion(this.worldQuaternion), this.rotationAngle = this.offset.dot(this.tempVector.cross(this.eye).normalize()) * w), this.rotationSnap && (this.rotationAngle = Math.round(this.rotationAngle / this.rotationSnap) * this.rotationSnap), m === "local" && c !== "E" && c !== "XYZE" ? (h2.quaternion.copy(this.quaternionStart), h2.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis, this.rotationAngle)).normalize()) : (this.rotationAxis.applyQuaternion(this.parentQuaternionInv), h2.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis, this.rotationAngle)), h2.quaternion.multiply(this.quaternionStart).normalize());
  1120. }
  1121. this.dispatchEvent(this.changeEvent), this.dispatchEvent(this.objectChangeEvent);
  1122. }
  1123. }), P(this, "pointerUp", (o) => {
  1124. o.button === 0 && (this.dragging && this.axis !== null && (this.mouseUpEvent.mode = this.mode, this.dispatchEvent(this.mouseUpEvent)), this.dragging = false, this.axis = null);
  1125. }), P(this, "getPointer", (o) => {
  1126. var c;
  1127. if (this.domElement && (c = this.domElement.ownerDocument) !== null && c !== void 0 && c.pointerLockElement)
  1128. return {
  1129. x: 0,
  1130. y: 0,
  1131. button: o.button
  1132. };
  1133. {
  1134. var p2;
  1135. const h2 = o.changedTouches ? o.changedTouches[0] : o, m = (p2 = this.domElement) === null || p2 === void 0 ? void 0 : p2.getBoundingClientRect();
  1136. return {
  1137. x: (h2.clientX - m.left) / m.width * 2 - 1,
  1138. y: -(h2.clientY - m.top) / m.height * 2 + 1,
  1139. button: o.button
  1140. };
  1141. }
  1142. }), P(this, "onPointerHover", (o) => {
  1143. if (this.enabled)
  1144. switch (o.pointerType) {
  1145. case "mouse":
  1146. case "pen":
  1147. this.pointerHover(this.getPointer(o));
  1148. break;
  1149. }
  1150. }), P(this, "onPointerDown", (o) => {
  1151. !this.enabled || !this.domElement || (this.domElement.style.touchAction = "none", this.domElement.ownerDocument.addEventListener("pointermove", this.onPointerMove), this.pointerHover(this.getPointer(o)), this.pointerDown(this.getPointer(o)));
  1152. }), P(this, "onPointerMove", (o) => {
  1153. this.enabled && this.pointerMove(this.getPointer(o));
  1154. }), P(this, "onPointerUp", (o) => {
  1155. !this.enabled || !this.domElement || (this.domElement.style.touchAction = "", this.domElement.ownerDocument.removeEventListener("pointermove", this.onPointerMove), this.pointerUp(this.getPointer(o)));
  1156. }), P(this, "getMode", () => this.mode), P(this, "setMode", (o) => {
  1157. this.mode = o;
  1158. }), P(this, "setTranslationSnap", (o) => {
  1159. this.translationSnap = o;
  1160. }), P(this, "setRotationSnap", (o) => {
  1161. this.rotationSnap = o;
  1162. }), P(this, "setScaleSnap", (o) => {
  1163. this.scaleSnap = o;
  1164. }), P(this, "setSize", (o) => {
  1165. this.size = o;
  1166. }), P(this, "setSpace", (o) => {
  1167. this.space = o;
  1168. }), P(this, "update", () => {
  1169. console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.");
  1170. }), P(this, "connect", (o) => {
  1171. o === document && console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'), this.domElement = o, this.domElement.addEventListener("pointerdown", this.onPointerDown), this.domElement.addEventListener("pointermove", this.onPointerHover), this.domElement.ownerDocument.addEventListener("pointerup", this.onPointerUp);
  1172. }), P(this, "dispose", () => {
  1173. var o, c, p2, h2, m, g;
  1174. (o = this.domElement) === null || o === void 0 || o.removeEventListener("pointerdown", this.onPointerDown), (c = this.domElement) === null || c === void 0 || c.removeEventListener("pointermove", this.onPointerHover), (p2 = this.domElement) === null || p2 === void 0 || (h2 = p2.ownerDocument) === null || h2 === void 0 || h2.removeEventListener("pointermove", this.onPointerMove), (m = this.domElement) === null || m === void 0 || (g = m.ownerDocument) === null || g === void 0 || g.removeEventListener("pointerup", this.onPointerUp), this.traverse((w) => {
  1175. const _2 = w;
  1176. _2.geometry && _2.geometry.dispose(), _2.material && _2.material.dispose();
  1177. });
  1178. }), this.domElement = s, this.camera = i, this.gizmo = new fp(), this.add(this.gizmo), this.plane = new vp(), this.add(this.plane);
  1179. const r = (o, c) => {
  1180. let p2 = c;
  1181. Object.defineProperty(this, o, {
  1182. get: function() {
  1183. return p2 !== void 0 ? p2 : c;
  1184. },
  1185. set: function(h2) {
  1186. p2 !== h2 && (p2 = h2, this.plane[o] = h2, this.gizmo[o] = h2, this.dispatchEvent({
  1187. type: o + "-changed",
  1188. value: h2
  1189. }), this.dispatchEvent(this.changeEvent));
  1190. }
  1191. }), this[o] = c, this.plane[o] = c, this.gizmo[o] = c;
  1192. };
  1193. r("camera", this.camera), r("object", this.object), r("enabled", this.enabled), r("axis", this.axis), r("mode", this.mode), r("translationSnap", this.translationSnap), r("rotationSnap", this.rotationSnap), r("scaleSnap", this.scaleSnap), r("space", this.space), r("size", this.size), r("dragging", this.dragging), r("showX", this.showX), r("showY", this.showY), r("showZ", this.showZ), r("worldPosition", this.worldPosition), r("worldPositionStart", this.worldPositionStart), r("worldQuaternion", this.worldQuaternion), r("worldQuaternionStart", this.worldQuaternionStart), r("cameraPosition", this.cameraPosition), r("cameraQuaternion", this.cameraQuaternion), r("pointStart", this.pointStart), r("pointEnd", this.pointEnd), r("rotationAxis", this.rotationAxis), r("rotationAngle", this.rotationAngle), r("eye", this.eye), s !== void 0 && this.connect(s);
  1194. }
  1195. };
  1196. var fp = class extends Object3D {
  1197. // these are set from parent class TransformControls
  1198. constructor() {
  1199. super(), P(this, "isTransformControlsGizmo", true), P(this, "type", "TransformControlsGizmo"), P(this, "tempVector", new Vector3(0, 0, 0)), P(this, "tempEuler", new Euler()), P(this, "alignVector", new Vector3(0, 1, 0)), P(this, "zeroVector", new Vector3(0, 0, 0)), P(this, "lookAtMatrix", new Matrix4()), P(this, "tempQuaternion", new Quaternion()), P(this, "tempQuaternion2", new Quaternion()), P(this, "identityQuaternion", new Quaternion()), P(this, "unitX", new Vector3(1, 0, 0)), P(this, "unitY", new Vector3(0, 1, 0)), P(this, "unitZ", new Vector3(0, 0, 1)), P(this, "gizmo", void 0), P(this, "picker", void 0), P(this, "helper", void 0), P(this, "rotationAxis", new Vector3()), P(this, "cameraPosition", new Vector3()), P(this, "worldPositionStart", new Vector3()), P(this, "worldQuaternionStart", new Quaternion()), P(this, "worldPosition", new Vector3()), P(this, "worldQuaternion", new Quaternion()), P(this, "eye", new Vector3()), P(this, "camera", null), P(this, "enabled", true), P(this, "axis", null), P(this, "mode", "translate"), P(this, "space", "world"), P(this, "size", 1), P(this, "dragging", false), P(this, "showX", true), P(this, "showY", true), P(this, "showZ", true), P(this, "updateMatrixWorld", () => {
  1200. let fe2 = this.space;
  1201. this.mode === "scale" && (fe2 = "local");
  1202. const oe2 = fe2 === "local" ? this.worldQuaternion : this.identityQuaternion;
  1203. this.gizmo.translate.visible = this.mode === "translate", this.gizmo.rotate.visible = this.mode === "rotate", this.gizmo.scale.visible = this.mode === "scale", this.helper.translate.visible = this.mode === "translate", this.helper.rotate.visible = this.mode === "rotate", this.helper.scale.visible = this.mode === "scale";
  1204. let ne = [];
  1205. ne = ne.concat(this.picker[this.mode].children), ne = ne.concat(this.gizmo[this.mode].children), ne = ne.concat(this.helper[this.mode].children);
  1206. for (let ge = 0; ge < ne.length; ge++) {
  1207. const A2 = ne[ge];
  1208. A2.visible = true, A2.rotation.set(0, 0, 0), A2.position.copy(this.worldPosition);
  1209. let ae;
  1210. if (this.camera.isOrthographicCamera ? ae = (this.camera.top - this.camera.bottom) / this.camera.zoom : ae = this.worldPosition.distanceTo(this.cameraPosition) * Math.min(1.9 * Math.tan(Math.PI * this.camera.fov / 360) / this.camera.zoom, 7), A2.scale.set(1, 1, 1).multiplyScalar(ae * this.size / 7), A2.tag === "helper") {
  1211. A2.visible = false, A2.name === "AXIS" ? (A2.position.copy(this.worldPositionStart), A2.visible = !!this.axis, this.axis === "X" && (this.tempQuaternion.setFromEuler(this.tempEuler.set(0, 0, 0)), A2.quaternion.copy(oe2).multiply(this.tempQuaternion), Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(oe2).dot(this.eye)) > 0.9 && (A2.visible = false)), this.axis === "Y" && (this.tempQuaternion.setFromEuler(this.tempEuler.set(0, 0, Math.PI / 2)), A2.quaternion.copy(oe2).multiply(this.tempQuaternion), Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(oe2).dot(this.eye)) > 0.9 && (A2.visible = false)), this.axis === "Z" && (this.tempQuaternion.setFromEuler(this.tempEuler.set(0, Math.PI / 2, 0)), A2.quaternion.copy(oe2).multiply(this.tempQuaternion), Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(oe2).dot(this.eye)) > 0.9 && (A2.visible = false)), this.axis === "XYZE" && (this.tempQuaternion.setFromEuler(this.tempEuler.set(0, Math.PI / 2, 0)), this.alignVector.copy(this.rotationAxis), A2.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector, this.alignVector, this.unitY)), A2.quaternion.multiply(this.tempQuaternion), A2.visible = this.dragging), this.axis === "E" && (A2.visible = false)) : A2.name === "START" ? (A2.position.copy(this.worldPositionStart), A2.visible = this.dragging) : A2.name === "END" ? (A2.position.copy(this.worldPosition), A2.visible = this.dragging) : A2.name === "DELTA" ? (A2.position.copy(this.worldPositionStart), A2.quaternion.copy(this.worldQuaternionStart), this.tempVector.set(1e-10, 1e-10, 1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1), this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()), A2.scale.copy(this.tempVector), A2.visible = this.dragging) : (A2.quaternion.copy(oe2), this.dragging ? A2.position.copy(this.worldPositionStart) : A2.position.copy(this.worldPosition), this.axis && (A2.visible = this.axis.search(A2.name) !== -1));
  1212. continue;
  1213. }
  1214. A2.quaternion.copy(oe2), this.mode === "translate" || this.mode === "scale" ? ((A2.name === "X" || A2.name === "XYZX") && Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(oe2).dot(this.eye)) > 0.99 && (A2.scale.set(1e-10, 1e-10, 1e-10), A2.visible = false), (A2.name === "Y" || A2.name === "XYZY") && Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(oe2).dot(this.eye)) > 0.99 && (A2.scale.set(1e-10, 1e-10, 1e-10), A2.visible = false), (A2.name === "Z" || A2.name === "XYZZ") && Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(oe2).dot(this.eye)) > 0.99 && (A2.scale.set(1e-10, 1e-10, 1e-10), A2.visible = false), A2.name === "XY" && Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(oe2).dot(this.eye)) < 0.2 && (A2.scale.set(1e-10, 1e-10, 1e-10), A2.visible = false), A2.name === "YZ" && Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(oe2).dot(this.eye)) < 0.2 && (A2.scale.set(1e-10, 1e-10, 1e-10), A2.visible = false), A2.name === "XZ" && Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(oe2).dot(this.eye)) < 0.2 && (A2.scale.set(1e-10, 1e-10, 1e-10), A2.visible = false), A2.name.search("X") !== -1 && (this.alignVector.copy(this.unitX).applyQuaternion(oe2).dot(this.eye) < 0 ? A2.tag === "fwd" ? A2.visible = false : A2.scale.x *= -1 : A2.tag === "bwd" && (A2.visible = false)), A2.name.search("Y") !== -1 && (this.alignVector.copy(this.unitY).applyQuaternion(oe2).dot(this.eye) < 0 ? A2.tag === "fwd" ? A2.visible = false : A2.scale.y *= -1 : A2.tag === "bwd" && (A2.visible = false)), A2.name.search("Z") !== -1 && (this.alignVector.copy(this.unitZ).applyQuaternion(oe2).dot(this.eye) < 0 ? A2.tag === "fwd" ? A2.visible = false : A2.scale.z *= -1 : A2.tag === "bwd" && (A2.visible = false))) : this.mode === "rotate" && (this.tempQuaternion2.copy(oe2), this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(oe2).invert()), A2.name.search("E") !== -1 && A2.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye, this.zeroVector, this.unitY)), A2.name === "X" && (this.tempQuaternion.setFromAxisAngle(this.unitX, Math.atan2(-this.alignVector.y, this.alignVector.z)), this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2, this.tempQuaternion), A2.quaternion.copy(this.tempQuaternion)), A2.name === "Y" && (this.tempQuaternion.setFromAxisAngle(this.unitY, Math.atan2(this.alignVector.x, this.alignVector.z)), this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2, this.tempQuaternion), A2.quaternion.copy(this.tempQuaternion)), A2.name === "Z" && (this.tempQuaternion.setFromAxisAngle(this.unitZ, Math.atan2(this.alignVector.y, this.alignVector.x)), this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2, this.tempQuaternion), A2.quaternion.copy(this.tempQuaternion))), A2.visible = A2.visible && (A2.name.indexOf("X") === -1 || this.showX), A2.visible = A2.visible && (A2.name.indexOf("Y") === -1 || this.showY), A2.visible = A2.visible && (A2.name.indexOf("Z") === -1 || this.showZ), A2.visible = A2.visible && (A2.name.indexOf("E") === -1 || this.showX && this.showY && this.showZ), A2.material.tempOpacity = A2.material.tempOpacity || A2.material.opacity, A2.material.tempColor = A2.material.tempColor || A2.material.color.clone(), A2.material.color.copy(A2.material.tempColor), A2.material.opacity = A2.material.tempOpacity, this.enabled ? this.axis && (A2.name === this.axis ? (A2.material.opacity = 1, A2.material.color.lerp(new Color(1, 1, 1), 0.5)) : this.axis.split("").some(function(Ne) {
  1215. return A2.name === Ne;
  1216. }) ? (A2.material.opacity = 1, A2.material.color.lerp(new Color(1, 1, 1), 0.5)) : (A2.material.opacity *= 0.25, A2.material.color.lerp(new Color(1, 1, 1), 0.5))) : (A2.material.opacity *= 0.5, A2.material.color.lerp(new Color(1, 1, 1), 0.5));
  1217. }
  1218. super.updateMatrixWorld();
  1219. });
  1220. const i = new MeshBasicMaterial({
  1221. depthTest: false,
  1222. depthWrite: false,
  1223. transparent: true,
  1224. side: DoubleSide,
  1225. fog: false,
  1226. toneMapped: false
  1227. }), s = new LineBasicMaterial({
  1228. depthTest: false,
  1229. depthWrite: false,
  1230. transparent: true,
  1231. linewidth: 1,
  1232. fog: false,
  1233. toneMapped: false
  1234. }), r = i.clone();
  1235. r.opacity = 0.15;
  1236. const o = i.clone();
  1237. o.opacity = 0.33;
  1238. const c = i.clone();
  1239. c.color.set(16711680);
  1240. const p2 = i.clone();
  1241. p2.color.set(65280);
  1242. const h2 = i.clone();
  1243. h2.color.set(255);
  1244. const m = i.clone();
  1245. m.opacity = 0.25;
  1246. const g = m.clone();
  1247. g.color.set(16776960);
  1248. const w = m.clone();
  1249. w.color.set(65535);
  1250. const _2 = m.clone();
  1251. _2.color.set(16711935), i.clone().color.set(16776960);
  1252. const C = s.clone();
  1253. C.color.set(16711680);
  1254. const L = s.clone();
  1255. L.color.set(65280);
  1256. const S = s.clone();
  1257. S.color.set(255);
  1258. const R = s.clone();
  1259. R.color.set(65535);
  1260. const O = s.clone();
  1261. O.color.set(16711935);
  1262. const N = s.clone();
  1263. N.color.set(16776960);
  1264. const I2 = s.clone();
  1265. I2.color.set(7895160);
  1266. const D2 = N.clone();
  1267. D2.opacity = 0.25;
  1268. const Y = new CylinderGeometry(0, 0.05, 0.2, 12, 1, false), G = new BoxGeometry(0.125, 0.125, 0.125), F = new BufferGeometry();
  1269. F.setAttribute("position", new Float32BufferAttribute([0, 0, 0, 1, 0, 0], 3));
  1270. const B = (fe2, oe2) => {
  1271. const ne = new BufferGeometry(), ge = [];
  1272. for (let A2 = 0; A2 <= 64 * oe2; ++A2)
  1273. ge.push(0, Math.cos(A2 / 32 * Math.PI) * fe2, Math.sin(A2 / 32 * Math.PI) * fe2);
  1274. return ne.setAttribute("position", new Float32BufferAttribute(ge, 3)), ne;
  1275. }, H2 = () => {
  1276. const fe2 = new BufferGeometry();
  1277. return fe2.setAttribute("position", new Float32BufferAttribute([0, 0, 0, 1, 1, 1], 3)), fe2;
  1278. }, K2 = {
  1279. X: [[new Mesh(Y, c), [1, 0, 0], [0, 0, -Math.PI / 2], null, "fwd"], [new Mesh(Y, c), [1, 0, 0], [0, 0, Math.PI / 2], null, "bwd"], [new Line(F, C)]],
  1280. Y: [[new Mesh(Y, p2), [0, 1, 0], null, null, "fwd"], [new Mesh(Y, p2), [0, 1, 0], [Math.PI, 0, 0], null, "bwd"], [new Line(F, L), null, [0, 0, Math.PI / 2]]],
  1281. Z: [[new Mesh(Y, h2), [0, 0, 1], [Math.PI / 2, 0, 0], null, "fwd"], [new Mesh(Y, h2), [0, 0, 1], [-Math.PI / 2, 0, 0], null, "bwd"], [new Line(F, S), null, [0, -Math.PI / 2, 0]]],
  1282. XYZ: [[new Mesh(new OctahedronGeometry(0.1, 0), m.clone()), [0, 0, 0], [0, 0, 0]]],
  1283. XY: [[new Mesh(new PlaneGeometry(0.295, 0.295), g.clone()), [0.15, 0.15, 0]], [new Line(F, N), [0.18, 0.3, 0], null, [0.125, 1, 1]], [new Line(F, N), [0.3, 0.18, 0], [0, 0, Math.PI / 2], [0.125, 1, 1]]],
  1284. YZ: [[new Mesh(new PlaneGeometry(0.295, 0.295), w.clone()), [0, 0.15, 0.15], [0, Math.PI / 2, 0]], [new Line(F, R), [0, 0.18, 0.3], [0, 0, Math.PI / 2], [0.125, 1, 1]], [new Line(F, R), [0, 0.3, 0.18], [0, -Math.PI / 2, 0], [0.125, 1, 1]]],
  1285. XZ: [[new Mesh(new PlaneGeometry(0.295, 0.295), _2.clone()), [0.15, 0, 0.15], [-Math.PI / 2, 0, 0]], [new Line(F, O), [0.18, 0, 0.3], null, [0.125, 1, 1]], [new Line(F, O), [0.3, 0, 0.18], [0, -Math.PI / 2, 0], [0.125, 1, 1]]]
  1286. }, q = {
  1287. X: [[new Mesh(new CylinderGeometry(0.2, 0, 1, 4, 1, false), r), [0.6, 0, 0], [0, 0, -Math.PI / 2]]],
  1288. Y: [[new Mesh(new CylinderGeometry(0.2, 0, 1, 4, 1, false), r), [0, 0.6, 0]]],
  1289. Z: [[new Mesh(new CylinderGeometry(0.2, 0, 1, 4, 1, false), r), [0, 0, 0.6], [Math.PI / 2, 0, 0]]],
  1290. XYZ: [[new Mesh(new OctahedronGeometry(0.2, 0), r)]],
  1291. XY: [[new Mesh(new PlaneGeometry(0.4, 0.4), r), [0.2, 0.2, 0]]],
  1292. YZ: [[new Mesh(new PlaneGeometry(0.4, 0.4), r), [0, 0.2, 0.2], [0, Math.PI / 2, 0]]],
  1293. XZ: [[new Mesh(new PlaneGeometry(0.4, 0.4), r), [0.2, 0, 0.2], [-Math.PI / 2, 0, 0]]]
  1294. }, pe = {
  1295. START: [[new Mesh(new OctahedronGeometry(0.01, 2), o), null, null, null, "helper"]],
  1296. END: [[new Mesh(new OctahedronGeometry(0.01, 2), o), null, null, null, "helper"]],
  1297. DELTA: [[new Line(H2(), o), null, null, null, "helper"]],
  1298. X: [[new Line(F, o.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]],
  1299. Y: [[new Line(F, o.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]],
  1300. Z: [[new Line(F, o.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]]
  1301. }, _e = {
  1302. X: [[new Line(B(1, 0.5), C)], [new Mesh(new OctahedronGeometry(0.04, 0), c), [0, 0, 0.99], null, [1, 3, 1]]],
  1303. Y: [[new Line(B(1, 0.5), L), null, [0, 0, -Math.PI / 2]], [new Mesh(new OctahedronGeometry(0.04, 0), p2), [0, 0, 0.99], null, [3, 1, 1]]],
  1304. Z: [[new Line(B(1, 0.5), S), null, [0, Math.PI / 2, 0]], [new Mesh(new OctahedronGeometry(0.04, 0), h2), [0.99, 0, 0], null, [1, 3, 1]]],
  1305. E: [[new Line(B(1.25, 1), D2), null, [0, Math.PI / 2, 0]], [new Mesh(new CylinderGeometry(0.03, 0, 0.15, 4, 1, false), D2), [1.17, 0, 0], [0, 0, -Math.PI / 2], [1, 1, 1e-3]], [new Mesh(new CylinderGeometry(0.03, 0, 0.15, 4, 1, false), D2), [-1.17, 0, 0], [0, 0, Math.PI / 2], [1, 1, 1e-3]], [new Mesh(new CylinderGeometry(0.03, 0, 0.15, 4, 1, false), D2), [0, -1.17, 0], [Math.PI, 0, 0], [1, 1, 1e-3]], [new Mesh(new CylinderGeometry(0.03, 0, 0.15, 4, 1, false), D2), [0, 1.17, 0], [0, 0, 0], [1, 1, 1e-3]]],
  1306. XYZE: [[new Line(B(1, 1), I2), null, [0, Math.PI / 2, 0]]]
  1307. }, ce2 = {
  1308. AXIS: [[new Line(F, o.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]]
  1309. }, me = {
  1310. X: [[new Mesh(new TorusGeometry(1, 0.1, 4, 24), r), [0, 0, 0], [0, -Math.PI / 2, -Math.PI / 2]]],
  1311. Y: [[new Mesh(new TorusGeometry(1, 0.1, 4, 24), r), [0, 0, 0], [Math.PI / 2, 0, 0]]],
  1312. Z: [[new Mesh(new TorusGeometry(1, 0.1, 4, 24), r), [0, 0, 0], [0, 0, -Math.PI / 2]]],
  1313. E: [[new Mesh(new TorusGeometry(1.25, 0.1, 2, 24), r)]],
  1314. XYZE: [[new Mesh(new SphereGeometry(0.7, 10, 8), r)]]
  1315. }, he = {
  1316. X: [[new Mesh(G, c), [0.8, 0, 0], [0, 0, -Math.PI / 2]], [new Line(F, C), null, null, [0.8, 1, 1]]],
  1317. Y: [[new Mesh(G, p2), [0, 0.8, 0]], [new Line(F, L), null, [0, 0, Math.PI / 2], [0.8, 1, 1]]],
  1318. Z: [[new Mesh(G, h2), [0, 0, 0.8], [Math.PI / 2, 0, 0]], [new Line(F, S), null, [0, -Math.PI / 2, 0], [0.8, 1, 1]]],
  1319. XY: [[new Mesh(G, g), [0.85, 0.85, 0], null, [2, 2, 0.2]], [new Line(F, N), [0.855, 0.98, 0], null, [0.125, 1, 1]], [new Line(F, N), [0.98, 0.855, 0], [0, 0, Math.PI / 2], [0.125, 1, 1]]],
  1320. YZ: [[new Mesh(G, w), [0, 0.85, 0.85], null, [0.2, 2, 2]], [new Line(F, R), [0, 0.855, 0.98], [0, 0, Math.PI / 2], [0.125, 1, 1]], [new Line(F, R), [0, 0.98, 0.855], [0, -Math.PI / 2, 0], [0.125, 1, 1]]],
  1321. XZ: [[new Mesh(G, _2), [0.85, 0, 0.85], null, [2, 0.2, 2]], [new Line(F, O), [0.855, 0, 0.98], null, [0.125, 1, 1]], [new Line(F, O), [0.98, 0, 0.855], [0, -Math.PI / 2, 0], [0.125, 1, 1]]],
  1322. XYZX: [[new Mesh(new BoxGeometry(0.125, 0.125, 0.125), m.clone()), [1.1, 0, 0]]],
  1323. XYZY: [[new Mesh(new BoxGeometry(0.125, 0.125, 0.125), m.clone()), [0, 1.1, 0]]],
  1324. XYZZ: [[new Mesh(new BoxGeometry(0.125, 0.125, 0.125), m.clone()), [0, 0, 1.1]]]
  1325. }, ee = {
  1326. X: [[new Mesh(new CylinderGeometry(0.2, 0, 0.8, 4, 1, false), r), [0.5, 0, 0], [0, 0, -Math.PI / 2]]],
  1327. Y: [[new Mesh(new CylinderGeometry(0.2, 0, 0.8, 4, 1, false), r), [0, 0.5, 0]]],
  1328. Z: [[new Mesh(new CylinderGeometry(0.2, 0, 0.8, 4, 1, false), r), [0, 0, 0.5], [Math.PI / 2, 0, 0]]],
  1329. XY: [[new Mesh(G, r), [0.85, 0.85, 0], null, [3, 3, 0.2]]],
  1330. YZ: [[new Mesh(G, r), [0, 0.85, 0.85], null, [0.2, 3, 3]]],
  1331. XZ: [[new Mesh(G, r), [0.85, 0, 0.85], null, [3, 0.2, 3]]],
  1332. XYZX: [[new Mesh(new BoxGeometry(0.2, 0.2, 0.2), r), [1.1, 0, 0]]],
  1333. XYZY: [[new Mesh(new BoxGeometry(0.2, 0.2, 0.2), r), [0, 1.1, 0]]],
  1334. XYZZ: [[new Mesh(new BoxGeometry(0.2, 0.2, 0.2), r), [0, 0, 1.1]]]
  1335. }, X2 = {
  1336. X: [[new Line(F, o.clone()), [-1e3, 0, 0], null, [1e6, 1, 1], "helper"]],
  1337. Y: [[new Line(F, o.clone()), [0, -1e3, 0], [0, 0, Math.PI / 2], [1e6, 1, 1], "helper"]],
  1338. Z: [[new Line(F, o.clone()), [0, 0, -1e3], [0, -Math.PI / 2, 0], [1e6, 1, 1], "helper"]]
  1339. }, Se2 = (fe2) => {
  1340. const oe2 = new Object3D();
  1341. for (let ne in fe2)
  1342. for (let ge = fe2[ne].length; ge--; ) {
  1343. const A2 = fe2[ne][ge][0].clone(), ae = fe2[ne][ge][1], Ne = fe2[ne][ge][2], Ue = fe2[ne][ge][3], xe2 = fe2[ne][ge][4];
  1344. A2.name = ne, A2.tag = xe2, ae && A2.position.set(ae[0], ae[1], ae[2]), Ne && A2.rotation.set(Ne[0], Ne[1], Ne[2]), Ue && A2.scale.set(Ue[0], Ue[1], Ue[2]), A2.updateMatrix();
  1345. const rt2 = A2.geometry.clone();
  1346. rt2.applyMatrix4(A2.matrix), A2.geometry = rt2, A2.renderOrder = 1 / 0, A2.position.set(0, 0, 0), A2.rotation.set(0, 0, 0), A2.scale.set(1, 1, 1), oe2.add(A2);
  1347. }
  1348. return oe2;
  1349. };
  1350. this.gizmo = {}, this.picker = {}, this.helper = {}, this.add(this.gizmo.translate = Se2(K2)), this.add(this.gizmo.rotate = Se2(_e)), this.add(this.gizmo.scale = Se2(he)), this.add(this.picker.translate = Se2(q)), this.add(this.picker.rotate = Se2(me)), this.add(this.picker.scale = Se2(ee)), this.add(this.helper.translate = Se2(pe)), this.add(this.helper.rotate = Se2(ce2)), this.add(this.helper.scale = Se2(X2)), this.picker.translate.visible = false, this.picker.rotate.visible = false, this.picker.scale.visible = false;
  1351. }
  1352. // updateMatrixWorld will update transformations and appearance of individual handles
  1353. };
  1354. var vp = class extends Mesh {
  1355. constructor() {
  1356. super(new PlaneGeometry(1e5, 1e5, 2, 2), new MeshBasicMaterial({
  1357. visible: false,
  1358. wireframe: true,
  1359. side: DoubleSide,
  1360. transparent: true,
  1361. opacity: 0.1,
  1362. toneMapped: false
  1363. })), P(this, "isTransformControlsPlane", true), P(this, "type", "TransformControlsPlane"), P(this, "unitX", new Vector3(1, 0, 0)), P(this, "unitY", new Vector3(0, 1, 0)), P(this, "unitZ", new Vector3(0, 0, 1)), P(this, "tempVector", new Vector3()), P(this, "dirVector", new Vector3()), P(this, "alignVector", new Vector3()), P(this, "tempMatrix", new Matrix4()), P(this, "identityQuaternion", new Quaternion()), P(this, "cameraQuaternion", new Quaternion()), P(this, "worldPosition", new Vector3()), P(this, "worldQuaternion", new Quaternion()), P(this, "eye", new Vector3()), P(this, "axis", null), P(this, "mode", "translate"), P(this, "space", "world"), P(this, "updateMatrixWorld", () => {
  1364. let i = this.space;
  1365. switch (this.position.copy(this.worldPosition), this.mode === "scale" && (i = "local"), this.unitX.set(1, 0, 0).applyQuaternion(i === "local" ? this.worldQuaternion : this.identityQuaternion), this.unitY.set(0, 1, 0).applyQuaternion(i === "local" ? this.worldQuaternion : this.identityQuaternion), this.unitZ.set(0, 0, 1).applyQuaternion(i === "local" ? this.worldQuaternion : this.identityQuaternion), this.alignVector.copy(this.unitY), this.mode) {
  1366. case "translate":
  1367. case "scale":
  1368. switch (this.axis) {
  1369. case "X":
  1370. this.alignVector.copy(this.eye).cross(this.unitX), this.dirVector.copy(this.unitX).cross(this.alignVector);
  1371. break;
  1372. case "Y":
  1373. this.alignVector.copy(this.eye).cross(this.unitY), this.dirVector.copy(this.unitY).cross(this.alignVector);
  1374. break;
  1375. case "Z":
  1376. this.alignVector.copy(this.eye).cross(this.unitZ), this.dirVector.copy(this.unitZ).cross(this.alignVector);
  1377. break;
  1378. case "XY":
  1379. this.dirVector.copy(this.unitZ);
  1380. break;
  1381. case "YZ":
  1382. this.dirVector.copy(this.unitX);
  1383. break;
  1384. case "XZ":
  1385. this.alignVector.copy(this.unitZ), this.dirVector.copy(this.unitY);
  1386. break;
  1387. case "XYZ":
  1388. case "E":
  1389. this.dirVector.set(0, 0, 0);
  1390. break;
  1391. }
  1392. break;
  1393. case "rotate":
  1394. default:
  1395. this.dirVector.set(0, 0, 0);
  1396. }
  1397. this.dirVector.length() === 0 ? this.quaternion.copy(this.cameraQuaternion) : (this.tempMatrix.lookAt(this.tempVector.set(0, 0, 0), this.dirVector, this.alignVector), this.quaternion.setFromRotationMatrix(this.tempMatrix)), super.updateMatrixWorld();
  1398. });
  1399. }
  1400. };
  1401. var ui = new Euler(0, 0, 0, "YXZ");
  1402. var pi = new Vector3();
  1403. var bp = {
  1404. type: "change"
  1405. };
  1406. var gp = {
  1407. type: "lock"
  1408. };
  1409. var _p = {
  1410. type: "unlock"
  1411. };
  1412. var ma = Math.PI / 2;
  1413. var wp = class extends EventDispatcher {
  1414. constructor(i, s) {
  1415. super(), P(this, "camera", void 0), P(this, "domElement", void 0), P(this, "isLocked", void 0), P(this, "minPolarAngle", void 0), P(this, "maxPolarAngle", void 0), P(this, "pointerSpeed", void 0), P(this, "onMouseMove", (r) => {
  1416. if (!this.domElement || this.isLocked === false)
  1417. return;
  1418. const o = r.movementX || r.mozMovementX || r.webkitMovementX || 0, c = r.movementY || r.mozMovementY || r.webkitMovementY || 0;
  1419. ui.setFromQuaternion(this.camera.quaternion), ui.y -= o * 2e-3 * this.pointerSpeed, ui.x -= c * 2e-3 * this.pointerSpeed, ui.x = Math.max(ma - this.maxPolarAngle, Math.min(ma - this.minPolarAngle, ui.x)), this.camera.quaternion.setFromEuler(ui), this.dispatchEvent(bp);
  1420. }), P(this, "onPointerlockChange", () => {
  1421. this.domElement && (this.domElement.ownerDocument.pointerLockElement === this.domElement ? (this.dispatchEvent(gp), this.isLocked = true) : (this.dispatchEvent(_p), this.isLocked = false));
  1422. }), P(this, "onPointerlockError", () => {
  1423. console.error("THREE.PointerLockControls: Unable to use Pointer Lock API");
  1424. }), P(this, "connect", (r) => {
  1425. this.domElement = r || this.domElement, this.domElement && (this.domElement.ownerDocument.addEventListener("mousemove", this.onMouseMove), this.domElement.ownerDocument.addEventListener("pointerlockchange", this.onPointerlockChange), this.domElement.ownerDocument.addEventListener("pointerlockerror", this.onPointerlockError));
  1426. }), P(this, "disconnect", () => {
  1427. this.domElement && (this.domElement.ownerDocument.removeEventListener("mousemove", this.onMouseMove), this.domElement.ownerDocument.removeEventListener("pointerlockchange", this.onPointerlockChange), this.domElement.ownerDocument.removeEventListener("pointerlockerror", this.onPointerlockError));
  1428. }), P(this, "dispose", () => {
  1429. this.disconnect();
  1430. }), P(this, "getObject", () => this.camera), P(this, "direction", new Vector3(0, 0, -1)), P(this, "getDirection", (r) => r.copy(this.direction).applyQuaternion(this.camera.quaternion)), P(this, "moveForward", (r) => {
  1431. pi.setFromMatrixColumn(this.camera.matrix, 0), pi.crossVectors(this.camera.up, pi), this.camera.position.addScaledVector(pi, r);
  1432. }), P(this, "moveRight", (r) => {
  1433. pi.setFromMatrixColumn(this.camera.matrix, 0), this.camera.position.addScaledVector(pi, r);
  1434. }), P(this, "lock", () => {
  1435. this.domElement && this.domElement.requestPointerLock();
  1436. }), P(this, "unlock", () => {
  1437. this.domElement && this.domElement.ownerDocument.exitPointerLock();
  1438. }), this.camera = i, this.domElement = s, this.isLocked = false, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.pointerSpeed = 1, s && this.connect(s);
  1439. }
  1440. };
  1441. var fa = (f, i) => (f % i + i) % i;
  1442. var qa = class extends EventDispatcher {
  1443. // Set to false to disable this control
  1444. // "target" sets the location of focus, where the object orbits around
  1445. // How far you can dolly in and out ( PerspectiveCamera only )
  1446. // How far you can zoom in and out ( OrthographicCamera only )
  1447. // How far you can orbit vertically, upper and lower limits.
  1448. // Range is 0 to Math.PI radians.
  1449. // radians
  1450. // radians
  1451. // How far you can orbit horizontally, upper and lower limits.
  1452. // If set, the interval [ min, max ] must be a sub-interval of [ - 2 PI, 2 PI ], with ( max - min < 2 PI )
  1453. // radians
  1454. // radians
  1455. // Set to true to enable damping (inertia)
  1456. // If damping is enabled, you must call controls.update() in your animation loop
  1457. // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
  1458. // Set to false to disable zooming
  1459. // Set to false to disable rotating
  1460. // Set to false to disable panning
  1461. // if false, pan orthogonal to world-space direction camera.up
  1462. // pixels moved per arrow key push
  1463. // Set to true to automatically rotate around the target
  1464. // If auto-rotate is enabled, you must call controls.update() in your animation loop
  1465. // 30 seconds per orbit when fps is 60
  1466. // true if you want to reverse the orbit to mouse drag from left to right = orbits left
  1467. // The four arrow keys
  1468. // Mouse buttons
  1469. // Touch fingers
  1470. // the target DOM element for key events
  1471. constructor(i, s) {
  1472. super(), P(this, "object", void 0), P(this, "domElement", void 0), P(this, "enabled", true), P(this, "target", new Vector3()), P(this, "minDistance", 0), P(this, "maxDistance", 1 / 0), P(this, "minZoom", 0), P(this, "maxZoom", 1 / 0), P(this, "minPolarAngle", 0), P(this, "maxPolarAngle", Math.PI), P(this, "minAzimuthAngle", -1 / 0), P(this, "maxAzimuthAngle", 1 / 0), P(this, "enableDamping", false), P(this, "dampingFactor", 0.05), P(this, "enableZoom", true), P(this, "zoomSpeed", 1), P(this, "enableRotate", true), P(this, "rotateSpeed", 1), P(this, "enablePan", true), P(this, "panSpeed", 1), P(this, "screenSpacePanning", true), P(this, "keyPanSpeed", 7), P(this, "autoRotate", false), P(this, "autoRotateSpeed", 2), P(this, "reverseOrbit", false), P(this, "keys", {
  1473. LEFT: "ArrowLeft",
  1474. UP: "ArrowUp",
  1475. RIGHT: "ArrowRight",
  1476. BOTTOM: "ArrowDown"
  1477. }), P(this, "mouseButtons", {
  1478. LEFT: MOUSE.ROTATE,
  1479. MIDDLE: MOUSE.DOLLY,
  1480. RIGHT: MOUSE.PAN
  1481. }), P(this, "touches", {
  1482. ONE: TOUCH.ROTATE,
  1483. TWO: TOUCH.DOLLY_PAN
  1484. }), P(this, "target0", void 0), P(this, "position0", void 0), P(this, "zoom0", void 0), P(this, "_domElementKeyEvents", null), P(this, "getPolarAngle", void 0), P(this, "getAzimuthalAngle", void 0), P(this, "setPolarAngle", void 0), P(this, "setAzimuthalAngle", void 0), P(this, "getDistance", void 0), P(this, "listenToKeyEvents", void 0), P(this, "saveState", void 0), P(this, "reset", void 0), P(this, "update", void 0), P(this, "connect", void 0), P(this, "dispose", void 0), this.object = i, this.domElement = s, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object instanceof PerspectiveCamera ? this.object.zoom : 1, this.getPolarAngle = () => w.phi, this.getAzimuthalAngle = () => w.theta, this.setPolarAngle = (M) => {
  1485. let U2 = fa(M, 2 * Math.PI), W = w.phi;
  1486. W < 0 && (W += 2 * Math.PI), U2 < 0 && (U2 += 2 * Math.PI);
  1487. let ie2 = Math.abs(U2 - W);
  1488. 2 * Math.PI - ie2 < ie2 && (U2 < W ? U2 += 2 * Math.PI : W += 2 * Math.PI), _2.phi = U2 - W, r.update();
  1489. }, this.setAzimuthalAngle = (M) => {
  1490. let U2 = fa(M, 2 * Math.PI), W = w.theta;
  1491. W < 0 && (W += 2 * Math.PI), U2 < 0 && (U2 += 2 * Math.PI);
  1492. let ie2 = Math.abs(U2 - W);
  1493. 2 * Math.PI - ie2 < ie2 && (U2 < W ? U2 += 2 * Math.PI : W += 2 * Math.PI), _2.theta = U2 - W, r.update();
  1494. }, this.getDistance = () => r.object.position.distanceTo(r.target), this.listenToKeyEvents = (M) => {
  1495. M.addEventListener("keydown", Et2), this._domElementKeyEvents = M;
  1496. }, this.saveState = () => {
  1497. r.target0.copy(r.target), r.position0.copy(r.object.position), r.zoom0 = r.object instanceof PerspectiveCamera ? r.object.zoom : 1;
  1498. }, this.reset = () => {
  1499. r.target.copy(r.target0), r.object.position.copy(r.position0), r.object instanceof PerspectiveCamera && (r.object.zoom = r.zoom0, r.object.updateProjectionMatrix()), r.dispatchEvent(o), r.update(), m = h2.NONE;
  1500. }, this.update = (() => {
  1501. const M = new Vector3(), U2 = new Quaternion().setFromUnitVectors(i.up, new Vector3(0, 1, 0)), W = U2.clone().invert(), ie2 = new Vector3(), Ee2 = new Quaternion(), Fe = 2 * Math.PI;
  1502. return function() {
  1503. const fn = r.object.position;
  1504. M.copy(fn).sub(r.target), M.applyQuaternion(U2), w.setFromVector3(M), r.autoRotate && m === h2.NONE && pe(K2()), r.enableDamping ? (w.theta += _2.theta * r.dampingFactor, w.phi += _2.phi * r.dampingFactor) : (w.theta += _2.theta, w.phi += _2.phi);
  1505. let $e = r.minAzimuthAngle, Xe = r.maxAzimuthAngle;
  1506. return isFinite($e) && isFinite(Xe) && ($e < -Math.PI ? $e += Fe : $e > Math.PI && ($e -= Fe), Xe < -Math.PI ? Xe += Fe : Xe > Math.PI && (Xe -= Fe), $e <= Xe ? w.theta = Math.max($e, Math.min(Xe, w.theta)) : w.theta = w.theta > ($e + Xe) / 2 ? Math.max($e, w.theta) : Math.min(Xe, w.theta)), w.phi = Math.max(r.minPolarAngle, Math.min(r.maxPolarAngle, w.phi)), w.makeSafe(), w.radius *= y, w.radius = Math.max(r.minDistance, Math.min(r.maxDistance, w.radius)), r.enableDamping === true ? r.target.addScaledVector(C, r.dampingFactor) : r.target.add(C), M.setFromSpherical(w), M.applyQuaternion(W), fn.copy(r.target).add(M), r.object.lookAt(r.target), r.enableDamping === true ? (_2.theta *= 1 - r.dampingFactor, _2.phi *= 1 - r.dampingFactor, C.multiplyScalar(1 - r.dampingFactor)) : (_2.set(0, 0, 0), C.set(0, 0, 0)), y = 1, L || ie2.distanceToSquared(r.object.position) > g || 8 * (1 - Ee2.dot(r.object.quaternion)) > g ? (r.dispatchEvent(o), ie2.copy(r.object.position), Ee2.copy(r.object.quaternion), L = false, true) : false;
  1507. };
  1508. })(), this.connect = (M) => {
  1509. M === document && console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'), r.domElement = M, r.domElement.style.touchAction = "none", r.domElement.addEventListener("contextmenu", mn), r.domElement.addEventListener("pointerdown", ot2), r.domElement.addEventListener("pointercancel", Hn), r.domElement.addEventListener("wheel", $n);
  1510. }, this.dispose = () => {
  1511. var M, U2, W, ie2, Ee2, Fe;
  1512. (M = r.domElement) === null || M === void 0 || M.removeEventListener("contextmenu", mn), (U2 = r.domElement) === null || U2 === void 0 || U2.removeEventListener("pointerdown", ot2), (W = r.domElement) === null || W === void 0 || W.removeEventListener("pointercancel", Hn), (ie2 = r.domElement) === null || ie2 === void 0 || ie2.removeEventListener("wheel", $n), (Ee2 = r.domElement) === null || Ee2 === void 0 || Ee2.ownerDocument.removeEventListener("pointermove", dn), (Fe = r.domElement) === null || Fe === void 0 || Fe.ownerDocument.removeEventListener("pointerup", bt2), r._domElementKeyEvents !== null && r._domElementKeyEvents.removeEventListener("keydown", Et2);
  1513. };
  1514. const r = this, o = {
  1515. type: "change"
  1516. }, c = {
  1517. type: "start"
  1518. }, p2 = {
  1519. type: "end"
  1520. }, h2 = {
  1521. NONE: -1,
  1522. ROTATE: 0,
  1523. DOLLY: 1,
  1524. PAN: 2,
  1525. TOUCH_ROTATE: 3,
  1526. TOUCH_PAN: 4,
  1527. TOUCH_DOLLY_PAN: 5,
  1528. TOUCH_DOLLY_ROTATE: 6
  1529. };
  1530. let m = h2.NONE;
  1531. const g = 1e-6, w = new Spherical(), _2 = new Spherical();
  1532. let y = 1;
  1533. const C = new Vector3();
  1534. let L = false;
  1535. const S = new Vector2(), R = new Vector2(), O = new Vector2(), N = new Vector2(), I2 = new Vector2(), D2 = new Vector2(), Y = new Vector2(), G = new Vector2(), F = new Vector2(), B = [], H2 = {};
  1536. function K2() {
  1537. return 2 * Math.PI / 60 / 60 * r.autoRotateSpeed;
  1538. }
  1539. function q() {
  1540. return Math.pow(0.95, r.zoomSpeed);
  1541. }
  1542. function pe(M) {
  1543. r.reverseOrbit ? _2.theta += M : _2.theta -= M;
  1544. }
  1545. function _e(M) {
  1546. r.reverseOrbit ? _2.phi += M : _2.phi -= M;
  1547. }
  1548. const ce2 = (() => {
  1549. const M = new Vector3();
  1550. return function(W, ie2) {
  1551. M.setFromMatrixColumn(ie2, 0), M.multiplyScalar(-W), C.add(M);
  1552. };
  1553. })(), me = (() => {
  1554. const M = new Vector3();
  1555. return function(W, ie2) {
  1556. r.screenSpacePanning === true ? M.setFromMatrixColumn(ie2, 1) : (M.setFromMatrixColumn(ie2, 0), M.crossVectors(r.object.up, M)), M.multiplyScalar(W), C.add(M);
  1557. };
  1558. })(), he = (() => {
  1559. const M = new Vector3();
  1560. return function(W, ie2) {
  1561. const Ee2 = r.domElement;
  1562. if (Ee2 && r.object instanceof PerspectiveCamera && r.object.isPerspectiveCamera) {
  1563. const Fe = r.object.position;
  1564. M.copy(Fe).sub(r.target);
  1565. let Gt = M.length();
  1566. Gt *= Math.tan(r.object.fov / 2 * Math.PI / 180), ce2(2 * W * Gt / Ee2.clientHeight, r.object.matrix), me(2 * ie2 * Gt / Ee2.clientHeight, r.object.matrix);
  1567. } else
  1568. Ee2 && r.object instanceof OrthographicCamera && r.object.isOrthographicCamera ? (ce2(W * (r.object.right - r.object.left) / r.object.zoom / Ee2.clientWidth, r.object.matrix), me(ie2 * (r.object.top - r.object.bottom) / r.object.zoom / Ee2.clientHeight, r.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), r.enablePan = false);
  1569. };
  1570. })();
  1571. function ee(M) {
  1572. r.object instanceof PerspectiveCamera && r.object.isPerspectiveCamera ? y /= M : r.object instanceof OrthographicCamera && r.object.isOrthographicCamera ? (r.object.zoom = Math.max(r.minZoom, Math.min(r.maxZoom, r.object.zoom * M)), r.object.updateProjectionMatrix(), L = true) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), r.enableZoom = false);
  1573. }
  1574. function X2(M) {
  1575. r.object instanceof PerspectiveCamera && r.object.isPerspectiveCamera ? y *= M : r.object instanceof OrthographicCamera && r.object.isOrthographicCamera ? (r.object.zoom = Math.max(r.minZoom, Math.min(r.maxZoom, r.object.zoom / M)), r.object.updateProjectionMatrix(), L = true) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), r.enableZoom = false);
  1576. }
  1577. function Se2(M) {
  1578. S.set(M.clientX, M.clientY);
  1579. }
  1580. function fe2(M) {
  1581. Y.set(M.clientX, M.clientY);
  1582. }
  1583. function oe2(M) {
  1584. N.set(M.clientX, M.clientY);
  1585. }
  1586. function ne(M) {
  1587. R.set(M.clientX, M.clientY), O.subVectors(R, S).multiplyScalar(r.rotateSpeed);
  1588. const U2 = r.domElement;
  1589. U2 && (pe(2 * Math.PI * O.x / U2.clientHeight), _e(2 * Math.PI * O.y / U2.clientHeight)), S.copy(R), r.update();
  1590. }
  1591. function ge(M) {
  1592. G.set(M.clientX, M.clientY), F.subVectors(G, Y), F.y > 0 ? ee(q()) : F.y < 0 && X2(q()), Y.copy(G), r.update();
  1593. }
  1594. function A2(M) {
  1595. I2.set(M.clientX, M.clientY), D2.subVectors(I2, N).multiplyScalar(r.panSpeed), he(D2.x, D2.y), N.copy(I2), r.update();
  1596. }
  1597. function ae(M) {
  1598. M.deltaY < 0 ? X2(q()) : M.deltaY > 0 && ee(q()), r.update();
  1599. }
  1600. function Ne(M) {
  1601. let U2 = false;
  1602. switch (M.code) {
  1603. case r.keys.UP:
  1604. he(0, r.keyPanSpeed), U2 = true;
  1605. break;
  1606. case r.keys.BOTTOM:
  1607. he(0, -r.keyPanSpeed), U2 = true;
  1608. break;
  1609. case r.keys.LEFT:
  1610. he(r.keyPanSpeed, 0), U2 = true;
  1611. break;
  1612. case r.keys.RIGHT:
  1613. he(-r.keyPanSpeed, 0), U2 = true;
  1614. break;
  1615. }
  1616. U2 && (M.preventDefault(), r.update());
  1617. }
  1618. function Ue() {
  1619. if (B.length == 1)
  1620. S.set(B[0].pageX, B[0].pageY);
  1621. else {
  1622. const M = 0.5 * (B[0].pageX + B[1].pageX), U2 = 0.5 * (B[0].pageY + B[1].pageY);
  1623. S.set(M, U2);
  1624. }
  1625. }
  1626. function xe2() {
  1627. if (B.length == 1)
  1628. N.set(B[0].pageX, B[0].pageY);
  1629. else {
  1630. const M = 0.5 * (B[0].pageX + B[1].pageX), U2 = 0.5 * (B[0].pageY + B[1].pageY);
  1631. N.set(M, U2);
  1632. }
  1633. }
  1634. function rt2() {
  1635. const M = B[0].pageX - B[1].pageX, U2 = B[0].pageY - B[1].pageY, W = Math.sqrt(M * M + U2 * U2);
  1636. Y.set(0, W);
  1637. }
  1638. function Un() {
  1639. r.enableZoom && rt2(), r.enablePan && xe2();
  1640. }
  1641. function Ze2() {
  1642. r.enableZoom && rt2(), r.enableRotate && Ue();
  1643. }
  1644. function Gn(M) {
  1645. if (B.length == 1)
  1646. R.set(M.pageX, M.pageY);
  1647. else {
  1648. const W = St(M), ie2 = 0.5 * (M.pageX + W.x), Ee2 = 0.5 * (M.pageY + W.y);
  1649. R.set(ie2, Ee2);
  1650. }
  1651. O.subVectors(R, S).multiplyScalar(r.rotateSpeed);
  1652. const U2 = r.domElement;
  1653. U2 && (pe(2 * Math.PI * O.x / U2.clientHeight), _e(2 * Math.PI * O.y / U2.clientHeight)), S.copy(R);
  1654. }
  1655. function hn(M) {
  1656. if (B.length == 1)
  1657. I2.set(M.pageX, M.pageY);
  1658. else {
  1659. const U2 = St(M), W = 0.5 * (M.pageX + U2.x), ie2 = 0.5 * (M.pageY + U2.y);
  1660. I2.set(W, ie2);
  1661. }
  1662. D2.subVectors(I2, N).multiplyScalar(r.panSpeed), he(D2.x, D2.y), N.copy(I2);
  1663. }
  1664. function vt2(M) {
  1665. const U2 = St(M), W = M.pageX - U2.x, ie2 = M.pageY - U2.y, Ee2 = Math.sqrt(W * W + ie2 * ie2);
  1666. G.set(0, Ee2), F.set(0, Math.pow(G.y / Y.y, r.zoomSpeed)), ee(F.y), Y.copy(G);
  1667. }
  1668. function At(M) {
  1669. r.enableZoom && vt2(M), r.enablePan && hn(M);
  1670. }
  1671. function Ke(M) {
  1672. r.enableZoom && vt2(M), r.enableRotate && Gn(M);
  1673. }
  1674. function ot2(M) {
  1675. if (r.enabled !== false) {
  1676. if (B.length === 0) {
  1677. var U2, W;
  1678. (U2 = r.domElement) === null || U2 === void 0 || U2.ownerDocument.addEventListener("pointermove", dn), (W = r.domElement) === null || W === void 0 || W.ownerDocument.addEventListener("pointerup", bt2);
  1679. }
  1680. Yn(M), M.pointerType === "touch" ? Mt(M) : bi(M);
  1681. }
  1682. }
  1683. function dn(M) {
  1684. r.enabled !== false && (M.pointerType === "touch" ? Xn(M) : Kn(M));
  1685. }
  1686. function bt2(M) {
  1687. if (Ct(M), B.length === 0) {
  1688. var U2, W, ie2;
  1689. (U2 = r.domElement) === null || U2 === void 0 || U2.releasePointerCapture(M.pointerId), (W = r.domElement) === null || W === void 0 || W.ownerDocument.removeEventListener("pointermove", dn), (ie2 = r.domElement) === null || ie2 === void 0 || ie2.ownerDocument.removeEventListener("pointerup", bt2);
  1690. }
  1691. r.dispatchEvent(p2), m = h2.NONE;
  1692. }
  1693. function Hn(M) {
  1694. Ct(M);
  1695. }
  1696. function bi(M) {
  1697. let U2;
  1698. switch (M.button) {
  1699. case 0:
  1700. U2 = r.mouseButtons.LEFT;
  1701. break;
  1702. case 1:
  1703. U2 = r.mouseButtons.MIDDLE;
  1704. break;
  1705. case 2:
  1706. U2 = r.mouseButtons.RIGHT;
  1707. break;
  1708. default:
  1709. U2 = -1;
  1710. }
  1711. switch (U2) {
  1712. case MOUSE.DOLLY:
  1713. if (r.enableZoom === false)
  1714. return;
  1715. fe2(M), m = h2.DOLLY;
  1716. break;
  1717. case MOUSE.ROTATE:
  1718. if (M.ctrlKey || M.metaKey || M.shiftKey) {
  1719. if (r.enablePan === false)
  1720. return;
  1721. oe2(M), m = h2.PAN;
  1722. } else {
  1723. if (r.enableRotate === false)
  1724. return;
  1725. Se2(M), m = h2.ROTATE;
  1726. }
  1727. break;
  1728. case MOUSE.PAN:
  1729. if (M.ctrlKey || M.metaKey || M.shiftKey) {
  1730. if (r.enableRotate === false)
  1731. return;
  1732. Se2(M), m = h2.ROTATE;
  1733. } else {
  1734. if (r.enablePan === false)
  1735. return;
  1736. oe2(M), m = h2.PAN;
  1737. }
  1738. break;
  1739. default:
  1740. m = h2.NONE;
  1741. }
  1742. m !== h2.NONE && r.dispatchEvent(c);
  1743. }
  1744. function Kn(M) {
  1745. if (r.enabled !== false)
  1746. switch (m) {
  1747. case h2.ROTATE:
  1748. if (r.enableRotate === false)
  1749. return;
  1750. ne(M);
  1751. break;
  1752. case h2.DOLLY:
  1753. if (r.enableZoom === false)
  1754. return;
  1755. ge(M);
  1756. break;
  1757. case h2.PAN:
  1758. if (r.enablePan === false)
  1759. return;
  1760. A2(M);
  1761. break;
  1762. }
  1763. }
  1764. function $n(M) {
  1765. r.enabled === false || r.enableZoom === false || m !== h2.NONE && m !== h2.ROTATE || (M.preventDefault(), r.dispatchEvent(c), ae(M), r.dispatchEvent(p2));
  1766. }
  1767. function Et2(M) {
  1768. r.enabled === false || r.enablePan === false || Ne(M);
  1769. }
  1770. function Mt(M) {
  1771. switch (gt2(M), B.length) {
  1772. case 1:
  1773. switch (r.touches.ONE) {
  1774. case TOUCH.ROTATE:
  1775. if (r.enableRotate === false)
  1776. return;
  1777. Ue(), m = h2.TOUCH_ROTATE;
  1778. break;
  1779. case TOUCH.PAN:
  1780. if (r.enablePan === false)
  1781. return;
  1782. xe2(), m = h2.TOUCH_PAN;
  1783. break;
  1784. default:
  1785. m = h2.NONE;
  1786. }
  1787. break;
  1788. case 2:
  1789. switch (r.touches.TWO) {
  1790. case TOUCH.DOLLY_PAN:
  1791. if (r.enableZoom === false && r.enablePan === false)
  1792. return;
  1793. Un(), m = h2.TOUCH_DOLLY_PAN;
  1794. break;
  1795. case TOUCH.DOLLY_ROTATE:
  1796. if (r.enableZoom === false && r.enableRotate === false)
  1797. return;
  1798. Ze2(), m = h2.TOUCH_DOLLY_ROTATE;
  1799. break;
  1800. default:
  1801. m = h2.NONE;
  1802. }
  1803. break;
  1804. default:
  1805. m = h2.NONE;
  1806. }
  1807. m !== h2.NONE && r.dispatchEvent(c);
  1808. }
  1809. function Xn(M) {
  1810. switch (gt2(M), m) {
  1811. case h2.TOUCH_ROTATE:
  1812. if (r.enableRotate === false)
  1813. return;
  1814. Gn(M), r.update();
  1815. break;
  1816. case h2.TOUCH_PAN:
  1817. if (r.enablePan === false)
  1818. return;
  1819. hn(M), r.update();
  1820. break;
  1821. case h2.TOUCH_DOLLY_PAN:
  1822. if (r.enableZoom === false && r.enablePan === false)
  1823. return;
  1824. At(M), r.update();
  1825. break;
  1826. case h2.TOUCH_DOLLY_ROTATE:
  1827. if (r.enableZoom === false && r.enableRotate === false)
  1828. return;
  1829. Ke(M), r.update();
  1830. break;
  1831. default:
  1832. m = h2.NONE;
  1833. }
  1834. }
  1835. function mn(M) {
  1836. r.enabled !== false && M.preventDefault();
  1837. }
  1838. function Yn(M) {
  1839. B.push(M);
  1840. }
  1841. function Ct(M) {
  1842. delete H2[M.pointerId];
  1843. for (let U2 = 0; U2 < B.length; U2++)
  1844. if (B[U2].pointerId == M.pointerId) {
  1845. B.splice(U2, 1);
  1846. return;
  1847. }
  1848. }
  1849. function gt2(M) {
  1850. let U2 = H2[M.pointerId];
  1851. U2 === void 0 && (U2 = new Vector2(), H2[M.pointerId] = U2), U2.set(M.pageX, M.pageY);
  1852. }
  1853. function St(M) {
  1854. const U2 = M.pointerId === B[0].pointerId ? B[1] : B[0];
  1855. return H2[U2.pointerId];
  1856. }
  1857. s !== void 0 && this.connect(s), this.update();
  1858. }
  1859. };
  1860. var yp = class extends qa {
  1861. constructor(i, s) {
  1862. super(i, s), this.screenSpacePanning = false, this.mouseButtons.LEFT = MOUSE.PAN, this.mouseButtons.RIGHT = MOUSE.ROTATE, this.touches.ONE = TOUCH.PAN, this.touches.TWO = TOUCH.DOLLY_ROTATE;
  1863. }
  1864. };
  1865. var xp = class extends Loader {
  1866. constructor(i) {
  1867. super(i), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(s) {
  1868. return new kp(s);
  1869. }), this.register(function(s) {
  1870. return new Ip(s);
  1871. }), this.register(function(s) {
  1872. return new Dp(s);
  1873. }), this.register(function(s) {
  1874. return new Op(s);
  1875. }), this.register(function(s) {
  1876. return new Mp(s);
  1877. }), this.register(function(s) {
  1878. return new Sp(s);
  1879. }), this.register(function(s) {
  1880. return new Lp(s);
  1881. }), this.register(function(s) {
  1882. return new Rp(s);
  1883. }), this.register(function(s) {
  1884. return new Tp(s);
  1885. }), this.register(function(s) {
  1886. return new Vp(s);
  1887. }), this.register(function(s) {
  1888. return new Ap(s);
  1889. }), this.register(function(s) {
  1890. return new Cp(s);
  1891. }), this.register(function(s) {
  1892. return new Np(s);
  1893. }), this.register(function(s) {
  1894. return new Bp(s);
  1895. });
  1896. }
  1897. load(i, s, r, o) {
  1898. const c = this;
  1899. let p2;
  1900. this.resourcePath !== "" ? p2 = this.resourcePath : this.path !== "" ? p2 = this.path : p2 = LoaderUtils.extractUrlBase(i), this.manager.itemStart(i);
  1901. const h2 = function(g) {
  1902. o ? o(g) : console.error(g), c.manager.itemError(i), c.manager.itemEnd(i);
  1903. }, m = new FileLoader(this.manager);
  1904. m.setPath(this.path), m.setResponseType("arraybuffer"), m.setRequestHeader(this.requestHeader), m.setWithCredentials(this.withCredentials), m.load(i, function(g) {
  1905. try {
  1906. c.parse(g, p2, function(w) {
  1907. s(w), c.manager.itemEnd(i);
  1908. }, h2);
  1909. } catch (w) {
  1910. h2(w);
  1911. }
  1912. }, r, h2);
  1913. }
  1914. setDRACOLoader(i) {
  1915. return this.dracoLoader = i, this;
  1916. }
  1917. setDDSLoader() {
  1918. throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".');
  1919. }
  1920. setKTX2Loader(i) {
  1921. return this.ktx2Loader = i, this;
  1922. }
  1923. setMeshoptDecoder(i) {
  1924. return this.meshoptDecoder = i, this;
  1925. }
  1926. register(i) {
  1927. return this.pluginCallbacks.indexOf(i) === -1 && this.pluginCallbacks.push(i), this;
  1928. }
  1929. unregister(i) {
  1930. return this.pluginCallbacks.indexOf(i) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(i), 1), this;
  1931. }
  1932. parse(i, s, r, o) {
  1933. let c;
  1934. const p2 = {}, h2 = {}, m = new TextDecoder();
  1935. if (typeof i == "string")
  1936. c = JSON.parse(i);
  1937. else if (i instanceof ArrayBuffer)
  1938. if (m.decode(new Uint8Array(i, 0, 4)) === Qa) {
  1939. try {
  1940. p2[le2.KHR_BINARY_GLTF] = new Fp(i);
  1941. } catch (_2) {
  1942. o && o(_2);
  1943. return;
  1944. }
  1945. c = JSON.parse(p2[le2.KHR_BINARY_GLTF].content);
  1946. } else
  1947. c = JSON.parse(m.decode(i));
  1948. else
  1949. c = i;
  1950. if (c.asset === void 0 || c.asset.version[0] < 2) {
  1951. o && o(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
  1952. return;
  1953. }
  1954. const g = new Wp(c, {
  1955. path: s || this.resourcePath || "",
  1956. crossOrigin: this.crossOrigin,
  1957. requestHeader: this.requestHeader,
  1958. manager: this.manager,
  1959. ktx2Loader: this.ktx2Loader,
  1960. meshoptDecoder: this.meshoptDecoder
  1961. });
  1962. g.fileLoader.setRequestHeader(this.requestHeader);
  1963. for (let w = 0; w < this.pluginCallbacks.length; w++) {
  1964. const _2 = this.pluginCallbacks[w](g);
  1965. h2[_2.name] = _2, p2[_2.name] = true;
  1966. }
  1967. if (c.extensionsUsed)
  1968. for (let w = 0; w < c.extensionsUsed.length; ++w) {
  1969. const _2 = c.extensionsUsed[w], y = c.extensionsRequired || [];
  1970. switch (_2) {
  1971. case le2.KHR_MATERIALS_UNLIT:
  1972. p2[_2] = new Pp();
  1973. break;
  1974. case le2.KHR_DRACO_MESH_COMPRESSION:
  1975. p2[_2] = new jp(c, this.dracoLoader);
  1976. break;
  1977. case le2.KHR_TEXTURE_TRANSFORM:
  1978. p2[_2] = new zp();
  1979. break;
  1980. case le2.KHR_MESH_QUANTIZATION:
  1981. p2[_2] = new Up();
  1982. break;
  1983. default:
  1984. y.indexOf(_2) >= 0 && h2[_2] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + _2 + '".');
  1985. }
  1986. }
  1987. g.setExtensions(p2), g.setPlugins(h2), g.parse(r, o);
  1988. }
  1989. parseAsync(i, s) {
  1990. const r = this;
  1991. return new Promise(function(o, c) {
  1992. r.parse(i, s, o, c);
  1993. });
  1994. }
  1995. };
  1996. function Ep() {
  1997. let f = {};
  1998. return {
  1999. get: function(i) {
  2000. return f[i];
  2001. },
  2002. add: function(i, s) {
  2003. f[i] = s;
  2004. },
  2005. remove: function(i) {
  2006. delete f[i];
  2007. },
  2008. removeAll: function() {
  2009. f = {};
  2010. }
  2011. };
  2012. }
  2013. var le2 = {
  2014. KHR_BINARY_GLTF: "KHR_binary_glTF",
  2015. KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
  2016. KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
  2017. KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
  2018. KHR_MATERIALS_IOR: "KHR_materials_ior",
  2019. KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
  2020. KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
  2021. KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
  2022. KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
  2023. KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
  2024. KHR_MATERIALS_VOLUME: "KHR_materials_volume",
  2025. KHR_TEXTURE_BASISU: "KHR_texture_basisu",
  2026. KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
  2027. KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
  2028. KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
  2029. EXT_TEXTURE_WEBP: "EXT_texture_webp",
  2030. EXT_TEXTURE_AVIF: "EXT_texture_avif",
  2031. EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
  2032. EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
  2033. };
  2034. var Cp = class {
  2035. constructor(i) {
  2036. this.parser = i, this.name = le2.KHR_LIGHTS_PUNCTUAL, this.cache = {
  2037. refs: {},
  2038. uses: {}
  2039. };
  2040. }
  2041. _markDefs() {
  2042. const i = this.parser, s = this.parser.json.nodes || [];
  2043. for (let r = 0, o = s.length; r < o; r++) {
  2044. const c = s[r];
  2045. c.extensions && c.extensions[this.name] && c.extensions[this.name].light !== void 0 && i._addNodeRef(this.cache, c.extensions[this.name].light);
  2046. }
  2047. }
  2048. _loadLight(i) {
  2049. const s = this.parser, r = "light:" + i;
  2050. let o = s.cache.get(r);
  2051. if (o)
  2052. return o;
  2053. const c = s.json, m = ((c.extensions && c.extensions[this.name] || {}).lights || [])[i];
  2054. let g;
  2055. const w = new Color(16777215);
  2056. m.color !== void 0 && w.fromArray(m.color);
  2057. const _2 = m.range !== void 0 ? m.range : 0;
  2058. switch (m.type) {
  2059. case "directional":
  2060. g = new DirectionalLight(w), g.target.position.set(0, 0, -1), g.add(g.target);
  2061. break;
  2062. case "point":
  2063. g = new PointLight(w), g.distance = _2;
  2064. break;
  2065. case "spot":
  2066. g = new SpotLight(w), g.distance = _2, m.spot = m.spot || {}, m.spot.innerConeAngle = m.spot.innerConeAngle !== void 0 ? m.spot.innerConeAngle : 0, m.spot.outerConeAngle = m.spot.outerConeAngle !== void 0 ? m.spot.outerConeAngle : Math.PI / 4, g.angle = m.spot.outerConeAngle, g.penumbra = 1 - m.spot.innerConeAngle / m.spot.outerConeAngle, g.target.position.set(0, 0, -1), g.add(g.target);
  2067. break;
  2068. default:
  2069. throw new Error("THREE.GLTFLoader: Unexpected light type: " + m.type);
  2070. }
  2071. return g.position.set(0, 0, 0), g.decay = 2, ln(g, m), m.intensity !== void 0 && (g.intensity = m.intensity), g.name = s.createUniqueName(m.name || "light_" + i), o = Promise.resolve(g), s.cache.add(r, o), o;
  2072. }
  2073. getDependency(i, s) {
  2074. if (i === "light")
  2075. return this._loadLight(s);
  2076. }
  2077. createNodeAttachment(i) {
  2078. const s = this, r = this.parser, c = r.json.nodes[i], h2 = (c.extensions && c.extensions[this.name] || {}).light;
  2079. return h2 === void 0 ? null : this._loadLight(h2).then(function(m) {
  2080. return r._getNodeRef(s.cache, h2, m);
  2081. });
  2082. }
  2083. };
  2084. var Pp = class {
  2085. constructor() {
  2086. this.name = le2.KHR_MATERIALS_UNLIT;
  2087. }
  2088. getMaterialType() {
  2089. return MeshBasicMaterial;
  2090. }
  2091. extendParams(i, s, r) {
  2092. const o = [];
  2093. i.color = new Color(1, 1, 1), i.opacity = 1;
  2094. const c = s.pbrMetallicRoughness;
  2095. if (c) {
  2096. if (Array.isArray(c.baseColorFactor)) {
  2097. const p2 = c.baseColorFactor;
  2098. i.color.fromArray(p2), i.opacity = p2[3];
  2099. }
  2100. c.baseColorTexture !== void 0 && o.push(r.assignTexture(i, "map", c.baseColorTexture, sRGBEncoding));
  2101. }
  2102. return Promise.all(o);
  2103. }
  2104. };
  2105. var Tp = class {
  2106. constructor(i) {
  2107. this.parser = i, this.name = le2.KHR_MATERIALS_EMISSIVE_STRENGTH;
  2108. }
  2109. extendMaterialParams(i, s) {
  2110. const o = this.parser.json.materials[i];
  2111. if (!o.extensions || !o.extensions[this.name])
  2112. return Promise.resolve();
  2113. const c = o.extensions[this.name].emissiveStrength;
  2114. return c !== void 0 && (s.emissiveIntensity = c), Promise.resolve();
  2115. }
  2116. };
  2117. var kp = class {
  2118. constructor(i) {
  2119. this.parser = i, this.name = le2.KHR_MATERIALS_CLEARCOAT;
  2120. }
  2121. getMaterialType(i) {
  2122. const r = this.parser.json.materials[i];
  2123. return !r.extensions || !r.extensions[this.name] ? null : MeshPhysicalMaterial;
  2124. }
  2125. extendMaterialParams(i, s) {
  2126. const r = this.parser, o = r.json.materials[i];
  2127. if (!o.extensions || !o.extensions[this.name])
  2128. return Promise.resolve();
  2129. const c = [], p2 = o.extensions[this.name];
  2130. if (p2.clearcoatFactor !== void 0 && (s.clearcoat = p2.clearcoatFactor), p2.clearcoatTexture !== void 0 && c.push(r.assignTexture(s, "clearcoatMap", p2.clearcoatTexture)), p2.clearcoatRoughnessFactor !== void 0 && (s.clearcoatRoughness = p2.clearcoatRoughnessFactor), p2.clearcoatRoughnessTexture !== void 0 && c.push(r.assignTexture(s, "clearcoatRoughnessMap", p2.clearcoatRoughnessTexture)), p2.clearcoatNormalTexture !== void 0 && (c.push(r.assignTexture(s, "clearcoatNormalMap", p2.clearcoatNormalTexture)), p2.clearcoatNormalTexture.scale !== void 0)) {
  2131. const h2 = p2.clearcoatNormalTexture.scale;
  2132. s.clearcoatNormalScale = new Vector2(h2, h2);
  2133. }
  2134. return Promise.all(c);
  2135. }
  2136. };
  2137. var Ap = class {
  2138. constructor(i) {
  2139. this.parser = i, this.name = le2.KHR_MATERIALS_IRIDESCENCE;
  2140. }
  2141. getMaterialType(i) {
  2142. const r = this.parser.json.materials[i];
  2143. return !r.extensions || !r.extensions[this.name] ? null : MeshPhysicalMaterial;
  2144. }
  2145. extendMaterialParams(i, s) {
  2146. const r = this.parser, o = r.json.materials[i];
  2147. if (!o.extensions || !o.extensions[this.name])
  2148. return Promise.resolve();
  2149. const c = [], p2 = o.extensions[this.name];
  2150. return p2.iridescenceFactor !== void 0 && (s.iridescence = p2.iridescenceFactor), p2.iridescenceTexture !== void 0 && c.push(r.assignTexture(s, "iridescenceMap", p2.iridescenceTexture)), p2.iridescenceIor !== void 0 && (s.iridescenceIOR = p2.iridescenceIor), s.iridescenceThicknessRange === void 0 && (s.iridescenceThicknessRange = [100, 400]), p2.iridescenceThicknessMinimum !== void 0 && (s.iridescenceThicknessRange[0] = p2.iridescenceThicknessMinimum), p2.iridescenceThicknessMaximum !== void 0 && (s.iridescenceThicknessRange[1] = p2.iridescenceThicknessMaximum), p2.iridescenceThicknessTexture !== void 0 && c.push(r.assignTexture(s, "iridescenceThicknessMap", p2.iridescenceThicknessTexture)), Promise.all(c);
  2151. }
  2152. };
  2153. var Mp = class {
  2154. constructor(i) {
  2155. this.parser = i, this.name = le2.KHR_MATERIALS_SHEEN;
  2156. }
  2157. getMaterialType(i) {
  2158. const r = this.parser.json.materials[i];
  2159. return !r.extensions || !r.extensions[this.name] ? null : MeshPhysicalMaterial;
  2160. }
  2161. extendMaterialParams(i, s) {
  2162. const r = this.parser, o = r.json.materials[i];
  2163. if (!o.extensions || !o.extensions[this.name])
  2164. return Promise.resolve();
  2165. const c = [];
  2166. s.sheenColor = new Color(0, 0, 0), s.sheenRoughness = 0, s.sheen = 1;
  2167. const p2 = o.extensions[this.name];
  2168. return p2.sheenColorFactor !== void 0 && s.sheenColor.fromArray(p2.sheenColorFactor), p2.sheenRoughnessFactor !== void 0 && (s.sheenRoughness = p2.sheenRoughnessFactor), p2.sheenColorTexture !== void 0 && c.push(r.assignTexture(s, "sheenColorMap", p2.sheenColorTexture, sRGBEncoding)), p2.sheenRoughnessTexture !== void 0 && c.push(r.assignTexture(s, "sheenRoughnessMap", p2.sheenRoughnessTexture)), Promise.all(c);
  2169. }
  2170. };
  2171. var Sp = class {
  2172. constructor(i) {
  2173. this.parser = i, this.name = le2.KHR_MATERIALS_TRANSMISSION;
  2174. }
  2175. getMaterialType(i) {
  2176. const r = this.parser.json.materials[i];
  2177. return !r.extensions || !r.extensions[this.name] ? null : MeshPhysicalMaterial;
  2178. }
  2179. extendMaterialParams(i, s) {
  2180. const r = this.parser, o = r.json.materials[i];
  2181. if (!o.extensions || !o.extensions[this.name])
  2182. return Promise.resolve();
  2183. const c = [], p2 = o.extensions[this.name];
  2184. return p2.transmissionFactor !== void 0 && (s.transmission = p2.transmissionFactor), p2.transmissionTexture !== void 0 && c.push(r.assignTexture(s, "transmissionMap", p2.transmissionTexture)), Promise.all(c);
  2185. }
  2186. };
  2187. var Lp = class {
  2188. constructor(i) {
  2189. this.parser = i, this.name = le2.KHR_MATERIALS_VOLUME;
  2190. }
  2191. getMaterialType(i) {
  2192. const r = this.parser.json.materials[i];
  2193. return !r.extensions || !r.extensions[this.name] ? null : MeshPhysicalMaterial;
  2194. }
  2195. extendMaterialParams(i, s) {
  2196. const r = this.parser, o = r.json.materials[i];
  2197. if (!o.extensions || !o.extensions[this.name])
  2198. return Promise.resolve();
  2199. const c = [], p2 = o.extensions[this.name];
  2200. s.thickness = p2.thicknessFactor !== void 0 ? p2.thicknessFactor : 0, p2.thicknessTexture !== void 0 && c.push(r.assignTexture(s, "thicknessMap", p2.thicknessTexture)), s.attenuationDistance = p2.attenuationDistance || 1 / 0;
  2201. const h2 = p2.attenuationColor || [1, 1, 1];
  2202. return s.attenuationColor = new Color(h2[0], h2[1], h2[2]), Promise.all(c);
  2203. }
  2204. };
  2205. var Rp = class {
  2206. constructor(i) {
  2207. this.parser = i, this.name = le2.KHR_MATERIALS_IOR;
  2208. }
  2209. getMaterialType(i) {
  2210. const r = this.parser.json.materials[i];
  2211. return !r.extensions || !r.extensions[this.name] ? null : MeshPhysicalMaterial;
  2212. }
  2213. extendMaterialParams(i, s) {
  2214. const o = this.parser.json.materials[i];
  2215. if (!o.extensions || !o.extensions[this.name])
  2216. return Promise.resolve();
  2217. const c = o.extensions[this.name];
  2218. return s.ior = c.ior !== void 0 ? c.ior : 1.5, Promise.resolve();
  2219. }
  2220. };
  2221. var Vp = class {
  2222. constructor(i) {
  2223. this.parser = i, this.name = le2.KHR_MATERIALS_SPECULAR;
  2224. }
  2225. getMaterialType(i) {
  2226. const r = this.parser.json.materials[i];
  2227. return !r.extensions || !r.extensions[this.name] ? null : MeshPhysicalMaterial;
  2228. }
  2229. extendMaterialParams(i, s) {
  2230. const r = this.parser, o = r.json.materials[i];
  2231. if (!o.extensions || !o.extensions[this.name])
  2232. return Promise.resolve();
  2233. const c = [], p2 = o.extensions[this.name];
  2234. s.specularIntensity = p2.specularFactor !== void 0 ? p2.specularFactor : 1, p2.specularTexture !== void 0 && c.push(r.assignTexture(s, "specularIntensityMap", p2.specularTexture));
  2235. const h2 = p2.specularColorFactor || [1, 1, 1];
  2236. return s.specularColor = new Color(h2[0], h2[1], h2[2]), p2.specularColorTexture !== void 0 && c.push(r.assignTexture(s, "specularColorMap", p2.specularColorTexture, sRGBEncoding)), Promise.all(c);
  2237. }
  2238. };
  2239. var Ip = class {
  2240. constructor(i) {
  2241. this.parser = i, this.name = le2.KHR_TEXTURE_BASISU;
  2242. }
  2243. loadTexture(i) {
  2244. const s = this.parser, r = s.json, o = r.textures[i];
  2245. if (!o.extensions || !o.extensions[this.name])
  2246. return null;
  2247. const c = o.extensions[this.name], p2 = s.options.ktx2Loader;
  2248. if (!p2) {
  2249. if (r.extensionsRequired && r.extensionsRequired.indexOf(this.name) >= 0)
  2250. throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
  2251. return null;
  2252. }
  2253. return s.loadTextureImage(i, c.source, p2);
  2254. }
  2255. };
  2256. var Dp = class {
  2257. constructor(i) {
  2258. this.parser = i, this.name = le2.EXT_TEXTURE_WEBP, this.isSupported = null;
  2259. }
  2260. loadTexture(i) {
  2261. const s = this.name, r = this.parser, o = r.json, c = o.textures[i];
  2262. if (!c.extensions || !c.extensions[s])
  2263. return null;
  2264. const p2 = c.extensions[s], h2 = o.images[p2.source];
  2265. let m = r.textureLoader;
  2266. if (h2.uri) {
  2267. const g = r.options.manager.getHandler(h2.uri);
  2268. g !== null && (m = g);
  2269. }
  2270. return this.detectSupport().then(function(g) {
  2271. if (g)
  2272. return r.loadTextureImage(i, p2.source, m);
  2273. if (o.extensionsRequired && o.extensionsRequired.indexOf(s) >= 0)
  2274. throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");
  2275. return r.loadTexture(i);
  2276. });
  2277. }
  2278. detectSupport() {
  2279. return this.isSupported || (this.isSupported = new Promise(function(i) {
  2280. const s = new Image();
  2281. s.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", s.onload = s.onerror = function() {
  2282. i(s.height === 1);
  2283. };
  2284. })), this.isSupported;
  2285. }
  2286. };
  2287. var Op = class {
  2288. constructor(i) {
  2289. this.parser = i, this.name = le2.EXT_TEXTURE_AVIF, this.isSupported = null;
  2290. }
  2291. loadTexture(i) {
  2292. const s = this.name, r = this.parser, o = r.json, c = o.textures[i];
  2293. if (!c.extensions || !c.extensions[s])
  2294. return null;
  2295. const p2 = c.extensions[s], h2 = o.images[p2.source];
  2296. let m = r.textureLoader;
  2297. if (h2.uri) {
  2298. const g = r.options.manager.getHandler(h2.uri);
  2299. g !== null && (m = g);
  2300. }
  2301. return this.detectSupport().then(function(g) {
  2302. if (g)
  2303. return r.loadTextureImage(i, p2.source, m);
  2304. if (o.extensionsRequired && o.extensionsRequired.indexOf(s) >= 0)
  2305. throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");
  2306. return r.loadTexture(i);
  2307. });
  2308. }
  2309. detectSupport() {
  2310. return this.isSupported || (this.isSupported = new Promise(function(i) {
  2311. const s = new Image();
  2312. s.src = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=", s.onload = s.onerror = function() {
  2313. i(s.height === 1);
  2314. };
  2315. })), this.isSupported;
  2316. }
  2317. };
  2318. var Np = class {
  2319. constructor(i) {
  2320. this.name = le2.EXT_MESHOPT_COMPRESSION, this.parser = i;
  2321. }
  2322. loadBufferView(i) {
  2323. const s = this.parser.json, r = s.bufferViews[i];
  2324. if (r.extensions && r.extensions[this.name]) {
  2325. const o = r.extensions[this.name], c = this.parser.getDependency("buffer", o.buffer), p2 = this.parser.options.meshoptDecoder;
  2326. if (!p2 || !p2.supported) {
  2327. if (s.extensionsRequired && s.extensionsRequired.indexOf(this.name) >= 0)
  2328. throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
  2329. return null;
  2330. }
  2331. return c.then(function(h2) {
  2332. const m = o.byteOffset || 0, g = o.byteLength || 0, w = o.count, _2 = o.byteStride, y = new Uint8Array(h2, m, g);
  2333. return p2.decodeGltfBufferAsync ? p2.decodeGltfBufferAsync(w, _2, y, o.mode, o.filter).then(function(C) {
  2334. return C.buffer;
  2335. }) : p2.ready.then(function() {
  2336. const C = new ArrayBuffer(w * _2);
  2337. return p2.decodeGltfBuffer(new Uint8Array(C), w, _2, y, o.mode, o.filter), C;
  2338. });
  2339. });
  2340. } else
  2341. return null;
  2342. }
  2343. };
  2344. var Bp = class {
  2345. constructor(i) {
  2346. this.name = le2.EXT_MESH_GPU_INSTANCING, this.parser = i;
  2347. }
  2348. createNodeMesh(i) {
  2349. const s = this.parser.json, r = s.nodes[i];
  2350. if (!r.extensions || !r.extensions[this.name] || r.mesh === void 0)
  2351. return null;
  2352. const o = s.meshes[r.mesh];
  2353. for (const g of o.primitives)
  2354. if (g.mode !== dt2.TRIANGLES && g.mode !== dt2.TRIANGLE_STRIP && g.mode !== dt2.TRIANGLE_FAN && g.mode !== void 0)
  2355. return null;
  2356. const p2 = r.extensions[this.name].attributes, h2 = [], m = {};
  2357. for (const g in p2)
  2358. h2.push(this.parser.getDependency("accessor", p2[g]).then((w) => (m[g] = w, m[g])));
  2359. return h2.length < 1 ? null : (h2.push(this.parser.createNodeMesh(i)), Promise.all(h2).then((g) => {
  2360. const w = g.pop(), _2 = w.isGroup ? w.children : [w], y = g[0].count, C = [];
  2361. for (const L of _2) {
  2362. const S = new Matrix4(), R = new Vector3(), O = new Quaternion(), N = new Vector3(1, 1, 1), I2 = new InstancedMesh(L.geometry, L.material, y);
  2363. for (let D2 = 0; D2 < y; D2++)
  2364. m.TRANSLATION && R.fromBufferAttribute(m.TRANSLATION, D2), m.ROTATION && O.fromBufferAttribute(m.ROTATION, D2), m.SCALE && N.fromBufferAttribute(m.SCALE, D2), I2.setMatrixAt(D2, S.compose(R, O, N));
  2365. for (const D2 in m)
  2366. D2 !== "TRANSLATION" && D2 !== "ROTATION" && D2 !== "SCALE" && L.geometry.setAttribute(D2, m[D2]);
  2367. Object3D.prototype.copy.call(I2, L), this.parser.assignFinalMaterial(I2), C.push(I2);
  2368. }
  2369. return w.isGroup ? (w.clear(), w.add(...C), w) : C[0];
  2370. }));
  2371. }
  2372. };
  2373. var Qa = "glTF";
  2374. var Yi = 12;
  2375. var va = {
  2376. JSON: 1313821514,
  2377. BIN: 5130562
  2378. };
  2379. var Fp = class {
  2380. constructor(i) {
  2381. this.name = le2.KHR_BINARY_GLTF, this.content = null, this.body = null;
  2382. const s = new DataView(i, 0, Yi), r = new TextDecoder();
  2383. if (this.header = {
  2384. magic: r.decode(new Uint8Array(i.slice(0, 4))),
  2385. version: s.getUint32(4, true),
  2386. length: s.getUint32(8, true)
  2387. }, this.header.magic !== Qa)
  2388. throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
  2389. if (this.header.version < 2)
  2390. throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
  2391. const o = this.header.length - Yi, c = new DataView(i, Yi);
  2392. let p2 = 0;
  2393. for (; p2 < o; ) {
  2394. const h2 = c.getUint32(p2, true);
  2395. p2 += 4;
  2396. const m = c.getUint32(p2, true);
  2397. if (p2 += 4, m === va.JSON) {
  2398. const g = new Uint8Array(i, Yi + p2, h2);
  2399. this.content = r.decode(g);
  2400. } else if (m === va.BIN) {
  2401. const g = Yi + p2;
  2402. this.body = i.slice(g, g + h2);
  2403. }
  2404. p2 += h2;
  2405. }
  2406. if (this.content === null)
  2407. throw new Error("THREE.GLTFLoader: JSON content not found.");
  2408. }
  2409. };
  2410. var jp = class {
  2411. constructor(i, s) {
  2412. if (!s)
  2413. throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
  2414. this.name = le2.KHR_DRACO_MESH_COMPRESSION, this.json = i, this.dracoLoader = s, this.dracoLoader.preload();
  2415. }
  2416. decodePrimitive(i, s) {
  2417. const r = this.json, o = this.dracoLoader, c = i.extensions[this.name].bufferView, p2 = i.extensions[this.name].attributes, h2 = {}, m = {}, g = {};
  2418. for (const w in p2) {
  2419. const _2 = go[w] || w.toLowerCase();
  2420. h2[_2] = p2[w];
  2421. }
  2422. for (const w in i.attributes) {
  2423. const _2 = go[w] || w.toLowerCase();
  2424. if (p2[w] !== void 0) {
  2425. const y = r.accessors[i.attributes[w]], C = di[y.componentType];
  2426. g[_2] = C.name, m[_2] = y.normalized === true;
  2427. }
  2428. }
  2429. return s.getDependency("bufferView", c).then(function(w) {
  2430. return new Promise(function(_2) {
  2431. o.decodeDracoFile(w, function(y) {
  2432. for (const C in y.attributes) {
  2433. const L = y.attributes[C], S = m[C];
  2434. S !== void 0 && (L.normalized = S);
  2435. }
  2436. _2(y);
  2437. }, h2, g);
  2438. });
  2439. });
  2440. }
  2441. };
  2442. var zp = class {
  2443. constructor() {
  2444. this.name = le2.KHR_TEXTURE_TRANSFORM;
  2445. }
  2446. extendTexture(i, s) {
  2447. return (s.texCoord === void 0 || s.texCoord === i.channel) && s.offset === void 0 && s.rotation === void 0 && s.scale === void 0 || (i = i.clone(), s.texCoord !== void 0 && (i.channel = s.texCoord), s.offset !== void 0 && i.offset.fromArray(s.offset), s.rotation !== void 0 && (i.rotation = s.rotation), s.scale !== void 0 && i.repeat.fromArray(s.scale), i.needsUpdate = true), i;
  2448. }
  2449. };
  2450. var Up = class {
  2451. constructor() {
  2452. this.name = le2.KHR_MESH_QUANTIZATION;
  2453. }
  2454. };
  2455. var Za = class extends Interpolant {
  2456. constructor(i, s, r, o) {
  2457. super(i, s, r, o);
  2458. }
  2459. copySampleValue_(i) {
  2460. const s = this.resultBuffer, r = this.sampleValues, o = this.valueSize, c = i * o * 3 + o;
  2461. for (let p2 = 0; p2 !== o; p2++)
  2462. s[p2] = r[c + p2];
  2463. return s;
  2464. }
  2465. interpolate_(i, s, r, o) {
  2466. const c = this.resultBuffer, p2 = this.sampleValues, h2 = this.valueSize, m = h2 * 2, g = h2 * 3, w = o - s, _2 = (r - s) / w, y = _2 * _2, C = y * _2, L = i * g, S = L - g, R = -2 * C + 3 * y, O = C - y, N = 1 - R, I2 = O - y + _2;
  2467. for (let D2 = 0; D2 !== h2; D2++) {
  2468. const Y = p2[S + D2 + h2], G = p2[S + D2 + m] * w, F = p2[L + D2 + h2], B = p2[L + D2] * w;
  2469. c[D2] = N * Y + I2 * G + R * F + O * B;
  2470. }
  2471. return c;
  2472. }
  2473. };
  2474. var Gp = new Quaternion();
  2475. var Hp = class extends Za {
  2476. interpolate_(i, s, r, o) {
  2477. const c = super.interpolate_(i, s, r, o);
  2478. return Gp.fromArray(c).normalize().toArray(c), c;
  2479. }
  2480. };
  2481. var dt2 = {
  2482. FLOAT: 5126,
  2483. //FLOAT_MAT2: 35674,
  2484. FLOAT_MAT3: 35675,
  2485. FLOAT_MAT4: 35676,
  2486. FLOAT_VEC2: 35664,
  2487. FLOAT_VEC3: 35665,
  2488. FLOAT_VEC4: 35666,
  2489. LINEAR: 9729,
  2490. REPEAT: 10497,
  2491. SAMPLER_2D: 35678,
  2492. POINTS: 0,
  2493. LINES: 1,
  2494. LINE_LOOP: 2,
  2495. LINE_STRIP: 3,
  2496. TRIANGLES: 4,
  2497. TRIANGLE_STRIP: 5,
  2498. TRIANGLE_FAN: 6,
  2499. UNSIGNED_BYTE: 5121,
  2500. UNSIGNED_SHORT: 5123
  2501. };
  2502. var di = {
  2503. 5120: Int8Array,
  2504. 5121: Uint8Array,
  2505. 5122: Int16Array,
  2506. 5123: Uint16Array,
  2507. 5125: Uint32Array,
  2508. 5126: Float32Array
  2509. };
  2510. var ba = {
  2511. 9728: NearestFilter,
  2512. 9729: LinearFilter,
  2513. 9984: NearestMipmapNearestFilter,
  2514. 9985: LinearMipmapNearestFilter,
  2515. 9986: NearestMipmapLinearFilter,
  2516. 9987: LinearMipmapLinearFilter
  2517. };
  2518. var ga = {
  2519. 33071: ClampToEdgeWrapping,
  2520. 33648: MirroredRepeatWrapping,
  2521. 10497: RepeatWrapping
  2522. };
  2523. var io = {
  2524. SCALAR: 1,
  2525. VEC2: 2,
  2526. VEC3: 3,
  2527. VEC4: 4,
  2528. MAT2: 4,
  2529. MAT3: 9,
  2530. MAT4: 16
  2531. };
  2532. var go = {
  2533. POSITION: "position",
  2534. NORMAL: "normal",
  2535. TANGENT: "tangent",
  2536. TEXCOORD_0: "uv",
  2537. TEXCOORD_1: "uv2",
  2538. COLOR_0: "color",
  2539. WEIGHTS_0: "skinWeight",
  2540. JOINTS_0: "skinIndex"
  2541. };
  2542. var sn = {
  2543. scale: "scale",
  2544. translation: "position",
  2545. rotation: "quaternion",
  2546. weights: "morphTargetInfluences"
  2547. };
  2548. var Kp = {
  2549. CUBICSPLINE: void 0,
  2550. // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
  2551. // keyframe track will be initialized with a default interpolation type, then modified.
  2552. LINEAR: InterpolateLinear,
  2553. STEP: InterpolateDiscrete
  2554. };
  2555. var so = {
  2556. OPAQUE: "OPAQUE",
  2557. MASK: "MASK",
  2558. BLEND: "BLEND"
  2559. };
  2560. function $p(f) {
  2561. return f.DefaultMaterial === void 0 && (f.DefaultMaterial = new MeshStandardMaterial({
  2562. color: 16777215,
  2563. emissive: 0,
  2564. metalness: 1,
  2565. roughness: 1,
  2566. transparent: false,
  2567. depthTest: true,
  2568. side: FrontSide
  2569. })), f.DefaultMaterial;
  2570. }
  2571. function qi(f, i, s) {
  2572. for (const r in s.extensions)
  2573. f[r] === void 0 && (i.userData.gltfExtensions = i.userData.gltfExtensions || {}, i.userData.gltfExtensions[r] = s.extensions[r]);
  2574. }
  2575. function ln(f, i) {
  2576. i.extras !== void 0 && (typeof i.extras == "object" ? Object.assign(f.userData, i.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + i.extras));
  2577. }
  2578. function Xp(f, i, s) {
  2579. let r = false, o = false, c = false;
  2580. for (let g = 0, w = i.length; g < w; g++) {
  2581. const _2 = i[g];
  2582. if (_2.POSITION !== void 0 && (r = true), _2.NORMAL !== void 0 && (o = true), _2.COLOR_0 !== void 0 && (c = true), r && o && c)
  2583. break;
  2584. }
  2585. if (!r && !o && !c)
  2586. return Promise.resolve(f);
  2587. const p2 = [], h2 = [], m = [];
  2588. for (let g = 0, w = i.length; g < w; g++) {
  2589. const _2 = i[g];
  2590. if (r) {
  2591. const y = _2.POSITION !== void 0 ? s.getDependency("accessor", _2.POSITION) : f.attributes.position;
  2592. p2.push(y);
  2593. }
  2594. if (o) {
  2595. const y = _2.NORMAL !== void 0 ? s.getDependency("accessor", _2.NORMAL) : f.attributes.normal;
  2596. h2.push(y);
  2597. }
  2598. if (c) {
  2599. const y = _2.COLOR_0 !== void 0 ? s.getDependency("accessor", _2.COLOR_0) : f.attributes.color;
  2600. m.push(y);
  2601. }
  2602. }
  2603. return Promise.all([Promise.all(p2), Promise.all(h2), Promise.all(m)]).then(function(g) {
  2604. const w = g[0], _2 = g[1], y = g[2];
  2605. return r && (f.morphAttributes.position = w), o && (f.morphAttributes.normal = _2), c && (f.morphAttributes.color = y), f.morphTargetsRelative = true, f;
  2606. });
  2607. }
  2608. function Yp(f, i) {
  2609. if (f.updateMorphTargets(), i.weights !== void 0)
  2610. for (let s = 0, r = i.weights.length; s < r; s++)
  2611. f.morphTargetInfluences[s] = i.weights[s];
  2612. if (i.extras && Array.isArray(i.extras.targetNames)) {
  2613. const s = i.extras.targetNames;
  2614. if (f.morphTargetInfluences.length === s.length) {
  2615. f.morphTargetDictionary = {};
  2616. for (let r = 0, o = s.length; r < o; r++)
  2617. f.morphTargetDictionary[s[r]] = r;
  2618. } else
  2619. console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
  2620. }
  2621. }
  2622. function qp(f) {
  2623. const i = f.extensions && f.extensions[le2.KHR_DRACO_MESH_COMPRESSION];
  2624. let s;
  2625. return i ? s = "draco:" + i.bufferView + ":" + i.indices + ":" + _a(i.attributes) : s = f.indices + ":" + _a(f.attributes) + ":" + f.mode, s;
  2626. }
  2627. function _a(f) {
  2628. let i = "";
  2629. const s = Object.keys(f).sort();
  2630. for (let r = 0, o = s.length; r < o; r++)
  2631. i += s[r] + ":" + f[s[r]] + ";";
  2632. return i;
  2633. }
  2634. function _o(f) {
  2635. switch (f) {
  2636. case Int8Array:
  2637. return 1 / 127;
  2638. case Uint8Array:
  2639. return 1 / 255;
  2640. case Int16Array:
  2641. return 1 / 32767;
  2642. case Uint16Array:
  2643. return 1 / 65535;
  2644. default:
  2645. throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
  2646. }
  2647. }
  2648. function Qp(f) {
  2649. return f.search(/\.jpe?g($|\?)/i) > 0 || f.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : f.search(/\.webp($|\?)/i) > 0 || f.search(/^data\:image\/webp/) === 0 ? "image/webp" : "image/png";
  2650. }
  2651. var Zp = new Matrix4();
  2652. var Wp = class {
  2653. constructor(i = {}, s = {}) {
  2654. this.json = i, this.extensions = {}, this.plugins = {}, this.options = s, this.cache = new Ep(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = {
  2655. refs: {},
  2656. uses: {}
  2657. }, this.cameraCache = {
  2658. refs: {},
  2659. uses: {}
  2660. }, this.lightCache = {
  2661. refs: {},
  2662. uses: {}
  2663. }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
  2664. let r = false, o = false, c = -1;
  2665. typeof navigator < "u" && (r = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) === true, o = navigator.userAgent.indexOf("Firefox") > -1, c = o ? navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1] : -1), typeof createImageBitmap > "u" || r || o && c < 98 ? this.textureLoader = new TextureLoader(this.options.manager) : this.textureLoader = new ImageBitmapLoader(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new FileLoader(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(true);
  2666. }
  2667. setExtensions(i) {
  2668. this.extensions = i;
  2669. }
  2670. setPlugins(i) {
  2671. this.plugins = i;
  2672. }
  2673. parse(i, s) {
  2674. const r = this, o = this.json, c = this.extensions;
  2675. this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(p2) {
  2676. return p2._markDefs && p2._markDefs();
  2677. }), Promise.all(this._invokeAll(function(p2) {
  2678. return p2.beforeRoot && p2.beforeRoot();
  2679. })).then(function() {
  2680. return Promise.all([r.getDependencies("scene"), r.getDependencies("animation"), r.getDependencies("camera")]);
  2681. }).then(function(p2) {
  2682. const h2 = {
  2683. scene: p2[0][o.scene || 0],
  2684. scenes: p2[0],
  2685. animations: p2[1],
  2686. cameras: p2[2],
  2687. asset: o.asset,
  2688. parser: r,
  2689. userData: {}
  2690. };
  2691. qi(c, h2, o), ln(h2, o), Promise.all(r._invokeAll(function(m) {
  2692. return m.afterRoot && m.afterRoot(h2);
  2693. })).then(function() {
  2694. i(h2);
  2695. });
  2696. }).catch(s);
  2697. }
  2698. /**
  2699. * Marks the special nodes/meshes in json for efficient parse.
  2700. */
  2701. _markDefs() {
  2702. const i = this.json.nodes || [], s = this.json.skins || [], r = this.json.meshes || [];
  2703. for (let o = 0, c = s.length; o < c; o++) {
  2704. const p2 = s[o].joints;
  2705. for (let h2 = 0, m = p2.length; h2 < m; h2++)
  2706. i[p2[h2]].isBone = true;
  2707. }
  2708. for (let o = 0, c = i.length; o < c; o++) {
  2709. const p2 = i[o];
  2710. p2.mesh !== void 0 && (this._addNodeRef(this.meshCache, p2.mesh), p2.skin !== void 0 && (r[p2.mesh].isSkinnedMesh = true)), p2.camera !== void 0 && this._addNodeRef(this.cameraCache, p2.camera);
  2711. }
  2712. }
  2713. /**
  2714. * Counts references to shared node / Object3D resources. These resources
  2715. * can be reused, or "instantiated", at multiple nodes in the scene
  2716. * hierarchy. Mesh, Camera, and Light instances are instantiated and must
  2717. * be marked. Non-scenegraph resources (like Materials, Geometries, and
  2718. * Textures) can be reused directly and are not marked here.
  2719. *
  2720. * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
  2721. */
  2722. _addNodeRef(i, s) {
  2723. s !== void 0 && (i.refs[s] === void 0 && (i.refs[s] = i.uses[s] = 0), i.refs[s]++);
  2724. }
  2725. /** Returns a reference to a shared resource, cloning it if necessary. */
  2726. _getNodeRef(i, s, r) {
  2727. if (i.refs[s] <= 1)
  2728. return r;
  2729. const o = r.clone(), c = (p2, h2) => {
  2730. const m = this.associations.get(p2);
  2731. m != null && this.associations.set(h2, m);
  2732. for (const [g, w] of p2.children.entries())
  2733. c(w, h2.children[g]);
  2734. };
  2735. return c(r, o), o.name += "_instance_" + i.uses[s]++, o;
  2736. }
  2737. _invokeOne(i) {
  2738. const s = Object.values(this.plugins);
  2739. s.push(this);
  2740. for (let r = 0; r < s.length; r++) {
  2741. const o = i(s[r]);
  2742. if (o)
  2743. return o;
  2744. }
  2745. return null;
  2746. }
  2747. _invokeAll(i) {
  2748. const s = Object.values(this.plugins);
  2749. s.unshift(this);
  2750. const r = [];
  2751. for (let o = 0; o < s.length; o++) {
  2752. const c = i(s[o]);
  2753. c && r.push(c);
  2754. }
  2755. return r;
  2756. }
  2757. /**
  2758. * Requests the specified dependency asynchronously, with caching.
  2759. * @param {string} type
  2760. * @param {number} index
  2761. * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
  2762. */
  2763. getDependency(i, s) {
  2764. const r = i + ":" + s;
  2765. let o = this.cache.get(r);
  2766. if (!o) {
  2767. switch (i) {
  2768. case "scene":
  2769. o = this.loadScene(s);
  2770. break;
  2771. case "node":
  2772. o = this._invokeOne(function(c) {
  2773. return c.loadNode && c.loadNode(s);
  2774. });
  2775. break;
  2776. case "mesh":
  2777. o = this._invokeOne(function(c) {
  2778. return c.loadMesh && c.loadMesh(s);
  2779. });
  2780. break;
  2781. case "accessor":
  2782. o = this.loadAccessor(s);
  2783. break;
  2784. case "bufferView":
  2785. o = this._invokeOne(function(c) {
  2786. return c.loadBufferView && c.loadBufferView(s);
  2787. });
  2788. break;
  2789. case "buffer":
  2790. o = this.loadBuffer(s);
  2791. break;
  2792. case "material":
  2793. o = this._invokeOne(function(c) {
  2794. return c.loadMaterial && c.loadMaterial(s);
  2795. });
  2796. break;
  2797. case "texture":
  2798. o = this._invokeOne(function(c) {
  2799. return c.loadTexture && c.loadTexture(s);
  2800. });
  2801. break;
  2802. case "skin":
  2803. o = this.loadSkin(s);
  2804. break;
  2805. case "animation":
  2806. o = this._invokeOne(function(c) {
  2807. return c.loadAnimation && c.loadAnimation(s);
  2808. });
  2809. break;
  2810. case "camera":
  2811. o = this.loadCamera(s);
  2812. break;
  2813. default:
  2814. if (o = this._invokeOne(function(c) {
  2815. return c != this && c.getDependency && c.getDependency(i, s);
  2816. }), !o)
  2817. throw new Error("Unknown type: " + i);
  2818. break;
  2819. }
  2820. this.cache.add(r, o);
  2821. }
  2822. return o;
  2823. }
  2824. /**
  2825. * Requests all dependencies of the specified type asynchronously, with caching.
  2826. * @param {string} type
  2827. * @return {Promise<Array<Object>>}
  2828. */
  2829. getDependencies(i) {
  2830. let s = this.cache.get(i);
  2831. if (!s) {
  2832. const r = this, o = this.json[i + (i === "mesh" ? "es" : "s")] || [];
  2833. s = Promise.all(o.map(function(c, p2) {
  2834. return r.getDependency(i, p2);
  2835. })), this.cache.add(i, s);
  2836. }
  2837. return s;
  2838. }
  2839. /**
  2840. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
  2841. * @param {number} bufferIndex
  2842. * @return {Promise<ArrayBuffer>}
  2843. */
  2844. loadBuffer(i) {
  2845. const s = this.json.buffers[i], r = this.fileLoader;
  2846. if (s.type && s.type !== "arraybuffer")
  2847. throw new Error("THREE.GLTFLoader: " + s.type + " buffer type is not supported.");
  2848. if (s.uri === void 0 && i === 0)
  2849. return Promise.resolve(this.extensions[le2.KHR_BINARY_GLTF].body);
  2850. const o = this.options;
  2851. return new Promise(function(c, p2) {
  2852. r.load(LoaderUtils.resolveURL(s.uri, o.path), c, void 0, function() {
  2853. p2(new Error('THREE.GLTFLoader: Failed to load buffer "' + s.uri + '".'));
  2854. });
  2855. });
  2856. }
  2857. /**
  2858. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
  2859. * @param {number} bufferViewIndex
  2860. * @return {Promise<ArrayBuffer>}
  2861. */
  2862. loadBufferView(i) {
  2863. const s = this.json.bufferViews[i];
  2864. return this.getDependency("buffer", s.buffer).then(function(r) {
  2865. const o = s.byteLength || 0, c = s.byteOffset || 0;
  2866. return r.slice(c, c + o);
  2867. });
  2868. }
  2869. /**
  2870. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
  2871. * @param {number} accessorIndex
  2872. * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
  2873. */
  2874. loadAccessor(i) {
  2875. const s = this, r = this.json, o = this.json.accessors[i];
  2876. if (o.bufferView === void 0 && o.sparse === void 0) {
  2877. const p2 = io[o.type], h2 = di[o.componentType], m = o.normalized === true, g = new h2(o.count * p2);
  2878. return Promise.resolve(new BufferAttribute(g, p2, m));
  2879. }
  2880. const c = [];
  2881. return o.bufferView !== void 0 ? c.push(this.getDependency("bufferView", o.bufferView)) : c.push(null), o.sparse !== void 0 && (c.push(this.getDependency("bufferView", o.sparse.indices.bufferView)), c.push(this.getDependency("bufferView", o.sparse.values.bufferView))), Promise.all(c).then(function(p2) {
  2882. const h2 = p2[0], m = io[o.type], g = di[o.componentType], w = g.BYTES_PER_ELEMENT, _2 = w * m, y = o.byteOffset || 0, C = o.bufferView !== void 0 ? r.bufferViews[o.bufferView].byteStride : void 0, L = o.normalized === true;
  2883. let S, R;
  2884. if (C && C !== _2) {
  2885. const O = Math.floor(y / C), N = "InterleavedBuffer:" + o.bufferView + ":" + o.componentType + ":" + O + ":" + o.count;
  2886. let I2 = s.cache.get(N);
  2887. I2 || (S = new g(h2, O * C, o.count * C / w), I2 = new InterleavedBuffer(S, C / w), s.cache.add(N, I2)), R = new InterleavedBufferAttribute(I2, m, y % C / w, L);
  2888. } else
  2889. h2 === null ? S = new g(o.count * m) : S = new g(h2, y, o.count * m), R = new BufferAttribute(S, m, L);
  2890. if (o.sparse !== void 0) {
  2891. const O = io.SCALAR, N = di[o.sparse.indices.componentType], I2 = o.sparse.indices.byteOffset || 0, D2 = o.sparse.values.byteOffset || 0, Y = new N(p2[1], I2, o.sparse.count * O), G = new g(p2[2], D2, o.sparse.count * m);
  2892. h2 !== null && (R = new BufferAttribute(R.array.slice(), R.itemSize, R.normalized));
  2893. for (let F = 0, B = Y.length; F < B; F++) {
  2894. const H2 = Y[F];
  2895. if (R.setX(H2, G[F * m]), m >= 2 && R.setY(H2, G[F * m + 1]), m >= 3 && R.setZ(H2, G[F * m + 2]), m >= 4 && R.setW(H2, G[F * m + 3]), m >= 5)
  2896. throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
  2897. }
  2898. }
  2899. return R;
  2900. });
  2901. }
  2902. /**
  2903. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
  2904. * @param {number} textureIndex
  2905. * @return {Promise<THREE.Texture|null>}
  2906. */
  2907. loadTexture(i) {
  2908. const s = this.json, r = this.options, c = s.textures[i].source, p2 = s.images[c];
  2909. let h2 = this.textureLoader;
  2910. if (p2.uri) {
  2911. const m = r.manager.getHandler(p2.uri);
  2912. m !== null && (h2 = m);
  2913. }
  2914. return this.loadTextureImage(i, c, h2);
  2915. }
  2916. loadTextureImage(i, s, r) {
  2917. const o = this, c = this.json, p2 = c.textures[i], h2 = c.images[s], m = (h2.uri || h2.bufferView) + ":" + p2.sampler;
  2918. if (this.textureCache[m])
  2919. return this.textureCache[m];
  2920. const g = this.loadImageSource(s, r).then(function(w) {
  2921. w.flipY = false, w.name = p2.name || h2.name || "", w.name === "" && typeof h2.uri == "string" && h2.uri.startsWith("data:image/") === false && (w.name = h2.uri);
  2922. const y = (c.samplers || {})[p2.sampler] || {};
  2923. return w.magFilter = ba[y.magFilter] || LinearFilter, w.minFilter = ba[y.minFilter] || LinearMipmapLinearFilter, w.wrapS = ga[y.wrapS] || RepeatWrapping, w.wrapT = ga[y.wrapT] || RepeatWrapping, o.associations.set(w, {
  2924. textures: i
  2925. }), w;
  2926. }).catch(function() {
  2927. return null;
  2928. });
  2929. return this.textureCache[m] = g, g;
  2930. }
  2931. loadImageSource(i, s) {
  2932. const r = this, o = this.json, c = this.options;
  2933. if (this.sourceCache[i] !== void 0)
  2934. return this.sourceCache[i].then((_2) => _2.clone());
  2935. const p2 = o.images[i], h2 = self.URL || self.webkitURL;
  2936. let m = p2.uri || "", g = false;
  2937. if (p2.bufferView !== void 0)
  2938. m = r.getDependency("bufferView", p2.bufferView).then(function(_2) {
  2939. g = true;
  2940. const y = new Blob([_2], {
  2941. type: p2.mimeType
  2942. });
  2943. return m = h2.createObjectURL(y), m;
  2944. });
  2945. else if (p2.uri === void 0)
  2946. throw new Error("THREE.GLTFLoader: Image " + i + " is missing URI and bufferView");
  2947. const w = Promise.resolve(m).then(function(_2) {
  2948. return new Promise(function(y, C) {
  2949. let L = y;
  2950. s.isImageBitmapLoader === true && (L = function(S) {
  2951. const R = new Texture(S);
  2952. R.needsUpdate = true, y(R);
  2953. }), s.load(LoaderUtils.resolveURL(_2, c.path), L, void 0, C);
  2954. });
  2955. }).then(function(_2) {
  2956. return g === true && h2.revokeObjectURL(m), _2.userData.mimeType = p2.mimeType || Qp(p2.uri), _2;
  2957. }).catch(function(_2) {
  2958. throw console.error("THREE.GLTFLoader: Couldn't load texture", m), _2;
  2959. });
  2960. return this.sourceCache[i] = w, w;
  2961. }
  2962. /**
  2963. * Asynchronously assigns a texture to the given material parameters.
  2964. * @param {Object} materialParams
  2965. * @param {string} mapName
  2966. * @param {Object} mapDef
  2967. * @return {Promise<Texture>}
  2968. */
  2969. assignTexture(i, s, r, o) {
  2970. const c = this;
  2971. return this.getDependency("texture", r.index).then(function(p2) {
  2972. if (!p2)
  2973. return null;
  2974. if (r.texCoord !== void 0 && r.texCoord > 0 && (p2 = p2.clone(), p2.channel = r.texCoord), c.extensions[le2.KHR_TEXTURE_TRANSFORM]) {
  2975. const h2 = r.extensions !== void 0 ? r.extensions[le2.KHR_TEXTURE_TRANSFORM] : void 0;
  2976. if (h2) {
  2977. const m = c.associations.get(p2);
  2978. p2 = c.extensions[le2.KHR_TEXTURE_TRANSFORM].extendTexture(p2, h2), c.associations.set(p2, m);
  2979. }
  2980. }
  2981. return o !== void 0 && (p2.encoding = o), i[s] = p2, p2;
  2982. });
  2983. }
  2984. /**
  2985. * Assigns final material to a Mesh, Line, or Points instance. The instance
  2986. * already has a material (generated from the glTF material options alone)
  2987. * but reuse of the same glTF material may require multiple threejs materials
  2988. * to accommodate different primitive types, defines, etc. New materials will
  2989. * be created if necessary, and reused from a cache.
  2990. * @param {Object3D} mesh Mesh, Line, or Points instance.
  2991. */
  2992. assignFinalMaterial(i) {
  2993. const s = i.geometry;
  2994. let r = i.material;
  2995. const o = s.attributes.tangent === void 0, c = s.attributes.color !== void 0, p2 = s.attributes.normal === void 0;
  2996. if (i.isPoints) {
  2997. const h2 = "PointsMaterial:" + r.uuid;
  2998. let m = this.cache.get(h2);
  2999. m || (m = new PointsMaterial(), Material.prototype.copy.call(m, r), m.color.copy(r.color), m.map = r.map, m.sizeAttenuation = false, this.cache.add(h2, m)), r = m;
  3000. } else if (i.isLine) {
  3001. const h2 = "LineBasicMaterial:" + r.uuid;
  3002. let m = this.cache.get(h2);
  3003. m || (m = new LineBasicMaterial(), Material.prototype.copy.call(m, r), m.color.copy(r.color), m.map = r.map, this.cache.add(h2, m)), r = m;
  3004. }
  3005. if (o || c || p2) {
  3006. let h2 = "ClonedMaterial:" + r.uuid + ":";
  3007. o && (h2 += "derivative-tangents:"), c && (h2 += "vertex-colors:"), p2 && (h2 += "flat-shading:");
  3008. let m = this.cache.get(h2);
  3009. m || (m = r.clone(), c && (m.vertexColors = true), p2 && (m.flatShading = true), o && (m.normalScale && (m.normalScale.y *= -1), m.clearcoatNormalScale && (m.clearcoatNormalScale.y *= -1)), this.cache.add(h2, m), this.associations.set(m, this.associations.get(r))), r = m;
  3010. }
  3011. i.material = r;
  3012. }
  3013. getMaterialType() {
  3014. return MeshStandardMaterial;
  3015. }
  3016. /**
  3017. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
  3018. * @param {number} materialIndex
  3019. * @return {Promise<Material>}
  3020. */
  3021. loadMaterial(i) {
  3022. const s = this, r = this.json, o = this.extensions, c = r.materials[i];
  3023. let p2;
  3024. const h2 = {}, m = c.extensions || {}, g = [];
  3025. if (m[le2.KHR_MATERIALS_UNLIT]) {
  3026. const _2 = o[le2.KHR_MATERIALS_UNLIT];
  3027. p2 = _2.getMaterialType(), g.push(_2.extendParams(h2, c, s));
  3028. } else {
  3029. const _2 = c.pbrMetallicRoughness || {};
  3030. if (h2.color = new Color(1, 1, 1), h2.opacity = 1, Array.isArray(_2.baseColorFactor)) {
  3031. const y = _2.baseColorFactor;
  3032. h2.color.fromArray(y), h2.opacity = y[3];
  3033. }
  3034. _2.baseColorTexture !== void 0 && g.push(s.assignTexture(h2, "map", _2.baseColorTexture, sRGBEncoding)), h2.metalness = _2.metallicFactor !== void 0 ? _2.metallicFactor : 1, h2.roughness = _2.roughnessFactor !== void 0 ? _2.roughnessFactor : 1, _2.metallicRoughnessTexture !== void 0 && (g.push(s.assignTexture(h2, "metalnessMap", _2.metallicRoughnessTexture)), g.push(s.assignTexture(h2, "roughnessMap", _2.metallicRoughnessTexture))), p2 = this._invokeOne(function(y) {
  3035. return y.getMaterialType && y.getMaterialType(i);
  3036. }), g.push(Promise.all(this._invokeAll(function(y) {
  3037. return y.extendMaterialParams && y.extendMaterialParams(i, h2);
  3038. })));
  3039. }
  3040. c.doubleSided === true && (h2.side = DoubleSide);
  3041. const w = c.alphaMode || so.OPAQUE;
  3042. if (w === so.BLEND ? (h2.transparent = true, h2.depthWrite = false) : (h2.transparent = false, w === so.MASK && (h2.alphaTest = c.alphaCutoff !== void 0 ? c.alphaCutoff : 0.5)), c.normalTexture !== void 0 && p2 !== MeshBasicMaterial && (g.push(s.assignTexture(h2, "normalMap", c.normalTexture)), h2.normalScale = new Vector2(1, 1), c.normalTexture.scale !== void 0)) {
  3043. const _2 = c.normalTexture.scale;
  3044. h2.normalScale.set(_2, _2);
  3045. }
  3046. return c.occlusionTexture !== void 0 && p2 !== MeshBasicMaterial && (g.push(s.assignTexture(h2, "aoMap", c.occlusionTexture)), c.occlusionTexture.strength !== void 0 && (h2.aoMapIntensity = c.occlusionTexture.strength)), c.emissiveFactor !== void 0 && p2 !== MeshBasicMaterial && (h2.emissive = new Color().fromArray(c.emissiveFactor)), c.emissiveTexture !== void 0 && p2 !== MeshBasicMaterial && g.push(s.assignTexture(h2, "emissiveMap", c.emissiveTexture, sRGBEncoding)), Promise.all(g).then(function() {
  3047. const _2 = new p2(h2);
  3048. return c.name && (_2.name = c.name), ln(_2, c), s.associations.set(_2, {
  3049. materials: i
  3050. }), c.extensions && qi(o, _2, c), _2;
  3051. });
  3052. }
  3053. /** When Object3D instances are targeted by animation, they need unique names. */
  3054. createUniqueName(i) {
  3055. const s = PropertyBinding.sanitizeNodeName(i || "");
  3056. let r = s;
  3057. for (let o = 1; this.nodeNamesUsed[r]; ++o)
  3058. r = s + "_" + o;
  3059. return this.nodeNamesUsed[r] = true, r;
  3060. }
  3061. /**
  3062. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
  3063. *
  3064. * Creates BufferGeometries from primitives.
  3065. *
  3066. * @param {Array<GLTF.Primitive>} primitives
  3067. * @return {Promise<Array<BufferGeometry>>}
  3068. */
  3069. loadGeometries(i) {
  3070. const s = this, r = this.extensions, o = this.primitiveCache;
  3071. function c(h2) {
  3072. return r[le2.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h2, s).then(function(m) {
  3073. return wa(m, h2, s);
  3074. });
  3075. }
  3076. const p2 = [];
  3077. for (let h2 = 0, m = i.length; h2 < m; h2++) {
  3078. const g = i[h2], w = qp(g), _2 = o[w];
  3079. if (_2)
  3080. p2.push(_2.promise);
  3081. else {
  3082. let y;
  3083. g.extensions && g.extensions[le2.KHR_DRACO_MESH_COMPRESSION] ? y = c(g) : y = wa(new BufferGeometry(), g, s), o[w] = {
  3084. primitive: g,
  3085. promise: y
  3086. }, p2.push(y);
  3087. }
  3088. }
  3089. return Promise.all(p2);
  3090. }
  3091. /**
  3092. * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
  3093. * @param {number} meshIndex
  3094. * @return {Promise<Group|Mesh|SkinnedMesh>}
  3095. */
  3096. loadMesh(i) {
  3097. const s = this, r = this.json, o = this.extensions, c = r.meshes[i], p2 = c.primitives, h2 = [];
  3098. for (let m = 0, g = p2.length; m < g; m++) {
  3099. const w = p2[m].material === void 0 ? $p(this.cache) : this.getDependency("material", p2[m].material);
  3100. h2.push(w);
  3101. }
  3102. return h2.push(s.loadGeometries(p2)), Promise.all(h2).then(function(m) {
  3103. const g = m.slice(0, m.length - 1), w = m[m.length - 1], _2 = [];
  3104. for (let C = 0, L = w.length; C < L; C++) {
  3105. const S = w[C], R = p2[C];
  3106. let O;
  3107. const N = g[C];
  3108. if (R.mode === dt2.TRIANGLES || R.mode === dt2.TRIANGLE_STRIP || R.mode === dt2.TRIANGLE_FAN || R.mode === void 0)
  3109. O = c.isSkinnedMesh === true ? new SkinnedMesh(S, N) : new Mesh(S, N), O.isSkinnedMesh === true && O.normalizeSkinWeights(), R.mode === dt2.TRIANGLE_STRIP ? O.geometry = da(O.geometry, TriangleStripDrawMode) : R.mode === dt2.TRIANGLE_FAN && (O.geometry = da(O.geometry, TriangleFanDrawMode));
  3110. else if (R.mode === dt2.LINES)
  3111. O = new LineSegments(S, N);
  3112. else if (R.mode === dt2.LINE_STRIP)
  3113. O = new Line(S, N);
  3114. else if (R.mode === dt2.LINE_LOOP)
  3115. O = new LineLoop(S, N);
  3116. else if (R.mode === dt2.POINTS)
  3117. O = new Points(S, N);
  3118. else
  3119. throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + R.mode);
  3120. Object.keys(O.geometry.morphAttributes).length > 0 && Yp(O, c), O.name = s.createUniqueName(c.name || "mesh_" + i), ln(O, c), R.extensions && qi(o, O, R), s.assignFinalMaterial(O), _2.push(O);
  3121. }
  3122. for (let C = 0, L = _2.length; C < L; C++)
  3123. s.associations.set(_2[C], {
  3124. meshes: i,
  3125. primitives: C
  3126. });
  3127. if (_2.length === 1)
  3128. return _2[0];
  3129. const y = new Group();
  3130. s.associations.set(y, {
  3131. meshes: i
  3132. });
  3133. for (let C = 0, L = _2.length; C < L; C++)
  3134. y.add(_2[C]);
  3135. return y;
  3136. });
  3137. }
  3138. /**
  3139. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
  3140. * @param {number} cameraIndex
  3141. * @return {Promise<THREE.Camera>}
  3142. */
  3143. loadCamera(i) {
  3144. let s;
  3145. const r = this.json.cameras[i], o = r[r.type];
  3146. if (!o) {
  3147. console.warn("THREE.GLTFLoader: Missing camera parameters.");
  3148. return;
  3149. }
  3150. return r.type === "perspective" ? s = new PerspectiveCamera(MathUtils.radToDeg(o.yfov), o.aspectRatio || 1, o.znear || 1, o.zfar || 2e6) : r.type === "orthographic" && (s = new OrthographicCamera(-o.xmag, o.xmag, o.ymag, -o.ymag, o.znear, o.zfar)), r.name && (s.name = this.createUniqueName(r.name)), ln(s, r), Promise.resolve(s);
  3151. }
  3152. /**
  3153. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
  3154. * @param {number} skinIndex
  3155. * @return {Promise<Skeleton>}
  3156. */
  3157. loadSkin(i) {
  3158. const s = this.json.skins[i], r = [];
  3159. for (let o = 0, c = s.joints.length; o < c; o++)
  3160. r.push(this._loadNodeShallow(s.joints[o]));
  3161. return s.inverseBindMatrices !== void 0 ? r.push(this.getDependency("accessor", s.inverseBindMatrices)) : r.push(null), Promise.all(r).then(function(o) {
  3162. const c = o.pop(), p2 = o, h2 = [], m = [];
  3163. for (let g = 0, w = p2.length; g < w; g++) {
  3164. const _2 = p2[g];
  3165. if (_2) {
  3166. h2.push(_2);
  3167. const y = new Matrix4();
  3168. c !== null && y.fromArray(c.array, g * 16), m.push(y);
  3169. } else
  3170. console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', s.joints[g]);
  3171. }
  3172. return new Skeleton(h2, m);
  3173. });
  3174. }
  3175. /**
  3176. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
  3177. * @param {number} animationIndex
  3178. * @return {Promise<AnimationClip>}
  3179. */
  3180. loadAnimation(i) {
  3181. const r = this.json.animations[i], o = r.name ? r.name : "animation_" + i, c = [], p2 = [], h2 = [], m = [], g = [];
  3182. for (let w = 0, _2 = r.channels.length; w < _2; w++) {
  3183. const y = r.channels[w], C = r.samplers[y.sampler], L = y.target, S = L.node, R = r.parameters !== void 0 ? r.parameters[C.input] : C.input, O = r.parameters !== void 0 ? r.parameters[C.output] : C.output;
  3184. L.node !== void 0 && (c.push(this.getDependency("node", S)), p2.push(this.getDependency("accessor", R)), h2.push(this.getDependency("accessor", O)), m.push(C), g.push(L));
  3185. }
  3186. return Promise.all([Promise.all(c), Promise.all(p2), Promise.all(h2), Promise.all(m), Promise.all(g)]).then(function(w) {
  3187. const _2 = w[0], y = w[1], C = w[2], L = w[3], S = w[4], R = [];
  3188. for (let O = 0, N = _2.length; O < N; O++) {
  3189. const I2 = _2[O], D2 = y[O], Y = C[O], G = L[O], F = S[O];
  3190. if (I2 === void 0)
  3191. continue;
  3192. I2.updateMatrix();
  3193. let B;
  3194. switch (sn[F.path]) {
  3195. case sn.weights:
  3196. B = NumberKeyframeTrack;
  3197. break;
  3198. case sn.rotation:
  3199. B = QuaternionKeyframeTrack;
  3200. break;
  3201. case sn.position:
  3202. case sn.scale:
  3203. default:
  3204. B = VectorKeyframeTrack;
  3205. break;
  3206. }
  3207. const H2 = I2.name ? I2.name : I2.uuid, K2 = G.interpolation !== void 0 ? Kp[G.interpolation] : InterpolateLinear, q = [];
  3208. sn[F.path] === sn.weights ? I2.traverse(function(_e) {
  3209. _e.morphTargetInfluences && q.push(_e.name ? _e.name : _e.uuid);
  3210. }) : q.push(H2);
  3211. let pe = Y.array;
  3212. if (Y.normalized) {
  3213. const _e = _o(pe.constructor), ce2 = new Float32Array(pe.length);
  3214. for (let me = 0, he = pe.length; me < he; me++)
  3215. ce2[me] = pe[me] * _e;
  3216. pe = ce2;
  3217. }
  3218. for (let _e = 0, ce2 = q.length; _e < ce2; _e++) {
  3219. const me = new B(q[_e] + "." + sn[F.path], D2.array, pe, K2);
  3220. G.interpolation === "CUBICSPLINE" && (me.createInterpolant = function(ee) {
  3221. const X2 = this instanceof QuaternionKeyframeTrack ? Hp : Za;
  3222. return new X2(this.times, this.values, this.getValueSize() / 3, ee);
  3223. }, me.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true), R.push(me);
  3224. }
  3225. }
  3226. return new AnimationClip(o, void 0, R);
  3227. });
  3228. }
  3229. createNodeMesh(i) {
  3230. const s = this.json, r = this, o = s.nodes[i];
  3231. return o.mesh === void 0 ? null : r.getDependency("mesh", o.mesh).then(function(c) {
  3232. const p2 = r._getNodeRef(r.meshCache, o.mesh, c);
  3233. return o.weights !== void 0 && p2.traverse(function(h2) {
  3234. if (h2.isMesh)
  3235. for (let m = 0, g = o.weights.length; m < g; m++)
  3236. h2.morphTargetInfluences[m] = o.weights[m];
  3237. }), p2;
  3238. });
  3239. }
  3240. /**
  3241. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
  3242. * @param {number} nodeIndex
  3243. * @return {Promise<Object3D>}
  3244. */
  3245. loadNode(i) {
  3246. const s = this.json, r = this, o = s.nodes[i], c = r._loadNodeShallow(i), p2 = [], h2 = o.children || [];
  3247. for (let g = 0, w = h2.length; g < w; g++)
  3248. p2.push(r.getDependency("node", h2[g]));
  3249. const m = o.skin === void 0 ? Promise.resolve(null) : r.getDependency("skin", o.skin);
  3250. return Promise.all([c, Promise.all(p2), m]).then(function(g) {
  3251. const w = g[0], _2 = g[1], y = g[2];
  3252. y !== null && w.traverse(function(C) {
  3253. C.isSkinnedMesh && C.bind(y, Zp);
  3254. });
  3255. for (let C = 0, L = _2.length; C < L; C++)
  3256. w.add(_2[C]);
  3257. return w;
  3258. });
  3259. }
  3260. // ._loadNodeShallow() parses a single node.
  3261. // skin and child nodes are created and added in .loadNode() (no '_' prefix).
  3262. _loadNodeShallow(i) {
  3263. const s = this.json, r = this.extensions, o = this;
  3264. if (this.nodeCache[i] !== void 0)
  3265. return this.nodeCache[i];
  3266. const c = s.nodes[i], p2 = c.name ? o.createUniqueName(c.name) : "", h2 = [], m = o._invokeOne(function(g) {
  3267. return g.createNodeMesh && g.createNodeMesh(i);
  3268. });
  3269. return m && h2.push(m), c.camera !== void 0 && h2.push(o.getDependency("camera", c.camera).then(function(g) {
  3270. return o._getNodeRef(o.cameraCache, c.camera, g);
  3271. })), o._invokeAll(function(g) {
  3272. return g.createNodeAttachment && g.createNodeAttachment(i);
  3273. }).forEach(function(g) {
  3274. h2.push(g);
  3275. }), this.nodeCache[i] = Promise.all(h2).then(function(g) {
  3276. let w;
  3277. if (c.isBone === true ? w = new Bone() : g.length > 1 ? w = new Group() : g.length === 1 ? w = g[0] : w = new Object3D(), w !== g[0])
  3278. for (let _2 = 0, y = g.length; _2 < y; _2++)
  3279. w.add(g[_2]);
  3280. if (c.name && (w.userData.name = c.name, w.name = p2), ln(w, c), c.extensions && qi(r, w, c), c.matrix !== void 0) {
  3281. const _2 = new Matrix4();
  3282. _2.fromArray(c.matrix), w.applyMatrix4(_2);
  3283. } else
  3284. c.translation !== void 0 && w.position.fromArray(c.translation), c.rotation !== void 0 && w.quaternion.fromArray(c.rotation), c.scale !== void 0 && w.scale.fromArray(c.scale);
  3285. return o.associations.has(w) || o.associations.set(w, {}), o.associations.get(w).nodes = i, w;
  3286. }), this.nodeCache[i];
  3287. }
  3288. /**
  3289. * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
  3290. * @param {number} sceneIndex
  3291. * @return {Promise<Group>}
  3292. */
  3293. loadScene(i) {
  3294. const s = this.extensions, r = this.json.scenes[i], o = this, c = new Group();
  3295. r.name && (c.name = o.createUniqueName(r.name)), ln(c, r), r.extensions && qi(s, c, r);
  3296. const p2 = r.nodes || [], h2 = [];
  3297. for (let m = 0, g = p2.length; m < g; m++)
  3298. h2.push(o.getDependency("node", p2[m]));
  3299. return Promise.all(h2).then(function(m) {
  3300. for (let w = 0, _2 = m.length; w < _2; w++)
  3301. c.add(m[w]);
  3302. const g = (w) => {
  3303. const _2 = /* @__PURE__ */ new Map();
  3304. for (const [y, C] of o.associations)
  3305. (y instanceof Material || y instanceof Texture) && _2.set(y, C);
  3306. return w.traverse((y) => {
  3307. const C = o.associations.get(y);
  3308. C != null && _2.set(y, C);
  3309. }), _2;
  3310. };
  3311. return o.associations = g(c), c;
  3312. });
  3313. }
  3314. };
  3315. function Jp(f, i, s) {
  3316. const r = i.attributes, o = new Box3();
  3317. if (r.POSITION !== void 0) {
  3318. const h2 = s.json.accessors[r.POSITION], m = h2.min, g = h2.max;
  3319. if (m !== void 0 && g !== void 0) {
  3320. if (o.set(new Vector3(m[0], m[1], m[2]), new Vector3(g[0], g[1], g[2])), h2.normalized) {
  3321. const w = _o(di[h2.componentType]);
  3322. o.min.multiplyScalar(w), o.max.multiplyScalar(w);
  3323. }
  3324. } else {
  3325. console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
  3326. return;
  3327. }
  3328. } else
  3329. return;
  3330. const c = i.targets;
  3331. if (c !== void 0) {
  3332. const h2 = new Vector3(), m = new Vector3();
  3333. for (let g = 0, w = c.length; g < w; g++) {
  3334. const _2 = c[g];
  3335. if (_2.POSITION !== void 0) {
  3336. const y = s.json.accessors[_2.POSITION], C = y.min, L = y.max;
  3337. if (C !== void 0 && L !== void 0) {
  3338. if (m.setX(Math.max(Math.abs(C[0]), Math.abs(L[0]))), m.setY(Math.max(Math.abs(C[1]), Math.abs(L[1]))), m.setZ(Math.max(Math.abs(C[2]), Math.abs(L[2]))), y.normalized) {
  3339. const S = _o(di[y.componentType]);
  3340. m.multiplyScalar(S);
  3341. }
  3342. h2.max(m);
  3343. } else
  3344. console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
  3345. }
  3346. }
  3347. o.expandByVector(h2);
  3348. }
  3349. f.boundingBox = o;
  3350. const p2 = new Sphere();
  3351. o.getCenter(p2.center), p2.radius = o.min.distanceTo(o.max) / 2, f.boundingSphere = p2;
  3352. }
  3353. function wa(f, i, s) {
  3354. const r = i.attributes, o = [];
  3355. function c(p2, h2) {
  3356. return s.getDependency("accessor", p2).then(function(m) {
  3357. f.setAttribute(h2, m);
  3358. });
  3359. }
  3360. for (const p2 in r) {
  3361. const h2 = go[p2] || p2.toLowerCase();
  3362. h2 in f.attributes || o.push(c(r[p2], h2));
  3363. }
  3364. if (i.indices !== void 0 && !f.index) {
  3365. const p2 = s.getDependency("accessor", i.indices).then(function(h2) {
  3366. f.setIndex(h2);
  3367. });
  3368. o.push(p2);
  3369. }
  3370. return ln(f, i), Jp(f, i, s), Promise.all(o).then(function() {
  3371. return i.targets !== void 0 ? Xp(f, i.targets, s) : f;
  3372. });
  3373. }
  3374. var ya = class extends ExtrudeGeometry {
  3375. constructor(i, s = {}) {
  3376. const {
  3377. bevelEnabled: r = false,
  3378. bevelSize: o = 8,
  3379. bevelThickness: c = 10,
  3380. font: p2,
  3381. height: h2 = 50,
  3382. size: m = 100,
  3383. lineHeight: g = 1,
  3384. letterSpacing: w = 0,
  3385. ..._2
  3386. } = s;
  3387. if (p2 === void 0)
  3388. super();
  3389. else {
  3390. const y = p2.generateShapes(i, m, {
  3391. lineHeight: g,
  3392. letterSpacing: w
  3393. });
  3394. super(y, {
  3395. ..._2,
  3396. bevelEnabled: r,
  3397. bevelSize: o,
  3398. bevelThickness: c,
  3399. depth: h2
  3400. });
  3401. }
  3402. this.type = "TextGeometry";
  3403. }
  3404. };
  3405. function Wa(f, i, s) {
  3406. const r = s.length - f - 1;
  3407. if (i >= s[r])
  3408. return r - 1;
  3409. if (i <= s[f])
  3410. return f;
  3411. let o = f, c = r, p2 = Math.floor((o + c) / 2);
  3412. for (; i < s[p2] || i >= s[p2 + 1]; )
  3413. i < s[p2] ? c = p2 : o = p2, p2 = Math.floor((o + c) / 2);
  3414. return p2;
  3415. }
  3416. function eh(f, i, s, r) {
  3417. const o = [], c = [], p2 = [];
  3418. o[0] = 1;
  3419. for (let h2 = 1; h2 <= s; ++h2) {
  3420. c[h2] = i - r[f + 1 - h2], p2[h2] = r[f + h2] - i;
  3421. let m = 0;
  3422. for (let g = 0; g < h2; ++g) {
  3423. const w = p2[g + 1], _2 = c[h2 - g], y = o[g] / (w + _2);
  3424. o[g] = m + w * y, m = _2 * y;
  3425. }
  3426. o[h2] = m;
  3427. }
  3428. return o;
  3429. }
  3430. function th(f, i, s, r) {
  3431. const o = Wa(f, r, i), c = eh(o, r, f, i), p2 = new Vector4(0, 0, 0, 0);
  3432. for (let h2 = 0; h2 <= f; ++h2) {
  3433. const m = s[o - f + h2], g = c[h2], w = m.w * g;
  3434. p2.x += m.x * w, p2.y += m.y * w, p2.z += m.z * w, p2.w += m.w * g;
  3435. }
  3436. return p2;
  3437. }
  3438. function nh(f, i, s, r, o) {
  3439. const c = [];
  3440. for (let y = 0; y <= s; ++y)
  3441. c[y] = 0;
  3442. const p2 = [];
  3443. for (let y = 0; y <= r; ++y)
  3444. p2[y] = c.slice(0);
  3445. const h2 = [];
  3446. for (let y = 0; y <= s; ++y)
  3447. h2[y] = c.slice(0);
  3448. h2[0][0] = 1;
  3449. const m = c.slice(0), g = c.slice(0);
  3450. for (let y = 1; y <= s; ++y) {
  3451. m[y] = i - o[f + 1 - y], g[y] = o[f + y] - i;
  3452. let C = 0;
  3453. for (let L = 0; L < y; ++L) {
  3454. const S = g[L + 1], R = m[y - L];
  3455. h2[y][L] = S + R;
  3456. const O = h2[L][y - 1] / h2[y][L];
  3457. h2[L][y] = C + S * O, C = R * O;
  3458. }
  3459. h2[y][y] = C;
  3460. }
  3461. for (let y = 0; y <= s; ++y)
  3462. p2[0][y] = h2[y][s];
  3463. for (let y = 0; y <= s; ++y) {
  3464. let C = 0, L = 1;
  3465. const S = [];
  3466. for (let R = 0; R <= s; ++R)
  3467. S[R] = c.slice(0);
  3468. S[0][0] = 1;
  3469. for (let R = 1; R <= r; ++R) {
  3470. let O = 0;
  3471. const N = y - R, I2 = s - R;
  3472. y >= R && (S[L][0] = S[C][0] / h2[I2 + 1][N], O = S[L][0] * h2[N][I2]);
  3473. const D2 = N >= -1 ? 1 : -N, Y = y - 1 <= I2 ? R - 1 : s - y;
  3474. for (let G = D2; G <= Y; ++G)
  3475. S[L][G] = (S[C][G] - S[C][G - 1]) / h2[I2 + 1][N + G], O += S[L][G] * h2[N + G][I2];
  3476. y <= I2 && (S[L][R] = -S[C][R - 1] / h2[I2 + 1][y], O += S[L][R] * h2[y][I2]), p2[R][y] = O;
  3477. var w = C;
  3478. C = L, L = w;
  3479. }
  3480. }
  3481. var _2 = s;
  3482. for (let y = 1; y <= r; ++y) {
  3483. for (let C = 0; C <= s; ++C)
  3484. p2[y][C] *= _2;
  3485. _2 *= s - y;
  3486. }
  3487. return p2;
  3488. }
  3489. function ih(f, i, s, r, o) {
  3490. const c = o < f ? o : f, p2 = [], h2 = Wa(f, r, i), m = nh(h2, r, f, c, i), g = [];
  3491. for (let _2 = 0; _2 < s.length; ++_2) {
  3492. var w = s[_2].clone();
  3493. const y = w.w;
  3494. w.x *= y, w.y *= y, w.z *= y, g[_2] = w;
  3495. }
  3496. for (let _2 = 0; _2 <= c; ++_2) {
  3497. var w = g[h2 - f].clone().multiplyScalar(m[_2][0]);
  3498. for (let C = 1; C <= f; ++C)
  3499. w.add(g[h2 - f + C].clone().multiplyScalar(m[_2][C]));
  3500. p2[_2] = w;
  3501. }
  3502. for (let _2 = c + 1; _2 <= o + 1; ++_2)
  3503. p2[_2] = new Vector4(0, 0, 0);
  3504. return p2;
  3505. }
  3506. function sh(f, i) {
  3507. let s = 1;
  3508. for (let o = 2; o <= f; ++o)
  3509. s *= o;
  3510. let r = 1;
  3511. for (let o = 2; o <= i; ++o)
  3512. r *= o;
  3513. for (let o = 2; o <= f - i; ++o)
  3514. r *= o;
  3515. return s / r;
  3516. }
  3517. function rh(f) {
  3518. const i = f.length, s = [], r = [];
  3519. for (let c = 0; c < i; ++c) {
  3520. const p2 = f[c];
  3521. s[c] = new Vector3(p2.x, p2.y, p2.z), r[c] = p2.w;
  3522. }
  3523. const o = [];
  3524. for (let c = 0; c < i; ++c) {
  3525. const p2 = s[c].clone();
  3526. for (let h2 = 1; h2 <= c; ++h2)
  3527. p2.sub(o[c - h2].clone().multiplyScalar(sh(c, h2) * r[h2]));
  3528. o[c] = p2.divideScalar(r[0]);
  3529. }
  3530. return o;
  3531. }
  3532. function oh(f, i, s, r, o) {
  3533. const c = ih(f, i, s, r, o);
  3534. return rh(c);
  3535. }
  3536. var xa = class extends Curve {
  3537. constructor(i, s, r, o, c) {
  3538. super(), this.degree = i, this.knots = s, this.controlPoints = [], this.startKnot = o || 0, this.endKnot = c || this.knots.length - 1;
  3539. for (let p2 = 0; p2 < r.length; ++p2) {
  3540. const h2 = r[p2];
  3541. this.controlPoints[p2] = new Vector4(h2.x, h2.y, h2.z, h2.w);
  3542. }
  3543. }
  3544. getPoint(i, s) {
  3545. const r = s || new Vector3(), o = this.knots[this.startKnot] + i * (this.knots[this.endKnot] - this.knots[this.startKnot]), c = th(this.degree, this.knots, this.controlPoints, o);
  3546. return c.w != 1 && c.divideScalar(c.w), r.set(c.x, c.y, c.z);
  3547. }
  3548. getTangent(i, s) {
  3549. const r = s || new Vector3(), o = this.knots[0] + i * (this.knots[this.knots.length - 1] - this.knots[0]), c = oh(this.degree, this.knots, this.controlPoints, o, 1);
  3550. return r.copy(c[1]).normalize(), r;
  3551. }
  3552. };
  3553. var se2;
  3554. var Ve;
  3555. var nt2;
  3556. var ah = class extends Loader {
  3557. constructor(i) {
  3558. super(i);
  3559. }
  3560. load(i, s, r, o) {
  3561. const c = this, p2 = c.path === "" ? LoaderUtils.extractUrlBase(i) : c.path, h2 = new FileLoader(this.manager);
  3562. h2.setPath(c.path), h2.setResponseType("arraybuffer"), h2.setRequestHeader(c.requestHeader), h2.setWithCredentials(c.withCredentials), h2.load(i, function(m) {
  3563. try {
  3564. s(c.parse(m, p2));
  3565. } catch (g) {
  3566. o ? o(g) : console.error(g), c.manager.itemError(i);
  3567. }
  3568. }, r, o);
  3569. }
  3570. parse(i, s) {
  3571. if (dh(i))
  3572. se2 = new hh().parse(i);
  3573. else {
  3574. const o = nl(i);
  3575. if (!mh(o))
  3576. throw new Error("THREE.FBXLoader: Unknown format.");
  3577. if (Ca(o) < 7e3)
  3578. throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: " + Ca(o));
  3579. se2 = new ph().parse(o);
  3580. }
  3581. const r = new TextureLoader(this.manager).setPath(this.resourcePath || s).setCrossOrigin(this.crossOrigin);
  3582. return new lh(r, this.manager).parse(se2);
  3583. }
  3584. };
  3585. var lh = class {
  3586. constructor(i, s) {
  3587. this.textureLoader = i, this.manager = s;
  3588. }
  3589. parse() {
  3590. Ve = this.parseConnections();
  3591. const i = this.parseImages(), s = this.parseTextures(i), r = this.parseMaterials(s), o = this.parseDeformers(), c = new ch().parse(o);
  3592. return this.parseScene(o, c, r), nt2;
  3593. }
  3594. // Parses FBXTree.Connections which holds parent-child connections between objects (e.g. material -> texture, model->geometry )
  3595. // and details the connection type
  3596. parseConnections() {
  3597. const i = /* @__PURE__ */ new Map();
  3598. return "Connections" in se2 && se2.Connections.connections.forEach(function(r) {
  3599. const o = r[0], c = r[1], p2 = r[2];
  3600. i.has(o) || i.set(o, {
  3601. parents: [],
  3602. children: []
  3603. });
  3604. const h2 = {
  3605. ID: c,
  3606. relationship: p2
  3607. };
  3608. i.get(o).parents.push(h2), i.has(c) || i.set(c, {
  3609. parents: [],
  3610. children: []
  3611. });
  3612. const m = {
  3613. ID: o,
  3614. relationship: p2
  3615. };
  3616. i.get(c).children.push(m);
  3617. }), i;
  3618. }
  3619. // Parse FBXTree.Objects.Video for embedded image data
  3620. // These images are connected to textures in FBXTree.Objects.Textures
  3621. // via FBXTree.Connections.
  3622. parseImages() {
  3623. const i = {}, s = {};
  3624. if ("Video" in se2.Objects) {
  3625. const r = se2.Objects.Video;
  3626. for (const o in r) {
  3627. const c = r[o], p2 = parseInt(o);
  3628. if (i[p2] = c.RelativeFilename || c.Filename, "Content" in c) {
  3629. const h2 = c.Content instanceof ArrayBuffer && c.Content.byteLength > 0, m = typeof c.Content == "string" && c.Content !== "";
  3630. if (h2 || m) {
  3631. const g = this.parseImage(r[o]);
  3632. s[c.RelativeFilename || c.Filename] = g;
  3633. }
  3634. }
  3635. }
  3636. }
  3637. for (const r in i) {
  3638. const o = i[r];
  3639. s[o] !== void 0 ? i[r] = s[o] : i[r] = i[r].split("\\").pop();
  3640. }
  3641. return i;
  3642. }
  3643. // Parse embedded image data in FBXTree.Video.Content
  3644. parseImage(i) {
  3645. const s = i.Content, r = i.RelativeFilename || i.Filename, o = r.slice(r.lastIndexOf(".") + 1).toLowerCase();
  3646. let c;
  3647. switch (o) {
  3648. case "bmp":
  3649. c = "image/bmp";
  3650. break;
  3651. case "jpg":
  3652. case "jpeg":
  3653. c = "image/jpeg";
  3654. break;
  3655. case "png":
  3656. c = "image/png";
  3657. break;
  3658. case "tif":
  3659. c = "image/tiff";
  3660. break;
  3661. case "tga":
  3662. this.manager.getHandler(".tga") === null && console.warn("FBXLoader: TGA loader not found, skipping ", r), c = "image/tga";
  3663. break;
  3664. default:
  3665. console.warn('FBXLoader: Image type "' + o + '" is not supported.');
  3666. return;
  3667. }
  3668. if (typeof s == "string")
  3669. return "data:" + c + ";base64," + s;
  3670. {
  3671. const p2 = new Uint8Array(s);
  3672. return window.URL.createObjectURL(new Blob([p2], {
  3673. type: c
  3674. }));
  3675. }
  3676. }
  3677. // Parse nodes in FBXTree.Objects.Texture
  3678. // These contain details such as UV scaling, cropping, rotation etc and are connected
  3679. // to images in FBXTree.Objects.Video
  3680. parseTextures(i) {
  3681. const s = /* @__PURE__ */ new Map();
  3682. if ("Texture" in se2.Objects) {
  3683. const r = se2.Objects.Texture;
  3684. for (const o in r) {
  3685. const c = this.parseTexture(r[o], i);
  3686. s.set(parseInt(o), c);
  3687. }
  3688. }
  3689. return s;
  3690. }
  3691. // Parse individual node in FBXTree.Objects.Texture
  3692. parseTexture(i, s) {
  3693. const r = this.loadTexture(i, s);
  3694. r.ID = i.id, r.name = i.attrName;
  3695. const o = i.WrapModeU, c = i.WrapModeV, p2 = o !== void 0 ? o.value : 0, h2 = c !== void 0 ? c.value : 0;
  3696. if (r.wrapS = p2 === 0 ? RepeatWrapping : ClampToEdgeWrapping, r.wrapT = h2 === 0 ? RepeatWrapping : ClampToEdgeWrapping, "Scaling" in i) {
  3697. const m = i.Scaling.value;
  3698. r.repeat.x = m[0], r.repeat.y = m[1];
  3699. }
  3700. return r;
  3701. }
  3702. // load a texture specified as a blob or data URI, or via an external URL using TextureLoader
  3703. loadTexture(i, s) {
  3704. let r;
  3705. const o = this.textureLoader.path, c = Ve.get(i.id).children;
  3706. c !== void 0 && c.length > 0 && s[c[0].ID] !== void 0 && (r = s[c[0].ID], (r.indexOf("blob:") === 0 || r.indexOf("data:") === 0) && this.textureLoader.setPath(void 0));
  3707. let p2;
  3708. const h2 = i.FileName.slice(-3).toLowerCase();
  3709. if (h2 === "tga") {
  3710. const m = this.manager.getHandler(".tga");
  3711. m === null ? (console.warn("FBXLoader: TGA loader not found, creating placeholder texture for", i.RelativeFilename), p2 = new Texture()) : (m.setPath(this.textureLoader.path), p2 = m.load(r));
  3712. } else
  3713. h2 === "psd" ? (console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for", i.RelativeFilename), p2 = new Texture()) : p2 = this.textureLoader.load(r);
  3714. return this.textureLoader.setPath(o), p2;
  3715. }
  3716. // Parse nodes in FBXTree.Objects.Material
  3717. parseMaterials(i) {
  3718. const s = /* @__PURE__ */ new Map();
  3719. if ("Material" in se2.Objects) {
  3720. const r = se2.Objects.Material;
  3721. for (const o in r) {
  3722. const c = this.parseMaterial(r[o], i);
  3723. c !== null && s.set(parseInt(o), c);
  3724. }
  3725. }
  3726. return s;
  3727. }
  3728. // Parse single node in FBXTree.Objects.Material
  3729. // Materials are connected to texture maps in FBXTree.Objects.Textures
  3730. // FBX format currently only supports Lambert and Phong shading models
  3731. parseMaterial(i, s) {
  3732. const r = i.id, o = i.attrName;
  3733. let c = i.ShadingModel;
  3734. if (typeof c == "object" && (c = c.value), !Ve.has(r))
  3735. return null;
  3736. const p2 = this.parseParameters(i, s, r);
  3737. let h2;
  3738. switch (c.toLowerCase()) {
  3739. case "phong":
  3740. h2 = new MeshPhongMaterial();
  3741. break;
  3742. case "lambert":
  3743. h2 = new MeshLambertMaterial();
  3744. break;
  3745. default:
  3746. console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.', c), h2 = new MeshPhongMaterial();
  3747. break;
  3748. }
  3749. return h2.setValues(p2), h2.name = o, h2;
  3750. }
  3751. // Parse FBX material and return parameters suitable for a three.js material
  3752. // Also parse the texture map and return any textures associated with the material
  3753. parseParameters(i, s, r) {
  3754. const o = {};
  3755. i.BumpFactor && (o.bumpScale = i.BumpFactor.value), i.Diffuse ? o.color = new Color().fromArray(i.Diffuse.value) : i.DiffuseColor && (i.DiffuseColor.type === "Color" || i.DiffuseColor.type === "ColorRGB") && (o.color = new Color().fromArray(i.DiffuseColor.value)), i.DisplacementFactor && (o.displacementScale = i.DisplacementFactor.value), i.Emissive ? o.emissive = new Color().fromArray(i.Emissive.value) : i.EmissiveColor && (i.EmissiveColor.type === "Color" || i.EmissiveColor.type === "ColorRGB") && (o.emissive = new Color().fromArray(i.EmissiveColor.value)), i.EmissiveFactor && (o.emissiveIntensity = parseFloat(i.EmissiveFactor.value)), i.Opacity && (o.opacity = parseFloat(i.Opacity.value)), o.opacity < 1 && (o.transparent = true), i.ReflectionFactor && (o.reflectivity = i.ReflectionFactor.value), i.Shininess && (o.shininess = i.Shininess.value), i.Specular ? o.specular = new Color().fromArray(i.Specular.value) : i.SpecularColor && i.SpecularColor.type === "Color" && (o.specular = new Color().fromArray(i.SpecularColor.value));
  3756. const c = this;
  3757. return Ve.get(r).children.forEach(function(p2) {
  3758. const h2 = p2.relationship;
  3759. switch (h2) {
  3760. case "Bump":
  3761. o.bumpMap = c.getTexture(s, p2.ID);
  3762. break;
  3763. case "Maya|TEX_ao_map":
  3764. o.aoMap = c.getTexture(s, p2.ID);
  3765. break;
  3766. case "DiffuseColor":
  3767. case "Maya|TEX_color_map":
  3768. o.map = c.getTexture(s, p2.ID), o.map !== void 0 && (o.map.encoding = sRGBEncoding);
  3769. break;
  3770. case "DisplacementColor":
  3771. o.displacementMap = c.getTexture(s, p2.ID);
  3772. break;
  3773. case "EmissiveColor":
  3774. o.emissiveMap = c.getTexture(s, p2.ID), o.emissiveMap !== void 0 && (o.emissiveMap.encoding = sRGBEncoding);
  3775. break;
  3776. case "NormalMap":
  3777. case "Maya|TEX_normal_map":
  3778. o.normalMap = c.getTexture(s, p2.ID);
  3779. break;
  3780. case "ReflectionColor":
  3781. o.envMap = c.getTexture(s, p2.ID), o.envMap !== void 0 && (o.envMap.mapping = EquirectangularReflectionMapping, o.envMap.encoding = sRGBEncoding);
  3782. break;
  3783. case "SpecularColor":
  3784. o.specularMap = c.getTexture(s, p2.ID), o.specularMap !== void 0 && (o.specularMap.encoding = sRGBEncoding);
  3785. break;
  3786. case "TransparentColor":
  3787. case "TransparencyFactor":
  3788. o.alphaMap = c.getTexture(s, p2.ID), o.transparent = true;
  3789. break;
  3790. case "AmbientColor":
  3791. case "ShininessExponent":
  3792. case "SpecularFactor":
  3793. case "VectorDisplacementColor":
  3794. default:
  3795. console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.", h2);
  3796. break;
  3797. }
  3798. }), o;
  3799. }
  3800. // get a texture from the textureMap for use by a material.
  3801. getTexture(i, s) {
  3802. return "LayeredTexture" in se2.Objects && s in se2.Objects.LayeredTexture && (console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."), s = Ve.get(s).children[0].ID), i.get(s);
  3803. }
  3804. // Parse nodes in FBXTree.Objects.Deformer
  3805. // Deformer node can contain skinning or Vertex Cache animation data, however only skinning is supported here
  3806. // Generates map of Skeleton-like objects for use later when generating and binding skeletons.
  3807. parseDeformers() {
  3808. const i = {}, s = {};
  3809. if ("Deformer" in se2.Objects) {
  3810. const r = se2.Objects.Deformer;
  3811. for (const o in r) {
  3812. const c = r[o], p2 = Ve.get(parseInt(o));
  3813. if (c.attrType === "Skin") {
  3814. const h2 = this.parseSkeleton(p2, r);
  3815. h2.ID = o, p2.parents.length > 1 && console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."), h2.geometryID = p2.parents[0].ID, i[o] = h2;
  3816. } else if (c.attrType === "BlendShape") {
  3817. const h2 = {
  3818. id: o
  3819. };
  3820. h2.rawTargets = this.parseMorphTargets(p2, r), h2.id = o, p2.parents.length > 1 && console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."), s[o] = h2;
  3821. }
  3822. }
  3823. }
  3824. return {
  3825. skeletons: i,
  3826. morphTargets: s
  3827. };
  3828. }
  3829. // Parse single nodes in FBXTree.Objects.Deformer
  3830. // The top level skeleton node has type 'Skin' and sub nodes have type 'Cluster'
  3831. // Each skin node represents a skeleton and each cluster node represents a bone
  3832. parseSkeleton(i, s) {
  3833. const r = [];
  3834. return i.children.forEach(function(o) {
  3835. const c = s[o.ID];
  3836. if (c.attrType !== "Cluster")
  3837. return;
  3838. const p2 = {
  3839. ID: o.ID,
  3840. indices: [],
  3841. weights: [],
  3842. transformLink: new Matrix4().fromArray(c.TransformLink.a)
  3843. // transform: new Matrix4().fromArray( boneNode.Transform.a ),
  3844. // linkMode: boneNode.Mode,
  3845. };
  3846. "Indexes" in c && (p2.indices = c.Indexes.a, p2.weights = c.Weights.a), r.push(p2);
  3847. }), {
  3848. rawBones: r,
  3849. bones: []
  3850. };
  3851. }
  3852. // The top level morph deformer node has type "BlendShape" and sub nodes have type "BlendShapeChannel"
  3853. parseMorphTargets(i, s) {
  3854. const r = [];
  3855. for (let o = 0; o < i.children.length; o++) {
  3856. const c = i.children[o], p2 = s[c.ID], h2 = {
  3857. name: p2.attrName,
  3858. initialWeight: p2.DeformPercent,
  3859. id: p2.id,
  3860. fullWeights: p2.FullWeights.a
  3861. };
  3862. if (p2.attrType !== "BlendShapeChannel")
  3863. return;
  3864. h2.geoID = Ve.get(parseInt(c.ID)).children.filter(function(m) {
  3865. return m.relationship === void 0;
  3866. })[0].ID, r.push(h2);
  3867. }
  3868. return r;
  3869. }
  3870. // create the main Group() to be returned by the loader
  3871. parseScene(i, s, r) {
  3872. nt2 = new Group();
  3873. const o = this.parseModels(i.skeletons, s, r), c = se2.Objects.Model, p2 = this;
  3874. o.forEach(function(m) {
  3875. const g = c[m.ID];
  3876. p2.setLookAtProperties(m, g), Ve.get(m.ID).parents.forEach(function(_2) {
  3877. const y = o.get(_2.ID);
  3878. y !== void 0 && y.add(m);
  3879. }), m.parent === null && nt2.add(m);
  3880. }), this.bindSkeleton(i.skeletons, s, o), this.createAmbientLight(), nt2.traverse(function(m) {
  3881. if (m.userData.transformData) {
  3882. m.parent && (m.userData.transformData.parentMatrix = m.parent.matrix, m.userData.transformData.parentMatrixWorld = m.parent.matrixWorld);
  3883. const g = el(m.userData.transformData);
  3884. m.applyMatrix4(g), m.updateWorldMatrix();
  3885. }
  3886. });
  3887. const h2 = new uh().parse();
  3888. nt2.children.length === 1 && nt2.children[0].isGroup && (nt2.children[0].animations = h2, nt2 = nt2.children[0]), nt2.animations = h2;
  3889. }
  3890. // parse nodes in FBXTree.Objects.Model
  3891. parseModels(i, s, r) {
  3892. const o = /* @__PURE__ */ new Map(), c = se2.Objects.Model;
  3893. for (const p2 in c) {
  3894. const h2 = parseInt(p2), m = c[p2], g = Ve.get(h2);
  3895. let w = this.buildSkeleton(g, i, h2, m.attrName);
  3896. if (!w) {
  3897. switch (m.attrType) {
  3898. case "Camera":
  3899. w = this.createCamera(g);
  3900. break;
  3901. case "Light":
  3902. w = this.createLight(g);
  3903. break;
  3904. case "Mesh":
  3905. w = this.createMesh(g, s, r);
  3906. break;
  3907. case "NurbsCurve":
  3908. w = this.createCurve(g, s);
  3909. break;
  3910. case "LimbNode":
  3911. case "Root":
  3912. w = new Bone();
  3913. break;
  3914. case "Null":
  3915. default:
  3916. w = new Group();
  3917. break;
  3918. }
  3919. w.name = m.attrName ? PropertyBinding.sanitizeNodeName(m.attrName) : "", w.ID = h2;
  3920. }
  3921. this.getTransformData(w, m), o.set(h2, w);
  3922. }
  3923. return o;
  3924. }
  3925. buildSkeleton(i, s, r, o) {
  3926. let c = null;
  3927. return i.parents.forEach(function(p2) {
  3928. for (const h2 in s) {
  3929. const m = s[h2];
  3930. m.rawBones.forEach(function(g, w) {
  3931. if (g.ID === p2.ID) {
  3932. const _2 = c;
  3933. c = new Bone(), c.matrixWorld.copy(g.transformLink), c.name = o ? PropertyBinding.sanitizeNodeName(o) : "", c.ID = r, m.bones[w] = c, _2 !== null && c.add(_2);
  3934. }
  3935. });
  3936. }
  3937. }), c;
  3938. }
  3939. // create a PerspectiveCamera or OrthographicCamera
  3940. createCamera(i) {
  3941. let s, r;
  3942. if (i.children.forEach(function(o) {
  3943. const c = se2.Objects.NodeAttribute[o.ID];
  3944. c !== void 0 && (r = c);
  3945. }), r === void 0)
  3946. s = new Object3D();
  3947. else {
  3948. let o = 0;
  3949. r.CameraProjectionType !== void 0 && r.CameraProjectionType.value === 1 && (o = 1);
  3950. let c = 1;
  3951. r.NearPlane !== void 0 && (c = r.NearPlane.value / 1e3);
  3952. let p2 = 1e3;
  3953. r.FarPlane !== void 0 && (p2 = r.FarPlane.value / 1e3);
  3954. let h2 = window.innerWidth, m = window.innerHeight;
  3955. r.AspectWidth !== void 0 && r.AspectHeight !== void 0 && (h2 = r.AspectWidth.value, m = r.AspectHeight.value);
  3956. const g = h2 / m;
  3957. let w = 45;
  3958. r.FieldOfView !== void 0 && (w = r.FieldOfView.value);
  3959. const _2 = r.FocalLength ? r.FocalLength.value : null;
  3960. switch (o) {
  3961. case 0:
  3962. s = new PerspectiveCamera(w, g, c, p2), _2 !== null && s.setFocalLength(_2);
  3963. break;
  3964. case 1:
  3965. s = new OrthographicCamera(-h2 / 2, h2 / 2, m / 2, -m / 2, c, p2);
  3966. break;
  3967. default:
  3968. console.warn("THREE.FBXLoader: Unknown camera type " + o + "."), s = new Object3D();
  3969. break;
  3970. }
  3971. }
  3972. return s;
  3973. }
  3974. // Create a DirectionalLight, PointLight or SpotLight
  3975. createLight(i) {
  3976. let s, r;
  3977. if (i.children.forEach(function(o) {
  3978. const c = se2.Objects.NodeAttribute[o.ID];
  3979. c !== void 0 && (r = c);
  3980. }), r === void 0)
  3981. s = new Object3D();
  3982. else {
  3983. let o;
  3984. r.LightType === void 0 ? o = 0 : o = r.LightType.value;
  3985. let c = 16777215;
  3986. r.Color !== void 0 && (c = new Color().fromArray(r.Color.value));
  3987. let p2 = r.Intensity === void 0 ? 1 : r.Intensity.value / 100;
  3988. r.CastLightOnObject !== void 0 && r.CastLightOnObject.value === 0 && (p2 = 0);
  3989. let h2 = 0;
  3990. r.FarAttenuationEnd !== void 0 && (r.EnableFarAttenuation !== void 0 && r.EnableFarAttenuation.value === 0 ? h2 = 0 : h2 = r.FarAttenuationEnd.value);
  3991. const m = 1;
  3992. switch (o) {
  3993. case 0:
  3994. s = new PointLight(c, p2, h2, m);
  3995. break;
  3996. case 1:
  3997. s = new DirectionalLight(c, p2);
  3998. break;
  3999. case 2:
  4000. let g = Math.PI / 3;
  4001. r.InnerAngle !== void 0 && (g = MathUtils.degToRad(r.InnerAngle.value));
  4002. let w = 0;
  4003. r.OuterAngle !== void 0 && (w = MathUtils.degToRad(r.OuterAngle.value), w = Math.max(w, 1)), s = new SpotLight(c, p2, h2, g, w, m);
  4004. break;
  4005. default:
  4006. console.warn("THREE.FBXLoader: Unknown light type " + r.LightType.value + ", defaulting to a PointLight."), s = new PointLight(c, p2);
  4007. break;
  4008. }
  4009. r.CastShadows !== void 0 && r.CastShadows.value === 1 && (s.castShadow = true);
  4010. }
  4011. return s;
  4012. }
  4013. createMesh(i, s, r) {
  4014. let o, c = null, p2 = null;
  4015. const h2 = [];
  4016. return i.children.forEach(function(m) {
  4017. s.has(m.ID) && (c = s.get(m.ID)), r.has(m.ID) && h2.push(r.get(m.ID));
  4018. }), h2.length > 1 ? p2 = h2 : h2.length > 0 ? p2 = h2[0] : (p2 = new MeshPhongMaterial({
  4019. color: 13421772
  4020. }), h2.push(p2)), "color" in c.attributes && h2.forEach(function(m) {
  4021. m.vertexColors = true;
  4022. }), c.FBX_Deformer ? (o = new SkinnedMesh(c, p2), o.normalizeSkinWeights()) : o = new Mesh(c, p2), o;
  4023. }
  4024. createCurve(i, s) {
  4025. const r = i.children.reduce(function(c, p2) {
  4026. return s.has(p2.ID) && (c = s.get(p2.ID)), c;
  4027. }, null), o = new LineBasicMaterial({
  4028. color: 3342591,
  4029. linewidth: 1
  4030. });
  4031. return new Line(r, o);
  4032. }
  4033. // parse the model node for transform data
  4034. getTransformData(i, s) {
  4035. const r = {};
  4036. "InheritType" in s && (r.inheritType = parseInt(s.InheritType.value)), "RotationOrder" in s ? r.eulerOrder = tl(s.RotationOrder.value) : r.eulerOrder = "ZYX", "Lcl_Translation" in s && (r.translation = s.Lcl_Translation.value), "PreRotation" in s && (r.preRotation = s.PreRotation.value), "Lcl_Rotation" in s && (r.rotation = s.Lcl_Rotation.value), "PostRotation" in s && (r.postRotation = s.PostRotation.value), "Lcl_Scaling" in s && (r.scale = s.Lcl_Scaling.value), "ScalingOffset" in s && (r.scalingOffset = s.ScalingOffset.value), "ScalingPivot" in s && (r.scalingPivot = s.ScalingPivot.value), "RotationOffset" in s && (r.rotationOffset = s.RotationOffset.value), "RotationPivot" in s && (r.rotationPivot = s.RotationPivot.value), i.userData.transformData = r;
  4037. }
  4038. setLookAtProperties(i, s) {
  4039. "LookAtProperty" in s && Ve.get(i.ID).children.forEach(function(o) {
  4040. if (o.relationship === "LookAtProperty") {
  4041. const c = se2.Objects.Model[o.ID];
  4042. if ("Lcl_Translation" in c) {
  4043. const p2 = c.Lcl_Translation.value;
  4044. i.target !== void 0 ? (i.target.position.fromArray(p2), nt2.add(i.target)) : i.lookAt(new Vector3().fromArray(p2));
  4045. }
  4046. }
  4047. });
  4048. }
  4049. bindSkeleton(i, s, r) {
  4050. const o = this.parsePoseNodes();
  4051. for (const c in i) {
  4052. const p2 = i[c];
  4053. Ve.get(parseInt(p2.ID)).parents.forEach(function(m) {
  4054. if (s.has(m.ID)) {
  4055. const g = m.ID;
  4056. Ve.get(g).parents.forEach(function(_2) {
  4057. r.has(_2.ID) && r.get(_2.ID).bind(new Skeleton(p2.bones), o[_2.ID]);
  4058. });
  4059. }
  4060. });
  4061. }
  4062. }
  4063. parsePoseNodes() {
  4064. const i = {};
  4065. if ("Pose" in se2.Objects) {
  4066. const s = se2.Objects.Pose;
  4067. for (const r in s)
  4068. if (s[r].attrType === "BindPose" && s[r].NbPoseNodes > 0) {
  4069. const o = s[r].PoseNode;
  4070. Array.isArray(o) ? o.forEach(function(c) {
  4071. i[c.Node] = new Matrix4().fromArray(c.Matrix.a);
  4072. }) : i[o.Node] = new Matrix4().fromArray(o.Matrix.a);
  4073. }
  4074. }
  4075. return i;
  4076. }
  4077. // Parse ambient color in FBXTree.GlobalSettings - if it's not set to black (default), create an ambient light
  4078. createAmbientLight() {
  4079. if ("GlobalSettings" in se2 && "AmbientColor" in se2.GlobalSettings) {
  4080. const i = se2.GlobalSettings.AmbientColor.value, s = i[0], r = i[1], o = i[2];
  4081. if (s !== 0 || r !== 0 || o !== 0) {
  4082. const c = new Color(s, r, o);
  4083. nt2.add(new AmbientLight(c, 1));
  4084. }
  4085. }
  4086. }
  4087. };
  4088. var ch = class {
  4089. // Parse nodes in FBXTree.Objects.Geometry
  4090. parse(i) {
  4091. const s = /* @__PURE__ */ new Map();
  4092. if ("Geometry" in se2.Objects) {
  4093. const r = se2.Objects.Geometry;
  4094. for (const o in r) {
  4095. const c = Ve.get(parseInt(o)), p2 = this.parseGeometry(c, r[o], i);
  4096. s.set(parseInt(o), p2);
  4097. }
  4098. }
  4099. return s;
  4100. }
  4101. // Parse single node in FBXTree.Objects.Geometry
  4102. parseGeometry(i, s, r) {
  4103. switch (s.attrType) {
  4104. case "Mesh":
  4105. return this.parseMeshGeometry(i, s, r);
  4106. case "NurbsCurve":
  4107. return this.parseNurbsGeometry(s);
  4108. }
  4109. }
  4110. // Parse single node mesh geometry in FBXTree.Objects.Geometry
  4111. parseMeshGeometry(i, s, r) {
  4112. const o = r.skeletons, c = [], p2 = i.parents.map(function(_2) {
  4113. return se2.Objects.Model[_2.ID];
  4114. });
  4115. if (p2.length === 0)
  4116. return;
  4117. const h2 = i.children.reduce(function(_2, y) {
  4118. return o[y.ID] !== void 0 && (_2 = o[y.ID]), _2;
  4119. }, null);
  4120. i.children.forEach(function(_2) {
  4121. r.morphTargets[_2.ID] !== void 0 && c.push(r.morphTargets[_2.ID]);
  4122. });
  4123. const m = p2[0], g = {};
  4124. "RotationOrder" in m && (g.eulerOrder = tl(m.RotationOrder.value)), "InheritType" in m && (g.inheritType = parseInt(m.InheritType.value)), "GeometricTranslation" in m && (g.translation = m.GeometricTranslation.value), "GeometricRotation" in m && (g.rotation = m.GeometricRotation.value), "GeometricScaling" in m && (g.scale = m.GeometricScaling.value);
  4125. const w = el(g);
  4126. return this.genGeometry(s, h2, c, w);
  4127. }
  4128. // Generate a BufferGeometry from a node in FBXTree.Objects.Geometry
  4129. genGeometry(i, s, r, o) {
  4130. const c = new BufferGeometry();
  4131. i.attrName && (c.name = i.attrName);
  4132. const p2 = this.parseGeoNode(i, s), h2 = this.genBuffers(p2), m = new Float32BufferAttribute(h2.vertex, 3);
  4133. if (m.applyMatrix4(o), c.setAttribute("position", m), h2.colors.length > 0 && c.setAttribute("color", new Float32BufferAttribute(h2.colors, 3)), s && (c.setAttribute("skinIndex", new Uint16BufferAttribute(h2.weightsIndices, 4)), c.setAttribute("skinWeight", new Float32BufferAttribute(h2.vertexWeights, 4)), c.FBX_Deformer = s), h2.normal.length > 0) {
  4134. const g = new Matrix3().getNormalMatrix(o), w = new Float32BufferAttribute(h2.normal, 3);
  4135. w.applyNormalMatrix(g), c.setAttribute("normal", w);
  4136. }
  4137. if (h2.uvs.forEach(function(g, w) {
  4138. let _2 = "uv" + (w + 1).toString();
  4139. w === 0 && (_2 = "uv"), c.setAttribute(_2, new Float32BufferAttribute(h2.uvs[w], 2));
  4140. }), p2.material && p2.material.mappingType !== "AllSame") {
  4141. let g = h2.materialIndex[0], w = 0;
  4142. if (h2.materialIndex.forEach(function(_2, y) {
  4143. _2 !== g && (c.addGroup(w, y - w, g), g = _2, w = y);
  4144. }), c.groups.length > 0) {
  4145. const _2 = c.groups[c.groups.length - 1], y = _2.start + _2.count;
  4146. y !== h2.materialIndex.length && c.addGroup(y, h2.materialIndex.length - y, g);
  4147. }
  4148. c.groups.length === 0 && c.addGroup(0, h2.materialIndex.length, h2.materialIndex[0]);
  4149. }
  4150. return this.addMorphTargets(c, i, r, o), c;
  4151. }
  4152. parseGeoNode(i, s) {
  4153. const r = {};
  4154. if (r.vertexPositions = i.Vertices !== void 0 ? i.Vertices.a : [], r.vertexIndices = i.PolygonVertexIndex !== void 0 ? i.PolygonVertexIndex.a : [], i.LayerElementColor && (r.color = this.parseVertexColors(i.LayerElementColor[0])), i.LayerElementMaterial && (r.material = this.parseMaterialIndices(i.LayerElementMaterial[0])), i.LayerElementNormal && (r.normal = this.parseNormals(i.LayerElementNormal[0])), i.LayerElementUV) {
  4155. r.uv = [];
  4156. let o = 0;
  4157. for (; i.LayerElementUV[o]; )
  4158. i.LayerElementUV[o].UV && r.uv.push(this.parseUVs(i.LayerElementUV[o])), o++;
  4159. }
  4160. return r.weightTable = {}, s !== null && (r.skeleton = s, s.rawBones.forEach(function(o, c) {
  4161. o.indices.forEach(function(p2, h2) {
  4162. r.weightTable[p2] === void 0 && (r.weightTable[p2] = []), r.weightTable[p2].push({
  4163. id: c,
  4164. weight: o.weights[h2]
  4165. });
  4166. });
  4167. })), r;
  4168. }
  4169. genBuffers(i) {
  4170. const s = {
  4171. vertex: [],
  4172. normal: [],
  4173. colors: [],
  4174. uvs: [],
  4175. materialIndex: [],
  4176. vertexWeights: [],
  4177. weightsIndices: []
  4178. };
  4179. let r = 0, o = 0, c = false, p2 = [], h2 = [], m = [], g = [], w = [], _2 = [];
  4180. const y = this;
  4181. return i.vertexIndices.forEach(function(C, L) {
  4182. let S, R = false;
  4183. C < 0 && (C = C ^ -1, R = true);
  4184. let O = [], N = [];
  4185. if (p2.push(C * 3, C * 3 + 1, C * 3 + 2), i.color) {
  4186. const I2 = js(L, r, C, i.color);
  4187. m.push(I2[0], I2[1], I2[2]);
  4188. }
  4189. if (i.skeleton) {
  4190. if (i.weightTable[C] !== void 0 && i.weightTable[C].forEach(function(I2) {
  4191. N.push(I2.weight), O.push(I2.id);
  4192. }), N.length > 4) {
  4193. c || (console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."), c = true);
  4194. const I2 = [0, 0, 0, 0], D2 = [0, 0, 0, 0];
  4195. N.forEach(function(Y, G) {
  4196. let F = Y, B = O[G];
  4197. D2.forEach(function(H2, K2, q) {
  4198. if (F > H2) {
  4199. q[K2] = F, F = H2;
  4200. const pe = I2[K2];
  4201. I2[K2] = B, B = pe;
  4202. }
  4203. });
  4204. }), O = I2, N = D2;
  4205. }
  4206. for (; N.length < 4; )
  4207. N.push(0), O.push(0);
  4208. for (let I2 = 0; I2 < 4; ++I2)
  4209. w.push(N[I2]), _2.push(O[I2]);
  4210. }
  4211. if (i.normal) {
  4212. const I2 = js(L, r, C, i.normal);
  4213. h2.push(I2[0], I2[1], I2[2]);
  4214. }
  4215. i.material && i.material.mappingType !== "AllSame" && (S = js(L, r, C, i.material)[0]), i.uv && i.uv.forEach(function(I2, D2) {
  4216. const Y = js(L, r, C, I2);
  4217. g[D2] === void 0 && (g[D2] = []), g[D2].push(Y[0]), g[D2].push(Y[1]);
  4218. }), o++, R && (y.genFace(s, i, p2, S, h2, m, g, w, _2, o), r++, o = 0, p2 = [], h2 = [], m = [], g = [], w = [], _2 = []);
  4219. }), s;
  4220. }
  4221. // Generate data for a single face in a geometry. If the face is a quad then split it into 2 tris
  4222. genFace(i, s, r, o, c, p2, h2, m, g, w) {
  4223. for (let _2 = 2; _2 < w; _2++)
  4224. i.vertex.push(s.vertexPositions[r[0]]), i.vertex.push(s.vertexPositions[r[1]]), i.vertex.push(s.vertexPositions[r[2]]), i.vertex.push(s.vertexPositions[r[(_2 - 1) * 3]]), i.vertex.push(s.vertexPositions[r[(_2 - 1) * 3 + 1]]), i.vertex.push(s.vertexPositions[r[(_2 - 1) * 3 + 2]]), i.vertex.push(s.vertexPositions[r[_2 * 3]]), i.vertex.push(s.vertexPositions[r[_2 * 3 + 1]]), i.vertex.push(s.vertexPositions[r[_2 * 3 + 2]]), s.skeleton && (i.vertexWeights.push(m[0]), i.vertexWeights.push(m[1]), i.vertexWeights.push(m[2]), i.vertexWeights.push(m[3]), i.vertexWeights.push(m[(_2 - 1) * 4]), i.vertexWeights.push(m[(_2 - 1) * 4 + 1]), i.vertexWeights.push(m[(_2 - 1) * 4 + 2]), i.vertexWeights.push(m[(_2 - 1) * 4 + 3]), i.vertexWeights.push(m[_2 * 4]), i.vertexWeights.push(m[_2 * 4 + 1]), i.vertexWeights.push(m[_2 * 4 + 2]), i.vertexWeights.push(m[_2 * 4 + 3]), i.weightsIndices.push(g[0]), i.weightsIndices.push(g[1]), i.weightsIndices.push(g[2]), i.weightsIndices.push(g[3]), i.weightsIndices.push(g[(_2 - 1) * 4]), i.weightsIndices.push(g[(_2 - 1) * 4 + 1]), i.weightsIndices.push(g[(_2 - 1) * 4 + 2]), i.weightsIndices.push(g[(_2 - 1) * 4 + 3]), i.weightsIndices.push(g[_2 * 4]), i.weightsIndices.push(g[_2 * 4 + 1]), i.weightsIndices.push(g[_2 * 4 + 2]), i.weightsIndices.push(g[_2 * 4 + 3])), s.color && (i.colors.push(p2[0]), i.colors.push(p2[1]), i.colors.push(p2[2]), i.colors.push(p2[(_2 - 1) * 3]), i.colors.push(p2[(_2 - 1) * 3 + 1]), i.colors.push(p2[(_2 - 1) * 3 + 2]), i.colors.push(p2[_2 * 3]), i.colors.push(p2[_2 * 3 + 1]), i.colors.push(p2[_2 * 3 + 2])), s.material && s.material.mappingType !== "AllSame" && (i.materialIndex.push(o), i.materialIndex.push(o), i.materialIndex.push(o)), s.normal && (i.normal.push(c[0]), i.normal.push(c[1]), i.normal.push(c[2]), i.normal.push(c[(_2 - 1) * 3]), i.normal.push(c[(_2 - 1) * 3 + 1]), i.normal.push(c[(_2 - 1) * 3 + 2]), i.normal.push(c[_2 * 3]), i.normal.push(c[_2 * 3 + 1]), i.normal.push(c[_2 * 3 + 2])), s.uv && s.uv.forEach(function(y, C) {
  4225. i.uvs[C] === void 0 && (i.uvs[C] = []), i.uvs[C].push(h2[C][0]), i.uvs[C].push(h2[C][1]), i.uvs[C].push(h2[C][(_2 - 1) * 2]), i.uvs[C].push(h2[C][(_2 - 1) * 2 + 1]), i.uvs[C].push(h2[C][_2 * 2]), i.uvs[C].push(h2[C][_2 * 2 + 1]);
  4226. });
  4227. }
  4228. addMorphTargets(i, s, r, o) {
  4229. if (r.length === 0)
  4230. return;
  4231. i.morphTargetsRelative = true, i.morphAttributes.position = [];
  4232. const c = this;
  4233. r.forEach(function(p2) {
  4234. p2.rawTargets.forEach(function(h2) {
  4235. const m = se2.Objects.Geometry[h2.geoID];
  4236. m !== void 0 && c.genMorphGeometry(i, s, m, o, h2.name);
  4237. });
  4238. });
  4239. }
  4240. // a morph geometry node is similar to a standard node, and the node is also contained
  4241. // in FBXTree.Objects.Geometry, however it can only have attributes for position, normal
  4242. // and a special attribute Index defining which vertices of the original geometry are affected
  4243. // Normal and position attributes only have data for the vertices that are affected by the morph
  4244. genMorphGeometry(i, s, r, o, c) {
  4245. const p2 = s.PolygonVertexIndex !== void 0 ? s.PolygonVertexIndex.a : [], h2 = r.Vertices !== void 0 ? r.Vertices.a : [], m = r.Indexes !== void 0 ? r.Indexes.a : [], g = i.attributes.position.count * 3, w = new Float32Array(g);
  4246. for (let L = 0; L < m.length; L++) {
  4247. const S = m[L] * 3;
  4248. w[S] = h2[L * 3], w[S + 1] = h2[L * 3 + 1], w[S + 2] = h2[L * 3 + 2];
  4249. }
  4250. const _2 = {
  4251. vertexIndices: p2,
  4252. vertexPositions: w
  4253. }, y = this.genBuffers(_2), C = new Float32BufferAttribute(y.vertex, 3);
  4254. C.name = c || r.attrName, C.applyMatrix4(o), i.morphAttributes.position.push(C);
  4255. }
  4256. // Parse normal from FBXTree.Objects.Geometry.LayerElementNormal if it exists
  4257. parseNormals(i) {
  4258. const s = i.MappingInformationType, r = i.ReferenceInformationType, o = i.Normals.a;
  4259. let c = [];
  4260. return r === "IndexToDirect" && ("NormalIndex" in i ? c = i.NormalIndex.a : "NormalsIndex" in i && (c = i.NormalsIndex.a)), {
  4261. dataSize: 3,
  4262. buffer: o,
  4263. indices: c,
  4264. mappingType: s,
  4265. referenceType: r
  4266. };
  4267. }
  4268. // Parse UVs from FBXTree.Objects.Geometry.LayerElementUV if it exists
  4269. parseUVs(i) {
  4270. const s = i.MappingInformationType, r = i.ReferenceInformationType, o = i.UV.a;
  4271. let c = [];
  4272. return r === "IndexToDirect" && (c = i.UVIndex.a), {
  4273. dataSize: 2,
  4274. buffer: o,
  4275. indices: c,
  4276. mappingType: s,
  4277. referenceType: r
  4278. };
  4279. }
  4280. // Parse Vertex Colors from FBXTree.Objects.Geometry.LayerElementColor if it exists
  4281. parseVertexColors(i) {
  4282. const s = i.MappingInformationType, r = i.ReferenceInformationType, o = i.Colors.a;
  4283. let c = [];
  4284. return r === "IndexToDirect" && (c = i.ColorIndex.a), {
  4285. dataSize: 4,
  4286. buffer: o,
  4287. indices: c,
  4288. mappingType: s,
  4289. referenceType: r
  4290. };
  4291. }
  4292. // Parse mapping and material data in FBXTree.Objects.Geometry.LayerElementMaterial if it exists
  4293. parseMaterialIndices(i) {
  4294. const s = i.MappingInformationType, r = i.ReferenceInformationType;
  4295. if (s === "NoMappingInformation")
  4296. return {
  4297. dataSize: 1,
  4298. buffer: [0],
  4299. indices: [0],
  4300. mappingType: "AllSame",
  4301. referenceType: r
  4302. };
  4303. const o = i.Materials.a, c = [];
  4304. for (let p2 = 0; p2 < o.length; ++p2)
  4305. c.push(p2);
  4306. return {
  4307. dataSize: 1,
  4308. buffer: o,
  4309. indices: c,
  4310. mappingType: s,
  4311. referenceType: r
  4312. };
  4313. }
  4314. // Generate a NurbGeometry from a node in FBXTree.Objects.Geometry
  4315. parseNurbsGeometry(i) {
  4316. if (xa === void 0)
  4317. return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."), new BufferGeometry();
  4318. const s = parseInt(i.Order);
  4319. if (isNaN(s))
  4320. return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s", i.Order, i.id), new BufferGeometry();
  4321. const r = s - 1, o = i.KnotVector.a, c = [], p2 = i.Points.a;
  4322. for (let _2 = 0, y = p2.length; _2 < y; _2 += 4)
  4323. c.push(new Vector4().fromArray(p2, _2));
  4324. let h2, m;
  4325. if (i.Form === "Closed")
  4326. c.push(c[0]);
  4327. else if (i.Form === "Periodic") {
  4328. h2 = r, m = o.length - 1 - h2;
  4329. for (let _2 = 0; _2 < r; ++_2)
  4330. c.push(c[_2]);
  4331. }
  4332. const w = new xa(r, o, c, h2, m).getPoints(c.length * 12);
  4333. return new BufferGeometry().setFromPoints(w);
  4334. }
  4335. };
  4336. var uh = class {
  4337. // take raw animation clips and turn them into three.js animation clips
  4338. parse() {
  4339. const i = [], s = this.parseClips();
  4340. if (s !== void 0)
  4341. for (const r in s) {
  4342. const o = s[r], c = this.addClip(o);
  4343. i.push(c);
  4344. }
  4345. return i;
  4346. }
  4347. parseClips() {
  4348. if (se2.Objects.AnimationCurve === void 0)
  4349. return;
  4350. const i = this.parseAnimationCurveNodes();
  4351. this.parseAnimationCurves(i);
  4352. const s = this.parseAnimationLayers(i);
  4353. return this.parseAnimStacks(s);
  4354. }
  4355. // parse nodes in FBXTree.Objects.AnimationCurveNode
  4356. // each AnimationCurveNode holds data for an animation transform for a model (e.g. left arm rotation )
  4357. // and is referenced by an AnimationLayer
  4358. parseAnimationCurveNodes() {
  4359. const i = se2.Objects.AnimationCurveNode, s = /* @__PURE__ */ new Map();
  4360. for (const r in i) {
  4361. const o = i[r];
  4362. if (o.attrName.match(/S|R|T|DeformPercent/) !== null) {
  4363. const c = {
  4364. id: o.id,
  4365. attr: o.attrName,
  4366. curves: {}
  4367. };
  4368. s.set(c.id, c);
  4369. }
  4370. }
  4371. return s;
  4372. }
  4373. // parse nodes in FBXTree.Objects.AnimationCurve and connect them up to
  4374. // previously parsed AnimationCurveNodes. Each AnimationCurve holds data for a single animated
  4375. // axis ( e.g. times and values of x rotation)
  4376. parseAnimationCurves(i) {
  4377. const s = se2.Objects.AnimationCurve;
  4378. for (const r in s) {
  4379. const o = {
  4380. id: s[r].id,
  4381. times: s[r].KeyTime.a.map(fh),
  4382. values: s[r].KeyValueFloat.a
  4383. }, c = Ve.get(o.id);
  4384. if (c !== void 0) {
  4385. const p2 = c.parents[0].ID, h2 = c.parents[0].relationship;
  4386. h2.match(/X/) ? i.get(p2).curves.x = o : h2.match(/Y/) ? i.get(p2).curves.y = o : h2.match(/Z/) ? i.get(p2).curves.z = o : h2.match(/d|DeformPercent/) && i.has(p2) && (i.get(p2).curves.morph = o);
  4387. }
  4388. }
  4389. }
  4390. // parse nodes in FBXTree.Objects.AnimationLayer. Each layers holds references
  4391. // to various AnimationCurveNodes and is referenced by an AnimationStack node
  4392. // note: theoretically a stack can have multiple layers, however in practice there always seems to be one per stack
  4393. parseAnimationLayers(i) {
  4394. const s = se2.Objects.AnimationLayer, r = /* @__PURE__ */ new Map();
  4395. for (const o in s) {
  4396. const c = [], p2 = Ve.get(parseInt(o));
  4397. p2 !== void 0 && (p2.children.forEach(function(m, g) {
  4398. if (i.has(m.ID)) {
  4399. const w = i.get(m.ID);
  4400. if (w.curves.x !== void 0 || w.curves.y !== void 0 || w.curves.z !== void 0) {
  4401. if (c[g] === void 0) {
  4402. const _2 = Ve.get(m.ID).parents.filter(function(y) {
  4403. return y.relationship !== void 0;
  4404. })[0].ID;
  4405. if (_2 !== void 0) {
  4406. const y = se2.Objects.Model[_2.toString()];
  4407. if (y === void 0) {
  4408. console.warn("THREE.FBXLoader: Encountered a unused curve.", m);
  4409. return;
  4410. }
  4411. const C = {
  4412. modelName: y.attrName ? PropertyBinding.sanitizeNodeName(y.attrName) : "",
  4413. ID: y.id,
  4414. initialPosition: [0, 0, 0],
  4415. initialRotation: [0, 0, 0],
  4416. initialScale: [1, 1, 1]
  4417. };
  4418. nt2.traverse(function(L) {
  4419. L.ID === y.id && (C.transform = L.matrix, L.userData.transformData && (C.eulerOrder = L.userData.transformData.eulerOrder));
  4420. }), C.transform || (C.transform = new Matrix4()), "PreRotation" in y && (C.preRotation = y.PreRotation.value), "PostRotation" in y && (C.postRotation = y.PostRotation.value), c[g] = C;
  4421. }
  4422. }
  4423. c[g] && (c[g][w.attr] = w);
  4424. } else if (w.curves.morph !== void 0) {
  4425. if (c[g] === void 0) {
  4426. const _2 = Ve.get(m.ID).parents.filter(function(O) {
  4427. return O.relationship !== void 0;
  4428. })[0].ID, y = Ve.get(_2).parents[0].ID, C = Ve.get(y).parents[0].ID, L = Ve.get(C).parents[0].ID, S = se2.Objects.Model[L], R = {
  4429. modelName: S.attrName ? PropertyBinding.sanitizeNodeName(S.attrName) : "",
  4430. morphName: se2.Objects.Deformer[_2].attrName
  4431. };
  4432. c[g] = R;
  4433. }
  4434. c[g][w.attr] = w;
  4435. }
  4436. }
  4437. }), r.set(parseInt(o), c));
  4438. }
  4439. return r;
  4440. }
  4441. // parse nodes in FBXTree.Objects.AnimationStack. These are the top level node in the animation
  4442. // hierarchy. Each Stack node will be used to create a AnimationClip
  4443. parseAnimStacks(i) {
  4444. const s = se2.Objects.AnimationStack, r = {};
  4445. for (const o in s) {
  4446. const c = Ve.get(parseInt(o)).children;
  4447. c.length > 1 && console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");
  4448. const p2 = i.get(c[0].ID);
  4449. r[o] = {
  4450. name: s[o].attrName,
  4451. layer: p2
  4452. };
  4453. }
  4454. return r;
  4455. }
  4456. addClip(i) {
  4457. let s = [];
  4458. const r = this;
  4459. return i.layer.forEach(function(o) {
  4460. s = s.concat(r.generateTracks(o));
  4461. }), new AnimationClip(i.name, -1, s);
  4462. }
  4463. generateTracks(i) {
  4464. const s = [];
  4465. let r = new Vector3(), o = new Quaternion(), c = new Vector3();
  4466. if (i.transform && i.transform.decompose(r, o, c), r = r.toArray(), o = new Euler().setFromQuaternion(o, i.eulerOrder).toArray(), c = c.toArray(), i.T !== void 0 && Object.keys(i.T.curves).length > 0) {
  4467. const p2 = this.generateVectorTrack(i.modelName, i.T.curves, r, "position");
  4468. p2 !== void 0 && s.push(p2);
  4469. }
  4470. if (i.R !== void 0 && Object.keys(i.R.curves).length > 0) {
  4471. const p2 = this.generateRotationTrack(i.modelName, i.R.curves, o, i.preRotation, i.postRotation, i.eulerOrder);
  4472. p2 !== void 0 && s.push(p2);
  4473. }
  4474. if (i.S !== void 0 && Object.keys(i.S.curves).length > 0) {
  4475. const p2 = this.generateVectorTrack(i.modelName, i.S.curves, c, "scale");
  4476. p2 !== void 0 && s.push(p2);
  4477. }
  4478. if (i.DeformPercent !== void 0) {
  4479. const p2 = this.generateMorphTrack(i);
  4480. p2 !== void 0 && s.push(p2);
  4481. }
  4482. return s;
  4483. }
  4484. generateVectorTrack(i, s, r, o) {
  4485. const c = this.getTimesForAllAxes(s), p2 = this.getKeyframeTrackValues(c, s, r);
  4486. return new VectorKeyframeTrack(i + "." + o, c, p2);
  4487. }
  4488. generateRotationTrack(i, s, r, o, c, p2) {
  4489. s.x !== void 0 && (this.interpolateRotations(s.x), s.x.values = s.x.values.map(MathUtils.degToRad)), s.y !== void 0 && (this.interpolateRotations(s.y), s.y.values = s.y.values.map(MathUtils.degToRad)), s.z !== void 0 && (this.interpolateRotations(s.z), s.z.values = s.z.values.map(MathUtils.degToRad));
  4490. const h2 = this.getTimesForAllAxes(s), m = this.getKeyframeTrackValues(h2, s, r);
  4491. o !== void 0 && (o = o.map(MathUtils.degToRad), o.push(p2), o = new Euler().fromArray(o), o = new Quaternion().setFromEuler(o)), c !== void 0 && (c = c.map(MathUtils.degToRad), c.push(p2), c = new Euler().fromArray(c), c = new Quaternion().setFromEuler(c).invert());
  4492. const g = new Quaternion(), w = new Euler(), _2 = [];
  4493. for (let y = 0; y < m.length; y += 3)
  4494. w.set(m[y], m[y + 1], m[y + 2], p2), g.setFromEuler(w), o !== void 0 && g.premultiply(o), c !== void 0 && g.multiply(c), g.toArray(_2, y / 3 * 4);
  4495. return new QuaternionKeyframeTrack(i + ".quaternion", h2, _2);
  4496. }
  4497. generateMorphTrack(i) {
  4498. const s = i.DeformPercent.curves.morph, r = s.values.map(function(c) {
  4499. return c / 100;
  4500. }), o = nt2.getObjectByName(i.modelName).morphTargetDictionary[i.morphName];
  4501. return new NumberKeyframeTrack(i.modelName + ".morphTargetInfluences[" + o + "]", s.times, r);
  4502. }
  4503. // For all animated objects, times are defined separately for each axis
  4504. // Here we'll combine the times into one sorted array without duplicates
  4505. getTimesForAllAxes(i) {
  4506. let s = [];
  4507. if (i.x !== void 0 && (s = s.concat(i.x.times)), i.y !== void 0 && (s = s.concat(i.y.times)), i.z !== void 0 && (s = s.concat(i.z.times)), s = s.sort(function(r, o) {
  4508. return r - o;
  4509. }), s.length > 1) {
  4510. let r = 1, o = s[0];
  4511. for (let c = 1; c < s.length; c++) {
  4512. const p2 = s[c];
  4513. p2 !== o && (s[r] = p2, o = p2, r++);
  4514. }
  4515. s = s.slice(0, r);
  4516. }
  4517. return s;
  4518. }
  4519. getKeyframeTrackValues(i, s, r) {
  4520. const o = r, c = [];
  4521. let p2 = -1, h2 = -1, m = -1;
  4522. return i.forEach(function(g) {
  4523. if (s.x && (p2 = s.x.times.indexOf(g)), s.y && (h2 = s.y.times.indexOf(g)), s.z && (m = s.z.times.indexOf(g)), p2 !== -1) {
  4524. const w = s.x.values[p2];
  4525. c.push(w), o[0] = w;
  4526. } else
  4527. c.push(o[0]);
  4528. if (h2 !== -1) {
  4529. const w = s.y.values[h2];
  4530. c.push(w), o[1] = w;
  4531. } else
  4532. c.push(o[1]);
  4533. if (m !== -1) {
  4534. const w = s.z.values[m];
  4535. c.push(w), o[2] = w;
  4536. } else
  4537. c.push(o[2]);
  4538. }), c;
  4539. }
  4540. // Rotations are defined as Euler angles which can have values of any size
  4541. // These will be converted to quaternions which don't support values greater than
  4542. // PI, so we'll interpolate large rotations
  4543. interpolateRotations(i) {
  4544. for (let s = 1; s < i.values.length; s++) {
  4545. const r = i.values[s - 1], o = i.values[s] - r, c = Math.abs(o);
  4546. if (c >= 180) {
  4547. const p2 = c / 180, h2 = o / p2;
  4548. let m = r + h2;
  4549. const g = i.times[s - 1], _2 = (i.times[s] - g) / p2;
  4550. let y = g + _2;
  4551. const C = [], L = [];
  4552. for (; y < i.times[s]; )
  4553. C.push(y), y += _2, L.push(m), m += h2;
  4554. i.times = Pa(i.times, s, C), i.values = Pa(i.values, s, L);
  4555. }
  4556. }
  4557. }
  4558. };
  4559. var ph = class {
  4560. getPrevNode() {
  4561. return this.nodeStack[this.currentIndent - 2];
  4562. }
  4563. getCurrentNode() {
  4564. return this.nodeStack[this.currentIndent - 1];
  4565. }
  4566. getCurrentProp() {
  4567. return this.currentProp;
  4568. }
  4569. pushStack(i) {
  4570. this.nodeStack.push(i), this.currentIndent += 1;
  4571. }
  4572. popStack() {
  4573. this.nodeStack.pop(), this.currentIndent -= 1;
  4574. }
  4575. setCurrentProp(i, s) {
  4576. this.currentProp = i, this.currentPropName = s;
  4577. }
  4578. parse(i) {
  4579. this.currentIndent = 0, this.allNodes = new Ja(), this.nodeStack = [], this.currentProp = [], this.currentPropName = "";
  4580. const s = this, r = i.split(/[\r\n]+/);
  4581. return r.forEach(function(o, c) {
  4582. const p2 = o.match(/^[\s\t]*;/), h2 = o.match(/^[\s\t]*$/);
  4583. if (p2 || h2)
  4584. return;
  4585. const m = o.match("^\\t{" + s.currentIndent + "}(\\w+):(.*){", ""), g = o.match("^\\t{" + s.currentIndent + "}(\\w+):[\\s\\t\\r\\n](.*)"), w = o.match("^\\t{" + (s.currentIndent - 1) + "}}");
  4586. m ? s.parseNodeBegin(o, m) : g ? s.parseNodeProperty(o, g, r[++c]) : w ? s.popStack() : o.match(/^[^\s\t}]/) && s.parseNodePropertyContinued(o);
  4587. }), this.allNodes;
  4588. }
  4589. parseNodeBegin(i, s) {
  4590. const r = s[1].trim().replace(/^"/, "").replace(/"$/, ""), o = s[2].split(",").map(function(m) {
  4591. return m.trim().replace(/^"/, "").replace(/"$/, "");
  4592. }), c = {
  4593. name: r
  4594. }, p2 = this.parseNodeAttr(o), h2 = this.getCurrentNode();
  4595. this.currentIndent === 0 ? this.allNodes.add(r, c) : r in h2 ? (r === "PoseNode" ? h2.PoseNode.push(c) : h2[r].id !== void 0 && (h2[r] = {}, h2[r][h2[r].id] = h2[r]), p2.id !== "" && (h2[r][p2.id] = c)) : typeof p2.id == "number" ? (h2[r] = {}, h2[r][p2.id] = c) : r !== "Properties70" && (r === "PoseNode" ? h2[r] = [c] : h2[r] = c), typeof p2.id == "number" && (c.id = p2.id), p2.name !== "" && (c.attrName = p2.name), p2.type !== "" && (c.attrType = p2.type), this.pushStack(c);
  4596. }
  4597. parseNodeAttr(i) {
  4598. let s = i[0];
  4599. i[0] !== "" && (s = parseInt(i[0]), isNaN(s) && (s = i[0]));
  4600. let r = "", o = "";
  4601. return i.length > 1 && (r = i[1].replace(/^(\w+)::/, ""), o = i[2]), {
  4602. id: s,
  4603. name: r,
  4604. type: o
  4605. };
  4606. }
  4607. parseNodeProperty(i, s, r) {
  4608. let o = s[1].replace(/^"/, "").replace(/"$/, "").trim(), c = s[2].replace(/^"/, "").replace(/"$/, "").trim();
  4609. o === "Content" && c === "," && (c = r.replace(/"/g, "").replace(/,$/, "").trim());
  4610. const p2 = this.getCurrentNode();
  4611. if (p2.name === "Properties70") {
  4612. this.parseNodeSpecialProperty(i, o, c);
  4613. return;
  4614. }
  4615. if (o === "C") {
  4616. const m = c.split(",").slice(1), g = parseInt(m[0]), w = parseInt(m[1]);
  4617. let _2 = c.split(",").slice(3);
  4618. _2 = _2.map(function(y) {
  4619. return y.trim().replace(/^"/, "");
  4620. }), o = "connections", c = [g, w], bh(c, _2), p2[o] === void 0 && (p2[o] = []);
  4621. }
  4622. o === "Node" && (p2.id = c), o in p2 && Array.isArray(p2[o]) ? p2[o].push(c) : o !== "a" ? p2[o] = c : p2.a = c, this.setCurrentProp(p2, o), o === "a" && c.slice(-1) !== "," && (p2.a = oo(c));
  4623. }
  4624. parseNodePropertyContinued(i) {
  4625. const s = this.getCurrentNode();
  4626. s.a += i, i.slice(-1) !== "," && (s.a = oo(s.a));
  4627. }
  4628. // parse "Property70"
  4629. parseNodeSpecialProperty(i, s, r) {
  4630. const o = r.split('",').map(function(w) {
  4631. return w.trim().replace(/^\"/, "").replace(/\s/, "_");
  4632. }), c = o[0], p2 = o[1], h2 = o[2], m = o[3];
  4633. let g = o[4];
  4634. switch (p2) {
  4635. case "int":
  4636. case "enum":
  4637. case "bool":
  4638. case "ULongLong":
  4639. case "double":
  4640. case "Number":
  4641. case "FieldOfView":
  4642. g = parseFloat(g);
  4643. break;
  4644. case "Color":
  4645. case "ColorRGB":
  4646. case "Vector3D":
  4647. case "Lcl_Translation":
  4648. case "Lcl_Rotation":
  4649. case "Lcl_Scaling":
  4650. g = oo(g);
  4651. break;
  4652. }
  4653. this.getPrevNode()[c] = {
  4654. type: p2,
  4655. type2: h2,
  4656. flag: m,
  4657. value: g
  4658. }, this.setCurrentProp(this.getPrevNode(), c);
  4659. }
  4660. };
  4661. var hh = class {
  4662. parse(i) {
  4663. const s = new Ea(i);
  4664. s.skip(23);
  4665. const r = s.getUint32();
  4666. if (r < 6400)
  4667. throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: " + r);
  4668. const o = new Ja();
  4669. for (; !this.endOfContent(s); ) {
  4670. const c = this.parseNode(s, r);
  4671. c !== null && o.add(c.name, c);
  4672. }
  4673. return o;
  4674. }
  4675. // Check if reader has reached the end of content.
  4676. endOfContent(i) {
  4677. return i.size() % 16 === 0 ? (i.getOffset() + 160 + 16 & -16) >= i.size() : i.getOffset() + 160 + 16 >= i.size();
  4678. }
  4679. // recursively parse nodes until the end of the file is reached
  4680. parseNode(i, s) {
  4681. const r = {}, o = s >= 7500 ? i.getUint64() : i.getUint32(), c = s >= 7500 ? i.getUint64() : i.getUint32();
  4682. s >= 7500 ? i.getUint64() : i.getUint32();
  4683. const p2 = i.getUint8(), h2 = i.getString(p2);
  4684. if (o === 0)
  4685. return null;
  4686. const m = [];
  4687. for (let y = 0; y < c; y++)
  4688. m.push(this.parseProperty(i));
  4689. const g = m.length > 0 ? m[0] : "", w = m.length > 1 ? m[1] : "", _2 = m.length > 2 ? m[2] : "";
  4690. for (r.singleProperty = c === 1 && i.getOffset() === o; o > i.getOffset(); ) {
  4691. const y = this.parseNode(i, s);
  4692. y !== null && this.parseSubNode(h2, r, y);
  4693. }
  4694. return r.propertyList = m, typeof g == "number" && (r.id = g), w !== "" && (r.attrName = w), _2 !== "" && (r.attrType = _2), h2 !== "" && (r.name = h2), r;
  4695. }
  4696. parseSubNode(i, s, r) {
  4697. if (r.singleProperty === true) {
  4698. const o = r.propertyList[0];
  4699. Array.isArray(o) ? (s[r.name] = r, r.a = o) : s[r.name] = o;
  4700. } else if (i === "Connections" && r.name === "C") {
  4701. const o = [];
  4702. r.propertyList.forEach(function(c, p2) {
  4703. p2 !== 0 && o.push(c);
  4704. }), s.connections === void 0 && (s.connections = []), s.connections.push(o);
  4705. } else if (r.name === "Properties70")
  4706. Object.keys(r).forEach(function(c) {
  4707. s[c] = r[c];
  4708. });
  4709. else if (i === "Properties70" && r.name === "P") {
  4710. let o = r.propertyList[0], c = r.propertyList[1];
  4711. const p2 = r.propertyList[2], h2 = r.propertyList[3];
  4712. let m;
  4713. o.indexOf("Lcl ") === 0 && (o = o.replace("Lcl ", "Lcl_")), c.indexOf("Lcl ") === 0 && (c = c.replace("Lcl ", "Lcl_")), c === "Color" || c === "ColorRGB" || c === "Vector" || c === "Vector3D" || c.indexOf("Lcl_") === 0 ? m = [r.propertyList[4], r.propertyList[5], r.propertyList[6]] : m = r.propertyList[4], s[o] = {
  4714. type: c,
  4715. type2: p2,
  4716. flag: h2,
  4717. value: m
  4718. };
  4719. } else
  4720. s[r.name] === void 0 ? typeof r.id == "number" ? (s[r.name] = {}, s[r.name][r.id] = r) : s[r.name] = r : r.name === "PoseNode" ? (Array.isArray(s[r.name]) || (s[r.name] = [s[r.name]]), s[r.name].push(r)) : s[r.name][r.id] === void 0 && (s[r.name][r.id] = r);
  4721. }
  4722. parseProperty(i) {
  4723. const s = i.getString(1);
  4724. let r;
  4725. switch (s) {
  4726. case "C":
  4727. return i.getBoolean();
  4728. case "D":
  4729. return i.getFloat64();
  4730. case "F":
  4731. return i.getFloat32();
  4732. case "I":
  4733. return i.getInt32();
  4734. case "L":
  4735. return i.getInt64();
  4736. case "R":
  4737. return r = i.getUint32(), i.getArrayBuffer(r);
  4738. case "S":
  4739. return r = i.getUint32(), i.getString(r);
  4740. case "Y":
  4741. return i.getInt16();
  4742. case "b":
  4743. case "c":
  4744. case "d":
  4745. case "f":
  4746. case "i":
  4747. case "l":
  4748. const o = i.getUint32(), c = i.getUint32(), p2 = i.getUint32();
  4749. if (c === 0)
  4750. switch (s) {
  4751. case "b":
  4752. case "c":
  4753. return i.getBooleanArray(o);
  4754. case "d":
  4755. return i.getFloat64Array(o);
  4756. case "f":
  4757. return i.getFloat32Array(o);
  4758. case "i":
  4759. return i.getInt32Array(o);
  4760. case "l":
  4761. return i.getInt64Array(o);
  4762. }
  4763. const h2 = pp(new Uint8Array(i.getArrayBuffer(p2))), m = new Ea(h2.buffer);
  4764. switch (s) {
  4765. case "b":
  4766. case "c":
  4767. return m.getBooleanArray(o);
  4768. case "d":
  4769. return m.getFloat64Array(o);
  4770. case "f":
  4771. return m.getFloat32Array(o);
  4772. case "i":
  4773. return m.getInt32Array(o);
  4774. case "l":
  4775. return m.getInt64Array(o);
  4776. }
  4777. default:
  4778. throw new Error("THREE.FBXLoader: Unknown property type " + s);
  4779. }
  4780. }
  4781. };
  4782. var Ea = class {
  4783. constructor(i, s) {
  4784. this.dv = new DataView(i), this.offset = 0, this.littleEndian = s !== void 0 ? s : true;
  4785. }
  4786. getOffset() {
  4787. return this.offset;
  4788. }
  4789. size() {
  4790. return this.dv.buffer.byteLength;
  4791. }
  4792. skip(i) {
  4793. this.offset += i;
  4794. }
  4795. // seems like true/false representation depends on exporter.
  4796. // true: 1 or 'Y'(=0x59), false: 0 or 'T'(=0x54)
  4797. // then sees LSB.
  4798. getBoolean() {
  4799. return (this.getUint8() & 1) === 1;
  4800. }
  4801. getBooleanArray(i) {
  4802. const s = [];
  4803. for (let r = 0; r < i; r++)
  4804. s.push(this.getBoolean());
  4805. return s;
  4806. }
  4807. getUint8() {
  4808. const i = this.dv.getUint8(this.offset);
  4809. return this.offset += 1, i;
  4810. }
  4811. getInt16() {
  4812. const i = this.dv.getInt16(this.offset, this.littleEndian);
  4813. return this.offset += 2, i;
  4814. }
  4815. getInt32() {
  4816. const i = this.dv.getInt32(this.offset, this.littleEndian);
  4817. return this.offset += 4, i;
  4818. }
  4819. getInt32Array(i) {
  4820. const s = [];
  4821. for (let r = 0; r < i; r++)
  4822. s.push(this.getInt32());
  4823. return s;
  4824. }
  4825. getUint32() {
  4826. const i = this.dv.getUint32(this.offset, this.littleEndian);
  4827. return this.offset += 4, i;
  4828. }
  4829. // JavaScript doesn't support 64-bit integer so calculate this here
  4830. // 1 << 32 will return 1 so using multiply operation instead here.
  4831. // There's a possibility that this method returns wrong value if the value
  4832. // is out of the range between Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER.
  4833. // TODO: safely handle 64-bit integer
  4834. getInt64() {
  4835. let i, s;
  4836. return this.littleEndian ? (i = this.getUint32(), s = this.getUint32()) : (s = this.getUint32(), i = this.getUint32()), s & 2147483648 ? (s = ~s & 4294967295, i = ~i & 4294967295, i === 4294967295 && (s = s + 1 & 4294967295), i = i + 1 & 4294967295, -(s * 4294967296 + i)) : s * 4294967296 + i;
  4837. }
  4838. getInt64Array(i) {
  4839. const s = [];
  4840. for (let r = 0; r < i; r++)
  4841. s.push(this.getInt64());
  4842. return s;
  4843. }
  4844. // Note: see getInt64() comment
  4845. getUint64() {
  4846. let i, s;
  4847. return this.littleEndian ? (i = this.getUint32(), s = this.getUint32()) : (s = this.getUint32(), i = this.getUint32()), s * 4294967296 + i;
  4848. }
  4849. getFloat32() {
  4850. const i = this.dv.getFloat32(this.offset, this.littleEndian);
  4851. return this.offset += 4, i;
  4852. }
  4853. getFloat32Array(i) {
  4854. const s = [];
  4855. for (let r = 0; r < i; r++)
  4856. s.push(this.getFloat32());
  4857. return s;
  4858. }
  4859. getFloat64() {
  4860. const i = this.dv.getFloat64(this.offset, this.littleEndian);
  4861. return this.offset += 8, i;
  4862. }
  4863. getFloat64Array(i) {
  4864. const s = [];
  4865. for (let r = 0; r < i; r++)
  4866. s.push(this.getFloat64());
  4867. return s;
  4868. }
  4869. getArrayBuffer(i) {
  4870. const s = this.dv.buffer.slice(this.offset, this.offset + i);
  4871. return this.offset += i, s;
  4872. }
  4873. getString(i) {
  4874. let s = [];
  4875. for (let o = 0; o < i; o++)
  4876. s[o] = this.getUint8();
  4877. const r = s.indexOf(0);
  4878. return r >= 0 && (s = s.slice(0, r)), LoaderUtils.decodeText(new Uint8Array(s));
  4879. }
  4880. };
  4881. var Ja = class {
  4882. add(i, s) {
  4883. this[i] = s;
  4884. }
  4885. };
  4886. function dh(f) {
  4887. const i = "Kaydara FBX Binary \0";
  4888. return f.byteLength >= i.length && i === nl(f, 0, i.length);
  4889. }
  4890. function mh(f) {
  4891. const i = ["K", "a", "y", "d", "a", "r", "a", "\\", "F", "B", "X", "\\", "B", "i", "n", "a", "r", "y", "\\", "\\"];
  4892. let s = 0;
  4893. function r(o) {
  4894. const c = f[o - 1];
  4895. return f = f.slice(s + o), s++, c;
  4896. }
  4897. for (let o = 0; o < i.length; ++o)
  4898. if (r(1) === i[o])
  4899. return false;
  4900. return true;
  4901. }
  4902. function Ca(f) {
  4903. const i = /FBXVersion: (\d+)/, s = f.match(i);
  4904. if (s)
  4905. return parseInt(s[1]);
  4906. throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.");
  4907. }
  4908. function fh(f) {
  4909. return f / 46186158e3;
  4910. }
  4911. var vh = [];
  4912. function js(f, i, s, r) {
  4913. let o;
  4914. switch (r.mappingType) {
  4915. case "ByPolygonVertex":
  4916. o = f;
  4917. break;
  4918. case "ByPolygon":
  4919. o = i;
  4920. break;
  4921. case "ByVertice":
  4922. o = s;
  4923. break;
  4924. case "AllSame":
  4925. o = r.indices[0];
  4926. break;
  4927. default:
  4928. console.warn("THREE.FBXLoader: unknown attribute mapping type " + r.mappingType);
  4929. }
  4930. r.referenceType === "IndexToDirect" && (o = r.indices[o]);
  4931. const c = o * r.dataSize, p2 = c + r.dataSize;
  4932. return gh(vh, r.buffer, c, p2);
  4933. }
  4934. var ro = new Euler();
  4935. var hi = new Vector3();
  4936. function el(f) {
  4937. const i = new Matrix4(), s = new Matrix4(), r = new Matrix4(), o = new Matrix4(), c = new Matrix4(), p2 = new Matrix4(), h2 = new Matrix4(), m = new Matrix4(), g = new Matrix4(), w = new Matrix4(), _2 = new Matrix4(), y = new Matrix4(), C = f.inheritType ? f.inheritType : 0;
  4938. if (f.translation && i.setPosition(hi.fromArray(f.translation)), f.preRotation) {
  4939. const K2 = f.preRotation.map(MathUtils.degToRad);
  4940. K2.push(f.eulerOrder), s.makeRotationFromEuler(ro.fromArray(K2));
  4941. }
  4942. if (f.rotation) {
  4943. const K2 = f.rotation.map(MathUtils.degToRad);
  4944. K2.push(f.eulerOrder), r.makeRotationFromEuler(ro.fromArray(K2));
  4945. }
  4946. if (f.postRotation) {
  4947. const K2 = f.postRotation.map(MathUtils.degToRad);
  4948. K2.push(f.eulerOrder), o.makeRotationFromEuler(ro.fromArray(K2)), o.invert();
  4949. }
  4950. f.scale && c.scale(hi.fromArray(f.scale)), f.scalingOffset && h2.setPosition(hi.fromArray(f.scalingOffset)), f.scalingPivot && p2.setPosition(hi.fromArray(f.scalingPivot)), f.rotationOffset && m.setPosition(hi.fromArray(f.rotationOffset)), f.rotationPivot && g.setPosition(hi.fromArray(f.rotationPivot)), f.parentMatrixWorld && (_2.copy(f.parentMatrix), w.copy(f.parentMatrixWorld));
  4951. const L = s.clone().multiply(r).multiply(o), S = new Matrix4();
  4952. S.extractRotation(w);
  4953. const R = new Matrix4();
  4954. R.copyPosition(w);
  4955. const O = R.clone().invert().multiply(w), N = S.clone().invert().multiply(O), I2 = c, D2 = new Matrix4();
  4956. if (C === 0)
  4957. D2.copy(S).multiply(L).multiply(N).multiply(I2);
  4958. else if (C === 1)
  4959. D2.copy(S).multiply(N).multiply(L).multiply(I2);
  4960. else {
  4961. const q = new Matrix4().scale(new Vector3().setFromMatrixScale(_2)).clone().invert(), pe = N.clone().multiply(q);
  4962. D2.copy(S).multiply(L).multiply(pe).multiply(I2);
  4963. }
  4964. const Y = g.clone().invert(), G = p2.clone().invert();
  4965. let F = i.clone().multiply(m).multiply(g).multiply(s).multiply(r).multiply(o).multiply(Y).multiply(h2).multiply(p2).multiply(c).multiply(G);
  4966. const B = new Matrix4().copyPosition(F), H2 = w.clone().multiply(B);
  4967. return y.copyPosition(H2), F = y.clone().multiply(D2), F.premultiply(w.invert()), F;
  4968. }
  4969. function tl(f) {
  4970. f = f || 0;
  4971. const i = [
  4972. "ZYX",
  4973. // -> XYZ extrinsic
  4974. "YZX",
  4975. // -> XZY extrinsic
  4976. "XZY",
  4977. // -> YZX extrinsic
  4978. "ZXY",
  4979. // -> YXZ extrinsic
  4980. "YXZ",
  4981. // -> ZXY extrinsic
  4982. "XYZ"
  4983. // -> ZYX extrinsic
  4984. //'SphericXYZ', // not possible to support
  4985. ];
  4986. return f === 6 ? (console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."), i[0]) : i[f];
  4987. }
  4988. function oo(f) {
  4989. return f.split(",").map(function(s) {
  4990. return parseFloat(s);
  4991. });
  4992. }
  4993. function nl(f, i, s) {
  4994. return i === void 0 && (i = 0), s === void 0 && (s = f.byteLength), LoaderUtils.decodeText(new Uint8Array(f, i, s));
  4995. }
  4996. function bh(f, i) {
  4997. for (let s = 0, r = f.length, o = i.length; s < o; s++, r++)
  4998. f[r] = i[s];
  4999. }
  5000. function gh(f, i, s, r) {
  5001. for (let o = s, c = 0; o < r; o++, c++)
  5002. f[c] = i[o];
  5003. return f;
  5004. }
  5005. function Pa(f, i, s) {
  5006. return f.slice(0, i).concat(s).concat(f.slice(i));
  5007. }
  5008. var _h = class extends Loader {
  5009. constructor(i) {
  5010. super(i);
  5011. }
  5012. load(i, s, r, o) {
  5013. const c = new FileLoader(this.manager);
  5014. c.setPath(this.path), c.setRequestHeader(this.requestHeader), c.setWithCredentials(this.withCredentials), c.load(i, (p2) => {
  5015. if (typeof p2 != "string")
  5016. throw new Error("unsupported data type");
  5017. const h2 = JSON.parse(p2), m = this.parse(h2);
  5018. s && s(m);
  5019. }, r, o);
  5020. }
  5021. parse(i) {
  5022. return new ko(i);
  5023. }
  5024. };
  5025. var ko = class {
  5026. constructor(i) {
  5027. P(this, "data", void 0), this.data = i;
  5028. }
  5029. generateShapes(i, s = 100, r) {
  5030. const o = [], c = {
  5031. letterSpacing: 0,
  5032. lineHeight: 1,
  5033. ...r
  5034. }, p2 = wh(i, s, this.data, c);
  5035. for (let h2 = 0, m = p2.length; h2 < m; h2++)
  5036. Array.prototype.push.apply(o, p2[h2].toShapes(false));
  5037. return o;
  5038. }
  5039. };
  5040. P(ko, "isFont", void 0);
  5041. P(ko, "type", void 0);
  5042. function wh(f, i, s, r) {
  5043. const o = Array.from(f), c = i / s.resolution, p2 = (s.boundingBox.yMax - s.boundingBox.yMin + s.underlineThickness) * c, h2 = [];
  5044. let m = 0, g = 0;
  5045. for (let w = 0; w < o.length; w++) {
  5046. const _2 = o[w];
  5047. if (_2 === `
  5048. `)
  5049. m = 0, g -= p2 * r.lineHeight;
  5050. else {
  5051. const y = yh(_2, c, m, g, s);
  5052. y && (m += y.offsetX + r.letterSpacing, h2.push(y.path));
  5053. }
  5054. }
  5055. return h2;
  5056. }
  5057. function yh(f, i, s, r, o) {
  5058. const c = o.glyphs[f] || o.glyphs["?"];
  5059. if (!c) {
  5060. console.error('THREE.Font: character "' + f + '" does not exists in font family ' + o.familyName + ".");
  5061. return;
  5062. }
  5063. const p2 = new ShapePath();
  5064. let h2, m, g, w, _2, y, C, L;
  5065. if (c.o) {
  5066. const S = c._cachedOutline || (c._cachedOutline = c.o.split(" "));
  5067. for (let R = 0, O = S.length; R < O; )
  5068. switch (S[R++]) {
  5069. case "m":
  5070. h2 = parseInt(S[R++]) * i + s, m = parseInt(S[R++]) * i + r, p2.moveTo(h2, m);
  5071. break;
  5072. case "l":
  5073. h2 = parseInt(S[R++]) * i + s, m = parseInt(S[R++]) * i + r, p2.lineTo(h2, m);
  5074. break;
  5075. case "q":
  5076. g = parseInt(S[R++]) * i + s, w = parseInt(S[R++]) * i + r, _2 = parseInt(S[R++]) * i + s, y = parseInt(S[R++]) * i + r, p2.quadraticCurveTo(_2, y, g, w);
  5077. break;
  5078. case "b":
  5079. g = parseInt(S[R++]) * i + s, w = parseInt(S[R++]) * i + r, _2 = parseInt(S[R++]) * i + s, y = parseInt(S[R++]) * i + r, C = parseInt(S[R++]) * i + s, L = parseInt(S[R++]) * i + r, p2.bezierCurveTo(_2, y, C, L, g, w);
  5080. break;
  5081. }
  5082. }
  5083. return {
  5084. offsetX: c.ha * i,
  5085. path: p2
  5086. };
  5087. }
  5088. var il = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
  5089. function xh(f) {
  5090. return f && f.__esModule && Object.prototype.hasOwnProperty.call(f, "default") ? f.default : f;
  5091. }
  5092. var Eh = class extends DataTextureLoader {
  5093. constructor(i) {
  5094. super(i), this.type = HalfFloatType;
  5095. }
  5096. // adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
  5097. parse(i) {
  5098. const h2 = function(I2, D2) {
  5099. switch (I2) {
  5100. case 1:
  5101. console.error("THREE.RGBELoader Read Error: " + (D2 || ""));
  5102. break;
  5103. case 2:
  5104. console.error("THREE.RGBELoader Write Error: " + (D2 || ""));
  5105. break;
  5106. case 3:
  5107. console.error("THREE.RGBELoader Bad File Format: " + (D2 || ""));
  5108. break;
  5109. default:
  5110. case 4:
  5111. console.error("THREE.RGBELoader: Error: " + (D2 || ""));
  5112. }
  5113. return -1;
  5114. }, _2 = `
  5115. `, y = function(I2, D2, Y) {
  5116. D2 = D2 || 1024;
  5117. let F = I2.pos, B = -1, H2 = 0, K2 = "", q = String.fromCharCode.apply(null, new Uint16Array(I2.subarray(F, F + 128)));
  5118. for (; 0 > (B = q.indexOf(_2)) && H2 < D2 && F < I2.byteLength; )
  5119. K2 += q, H2 += q.length, F += 128, q += String.fromCharCode.apply(null, new Uint16Array(I2.subarray(F, F + 128)));
  5120. return -1 < B ? (Y !== false && (I2.pos += H2 + B + 1), K2 + q.slice(0, B)) : false;
  5121. }, C = function(I2) {
  5122. const D2 = /^#\?(\S+)/, Y = /^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/, G = /^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/, F = /^\s*FORMAT=(\S+)\s*$/, B = /^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/, H2 = {
  5123. valid: 0,
  5124. string: "",
  5125. comments: "",
  5126. programtype: "RGBE",
  5127. format: "",
  5128. gamma: 1,
  5129. exposure: 1,
  5130. width: 0,
  5131. height: 0
  5132. /* image dimensions, width/height */
  5133. };
  5134. let K2, q;
  5135. if (I2.pos >= I2.byteLength || !(K2 = y(I2)))
  5136. return h2(1, "no header found");
  5137. if (!(q = K2.match(D2)))
  5138. return h2(3, "bad initial token");
  5139. for (H2.valid |= 1, H2.programtype = q[1], H2.string += K2 + `
  5140. `; K2 = y(I2), K2 !== false; ) {
  5141. if (H2.string += K2 + `
  5142. `, K2.charAt(0) === "#") {
  5143. H2.comments += K2 + `
  5144. `;
  5145. continue;
  5146. }
  5147. if ((q = K2.match(Y)) && (H2.gamma = parseFloat(q[1])), (q = K2.match(G)) && (H2.exposure = parseFloat(q[1])), (q = K2.match(F)) && (H2.valid |= 2, H2.format = q[1]), (q = K2.match(B)) && (H2.valid |= 4, H2.height = parseInt(q[1], 10), H2.width = parseInt(q[2], 10)), H2.valid & 2 && H2.valid & 4)
  5148. break;
  5149. }
  5150. return H2.valid & 2 ? H2.valid & 4 ? H2 : h2(3, "missing image size specifier") : h2(3, "missing format specifier");
  5151. }, L = function(I2, D2, Y) {
  5152. const G = D2;
  5153. if (
  5154. // run length encoding is not allowed so read flat
  5155. G < 8 || G > 32767 || // this file is not run length encoded
  5156. I2[0] !== 2 || I2[1] !== 2 || I2[2] & 128
  5157. )
  5158. return new Uint8Array(I2);
  5159. if (G !== (I2[2] << 8 | I2[3]))
  5160. return h2(3, "wrong scanline width");
  5161. const F = new Uint8Array(4 * D2 * Y);
  5162. if (!F.length)
  5163. return h2(4, "unable to allocate buffer space");
  5164. let B = 0, H2 = 0;
  5165. const K2 = 4 * G, q = new Uint8Array(4), pe = new Uint8Array(K2);
  5166. let _e = Y;
  5167. for (; _e > 0 && H2 < I2.byteLength; ) {
  5168. if (H2 + 4 > I2.byteLength)
  5169. return h2(1);
  5170. if (q[0] = I2[H2++], q[1] = I2[H2++], q[2] = I2[H2++], q[3] = I2[H2++], q[0] != 2 || q[1] != 2 || (q[2] << 8 | q[3]) != G)
  5171. return h2(3, "bad rgbe scanline format");
  5172. let ce2 = 0, me;
  5173. for (; ce2 < K2 && H2 < I2.byteLength; ) {
  5174. me = I2[H2++];
  5175. const ee = me > 128;
  5176. if (ee && (me -= 128), me === 0 || ce2 + me > K2)
  5177. return h2(3, "bad scanline data");
  5178. if (ee) {
  5179. const X2 = I2[H2++];
  5180. for (let Se2 = 0; Se2 < me; Se2++)
  5181. pe[ce2++] = X2;
  5182. } else
  5183. pe.set(I2.subarray(H2, H2 + me), ce2), ce2 += me, H2 += me;
  5184. }
  5185. const he = G;
  5186. for (let ee = 0; ee < he; ee++) {
  5187. let X2 = 0;
  5188. F[B] = pe[ee + X2], X2 += G, F[B + 1] = pe[ee + X2], X2 += G, F[B + 2] = pe[ee + X2], X2 += G, F[B + 3] = pe[ee + X2], B += 4;
  5189. }
  5190. _e--;
  5191. }
  5192. return F;
  5193. }, S = function(I2, D2, Y, G) {
  5194. const F = I2[D2 + 3], B = Math.pow(2, F - 128) / 255;
  5195. Y[G + 0] = I2[D2 + 0] * B, Y[G + 1] = I2[D2 + 1] * B, Y[G + 2] = I2[D2 + 2] * B, Y[G + 3] = 1;
  5196. }, R = function(I2, D2, Y, G) {
  5197. const F = I2[D2 + 3], B = Math.pow(2, F - 128) / 255;
  5198. Y[G + 0] = DataUtils.toHalfFloat(Math.min(I2[D2 + 0] * B, 65504)), Y[G + 1] = DataUtils.toHalfFloat(Math.min(I2[D2 + 1] * B, 65504)), Y[G + 2] = DataUtils.toHalfFloat(Math.min(I2[D2 + 2] * B, 65504)), Y[G + 3] = DataUtils.toHalfFloat(1);
  5199. }, O = new Uint8Array(i);
  5200. O.pos = 0;
  5201. const N = C(O);
  5202. if (N !== -1) {
  5203. const I2 = N.width, D2 = N.height, Y = L(O.subarray(O.pos), I2, D2);
  5204. if (Y !== -1) {
  5205. let G, F, B;
  5206. switch (this.type) {
  5207. case FloatType:
  5208. B = Y.length / 4;
  5209. const H2 = new Float32Array(B * 4);
  5210. for (let q = 0; q < B; q++)
  5211. S(Y, q * 4, H2, q * 4);
  5212. G = H2, F = FloatType;
  5213. break;
  5214. case HalfFloatType:
  5215. B = Y.length / 4;
  5216. const K2 = new Uint16Array(B * 4);
  5217. for (let q = 0; q < B; q++)
  5218. R(Y, q * 4, K2, q * 4);
  5219. G = K2, F = HalfFloatType;
  5220. break;
  5221. default:
  5222. console.error("THREE.RGBELoader: unsupported type: ", this.type);
  5223. break;
  5224. }
  5225. return {
  5226. width: I2,
  5227. height: D2,
  5228. data: G,
  5229. header: N.string,
  5230. gamma: N.gamma,
  5231. exposure: N.exposure,
  5232. type: F
  5233. };
  5234. }
  5235. }
  5236. return null;
  5237. }
  5238. setDataType(i) {
  5239. return this.type = i, this;
  5240. }
  5241. load(i, s, r, o) {
  5242. function c(p2, h2) {
  5243. switch (p2.type) {
  5244. case FloatType:
  5245. case HalfFloatType:
  5246. p2.encoding = LinearEncoding, p2.minFilter = LinearFilter, p2.magFilter = LinearFilter, p2.generateMipmaps = false, p2.flipY = true;
  5247. break;
  5248. }
  5249. s && s(p2, h2);
  5250. }
  5251. return super.load(i, c, r, o);
  5252. }
  5253. };
  5254. var ao = /* @__PURE__ */ new WeakMap();
  5255. var Ch = class extends Loader {
  5256. constructor(i) {
  5257. super(i), this.decoderPath = "", this.decoderConfig = {}, this.decoderBinary = null, this.decoderPending = null, this.workerLimit = 4, this.workerPool = [], this.workerNextTaskID = 1, this.workerSourceURL = "", this.defaultAttributeIDs = {
  5258. position: "POSITION",
  5259. normal: "NORMAL",
  5260. color: "COLOR",
  5261. uv: "TEX_COORD"
  5262. }, this.defaultAttributeTypes = {
  5263. position: "Float32Array",
  5264. normal: "Float32Array",
  5265. color: "Float32Array",
  5266. uv: "Float32Array"
  5267. };
  5268. }
  5269. setDecoderPath(i) {
  5270. return this.decoderPath = i, this;
  5271. }
  5272. setDecoderConfig(i) {
  5273. return this.decoderConfig = i, this;
  5274. }
  5275. setWorkerLimit(i) {
  5276. return this.workerLimit = i, this;
  5277. }
  5278. load(i, s, r, o) {
  5279. const c = new FileLoader(this.manager);
  5280. c.setPath(this.path), c.setResponseType("arraybuffer"), c.setRequestHeader(this.requestHeader), c.setWithCredentials(this.withCredentials), c.load(i, (p2) => {
  5281. const h2 = {
  5282. attributeIDs: this.defaultAttributeIDs,
  5283. attributeTypes: this.defaultAttributeTypes,
  5284. useUniqueIDs: false
  5285. };
  5286. this.decodeGeometry(p2, h2).then(s).catch(o);
  5287. }, r, o);
  5288. }
  5289. /** @deprecated Kept for backward-compatibility with previous DRACOLoader versions. */
  5290. decodeDracoFile(i, s, r, o) {
  5291. const c = {
  5292. attributeIDs: r || this.defaultAttributeIDs,
  5293. attributeTypes: o || this.defaultAttributeTypes,
  5294. useUniqueIDs: !!r
  5295. };
  5296. this.decodeGeometry(i, c).then(s);
  5297. }
  5298. decodeGeometry(i, s) {
  5299. for (const m in s.attributeTypes) {
  5300. const g = s.attributeTypes[m];
  5301. g.BYTES_PER_ELEMENT !== void 0 && (s.attributeTypes[m] = g.name);
  5302. }
  5303. const r = JSON.stringify(s);
  5304. if (ao.has(i)) {
  5305. const m = ao.get(i);
  5306. if (m.key === r)
  5307. return m.promise;
  5308. if (i.byteLength === 0)
  5309. throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.");
  5310. }
  5311. let o;
  5312. const c = this.workerNextTaskID++, p2 = i.byteLength, h2 = this._getWorker(c, p2).then((m) => (o = m, new Promise((g, w) => {
  5313. o._callbacks[c] = {
  5314. resolve: g,
  5315. reject: w
  5316. }, o.postMessage({
  5317. type: "decode",
  5318. id: c,
  5319. taskConfig: s,
  5320. buffer: i
  5321. }, [i]);
  5322. }))).then((m) => this._createGeometry(m.geometry));
  5323. return h2.catch(() => true).then(() => {
  5324. o && c && this._releaseTask(o, c);
  5325. }), ao.set(i, {
  5326. key: r,
  5327. promise: h2
  5328. }), h2;
  5329. }
  5330. _createGeometry(i) {
  5331. const s = new BufferGeometry();
  5332. i.index && s.setIndex(new BufferAttribute(i.index.array, 1));
  5333. for (let r = 0; r < i.attributes.length; r++) {
  5334. const o = i.attributes[r], c = o.name, p2 = o.array, h2 = o.itemSize;
  5335. s.setAttribute(c, new BufferAttribute(p2, h2));
  5336. }
  5337. return s;
  5338. }
  5339. _loadLibrary(i, s) {
  5340. const r = new FileLoader(this.manager);
  5341. return r.setPath(this.decoderPath), r.setResponseType(s), r.setWithCredentials(this.withCredentials), new Promise((o, c) => {
  5342. r.load(i, o, void 0, c);
  5343. });
  5344. }
  5345. preload() {
  5346. return this._initDecoder(), this;
  5347. }
  5348. _initDecoder() {
  5349. if (this.decoderPending)
  5350. return this.decoderPending;
  5351. const i = typeof WebAssembly != "object" || this.decoderConfig.type === "js", s = [];
  5352. return i ? s.push(this._loadLibrary("draco_decoder.js", "text")) : (s.push(this._loadLibrary("draco_wasm_wrapper.js", "text")), s.push(this._loadLibrary("draco_decoder.wasm", "arraybuffer"))), this.decoderPending = Promise.all(s).then((r) => {
  5353. const o = r[0];
  5354. i || (this.decoderConfig.wasmBinary = r[1]);
  5355. const c = Ph.toString(), p2 = ["/* draco decoder */", o, "", "/* worker */", c.substring(c.indexOf("{") + 1, c.lastIndexOf("}"))].join(`
  5356. `);
  5357. this.workerSourceURL = URL.createObjectURL(new Blob([p2]));
  5358. }), this.decoderPending;
  5359. }
  5360. _getWorker(i, s) {
  5361. return this._initDecoder().then(() => {
  5362. if (this.workerPool.length < this.workerLimit) {
  5363. const o = new Worker(this.workerSourceURL);
  5364. o._callbacks = {}, o._taskCosts = {}, o._taskLoad = 0, o.postMessage({
  5365. type: "init",
  5366. decoderConfig: this.decoderConfig
  5367. }), o.onmessage = function(c) {
  5368. const p2 = c.data;
  5369. switch (p2.type) {
  5370. case "decode":
  5371. o._callbacks[p2.id].resolve(p2);
  5372. break;
  5373. case "error":
  5374. o._callbacks[p2.id].reject(p2);
  5375. break;
  5376. default:
  5377. console.error('THREE.DRACOLoader: Unexpected message, "' + p2.type + '"');
  5378. }
  5379. }, this.workerPool.push(o);
  5380. } else
  5381. this.workerPool.sort(function(o, c) {
  5382. return o._taskLoad > c._taskLoad ? -1 : 1;
  5383. });
  5384. const r = this.workerPool[this.workerPool.length - 1];
  5385. return r._taskCosts[i] = s, r._taskLoad += s, r;
  5386. });
  5387. }
  5388. _releaseTask(i, s) {
  5389. i._taskLoad -= i._taskCosts[s], delete i._callbacks[s], delete i._taskCosts[s];
  5390. }
  5391. debug() {
  5392. console.log("Task load: ", this.workerPool.map((i) => i._taskLoad));
  5393. }
  5394. dispose() {
  5395. for (let i = 0; i < this.workerPool.length; ++i)
  5396. this.workerPool[i].terminate();
  5397. return this.workerPool.length = 0, this;
  5398. }
  5399. };
  5400. function Ph() {
  5401. let f, i;
  5402. onmessage = function(p2) {
  5403. const h2 = p2.data;
  5404. switch (h2.type) {
  5405. case "init":
  5406. f = h2.decoderConfig, i = new Promise(function(w) {
  5407. f.onModuleLoaded = function(_2) {
  5408. w({
  5409. draco: _2
  5410. });
  5411. }, DracoDecoderModule(f);
  5412. });
  5413. break;
  5414. case "decode":
  5415. const m = h2.buffer, g = h2.taskConfig;
  5416. i.then((w) => {
  5417. const _2 = w.draco, y = new _2.Decoder(), C = new _2.DecoderBuffer();
  5418. C.Init(new Int8Array(m), m.byteLength);
  5419. try {
  5420. const L = s(_2, y, C, g), S = L.attributes.map((R) => R.array.buffer);
  5421. L.index && S.push(L.index.array.buffer), self.postMessage({
  5422. type: "decode",
  5423. id: h2.id,
  5424. geometry: L
  5425. }, S);
  5426. } catch (L) {
  5427. console.error(L), self.postMessage({
  5428. type: "error",
  5429. id: h2.id,
  5430. error: L.message
  5431. });
  5432. } finally {
  5433. _2.destroy(C), _2.destroy(y);
  5434. }
  5435. });
  5436. break;
  5437. }
  5438. };
  5439. function s(p2, h2, m, g) {
  5440. const w = g.attributeIDs, _2 = g.attributeTypes;
  5441. let y, C;
  5442. const L = h2.GetEncodedGeometryType(m);
  5443. if (L === p2.TRIANGULAR_MESH)
  5444. y = new p2.Mesh(), C = h2.DecodeBufferToMesh(m, y);
  5445. else if (L === p2.POINT_CLOUD)
  5446. y = new p2.PointCloud(), C = h2.DecodeBufferToPointCloud(m, y);
  5447. else
  5448. throw new Error("THREE.DRACOLoader: Unexpected geometry type.");
  5449. if (!C.ok() || y.ptr === 0)
  5450. throw new Error("THREE.DRACOLoader: Decoding failed: " + C.error_msg());
  5451. const S = {
  5452. index: null,
  5453. attributes: []
  5454. };
  5455. for (const R in w) {
  5456. const O = self[_2[R]];
  5457. let N, I2;
  5458. if (g.useUniqueIDs)
  5459. I2 = w[R], N = h2.GetAttributeByUniqueId(y, I2);
  5460. else {
  5461. if (I2 = h2.GetAttributeId(y, p2[w[R]]), I2 === -1)
  5462. continue;
  5463. N = h2.GetAttribute(y, I2);
  5464. }
  5465. S.attributes.push(o(p2, h2, y, R, O, N));
  5466. }
  5467. return L === p2.TRIANGULAR_MESH && (S.index = r(p2, h2, y)), p2.destroy(y), S;
  5468. }
  5469. function r(p2, h2, m) {
  5470. const w = m.num_faces() * 3, _2 = w * 4, y = p2._malloc(_2);
  5471. h2.GetTrianglesUInt32Array(m, _2, y);
  5472. const C = new Uint32Array(p2.HEAPF32.buffer, y, w).slice();
  5473. return p2._free(y), {
  5474. array: C,
  5475. itemSize: 1
  5476. };
  5477. }
  5478. function o(p2, h2, m, g, w, _2) {
  5479. const y = _2.num_components(), L = m.num_points() * y, S = L * w.BYTES_PER_ELEMENT, R = c(p2, w), O = p2._malloc(S);
  5480. h2.GetAttributeDataArrayForAllPoints(m, _2, R, S, O);
  5481. const N = new w(p2.HEAPF32.buffer, O, L).slice();
  5482. return p2._free(O), {
  5483. name: g,
  5484. array: N,
  5485. itemSize: y
  5486. };
  5487. }
  5488. function c(p2, h2) {
  5489. switch (h2) {
  5490. case Float32Array:
  5491. return p2.DT_FLOAT32;
  5492. case Int8Array:
  5493. return p2.DT_INT8;
  5494. case Int16Array:
  5495. return p2.DT_INT16;
  5496. case Int32Array:
  5497. return p2.DT_INT32;
  5498. case Uint8Array:
  5499. return p2.DT_UINT8;
  5500. case Uint16Array:
  5501. return p2.DT_UINT16;
  5502. case Uint32Array:
  5503. return p2.DT_UINT32;
  5504. }
  5505. }
  5506. }
  5507. function Ut() {
  5508. const { state: f, setState: i } = inject("useTres", _()), s = inject("extend") || (() => {
  5509. });
  5510. return {
  5511. state: f,
  5512. setState: i,
  5513. extend: s
  5514. };
  5515. }
  5516. var Th = ["args", "center"];
  5517. var Dd = defineComponent({
  5518. __name: "Text3D",
  5519. props: {
  5520. font: null,
  5521. text: null,
  5522. size: { default: 0.5 },
  5523. height: { default: 0.2 },
  5524. curveSegments: { default: 5 },
  5525. bevelEnabled: { type: Boolean, default: true },
  5526. bevelThickness: { default: 0.05 },
  5527. bevelSize: { default: 0.02 },
  5528. bevelOffset: { default: 0 },
  5529. bevelSegments: { default: 4 },
  5530. center: { type: Boolean, default: false },
  5531. needUpdates: { type: Boolean, default: false }
  5532. },
  5533. async setup(f, { expose: i }) {
  5534. let s, r;
  5535. const o = f, { extend: c } = Ut();
  5536. c({ TextGeometry: ya });
  5537. const p2 = new _h(), h2 = useSlots(), m = computed(() => {
  5538. var y;
  5539. return o.text ? o.text : h2.default ? (y = h2.default()[0].children) == null ? void 0 : y.trim() : o.needUpdates ? "" : "TresJS";
  5540. }), g = shallowRef();
  5541. i({
  5542. value: g
  5543. });
  5544. const w = ([s, r] = withAsyncContext(() => new Promise((y, C) => {
  5545. try {
  5546. typeof o.font == "string" ? p2.load(o.font, (L) => {
  5547. y(L);
  5548. }) : y(o.font);
  5549. } catch (L) {
  5550. C(console.error("cientos", L));
  5551. }
  5552. })), s = await s, r(), s), _2 = computed(() => ({
  5553. font: w,
  5554. size: o.size,
  5555. height: o.height,
  5556. curveSegments: o.curveSegments,
  5557. bevelEnabled: o.bevelEnabled,
  5558. bevelThickness: o.bevelThickness,
  5559. bevelSize: o.bevelSize,
  5560. bevelOffset: o.bevelOffset,
  5561. bevelSegments: o.bevelSegments
  5562. }));
  5563. return watchEffect(() => {
  5564. g.value && o.needUpdates && (g.value.geometry.dispose(), g.value.geometry = new ya(m.value, _2.value), o.center && g.value.geometry.center());
  5565. }), (y, C) => unref(w) ? (openBlock(), createElementBlock("TresMesh", {
  5566. key: 0,
  5567. ref_key: "text3DRef",
  5568. ref: g
  5569. }, [
  5570. unref(m) ? (openBlock(), createElementBlock("TresTextGeometry", {
  5571. key: 0,
  5572. args: [unref(m), unref(_2)],
  5573. center: f.center
  5574. }, null, 8, Th)) : createCommentVNode("", true),
  5575. renderSlot(y.$slots, "default")
  5576. ], 512)) : createCommentVNode("", true);
  5577. }
  5578. });
  5579. function Od(f, i) {
  5580. const s = ref(i), r = new AnimationMixer(s.value), o = shallowReactive({});
  5581. f.forEach((p2) => {
  5582. const h2 = r.clipAction(p2, s.value);
  5583. o[p2.name] = h2;
  5584. });
  5585. const { onLoop: c } = Pe();
  5586. return c(({ delta: p2 }) => {
  5587. r.update(p2);
  5588. }), {
  5589. actions: o,
  5590. mixer: r
  5591. };
  5592. }
  5593. var lo = {
  5594. sunset: "venice/venice_sunset_4k.hdr"
  5595. };
  5596. async function kh({
  5597. files: f = ["/px.png", "/nx.png", "/py.png", "/ny.png", "/pz.png", "/nz.png"],
  5598. blur: i = 0,
  5599. background: s = false,
  5600. path: r = "/",
  5601. preset: o = void 0
  5602. }) {
  5603. const { state: c } = Ut();
  5604. if (o) {
  5605. if (!(o in lo))
  5606. throw new Error("Preset must be one of: " + Object.keys(lo).join(", "));
  5607. f = lo[o], r = "https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/";
  5608. }
  5609. const p2 = Array.isArray(f), m = await Rt(
  5610. p2 ? CubeTextureLoader : Eh,
  5611. p2 ? [f] : f,
  5612. (w) => {
  5613. r && w.setPath(r);
  5614. }
  5615. ), g = p2 ? m[0] : m;
  5616. return g && (g.mapping = p2 ? CubeReflectionMapping : EquirectangularReflectionMapping, g.colorSpace = SRGBColorSpace), c.scene && (c.scene.environment = g, s !== void 0 && (c.scene.background = g), i && (c.scene.backgroundBlurriness = i | 0)), g;
  5617. }
  5618. var Nd = defineComponent({
  5619. name: "Environment",
  5620. props: ["background", "blur", "files", "encoding", "path", "preset"],
  5621. async setup(f, { expose: i }) {
  5622. let s = null;
  5623. return i({ getTexture: () => s }), s = await kh(f), () => {
  5624. };
  5625. }
  5626. });
  5627. function sl(f) {
  5628. return getCurrentScope() ? (onScopeDispose(f), true) : false;
  5629. }
  5630. function rl(f) {
  5631. return typeof f == "function" ? f() : unref(f);
  5632. }
  5633. var Ah = typeof window < "u";
  5634. var ol = () => {
  5635. };
  5636. function Mh(...f) {
  5637. if (f.length !== 1)
  5638. return toRef(...f);
  5639. const i = f[0];
  5640. return typeof i == "function" ? readonly(customRef(() => ({ get: i, set: ol }))) : ref(i);
  5641. }
  5642. function Sh(f, i = true) {
  5643. getCurrentInstance() ? onMounted(f) : i ? f() : nextTick(f);
  5644. }
  5645. function Lh(f) {
  5646. var i;
  5647. const s = rl(f);
  5648. return (i = s == null ? void 0 : s.$el) != null ? i : s;
  5649. }
  5650. var Ys = Ah ? window : void 0;
  5651. function Bn(...f) {
  5652. let i, s, r, o;
  5653. if (typeof f[0] == "string" || Array.isArray(f[0]) ? ([s, r, o] = f, i = Ys) : [i, s, r, o] = f, !i)
  5654. return ol;
  5655. Array.isArray(s) || (s = [s]), Array.isArray(r) || (r = [r]);
  5656. const c = [], p2 = () => {
  5657. c.forEach((w) => w()), c.length = 0;
  5658. }, h2 = (w, _2, y, C) => (w.addEventListener(_2, y, C), () => w.removeEventListener(_2, y, C)), m = watch(
  5659. () => [Lh(i), rl(o)],
  5660. ([w, _2]) => {
  5661. p2(), w && c.push(
  5662. ...s.flatMap((y) => r.map((C) => h2(w, y, C, _2)))
  5663. );
  5664. },
  5665. { immediate: true, flush: "post" }
  5666. ), g = () => {
  5667. m(), p2();
  5668. };
  5669. return sl(g), g;
  5670. }
  5671. function Rh() {
  5672. const f = ref(false);
  5673. return getCurrentInstance() && onMounted(() => {
  5674. f.value = true;
  5675. }), f;
  5676. }
  5677. function Vh(f) {
  5678. const i = Rh();
  5679. return computed(() => (i.value, !!f()));
  5680. }
  5681. function Ih(f, i = {}) {
  5682. const { window: s = Ys } = i, r = Vh(() => s && "matchMedia" in s && typeof s.matchMedia == "function");
  5683. let o;
  5684. const c = ref(false), p2 = () => {
  5685. o && ("removeEventListener" in o ? o.removeEventListener("change", h2) : o.removeListener(h2));
  5686. }, h2 = () => {
  5687. r.value && (p2(), o = s.matchMedia(Mh(f).value), c.value = !!(o != null && o.matches), o && ("addEventListener" in o ? o.addEventListener("change", h2) : o.addListener(h2)));
  5688. };
  5689. return watchEffect(h2), sl(() => p2()), c;
  5690. }
  5691. var Dh = {
  5692. page: (f) => [f.pageX, f.pageY],
  5693. client: (f) => [f.clientX, f.clientY],
  5694. screen: (f) => [f.screenX, f.screenY],
  5695. movement: (f) => f instanceof Touch ? null : [f.movementX, f.movementY]
  5696. };
  5697. function Oh(f = {}) {
  5698. const {
  5699. type: i = "page",
  5700. touch: s = true,
  5701. resetOnTouchEnds: r = false,
  5702. initialValue: o = { x: 0, y: 0 },
  5703. window: c = Ys,
  5704. target: p2 = c,
  5705. eventFilter: h2
  5706. } = f, m = ref(o.x), g = ref(o.y), w = ref(null), _2 = typeof i == "function" ? i : Dh[i], y = (O) => {
  5707. const N = _2(O);
  5708. N && ([m.value, g.value] = N, w.value = "mouse");
  5709. }, C = (O) => {
  5710. if (O.touches.length > 0) {
  5711. const N = _2(O.touches[0]);
  5712. N && ([m.value, g.value] = N, w.value = "touch");
  5713. }
  5714. }, L = () => {
  5715. m.value = o.x, g.value = o.y;
  5716. }, S = h2 ? (O) => h2(() => y(O), {}) : (O) => y(O), R = h2 ? (O) => h2(() => C(O), {}) : (O) => C(O);
  5717. return p2 && (Bn(p2, "mousemove", S, { passive: true }), Bn(p2, "dragover", S, { passive: true }), s && i !== "movement" && (Bn(p2, "touchstart", R, { passive: true }), Bn(p2, "touchmove", R, { passive: true }), r && Bn(p2, "touchend", L, { passive: true }))), {
  5718. x: m,
  5719. y: g,
  5720. sourceType: w
  5721. };
  5722. }
  5723. function Nh(f = {}) {
  5724. const {
  5725. window: i = Ys,
  5726. initialWidth: s = 1 / 0,
  5727. initialHeight: r = 1 / 0,
  5728. listenOrientation: o = true,
  5729. includeScrollbar: c = true
  5730. } = f, p2 = ref(s), h2 = ref(r), m = () => {
  5731. i && (c ? (p2.value = i.innerWidth, h2.value = i.innerHeight) : (p2.value = i.document.documentElement.clientWidth, h2.value = i.document.documentElement.clientHeight));
  5732. };
  5733. if (m(), Sh(m), Bn("resize", m, { passive: true }), o) {
  5734. const g = Ih("(orientation: portrait)");
  5735. watch(g, () => m());
  5736. }
  5737. return { width: p2, height: h2 };
  5738. }
  5739. function Bh(f = false, i = 5, s) {
  5740. const { x: r, y: o } = Oh(), { logWarning: c } = I(), { width: p2, height: h2 } = Nh(), m = computed(() => (r.value / p2.value - 0.5) * i), g = computed(() => -(o.value / h2.value - 0.5) * i);
  5741. if (s) {
  5742. const { x: w, y: _2 } = s.position;
  5743. watchEffect(() => {
  5744. f || s && (s.position.x = w + m.value, s.position.y = _2 + g.value);
  5745. });
  5746. } else
  5747. c("Scene must contain a Camera component to use this composable");
  5748. }
  5749. var Bd = defineComponent({
  5750. name: "PamCameraMouse",
  5751. props: ["disabled", "factor"],
  5752. setup(f) {
  5753. const { state: i } = Ut();
  5754. return watchEffect(() => {
  5755. if (i != null && i.camera) {
  5756. const s = i == null ? void 0 : i.camera;
  5757. Bh(f.disabled, f.factor, s);
  5758. }
  5759. }), () => {
  5760. };
  5761. }
  5762. });
  5763. var Fh = ["position", "a-scale"];
  5764. var Fd = defineComponent({
  5765. __name: "Stars",
  5766. props: {
  5767. size: { default: 0.1 },
  5768. sizeAttenuation: { type: Boolean, default: true },
  5769. transparent: { type: Boolean, default: true },
  5770. alphaTest: { default: 0.01 },
  5771. count: { default: 5e3 },
  5772. depth: { default: 50 },
  5773. radius: { default: 100 },
  5774. factor: { default: 4 },
  5775. alphaMap: { default: null }
  5776. },
  5777. setup(f, { expose: i }) {
  5778. const s = f;
  5779. let r = s.radius + s.depth;
  5780. const o = s.depth / s.count, c = [], p2 = Array.from({ length: s.count }, () => (0.5 + 0.5 * Math.random()) * s.factor), h2 = (y) => new Vector3().setFromSpherical(new Spherical(y, Math.acos(1 - Math.random() * 2), Math.random() * 2 * Math.PI));
  5781. for (let y = 0; y < s.count; y++)
  5782. r -= o * Math.random(), c.push(...h2(r).toArray());
  5783. const m = new Float32Array(c), g = new Float32Array(p2), w = computed(() => ({
  5784. size: s.size,
  5785. sizeAttenuation: s.sizeAttenuation,
  5786. transparent: s.transparent,
  5787. alphaTest: s.alphaTest,
  5788. alphaMap: s.alphaMap
  5789. })), _2 = shallowRef();
  5790. return i({
  5791. value: _2
  5792. }), (y, C) => (openBlock(), createElementBlock("TresPoints", {
  5793. ref_key: "starsRef",
  5794. ref: _2
  5795. }, [
  5796. createBaseVNode("TresBufferGeometry", {
  5797. position: [unref(m), 3],
  5798. "a-scale": [unref(g), 1]
  5799. }, null, 8, Fh),
  5800. createBaseVNode("TresPointsMaterial", normalizeProps(guardReactiveProps(unref(w))), null, 16)
  5801. ], 512));
  5802. }
  5803. });
  5804. var jh = ["position"];
  5805. var zh = ["position"];
  5806. var Uh = ["scale"];
  5807. var Gh = ["map", "map-encoding", "depth-test", "color", "opacity"];
  5808. var jd = defineComponent({
  5809. __name: "Smoke",
  5810. props: {
  5811. color: { default: "#ffffff" },
  5812. opacity: { default: 0.5 },
  5813. speed: { default: 0.4 },
  5814. width: { default: 10 },
  5815. depth: { default: 1.5 },
  5816. segments: { default: 20 },
  5817. texture: { default: "https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png" },
  5818. depthTest: { type: Boolean, default: true }
  5819. },
  5820. async setup(f, { expose: i }) {
  5821. let s, r;
  5822. const o = f, c = shallowRef(), p2 = shallowRef();
  5823. i({
  5824. value: c
  5825. });
  5826. const h2 = [...new Array(o.segments)].map((C, L) => ({
  5827. x: o.width / 2 - Math.random() * o.width,
  5828. y: o.width / 2 - Math.random() * o.width,
  5829. scale: 0.4 + Math.sin((L + 1) / o.segments * Math.PI) * ((0.2 + Math.random()) * 10),
  5830. density: Math.max(0.2, Math.random()),
  5831. rotation: Math.max(2e-3, 5e-3 * Math.random()) * o.speed
  5832. })), m = (C, L) => C / 6 * L * o.opacity, { map: g } = ([s, r] = withAsyncContext(() => Et({ map: o.texture })), s = await s, r(), s), { state: w } = Ut(), _2 = computed(() => {
  5833. var C;
  5834. return (C = w.renderer) == null ? void 0 : C.outputColorSpace;
  5835. }), { onLoop: y } = Pe();
  5836. return y(() => {
  5837. var C, L;
  5838. c.value && w.camera && p2.value && ((C = p2.value) == null || C.children.forEach((S, R) => {
  5839. S.rotation.z += h2[R].rotation;
  5840. }), c.value.lookAt((L = w.camera) == null ? void 0 : L.position));
  5841. }), (C, L) => (openBlock(), createElementBlock("TresGroup", mergeProps({
  5842. ref_key: "smokeRef",
  5843. ref: c
  5844. }, C.$attrs), [
  5845. createBaseVNode("TresGroup", {
  5846. ref_key: "groupRef",
  5847. ref: p2,
  5848. position: [0, 0, f.segments / 2 * f.depth]
  5849. }, [
  5850. (openBlock(true), createElementBlock(Fragment, null, renderList(unref(h2), ({ scale: S, x: R, y: O, density: N }, I2) => (openBlock(), createElementBlock("TresMesh", {
  5851. key: I2,
  5852. position: [R, O, -I2 * f.depth]
  5853. }, [
  5854. createBaseVNode("TresPlaneGeometry", {
  5855. scale: [S, S, S],
  5856. rotation: [0, 0, 0]
  5857. }, null, 8, Uh),
  5858. createBaseVNode("TresMeshStandardMaterial", {
  5859. map: unref(g),
  5860. "map-encoding": unref(_2),
  5861. "depth-test": f.depthTest,
  5862. color: f.color,
  5863. "depth-write": false,
  5864. transparent: "",
  5865. opacity: m(S, N)
  5866. }, null, 8, Gh)
  5867. ], 8, zh))), 128))
  5868. ], 8, jh)
  5869. ], 16));
  5870. }
  5871. });
  5872. var zd = defineComponent({
  5873. __name: "Levioso",
  5874. props: {
  5875. speed: { default: 1 },
  5876. rotationFactor: { default: 1 },
  5877. floatFactor: { default: 1 },
  5878. range: { default: () => [-0.1, 0.1] }
  5879. },
  5880. setup(f, { expose: i }) {
  5881. const s = f, r = shallowRef();
  5882. i({
  5883. value: r
  5884. });
  5885. const { onLoop: o } = Pe(), c = ref(Math.random() * 1e4);
  5886. return o(({ elapsed: p2 }) => {
  5887. var g, w;
  5888. if (!r.value)
  5889. return;
  5890. const h2 = c.value + p2;
  5891. r.value.rotation.x = Math.cos(h2 / 4 * s.speed) / 8 * s.rotationFactor, r.value.rotation.y = Math.sin(h2 / 4 * s.speed) / 8 * s.rotationFactor, r.value.rotation.z = Math.sin(h2 / 4 * s.speed) / 20 * s.rotationFactor;
  5892. let m = Math.sin(h2 / 4 * s.speed) / 10;
  5893. m = MathUtils.mapLinear(m, -0.1, 0.1, ((g = s.range) == null ? void 0 : g[0]) ?? -0.1, ((w = s.range) == null ? void 0 : w[1]) ?? 0.1), r.value.position.y = m * s.floatFactor;
  5894. }), (p2, h2) => (openBlock(), createElementBlock("TresGroup", mergeProps(p2.$attrs, {
  5895. ref_key: "groupRef",
  5896. ref: r
  5897. }), [
  5898. renderSlot(p2.$slots, "default")
  5899. ], 16));
  5900. }
  5901. });
  5902. var zs = null;
  5903. function Hh(f, i) {
  5904. return (s) => {
  5905. i && i(s), f.draco && (zs || (zs = new Ch()), zs.setDecoderPath(f.decoderPath || "https://www.gstatic.com/draco/versioned/decoders/1.4.3/"), s.setDRACOLoader(zs));
  5906. };
  5907. }
  5908. async function Kh(f, i = {
  5909. draco: false
  5910. }, s) {
  5911. return await Rt(xp, f, Hh(i, s));
  5912. }
  5913. var Ud = defineComponent({
  5914. __name: "component",
  5915. props: {
  5916. path: null,
  5917. draco: { type: Boolean, default: false },
  5918. decoderPath: { default: "https://www.gstatic.com/draco/versioned/decoders/1.4.1/" }
  5919. },
  5920. async setup(f, { expose: i }) {
  5921. let s, r;
  5922. const o = f, c = ref();
  5923. i({
  5924. value: c
  5925. });
  5926. const { scene: p2 } = ([s, r] = withAsyncContext(() => Kh(o.path, { draco: o.draco, decoderPath: o.decoderPath })), s = await s, r(), s);
  5927. return (h2, m) => {
  5928. const g = resolveComponent("primitive");
  5929. return openBlock(), createBlock(g, mergeProps({
  5930. ref_key: "modelRef",
  5931. ref: c,
  5932. object: unref(p2)
  5933. }, h2.$attrs), null, 16, ["object"]);
  5934. };
  5935. }
  5936. });
  5937. async function $h(f) {
  5938. return await Rt(ah, f);
  5939. }
  5940. var Gd = defineComponent({
  5941. __name: "component",
  5942. props: {
  5943. path: null
  5944. },
  5945. async setup(f, { expose: i }) {
  5946. let s, r;
  5947. const o = f, c = ref();
  5948. i({
  5949. value: c
  5950. });
  5951. const p2 = ([s, r] = withAsyncContext(() => $h(o.path)), s = await s, r(), s);
  5952. return (h2, m) => {
  5953. const g = resolveComponent("primitive");
  5954. return openBlock(), createBlock(g, mergeProps({
  5955. ref_key: "modelRef",
  5956. ref: c,
  5957. object: unref(p2)
  5958. }, h2.$attrs), null, 16, ["object"]);
  5959. };
  5960. }
  5961. });
  5962. var Xh = ["args"];
  5963. var Hd = defineComponent({
  5964. __name: "OrbitControls",
  5965. props: {
  5966. makeDefault: { type: Boolean, default: false },
  5967. camera: null,
  5968. domElement: null,
  5969. target: null,
  5970. enableDamping: { type: Boolean }
  5971. },
  5972. setup(f) {
  5973. const i = f, { state: s, setState: r, extend: o } = Ut(), c = ref(null);
  5974. return o({ OrbitControls: qa }), watch(c, (p2) => {
  5975. p2 && i.makeDefault ? r("controls", p2) : r("controls", null);
  5976. }), (p2, h2) => {
  5977. var m;
  5978. return unref(s).camera && unref(s).renderer ? (openBlock(), createElementBlock("TresOrbitControls", {
  5979. key: 0,
  5980. ref_key: "controls",
  5981. ref: c,
  5982. args: [unref(s).camera || f.camera, ((m = unref(s).renderer) == null ? void 0 : m.domElement) || f.domElement]
  5983. }, null, 8, Xh)) : createCommentVNode("", true);
  5984. };
  5985. }
  5986. });
  5987. function Yh(f, i) {
  5988. const s = {};
  5989. for (const r of i)
  5990. Object.prototype.hasOwnProperty.call(f, r) && (s[r] = f[r]);
  5991. return s;
  5992. }
  5993. function qh(f, i) {
  5994. const s = `set${i[0].toUpperCase()}${i.slice(1)}`;
  5995. return f[s] !== void 0;
  5996. }
  5997. var Kd = defineComponent({
  5998. __name: "TransformControls",
  5999. props: {
  6000. object: null,
  6001. mode: null,
  6002. enabled: { type: Boolean, default: true },
  6003. axis: null,
  6004. translationSnap: null,
  6005. rotationSnap: null,
  6006. scaleSnap: null,
  6007. space: null,
  6008. size: null,
  6009. showX: { type: Boolean },
  6010. showY: { type: Boolean },
  6011. showZ: { type: Boolean }
  6012. },
  6013. emits: ["dragging", "change", "mouseDown", "mouseUp", "objectChange"],
  6014. setup(f, { emit: i }) {
  6015. const s = f;
  6016. let r = shallowRef();
  6017. const { state: o } = Ut(), c = computed(
  6018. () => Yh(s, [
  6019. "enabled",
  6020. "axis",
  6021. "mode",
  6022. "translationSnap",
  6023. "rotationSnap",
  6024. "scaleSnap",
  6025. "space",
  6026. "size",
  6027. "showX",
  6028. "showY",
  6029. "showZ"
  6030. ])
  6031. ), p2 = () => i("change", r.value), h2 = () => i("mouseDown", r.value), m = () => i("mouseUp", r.value), g = () => i("objectChange", r.value), w = (y) => {
  6032. o.controls && (o.controls.enabled = !y.value), i("dragging", y.value);
  6033. };
  6034. function _2(y) {
  6035. y.addEventListener("dragging-changed", w), y.addEventListener("change", p2), y.addEventListener("mouseDown", h2), y.addEventListener("mouseUp", m), y.addEventListener("objectChange", g);
  6036. }
  6037. return watchEffect(() => {
  6038. o.camera && o.renderer && o.scene && s.object && (r.value = new mp(o.camera, o.renderer.domElement), r.value.attach(s.object), o.scene.add(r.value), _2(r.value));
  6039. }), watch(
  6040. [c, r],
  6041. // TODO: properly type this
  6042. ([y, C]) => {
  6043. if (y && C)
  6044. for (const L in y)
  6045. if (!qh(C, L))
  6046. C[L] = y[L];
  6047. else {
  6048. const S = `set${L[0].toUpperCase()}${L.slice(1)}`;
  6049. typeof C[S] == "function" && y[L] !== void 0 && C[S](y[L]);
  6050. }
  6051. },
  6052. {
  6053. immediate: true
  6054. }
  6055. ), onUnmounted(() => {
  6056. r.value && (r.value.removeEventListener("dragging-changed", w), r.value.removeEventListener("change", p2), r.value.removeEventListener("mouseDown", h2), r.value.removeEventListener("mouseUp", m), r.value.removeEventListener("objectChange", g));
  6057. }), (y, C) => renderSlot(y.$slots, "default");
  6058. }
  6059. });
  6060. var Qh = ["args"];
  6061. var $d = defineComponent({
  6062. __name: "PointerLockControls",
  6063. props: {
  6064. makeDefault: { type: Boolean, default: false },
  6065. camera: null,
  6066. domElement: null,
  6067. selector: null
  6068. },
  6069. setup(f, { expose: i }) {
  6070. const s = f, { state: r, setState: o, extend: c } = Ut(), p2 = ref(null);
  6071. let h2;
  6072. return c({ PointerLockControls: wp }), watch(p2, (m) => {
  6073. var w;
  6074. m && s.makeDefault ? o("controls", m) : o("controls", null);
  6075. const g = document.getElementById(s.selector || "");
  6076. h2 = g || ((w = r.renderer) == null ? void 0 : w.domElement), Bn(h2, "click", () => {
  6077. var _2;
  6078. (_2 = p2.value) == null || _2.lock();
  6079. });
  6080. }), i({
  6081. value: p2
  6082. }), (m, g) => {
  6083. var w;
  6084. return unref(r).camera && unref(r).renderer ? (openBlock(), createElementBlock("TresPointerLockControls", {
  6085. key: 0,
  6086. ref_key: "controls",
  6087. ref: p2,
  6088. args: [unref(r).camera || f.camera, ((w = unref(r).renderer) == null ? void 0 : w.domElement) || f.domElement]
  6089. }, null, 8, Qh)) : createCommentVNode("", true);
  6090. };
  6091. }
  6092. });
  6093. var Zh = ["args"];
  6094. var Xd = defineComponent({
  6095. __name: "MapControls",
  6096. props: {
  6097. makeDefault: { type: Boolean, default: false },
  6098. camera: null,
  6099. domElement: null
  6100. },
  6101. setup(f) {
  6102. const i = f, { state: s, setState: r, extend: o } = Ut(), c = ref(null);
  6103. return o({ MapControls: yp }), watch(c, (p2) => {
  6104. p2 && i.makeDefault ? r("controls", p2) : r("controls", null);
  6105. }), (p2, h2) => {
  6106. var m;
  6107. return unref(s).camera && unref(s).renderer ? (openBlock(), createElementBlock("TresMapControls", {
  6108. key: 0,
  6109. ref_key: "controls",
  6110. ref: c,
  6111. args: [unref(s).camera || f.camera, ((m = unref(s).renderer) == null ? void 0 : m.domElement) || f.domElement]
  6112. }, null, 8, Zh)) : createCommentVNode("", true);
  6113. };
  6114. }
  6115. });
  6116. var Wh = class extends MeshStandardMaterial {
  6117. constructor(s = {}) {
  6118. super(s);
  6119. Zr(this, "_time");
  6120. Zr(this, "_factor");
  6121. this.setValues(s), this._time = { value: 0 }, this._factor = { value: 1 };
  6122. }
  6123. onBeforeCompile(s) {
  6124. s.uniforms || (s.uniforms = {}), s.uniforms.time = this._time, s.uniforms.factor = this._factor, s.vertexShader = `
  6125. uniform float time;
  6126. uniform float factor;
  6127. ${s.vertexShader}
  6128. `, s.vertexShader = s.vertexShader.replace(
  6129. "#include <begin_vertex>",
  6130. `float theta = sin( time + position.y ) / 2.0 * factor;
  6131. float c = cos( theta );
  6132. float s = sin( theta );
  6133. mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );
  6134. vec3 transformed = vec3( position ) * m;
  6135. vNormal = vNormal * m;`
  6136. );
  6137. }
  6138. get time() {
  6139. return this._time.value;
  6140. }
  6141. set time(s) {
  6142. this._time.value = s;
  6143. }
  6144. get factor() {
  6145. return this._factor.value;
  6146. }
  6147. set factor(s) {
  6148. this._factor.value = s;
  6149. }
  6150. };
  6151. var Jh = ["factor"];
  6152. var Yd = defineComponent({
  6153. __name: "index",
  6154. props: {
  6155. speed: { default: 1 },
  6156. factor: { default: 1 }
  6157. },
  6158. setup(f) {
  6159. const i = f, s = shallowRef(), { extend: r } = Ut();
  6160. r({ MeshWobbleMaterial: Wh });
  6161. const { onLoop: o } = Pe();
  6162. return o(({ elapsed: c }) => {
  6163. s.value && (s.value.time = c * (i == null ? void 0 : i.speed));
  6164. }), (c, p2) => (openBlock(), createElementBlock("TresMeshWobbleMaterial", mergeProps({
  6165. ref_key: "materialRef",
  6166. ref: s,
  6167. factor: f.factor
  6168. }, c.$attrs), null, 16, Jh));
  6169. }
  6170. });
  6171. var ed = ["args"];
  6172. var td = ["color"];
  6173. var qd = defineComponent({
  6174. __name: "Box",
  6175. props: {
  6176. args: { default: () => [1, 1, 1] },
  6177. color: { default: "0xffffff" }
  6178. },
  6179. setup(f, { expose: i }) {
  6180. const s = shallowRef();
  6181. return i({
  6182. value: s
  6183. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6184. ref_key: "boxRef",
  6185. ref: s
  6186. }, r.$attrs), [
  6187. createBaseVNode("TresBoxGeometry", { args: f.args }, null, 8, ed),
  6188. renderSlot(r.$slots, "default", {}, () => [
  6189. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, td)
  6190. ])
  6191. ], 16));
  6192. }
  6193. });
  6194. var nd = ["args"];
  6195. var id = ["color"];
  6196. var Qd = defineComponent({
  6197. __name: "Circle",
  6198. props: {
  6199. args: { default: () => [1, 32, 0, Math.PI * 2] },
  6200. color: { default: "0xffffff" }
  6201. },
  6202. setup(f, { expose: i }) {
  6203. const s = shallowRef();
  6204. return i({
  6205. value: s
  6206. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6207. ref_key: "circleRef",
  6208. ref: s
  6209. }, r.$attrs), [
  6210. createBaseVNode("TresCircleGeometry", { args: f.args }, null, 8, nd),
  6211. renderSlot(r.$slots, "default", {}, () => [
  6212. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, id)
  6213. ])
  6214. ], 16));
  6215. }
  6216. });
  6217. var sd = ["args"];
  6218. var rd = ["color"];
  6219. var Zd = defineComponent({
  6220. __name: "Cone",
  6221. props: {
  6222. args: { default: () => [1, 1, 12, false, 0, Math.PI * 2] },
  6223. color: { default: "0xffffff" }
  6224. },
  6225. setup(f, { expose: i }) {
  6226. const s = shallowRef();
  6227. return i({
  6228. value: s
  6229. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6230. ref_key: "coneRef",
  6231. ref: s
  6232. }, r.$attrs), [
  6233. createBaseVNode("TresConeGeometry", { args: f.args }, null, 8, sd),
  6234. renderSlot(r.$slots, "default", {}, () => [
  6235. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, rd)
  6236. ])
  6237. ], 16));
  6238. }
  6239. });
  6240. var od = ["args"];
  6241. var ad = ["color"];
  6242. var Wd = defineComponent({
  6243. __name: "Dodecahedron",
  6244. props: {
  6245. args: { default: () => [1, 0] },
  6246. color: { default: "0xffffff" }
  6247. },
  6248. setup(f, { expose: i }) {
  6249. const s = shallowRef();
  6250. return i({
  6251. value: s
  6252. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6253. ref_key: "dodecahedronRef",
  6254. ref: s
  6255. }, r.$attrs), [
  6256. createBaseVNode("TresDodecahedronGeometry", { args: f.args }, null, 8, od),
  6257. renderSlot(r.$slots, "default", {}, () => [
  6258. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, ad)
  6259. ])
  6260. ], 16));
  6261. }
  6262. });
  6263. var ld = ["args"];
  6264. var cd = ["color"];
  6265. var Jd = defineComponent({
  6266. __name: "Icosahedron",
  6267. props: {
  6268. args: { default: () => [1, 0] },
  6269. color: { default: "0xffffff" }
  6270. },
  6271. setup(f, { expose: i }) {
  6272. const s = shallowRef();
  6273. return i({
  6274. value: s
  6275. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6276. ref_key: "icosahedronRef",
  6277. ref: s
  6278. }, r.$attrs), [
  6279. createBaseVNode("TresIcosahedronGeometry", { args: f.args }, null, 8, ld),
  6280. renderSlot(r.$slots, "default", {}, () => [
  6281. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, cd)
  6282. ])
  6283. ], 16));
  6284. }
  6285. });
  6286. var ud = ["args"];
  6287. var pd = ["color"];
  6288. var em = defineComponent({
  6289. __name: "Octahedron",
  6290. props: {
  6291. args: { default: () => [1, 0] },
  6292. color: { default: "0xffffff" }
  6293. },
  6294. setup(f, { expose: i }) {
  6295. const s = shallowRef();
  6296. return i({
  6297. value: s
  6298. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6299. ref_key: "octahedronRef",
  6300. ref: s
  6301. }, r.$attrs), [
  6302. createBaseVNode("TresOctahedronGeometry", { args: f.args }, null, 8, ud),
  6303. renderSlot(r.$slots, "default", {}, () => [
  6304. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, pd)
  6305. ])
  6306. ], 16));
  6307. }
  6308. });
  6309. var hd = ["rotation"];
  6310. var dd = ["args"];
  6311. var md = ["color"];
  6312. var tm = defineComponent({
  6313. __name: "Plane",
  6314. props: {
  6315. args: { default: () => [1, 1] },
  6316. color: { default: "0xffffff" }
  6317. },
  6318. setup(f, { expose: i }) {
  6319. const s = shallowRef();
  6320. return i({
  6321. value: s
  6322. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6323. ref_key: "planeRef",
  6324. ref: s,
  6325. rotation: [-Math.PI / 2, 0, 0]
  6326. }, r.$attrs), [
  6327. createBaseVNode("TresPlaneGeometry", { args: f.args }, null, 8, dd),
  6328. renderSlot(r.$slots, "default", {}, () => [
  6329. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, md)
  6330. ])
  6331. ], 16, hd));
  6332. }
  6333. });
  6334. var fd = ["args"];
  6335. var vd = ["color"];
  6336. var nm = defineComponent({
  6337. __name: "Ring",
  6338. props: {
  6339. args: { default: () => [0.5, 1, 32] },
  6340. color: { default: "0xffffff" }
  6341. },
  6342. setup(f, { expose: i }) {
  6343. const s = shallowRef();
  6344. return i({
  6345. value: s
  6346. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6347. ref_key: "ringRef",
  6348. ref: s
  6349. }, r.$attrs), [
  6350. createBaseVNode("TresRingGeometry", { args: f.args }, null, 8, fd),
  6351. renderSlot(r.$slots, "default", {}, () => [
  6352. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, vd)
  6353. ])
  6354. ], 16));
  6355. }
  6356. });
  6357. var bd = ["args"];
  6358. var gd = ["color"];
  6359. var im = defineComponent({
  6360. __name: "Sphere",
  6361. props: {
  6362. args: { default: () => [2, 32, 16] },
  6363. color: { default: "0xffffff" }
  6364. },
  6365. setup(f, { expose: i }) {
  6366. const s = shallowRef();
  6367. return i({
  6368. value: s
  6369. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6370. ref_key: "sphereRef",
  6371. ref: s
  6372. }, r.$attrs), [
  6373. createBaseVNode("TresSphereGeometry", { args: f.args }, null, 8, bd),
  6374. renderSlot(r.$slots, "default", {}, () => [
  6375. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, gd)
  6376. ])
  6377. ], 16));
  6378. }
  6379. });
  6380. var _d = ["rotation"];
  6381. var wd = ["args"];
  6382. var yd = ["color"];
  6383. var sm = defineComponent({
  6384. __name: "Tetrahedron",
  6385. props: {
  6386. args: { default: () => [1, 0] },
  6387. color: { default: "0xffffff" }
  6388. },
  6389. setup(f, { expose: i }) {
  6390. const s = shallowRef();
  6391. return i({
  6392. value: s
  6393. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6394. ref_key: "tetrahedronRef",
  6395. ref: s,
  6396. rotation: [-Math.PI / 2, 0, 0]
  6397. }, r.$attrs), [
  6398. createBaseVNode("TresTetrahedronGeometry", { args: f.args }, null, 8, wd),
  6399. renderSlot(r.$slots, "default", {}, () => [
  6400. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, yd)
  6401. ])
  6402. ], 16, _d));
  6403. }
  6404. });
  6405. var xd = ["args"];
  6406. var Ed = ["color"];
  6407. var rm = defineComponent({
  6408. __name: "Torus",
  6409. props: {
  6410. args: { default: () => [1, 1, 16, 80] },
  6411. color: { default: "0xffffff" }
  6412. },
  6413. setup(f, { expose: i }) {
  6414. const s = shallowRef();
  6415. return i({
  6416. value: s
  6417. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6418. ref_key: "torusRef",
  6419. ref: s
  6420. }, r.$attrs), [
  6421. createBaseVNode("TresTorusGeometry", { args: f.args }, null, 8, xd),
  6422. renderSlot(r.$slots, "default", {}, () => [
  6423. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, Ed)
  6424. ])
  6425. ], 16));
  6426. }
  6427. });
  6428. var Cd = ["args"];
  6429. var Pd = ["color"];
  6430. var om = defineComponent({
  6431. __name: "TorusKnot",
  6432. props: {
  6433. args: { default: () => [1, 0.4, 64, 8] },
  6434. color: { default: "0xffffff" }
  6435. },
  6436. setup(f, { expose: i }) {
  6437. const s = shallowRef();
  6438. return i({
  6439. value: s
  6440. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6441. ref_key: "torusKnotRef",
  6442. ref: s
  6443. }, r.$attrs), [
  6444. createBaseVNode("TresTorusKnotGeometry", { args: f.args }, null, 8, Cd),
  6445. renderSlot(r.$slots, "default", {}, () => [
  6446. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, Pd)
  6447. ])
  6448. ], 16));
  6449. }
  6450. });
  6451. var Td = ["args"];
  6452. var kd = ["color"];
  6453. var am = defineComponent({
  6454. __name: "Tube",
  6455. props: {
  6456. args: { default: () => [
  6457. new QuadraticBezierCurve3(new Vector3(-1, 0, 0), new Vector3(0, 1, 0), new Vector3(1, 0, 0)),
  6458. 20,
  6459. 0.2,
  6460. 8,
  6461. false
  6462. ] },
  6463. color: { default: "0xffffff" }
  6464. },
  6465. setup(f, { expose: i }) {
  6466. const s = shallowRef();
  6467. return i({
  6468. value: s
  6469. }), (r, o) => (openBlock(), createElementBlock("TresMesh", mergeProps({
  6470. ref_key: "tubeRef",
  6471. ref: s
  6472. }, r.$attrs), [
  6473. createBaseVNode("TresTubeGeometry", { args: f.args }, null, 8, Td),
  6474. renderSlot(r.$slots, "default", {}, () => [
  6475. createBaseVNode("TresMeshBasicMaterial", { color: f.color }, null, 8, kd)
  6476. ])
  6477. ], 16));
  6478. }
  6479. });
  6480. var wo = { exports: {} };
  6481. (function(f, i) {
  6482. (function(s, r) {
  6483. r(i);
  6484. })(il, function(s) {
  6485. class r {
  6486. /**
  6487. * @hidden
  6488. */
  6489. constructor(e) {
  6490. const [t, l] = e.split("-"), b = t.split(".");
  6491. this.major = parseInt(b[0], 10), this.minor = parseInt(b[1], 10), this.patch = parseInt(b[2], 10), this.prerelease = l ?? null;
  6492. }
  6493. toString() {
  6494. const e = [this.major, this.minor, this.patch].join(".");
  6495. return this.prerelease !== null ? [e, this.prerelease].join("-") : e;
  6496. }
  6497. }
  6498. class o {
  6499. constructor(e) {
  6500. this.controller_ = e;
  6501. }
  6502. get element() {
  6503. return this.controller_.view.element;
  6504. }
  6505. get disabled() {
  6506. return this.controller_.viewProps.get("disabled");
  6507. }
  6508. set disabled(e) {
  6509. this.controller_.viewProps.set("disabled", e);
  6510. }
  6511. get hidden() {
  6512. return this.controller_.viewProps.get("hidden");
  6513. }
  6514. set hidden(e) {
  6515. this.controller_.viewProps.set("hidden", e);
  6516. }
  6517. dispose() {
  6518. this.controller_.viewProps.set("disposed", true);
  6519. }
  6520. }
  6521. class c {
  6522. constructor(e) {
  6523. this.target = e;
  6524. }
  6525. }
  6526. class p2 extends c {
  6527. constructor(e, t, l, b) {
  6528. super(e), this.value = t, this.presetKey = l, this.last = b ?? true;
  6529. }
  6530. }
  6531. class h2 extends c {
  6532. constructor(e, t, l) {
  6533. super(e), this.value = t, this.presetKey = l;
  6534. }
  6535. }
  6536. class m extends c {
  6537. constructor(e, t) {
  6538. super(e), this.expanded = t;
  6539. }
  6540. }
  6541. class g extends c {
  6542. constructor(e, t) {
  6543. super(e), this.index = t;
  6544. }
  6545. }
  6546. function w(n) {
  6547. return n;
  6548. }
  6549. function _2(n) {
  6550. return n == null;
  6551. }
  6552. function y(n, e) {
  6553. if (n.length !== e.length)
  6554. return false;
  6555. for (let t = 0; t < n.length; t++)
  6556. if (n[t] !== e[t])
  6557. return false;
  6558. return true;
  6559. }
  6560. function C(n, e) {
  6561. let t = n;
  6562. do {
  6563. const l = Object.getOwnPropertyDescriptor(t, e);
  6564. if (l && (l.set !== void 0 || l.writable === true))
  6565. return true;
  6566. t = Object.getPrototypeOf(t);
  6567. } while (t !== null);
  6568. return false;
  6569. }
  6570. const L = {
  6571. alreadydisposed: () => "View has been already disposed",
  6572. invalidparams: (n) => `Invalid parameters for '${n.name}'`,
  6573. nomatchingcontroller: (n) => `No matching controller for '${n.key}'`,
  6574. nomatchingview: (n) => `No matching view for '${JSON.stringify(n.params)}'`,
  6575. notbindable: () => "Value is not bindable",
  6576. propertynotfound: (n) => `Property '${n.name}' not found`,
  6577. shouldneverhappen: () => "This error should never happen"
  6578. };
  6579. class S {
  6580. static alreadyDisposed() {
  6581. return new S({ type: "alreadydisposed" });
  6582. }
  6583. static notBindable() {
  6584. return new S({
  6585. type: "notbindable"
  6586. });
  6587. }
  6588. static propertyNotFound(e) {
  6589. return new S({
  6590. type: "propertynotfound",
  6591. context: {
  6592. name: e
  6593. }
  6594. });
  6595. }
  6596. static shouldNeverHappen() {
  6597. return new S({ type: "shouldneverhappen" });
  6598. }
  6599. constructor(e) {
  6600. var t;
  6601. this.message = (t = L[e.type](e.context)) !== null && t !== void 0 ? t : "Unexpected error", this.name = this.constructor.name, this.stack = new Error(this.message).stack, this.type = e.type;
  6602. }
  6603. }
  6604. class R {
  6605. constructor(e, t, l) {
  6606. this.obj_ = e, this.key_ = t, this.presetKey_ = l ?? t;
  6607. }
  6608. static isBindable(e) {
  6609. return !(e === null || typeof e != "object" && typeof e != "function");
  6610. }
  6611. get key() {
  6612. return this.key_;
  6613. }
  6614. get presetKey() {
  6615. return this.presetKey_;
  6616. }
  6617. read() {
  6618. return this.obj_[this.key_];
  6619. }
  6620. write(e) {
  6621. this.obj_[this.key_] = e;
  6622. }
  6623. writeProperty(e, t) {
  6624. const l = this.read();
  6625. if (!R.isBindable(l))
  6626. throw S.notBindable();
  6627. if (!(e in l))
  6628. throw S.propertyNotFound(e);
  6629. l[e] = t;
  6630. }
  6631. }
  6632. class O extends o {
  6633. get label() {
  6634. return this.controller_.props.get("label");
  6635. }
  6636. set label(e) {
  6637. this.controller_.props.set("label", e);
  6638. }
  6639. get title() {
  6640. var e;
  6641. return (e = this.controller_.valueController.props.get("title")) !== null && e !== void 0 ? e : "";
  6642. }
  6643. set title(e) {
  6644. this.controller_.valueController.props.set("title", e);
  6645. }
  6646. on(e, t) {
  6647. const l = t.bind(this);
  6648. return this.controller_.valueController.emitter.on(e, () => {
  6649. l(new c(this));
  6650. }), this;
  6651. }
  6652. }
  6653. class N {
  6654. constructor() {
  6655. this.observers_ = {};
  6656. }
  6657. on(e, t) {
  6658. let l = this.observers_[e];
  6659. return l || (l = this.observers_[e] = []), l.push({
  6660. handler: t
  6661. }), this;
  6662. }
  6663. off(e, t) {
  6664. const l = this.observers_[e];
  6665. return l && (this.observers_[e] = l.filter((b) => b.handler !== t)), this;
  6666. }
  6667. emit(e, t) {
  6668. const l = this.observers_[e];
  6669. l && l.forEach((b) => {
  6670. b.handler(t);
  6671. });
  6672. }
  6673. }
  6674. const I2 = "tp";
  6675. function D2(n) {
  6676. return (t, l) => [
  6677. I2,
  6678. "-",
  6679. n,
  6680. "v",
  6681. t ? `_${t}` : "",
  6682. l ? `-${l}` : ""
  6683. ].join("");
  6684. }
  6685. function Y(n, e) {
  6686. return (t) => e(n(t));
  6687. }
  6688. function G(n) {
  6689. return n.rawValue;
  6690. }
  6691. function F(n, e) {
  6692. n.emitter.on("change", Y(G, e)), e(n.rawValue);
  6693. }
  6694. function B(n, e, t) {
  6695. F(n.value(e), t);
  6696. }
  6697. function H2(n, e, t) {
  6698. t ? n.classList.add(e) : n.classList.remove(e);
  6699. }
  6700. function K2(n, e) {
  6701. return (t) => {
  6702. H2(n, e, t);
  6703. };
  6704. }
  6705. function q(n, e) {
  6706. F(n, (t) => {
  6707. e.textContent = t ?? "";
  6708. });
  6709. }
  6710. const pe = D2("btn");
  6711. class _e {
  6712. constructor(e, t) {
  6713. this.element = e.createElement("div"), this.element.classList.add(pe()), t.viewProps.bindClassModifiers(this.element);
  6714. const l = e.createElement("button");
  6715. l.classList.add(pe("b")), t.viewProps.bindDisabled(l), this.element.appendChild(l), this.buttonElement = l;
  6716. const b = e.createElement("div");
  6717. b.classList.add(pe("t")), q(t.props.value("title"), b), this.buttonElement.appendChild(b);
  6718. }
  6719. }
  6720. class ce2 {
  6721. constructor(e, t) {
  6722. this.emitter = new N(), this.onClick_ = this.onClick_.bind(this), this.props = t.props, this.viewProps = t.viewProps, this.view = new _e(e, {
  6723. props: this.props,
  6724. viewProps: this.viewProps
  6725. }), this.view.buttonElement.addEventListener("click", this.onClick_);
  6726. }
  6727. onClick_() {
  6728. this.emitter.emit("click", {
  6729. sender: this
  6730. });
  6731. }
  6732. }
  6733. class me {
  6734. constructor(e, t) {
  6735. var l;
  6736. this.constraint_ = t == null ? void 0 : t.constraint, this.equals_ = (l = t == null ? void 0 : t.equals) !== null && l !== void 0 ? l : (b, E) => b === E, this.emitter = new N(), this.rawValue_ = e;
  6737. }
  6738. get constraint() {
  6739. return this.constraint_;
  6740. }
  6741. get rawValue() {
  6742. return this.rawValue_;
  6743. }
  6744. set rawValue(e) {
  6745. this.setRawValue(e, {
  6746. forceEmit: false,
  6747. last: true
  6748. });
  6749. }
  6750. setRawValue(e, t) {
  6751. const l = t ?? {
  6752. forceEmit: false,
  6753. last: true
  6754. }, b = this.constraint_ ? this.constraint_.constrain(e) : e, E = this.rawValue_;
  6755. this.equals_(E, b) && !l.forceEmit || (this.emitter.emit("beforechange", {
  6756. sender: this
  6757. }), this.rawValue_ = b, this.emitter.emit("change", {
  6758. options: l,
  6759. previousRawValue: E,
  6760. rawValue: b,
  6761. sender: this
  6762. }));
  6763. }
  6764. }
  6765. class he {
  6766. constructor(e) {
  6767. this.emitter = new N(), this.value_ = e;
  6768. }
  6769. get rawValue() {
  6770. return this.value_;
  6771. }
  6772. set rawValue(e) {
  6773. this.setRawValue(e, {
  6774. forceEmit: false,
  6775. last: true
  6776. });
  6777. }
  6778. setRawValue(e, t) {
  6779. const l = t ?? {
  6780. forceEmit: false,
  6781. last: true
  6782. }, b = this.value_;
  6783. b === e && !l.forceEmit || (this.emitter.emit("beforechange", {
  6784. sender: this
  6785. }), this.value_ = e, this.emitter.emit("change", {
  6786. options: l,
  6787. previousRawValue: b,
  6788. rawValue: this.value_,
  6789. sender: this
  6790. }));
  6791. }
  6792. }
  6793. function ee(n, e) {
  6794. const t = e == null ? void 0 : e.constraint, l = e == null ? void 0 : e.equals;
  6795. return !t && !l ? new he(n) : new me(n, e);
  6796. }
  6797. class X2 {
  6798. constructor(e) {
  6799. this.emitter = new N(), this.valMap_ = e;
  6800. for (const t in this.valMap_)
  6801. this.valMap_[t].emitter.on("change", () => {
  6802. this.emitter.emit("change", {
  6803. key: t,
  6804. sender: this
  6805. });
  6806. });
  6807. }
  6808. static createCore(e) {
  6809. return Object.keys(e).reduce((l, b) => Object.assign(l, {
  6810. [b]: ee(e[b])
  6811. }), {});
  6812. }
  6813. static fromObject(e) {
  6814. const t = this.createCore(e);
  6815. return new X2(t);
  6816. }
  6817. get(e) {
  6818. return this.valMap_[e].rawValue;
  6819. }
  6820. set(e, t) {
  6821. this.valMap_[e].rawValue = t;
  6822. }
  6823. value(e) {
  6824. return this.valMap_[e];
  6825. }
  6826. }
  6827. function Se2(n, e) {
  6828. const l = Object.keys(e).reduce((b, E) => {
  6829. if (b === void 0)
  6830. return;
  6831. const k = e[E], j = k(n[E]);
  6832. return j.succeeded ? Object.assign(Object.assign({}, b), { [E]: j.value }) : void 0;
  6833. }, {});
  6834. return l;
  6835. }
  6836. function fe2(n, e) {
  6837. return n.reduce((t, l) => {
  6838. if (t === void 0)
  6839. return;
  6840. const b = e(l);
  6841. if (!(!b.succeeded || b.value === void 0))
  6842. return [...t, b.value];
  6843. }, []);
  6844. }
  6845. function oe2(n) {
  6846. return n === null ? false : typeof n == "object";
  6847. }
  6848. function ne(n) {
  6849. return (e) => (t) => {
  6850. if (!e && t === void 0)
  6851. return {
  6852. succeeded: false,
  6853. value: void 0
  6854. };
  6855. if (e && t === void 0)
  6856. return {
  6857. succeeded: true,
  6858. value: void 0
  6859. };
  6860. const l = n(t);
  6861. return l !== void 0 ? {
  6862. succeeded: true,
  6863. value: l
  6864. } : {
  6865. succeeded: false,
  6866. value: void 0
  6867. };
  6868. };
  6869. }
  6870. function ge(n) {
  6871. return {
  6872. custom: (e) => ne(e)(n),
  6873. boolean: ne((e) => typeof e == "boolean" ? e : void 0)(n),
  6874. number: ne((e) => typeof e == "number" ? e : void 0)(n),
  6875. string: ne((e) => typeof e == "string" ? e : void 0)(n),
  6876. function: ne((e) => typeof e == "function" ? e : void 0)(n),
  6877. constant: (e) => ne((t) => t === e ? e : void 0)(n),
  6878. raw: ne((e) => e)(n),
  6879. object: (e) => ne((t) => {
  6880. if (oe2(t))
  6881. return Se2(t, e);
  6882. })(n),
  6883. array: (e) => ne((t) => {
  6884. if (Array.isArray(t))
  6885. return fe2(t, e);
  6886. })(n)
  6887. };
  6888. }
  6889. const A2 = {
  6890. optional: ge(true),
  6891. required: ge(false)
  6892. };
  6893. function ae(n, e) {
  6894. const t = A2.required.object(e)(n);
  6895. return t.succeeded ? t.value : void 0;
  6896. }
  6897. function Ne(n) {
  6898. console.warn([
  6899. `Missing '${n.key}' of ${n.target} in ${n.place}.`,
  6900. "Please rebuild plugins with the latest core package."
  6901. ].join(" "));
  6902. }
  6903. function Ue(n) {
  6904. return n && n.parentElement && n.parentElement.removeChild(n), null;
  6905. }
  6906. class xe2 {
  6907. constructor(e) {
  6908. this.value_ = e;
  6909. }
  6910. static create(e) {
  6911. return [
  6912. new xe2(e),
  6913. (t, l) => {
  6914. e.setRawValue(t, l);
  6915. }
  6916. ];
  6917. }
  6918. get emitter() {
  6919. return this.value_.emitter;
  6920. }
  6921. get rawValue() {
  6922. return this.value_.rawValue;
  6923. }
  6924. }
  6925. const rt2 = D2("");
  6926. function Un(n, e) {
  6927. return K2(n, rt2(void 0, e));
  6928. }
  6929. class Ze2 extends X2 {
  6930. constructor(e) {
  6931. var t;
  6932. super(e), this.onDisabledChange_ = this.onDisabledChange_.bind(this), this.onParentChange_ = this.onParentChange_.bind(this), this.onParentGlobalDisabledChange_ = this.onParentGlobalDisabledChange_.bind(this), [this.globalDisabled_, this.setGlobalDisabled_] = xe2.create(ee(this.getGlobalDisabled_())), this.value("disabled").emitter.on("change", this.onDisabledChange_), this.value("parent").emitter.on("change", this.onParentChange_), (t = this.get("parent")) === null || t === void 0 || t.globalDisabled.emitter.on("change", this.onParentGlobalDisabledChange_);
  6933. }
  6934. static create(e) {
  6935. var t, l, b;
  6936. const E = e ?? {};
  6937. return new Ze2(X2.createCore({
  6938. disabled: (t = E.disabled) !== null && t !== void 0 ? t : false,
  6939. disposed: false,
  6940. hidden: (l = E.hidden) !== null && l !== void 0 ? l : false,
  6941. parent: (b = E.parent) !== null && b !== void 0 ? b : null
  6942. }));
  6943. }
  6944. get globalDisabled() {
  6945. return this.globalDisabled_;
  6946. }
  6947. bindClassModifiers(e) {
  6948. F(this.globalDisabled_, Un(e, "disabled")), B(this, "hidden", Un(e, "hidden"));
  6949. }
  6950. bindDisabled(e) {
  6951. F(this.globalDisabled_, (t) => {
  6952. e.disabled = t;
  6953. });
  6954. }
  6955. bindTabIndex(e) {
  6956. F(this.globalDisabled_, (t) => {
  6957. e.tabIndex = t ? -1 : 0;
  6958. });
  6959. }
  6960. handleDispose(e) {
  6961. this.value("disposed").emitter.on("change", (t) => {
  6962. t && e();
  6963. });
  6964. }
  6965. getGlobalDisabled_() {
  6966. const e = this.get("parent");
  6967. return (e ? e.globalDisabled.rawValue : false) || this.get("disabled");
  6968. }
  6969. updateGlobalDisabled_() {
  6970. this.setGlobalDisabled_(this.getGlobalDisabled_());
  6971. }
  6972. onDisabledChange_() {
  6973. this.updateGlobalDisabled_();
  6974. }
  6975. onParentGlobalDisabledChange_() {
  6976. this.updateGlobalDisabled_();
  6977. }
  6978. onParentChange_(e) {
  6979. var t;
  6980. const l = e.previousRawValue;
  6981. l == null || l.globalDisabled.emitter.off("change", this.onParentGlobalDisabledChange_), (t = this.get("parent")) === null || t === void 0 || t.globalDisabled.emitter.on("change", this.onParentGlobalDisabledChange_), this.updateGlobalDisabled_();
  6982. }
  6983. }
  6984. function Gn() {
  6985. return ["veryfirst", "first", "last", "verylast"];
  6986. }
  6987. const hn = D2(""), vt2 = {
  6988. veryfirst: "vfst",
  6989. first: "fst",
  6990. last: "lst",
  6991. verylast: "vlst"
  6992. };
  6993. class At {
  6994. constructor(e) {
  6995. this.parent_ = null, this.blade = e.blade, this.view = e.view, this.viewProps = e.viewProps;
  6996. const t = this.view.element;
  6997. this.blade.value("positions").emitter.on("change", () => {
  6998. Gn().forEach((l) => {
  6999. t.classList.remove(hn(void 0, vt2[l]));
  7000. }), this.blade.get("positions").forEach((l) => {
  7001. t.classList.add(hn(void 0, vt2[l]));
  7002. });
  7003. }), this.viewProps.handleDispose(() => {
  7004. Ue(t);
  7005. });
  7006. }
  7007. get parent() {
  7008. return this.parent_;
  7009. }
  7010. set parent(e) {
  7011. if (this.parent_ = e, !("parent" in this.viewProps.valMap_)) {
  7012. Ne({
  7013. key: "parent",
  7014. target: Ze2.name,
  7015. place: "BladeController.parent"
  7016. });
  7017. return;
  7018. }
  7019. this.viewProps.set("parent", this.parent_ ? this.parent_.viewProps : null);
  7020. }
  7021. }
  7022. const Ke = "http://www.w3.org/2000/svg";
  7023. function ot2(n) {
  7024. n.offsetHeight;
  7025. }
  7026. function dn(n, e) {
  7027. const t = n.style.transition;
  7028. n.style.transition = "none", e(), n.style.transition = t;
  7029. }
  7030. function bt2(n) {
  7031. return n.ontouchstart !== void 0;
  7032. }
  7033. function Hn() {
  7034. return globalThis;
  7035. }
  7036. function bi() {
  7037. return Hn().document;
  7038. }
  7039. function Kn(n) {
  7040. const e = n.ownerDocument.defaultView;
  7041. return e && "document" in e ? n.getContext("2d", {
  7042. willReadFrequently: true
  7043. }) : null;
  7044. }
  7045. const $n = {
  7046. check: '<path d="M2 8l4 4l8 -8"/>',
  7047. dropdown: '<path d="M5 7h6l-3 3 z"/>',
  7048. p2dpad: '<path d="M8 4v8"/><path d="M4 8h8"/><circle cx="12" cy="12" r="1.2"/>'
  7049. };
  7050. function Et2(n, e) {
  7051. const t = n.createElementNS(Ke, "svg");
  7052. return t.innerHTML = $n[e], t;
  7053. }
  7054. function Mt(n, e, t) {
  7055. n.insertBefore(e, n.children[t]);
  7056. }
  7057. function Xn(n) {
  7058. n.parentElement && n.parentElement.removeChild(n);
  7059. }
  7060. function mn(n) {
  7061. for (; n.children.length > 0; )
  7062. n.removeChild(n.children[0]);
  7063. }
  7064. function Yn(n) {
  7065. for (; n.childNodes.length > 0; )
  7066. n.removeChild(n.childNodes[0]);
  7067. }
  7068. function Ct(n) {
  7069. return n.relatedTarget ? n.relatedTarget : "explicitOriginalTarget" in n ? n.explicitOriginalTarget : null;
  7070. }
  7071. const gt2 = D2("lbl");
  7072. function St(n, e) {
  7073. const t = n.createDocumentFragment();
  7074. return e.split(`
  7075. `).map((b) => n.createTextNode(b)).forEach((b, E) => {
  7076. E > 0 && t.appendChild(n.createElement("br")), t.appendChild(b);
  7077. }), t;
  7078. }
  7079. class M {
  7080. constructor(e, t) {
  7081. this.element = e.createElement("div"), this.element.classList.add(gt2()), t.viewProps.bindClassModifiers(this.element);
  7082. const l = e.createElement("div");
  7083. l.classList.add(gt2("l")), B(t.props, "label", (E) => {
  7084. _2(E) ? this.element.classList.add(gt2(void 0, "nol")) : (this.element.classList.remove(gt2(void 0, "nol")), Yn(l), l.appendChild(St(e, E)));
  7085. }), this.element.appendChild(l), this.labelElement = l;
  7086. const b = e.createElement("div");
  7087. b.classList.add(gt2("v")), this.element.appendChild(b), this.valueElement = b;
  7088. }
  7089. }
  7090. class U2 extends At {
  7091. constructor(e, t) {
  7092. const l = t.valueController.viewProps;
  7093. super(Object.assign(Object.assign({}, t), { view: new M(e, {
  7094. props: t.props,
  7095. viewProps: l
  7096. }), viewProps: l })), this.props = t.props, this.valueController = t.valueController, this.view.valueElement.appendChild(this.valueController.view.element);
  7097. }
  7098. }
  7099. const W = {
  7100. id: "button",
  7101. type: "blade",
  7102. accept(n) {
  7103. const e = A2, t = ae(n, {
  7104. title: e.required.string,
  7105. view: e.required.constant("button"),
  7106. label: e.optional.string
  7107. });
  7108. return t ? { params: t } : null;
  7109. },
  7110. controller(n) {
  7111. return new U2(n.document, {
  7112. blade: n.blade,
  7113. props: X2.fromObject({
  7114. label: n.params.label
  7115. }),
  7116. valueController: new ce2(n.document, {
  7117. props: X2.fromObject({
  7118. title: n.params.title
  7119. }),
  7120. viewProps: n.viewProps
  7121. })
  7122. });
  7123. },
  7124. api(n) {
  7125. return !(n.controller instanceof U2) || !(n.controller.valueController instanceof ce2) ? null : new O(n.controller);
  7126. }
  7127. };
  7128. class ie2 extends At {
  7129. constructor(e) {
  7130. super(e), this.value = e.value;
  7131. }
  7132. }
  7133. function Ee2() {
  7134. return new X2({
  7135. positions: ee([], {
  7136. equals: y
  7137. })
  7138. });
  7139. }
  7140. class Fe extends X2 {
  7141. constructor(e) {
  7142. super(e);
  7143. }
  7144. static create(e) {
  7145. const t = {
  7146. completed: true,
  7147. expanded: e,
  7148. expandedHeight: null,
  7149. shouldFixHeight: false,
  7150. temporaryExpanded: null
  7151. }, l = X2.createCore(t);
  7152. return new Fe(l);
  7153. }
  7154. get styleExpanded() {
  7155. var e;
  7156. return (e = this.get("temporaryExpanded")) !== null && e !== void 0 ? e : this.get("expanded");
  7157. }
  7158. get styleHeight() {
  7159. if (!this.styleExpanded)
  7160. return "0";
  7161. const e = this.get("expandedHeight");
  7162. return this.get("shouldFixHeight") && !_2(e) ? `${e}px` : "auto";
  7163. }
  7164. bindExpandedClass(e, t) {
  7165. const l = () => {
  7166. this.styleExpanded ? e.classList.add(t) : e.classList.remove(t);
  7167. };
  7168. B(this, "expanded", l), B(this, "temporaryExpanded", l);
  7169. }
  7170. cleanUpTransition() {
  7171. this.set("shouldFixHeight", false), this.set("expandedHeight", null), this.set("completed", true);
  7172. }
  7173. }
  7174. function Gt(n, e) {
  7175. let t = 0;
  7176. return dn(e, () => {
  7177. n.set("expandedHeight", null), n.set("temporaryExpanded", true), ot2(e), t = e.clientHeight, n.set("temporaryExpanded", null), ot2(e);
  7178. }), t;
  7179. }
  7180. function fn(n, e) {
  7181. e.style.height = n.styleHeight;
  7182. }
  7183. function $e(n, e) {
  7184. n.value("expanded").emitter.on("beforechange", () => {
  7185. if (n.set("completed", false), _2(n.get("expandedHeight"))) {
  7186. const t = Gt(n, e);
  7187. t > 0 && n.set("expandedHeight", t);
  7188. }
  7189. n.set("shouldFixHeight", true), ot2(e);
  7190. }), n.emitter.on("change", () => {
  7191. fn(n, e);
  7192. }), fn(n, e), e.addEventListener("transitionend", (t) => {
  7193. t.propertyName === "height" && n.cleanUpTransition();
  7194. });
  7195. }
  7196. class Xe extends o {
  7197. constructor(e, t) {
  7198. super(e), this.rackApi_ = t;
  7199. }
  7200. }
  7201. function qs(n, e) {
  7202. return n.addBlade(Object.assign(Object.assign({}, e), { view: "button" }));
  7203. }
  7204. function Qs(n, e) {
  7205. return n.addBlade(Object.assign(Object.assign({}, e), { view: "folder" }));
  7206. }
  7207. function Zs(n, e) {
  7208. const t = e ?? {};
  7209. return n.addBlade(Object.assign(Object.assign({}, t), { view: "separator" }));
  7210. }
  7211. function gi(n, e) {
  7212. return n.addBlade(Object.assign(Object.assign({}, e), { view: "tab" }));
  7213. }
  7214. class Lt {
  7215. constructor(e) {
  7216. this.emitter = new N(), this.items_ = [], this.cache_ = /* @__PURE__ */ new Set(), this.onSubListAdd_ = this.onSubListAdd_.bind(this), this.onSubListRemove_ = this.onSubListRemove_.bind(this), this.extract_ = e;
  7217. }
  7218. get items() {
  7219. return this.items_;
  7220. }
  7221. allItems() {
  7222. return Array.from(this.cache_);
  7223. }
  7224. find(e) {
  7225. for (const t of this.allItems())
  7226. if (e(t))
  7227. return t;
  7228. return null;
  7229. }
  7230. includes(e) {
  7231. return this.cache_.has(e);
  7232. }
  7233. add(e, t) {
  7234. if (this.includes(e))
  7235. throw S.shouldNeverHappen();
  7236. const l = t !== void 0 ? t : this.items_.length;
  7237. this.items_.splice(l, 0, e), this.cache_.add(e);
  7238. const b = this.extract_(e);
  7239. b && (b.emitter.on("add", this.onSubListAdd_), b.emitter.on("remove", this.onSubListRemove_), b.allItems().forEach((E) => {
  7240. this.cache_.add(E);
  7241. })), this.emitter.emit("add", {
  7242. index: l,
  7243. item: e,
  7244. root: this,
  7245. target: this
  7246. });
  7247. }
  7248. remove(e) {
  7249. const t = this.items_.indexOf(e);
  7250. if (t < 0)
  7251. return;
  7252. this.items_.splice(t, 1), this.cache_.delete(e);
  7253. const l = this.extract_(e);
  7254. l && (l.emitter.off("add", this.onSubListAdd_), l.emitter.off("remove", this.onSubListRemove_)), this.emitter.emit("remove", {
  7255. index: t,
  7256. item: e,
  7257. root: this,
  7258. target: this
  7259. });
  7260. }
  7261. onSubListAdd_(e) {
  7262. this.cache_.add(e.item), this.emitter.emit("add", {
  7263. index: e.index,
  7264. item: e.item,
  7265. root: this,
  7266. target: e.target
  7267. });
  7268. }
  7269. onSubListRemove_(e) {
  7270. this.cache_.delete(e.item), this.emitter.emit("remove", {
  7271. index: e.index,
  7272. item: e.item,
  7273. root: this,
  7274. target: e.target
  7275. });
  7276. }
  7277. }
  7278. class _i extends o {
  7279. constructor(e) {
  7280. super(e), this.onBindingChange_ = this.onBindingChange_.bind(this), this.emitter_ = new N(), this.controller_.binding.emitter.on("change", this.onBindingChange_);
  7281. }
  7282. get label() {
  7283. return this.controller_.props.get("label");
  7284. }
  7285. set label(e) {
  7286. this.controller_.props.set("label", e);
  7287. }
  7288. on(e, t) {
  7289. const l = t.bind(this);
  7290. return this.emitter_.on(e, (b) => {
  7291. l(b.event);
  7292. }), this;
  7293. }
  7294. refresh() {
  7295. this.controller_.binding.read();
  7296. }
  7297. onBindingChange_(e) {
  7298. const t = e.sender.target.read();
  7299. this.emitter_.emit("change", {
  7300. event: new p2(this, t, this.controller_.binding.target.presetKey, e.options.last)
  7301. });
  7302. }
  7303. }
  7304. class Ge extends U2 {
  7305. constructor(e, t) {
  7306. super(e, t), this.binding = t.binding;
  7307. }
  7308. }
  7309. class wi extends o {
  7310. constructor(e) {
  7311. super(e), this.onBindingUpdate_ = this.onBindingUpdate_.bind(this), this.emitter_ = new N(), this.controller_.binding.emitter.on("update", this.onBindingUpdate_);
  7312. }
  7313. get label() {
  7314. return this.controller_.props.get("label");
  7315. }
  7316. set label(e) {
  7317. this.controller_.props.set("label", e);
  7318. }
  7319. on(e, t) {
  7320. const l = t.bind(this);
  7321. return this.emitter_.on(e, (b) => {
  7322. l(b.event);
  7323. }), this;
  7324. }
  7325. refresh() {
  7326. this.controller_.binding.read();
  7327. }
  7328. onBindingUpdate_(e) {
  7329. const t = e.sender.target.read();
  7330. this.emitter_.emit("update", {
  7331. event: new h2(this, t, this.controller_.binding.target.presetKey)
  7332. });
  7333. }
  7334. }
  7335. class at2 extends U2 {
  7336. constructor(e, t) {
  7337. super(e, t), this.binding = t.binding, this.viewProps.bindDisabled(this.binding.ticker), this.viewProps.handleDispose(() => {
  7338. this.binding.dispose();
  7339. });
  7340. }
  7341. }
  7342. function as(n) {
  7343. return n instanceof qn ? n.apiSet_ : n instanceof Xe ? n.rackApi_.apiSet_ : null;
  7344. }
  7345. function vn(n, e) {
  7346. const t = n.find((l) => l.controller_ === e);
  7347. if (!t)
  7348. throw S.shouldNeverHappen();
  7349. return t;
  7350. }
  7351. function ls(n, e, t) {
  7352. if (!R.isBindable(n))
  7353. throw S.notBindable();
  7354. return new R(n, e, t);
  7355. }
  7356. class qn extends o {
  7357. constructor(e, t) {
  7358. super(e), this.onRackAdd_ = this.onRackAdd_.bind(this), this.onRackRemove_ = this.onRackRemove_.bind(this), this.onRackInputChange_ = this.onRackInputChange_.bind(this), this.onRackMonitorUpdate_ = this.onRackMonitorUpdate_.bind(this), this.emitter_ = new N(), this.apiSet_ = new Lt(as), this.pool_ = t;
  7359. const l = this.controller_.rack;
  7360. l.emitter.on("add", this.onRackAdd_), l.emitter.on("remove", this.onRackRemove_), l.emitter.on("inputchange", this.onRackInputChange_), l.emitter.on("monitorupdate", this.onRackMonitorUpdate_), l.children.forEach((b) => {
  7361. this.setUpApi_(b);
  7362. });
  7363. }
  7364. get children() {
  7365. return this.controller_.rack.children.map((e) => vn(this.apiSet_, e));
  7366. }
  7367. addInput(e, t, l) {
  7368. const b = l ?? {}, E = this.controller_.view.element.ownerDocument, k = this.pool_.createInput(E, ls(e, t, b.presetKey), b), j = new _i(k);
  7369. return this.add(j, b.index);
  7370. }
  7371. addMonitor(e, t, l) {
  7372. const b = l ?? {}, E = this.controller_.view.element.ownerDocument, k = this.pool_.createMonitor(E, ls(e, t), b), j = new wi(k);
  7373. return this.add(j, b.index);
  7374. }
  7375. addFolder(e) {
  7376. return Qs(this, e);
  7377. }
  7378. addButton(e) {
  7379. return qs(this, e);
  7380. }
  7381. addSeparator(e) {
  7382. return Zs(this, e);
  7383. }
  7384. addTab(e) {
  7385. return gi(this, e);
  7386. }
  7387. add(e, t) {
  7388. this.controller_.rack.add(e.controller_, t);
  7389. const l = this.apiSet_.find((b) => b.controller_ === e.controller_);
  7390. return l && this.apiSet_.remove(l), this.apiSet_.add(e), e;
  7391. }
  7392. remove(e) {
  7393. this.controller_.rack.remove(e.controller_);
  7394. }
  7395. addBlade(e) {
  7396. const t = this.controller_.view.element.ownerDocument, l = this.pool_.createBlade(t, e), b = this.pool_.createBladeApi(l);
  7397. return this.add(b, e.index);
  7398. }
  7399. on(e, t) {
  7400. const l = t.bind(this);
  7401. return this.emitter_.on(e, (b) => {
  7402. l(b.event);
  7403. }), this;
  7404. }
  7405. setUpApi_(e) {
  7406. this.apiSet_.find((l) => l.controller_ === e) || this.apiSet_.add(this.pool_.createBladeApi(e));
  7407. }
  7408. onRackAdd_(e) {
  7409. this.setUpApi_(e.bladeController);
  7410. }
  7411. onRackRemove_(e) {
  7412. if (e.isRoot) {
  7413. const t = vn(this.apiSet_, e.bladeController);
  7414. this.apiSet_.remove(t);
  7415. }
  7416. }
  7417. onRackInputChange_(e) {
  7418. const t = e.bladeController;
  7419. if (t instanceof Ge) {
  7420. const l = vn(this.apiSet_, t), b = t.binding;
  7421. this.emitter_.emit("change", {
  7422. event: new p2(l, b.target.read(), b.target.presetKey, e.options.last)
  7423. });
  7424. } else if (t instanceof ie2) {
  7425. const l = vn(this.apiSet_, t);
  7426. this.emitter_.emit("change", {
  7427. event: new p2(l, t.value.rawValue, void 0, e.options.last)
  7428. });
  7429. }
  7430. }
  7431. onRackMonitorUpdate_(e) {
  7432. if (!(e.bladeController instanceof at2))
  7433. throw S.shouldNeverHappen();
  7434. const t = vn(this.apiSet_, e.bladeController), l = e.bladeController.binding;
  7435. this.emitter_.emit("update", {
  7436. event: new h2(t, l.target.read(), l.target.presetKey)
  7437. });
  7438. }
  7439. }
  7440. class yi extends Xe {
  7441. constructor(e, t) {
  7442. super(e, new qn(e.rackController, t)), this.emitter_ = new N(), this.controller_.foldable.value("expanded").emitter.on("change", (l) => {
  7443. this.emitter_.emit("fold", {
  7444. event: new m(this, l.sender.rawValue)
  7445. });
  7446. }), this.rackApi_.on("change", (l) => {
  7447. this.emitter_.emit("change", {
  7448. event: l
  7449. });
  7450. }), this.rackApi_.on("update", (l) => {
  7451. this.emitter_.emit("update", {
  7452. event: l
  7453. });
  7454. });
  7455. }
  7456. get expanded() {
  7457. return this.controller_.foldable.get("expanded");
  7458. }
  7459. set expanded(e) {
  7460. this.controller_.foldable.set("expanded", e);
  7461. }
  7462. get title() {
  7463. return this.controller_.props.get("title");
  7464. }
  7465. set title(e) {
  7466. this.controller_.props.set("title", e);
  7467. }
  7468. get children() {
  7469. return this.rackApi_.children;
  7470. }
  7471. addInput(e, t, l) {
  7472. return this.rackApi_.addInput(e, t, l);
  7473. }
  7474. addMonitor(e, t, l) {
  7475. return this.rackApi_.addMonitor(e, t, l);
  7476. }
  7477. addFolder(e) {
  7478. return this.rackApi_.addFolder(e);
  7479. }
  7480. addButton(e) {
  7481. return this.rackApi_.addButton(e);
  7482. }
  7483. addSeparator(e) {
  7484. return this.rackApi_.addSeparator(e);
  7485. }
  7486. addTab(e) {
  7487. return this.rackApi_.addTab(e);
  7488. }
  7489. add(e, t) {
  7490. return this.rackApi_.add(e, t);
  7491. }
  7492. remove(e) {
  7493. this.rackApi_.remove(e);
  7494. }
  7495. addBlade(e) {
  7496. return this.rackApi_.addBlade(e);
  7497. }
  7498. on(e, t) {
  7499. const l = t.bind(this);
  7500. return this.emitter_.on(e, (b) => {
  7501. l(b.event);
  7502. }), this;
  7503. }
  7504. }
  7505. class xi extends At {
  7506. constructor(e) {
  7507. super({
  7508. blade: e.blade,
  7509. view: e.view,
  7510. viewProps: e.rackController.viewProps
  7511. }), this.rackController = e.rackController;
  7512. }
  7513. }
  7514. class Ws {
  7515. constructor(e, t) {
  7516. const l = D2(t.viewName);
  7517. this.element = e.createElement("div"), this.element.classList.add(l()), t.viewProps.bindClassModifiers(this.element);
  7518. }
  7519. }
  7520. function Js(n, e) {
  7521. for (let t = 0; t < n.length; t++) {
  7522. const l = n[t];
  7523. if (l instanceof Ge && l.binding === e)
  7524. return l;
  7525. }
  7526. return null;
  7527. }
  7528. function er(n, e) {
  7529. for (let t = 0; t < n.length; t++) {
  7530. const l = n[t];
  7531. if (l instanceof at2 && l.binding === e)
  7532. return l;
  7533. }
  7534. return null;
  7535. }
  7536. function tr(n, e) {
  7537. for (let t = 0; t < n.length; t++) {
  7538. const l = n[t];
  7539. if (l instanceof ie2 && l.value === e)
  7540. return l;
  7541. }
  7542. return null;
  7543. }
  7544. function Ei(n) {
  7545. return n instanceof bn ? n.rack : n instanceof xi ? n.rackController.rack : null;
  7546. }
  7547. function nr(n) {
  7548. const e = Ei(n);
  7549. return e ? e.bcSet_ : null;
  7550. }
  7551. class ir {
  7552. constructor(e) {
  7553. var t, l;
  7554. this.onBladePositionsChange_ = this.onBladePositionsChange_.bind(this), this.onSetAdd_ = this.onSetAdd_.bind(this), this.onSetRemove_ = this.onSetRemove_.bind(this), this.onChildDispose_ = this.onChildDispose_.bind(this), this.onChildPositionsChange_ = this.onChildPositionsChange_.bind(this), this.onChildInputChange_ = this.onChildInputChange_.bind(this), this.onChildMonitorUpdate_ = this.onChildMonitorUpdate_.bind(this), this.onChildValueChange_ = this.onChildValueChange_.bind(this), this.onChildViewPropsChange_ = this.onChildViewPropsChange_.bind(this), this.onDescendantLayout_ = this.onDescendantLayout_.bind(this), this.onDescendantInputChange_ = this.onDescendantInputChange_.bind(this), this.onDescendantMonitorUpdate_ = this.onDescendantMonitorUpdate_.bind(this), this.emitter = new N(), this.blade_ = (t = e.blade) !== null && t !== void 0 ? t : null, (l = this.blade_) === null || l === void 0 || l.value("positions").emitter.on("change", this.onBladePositionsChange_), this.viewProps = e.viewProps, this.bcSet_ = new Lt(nr), this.bcSet_.emitter.on("add", this.onSetAdd_), this.bcSet_.emitter.on("remove", this.onSetRemove_);
  7555. }
  7556. get children() {
  7557. return this.bcSet_.items;
  7558. }
  7559. add(e, t) {
  7560. var l;
  7561. (l = e.parent) === null || l === void 0 || l.remove(e), C(e, "parent") ? e.parent = this : (e.parent_ = this, Ne({
  7562. key: "parent",
  7563. target: "BladeController",
  7564. place: "BladeRack.add"
  7565. })), this.bcSet_.add(e, t);
  7566. }
  7567. remove(e) {
  7568. C(e, "parent") ? e.parent = null : (e.parent_ = null, Ne({
  7569. key: "parent",
  7570. target: "BladeController",
  7571. place: "BladeRack.remove"
  7572. })), this.bcSet_.remove(e);
  7573. }
  7574. find(e) {
  7575. return this.bcSet_.allItems().filter((t) => t instanceof e);
  7576. }
  7577. onSetAdd_(e) {
  7578. this.updatePositions_();
  7579. const t = e.target === e.root;
  7580. if (this.emitter.emit("add", {
  7581. bladeController: e.item,
  7582. index: e.index,
  7583. isRoot: t,
  7584. sender: this
  7585. }), !t)
  7586. return;
  7587. const l = e.item;
  7588. if (l.viewProps.emitter.on("change", this.onChildViewPropsChange_), l.blade.value("positions").emitter.on("change", this.onChildPositionsChange_), l.viewProps.handleDispose(this.onChildDispose_), l instanceof Ge)
  7589. l.binding.emitter.on("change", this.onChildInputChange_);
  7590. else if (l instanceof at2)
  7591. l.binding.emitter.on("update", this.onChildMonitorUpdate_);
  7592. else if (l instanceof ie2)
  7593. l.value.emitter.on("change", this.onChildValueChange_);
  7594. else {
  7595. const b = Ei(l);
  7596. if (b) {
  7597. const E = b.emitter;
  7598. E.on("layout", this.onDescendantLayout_), E.on("inputchange", this.onDescendantInputChange_), E.on("monitorupdate", this.onDescendantMonitorUpdate_);
  7599. }
  7600. }
  7601. }
  7602. onSetRemove_(e) {
  7603. this.updatePositions_();
  7604. const t = e.target === e.root;
  7605. if (this.emitter.emit("remove", {
  7606. bladeController: e.item,
  7607. isRoot: t,
  7608. sender: this
  7609. }), !t)
  7610. return;
  7611. const l = e.item;
  7612. if (l instanceof Ge)
  7613. l.binding.emitter.off("change", this.onChildInputChange_);
  7614. else if (l instanceof at2)
  7615. l.binding.emitter.off("update", this.onChildMonitorUpdate_);
  7616. else if (l instanceof ie2)
  7617. l.value.emitter.off("change", this.onChildValueChange_);
  7618. else {
  7619. const b = Ei(l);
  7620. if (b) {
  7621. const E = b.emitter;
  7622. E.off("layout", this.onDescendantLayout_), E.off("inputchange", this.onDescendantInputChange_), E.off("monitorupdate", this.onDescendantMonitorUpdate_);
  7623. }
  7624. }
  7625. }
  7626. updatePositions_() {
  7627. const e = this.bcSet_.items.filter((b) => !b.viewProps.get("hidden")), t = e[0], l = e[e.length - 1];
  7628. this.bcSet_.items.forEach((b) => {
  7629. const E = [];
  7630. b === t && (E.push("first"), (!this.blade_ || this.blade_.get("positions").includes("veryfirst")) && E.push("veryfirst")), b === l && (E.push("last"), (!this.blade_ || this.blade_.get("positions").includes("verylast")) && E.push("verylast")), b.blade.set("positions", E);
  7631. });
  7632. }
  7633. onChildPositionsChange_() {
  7634. this.updatePositions_(), this.emitter.emit("layout", {
  7635. sender: this
  7636. });
  7637. }
  7638. onChildViewPropsChange_(e) {
  7639. this.updatePositions_(), this.emitter.emit("layout", {
  7640. sender: this
  7641. });
  7642. }
  7643. onChildDispose_() {
  7644. this.bcSet_.items.filter((t) => t.viewProps.get("disposed")).forEach((t) => {
  7645. this.bcSet_.remove(t);
  7646. });
  7647. }
  7648. onChildInputChange_(e) {
  7649. const t = Js(this.find(Ge), e.sender);
  7650. if (!t)
  7651. throw S.alreadyDisposed();
  7652. this.emitter.emit("inputchange", {
  7653. bladeController: t,
  7654. options: e.options,
  7655. sender: this
  7656. });
  7657. }
  7658. onChildMonitorUpdate_(e) {
  7659. const t = er(this.find(at2), e.sender);
  7660. if (!t)
  7661. throw S.alreadyDisposed();
  7662. this.emitter.emit("monitorupdate", {
  7663. bladeController: t,
  7664. sender: this
  7665. });
  7666. }
  7667. onChildValueChange_(e) {
  7668. const t = tr(this.find(ie2), e.sender);
  7669. if (!t)
  7670. throw S.alreadyDisposed();
  7671. this.emitter.emit("inputchange", {
  7672. bladeController: t,
  7673. options: e.options,
  7674. sender: this
  7675. });
  7676. }
  7677. onDescendantLayout_(e) {
  7678. this.updatePositions_(), this.emitter.emit("layout", {
  7679. sender: this
  7680. });
  7681. }
  7682. onDescendantInputChange_(e) {
  7683. this.emitter.emit("inputchange", {
  7684. bladeController: e.bladeController,
  7685. options: e.options,
  7686. sender: this
  7687. });
  7688. }
  7689. onDescendantMonitorUpdate_(e) {
  7690. this.emitter.emit("monitorupdate", {
  7691. bladeController: e.bladeController,
  7692. sender: this
  7693. });
  7694. }
  7695. onBladePositionsChange_() {
  7696. this.updatePositions_();
  7697. }
  7698. }
  7699. class bn extends At {
  7700. constructor(e, t) {
  7701. super(Object.assign(Object.assign({}, t), { view: new Ws(e, {
  7702. viewName: "brk",
  7703. viewProps: t.viewProps
  7704. }) })), this.onRackAdd_ = this.onRackAdd_.bind(this), this.onRackRemove_ = this.onRackRemove_.bind(this);
  7705. const l = new ir({
  7706. blade: t.root ? void 0 : t.blade,
  7707. viewProps: t.viewProps
  7708. });
  7709. l.emitter.on("add", this.onRackAdd_), l.emitter.on("remove", this.onRackRemove_), this.rack = l, this.viewProps.handleDispose(() => {
  7710. for (let b = this.rack.children.length - 1; b >= 0; b--)
  7711. this.rack.children[b].viewProps.set("disposed", true);
  7712. });
  7713. }
  7714. onRackAdd_(e) {
  7715. e.isRoot && Mt(this.view.element, e.bladeController.view.element, e.index);
  7716. }
  7717. onRackRemove_(e) {
  7718. e.isRoot && Xn(e.bladeController.view.element);
  7719. }
  7720. }
  7721. const cs = D2("cnt");
  7722. class sr {
  7723. constructor(e, t) {
  7724. var l;
  7725. this.className_ = D2((l = t.viewName) !== null && l !== void 0 ? l : "fld"), this.element = e.createElement("div"), this.element.classList.add(this.className_(), cs()), t.viewProps.bindClassModifiers(this.element), this.foldable_ = t.foldable, this.foldable_.bindExpandedClass(this.element, this.className_(void 0, "expanded")), B(this.foldable_, "completed", K2(this.element, this.className_(void 0, "cpl")));
  7726. const b = e.createElement("button");
  7727. b.classList.add(this.className_("b")), B(t.props, "title", (J) => {
  7728. _2(J) ? this.element.classList.add(this.className_(void 0, "not")) : this.element.classList.remove(this.className_(void 0, "not"));
  7729. }), t.viewProps.bindDisabled(b), this.element.appendChild(b), this.buttonElement = b;
  7730. const E = e.createElement("div");
  7731. E.classList.add(this.className_("i")), this.element.appendChild(E);
  7732. const k = e.createElement("div");
  7733. k.classList.add(this.className_("t")), q(t.props.value("title"), k), this.buttonElement.appendChild(k), this.titleElement = k;
  7734. const j = e.createElement("div");
  7735. j.classList.add(this.className_("m")), this.buttonElement.appendChild(j);
  7736. const Q2 = t.containerElement;
  7737. Q2.classList.add(this.className_("c")), this.element.appendChild(Q2), this.containerElement = Q2;
  7738. }
  7739. }
  7740. class Qn extends xi {
  7741. constructor(e, t) {
  7742. var l;
  7743. const b = Fe.create((l = t.expanded) !== null && l !== void 0 ? l : true), E = new bn(e, {
  7744. blade: t.blade,
  7745. root: t.root,
  7746. viewProps: t.viewProps
  7747. });
  7748. super(Object.assign(Object.assign({}, t), { rackController: E, view: new sr(e, {
  7749. containerElement: E.view.element,
  7750. foldable: b,
  7751. props: t.props,
  7752. viewName: t.root ? "rot" : void 0,
  7753. viewProps: t.viewProps
  7754. }) })), this.onTitleClick_ = this.onTitleClick_.bind(this), this.props = t.props, this.foldable = b, $e(this.foldable, this.view.containerElement), this.rackController.rack.emitter.on("add", () => {
  7755. this.foldable.cleanUpTransition();
  7756. }), this.rackController.rack.emitter.on("remove", () => {
  7757. this.foldable.cleanUpTransition();
  7758. }), this.view.buttonElement.addEventListener("click", this.onTitleClick_);
  7759. }
  7760. get document() {
  7761. return this.view.element.ownerDocument;
  7762. }
  7763. onTitleClick_() {
  7764. this.foldable.set("expanded", !this.foldable.get("expanded"));
  7765. }
  7766. }
  7767. const rr = {
  7768. id: "folder",
  7769. type: "blade",
  7770. accept(n) {
  7771. const e = A2, t = ae(n, {
  7772. title: e.required.string,
  7773. view: e.required.constant("folder"),
  7774. expanded: e.optional.boolean
  7775. });
  7776. return t ? { params: t } : null;
  7777. },
  7778. controller(n) {
  7779. return new Qn(n.document, {
  7780. blade: n.blade,
  7781. expanded: n.params.expanded,
  7782. props: X2.fromObject({
  7783. title: n.params.title
  7784. }),
  7785. viewProps: n.viewProps
  7786. });
  7787. },
  7788. api(n) {
  7789. return n.controller instanceof Qn ? new yi(n.controller, n.pool) : null;
  7790. }
  7791. };
  7792. class Ht extends ie2 {
  7793. constructor(e, t) {
  7794. const l = t.valueController.viewProps;
  7795. super(Object.assign(Object.assign({}, t), { value: t.valueController.value, view: new M(e, {
  7796. props: t.props,
  7797. viewProps: l
  7798. }), viewProps: l })), this.props = t.props, this.valueController = t.valueController, this.view.valueElement.appendChild(this.valueController.view.element);
  7799. }
  7800. }
  7801. class us extends o {
  7802. }
  7803. const Ci = D2("spr");
  7804. class or {
  7805. constructor(e, t) {
  7806. this.element = e.createElement("div"), this.element.classList.add(Ci()), t.viewProps.bindClassModifiers(this.element);
  7807. const l = e.createElement("hr");
  7808. l.classList.add(Ci("r")), this.element.appendChild(l);
  7809. }
  7810. }
  7811. class gn extends At {
  7812. constructor(e, t) {
  7813. super(Object.assign(Object.assign({}, t), { view: new or(e, {
  7814. viewProps: t.viewProps
  7815. }) }));
  7816. }
  7817. }
  7818. const ar = {
  7819. id: "separator",
  7820. type: "blade",
  7821. accept(n) {
  7822. const t = ae(n, {
  7823. view: A2.required.constant("separator")
  7824. });
  7825. return t ? { params: t } : null;
  7826. },
  7827. controller(n) {
  7828. return new gn(n.document, {
  7829. blade: n.blade,
  7830. viewProps: n.viewProps
  7831. });
  7832. },
  7833. api(n) {
  7834. return n.controller instanceof gn ? new us(n.controller) : null;
  7835. }
  7836. }, Ie = D2("tbi");
  7837. class lr {
  7838. constructor(e, t) {
  7839. this.element = e.createElement("div"), this.element.classList.add(Ie()), t.viewProps.bindClassModifiers(this.element), B(t.props, "selected", (E) => {
  7840. E ? this.element.classList.add(Ie(void 0, "sel")) : this.element.classList.remove(Ie(void 0, "sel"));
  7841. });
  7842. const l = e.createElement("button");
  7843. l.classList.add(Ie("b")), t.viewProps.bindDisabled(l), this.element.appendChild(l), this.buttonElement = l;
  7844. const b = e.createElement("div");
  7845. b.classList.add(Ie("t")), q(t.props.value("title"), b), this.buttonElement.appendChild(b), this.titleElement = b;
  7846. }
  7847. }
  7848. class Zn {
  7849. constructor(e, t) {
  7850. this.emitter = new N(), this.onClick_ = this.onClick_.bind(this), this.props = t.props, this.viewProps = t.viewProps, this.view = new lr(e, {
  7851. props: t.props,
  7852. viewProps: t.viewProps
  7853. }), this.view.buttonElement.addEventListener("click", this.onClick_);
  7854. }
  7855. onClick_() {
  7856. this.emitter.emit("click", {
  7857. sender: this
  7858. });
  7859. }
  7860. }
  7861. class ps {
  7862. constructor(e, t) {
  7863. this.onItemClick_ = this.onItemClick_.bind(this), this.ic_ = new Zn(e, {
  7864. props: t.itemProps,
  7865. viewProps: Ze2.create()
  7866. }), this.ic_.emitter.on("click", this.onItemClick_), this.cc_ = new bn(e, {
  7867. blade: Ee2(),
  7868. viewProps: Ze2.create()
  7869. }), this.props = t.props, B(this.props, "selected", (l) => {
  7870. this.itemController.props.set("selected", l), this.contentController.viewProps.set("hidden", !l);
  7871. });
  7872. }
  7873. get itemController() {
  7874. return this.ic_;
  7875. }
  7876. get contentController() {
  7877. return this.cc_;
  7878. }
  7879. onItemClick_() {
  7880. this.props.set("selected", true);
  7881. }
  7882. }
  7883. class Pi {
  7884. constructor(e, t) {
  7885. this.controller_ = e, this.rackApi_ = t;
  7886. }
  7887. get title() {
  7888. var e;
  7889. return (e = this.controller_.itemController.props.get("title")) !== null && e !== void 0 ? e : "";
  7890. }
  7891. set title(e) {
  7892. this.controller_.itemController.props.set("title", e);
  7893. }
  7894. get selected() {
  7895. return this.controller_.props.get("selected");
  7896. }
  7897. set selected(e) {
  7898. this.controller_.props.set("selected", e);
  7899. }
  7900. get children() {
  7901. return this.rackApi_.children;
  7902. }
  7903. addButton(e) {
  7904. return this.rackApi_.addButton(e);
  7905. }
  7906. addFolder(e) {
  7907. return this.rackApi_.addFolder(e);
  7908. }
  7909. addSeparator(e) {
  7910. return this.rackApi_.addSeparator(e);
  7911. }
  7912. addTab(e) {
  7913. return this.rackApi_.addTab(e);
  7914. }
  7915. add(e, t) {
  7916. this.rackApi_.add(e, t);
  7917. }
  7918. remove(e) {
  7919. this.rackApi_.remove(e);
  7920. }
  7921. addInput(e, t, l) {
  7922. return this.rackApi_.addInput(e, t, l);
  7923. }
  7924. addMonitor(e, t, l) {
  7925. return this.rackApi_.addMonitor(e, t, l);
  7926. }
  7927. addBlade(e) {
  7928. return this.rackApi_.addBlade(e);
  7929. }
  7930. }
  7931. class hs extends Xe {
  7932. constructor(e, t) {
  7933. super(e, new qn(e.rackController, t)), this.onPageAdd_ = this.onPageAdd_.bind(this), this.onPageRemove_ = this.onPageRemove_.bind(this), this.onSelect_ = this.onSelect_.bind(this), this.emitter_ = new N(), this.pageApiMap_ = /* @__PURE__ */ new Map(), this.rackApi_.on("change", (l) => {
  7934. this.emitter_.emit("change", {
  7935. event: l
  7936. });
  7937. }), this.rackApi_.on("update", (l) => {
  7938. this.emitter_.emit("update", {
  7939. event: l
  7940. });
  7941. }), this.controller_.tab.selectedIndex.emitter.on("change", this.onSelect_), this.controller_.pageSet.emitter.on("add", this.onPageAdd_), this.controller_.pageSet.emitter.on("remove", this.onPageRemove_), this.controller_.pageSet.items.forEach((l) => {
  7942. this.setUpPageApi_(l);
  7943. });
  7944. }
  7945. get pages() {
  7946. return this.controller_.pageSet.items.map((e) => {
  7947. const t = this.pageApiMap_.get(e);
  7948. if (!t)
  7949. throw S.shouldNeverHappen();
  7950. return t;
  7951. });
  7952. }
  7953. addPage(e) {
  7954. const t = this.controller_.view.element.ownerDocument, l = new ps(t, {
  7955. itemProps: X2.fromObject({
  7956. selected: false,
  7957. title: e.title
  7958. }),
  7959. props: X2.fromObject({
  7960. selected: false
  7961. })
  7962. });
  7963. this.controller_.add(l, e.index);
  7964. const b = this.pageApiMap_.get(l);
  7965. if (!b)
  7966. throw S.shouldNeverHappen();
  7967. return b;
  7968. }
  7969. removePage(e) {
  7970. this.controller_.remove(e);
  7971. }
  7972. on(e, t) {
  7973. const l = t.bind(this);
  7974. return this.emitter_.on(e, (b) => {
  7975. l(b.event);
  7976. }), this;
  7977. }
  7978. setUpPageApi_(e) {
  7979. const t = this.rackApi_.apiSet_.find((b) => b.controller_ === e.contentController);
  7980. if (!t)
  7981. throw S.shouldNeverHappen();
  7982. const l = new Pi(e, t);
  7983. this.pageApiMap_.set(e, l);
  7984. }
  7985. onPageAdd_(e) {
  7986. this.setUpPageApi_(e.item);
  7987. }
  7988. onPageRemove_(e) {
  7989. if (!this.pageApiMap_.get(e.item))
  7990. throw S.shouldNeverHappen();
  7991. this.pageApiMap_.delete(e.item);
  7992. }
  7993. onSelect_(e) {
  7994. this.emitter_.emit("select", {
  7995. event: new g(this, e.rawValue)
  7996. });
  7997. }
  7998. }
  7999. const ds = -1;
  8000. class cr {
  8001. constructor() {
  8002. this.onItemSelectedChange_ = this.onItemSelectedChange_.bind(this), this.empty = ee(true), this.selectedIndex = ee(ds), this.items_ = [];
  8003. }
  8004. add(e, t) {
  8005. const l = t ?? this.items_.length;
  8006. this.items_.splice(l, 0, e), e.emitter.on("change", this.onItemSelectedChange_), this.keepSelection_();
  8007. }
  8008. remove(e) {
  8009. const t = this.items_.indexOf(e);
  8010. t < 0 || (this.items_.splice(t, 1), e.emitter.off("change", this.onItemSelectedChange_), this.keepSelection_());
  8011. }
  8012. keepSelection_() {
  8013. if (this.items_.length === 0) {
  8014. this.selectedIndex.rawValue = ds, this.empty.rawValue = true;
  8015. return;
  8016. }
  8017. const e = this.items_.findIndex((t) => t.rawValue);
  8018. e < 0 ? (this.items_.forEach((t, l) => {
  8019. t.rawValue = l === 0;
  8020. }), this.selectedIndex.rawValue = 0) : (this.items_.forEach((t, l) => {
  8021. t.rawValue = l === e;
  8022. }), this.selectedIndex.rawValue = e), this.empty.rawValue = false;
  8023. }
  8024. onItemSelectedChange_(e) {
  8025. if (e.rawValue) {
  8026. const t = this.items_.findIndex((l) => l === e.sender);
  8027. this.items_.forEach((l, b) => {
  8028. l.rawValue = b === t;
  8029. }), this.selectedIndex.rawValue = t;
  8030. } else
  8031. this.keepSelection_();
  8032. }
  8033. }
  8034. const Kt = D2("tab");
  8035. class $t {
  8036. constructor(e, t) {
  8037. this.element = e.createElement("div"), this.element.classList.add(Kt(), cs()), t.viewProps.bindClassModifiers(this.element), F(t.empty, K2(this.element, Kt(void 0, "nop")));
  8038. const l = e.createElement("div");
  8039. l.classList.add(Kt("t")), this.element.appendChild(l), this.itemsElement = l;
  8040. const b = e.createElement("div");
  8041. b.classList.add(Kt("i")), this.element.appendChild(b);
  8042. const E = t.contentsElement;
  8043. E.classList.add(Kt("c")), this.element.appendChild(E), this.contentsElement = E;
  8044. }
  8045. }
  8046. class _n extends xi {
  8047. constructor(e, t) {
  8048. const l = new bn(e, {
  8049. blade: t.blade,
  8050. viewProps: t.viewProps
  8051. }), b = new cr();
  8052. super({
  8053. blade: t.blade,
  8054. rackController: l,
  8055. view: new $t(e, {
  8056. contentsElement: l.view.element,
  8057. empty: b.empty,
  8058. viewProps: t.viewProps
  8059. })
  8060. }), this.onPageAdd_ = this.onPageAdd_.bind(this), this.onPageRemove_ = this.onPageRemove_.bind(this), this.pageSet_ = new Lt(() => null), this.pageSet_.emitter.on("add", this.onPageAdd_), this.pageSet_.emitter.on("remove", this.onPageRemove_), this.tab = b;
  8061. }
  8062. get pageSet() {
  8063. return this.pageSet_;
  8064. }
  8065. add(e, t) {
  8066. this.pageSet_.add(e, t);
  8067. }
  8068. remove(e) {
  8069. this.pageSet_.remove(this.pageSet_.items[e]);
  8070. }
  8071. onPageAdd_(e) {
  8072. const t = e.item;
  8073. Mt(this.view.itemsElement, t.itemController.view.element, e.index), t.itemController.viewProps.set("parent", this.viewProps), this.rackController.rack.add(t.contentController, e.index), this.tab.add(t.props.value("selected"));
  8074. }
  8075. onPageRemove_(e) {
  8076. const t = e.item;
  8077. Xn(t.itemController.view.element), t.itemController.viewProps.set("parent", null), this.rackController.rack.remove(t.contentController), this.tab.remove(t.props.value("selected"));
  8078. }
  8079. }
  8080. const Ti = {
  8081. id: "tab",
  8082. type: "blade",
  8083. accept(n) {
  8084. const e = A2, t = ae(n, {
  8085. pages: e.required.array(e.required.object({ title: e.required.string })),
  8086. view: e.required.constant("tab")
  8087. });
  8088. return !t || t.pages.length === 0 ? null : { params: t };
  8089. },
  8090. controller(n) {
  8091. const e = new _n(n.document, {
  8092. blade: n.blade,
  8093. viewProps: n.viewProps
  8094. });
  8095. return n.params.pages.forEach((t) => {
  8096. const l = new ps(n.document, {
  8097. itemProps: X2.fromObject({
  8098. selected: false,
  8099. title: t.title
  8100. }),
  8101. props: X2.fromObject({
  8102. selected: false
  8103. })
  8104. });
  8105. e.add(l);
  8106. }), e;
  8107. },
  8108. api(n) {
  8109. return n.controller instanceof _n ? new hs(n.controller, n.pool) : null;
  8110. }
  8111. };
  8112. function ur(n, e) {
  8113. const t = n.accept(e.params);
  8114. if (!t)
  8115. return null;
  8116. const l = A2.optional.boolean(e.params.disabled).value, b = A2.optional.boolean(e.params.hidden).value;
  8117. return n.controller({
  8118. blade: Ee2(),
  8119. document: e.document,
  8120. params: Object.assign(Object.assign({}, t.params), { disabled: l, hidden: b }),
  8121. viewProps: Ze2.create({
  8122. disabled: l,
  8123. hidden: b
  8124. })
  8125. });
  8126. }
  8127. class ms {
  8128. constructor() {
  8129. this.disabled = false, this.emitter = new N();
  8130. }
  8131. dispose() {
  8132. }
  8133. tick() {
  8134. this.disabled || this.emitter.emit("tick", {
  8135. sender: this
  8136. });
  8137. }
  8138. }
  8139. class ki {
  8140. constructor(e, t) {
  8141. this.disabled_ = false, this.timerId_ = null, this.onTick_ = this.onTick_.bind(this), this.doc_ = e, this.emitter = new N(), this.interval_ = t, this.setTimer_();
  8142. }
  8143. get disabled() {
  8144. return this.disabled_;
  8145. }
  8146. set disabled(e) {
  8147. this.disabled_ = e, this.disabled_ ? this.clearTimer_() : this.setTimer_();
  8148. }
  8149. dispose() {
  8150. this.clearTimer_();
  8151. }
  8152. clearTimer_() {
  8153. if (this.timerId_ === null)
  8154. return;
  8155. const e = this.doc_.defaultView;
  8156. e && e.clearInterval(this.timerId_), this.timerId_ = null;
  8157. }
  8158. setTimer_() {
  8159. if (this.clearTimer_(), this.interval_ <= 0)
  8160. return;
  8161. const e = this.doc_.defaultView;
  8162. e && (this.timerId_ = e.setInterval(this.onTick_, this.interval_));
  8163. }
  8164. onTick_() {
  8165. this.disabled_ || this.emitter.emit("tick", {
  8166. sender: this
  8167. });
  8168. }
  8169. }
  8170. class Wn {
  8171. constructor(e) {
  8172. this.onValueChange_ = this.onValueChange_.bind(this), this.reader = e.reader, this.writer = e.writer, this.emitter = new N(), this.value = e.value, this.value.emitter.on("change", this.onValueChange_), this.target = e.target, this.read();
  8173. }
  8174. read() {
  8175. const e = this.target.read();
  8176. e !== void 0 && (this.value.rawValue = this.reader(e));
  8177. }
  8178. write_(e) {
  8179. this.writer(this.target, e);
  8180. }
  8181. onValueChange_(e) {
  8182. this.write_(e.rawValue), this.emitter.emit("change", {
  8183. options: e.options,
  8184. rawValue: e.rawValue,
  8185. sender: this
  8186. });
  8187. }
  8188. }
  8189. function Le(n, e) {
  8190. for (; n.length < e; )
  8191. n.push(void 0);
  8192. }
  8193. function fs(n) {
  8194. const e = [];
  8195. return Le(e, n), ee(e);
  8196. }
  8197. function Xt(n) {
  8198. const e = n.indexOf(void 0);
  8199. return e < 0 ? n : n.slice(0, e);
  8200. }
  8201. function We(n, e) {
  8202. const t = [...Xt(n), e];
  8203. return t.length > n.length ? t.splice(0, t.length - n.length) : Le(t, n.length), t;
  8204. }
  8205. class pr {
  8206. constructor(e) {
  8207. this.onTick_ = this.onTick_.bind(this), this.reader_ = e.reader, this.target = e.target, this.emitter = new N(), this.value = e.value, this.ticker = e.ticker, this.ticker.emitter.on("tick", this.onTick_), this.read();
  8208. }
  8209. dispose() {
  8210. this.ticker.dispose();
  8211. }
  8212. read() {
  8213. const e = this.target.read();
  8214. if (e === void 0)
  8215. return;
  8216. const t = this.value.rawValue, l = this.reader_(e);
  8217. this.value.rawValue = We(t, l), this.emitter.emit("update", {
  8218. rawValue: l,
  8219. sender: this
  8220. });
  8221. }
  8222. onTick_(e) {
  8223. this.read();
  8224. }
  8225. }
  8226. class wn {
  8227. constructor(e) {
  8228. this.constraints = e;
  8229. }
  8230. constrain(e) {
  8231. return this.constraints.reduce((t, l) => l.constrain(t), e);
  8232. }
  8233. }
  8234. function it2(n, e) {
  8235. if (n instanceof e)
  8236. return n;
  8237. if (n instanceof wn) {
  8238. const t = n.constraints.reduce((l, b) => l || (b instanceof e ? b : null), null);
  8239. if (t)
  8240. return t;
  8241. }
  8242. return null;
  8243. }
  8244. class Yt {
  8245. constructor(e) {
  8246. this.values = X2.fromObject({
  8247. max: e.max,
  8248. min: e.min
  8249. });
  8250. }
  8251. constrain(e) {
  8252. const t = this.values.get("max"), l = this.values.get("min");
  8253. return Math.min(Math.max(e, l), t);
  8254. }
  8255. }
  8256. class yn {
  8257. constructor(e) {
  8258. this.values = X2.fromObject({
  8259. options: e
  8260. });
  8261. }
  8262. get options() {
  8263. return this.values.get("options");
  8264. }
  8265. constrain(e) {
  8266. const t = this.values.get("options");
  8267. return t.length === 0 || t.filter((b) => b.value === e).length > 0 ? e : t[0].value;
  8268. }
  8269. }
  8270. class Ai {
  8271. constructor(e) {
  8272. this.values = X2.fromObject({
  8273. max: e.max,
  8274. min: e.min
  8275. });
  8276. }
  8277. get maxValue() {
  8278. return this.values.get("max");
  8279. }
  8280. get minValue() {
  8281. return this.values.get("min");
  8282. }
  8283. constrain(e) {
  8284. const t = this.values.get("max"), l = this.values.get("min");
  8285. let b = e;
  8286. return _2(l) || (b = Math.max(b, l)), _2(t) || (b = Math.min(b, t)), b;
  8287. }
  8288. }
  8289. class Jn {
  8290. constructor(e, t = 0) {
  8291. this.step = e, this.origin = t;
  8292. }
  8293. constrain(e) {
  8294. const t = this.origin % this.step, l = Math.round((e - t) / this.step);
  8295. return t + l * this.step;
  8296. }
  8297. }
  8298. const qt = D2("lst");
  8299. class vs {
  8300. constructor(e, t) {
  8301. this.onValueChange_ = this.onValueChange_.bind(this), this.props_ = t.props, this.element = e.createElement("div"), this.element.classList.add(qt()), t.viewProps.bindClassModifiers(this.element);
  8302. const l = e.createElement("select");
  8303. l.classList.add(qt("s")), B(this.props_, "options", (E) => {
  8304. mn(l), E.forEach((k, j) => {
  8305. const Q2 = e.createElement("option");
  8306. Q2.dataset.index = String(j), Q2.textContent = k.text, Q2.value = String(k.value), l.appendChild(Q2);
  8307. });
  8308. }), t.viewProps.bindDisabled(l), this.element.appendChild(l), this.selectElement = l;
  8309. const b = e.createElement("div");
  8310. b.classList.add(qt("m")), b.appendChild(Et2(e, "dropdown")), this.element.appendChild(b), t.value.emitter.on("change", this.onValueChange_), this.value_ = t.value, this.update_();
  8311. }
  8312. update_() {
  8313. this.selectElement.value = String(this.value_.rawValue);
  8314. }
  8315. onValueChange_() {
  8316. this.update_();
  8317. }
  8318. }
  8319. class xn {
  8320. constructor(e, t) {
  8321. this.onSelectChange_ = this.onSelectChange_.bind(this), this.props = t.props, this.value = t.value, this.viewProps = t.viewProps, this.view = new vs(e, {
  8322. props: this.props,
  8323. value: this.value,
  8324. viewProps: this.viewProps
  8325. }), this.view.selectElement.addEventListener("change", this.onSelectChange_);
  8326. }
  8327. onSelectChange_(e) {
  8328. const l = e.currentTarget.selectedOptions.item(0);
  8329. if (!l)
  8330. return;
  8331. const b = Number(l.dataset.index);
  8332. this.value.rawValue = this.props.get("options")[b].value;
  8333. }
  8334. }
  8335. const bs = D2("pop");
  8336. class hr {
  8337. constructor(e, t) {
  8338. this.element = e.createElement("div"), this.element.classList.add(bs()), t.viewProps.bindClassModifiers(this.element), F(t.shows, K2(this.element, bs(void 0, "v")));
  8339. }
  8340. }
  8341. class gs {
  8342. constructor(e, t) {
  8343. this.shows = ee(false), this.viewProps = t.viewProps, this.view = new hr(e, {
  8344. shows: this.shows,
  8345. viewProps: this.viewProps
  8346. });
  8347. }
  8348. }
  8349. const _s = D2("txt");
  8350. class dr {
  8351. constructor(e, t) {
  8352. this.onChange_ = this.onChange_.bind(this), this.element = e.createElement("div"), this.element.classList.add(_s()), t.viewProps.bindClassModifiers(this.element), this.props_ = t.props, this.props_.emitter.on("change", this.onChange_);
  8353. const l = e.createElement("input");
  8354. l.classList.add(_s("i")), l.type = "text", t.viewProps.bindDisabled(l), this.element.appendChild(l), this.inputElement = l, t.value.emitter.on("change", this.onChange_), this.value_ = t.value, this.refresh();
  8355. }
  8356. refresh() {
  8357. const e = this.props_.get("formatter");
  8358. this.inputElement.value = e(this.value_.rawValue);
  8359. }
  8360. onChange_() {
  8361. this.refresh();
  8362. }
  8363. }
  8364. class ei {
  8365. constructor(e, t) {
  8366. this.onInputChange_ = this.onInputChange_.bind(this), this.parser_ = t.parser, this.props = t.props, this.value = t.value, this.viewProps = t.viewProps, this.view = new dr(e, {
  8367. props: t.props,
  8368. value: this.value,
  8369. viewProps: this.viewProps
  8370. }), this.view.inputElement.addEventListener("change", this.onInputChange_);
  8371. }
  8372. onInputChange_(e) {
  8373. const l = e.currentTarget.value, b = this.parser_(l);
  8374. _2(b) || (this.value.rawValue = b), this.view.refresh();
  8375. }
  8376. }
  8377. function mr(n) {
  8378. return String(n);
  8379. }
  8380. function ws(n) {
  8381. return n === "false" ? false : !!n;
  8382. }
  8383. function ys(n) {
  8384. return mr(n);
  8385. }
  8386. class fr {
  8387. constructor(e) {
  8388. this.text = e;
  8389. }
  8390. evaluate() {
  8391. return Number(this.text);
  8392. }
  8393. toString() {
  8394. return this.text;
  8395. }
  8396. }
  8397. const vr = {
  8398. "**": (n, e) => Math.pow(n, e),
  8399. "*": (n, e) => n * e,
  8400. "/": (n, e) => n / e,
  8401. "%": (n, e) => n % e,
  8402. "+": (n, e) => n + e,
  8403. "-": (n, e) => n - e,
  8404. "<<": (n, e) => n << e,
  8405. ">>": (n, e) => n >> e,
  8406. ">>>": (n, e) => n >>> e,
  8407. "&": (n, e) => n & e,
  8408. "^": (n, e) => n ^ e,
  8409. "|": (n, e) => n | e
  8410. };
  8411. class br {
  8412. constructor(e, t, l) {
  8413. this.left = t, this.operator = e, this.right = l;
  8414. }
  8415. evaluate() {
  8416. const e = vr[this.operator];
  8417. if (!e)
  8418. throw new Error(`unexpected binary operator: '${this.operator}`);
  8419. return e(this.left.evaluate(), this.right.evaluate());
  8420. }
  8421. toString() {
  8422. return [
  8423. "b(",
  8424. this.left.toString(),
  8425. this.operator,
  8426. this.right.toString(),
  8427. ")"
  8428. ].join(" ");
  8429. }
  8430. }
  8431. const xs = {
  8432. "+": (n) => n,
  8433. "-": (n) => -n,
  8434. "~": (n) => ~n
  8435. };
  8436. class gr {
  8437. constructor(e, t) {
  8438. this.operator = e, this.expression = t;
  8439. }
  8440. evaluate() {
  8441. const e = xs[this.operator];
  8442. if (!e)
  8443. throw new Error(`unexpected unary operator: '${this.operator}`);
  8444. return e(this.expression.evaluate());
  8445. }
  8446. toString() {
  8447. return ["u(", this.operator, this.expression.toString(), ")"].join(" ");
  8448. }
  8449. }
  8450. function Mi(n) {
  8451. return (e, t) => {
  8452. for (let l = 0; l < n.length; l++) {
  8453. const b = n[l](e, t);
  8454. if (b !== "")
  8455. return b;
  8456. }
  8457. return "";
  8458. };
  8459. }
  8460. function Rt2(n, e) {
  8461. var t;
  8462. const l = n.substr(e).match(/^\s+/);
  8463. return (t = l && l[0]) !== null && t !== void 0 ? t : "";
  8464. }
  8465. function _r(n, e) {
  8466. const t = n.substr(e, 1);
  8467. return t.match(/^[1-9]$/) ? t : "";
  8468. }
  8469. function En(n, e) {
  8470. var t;
  8471. const l = n.substr(e).match(/^[0-9]+/);
  8472. return (t = l && l[0]) !== null && t !== void 0 ? t : "";
  8473. }
  8474. function wr(n, e) {
  8475. const t = En(n, e);
  8476. if (t !== "")
  8477. return t;
  8478. const l = n.substr(e, 1);
  8479. if (e += 1, l !== "-" && l !== "+")
  8480. return "";
  8481. const b = En(n, e);
  8482. return b === "" ? "" : l + b;
  8483. }
  8484. function lt2(n, e) {
  8485. const t = n.substr(e, 1);
  8486. if (e += 1, t.toLowerCase() !== "e")
  8487. return "";
  8488. const l = wr(n, e);
  8489. return l === "" ? "" : t + l;
  8490. }
  8491. function Es(n, e) {
  8492. const t = n.substr(e, 1);
  8493. if (t === "0")
  8494. return t;
  8495. const l = _r(n, e);
  8496. return e += l.length, l === "" ? "" : l + En(n, e);
  8497. }
  8498. function yr(n, e) {
  8499. const t = Es(n, e);
  8500. if (e += t.length, t === "")
  8501. return "";
  8502. const l = n.substr(e, 1);
  8503. if (e += l.length, l !== ".")
  8504. return "";
  8505. const b = En(n, e);
  8506. return e += b.length, t + l + b + lt2(n, e);
  8507. }
  8508. function Cs(n, e) {
  8509. const t = n.substr(e, 1);
  8510. if (e += t.length, t !== ".")
  8511. return "";
  8512. const l = En(n, e);
  8513. return e += l.length, l === "" ? "" : t + l + lt2(n, e);
  8514. }
  8515. function xr(n, e) {
  8516. const t = Es(n, e);
  8517. return e += t.length, t === "" ? "" : t + lt2(n, e);
  8518. }
  8519. const Ps = Mi([
  8520. yr,
  8521. Cs,
  8522. xr
  8523. ]);
  8524. function Si(n, e) {
  8525. var t;
  8526. const l = n.substr(e).match(/^[01]+/);
  8527. return (t = l && l[0]) !== null && t !== void 0 ? t : "";
  8528. }
  8529. function Er(n, e) {
  8530. const t = n.substr(e, 2);
  8531. if (e += t.length, t.toLowerCase() !== "0b")
  8532. return "";
  8533. const l = Si(n, e);
  8534. return l === "" ? "" : t + l;
  8535. }
  8536. function Ts(n, e) {
  8537. var t;
  8538. const l = n.substr(e).match(/^[0-7]+/);
  8539. return (t = l && l[0]) !== null && t !== void 0 ? t : "";
  8540. }
  8541. function Je(n, e) {
  8542. const t = n.substr(e, 2);
  8543. if (e += t.length, t.toLowerCase() !== "0o")
  8544. return "";
  8545. const l = Ts(n, e);
  8546. return l === "" ? "" : t + l;
  8547. }
  8548. function Cr(n, e) {
  8549. var t;
  8550. const l = n.substr(e).match(/^[0-9a-f]+/i);
  8551. return (t = l && l[0]) !== null && t !== void 0 ? t : "";
  8552. }
  8553. function Pr(n, e) {
  8554. const t = n.substr(e, 2);
  8555. if (e += t.length, t.toLowerCase() !== "0x")
  8556. return "";
  8557. const l = Cr(n, e);
  8558. return l === "" ? "" : t + l;
  8559. }
  8560. const Li = Mi([
  8561. Er,
  8562. Je,
  8563. Pr
  8564. ]), Tr = Mi([
  8565. Li,
  8566. Ps
  8567. ]);
  8568. function Pt(n, e) {
  8569. const t = Tr(n, e);
  8570. return e += t.length, t === "" ? null : {
  8571. evaluable: new fr(t),
  8572. cursor: e
  8573. };
  8574. }
  8575. function Ri(n, e) {
  8576. const t = n.substr(e, 1);
  8577. if (e += t.length, t !== "(")
  8578. return null;
  8579. const l = ti(n, e);
  8580. if (!l)
  8581. return null;
  8582. e = l.cursor, e += Rt2(n, e).length;
  8583. const b = n.substr(e, 1);
  8584. return e += b.length, b !== ")" ? null : {
  8585. evaluable: l.evaluable,
  8586. cursor: e
  8587. };
  8588. }
  8589. function kr(n, e) {
  8590. var t;
  8591. return (t = Pt(n, e)) !== null && t !== void 0 ? t : Ri(n, e);
  8592. }
  8593. function Vi(n, e) {
  8594. const t = kr(n, e);
  8595. if (t)
  8596. return t;
  8597. const l = n.substr(e, 1);
  8598. if (e += l.length, l !== "+" && l !== "-" && l !== "~")
  8599. return null;
  8600. const b = Vi(n, e);
  8601. return b ? (e = b.cursor, {
  8602. cursor: e,
  8603. evaluable: new gr(l, b.evaluable)
  8604. }) : null;
  8605. }
  8606. function Ar(n, e, t) {
  8607. t += Rt2(e, t).length;
  8608. const l = n.filter((b) => e.startsWith(b, t))[0];
  8609. return l ? (t += l.length, t += Rt2(e, t).length, {
  8610. cursor: t,
  8611. operator: l
  8612. }) : null;
  8613. }
  8614. function Vt(n, e) {
  8615. return (t, l) => {
  8616. const b = n(t, l);
  8617. if (!b)
  8618. return null;
  8619. l = b.cursor;
  8620. let E = b.evaluable;
  8621. for (; ; ) {
  8622. const k = Ar(e, t, l);
  8623. if (!k)
  8624. break;
  8625. l = k.cursor;
  8626. const j = n(t, l);
  8627. if (!j)
  8628. return null;
  8629. l = j.cursor, E = new br(k.operator, E, j.evaluable);
  8630. }
  8631. return E ? {
  8632. cursor: l,
  8633. evaluable: E
  8634. } : null;
  8635. };
  8636. }
  8637. const ks = [
  8638. ["**"],
  8639. ["*", "/", "%"],
  8640. ["+", "-"],
  8641. ["<<", ">>>", ">>"],
  8642. ["&"],
  8643. ["^"],
  8644. ["|"]
  8645. ].reduce((n, e) => Vt(n, e), Vi);
  8646. function ti(n, e) {
  8647. return e += Rt2(n, e).length, ks(n, e);
  8648. }
  8649. function As(n) {
  8650. const e = ti(n, 0);
  8651. return !e || e.cursor + Rt2(n, e.cursor).length !== n.length ? null : e.evaluable;
  8652. }
  8653. function ct2(n) {
  8654. var e;
  8655. const t = As(n);
  8656. return (e = t == null ? void 0 : t.evaluate()) !== null && e !== void 0 ? e : null;
  8657. }
  8658. function _t(n) {
  8659. if (typeof n == "number")
  8660. return n;
  8661. if (typeof n == "string") {
  8662. const e = ct2(n);
  8663. if (!_2(e))
  8664. return e;
  8665. }
  8666. return 0;
  8667. }
  8668. function Mr(n) {
  8669. return String(n);
  8670. }
  8671. function De(n) {
  8672. return (e) => e.toFixed(Math.max(Math.min(n, 20), 0));
  8673. }
  8674. const Ms = De(0);
  8675. function Cn(n) {
  8676. return Ms(n) + "%";
  8677. }
  8678. function Ii(n) {
  8679. return String(n);
  8680. }
  8681. function Tt(n) {
  8682. return n;
  8683. }
  8684. function Qt({ primary: n, secondary: e, forward: t, backward: l }) {
  8685. let b = false;
  8686. function E(k) {
  8687. b || (b = true, k(), b = false);
  8688. }
  8689. n.emitter.on("change", (k) => {
  8690. E(() => {
  8691. e.setRawValue(t(n, e), k.options);
  8692. });
  8693. }), e.emitter.on("change", (k) => {
  8694. E(() => {
  8695. n.setRawValue(l(n, e), k.options);
  8696. }), E(() => {
  8697. e.setRawValue(t(n, e), k.options);
  8698. });
  8699. }), E(() => {
  8700. e.setRawValue(t(n, e), {
  8701. forceEmit: false,
  8702. last: true
  8703. });
  8704. });
  8705. }
  8706. function je(n, e) {
  8707. const t = n * (e.altKey ? 0.1 : 1) * (e.shiftKey ? 10 : 1);
  8708. return e.upKey ? +t : e.downKey ? -t : 0;
  8709. }
  8710. function Pn(n) {
  8711. return {
  8712. altKey: n.altKey,
  8713. downKey: n.key === "ArrowDown",
  8714. shiftKey: n.shiftKey,
  8715. upKey: n.key === "ArrowUp"
  8716. };
  8717. }
  8718. function ut2(n) {
  8719. return {
  8720. altKey: n.altKey,
  8721. downKey: n.key === "ArrowLeft",
  8722. shiftKey: n.shiftKey,
  8723. upKey: n.key === "ArrowRight"
  8724. };
  8725. }
  8726. function Ss(n) {
  8727. return n === "ArrowUp" || n === "ArrowDown";
  8728. }
  8729. function ni(n) {
  8730. return Ss(n) || n === "ArrowLeft" || n === "ArrowRight";
  8731. }
  8732. function Di(n, e) {
  8733. var t, l;
  8734. const b = e.ownerDocument.defaultView, E = e.getBoundingClientRect();
  8735. return {
  8736. x: n.pageX - (((t = b && b.scrollX) !== null && t !== void 0 ? t : 0) + E.left),
  8737. y: n.pageY - (((l = b && b.scrollY) !== null && l !== void 0 ? l : 0) + E.top)
  8738. };
  8739. }
  8740. class It {
  8741. constructor(e) {
  8742. this.lastTouch_ = null, this.onDocumentMouseMove_ = this.onDocumentMouseMove_.bind(this), this.onDocumentMouseUp_ = this.onDocumentMouseUp_.bind(this), this.onMouseDown_ = this.onMouseDown_.bind(this), this.onTouchEnd_ = this.onTouchEnd_.bind(this), this.onTouchMove_ = this.onTouchMove_.bind(this), this.onTouchStart_ = this.onTouchStart_.bind(this), this.elem_ = e, this.emitter = new N(), e.addEventListener("touchstart", this.onTouchStart_, {
  8743. passive: false
  8744. }), e.addEventListener("touchmove", this.onTouchMove_, {
  8745. passive: true
  8746. }), e.addEventListener("touchend", this.onTouchEnd_), e.addEventListener("mousedown", this.onMouseDown_);
  8747. }
  8748. computePosition_(e) {
  8749. const t = this.elem_.getBoundingClientRect();
  8750. return {
  8751. bounds: {
  8752. width: t.width,
  8753. height: t.height
  8754. },
  8755. point: e ? {
  8756. x: e.x,
  8757. y: e.y
  8758. } : null
  8759. };
  8760. }
  8761. onMouseDown_(e) {
  8762. var t;
  8763. e.preventDefault(), (t = e.currentTarget) === null || t === void 0 || t.focus();
  8764. const l = this.elem_.ownerDocument;
  8765. l.addEventListener("mousemove", this.onDocumentMouseMove_), l.addEventListener("mouseup", this.onDocumentMouseUp_), this.emitter.emit("down", {
  8766. altKey: e.altKey,
  8767. data: this.computePosition_(Di(e, this.elem_)),
  8768. sender: this,
  8769. shiftKey: e.shiftKey
  8770. });
  8771. }
  8772. onDocumentMouseMove_(e) {
  8773. this.emitter.emit("move", {
  8774. altKey: e.altKey,
  8775. data: this.computePosition_(Di(e, this.elem_)),
  8776. sender: this,
  8777. shiftKey: e.shiftKey
  8778. });
  8779. }
  8780. onDocumentMouseUp_(e) {
  8781. const t = this.elem_.ownerDocument;
  8782. t.removeEventListener("mousemove", this.onDocumentMouseMove_), t.removeEventListener("mouseup", this.onDocumentMouseUp_), this.emitter.emit("up", {
  8783. altKey: e.altKey,
  8784. data: this.computePosition_(Di(e, this.elem_)),
  8785. sender: this,
  8786. shiftKey: e.shiftKey
  8787. });
  8788. }
  8789. onTouchStart_(e) {
  8790. e.preventDefault();
  8791. const t = e.targetTouches.item(0), l = this.elem_.getBoundingClientRect();
  8792. this.emitter.emit("down", {
  8793. altKey: e.altKey,
  8794. data: this.computePosition_(t ? {
  8795. x: t.clientX - l.left,
  8796. y: t.clientY - l.top
  8797. } : void 0),
  8798. sender: this,
  8799. shiftKey: e.shiftKey
  8800. }), this.lastTouch_ = t;
  8801. }
  8802. onTouchMove_(e) {
  8803. const t = e.targetTouches.item(0), l = this.elem_.getBoundingClientRect();
  8804. this.emitter.emit("move", {
  8805. altKey: e.altKey,
  8806. data: this.computePosition_(t ? {
  8807. x: t.clientX - l.left,
  8808. y: t.clientY - l.top
  8809. } : void 0),
  8810. sender: this,
  8811. shiftKey: e.shiftKey
  8812. }), this.lastTouch_ = t;
  8813. }
  8814. onTouchEnd_(e) {
  8815. var t;
  8816. const l = (t = e.targetTouches.item(0)) !== null && t !== void 0 ? t : this.lastTouch_, b = this.elem_.getBoundingClientRect();
  8817. this.emitter.emit("up", {
  8818. altKey: e.altKey,
  8819. data: this.computePosition_(l ? {
  8820. x: l.clientX - b.left,
  8821. y: l.clientY - b.top
  8822. } : void 0),
  8823. sender: this,
  8824. shiftKey: e.shiftKey
  8825. });
  8826. }
  8827. }
  8828. function we(n, e, t, l, b) {
  8829. const E = (n - e) / (t - e);
  8830. return l + E * (b - l);
  8831. }
  8832. function Oi(n) {
  8833. return String(n.toFixed(10)).split(".")[1].replace(/0+$/, "").length;
  8834. }
  8835. function Re2(n, e, t) {
  8836. return Math.min(Math.max(n, e), t);
  8837. }
  8838. function Zt(n, e) {
  8839. return (n % e + e) % e;
  8840. }
  8841. const Ye = D2("txt");
  8842. class Ni {
  8843. constructor(e, t) {
  8844. this.onChange_ = this.onChange_.bind(this), this.props_ = t.props, this.props_.emitter.on("change", this.onChange_), this.element = e.createElement("div"), this.element.classList.add(Ye(), Ye(void 0, "num")), t.arrayPosition && this.element.classList.add(Ye(void 0, t.arrayPosition)), t.viewProps.bindClassModifiers(this.element);
  8845. const l = e.createElement("input");
  8846. l.classList.add(Ye("i")), l.type = "text", t.viewProps.bindDisabled(l), this.element.appendChild(l), this.inputElement = l, this.onDraggingChange_ = this.onDraggingChange_.bind(this), this.dragging_ = t.dragging, this.dragging_.emitter.on("change", this.onDraggingChange_), this.element.classList.add(Ye()), this.inputElement.classList.add(Ye("i"));
  8847. const b = e.createElement("div");
  8848. b.classList.add(Ye("k")), this.element.appendChild(b), this.knobElement = b;
  8849. const E = e.createElementNS(Ke, "svg");
  8850. E.classList.add(Ye("g")), this.knobElement.appendChild(E);
  8851. const k = e.createElementNS(Ke, "path");
  8852. k.classList.add(Ye("gb")), E.appendChild(k), this.guideBodyElem_ = k;
  8853. const j = e.createElementNS(Ke, "path");
  8854. j.classList.add(Ye("gh")), E.appendChild(j), this.guideHeadElem_ = j;
  8855. const Q2 = e.createElement("div");
  8856. Q2.classList.add(D2("tt")()), this.knobElement.appendChild(Q2), this.tooltipElem_ = Q2, t.value.emitter.on("change", this.onChange_), this.value = t.value, this.refresh();
  8857. }
  8858. onDraggingChange_(e) {
  8859. if (e.rawValue === null) {
  8860. this.element.classList.remove(Ye(void 0, "drg"));
  8861. return;
  8862. }
  8863. this.element.classList.add(Ye(void 0, "drg"));
  8864. const t = e.rawValue / this.props_.get("draggingScale"), l = t + (t > 0 ? -1 : t < 0 ? 1 : 0), b = Re2(-l, -4, 4);
  8865. this.guideHeadElem_.setAttributeNS(null, "d", [`M ${l + b},0 L${l},4 L${l + b},8`, `M ${t},-1 L${t},9`].join(" ")), this.guideBodyElem_.setAttributeNS(null, "d", `M 0,4 L${t},4`);
  8866. const E = this.props_.get("formatter");
  8867. this.tooltipElem_.textContent = E(this.value.rawValue), this.tooltipElem_.style.left = `${t}px`;
  8868. }
  8869. refresh() {
  8870. const e = this.props_.get("formatter");
  8871. this.inputElement.value = e(this.value.rawValue);
  8872. }
  8873. onChange_() {
  8874. this.refresh();
  8875. }
  8876. }
  8877. class Tn {
  8878. constructor(e, t) {
  8879. var l;
  8880. this.originRawValue_ = 0, this.onInputChange_ = this.onInputChange_.bind(this), this.onInputKeyDown_ = this.onInputKeyDown_.bind(this), this.onInputKeyUp_ = this.onInputKeyUp_.bind(this), this.onPointerDown_ = this.onPointerDown_.bind(this), this.onPointerMove_ = this.onPointerMove_.bind(this), this.onPointerUp_ = this.onPointerUp_.bind(this), this.baseStep_ = t.baseStep, this.parser_ = t.parser, this.props = t.props, this.sliderProps_ = (l = t.sliderProps) !== null && l !== void 0 ? l : null, this.value = t.value, this.viewProps = t.viewProps, this.dragging_ = ee(null), this.view = new Ni(e, {
  8881. arrayPosition: t.arrayPosition,
  8882. dragging: this.dragging_,
  8883. props: this.props,
  8884. value: this.value,
  8885. viewProps: this.viewProps
  8886. }), this.view.inputElement.addEventListener("change", this.onInputChange_), this.view.inputElement.addEventListener("keydown", this.onInputKeyDown_), this.view.inputElement.addEventListener("keyup", this.onInputKeyUp_);
  8887. const b = new It(this.view.knobElement);
  8888. b.emitter.on("down", this.onPointerDown_), b.emitter.on("move", this.onPointerMove_), b.emitter.on("up", this.onPointerUp_);
  8889. }
  8890. constrainValue_(e) {
  8891. var t, l;
  8892. const b = (t = this.sliderProps_) === null || t === void 0 ? void 0 : t.get("minValue"), E = (l = this.sliderProps_) === null || l === void 0 ? void 0 : l.get("maxValue");
  8893. let k = e;
  8894. return b !== void 0 && (k = Math.max(k, b)), E !== void 0 && (k = Math.min(k, E)), k;
  8895. }
  8896. onInputChange_(e) {
  8897. const l = e.currentTarget.value, b = this.parser_(l);
  8898. _2(b) || (this.value.rawValue = this.constrainValue_(b)), this.view.refresh();
  8899. }
  8900. onInputKeyDown_(e) {
  8901. const t = je(this.baseStep_, Pn(e));
  8902. t !== 0 && this.value.setRawValue(this.constrainValue_(this.value.rawValue + t), {
  8903. forceEmit: false,
  8904. last: false
  8905. });
  8906. }
  8907. onInputKeyUp_(e) {
  8908. je(this.baseStep_, Pn(e)) !== 0 && this.value.setRawValue(this.value.rawValue, {
  8909. forceEmit: true,
  8910. last: true
  8911. });
  8912. }
  8913. onPointerDown_() {
  8914. this.originRawValue_ = this.value.rawValue, this.dragging_.rawValue = 0;
  8915. }
  8916. computeDraggingValue_(e) {
  8917. if (!e.point)
  8918. return null;
  8919. const t = e.point.x - e.bounds.width / 2;
  8920. return this.constrainValue_(this.originRawValue_ + t * this.props.get("draggingScale"));
  8921. }
  8922. onPointerMove_(e) {
  8923. const t = this.computeDraggingValue_(e.data);
  8924. t !== null && (this.value.setRawValue(t, {
  8925. forceEmit: false,
  8926. last: false
  8927. }), this.dragging_.rawValue = this.value.rawValue - this.originRawValue_);
  8928. }
  8929. onPointerUp_(e) {
  8930. const t = this.computeDraggingValue_(e.data);
  8931. t !== null && (this.value.setRawValue(t, {
  8932. forceEmit: true,
  8933. last: true
  8934. }), this.dragging_.rawValue = null);
  8935. }
  8936. }
  8937. const Bi = D2("sld");
  8938. class qe {
  8939. constructor(e, t) {
  8940. this.onChange_ = this.onChange_.bind(this), this.props_ = t.props, this.props_.emitter.on("change", this.onChange_), this.element = e.createElement("div"), this.element.classList.add(Bi()), t.viewProps.bindClassModifiers(this.element);
  8941. const l = e.createElement("div");
  8942. l.classList.add(Bi("t")), t.viewProps.bindTabIndex(l), this.element.appendChild(l), this.trackElement = l;
  8943. const b = e.createElement("div");
  8944. b.classList.add(Bi("k")), this.trackElement.appendChild(b), this.knobElement = b, t.value.emitter.on("change", this.onChange_), this.value = t.value, this.update_();
  8945. }
  8946. update_() {
  8947. const e = Re2(we(this.value.rawValue, this.props_.get("minValue"), this.props_.get("maxValue"), 0, 100), 0, 100);
  8948. this.knobElement.style.width = `${e}%`;
  8949. }
  8950. onChange_() {
  8951. this.update_();
  8952. }
  8953. }
  8954. class Fi {
  8955. constructor(e, t) {
  8956. this.onKeyDown_ = this.onKeyDown_.bind(this), this.onKeyUp_ = this.onKeyUp_.bind(this), this.onPointerDownOrMove_ = this.onPointerDownOrMove_.bind(this), this.onPointerUp_ = this.onPointerUp_.bind(this), this.baseStep_ = t.baseStep, this.value = t.value, this.viewProps = t.viewProps, this.props = t.props, this.view = new qe(e, {
  8957. props: this.props,
  8958. value: this.value,
  8959. viewProps: this.viewProps
  8960. }), this.ptHandler_ = new It(this.view.trackElement), this.ptHandler_.emitter.on("down", this.onPointerDownOrMove_), this.ptHandler_.emitter.on("move", this.onPointerDownOrMove_), this.ptHandler_.emitter.on("up", this.onPointerUp_), this.view.trackElement.addEventListener("keydown", this.onKeyDown_), this.view.trackElement.addEventListener("keyup", this.onKeyUp_);
  8961. }
  8962. handlePointerEvent_(e, t) {
  8963. e.point && this.value.setRawValue(we(Re2(e.point.x, 0, e.bounds.width), 0, e.bounds.width, this.props.get("minValue"), this.props.get("maxValue")), t);
  8964. }
  8965. onPointerDownOrMove_(e) {
  8966. this.handlePointerEvent_(e.data, {
  8967. forceEmit: false,
  8968. last: false
  8969. });
  8970. }
  8971. onPointerUp_(e) {
  8972. this.handlePointerEvent_(e.data, {
  8973. forceEmit: true,
  8974. last: true
  8975. });
  8976. }
  8977. onKeyDown_(e) {
  8978. const t = je(this.baseStep_, ut2(e));
  8979. t !== 0 && this.value.setRawValue(this.value.rawValue + t, {
  8980. forceEmit: false,
  8981. last: false
  8982. });
  8983. }
  8984. onKeyUp_(e) {
  8985. je(this.baseStep_, ut2(e)) !== 0 && this.value.setRawValue(this.value.rawValue, {
  8986. forceEmit: true,
  8987. last: true
  8988. });
  8989. }
  8990. }
  8991. const kn = D2("sldtxt");
  8992. class ji {
  8993. constructor(e, t) {
  8994. this.element = e.createElement("div"), this.element.classList.add(kn());
  8995. const l = e.createElement("div");
  8996. l.classList.add(kn("s")), this.sliderView_ = t.sliderView, l.appendChild(this.sliderView_.element), this.element.appendChild(l);
  8997. const b = e.createElement("div");
  8998. b.classList.add(kn("t")), this.textView_ = t.textView, b.appendChild(this.textView_.element), this.element.appendChild(b);
  8999. }
  9000. }
  9001. class ii {
  9002. constructor(e, t) {
  9003. this.value = t.value, this.viewProps = t.viewProps, this.sliderC_ = new Fi(e, {
  9004. baseStep: t.baseStep,
  9005. props: t.sliderProps,
  9006. value: t.value,
  9007. viewProps: this.viewProps
  9008. }), this.textC_ = new Tn(e, {
  9009. baseStep: t.baseStep,
  9010. parser: t.parser,
  9011. props: t.textProps,
  9012. sliderProps: t.sliderProps,
  9013. value: t.value,
  9014. viewProps: t.viewProps
  9015. }), this.view = new ji(e, {
  9016. sliderView: this.sliderC_.view,
  9017. textView: this.textC_.view
  9018. });
  9019. }
  9020. get sliderController() {
  9021. return this.sliderC_;
  9022. }
  9023. get textController() {
  9024. return this.textC_;
  9025. }
  9026. }
  9027. function st2(n, e) {
  9028. n.write(e);
  9029. }
  9030. function An(n) {
  9031. const e = A2;
  9032. if (Array.isArray(n))
  9033. return e.required.array(e.required.object({
  9034. text: e.required.string,
  9035. value: e.required.raw
  9036. }))(n).value;
  9037. if (typeof n == "object")
  9038. return e.required.raw(n).value;
  9039. }
  9040. function zi(n) {
  9041. if (n === "inline" || n === "popup")
  9042. return n;
  9043. }
  9044. function wt2(n) {
  9045. const e = A2;
  9046. return e.required.object({
  9047. max: e.optional.number,
  9048. min: e.optional.number,
  9049. step: e.optional.number
  9050. })(n).value;
  9051. }
  9052. function Ls(n) {
  9053. if (Array.isArray(n))
  9054. return n;
  9055. const e = [];
  9056. return Object.keys(n).forEach((t) => {
  9057. e.push({ text: t, value: n[t] });
  9058. }), e;
  9059. }
  9060. function Ui(n) {
  9061. return _2(n) ? null : new yn(Ls(n));
  9062. }
  9063. function Sr(n) {
  9064. const e = n ? it2(n, Jn) : null;
  9065. return e ? e.step : null;
  9066. }
  9067. function si(n, e) {
  9068. const t = n && it2(n, Jn);
  9069. return t ? Oi(t.step) : Math.max(Oi(e), 2);
  9070. }
  9071. function Dt(n) {
  9072. const e = Sr(n);
  9073. return e ?? 1;
  9074. }
  9075. function Ot(n, e) {
  9076. var t;
  9077. const l = n && it2(n, Jn), b = Math.abs((t = l == null ? void 0 : l.step) !== null && t !== void 0 ? t : e);
  9078. return b === 0 ? 0.1 : Math.pow(10, Math.floor(Math.log10(b)) - 1);
  9079. }
  9080. const Mn = D2("ckb");
  9081. class Sn {
  9082. constructor(e, t) {
  9083. this.onValueChange_ = this.onValueChange_.bind(this), this.element = e.createElement("div"), this.element.classList.add(Mn()), t.viewProps.bindClassModifiers(this.element);
  9084. const l = e.createElement("label");
  9085. l.classList.add(Mn("l")), this.element.appendChild(l);
  9086. const b = e.createElement("input");
  9087. b.classList.add(Mn("i")), b.type = "checkbox", l.appendChild(b), this.inputElement = b, t.viewProps.bindDisabled(this.inputElement);
  9088. const E = e.createElement("div");
  9089. E.classList.add(Mn("w")), l.appendChild(E);
  9090. const k = Et2(e, "check");
  9091. E.appendChild(k), t.value.emitter.on("change", this.onValueChange_), this.value = t.value, this.update_();
  9092. }
  9093. update_() {
  9094. this.inputElement.checked = this.value.rawValue;
  9095. }
  9096. onValueChange_() {
  9097. this.update_();
  9098. }
  9099. }
  9100. class Rs {
  9101. constructor(e, t) {
  9102. this.onInputChange_ = this.onInputChange_.bind(this), this.value = t.value, this.viewProps = t.viewProps, this.view = new Sn(e, {
  9103. value: this.value,
  9104. viewProps: this.viewProps
  9105. }), this.view.inputElement.addEventListener("change", this.onInputChange_);
  9106. }
  9107. onInputChange_(e) {
  9108. const t = e.currentTarget;
  9109. this.value.rawValue = t.checked;
  9110. }
  9111. }
  9112. function Vs(n) {
  9113. const e = [], t = Ui(n.options);
  9114. return t && e.push(t), new wn(e);
  9115. }
  9116. const ri = {
  9117. id: "input-bool",
  9118. type: "input",
  9119. accept: (n, e) => {
  9120. if (typeof n != "boolean")
  9121. return null;
  9122. const l = ae(e, {
  9123. options: A2.optional.custom(An)
  9124. });
  9125. return l ? {
  9126. initialValue: n,
  9127. params: l
  9128. } : null;
  9129. },
  9130. binding: {
  9131. reader: (n) => ws,
  9132. constraint: (n) => Vs(n.params),
  9133. writer: (n) => st2
  9134. },
  9135. controller: (n) => {
  9136. const e = n.document, t = n.value, l = n.constraint, b = l && it2(l, yn);
  9137. return b ? new xn(e, {
  9138. props: new X2({
  9139. options: b.values.value("options")
  9140. }),
  9141. value: t,
  9142. viewProps: n.viewProps
  9143. }) : new Rs(e, {
  9144. value: t,
  9145. viewProps: n.viewProps
  9146. });
  9147. }
  9148. }, Nt = D2("col");
  9149. class Gi {
  9150. constructor(e, t) {
  9151. this.element = e.createElement("div"), this.element.classList.add(Nt()), t.foldable.bindExpandedClass(this.element, Nt(void 0, "expanded")), B(t.foldable, "completed", K2(this.element, Nt(void 0, "cpl")));
  9152. const l = e.createElement("div");
  9153. l.classList.add(Nt("h")), this.element.appendChild(l);
  9154. const b = e.createElement("div");
  9155. b.classList.add(Nt("s")), l.appendChild(b), this.swatchElement = b;
  9156. const E = e.createElement("div");
  9157. if (E.classList.add(Nt("t")), l.appendChild(E), this.textElement = E, t.pickerLayout === "inline") {
  9158. const k = e.createElement("div");
  9159. k.classList.add(Nt("p")), this.element.appendChild(k), this.pickerElement = k;
  9160. } else
  9161. this.pickerElement = null;
  9162. }
  9163. }
  9164. function Lr(n, e, t) {
  9165. const l = Re2(n / 255, 0, 1), b = Re2(e / 255, 0, 1), E = Re2(t / 255, 0, 1), k = Math.max(l, b, E), j = Math.min(l, b, E), Q2 = k - j;
  9166. let J = 0, de = 0;
  9167. const ve = (j + k) / 2;
  9168. return Q2 !== 0 && (de = Q2 / (1 - Math.abs(k + j - 1)), l === k ? J = (b - E) / Q2 : b === k ? J = 2 + (E - l) / Q2 : J = 4 + (l - b) / Q2, J = J / 6 + (J < 0 ? 1 : 0)), [J * 360, de * 100, ve * 100];
  9169. }
  9170. function Rr(n, e, t) {
  9171. const l = (n % 360 + 360) % 360, b = Re2(e / 100, 0, 1), E = Re2(t / 100, 0, 1), k = (1 - Math.abs(2 * E - 1)) * b, j = k * (1 - Math.abs(l / 60 % 2 - 1)), Q2 = E - k / 2;
  9172. let J, de, ve;
  9173. return l >= 0 && l < 60 ? [J, de, ve] = [k, j, 0] : l >= 60 && l < 120 ? [J, de, ve] = [j, k, 0] : l >= 120 && l < 180 ? [J, de, ve] = [0, k, j] : l >= 180 && l < 240 ? [J, de, ve] = [0, j, k] : l >= 240 && l < 300 ? [J, de, ve] = [j, 0, k] : [J, de, ve] = [k, 0, j], [(J + Q2) * 255, (de + Q2) * 255, (ve + Q2) * 255];
  9174. }
  9175. function Vr(n, e, t) {
  9176. const l = Re2(n / 255, 0, 1), b = Re2(e / 255, 0, 1), E = Re2(t / 255, 0, 1), k = Math.max(l, b, E), j = Math.min(l, b, E), Q2 = k - j;
  9177. let J;
  9178. Q2 === 0 ? J = 0 : k === l ? J = 60 * (((b - E) / Q2 % 6 + 6) % 6) : k === b ? J = 60 * ((E - l) / Q2 + 2) : J = 60 * ((l - b) / Q2 + 4);
  9179. const de = k === 0 ? 0 : Q2 / k, ve = k;
  9180. return [J, de * 100, ve * 100];
  9181. }
  9182. function Is(n, e, t) {
  9183. const l = Zt(n, 360), b = Re2(e / 100, 0, 1), E = Re2(t / 100, 0, 1), k = E * b, j = k * (1 - Math.abs(l / 60 % 2 - 1)), Q2 = E - k;
  9184. let J, de, ve;
  9185. return l >= 0 && l < 60 ? [J, de, ve] = [k, j, 0] : l >= 60 && l < 120 ? [J, de, ve] = [j, k, 0] : l >= 120 && l < 180 ? [J, de, ve] = [0, k, j] : l >= 180 && l < 240 ? [J, de, ve] = [0, j, k] : l >= 240 && l < 300 ? [J, de, ve] = [j, 0, k] : [J, de, ve] = [k, 0, j], [(J + Q2) * 255, (de + Q2) * 255, (ve + Q2) * 255];
  9186. }
  9187. function d(n, e, t) {
  9188. const l = t + e * (100 - Math.abs(2 * t - 100)) / 200;
  9189. return [
  9190. n,
  9191. l !== 0 ? e * (100 - Math.abs(2 * t - 100)) / l : 0,
  9192. t + e * (100 - Math.abs(2 * t - 100)) / (2 * 100)
  9193. ];
  9194. }
  9195. function a(n, e, t) {
  9196. const l = 100 - Math.abs(t * (200 - e) / 100 - 100);
  9197. return [n, l !== 0 ? e * t / l : 0, t * (200 - e) / (2 * 100)];
  9198. }
  9199. function u(n) {
  9200. return [n[0], n[1], n[2]];
  9201. }
  9202. function v(n, e) {
  9203. return [n[0], n[1], n[2], e];
  9204. }
  9205. const x = {
  9206. hsl: {
  9207. hsl: (n, e, t) => [n, e, t],
  9208. hsv: d,
  9209. rgb: Rr
  9210. },
  9211. hsv: {
  9212. hsl: a,
  9213. hsv: (n, e, t) => [n, e, t],
  9214. rgb: Is
  9215. },
  9216. rgb: {
  9217. hsl: Lr,
  9218. hsv: Vr,
  9219. rgb: (n, e, t) => [n, e, t]
  9220. }
  9221. };
  9222. function T(n, e) {
  9223. return [
  9224. e === "float" ? 1 : n === "rgb" ? 255 : 360,
  9225. e === "float" ? 1 : n === "rgb" ? 255 : 100,
  9226. e === "float" ? 1 : n === "rgb" ? 255 : 100
  9227. ];
  9228. }
  9229. function V2(n, e) {
  9230. return n === e ? e : Zt(n, e);
  9231. }
  9232. function z(n, e, t) {
  9233. var l;
  9234. const b = T(e, t);
  9235. return [
  9236. e === "rgb" ? Re2(n[0], 0, b[0]) : V2(n[0], b[0]),
  9237. Re2(n[1], 0, b[1]),
  9238. Re2(n[2], 0, b[2]),
  9239. Re2((l = n[3]) !== null && l !== void 0 ? l : 1, 0, 1)
  9240. ];
  9241. }
  9242. function re(n, e, t, l) {
  9243. const b = T(e, t), E = T(e, l);
  9244. return n.map((k, j) => k / b[j] * E[j]);
  9245. }
  9246. function et2(n, e, t) {
  9247. const l = re(n, e.mode, e.type, "int"), b = x[e.mode][t.mode](...l);
  9248. return re(b, t.mode, "int", t.type);
  9249. }
  9250. function tt2(n, e) {
  9251. return typeof n != "object" || _2(n) ? false : e in n && typeof n[e] == "number";
  9252. }
  9253. class te {
  9254. static black(e = "int") {
  9255. return new te([0, 0, 0], "rgb", e);
  9256. }
  9257. static fromObject(e, t = "int") {
  9258. const l = "a" in e ? [e.r, e.g, e.b, e.a] : [e.r, e.g, e.b];
  9259. return new te(l, "rgb", t);
  9260. }
  9261. static toRgbaObject(e, t = "int") {
  9262. return e.toRgbaObject(t);
  9263. }
  9264. static isRgbColorObject(e) {
  9265. return tt2(e, "r") && tt2(e, "g") && tt2(e, "b");
  9266. }
  9267. static isRgbaColorObject(e) {
  9268. return this.isRgbColorObject(e) && tt2(e, "a");
  9269. }
  9270. static isColorObject(e) {
  9271. return this.isRgbColorObject(e);
  9272. }
  9273. static equals(e, t) {
  9274. if (e.mode !== t.mode)
  9275. return false;
  9276. const l = e.comps_, b = t.comps_;
  9277. for (let E = 0; E < l.length; E++)
  9278. if (l[E] !== b[E])
  9279. return false;
  9280. return true;
  9281. }
  9282. constructor(e, t, l = "int") {
  9283. this.mode = t, this.type = l, this.comps_ = z(e, t, l);
  9284. }
  9285. getComponents(e, t = "int") {
  9286. return v(et2(u(this.comps_), { mode: this.mode, type: this.type }, { mode: e ?? this.mode, type: t }), this.comps_[3]);
  9287. }
  9288. toRgbaObject(e = "int") {
  9289. const t = this.getComponents("rgb", e);
  9290. return {
  9291. r: t[0],
  9292. g: t[1],
  9293. b: t[2],
  9294. a: t[3]
  9295. };
  9296. }
  9297. }
  9298. const kt = D2("colp");
  9299. class Ir {
  9300. constructor(e, t) {
  9301. this.alphaViews_ = null, this.element = e.createElement("div"), this.element.classList.add(kt()), t.viewProps.bindClassModifiers(this.element);
  9302. const l = e.createElement("div");
  9303. l.classList.add(kt("hsv"));
  9304. const b = e.createElement("div");
  9305. b.classList.add(kt("sv")), this.svPaletteView_ = t.svPaletteView, b.appendChild(this.svPaletteView_.element), l.appendChild(b);
  9306. const E = e.createElement("div");
  9307. E.classList.add(kt("h")), this.hPaletteView_ = t.hPaletteView, E.appendChild(this.hPaletteView_.element), l.appendChild(E), this.element.appendChild(l);
  9308. const k = e.createElement("div");
  9309. if (k.classList.add(kt("rgb")), this.textView_ = t.textView, k.appendChild(this.textView_.element), this.element.appendChild(k), t.alphaViews) {
  9310. this.alphaViews_ = {
  9311. palette: t.alphaViews.palette,
  9312. text: t.alphaViews.text
  9313. };
  9314. const j = e.createElement("div");
  9315. j.classList.add(kt("a"));
  9316. const Q2 = e.createElement("div");
  9317. Q2.classList.add(kt("ap")), Q2.appendChild(this.alphaViews_.palette.element), j.appendChild(Q2);
  9318. const J = e.createElement("div");
  9319. J.classList.add(kt("at")), J.appendChild(this.alphaViews_.text.element), j.appendChild(J), this.element.appendChild(j);
  9320. }
  9321. }
  9322. get allFocusableElements() {
  9323. const e = [
  9324. this.svPaletteView_.element,
  9325. this.hPaletteView_.element,
  9326. this.textView_.modeSelectElement,
  9327. ...this.textView_.textViews.map((t) => t.inputElement)
  9328. ];
  9329. return this.alphaViews_ && e.push(this.alphaViews_.palette.element, this.alphaViews_.text.inputElement), e;
  9330. }
  9331. }
  9332. function ll(n) {
  9333. return n === "int" ? "int" : n === "float" ? "float" : void 0;
  9334. }
  9335. function Dr(n) {
  9336. const e = A2;
  9337. return ae(n, {
  9338. alpha: e.optional.boolean,
  9339. color: e.optional.object({
  9340. alpha: e.optional.boolean,
  9341. type: e.optional.custom(ll)
  9342. }),
  9343. expanded: e.optional.boolean,
  9344. picker: e.optional.custom(zi)
  9345. });
  9346. }
  9347. function Ln(n) {
  9348. return n ? 0.1 : 1;
  9349. }
  9350. function Rn(n) {
  9351. var e;
  9352. return (e = n.color) === null || e === void 0 ? void 0 : e.type;
  9353. }
  9354. function cl(n, e) {
  9355. return n.alpha === e.alpha && n.mode === e.mode && n.notation === e.notation && n.type === e.type;
  9356. }
  9357. function pt2(n, e) {
  9358. const t = n.match(/^(.+)%$/);
  9359. return Math.min(t ? parseFloat(t[1]) * 0.01 * e : parseFloat(n), e);
  9360. }
  9361. const ul = {
  9362. deg: (n) => n,
  9363. grad: (n) => n * 360 / 400,
  9364. rad: (n) => n * 360 / (2 * Math.PI),
  9365. turn: (n) => n * 360
  9366. };
  9367. function Ao(n) {
  9368. const e = n.match(/^([0-9.]+?)(deg|grad|rad|turn)$/);
  9369. if (!e)
  9370. return parseFloat(n);
  9371. const t = parseFloat(e[1]), l = e[2];
  9372. return ul[l](t);
  9373. }
  9374. function Mo(n) {
  9375. const e = n.match(/^rgb\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);
  9376. if (!e)
  9377. return null;
  9378. const t = [
  9379. pt2(e[1], 255),
  9380. pt2(e[2], 255),
  9381. pt2(e[3], 255)
  9382. ];
  9383. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) ? null : t;
  9384. }
  9385. function So(n) {
  9386. return (e) => {
  9387. const t = Mo(e);
  9388. return t ? new te(t, "rgb", n) : null;
  9389. };
  9390. }
  9391. function Lo(n) {
  9392. const e = n.match(/^rgba\(\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);
  9393. if (!e)
  9394. return null;
  9395. const t = [
  9396. pt2(e[1], 255),
  9397. pt2(e[2], 255),
  9398. pt2(e[3], 255),
  9399. pt2(e[4], 1)
  9400. ];
  9401. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) || isNaN(t[3]) ? null : t;
  9402. }
  9403. function Ro(n) {
  9404. return (e) => {
  9405. const t = Lo(e);
  9406. return t ? new te(t, "rgb", n) : null;
  9407. };
  9408. }
  9409. function Vo(n) {
  9410. const e = n.match(/^hsl\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);
  9411. if (!e)
  9412. return null;
  9413. const t = [
  9414. Ao(e[1]),
  9415. pt2(e[2], 100),
  9416. pt2(e[3], 100)
  9417. ];
  9418. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) ? null : t;
  9419. }
  9420. function Io(n) {
  9421. return (e) => {
  9422. const t = Vo(e);
  9423. return t ? new te(t, "hsl", n) : null;
  9424. };
  9425. }
  9426. function Do(n) {
  9427. const e = n.match(/^hsla\(\s*([0-9A-Fa-f.]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*,\s*([0-9A-Fa-f.]+%?)\s*\)$/);
  9428. if (!e)
  9429. return null;
  9430. const t = [
  9431. Ao(e[1]),
  9432. pt2(e[2], 100),
  9433. pt2(e[3], 100),
  9434. pt2(e[4], 1)
  9435. ];
  9436. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) || isNaN(t[3]) ? null : t;
  9437. }
  9438. function Oo(n) {
  9439. return (e) => {
  9440. const t = Do(e);
  9441. return t ? new te(t, "hsl", n) : null;
  9442. };
  9443. }
  9444. function No(n) {
  9445. const e = n.match(/^#([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);
  9446. if (e)
  9447. return [
  9448. parseInt(e[1] + e[1], 16),
  9449. parseInt(e[2] + e[2], 16),
  9450. parseInt(e[3] + e[3], 16)
  9451. ];
  9452. const t = n.match(/^(?:#|0x)([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);
  9453. return t ? [
  9454. parseInt(t[1], 16),
  9455. parseInt(t[2], 16),
  9456. parseInt(t[3], 16)
  9457. ] : null;
  9458. }
  9459. function pl(n) {
  9460. const e = No(n);
  9461. return e ? new te(e, "rgb", "int") : null;
  9462. }
  9463. function Bo(n) {
  9464. const e = n.match(/^#?([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])([0-9A-Fa-f])$/);
  9465. if (e)
  9466. return [
  9467. parseInt(e[1] + e[1], 16),
  9468. parseInt(e[2] + e[2], 16),
  9469. parseInt(e[3] + e[3], 16),
  9470. we(parseInt(e[4] + e[4], 16), 0, 255, 0, 1)
  9471. ];
  9472. const t = n.match(/^(?:#|0x)?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/);
  9473. return t ? [
  9474. parseInt(t[1], 16),
  9475. parseInt(t[2], 16),
  9476. parseInt(t[3], 16),
  9477. we(parseInt(t[4], 16), 0, 255, 0, 1)
  9478. ] : null;
  9479. }
  9480. function hl(n) {
  9481. const e = Bo(n);
  9482. return e ? new te(e, "rgb", "int") : null;
  9483. }
  9484. function Fo(n) {
  9485. const e = n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);
  9486. if (!e)
  9487. return null;
  9488. const t = [
  9489. parseFloat(e[1]),
  9490. parseFloat(e[2]),
  9491. parseFloat(e[3])
  9492. ];
  9493. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) ? null : t;
  9494. }
  9495. function jo(n) {
  9496. return (e) => {
  9497. const t = Fo(e);
  9498. return t ? new te(t, "rgb", n) : null;
  9499. };
  9500. }
  9501. function zo(n) {
  9502. const e = n.match(/^\{\s*r\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*g\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*b\s*:\s*([0-9A-Fa-f.]+%?)\s*,\s*a\s*:\s*([0-9A-Fa-f.]+%?)\s*\}$/);
  9503. if (!e)
  9504. return null;
  9505. const t = [
  9506. parseFloat(e[1]),
  9507. parseFloat(e[2]),
  9508. parseFloat(e[3]),
  9509. parseFloat(e[4])
  9510. ];
  9511. return isNaN(t[0]) || isNaN(t[1]) || isNaN(t[2]) || isNaN(t[3]) ? null : t;
  9512. }
  9513. function Uo(n) {
  9514. return (e) => {
  9515. const t = zo(e);
  9516. return t ? new te(t, "rgb", n) : null;
  9517. };
  9518. }
  9519. const dl = [
  9520. {
  9521. parser: No,
  9522. result: {
  9523. alpha: false,
  9524. mode: "rgb",
  9525. notation: "hex"
  9526. }
  9527. },
  9528. {
  9529. parser: Bo,
  9530. result: {
  9531. alpha: true,
  9532. mode: "rgb",
  9533. notation: "hex"
  9534. }
  9535. },
  9536. {
  9537. parser: Mo,
  9538. result: {
  9539. alpha: false,
  9540. mode: "rgb",
  9541. notation: "func"
  9542. }
  9543. },
  9544. {
  9545. parser: Lo,
  9546. result: {
  9547. alpha: true,
  9548. mode: "rgb",
  9549. notation: "func"
  9550. }
  9551. },
  9552. {
  9553. parser: Vo,
  9554. result: {
  9555. alpha: false,
  9556. mode: "hsl",
  9557. notation: "func"
  9558. }
  9559. },
  9560. {
  9561. parser: Do,
  9562. result: {
  9563. alpha: true,
  9564. mode: "hsl",
  9565. notation: "func"
  9566. }
  9567. },
  9568. {
  9569. parser: Fo,
  9570. result: {
  9571. alpha: false,
  9572. mode: "rgb",
  9573. notation: "object"
  9574. }
  9575. },
  9576. {
  9577. parser: zo,
  9578. result: {
  9579. alpha: true,
  9580. mode: "rgb",
  9581. notation: "object"
  9582. }
  9583. }
  9584. ];
  9585. function ml(n) {
  9586. return dl.reduce((e, { parser: t, result: l }) => e || (t(n) ? l : null), null);
  9587. }
  9588. function Or(n, e = "int") {
  9589. const t = ml(n);
  9590. return t ? t.notation === "hex" && e !== "float" ? Object.assign(Object.assign({}, t), { type: "int" }) : t.notation === "func" ? Object.assign(Object.assign({}, t), { type: e }) : null : null;
  9591. }
  9592. const Go = {
  9593. int: [
  9594. pl,
  9595. hl,
  9596. So("int"),
  9597. Ro("int"),
  9598. Io("int"),
  9599. Oo("int"),
  9600. jo("int"),
  9601. Uo("int")
  9602. ],
  9603. float: [
  9604. So("float"),
  9605. Ro("float"),
  9606. Io("float"),
  9607. Oo("float"),
  9608. jo("float"),
  9609. Uo("float")
  9610. ]
  9611. };
  9612. function fl(n) {
  9613. const e = Go[n];
  9614. return (t) => {
  9615. if (typeof t != "string")
  9616. return te.black(n);
  9617. const l = e.reduce((b, E) => b || E(t), null);
  9618. return l ?? te.black(n);
  9619. };
  9620. }
  9621. function Nr(n) {
  9622. const e = Go[n];
  9623. return (t) => e.reduce((l, b) => l || b(t), null);
  9624. }
  9625. function Ho(n) {
  9626. const e = Re2(Math.floor(n), 0, 255).toString(16);
  9627. return e.length === 1 ? `0${e}` : e;
  9628. }
  9629. function Ko(n, e = "#") {
  9630. const t = u(n.getComponents("rgb")).map(Ho).join("");
  9631. return `${e}${t}`;
  9632. }
  9633. function Br(n, e = "#") {
  9634. const t = n.getComponents("rgb"), l = [t[0], t[1], t[2], t[3] * 255].map(Ho).join("");
  9635. return `${e}${l}`;
  9636. }
  9637. function $o(n, e) {
  9638. const t = De(e === "float" ? 2 : 0);
  9639. return `rgb(${u(n.getComponents("rgb", e)).map((b) => t(b)).join(", ")})`;
  9640. }
  9641. function vl(n) {
  9642. return (e) => $o(e, n);
  9643. }
  9644. function Ds(n, e) {
  9645. const t = De(2), l = De(e === "float" ? 2 : 0);
  9646. return `rgba(${n.getComponents("rgb", e).map((E, k) => (k === 3 ? t : l)(E)).join(", ")})`;
  9647. }
  9648. function bl(n) {
  9649. return (e) => Ds(e, n);
  9650. }
  9651. function gl(n) {
  9652. const e = [
  9653. De(0),
  9654. Cn,
  9655. Cn
  9656. ];
  9657. return `hsl(${u(n.getComponents("hsl")).map((l, b) => e[b](l)).join(", ")})`;
  9658. }
  9659. function _l(n) {
  9660. const e = [
  9661. De(0),
  9662. Cn,
  9663. Cn,
  9664. De(2)
  9665. ];
  9666. return `hsla(${n.getComponents("hsl").map((l, b) => e[b](l)).join(", ")})`;
  9667. }
  9668. function Xo(n, e) {
  9669. const t = De(e === "float" ? 2 : 0), l = ["r", "g", "b"];
  9670. return `{${u(n.getComponents("rgb", e)).map((E, k) => `${l[k]}: ${t(E)}`).join(", ")}}`;
  9671. }
  9672. function wl(n) {
  9673. return (e) => Xo(e, n);
  9674. }
  9675. function Yo(n, e) {
  9676. const t = De(2), l = De(e === "float" ? 2 : 0), b = ["r", "g", "b", "a"];
  9677. return `{${n.getComponents("rgb", e).map((k, j) => {
  9678. const Q2 = j === 3 ? t : l;
  9679. return `${b[j]}: ${Q2(k)}`;
  9680. }).join(", ")}}`;
  9681. }
  9682. function yl(n) {
  9683. return (e) => Yo(e, n);
  9684. }
  9685. const xl = [
  9686. {
  9687. format: {
  9688. alpha: false,
  9689. mode: "rgb",
  9690. notation: "hex",
  9691. type: "int"
  9692. },
  9693. stringifier: Ko
  9694. },
  9695. {
  9696. format: {
  9697. alpha: true,
  9698. mode: "rgb",
  9699. notation: "hex",
  9700. type: "int"
  9701. },
  9702. stringifier: Br
  9703. },
  9704. {
  9705. format: {
  9706. alpha: false,
  9707. mode: "hsl",
  9708. notation: "func",
  9709. type: "int"
  9710. },
  9711. stringifier: gl
  9712. },
  9713. {
  9714. format: {
  9715. alpha: true,
  9716. mode: "hsl",
  9717. notation: "func",
  9718. type: "int"
  9719. },
  9720. stringifier: _l
  9721. },
  9722. ...["int", "float"].reduce((n, e) => [
  9723. ...n,
  9724. {
  9725. format: {
  9726. alpha: false,
  9727. mode: "rgb",
  9728. notation: "func",
  9729. type: e
  9730. },
  9731. stringifier: vl(e)
  9732. },
  9733. {
  9734. format: {
  9735. alpha: true,
  9736. mode: "rgb",
  9737. notation: "func",
  9738. type: e
  9739. },
  9740. stringifier: bl(e)
  9741. },
  9742. {
  9743. format: {
  9744. alpha: false,
  9745. mode: "rgb",
  9746. notation: "object",
  9747. type: e
  9748. },
  9749. stringifier: wl(e)
  9750. },
  9751. {
  9752. format: {
  9753. alpha: true,
  9754. mode: "rgb",
  9755. notation: "object",
  9756. type: e
  9757. },
  9758. stringifier: yl(e)
  9759. }
  9760. ], [])
  9761. ];
  9762. function Fr(n) {
  9763. return xl.reduce((e, t) => e || (cl(t.format, n) ? t.stringifier : null), null);
  9764. }
  9765. const Hi = D2("apl");
  9766. class El {
  9767. constructor(e, t) {
  9768. this.onValueChange_ = this.onValueChange_.bind(this), this.value = t.value, this.value.emitter.on("change", this.onValueChange_), this.element = e.createElement("div"), this.element.classList.add(Hi()), t.viewProps.bindClassModifiers(this.element), t.viewProps.bindTabIndex(this.element);
  9769. const l = e.createElement("div");
  9770. l.classList.add(Hi("b")), this.element.appendChild(l);
  9771. const b = e.createElement("div");
  9772. b.classList.add(Hi("c")), l.appendChild(b), this.colorElem_ = b;
  9773. const E = e.createElement("div");
  9774. E.classList.add(Hi("m")), this.element.appendChild(E), this.markerElem_ = E;
  9775. const k = e.createElement("div");
  9776. k.classList.add(Hi("p")), this.markerElem_.appendChild(k), this.previewElem_ = k, this.update_();
  9777. }
  9778. update_() {
  9779. const e = this.value.rawValue, t = e.getComponents("rgb"), l = new te([t[0], t[1], t[2], 0], "rgb"), b = new te([t[0], t[1], t[2], 255], "rgb"), E = [
  9780. "to right",
  9781. Ds(l),
  9782. Ds(b)
  9783. ];
  9784. this.colorElem_.style.background = `linear-gradient(${E.join(",")})`, this.previewElem_.style.backgroundColor = Ds(e);
  9785. const k = we(t[3], 0, 1, 0, 100);
  9786. this.markerElem_.style.left = `${k}%`;
  9787. }
  9788. onValueChange_() {
  9789. this.update_();
  9790. }
  9791. }
  9792. class Cl {
  9793. constructor(e, t) {
  9794. this.onKeyDown_ = this.onKeyDown_.bind(this), this.onKeyUp_ = this.onKeyUp_.bind(this), this.onPointerDown_ = this.onPointerDown_.bind(this), this.onPointerMove_ = this.onPointerMove_.bind(this), this.onPointerUp_ = this.onPointerUp_.bind(this), this.value = t.value, this.viewProps = t.viewProps, this.view = new El(e, {
  9795. value: this.value,
  9796. viewProps: this.viewProps
  9797. }), this.ptHandler_ = new It(this.view.element), this.ptHandler_.emitter.on("down", this.onPointerDown_), this.ptHandler_.emitter.on("move", this.onPointerMove_), this.ptHandler_.emitter.on("up", this.onPointerUp_), this.view.element.addEventListener("keydown", this.onKeyDown_), this.view.element.addEventListener("keyup", this.onKeyUp_);
  9798. }
  9799. handlePointerEvent_(e, t) {
  9800. if (!e.point)
  9801. return;
  9802. const l = e.point.x / e.bounds.width, b = this.value.rawValue, [E, k, j] = b.getComponents("hsv");
  9803. this.value.setRawValue(new te([E, k, j, l], "hsv"), t);
  9804. }
  9805. onPointerDown_(e) {
  9806. this.handlePointerEvent_(e.data, {
  9807. forceEmit: false,
  9808. last: false
  9809. });
  9810. }
  9811. onPointerMove_(e) {
  9812. this.handlePointerEvent_(e.data, {
  9813. forceEmit: false,
  9814. last: false
  9815. });
  9816. }
  9817. onPointerUp_(e) {
  9818. this.handlePointerEvent_(e.data, {
  9819. forceEmit: true,
  9820. last: true
  9821. });
  9822. }
  9823. onKeyDown_(e) {
  9824. const t = je(Ln(true), ut2(e));
  9825. if (t === 0)
  9826. return;
  9827. const l = this.value.rawValue, [b, E, k, j] = l.getComponents("hsv");
  9828. this.value.setRawValue(new te([b, E, k, j + t], "hsv"), {
  9829. forceEmit: false,
  9830. last: false
  9831. });
  9832. }
  9833. onKeyUp_(e) {
  9834. je(Ln(true), ut2(e)) !== 0 && this.value.setRawValue(this.value.rawValue, {
  9835. forceEmit: true,
  9836. last: true
  9837. });
  9838. }
  9839. }
  9840. const oi = D2("coltxt");
  9841. function Pl(n) {
  9842. const e = n.createElement("select"), t = [
  9843. { text: "RGB", value: "rgb" },
  9844. { text: "HSL", value: "hsl" },
  9845. { text: "HSV", value: "hsv" }
  9846. ];
  9847. return e.appendChild(t.reduce((l, b) => {
  9848. const E = n.createElement("option");
  9849. return E.textContent = b.text, E.value = b.value, l.appendChild(E), l;
  9850. }, n.createDocumentFragment())), e;
  9851. }
  9852. class Tl {
  9853. constructor(e, t) {
  9854. this.element = e.createElement("div"), this.element.classList.add(oi()), t.viewProps.bindClassModifiers(this.element);
  9855. const l = e.createElement("div");
  9856. l.classList.add(oi("m")), this.modeElem_ = Pl(e), this.modeElem_.classList.add(oi("ms")), l.appendChild(this.modeSelectElement), t.viewProps.bindDisabled(this.modeElem_);
  9857. const b = e.createElement("div");
  9858. b.classList.add(oi("mm")), b.appendChild(Et2(e, "dropdown")), l.appendChild(b), this.element.appendChild(l);
  9859. const E = e.createElement("div");
  9860. E.classList.add(oi("w")), this.element.appendChild(E), this.textsElem_ = E, this.textViews_ = t.textViews, this.applyTextViews_(), F(t.colorMode, (k) => {
  9861. this.modeElem_.value = k;
  9862. });
  9863. }
  9864. get modeSelectElement() {
  9865. return this.modeElem_;
  9866. }
  9867. get textViews() {
  9868. return this.textViews_;
  9869. }
  9870. set textViews(e) {
  9871. this.textViews_ = e, this.applyTextViews_();
  9872. }
  9873. applyTextViews_() {
  9874. mn(this.textsElem_);
  9875. const e = this.element.ownerDocument;
  9876. this.textViews_.forEach((t) => {
  9877. const l = e.createElement("div");
  9878. l.classList.add(oi("c")), l.appendChild(t.element), this.textsElem_.appendChild(l);
  9879. });
  9880. }
  9881. }
  9882. function kl(n) {
  9883. return De(n === "float" ? 2 : 0);
  9884. }
  9885. function Al(n, e, t) {
  9886. const l = T(n, e)[t];
  9887. return new Yt({
  9888. min: 0,
  9889. max: l
  9890. });
  9891. }
  9892. function jr(n, e, t) {
  9893. return new Tn(n, {
  9894. arrayPosition: t === 0 ? "fst" : t === 3 - 1 ? "lst" : "mid",
  9895. baseStep: Ln(false),
  9896. parser: e.parser,
  9897. props: X2.fromObject({
  9898. draggingScale: e.colorType === "float" ? 0.01 : 1,
  9899. formatter: kl(e.colorType)
  9900. }),
  9901. value: ee(0, {
  9902. constraint: Al(e.colorMode, e.colorType, t)
  9903. }),
  9904. viewProps: e.viewProps
  9905. });
  9906. }
  9907. class Ml {
  9908. constructor(e, t) {
  9909. this.onModeSelectChange_ = this.onModeSelectChange_.bind(this), this.colorType_ = t.colorType, this.parser_ = t.parser, this.value = t.value, this.viewProps = t.viewProps, this.colorMode = ee(this.value.rawValue.mode), this.ccs_ = this.createComponentControllers_(e), this.view = new Tl(e, {
  9910. colorMode: this.colorMode,
  9911. textViews: [this.ccs_[0].view, this.ccs_[1].view, this.ccs_[2].view],
  9912. viewProps: this.viewProps
  9913. }), this.view.modeSelectElement.addEventListener("change", this.onModeSelectChange_);
  9914. }
  9915. createComponentControllers_(e) {
  9916. const t = {
  9917. colorMode: this.colorMode.rawValue,
  9918. colorType: this.colorType_,
  9919. parser: this.parser_,
  9920. viewProps: this.viewProps
  9921. }, l = [
  9922. jr(e, t, 0),
  9923. jr(e, t, 1),
  9924. jr(e, t, 2)
  9925. ];
  9926. return l.forEach((b, E) => {
  9927. Qt({
  9928. primary: this.value,
  9929. secondary: b.value,
  9930. forward: (k) => k.rawValue.getComponents(this.colorMode.rawValue, this.colorType_)[E],
  9931. backward: (k, j) => {
  9932. const Q2 = this.colorMode.rawValue, J = k.rawValue.getComponents(Q2, this.colorType_);
  9933. return J[E] = j.rawValue, new te(v(u(J), J[3]), Q2, this.colorType_);
  9934. }
  9935. });
  9936. }), l;
  9937. }
  9938. onModeSelectChange_(e) {
  9939. const t = e.currentTarget;
  9940. this.colorMode.rawValue = t.value, this.ccs_ = this.createComponentControllers_(this.view.element.ownerDocument), this.view.textViews = [
  9941. this.ccs_[0].view,
  9942. this.ccs_[1].view,
  9943. this.ccs_[2].view
  9944. ];
  9945. }
  9946. }
  9947. const zr = D2("hpl");
  9948. class Sl {
  9949. constructor(e, t) {
  9950. this.onValueChange_ = this.onValueChange_.bind(this), this.value = t.value, this.value.emitter.on("change", this.onValueChange_), this.element = e.createElement("div"), this.element.classList.add(zr()), t.viewProps.bindClassModifiers(this.element), t.viewProps.bindTabIndex(this.element);
  9951. const l = e.createElement("div");
  9952. l.classList.add(zr("c")), this.element.appendChild(l);
  9953. const b = e.createElement("div");
  9954. b.classList.add(zr("m")), this.element.appendChild(b), this.markerElem_ = b, this.update_();
  9955. }
  9956. update_() {
  9957. const e = this.value.rawValue, [t] = e.getComponents("hsv");
  9958. this.markerElem_.style.backgroundColor = $o(new te([t, 100, 100], "hsv"));
  9959. const l = we(t, 0, 360, 0, 100);
  9960. this.markerElem_.style.left = `${l}%`;
  9961. }
  9962. onValueChange_() {
  9963. this.update_();
  9964. }
  9965. }
  9966. class Ll {
  9967. constructor(e, t) {
  9968. this.onKeyDown_ = this.onKeyDown_.bind(this), this.onKeyUp_ = this.onKeyUp_.bind(this), this.onPointerDown_ = this.onPointerDown_.bind(this), this.onPointerMove_ = this.onPointerMove_.bind(this), this.onPointerUp_ = this.onPointerUp_.bind(this), this.value = t.value, this.viewProps = t.viewProps, this.view = new Sl(e, {
  9969. value: this.value,
  9970. viewProps: this.viewProps
  9971. }), this.ptHandler_ = new It(this.view.element), this.ptHandler_.emitter.on("down", this.onPointerDown_), this.ptHandler_.emitter.on("move", this.onPointerMove_), this.ptHandler_.emitter.on("up", this.onPointerUp_), this.view.element.addEventListener("keydown", this.onKeyDown_), this.view.element.addEventListener("keyup", this.onKeyUp_);
  9972. }
  9973. handlePointerEvent_(e, t) {
  9974. if (!e.point)
  9975. return;
  9976. const l = we(Re2(e.point.x, 0, e.bounds.width), 0, e.bounds.width, 0, 360), b = this.value.rawValue, [, E, k, j] = b.getComponents("hsv");
  9977. this.value.setRawValue(new te([l, E, k, j], "hsv"), t);
  9978. }
  9979. onPointerDown_(e) {
  9980. this.handlePointerEvent_(e.data, {
  9981. forceEmit: false,
  9982. last: false
  9983. });
  9984. }
  9985. onPointerMove_(e) {
  9986. this.handlePointerEvent_(e.data, {
  9987. forceEmit: false,
  9988. last: false
  9989. });
  9990. }
  9991. onPointerUp_(e) {
  9992. this.handlePointerEvent_(e.data, {
  9993. forceEmit: true,
  9994. last: true
  9995. });
  9996. }
  9997. onKeyDown_(e) {
  9998. const t = je(Ln(false), ut2(e));
  9999. if (t === 0)
  10000. return;
  10001. const l = this.value.rawValue, [b, E, k, j] = l.getComponents("hsv");
  10002. this.value.setRawValue(new te([b + t, E, k, j], "hsv"), {
  10003. forceEmit: false,
  10004. last: false
  10005. });
  10006. }
  10007. onKeyUp_(e) {
  10008. je(Ln(false), ut2(e)) !== 0 && this.value.setRawValue(this.value.rawValue, {
  10009. forceEmit: true,
  10010. last: true
  10011. });
  10012. }
  10013. }
  10014. const Ur = D2("svp"), qo = 64;
  10015. class Rl {
  10016. constructor(e, t) {
  10017. this.onValueChange_ = this.onValueChange_.bind(this), this.value = t.value, this.value.emitter.on("change", this.onValueChange_), this.element = e.createElement("div"), this.element.classList.add(Ur()), t.viewProps.bindClassModifiers(this.element), t.viewProps.bindTabIndex(this.element);
  10018. const l = e.createElement("canvas");
  10019. l.height = qo, l.width = qo, l.classList.add(Ur("c")), this.element.appendChild(l), this.canvasElement = l;
  10020. const b = e.createElement("div");
  10021. b.classList.add(Ur("m")), this.element.appendChild(b), this.markerElem_ = b, this.update_();
  10022. }
  10023. update_() {
  10024. const e = Kn(this.canvasElement);
  10025. if (!e)
  10026. return;
  10027. const l = this.value.rawValue.getComponents("hsv"), b = this.canvasElement.width, E = this.canvasElement.height, k = e.getImageData(0, 0, b, E), j = k.data;
  10028. for (let de = 0; de < E; de++)
  10029. for (let ve = 0; ve < b; ve++) {
  10030. const Vn = we(ve, 0, b, 0, 100), $i = we(de, 0, E, 100, 0), Xi = Is(l[0], Vn, $i), Os = (de * b + ve) * 4;
  10031. j[Os] = Xi[0], j[Os + 1] = Xi[1], j[Os + 2] = Xi[2], j[Os + 3] = 255;
  10032. }
  10033. e.putImageData(k, 0, 0);
  10034. const Q2 = we(l[1], 0, 100, 0, 100);
  10035. this.markerElem_.style.left = `${Q2}%`;
  10036. const J = we(l[2], 0, 100, 100, 0);
  10037. this.markerElem_.style.top = `${J}%`;
  10038. }
  10039. onValueChange_() {
  10040. this.update_();
  10041. }
  10042. }
  10043. class Vl {
  10044. constructor(e, t) {
  10045. this.onKeyDown_ = this.onKeyDown_.bind(this), this.onKeyUp_ = this.onKeyUp_.bind(this), this.onPointerDown_ = this.onPointerDown_.bind(this), this.onPointerMove_ = this.onPointerMove_.bind(this), this.onPointerUp_ = this.onPointerUp_.bind(this), this.value = t.value, this.viewProps = t.viewProps, this.view = new Rl(e, {
  10046. value: this.value,
  10047. viewProps: this.viewProps
  10048. }), this.ptHandler_ = new It(this.view.element), this.ptHandler_.emitter.on("down", this.onPointerDown_), this.ptHandler_.emitter.on("move", this.onPointerMove_), this.ptHandler_.emitter.on("up", this.onPointerUp_), this.view.element.addEventListener("keydown", this.onKeyDown_), this.view.element.addEventListener("keyup", this.onKeyUp_);
  10049. }
  10050. handlePointerEvent_(e, t) {
  10051. if (!e.point)
  10052. return;
  10053. const l = we(e.point.x, 0, e.bounds.width, 0, 100), b = we(e.point.y, 0, e.bounds.height, 100, 0), [E, , , k] = this.value.rawValue.getComponents("hsv");
  10054. this.value.setRawValue(new te([E, l, b, k], "hsv"), t);
  10055. }
  10056. onPointerDown_(e) {
  10057. this.handlePointerEvent_(e.data, {
  10058. forceEmit: false,
  10059. last: false
  10060. });
  10061. }
  10062. onPointerMove_(e) {
  10063. this.handlePointerEvent_(e.data, {
  10064. forceEmit: false,
  10065. last: false
  10066. });
  10067. }
  10068. onPointerUp_(e) {
  10069. this.handlePointerEvent_(e.data, {
  10070. forceEmit: true,
  10071. last: true
  10072. });
  10073. }
  10074. onKeyDown_(e) {
  10075. ni(e.key) && e.preventDefault();
  10076. const [t, l, b, E] = this.value.rawValue.getComponents("hsv"), k = Ln(false), j = je(k, ut2(e)), Q2 = je(k, Pn(e));
  10077. j === 0 && Q2 === 0 || this.value.setRawValue(new te([t, l + j, b + Q2, E], "hsv"), {
  10078. forceEmit: false,
  10079. last: false
  10080. });
  10081. }
  10082. onKeyUp_(e) {
  10083. const t = Ln(false), l = je(t, ut2(e)), b = je(t, Pn(e));
  10084. l === 0 && b === 0 || this.value.setRawValue(this.value.rawValue, {
  10085. forceEmit: true,
  10086. last: true
  10087. });
  10088. }
  10089. }
  10090. class Il {
  10091. constructor(e, t) {
  10092. this.value = t.value, this.viewProps = t.viewProps, this.hPaletteC_ = new Ll(e, {
  10093. value: this.value,
  10094. viewProps: this.viewProps
  10095. }), this.svPaletteC_ = new Vl(e, {
  10096. value: this.value,
  10097. viewProps: this.viewProps
  10098. }), this.alphaIcs_ = t.supportsAlpha ? {
  10099. palette: new Cl(e, {
  10100. value: this.value,
  10101. viewProps: this.viewProps
  10102. }),
  10103. text: new Tn(e, {
  10104. parser: ct2,
  10105. baseStep: 0.1,
  10106. props: X2.fromObject({
  10107. draggingScale: 0.01,
  10108. formatter: De(2)
  10109. }),
  10110. value: ee(0, {
  10111. constraint: new Yt({ min: 0, max: 1 })
  10112. }),
  10113. viewProps: this.viewProps
  10114. })
  10115. } : null, this.alphaIcs_ && Qt({
  10116. primary: this.value,
  10117. secondary: this.alphaIcs_.text.value,
  10118. forward: (l) => l.rawValue.getComponents()[3],
  10119. backward: (l, b) => {
  10120. const E = l.rawValue.getComponents();
  10121. return E[3] = b.rawValue, new te(E, l.rawValue.mode);
  10122. }
  10123. }), this.textC_ = new Ml(e, {
  10124. colorType: t.colorType,
  10125. parser: ct2,
  10126. value: this.value,
  10127. viewProps: this.viewProps
  10128. }), this.view = new Ir(e, {
  10129. alphaViews: this.alphaIcs_ ? {
  10130. palette: this.alphaIcs_.palette.view,
  10131. text: this.alphaIcs_.text.view
  10132. } : null,
  10133. hPaletteView: this.hPaletteC_.view,
  10134. supportsAlpha: t.supportsAlpha,
  10135. svPaletteView: this.svPaletteC_.view,
  10136. textView: this.textC_.view,
  10137. viewProps: this.viewProps
  10138. });
  10139. }
  10140. get textController() {
  10141. return this.textC_;
  10142. }
  10143. }
  10144. const Gr = D2("colsw");
  10145. class Dl {
  10146. constructor(e, t) {
  10147. this.onValueChange_ = this.onValueChange_.bind(this), t.value.emitter.on("change", this.onValueChange_), this.value = t.value, this.element = e.createElement("div"), this.element.classList.add(Gr()), t.viewProps.bindClassModifiers(this.element);
  10148. const l = e.createElement("div");
  10149. l.classList.add(Gr("sw")), this.element.appendChild(l), this.swatchElem_ = l;
  10150. const b = e.createElement("button");
  10151. b.classList.add(Gr("b")), t.viewProps.bindDisabled(b), this.element.appendChild(b), this.buttonElement = b, this.update_();
  10152. }
  10153. update_() {
  10154. const e = this.value.rawValue;
  10155. this.swatchElem_.style.backgroundColor = Br(e);
  10156. }
  10157. onValueChange_() {
  10158. this.update_();
  10159. }
  10160. }
  10161. class Ol {
  10162. constructor(e, t) {
  10163. this.value = t.value, this.viewProps = t.viewProps, this.view = new Dl(e, {
  10164. value: this.value,
  10165. viewProps: this.viewProps
  10166. });
  10167. }
  10168. }
  10169. class Hr {
  10170. constructor(e, t) {
  10171. this.onButtonBlur_ = this.onButtonBlur_.bind(this), this.onButtonClick_ = this.onButtonClick_.bind(this), this.onPopupChildBlur_ = this.onPopupChildBlur_.bind(this), this.onPopupChildKeydown_ = this.onPopupChildKeydown_.bind(this), this.value = t.value, this.viewProps = t.viewProps, this.foldable_ = Fe.create(t.expanded), this.swatchC_ = new Ol(e, {
  10172. value: this.value,
  10173. viewProps: this.viewProps
  10174. });
  10175. const l = this.swatchC_.view.buttonElement;
  10176. l.addEventListener("blur", this.onButtonBlur_), l.addEventListener("click", this.onButtonClick_), this.textC_ = new ei(e, {
  10177. parser: t.parser,
  10178. props: X2.fromObject({
  10179. formatter: t.formatter
  10180. }),
  10181. value: this.value,
  10182. viewProps: this.viewProps
  10183. }), this.view = new Gi(e, {
  10184. foldable: this.foldable_,
  10185. pickerLayout: t.pickerLayout
  10186. }), this.view.swatchElement.appendChild(this.swatchC_.view.element), this.view.textElement.appendChild(this.textC_.view.element), this.popC_ = t.pickerLayout === "popup" ? new gs(e, {
  10187. viewProps: this.viewProps
  10188. }) : null;
  10189. const b = new Il(e, {
  10190. colorType: t.colorType,
  10191. supportsAlpha: t.supportsAlpha,
  10192. value: this.value,
  10193. viewProps: this.viewProps
  10194. });
  10195. b.view.allFocusableElements.forEach((E) => {
  10196. E.addEventListener("blur", this.onPopupChildBlur_), E.addEventListener("keydown", this.onPopupChildKeydown_);
  10197. }), this.pickerC_ = b, this.popC_ ? (this.view.element.appendChild(this.popC_.view.element), this.popC_.view.element.appendChild(b.view.element), Qt({
  10198. primary: this.foldable_.value("expanded"),
  10199. secondary: this.popC_.shows,
  10200. forward: (E) => E.rawValue,
  10201. backward: (E, k) => k.rawValue
  10202. })) : this.view.pickerElement && (this.view.pickerElement.appendChild(this.pickerC_.view.element), $e(this.foldable_, this.view.pickerElement));
  10203. }
  10204. get textController() {
  10205. return this.textC_;
  10206. }
  10207. onButtonBlur_(e) {
  10208. if (!this.popC_)
  10209. return;
  10210. const t = this.view.element, l = e.relatedTarget;
  10211. (!l || !t.contains(l)) && (this.popC_.shows.rawValue = false);
  10212. }
  10213. onButtonClick_() {
  10214. this.foldable_.set("expanded", !this.foldable_.get("expanded")), this.foldable_.get("expanded") && this.pickerC_.view.allFocusableElements[0].focus();
  10215. }
  10216. onPopupChildBlur_(e) {
  10217. if (!this.popC_)
  10218. return;
  10219. const t = this.popC_.view.element, l = Ct(e);
  10220. l && t.contains(l) || l && l === this.swatchC_.view.buttonElement && !bt2(t.ownerDocument) || (this.popC_.shows.rawValue = false);
  10221. }
  10222. onPopupChildKeydown_(e) {
  10223. this.popC_ ? e.key === "Escape" && (this.popC_.shows.rawValue = false) : this.view.pickerElement && e.key === "Escape" && this.swatchC_.view.buttonElement.focus();
  10224. }
  10225. }
  10226. function Nl(n, e) {
  10227. return te.isColorObject(n) ? te.fromObject(n, e) : te.black(e);
  10228. }
  10229. function Bl(n) {
  10230. return u(n.getComponents("rgb")).reduce((e, t) => e << 8 | Math.floor(t) & 255, 0);
  10231. }
  10232. function Fl(n) {
  10233. return n.getComponents("rgb").reduce((e, t, l) => {
  10234. const b = Math.floor(l === 3 ? t * 255 : t) & 255;
  10235. return e << 8 | b;
  10236. }, 0) >>> 0;
  10237. }
  10238. function jl(n) {
  10239. return new te([n >> 16 & 255, n >> 8 & 255, n & 255], "rgb");
  10240. }
  10241. function zl(n) {
  10242. return new te([
  10243. n >> 24 & 255,
  10244. n >> 16 & 255,
  10245. n >> 8 & 255,
  10246. we(n & 255, 0, 255, 0, 1)
  10247. ], "rgb");
  10248. }
  10249. function Ul(n) {
  10250. return typeof n != "number" ? te.black() : jl(n);
  10251. }
  10252. function Gl(n) {
  10253. return typeof n != "number" ? te.black() : zl(n);
  10254. }
  10255. function Hl(n) {
  10256. const e = Fr(n);
  10257. return e ? (t, l) => {
  10258. st2(t, e(l));
  10259. } : null;
  10260. }
  10261. function Kl(n) {
  10262. const e = n ? Fl : Bl;
  10263. return (t, l) => {
  10264. st2(t, e(l));
  10265. };
  10266. }
  10267. function $l(n, e, t) {
  10268. const l = e.toRgbaObject(t);
  10269. n.writeProperty("r", l.r), n.writeProperty("g", l.g), n.writeProperty("b", l.b), n.writeProperty("a", l.a);
  10270. }
  10271. function Xl(n, e, t) {
  10272. const l = e.toRgbaObject(t);
  10273. n.writeProperty("r", l.r), n.writeProperty("g", l.g), n.writeProperty("b", l.b);
  10274. }
  10275. function Yl(n, e) {
  10276. return (t, l) => {
  10277. n ? $l(t, l, e) : Xl(t, l, e);
  10278. };
  10279. }
  10280. function Kr(n) {
  10281. var e;
  10282. return !!(n != null && n.alpha || !((e = n == null ? void 0 : n.color) === null || e === void 0) && e.alpha);
  10283. }
  10284. function ql(n) {
  10285. return n ? (e) => Br(e, "0x") : (e) => Ko(e, "0x");
  10286. }
  10287. function Ql(n) {
  10288. return "color" in n || "view" in n && n.view === "color";
  10289. }
  10290. const Zl = {
  10291. id: "input-color-number",
  10292. type: "input",
  10293. accept: (n, e) => {
  10294. if (typeof n != "number" || !Ql(e))
  10295. return null;
  10296. const t = Dr(e);
  10297. return t ? {
  10298. initialValue: n,
  10299. params: t
  10300. } : null;
  10301. },
  10302. binding: {
  10303. reader: (n) => Kr(n.params) ? Gl : Ul,
  10304. equals: te.equals,
  10305. writer: (n) => Kl(Kr(n.params))
  10306. },
  10307. controller: (n) => {
  10308. const e = Kr(n.params), t = "expanded" in n.params ? n.params.expanded : void 0, l = "picker" in n.params ? n.params.picker : void 0;
  10309. return new Hr(n.document, {
  10310. colorType: "int",
  10311. expanded: t ?? false,
  10312. formatter: ql(e),
  10313. parser: Nr("int"),
  10314. pickerLayout: l ?? "popup",
  10315. supportsAlpha: e,
  10316. value: n.value,
  10317. viewProps: n.viewProps
  10318. });
  10319. }
  10320. };
  10321. function Wl(n) {
  10322. return te.isRgbaColorObject(n);
  10323. }
  10324. function Jl(n) {
  10325. return (e) => Nl(e, n);
  10326. }
  10327. function ec(n, e) {
  10328. return (t) => n ? Yo(t, e) : Xo(t, e);
  10329. }
  10330. const tc = {
  10331. id: "input-color-object",
  10332. type: "input",
  10333. accept: (n, e) => {
  10334. if (!te.isColorObject(n))
  10335. return null;
  10336. const t = Dr(e);
  10337. return t ? {
  10338. initialValue: n,
  10339. params: t
  10340. } : null;
  10341. },
  10342. binding: {
  10343. reader: (n) => Jl(Rn(n.params)),
  10344. equals: te.equals,
  10345. writer: (n) => Yl(Wl(n.initialValue), Rn(n.params))
  10346. },
  10347. controller: (n) => {
  10348. var e;
  10349. const t = te.isRgbaColorObject(n.initialValue), l = "expanded" in n.params ? n.params.expanded : void 0, b = "picker" in n.params ? n.params.picker : void 0, E = (e = Rn(n.params)) !== null && e !== void 0 ? e : "int";
  10350. return new Hr(n.document, {
  10351. colorType: E,
  10352. expanded: l ?? false,
  10353. formatter: ec(t, E),
  10354. parser: Nr(E),
  10355. pickerLayout: b ?? "popup",
  10356. supportsAlpha: t,
  10357. value: n.value,
  10358. viewProps: n.viewProps
  10359. });
  10360. }
  10361. }, nc = {
  10362. id: "input-color-string",
  10363. type: "input",
  10364. accept: (n, e) => {
  10365. if (typeof n != "string" || "view" in e && e.view === "text")
  10366. return null;
  10367. const t = Or(n, Rn(e));
  10368. if (!t || !Fr(t))
  10369. return null;
  10370. const b = Dr(e);
  10371. return b ? {
  10372. initialValue: n,
  10373. params: b
  10374. } : null;
  10375. },
  10376. binding: {
  10377. reader: (n) => {
  10378. var e;
  10379. return fl((e = Rn(n.params)) !== null && e !== void 0 ? e : "int");
  10380. },
  10381. equals: te.equals,
  10382. writer: (n) => {
  10383. const e = Or(n.initialValue, Rn(n.params));
  10384. if (!e)
  10385. throw S.shouldNeverHappen();
  10386. const t = Hl(e);
  10387. if (!t)
  10388. throw S.notBindable();
  10389. return t;
  10390. }
  10391. },
  10392. controller: (n) => {
  10393. const e = Or(n.initialValue, Rn(n.params));
  10394. if (!e)
  10395. throw S.shouldNeverHappen();
  10396. const t = Fr(e);
  10397. if (!t)
  10398. throw S.shouldNeverHappen();
  10399. const l = "expanded" in n.params ? n.params.expanded : void 0, b = "picker" in n.params ? n.params.picker : void 0;
  10400. return new Hr(n.document, {
  10401. colorType: e.type,
  10402. expanded: l ?? false,
  10403. formatter: t,
  10404. parser: Nr(e.type),
  10405. pickerLayout: b ?? "popup",
  10406. supportsAlpha: e.alpha,
  10407. value: n.value,
  10408. viewProps: n.viewProps
  10409. });
  10410. }
  10411. };
  10412. class Wt {
  10413. constructor(e) {
  10414. this.components = e.components, this.asm_ = e.assembly;
  10415. }
  10416. constrain(e) {
  10417. const t = this.asm_.toComponents(e).map((l, b) => {
  10418. var E, k;
  10419. return (k = (E = this.components[b]) === null || E === void 0 ? void 0 : E.constrain(l)) !== null && k !== void 0 ? k : l;
  10420. });
  10421. return this.asm_.fromComponents(t);
  10422. }
  10423. }
  10424. const Qo = D2("pndtxt");
  10425. class ic {
  10426. constructor(e, t) {
  10427. this.textViews = t.textViews, this.element = e.createElement("div"), this.element.classList.add(Qo()), this.textViews.forEach((l) => {
  10428. const b = e.createElement("div");
  10429. b.classList.add(Qo("a")), b.appendChild(l.element), this.element.appendChild(b);
  10430. });
  10431. }
  10432. }
  10433. function sc(n, e, t) {
  10434. return new Tn(n, {
  10435. arrayPosition: t === 0 ? "fst" : t === e.axes.length - 1 ? "lst" : "mid",
  10436. baseStep: e.axes[t].baseStep,
  10437. parser: e.parser,
  10438. props: e.axes[t].textProps,
  10439. value: ee(0, {
  10440. constraint: e.axes[t].constraint
  10441. }),
  10442. viewProps: e.viewProps
  10443. });
  10444. }
  10445. class $r {
  10446. constructor(e, t) {
  10447. this.value = t.value, this.viewProps = t.viewProps, this.acs_ = t.axes.map((l, b) => sc(e, t, b)), this.acs_.forEach((l, b) => {
  10448. Qt({
  10449. primary: this.value,
  10450. secondary: l.value,
  10451. forward: (E) => t.assembly.toComponents(E.rawValue)[b],
  10452. backward: (E, k) => {
  10453. const j = t.assembly.toComponents(E.rawValue);
  10454. return j[b] = k.rawValue, t.assembly.fromComponents(j);
  10455. }
  10456. });
  10457. }), this.view = new ic(e, {
  10458. textViews: this.acs_.map((l) => l.view)
  10459. });
  10460. }
  10461. }
  10462. function Zo(n, e) {
  10463. return "step" in n && !_2(n.step) ? new Jn(n.step, e) : null;
  10464. }
  10465. function Wo(n) {
  10466. return !_2(n.max) && !_2(n.min) ? new Yt({
  10467. max: n.max,
  10468. min: n.min
  10469. }) : !_2(n.max) || !_2(n.min) ? new Ai({
  10470. max: n.max,
  10471. min: n.min
  10472. }) : null;
  10473. }
  10474. function rc(n) {
  10475. const e = it2(n, Yt);
  10476. if (e)
  10477. return [e.values.get("min"), e.values.get("max")];
  10478. const t = it2(n, Ai);
  10479. return t ? [t.minValue, t.maxValue] : [void 0, void 0];
  10480. }
  10481. function oc(n, e) {
  10482. const t = [], l = Zo(n, e);
  10483. l && t.push(l);
  10484. const b = Wo(n);
  10485. b && t.push(b);
  10486. const E = Ui(n.options);
  10487. return E && t.push(E), new wn(t);
  10488. }
  10489. const ac = {
  10490. id: "input-number",
  10491. type: "input",
  10492. accept: (n, e) => {
  10493. if (typeof n != "number")
  10494. return null;
  10495. const t = A2, l = ae(e, {
  10496. format: t.optional.function,
  10497. max: t.optional.number,
  10498. min: t.optional.number,
  10499. options: t.optional.custom(An),
  10500. step: t.optional.number
  10501. });
  10502. return l ? {
  10503. initialValue: n,
  10504. params: l
  10505. } : null;
  10506. },
  10507. binding: {
  10508. reader: (n) => _t,
  10509. constraint: (n) => oc(n.params, n.initialValue),
  10510. writer: (n) => st2
  10511. },
  10512. controller: (n) => {
  10513. var e;
  10514. const t = n.value, l = n.constraint, b = l && it2(l, yn);
  10515. if (b)
  10516. return new xn(n.document, {
  10517. props: new X2({
  10518. options: b.values.value("options")
  10519. }),
  10520. value: t,
  10521. viewProps: n.viewProps
  10522. });
  10523. const E = (e = "format" in n.params ? n.params.format : void 0) !== null && e !== void 0 ? e : De(si(l, t.rawValue)), k = l && it2(l, Yt);
  10524. return k ? new ii(n.document, {
  10525. baseStep: Dt(l),
  10526. parser: ct2,
  10527. sliderProps: new X2({
  10528. maxValue: k.values.value("max"),
  10529. minValue: k.values.value("min")
  10530. }),
  10531. textProps: X2.fromObject({
  10532. draggingScale: Ot(l, t.rawValue),
  10533. formatter: E
  10534. }),
  10535. value: t,
  10536. viewProps: n.viewProps
  10537. }) : new Tn(n.document, {
  10538. baseStep: Dt(l),
  10539. parser: ct2,
  10540. props: X2.fromObject({
  10541. draggingScale: Ot(l, t.rawValue),
  10542. formatter: E
  10543. }),
  10544. value: t,
  10545. viewProps: n.viewProps
  10546. });
  10547. }
  10548. };
  10549. class Jt {
  10550. constructor(e = 0, t = 0) {
  10551. this.x = e, this.y = t;
  10552. }
  10553. getComponents() {
  10554. return [this.x, this.y];
  10555. }
  10556. static isObject(e) {
  10557. if (_2(e))
  10558. return false;
  10559. const t = e.x, l = e.y;
  10560. return !(typeof t != "number" || typeof l != "number");
  10561. }
  10562. static equals(e, t) {
  10563. return e.x === t.x && e.y === t.y;
  10564. }
  10565. toObject() {
  10566. return {
  10567. x: this.x,
  10568. y: this.y
  10569. };
  10570. }
  10571. }
  10572. const Jo = {
  10573. toComponents: (n) => n.getComponents(),
  10574. fromComponents: (n) => new Jt(...n)
  10575. }, ai = D2("p2d");
  10576. class lc {
  10577. constructor(e, t) {
  10578. this.element = e.createElement("div"), this.element.classList.add(ai()), t.viewProps.bindClassModifiers(this.element), F(t.expanded, K2(this.element, ai(void 0, "expanded")));
  10579. const l = e.createElement("div");
  10580. l.classList.add(ai("h")), this.element.appendChild(l);
  10581. const b = e.createElement("button");
  10582. b.classList.add(ai("b")), b.appendChild(Et2(e, "p2dpad")), t.viewProps.bindDisabled(b), l.appendChild(b), this.buttonElement = b;
  10583. const E = e.createElement("div");
  10584. if (E.classList.add(ai("t")), l.appendChild(E), this.textElement = E, t.pickerLayout === "inline") {
  10585. const k = e.createElement("div");
  10586. k.classList.add(ai("p")), this.element.appendChild(k), this.pickerElement = k;
  10587. } else
  10588. this.pickerElement = null;
  10589. }
  10590. }
  10591. const en = D2("p2dp");
  10592. class cc {
  10593. constructor(e, t) {
  10594. this.onFoldableChange_ = this.onFoldableChange_.bind(this), this.onValueChange_ = this.onValueChange_.bind(this), this.invertsY_ = t.invertsY, this.maxValue_ = t.maxValue, this.element = e.createElement("div"), this.element.classList.add(en()), t.layout === "popup" && this.element.classList.add(en(void 0, "p")), t.viewProps.bindClassModifiers(this.element);
  10595. const l = e.createElement("div");
  10596. l.classList.add(en("p")), t.viewProps.bindTabIndex(l), this.element.appendChild(l), this.padElement = l;
  10597. const b = e.createElementNS(Ke, "svg");
  10598. b.classList.add(en("g")), this.padElement.appendChild(b), this.svgElem_ = b;
  10599. const E = e.createElementNS(Ke, "line");
  10600. E.classList.add(en("ax")), E.setAttributeNS(null, "x1", "0"), E.setAttributeNS(null, "y1", "50%"), E.setAttributeNS(null, "x2", "100%"), E.setAttributeNS(null, "y2", "50%"), this.svgElem_.appendChild(E);
  10601. const k = e.createElementNS(Ke, "line");
  10602. k.classList.add(en("ax")), k.setAttributeNS(null, "x1", "50%"), k.setAttributeNS(null, "y1", "0"), k.setAttributeNS(null, "x2", "50%"), k.setAttributeNS(null, "y2", "100%"), this.svgElem_.appendChild(k);
  10603. const j = e.createElementNS(Ke, "line");
  10604. j.classList.add(en("l")), j.setAttributeNS(null, "x1", "50%"), j.setAttributeNS(null, "y1", "50%"), this.svgElem_.appendChild(j), this.lineElem_ = j;
  10605. const Q2 = e.createElement("div");
  10606. Q2.classList.add(en("m")), this.padElement.appendChild(Q2), this.markerElem_ = Q2, t.value.emitter.on("change", this.onValueChange_), this.value = t.value, this.update_();
  10607. }
  10608. get allFocusableElements() {
  10609. return [this.padElement];
  10610. }
  10611. update_() {
  10612. const [e, t] = this.value.rawValue.getComponents(), l = this.maxValue_, b = we(e, -l, +l, 0, 100), E = we(t, -l, +l, 0, 100), k = this.invertsY_ ? 100 - E : E;
  10613. this.lineElem_.setAttributeNS(null, "x2", `${b}%`), this.lineElem_.setAttributeNS(null, "y2", `${k}%`), this.markerElem_.style.left = `${b}%`, this.markerElem_.style.top = `${k}%`;
  10614. }
  10615. onValueChange_() {
  10616. this.update_();
  10617. }
  10618. onFoldableChange_() {
  10619. this.update_();
  10620. }
  10621. }
  10622. function ea(n, e, t) {
  10623. return [
  10624. je(e[0], ut2(n)),
  10625. je(e[1], Pn(n)) * (t ? 1 : -1)
  10626. ];
  10627. }
  10628. class uc {
  10629. constructor(e, t) {
  10630. this.onPadKeyDown_ = this.onPadKeyDown_.bind(this), this.onPadKeyUp_ = this.onPadKeyUp_.bind(this), this.onPointerDown_ = this.onPointerDown_.bind(this), this.onPointerMove_ = this.onPointerMove_.bind(this), this.onPointerUp_ = this.onPointerUp_.bind(this), this.value = t.value, this.viewProps = t.viewProps, this.baseSteps_ = t.baseSteps, this.maxValue_ = t.maxValue, this.invertsY_ = t.invertsY, this.view = new cc(e, {
  10631. invertsY: this.invertsY_,
  10632. layout: t.layout,
  10633. maxValue: this.maxValue_,
  10634. value: this.value,
  10635. viewProps: this.viewProps
  10636. }), this.ptHandler_ = new It(this.view.padElement), this.ptHandler_.emitter.on("down", this.onPointerDown_), this.ptHandler_.emitter.on("move", this.onPointerMove_), this.ptHandler_.emitter.on("up", this.onPointerUp_), this.view.padElement.addEventListener("keydown", this.onPadKeyDown_), this.view.padElement.addEventListener("keyup", this.onPadKeyUp_);
  10637. }
  10638. handlePointerEvent_(e, t) {
  10639. if (!e.point)
  10640. return;
  10641. const l = this.maxValue_, b = we(e.point.x, 0, e.bounds.width, -l, +l), E = we(this.invertsY_ ? e.bounds.height - e.point.y : e.point.y, 0, e.bounds.height, -l, +l);
  10642. this.value.setRawValue(new Jt(b, E), t);
  10643. }
  10644. onPointerDown_(e) {
  10645. this.handlePointerEvent_(e.data, {
  10646. forceEmit: false,
  10647. last: false
  10648. });
  10649. }
  10650. onPointerMove_(e) {
  10651. this.handlePointerEvent_(e.data, {
  10652. forceEmit: false,
  10653. last: false
  10654. });
  10655. }
  10656. onPointerUp_(e) {
  10657. this.handlePointerEvent_(e.data, {
  10658. forceEmit: true,
  10659. last: true
  10660. });
  10661. }
  10662. onPadKeyDown_(e) {
  10663. ni(e.key) && e.preventDefault();
  10664. const [t, l] = ea(e, this.baseSteps_, this.invertsY_);
  10665. t === 0 && l === 0 || this.value.setRawValue(new Jt(this.value.rawValue.x + t, this.value.rawValue.y + l), {
  10666. forceEmit: false,
  10667. last: false
  10668. });
  10669. }
  10670. onPadKeyUp_(e) {
  10671. const [t, l] = ea(e, this.baseSteps_, this.invertsY_);
  10672. t === 0 && l === 0 || this.value.setRawValue(this.value.rawValue, {
  10673. forceEmit: true,
  10674. last: true
  10675. });
  10676. }
  10677. }
  10678. class pc {
  10679. constructor(e, t) {
  10680. var l, b;
  10681. this.onPopupChildBlur_ = this.onPopupChildBlur_.bind(this), this.onPopupChildKeydown_ = this.onPopupChildKeydown_.bind(this), this.onPadButtonBlur_ = this.onPadButtonBlur_.bind(this), this.onPadButtonClick_ = this.onPadButtonClick_.bind(this), this.value = t.value, this.viewProps = t.viewProps, this.foldable_ = Fe.create(t.expanded), this.popC_ = t.pickerLayout === "popup" ? new gs(e, {
  10682. viewProps: this.viewProps
  10683. }) : null;
  10684. const E = new uc(e, {
  10685. baseSteps: [t.axes[0].baseStep, t.axes[1].baseStep],
  10686. invertsY: t.invertsY,
  10687. layout: t.pickerLayout,
  10688. maxValue: t.maxValue,
  10689. value: this.value,
  10690. viewProps: this.viewProps
  10691. });
  10692. E.view.allFocusableElements.forEach((k) => {
  10693. k.addEventListener("blur", this.onPopupChildBlur_), k.addEventListener("keydown", this.onPopupChildKeydown_);
  10694. }), this.pickerC_ = E, this.textC_ = new $r(e, {
  10695. assembly: Jo,
  10696. axes: t.axes,
  10697. parser: t.parser,
  10698. value: this.value,
  10699. viewProps: this.viewProps
  10700. }), this.view = new lc(e, {
  10701. expanded: this.foldable_.value("expanded"),
  10702. pickerLayout: t.pickerLayout,
  10703. viewProps: this.viewProps
  10704. }), this.view.textElement.appendChild(this.textC_.view.element), (l = this.view.buttonElement) === null || l === void 0 || l.addEventListener("blur", this.onPadButtonBlur_), (b = this.view.buttonElement) === null || b === void 0 || b.addEventListener("click", this.onPadButtonClick_), this.popC_ ? (this.view.element.appendChild(this.popC_.view.element), this.popC_.view.element.appendChild(this.pickerC_.view.element), Qt({
  10705. primary: this.foldable_.value("expanded"),
  10706. secondary: this.popC_.shows,
  10707. forward: (k) => k.rawValue,
  10708. backward: (k, j) => j.rawValue
  10709. })) : this.view.pickerElement && (this.view.pickerElement.appendChild(this.pickerC_.view.element), $e(this.foldable_, this.view.pickerElement));
  10710. }
  10711. onPadButtonBlur_(e) {
  10712. if (!this.popC_)
  10713. return;
  10714. const t = this.view.element, l = e.relatedTarget;
  10715. (!l || !t.contains(l)) && (this.popC_.shows.rawValue = false);
  10716. }
  10717. onPadButtonClick_() {
  10718. this.foldable_.set("expanded", !this.foldable_.get("expanded")), this.foldable_.get("expanded") && this.pickerC_.view.allFocusableElements[0].focus();
  10719. }
  10720. onPopupChildBlur_(e) {
  10721. if (!this.popC_)
  10722. return;
  10723. const t = this.popC_.view.element, l = Ct(e);
  10724. l && t.contains(l) || l && l === this.view.buttonElement && !bt2(t.ownerDocument) || (this.popC_.shows.rawValue = false);
  10725. }
  10726. onPopupChildKeydown_(e) {
  10727. this.popC_ ? e.key === "Escape" && (this.popC_.shows.rawValue = false) : this.view.pickerElement && e.key === "Escape" && this.view.buttonElement.focus();
  10728. }
  10729. }
  10730. class li {
  10731. constructor(e = 0, t = 0, l = 0) {
  10732. this.x = e, this.y = t, this.z = l;
  10733. }
  10734. getComponents() {
  10735. return [this.x, this.y, this.z];
  10736. }
  10737. static isObject(e) {
  10738. if (_2(e))
  10739. return false;
  10740. const t = e.x, l = e.y, b = e.z;
  10741. return !(typeof t != "number" || typeof l != "number" || typeof b != "number");
  10742. }
  10743. static equals(e, t) {
  10744. return e.x === t.x && e.y === t.y && e.z === t.z;
  10745. }
  10746. toObject() {
  10747. return {
  10748. x: this.x,
  10749. y: this.y,
  10750. z: this.z
  10751. };
  10752. }
  10753. }
  10754. const ta = {
  10755. toComponents: (n) => n.getComponents(),
  10756. fromComponents: (n) => new li(...n)
  10757. };
  10758. function hc(n) {
  10759. return li.isObject(n) ? new li(n.x, n.y, n.z) : new li();
  10760. }
  10761. function dc(n, e) {
  10762. n.writeProperty("x", e.x), n.writeProperty("y", e.y), n.writeProperty("z", e.z);
  10763. }
  10764. function mc(n, e) {
  10765. return new Wt({
  10766. assembly: ta,
  10767. components: [
  10768. Bt("x" in n ? n.x : void 0, e.x),
  10769. Bt("y" in n ? n.y : void 0, e.y),
  10770. Bt("z" in n ? n.z : void 0, e.z)
  10771. ]
  10772. });
  10773. }
  10774. function Xr(n, e) {
  10775. return {
  10776. baseStep: Dt(e),
  10777. constraint: e,
  10778. textProps: X2.fromObject({
  10779. draggingScale: Ot(e, n),
  10780. formatter: De(si(e, n))
  10781. })
  10782. };
  10783. }
  10784. const fc = {
  10785. id: "input-point3d",
  10786. type: "input",
  10787. accept: (n, e) => {
  10788. if (!li.isObject(n))
  10789. return null;
  10790. const t = A2, l = ae(e, {
  10791. x: t.optional.custom(wt2),
  10792. y: t.optional.custom(wt2),
  10793. z: t.optional.custom(wt2)
  10794. });
  10795. return l ? {
  10796. initialValue: n,
  10797. params: l
  10798. } : null;
  10799. },
  10800. binding: {
  10801. reader: (n) => hc,
  10802. constraint: (n) => mc(n.params, n.initialValue),
  10803. equals: li.equals,
  10804. writer: (n) => dc
  10805. },
  10806. controller: (n) => {
  10807. const e = n.value, t = n.constraint;
  10808. if (!(t instanceof Wt))
  10809. throw S.shouldNeverHappen();
  10810. return new $r(n.document, {
  10811. assembly: ta,
  10812. axes: [
  10813. Xr(e.rawValue.x, t.components[0]),
  10814. Xr(e.rawValue.y, t.components[1]),
  10815. Xr(e.rawValue.z, t.components[2])
  10816. ],
  10817. parser: ct2,
  10818. value: e,
  10819. viewProps: n.viewProps
  10820. });
  10821. }
  10822. };
  10823. class ci {
  10824. constructor(e = 0, t = 0, l = 0, b = 0) {
  10825. this.x = e, this.y = t, this.z = l, this.w = b;
  10826. }
  10827. getComponents() {
  10828. return [this.x, this.y, this.z, this.w];
  10829. }
  10830. static isObject(e) {
  10831. if (_2(e))
  10832. return false;
  10833. const t = e.x, l = e.y, b = e.z, E = e.w;
  10834. return !(typeof t != "number" || typeof l != "number" || typeof b != "number" || typeof E != "number");
  10835. }
  10836. static equals(e, t) {
  10837. return e.x === t.x && e.y === t.y && e.z === t.z && e.w === t.w;
  10838. }
  10839. toObject() {
  10840. return {
  10841. x: this.x,
  10842. y: this.y,
  10843. z: this.z,
  10844. w: this.w
  10845. };
  10846. }
  10847. }
  10848. const na = {
  10849. toComponents: (n) => n.getComponents(),
  10850. fromComponents: (n) => new ci(...n)
  10851. };
  10852. function vc(n) {
  10853. return ci.isObject(n) ? new ci(n.x, n.y, n.z, n.w) : new ci();
  10854. }
  10855. function bc(n, e) {
  10856. n.writeProperty("x", e.x), n.writeProperty("y", e.y), n.writeProperty("z", e.z), n.writeProperty("w", e.w);
  10857. }
  10858. function gc(n, e) {
  10859. return new Wt({
  10860. assembly: na,
  10861. components: [
  10862. Bt("x" in n ? n.x : void 0, e.x),
  10863. Bt("y" in n ? n.y : void 0, e.y),
  10864. Bt("z" in n ? n.z : void 0, e.z),
  10865. Bt("w" in n ? n.w : void 0, e.w)
  10866. ]
  10867. });
  10868. }
  10869. function _c(n, e) {
  10870. return {
  10871. baseStep: Dt(e),
  10872. constraint: e,
  10873. textProps: X2.fromObject({
  10874. draggingScale: Ot(e, n),
  10875. formatter: De(si(e, n))
  10876. })
  10877. };
  10878. }
  10879. const wc = {
  10880. id: "input-point4d",
  10881. type: "input",
  10882. accept: (n, e) => {
  10883. if (!ci.isObject(n))
  10884. return null;
  10885. const t = A2, l = ae(e, {
  10886. x: t.optional.custom(wt2),
  10887. y: t.optional.custom(wt2),
  10888. z: t.optional.custom(wt2),
  10889. w: t.optional.custom(wt2)
  10890. });
  10891. return l ? {
  10892. initialValue: n,
  10893. params: l
  10894. } : null;
  10895. },
  10896. binding: {
  10897. reader: (n) => vc,
  10898. constraint: (n) => gc(n.params, n.initialValue),
  10899. equals: ci.equals,
  10900. writer: (n) => bc
  10901. },
  10902. controller: (n) => {
  10903. const e = n.value, t = n.constraint;
  10904. if (!(t instanceof Wt))
  10905. throw S.shouldNeverHappen();
  10906. return new $r(n.document, {
  10907. assembly: na,
  10908. axes: e.rawValue.getComponents().map((l, b) => _c(l, t.components[b])),
  10909. parser: ct2,
  10910. value: e,
  10911. viewProps: n.viewProps
  10912. });
  10913. }
  10914. };
  10915. function yc(n) {
  10916. const e = [], t = Ui(n.options);
  10917. return t && e.push(t), new wn(e);
  10918. }
  10919. const xc = {
  10920. id: "input-string",
  10921. type: "input",
  10922. accept: (n, e) => {
  10923. if (typeof n != "string")
  10924. return null;
  10925. const l = ae(e, {
  10926. options: A2.optional.custom(An)
  10927. });
  10928. return l ? {
  10929. initialValue: n,
  10930. params: l
  10931. } : null;
  10932. },
  10933. binding: {
  10934. reader: (n) => Ii,
  10935. constraint: (n) => yc(n.params),
  10936. writer: (n) => st2
  10937. },
  10938. controller: (n) => {
  10939. const e = n.document, t = n.value, l = n.constraint, b = l && it2(l, yn);
  10940. return b ? new xn(e, {
  10941. props: new X2({
  10942. options: b.values.value("options")
  10943. }),
  10944. value: t,
  10945. viewProps: n.viewProps
  10946. }) : new ei(e, {
  10947. parser: (E) => E,
  10948. props: X2.fromObject({
  10949. formatter: Tt
  10950. }),
  10951. value: t,
  10952. viewProps: n.viewProps
  10953. });
  10954. }
  10955. }, Ki = {
  10956. monitor: {
  10957. defaultInterval: 200,
  10958. defaultLineCount: 3
  10959. }
  10960. }, ia = D2("mll");
  10961. class Ec {
  10962. constructor(e, t) {
  10963. this.onValueUpdate_ = this.onValueUpdate_.bind(this), this.formatter_ = t.formatter, this.element = e.createElement("div"), this.element.classList.add(ia()), t.viewProps.bindClassModifiers(this.element);
  10964. const l = e.createElement("textarea");
  10965. l.classList.add(ia("i")), l.style.height = `calc(var(--bld-us) * ${t.lineCount})`, l.readOnly = true, t.viewProps.bindDisabled(l), this.element.appendChild(l), this.textareaElem_ = l, t.value.emitter.on("change", this.onValueUpdate_), this.value = t.value, this.update_();
  10966. }
  10967. update_() {
  10968. const e = this.textareaElem_, t = e.scrollTop === e.scrollHeight - e.clientHeight, l = [];
  10969. this.value.rawValue.forEach((b) => {
  10970. b !== void 0 && l.push(this.formatter_(b));
  10971. }), e.textContent = l.join(`
  10972. `), t && (e.scrollTop = e.scrollHeight);
  10973. }
  10974. onValueUpdate_() {
  10975. this.update_();
  10976. }
  10977. }
  10978. class Yr {
  10979. constructor(e, t) {
  10980. this.value = t.value, this.viewProps = t.viewProps, this.view = new Ec(e, {
  10981. formatter: t.formatter,
  10982. lineCount: t.lineCount,
  10983. value: this.value,
  10984. viewProps: this.viewProps
  10985. });
  10986. }
  10987. }
  10988. const sa = D2("sgl");
  10989. class Cc {
  10990. constructor(e, t) {
  10991. this.onValueUpdate_ = this.onValueUpdate_.bind(this), this.formatter_ = t.formatter, this.element = e.createElement("div"), this.element.classList.add(sa()), t.viewProps.bindClassModifiers(this.element);
  10992. const l = e.createElement("input");
  10993. l.classList.add(sa("i")), l.readOnly = true, l.type = "text", t.viewProps.bindDisabled(l), this.element.appendChild(l), this.inputElement = l, t.value.emitter.on("change", this.onValueUpdate_), this.value = t.value, this.update_();
  10994. }
  10995. update_() {
  10996. const e = this.value.rawValue, t = e[e.length - 1];
  10997. this.inputElement.value = t !== void 0 ? this.formatter_(t) : "";
  10998. }
  10999. onValueUpdate_() {
  11000. this.update_();
  11001. }
  11002. }
  11003. class qr {
  11004. constructor(e, t) {
  11005. this.value = t.value, this.viewProps = t.viewProps, this.view = new Cc(e, {
  11006. formatter: t.formatter,
  11007. value: this.value,
  11008. viewProps: this.viewProps
  11009. });
  11010. }
  11011. }
  11012. const Pc = {
  11013. id: "monitor-bool",
  11014. type: "monitor",
  11015. accept: (n, e) => {
  11016. if (typeof n != "boolean")
  11017. return null;
  11018. const l = ae(e, {
  11019. lineCount: A2.optional.number
  11020. });
  11021. return l ? {
  11022. initialValue: n,
  11023. params: l
  11024. } : null;
  11025. },
  11026. binding: {
  11027. reader: (n) => ws
  11028. },
  11029. controller: (n) => {
  11030. var e;
  11031. return n.value.rawValue.length === 1 ? new qr(n.document, {
  11032. formatter: ys,
  11033. value: n.value,
  11034. viewProps: n.viewProps
  11035. }) : new Yr(n.document, {
  11036. formatter: ys,
  11037. lineCount: (e = n.params.lineCount) !== null && e !== void 0 ? e : Ki.monitor.defaultLineCount,
  11038. value: n.value,
  11039. viewProps: n.viewProps
  11040. });
  11041. }
  11042. }, tn = D2("grl");
  11043. class Tc {
  11044. constructor(e, t) {
  11045. this.onCursorChange_ = this.onCursorChange_.bind(this), this.onValueUpdate_ = this.onValueUpdate_.bind(this), this.element = e.createElement("div"), this.element.classList.add(tn()), t.viewProps.bindClassModifiers(this.element), this.formatter_ = t.formatter, this.props_ = t.props, this.cursor_ = t.cursor, this.cursor_.emitter.on("change", this.onCursorChange_);
  11046. const l = e.createElementNS(Ke, "svg");
  11047. l.classList.add(tn("g")), l.style.height = `calc(var(--bld-us) * ${t.lineCount})`, this.element.appendChild(l), this.svgElem_ = l;
  11048. const b = e.createElementNS(Ke, "polyline");
  11049. this.svgElem_.appendChild(b), this.lineElem_ = b;
  11050. const E = e.createElement("div");
  11051. E.classList.add(tn("t"), D2("tt")()), this.element.appendChild(E), this.tooltipElem_ = E, t.value.emitter.on("change", this.onValueUpdate_), this.value = t.value, this.update_();
  11052. }
  11053. get graphElement() {
  11054. return this.svgElem_;
  11055. }
  11056. update_() {
  11057. const e = this.svgElem_.getBoundingClientRect(), t = this.value.rawValue.length - 1, l = this.props_.get("minValue"), b = this.props_.get("maxValue"), E = [];
  11058. this.value.rawValue.forEach((de, ve) => {
  11059. if (de === void 0)
  11060. return;
  11061. const Vn = we(ve, 0, t, 0, e.width), $i = we(de, l, b, e.height, 0);
  11062. E.push([Vn, $i].join(","));
  11063. }), this.lineElem_.setAttributeNS(null, "points", E.join(" "));
  11064. const k = this.tooltipElem_, j = this.value.rawValue[this.cursor_.rawValue];
  11065. if (j === void 0) {
  11066. k.classList.remove(tn("t", "a"));
  11067. return;
  11068. }
  11069. const Q2 = we(this.cursor_.rawValue, 0, t, 0, e.width), J = we(j, l, b, e.height, 0);
  11070. k.style.left = `${Q2}px`, k.style.top = `${J}px`, k.textContent = `${this.formatter_(j)}`, k.classList.contains(tn("t", "a")) || (k.classList.add(tn("t", "a"), tn("t", "in")), ot2(k), k.classList.remove(tn("t", "in")));
  11071. }
  11072. onValueUpdate_() {
  11073. this.update_();
  11074. }
  11075. onCursorChange_() {
  11076. this.update_();
  11077. }
  11078. }
  11079. class kc {
  11080. constructor(e, t) {
  11081. if (this.onGraphMouseMove_ = this.onGraphMouseMove_.bind(this), this.onGraphMouseLeave_ = this.onGraphMouseLeave_.bind(this), this.onGraphPointerDown_ = this.onGraphPointerDown_.bind(this), this.onGraphPointerMove_ = this.onGraphPointerMove_.bind(this), this.onGraphPointerUp_ = this.onGraphPointerUp_.bind(this), this.props_ = t.props, this.value = t.value, this.viewProps = t.viewProps, this.cursor_ = ee(-1), this.view = new Tc(e, {
  11082. cursor: this.cursor_,
  11083. formatter: t.formatter,
  11084. lineCount: t.lineCount,
  11085. props: this.props_,
  11086. value: this.value,
  11087. viewProps: this.viewProps
  11088. }), !bt2(e))
  11089. this.view.element.addEventListener("mousemove", this.onGraphMouseMove_), this.view.element.addEventListener("mouseleave", this.onGraphMouseLeave_);
  11090. else {
  11091. const l = new It(this.view.element);
  11092. l.emitter.on("down", this.onGraphPointerDown_), l.emitter.on("move", this.onGraphPointerMove_), l.emitter.on("up", this.onGraphPointerUp_);
  11093. }
  11094. }
  11095. onGraphMouseLeave_() {
  11096. this.cursor_.rawValue = -1;
  11097. }
  11098. onGraphMouseMove_(e) {
  11099. const t = this.view.element.getBoundingClientRect();
  11100. this.cursor_.rawValue = Math.floor(we(e.offsetX, 0, t.width, 0, this.value.rawValue.length));
  11101. }
  11102. onGraphPointerDown_(e) {
  11103. this.onGraphPointerMove_(e);
  11104. }
  11105. onGraphPointerMove_(e) {
  11106. if (!e.data.point) {
  11107. this.cursor_.rawValue = -1;
  11108. return;
  11109. }
  11110. this.cursor_.rawValue = Math.floor(we(e.data.point.x, 0, e.data.bounds.width, 0, this.value.rawValue.length));
  11111. }
  11112. onGraphPointerUp_() {
  11113. this.cursor_.rawValue = -1;
  11114. }
  11115. }
  11116. function Qr(n) {
  11117. return "format" in n && !_2(n.format) ? n.format : De(2);
  11118. }
  11119. function Ac(n) {
  11120. var e;
  11121. return n.value.rawValue.length === 1 ? new qr(n.document, {
  11122. formatter: Qr(n.params),
  11123. value: n.value,
  11124. viewProps: n.viewProps
  11125. }) : new Yr(n.document, {
  11126. formatter: Qr(n.params),
  11127. lineCount: (e = n.params.lineCount) !== null && e !== void 0 ? e : Ki.monitor.defaultLineCount,
  11128. value: n.value,
  11129. viewProps: n.viewProps
  11130. });
  11131. }
  11132. function Mc(n) {
  11133. var e, t, l;
  11134. return new kc(n.document, {
  11135. formatter: Qr(n.params),
  11136. lineCount: (e = n.params.lineCount) !== null && e !== void 0 ? e : Ki.monitor.defaultLineCount,
  11137. props: X2.fromObject({
  11138. maxValue: (t = "max" in n.params ? n.params.max : null) !== null && t !== void 0 ? t : 100,
  11139. minValue: (l = "min" in n.params ? n.params.min : null) !== null && l !== void 0 ? l : 0
  11140. }),
  11141. value: n.value,
  11142. viewProps: n.viewProps
  11143. });
  11144. }
  11145. function ra(n) {
  11146. return "view" in n && n.view === "graph";
  11147. }
  11148. const Sc = {
  11149. id: "monitor-number",
  11150. type: "monitor",
  11151. accept: (n, e) => {
  11152. if (typeof n != "number")
  11153. return null;
  11154. const t = A2, l = ae(e, {
  11155. format: t.optional.function,
  11156. lineCount: t.optional.number,
  11157. max: t.optional.number,
  11158. min: t.optional.number,
  11159. view: t.optional.string
  11160. });
  11161. return l ? {
  11162. initialValue: n,
  11163. params: l
  11164. } : null;
  11165. },
  11166. binding: {
  11167. defaultBufferSize: (n) => ra(n) ? 64 : 1,
  11168. reader: (n) => _t
  11169. },
  11170. controller: (n) => ra(n.params) ? Mc(n) : Ac(n)
  11171. }, Lc = {
  11172. id: "monitor-string",
  11173. type: "monitor",
  11174. accept: (n, e) => {
  11175. if (typeof n != "string")
  11176. return null;
  11177. const t = A2, l = ae(e, {
  11178. lineCount: t.optional.number,
  11179. multiline: t.optional.boolean
  11180. });
  11181. return l ? {
  11182. initialValue: n,
  11183. params: l
  11184. } : null;
  11185. },
  11186. binding: {
  11187. reader: (n) => Ii
  11188. },
  11189. controller: (n) => {
  11190. var e;
  11191. const t = n.value;
  11192. return t.rawValue.length > 1 || "multiline" in n.params && n.params.multiline ? new Yr(n.document, {
  11193. formatter: Tt,
  11194. lineCount: (e = n.params.lineCount) !== null && e !== void 0 ? e : Ki.monitor.defaultLineCount,
  11195. value: t,
  11196. viewProps: n.viewProps
  11197. }) : new qr(n.document, {
  11198. formatter: Tt,
  11199. value: t,
  11200. viewProps: n.viewProps
  11201. });
  11202. }
  11203. };
  11204. function Rc(n, e) {
  11205. var t;
  11206. const l = n.accept(e.target.read(), e.params);
  11207. if (_2(l))
  11208. return null;
  11209. const b = A2, E = {
  11210. target: e.target,
  11211. initialValue: l.initialValue,
  11212. params: l.params
  11213. }, k = n.binding.reader(E), j = n.binding.constraint ? n.binding.constraint(E) : void 0, Q2 = ee(k(l.initialValue), {
  11214. constraint: j,
  11215. equals: n.binding.equals
  11216. }), J = new Wn({
  11217. reader: k,
  11218. target: e.target,
  11219. value: Q2,
  11220. writer: n.binding.writer(E)
  11221. }), de = b.optional.boolean(e.params.disabled).value, ve = b.optional.boolean(e.params.hidden).value, Vn = n.controller({
  11222. constraint: j,
  11223. document: e.document,
  11224. initialValue: l.initialValue,
  11225. params: l.params,
  11226. value: J.value,
  11227. viewProps: Ze2.create({
  11228. disabled: de,
  11229. hidden: ve
  11230. })
  11231. });
  11232. return new Ge(e.document, {
  11233. binding: J,
  11234. blade: Ee2(),
  11235. props: X2.fromObject({
  11236. label: "label" in e.params ? (t = b.optional.string(e.params.label).value) !== null && t !== void 0 ? t : null : e.target.key
  11237. }),
  11238. valueController: Vn
  11239. });
  11240. }
  11241. function Vc(n, e) {
  11242. return e === 0 ? new ms() : new ki(n, e ?? Ki.monitor.defaultInterval);
  11243. }
  11244. function Ic(n, e) {
  11245. var t, l, b;
  11246. const E = A2, k = n.accept(e.target.read(), e.params);
  11247. if (_2(k))
  11248. return null;
  11249. const j = {
  11250. target: e.target,
  11251. initialValue: k.initialValue,
  11252. params: k.params
  11253. }, Q2 = n.binding.reader(j), J = (l = (t = E.optional.number(e.params.bufferSize).value) !== null && t !== void 0 ? t : n.binding.defaultBufferSize && n.binding.defaultBufferSize(k.params)) !== null && l !== void 0 ? l : 1, de = E.optional.number(e.params.interval).value, ve = new pr({
  11254. reader: Q2,
  11255. target: e.target,
  11256. ticker: Vc(e.document, de),
  11257. value: fs(J)
  11258. }), Vn = E.optional.boolean(e.params.disabled).value, $i = E.optional.boolean(e.params.hidden).value, Xi = n.controller({
  11259. document: e.document,
  11260. params: k.params,
  11261. value: ve.value,
  11262. viewProps: Ze2.create({
  11263. disabled: Vn,
  11264. hidden: $i
  11265. })
  11266. });
  11267. return new at2(e.document, {
  11268. binding: ve,
  11269. blade: Ee2(),
  11270. props: X2.fromObject({
  11271. label: "label" in e.params ? (b = E.optional.string(e.params.label).value) !== null && b !== void 0 ? b : null : e.target.key
  11272. }),
  11273. valueController: Xi
  11274. });
  11275. }
  11276. class Dc {
  11277. constructor() {
  11278. this.pluginsMap_ = {
  11279. blades: [],
  11280. inputs: [],
  11281. monitors: []
  11282. };
  11283. }
  11284. getAll() {
  11285. return [
  11286. ...this.pluginsMap_.blades,
  11287. ...this.pluginsMap_.inputs,
  11288. ...this.pluginsMap_.monitors
  11289. ];
  11290. }
  11291. register(e) {
  11292. e.type === "blade" ? this.pluginsMap_.blades.unshift(e) : e.type === "input" ? this.pluginsMap_.inputs.unshift(e) : e.type === "monitor" && this.pluginsMap_.monitors.unshift(e);
  11293. }
  11294. createInput(e, t, l) {
  11295. const b = t.read();
  11296. if (_2(b))
  11297. throw new S({
  11298. context: {
  11299. key: t.key
  11300. },
  11301. type: "nomatchingcontroller"
  11302. });
  11303. const E = this.pluginsMap_.inputs.reduce((k, j) => k ?? Rc(j, {
  11304. document: e,
  11305. target: t,
  11306. params: l
  11307. }), null);
  11308. if (E)
  11309. return E;
  11310. throw new S({
  11311. context: {
  11312. key: t.key
  11313. },
  11314. type: "nomatchingcontroller"
  11315. });
  11316. }
  11317. createMonitor(e, t, l) {
  11318. const b = this.pluginsMap_.monitors.reduce((E, k) => E ?? Ic(k, {
  11319. document: e,
  11320. params: l,
  11321. target: t
  11322. }), null);
  11323. if (b)
  11324. return b;
  11325. throw new S({
  11326. context: {
  11327. key: t.key
  11328. },
  11329. type: "nomatchingcontroller"
  11330. });
  11331. }
  11332. createBlade(e, t) {
  11333. const l = this.pluginsMap_.blades.reduce((b, E) => b ?? ur(E, {
  11334. document: e,
  11335. params: t
  11336. }), null);
  11337. if (!l)
  11338. throw new S({
  11339. type: "nomatchingview",
  11340. context: {
  11341. params: t
  11342. }
  11343. });
  11344. return l;
  11345. }
  11346. createBladeApi(e) {
  11347. if (e instanceof Ge)
  11348. return new _i(e);
  11349. if (e instanceof at2)
  11350. return new wi(e);
  11351. if (e instanceof bn)
  11352. return new qn(e, this);
  11353. const t = this.pluginsMap_.blades.reduce((l, b) => l ?? b.api({
  11354. controller: e,
  11355. pool: this
  11356. }), null);
  11357. if (!t)
  11358. throw S.shouldNeverHappen();
  11359. return t;
  11360. }
  11361. }
  11362. function Oc() {
  11363. const n = new Dc();
  11364. return [
  11365. Uc,
  11366. fc,
  11367. wc,
  11368. xc,
  11369. ac,
  11370. nc,
  11371. tc,
  11372. Zl,
  11373. ri,
  11374. Pc,
  11375. Lc,
  11376. Sc,
  11377. W,
  11378. rr,
  11379. ar,
  11380. Ti
  11381. ].forEach((e) => {
  11382. n.register(e);
  11383. }), n;
  11384. }
  11385. function Nc(n) {
  11386. return Jt.isObject(n) ? new Jt(n.x, n.y) : new Jt();
  11387. }
  11388. function Bc(n, e) {
  11389. n.writeProperty("x", e.x), n.writeProperty("y", e.y);
  11390. }
  11391. function Bt(n, e) {
  11392. if (!n)
  11393. return;
  11394. const t = [], l = Zo(n, e);
  11395. l && t.push(l);
  11396. const b = Wo(n);
  11397. return b && t.push(b), new wn(t);
  11398. }
  11399. function Fc(n, e) {
  11400. return new Wt({
  11401. assembly: Jo,
  11402. components: [
  11403. Bt("x" in n ? n.x : void 0, e.x),
  11404. Bt("y" in n ? n.y : void 0, e.y)
  11405. ]
  11406. });
  11407. }
  11408. function oa(n, e) {
  11409. const [t, l] = n ? rc(n) : [];
  11410. if (!_2(t) || !_2(l))
  11411. return Math.max(Math.abs(t ?? 0), Math.abs(l ?? 0));
  11412. const b = Dt(n);
  11413. return Math.max(Math.abs(b) * 10, Math.abs(e) * 10);
  11414. }
  11415. function jc(n, e) {
  11416. const t = e instanceof Wt ? e.components[0] : void 0, l = e instanceof Wt ? e.components[1] : void 0, b = oa(t, n.x), E = oa(l, n.y);
  11417. return Math.max(b, E);
  11418. }
  11419. function aa(n, e) {
  11420. return {
  11421. baseStep: Dt(e),
  11422. constraint: e,
  11423. textProps: X2.fromObject({
  11424. draggingScale: Ot(e, n),
  11425. formatter: De(si(e, n))
  11426. })
  11427. };
  11428. }
  11429. function zc(n) {
  11430. if (!("y" in n))
  11431. return false;
  11432. const e = n.y;
  11433. return e && "inverted" in e ? !!e.inverted : false;
  11434. }
  11435. const Uc = {
  11436. id: "input-point2d",
  11437. type: "input",
  11438. accept: (n, e) => {
  11439. if (!Jt.isObject(n))
  11440. return null;
  11441. const t = A2, l = ae(e, {
  11442. expanded: t.optional.boolean,
  11443. picker: t.optional.custom(zi),
  11444. x: t.optional.custom(wt2),
  11445. y: t.optional.object({
  11446. inverted: t.optional.boolean,
  11447. max: t.optional.number,
  11448. min: t.optional.number,
  11449. step: t.optional.number
  11450. })
  11451. });
  11452. return l ? {
  11453. initialValue: n,
  11454. params: l
  11455. } : null;
  11456. },
  11457. binding: {
  11458. reader: (n) => Nc,
  11459. constraint: (n) => Fc(n.params, n.initialValue),
  11460. equals: Jt.equals,
  11461. writer: (n) => Bc
  11462. },
  11463. controller: (n) => {
  11464. const e = n.document, t = n.value, l = n.constraint;
  11465. if (!(l instanceof Wt))
  11466. throw S.shouldNeverHappen();
  11467. const b = "expanded" in n.params ? n.params.expanded : void 0, E = "picker" in n.params ? n.params.picker : void 0;
  11468. return new pc(e, {
  11469. axes: [
  11470. aa(t.rawValue.x, l.components[0]),
  11471. aa(t.rawValue.y, l.components[1])
  11472. ],
  11473. expanded: b ?? false,
  11474. invertsY: zc(n.params),
  11475. maxValue: jc(t.rawValue, l),
  11476. parser: ct2,
  11477. pickerLayout: E ?? "popup",
  11478. value: t,
  11479. viewProps: n.viewProps
  11480. });
  11481. }
  11482. };
  11483. class la extends o {
  11484. constructor(e) {
  11485. super(e), this.emitter_ = new N(), this.controller_.valueController.value.emitter.on("change", (t) => {
  11486. this.emitter_.emit("change", {
  11487. event: new p2(this, t.rawValue)
  11488. });
  11489. });
  11490. }
  11491. get label() {
  11492. return this.controller_.props.get("label");
  11493. }
  11494. set label(e) {
  11495. this.controller_.props.set("label", e);
  11496. }
  11497. get options() {
  11498. return this.controller_.valueController.props.get("options");
  11499. }
  11500. set options(e) {
  11501. this.controller_.valueController.props.set("options", e);
  11502. }
  11503. get value() {
  11504. return this.controller_.valueController.value.rawValue;
  11505. }
  11506. set value(e) {
  11507. this.controller_.valueController.value.rawValue = e;
  11508. }
  11509. on(e, t) {
  11510. const l = t.bind(this);
  11511. return this.emitter_.on(e, (b) => {
  11512. l(b.event);
  11513. }), this;
  11514. }
  11515. }
  11516. class ca extends o {
  11517. constructor(e) {
  11518. super(e), this.emitter_ = new N(), this.controller_.valueController.value.emitter.on("change", (t) => {
  11519. this.emitter_.emit("change", {
  11520. event: new p2(this, t.rawValue)
  11521. });
  11522. });
  11523. }
  11524. get label() {
  11525. return this.controller_.props.get("label");
  11526. }
  11527. set label(e) {
  11528. this.controller_.props.set("label", e);
  11529. }
  11530. get maxValue() {
  11531. return this.controller_.valueController.sliderController.props.get("maxValue");
  11532. }
  11533. set maxValue(e) {
  11534. this.controller_.valueController.sliderController.props.set("maxValue", e);
  11535. }
  11536. get minValue() {
  11537. return this.controller_.valueController.sliderController.props.get("minValue");
  11538. }
  11539. set minValue(e) {
  11540. this.controller_.valueController.sliderController.props.set("minValue", e);
  11541. }
  11542. get value() {
  11543. return this.controller_.valueController.value.rawValue;
  11544. }
  11545. set value(e) {
  11546. this.controller_.valueController.value.rawValue = e;
  11547. }
  11548. on(e, t) {
  11549. const l = t.bind(this);
  11550. return this.emitter_.on(e, (b) => {
  11551. l(b.event);
  11552. }), this;
  11553. }
  11554. }
  11555. class ua extends o {
  11556. constructor(e) {
  11557. super(e), this.emitter_ = new N(), this.controller_.valueController.value.emitter.on("change", (t) => {
  11558. this.emitter_.emit("change", {
  11559. event: new p2(this, t.rawValue)
  11560. });
  11561. });
  11562. }
  11563. get label() {
  11564. return this.controller_.props.get("label");
  11565. }
  11566. set label(e) {
  11567. this.controller_.props.set("label", e);
  11568. }
  11569. get formatter() {
  11570. return this.controller_.valueController.props.get("formatter");
  11571. }
  11572. set formatter(e) {
  11573. this.controller_.valueController.props.set("formatter", e);
  11574. }
  11575. get value() {
  11576. return this.controller_.valueController.value.rawValue;
  11577. }
  11578. set value(e) {
  11579. this.controller_.valueController.value.rawValue = e;
  11580. }
  11581. on(e, t) {
  11582. const l = t.bind(this);
  11583. return this.emitter_.on(e, (b) => {
  11584. l(b.event);
  11585. }), this;
  11586. }
  11587. }
  11588. const Gc = function() {
  11589. return {
  11590. id: "list",
  11591. type: "blade",
  11592. accept(n) {
  11593. const e = A2, t = ae(n, {
  11594. options: e.required.custom(An),
  11595. value: e.required.raw,
  11596. view: e.required.constant("list"),
  11597. label: e.optional.string
  11598. });
  11599. return t ? { params: t } : null;
  11600. },
  11601. controller(n) {
  11602. const e = new yn(Ls(n.params.options)), t = ee(n.params.value, {
  11603. constraint: e
  11604. }), l = new xn(n.document, {
  11605. props: new X2({
  11606. options: e.values.value("options")
  11607. }),
  11608. value: t,
  11609. viewProps: n.viewProps
  11610. });
  11611. return new Ht(n.document, {
  11612. blade: n.blade,
  11613. props: X2.fromObject({
  11614. label: n.params.label
  11615. }),
  11616. valueController: l
  11617. });
  11618. },
  11619. api(n) {
  11620. return !(n.controller instanceof Ht) || !(n.controller.valueController instanceof xn) ? null : new la(n.controller);
  11621. }
  11622. };
  11623. }();
  11624. function Hc(n) {
  11625. return n.reduce((e, t) => Object.assign(e, {
  11626. [t.presetKey]: t.read()
  11627. }), {});
  11628. }
  11629. function Kc(n, e) {
  11630. n.forEach((t) => {
  11631. const l = e[t.target.presetKey];
  11632. l !== void 0 && t.writer(t.target, t.reader(l));
  11633. });
  11634. }
  11635. class $c extends yi {
  11636. /**
  11637. * @hidden
  11638. */
  11639. constructor(e, t) {
  11640. super(e, t);
  11641. }
  11642. get element() {
  11643. return this.controller_.view.element;
  11644. }
  11645. /**
  11646. * Imports a preset of all inputs.
  11647. * @param preset The preset object to import.
  11648. */
  11649. importPreset(e) {
  11650. const t = this.controller_.rackController.rack.find(Ge).map((l) => l.binding);
  11651. Kc(t, e), this.refresh();
  11652. }
  11653. /**
  11654. * Exports a preset of all inputs.
  11655. * @return An exported preset object.
  11656. */
  11657. exportPreset() {
  11658. const e = this.controller_.rackController.rack.find(Ge).map((t) => t.binding.target);
  11659. return Hc(e);
  11660. }
  11661. /**
  11662. * Refreshes all bindings of the pane.
  11663. */
  11664. refresh() {
  11665. this.controller_.rackController.rack.find(Ge).forEach((e) => {
  11666. e.binding.read();
  11667. }), this.controller_.rackController.rack.find(at2).forEach((e) => {
  11668. e.binding.read();
  11669. });
  11670. }
  11671. }
  11672. class Xc extends Qn {
  11673. constructor(e, t) {
  11674. super(e, {
  11675. expanded: t.expanded,
  11676. blade: t.blade,
  11677. props: t.props,
  11678. root: true,
  11679. viewProps: t.viewProps
  11680. });
  11681. }
  11682. }
  11683. const Yc = {
  11684. id: "slider",
  11685. type: "blade",
  11686. accept(n) {
  11687. const e = A2, t = ae(n, {
  11688. max: e.required.number,
  11689. min: e.required.number,
  11690. view: e.required.constant("slider"),
  11691. format: e.optional.function,
  11692. label: e.optional.string,
  11693. value: e.optional.number
  11694. });
  11695. return t ? { params: t } : null;
  11696. },
  11697. controller(n) {
  11698. var e, t;
  11699. const l = (e = n.params.value) !== null && e !== void 0 ? e : 0, b = new Yt({
  11700. max: n.params.max,
  11701. min: n.params.min
  11702. }), E = new ii(n.document, {
  11703. baseStep: 1,
  11704. parser: ct2,
  11705. sliderProps: new X2({
  11706. maxValue: b.values.value("max"),
  11707. minValue: b.values.value("min")
  11708. }),
  11709. textProps: X2.fromObject({
  11710. draggingScale: Ot(void 0, l),
  11711. formatter: (t = n.params.format) !== null && t !== void 0 ? t : Mr
  11712. }),
  11713. value: ee(l, {
  11714. constraint: b
  11715. }),
  11716. viewProps: n.viewProps
  11717. });
  11718. return new Ht(n.document, {
  11719. blade: n.blade,
  11720. props: X2.fromObject({
  11721. label: n.params.label
  11722. }),
  11723. valueController: E
  11724. });
  11725. },
  11726. api(n) {
  11727. return !(n.controller instanceof Ht) || !(n.controller.valueController instanceof ii) ? null : new ca(n.controller);
  11728. }
  11729. }, qc = function() {
  11730. return {
  11731. id: "text",
  11732. type: "blade",
  11733. accept(n) {
  11734. const e = A2, t = ae(n, {
  11735. parse: e.required.function,
  11736. value: e.required.raw,
  11737. view: e.required.constant("text"),
  11738. format: e.optional.function,
  11739. label: e.optional.string
  11740. });
  11741. return t ? { params: t } : null;
  11742. },
  11743. controller(n) {
  11744. var e;
  11745. const t = new ei(n.document, {
  11746. parser: n.params.parse,
  11747. props: X2.fromObject({
  11748. formatter: (e = n.params.format) !== null && e !== void 0 ? e : (l) => String(l)
  11749. }),
  11750. value: ee(n.params.value),
  11751. viewProps: n.viewProps
  11752. });
  11753. return new Ht(n.document, {
  11754. blade: n.blade,
  11755. props: X2.fromObject({
  11756. label: n.params.label
  11757. }),
  11758. valueController: t
  11759. });
  11760. },
  11761. api(n) {
  11762. return !(n.controller instanceof Ht) || !(n.controller.valueController instanceof ei) ? null : new ua(n.controller);
  11763. }
  11764. };
  11765. }();
  11766. function Qc(n) {
  11767. const e = n.createElement("div");
  11768. return e.classList.add(D2("dfw")()), n.body && n.body.appendChild(e), e;
  11769. }
  11770. function pa(n, e, t) {
  11771. if (n.querySelector(`style[data-tp-style=${e}]`))
  11772. return;
  11773. const l = n.createElement("style");
  11774. l.dataset.tpStyle = e, l.textContent = t, n.head.appendChild(l);
  11775. }
  11776. class Zc extends $c {
  11777. constructor(e) {
  11778. var t, l;
  11779. const b = e ?? {}, E = (t = b.document) !== null && t !== void 0 ? t : bi(), k = Oc(), j = new Xc(E, {
  11780. expanded: b.expanded,
  11781. blade: Ee2(),
  11782. props: X2.fromObject({
  11783. title: b.title
  11784. }),
  11785. viewProps: Ze2.create()
  11786. });
  11787. super(j, k), this.pool_ = k, this.containerElem_ = (l = b.container) !== null && l !== void 0 ? l : Qc(E), this.containerElem_.appendChild(this.element), this.doc_ = E, this.usesDefaultWrapper_ = !b.container, this.setUpDefaultPlugins_();
  11788. }
  11789. get document() {
  11790. if (!this.doc_)
  11791. throw S.alreadyDisposed();
  11792. return this.doc_;
  11793. }
  11794. dispose() {
  11795. const e = this.containerElem_;
  11796. if (!e)
  11797. throw S.alreadyDisposed();
  11798. if (this.usesDefaultWrapper_) {
  11799. const t = e.parentElement;
  11800. t && t.removeChild(e);
  11801. }
  11802. this.containerElem_ = null, this.doc_ = null, super.dispose();
  11803. }
  11804. registerPlugin(e) {
  11805. ("plugin" in e ? [e.plugin] : "plugins" in e ? e.plugins : []).forEach((l) => {
  11806. this.pool_.register(l), this.embedPluginStyle_(l);
  11807. });
  11808. }
  11809. embedPluginStyle_(e) {
  11810. e.css && pa(this.document, `plugin-${e.id}`, e.css);
  11811. }
  11812. setUpDefaultPlugins_() {
  11813. pa(this.document, "default", '.tp-tbiv_b,.tp-coltxtv_ms,.tp-ckbv_i,.tp-rotv_b,.tp-fldv_b,.tp-mllv_i,.tp-sglv_i,.tp-grlv_g,.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw,.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-p2dv_b,.tp-btnv_b,.tp-lstv_s{background-color:var(--btn-bg);border-radius:var(--elm-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--bld-us);line-height:var(--bld-us);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-p2dv_b:hover,.tp-btnv_b:hover,.tp-lstv_s:hover{background-color:var(--btn-bg-h)}.tp-p2dv_b:focus,.tp-btnv_b:focus,.tp-lstv_s:focus{background-color:var(--btn-bg-f)}.tp-p2dv_b:active,.tp-btnv_b:active,.tp-lstv_s:active{background-color:var(--btn-bg-a)}.tp-p2dv_b:disabled,.tp-btnv_b:disabled,.tp-lstv_s:disabled{opacity:.5}.tp-txtv_i,.tp-p2dpv_p,.tp-colswv_sw{background-color:var(--in-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--bld-us);line-height:var(--bld-us);min-width:0;width:100%}.tp-txtv_i:hover,.tp-p2dpv_p:hover,.tp-colswv_sw:hover{background-color:var(--in-bg-h)}.tp-txtv_i:focus,.tp-p2dpv_p:focus,.tp-colswv_sw:focus{background-color:var(--in-bg-f)}.tp-txtv_i:active,.tp-p2dpv_p:active,.tp-colswv_sw:active{background-color:var(--in-bg-a)}.tp-txtv_i:disabled,.tp-p2dpv_p:disabled,.tp-colswv_sw:disabled{opacity:.5}.tp-mllv_i,.tp-sglv_i,.tp-grlv_g{background-color:var(--mo-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--mo-fg);height:var(--bld-us);scrollbar-color:currentColor rgba(0,0,0,0);scrollbar-width:thin;width:100%}.tp-mllv_i::-webkit-scrollbar,.tp-sglv_i::-webkit-scrollbar,.tp-grlv_g::-webkit-scrollbar{height:8px;width:8px}.tp-mllv_i::-webkit-scrollbar-corner,.tp-sglv_i::-webkit-scrollbar-corner,.tp-grlv_g::-webkit-scrollbar-corner{background-color:rgba(0,0,0,0)}.tp-mllv_i::-webkit-scrollbar-thumb,.tp-sglv_i::-webkit-scrollbar-thumb,.tp-grlv_g::-webkit-scrollbar-thumb{background-clip:padding-box;background-color:currentColor;border:rgba(0,0,0,0) solid 2px;border-radius:4px}.tp-rotv{--font-family: var(--tp-font-family, Roboto Mono, Source Code Pro, Menlo, Courier, monospace);--bs-br: var(--tp-base-border-radius, 6px);--cnt-h-p: var(--tp-container-horizontal-padding, 4px);--cnt-v-p: var(--tp-container-vertical-padding, 4px);--elm-br: var(--tp-element-border-radius, 2px);--bld-s: var(--tp-blade-spacing, 4px);--bld-us: var(--tp-blade-unit-size, 20px);--bs-bg: var(--tp-base-background-color, hsl(230, 7%, 17%));--bs-sh: var(--tp-base-shadow-color, rgba(0, 0, 0, 0.2));--btn-bg: var(--tp-button-background-color, hsl(230, 7%, 70%));--btn-bg-a: var(--tp-button-background-color-active, #d6d7db);--btn-bg-f: var(--tp-button-background-color-focus, #c8cad0);--btn-bg-h: var(--tp-button-background-color-hover, #bbbcc4);--btn-fg: var(--tp-button-foreground-color, hsl(230, 7%, 17%));--cnt-bg: var(--tp-container-background-color, rgba(187, 188, 196, 0.1));--cnt-bg-a: var(--tp-container-background-color-active, rgba(187, 188, 196, 0.25));--cnt-bg-f: var(--tp-container-background-color-focus, rgba(187, 188, 196, 0.2));--cnt-bg-h: var(--tp-container-background-color-hover, rgba(187, 188, 196, 0.15));--cnt-fg: var(--tp-container-foreground-color, hsl(230, 7%, 75%));--in-bg: var(--tp-input-background-color, rgba(187, 188, 196, 0.1));--in-bg-a: var(--tp-input-background-color-active, rgba(187, 188, 196, 0.25));--in-bg-f: var(--tp-input-background-color-focus, rgba(187, 188, 196, 0.2));--in-bg-h: var(--tp-input-background-color-hover, rgba(187, 188, 196, 0.15));--in-fg: var(--tp-input-foreground-color, hsl(230, 7%, 75%));--lbl-fg: var(--tp-label-foreground-color, rgba(187, 188, 196, 0.7));--mo-bg: var(--tp-monitor-background-color, rgba(0, 0, 0, 0.2));--mo-fg: var(--tp-monitor-foreground-color, rgba(187, 188, 196, 0.7));--grv-fg: var(--tp-groove-foreground-color, rgba(187, 188, 196, 0.1))}.tp-rotv_c>.tp-cntv.tp-v-lst,.tp-tabv_c .tp-brkv>.tp-cntv.tp-v-lst,.tp-fldv_c>.tp-cntv.tp-v-lst{margin-bottom:calc(-1*var(--cnt-v-p))}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-tabv_c .tp-brkv>.tp-fldv.tp-v-lst .tp-fldv_c,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_c{border-bottom-left-radius:0}.tp-rotv_c>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-tabv_c .tp-brkv>.tp-fldv.tp-v-lst .tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-v-lst .tp-fldv_b{border-bottom-left-radius:0}.tp-rotv_c>*:not(.tp-v-fst),.tp-tabv_c .tp-brkv>*:not(.tp-v-fst),.tp-fldv_c>*:not(.tp-v-fst){margin-top:var(--bld-s)}.tp-rotv_c>.tp-sprv:not(.tp-v-fst),.tp-tabv_c .tp-brkv>.tp-sprv:not(.tp-v-fst),.tp-fldv_c>.tp-sprv:not(.tp-v-fst),.tp-rotv_c>.tp-cntv:not(.tp-v-fst),.tp-tabv_c .tp-brkv>.tp-cntv:not(.tp-v-fst),.tp-fldv_c>.tp-cntv:not(.tp-v-fst){margin-top:var(--cnt-v-p)}.tp-rotv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-tabv_c .tp-brkv>.tp-sprv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-sprv+*:not(.tp-v-hidden),.tp-rotv_c>.tp-cntv+*:not(.tp-v-hidden),.tp-tabv_c .tp-brkv>.tp-cntv+*:not(.tp-v-hidden),.tp-fldv_c>.tp-cntv+*:not(.tp-v-hidden){margin-top:var(--cnt-v-p)}.tp-rotv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-tabv_c .tp-brkv>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-fldv_c>.tp-sprv:not(.tp-v-hidden)+.tp-sprv,.tp-rotv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-tabv_c .tp-brkv>.tp-cntv:not(.tp-v-hidden)+.tp-cntv,.tp-fldv_c>.tp-cntv:not(.tp-v-hidden)+.tp-cntv{margin-top:0}.tp-tabv_c .tp-brkv>.tp-cntv,.tp-fldv_c>.tp-cntv{margin-left:4px}.tp-tabv_c .tp-brkv>.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-fldv>.tp-fldv_b{border-top-left-radius:var(--elm-br);border-bottom-left-radius:var(--elm-br)}.tp-tabv_c .tp-brkv>.tp-fldv.tp-fldv-expanded>.tp-fldv_b,.tp-fldv_c>.tp-fldv.tp-fldv-expanded>.tp-fldv_b{border-bottom-left-radius:0}.tp-tabv_c .tp-brkv .tp-fldv>.tp-fldv_c,.tp-fldv_c .tp-fldv>.tp-fldv_c{border-bottom-left-radius:var(--elm-br)}.tp-tabv_c .tp-brkv>.tp-cntv+.tp-fldv>.tp-fldv_b,.tp-fldv_c>.tp-cntv+.tp-fldv>.tp-fldv_b{border-top-left-radius:0}.tp-tabv_c .tp-brkv>.tp-cntv+.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-cntv+.tp-tabv>.tp-tabv_t{border-top-left-radius:0}.tp-tabv_c .tp-brkv>.tp-tabv>.tp-tabv_t,.tp-fldv_c>.tp-tabv>.tp-tabv_t{border-top-left-radius:var(--elm-br)}.tp-tabv_c .tp-brkv .tp-tabv>.tp-tabv_c,.tp-fldv_c .tp-tabv>.tp-tabv_c{border-bottom-left-radius:var(--elm-br)}.tp-rotv_b,.tp-fldv_b{background-color:var(--cnt-bg);color:var(--cnt-fg);cursor:pointer;display:block;height:calc(var(--bld-us) + 4px);line-height:calc(var(--bld-us) + 4px);overflow:hidden;padding-left:var(--cnt-h-p);padding-right:calc(4px + var(--bld-us) + var(--cnt-h-p));position:relative;text-align:left;text-overflow:ellipsis;white-space:nowrap;width:100%;transition:border-radius .2s ease-in-out .2s}.tp-rotv_b:hover,.tp-fldv_b:hover{background-color:var(--cnt-bg-h)}.tp-rotv_b:focus,.tp-fldv_b:focus{background-color:var(--cnt-bg-f)}.tp-rotv_b:active,.tp-fldv_b:active{background-color:var(--cnt-bg-a)}.tp-rotv_b:disabled,.tp-fldv_b:disabled{opacity:.5}.tp-rotv_m,.tp-fldv_m{background:linear-gradient(to left, var(--cnt-fg), var(--cnt-fg) 2px, transparent 2px, transparent 4px, var(--cnt-fg) 4px);border-radius:2px;bottom:0;content:"";display:block;height:6px;right:calc(var(--cnt-h-p) + (var(--bld-us) + 4px - 6px)/2 - 2px);margin:auto;opacity:.5;position:absolute;top:0;transform:rotate(90deg);transition:transform .2s ease-in-out;width:6px}.tp-rotv.tp-rotv-expanded .tp-rotv_m,.tp-fldv.tp-fldv-expanded>.tp-fldv_b>.tp-fldv_m{transform:none}.tp-rotv_c,.tp-fldv_c{box-sizing:border-box;height:0;opacity:0;overflow:hidden;padding-bottom:0;padding-top:0;position:relative;transition:height .2s ease-in-out,opacity .2s linear,padding .2s ease-in-out}.tp-rotv.tp-rotv-cpl:not(.tp-rotv-expanded) .tp-rotv_c,.tp-fldv.tp-fldv-cpl:not(.tp-fldv-expanded)>.tp-fldv_c{display:none}.tp-rotv.tp-rotv-expanded .tp-rotv_c,.tp-fldv.tp-fldv-expanded>.tp-fldv_c{opacity:1;padding-bottom:var(--cnt-v-p);padding-top:var(--cnt-v-p);transform:none;overflow:visible;transition:height .2s ease-in-out,opacity .2s linear .2s,padding .2s ease-in-out}.tp-lstv,.tp-coltxtv_m{position:relative}.tp-lstv_s{padding:0 20px 0 4px;width:100%}.tp-lstv_m,.tp-coltxtv_mm{bottom:0;margin:auto;pointer-events:none;position:absolute;right:2px;top:0}.tp-lstv_m svg,.tp-coltxtv_mm svg{bottom:0;height:16px;margin:auto;position:absolute;right:0;top:0;width:16px}.tp-lstv_m svg path,.tp-coltxtv_mm svg path{fill:currentColor}.tp-pndtxtv,.tp-coltxtv_w{display:flex}.tp-pndtxtv_a,.tp-coltxtv_c{width:100%}.tp-pndtxtv_a+.tp-pndtxtv_a,.tp-coltxtv_c+.tp-pndtxtv_a,.tp-pndtxtv_a+.tp-coltxtv_c,.tp-coltxtv_c+.tp-coltxtv_c{margin-left:2px}.tp-btnv_b{width:100%}.tp-btnv_t{text-align:center}.tp-ckbv_l{display:block;position:relative}.tp-ckbv_i{left:0;opacity:0;position:absolute;top:0}.tp-ckbv_w{background-color:var(--in-bg);border-radius:var(--elm-br);cursor:pointer;display:block;height:var(--bld-us);position:relative;width:var(--bld-us)}.tp-ckbv_w svg{bottom:0;display:block;height:16px;left:0;margin:auto;opacity:0;position:absolute;right:0;top:0;width:16px}.tp-ckbv_w svg path{fill:none;stroke:var(--in-fg);stroke-width:2}.tp-ckbv_i:hover+.tp-ckbv_w{background-color:var(--in-bg-h)}.tp-ckbv_i:focus+.tp-ckbv_w{background-color:var(--in-bg-f)}.tp-ckbv_i:active+.tp-ckbv_w{background-color:var(--in-bg-a)}.tp-ckbv_i:checked+.tp-ckbv_w svg{opacity:1}.tp-ckbv.tp-v-disabled .tp-ckbv_w{opacity:.5}.tp-colv{position:relative}.tp-colv_h{display:flex}.tp-colv_s{flex-grow:0;flex-shrink:0;width:var(--bld-us)}.tp-colv_t{flex:1;margin-left:4px}.tp-colv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-colv.tp-colv-expanded.tp-colv-cpl .tp-colv_p{overflow:visible}.tp-colv.tp-colv-expanded .tp-colv_p{margin-top:var(--bld-s);opacity:1}.tp-colv .tp-popv{left:calc(-1*var(--cnt-h-p));right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-colpv_h,.tp-colpv_ap{margin-left:6px;margin-right:6px}.tp-colpv_h{margin-top:var(--bld-s)}.tp-colpv_rgb{display:flex;margin-top:var(--bld-s);width:100%}.tp-colpv_a{display:flex;margin-top:var(--cnt-v-p);padding-top:calc(var(--cnt-v-p) + 2px);position:relative}.tp-colpv_a::before{background-color:var(--grv-fg);content:"";height:2px;left:calc(-1*var(--cnt-h-p));position:absolute;right:calc(-1*var(--cnt-h-p));top:0}.tp-colpv.tp-v-disabled .tp-colpv_a::before{opacity:.5}.tp-colpv_ap{align-items:center;display:flex;flex:3}.tp-colpv_at{flex:1;margin-left:4px}.tp-svpv{border-radius:var(--elm-br);outline:none;overflow:hidden;position:relative}.tp-svpv.tp-v-disabled{opacity:.5}.tp-svpv_c{cursor:crosshair;display:block;height:calc(var(--bld-us)*4);width:100%}.tp-svpv_m{border-radius:100%;border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;filter:drop-shadow(0 0 1px rgba(0, 0, 0, 0.3));height:12px;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;width:12px}.tp-svpv:focus .tp-svpv_m{border-color:#fff}.tp-hplv{cursor:pointer;height:var(--bld-us);outline:none;position:relative}.tp-hplv.tp-v-disabled{opacity:.5}.tp-hplv_c{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAABCAYAAABubagXAAAAQ0lEQVQoU2P8z8Dwn0GCgQEDi2OK/RBgYHjBgIpfovFh8j8YBIgzFGQxuqEgPhaDOT5gOhPkdCxOZeBg+IDFZZiGAgCaSSMYtcRHLgAAAABJRU5ErkJggg==);background-position:left top;background-repeat:no-repeat;background-size:100% 100%;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;position:absolute;top:50%;width:100%}.tp-hplv_m{border-radius:var(--elm-br);border:rgba(255,255,255,.75) solid 2px;box-shadow:0 0 2px rgba(0,0,0,.1);box-sizing:border-box;height:12px;left:50%;margin-left:-6px;margin-top:-6px;pointer-events:none;position:absolute;top:50%;width:12px}.tp-hplv:focus .tp-hplv_m{border-color:#fff}.tp-aplv{cursor:pointer;height:var(--bld-us);outline:none;position:relative;width:100%}.tp-aplv.tp-v-disabled{opacity:.5}.tp-aplv_b{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:4px 4px;background-position:0 0,2px 2px;border-radius:2px;display:block;height:4px;left:0;margin-top:-2px;overflow:hidden;position:absolute;top:50%;width:100%}.tp-aplv_c{bottom:0;left:0;position:absolute;right:0;top:0}.tp-aplv_m{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:12px 12px;background-position:0 0,6px 6px;border-radius:var(--elm-br);box-shadow:0 0 2px rgba(0,0,0,.1);height:12px;left:50%;margin-left:-6px;margin-top:-6px;overflow:hidden;pointer-events:none;position:absolute;top:50%;width:12px}.tp-aplv_p{border-radius:var(--elm-br);border:rgba(255,255,255,.75) solid 2px;box-sizing:border-box;bottom:0;left:0;position:absolute;right:0;top:0}.tp-aplv:focus .tp-aplv_p{border-color:#fff}.tp-colswv{background-color:#fff;background-image:linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%),linear-gradient(to top right, #ddd 25%, transparent 25%, transparent 75%, #ddd 75%);background-size:10px 10px;background-position:0 0,5px 5px;border-radius:var(--elm-br);overflow:hidden}.tp-colswv.tp-v-disabled{opacity:.5}.tp-colswv_sw{border-radius:0}.tp-colswv_b{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;cursor:pointer;display:block;height:var(--bld-us);left:0;margin:0;outline:none;padding:0;position:absolute;top:0;width:var(--bld-us)}.tp-colswv_b:focus::after{border:rgba(255,255,255,.75) solid 2px;border-radius:var(--elm-br);bottom:0;content:"";display:block;left:0;position:absolute;right:0;top:0}.tp-coltxtv{display:flex;width:100%}.tp-coltxtv_m{margin-right:4px}.tp-coltxtv_ms{border-radius:var(--elm-br);color:var(--lbl-fg);cursor:pointer;height:var(--bld-us);line-height:var(--bld-us);padding:0 18px 0 4px}.tp-coltxtv_ms:hover{background-color:var(--in-bg-h)}.tp-coltxtv_ms:focus{background-color:var(--in-bg-f)}.tp-coltxtv_ms:active{background-color:var(--in-bg-a)}.tp-coltxtv_mm{color:var(--lbl-fg)}.tp-coltxtv.tp-v-disabled .tp-coltxtv_mm{opacity:.5}.tp-coltxtv_w{flex:1}.tp-dfwv{position:absolute;top:8px;right:8px;width:256px}.tp-fldv{position:relative}.tp-fldv.tp-fldv-not .tp-fldv_b{display:none}.tp-fldv_t{padding-left:4px}.tp-fldv_b:disabled .tp-fldv_m{display:none}.tp-fldv_c{padding-left:4px}.tp-fldv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--bld-us) + 4px);width:var(--bs-br)}.tp-fldv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-fldv_b:hover+.tp-fldv_i{color:var(--cnt-bg-h)}.tp-fldv_b:focus+.tp-fldv_i{color:var(--cnt-bg-f)}.tp-fldv_b:active+.tp-fldv_i{color:var(--cnt-bg-a)}.tp-fldv.tp-v-disabled>.tp-fldv_i{opacity:.5}.tp-grlv{position:relative}.tp-grlv_g{display:block;height:calc(var(--bld-us)*3)}.tp-grlv_g polyline{fill:none;stroke:var(--mo-fg);stroke-linejoin:round}.tp-grlv_t{margin-top:-4px;transition:left .05s,top .05s;visibility:hidden}.tp-grlv_t.tp-grlv_t-a{visibility:visible}.tp-grlv_t.tp-grlv_t-in{transition:none}.tp-grlv.tp-v-disabled .tp-grlv_g{opacity:.5}.tp-grlv .tp-ttv{background-color:var(--mo-fg)}.tp-grlv .tp-ttv::before{border-top-color:var(--mo-fg)}.tp-lblv{align-items:center;display:flex;line-height:1.3;padding-left:var(--cnt-h-p);padding-right:var(--cnt-h-p)}.tp-lblv.tp-lblv-nol{display:block}.tp-lblv_l{color:var(--lbl-fg);flex:1;-webkit-hyphens:auto;hyphens:auto;overflow:hidden;padding-left:4px;padding-right:16px}.tp-lblv.tp-v-disabled .tp-lblv_l{opacity:.5}.tp-lblv.tp-lblv-nol .tp-lblv_l{display:none}.tp-lblv_v{align-self:flex-start;flex-grow:0;flex-shrink:0;width:160px}.tp-lblv.tp-lblv-nol .tp-lblv_v{width:100%}.tp-lstv_s{padding:0 20px 0 4px;width:100%}.tp-lstv_m{color:var(--btn-fg)}.tp-sglv_i{padding:0 4px}.tp-sglv.tp-v-disabled .tp-sglv_i{opacity:.5}.tp-mllv_i{display:block;height:calc(var(--bld-us)*3);line-height:var(--bld-us);padding:0 4px;resize:none;white-space:pre}.tp-mllv.tp-v-disabled .tp-mllv_i{opacity:.5}.tp-p2dv{position:relative}.tp-p2dv_h{display:flex}.tp-p2dv_b{height:var(--bld-us);margin-right:4px;position:relative;width:var(--bld-us)}.tp-p2dv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-p2dv_b svg path{stroke:currentColor;stroke-width:2}.tp-p2dv_b svg circle{fill:currentColor}.tp-p2dv_t{flex:1}.tp-p2dv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-p2dv.tp-p2dv-expanded .tp-p2dv_p{margin-top:var(--bld-s);opacity:1}.tp-p2dv .tp-popv{left:calc(-1*var(--cnt-h-p));right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-p2dpv{padding-left:calc(var(--bld-us) + 4px)}.tp-p2dpv_p{cursor:crosshair;height:0;overflow:hidden;padding-bottom:100%;position:relative}.tp-p2dpv.tp-v-disabled .tp-p2dpv_p{opacity:.5}.tp-p2dpv_g{display:block;height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.tp-p2dpv_ax{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_l{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-p2dpv_m{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;position:absolute;width:4px}.tp-p2dpv_p:focus .tp-p2dpv_m{background-color:var(--in-fg);border-width:0}.tp-popv{background-color:var(--bs-bg);border-radius:6px;box-shadow:0 2px 4px var(--bs-sh);display:none;max-width:168px;padding:var(--cnt-v-p) var(--cnt-h-p);position:absolute;visibility:hidden;z-index:1000}.tp-popv.tp-popv-v{display:block;visibility:visible}.tp-sprv_r{background-color:var(--grv-fg);border-width:0;display:block;height:2px;margin:0;width:100%}.tp-sprv.tp-v-disabled .tp-sprv_r{opacity:.5}.tp-sldv.tp-v-disabled{opacity:.5}.tp-sldv_t{box-sizing:border-box;cursor:pointer;height:var(--bld-us);margin:0 6px;outline:none;position:relative}.tp-sldv_t::before{background-color:var(--in-bg);border-radius:1px;bottom:0;content:"";display:block;height:2px;left:0;margin:auto;position:absolute;right:0;top:0}.tp-sldv_k{height:100%;left:0;position:absolute;top:0}.tp-sldv_k::before{background-color:var(--in-fg);border-radius:1px;bottom:0;content:"";display:block;height:2px;left:0;margin-bottom:auto;margin-top:auto;position:absolute;right:0;top:0}.tp-sldv_k::after{background-color:var(--btn-bg);border-radius:var(--elm-br);bottom:0;content:"";display:block;height:12px;margin-bottom:auto;margin-top:auto;position:absolute;right:-6px;top:0;width:12px}.tp-sldv_t:hover .tp-sldv_k::after{background-color:var(--btn-bg-h)}.tp-sldv_t:focus .tp-sldv_k::after{background-color:var(--btn-bg-f)}.tp-sldv_t:active .tp-sldv_k::after{background-color:var(--btn-bg-a)}.tp-sldtxtv{display:flex}.tp-sldtxtv_s{flex:2}.tp-sldtxtv_t{flex:1;margin-left:4px}.tp-tabv{position:relative}.tp-tabv_t{align-items:flex-end;color:var(--cnt-bg);display:flex;overflow:hidden;position:relative}.tp-tabv_t:hover{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus){color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active){color:var(--cnt-bg-a)}.tp-tabv_t::before{background-color:currentColor;bottom:0;content:"";height:2px;left:0;pointer-events:none;position:absolute;right:0}.tp-tabv.tp-v-disabled .tp-tabv_t::before{opacity:.5}.tp-tabv.tp-tabv-nop .tp-tabv_t{height:calc(var(--bld-us) + 4px);position:relative}.tp-tabv.tp-tabv-nop .tp-tabv_t::before{background-color:var(--cnt-bg);bottom:0;content:"";height:2px;left:0;position:absolute;right:0}.tp-tabv_c{padding-bottom:var(--cnt-v-p);padding-left:4px;padding-top:var(--cnt-v-p)}.tp-tabv_i{bottom:0;color:var(--cnt-bg);left:0;overflow:hidden;position:absolute;top:calc(var(--bld-us) + 4px);width:var(--bs-br)}.tp-tabv_i::before{background-color:currentColor;bottom:0;content:"";left:0;position:absolute;top:0;width:4px}.tp-tabv_t:hover+.tp-tabv_i{color:var(--cnt-bg-h)}.tp-tabv_t:has(*:focus)+.tp-tabv_i{color:var(--cnt-bg-f)}.tp-tabv_t:has(*:active)+.tp-tabv_i{color:var(--cnt-bg-a)}.tp-tabv.tp-v-disabled>.tp-tabv_i{opacity:.5}.tp-tbiv{flex:1;min-width:0;position:relative}.tp-tbiv+.tp-tbiv{margin-left:2px}.tp-tbiv+.tp-tbiv.tp-v-disabled::before{opacity:.5}.tp-tbiv_b{display:block;padding-left:calc(var(--cnt-h-p) + 4px);padding-right:calc(var(--cnt-h-p) + 4px);position:relative;width:100%}.tp-tbiv_b:disabled{opacity:.5}.tp-tbiv_b::before{background-color:var(--cnt-bg);bottom:2px;content:"";left:0;pointer-events:none;position:absolute;right:0;top:0}.tp-tbiv_b:hover::before{background-color:var(--cnt-bg-h)}.tp-tbiv_b:focus::before{background-color:var(--cnt-bg-f)}.tp-tbiv_b:active::before{background-color:var(--cnt-bg-a)}.tp-tbiv_t{color:var(--cnt-fg);height:calc(var(--bld-us) + 4px);line-height:calc(var(--bld-us) + 4px);opacity:.5;overflow:hidden;text-overflow:ellipsis}.tp-tbiv.tp-tbiv-sel .tp-tbiv_t{opacity:1}.tp-txtv{position:relative}.tp-txtv_i{padding:0 4px}.tp-txtv.tp-txtv-fst .tp-txtv_i{border-bottom-right-radius:0;border-top-right-radius:0}.tp-txtv.tp-txtv-mid .tp-txtv_i{border-radius:0}.tp-txtv.tp-txtv-lst .tp-txtv_i{border-bottom-left-radius:0;border-top-left-radius:0}.tp-txtv.tp-txtv-num .tp-txtv_i{text-align:right}.tp-txtv.tp-txtv-drg .tp-txtv_i{opacity:.3}.tp-txtv_k{cursor:pointer;height:100%;left:-3px;position:absolute;top:0;width:12px}.tp-txtv_k::before{background-color:var(--in-fg);border-radius:1px;bottom:0;content:"";height:calc(var(--bld-us) - 4px);left:50%;margin-bottom:auto;margin-left:-1px;margin-top:auto;opacity:.1;position:absolute;top:0;transition:border-radius .1s,height .1s,transform .1s,width .1s;width:2px}.tp-txtv_k:hover::before,.tp-txtv.tp-txtv-drg .tp-txtv_k::before{opacity:1}.tp-txtv.tp-txtv-drg .tp-txtv_k::before{border-radius:50%;height:4px;transform:translateX(-1px);width:4px}.tp-txtv_g{bottom:0;display:block;height:8px;left:50%;margin:auto;overflow:visible;pointer-events:none;position:absolute;top:0;visibility:hidden;width:100%}.tp-txtv.tp-txtv-drg .tp-txtv_g{visibility:visible}.tp-txtv_gb{fill:none;stroke:var(--in-fg);stroke-dasharray:1}.tp-txtv_gh{fill:none;stroke:var(--in-fg)}.tp-txtv .tp-ttv{margin-left:6px;visibility:hidden}.tp-txtv.tp-txtv-drg .tp-ttv{visibility:visible}.tp-ttv{background-color:var(--in-fg);border-radius:var(--elm-br);color:var(--bs-bg);padding:2px 4px;pointer-events:none;position:absolute;transform:translate(-50%, -100%)}.tp-ttv::before{border-color:var(--in-fg) rgba(0,0,0,0) rgba(0,0,0,0) rgba(0,0,0,0);border-style:solid;border-width:2px;box-sizing:border-box;content:"";font-size:.9em;height:4px;left:50%;margin-left:-2px;position:absolute;top:100%;width:4px}.tp-rotv{background-color:var(--bs-bg);border-radius:var(--bs-br);box-shadow:0 2px 4px var(--bs-sh);font-family:var(--font-family);font-size:11px;font-weight:500;line-height:1;text-align:left}.tp-rotv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br);border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br);padding-left:calc(4px + var(--bld-us) + var(--cnt-h-p));text-align:center}.tp-rotv.tp-rotv-expanded .tp-rotv_b{border-bottom-left-radius:0;border-bottom-right-radius:0}.tp-rotv.tp-rotv-not .tp-rotv_b{display:none}.tp-rotv_b:disabled .tp-rotv_m{display:none}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst>.tp-fldv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv_c>.tp-fldv.tp-v-lst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c .tp-fldv.tp-v-vlst:not(.tp-fldv-expanded)>.tp-fldv_b{border-bottom-right-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst{margin-top:calc(-1*var(--cnt-v-p))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-fldv.tp-v-fst>.tp-fldv_b{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_c{border-bottom-left-radius:var(--bs-br);border-bottom-right-radius:var(--bs-br)}.tp-rotv_c>.tp-tabv.tp-v-lst>.tp-tabv_i{border-bottom-left-radius:var(--bs-br)}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst{margin-top:calc(-1*var(--cnt-v-p))}.tp-rotv.tp-rotv-not .tp-rotv_c>.tp-tabv.tp-v-fst>.tp-tabv_t{border-top-left-radius:var(--bs-br);border-top-right-radius:var(--bs-br)}.tp-rotv.tp-v-disabled,.tp-rotv .tp-v-disabled{pointer-events:none}.tp-rotv.tp-v-hidden,.tp-rotv .tp-v-hidden{display:none}'), this.pool_.getAll().forEach((e) => {
  11814. this.embedPluginStyle_(e);
  11815. }), this.registerPlugin({
  11816. plugins: [
  11817. Yc,
  11818. Gc,
  11819. Ti,
  11820. qc
  11821. ]
  11822. });
  11823. }
  11824. }
  11825. const Wc = new r("3.1.9");
  11826. s.BladeApi = o, s.ButtonApi = O, s.FolderApi = yi, s.InputBindingApi = _i, s.ListApi = la, s.MonitorBindingApi = wi, s.Pane = Zc, s.SeparatorApi = us, s.SliderApi = ca, s.TabApi = hs, s.TabPageApi = Pi, s.TextApi = ua, s.TpChangeEvent = p2, s.VERSION = Wc, Object.defineProperty(s, "__esModule", { value: true });
  11827. });
  11828. })(wo, wo.exports);
  11829. var Ad = wo.exports;
  11830. var yo = { exports: {} };
  11831. (function(f, i) {
  11832. (function(s, r) {
  11833. r(i);
  11834. })(il, function(s) {
  11835. class r {
  11836. constructor(a) {
  11837. this.controller_ = a;
  11838. }
  11839. get element() {
  11840. return this.controller_.view.element;
  11841. }
  11842. get disabled() {
  11843. return this.controller_.viewProps.get("disabled");
  11844. }
  11845. set disabled(a) {
  11846. this.controller_.viewProps.set("disabled", a);
  11847. }
  11848. get hidden() {
  11849. return this.controller_.viewProps.get("hidden");
  11850. }
  11851. set hidden(a) {
  11852. this.controller_.viewProps.set("hidden", a);
  11853. }
  11854. dispose() {
  11855. this.controller_.viewProps.set("disposed", true);
  11856. }
  11857. }
  11858. class o {
  11859. constructor(a) {
  11860. this.target = a;
  11861. }
  11862. }
  11863. class c extends o {
  11864. constructor(a, u, v, x) {
  11865. super(a), this.value = u, this.presetKey = v, this.last = x ?? true;
  11866. }
  11867. }
  11868. function p2(d) {
  11869. return d;
  11870. }
  11871. function h2(d) {
  11872. return d == null;
  11873. }
  11874. const m = {
  11875. alreadydisposed: () => "View has been already disposed",
  11876. invalidparams: (d) => `Invalid parameters for '${d.name}'`,
  11877. nomatchingcontroller: (d) => `No matching controller for '${d.key}'`,
  11878. nomatchingview: (d) => `No matching view for '${JSON.stringify(d.params)}'`,
  11879. notbindable: () => "Value is not bindable",
  11880. propertynotfound: (d) => `Property '${d.name}' not found`,
  11881. shouldneverhappen: () => "This error should never happen"
  11882. };
  11883. class g {
  11884. constructor(a) {
  11885. var u;
  11886. this.message = (u = m[a.type](a.context)) !== null && u !== void 0 ? u : "Unexpected error", this.name = this.constructor.name, this.stack = new Error(this.message).stack, this.type = a.type;
  11887. }
  11888. static alreadyDisposed() {
  11889. return new g({ type: "alreadydisposed" });
  11890. }
  11891. static notBindable() {
  11892. return new g({
  11893. type: "notbindable"
  11894. });
  11895. }
  11896. static propertyNotFound(a) {
  11897. return new g({
  11898. type: "propertynotfound",
  11899. context: {
  11900. name: a
  11901. }
  11902. });
  11903. }
  11904. static shouldNeverHappen() {
  11905. return new g({ type: "shouldneverhappen" });
  11906. }
  11907. }
  11908. class w {
  11909. constructor() {
  11910. this.observers_ = {};
  11911. }
  11912. on(a, u) {
  11913. let v = this.observers_[a];
  11914. return v || (v = this.observers_[a] = []), v.push({
  11915. handler: u
  11916. }), this;
  11917. }
  11918. off(a, u) {
  11919. const v = this.observers_[a];
  11920. return v && (this.observers_[a] = v.filter((x) => x.handler !== u)), this;
  11921. }
  11922. emit(a, u) {
  11923. const v = this.observers_[a];
  11924. v && v.forEach((x) => {
  11925. x.handler(u);
  11926. });
  11927. }
  11928. }
  11929. const _2 = "tp";
  11930. function y(d) {
  11931. return (u, v) => [
  11932. _2,
  11933. "-",
  11934. d,
  11935. "v",
  11936. u ? `_${u}` : "",
  11937. v ? `-${v}` : ""
  11938. ].join("");
  11939. }
  11940. function C(d, a) {
  11941. return (u) => a(d(u));
  11942. }
  11943. function L(d) {
  11944. return d.rawValue;
  11945. }
  11946. function S(d, a) {
  11947. d.emitter.on("change", C(L, a)), a(d.rawValue);
  11948. }
  11949. function R(d, a, u) {
  11950. S(d.value(a), u);
  11951. }
  11952. function O(d, a, u) {
  11953. u ? d.classList.add(a) : d.classList.remove(a);
  11954. }
  11955. function N(d, a) {
  11956. return (u) => {
  11957. O(d, a, u);
  11958. };
  11959. }
  11960. function I2(d, a) {
  11961. S(d, (u) => {
  11962. a.textContent = u ?? "";
  11963. });
  11964. }
  11965. const D2 = y("btn");
  11966. class Y {
  11967. constructor(a, u) {
  11968. this.element = a.createElement("div"), this.element.classList.add(D2()), u.viewProps.bindClassModifiers(this.element);
  11969. const v = a.createElement("button");
  11970. v.classList.add(D2("b")), u.viewProps.bindDisabled(v), this.element.appendChild(v), this.buttonElement = v;
  11971. const x = a.createElement("div");
  11972. x.classList.add(D2("t")), I2(u.props.value("title"), x), this.buttonElement.appendChild(x);
  11973. }
  11974. }
  11975. class G {
  11976. constructor(a, u) {
  11977. this.emitter = new w(), this.onClick_ = this.onClick_.bind(this), this.props = u.props, this.viewProps = u.viewProps, this.view = new Y(a, {
  11978. props: this.props,
  11979. viewProps: this.viewProps
  11980. }), this.view.buttonElement.addEventListener("click", this.onClick_);
  11981. }
  11982. onClick_() {
  11983. this.emitter.emit("click", {
  11984. sender: this
  11985. });
  11986. }
  11987. }
  11988. class F {
  11989. constructor(a, u) {
  11990. var v;
  11991. this.constraint_ = u == null ? void 0 : u.constraint, this.equals_ = (v = u == null ? void 0 : u.equals) !== null && v !== void 0 ? v : (x, T) => x === T, this.emitter = new w(), this.rawValue_ = a;
  11992. }
  11993. get constraint() {
  11994. return this.constraint_;
  11995. }
  11996. get rawValue() {
  11997. return this.rawValue_;
  11998. }
  11999. set rawValue(a) {
  12000. this.setRawValue(a, {
  12001. forceEmit: false,
  12002. last: true
  12003. });
  12004. }
  12005. setRawValue(a, u) {
  12006. const v = u ?? {
  12007. forceEmit: false,
  12008. last: true
  12009. }, x = this.constraint_ ? this.constraint_.constrain(a) : a, T = this.rawValue_;
  12010. this.equals_(T, x) && !v.forceEmit || (this.emitter.emit("beforechange", {
  12011. sender: this
  12012. }), this.rawValue_ = x, this.emitter.emit("change", {
  12013. options: v,
  12014. previousRawValue: T,
  12015. rawValue: x,
  12016. sender: this
  12017. }));
  12018. }
  12019. }
  12020. class B {
  12021. constructor(a) {
  12022. this.emitter = new w(), this.value_ = a;
  12023. }
  12024. get rawValue() {
  12025. return this.value_;
  12026. }
  12027. set rawValue(a) {
  12028. this.setRawValue(a, {
  12029. forceEmit: false,
  12030. last: true
  12031. });
  12032. }
  12033. setRawValue(a, u) {
  12034. const v = u ?? {
  12035. forceEmit: false,
  12036. last: true
  12037. }, x = this.value_;
  12038. x === a && !v.forceEmit || (this.emitter.emit("beforechange", {
  12039. sender: this
  12040. }), this.value_ = a, this.emitter.emit("change", {
  12041. options: v,
  12042. previousRawValue: x,
  12043. rawValue: this.value_,
  12044. sender: this
  12045. }));
  12046. }
  12047. }
  12048. function H2(d, a) {
  12049. const u = a == null ? void 0 : a.constraint, v = a == null ? void 0 : a.equals;
  12050. return !u && !v ? new B(d) : new F(d, a);
  12051. }
  12052. class K2 {
  12053. constructor(a) {
  12054. this.emitter = new w(), this.valMap_ = a;
  12055. for (const u in this.valMap_)
  12056. this.valMap_[u].emitter.on("change", () => {
  12057. this.emitter.emit("change", {
  12058. key: u,
  12059. sender: this
  12060. });
  12061. });
  12062. }
  12063. static createCore(a) {
  12064. return Object.keys(a).reduce((v, x) => Object.assign(v, {
  12065. [x]: H2(a[x])
  12066. }), {});
  12067. }
  12068. static fromObject(a) {
  12069. const u = this.createCore(a);
  12070. return new K2(u);
  12071. }
  12072. get(a) {
  12073. return this.valMap_[a].rawValue;
  12074. }
  12075. set(a, u) {
  12076. this.valMap_[a].rawValue = u;
  12077. }
  12078. value(a) {
  12079. return this.valMap_[a];
  12080. }
  12081. }
  12082. function q(d, a) {
  12083. const v = Object.keys(a).reduce((x, T) => {
  12084. if (x === void 0)
  12085. return;
  12086. const V2 = a[T], z = V2(d[T]);
  12087. return z.succeeded ? Object.assign(Object.assign({}, x), { [T]: z.value }) : void 0;
  12088. }, {});
  12089. return v;
  12090. }
  12091. function pe(d, a) {
  12092. return d.reduce((u, v) => {
  12093. if (u === void 0)
  12094. return;
  12095. const x = a(v);
  12096. if (!(!x.succeeded || x.value === void 0))
  12097. return [...u, x.value];
  12098. }, []);
  12099. }
  12100. function _e(d) {
  12101. return d === null ? false : typeof d == "object";
  12102. }
  12103. function ce2(d) {
  12104. return (a) => (u) => {
  12105. if (!a && u === void 0)
  12106. return {
  12107. succeeded: false,
  12108. value: void 0
  12109. };
  12110. if (a && u === void 0)
  12111. return {
  12112. succeeded: true,
  12113. value: void 0
  12114. };
  12115. const v = d(u);
  12116. return v !== void 0 ? {
  12117. succeeded: true,
  12118. value: v
  12119. } : {
  12120. succeeded: false,
  12121. value: void 0
  12122. };
  12123. };
  12124. }
  12125. function me(d) {
  12126. return {
  12127. custom: (a) => ce2(a)(d),
  12128. boolean: ce2((a) => typeof a == "boolean" ? a : void 0)(d),
  12129. number: ce2((a) => typeof a == "number" ? a : void 0)(d),
  12130. string: ce2((a) => typeof a == "string" ? a : void 0)(d),
  12131. function: ce2((a) => typeof a == "function" ? a : void 0)(d),
  12132. constant: (a) => ce2((u) => u === a ? a : void 0)(d),
  12133. raw: ce2((a) => a)(d),
  12134. object: (a) => ce2((u) => {
  12135. if (_e(u))
  12136. return q(u, a);
  12137. })(d),
  12138. array: (a) => ce2((u) => {
  12139. if (Array.isArray(u))
  12140. return pe(u, a);
  12141. })(d)
  12142. };
  12143. }
  12144. const he = {
  12145. optional: me(true),
  12146. required: me(false)
  12147. };
  12148. function ee(d, a) {
  12149. const u = he.required.object(a)(d);
  12150. return u.succeeded ? u.value : void 0;
  12151. }
  12152. function X2(d) {
  12153. console.warn([
  12154. `Missing '${d.key}' of ${d.target} in ${d.place}.`,
  12155. "Please rebuild plugins with the latest core package."
  12156. ].join(" "));
  12157. }
  12158. function Se2(d) {
  12159. return d && d.parentElement && d.parentElement.removeChild(d), null;
  12160. }
  12161. class fe2 {
  12162. constructor(a) {
  12163. this.value_ = a;
  12164. }
  12165. static create(a) {
  12166. return [
  12167. new fe2(a),
  12168. (u, v) => {
  12169. a.setRawValue(u, v);
  12170. }
  12171. ];
  12172. }
  12173. get emitter() {
  12174. return this.value_.emitter;
  12175. }
  12176. get rawValue() {
  12177. return this.value_.rawValue;
  12178. }
  12179. }
  12180. const oe2 = y("");
  12181. function ne(d, a) {
  12182. return N(d, oe2(void 0, a));
  12183. }
  12184. class ge extends K2 {
  12185. constructor(a) {
  12186. var u;
  12187. super(a), this.onDisabledChange_ = this.onDisabledChange_.bind(this), this.onParentChange_ = this.onParentChange_.bind(this), this.onParentGlobalDisabledChange_ = this.onParentGlobalDisabledChange_.bind(this), [this.globalDisabled_, this.setGlobalDisabled_] = fe2.create(H2(this.getGlobalDisabled_())), this.value("disabled").emitter.on("change", this.onDisabledChange_), this.value("parent").emitter.on("change", this.onParentChange_), (u = this.get("parent")) === null || u === void 0 || u.globalDisabled.emitter.on("change", this.onParentGlobalDisabledChange_);
  12188. }
  12189. static create(a) {
  12190. var u, v, x;
  12191. const T = a ?? {};
  12192. return new ge(K2.createCore({
  12193. disabled: (u = T.disabled) !== null && u !== void 0 ? u : false,
  12194. disposed: false,
  12195. hidden: (v = T.hidden) !== null && v !== void 0 ? v : false,
  12196. parent: (x = T.parent) !== null && x !== void 0 ? x : null
  12197. }));
  12198. }
  12199. get globalDisabled() {
  12200. return this.globalDisabled_;
  12201. }
  12202. bindClassModifiers(a) {
  12203. S(this.globalDisabled_, ne(a, "disabled")), R(this, "hidden", ne(a, "hidden"));
  12204. }
  12205. bindDisabled(a) {
  12206. S(this.globalDisabled_, (u) => {
  12207. a.disabled = u;
  12208. });
  12209. }
  12210. bindTabIndex(a) {
  12211. S(this.globalDisabled_, (u) => {
  12212. a.tabIndex = u ? -1 : 0;
  12213. });
  12214. }
  12215. handleDispose(a) {
  12216. this.value("disposed").emitter.on("change", (u) => {
  12217. u && a();
  12218. });
  12219. }
  12220. getGlobalDisabled_() {
  12221. const a = this.get("parent");
  12222. return (a ? a.globalDisabled.rawValue : false) || this.get("disabled");
  12223. }
  12224. updateGlobalDisabled_() {
  12225. this.setGlobalDisabled_(this.getGlobalDisabled_());
  12226. }
  12227. onDisabledChange_() {
  12228. this.updateGlobalDisabled_();
  12229. }
  12230. onParentGlobalDisabledChange_() {
  12231. this.updateGlobalDisabled_();
  12232. }
  12233. onParentChange_(a) {
  12234. var u;
  12235. const v = a.previousRawValue;
  12236. v == null || v.globalDisabled.emitter.off("change", this.onParentGlobalDisabledChange_), (u = this.get("parent")) === null || u === void 0 || u.globalDisabled.emitter.on("change", this.onParentGlobalDisabledChange_), this.updateGlobalDisabled_();
  12237. }
  12238. }
  12239. function A2() {
  12240. return ["veryfirst", "first", "last", "verylast"];
  12241. }
  12242. const ae = y(""), Ne = {
  12243. veryfirst: "vfst",
  12244. first: "fst",
  12245. last: "lst",
  12246. verylast: "vlst"
  12247. };
  12248. class Ue {
  12249. constructor(a) {
  12250. this.parent_ = null, this.blade = a.blade, this.view = a.view, this.viewProps = a.viewProps;
  12251. const u = this.view.element;
  12252. this.blade.value("positions").emitter.on("change", () => {
  12253. A2().forEach((v) => {
  12254. u.classList.remove(ae(void 0, Ne[v]));
  12255. }), this.blade.get("positions").forEach((v) => {
  12256. u.classList.add(ae(void 0, Ne[v]));
  12257. });
  12258. }), this.viewProps.handleDispose(() => {
  12259. Se2(u);
  12260. });
  12261. }
  12262. get parent() {
  12263. return this.parent_;
  12264. }
  12265. set parent(a) {
  12266. if (this.parent_ = a, !("parent" in this.viewProps.valMap_)) {
  12267. X2({
  12268. key: "parent",
  12269. target: ge.name,
  12270. place: "BladeController.parent"
  12271. });
  12272. return;
  12273. }
  12274. this.viewProps.set("parent", this.parent_ ? this.parent_.viewProps : null);
  12275. }
  12276. }
  12277. const xe2 = "http://www.w3.org/2000/svg";
  12278. function rt2(d) {
  12279. d.offsetHeight;
  12280. }
  12281. function Un(d, a) {
  12282. const u = d.style.transition;
  12283. d.style.transition = "none", a(), d.style.transition = u;
  12284. }
  12285. function Ze2(d) {
  12286. return d.ontouchstart !== void 0;
  12287. }
  12288. function Gn(d) {
  12289. for (; d.childNodes.length > 0; )
  12290. d.removeChild(d.childNodes[0]);
  12291. }
  12292. function hn(d) {
  12293. return d.relatedTarget ? d.relatedTarget : "explicitOriginalTarget" in d ? d.explicitOriginalTarget : null;
  12294. }
  12295. const vt2 = y("lbl");
  12296. function At(d, a) {
  12297. const u = d.createDocumentFragment();
  12298. return a.split(`
  12299. `).map((x) => d.createTextNode(x)).forEach((x, T) => {
  12300. T > 0 && u.appendChild(d.createElement("br")), u.appendChild(x);
  12301. }), u;
  12302. }
  12303. class Ke {
  12304. constructor(a, u) {
  12305. this.element = a.createElement("div"), this.element.classList.add(vt2()), u.viewProps.bindClassModifiers(this.element);
  12306. const v = a.createElement("div");
  12307. v.classList.add(vt2("l")), R(u.props, "label", (T) => {
  12308. h2(T) ? this.element.classList.add(vt2(void 0, "nol")) : (this.element.classList.remove(vt2(void 0, "nol")), Gn(v), v.appendChild(At(a, T)));
  12309. }), this.element.appendChild(v), this.labelElement = v;
  12310. const x = a.createElement("div");
  12311. x.classList.add(vt2("v")), this.element.appendChild(x), this.valueElement = x;
  12312. }
  12313. }
  12314. class ot2 extends Ue {
  12315. constructor(a, u) {
  12316. const v = u.valueController.viewProps;
  12317. super(Object.assign(Object.assign({}, u), { view: new Ke(a, {
  12318. props: u.props,
  12319. viewProps: v
  12320. }), viewProps: v })), this.props = u.props, this.valueController = u.valueController, this.view.valueElement.appendChild(this.valueController.view.element);
  12321. }
  12322. }
  12323. class dn extends Ue {
  12324. constructor(a) {
  12325. super(a), this.value = a.value;
  12326. }
  12327. }
  12328. class bt2 extends K2 {
  12329. constructor(a) {
  12330. super(a);
  12331. }
  12332. static create(a) {
  12333. const u = {
  12334. completed: true,
  12335. expanded: a,
  12336. expandedHeight: null,
  12337. shouldFixHeight: false,
  12338. temporaryExpanded: null
  12339. }, v = K2.createCore(u);
  12340. return new bt2(v);
  12341. }
  12342. get styleExpanded() {
  12343. var a;
  12344. return (a = this.get("temporaryExpanded")) !== null && a !== void 0 ? a : this.get("expanded");
  12345. }
  12346. get styleHeight() {
  12347. if (!this.styleExpanded)
  12348. return "0";
  12349. const a = this.get("expandedHeight");
  12350. return this.get("shouldFixHeight") && !h2(a) ? `${a}px` : "auto";
  12351. }
  12352. bindExpandedClass(a, u) {
  12353. const v = () => {
  12354. this.styleExpanded ? a.classList.add(u) : a.classList.remove(u);
  12355. };
  12356. R(this, "expanded", v), R(this, "temporaryExpanded", v);
  12357. }
  12358. cleanUpTransition() {
  12359. this.set("shouldFixHeight", false), this.set("expandedHeight", null), this.set("completed", true);
  12360. }
  12361. }
  12362. function Hn(d) {
  12363. return bt2.create(d);
  12364. }
  12365. function bi(d, a) {
  12366. let u = 0;
  12367. return Un(a, () => {
  12368. d.set("expandedHeight", null), d.set("temporaryExpanded", true), rt2(a), u = a.clientHeight, d.set("temporaryExpanded", null), rt2(a);
  12369. }), u;
  12370. }
  12371. function Kn(d, a) {
  12372. a.style.height = d.styleHeight;
  12373. }
  12374. function $n(d, a) {
  12375. d.value("expanded").emitter.on("beforechange", () => {
  12376. d.set("completed", false), h2(d.get("expandedHeight")) && d.set("expandedHeight", bi(d, a)), d.set("shouldFixHeight", true), rt2(a);
  12377. }), d.emitter.on("change", () => {
  12378. Kn(d, a);
  12379. }), Kn(d, a), a.addEventListener("transitionend", (u) => {
  12380. u.propertyName === "height" && d.cleanUpTransition();
  12381. });
  12382. }
  12383. class Et2 {
  12384. constructor(a, u) {
  12385. const v = y(u.viewName);
  12386. this.element = a.createElement("div"), this.element.classList.add(v()), u.viewProps.bindClassModifiers(this.element);
  12387. }
  12388. }
  12389. class Mt extends dn {
  12390. constructor(a, u) {
  12391. const v = u.valueController.viewProps;
  12392. super(Object.assign(Object.assign({}, u), { value: u.valueController.value, view: new Ke(a, {
  12393. props: u.props,
  12394. viewProps: v
  12395. }), viewProps: v })), this.props = u.props, this.valueController = u.valueController, this.view.valueElement.appendChild(this.valueController.view.element);
  12396. }
  12397. }
  12398. class Xn {
  12399. constructor() {
  12400. this.disabled = false, this.emitter = new w();
  12401. }
  12402. dispose() {
  12403. }
  12404. tick() {
  12405. this.disabled || this.emitter.emit("tick", {
  12406. sender: this
  12407. });
  12408. }
  12409. }
  12410. class mn {
  12411. constructor(a, u) {
  12412. this.disabled_ = false, this.timerId_ = null, this.onTick_ = this.onTick_.bind(this), this.doc_ = a, this.emitter = new w(), this.interval_ = u, this.setTimer_();
  12413. }
  12414. get disabled() {
  12415. return this.disabled_;
  12416. }
  12417. set disabled(a) {
  12418. this.disabled_ = a, this.disabled_ ? this.clearTimer_() : this.setTimer_();
  12419. }
  12420. dispose() {
  12421. this.clearTimer_();
  12422. }
  12423. clearTimer_() {
  12424. if (this.timerId_ === null)
  12425. return;
  12426. const a = this.doc_.defaultView;
  12427. a && a.clearInterval(this.timerId_), this.timerId_ = null;
  12428. }
  12429. setTimer_() {
  12430. if (this.clearTimer_(), this.interval_ <= 0)
  12431. return;
  12432. const a = this.doc_.defaultView;
  12433. a && (this.timerId_ = a.setInterval(this.onTick_, this.interval_));
  12434. }
  12435. onTick_() {
  12436. this.disabled_ || this.emitter.emit("tick", {
  12437. sender: this
  12438. });
  12439. }
  12440. }
  12441. class Yn {
  12442. constructor(a) {
  12443. this.constraints = a;
  12444. }
  12445. constrain(a) {
  12446. return this.constraints.reduce((u, v) => v.constrain(u), a);
  12447. }
  12448. }
  12449. function Ct(d, a) {
  12450. if (d instanceof a)
  12451. return d;
  12452. if (d instanceof Yn) {
  12453. const u = d.constraints.reduce((v, x) => v || (x instanceof a ? x : null), null);
  12454. if (u)
  12455. return u;
  12456. }
  12457. return null;
  12458. }
  12459. class gt2 {
  12460. constructor(a) {
  12461. this.values = K2.fromObject({
  12462. max: a.max,
  12463. min: a.min
  12464. });
  12465. }
  12466. constrain(a) {
  12467. const u = this.values.get("max"), v = this.values.get("min");
  12468. return Math.min(Math.max(a, v), u);
  12469. }
  12470. }
  12471. class St {
  12472. constructor(a) {
  12473. this.values = K2.fromObject({
  12474. max: a.max,
  12475. min: a.min
  12476. });
  12477. }
  12478. get maxValue() {
  12479. return this.values.get("max");
  12480. }
  12481. get minValue() {
  12482. return this.values.get("min");
  12483. }
  12484. constrain(a) {
  12485. const u = this.values.get("max"), v = this.values.get("min");
  12486. let x = a;
  12487. return h2(v) || (x = Math.max(x, v)), h2(u) || (x = Math.min(x, u)), x;
  12488. }
  12489. }
  12490. class M {
  12491. constructor(a, u = 0) {
  12492. this.step = a, this.origin = u;
  12493. }
  12494. constrain(a) {
  12495. const u = this.origin % this.step, v = Math.round((a - u) / this.step);
  12496. return u + v * this.step;
  12497. }
  12498. }
  12499. const U2 = y("pop");
  12500. class W {
  12501. constructor(a, u) {
  12502. this.element = a.createElement("div"), this.element.classList.add(U2()), u.viewProps.bindClassModifiers(this.element), S(u.shows, N(this.element, U2(void 0, "v")));
  12503. }
  12504. }
  12505. class ie2 {
  12506. constructor(a, u) {
  12507. this.shows = H2(false), this.viewProps = u.viewProps, this.view = new W(a, {
  12508. shows: this.shows,
  12509. viewProps: this.viewProps
  12510. });
  12511. }
  12512. }
  12513. const Ee2 = y("txt");
  12514. class Fe {
  12515. constructor(a, u) {
  12516. this.onChange_ = this.onChange_.bind(this), this.element = a.createElement("div"), this.element.classList.add(Ee2()), u.viewProps.bindClassModifiers(this.element), this.props_ = u.props, this.props_.emitter.on("change", this.onChange_);
  12517. const v = a.createElement("input");
  12518. v.classList.add(Ee2("i")), v.type = "text", u.viewProps.bindDisabled(v), this.element.appendChild(v), this.inputElement = v, u.value.emitter.on("change", this.onChange_), this.value_ = u.value, this.refresh();
  12519. }
  12520. refresh() {
  12521. const a = this.props_.get("formatter");
  12522. this.inputElement.value = a(this.value_.rawValue);
  12523. }
  12524. onChange_() {
  12525. this.refresh();
  12526. }
  12527. }
  12528. class Gt {
  12529. constructor(a, u) {
  12530. this.onInputChange_ = this.onInputChange_.bind(this), this.parser_ = u.parser, this.props = u.props, this.value = u.value, this.viewProps = u.viewProps, this.view = new Fe(a, {
  12531. props: u.props,
  12532. value: this.value,
  12533. viewProps: this.viewProps
  12534. }), this.view.inputElement.addEventListener("change", this.onInputChange_);
  12535. }
  12536. onInputChange_(a) {
  12537. const v = a.currentTarget.value, x = this.parser_(v);
  12538. h2(x) || (this.value.rawValue = x), this.view.refresh();
  12539. }
  12540. }
  12541. function fn(d) {
  12542. return d === "false" ? false : !!d;
  12543. }
  12544. class $e {
  12545. constructor(a) {
  12546. this.text = a;
  12547. }
  12548. evaluate() {
  12549. return Number(this.text);
  12550. }
  12551. toString() {
  12552. return this.text;
  12553. }
  12554. }
  12555. const Xe = {
  12556. "**": (d, a) => Math.pow(d, a),
  12557. "*": (d, a) => d * a,
  12558. "/": (d, a) => d / a,
  12559. "%": (d, a) => d % a,
  12560. "+": (d, a) => d + a,
  12561. "-": (d, a) => d - a,
  12562. "<<": (d, a) => d << a,
  12563. ">>": (d, a) => d >> a,
  12564. ">>>": (d, a) => d >>> a,
  12565. "&": (d, a) => d & a,
  12566. "^": (d, a) => d ^ a,
  12567. "|": (d, a) => d | a
  12568. };
  12569. class qs {
  12570. constructor(a, u, v) {
  12571. this.left = u, this.operator = a, this.right = v;
  12572. }
  12573. evaluate() {
  12574. const a = Xe[this.operator];
  12575. if (!a)
  12576. throw new Error(`unexpected binary operator: '${this.operator}`);
  12577. return a(this.left.evaluate(), this.right.evaluate());
  12578. }
  12579. toString() {
  12580. return [
  12581. "b(",
  12582. this.left.toString(),
  12583. this.operator,
  12584. this.right.toString(),
  12585. ")"
  12586. ].join(" ");
  12587. }
  12588. }
  12589. const Qs = {
  12590. "+": (d) => d,
  12591. "-": (d) => -d,
  12592. "~": (d) => ~d
  12593. };
  12594. class Zs {
  12595. constructor(a, u) {
  12596. this.operator = a, this.expression = u;
  12597. }
  12598. evaluate() {
  12599. const a = Qs[this.operator];
  12600. if (!a)
  12601. throw new Error(`unexpected unary operator: '${this.operator}`);
  12602. return a(this.expression.evaluate());
  12603. }
  12604. toString() {
  12605. return ["u(", this.operator, this.expression.toString(), ")"].join(" ");
  12606. }
  12607. }
  12608. function gi(d) {
  12609. return (a, u) => {
  12610. for (let v = 0; v < d.length; v++) {
  12611. const x = d[v](a, u);
  12612. if (x !== "")
  12613. return x;
  12614. }
  12615. return "";
  12616. };
  12617. }
  12618. function Lt(d, a) {
  12619. var u;
  12620. const v = d.substr(a).match(/^\s+/);
  12621. return (u = v && v[0]) !== null && u !== void 0 ? u : "";
  12622. }
  12623. function _i(d, a) {
  12624. const u = d.substr(a, 1);
  12625. return u.match(/^[1-9]$/) ? u : "";
  12626. }
  12627. function Ge(d, a) {
  12628. var u;
  12629. const v = d.substr(a).match(/^[0-9]+/);
  12630. return (u = v && v[0]) !== null && u !== void 0 ? u : "";
  12631. }
  12632. function wi(d, a) {
  12633. const u = Ge(d, a);
  12634. if (u !== "")
  12635. return u;
  12636. const v = d.substr(a, 1);
  12637. if (a += 1, v !== "-" && v !== "+")
  12638. return "";
  12639. const x = Ge(d, a);
  12640. return x === "" ? "" : v + x;
  12641. }
  12642. function at2(d, a) {
  12643. const u = d.substr(a, 1);
  12644. if (a += 1, u.toLowerCase() !== "e")
  12645. return "";
  12646. const v = wi(d, a);
  12647. return v === "" ? "" : u + v;
  12648. }
  12649. function as(d, a) {
  12650. const u = d.substr(a, 1);
  12651. if (u === "0")
  12652. return u;
  12653. const v = _i(d, a);
  12654. return a += v.length, v === "" ? "" : v + Ge(d, a);
  12655. }
  12656. function vn(d, a) {
  12657. const u = as(d, a);
  12658. if (a += u.length, u === "")
  12659. return "";
  12660. const v = d.substr(a, 1);
  12661. if (a += v.length, v !== ".")
  12662. return "";
  12663. const x = Ge(d, a);
  12664. return a += x.length, u + v + x + at2(d, a);
  12665. }
  12666. function ls(d, a) {
  12667. const u = d.substr(a, 1);
  12668. if (a += u.length, u !== ".")
  12669. return "";
  12670. const v = Ge(d, a);
  12671. return a += v.length, v === "" ? "" : u + v + at2(d, a);
  12672. }
  12673. function qn(d, a) {
  12674. const u = as(d, a);
  12675. return a += u.length, u === "" ? "" : u + at2(d, a);
  12676. }
  12677. const yi = gi([
  12678. vn,
  12679. ls,
  12680. qn
  12681. ]);
  12682. function xi(d, a) {
  12683. var u;
  12684. const v = d.substr(a).match(/^[01]+/);
  12685. return (u = v && v[0]) !== null && u !== void 0 ? u : "";
  12686. }
  12687. function Ws(d, a) {
  12688. const u = d.substr(a, 2);
  12689. if (a += u.length, u.toLowerCase() !== "0b")
  12690. return "";
  12691. const v = xi(d, a);
  12692. return v === "" ? "" : u + v;
  12693. }
  12694. function Js(d, a) {
  12695. var u;
  12696. const v = d.substr(a).match(/^[0-7]+/);
  12697. return (u = v && v[0]) !== null && u !== void 0 ? u : "";
  12698. }
  12699. function er(d, a) {
  12700. const u = d.substr(a, 2);
  12701. if (a += u.length, u.toLowerCase() !== "0o")
  12702. return "";
  12703. const v = Js(d, a);
  12704. return v === "" ? "" : u + v;
  12705. }
  12706. function tr(d, a) {
  12707. var u;
  12708. const v = d.substr(a).match(/^[0-9a-f]+/i);
  12709. return (u = v && v[0]) !== null && u !== void 0 ? u : "";
  12710. }
  12711. function Ei(d, a) {
  12712. const u = d.substr(a, 2);
  12713. if (a += u.length, u.toLowerCase() !== "0x")
  12714. return "";
  12715. const v = tr(d, a);
  12716. return v === "" ? "" : u + v;
  12717. }
  12718. const nr = gi([
  12719. Ws,
  12720. er,
  12721. Ei
  12722. ]), ir = gi([
  12723. nr,
  12724. yi
  12725. ]);
  12726. function bn(d, a) {
  12727. const u = ir(d, a);
  12728. return a += u.length, u === "" ? null : {
  12729. evaluable: new $e(u),
  12730. cursor: a
  12731. };
  12732. }
  12733. function cs(d, a) {
  12734. const u = d.substr(a, 1);
  12735. if (a += u.length, u !== "(")
  12736. return null;
  12737. const v = Ci(d, a);
  12738. if (!v)
  12739. return null;
  12740. a = v.cursor, a += Lt(d, a).length;
  12741. const x = d.substr(a, 1);
  12742. return a += x.length, x !== ")" ? null : {
  12743. evaluable: v.evaluable,
  12744. cursor: a
  12745. };
  12746. }
  12747. function sr(d, a) {
  12748. var u;
  12749. return (u = bn(d, a)) !== null && u !== void 0 ? u : cs(d, a);
  12750. }
  12751. function Qn(d, a) {
  12752. const u = sr(d, a);
  12753. if (u)
  12754. return u;
  12755. const v = d.substr(a, 1);
  12756. if (a += v.length, v !== "+" && v !== "-" && v !== "~")
  12757. return null;
  12758. const x = Qn(d, a);
  12759. return x ? (a = x.cursor, {
  12760. cursor: a,
  12761. evaluable: new Zs(v, x.evaluable)
  12762. }) : null;
  12763. }
  12764. function rr(d, a, u) {
  12765. u += Lt(a, u).length;
  12766. const v = d.filter((x) => a.startsWith(x, u))[0];
  12767. return v ? (u += v.length, u += Lt(a, u).length, {
  12768. cursor: u,
  12769. operator: v
  12770. }) : null;
  12771. }
  12772. function Ht(d, a) {
  12773. return (u, v) => {
  12774. const x = d(u, v);
  12775. if (!x)
  12776. return null;
  12777. v = x.cursor;
  12778. let T = x.evaluable;
  12779. for (; ; ) {
  12780. const V2 = rr(a, u, v);
  12781. if (!V2)
  12782. break;
  12783. v = V2.cursor;
  12784. const z = d(u, v);
  12785. if (!z)
  12786. return null;
  12787. v = z.cursor, T = new qs(V2.operator, T, z.evaluable);
  12788. }
  12789. return T ? {
  12790. cursor: v,
  12791. evaluable: T
  12792. } : null;
  12793. };
  12794. }
  12795. const us = [
  12796. ["**"],
  12797. ["*", "/", "%"],
  12798. ["+", "-"],
  12799. ["<<", ">>>", ">>"],
  12800. ["&"],
  12801. ["^"],
  12802. ["|"]
  12803. ].reduce((d, a) => Ht(d, a), Qn);
  12804. function Ci(d, a) {
  12805. return a += Lt(d, a).length, us(d, a);
  12806. }
  12807. function or(d) {
  12808. const a = Ci(d, 0);
  12809. return !a || a.cursor + Lt(d, a.cursor).length !== d.length ? null : a.evaluable;
  12810. }
  12811. function gn(d) {
  12812. var a;
  12813. const u = or(d);
  12814. return (a = u == null ? void 0 : u.evaluate()) !== null && a !== void 0 ? a : null;
  12815. }
  12816. function ar(d) {
  12817. if (typeof d == "number")
  12818. return d;
  12819. if (typeof d == "string") {
  12820. const a = gn(d);
  12821. if (!h2(a))
  12822. return a;
  12823. }
  12824. return 0;
  12825. }
  12826. function Ie(d) {
  12827. return (a) => a.toFixed(Math.max(Math.min(d, 20), 0));
  12828. }
  12829. const lr = Ie(0);
  12830. function Zn(d) {
  12831. return lr(d) + "%";
  12832. }
  12833. function ps(d) {
  12834. return String(d);
  12835. }
  12836. function Pi(d, a) {
  12837. for (; d.length < a; )
  12838. d.push(void 0);
  12839. }
  12840. function hs(d) {
  12841. const a = [];
  12842. return Pi(a, d), H2(a);
  12843. }
  12844. function ds(d) {
  12845. const a = d.indexOf(void 0);
  12846. return a < 0 ? d : d.slice(0, a);
  12847. }
  12848. function cr(d, a) {
  12849. const u = [...ds(d), a];
  12850. return u.length > d.length ? u.splice(0, u.length - d.length) : Pi(u, d.length), u;
  12851. }
  12852. function Kt({ primary: d, secondary: a, forward: u, backward: v }) {
  12853. let x = false;
  12854. function T(V2) {
  12855. x || (x = true, V2(), x = false);
  12856. }
  12857. d.emitter.on("change", (V2) => {
  12858. T(() => {
  12859. a.setRawValue(u(d, a), V2.options);
  12860. });
  12861. }), a.emitter.on("change", (V2) => {
  12862. T(() => {
  12863. d.setRawValue(v(d, a), V2.options);
  12864. }), T(() => {
  12865. a.setRawValue(u(d, a), V2.options);
  12866. });
  12867. }), T(() => {
  12868. a.setRawValue(u(d, a), {
  12869. forceEmit: false,
  12870. last: true
  12871. });
  12872. });
  12873. }
  12874. function $t(d, a) {
  12875. const u = d * (a.altKey ? 0.1 : 1) * (a.shiftKey ? 10 : 1);
  12876. return a.upKey ? +u : a.downKey ? -u : 0;
  12877. }
  12878. function _n(d) {
  12879. return {
  12880. altKey: d.altKey,
  12881. downKey: d.key === "ArrowDown",
  12882. shiftKey: d.shiftKey,
  12883. upKey: d.key === "ArrowUp"
  12884. };
  12885. }
  12886. function Ti(d) {
  12887. return {
  12888. altKey: d.altKey,
  12889. downKey: d.key === "ArrowLeft",
  12890. shiftKey: d.shiftKey,
  12891. upKey: d.key === "ArrowRight"
  12892. };
  12893. }
  12894. function ur(d) {
  12895. return d === "ArrowUp" || d === "ArrowDown";
  12896. }
  12897. function ms(d) {
  12898. return ur(d) || d === "ArrowLeft" || d === "ArrowRight";
  12899. }
  12900. function ki(d, a) {
  12901. var u, v;
  12902. const x = a.ownerDocument.defaultView, T = a.getBoundingClientRect();
  12903. return {
  12904. x: d.pageX - (((u = x && x.scrollX) !== null && u !== void 0 ? u : 0) + T.left),
  12905. y: d.pageY - (((v = x && x.scrollY) !== null && v !== void 0 ? v : 0) + T.top)
  12906. };
  12907. }
  12908. class Wn {
  12909. constructor(a) {
  12910. this.lastTouch_ = null, this.onDocumentMouseMove_ = this.onDocumentMouseMove_.bind(this), this.onDocumentMouseUp_ = this.onDocumentMouseUp_.bind(this), this.onMouseDown_ = this.onMouseDown_.bind(this), this.onTouchEnd_ = this.onTouchEnd_.bind(this), this.onTouchMove_ = this.onTouchMove_.bind(this), this.onTouchStart_ = this.onTouchStart_.bind(this), this.elem_ = a, this.emitter = new w(), a.addEventListener("touchstart", this.onTouchStart_, {
  12911. passive: false
  12912. }), a.addEventListener("touchmove", this.onTouchMove_, {
  12913. passive: true
  12914. }), a.addEventListener("touchend", this.onTouchEnd_), a.addEventListener("mousedown", this.onMouseDown_);
  12915. }
  12916. computePosition_(a) {
  12917. const u = this.elem_.getBoundingClientRect();
  12918. return {
  12919. bounds: {
  12920. width: u.width,
  12921. height: u.height
  12922. },
  12923. point: a ? {
  12924. x: a.x,
  12925. y: a.y
  12926. } : null
  12927. };
  12928. }
  12929. onMouseDown_(a) {
  12930. var u;
  12931. a.preventDefault(), (u = a.currentTarget) === null || u === void 0 || u.focus();
  12932. const v = this.elem_.ownerDocument;
  12933. v.addEventListener("mousemove", this.onDocumentMouseMove_), v.addEventListener("mouseup", this.onDocumentMouseUp_), this.emitter.emit("down", {
  12934. altKey: a.altKey,
  12935. data: this.computePosition_(ki(a, this.elem_)),
  12936. sender: this,
  12937. shiftKey: a.shiftKey
  12938. });
  12939. }
  12940. onDocumentMouseMove_(a) {
  12941. this.emitter.emit("move", {
  12942. altKey: a.altKey,
  12943. data: this.computePosition_(ki(a, this.elem_)),
  12944. sender: this,
  12945. shiftKey: a.shiftKey
  12946. });
  12947. }
  12948. onDocumentMouseUp_(a) {
  12949. const u = this.elem_.ownerDocument;
  12950. u.removeEventListener("mousemove", this.onDocumentMouseMove_), u.removeEventListener("mouseup", this.onDocumentMouseUp_), this.emitter.emit("up", {
  12951. altKey: a.altKey,
  12952. data: this.computePosition_(ki(a, this.elem_)),
  12953. sender: this,
  12954. shiftKey: a.shiftKey
  12955. });
  12956. }
  12957. onTouchStart_(a) {
  12958. a.preventDefault();
  12959. const u = a.targetTouches.item(0), v = this.elem_.getBoundingClientRect();
  12960. this.emitter.emit("down", {
  12961. altKey: a.altKey,
  12962. data: this.computePosition_(u ? {
  12963. x: u.clientX - v.left,
  12964. y: u.clientY - v.top
  12965. } : void 0),
  12966. sender: this,
  12967. shiftKey: a.shiftKey
  12968. }), this.lastTouch_ = u;
  12969. }
  12970. onTouchMove_(a) {
  12971. const u = a.targetTouches.item(0), v = this.elem_.getBoundingClientRect();
  12972. this.emitter.emit("move", {
  12973. altKey: a.altKey,
  12974. data: this.computePosition_(u ? {
  12975. x: u.clientX - v.left,
  12976. y: u.clientY - v.top
  12977. } : void 0),
  12978. sender: this,
  12979. shiftKey: a.shiftKey
  12980. }), this.lastTouch_ = u;
  12981. }
  12982. onTouchEnd_(a) {
  12983. var u;
  12984. const v = (u = a.targetTouches.item(0)) !== null && u !== void 0 ? u : this.lastTouch_, x = this.elem_.getBoundingClientRect();
  12985. this.emitter.emit("up", {
  12986. altKey: a.altKey,
  12987. data: this.computePosition_(v ? {
  12988. x: v.clientX - x.left,
  12989. y: v.clientY - x.top
  12990. } : void 0),
  12991. sender: this,
  12992. shiftKey: a.shiftKey
  12993. });
  12994. }
  12995. }
  12996. function Le(d, a, u, v, x) {
  12997. const T = (d - a) / (u - a);
  12998. return v + T * (x - v);
  12999. }
  13000. function fs(d) {
  13001. return String(d.toFixed(10)).split(".")[1].replace(/0+$/, "").length;
  13002. }
  13003. function Xt(d, a, u) {
  13004. return Math.min(Math.max(d, a), u);
  13005. }
  13006. const We = y("txt");
  13007. class pr {
  13008. constructor(a, u) {
  13009. this.onChange_ = this.onChange_.bind(this), this.props_ = u.props, this.props_.emitter.on("change", this.onChange_), this.element = a.createElement("div"), this.element.classList.add(We(), We(void 0, "num")), u.arrayPosition && this.element.classList.add(We(void 0, u.arrayPosition)), u.viewProps.bindClassModifiers(this.element);
  13010. const v = a.createElement("input");
  13011. v.classList.add(We("i")), v.type = "text", u.viewProps.bindDisabled(v), this.element.appendChild(v), this.inputElement = v, this.onDraggingChange_ = this.onDraggingChange_.bind(this), this.dragging_ = u.dragging, this.dragging_.emitter.on("change", this.onDraggingChange_), this.element.classList.add(We()), this.inputElement.classList.add(We("i"));
  13012. const x = a.createElement("div");
  13013. x.classList.add(We("k")), this.element.appendChild(x), this.knobElement = x;
  13014. const T = a.createElementNS(xe2, "svg");
  13015. T.classList.add(We("g")), this.knobElement.appendChild(T);
  13016. const V2 = a.createElementNS(xe2, "path");
  13017. V2.classList.add(We("gb")), T.appendChild(V2), this.guideBodyElem_ = V2;
  13018. const z = a.createElementNS(xe2, "path");
  13019. z.classList.add(We("gh")), T.appendChild(z), this.guideHeadElem_ = z;
  13020. const re = a.createElement("div");
  13021. re.classList.add(y("tt")()), this.knobElement.appendChild(re), this.tooltipElem_ = re, u.value.emitter.on("change", this.onChange_), this.value = u.value, this.refresh();
  13022. }
  13023. onDraggingChange_(a) {
  13024. if (a.rawValue === null) {
  13025. this.element.classList.remove(We(void 0, "drg"));
  13026. return;
  13027. }
  13028. this.element.classList.add(We(void 0, "drg"));
  13029. const u = a.rawValue / this.props_.get("draggingScale"), v = u + (u > 0 ? -1 : u < 0 ? 1 : 0), x = Xt(-v, -4, 4);
  13030. this.guideHeadElem_.setAttributeNS(null, "d", [`M ${v + x},0 L${v},4 L${v + x},8`, `M ${u},-1 L${u},9`].join(" ")), this.guideBodyElem_.setAttributeNS(null, "d", `M 0,4 L${u},4`);
  13031. const T = this.props_.get("formatter");
  13032. this.tooltipElem_.textContent = T(this.value.rawValue), this.tooltipElem_.style.left = `${u}px`;
  13033. }
  13034. refresh() {
  13035. const a = this.props_.get("formatter");
  13036. this.inputElement.value = a(this.value.rawValue);
  13037. }
  13038. onChange_() {
  13039. this.refresh();
  13040. }
  13041. }
  13042. class wn {
  13043. constructor(a, u) {
  13044. var v;
  13045. this.originRawValue_ = 0, this.onInputChange_ = this.onInputChange_.bind(this), this.onInputKeyDown_ = this.onInputKeyDown_.bind(this), this.onInputKeyUp_ = this.onInputKeyUp_.bind(this), this.onPointerDown_ = this.onPointerDown_.bind(this), this.onPointerMove_ = this.onPointerMove_.bind(this), this.onPointerUp_ = this.onPointerUp_.bind(this), this.baseStep_ = u.baseStep, this.parser_ = u.parser, this.props = u.props, this.sliderProps_ = (v = u.sliderProps) !== null && v !== void 0 ? v : null, this.value = u.value, this.viewProps = u.viewProps, this.dragging_ = H2(null), this.view = new pr(a, {
  13046. arrayPosition: u.arrayPosition,
  13047. dragging: this.dragging_,
  13048. props: this.props,
  13049. value: this.value,
  13050. viewProps: this.viewProps
  13051. }), this.view.inputElement.addEventListener("change", this.onInputChange_), this.view.inputElement.addEventListener("keydown", this.onInputKeyDown_), this.view.inputElement.addEventListener("keyup", this.onInputKeyUp_);
  13052. const x = new Wn(this.view.knobElement);
  13053. x.emitter.on("down", this.onPointerDown_), x.emitter.on("move", this.onPointerMove_), x.emitter.on("up", this.onPointerUp_);
  13054. }
  13055. constrainValue_(a) {
  13056. var u, v;
  13057. const x = (u = this.sliderProps_) === null || u === void 0 ? void 0 : u.get("minValue"), T = (v = this.sliderProps_) === null || v === void 0 ? void 0 : v.get("maxValue");
  13058. let V2 = a;
  13059. return x !== void 0 && (V2 = Math.max(V2, x)), T !== void 0 && (V2 = Math.min(V2, T)), V2;
  13060. }
  13061. onInputChange_(a) {
  13062. const v = a.currentTarget.value, x = this.parser_(v);
  13063. h2(x) || (this.value.rawValue = this.constrainValue_(x)), this.view.refresh();
  13064. }
  13065. onInputKeyDown_(a) {
  13066. const u = $t(this.baseStep_, _n(a));
  13067. u !== 0 && this.value.setRawValue(this.constrainValue_(this.value.rawValue + u), {
  13068. forceEmit: false,
  13069. last: false
  13070. });
  13071. }
  13072. onInputKeyUp_(a) {
  13073. $t(this.baseStep_, _n(a)) !== 0 && this.value.setRawValue(this.value.rawValue, {
  13074. forceEmit: true,
  13075. last: true
  13076. });
  13077. }
  13078. onPointerDown_() {
  13079. this.originRawValue_ = this.value.rawValue, this.dragging_.rawValue = 0;
  13080. }
  13081. computeDraggingValue_(a) {
  13082. if (!a.point)
  13083. return null;
  13084. const u = a.point.x - a.bounds.width / 2;
  13085. return this.constrainValue_(this.originRawValue_ + u * this.props.get("draggingScale"));
  13086. }
  13087. onPointerMove_(a) {
  13088. const u = this.computeDraggingValue_(a.data);
  13089. u !== null && (this.value.setRawValue(u, {
  13090. forceEmit: false,
  13091. last: false
  13092. }), this.dragging_.rawValue = this.value.rawValue - this.originRawValue_);
  13093. }
  13094. onPointerUp_(a) {
  13095. const u = this.computeDraggingValue_(a.data);
  13096. u !== null && (this.value.setRawValue(u, {
  13097. forceEmit: true,
  13098. last: true
  13099. }), this.dragging_.rawValue = null);
  13100. }
  13101. }
  13102. function it2(d, a) {
  13103. d.write(a);
  13104. }
  13105. function Yt(d) {
  13106. const a = d ? Ct(d, M) : null;
  13107. return a ? a.step : null;
  13108. }
  13109. function yn(d, a) {
  13110. const u = d && Ct(d, M);
  13111. return u ? fs(u.step) : Math.max(fs(a), 2);
  13112. }
  13113. function Ai(d) {
  13114. const a = Yt(d);
  13115. return a ?? 1;
  13116. }
  13117. function Jn(d, a) {
  13118. var u;
  13119. const v = d && Ct(d, M), x = Math.abs((u = v == null ? void 0 : v.step) !== null && u !== void 0 ? u : a);
  13120. return x === 0 ? 0.1 : Math.pow(10, Math.floor(Math.log10(x)) - 1);
  13121. }
  13122. function qt(d) {
  13123. return [d[0], d[1], d[2]];
  13124. }
  13125. function vs(d) {
  13126. const a = Xt(Math.floor(d), 0, 255).toString(16);
  13127. return a.length === 1 ? `0${a}` : a;
  13128. }
  13129. function xn(d, a = "#") {
  13130. const u = qt(d.getComponents("rgb")).map(vs).join("");
  13131. return `${a}${u}`;
  13132. }
  13133. function bs(d, a = "#") {
  13134. const u = d.getComponents("rgb"), v = [u[0], u[1], u[2], u[3] * 255].map(vs).join("");
  13135. return `${a}${v}`;
  13136. }
  13137. function hr(d, a) {
  13138. const u = Ie(a === "float" ? 2 : 0);
  13139. return `rgb(${qt(d.getComponents("rgb", a)).map((x) => u(x)).join(", ")})`;
  13140. }
  13141. function gs(d) {
  13142. return (a) => hr(a, d);
  13143. }
  13144. function _s(d, a) {
  13145. const u = Ie(2), v = Ie(a === "float" ? 2 : 0);
  13146. return `rgba(${d.getComponents("rgb", a).map((T, V2) => (V2 === 3 ? u : v)(T)).join(", ")})`;
  13147. }
  13148. function dr(d) {
  13149. return (a) => _s(a, d);
  13150. }
  13151. function ei(d) {
  13152. const a = [
  13153. Ie(0),
  13154. Zn,
  13155. Zn
  13156. ];
  13157. return `hsl(${qt(d.getComponents("hsl")).map((v, x) => a[x](v)).join(", ")})`;
  13158. }
  13159. function mr(d) {
  13160. const a = [
  13161. Ie(0),
  13162. Zn,
  13163. Zn,
  13164. Ie(2)
  13165. ];
  13166. return `hsla(${d.getComponents("hsl").map((v, x) => a[x](v)).join(", ")})`;
  13167. }
  13168. function ws(d, a) {
  13169. const u = Ie(a === "float" ? 2 : 0), v = ["r", "g", "b"];
  13170. return `{${qt(d.getComponents("rgb", a)).map((T, V2) => `${v[V2]}: ${u(T)}`).join(", ")}}`;
  13171. }
  13172. function ys(d) {
  13173. return (a) => ws(a, d);
  13174. }
  13175. function fr(d, a) {
  13176. const u = Ie(2), v = Ie(a === "float" ? 2 : 0), x = ["r", "g", "b", "a"];
  13177. return `{${d.getComponents("rgb", a).map((V2, z) => {
  13178. const re = z === 3 ? u : v;
  13179. return `${x[z]}: ${re(V2)}`;
  13180. }).join(", ")}}`;
  13181. }
  13182. function vr(d) {
  13183. return (a) => fr(a, d);
  13184. }
  13185. [
  13186. ...["int", "float"].reduce((d, a) => [
  13187. ...d,
  13188. {
  13189. format: {
  13190. alpha: false,
  13191. mode: "rgb",
  13192. notation: "func",
  13193. type: a
  13194. },
  13195. stringifier: gs(a)
  13196. },
  13197. {
  13198. format: {
  13199. alpha: true,
  13200. mode: "rgb",
  13201. notation: "func",
  13202. type: a
  13203. },
  13204. stringifier: dr(a)
  13205. },
  13206. {
  13207. format: {
  13208. alpha: false,
  13209. mode: "rgb",
  13210. notation: "object",
  13211. type: a
  13212. },
  13213. stringifier: ys(a)
  13214. },
  13215. {
  13216. format: {
  13217. alpha: true,
  13218. mode: "rgb",
  13219. notation: "object",
  13220. type: a
  13221. },
  13222. stringifier: vr(a)
  13223. }
  13224. ], [])
  13225. ];
  13226. class br {
  13227. constructor(a) {
  13228. this.components = a.components, this.asm_ = a.assembly;
  13229. }
  13230. constrain(a) {
  13231. const u = this.asm_.toComponents(a).map((v, x) => {
  13232. var T, V2;
  13233. return (V2 = (T = this.components[x]) === null || T === void 0 ? void 0 : T.constrain(v)) !== null && V2 !== void 0 ? V2 : v;
  13234. });
  13235. return this.asm_.fromComponents(u);
  13236. }
  13237. }
  13238. const xs = y("pndtxt");
  13239. class gr {
  13240. constructor(a, u) {
  13241. this.textViews = u.textViews, this.element = a.createElement("div"), this.element.classList.add(xs()), this.textViews.forEach((v) => {
  13242. const x = a.createElement("div");
  13243. x.classList.add(xs("a")), x.appendChild(v.element), this.element.appendChild(x);
  13244. });
  13245. }
  13246. }
  13247. function Mi(d, a, u) {
  13248. return new wn(d, {
  13249. arrayPosition: u === 0 ? "fst" : u === a.axes.length - 1 ? "lst" : "mid",
  13250. baseStep: a.axes[u].baseStep,
  13251. parser: a.parser,
  13252. props: a.axes[u].textProps,
  13253. value: H2(0, {
  13254. constraint: a.axes[u].constraint
  13255. }),
  13256. viewProps: a.viewProps
  13257. });
  13258. }
  13259. class Rt2 {
  13260. constructor(a, u) {
  13261. this.value = u.value, this.viewProps = u.viewProps, this.acs_ = u.axes.map((v, x) => Mi(a, u, x)), this.acs_.forEach((v, x) => {
  13262. Kt({
  13263. primary: this.value,
  13264. secondary: v.value,
  13265. forward: (T) => u.assembly.toComponents(T.rawValue)[x],
  13266. backward: (T, V2) => {
  13267. const z = u.assembly.toComponents(T.rawValue);
  13268. return z[x] = V2.rawValue, u.assembly.fromComponents(z);
  13269. }
  13270. });
  13271. }), this.view = new gr(a, {
  13272. textViews: this.acs_.map((v) => v.view)
  13273. });
  13274. }
  13275. }
  13276. function _r(d, a) {
  13277. return "step" in d && !h2(d.step) ? new M(d.step, a) : null;
  13278. }
  13279. function En(d) {
  13280. return !h2(d.max) && !h2(d.min) ? new gt2({
  13281. max: d.max,
  13282. min: d.min
  13283. }) : !h2(d.max) || !h2(d.min) ? new St({
  13284. max: d.max,
  13285. min: d.min
  13286. }) : null;
  13287. }
  13288. const wr = {
  13289. monitor: {
  13290. defaultInterval: 200,
  13291. defaultLineCount: 3
  13292. }
  13293. }, lt2 = y("grl");
  13294. class Es {
  13295. constructor(a, u) {
  13296. this.onCursorChange_ = this.onCursorChange_.bind(this), this.onValueUpdate_ = this.onValueUpdate_.bind(this), this.element = a.createElement("div"), this.element.classList.add(lt2()), u.viewProps.bindClassModifiers(this.element), this.formatter_ = u.formatter, this.props_ = u.props, this.cursor_ = u.cursor, this.cursor_.emitter.on("change", this.onCursorChange_);
  13297. const v = a.createElementNS(xe2, "svg");
  13298. v.classList.add(lt2("g")), v.style.height = `calc(var(--bld-us) * ${u.lineCount})`, this.element.appendChild(v), this.svgElem_ = v;
  13299. const x = a.createElementNS(xe2, "polyline");
  13300. this.svgElem_.appendChild(x), this.lineElem_ = x;
  13301. const T = a.createElement("div");
  13302. T.classList.add(lt2("t"), y("tt")()), this.element.appendChild(T), this.tooltipElem_ = T, u.value.emitter.on("change", this.onValueUpdate_), this.value = u.value, this.update_();
  13303. }
  13304. get graphElement() {
  13305. return this.svgElem_;
  13306. }
  13307. update_() {
  13308. const a = this.svgElem_.getBoundingClientRect(), u = this.value.rawValue.length - 1, v = this.props_.get("minValue"), x = this.props_.get("maxValue"), T = [];
  13309. this.value.rawValue.forEach((tt2, te) => {
  13310. if (tt2 === void 0)
  13311. return;
  13312. const kt = Le(te, 0, u, 0, a.width), Ir = Le(tt2, v, x, a.height, 0);
  13313. T.push([kt, Ir].join(","));
  13314. }), this.lineElem_.setAttributeNS(null, "points", T.join(" "));
  13315. const V2 = this.tooltipElem_, z = this.value.rawValue[this.cursor_.rawValue];
  13316. if (z === void 0) {
  13317. V2.classList.remove(lt2("t", "a"));
  13318. return;
  13319. }
  13320. const re = Le(this.cursor_.rawValue, 0, u, 0, a.width), et2 = Le(z, v, x, a.height, 0);
  13321. V2.style.left = `${re}px`, V2.style.top = `${et2}px`, V2.textContent = `${this.formatter_(z)}`, V2.classList.contains(lt2("t", "a")) || (V2.classList.add(lt2("t", "a"), lt2("t", "in")), rt2(V2), V2.classList.remove(lt2("t", "in")));
  13322. }
  13323. onValueUpdate_() {
  13324. this.update_();
  13325. }
  13326. onCursorChange_() {
  13327. this.update_();
  13328. }
  13329. }
  13330. class yr {
  13331. constructor(a, u) {
  13332. if (this.onGraphMouseMove_ = this.onGraphMouseMove_.bind(this), this.onGraphMouseLeave_ = this.onGraphMouseLeave_.bind(this), this.onGraphPointerDown_ = this.onGraphPointerDown_.bind(this), this.onGraphPointerMove_ = this.onGraphPointerMove_.bind(this), this.onGraphPointerUp_ = this.onGraphPointerUp_.bind(this), this.props_ = u.props, this.value = u.value, this.viewProps = u.viewProps, this.cursor_ = H2(-1), this.view = new Es(a, {
  13333. cursor: this.cursor_,
  13334. formatter: u.formatter,
  13335. lineCount: u.lineCount,
  13336. props: this.props_,
  13337. value: this.value,
  13338. viewProps: this.viewProps
  13339. }), !Ze2(a))
  13340. this.view.element.addEventListener("mousemove", this.onGraphMouseMove_), this.view.element.addEventListener("mouseleave", this.onGraphMouseLeave_);
  13341. else {
  13342. const v = new Wn(this.view.element);
  13343. v.emitter.on("down", this.onGraphPointerDown_), v.emitter.on("move", this.onGraphPointerMove_), v.emitter.on("up", this.onGraphPointerUp_);
  13344. }
  13345. }
  13346. onGraphMouseLeave_() {
  13347. this.cursor_.rawValue = -1;
  13348. }
  13349. onGraphMouseMove_(a) {
  13350. const u = this.view.element.getBoundingClientRect();
  13351. this.cursor_.rawValue = Math.floor(Le(a.offsetX, 0, u.width, 0, this.value.rawValue.length));
  13352. }
  13353. onGraphPointerDown_(a) {
  13354. this.onGraphPointerMove_(a);
  13355. }
  13356. onGraphPointerMove_(a) {
  13357. if (!a.data.point) {
  13358. this.cursor_.rawValue = -1;
  13359. return;
  13360. }
  13361. this.cursor_.rawValue = Math.floor(Le(a.data.point.x, 0, a.data.bounds.width, 0, this.value.rawValue.length));
  13362. }
  13363. onGraphPointerUp_() {
  13364. this.cursor_.rawValue = -1;
  13365. }
  13366. }
  13367. class Cs {
  13368. constructor(a) {
  13369. this.controller_ = a;
  13370. }
  13371. get disabled() {
  13372. return this.controller_.viewProps.get("disabled");
  13373. }
  13374. set disabled(a) {
  13375. this.controller_.viewProps.set("disabled", a);
  13376. }
  13377. get title() {
  13378. var a;
  13379. return (a = this.controller_.props.get("title")) !== null && a !== void 0 ? a : "";
  13380. }
  13381. set title(a) {
  13382. this.controller_.props.set("title", a);
  13383. }
  13384. on(a, u) {
  13385. const v = u.bind(this);
  13386. return this.controller_.emitter.on(a, () => {
  13387. v(new o(this));
  13388. }), this;
  13389. }
  13390. }
  13391. class xr extends o {
  13392. constructor(a, u, v) {
  13393. super(a), this.cell = u, this.index = v;
  13394. }
  13395. }
  13396. class Ps extends r {
  13397. constructor(a) {
  13398. super(a), this.cellToApiMap_ = /* @__PURE__ */ new Map(), this.emitter_ = new w();
  13399. const u = this.controller_.valueController;
  13400. u.cellControllers.forEach((v, x) => {
  13401. const T = new Cs(v);
  13402. this.cellToApiMap_.set(v, T), v.emitter.on("click", () => {
  13403. const V2 = x % u.size[0], z = Math.floor(x / u.size[0]);
  13404. this.emitter_.emit("click", {
  13405. event: new xr(this, T, [V2, z])
  13406. });
  13407. });
  13408. });
  13409. }
  13410. cell(a, u) {
  13411. const v = this.controller_.valueController, x = v.cellControllers[u * v.size[0] + a];
  13412. return this.cellToApiMap_.get(x);
  13413. }
  13414. on(a, u) {
  13415. const v = u.bind(this);
  13416. return this.emitter_.on(a, (x) => {
  13417. v(x.event);
  13418. }), this;
  13419. }
  13420. }
  13421. class Si {
  13422. constructor(a, u) {
  13423. this.size = u.size;
  13424. const [v, x] = this.size, T = [];
  13425. for (let V2 = 0; V2 < x; V2++)
  13426. for (let z = 0; z < v; z++) {
  13427. const re = new G(a, {
  13428. props: K2.fromObject(Object.assign({}, u.cellConfig(z, V2))),
  13429. viewProps: ge.create()
  13430. });
  13431. T.push(re);
  13432. }
  13433. this.cellCs_ = T, this.viewProps = ge.create(), this.viewProps.handleDispose(() => {
  13434. this.cellCs_.forEach((V2) => {
  13435. V2.viewProps.set("disposed", true);
  13436. });
  13437. }), this.view = new Et2(a, {
  13438. viewProps: this.viewProps,
  13439. viewName: "btngrid"
  13440. }), this.view.element.style.gridTemplateColumns = `repeat(${v}, 1fr)`, this.cellCs_.forEach((V2) => {
  13441. this.view.element.appendChild(V2.view.element);
  13442. });
  13443. }
  13444. get cellControllers() {
  13445. return this.cellCs_;
  13446. }
  13447. }
  13448. const Er = {
  13449. id: "buttongrid",
  13450. type: "blade",
  13451. // TODO:
  13452. css: '.tp-cbzgv,.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{background-color:var(--btn-bg);border-radius:var(--elm-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--bld-us);line-height:var(--bld-us);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-radv_b:hover,.tp-rslv_k:hover,.tp-cbzv_b:hover{background-color:var(--btn-bg-h)}.tp-radv_b:focus,.tp-rslv_k:focus,.tp-cbzv_b:focus{background-color:var(--btn-bg-f)}.tp-radv_b:active,.tp-rslv_k:active,.tp-cbzv_b:active{background-color:var(--btn-bg-a)}.tp-radv_b:disabled,.tp-rslv_k:disabled,.tp-cbzv_b:disabled{opacity:.5}.tp-cbzgv{background-color:var(--in-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--bld-us);line-height:var(--bld-us);min-width:0;width:100%}.tp-cbzgv:hover{background-color:var(--in-bg-h)}.tp-cbzgv:focus{background-color:var(--in-bg-f)}.tp-cbzgv:active{background-color:var(--in-bg-a)}.tp-cbzgv:disabled{opacity:.5}.tp-btngridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-btngridv.tp-v-disabled{opacity:.5}.tp-btngridv .tp-btnv_b:disabled{opacity:1}.tp-btngridv .tp-btnv_b:disabled .tp-btnv_t{opacity:.5}.tp-btngridv .tp-btnv_b{border-radius:0}.tp-cbzv{position:relative}.tp-cbzv_h{display:flex}.tp-cbzv_b{margin-right:4px;position:relative;width:var(--bld-us)}.tp-cbzv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-cbzv_b svg path{stroke:var(--bs-bg);stroke-width:2}.tp-cbzv_t{flex:1}.tp-cbzv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-cbzv.tp-cbzv-expanded .tp-cbzv_p{margin-top:var(--bld-s);opacity:1}.tp-cbzv.tp-cbzv-cpl .tp-cbzv_p{overflow:visible}.tp-cbzv .tp-popv{left:calc(-1*var(--cnt-h-p));position:absolute;right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-cbzpv_t{margin-top:var(--bld-s)}.tp-cbzgv{height:auto;overflow:hidden;position:relative}.tp-cbzgv.tp-v-disabled{opacity:.5}.tp-cbzgv_p{left:16px;position:absolute;right:16px;top:0}.tp-cbzgv_g{cursor:pointer;display:block;height:calc(var(--bld-us)*5);width:100%}.tp-cbzgv_u{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_l{fill:rgba(0,0,0,0);stroke:var(--in-fg)}.tp-cbzgv_v{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_h{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;pointer-events:none;position:absolute;width:4px}.tp-cbzgv:focus .tp-cbzgv_h-sel{background-color:var(--in-fg);border-width:0}.tp-cbzprvv{cursor:pointer;height:4px;padding:4px 0;position:relative}.tp-cbzprvv_g{display:block;height:100%;overflow:visible;width:100%}.tp-cbzprvv_t{opacity:.5;stroke:var(--mo-fg)}.tp-cbzprvv_m{background-color:var(--mo-fg);border-radius:50%;height:4px;margin-left:-2px;margin-top:-2px;opacity:0;position:absolute;top:50%;transition:opacity .2s ease-out;width:4px}.tp-cbzprvv_m.tp-cbzprvv_m-a{opacity:1}.tp-fpsv{position:relative}.tp-fpsv_l{bottom:4px;color:var(--mo-fg);line-height:1;right:4px;pointer-events:none;position:absolute}.tp-fpsv_u{margin-left:.2em;opacity:.7}.tp-rslv{cursor:pointer;padding-left:8px;padding-right:8px}.tp-rslv.tp-v-disabled{opacity:.5}.tp-rslv_t{height:calc(var(--bld-us));position:relative}.tp-rslv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:-4px;right:-4px}.tp-rslv_b{bottom:0;top:0;position:absolute}.tp-rslv_b::before{background-color:var(--in-fg);content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:0;right:0}.tp-rslv_k{height:calc(var(--bld-us) - 8px);margin-top:calc((var(--bld-us) - 8px)/-2);position:absolute;top:50%;width:8px}.tp-rslv_k.tp-rslv_k-min{margin-left:-8px}.tp-rslv_k.tp-rslv_k-max{margin-left:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-min{border-bottom-right-radius:0;border-top-right-radius:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-max{border-bottom-left-radius:0;border-top-left-radius:0}.tp-rsltxtv{display:flex}.tp-rsltxtv_s{flex:1}.tp-rsltxtv_t{flex:1;margin-left:4px}.tp-radv_l{display:block;position:relative}.tp-radv_i{left:0;opacity:0;position:absolute;top:0}.tp-radv_b{opacity:.5}.tp-radv_i:hover+.tp-radv_b{background-color:var(--btn-bg-h)}.tp-radv_i:focus+.tp-radv_b{background-color:var(--btn-bg-f)}.tp-radv_i:active+.tp-radv_b{background-color:var(--btn-bg-a)}.tp-radv_i:checked+.tp-radv_b{opacity:1}.tp-radv_t{bottom:0;color:inherit;left:0;overflow:hidden;position:absolute;right:0;text-align:center;text-overflow:ellipsis;top:0}.tp-radv_i:disabled+.tp-radv_b>.tp-radv_t{opacity:.5}.tp-radgridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-radgridv.tp-v-disabled{opacity:.5}.tp-radgridv .tp-radv_b{border-radius:0}',
  13453. accept(d) {
  13454. const a = he, u = ee(d, {
  13455. cells: a.required.function,
  13456. size: a.required.array(a.required.number),
  13457. view: a.required.constant("buttongrid"),
  13458. label: a.optional.string
  13459. });
  13460. return u ? { params: u } : null;
  13461. },
  13462. controller(d) {
  13463. return new ot2(d.document, {
  13464. blade: d.blade,
  13465. props: K2.fromObject({
  13466. label: d.params.label
  13467. }),
  13468. valueController: new Si(d.document, {
  13469. cellConfig: d.params.cells,
  13470. size: d.params.size
  13471. })
  13472. });
  13473. },
  13474. api(d) {
  13475. return !(d.controller instanceof ot2) || !(d.controller.valueController instanceof Si) ? null : new Ps(d.controller);
  13476. }
  13477. };
  13478. class Ts extends r {
  13479. get label() {
  13480. return this.controller_.props.get("label");
  13481. }
  13482. set label(a) {
  13483. this.controller_.props.set("label", a);
  13484. }
  13485. get value() {
  13486. return this.controller_.valueController.value.rawValue;
  13487. }
  13488. set value(a) {
  13489. this.controller_.valueController.value.rawValue = a;
  13490. }
  13491. on(a, u) {
  13492. const v = u.bind(this);
  13493. return this.controller_.valueController.value.emitter.on(a, (x) => {
  13494. v(new c(this, x.rawValue, void 0, x.options.last));
  13495. }), this;
  13496. }
  13497. }
  13498. function Je(d, a, u) {
  13499. return d * (1 - u) + a * u;
  13500. }
  13501. const Cr = 20, Pr = 1e-3, Li = 100;
  13502. function Tr(d, a) {
  13503. let u = 0.25, v = 0.5, x = -1;
  13504. for (let T = 0; T < Cr; T++) {
  13505. const [V2, z] = d.curve(v);
  13506. if (v += u * (V2 < a ? 1 : -1), x = z, u *= 0.5, Math.abs(a - V2) < Pr)
  13507. break;
  13508. }
  13509. return x;
  13510. }
  13511. class Pt {
  13512. constructor(a = 0, u = 0, v = 1, x = 1) {
  13513. this.cache_ = [], this.comps_ = [a, u, v, x];
  13514. }
  13515. get x1() {
  13516. return this.comps_[0];
  13517. }
  13518. get y1() {
  13519. return this.comps_[1];
  13520. }
  13521. get x2() {
  13522. return this.comps_[2];
  13523. }
  13524. get y2() {
  13525. return this.comps_[3];
  13526. }
  13527. static isObject(a) {
  13528. return h2(a) || !Array.isArray(a) ? false : typeof a[0] == "number" && typeof a[1] == "number" && typeof a[2] == "number" && typeof a[3] == "number";
  13529. }
  13530. static equals(a, u) {
  13531. return a.x1 === u.x1 && a.y1 === u.y1 && a.x2 === u.x2 && a.y2 === u.y2;
  13532. }
  13533. curve(a) {
  13534. const u = Je(0, this.x1, a), v = Je(0, this.y1, a), x = Je(this.x1, this.x2, a), T = Je(this.y1, this.y2, a), V2 = Je(this.x2, 1, a), z = Je(this.y2, 1, a), re = Je(u, x, a), et2 = Je(v, T, a), tt2 = Je(x, V2, a), te = Je(T, z, a);
  13535. return [Je(re, tt2, a), Je(et2, te, a)];
  13536. }
  13537. y(a) {
  13538. if (this.cache_.length === 0) {
  13539. const u = [];
  13540. for (let v = 0; v < Li; v++)
  13541. u.push(Tr(this, Le(v, 0, Li - 1, 0, 1)));
  13542. this.cache_ = u;
  13543. }
  13544. return this.cache_[Math.round(Le(Xt(a, 0, 1), 0, 1, 0, Li - 1))];
  13545. }
  13546. toObject() {
  13547. return [this.comps_[0], this.comps_[1], this.comps_[2], this.comps_[3]];
  13548. }
  13549. }
  13550. const Ri = {
  13551. toComponents: (d) => d.toObject(),
  13552. fromComponents: (d) => new Pt(...d)
  13553. };
  13554. function kr(d) {
  13555. const a = Ie(2);
  13556. return `cubic-bezier(${d.toObject().map((v) => a(v)).join(", ")})`;
  13557. }
  13558. const Vi = [0, 0.5, 0.5, 1];
  13559. function Ar(d) {
  13560. const a = d.match(/^cubic-bezier\s*\(\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*\)$/);
  13561. if (!a)
  13562. return new Pt(...Vi);
  13563. const u = [a[1], a[2], a[3], a[4]].reduce((v, x) => {
  13564. if (!v)
  13565. return null;
  13566. const T = Number(x);
  13567. return isNaN(T) ? null : [...v, T];
  13568. }, []);
  13569. return new Pt(...u ?? Vi);
  13570. }
  13571. const Vt = y("cbz");
  13572. class ks {
  13573. constructor(a, u) {
  13574. this.element = a.createElement("div"), this.element.classList.add(Vt()), u.viewProps.bindClassModifiers(this.element), u.foldable.bindExpandedClass(this.element, Vt(void 0, "expanded")), R(u.foldable, "completed", N(this.element, Vt(void 0, "cpl")));
  13575. const v = a.createElement("div");
  13576. v.classList.add(Vt("h")), this.element.appendChild(v);
  13577. const x = a.createElement("button");
  13578. x.classList.add(Vt("b")), u.viewProps.bindDisabled(x);
  13579. const T = a.createElementNS(xe2, "svg");
  13580. T.innerHTML = '<path d="M2 13C8 13 8 3 14 3"/>', x.appendChild(T), v.appendChild(x), this.buttonElement = x;
  13581. const V2 = a.createElement("div");
  13582. if (V2.classList.add(Vt("t")), v.appendChild(V2), this.textElement = V2, u.pickerLayout === "inline") {
  13583. const z = a.createElement("div");
  13584. z.classList.add(Vt("p")), this.element.appendChild(z), this.pickerElement = z;
  13585. } else
  13586. this.pickerElement = null;
  13587. }
  13588. }
  13589. const ti = y("cbzp");
  13590. class As {
  13591. constructor(a, u) {
  13592. this.element = a.createElement("div"), this.element.classList.add(ti()), u.viewProps.bindClassModifiers(this.element);
  13593. const v = a.createElement("div");
  13594. v.classList.add(ti("g")), this.element.appendChild(v), this.graphElement = v;
  13595. const x = a.createElement("div");
  13596. x.classList.add(ti("t")), this.element.appendChild(x), this.textElement = x;
  13597. }
  13598. }
  13599. function ct2(d, a) {
  13600. const u = new MutationObserver((x) => {
  13601. for (const T of x)
  13602. T.type === "childList" && T.addedNodes.forEach((V2) => {
  13603. V2.contains(V2) && (a(), u.disconnect());
  13604. });
  13605. }), v = d.ownerDocument;
  13606. u.observe(v.body, {
  13607. attributes: true,
  13608. childList: true,
  13609. subtree: true
  13610. });
  13611. }
  13612. const _t = y("cbzg");
  13613. function Mr(d, a) {
  13614. return (u) => a(d(u));
  13615. }
  13616. class De {
  13617. constructor(a, u) {
  13618. this.element = a.createElement("div"), this.element.classList.add(_t()), u.viewProps.bindClassModifiers(this.element), u.viewProps.bindTabIndex(this.element);
  13619. const v = a.createElement("div");
  13620. v.classList.add(_t("p")), this.element.appendChild(v), this.previewElement = v;
  13621. const x = a.createElementNS(xe2, "svg");
  13622. x.classList.add(_t("g")), this.element.appendChild(x), this.svgElem_ = x;
  13623. const T = a.createElementNS(xe2, "path");
  13624. T.classList.add(_t("u")), this.svgElem_.appendChild(T), this.guideElem_ = T;
  13625. const V2 = a.createElementNS(xe2, "polyline");
  13626. V2.classList.add(_t("l")), this.svgElem_.appendChild(V2), this.lineElem_ = V2, this.handleElems_ = [a.createElement("div"), a.createElement("div")], this.handleElems_.forEach((z) => {
  13627. z.classList.add(_t("h")), this.element.appendChild(z);
  13628. }), this.vectorElems_ = [
  13629. a.createElementNS(xe2, "line"),
  13630. a.createElementNS(xe2, "line")
  13631. ], this.vectorElems_.forEach((z) => {
  13632. z.classList.add(_t("v")), this.svgElem_.appendChild(z);
  13633. }), this.value_ = u.value, this.value_.emitter.on("change", this.onValueChange_.bind(this)), this.sel_ = u.selection, this.handleElems_.forEach((z, re) => {
  13634. S(this.sel_, Mr((et2) => et2 === re, N(z, _t("h", "sel"))));
  13635. }), ct2(this.element, () => {
  13636. this.refresh();
  13637. });
  13638. }
  13639. getVertMargin_(a) {
  13640. return a * 0.25;
  13641. }
  13642. valueToPosition(a, u) {
  13643. const v = this.element.getBoundingClientRect(), x = v.width, T = v.height, V2 = this.getVertMargin_(T);
  13644. return {
  13645. x: Le(a, 0, 1, 0, x),
  13646. y: Le(u, 0, 1, T - V2, V2)
  13647. };
  13648. }
  13649. positionToValue(a, u) {
  13650. const v = this.element.getBoundingClientRect(), x = v.width, T = v.height, V2 = this.getVertMargin_(T);
  13651. return {
  13652. x: Xt(Le(a, 0, x, 0, 1), 0, 1),
  13653. y: Le(u, T - V2, V2, 0, 1)
  13654. };
  13655. }
  13656. refresh() {
  13657. this.guideElem_.setAttributeNS(null, "d", [0, 1].map((T) => {
  13658. const V2 = this.valueToPosition(0, T), z = this.valueToPosition(1, T);
  13659. return [`M ${V2.x},${V2.y}`, `L ${z.x},${z.y}`].join(" ");
  13660. }).join(" "));
  13661. const a = this.value_.rawValue, u = [];
  13662. let v = 0;
  13663. for (; ; ) {
  13664. const T = this.valueToPosition(...a.curve(v));
  13665. if (u.push([T.x, T.y].join(",")), v >= 1)
  13666. break;
  13667. v = Math.min(v + 0.05, 1);
  13668. }
  13669. this.lineElem_.setAttributeNS(null, "points", u.join(" "));
  13670. const x = a.toObject();
  13671. [0, 1].forEach((T) => {
  13672. const V2 = this.valueToPosition(T, T), z = this.valueToPosition(x[T * 2], x[T * 2 + 1]), re = this.vectorElems_[T];
  13673. re.setAttributeNS(null, "x1", String(V2.x)), re.setAttributeNS(null, "y1", String(V2.y)), re.setAttributeNS(null, "x2", String(z.x)), re.setAttributeNS(null, "y2", String(z.y));
  13674. const et2 = this.handleElems_[T];
  13675. et2.style.left = `${z.x}px`, et2.style.top = `${z.y}px`;
  13676. });
  13677. }
  13678. onValueChange_() {
  13679. this.refresh();
  13680. }
  13681. }
  13682. const Ms = 24, Cn = 400, Ii = 1e3, Tt = y("cbzprv");
  13683. class Qt {
  13684. constructor(a, u) {
  13685. this.stopped_ = true, this.startTime_ = -1, this.onDispose_ = this.onDispose_.bind(this), this.onTimer_ = this.onTimer_.bind(this), this.onValueChange_ = this.onValueChange_.bind(this), this.element = a.createElement("div"), this.element.classList.add(Tt()), u.viewProps.bindClassModifiers(this.element);
  13686. const v = a.createElementNS(xe2, "svg");
  13687. v.classList.add(Tt("g")), this.element.appendChild(v), this.svgElem_ = v;
  13688. const x = a.createElementNS(xe2, "path");
  13689. x.classList.add(Tt("t")), this.svgElem_.appendChild(x), this.ticksElem_ = x;
  13690. const T = a.createElement("div");
  13691. T.classList.add(Tt("m")), this.element.appendChild(T), this.markerElem_ = T, this.value_ = u.value, this.value_.emitter.on("change", this.onValueChange_), u.viewProps.handleDispose(this.onDispose_), ct2(this.element, () => {
  13692. this.refresh();
  13693. });
  13694. }
  13695. play() {
  13696. this.stop(), this.updateMarker_(0), this.markerElem_.classList.add(Tt("m", "a")), this.startTime_ = (/* @__PURE__ */ new Date()).getTime() + Cn, this.stopped_ = false, requestAnimationFrame(this.onTimer_);
  13697. }
  13698. stop() {
  13699. this.stopped_ = true, this.markerElem_.classList.remove(Tt("m", "a"));
  13700. }
  13701. onDispose_() {
  13702. this.stop();
  13703. }
  13704. updateMarker_(a) {
  13705. const u = this.value_.rawValue.y(Xt(a, 0, 1));
  13706. this.markerElem_.style.left = `${u * 100}%`;
  13707. }
  13708. refresh() {
  13709. const a = this.svgElem_.getBoundingClientRect(), u = a.width, v = a.height, x = [], T = this.value_.rawValue;
  13710. for (let V2 = 0; V2 < Ms; V2++) {
  13711. const z = Le(V2, 0, Ms - 1, 0, 1), re = Le(T.y(z), 0, 1, 0, u);
  13712. x.push(`M ${re},0 v${v}`);
  13713. }
  13714. this.ticksElem_.setAttributeNS(null, "d", x.join(" "));
  13715. }
  13716. onTimer_() {
  13717. if (this.startTime_ === null)
  13718. return;
  13719. const a = (/* @__PURE__ */ new Date()).getTime() - this.startTime_, u = a / Ii;
  13720. this.updateMarker_(u), a > Ii + Cn && this.stop(), this.stopped_ || requestAnimationFrame(this.onTimer_);
  13721. }
  13722. onValueChange_() {
  13723. this.refresh(), this.play();
  13724. }
  13725. }
  13726. function je(d, a, u, v) {
  13727. const x = u - d, T = v - a;
  13728. return Math.sqrt(x * x + T * T);
  13729. }
  13730. function Pn(d, a, u, v) {
  13731. const x = je(d, a, u, v), T = Math.atan2(v - a, u - d), V2 = Math.round(T / (Math.PI / 4)) * Math.PI / 4;
  13732. return {
  13733. x: d + Math.cos(V2) * x,
  13734. y: a + Math.sin(V2) * x
  13735. };
  13736. }
  13737. class ut2 {
  13738. constructor(a, u) {
  13739. this.onKeyDown_ = this.onKeyDown_.bind(this), this.onKeyUp_ = this.onKeyUp_.bind(this), this.onPointerDown_ = this.onPointerDown_.bind(this), this.onPointerMove_ = this.onPointerMove_.bind(this), this.onPointerUp_ = this.onPointerUp_.bind(this), this.baseStep_ = u.baseStep, this.value = u.value, this.sel_ = H2(0), this.viewProps = u.viewProps, this.view = new De(a, {
  13740. selection: this.sel_,
  13741. value: this.value,
  13742. viewProps: this.viewProps
  13743. }), this.view.element.addEventListener("keydown", this.onKeyDown_), this.view.element.addEventListener("keyup", this.onKeyUp_), this.prevView_ = new Qt(a, {
  13744. value: this.value,
  13745. viewProps: this.viewProps
  13746. }), this.prevView_.element.addEventListener("mousedown", (x) => {
  13747. x.stopImmediatePropagation(), x.preventDefault(), this.prevView_.play();
  13748. }), this.view.previewElement.appendChild(this.prevView_.element);
  13749. const v = new Wn(this.view.element);
  13750. v.emitter.on("down", this.onPointerDown_), v.emitter.on("move", this.onPointerMove_), v.emitter.on("up", this.onPointerUp_);
  13751. }
  13752. refresh() {
  13753. this.view.refresh(), this.prevView_.refresh(), this.prevView_.play();
  13754. }
  13755. updateValue_(a, u, v) {
  13756. const x = this.sel_.rawValue, T = this.value.rawValue.toObject(), V2 = this.view.positionToValue(a.x, a.y), z = u ? Pn(x, x, V2.x, V2.y) : V2;
  13757. T[x * 2] = z.x, T[x * 2 + 1] = z.y, this.value.setRawValue(new Pt(...T), v);
  13758. }
  13759. onPointerDown_(a) {
  13760. const u = a.data;
  13761. if (!u.point)
  13762. return;
  13763. const v = this.value.rawValue, x = this.view.valueToPosition(v.x1, v.y1), T = je(u.point.x, u.point.y, x.x, x.y), V2 = this.view.valueToPosition(v.x2, v.y2), z = je(u.point.x, u.point.y, V2.x, V2.y);
  13764. this.sel_.rawValue = T <= z ? 0 : 1, this.updateValue_(u.point, a.shiftKey, {
  13765. forceEmit: false,
  13766. last: false
  13767. });
  13768. }
  13769. onPointerMove_(a) {
  13770. const u = a.data;
  13771. u.point && this.updateValue_(u.point, a.shiftKey, {
  13772. forceEmit: false,
  13773. last: false
  13774. });
  13775. }
  13776. onPointerUp_(a) {
  13777. const u = a.data;
  13778. u.point && this.updateValue_(u.point, a.shiftKey, {
  13779. forceEmit: true,
  13780. last: true
  13781. });
  13782. }
  13783. onKeyDown_(a) {
  13784. ms(a.key) && a.preventDefault();
  13785. const u = this.sel_.rawValue, v = this.value.rawValue.toObject();
  13786. v[u * 2] += $t(this.baseStep_, Ti(a)), v[u * 2 + 1] += $t(this.baseStep_, _n(a)), this.value.setRawValue(new Pt(...v), {
  13787. forceEmit: false,
  13788. last: false
  13789. });
  13790. }
  13791. onKeyUp_(a) {
  13792. ms(a.key) && a.preventDefault();
  13793. const u = $t(this.baseStep_, Ti(a)), v = $t(this.baseStep_, _n(a));
  13794. u === 0 && v === 0 || this.value.setRawValue(this.value.rawValue, {
  13795. forceEmit: true,
  13796. last: true
  13797. });
  13798. }
  13799. }
  13800. class Ss {
  13801. constructor(a, u) {
  13802. this.value = u.value, this.viewProps = u.viewProps, this.view = new As(a, {
  13803. viewProps: this.viewProps
  13804. }), this.gc_ = new ut2(a, {
  13805. baseStep: u.axis.baseStep,
  13806. value: this.value,
  13807. viewProps: this.viewProps
  13808. }), this.view.graphElement.appendChild(this.gc_.view.element);
  13809. const v = Object.assign(Object.assign({}, u.axis), { constraint: new St({ max: 1, min: 0 }) }), x = Object.assign(Object.assign({}, u.axis), { constraint: void 0 });
  13810. this.tc_ = new Rt2(a, {
  13811. assembly: Ri,
  13812. axes: [v, x, v, x],
  13813. parser: gn,
  13814. value: this.value,
  13815. viewProps: this.viewProps
  13816. }), this.view.textElement.appendChild(this.tc_.view.element);
  13817. }
  13818. get allFocusableElements() {
  13819. return [
  13820. this.gc_.view.element,
  13821. ...this.tc_.view.textViews.map((a) => a.inputElement)
  13822. ];
  13823. }
  13824. refresh() {
  13825. this.gc_.refresh();
  13826. }
  13827. }
  13828. class ni {
  13829. constructor(a, u) {
  13830. this.onButtonBlur_ = this.onButtonBlur_.bind(this), this.onButtonClick_ = this.onButtonClick_.bind(this), this.onPopupChildBlur_ = this.onPopupChildBlur_.bind(this), this.onPopupChildKeydown_ = this.onPopupChildKeydown_.bind(this), this.value = u.value, this.viewProps = u.viewProps, this.foldable_ = Hn(u.expanded), this.view = new ks(a, {
  13831. foldable: this.foldable_,
  13832. pickerLayout: u.pickerLayout,
  13833. viewProps: this.viewProps
  13834. }), this.view.buttonElement.addEventListener("blur", this.onButtonBlur_), this.view.buttonElement.addEventListener("click", this.onButtonClick_), this.tc_ = new Gt(a, {
  13835. parser: Ar,
  13836. props: K2.fromObject({
  13837. formatter: kr
  13838. }),
  13839. value: this.value,
  13840. viewProps: this.viewProps
  13841. }), this.view.textElement.appendChild(this.tc_.view.element), this.popC_ = u.pickerLayout === "popup" ? new ie2(a, {
  13842. viewProps: this.viewProps
  13843. }) : null;
  13844. const v = new Ss(a, {
  13845. axis: u.axis,
  13846. value: this.value,
  13847. viewProps: this.viewProps
  13848. });
  13849. v.allFocusableElements.forEach((x) => {
  13850. x.addEventListener("blur", this.onPopupChildBlur_), x.addEventListener("keydown", this.onPopupChildKeydown_);
  13851. }), this.pickerC_ = v, this.popC_ ? (this.view.element.appendChild(this.popC_.view.element), this.popC_.view.element.appendChild(this.pickerC_.view.element), S(this.popC_.shows, (x) => {
  13852. x && v.refresh();
  13853. }), Kt({
  13854. primary: this.foldable_.value("expanded"),
  13855. secondary: this.popC_.shows,
  13856. forward: (x) => x.rawValue,
  13857. backward: (x, T) => T.rawValue
  13858. })) : this.view.pickerElement && (this.view.pickerElement.appendChild(this.pickerC_.view.element), $n(this.foldable_, this.view.pickerElement));
  13859. }
  13860. onButtonBlur_(a) {
  13861. if (!this.popC_)
  13862. return;
  13863. const u = a.relatedTarget;
  13864. (!u || !this.popC_.view.element.contains(u)) && (this.popC_.shows.rawValue = false);
  13865. }
  13866. onButtonClick_() {
  13867. this.foldable_.set("expanded", !this.foldable_.get("expanded")), this.foldable_.get("expanded") && this.pickerC_.allFocusableElements[0].focus();
  13868. }
  13869. onPopupChildBlur_(a) {
  13870. if (!this.popC_)
  13871. return;
  13872. const u = this.popC_.view.element, v = hn(a);
  13873. v && u.contains(v) || v && v === this.view.buttonElement && !Ze2(u.ownerDocument) || (this.popC_.shows.rawValue = false);
  13874. }
  13875. onPopupChildKeydown_(a) {
  13876. this.popC_ && a.key === "Escape" && (this.popC_.shows.rawValue = false);
  13877. }
  13878. }
  13879. function Di() {
  13880. return new br({
  13881. assembly: Ri,
  13882. components: [0, 1, 2, 3].map((d) => d % 2 === 0 ? new St({
  13883. min: 0,
  13884. max: 1
  13885. }) : void 0)
  13886. });
  13887. }
  13888. const It = {
  13889. id: "cubic-bezier",
  13890. type: "blade",
  13891. css: '.tp-cbzgv,.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{background-color:var(--btn-bg);border-radius:var(--elm-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--bld-us);line-height:var(--bld-us);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-radv_b:hover,.tp-rslv_k:hover,.tp-cbzv_b:hover{background-color:var(--btn-bg-h)}.tp-radv_b:focus,.tp-rslv_k:focus,.tp-cbzv_b:focus{background-color:var(--btn-bg-f)}.tp-radv_b:active,.tp-rslv_k:active,.tp-cbzv_b:active{background-color:var(--btn-bg-a)}.tp-radv_b:disabled,.tp-rslv_k:disabled,.tp-cbzv_b:disabled{opacity:.5}.tp-cbzgv{background-color:var(--in-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--bld-us);line-height:var(--bld-us);min-width:0;width:100%}.tp-cbzgv:hover{background-color:var(--in-bg-h)}.tp-cbzgv:focus{background-color:var(--in-bg-f)}.tp-cbzgv:active{background-color:var(--in-bg-a)}.tp-cbzgv:disabled{opacity:.5}.tp-btngridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-btngridv.tp-v-disabled{opacity:.5}.tp-btngridv .tp-btnv_b:disabled{opacity:1}.tp-btngridv .tp-btnv_b:disabled .tp-btnv_t{opacity:.5}.tp-btngridv .tp-btnv_b{border-radius:0}.tp-cbzv{position:relative}.tp-cbzv_h{display:flex}.tp-cbzv_b{margin-right:4px;position:relative;width:var(--bld-us)}.tp-cbzv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-cbzv_b svg path{stroke:var(--bs-bg);stroke-width:2}.tp-cbzv_t{flex:1}.tp-cbzv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-cbzv.tp-cbzv-expanded .tp-cbzv_p{margin-top:var(--bld-s);opacity:1}.tp-cbzv.tp-cbzv-cpl .tp-cbzv_p{overflow:visible}.tp-cbzv .tp-popv{left:calc(-1*var(--cnt-h-p));position:absolute;right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-cbzpv_t{margin-top:var(--bld-s)}.tp-cbzgv{height:auto;overflow:hidden;position:relative}.tp-cbzgv.tp-v-disabled{opacity:.5}.tp-cbzgv_p{left:16px;position:absolute;right:16px;top:0}.tp-cbzgv_g{cursor:pointer;display:block;height:calc(var(--bld-us)*5);width:100%}.tp-cbzgv_u{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_l{fill:rgba(0,0,0,0);stroke:var(--in-fg)}.tp-cbzgv_v{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_h{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;pointer-events:none;position:absolute;width:4px}.tp-cbzgv:focus .tp-cbzgv_h-sel{background-color:var(--in-fg);border-width:0}.tp-cbzprvv{cursor:pointer;height:4px;padding:4px 0;position:relative}.tp-cbzprvv_g{display:block;height:100%;overflow:visible;width:100%}.tp-cbzprvv_t{opacity:.5;stroke:var(--mo-fg)}.tp-cbzprvv_m{background-color:var(--mo-fg);border-radius:50%;height:4px;margin-left:-2px;margin-top:-2px;opacity:0;position:absolute;top:50%;transition:opacity .2s ease-out;width:4px}.tp-cbzprvv_m.tp-cbzprvv_m-a{opacity:1}.tp-fpsv{position:relative}.tp-fpsv_l{bottom:4px;color:var(--mo-fg);line-height:1;right:4px;pointer-events:none;position:absolute}.tp-fpsv_u{margin-left:.2em;opacity:.7}.tp-rslv{cursor:pointer;padding-left:8px;padding-right:8px}.tp-rslv.tp-v-disabled{opacity:.5}.tp-rslv_t{height:calc(var(--bld-us));position:relative}.tp-rslv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:-4px;right:-4px}.tp-rslv_b{bottom:0;top:0;position:absolute}.tp-rslv_b::before{background-color:var(--in-fg);content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:0;right:0}.tp-rslv_k{height:calc(var(--bld-us) - 8px);margin-top:calc((var(--bld-us) - 8px)/-2);position:absolute;top:50%;width:8px}.tp-rslv_k.tp-rslv_k-min{margin-left:-8px}.tp-rslv_k.tp-rslv_k-max{margin-left:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-min{border-bottom-right-radius:0;border-top-right-radius:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-max{border-bottom-left-radius:0;border-top-left-radius:0}.tp-rsltxtv{display:flex}.tp-rsltxtv_s{flex:1}.tp-rsltxtv_t{flex:1;margin-left:4px}.tp-radv_l{display:block;position:relative}.tp-radv_i{left:0;opacity:0;position:absolute;top:0}.tp-radv_b{opacity:.5}.tp-radv_i:hover+.tp-radv_b{background-color:var(--btn-bg-h)}.tp-radv_i:focus+.tp-radv_b{background-color:var(--btn-bg-f)}.tp-radv_i:active+.tp-radv_b{background-color:var(--btn-bg-a)}.tp-radv_i:checked+.tp-radv_b{opacity:1}.tp-radv_t{bottom:0;color:inherit;left:0;overflow:hidden;position:absolute;right:0;text-align:center;text-overflow:ellipsis;top:0}.tp-radv_i:disabled+.tp-radv_b>.tp-radv_t{opacity:.5}.tp-radgridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-radgridv.tp-v-disabled{opacity:.5}.tp-radgridv .tp-radv_b{border-radius:0}',
  13892. accept(d) {
  13893. const a = he, u = ee(d, {
  13894. value: a.required.array(a.required.number),
  13895. view: a.required.constant("cubicbezier"),
  13896. expanded: a.optional.boolean,
  13897. label: a.optional.string,
  13898. picker: a.optional.custom((v) => v === "inline" || v === "popup" ? v : void 0)
  13899. });
  13900. return u ? { params: u } : null;
  13901. },
  13902. controller(d) {
  13903. var a, u;
  13904. const v = new Pt(...d.params.value), x = H2(v, {
  13905. constraint: Di(),
  13906. equals: Pt.equals
  13907. }), T = new ni(d.document, {
  13908. axis: {
  13909. baseStep: 0.1,
  13910. textProps: K2.fromObject({
  13911. draggingScale: 0.01,
  13912. formatter: Ie(2)
  13913. })
  13914. },
  13915. expanded: (a = d.params.expanded) !== null && a !== void 0 ? a : false,
  13916. pickerLayout: (u = d.params.picker) !== null && u !== void 0 ? u : "popup",
  13917. value: x,
  13918. viewProps: d.viewProps
  13919. });
  13920. return new Mt(d.document, {
  13921. blade: d.blade,
  13922. props: K2.fromObject({
  13923. label: d.params.label
  13924. }),
  13925. valueController: T
  13926. });
  13927. },
  13928. api(d) {
  13929. return !(d.controller instanceof Mt) || !(d.controller.valueController instanceof ni) ? null : new Ts(d.controller);
  13930. }
  13931. };
  13932. class we extends r {
  13933. begin() {
  13934. this.controller_.valueController.begin();
  13935. }
  13936. end() {
  13937. this.controller_.valueController.end();
  13938. }
  13939. }
  13940. const Oi = 20;
  13941. class Re2 {
  13942. constructor() {
  13943. this.start_ = null, this.duration_ = 0, this.fps_ = null, this.frameCount_ = 0, this.timestamps_ = [];
  13944. }
  13945. get duration() {
  13946. return this.duration_;
  13947. }
  13948. get fps() {
  13949. return this.fps_;
  13950. }
  13951. begin(a) {
  13952. this.start_ = a.getTime();
  13953. }
  13954. calculateFps_(a) {
  13955. if (this.timestamps_.length === 0)
  13956. return null;
  13957. const u = this.timestamps_[0];
  13958. return 1e3 * (this.frameCount_ - u.frameCount) / (a - u.time);
  13959. }
  13960. compactTimestamps_() {
  13961. if (this.timestamps_.length <= Oi)
  13962. return;
  13963. const a = this.timestamps_.length - Oi;
  13964. this.timestamps_.splice(0, a);
  13965. const u = this.timestamps_[0].frameCount;
  13966. this.timestamps_.forEach((v) => {
  13967. v.frameCount -= u;
  13968. }), this.frameCount_ -= u;
  13969. }
  13970. end(a) {
  13971. if (this.start_ === null)
  13972. return;
  13973. const u = a.getTime();
  13974. this.duration_ = u - this.start_, this.start_ = null, this.fps_ = this.calculateFps_(u), this.timestamps_.push({
  13975. frameCount: this.frameCount_,
  13976. time: u
  13977. }), ++this.frameCount_, this.compactTimestamps_();
  13978. }
  13979. }
  13980. const Zt = y("fps");
  13981. class Ye {
  13982. constructor(a, u) {
  13983. this.element = a.createElement("div"), this.element.classList.add(Zt()), u.viewProps.bindClassModifiers(this.element), this.graphElement = a.createElement("div"), this.graphElement.classList.add(Zt("g")), this.element.appendChild(this.graphElement);
  13984. const v = a.createElement("div");
  13985. v.classList.add(Zt("l")), this.element.appendChild(v);
  13986. const x = a.createElement("span");
  13987. x.classList.add(Zt("v")), x.textContent = "--", v.appendChild(x), this.valueElement = x;
  13988. const T = a.createElement("span");
  13989. T.classList.add(Zt("u")), T.textContent = "FPS", v.appendChild(T);
  13990. }
  13991. }
  13992. class Ni {
  13993. constructor(a, u) {
  13994. this.stopwatch_ = new Re2(), this.onTick_ = this.onTick_.bind(this), this.ticker_ = u.ticker, this.ticker_.emitter.on("tick", this.onTick_), this.value_ = u.value, this.viewProps = u.viewProps, this.view = new Ye(a, {
  13995. viewProps: this.viewProps
  13996. }), this.graphC_ = new yr(a, {
  13997. formatter: Ie(0),
  13998. lineCount: u.lineCount,
  13999. props: K2.fromObject({
  14000. maxValue: u.maxValue,
  14001. minValue: u.minValue
  14002. }),
  14003. value: this.value_,
  14004. viewProps: this.viewProps
  14005. }), this.view.graphElement.appendChild(this.graphC_.view.element), this.viewProps.handleDispose(() => {
  14006. this.graphC_.viewProps.set("disposed", true), this.ticker_.dispose();
  14007. });
  14008. }
  14009. begin() {
  14010. this.stopwatch_.begin(/* @__PURE__ */ new Date());
  14011. }
  14012. end() {
  14013. this.stopwatch_.end(/* @__PURE__ */ new Date());
  14014. }
  14015. onTick_() {
  14016. const a = this.stopwatch_.fps;
  14017. if (a !== null) {
  14018. const u = this.value_.rawValue;
  14019. this.value_.rawValue = cr(u, a), this.view.valueElement.textContent = a.toFixed(0);
  14020. }
  14021. }
  14022. }
  14023. function Tn(d, a) {
  14024. return a === 0 ? new Xn() : new mn(d, a ?? wr.monitor.defaultInterval);
  14025. }
  14026. const Bi = {
  14027. id: "fpsgraph",
  14028. type: "blade",
  14029. accept(d) {
  14030. const a = he, u = ee(d, {
  14031. view: a.required.constant("fpsgraph"),
  14032. interval: a.optional.number,
  14033. label: a.optional.string,
  14034. lineCount: a.optional.number,
  14035. max: a.optional.number,
  14036. min: a.optional.number
  14037. });
  14038. return u ? { params: u } : null;
  14039. },
  14040. controller(d) {
  14041. var a, u, v, x;
  14042. const T = (a = d.params.interval) !== null && a !== void 0 ? a : 500;
  14043. return new ot2(d.document, {
  14044. blade: d.blade,
  14045. props: K2.fromObject({
  14046. label: d.params.label
  14047. }),
  14048. valueController: new Ni(d.document, {
  14049. lineCount: (u = d.params.lineCount) !== null && u !== void 0 ? u : 2,
  14050. maxValue: (v = d.params.max) !== null && v !== void 0 ? v : 90,
  14051. minValue: (x = d.params.min) !== null && x !== void 0 ? x : 0,
  14052. ticker: Tn(d.document, T),
  14053. value: hs(80),
  14054. viewProps: d.viewProps
  14055. })
  14056. });
  14057. },
  14058. api(d) {
  14059. return !(d.controller instanceof ot2) || !(d.controller.valueController instanceof Ni) ? null : new we(d.controller);
  14060. }
  14061. };
  14062. class qe {
  14063. constructor(a, u) {
  14064. this.min = a, this.max = u;
  14065. }
  14066. static isObject(a) {
  14067. if (typeof a != "object" || a === null)
  14068. return false;
  14069. const u = a.min, v = a.max;
  14070. return !(typeof u != "number" || typeof v != "number");
  14071. }
  14072. static equals(a, u) {
  14073. return a.min === u.min && a.max === u.max;
  14074. }
  14075. get length() {
  14076. return this.max - this.min;
  14077. }
  14078. toObject() {
  14079. return {
  14080. min: this.min,
  14081. max: this.max
  14082. };
  14083. }
  14084. }
  14085. const Fi = {
  14086. fromComponents: (d) => new qe(d[0], d[1]),
  14087. toComponents: (d) => [d.min, d.max]
  14088. };
  14089. class kn {
  14090. constructor(a) {
  14091. this.edge = a;
  14092. }
  14093. constrain(a) {
  14094. var u, v, x, T, V2, z, re, et2;
  14095. if (a.min <= a.max)
  14096. return new qe((v = (u = this.edge) === null || u === void 0 ? void 0 : u.constrain(a.min)) !== null && v !== void 0 ? v : a.min, (T = (x = this.edge) === null || x === void 0 ? void 0 : x.constrain(a.max)) !== null && T !== void 0 ? T : a.max);
  14097. const tt2 = (a.min + a.max) / 2;
  14098. return new qe((z = (V2 = this.edge) === null || V2 === void 0 ? void 0 : V2.constrain(tt2)) !== null && z !== void 0 ? z : tt2, (et2 = (re = this.edge) === null || re === void 0 ? void 0 : re.constrain(tt2)) !== null && et2 !== void 0 ? et2 : tt2);
  14099. }
  14100. }
  14101. const ji = y("rsltxt");
  14102. class ii {
  14103. constructor(a, u) {
  14104. this.sliderView_ = u.sliderView, this.textView_ = u.textView, this.element = a.createElement("div"), this.element.classList.add(ji());
  14105. const v = a.createElement("div");
  14106. v.classList.add(ji("s")), v.appendChild(this.sliderView_.element), this.element.appendChild(v);
  14107. const x = a.createElement("div");
  14108. x.classList.add(ji("t")), x.appendChild(this.textView_.element), this.element.appendChild(x);
  14109. }
  14110. }
  14111. const st2 = y("rsl");
  14112. class An {
  14113. constructor(a, u) {
  14114. this.onSliderPropsChange_ = this.onSliderPropsChange_.bind(this), this.onValueChange_ = this.onValueChange_.bind(this), this.sliderProps_ = u.sliderProps, this.sliderProps_.emitter.on("change", this.onSliderPropsChange_), this.element = a.createElement("div"), this.element.classList.add(st2()), u.viewProps.bindClassModifiers(this.element), this.value_ = u.value, this.value_.emitter.on("change", this.onValueChange_);
  14115. const v = a.createElement("div");
  14116. v.classList.add(st2("t")), this.element.appendChild(v), this.trackElement = v;
  14117. const x = a.createElement("div");
  14118. x.classList.add(st2("b")), v.appendChild(x), this.barElement = x;
  14119. const T = ["min", "max"].map((V2) => {
  14120. const z = a.createElement("div");
  14121. return z.classList.add(st2("k"), st2("k", V2)), v.appendChild(z), z;
  14122. });
  14123. this.knobElements = [T[0], T[1]], this.update_();
  14124. }
  14125. valueToX_(a) {
  14126. const u = this.sliderProps_.get("minValue"), v = this.sliderProps_.get("maxValue");
  14127. return Xt(Le(a, u, v, 0, 1), 0, 1) * 100;
  14128. }
  14129. update_() {
  14130. const a = this.value_.rawValue;
  14131. a.length === 0 ? this.element.classList.add(st2(void 0, "zero")) : this.element.classList.remove(st2(void 0, "zero"));
  14132. const u = [this.valueToX_(a.min), this.valueToX_(a.max)];
  14133. this.barElement.style.left = `${u[0]}%`, this.barElement.style.right = `${100 - u[1]}%`, this.knobElements.forEach((v, x) => {
  14134. v.style.left = `${u[x]}%`;
  14135. });
  14136. }
  14137. onSliderPropsChange_() {
  14138. this.update_();
  14139. }
  14140. onValueChange_() {
  14141. this.update_();
  14142. }
  14143. }
  14144. class zi {
  14145. constructor(a, u) {
  14146. this.grabbing_ = null, this.grabOffset_ = 0, this.onPointerDown_ = this.onPointerDown_.bind(this), this.onPointerMove_ = this.onPointerMove_.bind(this), this.onPointerUp_ = this.onPointerUp_.bind(this), this.sliderProps = u.sliderProps, this.viewProps = u.viewProps, this.value = u.value, this.view = new An(a, {
  14147. sliderProps: this.sliderProps,
  14148. value: this.value,
  14149. viewProps: u.viewProps
  14150. });
  14151. const v = new Wn(this.view.trackElement);
  14152. v.emitter.on("down", this.onPointerDown_), v.emitter.on("move", this.onPointerMove_), v.emitter.on("up", this.onPointerUp_);
  14153. }
  14154. ofs_() {
  14155. return this.grabbing_ === "min" ? this.view.knobElements[0].getBoundingClientRect().width / 2 : this.grabbing_ === "max" ? -this.view.knobElements[1].getBoundingClientRect().width / 2 : 0;
  14156. }
  14157. valueFromData_(a) {
  14158. if (!a.point)
  14159. return null;
  14160. const u = (a.point.x + this.ofs_()) / a.bounds.width, v = this.sliderProps.get("minValue"), x = this.sliderProps.get("maxValue");
  14161. return Le(u, 0, 1, v, x);
  14162. }
  14163. onPointerDown_(a) {
  14164. if (!a.data.point)
  14165. return;
  14166. const u = a.data.point.x / a.data.bounds.width, v = this.value.rawValue, x = this.sliderProps.get("minValue"), T = this.sliderProps.get("maxValue"), V2 = Le(v.min, x, T, 0, 1), z = Le(v.max, x, T, 0, 1);
  14167. Math.abs(z - u) <= 0.025 ? this.grabbing_ = "max" : Math.abs(V2 - u) <= 0.025 ? this.grabbing_ = "min" : u >= V2 && u <= z ? (this.grabbing_ = "length", this.grabOffset_ = Le(u - V2, 0, 1, 0, T - x)) : u < V2 ? (this.grabbing_ = "min", this.onPointerMove_(a)) : u > z && (this.grabbing_ = "max", this.onPointerMove_(a));
  14168. }
  14169. applyPointToValue_(a, u) {
  14170. const v = this.valueFromData_(a);
  14171. if (v === null)
  14172. return;
  14173. const x = this.sliderProps.get("minValue"), T = this.sliderProps.get("maxValue");
  14174. if (this.grabbing_ === "min")
  14175. this.value.setRawValue(new qe(v, this.value.rawValue.max), u);
  14176. else if (this.grabbing_ === "max")
  14177. this.value.setRawValue(new qe(this.value.rawValue.min, v), u);
  14178. else if (this.grabbing_ === "length") {
  14179. const V2 = this.value.rawValue.length;
  14180. let z = v - this.grabOffset_, re = z + V2;
  14181. z < x ? (z = x, re = x + V2) : re > T && (z = T - V2, re = T), this.value.setRawValue(new qe(z, re), u);
  14182. }
  14183. }
  14184. onPointerMove_(a) {
  14185. this.applyPointToValue_(a.data, {
  14186. forceEmit: false,
  14187. last: false
  14188. });
  14189. }
  14190. onPointerUp_(a) {
  14191. this.applyPointToValue_(a.data, {
  14192. forceEmit: true,
  14193. last: true
  14194. }), this.grabbing_ = null;
  14195. }
  14196. }
  14197. class wt2 {
  14198. constructor(a, u) {
  14199. this.value = u.value, this.viewProps = u.viewProps, this.sc_ = new zi(a, u);
  14200. const v = {
  14201. baseStep: u.baseStep,
  14202. constraint: u.constraint,
  14203. textProps: K2.fromObject({
  14204. draggingScale: u.draggingScale,
  14205. formatter: u.formatter
  14206. })
  14207. };
  14208. this.tc_ = new Rt2(a, {
  14209. assembly: Fi,
  14210. axes: [v, v],
  14211. parser: u.parser,
  14212. value: this.value,
  14213. viewProps: u.viewProps
  14214. }), this.view = new ii(a, {
  14215. sliderView: this.sc_.view,
  14216. textView: this.tc_.view
  14217. });
  14218. }
  14219. get textController() {
  14220. return this.tc_;
  14221. }
  14222. }
  14223. function Ls(d) {
  14224. return qe.isObject(d) ? new qe(d.min, d.max) : new qe(0, 0);
  14225. }
  14226. function Ui(d, a) {
  14227. d.writeProperty("max", a.max), d.writeProperty("min", a.min);
  14228. }
  14229. function Sr(d) {
  14230. const a = [], u = En(d);
  14231. u && a.push(u);
  14232. const v = _r(d);
  14233. return v && a.push(v), new kn(new Yn(a));
  14234. }
  14235. const si = {
  14236. id: "input-interval",
  14237. type: "input",
  14238. css: '.tp-cbzgv,.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-radv_b,.tp-rslv_k,.tp-cbzv_b{background-color:var(--btn-bg);border-radius:var(--elm-br);color:var(--btn-fg);cursor:pointer;display:block;font-weight:bold;height:var(--bld-us);line-height:var(--bld-us);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tp-radv_b:hover,.tp-rslv_k:hover,.tp-cbzv_b:hover{background-color:var(--btn-bg-h)}.tp-radv_b:focus,.tp-rslv_k:focus,.tp-cbzv_b:focus{background-color:var(--btn-bg-f)}.tp-radv_b:active,.tp-rslv_k:active,.tp-cbzv_b:active{background-color:var(--btn-bg-a)}.tp-radv_b:disabled,.tp-rslv_k:disabled,.tp-cbzv_b:disabled{opacity:.5}.tp-cbzgv{background-color:var(--in-bg);border-radius:var(--elm-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--bld-us);line-height:var(--bld-us);min-width:0;width:100%}.tp-cbzgv:hover{background-color:var(--in-bg-h)}.tp-cbzgv:focus{background-color:var(--in-bg-f)}.tp-cbzgv:active{background-color:var(--in-bg-a)}.tp-cbzgv:disabled{opacity:.5}.tp-btngridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-btngridv.tp-v-disabled{opacity:.5}.tp-btngridv .tp-btnv_b:disabled{opacity:1}.tp-btngridv .tp-btnv_b:disabled .tp-btnv_t{opacity:.5}.tp-btngridv .tp-btnv_b{border-radius:0}.tp-cbzv{position:relative}.tp-cbzv_h{display:flex}.tp-cbzv_b{margin-right:4px;position:relative;width:var(--bld-us)}.tp-cbzv_b svg{display:block;height:16px;left:50%;margin-left:-8px;margin-top:-8px;position:absolute;top:50%;width:16px}.tp-cbzv_b svg path{stroke:var(--bs-bg);stroke-width:2}.tp-cbzv_t{flex:1}.tp-cbzv_p{height:0;margin-top:0;opacity:0;overflow:hidden;transition:height .2s ease-in-out,opacity .2s linear,margin .2s ease-in-out}.tp-cbzv.tp-cbzv-expanded .tp-cbzv_p{margin-top:var(--bld-s);opacity:1}.tp-cbzv.tp-cbzv-cpl .tp-cbzv_p{overflow:visible}.tp-cbzv .tp-popv{left:calc(-1*var(--cnt-h-p));position:absolute;right:calc(-1*var(--cnt-h-p));top:var(--bld-us)}.tp-cbzpv_t{margin-top:var(--bld-s)}.tp-cbzgv{height:auto;overflow:hidden;position:relative}.tp-cbzgv.tp-v-disabled{opacity:.5}.tp-cbzgv_p{left:16px;position:absolute;right:16px;top:0}.tp-cbzgv_g{cursor:pointer;display:block;height:calc(var(--bld-us)*5);width:100%}.tp-cbzgv_u{opacity:.1;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_l{fill:rgba(0,0,0,0);stroke:var(--in-fg)}.tp-cbzgv_v{opacity:.5;stroke:var(--in-fg);stroke-dasharray:1}.tp-cbzgv_h{border:var(--in-fg) solid 1px;border-radius:50%;box-sizing:border-box;height:4px;margin-left:-2px;margin-top:-2px;pointer-events:none;position:absolute;width:4px}.tp-cbzgv:focus .tp-cbzgv_h-sel{background-color:var(--in-fg);border-width:0}.tp-cbzprvv{cursor:pointer;height:4px;padding:4px 0;position:relative}.tp-cbzprvv_g{display:block;height:100%;overflow:visible;width:100%}.tp-cbzprvv_t{opacity:.5;stroke:var(--mo-fg)}.tp-cbzprvv_m{background-color:var(--mo-fg);border-radius:50%;height:4px;margin-left:-2px;margin-top:-2px;opacity:0;position:absolute;top:50%;transition:opacity .2s ease-out;width:4px}.tp-cbzprvv_m.tp-cbzprvv_m-a{opacity:1}.tp-fpsv{position:relative}.tp-fpsv_l{bottom:4px;color:var(--mo-fg);line-height:1;right:4px;pointer-events:none;position:absolute}.tp-fpsv_u{margin-left:.2em;opacity:.7}.tp-rslv{cursor:pointer;padding-left:8px;padding-right:8px}.tp-rslv.tp-v-disabled{opacity:.5}.tp-rslv_t{height:calc(var(--bld-us));position:relative}.tp-rslv_t::before{background-color:var(--in-bg);border-radius:1px;content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:-4px;right:-4px}.tp-rslv_b{bottom:0;top:0;position:absolute}.tp-rslv_b::before{background-color:var(--in-fg);content:"";height:2px;margin-top:-1px;position:absolute;top:50%;left:0;right:0}.tp-rslv_k{height:calc(var(--bld-us) - 8px);margin-top:calc((var(--bld-us) - 8px)/-2);position:absolute;top:50%;width:8px}.tp-rslv_k.tp-rslv_k-min{margin-left:-8px}.tp-rslv_k.tp-rslv_k-max{margin-left:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-min{border-bottom-right-radius:0;border-top-right-radius:0}.tp-rslv.tp-rslv-zero .tp-rslv_k.tp-rslv_k-max{border-bottom-left-radius:0;border-top-left-radius:0}.tp-rsltxtv{display:flex}.tp-rsltxtv_s{flex:1}.tp-rsltxtv_t{flex:1;margin-left:4px}.tp-radv_l{display:block;position:relative}.tp-radv_i{left:0;opacity:0;position:absolute;top:0}.tp-radv_b{opacity:.5}.tp-radv_i:hover+.tp-radv_b{background-color:var(--btn-bg-h)}.tp-radv_i:focus+.tp-radv_b{background-color:var(--btn-bg-f)}.tp-radv_i:active+.tp-radv_b{background-color:var(--btn-bg-a)}.tp-radv_i:checked+.tp-radv_b{opacity:1}.tp-radv_t{bottom:0;color:inherit;left:0;overflow:hidden;position:absolute;right:0;text-align:center;text-overflow:ellipsis;top:0}.tp-radv_i:disabled+.tp-radv_b>.tp-radv_t{opacity:.5}.tp-radgridv{border-radius:var(--elm-br);display:grid;overflow:hidden;gap:2px}.tp-radgridv.tp-v-disabled{opacity:.5}.tp-radgridv .tp-radv_b{border-radius:0}',
  14239. accept: (d, a) => {
  14240. if (!qe.isObject(d))
  14241. return null;
  14242. const u = he, v = ee(a, {
  14243. format: u.optional.function,
  14244. max: u.optional.number,
  14245. min: u.optional.number,
  14246. step: u.optional.number
  14247. });
  14248. return v ? {
  14249. initialValue: new qe(d.min, d.max),
  14250. params: v
  14251. } : null;
  14252. },
  14253. binding: {
  14254. reader: (d) => Ls,
  14255. constraint: (d) => Sr(d.params),
  14256. equals: qe.equals,
  14257. writer: (d) => Ui
  14258. },
  14259. controller(d) {
  14260. var a;
  14261. const u = d.value, v = d.constraint;
  14262. if (!(v instanceof kn))
  14263. throw g.shouldNeverHappen();
  14264. const x = (u.rawValue.min + u.rawValue.max) / 2, T = (a = d.params.format) !== null && a !== void 0 ? a : Ie(yn(v.edge, x)), V2 = v.edge && Ct(v.edge, gt2);
  14265. if (V2)
  14266. return new wt2(d.document, {
  14267. baseStep: Ai(v.edge),
  14268. constraint: v.edge,
  14269. draggingScale: Jn(v.edge, x),
  14270. formatter: T,
  14271. parser: gn,
  14272. sliderProps: new K2({
  14273. maxValue: V2.values.value("max"),
  14274. minValue: V2.values.value("min")
  14275. }),
  14276. value: u,
  14277. viewProps: d.viewProps
  14278. });
  14279. const z = {
  14280. baseStep: Ai(v.edge),
  14281. constraint: v.edge,
  14282. textProps: K2.fromObject({
  14283. draggingScale: x,
  14284. formatter: T
  14285. })
  14286. };
  14287. return new Rt2(d.document, {
  14288. assembly: Fi,
  14289. axes: [z, z],
  14290. parser: gn,
  14291. value: u,
  14292. viewProps: d.viewProps
  14293. });
  14294. }
  14295. };
  14296. class Dt {
  14297. constructor(a) {
  14298. this.controller_ = a;
  14299. }
  14300. get disabled() {
  14301. return this.controller_.viewProps.get("disabled");
  14302. }
  14303. set disabled(a) {
  14304. this.controller_.viewProps.set("disabled", a);
  14305. }
  14306. get title() {
  14307. var a;
  14308. return (a = this.controller_.props.get("title")) !== null && a !== void 0 ? a : "";
  14309. }
  14310. set title(a) {
  14311. this.controller_.props.set("title", a);
  14312. }
  14313. }
  14314. class Ot extends c {
  14315. constructor(a, u, v, x, T) {
  14316. super(a, x, T), this.cell = u, this.index = v;
  14317. }
  14318. }
  14319. class Mn extends r {
  14320. constructor(a) {
  14321. super(a), this.cellToApiMap_ = /* @__PURE__ */ new Map(), this.controller_.valueController.cellControllers.forEach((v) => {
  14322. const x = new Dt(v);
  14323. this.cellToApiMap_.set(v, x);
  14324. });
  14325. }
  14326. get value() {
  14327. return this.controller_.value;
  14328. }
  14329. cell(a, u) {
  14330. const v = this.controller_.valueController, x = v.cellControllers[u * v.size[0] + a];
  14331. return this.cellToApiMap_.get(x);
  14332. }
  14333. on(a, u) {
  14334. const v = u.bind(this);
  14335. this.controller_.value.emitter.on(a, (x) => {
  14336. const T = this.controller_.valueController, V2 = T.findCellByValue(x.rawValue);
  14337. if (!V2)
  14338. return;
  14339. const z = this.cellToApiMap_.get(V2);
  14340. if (!z)
  14341. return;
  14342. const re = T.cellControllers.indexOf(V2);
  14343. v(new Ot(this, z, [re % T.size[0], Math.floor(re / T.size[0])], x.rawValue, void 0));
  14344. });
  14345. }
  14346. }
  14347. const Sn = y("rad");
  14348. class Rs {
  14349. constructor(a, u) {
  14350. this.element = a.createElement("div"), this.element.classList.add(Sn()), u.viewProps.bindClassModifiers(this.element);
  14351. const v = a.createElement("label");
  14352. v.classList.add(Sn("l")), this.element.appendChild(v);
  14353. const x = a.createElement("input");
  14354. x.classList.add(Sn("i")), x.name = u.name, x.type = "radio", u.viewProps.bindDisabled(x), v.appendChild(x), this.inputElement = x;
  14355. const T = a.createElement("div");
  14356. T.classList.add(Sn("b")), v.appendChild(T);
  14357. const V2 = a.createElement("div");
  14358. V2.classList.add(Sn("t")), T.appendChild(V2), R(u.props, "title", (z) => {
  14359. V2.textContent = z;
  14360. });
  14361. }
  14362. }
  14363. class Vs {
  14364. constructor(a, u) {
  14365. this.props = u.props, this.viewProps = u.viewProps, this.view = new Rs(a, {
  14366. name: u.name,
  14367. props: this.props,
  14368. viewProps: this.viewProps
  14369. });
  14370. }
  14371. }
  14372. class ri {
  14373. constructor(a, u) {
  14374. this.cellCs_ = [], this.cellValues_ = [], this.onCellInputChange_ = this.onCellInputChange_.bind(this), this.size = u.size;
  14375. const [v, x] = this.size;
  14376. for (let T = 0; T < x; T++)
  14377. for (let V2 = 0; V2 < v; V2++) {
  14378. const z = new Vs(a, {
  14379. name: u.groupName,
  14380. props: K2.fromObject(Object.assign({}, u.cellConfig(V2, T))),
  14381. viewProps: ge.create()
  14382. });
  14383. this.cellCs_.push(z), this.cellValues_.push(u.cellConfig(V2, T).value);
  14384. }
  14385. this.value = u.value, S(this.value, (T) => {
  14386. const V2 = this.findCellByValue(T);
  14387. V2 && (V2.view.inputElement.checked = true);
  14388. }), this.viewProps = ge.create(), this.view = new Et2(a, {
  14389. viewProps: this.viewProps,
  14390. viewName: "radgrid"
  14391. }), this.view.element.style.gridTemplateColumns = `repeat(${v}, 1fr)`, this.cellCs_.forEach((T) => {
  14392. T.view.inputElement.addEventListener("change", this.onCellInputChange_), this.view.element.appendChild(T.view.element);
  14393. });
  14394. }
  14395. get cellControllers() {
  14396. return this.cellCs_;
  14397. }
  14398. findCellByValue(a) {
  14399. const u = this.cellValues_.findIndex((v) => v === a);
  14400. return u < 0 ? null : this.cellCs_[u];
  14401. }
  14402. onCellInputChange_(a) {
  14403. const u = a.currentTarget, v = this.cellCs_.findIndex((x) => x.view.inputElement === u);
  14404. v < 0 || (this.value.rawValue = this.cellValues_[v]);
  14405. }
  14406. }
  14407. const Nt = function() {
  14408. return {
  14409. id: "radiogrid",
  14410. type: "blade",
  14411. accept(d) {
  14412. const a = he, u = ee(d, {
  14413. cells: a.required.function,
  14414. groupName: a.required.string,
  14415. size: a.required.array(a.required.number),
  14416. value: a.required.raw,
  14417. view: a.required.constant("radiogrid"),
  14418. label: a.optional.string
  14419. });
  14420. return u ? { params: u } : null;
  14421. },
  14422. controller(d) {
  14423. return new Mt(d.document, {
  14424. blade: d.blade,
  14425. props: K2.fromObject({
  14426. label: d.params.label
  14427. }),
  14428. valueController: new ri(d.document, {
  14429. groupName: d.params.groupName,
  14430. cellConfig: d.params.cells,
  14431. size: d.params.size,
  14432. value: H2(d.params.value)
  14433. })
  14434. });
  14435. },
  14436. api(d) {
  14437. return !(d.controller instanceof Mt) || !(d.controller.valueController instanceof ri) ? null : new Mn(d.controller);
  14438. }
  14439. };
  14440. }();
  14441. function Gi(d) {
  14442. return {
  14443. id: "input-radiogrid",
  14444. type: "input",
  14445. accept(a, u) {
  14446. if (!d.isType(a))
  14447. return null;
  14448. const v = he, x = ee(u, {
  14449. cells: v.required.function,
  14450. groupName: v.required.string,
  14451. size: v.required.array(v.required.number),
  14452. view: v.required.constant("radiogrid")
  14453. });
  14454. return x ? {
  14455. initialValue: a,
  14456. params: x
  14457. } : null;
  14458. },
  14459. binding: d.binding,
  14460. controller: (a) => new ri(a.document, {
  14461. cellConfig: a.params.cells,
  14462. groupName: a.params.groupName,
  14463. size: a.params.size,
  14464. value: a.value
  14465. })
  14466. };
  14467. }
  14468. const Lr = Gi({
  14469. isType: (d) => typeof d == "number",
  14470. binding: {
  14471. reader: (d) => ar,
  14472. writer: (d) => it2
  14473. }
  14474. }), Rr = Gi({
  14475. isType: (d) => typeof d == "string",
  14476. binding: {
  14477. reader: (d) => ps,
  14478. writer: (d) => it2
  14479. }
  14480. }), Vr = Gi({
  14481. isType: (d) => typeof d == "boolean",
  14482. binding: {
  14483. reader: (d) => fn,
  14484. writer: (d) => it2
  14485. }
  14486. }), Is = [
  14487. Er,
  14488. It,
  14489. Bi,
  14490. si,
  14491. Nt,
  14492. Vr,
  14493. Lr,
  14494. Rr
  14495. ];
  14496. s.ButtonCellApi = Cs, s.ButtonGridApi = Ps, s.ButtonGridController = Si, s.CubicBezier = Pt, s.CubicBezierApi = Ts, s.CubicBezierAssembly = Ri, s.CubicBezierController = ni, s.CubicBezierGraphController = ut2, s.CubicBezierGraphView = De, s.CubicBezierPickerController = Ss, s.CubicBezierPickerView = As, s.CubicBezierPreviewView = Qt, s.CubicBezierView = ks, s.FpsGraphBladeApi = we, s.FpsGraphController = Ni, s.FpsView = Ye, s.Fpswatch = Re2, s.Interval = qe, s.IntervalAssembly = Fi, s.IntervalConstraint = kn, s.RadioCellApi = Dt, s.RadioController = Vs, s.RadioGridApi = Mn, s.RadioGridController = ri, s.RadioView = Rs, s.RangeSliderController = zi, s.RangeSliderTextController = wt2, s.RangeSliderTextView = ii, s.RangeSliderView = An, s.TpRadioGridChangeEvent = Ot, s.plugins = Is, Object.defineProperty(s, "__esModule", { value: true });
  14497. });
  14498. })(yo, yo.exports);
  14499. var al = yo.exports;
  14500. var Md = xh(al);
  14501. var Sd = Zu({
  14502. __proto__: null,
  14503. default: Md
  14504. }, [al]);
  14505. var On;
  14506. var Us;
  14507. var lm = (f = "tres-container") => {
  14508. On || (On = new Ad.Pane({
  14509. container: document.querySelector(f) || void 0
  14510. }), On.registerPlugin(Sd), Us = On.addBlade({
  14511. view: "fpsgraph",
  14512. label: "fpsgraph"
  14513. }));
  14514. function i() {
  14515. On && On.dispose();
  14516. }
  14517. return onMounted(() => {
  14518. const { onBeforeLoop: s, onAfterLoop: r, resume: o } = Pe();
  14519. o(), s(() => Us.begin()), r(() => Us.end());
  14520. }), onUnmounted(() => {
  14521. i();
  14522. }), { pane: On, fpsGraph: Us, disposeTweakPane: i };
  14523. };
  14524. export {
  14525. qd as Box,
  14526. Qd as Circle,
  14527. Zd as Cone,
  14528. Wd as Dodecahedron,
  14529. Nd as Environment,
  14530. Gd as FBXModel,
  14531. Ud as GLTFModel,
  14532. Jd as Icosahedron,
  14533. zd as Levioso,
  14534. Xd as MapControls,
  14535. Yd as MeshWobbleMaterial,
  14536. em as Octahedron,
  14537. Hd as OrbitControls,
  14538. Bd as PamCameraMouse,
  14539. tm as Plane,
  14540. $d as PointerLockControls,
  14541. nm as Ring,
  14542. jd as Smoke,
  14543. im as Sphere,
  14544. Fd as Stars,
  14545. sm as Tetrahedron,
  14546. Dd as Text3D,
  14547. rm as Torus,
  14548. om as TorusKnot,
  14549. Kd as TransformControls,
  14550. am as Tube,
  14551. Od as useAnimations,
  14552. kh as useEnvironment,
  14553. $h as useFBX,
  14554. Kh as useGLTF,
  14555. Bh as usePamCameraMouse,
  14556. lm as useTweakPane
  14557. };
  14558. /*! Bundled license information:
  14559. @tresjs/cientos/dist/trescientos.js:
  14560. (*! Tweakpane 3.1.9 (c) 2016 cocopon, licensed under the MIT license. *)
  14561. */
  14562. //# sourceMappingURL=@tresjs_cientos.js.map